@types/select2

  • Version 4.0.63
  • Published
  • 12.4 kB
  • 1 dependency
  • MIT license

Install

npm i @types/select2
yarn add @types/select2
pnpm add @types/select2

Overview

TypeScript definitions for select2

Index

Interfaces

interface AjaxOptions

interface AjaxOptions<Result = DataFormat | GroupedDataFormat, RemoteResult = any>
extends JQueryAjaxSettingsBase {}

    property data

    data?: ((params: QueryOptions) => PlainObject | string) | undefined;

      property delay

      delay?: number | undefined;

        property processResults

        processResults?:
        | ((data: RemoteResult, params: QueryOptions) => ProcessedResult<Result>)
        | undefined;

          property transport

          transport?:
          | ((
          settings: JQueryAjaxSettings,
          success: (data: RemoteResult) => undefined,
          failure: () => undefined
          ) => void)
          | undefined;

            property url

            url?: string | ((params: QueryOptions) => string) | undefined;

              interface DataFormat

              interface DataFormat {}

                property disabled

                disabled?: boolean | undefined;

                  property id

                  id: number | string;

                    property selected

                    selected?: boolean | undefined;

                      property text

                      text: string;

                        interface DataParams

                        interface DataParams {}

                          property data

                          data: OptionData;

                            property originalEvent

                            originalEvent: BaseJQueryEventObject;

                              interface Event

                              interface Event<TElement, T> extends BaseJQueryEventObject {}

                                property params

                                params: T;

                                  interface GroupedDataFormat

                                  interface GroupedDataFormat {}

                                    property children

                                    children?: DataFormat[] | undefined;

                                      property id

                                      id?: undefined;

                                        property text

                                        text: string;

                                          interface IdTextPair

                                          interface IdTextPair {}

                                            property element

                                            element?: undefined;

                                              property id

                                              id: string;

                                                property loading

                                                loading?: undefined;

                                                  property text

                                                  text: string;

                                                    interface IngParams

                                                    interface IngParams {}

                                                      property name

                                                      name: 'select' | 'open' | 'close' | 'unselect';

                                                        property prevented

                                                        prevented: boolean;

                                                          interface LoadingData

                                                          interface LoadingData {}

                                                            property element

                                                            element?: undefined;

                                                              property id

                                                              id?: undefined;

                                                                property loading

                                                                loading: boolean;

                                                                  property text

                                                                  text: string;

                                                                    interface OptGroupData

                                                                    interface OptGroupData {}

                                                                      property children

                                                                      children: OptionData[];

                                                                        property disabled

                                                                        disabled: boolean;

                                                                          property element

                                                                          element: HTMLOptGroupElement;

                                                                            property loading

                                                                            loading?: undefined;

                                                                              property selected

                                                                              selected: boolean;

                                                                                property text

                                                                                text: string;

                                                                                  property title

                                                                                  title: string;

                                                                                    interface OptionData

                                                                                    interface OptionData {}

                                                                                      property children

                                                                                      children?: undefined;

                                                                                        property disabled

                                                                                        disabled: boolean;

                                                                                          property element

                                                                                          element: HTMLOptionElement;

                                                                                            property id

                                                                                            id: string;

                                                                                              property loading

                                                                                              loading?: undefined;

                                                                                                property selected

                                                                                                selected: boolean;

                                                                                                  property text

                                                                                                  text: string;

                                                                                                    property title

                                                                                                    title: string;

                                                                                                      interface Options

                                                                                                      interface Options<Result = DataFormat | GroupedDataFormat, RemoteResult = any> {}

                                                                                                        property ajax

                                                                                                        ajax?: AjaxOptions<Result, RemoteResult> | undefined;

                                                                                                          property allowClear

                                                                                                          allowClear?: boolean | undefined;

                                                                                                            property amdBase

                                                                                                            amdBase?: string | undefined;

                                                                                                              property amdLanguageBase

                                                                                                              amdLanguageBase?: string | undefined;

                                                                                                                property closeOnSelect

                                                                                                                closeOnSelect?: boolean | undefined;

                                                                                                                  property containerCss

                                                                                                                  containerCss?: any;

                                                                                                                    property containerCssClass

                                                                                                                    containerCssClass?: string | undefined;

                                                                                                                      property createTag

                                                                                                                      createTag?:
                                                                                                                      | ((params: SearchOptions) => (IdTextPair & Record<string, any>) | null)
                                                                                                                      | undefined;

                                                                                                                        property data

                                                                                                                        data?: DataFormat[] | GroupedDataFormat[] | undefined;

                                                                                                                          property dataAdapter

                                                                                                                          dataAdapter?: any;

                                                                                                                            property debug

                                                                                                                            debug?: boolean | undefined;

                                                                                                                              property dir

                                                                                                                              dir?: 'ltr' | 'rtl' | undefined;

                                                                                                                                property disabled

                                                                                                                                disabled?: boolean | undefined;

                                                                                                                                  property dropdownAdapter

                                                                                                                                  dropdownAdapter?: any;

                                                                                                                                    property dropdownAutoWidth

                                                                                                                                    dropdownAutoWidth?: boolean | undefined;

                                                                                                                                      property dropdownCss

                                                                                                                                      dropdownCss?: any;

                                                                                                                                        property dropdownCssClass

                                                                                                                                        dropdownCssClass?: string | undefined;

                                                                                                                                          property dropdownParent

                                                                                                                                          dropdownParent?: HTMLElement | JQuery | string | undefined;

                                                                                                                                            property escapeMarkup

                                                                                                                                            escapeMarkup?: ((markup: string) => string) | undefined;

                                                                                                                                              property initSelection

                                                                                                                                              initSelection?:
                                                                                                                                              | ((element: JQuery, callback: (data: any) => void) => void)
                                                                                                                                              | undefined;

                                                                                                                                                property insertTag

                                                                                                                                                insertTag?:
                                                                                                                                                | ((data: Array<OptionData | IdTextPair>, tag: IdTextPair) => void)
                                                                                                                                                | undefined;

                                                                                                                                                  property language

                                                                                                                                                  language?: string | Translation | undefined;

                                                                                                                                                    property matcher

                                                                                                                                                    matcher?:
                                                                                                                                                    | ((
                                                                                                                                                    params: SearchOptions,
                                                                                                                                                    data: OptGroupData | OptionData
                                                                                                                                                    ) => OptGroupData | OptionData | null)
                                                                                                                                                    | undefined;

                                                                                                                                                      property maximumInputLength

                                                                                                                                                      maximumInputLength?: number | undefined;

                                                                                                                                                        property maximumSelectionLength

                                                                                                                                                        maximumSelectionLength?: number | undefined;

                                                                                                                                                          property minimumInputLength

                                                                                                                                                          minimumInputLength?: number | undefined;

                                                                                                                                                            property minimumResultsForSearch

                                                                                                                                                            minimumResultsForSearch?: number | undefined;

                                                                                                                                                              property multiple

                                                                                                                                                              multiple?: boolean | undefined;

                                                                                                                                                                property placeholder

                                                                                                                                                                placeholder?: string | IdTextPair | undefined;

                                                                                                                                                                  property resultsAdapter

                                                                                                                                                                  resultsAdapter?: any;

                                                                                                                                                                    property selectionAdapter

                                                                                                                                                                    selectionAdapter?: any;

                                                                                                                                                                      property selectOnClose

                                                                                                                                                                      selectOnClose?: boolean | undefined;

                                                                                                                                                                        property sorter

                                                                                                                                                                        sorter?:
                                                                                                                                                                        | ((
                                                                                                                                                                        data: Array<OptGroupData | OptionData | IdTextPair>
                                                                                                                                                                        ) => Array<OptGroupData | OptionData | IdTextPair>)
                                                                                                                                                                        | undefined;

                                                                                                                                                                          property tags

                                                                                                                                                                          tags?: boolean | undefined;

                                                                                                                                                                            property templateResult

                                                                                                                                                                            templateResult?:
                                                                                                                                                                            | ((result: LoadingData | Result) => string | JQuery | null)
                                                                                                                                                                            | undefined;

                                                                                                                                                                              property templateSelection

                                                                                                                                                                              templateSelection?:
                                                                                                                                                                              | ((
                                                                                                                                                                              selection: IdTextPair | LoadingData | Result,
                                                                                                                                                                              container: JQuery
                                                                                                                                                                              ) => string | JQuery)
                                                                                                                                                                              | undefined;

                                                                                                                                                                                property theme

                                                                                                                                                                                theme?: string | undefined;

                                                                                                                                                                                  property tokenizer

                                                                                                                                                                                  tokenizer?:
                                                                                                                                                                                  | ((
                                                                                                                                                                                  input: string,
                                                                                                                                                                                  selection: any[],
                                                                                                                                                                                  selectCallback: () => void,
                                                                                                                                                                                  options: Options
                                                                                                                                                                                  ) => string)
                                                                                                                                                                                  | undefined;

                                                                                                                                                                                    property tokenSeparators

                                                                                                                                                                                    tokenSeparators?: string[] | undefined;

                                                                                                                                                                                      property width

                                                                                                                                                                                      width?: string | undefined;

                                                                                                                                                                                        interface PlainObject

                                                                                                                                                                                        interface PlainObject<T = any> {}
                                                                                                                                                                                        • Same as jQuery v3 JQuery.PlainObject.

                                                                                                                                                                                        index signature

                                                                                                                                                                                        [key: string]: T;

                                                                                                                                                                                          interface ProcessedResult

                                                                                                                                                                                          interface ProcessedResult<Result = DataFormat | GroupedDataFormat> {}

                                                                                                                                                                                            property pagination

                                                                                                                                                                                            pagination?: { more: boolean } | undefined;

                                                                                                                                                                                              property results

                                                                                                                                                                                              results: Result[];

                                                                                                                                                                                                interface QueryOptions

                                                                                                                                                                                                interface QueryOptions {}

                                                                                                                                                                                                  property page

                                                                                                                                                                                                  page?: number | undefined;

                                                                                                                                                                                                    property term

                                                                                                                                                                                                    term?: string | undefined;

                                                                                                                                                                                                      interface SearchOptions

                                                                                                                                                                                                      interface SearchOptions {}

                                                                                                                                                                                                        property term

                                                                                                                                                                                                        term: string;

                                                                                                                                                                                                          interface Select2

                                                                                                                                                                                                          interface Select2 {}

                                                                                                                                                                                                            property $container

                                                                                                                                                                                                            $container: JQuery;

                                                                                                                                                                                                              property $dropdown

                                                                                                                                                                                                              $dropdown: JQuery;

                                                                                                                                                                                                                property $results

                                                                                                                                                                                                                $results: JQuery;

                                                                                                                                                                                                                  property $selection

                                                                                                                                                                                                                  $selection: JQuery;

                                                                                                                                                                                                                    property dropdown

                                                                                                                                                                                                                    dropdown: any;

                                                                                                                                                                                                                      property id

                                                                                                                                                                                                                      id: string;

                                                                                                                                                                                                                        property options

                                                                                                                                                                                                                        options: { options: Options };

                                                                                                                                                                                                                          property results

                                                                                                                                                                                                                          results: any;

                                                                                                                                                                                                                            property selection

                                                                                                                                                                                                                            selection: any;

                                                                                                                                                                                                                              interface Select2Plugin

                                                                                                                                                                                                                              interface Select2Plugin<TElement = HTMLElement> {}

                                                                                                                                                                                                                                property amd

                                                                                                                                                                                                                                amd: { require: Select2Require };

                                                                                                                                                                                                                                  property defaults

                                                                                                                                                                                                                                  defaults: {
                                                                                                                                                                                                                                  set: (key: string, value: any) => void;
                                                                                                                                                                                                                                  reset: () => void;
                                                                                                                                                                                                                                  };

                                                                                                                                                                                                                                    call signature

                                                                                                                                                                                                                                    (): JQuery<TElement>;

                                                                                                                                                                                                                                      call signature

                                                                                                                                                                                                                                      <Result = DataFormat | GroupedDataFormat, RemoteResult = any>(
                                                                                                                                                                                                                                      options: Options<Result, RemoteResult>
                                                                                                                                                                                                                                      ): JQuery<TElement>;

                                                                                                                                                                                                                                        call signature

                                                                                                                                                                                                                                        (method: 'data'): OptionData[];
                                                                                                                                                                                                                                        • Get the data object of the current selection

                                                                                                                                                                                                                                        call signature

                                                                                                                                                                                                                                        (method: 'destroy'): JQuery<TElement>;
                                                                                                                                                                                                                                        • Reverts changes to DOM done by Select2. Any selection done via Select2 will be preserved.

                                                                                                                                                                                                                                        call signature

                                                                                                                                                                                                                                        (method: 'open'): JQuery<TElement>;
                                                                                                                                                                                                                                        • Opens the dropdown

                                                                                                                                                                                                                                        call signature

                                                                                                                                                                                                                                        (method: 'close'): JQuery<TElement>;
                                                                                                                                                                                                                                        • Closes the dropdown

                                                                                                                                                                                                                                        interface Select2Require

                                                                                                                                                                                                                                        interface Select2Require {}

                                                                                                                                                                                                                                          method config

                                                                                                                                                                                                                                          config: (config: Select2RequireConfig) => Select2Require;

                                                                                                                                                                                                                                            call signature

                                                                                                                                                                                                                                            (module: string): any;

                                                                                                                                                                                                                                              call signature

                                                                                                                                                                                                                                              (modules: string[]): void;

                                                                                                                                                                                                                                                call signature

                                                                                                                                                                                                                                                (modules: string[], ready: (...modules: any[]) => void): void;

                                                                                                                                                                                                                                                  call signature

                                                                                                                                                                                                                                                  (
                                                                                                                                                                                                                                                  modules: string[],
                                                                                                                                                                                                                                                  ready: (...modules: any[]) => void,
                                                                                                                                                                                                                                                  errback: (err: any) => void
                                                                                                                                                                                                                                                  ): void;

                                                                                                                                                                                                                                                    interface Select2RequireConfig

                                                                                                                                                                                                                                                    interface Select2RequireConfig {}

                                                                                                                                                                                                                                                      property callback

                                                                                                                                                                                                                                                      callback?: ((...modules: any[]) => void) | undefined;

                                                                                                                                                                                                                                                        property config

                                                                                                                                                                                                                                                        config?: { [id: string]: {} } | undefined;

                                                                                                                                                                                                                                                          property deps

                                                                                                                                                                                                                                                          deps?: string[] | undefined;

                                                                                                                                                                                                                                                            property map

                                                                                                                                                                                                                                                            map?:
                                                                                                                                                                                                                                                            | {
                                                                                                                                                                                                                                                            [id: string]: {
                                                                                                                                                                                                                                                            [id: string]: string;
                                                                                                                                                                                                                                                            };
                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                            | undefined;

                                                                                                                                                                                                                                                              interface Translation

                                                                                                                                                                                                                                                              interface Translation {}

                                                                                                                                                                                                                                                                property errorLoading

                                                                                                                                                                                                                                                                errorLoading?: (() => string) | undefined;

                                                                                                                                                                                                                                                                  property inputTooLong

                                                                                                                                                                                                                                                                  inputTooLong?: ((arg: TranslationArg) => string) | undefined;

                                                                                                                                                                                                                                                                    property inputTooShort

                                                                                                                                                                                                                                                                    inputTooShort?: ((arg: TranslationArg) => string) | undefined;

                                                                                                                                                                                                                                                                      property loadingMore

                                                                                                                                                                                                                                                                      loadingMore?: (() => string) | undefined;

                                                                                                                                                                                                                                                                        property maximumSelected

                                                                                                                                                                                                                                                                        maximumSelected?: ((arg: TranslationArg) => string) | undefined;

                                                                                                                                                                                                                                                                          property noResults

                                                                                                                                                                                                                                                                          noResults?: (() => string) | undefined;

                                                                                                                                                                                                                                                                            property searching

                                                                                                                                                                                                                                                                            searching?: (() => string) | undefined;

                                                                                                                                                                                                                                                                              interface TranslationArg

                                                                                                                                                                                                                                                                              interface TranslationArg {}

                                                                                                                                                                                                                                                                                property input

                                                                                                                                                                                                                                                                                input: string;

                                                                                                                                                                                                                                                                                  property maximum

                                                                                                                                                                                                                                                                                  maximum: number;

                                                                                                                                                                                                                                                                                    property minimum

                                                                                                                                                                                                                                                                                    minimum: number;

                                                                                                                                                                                                                                                                                      interface Trigger

                                                                                                                                                                                                                                                                                      interface Trigger {}

                                                                                                                                                                                                                                                                                        property params

                                                                                                                                                                                                                                                                                        params: {
                                                                                                                                                                                                                                                                                        data: IdTextPair;
                                                                                                                                                                                                                                                                                        };

                                                                                                                                                                                                                                                                                          property type

                                                                                                                                                                                                                                                                                          type: 'select2:select';

                                                                                                                                                                                                                                                                                            Type Aliases

                                                                                                                                                                                                                                                                                            type JQueryAjaxSettingsBase

                                                                                                                                                                                                                                                                                            type JQueryAjaxSettingsBase = Pick<
                                                                                                                                                                                                                                                                                            JQueryAjaxSettings,
                                                                                                                                                                                                                                                                                            Sub<keyof JQueryAjaxSettings, 'url'>
                                                                                                                                                                                                                                                                                            >;
                                                                                                                                                                                                                                                                                            • Same as jQuery v3 JQuery.AjaxSettingsBase.

                                                                                                                                                                                                                                                                                            type JQueryEventHandlerBase

                                                                                                                                                                                                                                                                                            type JQueryEventHandlerBase<TContext, T> = (
                                                                                                                                                                                                                                                                                            this: TContext,
                                                                                                                                                                                                                                                                                            t: T,
                                                                                                                                                                                                                                                                                            ...args: any[]
                                                                                                                                                                                                                                                                                            ) => void | false;
                                                                                                                                                                                                                                                                                            • Same as jQuery v3 JQuery.EventHandlerBase.

                                                                                                                                                                                                                                                                                            type Sub

                                                                                                                                                                                                                                                                                            type Sub<O extends string, D extends string> = {
                                                                                                                                                                                                                                                                                            [K in O]: (Record<D, never> & Record<string, K>)[K];
                                                                                                                                                                                                                                                                                            }[O];

                                                                                                                                                                                                                                                                                              Namespaces

                                                                                                                                                                                                                                                                                              namespace global

                                                                                                                                                                                                                                                                                              namespace global {}

                                                                                                                                                                                                                                                                                                interface JQuery

                                                                                                                                                                                                                                                                                                interface JQuery<TElement = HTMLElement> {}

                                                                                                                                                                                                                                                                                                  property select2

                                                                                                                                                                                                                                                                                                  select2: Select2Plugin<TElement>;

                                                                                                                                                                                                                                                                                                    method data

                                                                                                                                                                                                                                                                                                    data: (key: 'select2') => Select2;

                                                                                                                                                                                                                                                                                                      method on

                                                                                                                                                                                                                                                                                                      on: {
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:closing',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, IngParams>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:close',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, {}>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:opening',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, IngParams>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:open',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, {}>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:selecting',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, IngParams>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:select',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, DataParams>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:unselecting',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, IngParams>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      (
                                                                                                                                                                                                                                                                                                      events: 'select2:unselect',
                                                                                                                                                                                                                                                                                                      handler?: JQueryEventHandlerBase<TElement, Event<TElement, DataParams>>
                                                                                                                                                                                                                                                                                                      ): this;
                                                                                                                                                                                                                                                                                                      };

                                                                                                                                                                                                                                                                                                        method trigger

                                                                                                                                                                                                                                                                                                        trigger: (events: Trigger) => void;

                                                                                                                                                                                                                                                                                                          Package Files (1)

                                                                                                                                                                                                                                                                                                          Dependencies (1)

                                                                                                                                                                                                                                                                                                          Dev Dependencies (0)

                                                                                                                                                                                                                                                                                                          No dev dependencies.

                                                                                                                                                                                                                                                                                                          Peer Dependencies (0)

                                                                                                                                                                                                                                                                                                          No peer dependencies.

                                                                                                                                                                                                                                                                                                          Badge

                                                                                                                                                                                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/select2.

                                                                                                                                                                                                                                                                                                          • Markdown
                                                                                                                                                                                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/select2)
                                                                                                                                                                                                                                                                                                          • HTML
                                                                                                                                                                                                                                                                                                            <a href="https://www.jsdocs.io/package/@types/select2"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>