Skip to content

Commit 678d935

Browse files
committed
refactor(material/expansion): convert to standalone
Converts `material/expansion` to standalone.
1 parent 5fccb18 commit 678d935

File tree

9 files changed

+70
-24
lines changed

9 files changed

+70
-24
lines changed

src/material/expansion/accordion.spec.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
MatExpansionPanel,
99
MatExpansionPanelHeader,
1010
} from './index';
11-
import {dispatchKeyboardEvent, createKeyboardEvent, dispatchEvent} from '../../cdk/testing/private';
11+
import {
12+
dispatchKeyboardEvent,
13+
createKeyboardEvent,
14+
dispatchEvent,
15+
} from '@angular/cdk/testing/private';
1216
import {DOWN_ARROW, UP_ARROW, HOME, END} from '@angular/cdk/keycodes';
1317
import {FocusMonitor} from '@angular/cdk/a11y';
1418

@@ -17,8 +21,9 @@ describe('MatAccordion', () => {
1721

1822
beforeEach(waitForAsync(() => {
1923
TestBed.configureTestingModule({
20-
imports: [BrowserAnimationsModule, MatExpansionModule],
21-
declarations: [
24+
imports: [
25+
BrowserAnimationsModule,
26+
MatExpansionModule,
2227
AccordionWithHideToggle,
2328
AccordionWithTogglePosition,
2429
NestedPanel,
@@ -310,6 +315,8 @@ describe('MatAccordion', () => {
310315
</mat-expansion-panel>
311316
}
312317
</mat-accordion>`,
318+
standalone: true,
319+
imports: [MatExpansionModule],
313320
})
314321
class SetOfItems {
315322
@ViewChild(MatAccordion) accordion: MatAccordion;
@@ -337,6 +344,8 @@ class SetOfItems {
337344
Content 1
338345
</mat-expansion-panel>
339346
</mat-accordion>`,
347+
standalone: true,
348+
imports: [MatExpansionModule],
340349
})
341350
class NestedAccordions {
342351
@ViewChildren(MatExpansionPanelHeader) headers: QueryList<MatExpansionPanelHeader>;
@@ -355,6 +364,8 @@ class NestedAccordions {
355364
</mat-expansion-panel>
356365
</mat-expansion-panel>
357366
</mat-accordion>`,
367+
standalone: true,
368+
imports: [MatExpansionModule],
358369
})
359370
class NestedPanel {
360371
@ViewChild('outerPanel') outerPanel: MatExpansionPanel;
@@ -369,6 +380,8 @@ class NestedPanel {
369380
<p>Content</p>
370381
</mat-expansion-panel>
371382
</mat-accordion>`,
383+
standalone: true,
384+
imports: [MatExpansionModule],
372385
})
373386
class AccordionWithHideToggle {
374387
hideToggle = false;
@@ -382,6 +395,8 @@ class AccordionWithHideToggle {
382395
<p>Content</p>
383396
</mat-expansion-panel>
384397
</mat-accordion>`,
398+
standalone: true,
399+
imports: [MatExpansionModule],
385400
})
386401
class AccordionWithTogglePosition {
387402
togglePosition = 'after';

src/material/expansion/accordion.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {MatExpansionPanelHeader} from './expansion-panel-header';
4545
// way for the harness to detect if multiple panel support is enabled.
4646
'[class.mat-accordion-multi]': 'this.multi',
4747
},
48+
standalone: true,
4849
})
4950
export class MatAccordion
5051
extends CdkAccordion

src/material/expansion/expansion-module.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import {
2020
} from './expansion-panel-header';
2121

2222
@NgModule({
23-
imports: [MatCommonModule, CdkAccordionModule, PortalModule],
24-
exports: [
23+
imports: [
24+
MatCommonModule,
25+
CdkAccordionModule,
26+
PortalModule,
2527
MatAccordion,
2628
MatExpansionPanel,
2729
MatExpansionPanelActionRow,
@@ -30,7 +32,7 @@ import {
3032
MatExpansionPanelDescription,
3133
MatExpansionPanelContent,
3234
],
33-
declarations: [
35+
exports: [
3436
MatAccordion,
3537
MatExpansionPanel,
3638
MatExpansionPanelActionRow,

src/material/expansion/expansion-panel-content.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {MAT_EXPANSION_PANEL, MatExpansionPanelBase} from './expansion-panel-base
1515
*/
1616
@Directive({
1717
selector: 'ng-template[matExpansionPanelContent]',
18+
standalone: true,
1819
})
1920
export class MatExpansionPanelContent {
2021
constructor(

src/material/expansion/expansion-panel-header.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import {
6161
'(click)': '_toggle()',
6262
'(keydown)': '_keydown($event)',
6363
},
64+
standalone: true,
6465
})
6566
export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, FocusableOption {
6667
private _parentChangeSubscription = Subscription.EMPTY;
@@ -229,6 +230,7 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa
229230
host: {
230231
class: 'mat-expansion-panel-header-description',
231232
},
233+
standalone: true,
232234
})
233235
export class MatExpansionPanelDescription {}
234236

@@ -240,5 +242,6 @@ export class MatExpansionPanelDescription {}
240242
host: {
241243
class: 'mat-expansion-panel-header-title',
242244
},
245+
standalone: true,
243246
})
244247
export class MatExpansionPanelTitle {}

src/material/expansion/expansion-panel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {AnimationEvent} from '@angular/animations';
1010
import {CdkAccordionItem} from '@angular/cdk/accordion';
1111
import {UniqueSelectionDispatcher} from '@angular/cdk/collections';
12-
import {TemplatePortal} from '@angular/cdk/portal';
12+
import {CdkPortalOutlet, TemplatePortal} from '@angular/cdk/portal';
1313
import {DOCUMENT} from '@angular/common';
1414
import {
1515
AfterContentInit,
@@ -96,6 +96,8 @@ export const MAT_EXPANSION_PANEL_DEFAULT_OPTIONS =
9696
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
9797
'[class.mat-expansion-panel-spacing]': '_hasSpacing()',
9898
},
99+
standalone: true,
100+
imports: [CdkPortalOutlet],
99101
})
100102
export class MatExpansionPanel
101103
extends CdkAccordionItem
@@ -261,5 +263,6 @@ export class MatExpansionPanel
261263
host: {
262264
class: 'mat-action-row',
263265
},
266+
standalone: true,
264267
})
265268
export class MatExpansionPanelActionRow {}

src/material/expansion/expansion.spec.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ import {
1616
MAT_EXPANSION_PANEL_DEFAULT_OPTIONS,
1717
} from './index';
1818
import {SPACE, ENTER} from '@angular/cdk/keycodes';
19-
import {dispatchKeyboardEvent, createKeyboardEvent, dispatchEvent} from '../../cdk/testing/private';
19+
import {
20+
dispatchKeyboardEvent,
21+
createKeyboardEvent,
22+
dispatchEvent,
23+
} from '@angular/cdk/testing/private';
2024

2125
describe('MatExpansionPanel', () => {
2226
beforeEach(waitForAsync(() => {
2327
TestBed.configureTestingModule({
24-
imports: [MatExpansionModule, NoopAnimationsModule],
25-
declarations: [
28+
imports: [
29+
MatExpansionModule,
30+
NoopAnimationsModule,
2631
PanelWithContent,
2732
PanelWithContentInNgIf,
2833
PanelWithCustomMargin,
@@ -400,7 +405,6 @@ describe('MatExpansionPanel', () => {
400405
TestBed.resetTestingModule()
401406
.configureTestingModule({
402407
imports: [MatExpansionModule, NoopAnimationsModule],
403-
declarations: [PanelWithTwoWayBinding],
404408
providers: [
405409
{
406410
provide: MAT_EXPANSION_PANEL_DEFAULT_OPTIONS,
@@ -570,6 +574,8 @@ describe('MatExpansionPanel', () => {
570574
<p>Some content</p>
571575
<button>I am a button</button>
572576
</mat-expansion-panel>`,
577+
standalone: true,
578+
imports: [MatExpansionModule],
573579
})
574580
class PanelWithContent {
575581
expanded = false;
@@ -590,6 +596,8 @@ class PanelWithContent {
590596
</div>
591597
}
592598
`,
599+
standalone: true,
600+
imports: [MatExpansionModule],
593601
})
594602
class PanelWithContentInNgIf {
595603
expansionShown = true;
@@ -607,6 +615,8 @@ class PanelWithContentInNgIf {
607615
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores officia, aliquam dicta
608616
corrupti maxime voluptate accusamus impedit atque incidunt pariatur.
609617
</mat-expansion-panel>`,
618+
standalone: true,
619+
imports: [MatExpansionModule],
610620
})
611621
class PanelWithCustomMargin {
612622
expanded = false;
@@ -622,6 +632,8 @@ class PanelWithCustomMargin {
622632
<button>I am a button</button>
623633
</ng-template>
624634
</mat-expansion-panel>`,
635+
standalone: true,
636+
imports: [MatExpansionModule],
625637
})
626638
class LazyPanelWithContent {
627639
expanded = false;
@@ -636,6 +648,8 @@ class LazyPanelWithContent {
636648
<p>Some content</p>
637649
</ng-template>
638650
</mat-expansion-panel>`,
651+
standalone: true,
652+
imports: [MatExpansionModule],
639653
})
640654
class LazyPanelOpenOnLoad {}
641655

@@ -644,6 +658,8 @@ class LazyPanelOpenOnLoad {}
644658
<mat-expansion-panel [(expanded)]="expanded">
645659
<mat-expansion-panel-header>Panel Title</mat-expansion-panel-header>
646660
</mat-expansion-panel>`,
661+
standalone: true,
662+
imports: [MatExpansionModule],
647663
})
648664
class PanelWithTwoWayBinding {
649665
expanded = false;
@@ -654,6 +670,8 @@ class PanelWithTwoWayBinding {
654670
<mat-expansion-panel>
655671
<mat-expansion-panel-header tabindex="7">Panel Title</mat-expansion-panel-header>
656672
</mat-expansion-panel>`,
673+
standalone: true,
674+
imports: [MatExpansionModule],
657675
})
658676
class PanelWithHeaderTabindex {}
659677

@@ -667,6 +685,8 @@ class PanelWithHeaderTabindex {}
667685
</mat-expansion-panel>
668686
</mat-expansion-panel>
669687
`,
688+
standalone: true,
689+
imports: [MatExpansionModule],
670690
})
671691
class NestedLazyPanelWithContent {
672692
parentExpanded = false;

src/material/expansion/testing/expansion-harness.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ describe('MatExpansionHarness', () => {
1313

1414
beforeEach(async () => {
1515
await TestBed.configureTestingModule({
16-
imports: [MatExpansionModule, NoopAnimationsModule],
17-
declarations: [ExpansionHarnessTestComponent],
16+
imports: [MatExpansionModule, NoopAnimationsModule, ExpansionHarnessTestComponent],
1817
}).compileComponents();
1918

2019
fixture = TestBed.createComponent(ExpansionHarnessTestComponent);
@@ -321,6 +320,8 @@ function getActiveElementTag() {
321320
322321
<div class="test-content-harness">Outside of expansion panel</div>
323322
`,
323+
standalone: true,
324+
imports: [MatExpansionModule],
324325
})
325326
class ExpansionHarnessTestComponent {
326327
panel1Expanded = false;

tools/public_api_guard/material/expansion.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import { FocusableOption } from '@angular/cdk/a11y';
1717
import { FocusMonitor } from '@angular/cdk/a11y';
1818
import { FocusOrigin } from '@angular/cdk/a11y';
1919
import * as i0 from '@angular/core';
20-
import * as i5 from '@angular/material/core';
21-
import * as i6 from '@angular/cdk/accordion';
22-
import * as i7 from '@angular/cdk/portal';
20+
import * as i1 from '@angular/material/core';
21+
import * as i2 from '@angular/cdk/accordion';
22+
import * as i3 from '@angular/cdk/portal';
2323
import { InjectionToken } from '@angular/core';
2424
import { OnChanges } from '@angular/core';
2525
import { OnDestroy } from '@angular/core';
@@ -59,7 +59,7 @@ export class MatAccordion extends CdkAccordion implements MatAccordionBase, Afte
5959
ngOnDestroy(): void;
6060
togglePosition: MatAccordionTogglePosition;
6161
// (undocumented)
62-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatAccordion, "mat-accordion", ["matAccordion"], { "multi": { "alias": "multi"; "required": false; }; "hideToggle": { "alias": "hideToggle"; "required": false; }; "displayMode": { "alias": "displayMode"; "required": false; }; "togglePosition": { "alias": "togglePosition"; "required": false; }; }, {}, ["_headers"], never, false, never>;
62+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatAccordion, "mat-accordion", ["matAccordion"], { "multi": { "alias": "multi"; "required": false; }; "hideToggle": { "alias": "hideToggle"; "required": false; }; "displayMode": { "alias": "displayMode"; "required": false; }; "togglePosition": { "alias": "togglePosition"; "required": false; }; }, {}, ["_headers"], never, true, never>;
6363
// (undocumented)
6464
static ɵfac: i0.ɵɵFactoryDeclaration<MatAccordion, never>;
6565
}
@@ -92,7 +92,7 @@ export class MatExpansionModule {
9292
// (undocumented)
9393
static ɵinj: i0.ɵɵInjectorDeclaration<MatExpansionModule>;
9494
// (undocumented)
95-
static ɵmod: i0.ɵɵNgModuleDeclaration<MatExpansionModule, [typeof i1.MatAccordion, typeof i2.MatExpansionPanel, typeof i2.MatExpansionPanelActionRow, typeof i3.MatExpansionPanelHeader, typeof i3.MatExpansionPanelTitle, typeof i3.MatExpansionPanelDescription, typeof i4.MatExpansionPanelContent], [typeof i5.MatCommonModule, typeof i6.CdkAccordionModule, typeof i7.PortalModule], [typeof i1.MatAccordion, typeof i2.MatExpansionPanel, typeof i2.MatExpansionPanelActionRow, typeof i3.MatExpansionPanelHeader, typeof i3.MatExpansionPanelTitle, typeof i3.MatExpansionPanelDescription, typeof i4.MatExpansionPanelContent]>;
95+
static ɵmod: i0.ɵɵNgModuleDeclaration<MatExpansionModule, never, [typeof i1.MatCommonModule, typeof i2.CdkAccordionModule, typeof i3.PortalModule, typeof i4.MatAccordion, typeof i5.MatExpansionPanel, typeof i5.MatExpansionPanelActionRow, typeof i6.MatExpansionPanelHeader, typeof i6.MatExpansionPanelTitle, typeof i6.MatExpansionPanelDescription, typeof i7.MatExpansionPanelContent], [typeof i4.MatAccordion, typeof i5.MatExpansionPanel, typeof i5.MatExpansionPanelActionRow, typeof i6.MatExpansionPanelHeader, typeof i6.MatExpansionPanelTitle, typeof i6.MatExpansionPanelDescription, typeof i7.MatExpansionPanelContent]>;
9696
}
9797

9898
// @public
@@ -128,15 +128,15 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
128128
get togglePosition(): MatAccordionTogglePosition;
129129
set togglePosition(value: MatAccordionTogglePosition);
130130
// (undocumented)
131-
static ɵcmp: i0.ɵɵComponentDeclaration<MatExpansionPanel, "mat-expansion-panel", ["matExpansionPanel"], { "disabled": { "alias": "disabled"; "required": false; }; "expanded": { "alias": "expanded"; "required": false; }; "hideToggle": { "alias": "hideToggle"; "required": false; }; "togglePosition": { "alias": "togglePosition"; "required": false; }; }, { "opened": "opened"; "closed": "closed"; "expandedChange": "expandedChange"; "afterExpand": "afterExpand"; "afterCollapse": "afterCollapse"; }, ["_lazyContent"], ["mat-expansion-panel-header", "*", "mat-action-row"], false, never>;
131+
static ɵcmp: i0.ɵɵComponentDeclaration<MatExpansionPanel, "mat-expansion-panel", ["matExpansionPanel"], { "disabled": { "alias": "disabled"; "required": false; }; "expanded": { "alias": "expanded"; "required": false; }; "hideToggle": { "alias": "hideToggle"; "required": false; }; "togglePosition": { "alias": "togglePosition"; "required": false; }; }, { "opened": "opened"; "closed": "closed"; "expandedChange": "expandedChange"; "afterExpand": "afterExpand"; "afterCollapse": "afterCollapse"; }, ["_lazyContent"], ["mat-expansion-panel-header", "*", "mat-action-row"], true, never>;
132132
// (undocumented)
133133
static ɵfac: i0.ɵɵFactoryDeclaration<MatExpansionPanel, [{ optional: true; skipSelf: true; }, null, null, null, null, { optional: true; }, { optional: true; }]>;
134134
}
135135

136136
// @public
137137
export class MatExpansionPanelActionRow {
138138
// (undocumented)
139-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelActionRow, "mat-action-row", never, {}, {}, never, never, false, never>;
139+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelActionRow, "mat-action-row", never, {}, {}, never, never, true, never>;
140140
// (undocumented)
141141
static ɵfac: i0.ɵɵFactoryDeclaration<MatExpansionPanelActionRow, never>;
142142
}
@@ -149,7 +149,7 @@ export class MatExpansionPanelContent {
149149
// (undocumented)
150150
_template: TemplateRef<any>;
151151
// (undocumented)
152-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelContent, "ng-template[matExpansionPanelContent]", never, {}, {}, never, never, false, never>;
152+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelContent, "ng-template[matExpansionPanelContent]", never, {}, {}, never, never, true, never>;
153153
// (undocumented)
154154
static ɵfac: i0.ɵɵFactoryDeclaration<MatExpansionPanelContent, [null, { optional: true; }]>;
155155
}
@@ -164,7 +164,7 @@ export interface MatExpansionPanelDefaultOptions {
164164
// @public
165165
export class MatExpansionPanelDescription {
166166
// (undocumented)
167-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelDescription, "mat-panel-description", never, {}, {}, never, never, false, never>;
167+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelDescription, "mat-panel-description", never, {}, {}, never, never, true, never>;
168168
// (undocumented)
169169
static ɵfac: i0.ɵɵFactoryDeclaration<MatExpansionPanelDescription, never>;
170170
}
@@ -196,7 +196,7 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa
196196
tabIndex: number;
197197
_toggle(): void;
198198
// (undocumented)
199-
static ɵcmp: i0.ɵɵComponentDeclaration<MatExpansionPanelHeader, "mat-expansion-panel-header", never, { "expandedHeight": { "alias": "expandedHeight"; "required": false; }; "collapsedHeight": { "alias": "collapsedHeight"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, {}, never, ["mat-panel-title", "mat-panel-description", "*"], false, never>;
199+
static ɵcmp: i0.ɵɵComponentDeclaration<MatExpansionPanelHeader, "mat-expansion-panel-header", never, { "expandedHeight": { "alias": "expandedHeight"; "required": false; }; "collapsedHeight": { "alias": "collapsedHeight"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, {}, never, ["mat-panel-title", "mat-panel-description", "*"], true, never>;
200200
// (undocumented)
201201
static ɵfac: i0.ɵɵFactoryDeclaration<MatExpansionPanelHeader, [{ host: true; }, null, null, null, { optional: true; }, { optional: true; }, { attribute: "tabindex"; }]>;
202202
}
@@ -207,7 +207,7 @@ export type MatExpansionPanelState = 'expanded' | 'collapsed';
207207
// @public
208208
export class MatExpansionPanelTitle {
209209
// (undocumented)
210-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelTitle, "mat-panel-title", never, {}, {}, never, never, false, never>;
210+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatExpansionPanelTitle, "mat-panel-title", never, {}, {}, never, never, true, never>;
211211
// (undocumented)
212212
static ɵfac: i0.ɵɵFactoryDeclaration<MatExpansionPanelTitle, never>;
213213
}

0 commit comments

Comments
 (0)