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 and 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; /** Additional CSS classes */ readonly classes: _angular_core.InputSignal; /** Template id */ readonly templateId: _angular_core.InputSignal; /** Arbitrary data attached to the option/group */ readonly data: _angular_core.InputSignal; /** 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; /** 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; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Directive representing a single option inside a or . * * Usage: * ```html * * Foo * Bar * * ``` */ declare class Select2OptionDirective extends Select2ContentDirective { /** The option value */ readonly value: _angular_core.InputSignal; /** Explicit label — falls back to the element's text content if omitted */ readonly label: _angular_core.InputSignal; /** Whether the option is disabled */ readonly disabled: _angular_core.InputSignalWithTransform; /** Template selection id */ readonly templateSelectionId: _angular_core.InputSignal; /** Hide this option */ readonly hide: _angular_core.InputSignalWithTransform; /** Build a plain Select2Option object from the current input values */ toOption(): Select2Option; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } 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; /** minimum characters to start filter search */ readonly minCharForSearch: _angular_core.InputSignalWithTransform; /** text placeholder */ readonly displaySearchStatus: _angular_core.InputSignal<"default" | "hidden" | "always" | undefined>; /** text placeholder */ readonly placeholder: _angular_core.InputSignal; /** in multiple: maximum selection element (0 = no limit) */ readonly limitSelection: _angular_core.InputSignalWithTransform; /** dropdown position */ readonly listPosition: _angular_core.InputSignal<"above" | "below" | "auto">; /** overlay with CDK Angular position */ readonly overlay: _angular_core.InputSignalWithTransform; /** select one or more item */ readonly multiple: _angular_core.InputSignalWithTransform; /** drag'n drop list of items in multiple */ readonly multipleDrag: _angular_core.InputSignalWithTransform; /** use the material style */ readonly styleMode: _angular_core.InputSignal<"default" | "material" | "noStyle" | "borderless">; /** message when no result */ readonly noResultMessage: _angular_core.InputSignal; /** maximum results limit (0 = no limit) */ readonly maxResults: _angular_core.InputSignalWithTransform; /** message when maximum results */ readonly maxResultsMessage: _angular_core.InputSignal; /** infinite scroll distance */ readonly infiniteScrollDistance: _angular_core.InputSignalWithTransform; /** infinite scroll distance */ readonly infiniteScrollThrottle: _angular_core.InputSignalWithTransform; /** infinite scroll activated */ readonly infiniteScroll: _angular_core.InputSignalWithTransform; /** auto create if not exist */ readonly autoCreate: _angular_core.InputSignalWithTransform; /** no template for label selection */ readonly noLabelTemplate: _angular_core.InputSignalWithTransform; /** 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; /** template for formatting selected option */ readonly templateSelection: _angular_core.InputSignal | undefined>; /** the max height of the results container when opening the select */ readonly resultMaxHeight: _angular_core.InputSignal; /** Active Search event */ readonly customSearchEnabled: _angular_core.InputSignalWithTransform; /** minimal data of show the search field */ readonly minCountForSearch: _angular_core.InputSignalWithTransform; /** Unique id of the element. */ readonly id: _angular_core.InputSignal; /** Unique id of label element. */ readonly idLabel: _angular_core.Signal; /** Unique id of combo element. */ readonly idCombo: _angular_core.Signal; /** Unique id of options element. */ readonly idOptions: _angular_core.Signal; /** Unique id of overlay element. */ readonly idOverlay: _angular_core.Signal; /** Whether the element is required. */ readonly required: _angular_core.InputSignalWithTransform; /** Whether selected items should be hidden. */ readonly disabled: _angular_core.InputSignalWithTransform; /** Whether items are hidden when has. */ readonly hideSelectedItems: _angular_core.InputSignalWithTransform; /** Whether the element is readonly. */ readonly readonly: _angular_core.InputSignalWithTransform; /** The input element's value. */ readonly value: _angular_core.InputSignal; /** Tab index for the select2 element. */ readonly tabIndex: _angular_core.InputSignalWithTransform; /** reset with no selected value */ readonly resettable: _angular_core.InputSignalWithTransform; /** selected value when × is clicked */ readonly resetSelectedValue: _angular_core.InputSignal; /** like native select keyboard navigation (only single mode) */ readonly nativeKeyboard: _angular_core.InputSignalWithTransform; /** highlight search text */ readonly highlightText: _angular_core.InputSignalWithTransform; /** grid: item by line * * 0 = no grid * * number = item by line (4) * * string = minimal size item (100px) */ readonly grid: _angular_core.InputSignal; /** * Replace selection by a text * * if string: `%size%` = total selected options * * if function: juste show the string */ readonly selectionOverride: _angular_core.InputSignal; /** force selection on one line */ readonly selectionNoWrap: _angular_core.InputSignalWithTransform; /** Add an option to select or remove all (if all is selected) */ readonly showSelectAll: _angular_core.InputSignalWithTransform; /** Show a checkbox next to each option */ readonly showOptionCheckbox: _angular_core.InputSignalWithTransform; /** Text for remove all options */ readonly removeAllText: _angular_core.InputSignal; /** Text for select all options */ readonly selectAllText: _angular_core.InputSignal; /** title attribute applied to the input */ readonly title: _angular_core.InputSignal; /** aria-labelledby attribute applied to the input, to specify en external label */ readonly ariaLabelledby: _angular_core.InputSignal; /** aria-describedby attribute applied to the input */ readonly ariaDescribedby: _angular_core.InputSignal; /** aria-invalid attribute applied to the input, to force error state */ readonly ariaInvalid: _angular_core.InputSignalWithTransform; /** description of the reset button when using 'resettable'. Default value : 'Reset' */ readonly ariaResetButtonDescription: _angular_core.InputSignal; readonly update: _angular_core.OutputEmitterRef>; readonly autoCreateItem: _angular_core.OutputEmitterRef>; readonly open: _angular_core.OutputEmitterRef; readonly close: _angular_core.OutputEmitterRef; readonly focus: _angular_core.OutputEmitterRef; readonly blur: _angular_core.OutputEmitterRef; readonly search: _angular_core.OutputEmitterRef>; readonly scroll: _angular_core.OutputEmitterRef; readonly removeOption: _angular_core.OutputEmitterRef>; readonly cdkConnectedOverlay: _angular_core.Signal; readonly selection: _angular_core.Signal>; readonly resultContainer: _angular_core.Signal | undefined>; readonly results: _angular_core.Signal[]>; readonly searchInput: _angular_core.Signal | undefined>; readonly dropdown: _angular_core.Signal | undefined>; /** Top-level elements (not inside a ) */ readonly _ngOptions: _angular_core.Signal; /** elements */ readonly _ngGroups: _angular_core.Signal; readonly classMaterial: _angular_core.Signal; readonly classNostyle: _angular_core.Signal; readonly classBorderless: _angular_core.Signal; readonly select2above: _angular_core.Signal; selectedOption: Select2Option | Select2Option[] | null; isOpen: boolean; searchStyle: string | undefined; /** Whether the element is focused or not. */ focused: boolean; filteredData: _angular_core.WritableSignal; 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; protected maxResultsExceeded: boolean | undefined; private hoveringOption; hoveringOptionId: _angular_core.Signal; 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 * (top-level and nested in ) 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): 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; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } 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 { /** component */ readonly component: Select2; /** current selected value */ readonly value: U | null; /** selected option */ readonly options: Select2Option[] | null; } interface Select2AutoCreateEvent { /** component */ readonly component: Select2; /** current selected value */ readonly value: U; /** selected option */ readonly options: Select2Option[] | null; } interface Select2SearchEvent { /** 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 { /** 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 | { [key: string]: TemplateRef; } | undefined; /** * Directive representing an option group inside a . * * Usage: * ```html * * * Apple * Banana * * * ``` */ declare class Select2GroupDirective extends Select2ContentDirective { /** The group label (required) */ readonly label: _angular_core.InputSignal; /** Child directives nested inside this group */ readonly _ngOptions: _angular_core.Signal; /** Build a plain Select2Group object from the current input values */ toGroup(): Select2Group; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } 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; static ɵpipe: _angular_core.ɵɵPipeDeclaration; } declare class Select2Hint { static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class Select2Label { static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } 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