Skip to content

Commit

Permalink
refactor(material-experimental/selection): switch to standalone
Browse files Browse the repository at this point in the history
Reworks `material-experimental/selection` to support standalone.
  • Loading branch information
crisbeto committed Nov 28, 2023
1 parent 30fc1b8 commit 6970266
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/material-experimental/selection/row-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {Input, Directive} from '@angular/core';
},
providers: [{provide: CdkRowSelection, useExisting: MatRowSelection}],
inputs: ['index: matRowSelectionIndex'],
standalone: true,
})
export class MatRowSelection<T> extends CdkRowSelection<T> {
/** The value that is associated with the row */
Expand Down
1 change: 1 addition & 0 deletions src/material-experimental/selection/select-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ import {Directive} from '@angular/core';
selector: '[matSelectAll]',
exportAs: 'matSelectAll',
providers: [{provide: CdkSelectAll, useExisting: MatSelectAll}],
standalone: true,
})
export class MatSelectAll<T> extends CdkSelectAll<T> {}
25 changes: 24 additions & 1 deletion src/material-experimental/selection/selection-column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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<T> implements OnInit, OnDestroy {
/** Column name that should be used to reference this column. */
Expand Down
8 changes: 5 additions & 3 deletions src/material-experimental/selection/selection-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
1 change: 1 addition & 0 deletions src/material-experimental/selection/selection-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> extends CdkSelectionToggle<T> {
/** The value that is associated with the toggle */
Expand Down
1 change: 1 addition & 0 deletions src/material-experimental/selection/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> extends CdkSelection<T> {
Expand Down

0 comments on commit 6970266

Please sign in to comment.