Skip to content

Commit 592d00b

Browse files
committed
refactor(cdk-experimental/selection): switch to standalone
Reworks `cdk-experimental/selection` to support standalone.
1 parent e3936b6 commit 592d00b

File tree

8 files changed

+34
-11
lines changed

8 files changed

+34
-11
lines changed

src/cdk-experimental/selection/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ng_test_library(
2929
":selection",
3030
"//src/cdk/table",
3131
"//src/cdk/testing/private",
32+
"@npm//@angular/common",
3233
],
3334
)
3435

src/cdk-experimental/selection/row-selection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {CdkSelection} from './selection';
2424
'[class.cdk-selected]': '_selection.isSelected(this.value, this.index)',
2525
'[attr.aria-selected]': '_selection.isSelected(this.value, this.index)',
2626
},
27+
standalone: true,
2728
})
2829
export class CdkRowSelection<T> {
2930
// We need an initializer here to avoid a TS error.

src/cdk-experimental/selection/select-all.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {CdkSelection} from './selection';
2626
@Directive({
2727
selector: '[cdkSelectAll]',
2828
exportAs: 'cdkSelectAll',
29+
standalone: true,
2930
})
3031
export class CdkSelectAll<T> implements OnDestroy, OnInit {
3132
/**

src/cdk-experimental/selection/selection-column.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import {
2020
} from '@angular/core';
2121

2222
import {CdkSelection} from './selection';
23+
import {AsyncPipe} from '@angular/common';
24+
import {CdkSelectionToggle} from './selection-toggle';
25+
import {CdkSelectAll} from './select-all';
2326

2427
/**
2528
* Column that adds row selecting checkboxes and a select-all checkbox if `cdkSelectionMultiple` is
@@ -54,6 +57,15 @@ import {CdkSelection} from './selection';
5457
`,
5558
changeDetection: ChangeDetectionStrategy.OnPush,
5659
encapsulation: ViewEncapsulation.None,
60+
standalone: true,
61+
imports: [
62+
CdkColumnDef,
63+
CdkHeaderCellDef,
64+
CdkSelectAll,
65+
CdkCellDef,
66+
CdkSelectionToggle,
67+
AsyncPipe,
68+
],
5769
})
5870
export class CdkSelectionColumn<T> implements OnInit, OnDestroy {
5971
/** Column name that should be used to reference this column. */

src/cdk-experimental/selection/selection-module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import {CdkSelectionColumn} from './selection-column';
1717
import {CdkSelectionToggle} from './selection-toggle';
1818

1919
@NgModule({
20-
imports: [CommonModule, CdkTableModule],
21-
exports: [CdkSelection, CdkSelectionToggle, CdkSelectAll, CdkSelectionColumn, CdkRowSelection],
22-
declarations: [
20+
imports: [
21+
CommonModule,
22+
CdkTableModule,
2323
CdkSelection,
2424
CdkSelectionToggle,
2525
CdkSelectAll,
2626
CdkSelectionColumn,
2727
CdkRowSelection,
2828
],
29+
exports: [CdkSelection, CdkSelectionToggle, CdkSelectAll, CdkSelectionColumn, CdkRowSelection],
2930
})
3031
export class CdkSelectionModule {}

src/cdk-experimental/selection/selection-toggle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {CdkSelection} from './selection';
2727
@Directive({
2828
selector: '[cdkSelectionToggle]',
2929
exportAs: 'cdkSelectionToggle',
30+
standalone: true,
3031
})
3132
export class CdkSelectionToggle<T> implements OnDestroy, OnInit {
3233
/** The value that is associated with the toggle */

src/cdk-experimental/selection/selection.spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {AsyncPipe} from '@angular/common';
12
import {CdkTableModule} from '@angular/cdk/table';
23
import {ChangeDetectorRef, Component, ElementRef, ViewChild} from '@angular/core';
34
import {waitForAsync, ComponentFixture, fakeAsync, flush, TestBed} from '@angular/core/testing';
@@ -12,8 +13,7 @@ describe('CdkSelection', () => {
1213

1314
beforeEach(waitForAsync(() => {
1415
TestBed.configureTestingModule({
15-
imports: [CdkSelectionModule],
16-
declarations: [ListWithMultiSelection],
16+
imports: [CdkSelectionModule, ListWithMultiSelection],
1717
}).compileComponents();
1818
}));
1919

@@ -239,8 +239,7 @@ describe('CdkSelection with multiple = false', () => {
239239

240240
beforeEach(waitForAsync(() => {
241241
TestBed.configureTestingModule({
242-
imports: [CdkSelectionModule],
243-
declarations: [ListWithSingleSelection],
242+
imports: [CdkSelectionModule, ListWithSingleSelection],
244243
}).compileComponents();
245244
}));
246245

@@ -305,8 +304,7 @@ describe('cdkSelectionColumn', () => {
305304

306305
beforeEach(waitForAsync(() => {
307306
TestBed.configureTestingModule({
308-
imports: [CdkSelectionModule, CdkTableModule],
309-
declarations: [MultiSelectTableWithSelectionColumn],
307+
imports: [CdkSelectionModule, CdkTableModule, MultiSelectTableWithSelectionColumn],
310308
}).compileComponents();
311309
}));
312310

@@ -400,8 +398,7 @@ describe('cdkSelectionColumn with multiple = false', () => {
400398

401399
beforeEach(waitForAsync(() => {
402400
TestBed.configureTestingModule({
403-
imports: [CdkSelectionModule, CdkTableModule],
404-
declarations: [SingleSelectTableWithSelectionColumn],
401+
imports: [CdkSelectionModule, CdkTableModule, SingleSelectTableWithSelectionColumn],
405402
}).compileComponents();
406403
}));
407404

@@ -454,6 +451,8 @@ describe('cdkSelectionColumn with multiple = false', () => {
454451
</li>
455452
}
456453
</ul>`,
454+
standalone: true,
455+
imports: [CdkSelectionModule, AsyncPipe],
457456
})
458457
class ListWithMultiSelection {
459458
@ViewChild(CdkSelection) cdkSelection: CdkSelection<string>;
@@ -519,6 +518,8 @@ class ListWithMultiSelection {
519518
</li>
520519
}
521520
</ul>`,
521+
standalone: true,
522+
imports: [CdkSelectionModule, AsyncPipe],
522523
})
523524
class ListWithSingleSelection {
524525
@ViewChild(CdkSelection) cdkSelection: CdkSelection<string>;
@@ -561,6 +562,8 @@ class ListWithSingleSelection {
561562
cdkRowSelection [cdkRowSelectionValue]="row"></tr>
562563
</table>
563564
`,
565+
standalone: true,
566+
imports: [CdkSelectionModule, CdkTableModule],
564567
})
565568
class MultiSelectTableWithSelectionColumn {
566569
@ViewChild(CdkSelection) cdkSelection: CdkSelection<string>;
@@ -627,6 +630,8 @@ class MultiSelectTableWithSelectionColumn {
627630
cdkRowSelection [cdkRowSelectionValue]="row"></tr>
628631
</table>
629632
`,
633+
standalone: true,
634+
imports: [CdkSelectionModule, CdkTableModule],
630635
})
631636
class SingleSelectTableWithSelectionColumn {
632637
@ViewChild(CdkSelection) cdkSelection: CdkSelection<string>;

src/cdk-experimental/selection/selection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {SelectableWithIndex, SelectionChange, SelectionSet} from './selection-se
3232
@Directive({
3333
selector: '[cdkSelection]',
3434
exportAs: 'cdkSelection',
35+
standalone: true,
3536
})
3637
export class CdkSelection<T> implements OnInit, AfterContentChecked, CollectionViewer, OnDestroy {
3738
viewChange: Observable<ListRange>;

0 commit comments

Comments
 (0)