Skip to content

Commit 85a577c

Browse files
committed
refactor(material/sort): convert to standalone
Converts `material/sort` to standalone.
1 parent e6ad74f commit 85a577c

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed

src/material/sort/sort-header.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ interface MatSortHeaderColumnDef {
9393
matSortAnimations.arrowPosition,
9494
matSortAnimations.allowChildren,
9595
],
96+
standalone: true,
9697
})
9798
export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewInit {
9899
private _rerenderSubscription: Subscription;

src/material/sort/sort-module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import {MAT_SORT_HEADER_INTL_PROVIDER} from './sort-header-intl';
1313
import {MatCommonModule} from '@angular/material/core';
1414

1515
@NgModule({
16-
imports: [MatCommonModule],
16+
imports: [MatCommonModule, MatSort, MatSortHeader],
1717
exports: [MatSort, MatSortHeader],
18-
declarations: [MatSort, MatSortHeader],
1918
providers: [MAT_SORT_HEADER_INTL_PROVIDER],
2019
})
2120
export class MatSortModule {}

src/material/sort/sort.spec.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
createMouseEvent,
66
dispatchMouseEvent,
77
wrappedErrorMessage,
8-
} from '../../cdk/testing/private';
8+
} from '@angular/cdk/testing/private';
99
import {Component, ElementRef, ViewChild} from '@angular/core';
1010
import {waitForAsync, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
1111
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
@@ -35,8 +35,11 @@ describe('MatSort', () => {
3535

3636
beforeEach(waitForAsync(() => {
3737
TestBed.configureTestingModule({
38-
imports: [MatSortModule, MatTableModule, CdkTableModule, NoopAnimationsModule],
39-
declarations: [
38+
imports: [
39+
MatSortModule,
40+
MatTableModule,
41+
CdkTableModule,
42+
NoopAnimationsModule,
4043
SimpleMatSortApp,
4144
CdkTableMatSortApp,
4245
MatTableMatSortApp,
@@ -507,8 +510,13 @@ describe('MatSort', () => {
507510

508511
beforeEach(waitForAsync(() => {
509512
TestBed.configureTestingModule({
510-
imports: [MatSortModule, MatTableModule, CdkTableModule, NoopAnimationsModule],
511-
declarations: [MatSortWithoutExplicitInputs],
513+
imports: [
514+
MatSortModule,
515+
MatTableModule,
516+
CdkTableModule,
517+
NoopAnimationsModule,
518+
MatSortWithoutExplicitInputs,
519+
],
512520
providers: [
513521
{
514522
provide: MAT_SORT_DEFAULT_OPTIONS,
@@ -541,8 +549,13 @@ describe('MatSort', () => {
541549

542550
beforeEach(waitForAsync(() => {
543551
TestBed.configureTestingModule({
544-
imports: [MatSortModule, MatTableModule, CdkTableModule, NoopAnimationsModule],
545-
declarations: [MatSortWithoutInputs],
552+
imports: [
553+
MatSortModule,
554+
MatTableModule,
555+
CdkTableModule,
556+
NoopAnimationsModule,
557+
MatSortWithoutInputs,
558+
],
546559
providers: [
547560
{
548561
provide: MAT_SORT_DEFAULT_OPTIONS,
@@ -648,6 +661,8 @@ type SimpleMatSortAppColumnIds = 'defaultA' | 'defaultB' | 'overrideStart' | 'ov
648661
</div>
649662
</div>
650663
`,
664+
standalone: true,
665+
imports: [MatSortModule, MatTableModule, CdkTableModule],
651666
})
652667
class SimpleMatSortApp {
653668
latestSortEvent: Sort;
@@ -728,6 +743,8 @@ class FakeDataSource extends DataSource<any> {
728743
<cdk-row *cdkRowDef="let row; columns: columnsToRender"></cdk-row>
729744
</cdk-table>
730745
`,
746+
standalone: true,
747+
imports: [MatSortModule, MatTableModule, CdkTableModule],
731748
})
732749
class CdkTableMatSortApp {
733750
@ViewChild(MatSort) matSort: MatSort;
@@ -758,6 +775,8 @@ class CdkTableMatSortApp {
758775
<mat-row *matRowDef="let row; columns: columnsToRender"></mat-row>
759776
</mat-table>
760777
`,
778+
standalone: true,
779+
imports: [MatSortModule, MatTableModule, CdkTableModule],
761780
})
762781
class MatTableMatSortApp {
763782
@ViewChild(MatSort) matSort: MatSort;
@@ -768,6 +787,8 @@ class MatTableMatSortApp {
768787

769788
@Component({
770789
template: `<div mat-sort-header="a"> A </div>`,
790+
standalone: true,
791+
imports: [MatSortModule, MatTableModule, CdkTableModule],
771792
})
772793
class MatSortHeaderMissingMatSortApp {}
773794

@@ -778,6 +799,8 @@ class MatSortHeaderMissingMatSortApp {}
778799
<div mat-sort-header="duplicateId"> A </div>
779800
</div>
780801
`,
802+
standalone: true,
803+
imports: [MatSortModule, MatTableModule, CdkTableModule],
781804
})
782805
class MatSortDuplicateMatSortableIdsApp {}
783806

@@ -787,6 +810,8 @@ class MatSortDuplicateMatSortableIdsApp {}
787810
<div mat-sort-header> A </div>
788811
</div>
789812
`,
813+
standalone: true,
814+
imports: [MatSortModule, MatTableModule, CdkTableModule],
790815
})
791816
class MatSortableMissingIdApp {}
792817

@@ -796,6 +821,8 @@ class MatSortableMissingIdApp {}
796821
<div mat-sort-header="a"> A </div>
797822
</div>
798823
`,
824+
standalone: true,
825+
imports: [MatSortModule, MatTableModule, CdkTableModule],
799826
})
800827
class MatSortableInvalidDirection {}
801828

@@ -810,6 +837,8 @@ class MatSortableInvalidDirection {}
810837
</div>
811838
</div>
812839
`,
840+
standalone: true,
841+
imports: [MatSortModule, MatTableModule, CdkTableModule],
813842
})
814843
class MatSortWithoutExplicitInputs {
815844
latestSortEvent: Sort;
@@ -843,6 +872,8 @@ class MatSortWithoutExplicitInputs {
843872
</div>
844873
</div>
845874
`,
875+
standalone: true,
876+
imports: [MatSortModule, MatTableModule, CdkTableModule],
846877
})
847878
class MatSortWithArrowPosition {
848879
arrowPosition?: 'before' | 'after';
@@ -862,6 +893,8 @@ class MatSortWithArrowPosition {
862893
</div>
863894
</div>
864895
`,
896+
standalone: true,
897+
imports: [MatSortModule, MatTableModule, CdkTableModule],
865898
})
866899
class MatSortWithoutInputs {
867900
@ViewChild(MatSort) matSort: MatSort;

src/material/sort/sort.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const _MatSortBase = mixinInitialized(class {});
7676
host: {
7777
'class': 'mat-sort',
7878
},
79+
standalone: true,
7980
})
8081
export class MatSort extends _MatSortBase implements HasInitialized, OnChanges, OnDestroy, OnInit {
8182
/** Collection of all registered sortables that this directive manages. */

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

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

1313
beforeEach(async () => {
1414
await TestBed.configureTestingModule({
15-
imports: [MatSortModule, NoopAnimationsModule],
16-
declarations: [SortHarnessTest],
15+
imports: [MatSortModule, NoopAnimationsModule, SortHarnessTest],
1716
}).compileComponents();
1817

1918
fixture = TestBed.createComponent(SortHarnessTest);
@@ -138,6 +137,8 @@ describe('MatSortHarness', () => {
138137
}
139138
</table>
140139
`,
140+
standalone: true,
141+
imports: [MatSortModule],
141142
})
142143
class SortHarnessTest {
143144
disableThirdHeader = false;

tools/public_api_guard/material/sort.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { EventEmitter } from '@angular/core';
1313
import { FocusMonitor } from '@angular/cdk/a11y';
1414
import { HasInitialized } from '@angular/material/core';
1515
import * as i0 from '@angular/core';
16-
import * as i3 from '@angular/material/core';
16+
import * as i1 from '@angular/material/core';
1717
import { InjectionToken } from '@angular/core';
1818
import { OnChanges } from '@angular/core';
1919
import { OnDestroy } from '@angular/core';
@@ -72,7 +72,7 @@ export class MatSort extends _MatSortBase implements HasInitialized, OnChanges,
7272
start: SortDirection;
7373
readonly _stateChanges: Subject<void>;
7474
// (undocumented)
75-
static ɵdir: i0.ɵɵDirectiveDeclaration<MatSort, "[matSort]", ["matSort"], { "active": { "alias": "matSortActive"; "required": false; }; "start": { "alias": "matSortStart"; "required": false; }; "direction": { "alias": "matSortDirection"; "required": false; }; "disableClear": { "alias": "matSortDisableClear"; "required": false; }; "disabled": { "alias": "matSortDisabled"; "required": false; }; }, { "sortChange": "matSortChange"; }, never, never, false, never>;
75+
static ɵdir: i0.ɵɵDirectiveDeclaration<MatSort, "[matSort]", ["matSort"], { "active": { "alias": "matSortActive"; "required": false; }; "start": { "alias": "matSortStart"; "required": false; }; "direction": { "alias": "matSortDirection"; "required": false; }; "disableClear": { "alias": "matSortDisableClear"; "required": false; }; "disabled": { "alias": "matSortDisabled"; "required": false; }; }, { "sortChange": "matSortChange"; }, never, never, true, never>;
7676
// (undocumented)
7777
static ɵfac: i0.ɵɵFactoryDeclaration<MatSort, [{ optional: true; }]>;
7878
}
@@ -148,7 +148,7 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI
148148
_updateArrowDirection(): void;
149149
_viewState: ArrowViewStateTransition;
150150
// (undocumented)
151-
static ɵcmp: i0.ɵɵComponentDeclaration<MatSortHeader, "[mat-sort-header]", ["matSortHeader"], { "id": { "alias": "mat-sort-header"; "required": false; }; "arrowPosition": { "alias": "arrowPosition"; "required": false; }; "start": { "alias": "start"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "sortActionDescription": { "alias": "sortActionDescription"; "required": false; }; "disableClear": { "alias": "disableClear"; "required": false; }; }, {}, never, ["*"], false, never>;
151+
static ɵcmp: i0.ɵɵComponentDeclaration<MatSortHeader, "[mat-sort-header]", ["matSortHeader"], { "id": { "alias": "mat-sort-header"; "required": false; }; "arrowPosition": { "alias": "arrowPosition"; "required": false; }; "start": { "alias": "start"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "sortActionDescription": { "alias": "sortActionDescription"; "required": false; }; "disableClear": { "alias": "disableClear"; "required": false; }; }, {}, never, ["*"], true, never>;
152152
// (undocumented)
153153
static ɵfac: i0.ɵɵFactoryDeclaration<MatSortHeader, [null, null, { optional: true; }, { optional: true; }, null, null, { optional: true; }, { optional: true; }]>;
154154
}
@@ -169,7 +169,7 @@ export class MatSortModule {
169169
// (undocumented)
170170
static ɵinj: i0.ɵɵInjectorDeclaration<MatSortModule>;
171171
// (undocumented)
172-
static ɵmod: i0.ɵɵNgModuleDeclaration<MatSortModule, [typeof i1.MatSort, typeof i2.MatSortHeader], [typeof i3.MatCommonModule], [typeof i1.MatSort, typeof i2.MatSortHeader]>;
172+
static ɵmod: i0.ɵɵNgModuleDeclaration<MatSortModule, never, [typeof i1.MatCommonModule, typeof i2.MatSort, typeof i3.MatSortHeader], [typeof i2.MatSort, typeof i3.MatSortHeader]>;
173173
}
174174

175175
// @public

0 commit comments

Comments
 (0)