UNPKG

ng-select2-component

Version:
600 lines (588 loc) 33.1 kB
import * as _angular_core from '@angular/core'; import { ElementRef, OnInit, DoCheck, AfterViewInit, OnDestroy, OnChanges, TemplateRef, SimpleChanges, PipeTransform } from '@angular/core'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { CdkConnectedOverlay, ConnectionPositionPair } from '@angular/cdk/overlay'; import { ViewportRuler } from '@angular/cdk/scrolling'; import { ControlValueAccessor, NgControl } from '@angular/forms'; import { SafeHtml } from '@angular/platform-browser'; declare const timeout = 200; /** * Latin - `[\u0300-\u036F]` matches combining diacritical marks: * - `\u0300-\u036F`: grave, acute, circumflex, tilde, macron, breve, dot above, diaeresis, ring above, etc. */ declare const latinDiacritical: { tmp: string; pattern: string; }; /** * Arabic - `[\u064B-\u0652\u0670]` matches Arabic diacritics (harakat): * - `\u064B-\u0652`: fatha, damma, kasra, sukun, shadda, tanwin, etc. * - `\u0670`: alif khanjariyah (superscript alif) */ declare const arabicDiacritical: { tmp: string; pattern: string; }; /** * Hebrew - `[\u05B0-\u05BC\u05C1\u05C2]` matches Hebrew diacritics (niqqud): * - `\u05B0-\u05BC`: vowel points (sheva, hataf, hiriq, tsere, segol, patah, qamats, holam, qubuts, dagesh, etc.) * - `\u05C1-\u05C2`: shin dot (right) and sin dot (left) */ declare const hebrewDiacritical: { tmp: string; pattern: string; }; declare const unicodePatterns: { l: string; s: RegExp; e?: string; d?: { tmp: string; pattern: string; }; }[]; declare const defaultMinCountForSearch = 6; declare const protectRegexp: RegExp; /** * Shared base for the <ng-option> and <ng-group> directives. * * Holds the inputs common to both (classes, templateId, data, dir) and the projected-content * reactivity: plain text content (interpolation in the element body) is not a tracked signal, so * the host component dirty-checks it in ngDoCheck and pushes changes into {@link _projectedContent}, * which the rebuild effect depends on through {@link _resolveLabel}. */ declare abstract class Select2ContentDirective { protected readonly _elementRef: ElementRef<any>; /** Additional CSS classes */ readonly classes: _angular_core.InputSignal<string | undefined>; /** Template id */ readonly templateId: _angular_core.InputSignal<string | undefined>; /** Arbitrary data attached to the option/group */ readonly data: _angular_core.InputSignal<any>; /** Force text direction */ readonly dir: _angular_core.InputSignal<"ltr" | "rtl" | undefined>; /** * Reactive trigger for the projected text content (interpolation in the element body). * The host component dirty-checks the DOM in its ngDoCheck and updates this signal when the * rendered text changes, so the component's rebuild effect re-runs even though plain text * content is not otherwise a tracked dependency. */ readonly _projectedContent: _angular_core.WritableSignal<string | undefined>; /** Read the host element's rendered text content (innerHTML, then textContent, then ''). */ private _readContent; /** * Re-read the host element's rendered content and update {@link _projectedContent} when it * changed. Returns true if a change was detected. Called from the host component's ngDoCheck. */ _refreshProjectedContent(): boolean; /** * Resolve the label: prefer the explicit [label] input, then the cached projected content, * then a one-off DOM read. Reading _projectedContent() registers it as a dependency of the * rebuild effect so interpolation/content changes propagate; the cached value avoids a second * DOM read, and _readContent() only runs on the initial pass. */ protected _resolveLabel(label: string | undefined): string; static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2ContentDirective, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<Select2ContentDirective, never, never, { "classes": { "alias": "classes"; "required": false; "isSignal": true; }; "templateId": { "alias": "templateId"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "dir": { "alias": "dir"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } /** * Directive representing a single option inside a <ng-select2> or <ng-group>. * * Usage: * ```html * <ng-select2> * <ng-option value="foo">Foo</ng-option> * <ng-option value="bar" [disabled]="true">Bar</ng-option> * </ng-select2> * ``` */ declare class Select2OptionDirective extends Select2ContentDirective { /** The option value */ readonly value: _angular_core.InputSignal<Select2Value>; /** Explicit label — falls back to the element's text content if omitted */ readonly label: _angular_core.InputSignal<string | undefined>; /** Whether the option is disabled */ readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Template selection id */ readonly templateSelectionId: _angular_core.InputSignal<string | undefined>; /** Hide this option */ readonly hide: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Build a plain Select2Option object from the current input values */ toOption(): Select2Option; static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2OptionDirective, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<Select2OptionDirective, "ng-option", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "templateSelectionId": { "alias": "templateSelectionId"; "required": false; "isSignal": true; }; "hide": { "alias": "hide"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } declare class Select2 implements ControlValueAccessor, OnInit, DoCheck, AfterViewInit, OnDestroy, OnChanges { protected _viewportRuler: ViewportRuler; private _changeDetectorRef; private _parentForm; private _parentFormGroup; _control: NgControl | null; readonly _uid: string; /** data of options & option groups */ readonly data: _angular_core.InputSignal<Select2Data>; /** minimum characters to start filter search */ readonly minCharForSearch: _angular_core.InputSignalWithTransform<number, unknown>; /** text placeholder */ readonly displaySearchStatus: _angular_core.InputSignal<"default" | "hidden" | "always" | undefined>; /** text placeholder */ readonly placeholder: _angular_core.InputSignal<string | undefined>; /** in multiple: maximum selection element (0 = no limit) */ readonly limitSelection: _angular_core.InputSignalWithTransform<number, unknown>; /** dropdown position */ readonly listPosition: _angular_core.InputSignal<"above" | "below" | "auto">; /** overlay with CDK Angular position */ readonly overlay: _angular_core.InputSignalWithTransform<boolean, unknown>; /** select one or more item */ readonly multiple: _angular_core.InputSignalWithTransform<boolean, unknown>; /** drag'n drop list of items in multiple */ readonly multipleDrag: _angular_core.InputSignalWithTransform<boolean, unknown>; /** use the material style */ readonly styleMode: _angular_core.InputSignal<"default" | "material" | "noStyle" | "borderless">; /** message when no result */ readonly noResultMessage: _angular_core.InputSignal<string | undefined>; /** maximum results limit (0 = no limit) */ readonly maxResults: _angular_core.InputSignalWithTransform<number, unknown>; /** message when maximum results */ readonly maxResultsMessage: _angular_core.InputSignal<string>; /** infinite scroll distance */ readonly infiniteScrollDistance: _angular_core.InputSignalWithTransform<number, unknown>; /** infinite scroll distance */ readonly infiniteScrollThrottle: _angular_core.InputSignalWithTransform<number, unknown>; /** infinite scroll activated */ readonly infiniteScroll: _angular_core.InputSignalWithTransform<boolean, unknown>; /** auto create if not exist */ readonly autoCreate: _angular_core.InputSignalWithTransform<boolean, unknown>; /** no template for label selection */ readonly noLabelTemplate: _angular_core.InputSignalWithTransform<boolean, unknown>; /** use it for change the pattern of the filter search */ readonly editPattern: _angular_core.InputSignal<((str: string) => string) | undefined>; /** template(s) for formatting */ readonly templates: _angular_core.InputSignal<Select2Template>; /** template for formatting selected option */ readonly templateSelection: _angular_core.InputSignal<TemplateRef<any> | undefined>; /** the max height of the results container when opening the select */ readonly resultMaxHeight: _angular_core.InputSignal<string>; /** Active Search event */ readonly customSearchEnabled: _angular_core.InputSignalWithTransform<boolean, unknown>; /** minimal data of show the search field */ readonly minCountForSearch: _angular_core.InputSignalWithTransform<number | undefined, unknown>; /** Unique id of the element. */ readonly id: _angular_core.InputSignal<string>; /** Unique id of label element. */ readonly idLabel: _angular_core.Signal<string>; /** Unique id of combo element. */ readonly idCombo: _angular_core.Signal<string>; /** Unique id of options element. */ readonly idOptions: _angular_core.Signal<string>; /** Unique id of overlay element. */ readonly idOverlay: _angular_core.Signal<string>; /** Whether the element is required. */ readonly required: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Whether selected items should be hidden. */ readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Whether items are hidden when has. */ readonly hideSelectedItems: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Whether the element is readonly. */ readonly readonly: _angular_core.InputSignalWithTransform<boolean, unknown>; /** The input element's value. */ readonly value: _angular_core.InputSignal<Select2UpdateValue>; /** Tab index for the select2 element. */ readonly tabIndex: _angular_core.InputSignalWithTransform<number, unknown>; /** reset with no selected value */ readonly resettable: _angular_core.InputSignalWithTransform<boolean, unknown>; /** selected value when × is clicked */ readonly resetSelectedValue: _angular_core.InputSignal<any>; /** like native select keyboard navigation (only single mode) */ readonly nativeKeyboard: _angular_core.InputSignalWithTransform<boolean, unknown>; /** highlight search text */ readonly highlightText: _angular_core.InputSignalWithTransform<boolean, unknown>; /** grid: item by line * * 0 = no grid * * number = item by line (4) * * string = minimal size item (100px) */ readonly grid: _angular_core.InputSignal<string>; /** * Replace selection by a text * * if string: `%size%` = total selected options * * if function: juste show the string */ readonly selectionOverride: _angular_core.InputSignal<Select2SelectionOverride | undefined>; /** force selection on one line */ readonly selectionNoWrap: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Add an option to select or remove all (if all is selected) */ readonly showSelectAll: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Show a checkbox next to each option */ readonly showOptionCheckbox: _angular_core.InputSignalWithTransform<boolean, unknown>; /** Text for remove all options */ readonly removeAllText: _angular_core.InputSignal<string>; /** Text for select all options */ readonly selectAllText: _angular_core.InputSignal<string>; /** title attribute applied to the input */ readonly title: _angular_core.InputSignal<string | undefined>; /** aria-labelledby attribute applied to the input, to specify en external label */ readonly ariaLabelledby: _angular_core.InputSignal<string | undefined>; /** aria-describedby attribute applied to the input */ readonly ariaDescribedby: _angular_core.InputSignal<string | undefined>; /** aria-invalid attribute applied to the input, to force error state */ readonly ariaInvalid: _angular_core.InputSignalWithTransform<boolean, unknown>; /** description of the reset button when using 'resettable'. Default value : 'Reset' */ readonly ariaResetButtonDescription: _angular_core.InputSignal<string>; readonly update: _angular_core.OutputEmitterRef<Select2UpdateEvent<Select2UpdateValue>>; readonly autoCreateItem: _angular_core.OutputEmitterRef<Select2AutoCreateEvent<Select2UpdateValue>>; readonly open: _angular_core.OutputEmitterRef<Select2>; readonly close: _angular_core.OutputEmitterRef<Select2>; readonly focus: _angular_core.OutputEmitterRef<Select2>; readonly blur: _angular_core.OutputEmitterRef<Select2>; readonly search: _angular_core.OutputEmitterRef<Select2SearchEvent<Select2UpdateValue>>; readonly scroll: _angular_core.OutputEmitterRef<Select2ScrollEvent>; readonly removeOption: _angular_core.OutputEmitterRef<Select2RemoveEvent<Select2UpdateValue>>; readonly cdkConnectedOverlay: _angular_core.Signal<CdkConnectedOverlay>; readonly selection: _angular_core.Signal<ElementRef<HTMLElement>>; readonly resultContainer: _angular_core.Signal<ElementRef<HTMLElement> | undefined>; readonly results: _angular_core.Signal<readonly ElementRef<any>[]>; readonly searchInput: _angular_core.Signal<ElementRef<HTMLElement> | undefined>; readonly dropdown: _angular_core.Signal<ElementRef<HTMLElement> | undefined>; /** Top-level <ng-option> elements (not inside a <ng-group>) */ readonly _ngOptions: _angular_core.Signal<readonly Select2OptionDirective[]>; /** <ng-group> elements */ readonly _ngGroups: _angular_core.Signal<readonly Select2GroupDirective[]>; readonly classMaterial: _angular_core.Signal<boolean>; readonly classNostyle: _angular_core.Signal<boolean>; readonly classBorderless: _angular_core.Signal<boolean>; readonly select2above: _angular_core.Signal<boolean>; selectedOption: Select2Option | Select2Option[] | null; isOpen: boolean; searchStyle: string | undefined; /** Whether the element is focused or not. */ focused: boolean; filteredData: _angular_core.WritableSignal<Select2Data | undefined>; get select2Options(): Select2Option[]; get select2Option(): Select2Option | null; get searchText(): string; protected set searchText(text: string); get disabledState(): boolean; protected overlayWidth: number | string; protected overlayHeight: number | string; protected _triggerRect: DOMRect | undefined; protected _dropdownRect: DOMRect | undefined; protected readonly _positions: _angular_core.Signal<ConnectionPositionPair[]>; protected maxResultsExceeded: boolean | undefined; private hoveringOption; hoveringOptionId: _angular_core.Signal<string | null>; private innerSearchText; protected isSearchboxHidden: boolean | undefined; private selectionElement; private get resultsElement(); private _stateChanges; /** Tab index for the element. */ protected get _tabIndex(): number; private _data; private _disabled; private _destroyed; protected _value: Select2UpdateValue | null; private _previousNativeValue; private _overlayPosition; private toObservable; constructor(); ngOnChanges(changes: SimpleChanges): void; clickDetection(e: MouseEvent): void; /** View -> model callback called when select has been touched */ private _onTouched; /** View -> model callback called when value changes */ private _onChange; _onViewportChange(): void; ngOnInit(): void; ngAfterViewInit(): void; ngDoCheck(): void; ngOnDestroy(): void; /** * Template mode only: dirty-check the rendered text content of every projected <ng-option> * (top-level and nested in <ng-group>) so interpolation changes ({{ }}) are picked up. * Updating an option's _projectedContent signal re-triggers the data rebuild effect. */ private _refreshProjectedContent; fixValue(): void; updateSearchBox(): void; getOptionStyle(option: Select2Option): string; mouseenter(option: Select2Option): void; click(option: Select2Option): void; reset(event?: MouseEvent): void; prevChange(event: Event): void; stopEvent(event: Event): void; toggleOpenAndClose(focus?: boolean, open?: boolean, event?: KeyboardEvent): void; hasTemplate(option: Select2Option | Select2Group, defaultValue: string, select?: boolean): boolean; getTemplate(option: Select2Option | Select2Group, defaultValue: string, select?: boolean): any; getContext(option: Select2Option): { searchText: string; highlightText: boolean; value: Select2Value; label: string; disabled?: boolean; id?: string; classes?: string; templateId?: string; templateSelectionId?: string; data?: any; hide?: boolean; dir?: "ltr" | "rtl"; }; triggerRect(): void; isNumber(o: any): boolean; selectAll(): void; selectAllTest(): boolean; private testSelection; private testValueChange; private updateFilteredData; private clickExit; private isInSelect; private ifParentContainsClass; private ifParentContainsId; private getParentElementByClass; private getParentElementById; private containClasses; private containAlmostOneClasses; private clickOnSelect2Element; focusin(options?: FocusOptions): void; focusout(event: FocusEvent): void; select(option: Select2Option | null, emit?: boolean, closeOnSelect?: boolean): void; private testDiffValue; keyDown(event: KeyboardEvent, create?: boolean): void; private actionAfterKeyDownMoveAction; openKey(event: KeyboardEvent, create?: boolean): void; private _closeOnKey; private _shouldKeyDownOnOpen; private _handleOnOpenAction; private _scrollToInitialOption; searchUpdate(e: Event): void; isSelected(option: Select2Option): "true" | "false"; isDisabled(option: Select2Option): "true" | "false"; removeSelection(e: MouseEvent | KeyboardEvent | Event, option: Select2Option): void; /** * Sets the model value. Implemented as part of ControlValueAccessor. * @param value */ writeValue(value: any): void; /** * Saves a callback function to be invoked when the select's value * changes from user input. Part of the ControlValueAccessor interface * required to integrate with Angular's core forms API. * * @param fn Callback to be triggered when the value changes. */ registerOnChange(fn: (value: any) => void): void; /** * Saves a callback function to be invoked when the select is blurred * by the user. Part of the ControlValueAccessor interface required * to integrate with Angular's core forms API. * * @param fn Callback to be triggered when the component has been touched. */ registerOnTouched(fn: () => void): void; /** * Sets whether the component should be disabled. * Implemented as part of ControlValueAccessor. * @param isDisabled */ setDisabledState(isDisabled: boolean): void; onScroll(way: 'up' | 'down'): void; private _setupScrollListener; _onScrollEvent(scrollTop: number, clientHeight: number, scrollHeight: number): void; drop(event: CdkDragDrop<string[], string[], any>): void; _isErrorState(): boolean; private _isFormSubmitted; _selectionOverrideLabel(): string | undefined; getElementId(elt: Select2Group | Select2Option | null): string | null; private _toSuffix; _getElementPath(elt: Select2Group | Select2Option): number[]; _toGroup(group: Select2Option | Select2Group): Select2Group; _toOption(option: Select2Option | Select2Group): Select2Option; private updateEvent; private optionsSize; private addItem; private createAndAdd; private moveUp; private moveDown; private moveStart; private moveEnd; private updateScrollFromOption; private selectByEnter; private _testKey; /** * Sets the selected option based on a value. If no option can be * found with the designated value, the select trigger is cleared. */ private _setSelectionByValue; private _preselectArrayValue; /** Does some manual dirty checking on the native input `value` property. */ private _dirtyCheckNativeValue; private _focusSearchbox; private _focus; private _isAbobeOverlay; _updateFocusState(state: boolean): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2, never>; static ɵcmp: _angular_core.ɵɵComponentDeclaration<Select2, "select2, ng-select2", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "minCharForSearch": { "alias": "minCharForSearch"; "required": false; "isSignal": true; }; "displaySearchStatus": { "alias": "displaySearchStatus"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "limitSelection": { "alias": "limitSelection"; "required": false; "isSignal": true; }; "listPosition": { "alias": "listPosition"; "required": false; "isSignal": true; }; "overlay": { "alias": "overlay"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "multipleDrag": { "alias": "multipleDrag"; "required": false; "isSignal": true; }; "styleMode": { "alias": "styleMode"; "required": false; "isSignal": true; }; "noResultMessage": { "alias": "noResultMessage"; "required": false; "isSignal": true; }; "maxResults": { "alias": "maxResults"; "required": false; "isSignal": true; }; "maxResultsMessage": { "alias": "maxResultsMessage"; "required": false; "isSignal": true; }; "infiniteScrollDistance": { "alias": "infiniteScrollDistance"; "required": false; "isSignal": true; }; "infiniteScrollThrottle": { "alias": "infiniteScrollThrottle"; "required": false; "isSignal": true; }; "infiniteScroll": { "alias": "infiniteScroll"; "required": false; "isSignal": true; }; "autoCreate": { "alias": "autoCreate"; "required": false; "isSignal": true; }; "noLabelTemplate": { "alias": "noLabelTemplate"; "required": false; "isSignal": true; }; "editPattern": { "alias": "editPattern"; "required": false; "isSignal": true; }; "templates": { "alias": "templates"; "required": false; "isSignal": true; }; "templateSelection": { "alias": "templateSelection"; "required": false; "isSignal": true; }; "resultMaxHeight": { "alias": "resultMaxHeight"; "required": false; "isSignal": true; }; "customSearchEnabled": { "alias": "customSearchEnabled"; "required": false; "isSignal": true; }; "minCountForSearch": { "alias": "minCountForSearch"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "hideSelectedItems": { "alias": "hideSelectedItems"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "tabIndex": { "alias": "tabIndex"; "required": false; "isSignal": true; }; "resettable": { "alias": "resettable"; "required": false; "isSignal": true; }; "resetSelectedValue": { "alias": "resetSelectedValue"; "required": false; "isSignal": true; }; "nativeKeyboard": { "alias": "nativeKeyboard"; "required": false; "isSignal": true; }; "highlightText": { "alias": "highlightText"; "required": false; "isSignal": true; }; "grid": { "alias": "grid"; "required": false; "isSignal": true; }; "selectionOverride": { "alias": "selectionOverride"; "required": false; "isSignal": true; }; "selectionNoWrap": { "alias": "selectionNoWrap"; "required": false; "isSignal": true; }; "showSelectAll": { "alias": "showSelectAll"; "required": false; "isSignal": true; }; "showOptionCheckbox": { "alias": "showOptionCheckbox"; "required": false; "isSignal": true; }; "removeAllText": { "alias": "removeAllText"; "required": false; "isSignal": true; }; "selectAllText": { "alias": "selectAllText"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "ariaDescribedby"; "required": false; "isSignal": true; }; "ariaInvalid": { "alias": "ariaInvalid"; "required": false; "isSignal": true; }; "ariaResetButtonDescription": { "alias": "ariaResetButtonDescription"; "required": false; "isSignal": true; }; }, { "update": "update"; "autoCreateItem": "autoCreateItem"; "open": "open"; "close": "close"; "focus": "focus"; "blur": "blur"; "search": "search"; "scroll": "scroll"; "removeOption": "removeOption"; }, ["_ngOptions", "_ngGroups"], ["select2-label, ng-select2-label", "select2-hint, ng-select2-hint"], true, never>; } interface Select2Group { /** for identification */ id?: string; /** label of group */ label: string; /** options list */ options: Select2Option[]; /** add classes */ classes?: string; /** template id dropdown & selection if no templateSelectionId */ templateId?: string; /** template data */ data?: any; /** force left to right or right to left */ dir?: 'ltr' | 'rtl'; } interface Select2Option { /** value */ value: Select2Value; /** label of option */ label: string; /** no selectable is disabled */ disabled?: boolean; /** for identification */ id?: string; /** add classes */ classes?: string; /** template id dropdown & selection if no templateSelectionId */ templateId?: string; /** template id for selection */ templateSelectionId?: string; /** template data */ data?: any; /** hide this option */ hide?: boolean; /** force left to right or right to left */ dir?: 'ltr' | 'rtl'; } type Select2Value = string | number | boolean | object | null | undefined; type Select2UpdateValue = Select2Value | Select2Value[] | undefined | null; type Select2Data = (Select2Group | Select2Option)[]; interface Select2UpdateEvent<U extends Select2UpdateValue = Select2Value> { /** component */ readonly component: Select2; /** current selected value */ readonly value: U | null; /** selected option */ readonly options: Select2Option[] | null; } interface Select2AutoCreateEvent<U extends Select2UpdateValue = Select2Value> { /** component */ readonly component: Select2; /** current selected value */ readonly value: U; /** selected option */ readonly options: Select2Option[] | null; } interface Select2SearchEvent<U extends Select2UpdateValue = Select2Value> { /** component */ readonly component: Select2; /** current selected value */ readonly value: U | null; /** search text */ readonly search: string; /** current data source */ readonly data: Select2Data; /** method to call to update the data */ readonly filteredData: (data: Select2Data) => void; } interface Select2RemoveEvent<U extends Select2UpdateValue = Select2Value> { /** component */ readonly component: Select2; /** current selected value */ readonly value: U; /** remove */ readonly removedOption: Select2Option; } interface Select2ScrollEvent { /** component */ readonly component: Select2; /** scroll way */ readonly way: 'up' | 'down'; /** search text */ readonly search: string; /** current data */ readonly data: Select2Data; } type Select2SelectionOverride = string | ((params: { size: number; options: Select2Option[] | null; }) => string); type Select2Template = TemplateRef<any> | { [key: string]: TemplateRef<any>; } | undefined; /** * Directive representing an option group inside a <ng-select2>. * * Usage: * ```html * <ng-select2> * <ng-group label="Fruits"> * <ng-option value="apple">Apple</ng-option> * <ng-option value="banana">Banana</ng-option> * </ng-group> * </ng-select2> * ``` */ declare class Select2GroupDirective extends Select2ContentDirective { /** The group label (required) */ readonly label: _angular_core.InputSignal<string>; /** Child <ng-option> directives nested inside this group */ readonly _ngOptions: _angular_core.Signal<readonly Select2OptionDirective[]>; /** Build a plain Select2Group object from the current input values */ toGroup(): Select2Group; static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2GroupDirective, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<Select2GroupDirective, "ng-group", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; }, {}, ["_ngOptions"], never, true, never>; } declare class Select2HighlightPipe implements PipeTransform { private readonly sanitizer; transform(value: string | null | undefined, search: string | null | undefined, disabled?: boolean): SafeHtml | string; static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2HighlightPipe, never>; static ɵpipe: _angular_core.ɵɵPipeDeclaration<Select2HighlightPipe, "highlightText", true>; } declare class Select2Hint { static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2Hint, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<Select2Hint, "select2-hint, ng-select2-hint", never, {}, {}, never, never, true, never>; } declare class Select2Label { static ɵfac: _angular_core.ɵɵFactoryDeclaration<Select2Label, never>; static ɵdir: _angular_core.ɵɵDirectiveDeclaration<Select2Label, "select2-label, ng-select2-label", never, {}, {}, never, never, true, never>; } declare class Select2Utils { static getOptionByValue(data: Select2Data, value: Select2Value): Select2Option | null; static getOptionsByValue(data: Select2Data, value: Select2UpdateValue | null | undefined, multiple: boolean | null | undefined): Select2Option | Select2Option[] | null; static getFirstAvailableOption(data: Select2Data): Select2Option | null; static optionIsNotInFilteredData(filteredData: Select2Data, option: Select2Option | null): boolean; static getPreviousOption(filteredData: Select2Data, hoveringOption: Select2Option | null): Select2Option | null; static getNextOption(filteredData: Select2Data | null, hoveringOption: Select2Option | null): Select2Option | null; static getFirstOption(filteredData: Select2Data): Select2Option | null; static getLastOption(filteredData: Select2Data): Select2Option | null; static isGroup(element: Select2Group | Select2Option): element is Select2Group; static isOption(element: Select2Group | Select2Option): element is Select2Option; static getReduceData(data: Select2Data, maxResults?: number): { result: Select2Data; reduce: boolean; }; static getFilteredData(data: Select2Data, searchText: string | null, editPattern?: (str: string) => string): Select2Data; static getFilteredSelectedData(data: Select2Data, selectedOptions: Select2Option | Select2Option[] | null): Select2Data; static isSearchboxHidden(data: Select2Data, minCountForSearch?: number): boolean; static isSelected(options: Select2Option | Select2Option[] | null, option: Select2Option, multiple: boolean | null | undefined): "true" | "false"; static removeSelection(options: Select2Option | Select2Option[] | null, option: Select2Option): void; private static getOptionsCount; private static isNullOrUndefined; private static containSearchText; static protectPattern(str: string): string; private static formatSansUnicode; static patternUnicode(str: string): string; static formatPattern(str: string, editPattern?: (str: string) => string): string; } export { Select2, Select2ContentDirective, Select2GroupDirective, Select2HighlightPipe, Select2Hint, Select2Label, Select2OptionDirective, Select2Utils, arabicDiacritical, defaultMinCountForSearch, hebrewDiacritical, latinDiacritical, protectRegexp, timeout, unicodePatterns }; export type { Select2AutoCreateEvent, Select2Data, Select2Group, Select2Option, Select2RemoveEvent, Select2ScrollEvent, Select2SearchEvent, Select2SelectionOverride, Select2Template, Select2UpdateEvent, Select2UpdateValue, Select2Value }; //# sourceMappingURL=ng-select2-component.d.ts.map