import { Directionality } from '@angular/cdk/bidi'; import { SelectionModel } from '@angular/cdk/collections'; import { CdkConnectedOverlay, CdkOverlayOrigin, ConnectedPosition } from '@angular/cdk/overlay'; import { AfterContentInit, AfterViewInit, ChangeDetectorRef, DoCheck, ElementRef, EventEmitter, InjectionToken, NgZone, OnDestroy, OnInit, Provider, QueryList, Renderer2, TemplateRef } from '@angular/core'; import { ControlValueAccessor, FormGroupDirective, NgControl, NgForm } from '@angular/forms'; import { CanUpdateErrorState, ErrorStateMatcher, KbqAbstractSelect, KbqComponentColors, KbqLocaleService, KbqSelectMatcher, KbqSelectSearch, KbqSelectTrigger } from '@koobiq/components/core'; import { KbqCleaner, KbqFormField, KbqFormFieldControl } from '@koobiq/components/form-field'; import { KbqTag } from '@koobiq/components/tags'; import { KbqTreeOption, KbqTreeSelection } from '@koobiq/components/tree'; import { Observable, Subject } from 'rxjs'; import * as i0 from "@angular/core"; /** Tree select trigger value type. */ export type KbqTreeSelectTriggerValue = { disabled: boolean; value: string; viewValue: string; }; /** Tree select panel width type. */ export type KbqTreeSelectPanelWidth = 'auto' | number | null; /** Options for the `kbq-tree-select` that can be configured using the `KBQ_TREE_SELECT_OPTIONS` injection token. */ export type KbqTreeSelectOptions = Partial<{ /** * Width of the panel. If set to `auto`, the panel will match the trigger width. * If set to null or an empty string, the panel will grow to match the longest option's text. */ panelWidth: KbqTreeSelectPanelWidth; /** * Minimum width of the panel. If minWidth is larger than window width or property set to null, it will be ignored. */ panelMinWidth: Exclude; /** * Whether to enable hiding search by default if options is less than minimum. * * - `'auto'` uses `KBQ_SELECT_SEARCH_MIN_OPTIONS_THRESHOLD` as min value. * - number - will enables search hiding and uses value as min. * @see KBQ_SELECT_SEARCH_MIN_OPTIONS_THRESHOLD */ searchMinOptionsThreshold: 'auto' | number; }>; /** Injection token that can be used to provide the default options for the `kbq-tree-select`. */ export declare const KBQ_TREE_SELECT_OPTIONS: InjectionToken; /** * Whether to enable hiding search by default if options is less than minimum. * * - `'auto'` uses `KBQ_SELECT_SEARCH_MIN_OPTIONS_THRESHOLD` as min value. * - number - will enables search hiding and uses value as min. * @see KBQ_SELECT_SEARCH_MIN_OPTIONS_THRESHOLD */ searchMinOptionsThreshold: "auto" | number; }>>; /** Utility provider for `KBQ_TREE_SELECT_OPTIONS`. */ export declare const kbqTreeSelectOptionsProvider: (options: KbqTreeSelectOptions) => Provider; /** Change event object that is emitted when the select value has changed. */ export declare class KbqTreeSelectChange { source: KbqTreeSelect; value: any; isUserInput: boolean; values?: unknown[] | undefined; constructor(source: KbqTreeSelect, value: any, isUserInput?: boolean, values?: unknown[] | undefined); } export declare class KbqTreeSelect extends KbqAbstractSelect implements AfterContentInit, AfterViewInit, OnDestroy, OnInit, DoCheck, ControlValueAccessor, KbqFormFieldControl, CanUpdateErrorState { elementRef: ElementRef; readonly changeDetectorRef: ChangeDetectorRef; private readonly ngZone; private readonly renderer; defaultErrorStateMatcher: ErrorStateMatcher; private readonly scrollStrategyFactory; private readonly dir; parentForm: NgForm; parentFormGroup: FormGroupDirective; private readonly parentFormField; ngControl: NgControl; private localeService?; protected readonly isBrowser: boolean; private readonly useLegacyValidation; private readonly defaultOptions; /** Whether the component is in an error state. */ errorState: boolean; /** * Emits whenever the component state changes and should cause the parent * form-field to update. Implemented as part of `KbqFormFieldControl`. * @docs-private */ readonly stateChanges: Subject; /** A name for this control that can be used by `kbq-form-field`. */ controlType: string; hiddenItems: number; /** The last measured value for the trigger's client bounding rect. */ triggerRect: DOMRect; /** The cached font-size of the trigger element. */ triggerFontSize: number; /** Deals with the selection logic. */ selectionModel: SelectionModel; /** The value of the select panel's transform-origin property. */ transformOrigin: string; /** Emits when the panel element is finished transforming in. */ panelDoneAnimatingStream: Subject; /** Strategy that will be used to handle scrolling while the select panel is open. */ scrollStrategy: any; /** * The y-offset of the overlay panel in relation to the trigger's top start corner. * This must be adjusted to align the selected option text over the trigger text. * when the panel opens. Will change based on the y-position of the selected option. */ offsetY: number; /** * This position config ensures that the top "start" corner of the overlay * is aligned with with the top "start" of the origin by default (overlapping * the trigger completely). If the panel cannot fit below the trigger, it * will fall back to a position above the trigger. */ positions: ConnectedPosition[]; options: QueryList; /** * Trigger - is a clickable field to open select dropdown panel */ trigger: ElementRef; panel: ElementRef; overlayDir: CdkConnectedOverlay; tags: QueryList; cleaner: KbqCleaner; /** User-supplied override of the trigger element. */ customTrigger: KbqSelectTrigger; customMatcher: KbqSelectMatcher; customTagTemplateRef: TemplateRef; tree: KbqTreeSelection; search: KbqSelectSearch; hiddenItemsText: string; /** Event emitted when the select panel has been toggled. */ readonly openedChange: EventEmitter; /** Event emitted when the select has been opened. */ readonly openedStream: Observable; /** Event emitted when the select has been closed. */ readonly closedStream: Observable; /** Event emitted when the selected value has been changed by the user. */ readonly selectionChange: EventEmitter; /** * Event that emits whenever the raw value of the select changes. This is here primarily * to facilitate the two-way binding for the `value` input. * @docs-private */ readonly valueChange: EventEmitter; /** Classes to be passed to the select panel. Supports the same syntax as `ngClass`. */ panelClass: string | string[] | Set | { [key: string]: any; }; backdropClass: string; /** Object used to control when error messages are shown. */ errorStateMatcher: ErrorStateMatcher; /** * Function used to sort the values in a select in multiple mode. * Follows the same logic as `Array.prototype.sort`. */ sortComparator: (a: KbqTreeOption, b: KbqTreeOption, options: KbqTreeOption[]) => number; /** * Whether to use a multiline matcher or not. Default is false */ multiline: boolean; /** Combined stream of all of the child options' change events. */ readonly optionSelectionChanges: Observable; /** Combined stream of all of the child options userInteraction events. */ readonly userInteractionChanges: Observable; get placeholder(): string; set placeholder(value: string); private _placeholder; get required(): boolean; set required(value: boolean); private _required; get multiple(): boolean; set multiple(value: boolean); private _multiple; get autoSelect(): boolean; set autoSelect(value: boolean); private _autoSelect; get value(): any; get id(): string; set id(value: string); private _id; get hasBackdrop(): boolean; set hasBackdrop(value: boolean); private _hasBackdrop; get tabIndex(): number | null; set tabIndex(value: number | null); private _tabIndex; get disabled(): boolean; set disabled(value: boolean); private _disabled; /** * Function for handling the combination Ctrl + A (select all). By default, the internal handler is used. */ get selectAllHandler(): (event: KeyboardEvent, select: KbqTreeSelect) => void; set selectAllHandler(fn: (event: KeyboardEvent, select: KbqTreeSelect) => void); /** Function for handling the combination Ctrl + A (select all). By default, the internal handler is used. */ private _selectAllHandler; /** Whether the select is focused. */ get focused(): boolean; set focused(value: boolean); /** Whether multiple choice is enabled or not. True if multiple or multiline */ get multiSelection(): boolean; private _focused; /** Width of the overlay panel. */ protected overlayWidth: string | number; /** Min width of the overlay panel. */ protected overlayMinWidth: string | number; /** * Minimum width of the panel. * If minWidth is larger than window width, it will be ignored. */ panelMinWidth: Exclude; /** Origin for the overlay panel. */ protected overlayOrigin?: CdkOverlayOrigin | ElementRef; /** * Width of the panel. If set to `auto`, the panel will match the trigger width. * If set to null or an empty string, the panel will grow to match the longest option's text. */ panelWidth: KbqTreeSelectPanelWidth; /** * Controls when the search functionality is displayed based on the number of available options. * * Automatically enables search hiding if value provided, even if `defaultOptions.searchMinOptionsThreshold` is provided. * @default undefined */ set searchMinOptionsThreshold(value: 'auto' | number | undefined); get searchMinOptionsThreshold(): number | undefined; private _searchMinOptionsThreshold; get panelOpen(): boolean; get canShowCleaner(): boolean; /** @docs-private */ get colorForState(): KbqComponentColors; isEmptySearchResult: boolean; triggerValues: KbqTreeSelectTriggerValue[]; private closeSubscription; private _panelOpen; private originalOnKeyDown; /** The scroll position of the overlay panel, calculated to center the selected option. */ private scrollTop; /** Unique id for this input. */ private readonly uid; private tempValues; private readonly destroyRef; private readonly window; constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, renderer: Renderer2, defaultErrorStateMatcher: ErrorStateMatcher, scrollStrategyFactory: any, dir: Directionality, parentForm: NgForm, parentFormGroup: FormGroupDirective, parentFormField: KbqFormField, ngControl: NgControl, localeService?: KbqLocaleService | undefined); ngOnInit(): void; ngDoCheck(): void; ngAfterContentInit(): void; ngAfterViewInit(): void; ngOnDestroy(): void; updateErrorState(): void; hiddenItemsTextFormatter(hiddenItemsText: string, hiddenItems: number): string; clearValue($event: any): void; /** `View -> model callback called when value changes` */ onChange: (value: any) => void; /** `View -> model callback called when select has been touched` */ onTouched: () => void; handleClick(): void; toggle(): void; open(): void; /** Closes the overlay panel and focuses the host element. */ close(): void; /** * Sets the select's value. Part of the ControlValueAccessor interface * required to integrate with Angular's core forms API. * * @param value New value to be written to the model. */ 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; /** * Disables the select. Part of the ControlValueAccessor interface required * to integrate with Angular's core forms API. * * @param isDisabled Sets whether the component is disabled. */ setDisabledState(isDisabled: boolean): void; get selected(): any; get selectedValues(): any; get triggerValue(): string; get empty(): boolean; isRtl(): boolean; get firstSelected(): any; handleKeydown(event: KeyboardEvent): void; onFocus(): void; /** * Calls the touched callback only if the panel is closed. Otherwise, the trigger will * "blur" to the panel when it opens, causing a false positive. */ onBlur(): void; /** Callback that is invoked when the overlay panel has been attached. */ onAttached(): void; /** Returns the theme to be used on the panel. */ getPanelTheme(): string; focus(): void; /** * Implemented as part of KbqFormFieldControl. * @docs-private */ onContainerClick(): void; /** Invoked when an option is clicked. */ onRemoveSelectedOption(selectedOption: any, $event: any): void; calculateHiddenItems: () => void; triggerKeydownHandler(event: KeyboardEvent): void; panelKeydownHandler(event: KeyboardEvent): any; /** @docs-private */ protected shouldShowSearch(): boolean; private updateLocaleParams; private closingActions; private getTotalItemsWidthInMatcher; private getTotalVisibleItems; /** Gets how wide the overlay panel should be. */ private getOverlayWidth; private buildTriggerClone; private getItemWidth; private refreshTriggerValues; /** * 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 initKeyManager; /** Sorts the selected values in the selected based on their order in the panel. */ private sortValues; /** * Highlights the selected item. If no option is selected, it will highlight * the first item instead. */ private highlightCorrectOption; /** Scrolls the active option into view. */ private scrollActiveOptionIntoView; private subscribeOnSearchChanges; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_multiline: unknown; static ngAcceptInputType_multiple: unknown; static ngAcceptInputType_disabled: unknown; static ngAcceptInputType_panelMinWidth: unknown; }