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 * as i1 from '@angular/cdk/platform';
|
8 | import { DOCUMENT } from '@angular/common';
|
9 | import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
10 | import { Subject, merge } from 'rxjs';
|
11 | import { take, takeUntil, startWith } from 'rxjs/operators';
|
12 | import { FocusKeyManager } from '@angular/cdk/a11y';
|
13 | import * as i1$1 from '@angular/cdk/bidi';
|
14 | import { SelectionModel } from '@angular/cdk/collections';
|
15 | import * as i2 from '@angular/forms';
|
16 | import { Validators } from '@angular/forms';
|
17 | import { MatFormFieldControl } from '@angular/material/form-field';
|
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 () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.Platform }, { type: undefined, decorators: [{
|
340 | type: Optional
|
341 | }, {
|
342 | type: Inject,
|
343 | args: [MAT_RIPPLE_GLOBAL_OPTIONS]
|
344 | }] }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
|
345 | type: Inject,
|
346 | args: [DOCUMENT]
|
347 | }] }, { type: undefined, decorators: [{
|
348 | type: Optional
|
349 | }, {
|
350 | type: Inject,
|
351 | args: [ANIMATION_MODULE_TYPE]
|
352 | }] }, { type: undefined, decorators: [{
|
353 | type: Attribute,
|
354 | args: ['tabindex']
|
355 | }] }]; }, propDecorators: { avatar: [{
|
356 | type: ContentChild,
|
357 | args: [MAT_CHIP_AVATAR]
|
358 | }], trailingIcon: [{
|
359 | type: ContentChild,
|
360 | args: [MAT_CHIP_TRAILING_ICON]
|
361 | }], removeIcon: [{
|
362 | type: ContentChild,
|
363 | args: [MAT_CHIP_REMOVE]
|
364 | }], role: [{
|
365 | type: Input
|
366 | }], selected: [{
|
367 | type: Input
|
368 | }], value: [{
|
369 | type: Input
|
370 | }], selectable: [{
|
371 | type: Input
|
372 | }], disabled: [{
|
373 | type: Input
|
374 | }], removable: [{
|
375 | type: Input
|
376 | }], selectionChange: [{
|
377 | type: Output
|
378 | }], destroyed: [{
|
379 | type: Output
|
380 | }], removed: [{
|
381 | type: Output
|
382 | }] } });
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 | class MatChipRemove {
|
397 | constructor(_parentChip, elementRef) {
|
398 | this._parentChip = _parentChip;
|
399 | if (elementRef.nativeElement.nodeName === 'BUTTON') {
|
400 | elementRef.nativeElement.setAttribute('type', 'button');
|
401 | }
|
402 | }
|
403 |
|
404 | _handleClick(event) {
|
405 | const parentChip = this._parentChip;
|
406 | if (parentChip.removable && !parentChip.disabled) {
|
407 | parentChip.remove();
|
408 | }
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 | event.stopPropagation();
|
415 | event.preventDefault();
|
416 | }
|
417 | }
|
418 | 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 });
|
419 | 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 });
|
420 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipRemove, decorators: [{
|
421 | type: Directive,
|
422 | args: [{
|
423 | selector: '[matChipRemove]',
|
424 | host: {
|
425 | 'class': 'mat-chip-remove mat-chip-trailing-icon',
|
426 | '(click)': '_handleClick($event)',
|
427 | },
|
428 | providers: [{ provide: MAT_CHIP_REMOVE, useExisting: MatChipRemove }],
|
429 | }]
|
430 | }], ctorParameters: function () { return [{ type: MatChip }, { type: i0.ElementRef }]; } });
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | const MAT_CHIPS_DEFAULT_OPTIONS = new InjectionToken('mat-chips-default-options');
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 | const _MatChipListBase = mixinErrorState(class {
|
452 | constructor(_defaultErrorStateMatcher, _parentForm, _parentFormGroup,
|
453 | /**
|
454 | * Form control bound to the component.
|
455 | * Implemented as part of `MatFormFieldControl`.
|
456 | * @docs-private
|
457 | */
|
458 | ngControl) {
|
459 | this._defaultErrorStateMatcher = _defaultErrorStateMatcher;
|
460 | this._parentForm = _parentForm;
|
461 | this._parentFormGroup = _parentFormGroup;
|
462 | this.ngControl = ngControl;
|
463 | |
464 |
|
465 |
|
466 |
|
467 |
|
468 | this.stateChanges = new Subject();
|
469 | }
|
470 | });
|
471 |
|
472 | let nextUniqueId$1 = 0;
|
473 |
|
474 | class MatChipListChange {
|
475 | constructor(
|
476 | /** Chip list that emitted the event. */
|
477 | source,
|
478 | /** Value of the chip list when the event was emitted. */
|
479 | value) {
|
480 | this.source = source;
|
481 | this.value = value;
|
482 | }
|
483 | }
|
484 |
|
485 |
|
486 |
|
487 | class MatChipList extends _MatChipListBase {
|
488 | constructor(_elementRef, _changeDetectorRef, _dir, _parentForm, _parentFormGroup, _defaultErrorStateMatcher, ngControl) {
|
489 | super(_defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl);
|
490 | this._elementRef = _elementRef;
|
491 | this._changeDetectorRef = _changeDetectorRef;
|
492 | this._dir = _dir;
|
493 | |
494 |
|
495 |
|
496 |
|
497 | this.controlType = 'mat-chip-list';
|
498 | |
499 |
|
500 |
|
501 |
|
502 |
|
503 | this._lastDestroyedChipIndex = null;
|
504 |
|
505 | this._destroyed = new Subject();
|
506 |
|
507 | this._uid = `mat-chip-list-${nextUniqueId$1++}`;
|
508 |
|
509 | this._tabIndex = 0;
|
510 | |
511 |
|
512 |
|
513 |
|
514 | this._userTabIndex = null;
|
515 |
|
516 | this._onTouched = () => { };
|
517 |
|
518 | this._onChange = () => { };
|
519 | this._multiple = false;
|
520 | this._compareWith = (o1, o2) => o1 === o2;
|
521 | this._disabled = false;
|
522 |
|
523 | this.ariaOrientation = 'horizontal';
|
524 | this._selectable = true;
|
525 |
|
526 | this.change = new EventEmitter();
|
527 | |
528 |
|
529 |
|
530 |
|
531 |
|
532 | this.valueChange = new EventEmitter();
|
533 | if (this.ngControl) {
|
534 | this.ngControl.valueAccessor = this;
|
535 | }
|
536 | }
|
537 |
|
538 | get selected() {
|
539 | return this.multiple ? this._selectionModel?.selected || [] : this._selectionModel?.selected[0];
|
540 | }
|
541 |
|
542 | get role() {
|
543 | if (this._explicitRole) {
|
544 | return this._explicitRole;
|
545 | }
|
546 | return this.empty ? null : 'listbox';
|
547 | }
|
548 | set role(role) {
|
549 | this._explicitRole = role;
|
550 | }
|
551 |
|
552 | get multiple() {
|
553 | return this._multiple;
|
554 | }
|
555 | set multiple(value) {
|
556 | this._multiple = coerceBooleanProperty(value);
|
557 | this._syncChipsState();
|
558 | }
|
559 | |
560 |
|
561 |
|
562 |
|
563 |
|
564 | get compareWith() {
|
565 | return this._compareWith;
|
566 | }
|
567 | set compareWith(fn) {
|
568 | this._compareWith = fn;
|
569 | if (this._selectionModel) {
|
570 |
|
571 | this._initializeSelection();
|
572 | }
|
573 | }
|
574 | |
575 |
|
576 |
|
577 |
|
578 | get value() {
|
579 | return this._value;
|
580 | }
|
581 | set value(value) {
|
582 | this.writeValue(value);
|
583 | this._value = value;
|
584 | }
|
585 | |
586 |
|
587 |
|
588 |
|
589 | get id() {
|
590 | return this._chipInput ? this._chipInput.id : this._uid;
|
591 | }
|
592 | |
593 |
|
594 |
|
595 |
|
596 | get required() {
|
597 | return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false;
|
598 | }
|
599 | set required(value) {
|
600 | this._required = coerceBooleanProperty(value);
|
601 | this.stateChanges.next();
|
602 | }
|
603 | |
604 |
|
605 |
|
606 |
|
607 | get placeholder() {
|
608 | return this._chipInput ? this._chipInput.placeholder : this._placeholder;
|
609 | }
|
610 | set placeholder(value) {
|
611 | this._placeholder = value;
|
612 | this.stateChanges.next();
|
613 | }
|
614 |
|
615 | get focused() {
|
616 | return (this._chipInput && this._chipInput.focused) || this._hasFocusedChip();
|
617 | }
|
618 | |
619 |
|
620 |
|
621 |
|
622 | get empty() {
|
623 | return (!this._chipInput || this._chipInput.empty) && (!this.chips || this.chips.length === 0);
|
624 | }
|
625 | |
626 |
|
627 |
|
628 |
|
629 | get shouldLabelFloat() {
|
630 | return !this.empty || this.focused;
|
631 | }
|
632 | |
633 |
|
634 |
|
635 |
|
636 | get disabled() {
|
637 | return this.ngControl ? !!this.ngControl.disabled : this._disabled;
|
638 | }
|
639 | set disabled(value) {
|
640 | this._disabled = coerceBooleanProperty(value);
|
641 | this._syncChipsState();
|
642 | }
|
643 | |
644 |
|
645 |
|
646 |
|
647 | get selectable() {
|
648 | return this._selectable;
|
649 | }
|
650 | set selectable(value) {
|
651 | this._selectable = coerceBooleanProperty(value);
|
652 | if (this.chips) {
|
653 | this.chips.forEach(chip => (chip.chipListSelectable = this._selectable));
|
654 | }
|
655 | }
|
656 | set tabIndex(value) {
|
657 | this._userTabIndex = value;
|
658 | this._tabIndex = value;
|
659 | }
|
660 |
|
661 | get chipSelectionChanges() {
|
662 | return merge(...this.chips.map(chip => chip.selectionChange));
|
663 | }
|
664 |
|
665 | get chipFocusChanges() {
|
666 | return merge(...this.chips.map(chip => chip._onFocus));
|
667 | }
|
668 |
|
669 | get chipBlurChanges() {
|
670 | return merge(...this.chips.map(chip => chip._onBlur));
|
671 | }
|
672 |
|
673 | get chipRemoveChanges() {
|
674 | return merge(...this.chips.map(chip => chip.destroyed));
|
675 | }
|
676 | ngAfterContentInit() {
|
677 | this._keyManager = new FocusKeyManager(this.chips)
|
678 | .withWrap()
|
679 | .withVerticalOrientation()
|
680 | .withHomeAndEnd()
|
681 | .withHorizontalOrientation(this._dir ? this._dir.value : 'ltr');
|
682 | if (this._dir) {
|
683 | this._dir.change
|
684 | .pipe(takeUntil(this._destroyed))
|
685 | .subscribe(dir => this._keyManager.withHorizontalOrientation(dir));
|
686 | }
|
687 | this._keyManager.tabOut.pipe(takeUntil(this._destroyed)).subscribe(() => {
|
688 | this._allowFocusEscape();
|
689 | });
|
690 |
|
691 | this.chips.changes.pipe(startWith(null), takeUntil(this._destroyed)).subscribe(() => {
|
692 | if (this.disabled) {
|
693 |
|
694 |
|
695 | Promise.resolve().then(() => {
|
696 | this._syncChipsState();
|
697 | });
|
698 | }
|
699 | this._resetChips();
|
700 |
|
701 | this._initializeSelection();
|
702 |
|
703 | this._updateTabIndex();
|
704 |
|
705 | this._updateFocusForDestroyedChips();
|
706 | this.stateChanges.next();
|
707 | });
|
708 | }
|
709 | ngOnInit() {
|
710 | this._selectionModel = new SelectionModel(this.multiple, undefined, false);
|
711 | this.stateChanges.next();
|
712 | }
|
713 | ngDoCheck() {
|
714 | if (this.ngControl) {
|
715 |
|
716 |
|
717 |
|
718 | this.updateErrorState();
|
719 | if (this.ngControl.disabled !== this._disabled) {
|
720 | this.disabled = !!this.ngControl.disabled;
|
721 | }
|
722 | }
|
723 | }
|
724 | ngOnDestroy() {
|
725 | this._destroyed.next();
|
726 | this._destroyed.complete();
|
727 | this.stateChanges.complete();
|
728 | this._dropSubscriptions();
|
729 | }
|
730 |
|
731 | registerInput(inputElement) {
|
732 | this._chipInput = inputElement;
|
733 |
|
734 |
|
735 | this._elementRef.nativeElement.setAttribute('data-mat-chip-input', inputElement.id);
|
736 | }
|
737 | |
738 |
|
739 |
|
740 |
|
741 | setDescribedByIds(ids) {
|
742 | if (ids.length) {
|
743 | this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));
|
744 | }
|
745 | else {
|
746 | this._elementRef.nativeElement.removeAttribute('aria-describedby');
|
747 | }
|
748 | }
|
749 |
|
750 | writeValue(value) {
|
751 | if (this.chips) {
|
752 | this._setSelectionByValue(value, false);
|
753 | }
|
754 | }
|
755 |
|
756 | registerOnChange(fn) {
|
757 | this._onChange = fn;
|
758 | }
|
759 |
|
760 | registerOnTouched(fn) {
|
761 | this._onTouched = fn;
|
762 | }
|
763 |
|
764 | setDisabledState(isDisabled) {
|
765 | this.disabled = isDisabled;
|
766 | this.stateChanges.next();
|
767 | }
|
768 | |
769 |
|
770 |
|
771 |
|
772 | onContainerClick(event) {
|
773 | if (!this._originatesFromChip(event)) {
|
774 | this.focus();
|
775 | }
|
776 | }
|
777 | |
778 |
|
779 |
|
780 |
|
781 | focus(options) {
|
782 | if (this.disabled) {
|
783 | return;
|
784 | }
|
785 |
|
786 |
|
787 | if (this._chipInput && this._chipInput.focused) {
|
788 |
|
789 | }
|
790 | else if (this.chips.length > 0) {
|
791 | this._keyManager.setFirstItemActive();
|
792 | this.stateChanges.next();
|
793 | }
|
794 | else {
|
795 | this._focusInput(options);
|
796 | this.stateChanges.next();
|
797 | }
|
798 | }
|
799 |
|
800 | _focusInput(options) {
|
801 | if (this._chipInput) {
|
802 | this._chipInput.focus(options);
|
803 | }
|
804 | }
|
805 | |
806 |
|
807 |
|
808 | _keydown(event) {
|
809 | const target = event.target;
|
810 | if (target && target.classList.contains('mat-chip')) {
|
811 | this._keyManager.onKeydown(event);
|
812 | this.stateChanges.next();
|
813 | }
|
814 | }
|
815 | |
816 |
|
817 |
|
818 | _updateTabIndex() {
|
819 |
|
820 | this._tabIndex = this._userTabIndex || (this.chips.length === 0 ? -1 : 0);
|
821 | }
|
822 | |
823 |
|
824 |
|
825 |
|
826 | _updateFocusForDestroyedChips() {
|
827 |
|
828 | if (this._lastDestroyedChipIndex != null) {
|
829 | if (this.chips.length) {
|
830 | const newChipIndex = Math.min(this._lastDestroyedChipIndex, this.chips.length - 1);
|
831 | this._keyManager.setActiveItem(newChipIndex);
|
832 | }
|
833 | else {
|
834 | this.focus();
|
835 | }
|
836 | }
|
837 | this._lastDestroyedChipIndex = null;
|
838 | }
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 | _isValidIndex(index) {
|
846 | return index >= 0 && index < this.chips.length;
|
847 | }
|
848 | _setSelectionByValue(value, isUserInput = true) {
|
849 | this._clearSelection();
|
850 | this.chips.forEach(chip => chip.deselect());
|
851 | if (Array.isArray(value)) {
|
852 | value.forEach(currentValue => this._selectValue(currentValue, isUserInput));
|
853 | this._sortValues();
|
854 | }
|
855 | else {
|
856 | const correspondingChip = this._selectValue(value, isUserInput);
|
857 |
|
858 |
|
859 | if (correspondingChip) {
|
860 | if (isUserInput) {
|
861 | this._keyManager.setActiveItem(correspondingChip);
|
862 | }
|
863 | }
|
864 | }
|
865 | }
|
866 | |
867 |
|
868 |
|
869 |
|
870 | _selectValue(value, isUserInput = true) {
|
871 | const correspondingChip = this.chips.find(chip => {
|
872 | return chip.value != null && this._compareWith(chip.value, value);
|
873 | });
|
874 | if (correspondingChip) {
|
875 | isUserInput ? correspondingChip.selectViaInteraction() : correspondingChip.select();
|
876 | this._selectionModel.select(correspondingChip);
|
877 | }
|
878 | return correspondingChip;
|
879 | }
|
880 | _initializeSelection() {
|
881 |
|
882 |
|
883 | Promise.resolve().then(() => {
|
884 | if (this.ngControl || this._value) {
|
885 | this._setSelectionByValue(this.ngControl ? this.ngControl.value : this._value, false);
|
886 | this.stateChanges.next();
|
887 | }
|
888 | });
|
889 | }
|
890 | |
891 |
|
892 |
|
893 |
|
894 | _clearSelection(skip) {
|
895 | this._selectionModel.clear();
|
896 | this.chips.forEach(chip => {
|
897 | if (chip !== skip) {
|
898 | chip.deselect();
|
899 | }
|
900 | });
|
901 | this.stateChanges.next();
|
902 | }
|
903 | |
904 |
|
905 |
|
906 |
|
907 | _sortValues() {
|
908 | if (this._multiple) {
|
909 | this._selectionModel.clear();
|
910 | this.chips.forEach(chip => {
|
911 | if (chip.selected) {
|
912 | this._selectionModel.select(chip);
|
913 | }
|
914 | });
|
915 | this.stateChanges.next();
|
916 | }
|
917 | }
|
918 |
|
919 | _propagateChanges(fallbackValue) {
|
920 | let valueToEmit = null;
|
921 | if (Array.isArray(this.selected)) {
|
922 | valueToEmit = this.selected.map(chip => chip.value);
|
923 | }
|
924 | else {
|
925 | valueToEmit = this.selected ? this.selected.value : fallbackValue;
|
926 | }
|
927 | this._value = valueToEmit;
|
928 | this.change.emit(new MatChipListChange(this, valueToEmit));
|
929 | this.valueChange.emit(valueToEmit);
|
930 | this._onChange(valueToEmit);
|
931 | this._changeDetectorRef.markForCheck();
|
932 | }
|
933 |
|
934 | _blur() {
|
935 | if (!this._hasFocusedChip()) {
|
936 | this._keyManager.setActiveItem(-1);
|
937 | }
|
938 | if (!this.disabled) {
|
939 | if (this._chipInput) {
|
940 |
|
941 |
|
942 |
|
943 |
|
944 | setTimeout(() => {
|
945 | if (!this.focused) {
|
946 | this._markAsTouched();
|
947 | }
|
948 | });
|
949 | }
|
950 | else {
|
951 |
|
952 | this._markAsTouched();
|
953 | }
|
954 | }
|
955 | }
|
956 |
|
957 | _markAsTouched() {
|
958 | this._onTouched();
|
959 | this._changeDetectorRef.markForCheck();
|
960 | this.stateChanges.next();
|
961 | }
|
962 | |
963 |
|
964 |
|
965 |
|
966 |
|
967 | _allowFocusEscape() {
|
968 | if (this._tabIndex !== -1) {
|
969 | this._tabIndex = -1;
|
970 | setTimeout(() => {
|
971 | this._tabIndex = this._userTabIndex || 0;
|
972 | this._changeDetectorRef.markForCheck();
|
973 | });
|
974 | }
|
975 | }
|
976 | _resetChips() {
|
977 | this._dropSubscriptions();
|
978 | this._listenToChipsFocus();
|
979 | this._listenToChipsSelection();
|
980 | this._listenToChipsRemoved();
|
981 | }
|
982 | _dropSubscriptions() {
|
983 | if (this._chipFocusSubscription) {
|
984 | this._chipFocusSubscription.unsubscribe();
|
985 | this._chipFocusSubscription = null;
|
986 | }
|
987 | if (this._chipBlurSubscription) {
|
988 | this._chipBlurSubscription.unsubscribe();
|
989 | this._chipBlurSubscription = null;
|
990 | }
|
991 | if (this._chipSelectionSubscription) {
|
992 | this._chipSelectionSubscription.unsubscribe();
|
993 | this._chipSelectionSubscription = null;
|
994 | }
|
995 | if (this._chipRemoveSubscription) {
|
996 | this._chipRemoveSubscription.unsubscribe();
|
997 | this._chipRemoveSubscription = null;
|
998 | }
|
999 | }
|
1000 |
|
1001 | _listenToChipsSelection() {
|
1002 | this._chipSelectionSubscription = this.chipSelectionChanges.subscribe(event => {
|
1003 | event.source.selected
|
1004 | ? this._selectionModel.select(event.source)
|
1005 | : this._selectionModel.deselect(event.source);
|
1006 |
|
1007 | if (!this.multiple) {
|
1008 | this.chips.forEach(chip => {
|
1009 | if (!this._selectionModel.isSelected(chip) && chip.selected) {
|
1010 | chip.deselect();
|
1011 | }
|
1012 | });
|
1013 | }
|
1014 | if (event.isUserInput) {
|
1015 | this._propagateChanges();
|
1016 | }
|
1017 | });
|
1018 | }
|
1019 |
|
1020 | _listenToChipsFocus() {
|
1021 | this._chipFocusSubscription = this.chipFocusChanges.subscribe(event => {
|
1022 | let chipIndex = this.chips.toArray().indexOf(event.chip);
|
1023 | if (this._isValidIndex(chipIndex)) {
|
1024 | this._keyManager.updateActiveItem(chipIndex);
|
1025 | }
|
1026 | this.stateChanges.next();
|
1027 | });
|
1028 | this._chipBlurSubscription = this.chipBlurChanges.subscribe(() => {
|
1029 | this._blur();
|
1030 | this.stateChanges.next();
|
1031 | });
|
1032 | }
|
1033 | _listenToChipsRemoved() {
|
1034 | this._chipRemoveSubscription = this.chipRemoveChanges.subscribe(event => {
|
1035 | const chip = event.chip;
|
1036 | const chipIndex = this.chips.toArray().indexOf(event.chip);
|
1037 |
|
1038 |
|
1039 |
|
1040 | if (this._isValidIndex(chipIndex) && chip._hasFocus) {
|
1041 | this._lastDestroyedChipIndex = chipIndex;
|
1042 | }
|
1043 | });
|
1044 | }
|
1045 |
|
1046 | _originatesFromChip(event) {
|
1047 | let currentElement = event.target;
|
1048 | while (currentElement && currentElement !== this._elementRef.nativeElement) {
|
1049 | if (currentElement.classList.contains('mat-chip')) {
|
1050 | return true;
|
1051 | }
|
1052 | currentElement = currentElement.parentElement;
|
1053 | }
|
1054 | return false;
|
1055 | }
|
1056 |
|
1057 | _hasFocusedChip() {
|
1058 | return this.chips && this.chips.some(chip => chip._hasFocus);
|
1059 | }
|
1060 |
|
1061 | _syncChipsState() {
|
1062 | if (this.chips) {
|
1063 | this.chips.forEach(chip => {
|
1064 | chip._chipListDisabled = this._disabled;
|
1065 | chip._chipListMultiple = this.multiple;
|
1066 | });
|
1067 | }
|
1068 | }
|
1069 | }
|
1070 | 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 });
|
1071 | 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 });
|
1072 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipList, decorators: [{
|
1073 | type: Component,
|
1074 | args: [{ selector: 'mat-chip-list', template: `<div class="mat-chip-list-wrapper"><ng-content></ng-content></div>`, exportAs: 'matChipList', host: {
|
1075 | '[attr.tabindex]': 'disabled ? null : _tabIndex',
|
1076 | '[attr.aria-required]': 'role ? required : null',
|
1077 | '[attr.aria-disabled]': 'disabled.toString()',
|
1078 | '[attr.aria-invalid]': 'errorState',
|
1079 | '[attr.aria-multiselectable]': 'multiple',
|
1080 | '[attr.role]': 'role',
|
1081 | '[class.mat-chip-list-disabled]': 'disabled',
|
1082 | '[class.mat-chip-list-invalid]': 'errorState',
|
1083 | '[class.mat-chip-list-required]': 'required',
|
1084 | '[attr.aria-orientation]': 'ariaOrientation',
|
1085 | 'class': 'mat-chip-list',
|
1086 | '(focus)': 'focus()',
|
1087 | '(blur)': '_blur()',
|
1088 | '(keydown)': '_keydown($event)',
|
1089 | '[id]': '_uid',
|
1090 | }, 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}"] }]
|
1091 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1$1.Directionality, decorators: [{
|
1092 | type: Optional
|
1093 | }] }, { type: i2.NgForm, decorators: [{
|
1094 | type: Optional
|
1095 | }] }, { type: i2.FormGroupDirective, decorators: [{
|
1096 | type: Optional
|
1097 | }] }, { type: i3.ErrorStateMatcher }, { type: i2.NgControl, decorators: [{
|
1098 | type: Optional
|
1099 | }, {
|
1100 | type: Self
|
1101 | }] }]; }, propDecorators: { role: [{
|
1102 | type: Input
|
1103 | }], userAriaDescribedBy: [{
|
1104 | type: Input,
|
1105 | args: ['aria-describedby']
|
1106 | }], errorStateMatcher: [{
|
1107 | type: Input
|
1108 | }], multiple: [{
|
1109 | type: Input
|
1110 | }], compareWith: [{
|
1111 | type: Input
|
1112 | }], value: [{
|
1113 | type: Input
|
1114 | }], required: [{
|
1115 | type: Input
|
1116 | }], placeholder: [{
|
1117 | type: Input
|
1118 | }], disabled: [{
|
1119 | type: Input
|
1120 | }], ariaOrientation: [{
|
1121 | type: Input,
|
1122 | args: ['aria-orientation']
|
1123 | }], selectable: [{
|
1124 | type: Input
|
1125 | }], tabIndex: [{
|
1126 | type: Input
|
1127 | }], change: [{
|
1128 | type: Output
|
1129 | }], valueChange: [{
|
1130 | type: Output
|
1131 | }], chips: [{
|
1132 | type: ContentChildren,
|
1133 | args: [MatChip, {
|
1134 |
|
1135 |
|
1136 | descendants: true,
|
1137 | }]
|
1138 | }] } });
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 | let nextUniqueId = 0;
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 | class MatChipInput {
|
1154 | constructor(_elementRef, _defaultOptions) {
|
1155 | this._elementRef = _elementRef;
|
1156 | this._defaultOptions = _defaultOptions;
|
1157 |
|
1158 | this.focused = false;
|
1159 | this._addOnBlur = false;
|
1160 | |
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 | this.separatorKeyCodes = this._defaultOptions.separatorKeyCodes;
|
1166 |
|
1167 | this.chipEnd = new EventEmitter();
|
1168 |
|
1169 | this.placeholder = '';
|
1170 |
|
1171 | this.id = `mat-chip-list-input-${nextUniqueId++}`;
|
1172 | this._disabled = false;
|
1173 | this.inputElement = this._elementRef.nativeElement;
|
1174 | }
|
1175 |
|
1176 | set chipList(value) {
|
1177 | if (value) {
|
1178 | this._chipList = value;
|
1179 | this._chipList.registerInput(this);
|
1180 | }
|
1181 | }
|
1182 | |
1183 |
|
1184 |
|
1185 | get addOnBlur() {
|
1186 | return this._addOnBlur;
|
1187 | }
|
1188 | set addOnBlur(value) {
|
1189 | this._addOnBlur = coerceBooleanProperty(value);
|
1190 | }
|
1191 |
|
1192 | get disabled() {
|
1193 | return this._disabled || (this._chipList && this._chipList.disabled);
|
1194 | }
|
1195 | set disabled(value) {
|
1196 | this._disabled = coerceBooleanProperty(value);
|
1197 | }
|
1198 |
|
1199 | get empty() {
|
1200 | return !this.inputElement.value;
|
1201 | }
|
1202 | ngOnChanges() {
|
1203 | this._chipList.stateChanges.next();
|
1204 | }
|
1205 | ngOnDestroy() {
|
1206 | this.chipEnd.complete();
|
1207 | }
|
1208 | ngAfterContentInit() {
|
1209 | this._focusLastChipOnBackspace = this.empty;
|
1210 | }
|
1211 |
|
1212 | _keydown(event) {
|
1213 | if (event) {
|
1214 |
|
1215 |
|
1216 | if (event.keyCode === TAB && !hasModifierKey(event, 'shiftKey')) {
|
1217 | this._chipList._allowFocusEscape();
|
1218 | }
|
1219 |
|
1220 |
|
1221 |
|
1222 | if (event.keyCode === BACKSPACE && this._focusLastChipOnBackspace) {
|
1223 | this._chipList._keyManager.setLastItemActive();
|
1224 | event.preventDefault();
|
1225 | return;
|
1226 | }
|
1227 | else {
|
1228 | this._focusLastChipOnBackspace = false;
|
1229 | }
|
1230 | }
|
1231 | this._emitChipEnd(event);
|
1232 | }
|
1233 | |
1234 |
|
1235 |
|
1236 | _keyup(event) {
|
1237 |
|
1238 | if (!this._focusLastChipOnBackspace && event.keyCode === BACKSPACE && this.empty) {
|
1239 | this._focusLastChipOnBackspace = true;
|
1240 | event.preventDefault();
|
1241 | }
|
1242 | }
|
1243 |
|
1244 | _blur() {
|
1245 | if (this.addOnBlur) {
|
1246 | this._emitChipEnd();
|
1247 | }
|
1248 | this.focused = false;
|
1249 |
|
1250 | if (!this._chipList.focused) {
|
1251 | this._chipList._blur();
|
1252 | }
|
1253 | this._chipList.stateChanges.next();
|
1254 | }
|
1255 | _focus() {
|
1256 | this.focused = true;
|
1257 | this._focusLastChipOnBackspace = this.empty;
|
1258 | this._chipList.stateChanges.next();
|
1259 | }
|
1260 |
|
1261 | _emitChipEnd(event) {
|
1262 | if (!this.inputElement.value && !!event) {
|
1263 | this._chipList._keydown(event);
|
1264 | }
|
1265 | if (!event || this._isSeparatorKey(event)) {
|
1266 | this.chipEnd.emit({
|
1267 | input: this.inputElement,
|
1268 | value: this.inputElement.value,
|
1269 | chipInput: this,
|
1270 | });
|
1271 | event?.preventDefault();
|
1272 | }
|
1273 | }
|
1274 | _onInput() {
|
1275 |
|
1276 | this._chipList.stateChanges.next();
|
1277 | }
|
1278 |
|
1279 | focus(options) {
|
1280 | this.inputElement.focus(options);
|
1281 | }
|
1282 |
|
1283 | clear() {
|
1284 | this.inputElement.value = '';
|
1285 | this._focusLastChipOnBackspace = true;
|
1286 | }
|
1287 |
|
1288 | _isSeparatorKey(event) {
|
1289 | return !hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode);
|
1290 | }
|
1291 | }
|
1292 | 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 });
|
1293 | 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 });
|
1294 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipInput, decorators: [{
|
1295 | type: Directive,
|
1296 | args: [{
|
1297 | selector: 'input[matChipInputFor]',
|
1298 | exportAs: 'matChipInput, matChipInputFor',
|
1299 | host: {
|
1300 | 'class': 'mat-chip-input mat-input-element',
|
1301 | '(keydown)': '_keydown($event)',
|
1302 | '(keyup)': '_keyup($event)',
|
1303 | '(blur)': '_blur()',
|
1304 | '(focus)': '_focus()',
|
1305 | '(input)': '_onInput()',
|
1306 | '[id]': 'id',
|
1307 | '[attr.disabled]': 'disabled || null',
|
1308 | '[attr.placeholder]': 'placeholder || null',
|
1309 | '[attr.aria-invalid]': '_chipList && _chipList.ngControl ? _chipList.ngControl.invalid : null',
|
1310 | '[attr.aria-required]': '_chipList && _chipList.required || null',
|
1311 | },
|
1312 | }]
|
1313 | }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
|
1314 | type: Inject,
|
1315 | args: [MAT_CHIPS_DEFAULT_OPTIONS]
|
1316 | }] }]; }, propDecorators: { chipList: [{
|
1317 | type: Input,
|
1318 | args: ['matChipInputFor']
|
1319 | }], addOnBlur: [{
|
1320 | type: Input,
|
1321 | args: ['matChipInputAddOnBlur']
|
1322 | }], separatorKeyCodes: [{
|
1323 | type: Input,
|
1324 | args: ['matChipInputSeparatorKeyCodes']
|
1325 | }], chipEnd: [{
|
1326 | type: Output,
|
1327 | args: ['matChipInputTokenEnd']
|
1328 | }], placeholder: [{
|
1329 | type: Input
|
1330 | }], id: [{
|
1331 | type: Input
|
1332 | }], disabled: [{
|
1333 | type: Input
|
1334 | }] } });
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 | const CHIP_DECLARATIONS = [
|
1344 | MatChipList,
|
1345 | MatChip,
|
1346 | MatChipInput,
|
1347 | MatChipRemove,
|
1348 | MatChipAvatar,
|
1349 | MatChipTrailingIcon,
|
1350 | ];
|
1351 | class MatChipsModule {
|
1352 | }
|
1353 | MatChipsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1354 | MatChipsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, declarations: [MatChipList,
|
1355 | MatChip,
|
1356 | MatChipInput,
|
1357 | MatChipRemove,
|
1358 | MatChipAvatar,
|
1359 | MatChipTrailingIcon], imports: [MatCommonModule], exports: [MatChipList,
|
1360 | MatChip,
|
1361 | MatChipInput,
|
1362 | MatChipRemove,
|
1363 | MatChipAvatar,
|
1364 | MatChipTrailingIcon] });
|
1365 | MatChipsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, providers: [
|
1366 | ErrorStateMatcher,
|
1367 | {
|
1368 | provide: MAT_CHIPS_DEFAULT_OPTIONS,
|
1369 | useValue: {
|
1370 | separatorKeyCodes: [ENTER],
|
1371 | },
|
1372 | },
|
1373 | ], imports: [MatCommonModule] });
|
1374 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatChipsModule, decorators: [{
|
1375 | type: NgModule,
|
1376 | args: [{
|
1377 | imports: [MatCommonModule],
|
1378 | exports: CHIP_DECLARATIONS,
|
1379 | declarations: CHIP_DECLARATIONS,
|
1380 | providers: [
|
1381 | ErrorStateMatcher,
|
1382 | {
|
1383 | provide: MAT_CHIPS_DEFAULT_OPTIONS,
|
1384 | useValue: {
|
1385 | separatorKeyCodes: [ENTER],
|
1386 | },
|
1387 | },
|
1388 | ],
|
1389 | }]
|
1390 | }] });
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 | export { MAT_CHIPS_DEFAULT_OPTIONS, MAT_CHIP_AVATAR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON, MatChip, MatChipAvatar, MatChipInput, MatChipList, MatChipListChange, MatChipRemove, MatChipSelectionChange, MatChipTrailingIcon, MatChipsModule };
|
1413 |
|