import { FocusableOption } from '@angular/cdk/a11y'; import { ElementRef, EventEmitter, NgZone, OnDestroy } from '@angular/core'; import { TsDocumentService } from '@terminus/ngx-tools/browser'; import { TsStyleThemeTypes } from '@terminus/ui/utilities'; import { Subject } from 'rxjs'; /** * Represents an event fired on an individual {@link TsChipComponent} */ export declare class TsChipEvent { chip: TsChipComponent; constructor(chip: TsChipComponent); } /** * Represents an event fired when clicking an individual {@link TsChipComponent} */ export declare class TsChipClickEvent { chip: TsChipComponent; constructor(chip: TsChipComponent, event: MouseEvent); } /** * Event object emitted by {@link TsChipComponent} when selected or deselected */ export declare class TsChipSelectionChange { source: TsChipComponent; selected: boolean; constructor(source: TsChipComponent, selected: boolean); } /** * A presentational component to render a chip * * @example * * * https://getterminus.github.io/ui-demos-release/components/chip */ export declare class TsChipComponent implements FocusableOption, OnDestroy { elementRef: ElementRef; private ngZone; private documentService; /** * Define if multiple chips are allowed * * Used by the {@link TsAutocompleteComponent} consumer * * @param value */ set allowMultiple(value: boolean); get allowMultiple(): boolean; private _allowMultiple; /** * Define the default component ID */ protected uid: string; /** * Emits when the chip is focused * * @internal */ readonly onFocus: Subject; /** * Whether the chip has focus * * @internal */ hasFocus: boolean; /** * Whether the chip collection is selectable * * @internal */ chipCollectionSelectable: boolean; /** * Whether the chip collection allows chip removable * * @internal */ chipCollectionRemovable: boolean; /** * Whether the chip collection is in multi-selection mode. * * @internal */ chipCollectionMultiple: boolean; /** * The ARIA selected applied to the chip. * * @internal */ get ariaSelected(): string | null; /** * Access to container for chip contents */ private content; /** * Define an ID for the component * * @param value */ set id(value: string); get id(): string; private _id; /** * Define if the chip should be disabled */ isDisabled: boolean; /** * Define if the chip allows focus */ isFocusable: boolean; /** * Define if the chip is removable */ isRemovable: boolean; /** * Whether or not the chip is selectable. * * By default a chip is selectable, and it becomes non-selectable if its parent chip collection is not selectable. * * @param value */ set isSelectable(value: boolean); get isSelectable(): boolean; private _selectable; /** * Define if the chip is selected * * @param value */ set selected(value: boolean); get selected(): boolean; protected _selected: boolean; /** * Define the value of the chip * * Falls back to the DOM content if not set. * * @param value */ set value(value: string | undefined); get value(): string | undefined; private _value; /** * Define the theme for a chip * * @param value */ set theme(value: TsStyleThemeTypes); get theme(): TsStyleThemeTypes; private _theme; /** * Emitted when the chip is clicked */ readonly clicked: EventEmitter; /** * Emitted when the chip is destroyed. */ readonly destroyed: EventEmitter; /** * Emitted when the chip is blurred */ readonly blurred: EventEmitter; /** * Emitted when the chip is to be removed */ readonly remove: EventEmitter; /** * Emitted when the chip is selected or deselected */ readonly selectionChange: EventEmitter; constructor(elementRef: ElementRef, ngZone: NgZone, documentService: TsDocumentService); /** * Alert consumers about destruction */ ngOnDestroy(): void; /** * Emit the 'clicked' event * * @internal * @param event */ click(event: MouseEvent): void; /** * Select the chip */ select(): void; /** * Deselect the chip */ deselect(): void; /** * Toggles the current selected state of this chip. */ toggleSelected(): boolean; /** * Allows for programmatic focusing of the chip. */ focus(): void; /** * Allows for programmatic removal of the chip. Called by the {@link TsChipCollectionComponent} when the DELETE or BACKSPACE keys are * pressed. * * Informs any listeners of the removal request. Does not remove the chip from the DOM. * * @param event */ removeChip(event?: MouseEvent | KeyboardEvent): void; /** * Handles click events on the chip. * * @internal * @param event - click event */ handleClick(event: MouseEvent): void; /** * Handle custom key presses. * * @internal * @param event - keyboard event */ handleKeydown(event: KeyboardEvent): void; /** * Defer marking the chip as not focused until the next time the zone stabilizes. */ handleBlur(): void; /** * When selection change action dispatched, emit selectionChange eventEmitter. */ private dispatchSelectionChange; }