import { OnInit, OnChanges, SimpleChanges, ElementRef, EventEmitter } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { MatSelect, MatSelectChange } from '@angular/material/select'; import * as i0 from "@angular/core"; export interface SelectOption { id?: any; value?: any; name?: string; label?: string; /** e.g. MOBILE, BROWSER — shown as a leading icon in the dropdown when set */ testType?: string; statusColor?: string; durationFormatted?: string; runNumberLabel?: string; hasHourRun?: boolean; hasMinuteRun?: boolean; runDateLabel?: string; } export interface DynamicSelectFieldConfig { key: string; label?: string; placeholder?: string; displayLabelAsInnerHtml?: boolean; disabled?: boolean; multiple?: boolean; searchable?: boolean; /** Controls how selection indicator is shown for multi-select options. */ optionStyle?: 'checkmark' | 'checkbox'; /** Show a 'Select All' option at the top (multi-select only). */ showSelectAll?: boolean; /** Custom label for the 'Select All' option. Defaults to 'All'. */ selectAllLabel?: string; /** If true, close the panel when an option is selected (useful for multi-select in headers). */ closeOnSelect?: boolean; /** Provide a default selected value (or array for multi-select) if the control has no value yet. */ selectedValue?: any | any[]; /** Optional callback invoked whenever the selection changes. */ onChange?: (value: any, event?: MatSelectChange) => void; /** Enable server-side search mode; component will emit search instead of local filtering. */ serverSearch?: boolean; /** * When true, triggers an initial search emit on panel open (serverSearch mode only). * Defaults to false so opening the dropdown does NOT call the API. */ initialFetchOnOpen?: boolean; /** Indicates more results are available for infinite scroll. */ hasMore?: boolean; /** Optional loading flag controlled by consumer to show loading state. */ isLoading?: boolean; /** Optional callback for server-side search when query changes. */ onSearch?: (query: string) => void; /** If true, renders testType icons (mobile/web/other) before labels. */ showTestTypeIcon?: boolean; /** Optional callback when more data is requested (infinite scroll). */ onLoadMore?: (query?: string) => void; /** Optional regex pattern or function to highlight parts of option text. */ highlightPattern?: RegExp | string | ((text: string) => string); /** When true (and searchable), allows adding the current search text as a new option via an "Add ''" choice. */ allowCustomValue?: boolean; options: SelectOption[]; isCompareRuns?: boolean; valueBy?: string; /** Optional extra CSS class appended to the mat-select panel (use for scoped overlay targeting). */ extraPanelClass?: string; } export declare class DynamicSelectFieldComponent implements OnInit, OnChanges { readonly SELECT_ALL_VALUE: string; readonly ADD_CUSTOM_VALUE_PREFIX: string; form: FormGroup; config: DynamicSelectFieldConfig; selectionChange: EventEmitter<{ key: string; value: any; event: MatSelectChange; }>; selectClick: EventEmitter; /** Emits when user types in search box (useful for server search) */ searchChange: EventEmitter<{ key: string; query: string; }>; /** Emits when the component requests more data for the current query */ loadMore: EventEmitter<{ key: string; query: string; }>; /** Emits when the user chooses to add a custom value (allowCustomValue: true). Consumer should add the value to options and set the control value. */ addCustomValue: EventEmitter<{ key: string; value: string; }>; selectRef?: MatSelect; hostEl?: ElementRef; searchTextByKey: Record; private outsideCleanup?; private loadMoreObserver?; private lastOptionsLength; loadingMore: boolean; private panelScrollEl?; private documentKeydownListener?; /** * Guard to ensure load-more is only triggered after the user has scrolled * at least once since opening the panel. Prevents auto-load on open. */ private hasScrolledSinceOpen; /** * True when the load-more sentinel is currently in view. Used to trigger only when * the sentinel transitions from out-of-view to in-view (user scrolled to bottom again), * not when it stays in view after new data arrives (which would cause repeated API calls). */ private sentinelCurrentlyInView; private onPanelScroll; ngOnInit(): void; get displayPlaceholder(): string | undefined; ngOnChanges(changes: SimpleChanges): void; get panelClass(): string; get isMultiple(): boolean; get singleSelectedDisplayLabel(): string; /** Resolved option for single-select trigger (icon + label). */ get singleSelectedOption(): SelectOption | null; /** * Maps API testType strings to icon variants. Unknown non-empty values use 'other'. */ testTypeIconKind(opt: SelectOption | null | undefined): 'mobile' | 'web' | 'other' | null; get isDisabled(): boolean; get useCheckboxStyle(): boolean; get allSelected(): boolean; private toBoolean; /** * Get the value for an option based on the valueBy property. * If valueBy is provided, use that property from the option. * Otherwise, fall back to id ?? value (default behavior). * Must be public for template access. */ getOptionValue(opt: SelectOption): any; /** * Sync the form control's disabled state from config. * Use the FormControl API instead of [disabled] in the template to avoid Angular's * "changed after checked" / reactive forms disabled-attribute warning. */ private syncDisabledState; private syncControlValueForMultipleMode; private applySelectedValueIfNeeded; private hasExistingValue; isOptionSelected(opt: SelectOption): boolean; private getAllOptionIds; onToggleSelectAll(select: MatSelect): void; onSelectOpenedChange(opened: boolean, _select: MatSelect): void; onSearch(key: string, value: string): void; /** * Handles keyboard events on the search input to enable navigation with arrow keys * and selection with Enter key, while still allowing typing in the search box. */ onSearchInputKeydown(event: KeyboardEvent): void; onSelectKeydown(event: KeyboardEvent): void; /** * Manually navigates through options when arrow keys are pressed from search input. * @param direction 1 for down, -1 for up */ private navigateOptions; /** * Returns the currently selected option ids for the configured control. */ private getSelectedIdsForKey; /** Programmatically close the select panel if open */ closePanel(): void; filteredOptions(c: DynamicSelectFieldConfig): SelectOption[]; /** When allowCustomValue is true and the user has typed a value that is not in options, returns that value for the "Add" option. */ get customValueToAdd(): string | null; get showAddCustomOption(): boolean; get addCustomSentinelValue(): string; onSelectionChange(event: MatSelectChange, select: MatSelect): void; handleDocumentClick(event: MouseEvent): void; /** * Highlights text based on the configured highlightPattern. * Returns HTML string with highlighted portions wrapped in . */ highlightText(text: string): string; /** * Escapes HTML special characters to prevent XSS. */ private escapeHtml; /** * Checks if highlighting is enabled for this component. */ get hasHighlighting(): boolean; /** * Sets up a document-level keyboard listener to handle arrow key navigation * when the panel is open and the search input is not focused. */ private setupDocumentKeydownListener; private setupLoadMoreObserver; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }