Skip to content

Commit af4a9a7

Browse files
committed
refactor(material/chips): convert to standalone
Converts `material/chips` to standalone.
1 parent 824e035 commit af4a9a7

29 files changed

+96
-45
lines changed

src/material/chips/chip-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {MAT_CHIP} from './tokens';
3434
'(click)': '_handleClick($event)',
3535
'(keydown)': '_handleKeydown($event)',
3636
},
37+
standalone: true,
3738
})
3839
export class MatChipAction {
3940
/** Whether the action is interactive. */

src/material/chips/chip-edit-input.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ describe('MDC-based MatChipEditInput', () => {
1212

1313
beforeEach(waitForAsync(() => {
1414
TestBed.configureTestingModule({
15-
imports: [MatChipsModule],
16-
declarations: [ChipEditInputContainer],
15+
imports: [MatChipsModule, ChipEditInputContainer],
1716
});
1817

1918
TestBed.compileComponents();
@@ -45,5 +44,7 @@ describe('MDC-based MatChipEditInput', () => {
4544

4645
@Component({
4746
template: `<mat-chip><span matChipEditInput></span></mat-chip>`,
47+
standalone: true,
48+
imports: [MatChipsModule],
4849
})
4950
class ChipEditInputContainer {}

src/material/chips/chip-edit-input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {DOCUMENT} from '@angular/common';
2121
'tabindex': '-1',
2222
'contenteditable': 'true',
2323
},
24+
standalone: true,
2425
})
2526
export class MatChipEditInput {
2627
constructor(

src/material/chips/chip-grid.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,11 +1007,11 @@ describe('MDC-based MatChipGrid', () => {
10071007
MatInputModule,
10081008
animationsModule,
10091009
],
1010-
declarations: [component],
10111010
providers: [
10121011
{provide: NgZone, useFactory: () => (zone = new MockNgZone())},
10131012
{provide: Directionality, useValue: directionality},
10141013
],
1014+
declarations: [component],
10151015
}).compileComponents();
10161016

10171017
const fixture = TestBed.createComponent<T>(component);

src/material/chips/chip-grid.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class MatChipGridChange {
8080
providers: [{provide: MatFormFieldControl, useExisting: MatChipGrid}],
8181
encapsulation: ViewEncapsulation.None,
8282
changeDetection: ChangeDetectionStrategy.OnPush,
83+
standalone: true,
8384
})
8485
export class MatChipGrid
8586
extends MatChipSet

src/material/chips/chip-icons.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {MAT_CHIP_AVATAR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON} from './tokens
1919
'role': 'img',
2020
},
2121
providers: [{provide: MAT_CHIP_AVATAR, useExisting: MatChipAvatar}],
22+
standalone: true,
2223
})
2324
export class MatChipAvatar {}
2425

@@ -31,6 +32,7 @@ export class MatChipAvatar {}
3132
'aria-hidden': 'true',
3233
},
3334
providers: [{provide: MAT_CHIP_TRAILING_ICON, useExisting: MatChipTrailingIcon}],
35+
standalone: true,
3436
})
3537
export class MatChipTrailingIcon extends MatChipAction {
3638
/**
@@ -68,6 +70,7 @@ export class MatChipTrailingIcon extends MatChipAction {
6870
'[attr.aria-hidden]': 'null',
6971
},
7072
providers: [{provide: MAT_CHIP_REMOVE, useExisting: MatChipRemove}],
73+
standalone: true,
7174
})
7275
export class MatChipRemove extends MatChipAction {
7376
override _isPrimary = false;

src/material/chips/chip-input.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Directionality} from '@angular/cdk/bidi';
22
import {COMMA, ENTER, TAB} from '@angular/cdk/keycodes';
33
import {PlatformModule} from '@angular/cdk/platform';
4-
import {dispatchKeyboardEvent} from '../../cdk/testing/private';
4+
import {dispatchKeyboardEvent} from '@angular/cdk/testing/private';
55
import {Component, DebugElement, ViewChild} from '@angular/core';
66
import {waitForAsync, ComponentFixture, fakeAsync, TestBed, flush} from '@angular/core/testing';
77
import {MatFormFieldModule} from '@angular/material/form-field';
@@ -28,7 +28,6 @@ describe('MDC-based MatChipInput', () => {
2828
beforeEach(waitForAsync(() => {
2929
TestBed.configureTestingModule({
3030
imports: [PlatformModule, MatChipsModule, MatFormFieldModule, NoopAnimationsModule],
31-
declarations: [TestChipInput],
3231
providers: [
3332
{
3433
provide: Directionality,
@@ -40,6 +39,7 @@ describe('MDC-based MatChipInput', () => {
4039
},
4140
},
4241
],
42+
declarations: [TestChipInput],
4343
});
4444

4545
TestBed.compileComponents();

src/material/chips/chip-input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ let nextUniqueId = 0;
6868
'[attr.aria-required]': '_chipGrid && _chipGrid.required || null',
6969
'[attr.required]': '_chipGrid && _chipGrid.required || null',
7070
},
71+
standalone: true,
7172
})
7273
export class MatChipInput implements MatChipTextControl, AfterContentInit, OnChanges, OnDestroy {
7374
/** Used to prevent focus moving to chips while user is holding backspace */

src/material/chips/chip-listbox.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,17 @@ describe('MDC-based MatChipListbox', () => {
517517

518518
primaryActions[1].click();
519519
fixture.detectChanges();
520+
flush();
520521
expect(getAriaSelected()).toEqual(['false', 'true', 'false']);
521522

522523
primaryActions[2].click();
523524
fixture.detectChanges();
525+
flush();
524526
expect(getAriaSelected()).toEqual(['false', 'false', 'true']);
525527

526528
primaryActions[0].click();
527529
fixture.detectChanges();
530+
flush();
528531
expect(getAriaSelected()).toEqual(['true', 'false', 'false']);
529532
}));
530533

@@ -552,18 +555,22 @@ describe('MDC-based MatChipListbox', () => {
552555

553556
primaryActions[1].click();
554557
fixture.detectChanges();
558+
flush();
555559
expect(getAriaSelected()).toEqual(['false', 'true', 'false']);
556560

557561
primaryActions[2].click();
558562
fixture.detectChanges();
563+
flush();
559564
expect(getAriaSelected()).toEqual(['false', 'true', 'true']);
560565

561566
primaryActions[0].click();
562567
fixture.detectChanges();
568+
flush();
563569
expect(getAriaSelected()).toEqual(['true', 'true', 'true']);
564570

565571
primaryActions[1].click();
566572
fixture.detectChanges();
573+
flush();
567574
expect(getAriaSelected()).toEqual(['true', 'false', 'true']);
568575
}));
569576
});
@@ -843,11 +850,11 @@ describe('MDC-based MatChipListbox', () => {
843850

844851
TestBed.configureTestingModule({
845852
imports: [FormsModule, ReactiveFormsModule, MatChipsModule],
846-
declarations: [component],
847853
providers: [
848854
{provide: NgZone, useFactory: () => (zone = new MockNgZone())},
849855
{provide: Directionality, useValue: directionality},
850856
],
857+
declarations: [component],
851858
}).compileComponents();
852859

853860
fixture = TestBed.createComponent<T>(component);

src/material/chips/chip-listbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const MAT_CHIP_LISTBOX_CONTROL_VALUE_ACCESSOR: any = {
8484
providers: [MAT_CHIP_LISTBOX_CONTROL_VALUE_ACCESSOR],
8585
encapsulation: ViewEncapsulation.None,
8686
changeDetection: ChangeDetectionStrategy.OnPush,
87+
standalone: true,
8788
})
8889
export class MatChipListbox
8990
extends MatChipSet

0 commit comments

Comments
 (0)