From 69702666a171261bd74d3464d9e272a412fb4864 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 28 Nov 2023 10:06:10 +0100 Subject: [PATCH] refactor(material-experimental/selection): switch to standalone Reworks `material-experimental/selection` to support standalone. --- .../selection/row-selection.ts | 1 + .../selection/select-all.ts | 1 + .../selection/selection-column.ts | 25 ++++++++++++++++++- .../selection/selection-module.ts | 8 +++--- .../selection/selection-toggle.ts | 1 + .../selection/selection.ts | 1 + 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/material-experimental/selection/row-selection.ts b/src/material-experimental/selection/row-selection.ts index 66138133e10c..4674f1e842f5 100644 --- a/src/material-experimental/selection/row-selection.ts +++ b/src/material-experimental/selection/row-selection.ts @@ -24,6 +24,7 @@ import {Input, Directive} from '@angular/core'; }, providers: [{provide: CdkRowSelection, useExisting: MatRowSelection}], inputs: ['index: matRowSelectionIndex'], + standalone: true, }) export class MatRowSelection extends CdkRowSelection { /** The value that is associated with the row */ diff --git a/src/material-experimental/selection/select-all.ts b/src/material-experimental/selection/select-all.ts index 72ed8ec0f7a5..8d91b2e87c4b 100644 --- a/src/material-experimental/selection/select-all.ts +++ b/src/material-experimental/selection/select-all.ts @@ -23,5 +23,6 @@ import {Directive} from '@angular/core'; selector: '[matSelectAll]', exportAs: 'matSelectAll', providers: [{provide: CdkSelectAll, useExisting: MatSelectAll}], + standalone: true, }) export class MatSelectAll extends CdkSelectAll {} diff --git a/src/material-experimental/selection/selection-column.ts b/src/material-experimental/selection/selection-column.ts index fb14d2ab814a..71c3ba36ec5d 100644 --- a/src/material-experimental/selection/selection-column.ts +++ b/src/material-experimental/selection/selection-column.ts @@ -6,7 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import {MatCellDef, MatColumnDef, MatHeaderCellDef, MatTable} from '@angular/material/table'; +import { + MatCell, + MatCellDef, + MatColumnDef, + MatHeaderCell, + MatHeaderCellDef, + MatTable, +} from '@angular/material/table'; import { Component, Input, @@ -18,8 +25,12 @@ import { ViewEncapsulation, Inject, } from '@angular/core'; +import {AsyncPipe} from '@angular/common'; import {MatSelection} from './selection'; +import {MatCheckbox} from '@angular/material/checkbox'; +import {MatSelectionToggle} from './selection-toggle'; +import {MatSelectAll} from './select-all'; /** * Column that adds row selecting checkboxes and a select-all checkbox if `matSelectionMultiple` is @@ -50,6 +61,18 @@ import {MatSelection} from './selection'; changeDetection: ChangeDetectionStrategy.OnPush, styleUrls: ['selection-column.css'], encapsulation: ViewEncapsulation.None, + standalone: true, + imports: [ + MatColumnDef, + MatHeaderCellDef, + MatHeaderCell, + MatCheckbox, + MatSelectAll, + MatCellDef, + MatCell, + MatSelectionToggle, + AsyncPipe, + ], }) export class MatSelectionColumn implements OnInit, OnDestroy { /** Column name that should be used to reference this column. */ diff --git a/src/material-experimental/selection/selection-module.ts b/src/material-experimental/selection/selection-module.ts index fcc913af037a..2439b4e15050 100644 --- a/src/material-experimental/selection/selection-module.ts +++ b/src/material-experimental/selection/selection-module.ts @@ -19,14 +19,16 @@ import {MatSelectionColumn} from './selection-column'; import {MatRowSelection} from './row-selection'; @NgModule({ - imports: [CommonModule, MatTableModule, MatCheckboxModule], - exports: [MatSelectAll, MatSelection, MatSelectionToggle, MatSelectionColumn, MatRowSelection], - declarations: [ + imports: [ + CommonModule, + MatTableModule, + MatCheckboxModule, MatSelectAll, MatSelection, MatSelectionToggle, MatSelectionColumn, MatRowSelection, ], + exports: [MatSelectAll, MatSelection, MatSelectionToggle, MatSelectionColumn, MatRowSelection], }) export class MatSelectionModule {} diff --git a/src/material-experimental/selection/selection-toggle.ts b/src/material-experimental/selection/selection-toggle.ts index 9d9b2ad7d6a7..9b197dc9cd90 100644 --- a/src/material-experimental/selection/selection-toggle.ts +++ b/src/material-experimental/selection/selection-toggle.ts @@ -24,6 +24,7 @@ import {Directive, Input} from '@angular/core'; exportAs: 'matSelectionToggle', inputs: ['index: matSelectionToggleIndex'], providers: [{provide: CdkSelectionToggle, useExisting: MatSelectionToggle}], + standalone: true, }) export class MatSelectionToggle extends CdkSelectionToggle { /** The value that is associated with the toggle */ diff --git a/src/material-experimental/selection/selection.ts b/src/material-experimental/selection/selection.ts index f39b2b057dde..cbca04386e8e 100644 --- a/src/material-experimental/selection/selection.ts +++ b/src/material-experimental/selection/selection.ts @@ -20,6 +20,7 @@ import {Directive, Input, Output, EventEmitter} from '@angular/core'; selector: '[matSelection]', exportAs: 'matSelection', providers: [{provide: CdkSelection, useExisting: MatSelection}], + standalone: true, }) // tslint:disable-next-line: coercion-types export class MatSelection extends CdkSelection {