UNPKG

@nova-ui/bits

Version:

SolarWinds Nova Framework

139 lines (138 loc) 7.7 kB
import { LiveAnnouncer } from "@angular/cdk/a11y"; import { OverlayConfig } from "@angular/cdk/overlay"; import { CdkVirtualScrollViewport } from "@angular/cdk/scrolling"; import { AfterContentInit, AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, QueryList, SimpleChanges } from "@angular/core"; import { ControlValueAccessor } from "@angular/forms"; import { Observable, Subject } from "rxjs"; import { SelectV2OptionComponent } from "./option/select-v2-option.component"; import { OptionKeyControlService } from "./option-key-control.service"; import { InputValueTypes, IOptionedComponent } from "./types"; import { OverlayComponent } from "../overlay/overlay-component/overlay.component"; import { OverlayUtilitiesService } from "../overlay/overlay-utilities.service"; import { IOption, OptionValueType, OverlayContainerType } from "../overlay/types"; import * as i0 from "@angular/core"; export declare abstract class BaseSelectV2 implements AfterViewInit, AfterContentInit, ControlValueAccessor, IOptionedComponent, OnDestroy, OnChanges { protected optionKeyControlService: OptionKeyControlService<IOption>; protected cdRef: ChangeDetectorRef; elRef: ElementRef<HTMLElement>; liveAnnouncer: LiveAnnouncer; /** Value used as a placeholder for the select. */ placeholder: string; /** Sets margin in px for the Dropdown relatively the container where the Dropdown appended to */ popupViewportMargin: number; /** Sets the Overlay Config in accordance with [Material CDK]{@link https://material.angular.io/cdk/overlay/api#OverlayConfig} */ get overlayConfig(): OverlayConfig; set overlayConfig(value: OverlayConfig); private _overlayConfig; /** Whether the multi-select mode */ multiselect: boolean; /** Whether the Dropdown controls manually */ manualDropdownControl: boolean; /** Sets value of the Select/Combobox */ value: OptionValueType | OptionValueType[] | null; /** Sets custom container for CDK Overlay. Selector OR ElementRef */ dropdownCustomContainer: OverlayContainerType; /** Sets whether an overlay must sync it's width with the width of the toggle reference */ syncWidth: boolean; /** Whether the Select/Combobox disabled */ isDisabled: boolean; /** Input to apply error state styles */ isInErrorState: boolean; private allowedKeys; /** Input to set aria label text */ get ariaLabel(): string; set ariaLabel(value: string); /** Corresponds to the Textbox of the Combobox */ inputElement: ElementRef; cdkVirtualScroll: CdkVirtualScrollViewport; /** Corresponds to the Options listed in the Dropdown */ options: QueryList<SelectV2OptionComponent>; /** Corresponds to the All Items listed in the Dropdown */ allPopupItems: QueryList<IOption>; /** Gets options from the model */ get selectedOptions(): SelectV2OptionComponent[]; /** Sets options to the model */ set selectedOptions(options: SelectV2OptionComponent[]); /** Name of the icon which indicates open/close state of the Dropdown */ caretIcon: string; dropdown: OverlayComponent; protected popupUtilities: OverlayUtilitiesService; protected destroy$: Subject<void>; protected mouseDown: boolean; private _selectedOptions; private _ariaLabel; private virtualScrollResizeObserver; /** Emits value which has been selected */ valueSelected: EventEmitter<OptionValueType | OptionValueType[]>; /** Emits value which has been changed */ valueChanged: EventEmitter<InputValueTypes>; /** Emits MouseEvent when click occurs outside Select/Combobox */ clickOutsideDropdown: EventEmitter<MouseEvent>; protected constructor(optionKeyControlService: OptionKeyControlService<IOption>, cdRef: ChangeDetectorRef, elRef: ElementRef<HTMLElement>, liveAnnouncer: LiveAnnouncer); ngOnChanges(changes: SimpleChanges): void; ngAfterContentInit(): void; ngAfterViewInit(): void; /** `View -> model callback called when value changes` */ onChange: (value: any) => void; /** `View -> model callback called when autocomplete has been touched` */ onTouched: () => void; /** Handles mousedown event */ onMouseDown(): void; /** Handles mouseup event */ onMouseUp(target: HTMLElement): void; /** * Handles focusin event. * To avoid triggering showDropdown() on MouseClick. We need to open dropdown only on TAB (SHIFT + TAB) action. */ onFocusIn(): void; onWindowResize(): void; /** Handles keydown event */ onKeyDown(event: KeyboardEvent): void; /** Shows dropdown */ showDropdown(): void; /** Hides dropdown */ hideDropdown(): void; /** Toggles dropdown */ toggleDropdown(): void; /** Selects specific option and set its value to the model */ selectOption(option: SelectV2OptionComponent): void; /** Removes selected options or passed option if multi-select mode enabled */ removeSelected(option?: SelectV2OptionComponent): void; registerOnChange(fn: (value: any) => void): void; registerOnTouched(fn: any): void; /** Handles disabled state */ setDisabledState(isDisabled: boolean): void; /** Sets value to the model */ writeValue(value: OptionValueType | OptionValueType[]): void; /** Returns last selected Option */ getLastSelectedOption(): SelectV2OptionComponent | undefined; /** Returns state of the Dropdown */ get isDropdownOpen(): boolean; /** * Calls to ngOnDestroy do not automatically get propagated to base classes. * This can lead to memory leaks. * This is a safe guard for preventing memory leaks in derived classes. */ ngOnDestroy(): void; protected getValueFromOptions(options?: SelectV2OptionComponent[]): OptionValueType | OptionValueType[] | null; protected handleValueChange(value: OptionValueType | OptionValueType[] | null): void; protected optionsChanged(): Observable<QueryList<IOption>>; private validateValueWithSelectedOptions; private scrollToOption; private initKeyboardManager; private setActiveItemOnDropdown; private initClosingOnClicksOutside; private initOnTouch; private isAllowedKeyOnManualDropdown; private defineDropdownContainer; private initPopupUtilities; /** * This helps to dynamically set minHeight for overlay to avoid issues with double * scroll. Overlay minHeight should be bigger than cdkVirtualScroll container. */ private adjustDropdownOnVScrollResize; private isOpenOnFocus; private announceDropdown; static ɵfac: i0.ɵɵFactoryDeclaration<BaseSelectV2, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<BaseSelectV2, never, never, { "placeholder": { "alias": "placeholder"; "required": false; }; "popupViewportMargin": { "alias": "popupViewportMargin"; "required": false; }; "overlayConfig": { "alias": "overlayConfig"; "required": false; }; "multiselect": { "alias": "multiselect"; "required": false; }; "manualDropdownControl": { "alias": "manualDropdownControl"; "required": false; }; "value": { "alias": "value"; "required": false; }; "dropdownCustomContainer": { "alias": "dropdownCustomContainer"; "required": false; }; "syncWidth": { "alias": "syncWidth"; "required": false; }; "isDisabled": { "alias": "isDisabled"; "required": false; }; "isInErrorState": { "alias": "isInErrorState"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; }, { "valueSelected": "valueSelected"; "valueChanged": "valueChanged"; "clickOutsideDropdown": "clickOutsideDropdown"; }, ["cdkVirtualScroll", "options", "allPopupItems"], never, false, never>; }