1 | import { SPACE, BACKSPACE, DELETE, TAB, hasModifierKey, ENTER } from '@angular/cdk/keycodes';
|
2 | import * as i0 from '@angular/core';
|
3 | import { InjectionToken, Directive, EventEmitter, Optional, Inject, Attribute, ContentChild, Input, Output, Component, ViewEncapsulation, ChangeDetectionStrategy, Self, ContentChildren, NgModule } from '@angular/core';
|
4 | import * as i3 from '@angular/material/core';
|
5 | import { mixinTabIndex, mixinColor, mixinDisableRipple, RippleRenderer, MAT_RIPPLE_GLOBAL_OPTIONS, mixinErrorState, MatCommonModule, ErrorStateMatcher } from '@angular/material/core';
|
6 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
7 | import { DOCUMENT } from '@angular/common';
|
8 | import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
9 | import { Subject, merge } from 'rxjs';
|
10 | import { take, takeUntil, startWith } from 'rxjs/operators';
|
11 | import * as i1 from '@angular/cdk/platform';
|
12 | import { FocusKeyManager } from '@angular/cdk/a11y';
|
13 | import { SelectionModel } from '@angular/cdk/collections';
|
14 | import * as i2 from '@angular/forms';
|
15 | import { Validators } from '@angular/forms';
|
16 | import { MatFormFieldControl } from '@angular/material/form-field';
|
17 | import * as i1$1 from '@angular/cdk/bidi';
|
18 |
|
19 |
|
20 | class MatChipSelectionChange {
|
21 | constructor(
|
22 | /** Reference to the chip that emitted the event. */
|
23 | source,
|
24 | /** Whether the chip that emitted the event is selected. */
|
25 | selected,
|
26 | /** Whether the selection change was a result of a user interaction. */
|
27 | isUserInput = false) {
|
28 | this.source = source;
|
29 | this.selected = selected;
|
30 | this.isUserInput = isUserInput;
|
31 | }
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | const MAT_CHIP_REMOVE = new InjectionToken('MatChipRemove');
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | const MAT_CHIP_AVATAR = new InjectionToken('MatChipAvatar');
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | const MAT_CHIP_TRAILING_ICON = new InjectionToken('MatChipTrailingIcon');
|
51 |
|
52 |
|
53 | class MatChipBase {
|
54 | constructor(_elementRef) {
|
55 | this._elementRef = _elementRef;
|
56 | }
|
57 | }
|
58 | const _MatChipMixinBase = mixinTabIndex(mixinColor(mixinDisableRipple(MatChipBase), 'primary'), -1);
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | class MatChipAvatar {
|
64 | }
|
65 | MatChipAvatar.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipAvatar, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
66 | MatChipAvatar.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatChipAvatar, selector: "mat-chip-avatar, [matChipAvatar]", host: { classAttribute: "mat-chip-avatar" }, providers: [{ provide: MAT_CHIP_AVATAR, useExisting: MatChipAvatar }], ngImport: i0 });
|
67 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipAvatar, decorators: [{
|
68 | type: Directive,
|
69 | args: [{
|
70 | selector: 'mat-chip-avatar, [matChipAvatar]',
|
71 | host: { 'class': 'mat-chip-avatar' },
|
72 | providers: [{ provide: MAT_CHIP_AVATAR, useExisting: MatChipAvatar }],
|
73 | }]
|
74 | }] });
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | class MatChipTrailingIcon {
|
80 | }
|
81 | MatChipTrailingIcon.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipTrailingIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
82 | MatChipTrailingIcon.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatChipTrailingIcon, selector: "mat-chip-trailing-icon, [matChipTrailingIcon]", host: { classAttribute: "mat-chip-trailing-icon" }, providers: [{ provide: MAT_CHIP_TRAILING_ICON, useExisting: MatChipTrailingIcon }], ngImport: i0 });
|
83 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipTrailingIcon, decorators: [{
|
84 | type: Directive,
|
85 | args: [{
|
86 | selector: 'mat-chip-trailing-icon, [matChipTrailingIcon]',
|
87 | host: { 'class': 'mat-chip-trailing-icon' },
|
88 | providers: [{ provide: MAT_CHIP_TRAILING_ICON, useExisting: MatChipTrailingIcon }],
|
89 | }]
|
90 | }] });
|
91 |
|
92 | class MatChip extends _MatChipMixinBase {
|
93 | constructor(elementRef, _ngZone, platform, globalRippleOptions, _changeDetectorRef, _document, animationMode, tabIndex) {
|
94 | super(elementRef);
|
95 | this._ngZone = _ngZone;
|
96 | this._changeDetectorRef = _changeDetectorRef;
|
97 |
|
98 | this._hasFocus = false;
|
99 |
|
100 | this.chipListSelectable = true;
|
101 |
|
102 | this._chipListMultiple = false;
|
103 |
|
104 | this._chipListDisabled = false;
|
105 |
|
106 | this.role = 'option';
|
107 | this._selected = false;
|
108 | this._selectable = true;
|
109 | this._disabled = false;
|
110 | this._removable = true;
|
111 |
|
112 | this._onFocus = new Subject();
|
113 |
|
114 | this._onBlur = new Subject();
|
115 |
|
116 | this.selectionChange = new EventEmitter();
|
117 |
|
118 | this.destroyed = new EventEmitter();
|
119 |
|
120 | this.removed = new EventEmitter();
|
121 | this._addHostClassName();
|
122 |
|
123 |
|
124 |
|
125 | this._chipRippleTarget = _document.createElement('div');
|
126 | this._chipRippleTarget.classList.add('mat-chip-ripple');
|
127 | this._elementRef.nativeElement.appendChild(this._chipRippleTarget);
|
128 | this._chipRipple = new RippleRenderer(this, _ngZone, this._chipRippleTarget, platform);
|
129 | this._chipRipple.setupTriggerEvents(elementRef);
|
130 | this.rippleConfig = globalRippleOptions || {};
|
131 | this._animationsDisabled = animationMode === 'NoopAnimations';
|
132 | this.tabIndex = tabIndex != null ? parseInt(tabIndex) || -1 : -1;
|
133 | }
|
134 | |
135 |
|
136 |
|
137 |
|
138 | get rippleDisabled() {
|
139 | return (this.disabled ||
|
140 | this.disableRipple ||
|
141 | this._animationsDisabled ||
|
142 | !!this.rippleConfig.disabled);
|
143 | }
|
144 |
|
145 | get selected() {
|
146 | return this._selected;
|
147 | }
|
148 | set selected(value) {
|
149 | const coercedValue = coerceBooleanProperty(value);
|
150 | if (coercedValue !== this._selected) {
|
151 | this._selected = coercedValue;
|
152 | this._dispatchSelectionChange();
|
153 | }
|
154 | }
|
155 |
|
156 | get value() {
|
157 | return this._value !== undefined ? this._value : this._elementRef.nativeElement.textContent;
|
158 | }
|
159 | set value(value) {
|
160 | this._value = value;
|
161 | }
|
162 | |
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 | get selectable() {
|
169 | return this._selectable && this.chipListSelectable;
|
170 | }
|
171 | set selectable(value) {
|
172 | this._selectable = coerceBooleanProperty(value);
|
173 | }
|
174 |
|
175 | get disabled() {
|
176 | return this._chipListDisabled || this._disabled;
|
177 | }
|
178 | set disabled(value) {
|
179 | this._disabled = coerceBooleanProperty(value);
|
180 | }
|
181 | |
182 |
|
183 |
|
184 | get removable() {
|
185 | return this._removable;
|
186 | }
|
187 | set removable(value) {
|
188 | this._removable = coerceBooleanProperty(value);
|
189 | }
|
190 |
|
191 | get ariaSelected() {
|
192 |
|
193 |
|
194 | return this.selectable && (this._chipListMultiple || this.selected)
|
195 | ? this.selected.toString()
|
196 | : null;
|
197 | }
|
198 | _addHostClassName() {
|
199 | const basicChipAttrName = 'mat-basic-chip';
|
200 | const element = this._elementRef.nativeElement;
|
201 | if (element.hasAttribute(basicChipAttrName) ||
|
202 | element.tagName.toLowerCase() === basicChipAttrName) {
|
203 | element.classList.add(basicChipAttrName);
|
204 | return;
|
205 | }
|
206 | else {
|
207 | element.classList.add('mat-standard-chip');
|
208 | }
|
209 | }
|
210 | ngOnDestroy() {
|
211 | this.destroyed.emit({ chip: this });
|
212 | this._chipRipple._removeTriggerEvents();
|
213 | }
|
214 |
|
215 | select() {
|
216 | if (!this._selected) {
|
217 | this._selected = true;
|
218 | this._dispatchSelectionChange();
|
219 | this._changeDetectorRef.markForCheck();
|
220 | }
|
221 | }
|
222 |
|
223 | deselect() {
|
224 | if (this._selected) {
|
225 | this._selected = false;
|
226 | this._dispatchSelectionChange();
|
227 | this._changeDetectorRef.markForCheck();
|
228 | }
|
229 | }
|
230 |
|
231 | selectViaInteraction() {
|
232 | if (!this._selected) {
|
233 | this._selected = true;
|
234 | this._dispatchSelectionChange(true);
|
235 | this._changeDetectorRef.markForCheck();
|
236 | }
|
237 | }
|
238 |
|
239 | toggleSelected(isUserInput = false) {
|
240 | this._selected = !this.selected;
|
241 | this._dispatchSelectionChange(isUserInput);
|
242 | this._changeDetectorRef.markForCheck();
|
243 | return this.selected;
|
244 | }
|
245 |
|
246 | focus() {
|
247 | if (!this._hasFocus) {
|
248 | this._elementRef.nativeElement.focus();
|
249 | this._onFocus.next({ chip: this });
|
250 | }
|
251 | this._hasFocus = true;
|
252 | }
|
253 | |
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | remove() {
|
260 | if (this.removable) {
|
261 | this.removed.emit({ chip: this });
|
262 | }
|
263 | }
|
264 |
|
265 | _handleClick(event) {
|
266 | if (this.disabled) {
|
267 | event.preventDefault();
|
268 | }
|
269 | }
|
270 |
|
271 | _handleKeydown(event) {
|
272 | if (this.disabled) {
|
273 | return;
|
274 | }
|
275 | switch (event.keyCode) {
|
276 | case DELETE:
|
277 | case BACKSPACE:
|
278 |
|
279 | this.remove();
|
280 |
|
281 | event.preventDefault();
|
282 | break;
|
283 | case SPACE:
|
284 |
|
285 | if (this.selectable) {
|
286 | this.toggleSelected(true);
|
287 | }
|
288 |
|
289 | event.preventDefault();
|
290 | break;
|
291 | }
|
292 | }
|
293 | _blur() {
|
294 |
|
295 |
|
296 |
|
297 |
|
298 | this._ngZone.onStable.pipe(take(1)).subscribe(() => {
|
299 | this._ngZone.run(() => {
|
300 | this._hasFocus = false;
|
301 | this._onBlur.next({ chip: this });
|
302 | });
|
303 | });
|
304 | }
|
305 | _dispatchSelectionChange(isUserInput = false) {
|
306 | this.selectionChange.emit({
|
307 | source: this,
|
308 | isUserInput,
|
309 | selected: this._selected,
|
310 | });
|
311 | }
|
312 | }
|
313 | MatChip.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChip, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i1.Platform }, { token: MAT_RIPPLE_GLOBAL_OPTIONS, optional: true }, { token: i0.ChangeDetectorRef }, { token: DOCUMENT }, { token: ANIMATION_MODULE_TYPE, optional: true }, { token: 'tabindex', attribute: true }], target: i0.ɵɵFactoryTarget.Directive });
|
314 | MatChip.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: { color: "color", disableRipple: "disableRipple", tabIndex: "tabIndex", role: "role", selected: "selected", value: "value", selectable: "selectable", disabled: "disabled", removable: "removable" }, outputs: { selectionChange: "selectionChange", destroyed: "destroyed", removed: "removed" }, host: { listeners: { "click": "_handleClick($event)", "keydown": "_handleKeydown($event)", "focus": "focus()", "blur": "_blur()" }, properties: { "attr.tabindex": "disabled ? null : tabIndex", "attr.role": "role", "class.mat-chip-selected": "selected", "class.mat-chip-with-avatar": "avatar", "class.mat-chip-with-trailing-icon": "trailingIcon || removeIcon", "class.mat-chip-disabled": "disabled", "class._mat-animation-noopable": "_animationsDisabled", "attr.disabled": "disabled || null", "attr.aria-disabled": "disabled.toString()", "attr.aria-selected": "ariaSelected" }, classAttribute: "mat-chip mat-focus-indicator" }, queries: [{ propertyName: "avatar", first: true, predicate: MAT_CHIP_AVATAR, descendants: true }, { propertyName: "trailingIcon", first: true, predicate: MAT_CHIP_TRAILING_ICON, descendants: true }, { propertyName: "removeIcon", first: true, predicate: MAT_CHIP_REMOVE, descendants: true }], exportAs: ["matChip"], usesInheritance: true, ngImport: i0 });
|
315 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChip, decorators: [{
|
316 | type: Directive,
|
317 | args: [{
|
318 | selector: `mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]`,
|
319 | inputs: ['color', 'disableRipple', 'tabIndex'],
|
320 | exportAs: 'matChip',
|
321 | host: {
|
322 | 'class': 'mat-chip mat-focus-indicator',
|
323 | '[attr.tabindex]': 'disabled ? null : tabIndex',
|
324 | '[attr.role]': 'role',
|
325 | '[class.mat-chip-selected]': 'selected',
|
326 | '[class.mat-chip-with-avatar]': 'avatar',
|
327 | '[class.mat-chip-with-trailing-icon]': 'trailingIcon || removeIcon',
|
328 | '[class.mat-chip-disabled]': 'disabled',
|
329 | '[class._mat-animation-noopable]': '_animationsDisabled',
|
330 | '[attr.disabled]': 'disabled || null',
|
331 | '[attr.aria-disabled]': 'disabled.toString()',
|
332 | '[attr.aria-selected]': 'ariaSelected',
|
333 | '(click)': '_handleClick($event)',
|
334 | '(keydown)': '_handleKeydown($event)',
|
335 | '(focus)': 'focus()',
|
336 | '(blur)': '_blur()',
|
337 | },
|
338 | }]
|
339 | }], ctorParameters: function () {
|
340 | return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.Platform }, { type: undefined, decorators: [{
|
341 | type: Optional
|
342 | }, {
|
343 | type: Inject,
|
344 | args: [MAT_RIPPLE_GLOBAL_OPTIONS]
|
345 | }] }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
|
346 | type: Inject,
|
347 | args: [DOCUMENT]
|
348 | }] }, { type: undefined, decorators: [{
|
349 | type: Optional
|
350 | }, {
|
351 | type: Inject,
|
352 | args: [ANIMATION_MODULE_TYPE]
|
353 | }] }, { type: undefined, decorators: [{
|
354 | type: Attribute,
|
355 | args: ['tabindex']
|
356 | }] }];
|
357 | }, propDecorators: { avatar: [{
|
358 | type: ContentChild,
|
359 | args: [MAT_CHIP_AVATAR]
|
360 | }], trailingIcon: [{
|
361 | type: ContentChild,
|
362 | args: [MAT_CHIP_TRAILING_ICON]
|
363 | }], removeIcon: [{
|
364 | type: ContentChild,
|
365 | args: [MAT_CHIP_REMOVE]
|
366 | }], role: [{
|
367 | type: Input
|
368 | }], selected: [{
|
369 | type: Input
|
370 | }], value: [{
|
371 | type: Input
|
372 | }], selectable: [{
|
373 | type: Input
|
374 | }], disabled: [{
|
375 | type: Input
|
376 | }], removable: [{
|
377 | type: Input
|
378 | }], selectionChange: [{
|
379 | type: Output
|
380 | }], destroyed: [{
|
381 | type: Output
|
382 | }], removed: [{
|
383 | type: Output
|
384 | }] } });
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 | class MatChipRemove {
|
399 | constructor(_parentChip, elementRef) {
|
400 | this._parentChip = _parentChip;
|
401 | if (elementRef.nativeElement.nodeName === 'BUTTON') {
|
402 | elementRef.nativeElement.setAttribute('type', 'button');
|
403 | }
|
404 | }
|
405 |
|
406 | _handleClick(event) {
|
407 | const parentChip = this._parentChip;
|
408 | if (parentChip.removable && !parentChip.disabled) {
|
409 | parentChip.remove();
|
410 | }
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 | event.stopPropagation();
|
417 | event.preventDefault();
|
418 | }
|
419 | }
|
420 | MatChipRemove.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipRemove, deps: [{ token: MatChip }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
421 | MatChipRemove.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatChipRemove, selector: "[matChipRemove]", host: { listeners: { "click": "_handleClick($event)" }, classAttribute: "mat-chip-remove mat-chip-trailing-icon" }, providers: [{ provide: MAT_CHIP_REMOVE, useExisting: MatChipRemove }], ngImport: i0 });
|
422 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipRemove, decorators: [{
|
423 | type: Directive,
|
424 | args: [{
|
425 | selector: '[matChipRemove]',
|
426 | host: {
|
427 | 'class': 'mat-chip-remove mat-chip-trailing-icon',
|
428 | '(click)': '_handleClick($event)',
|
429 | },
|
430 | providers: [{ provide: MAT_CHIP_REMOVE, useExisting: MatChipRemove }],
|
431 | }]
|
432 | }], ctorParameters: function () { return [{ type: MatChip }, { type: i0.ElementRef }]; } });
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 | const MAT_CHIPS_DEFAULT_OPTIONS = new InjectionToken('mat-chips-default-options');
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 | let nextUniqueId$1 = 0;
|
453 |
|
454 |
|
455 |
|
456 |
|
457 | class MatChipInput {
|
458 | constructor(_elementRef, _defaultOptions) {
|
459 | this._elementRef = _elementRef;
|
460 | this._defaultOptions = _defaultOptions;
|
461 |
|
462 | this.focused = false;
|
463 | this._addOnBlur = false;
|
464 | |
465 |
|
466 |
|
467 |
|
468 |
|
469 | this.separatorKeyCodes = this._defaultOptions.separatorKeyCodes;
|
470 |
|
471 | this.chipEnd = new EventEmitter();
|
472 |
|
473 | this.placeholder = '';
|
474 |
|
475 | this.id = `mat-chip-list-input-${nextUniqueId$1++}`;
|
476 | this._disabled = false;
|
477 | this.inputElement = this._elementRef.nativeElement;
|
478 | }
|
479 |
|
480 | set chipList(value) {
|
481 | if (value) {
|
482 | this._chipList = value;
|
483 | this._chipList.registerInput(this);
|
484 | }
|
485 | }
|
486 | |
487 |
|
488 |
|
489 | get addOnBlur() {
|
490 | return this._addOnBlur;
|
491 | }
|
492 | set addOnBlur(value) {
|
493 | this._addOnBlur = coerceBooleanProperty(value);
|
494 | }
|
495 |
|
496 | get disabled() {
|
497 | return this._disabled || (this._chipList && this._chipList.disabled);
|
498 | }
|
499 | set disabled(value) {
|
500 | this._disabled = coerceBooleanProperty(value);
|
501 | }
|
502 |
|
503 | get empty() {
|
504 | return !this.inputElement.value;
|
505 | }
|
506 | ngOnChanges() {
|
507 | this._chipList.stateChanges.next();
|
508 | }
|
509 | ngOnDestroy() {
|
510 | this.chipEnd.complete();
|
511 | }
|
512 | ngAfterContentInit() {
|
513 | this._focusLastChipOnBackspace = this.empty;
|
514 | }
|
515 |
|
516 | _keydown(event) {
|
517 | if (event) {
|
518 |
|
519 |
|
520 | if (event.keyCode === TAB && !hasModifierKey(event, 'shiftKey')) {
|
521 | this._chipList._allowFocusEscape();
|
522 | }
|
523 |
|
524 |
|
525 |
|
526 | if (event.keyCode === BACKSPACE && this._focusLastChipOnBackspace) {
|
527 | this._chipList._keyManager.setLastItemActive();
|
528 | event.preventDefault();
|
529 | return;
|
530 | }
|
531 | else {
|
532 | this._focusLastChipOnBackspace = false;
|
533 | }
|
534 | }
|
535 | this._emitChipEnd(event);
|
536 | }
|
537 | |
538 |
|
539 |
|
540 | _keyup(event) {
|
541 |
|
542 | if (!this._focusLastChipOnBackspace && event.keyCode === BACKSPACE && this.empty) {
|
543 | this._focusLastChipOnBackspace = true;
|
544 | event.preventDefault();
|
545 | }
|
546 | }
|
547 |
|
548 | _blur() {
|
549 | if (this.addOnBlur) {
|
550 | this._emitChipEnd();
|
551 | }
|
552 | this.focused = false;
|
553 |
|
554 | if (!this._chipList.focused) {
|
555 | this._chipList._blur();
|
556 | }
|
557 | this._chipList.stateChanges.next();
|
558 | }
|
559 | _focus() {
|
560 | this.focused = true;
|
561 | this._focusLastChipOnBackspace = this.empty;
|
562 | this._chipList.stateChanges.next();
|
563 | }
|
564 |
|
565 | _emitChipEnd(event) {
|
566 | if (!this.inputElement.value && !!event) {
|
567 | this._chipList._keydown(event);
|
568 | }
|
569 | if (!event || this._isSeparatorKey(event)) {
|
570 | this.chipEnd.emit({
|
571 | input: this.inputElement,
|
572 | value: this.inputElement.value,
|
573 | chipInput: this,
|
574 | });
|
575 | event === null || event === void 0 ? void 0 : event.preventDefault();
|
576 | }
|
577 | }
|
578 | _onInput() {
|
579 |
|
580 | this._chipList.stateChanges.next();
|
581 | }
|
582 |
|
583 | focus(options) {
|
584 | this.inputElement.focus(options);
|
585 | }
|
586 |
|
587 | clear() {
|
588 | this.inputElement.value = '';
|
589 | this._focusLastChipOnBackspace = true;
|
590 | }
|
591 |
|
592 | _isSeparatorKey(event) {
|
593 | return !hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode);
|
594 | }
|
595 | }
|
596 | MatChipInput.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipInput, deps: [{ token: i0.ElementRef }, { token: MAT_CHIPS_DEFAULT_OPTIONS }], target: i0.ɵɵFactoryTarget.Directive });
|
597 | MatChipInput.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatChipInput, selector: "input[matChipInputFor]", inputs: { chipList: ["matChipInputFor", "chipList"], addOnBlur: ["matChipInputAddOnBlur", "addOnBlur"], separatorKeyCodes: ["matChipInputSeparatorKeyCodes", "separatorKeyCodes"], placeholder: "placeholder", id: "id", disabled: "disabled" }, outputs: { chipEnd: "matChipInputTokenEnd" }, host: { listeners: { "keydown": "_keydown($event)", "keyup": "_keyup($event)", "blur": "_blur()", "focus": "_focus()", "input": "_onInput()" }, properties: { "id": "id", "attr.disabled": "disabled || null", "attr.placeholder": "placeholder || null", "attr.aria-invalid": "_chipList && _chipList.ngControl ? _chipList.ngControl.invalid : null", "attr.aria-required": "_chipList && _chipList.required || null" }, classAttribute: "mat-chip-input mat-input-element" }, exportAs: ["matChipInput", "matChipInputFor"], usesOnChanges: true, ngImport: i0 });
|
598 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipInput, decorators: [{
|
599 | type: Directive,
|
600 | args: [{
|
601 | selector: 'input[matChipInputFor]',
|
602 | exportAs: 'matChipInput, matChipInputFor',
|
603 | host: {
|
604 | 'class': 'mat-chip-input mat-input-element',
|
605 | '(keydown)': '_keydown($event)',
|
606 | '(keyup)': '_keyup($event)',
|
607 | '(blur)': '_blur()',
|
608 | '(focus)': '_focus()',
|
609 | '(input)': '_onInput()',
|
610 | '[id]': 'id',
|
611 | '[attr.disabled]': 'disabled || null',
|
612 | '[attr.placeholder]': 'placeholder || null',
|
613 | '[attr.aria-invalid]': '_chipList && _chipList.ngControl ? _chipList.ngControl.invalid : null',
|
614 | '[attr.aria-required]': '_chipList && _chipList.required || null',
|
615 | },
|
616 | }]
|
617 | }], ctorParameters: function () {
|
618 | return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
|
619 | type: Inject,
|
620 | args: [MAT_CHIPS_DEFAULT_OPTIONS]
|
621 | }] }];
|
622 | }, propDecorators: { chipList: [{
|
623 | type: Input,
|
624 | args: ['matChipInputFor']
|
625 | }], addOnBlur: [{
|
626 | type: Input,
|
627 | args: ['matChipInputAddOnBlur']
|
628 | }], separatorKeyCodes: [{
|
629 | type: Input,
|
630 | args: ['matChipInputSeparatorKeyCodes']
|
631 | }], chipEnd: [{
|
632 | type: Output,
|
633 | args: ['matChipInputTokenEnd']
|
634 | }], placeholder: [{
|
635 | type: Input
|
636 | }], id: [{
|
637 | type: Input
|
638 | }], disabled: [{
|
639 | type: Input
|
640 | }] } });
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 | const _MatChipListBase = mixinErrorState(class {
|
652 | constructor(_defaultErrorStateMatcher, _parentForm, _parentFormGroup,
|
653 | /**
|
654 | * Form control bound to the component.
|
655 | * Implemented as part of `MatFormFieldControl`.
|
656 | * @docs-private
|
657 | */
|
658 | ngControl) {
|
659 | this._defaultErrorStateMatcher = _defaultErrorStateMatcher;
|
660 | this._parentForm = _parentForm;
|
661 | this._parentFormGroup = _parentFormGroup;
|
662 | this.ngControl = ngControl;
|
663 | |
664 |
|
665 |
|
666 |
|
667 |
|
668 | this.stateChanges = new Subject();
|
669 | }
|
670 | });
|
671 |
|
672 | let nextUniqueId = 0;
|
673 |
|
674 | class MatChipListChange {
|
675 | constructor(
|
676 | /** Chip list that emitted the event. */
|
677 | source,
|
678 | /** Value of the chip list when the event was emitted. */
|
679 | value) {
|
680 | this.source = source;
|
681 | this.value = value;
|
682 | }
|
683 | }
|
684 |
|
685 |
|
686 |
|
687 | class MatChipList extends _MatChipListBase {
|
688 | constructor(_elementRef, _changeDetectorRef, _dir, _parentForm, _parentFormGroup, _defaultErrorStateMatcher, ngControl) {
|
689 | super(_defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl);
|
690 | this._elementRef = _elementRef;
|
691 | this._changeDetectorRef = _changeDetectorRef;
|
692 | this._dir = _dir;
|
693 | |
694 |
|
695 |
|
696 |
|
697 | this.controlType = 'mat-chip-list';
|
698 | |
699 |
|
700 |
|
701 |
|
702 |
|
703 | this._lastDestroyedChipIndex = null;
|
704 |
|
705 | this._destroyed = new Subject();
|
706 |
|
707 | this._uid = `mat-chip-list-${nextUniqueId++}`;
|
708 |
|
709 | this._tabIndex = 0;
|
710 | |
711 |
|
712 |
|
713 |
|
714 | this._userTabIndex = null;
|
715 |
|
716 | this._onTouched = () => { };
|
717 |
|
718 | this._onChange = () => { };
|
719 | this._multiple = false;
|
720 | this._compareWith = (o1, o2) => o1 === o2;
|
721 | this._disabled = false;
|
722 |
|
723 | this.ariaOrientation = 'horizontal';
|
724 | this._selectable = true;
|
725 |
|
726 | this.change = new EventEmitter();
|
727 | |
728 |
|
729 |
|
730 |
|
731 |
|
732 | this.valueChange = new EventEmitter();
|
733 | if (this.ngControl) {
|
734 | this.ngControl.valueAccessor = this;
|
735 | }
|
736 | }
|
737 |
|
738 | get selected() {
|
739 | var _a, _b;
|
740 | return this.multiple ? ((_a = this._selectionModel) === null || _a === void 0 ? void 0 : _a.selected) || [] : (_b = this._selectionModel) === null || _b === void 0 ? void 0 : _b.selected[0];
|
741 | }
|
742 |
|
743 | get role() {
|
744 | if (this._explicitRole) {
|
745 | return this._explicitRole;
|
746 | }
|
747 | return this.empty ? null : 'listbox';
|
748 | }
|
749 | set role(role) {
|
750 | this._explicitRole = role;
|
751 | }
|
752 |
|
753 | get multiple() {
|
754 | return this._multiple;
|
755 | }
|
756 | set multiple(value) {
|
757 | this._multiple = coerceBooleanProperty(value);
|
758 | this._syncChipsState();
|
759 | }
|
760 | |
761 |
|
762 |
|
763 |
|
764 |
|
765 | get compareWith() {
|
766 | return this._compareWith;
|
767 | }
|
768 | set compareWith(fn) {
|
769 | this._compareWith = fn;
|
770 | if (this._selectionModel) {
|
771 |
|
772 | this._initializeSelection();
|
773 | }
|
774 | }
|
775 | |
776 |
|
777 |
|
778 |
|
779 | get value() {
|
780 | return this._value;
|
781 | }
|
782 | set value(value) {
|
783 | this.writeValue(value);
|
784 | this._value = value;
|
785 | }
|
786 | |
787 |
|
788 |
|
789 |
|
790 | get id() {
|
791 | return this._chipInput ? this._chipInput.id : this._uid;
|
792 | }
|
793 | |
794 |
|
795 |
|
796 |
|
797 | get required() {
|
798 | var _a, _b, _c, _d;
|
799 | return (_d = (_a = this._required) !== null && _a !== void 0 ? _a : (_c = (_b = this.ngControl) === null || _b === void 0 ? void 0 : _b.control) === null || _c === void 0 ? void 0 : _c.hasValidator(Validators.required)) !== null && _d !== void 0 ? _d : false;
|
800 | }
|
801 | set required(value) {
|
802 | this._required = coerceBooleanProperty(value);
|
803 | this.stateChanges.next();
|
804 | }
|
805 | |
806 |
|
807 |
|
808 |
|
809 | get placeholder() {
|
810 | return this._chipInput ? this._chipInput.placeholder : this._placeholder;
|
811 | }
|
812 | set placeholder(value) {
|
813 | this._placeholder = value;
|
814 | this.stateChanges.next();
|
815 | }
|
816 |
|
817 | get focused() {
|
818 | return (this._chipInput && this._chipInput.focused) || this._hasFocusedChip();
|
819 | }
|
820 | |
821 |
|
822 |
|
823 |
|
824 | get empty() {
|
825 | return (!this._chipInput || this._chipInput.empty) && (!this.chips || this.chips.length === 0);
|
826 | }
|
827 | |
828 |
|
829 |
|
830 |
|
831 | get shouldLabelFloat() {
|
832 | return !this.empty || this.focused;
|
833 | }
|
834 | |
835 |
|
836 |
|
837 |
|
838 | get disabled() {
|
839 | return this.ngControl ? !!this.ngControl.disabled : this._disabled;
|
840 | }
|
841 | set disabled(value) {
|
842 | this._disabled = coerceBooleanProperty(value);
|
843 | this._syncChipsState();
|
844 | }
|
845 | |
846 |
|
847 |
|
848 |
|
849 | get selectable() {
|
850 | return this._selectable;
|
851 | }
|
852 | set selectable(value) {
|
853 | this._selectable = coerceBooleanProperty(value);
|
854 | if (this.chips) {
|
855 | this.chips.forEach(chip => (chip.chipListSelectable = this._selectable));
|
856 | }
|
857 | }
|
858 | set tabIndex(value) {
|
859 | this._userTabIndex = value;
|
860 | this._tabIndex = value;
|
861 | }
|
862 |
|
863 | get chipSelectionChanges() {
|
864 | return merge(...this.chips.map(chip => chip.selectionChange));
|
865 | }
|
866 |
|
867 | get chipFocusChanges() {
|
868 | return merge(...this.chips.map(chip => chip._onFocus));
|
869 | }
|
870 |
|
871 | get chipBlurChanges() {
|
872 | return merge(...this.chips.map(chip => chip._onBlur));
|
873 | }
|
874 |
|
875 | get chipRemoveChanges() {
|
876 | return merge(...this.chips.map(chip => chip.destroyed));
|
877 | }
|
878 | ngAfterContentInit() {
|
879 | this._keyManager = new FocusKeyManager(this.chips)
|
880 | .withWrap()
|
881 | .withVerticalOrientation()
|
882 | .withHomeAndEnd()
|
883 | .withHorizontalOrientation(this._dir ? this._dir.value : 'ltr');
|
884 | if (this._dir) {
|
885 | this._dir.change
|
886 | .pipe(takeUntil(this._destroyed))
|
887 | .subscribe(dir => this._keyManager.withHorizontalOrientation(dir));
|
888 | }
|
889 | this._keyManager.tabOut.pipe(takeUntil(this._destroyed)).subscribe(() => {
|
890 | this._allowFocusEscape();
|
891 | });
|
892 |
|
893 | this.chips.changes.pipe(startWith(null), takeUntil(this._destroyed)).subscribe(() => {
|
894 | if (this.disabled) {
|
895 |
|
896 |
|
897 | Promise.resolve().then(() => {
|
898 | this._syncChipsState();
|
899 | });
|
900 | }
|
901 | this._resetChips();
|
902 |
|
903 | this._initializeSelection();
|
904 |
|
905 | this._updateTabIndex();
|
906 |
|
907 | this._updateFocusForDestroyedChips();
|
908 | this.stateChanges.next();
|
909 | });
|
910 | }
|
911 | ngOnInit() {
|
912 | this._selectionModel = new SelectionModel(this.multiple, undefined, false);
|
913 | this.stateChanges.next();
|
914 | }
|
915 | ngDoCheck() {
|
916 | if (this.ngControl) {
|
917 |
|
918 |
|
919 |
|
920 | this.updateErrorState();
|
921 | if (this.ngControl.disabled !== this._disabled) {
|
922 | this.disabled = !!this.ngControl.disabled;
|
923 | }
|
924 | }
|
925 | }
|
926 | ngOnDestroy() {
|
927 | this._destroyed.next();
|
928 | this._destroyed.complete();
|
929 | this.stateChanges.complete();
|
930 | this._dropSubscriptions();
|
931 | }
|
932 |
|
933 | registerInput(inputElement) {
|
934 | this._chipInput = inputElement;
|
935 |
|
936 |
|
937 | this._elementRef.nativeElement.setAttribute('data-mat-chip-input', inputElement.id);
|
938 | }
|
939 | |
940 |
|
941 |
|
942 |
|
943 | setDescribedByIds(ids) {
|
944 | if (ids.length) {
|
945 | this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));
|
946 | }
|
947 | else {
|
948 | this._elementRef.nativeElement.removeAttribute('aria-describedby');
|
949 | }
|
950 | }
|
951 |
|
952 | writeValue(value) {
|
953 | if (this.chips) {
|
954 | this._setSelectionByValue(value, false);
|
955 | }
|
956 | }
|
957 |
|
958 | registerOnChange(fn) {
|
959 | this._onChange = fn;
|
960 | }
|
961 |
|
962 | registerOnTouched(fn) {
|
963 | this._onTouched = fn;
|
964 | }
|
965 |
|
966 | setDisabledState(isDisabled) {
|
967 | this.disabled = isDisabled;
|
968 | this.stateChanges.next();
|
969 | }
|
970 | |
971 |
|
972 |
|
973 |
|
974 | onContainerClick(event) {
|
975 | if (!this._originatesFromChip(event)) {
|
976 | this.focus();
|
977 | }
|
978 | }
|
979 | |
980 |
|
981 |
|
982 |
|
983 | focus(options) {
|
984 | if (this.disabled) {
|
985 | return;
|
986 | }
|
987 |
|
988 |
|
989 | if (this._chipInput && this._chipInput.focused) {
|
990 |
|
991 | }
|
992 | else if (this.chips.length > 0) {
|
993 | this._keyManager.setFirstItemActive();
|
994 | this.stateChanges.next();
|
995 | }
|
996 | else {
|
997 | this._focusInput(options);
|
998 | this.stateChanges.next();
|
999 | }
|
1000 | }
|
1001 |
|
1002 | _focusInput(options) {
|
1003 | if (this._chipInput) {
|
1004 | this._chipInput.focus(options);
|
1005 | }
|
1006 | }
|
1007 | |
1008 |
|
1009 |
|
1010 | _keydown(event) {
|
1011 | const target = event.target;
|
1012 | if (target && target.classList.contains('mat-chip')) {
|
1013 | this._keyManager.onKeydown(event);
|
1014 | this.stateChanges.next();
|
1015 | }
|
1016 | }
|
1017 | |
1018 |
|
1019 |
|
1020 | _updateTabIndex() {
|
1021 |
|
1022 | this._tabIndex = this._userTabIndex || (this.chips.length === 0 ? -1 : 0);
|
1023 | }
|
1024 | |
1025 |
|
1026 |
|
1027 |
|
1028 | _updateFocusForDestroyedChips() {
|
1029 |
|
1030 | if (this._lastDestroyedChipIndex != null) {
|
1031 | if (this.chips.length) {
|
1032 | const newChipIndex = Math.min(this._lastDestroyedChipIndex, this.chips.length - 1);
|
1033 | this._keyManager.setActiveItem(newChipIndex);
|
1034 | }
|
1035 | else {
|
1036 | this.focus();
|
1037 | }
|
1038 | }
|
1039 | this._lastDestroyedChipIndex = null;
|
1040 | }
|
1041 | |
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 | _isValidIndex(index) {
|
1048 | return index >= 0 && index < this.chips.length;
|
1049 | }
|
1050 | _setSelectionByValue(value, isUserInput = true) {
|
1051 | this._clearSelection();
|
1052 | this.chips.forEach(chip => chip.deselect());
|
1053 | if (Array.isArray(value)) {
|
1054 | value.forEach(currentValue => this._selectValue(currentValue, isUserInput));
|
1055 | this._sortValues();
|
1056 | }
|
1057 | else {
|
1058 | const correspondingChip = this._selectValue(value, isUserInput);
|
1059 |
|
1060 |
|
1061 | if (correspondingChip) {
|
1062 | if (isUserInput) {
|
1063 | this._keyManager.setActiveItem(correspondingChip);
|
1064 | }
|
1065 | }
|
1066 | }
|
1067 | }
|
1068 | |
1069 |
|
1070 |
|
1071 |
|
1072 | _selectValue(value, isUserInput = true) {
|
1073 | const correspondingChip = this.chips.find(chip => {
|
1074 | return chip.value != null && this._compareWith(chip.value, value);
|
1075 | });
|
1076 | if (correspondingChip) {
|
1077 | isUserInput ? correspondingChip.selectViaInteraction() : correspondingChip.select();
|
1078 | this._selectionModel.select(correspondingChip);
|
1079 | }
|
1080 | return correspondingChip;
|
1081 | }
|
1082 | _initializeSelection() {
|
1083 |
|
1084 |
|
1085 | Promise.resolve().then(() => {
|
1086 | if (this.ngControl || this._value) {
|
1087 | this._setSelectionByValue(this.ngControl ? this.ngControl.value : this._value, false);
|
1088 | this.stateChanges.next();
|
1089 | }
|
1090 | });
|
1091 | }
|
1092 | |
1093 |
|
1094 |
|
1095 |
|
1096 | _clearSelection(skip) {
|
1097 | this._selectionModel.clear();
|
1098 | this.chips.forEach(chip => {
|
1099 | if (chip !== skip) {
|
1100 | chip.deselect();
|
1101 | }
|
1102 | });
|
1103 | this.stateChanges.next();
|
1104 | }
|
1105 | |
1106 |
|
1107 |
|
1108 |
|
1109 | _sortValues() {
|
1110 | if (this._multiple) {
|
1111 | this._selectionModel.clear();
|
1112 | this.chips.forEach(chip => {
|
1113 | if (chip.selected) {
|
1114 | this._selectionModel.select(chip);
|
1115 | }
|
1116 | });
|
1117 | this.stateChanges.next();
|
1118 | }
|
1119 | }
|
1120 |
|
1121 | _propagateChanges(fallbackValue) {
|
1122 | let valueToEmit = null;
|
1123 | if (Array.isArray(this.selected)) {
|
1124 | valueToEmit = this.selected.map(chip => chip.value);
|
1125 | }
|
1126 | else {
|
1127 | valueToEmit = this.selected ? this.selected.value : fallbackValue;
|
1128 | }
|
1129 | this._value = valueToEmit;
|
1130 | this.change.emit(new MatChipListChange(this, valueToEmit));
|
1131 | this.valueChange.emit(valueToEmit);
|
1132 | this._onChange(valueToEmit);
|
1133 | this._changeDetectorRef.markForCheck();
|
1134 | }
|
1135 |
|
1136 | _blur() {
|
1137 | if (!this._hasFocusedChip()) {
|
1138 | this._keyManager.setActiveItem(-1);
|
1139 | }
|
1140 | if (!this.disabled) {
|
1141 | if (this._chipInput) {
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 | setTimeout(() => {
|
1147 | if (!this.focused) {
|
1148 | this._markAsTouched();
|
1149 | }
|
1150 | });
|
1151 | }
|
1152 | else {
|
1153 |
|
1154 | this._markAsTouched();
|
1155 | }
|
1156 | }
|
1157 | }
|
1158 |
|
1159 | _markAsTouched() {
|
1160 | this._onTouched();
|
1161 | this._changeDetectorRef.markForCheck();
|
1162 | this.stateChanges.next();
|
1163 | }
|
1164 | |
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 | _allowFocusEscape() {
|
1170 | if (this._tabIndex !== -1) {
|
1171 | this._tabIndex = -1;
|
1172 | setTimeout(() => {
|
1173 | this._tabIndex = this._userTabIndex || 0;
|
1174 | this._changeDetectorRef.markForCheck();
|
1175 | });
|
1176 | }
|
1177 | }
|
1178 | _resetChips() {
|
1179 | this._dropSubscriptions();
|
1180 | this._listenToChipsFocus();
|
1181 | this._listenToChipsSelection();
|
1182 | this._listenToChipsRemoved();
|
1183 | }
|
1184 | _dropSubscriptions() {
|
1185 | if (this._chipFocusSubscription) {
|
1186 | this._chipFocusSubscription.unsubscribe();
|
1187 | this._chipFocusSubscription = null;
|
1188 | }
|
1189 | if (this._chipBlurSubscription) {
|
1190 | this._chipBlurSubscription.unsubscribe();
|
1191 | this._chipBlurSubscription = null;
|
1192 | }
|
1193 | if (this._chipSelectionSubscription) {
|
1194 | this._chipSelectionSubscription.unsubscribe();
|
1195 | this._chipSelectionSubscription = null;
|
1196 | }
|
1197 | if (this._chipRemoveSubscription) {
|
1198 | this._chipRemoveSubscription.unsubscribe();
|
1199 | this._chipRemoveSubscription = null;
|
1200 | }
|
1201 | }
|
1202 |
|
1203 | _listenToChipsSelection() {
|
1204 | this._chipSelectionSubscription = this.chipSelectionChanges.subscribe(event => {
|
1205 | event.source.selected
|
1206 | ? this._selectionModel.select(event.source)
|
1207 | : this._selectionModel.deselect(event.source);
|
1208 |
|
1209 | if (!this.multiple) {
|
1210 | this.chips.forEach(chip => {
|
1211 | if (!this._selectionModel.isSelected(chip) && chip.selected) {
|
1212 | chip.deselect();
|
1213 | }
|
1214 | });
|
1215 | }
|
1216 | if (event.isUserInput) {
|
1217 | this._propagateChanges();
|
1218 | }
|
1219 | });
|
1220 | }
|
1221 |
|
1222 | _listenToChipsFocus() {
|
1223 | this._chipFocusSubscription = this.chipFocusChanges.subscribe(event => {
|
1224 | let chipIndex = this.chips.toArray().indexOf(event.chip);
|
1225 | if (this._isValidIndex(chipIndex)) {
|
1226 | this._keyManager.updateActiveItem(chipIndex);
|
1227 | }
|
1228 | this.stateChanges.next();
|
1229 | });
|
1230 | this._chipBlurSubscription = this.chipBlurChanges.subscribe(() => {
|
1231 | this._blur();
|
1232 | this.stateChanges.next();
|
1233 | });
|
1234 | }
|
1235 | _listenToChipsRemoved() {
|
1236 | this._chipRemoveSubscription = this.chipRemoveChanges.subscribe(event => {
|
1237 | const chip = event.chip;
|
1238 | const chipIndex = this.chips.toArray().indexOf(event.chip);
|
1239 |
|
1240 |
|
1241 |
|
1242 | if (this._isValidIndex(chipIndex) && chip._hasFocus) {
|
1243 | this._lastDestroyedChipIndex = chipIndex;
|
1244 | }
|
1245 | });
|
1246 | }
|
1247 |
|
1248 | _originatesFromChip(event) {
|
1249 | let currentElement = event.target;
|
1250 | while (currentElement && currentElement !== this._elementRef.nativeElement) {
|
1251 | if (currentElement.classList.contains('mat-chip')) {
|
1252 | return true;
|
1253 | }
|
1254 | currentElement = currentElement.parentElement;
|
1255 | }
|
1256 | return false;
|
1257 | }
|
1258 |
|
1259 | _hasFocusedChip() {
|
1260 | return this.chips && this.chips.some(chip => chip._hasFocus);
|
1261 | }
|
1262 |
|
1263 | _syncChipsState() {
|
1264 | if (this.chips) {
|
1265 | this.chips.forEach(chip => {
|
1266 | chip._chipListDisabled = this._disabled;
|
1267 | chip._chipListMultiple = this.multiple;
|
1268 | });
|
1269 | }
|
1270 | }
|
1271 | }
|
1272 | MatChipList.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipList, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1$1.Directionality, optional: true }, { token: i2.NgForm, optional: true }, { token: i2.FormGroupDirective, optional: true }, { token: i3.ErrorStateMatcher }, { token: i2.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component });
|
1273 | MatChipList.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.1", type: MatChipList, selector: "mat-chip-list", inputs: { role: "role", userAriaDescribedBy: ["aria-describedby", "userAriaDescribedBy"], errorStateMatcher: "errorStateMatcher", multiple: "multiple", compareWith: "compareWith", value: "value", required: "required", placeholder: "placeholder", disabled: "disabled", ariaOrientation: ["aria-orientation", "ariaOrientation"], selectable: "selectable", tabIndex: "tabIndex" }, outputs: { change: "change", valueChange: "valueChange" }, host: { listeners: { "focus": "focus()", "blur": "_blur()", "keydown": "_keydown($event)" }, properties: { "attr.tabindex": "disabled ? null : _tabIndex", "attr.aria-required": "role ? required : null", "attr.aria-disabled": "disabled.toString()", "attr.aria-invalid": "errorState", "attr.aria-multiselectable": "multiple", "attr.role": "role", "class.mat-chip-list-disabled": "disabled", "class.mat-chip-list-invalid": "errorState", "class.mat-chip-list-required": "required", "attr.aria-orientation": "ariaOrientation", "id": "_uid" }, classAttribute: "mat-chip-list" }, providers: [{ provide: MatFormFieldControl, useExisting: MatChipList }], queries: [{ propertyName: "chips", predicate: MatChip, descendants: true }], exportAs: ["matChipList"], usesInheritance: true, ngImport: i0, template: `<div class="mat-chip-list-wrapper"><ng-content></ng-content></div>`, isInline: true, styles: [".mat-chip{position:relative;box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0);border:none;-webkit-appearance:none;-moz-appearance:none}.mat-standard-chip{transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);display:inline-flex;padding:7px 12px;border-radius:16px;align-items:center;cursor:default;min-height:32px;height:1px}.mat-standard-chip._mat-animation-noopable{transition:none !important;animation:none !important}.mat-standard-chip .mat-chip-remove{border:none;-webkit-appearance:none;-moz-appearance:none;padding:0;background:none}.mat-standard-chip .mat-chip-remove.mat-icon,.mat-standard-chip .mat-chip-remove .mat-icon{width:18px;height:18px;font-size:18px}.mat-standard-chip::after{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:inherit;opacity:0;content:\"\";pointer-events:none;transition:opacity 200ms cubic-bezier(0.35, 0, 0.25, 1)}.mat-standard-chip:hover::after{opacity:.12}.mat-standard-chip:focus{outline:none}.mat-standard-chip:focus::after{opacity:.16}.cdk-high-contrast-active .mat-standard-chip{outline:solid 1px}.cdk-high-contrast-active .mat-standard-chip:focus{outline:dotted 2px}.cdk-high-contrast-active .mat-standard-chip.mat-chip-selected{outline-width:3px}.mat-standard-chip.mat-chip-disabled::after{opacity:0}.mat-standard-chip.mat-chip-disabled .mat-chip-remove,.mat-standard-chip.mat-chip-disabled .mat-chip-trailing-icon{cursor:default}.mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar,.mat-standard-chip.mat-chip-with-avatar{padding-top:0;padding-bottom:0}.mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar{padding-right:8px;padding-left:0}[dir=rtl] .mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar{padding-left:8px;padding-right:0}.mat-standard-chip.mat-chip-with-trailing-icon{padding-top:7px;padding-bottom:7px;padding-right:8px;padding-left:12px}[dir=rtl] .mat-standard-chip.mat-chip-with-trailing-icon{padding-left:8px;padding-right:12px}.mat-standard-chip.mat-chip-with-avatar{padding-left:0;padding-right:12px}[dir=rtl] .mat-standard-chip.mat-chip-with-avatar{padding-right:0;padding-left:12px}.mat-standard-chip .mat-chip-avatar{width:24px;height:24px;margin-right:8px;margin-left:4px}[dir=rtl] .mat-standard-chip .mat-chip-avatar{margin-left:8px;margin-right:4px}.mat-standard-chip .mat-chip-remove,.mat-standard-chip .mat-chip-trailing-icon{width:18px;height:18px;cursor:pointer}.mat-standard-chip .mat-chip-remove,.mat-standard-chip .mat-chip-trailing-icon{margin-left:8px;margin-right:0}[dir=rtl] .mat-standard-chip .mat-chip-remove,[dir=rtl] .mat-standard-chip .mat-chip-trailing-icon{margin-right:8px;margin-left:0}.mat-chip-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none;border-radius:inherit;overflow:hidden;transform:translateZ(0)}.mat-chip-list-wrapper{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;margin:-4px}.mat-chip-list-wrapper input.mat-input-element,.mat-chip-list-wrapper .mat-standard-chip{margin:4px}.mat-chip-list-stacked .mat-chip-list-wrapper{flex-direction:column;align-items:flex-start}.mat-chip-list-stacked .mat-chip-list-wrapper .mat-standard-chip{width:100%}.mat-chip-avatar{border-radius:50%;justify-content:center;align-items:center;display:flex;overflow:hidden;object-fit:cover}input.mat-chip-input{width:150px;margin:4px;flex:1 0 150px}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
1274 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipList, decorators: [{
|
1275 | type: Component,
|
1276 | args: [{ selector: 'mat-chip-list', template: `<div class="mat-chip-list-wrapper"><ng-content></ng-content></div>`, exportAs: 'matChipList', host: {
|
1277 | '[attr.tabindex]': 'disabled ? null : _tabIndex',
|
1278 | '[attr.aria-required]': 'role ? required : null',
|
1279 | '[attr.aria-disabled]': 'disabled.toString()',
|
1280 | '[attr.aria-invalid]': 'errorState',
|
1281 | '[attr.aria-multiselectable]': 'multiple',
|
1282 | '[attr.role]': 'role',
|
1283 | '[class.mat-chip-list-disabled]': 'disabled',
|
1284 | '[class.mat-chip-list-invalid]': 'errorState',
|
1285 | '[class.mat-chip-list-required]': 'required',
|
1286 | '[attr.aria-orientation]': 'ariaOrientation',
|
1287 | 'class': 'mat-chip-list',
|
1288 | '(focus)': 'focus()',
|
1289 | '(blur)': '_blur()',
|
1290 | '(keydown)': '_keydown($event)',
|
1291 | '[id]': '_uid',
|
1292 | }, providers: [{ provide: MatFormFieldControl, useExisting: MatChipList }], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".mat-chip{position:relative;box-sizing:border-box;-webkit-tap-highlight-color:rgba(0,0,0,0);border:none;-webkit-appearance:none;-moz-appearance:none}.mat-standard-chip{transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);display:inline-flex;padding:7px 12px;border-radius:16px;align-items:center;cursor:default;min-height:32px;height:1px}.mat-standard-chip._mat-animation-noopable{transition:none !important;animation:none !important}.mat-standard-chip .mat-chip-remove{border:none;-webkit-appearance:none;-moz-appearance:none;padding:0;background:none}.mat-standard-chip .mat-chip-remove.mat-icon,.mat-standard-chip .mat-chip-remove .mat-icon{width:18px;height:18px;font-size:18px}.mat-standard-chip::after{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:inherit;opacity:0;content:\"\";pointer-events:none;transition:opacity 200ms cubic-bezier(0.35, 0, 0.25, 1)}.mat-standard-chip:hover::after{opacity:.12}.mat-standard-chip:focus{outline:none}.mat-standard-chip:focus::after{opacity:.16}.cdk-high-contrast-active .mat-standard-chip{outline:solid 1px}.cdk-high-contrast-active .mat-standard-chip:focus{outline:dotted 2px}.cdk-high-contrast-active .mat-standard-chip.mat-chip-selected{outline-width:3px}.mat-standard-chip.mat-chip-disabled::after{opacity:0}.mat-standard-chip.mat-chip-disabled .mat-chip-remove,.mat-standard-chip.mat-chip-disabled .mat-chip-trailing-icon{cursor:default}.mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar,.mat-standard-chip.mat-chip-with-avatar{padding-top:0;padding-bottom:0}.mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar{padding-right:8px;padding-left:0}[dir=rtl] .mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar{padding-left:8px;padding-right:0}.mat-standard-chip.mat-chip-with-trailing-icon{padding-top:7px;padding-bottom:7px;padding-right:8px;padding-left:12px}[dir=rtl] .mat-standard-chip.mat-chip-with-trailing-icon{padding-left:8px;padding-right:12px}.mat-standard-chip.mat-chip-with-avatar{padding-left:0;padding-right:12px}[dir=rtl] .mat-standard-chip.mat-chip-with-avatar{padding-right:0;padding-left:12px}.mat-standard-chip .mat-chip-avatar{width:24px;height:24px;margin-right:8px;margin-left:4px}[dir=rtl] .mat-standard-chip .mat-chip-avatar{margin-left:8px;margin-right:4px}.mat-standard-chip .mat-chip-remove,.mat-standard-chip .mat-chip-trailing-icon{width:18px;height:18px;cursor:pointer}.mat-standard-chip .mat-chip-remove,.mat-standard-chip .mat-chip-trailing-icon{margin-left:8px;margin-right:0}[dir=rtl] .mat-standard-chip .mat-chip-remove,[dir=rtl] .mat-standard-chip .mat-chip-trailing-icon{margin-right:8px;margin-left:0}.mat-chip-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none;border-radius:inherit;overflow:hidden;transform:translateZ(0)}.mat-chip-list-wrapper{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;margin:-4px}.mat-chip-list-wrapper input.mat-input-element,.mat-chip-list-wrapper .mat-standard-chip{margin:4px}.mat-chip-list-stacked .mat-chip-list-wrapper{flex-direction:column;align-items:flex-start}.mat-chip-list-stacked .mat-chip-list-wrapper .mat-standard-chip{width:100%}.mat-chip-avatar{border-radius:50%;justify-content:center;align-items:center;display:flex;overflow:hidden;object-fit:cover}input.mat-chip-input{width:150px;margin:4px;flex:1 0 150px}"] }]
|
1293 | }], ctorParameters: function () {
|
1294 | return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1$1.Directionality, decorators: [{
|
1295 | type: Optional
|
1296 | }] }, { type: i2.NgForm, decorators: [{
|
1297 | type: Optional
|
1298 | }] }, { type: i2.FormGroupDirective, decorators: [{
|
1299 | type: Optional
|
1300 | }] }, { type: i3.ErrorStateMatcher }, { type: i2.NgControl, decorators: [{
|
1301 | type: Optional
|
1302 | }, {
|
1303 | type: Self
|
1304 | }] }];
|
1305 | }, propDecorators: { role: [{
|
1306 | type: Input
|
1307 | }], userAriaDescribedBy: [{
|
1308 | type: Input,
|
1309 | args: ['aria-describedby']
|
1310 | }], errorStateMatcher: [{
|
1311 | type: Input
|
1312 | }], multiple: [{
|
1313 | type: Input
|
1314 | }], compareWith: [{
|
1315 | type: Input
|
1316 | }], value: [{
|
1317 | type: Input
|
1318 | }], required: [{
|
1319 | type: Input
|
1320 | }], placeholder: [{
|
1321 | type: Input
|
1322 | }], disabled: [{
|
1323 | type: Input
|
1324 | }], ariaOrientation: [{
|
1325 | type: Input,
|
1326 | args: ['aria-orientation']
|
1327 | }], selectable: [{
|
1328 | type: Input
|
1329 | }], tabIndex: [{
|
1330 | type: Input
|
1331 | }], change: [{
|
1332 | type: Output
|
1333 | }], valueChange: [{
|
1334 | type: Output
|
1335 | }], chips: [{
|
1336 | type: ContentChildren,
|
1337 | args: [MatChip, {
|
1338 |
|
1339 |
|
1340 | descendants: true,
|
1341 | }]
|
1342 | }] } });
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 | const CHIP_DECLARATIONS = [
|
1352 | MatChipList,
|
1353 | MatChip,
|
1354 | MatChipInput,
|
1355 | MatChipRemove,
|
1356 | MatChipAvatar,
|
1357 | MatChipTrailingIcon,
|
1358 | ];
|
1359 | class MatChipsModule {
|
1360 | }
|
1361 | MatChipsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1362 | MatChipsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, declarations: [MatChipList,
|
1363 | MatChip,
|
1364 | MatChipInput,
|
1365 | MatChipRemove,
|
1366 | MatChipAvatar,
|
1367 | MatChipTrailingIcon], imports: [MatCommonModule], exports: [MatChipList,
|
1368 | MatChip,
|
1369 | MatChipInput,
|
1370 | MatChipRemove,
|
1371 | MatChipAvatar,
|
1372 | MatChipTrailingIcon] });
|
1373 | MatChipsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, providers: [
|
1374 | ErrorStateMatcher,
|
1375 | {
|
1376 | provide: MAT_CHIPS_DEFAULT_OPTIONS,
|
1377 | useValue: {
|
1378 | separatorKeyCodes: [ENTER],
|
1379 | },
|
1380 | },
|
1381 | ], imports: [MatCommonModule] });
|
1382 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, decorators: [{
|
1383 | type: NgModule,
|
1384 | args: [{
|
1385 | imports: [MatCommonModule],
|
1386 | exports: CHIP_DECLARATIONS,
|
1387 | declarations: CHIP_DECLARATIONS,
|
1388 | providers: [
|
1389 | ErrorStateMatcher,
|
1390 | {
|
1391 | provide: MAT_CHIPS_DEFAULT_OPTIONS,
|
1392 | useValue: {
|
1393 | separatorKeyCodes: [ENTER],
|
1394 | },
|
1395 | },
|
1396 | ],
|
1397 | }]
|
1398 | }] });
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 | export { MAT_CHIPS_DEFAULT_OPTIONS, MAT_CHIP_AVATAR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON, MatChip, MatChipAvatar, MatChipInput, MatChipList, MatChipListChange, MatChipRemove, MatChipSelectionChange, MatChipTrailingIcon, MatChipsModule };
|
1421 |
|