@angular-mdc/web
Version:
94 lines (93 loc) • 4.16 kB
TypeScript
import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, OnDestroy, QueryList } from '@angular/core';
import { ControlValueAccessor, FormGroupDirective, NgControl, NgForm } from '@angular/forms';
import { Observable } from 'rxjs';
import { MDCComponent } from '@angular-mdc/web/base';
import { MdcChipInteractionEvent, MdcChipNavigationEvent, MdcChipSelectionEvent, MdcChipRemovalEvent } from './types';
import { MdcChip } from './chip';
import { MDCChipSetFoundation } from '@material/chips';
export declare class MdcChipSetChange {
source: MdcChipSet;
value: any;
constructor(source: MdcChipSet, value: any);
}
export declare class MdcChipSet extends MDCComponent<MDCChipSetFoundation> implements AfterContentInit, OnDestroy, ControlValueAccessor {
private _changeDetectorRef;
elementRef: ElementRef<HTMLElement>;
ngControl: NgControl;
/** Emits whenever the component is destroyed. */
private _destroyed;
/**
* Indicates that the chips in the set are choice chips, which allow a single selection from a set of options.
*/
get choice(): boolean;
set choice(value: boolean);
private _choice;
/**
* Indicates that the chips in the set are filter chips, which allow multiple selection from a set of options.
*/
get filter(): boolean;
set filter(value: boolean);
private _filter;
/**
* Indicates that the chips in the set are input chips, which enable user input by converting text into chips.
*/
get input(): boolean;
set input(value: boolean);
private _input;
get value(): string | string[] | undefined;
set value(value: string | string[] | undefined);
private _value?;
/**
* A function to compare the option values with the selected values. The first argument
* is a value from an option. The second is a value from the selection. A boolean
* should be returned.
*/
private _compareWith;
readonly change: EventEmitter<MdcChipSetChange>;
readonly interaction: EventEmitter<MdcChipInteractionEvent>;
chips: QueryList<MdcChip>;
/** Function when touched */
_onTouched: () => void;
/** Function when changed */
_onChange: (value: any) => void;
/** Subscription to selection events in chips. */
private _chipSelectionSubscription;
/** Subscription to removal changes. */
private _chipRemovalSubscription;
/** Subscription to interaction events in chips. */
private _chipInteractionSubscription;
/** Subscription to navigation events. */
private _navigationSubscription;
/** Combined stream of all of the chip selection events. */
get chipSelections(): Observable<MdcChipSelectionEvent>;
/** Combined stream of all of the chip interaction events. */
get chipInteractions(): Observable<MdcChipInteractionEvent>;
/** Combined stream of all of the chip removal events. */
get chipRemovalChanges(): Observable<MdcChipRemovalEvent>;
/** Combined stream of all of the chip navigation events. */
get chipNavigations(): Observable<MdcChipNavigationEvent>;
getDefaultFoundation(): MDCChipSetFoundation;
constructor(_changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef<HTMLElement>, _parentForm: NgForm, _parentFormGroup: FormGroupDirective, ngControl: NgControl);
ngAfterContentInit(): void;
ngOnDestroy(): void;
writeValue(value: any): void;
registerOnChange(fn: (value: any) => void): void;
registerOnTouched(fn: () => void): void;
getSelectedChipIds(): ReadonlyArray<string>;
select(chipId: string): void;
selectByValue(value: string | string[] | undefined, shouldIgnore?: boolean): void;
/**
* Finds and selects the chip based on its value.
* @returns Chip that has the corresponding value.
*/
private _selectValue;
private _initializeSelection;
private _propagateChanges;
private _findChipIndex;
private _resetChipSet;
private _dropSubscriptions;
/** Listens to selected events on each chip. */
private _listenToChipEvents;
/** Retrieves the DOM element of the component host. */
private _getHostElement;
}