import { Highlightable } from '@angular/cdk/a11y'; import { AfterContentInit, AfterViewChecked, ChangeDetectorRef, ElementRef, EventEmitter, InjectionToken, NgZone, OnDestroy, QueryList, TemplateRef } from '@angular/core'; import { NgModel } from '@angular/forms'; import { TsStyleThemeTypes } from '@terminus/ui/utilities'; import { Subject } from 'rxjs'; import { TsOptionDisplayDirective } from './option-display.directive'; export interface TsOption { isDisabled?: boolean; children?: TsOption[]; } /** * Event object emitted by {@link TsOptionComponent} when selected or deselected */ export declare class TsOptionSelectionChange { source: TsOptionComponent; isUserInput: boolean; constructor(source: TsOptionComponent, isUserInput?: boolean); } /** * Describes a parent component that manages a list of options. * * Contains properties that the options can inherit. Used by {@link TS_OPTION_PARENT_COMPONENT} */ export interface TsOptionParentComponent { componentName: string; allowMultiple: boolean; theme: TsStyleThemeTypes; ngControl?: NgModel; } /** * Injection token used to provide the parent component to options. Used by {@link TsOptionComponent} * * Since TsSelectionListComponent imports TsOptionComponent, importing TsSelectionListComponent here will cause a circular dependency. * Injecting via an InjectionToken helps us circumvent that limitation. */ export declare const TS_OPTION_PARENT_COMPONENT: InjectionToken; /** * Describes a parent optgroup component. Used by {@link TS_OPTGROUP_PARENT_COMPONENT} */ export interface TsOptgroupParentComponent { optgroupOptions: QueryList; isDisabled: boolean; triggerChangeDetection: Function; } /** * Injection token used to provide the parent optgroup to options. Used by {@link TsOptgroupComponent} */ export declare const TS_OPTGROUP_PARENT_COMPONENT: InjectionToken; /** * Single option inside of a {@link TsSelectionListComponent} * * @example * * * https://getterminus.github.io/ui-demos-release/components/selection-list */ export declare class TsOptionComponent implements Highlightable, AfterContentInit, AfterViewChecked, OnDestroy { elementRef: ElementRef; private changeDetectorRef; private ngZone; private parent; readonly group: TsOptgroupParentComponent; /** * Store the most recent view value */ private mostRecentViewValue; /** * Emits when the state of the option changes and any parents have to be notified */ readonly stateChanges: Subject; /** * Store the text for the title attribute */ title: string; /** * Define the default component ID */ protected uid: string; /** * Define the active state */ active: boolean; /** * Whether the wrapping component is in multiple selection mode */ get allowMultiple(): boolean; /** * Whether or not the option is currently selected */ selected: boolean; /** * Whether parent component is an autocomplete component */ autocompleteComponent: boolean; /** * Whether parent component is an autocomplete component */ selectComponent: boolean; /** * Returns the correct tabindex for the option depending on the disabled state */ get tabIndex(): string; /** * Gets the host DOM element */ get hostElement(): HTMLElement; /** * The displayed value of the option. * * It is necessary to show the selected option in the {@link TsSelectComponent} trigger. */ get viewValue(): string; /** * Optional template passed in by the consumer */ optionTemplate: TemplateRef | undefined; /** * Access the user-defined text content */ displayElementRef: TsOptionDisplayDirective | undefined; /** * Define an ID for the component * * @param value */ set id(value: string); get id(): string; protected _id: string; /** * Whether the option is disabled * * @param value */ set isDisabled(value: boolean); get isDisabled(): boolean; private _isDisabled; /** * Define the option data object (needed for template support) * * @param value */ set option(value: TsOption | undefined); get option(): TsOption | undefined; private _option; /** * The form value of the option */ value: any; /** * Event emitted when the option is selected or deselected */ readonly selectionChange: EventEmitter; constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, parent: TsOptionParentComponent, group: TsOptgroupParentComponent); /** * If the user is trying to use a template without passing in data, alert the dev */ ngAfterContentInit(): void; /** * Trigger state changes if the view value has changed */ ngAfterViewChecked(): void; /** * Complete observables */ ngOnDestroy(): void; /** * Return the view value * * Used by `ListKeyManagerOption` */ getLabel(): string; /** * Deselect the option */ deselect(): void; /** * Ensure the option is selected when activated from the keyboard * * @param event */ handleKeydown(event: KeyboardEvent): void; /** * Select the option */ select(): void; /** * Selects the option while indicating the selection came from the user. * * Used to determine if the select's view -> model callback should be invoked. */ selectViaInteraction(): void; /** * This method sets display styles on the option to make it appear active. This is used by the ActiveDescendantKeyManager so key events * will display the proper options as active on arrow key events. */ setActiveStyles(): void; /** * This method removes display styles on the option that made it appear active. This is used by the ActiveDescendantKeyManager so key * events will display the proper options as active on arrow key events. */ setInactiveStyles(): void; /** * Emit the selection change event * * @param isUserInput */ private emitSelectionChangeEvent; }