[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import { FocusKeyManager } from '@angular/cdk/a11y';
|
---|
| 9 | import { Directionality } from '@angular/cdk/bidi';
|
---|
| 10 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
| 11 | import { SelectionModel } from '@angular/cdk/collections';
|
---|
| 12 | import { AfterContentInit, ChangeDetectorRef, DoCheck, ElementRef, EventEmitter, OnDestroy, OnInit, QueryList } from '@angular/core';
|
---|
| 13 | import { ControlValueAccessor, FormGroupDirective, NgControl, NgForm } from '@angular/forms';
|
---|
| 14 | import { CanUpdateErrorState, ErrorStateMatcher } from '@angular/material/core';
|
---|
| 15 | import { MatFormFieldControl } from '@angular/material/form-field';
|
---|
| 16 | import { Observable } from 'rxjs';
|
---|
| 17 | import { MatChip, MatChipEvent, MatChipSelectionChange } from './chip';
|
---|
| 18 | import { MatChipTextControl } from './chip-text-control';
|
---|
| 19 | /** @docs-private */
|
---|
| 20 | declare const _MatChipListBase: import("@angular/material/core/common-behaviors/constructor").Constructor<CanUpdateErrorState> & import("@angular/material/core/common-behaviors/constructor").AbstractConstructor<CanUpdateErrorState> & {
|
---|
| 21 | new (_defaultErrorStateMatcher: ErrorStateMatcher, _parentForm: NgForm, _parentFormGroup: FormGroupDirective, ngControl: NgControl): {
|
---|
| 22 | _defaultErrorStateMatcher: ErrorStateMatcher;
|
---|
| 23 | _parentForm: NgForm;
|
---|
| 24 | _parentFormGroup: FormGroupDirective;
|
---|
| 25 | /** @docs-private */
|
---|
| 26 | ngControl: NgControl;
|
---|
| 27 | };
|
---|
| 28 | };
|
---|
| 29 | /** Change event object that is emitted when the chip list value has changed. */
|
---|
| 30 | export declare class MatChipListChange {
|
---|
| 31 | /** Chip list that emitted the event. */
|
---|
| 32 | source: MatChipList;
|
---|
| 33 | /** Value of the chip list when the event was emitted. */
|
---|
| 34 | value: any;
|
---|
| 35 | constructor(
|
---|
| 36 | /** Chip list that emitted the event. */
|
---|
| 37 | source: MatChipList,
|
---|
| 38 | /** Value of the chip list when the event was emitted. */
|
---|
| 39 | value: any);
|
---|
| 40 | }
|
---|
| 41 | /**
|
---|
| 42 | * A material design chips component (named ChipList for its similarity to the List component).
|
---|
| 43 | */
|
---|
| 44 | export declare class MatChipList extends _MatChipListBase implements MatFormFieldControl<any>, ControlValueAccessor, AfterContentInit, DoCheck, OnInit, OnDestroy, CanUpdateErrorState {
|
---|
| 45 | protected _elementRef: ElementRef<HTMLElement>;
|
---|
| 46 | private _changeDetectorRef;
|
---|
| 47 | private _dir;
|
---|
| 48 | /**
|
---|
| 49 | * Implemented as part of MatFormFieldControl.
|
---|
| 50 | * @docs-private
|
---|
| 51 | */
|
---|
| 52 | readonly controlType: string;
|
---|
| 53 | /**
|
---|
| 54 | * When a chip is destroyed, we store the index of the destroyed chip until the chips
|
---|
| 55 | * query list notifies about the update. This is necessary because we cannot determine an
|
---|
| 56 | * appropriate chip that should receive focus until the array of chips updated completely.
|
---|
| 57 | */
|
---|
| 58 | private _lastDestroyedChipIndex;
|
---|
| 59 | /** Subject that emits when the component has been destroyed. */
|
---|
| 60 | private readonly _destroyed;
|
---|
| 61 | /** Subscription to focus changes in the chips. */
|
---|
| 62 | private _chipFocusSubscription;
|
---|
| 63 | /** Subscription to blur changes in the chips. */
|
---|
| 64 | private _chipBlurSubscription;
|
---|
| 65 | /** Subscription to selection changes in chips. */
|
---|
| 66 | private _chipSelectionSubscription;
|
---|
| 67 | /** Subscription to remove changes in chips. */
|
---|
| 68 | private _chipRemoveSubscription;
|
---|
| 69 | /** The chip input to add more chips */
|
---|
| 70 | protected _chipInput: MatChipTextControl;
|
---|
| 71 | /** Uid of the chip list */
|
---|
| 72 | _uid: string;
|
---|
| 73 | /** The aria-describedby attribute on the chip list for improved a11y. */
|
---|
| 74 | _ariaDescribedby: string;
|
---|
| 75 | /** Tab index for the chip list. */
|
---|
| 76 | _tabIndex: number;
|
---|
| 77 | /**
|
---|
| 78 | * User defined tab index.
|
---|
| 79 | * When it is not null, use user defined tab index. Otherwise use _tabIndex
|
---|
| 80 | */
|
---|
| 81 | _userTabIndex: number | null;
|
---|
| 82 | /** The FocusKeyManager which handles focus. */
|
---|
| 83 | _keyManager: FocusKeyManager<MatChip>;
|
---|
| 84 | /** Function when touched */
|
---|
| 85 | _onTouched: () => void;
|
---|
| 86 | /** Function when changed */
|
---|
| 87 | _onChange: (value: any) => void;
|
---|
| 88 | _selectionModel: SelectionModel<MatChip>;
|
---|
| 89 | /** The array of selected chips inside chip list. */
|
---|
| 90 | get selected(): MatChip[] | MatChip;
|
---|
| 91 | /** The ARIA role applied to the chip list. */
|
---|
| 92 | get role(): string | null;
|
---|
| 93 | /** An object used to control when error messages are shown. */
|
---|
| 94 | errorStateMatcher: ErrorStateMatcher;
|
---|
| 95 | /** Whether the user should be allowed to select multiple chips. */
|
---|
| 96 | get multiple(): boolean;
|
---|
| 97 | set multiple(value: boolean);
|
---|
| 98 | private _multiple;
|
---|
| 99 | /**
|
---|
| 100 | * A function to compare the option values with the selected values. The first argument
|
---|
| 101 | * is a value from an option. The second is a value from the selection. A boolean
|
---|
| 102 | * should be returned.
|
---|
| 103 | */
|
---|
| 104 | get compareWith(): (o1: any, o2: any) => boolean;
|
---|
| 105 | set compareWith(fn: (o1: any, o2: any) => boolean);
|
---|
| 106 | private _compareWith;
|
---|
| 107 | /**
|
---|
| 108 | * Implemented as part of MatFormFieldControl.
|
---|
| 109 | * @docs-private
|
---|
| 110 | */
|
---|
| 111 | get value(): any;
|
---|
| 112 | set value(value: any);
|
---|
| 113 | protected _value: any;
|
---|
| 114 | /**
|
---|
| 115 | * Implemented as part of MatFormFieldControl.
|
---|
| 116 | * @docs-private
|
---|
| 117 | */
|
---|
| 118 | get id(): string;
|
---|
| 119 | /**
|
---|
| 120 | * Implemented as part of MatFormFieldControl.
|
---|
| 121 | * @docs-private
|
---|
| 122 | */
|
---|
| 123 | get required(): boolean;
|
---|
| 124 | set required(value: boolean);
|
---|
| 125 | protected _required: boolean;
|
---|
| 126 | /**
|
---|
| 127 | * Implemented as part of MatFormFieldControl.
|
---|
| 128 | * @docs-private
|
---|
| 129 | */
|
---|
| 130 | get placeholder(): string;
|
---|
| 131 | set placeholder(value: string);
|
---|
| 132 | protected _placeholder: string;
|
---|
| 133 | /** Whether any chips or the matChipInput inside of this chip-list has focus. */
|
---|
| 134 | get focused(): boolean;
|
---|
| 135 | /**
|
---|
| 136 | * Implemented as part of MatFormFieldControl.
|
---|
| 137 | * @docs-private
|
---|
| 138 | */
|
---|
| 139 | get empty(): boolean;
|
---|
| 140 | /**
|
---|
| 141 | * Implemented as part of MatFormFieldControl.
|
---|
| 142 | * @docs-private
|
---|
| 143 | */
|
---|
| 144 | get shouldLabelFloat(): boolean;
|
---|
| 145 | /**
|
---|
| 146 | * Implemented as part of MatFormFieldControl.
|
---|
| 147 | * @docs-private
|
---|
| 148 | */
|
---|
| 149 | get disabled(): boolean;
|
---|
| 150 | set disabled(value: boolean);
|
---|
| 151 | protected _disabled: boolean;
|
---|
| 152 | /** Orientation of the chip list. */
|
---|
| 153 | ariaOrientation: 'horizontal' | 'vertical';
|
---|
| 154 | /**
|
---|
| 155 | * Whether or not this chip list is selectable. When a chip list is not selectable,
|
---|
| 156 | * the selected states for all the chips inside the chip list are always ignored.
|
---|
| 157 | */
|
---|
| 158 | get selectable(): boolean;
|
---|
| 159 | set selectable(value: boolean);
|
---|
| 160 | protected _selectable: boolean;
|
---|
| 161 | set tabIndex(value: number);
|
---|
| 162 | /** Combined stream of all of the child chips' selection change events. */
|
---|
| 163 | get chipSelectionChanges(): Observable<MatChipSelectionChange>;
|
---|
| 164 | /** Combined stream of all of the child chips' focus change events. */
|
---|
| 165 | get chipFocusChanges(): Observable<MatChipEvent>;
|
---|
| 166 | /** Combined stream of all of the child chips' blur change events. */
|
---|
| 167 | get chipBlurChanges(): Observable<MatChipEvent>;
|
---|
| 168 | /** Combined stream of all of the child chips' remove change events. */
|
---|
| 169 | get chipRemoveChanges(): Observable<MatChipEvent>;
|
---|
| 170 | /** Event emitted when the selected chip list value has been changed by the user. */
|
---|
| 171 | readonly change: EventEmitter<MatChipListChange>;
|
---|
| 172 | /**
|
---|
| 173 | * Event that emits whenever the raw value of the chip-list changes. This is here primarily
|
---|
| 174 | * to facilitate the two-way binding for the `value` input.
|
---|
| 175 | * @docs-private
|
---|
| 176 | */
|
---|
| 177 | readonly valueChange: EventEmitter<any>;
|
---|
| 178 | /** The chip components contained within this chip list. */
|
---|
| 179 | chips: QueryList<MatChip>;
|
---|
| 180 | constructor(_elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, _dir: Directionality, _parentForm: NgForm, _parentFormGroup: FormGroupDirective, _defaultErrorStateMatcher: ErrorStateMatcher, ngControl: NgControl);
|
---|
| 181 | ngAfterContentInit(): void;
|
---|
| 182 | ngOnInit(): void;
|
---|
| 183 | ngDoCheck(): void;
|
---|
| 184 | ngOnDestroy(): void;
|
---|
| 185 | /** Associates an HTML input element with this chip list. */
|
---|
| 186 | registerInput(inputElement: MatChipTextControl): void;
|
---|
| 187 | /**
|
---|
| 188 | * Implemented as part of MatFormFieldControl.
|
---|
| 189 | * @docs-private
|
---|
| 190 | */
|
---|
| 191 | setDescribedByIds(ids: string[]): void;
|
---|
| 192 | writeValue(value: any): void;
|
---|
| 193 | registerOnChange(fn: (value: any) => void): void;
|
---|
| 194 | registerOnTouched(fn: () => void): void;
|
---|
| 195 | setDisabledState(isDisabled: boolean): void;
|
---|
| 196 | /**
|
---|
| 197 | * Implemented as part of MatFormFieldControl.
|
---|
| 198 | * @docs-private
|
---|
| 199 | */
|
---|
| 200 | onContainerClick(event: MouseEvent): void;
|
---|
| 201 | /**
|
---|
| 202 | * Focuses the first non-disabled chip in this chip list, or the associated input when there
|
---|
| 203 | * are no eligible chips.
|
---|
| 204 | */
|
---|
| 205 | focus(options?: FocusOptions): void;
|
---|
| 206 | /** Attempt to focus an input if we have one. */
|
---|
| 207 | _focusInput(options?: FocusOptions): void;
|
---|
| 208 | /**
|
---|
| 209 | * Pass events to the keyboard manager. Available here for tests.
|
---|
| 210 | */
|
---|
| 211 | _keydown(event: KeyboardEvent): void;
|
---|
| 212 | /**
|
---|
| 213 | * Check the tab index as you should not be allowed to focus an empty list.
|
---|
| 214 | */
|
---|
| 215 | protected _updateTabIndex(): void;
|
---|
| 216 | /**
|
---|
| 217 | * If the amount of chips changed, we need to update the
|
---|
| 218 | * key manager state and focus the next closest chip.
|
---|
| 219 | */
|
---|
| 220 | protected _updateFocusForDestroyedChips(): void;
|
---|
| 221 | /**
|
---|
| 222 | * Utility to ensure all indexes are valid.
|
---|
| 223 | *
|
---|
| 224 | * @param index The index to be checked.
|
---|
| 225 | * @returns True if the index is valid for our list of chips.
|
---|
| 226 | */
|
---|
| 227 | private _isValidIndex;
|
---|
| 228 | _setSelectionByValue(value: any, isUserInput?: boolean): void;
|
---|
| 229 | /**
|
---|
| 230 | * Finds and selects the chip based on its value.
|
---|
| 231 | * @returns Chip that has the corresponding value.
|
---|
| 232 | */
|
---|
| 233 | private _selectValue;
|
---|
| 234 | private _initializeSelection;
|
---|
| 235 | /**
|
---|
| 236 | * Deselects every chip in the list.
|
---|
| 237 | * @param skip Chip that should not be deselected.
|
---|
| 238 | */
|
---|
| 239 | private _clearSelection;
|
---|
| 240 | /**
|
---|
| 241 | * Sorts the model values, ensuring that they keep the same
|
---|
| 242 | * order that they have in the panel.
|
---|
| 243 | */
|
---|
| 244 | private _sortValues;
|
---|
| 245 | /** Emits change event to set the model value. */
|
---|
| 246 | private _propagateChanges;
|
---|
| 247 | /** When blurred, mark the field as touched when focus moved outside the chip list. */
|
---|
| 248 | _blur(): void;
|
---|
| 249 | /** Mark the field as touched */
|
---|
| 250 | _markAsTouched(): void;
|
---|
| 251 | /**
|
---|
| 252 | * Removes the `tabindex` from the chip list and resets it back afterwards, allowing the
|
---|
| 253 | * user to tab out of it. This prevents the list from capturing focus and redirecting
|
---|
| 254 | * it back to the first chip, creating a focus trap, if it user tries to tab away.
|
---|
| 255 | */
|
---|
| 256 | _allowFocusEscape(): void;
|
---|
| 257 | private _resetChips;
|
---|
| 258 | private _dropSubscriptions;
|
---|
| 259 | /** Listens to user-generated selection events on each chip. */
|
---|
| 260 | private _listenToChipsSelection;
|
---|
| 261 | /** Listens to user-generated selection events on each chip. */
|
---|
| 262 | private _listenToChipsFocus;
|
---|
| 263 | private _listenToChipsRemoved;
|
---|
| 264 | /** Checks whether an event comes from inside a chip element. */
|
---|
| 265 | private _originatesFromChip;
|
---|
| 266 | /** Checks whether any of the chips is focused. */
|
---|
| 267 | private _hasFocusedChip;
|
---|
| 268 | /** Syncs the list's state with the individual chips. */
|
---|
| 269 | private _syncChipsState;
|
---|
| 270 | static ngAcceptInputType_multiple: BooleanInput;
|
---|
| 271 | static ngAcceptInputType_required: BooleanInput;
|
---|
| 272 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
| 273 | static ngAcceptInputType_selectable: BooleanInput;
|
---|
| 274 | }
|
---|
| 275 | export {};
|
---|