MCPcopy
hub / github.com/angular/components / MatChip

Class MatChip

src/material/chips/chip.ts:96–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94 imports: [MatChipContent],
95})
96export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck, OnDestroy {
97 _changeDetectorRef = inject(ChangeDetectorRef);
98 _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
99 private readonly _tagName = inject(HOST_TAG_NAME);
100 protected _ngZone = inject(NgZone);
101 private _focusMonitor = inject(FocusMonitor);
102 private _globalRippleOptions = inject<RippleGlobalOptions>(MAT_RIPPLE_GLOBAL_OPTIONS, {
103 optional: true,
104 });
105
106 protected _document = inject(DOCUMENT);
107
108 /** Emits when the chip is focused. */
109 readonly _onFocus = new Subject<MatChipEvent>();
110
111 /** Emits when the chip is blurred. */
112 readonly _onBlur = new Subject<MatChipEvent>();
113
114 /** Whether this chip is a basic (unstyled) chip. */
115 _isBasicChip = false;
116
117 /** Role for the root of the chip. */
118 @Input() role: string | null = null;
119
120 /** Whether the chip has focus. */
121 private _hasFocusInternal = false;
122
123 /** Whether moving focus into the chip is pending. */
124 private _pendingFocus: boolean = false;
125
126 /** Subscription to changes in the chip's actions. */
127 private _actionChanges: Subscription | undefined;
128
129 /** Whether animations for the chip are enabled. */
130 _animationsDisabled = _animationsDisabled();
131
132 /** All avatars present in the chip. */
133 @ContentChildren(MAT_CHIP_AVATAR, {descendants: true})
134 protected _allLeadingIcons!: QueryList<MatChipAvatar>;
135
136 /** All trailing icons present in the chip. */
137 @ContentChildren(MAT_CHIP_TRAILING_ICON, {descendants: true})
138 protected _allTrailingIcons!: QueryList<MatChipTrailingIcon>;
139
140 /** All edit icons present in the chip. */
141 @ContentChildren(MAT_CHIP_EDIT, {descendants: true})
142 protected _allEditIcons!: QueryList<MatChipEdit>;
143
144 /** All remove icons present in the chip. */
145 @ContentChildren(MAT_CHIP_REMOVE, {descendants: true})
146 protected _allRemoveIcons!: QueryList<MatChipRemove>;
147
148 _hasFocus() {
149 return this._hasFocusInternal;
150 }
151
152 /** A unique id for the chip. If none is supplied, it will be auto-generated. */
153 @Input() id: string = inject(_IdGenerator).getId('mat-mdc-chip-');

Callers

nothing calls this directly

Calls 2

_animationsDisabledFunction · 0.90
getIdMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…