diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 601245761f1d..ebaa392e81b8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -114,6 +114,7 @@ /src/material-experimental/mdc-theming/** @mmalerba /src/material-experimental/mdc-typography/** @mmalerba /src/material-experimental/popover-edit/** @kseamon @andrewseguin +/src/material-experimental/selection/** @yifange @jelbourn # CDK experimental package /src/cdk-experimental/* @jelbourn diff --git a/src/components-examples/BUILD.bazel b/src/components-examples/BUILD.bazel index cf51973985b6..ec73e0ff5883 100644 --- a/src/components-examples/BUILD.bazel +++ b/src/components-examples/BUILD.bazel @@ -44,6 +44,7 @@ EXAMPLE_PACKAGES = [ "//src/components-examples/material/badge", "//src/components-examples/material/autocomplete", "//src/components-examples/material-experimental/popover-edit", + "//src/components-examples/material-experimental/selection", "//src/components-examples/cdk/tree", "//src/components-examples/cdk/text-field", "//src/components-examples/cdk/table", diff --git a/src/components-examples/material-experimental/selection/BUILD.bazel b/src/components-examples/material-experimental/selection/BUILD.bazel new file mode 100644 index 000000000000..cfdbac096a3f --- /dev/null +++ b/src/components-examples/material-experimental/selection/BUILD.bazel @@ -0,0 +1,29 @@ +package(default_visibility = ["//visibility:public"]) + +load("//tools:defaults.bzl", "ng_module") + +ng_module( + name = "selection", + srcs = glob(["**/*.ts"]), + assets = glob([ + "**/*.html", + "**/*.css", + ]), + module_name = "@angular/components-examples/material-experimental/selection", + deps = [ + "//src/cdk/collections", + "//src/cdk/table", + "//src/material-experimental/selection", + "//src/material/checkbox", + "@npm//@angular/forms", + ], +) + +filegroup( + name = "source-files", + srcs = glob([ + "**/*.html", + "**/*.css", + "**/*.ts", + ]), +) diff --git a/src/components-examples/material-experimental/selection/index.ts b/src/components-examples/material-experimental/selection/index.ts new file mode 100644 index 000000000000..2e8fdc1e0cbe --- /dev/null +++ b/src/components-examples/material-experimental/selection/index.ts @@ -0,0 +1,34 @@ +import {MatSelectionModule} from '@angular/material-experimental/selection'; +import {MatTableModule} from '@angular/material/table'; +import {CommonModule} from '@angular/common'; +import {NgModule} from '@angular/core'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {MatCheckboxModule} from '@angular/material/checkbox'; + +import {MatSelectionColumnExample} from './mat-selection-column/mat-selection-column-example'; +import {MatSelectionListExample} from './mat-selection-list/mat-selection-list-example'; + +export { + MatSelectionListExample, + MatSelectionColumnExample, +}; + +const EXAMPLES = [ + MatSelectionListExample, + MatSelectionColumnExample, +]; + +@NgModule({ + imports: [ + MatSelectionModule, + MatTableModule, + CommonModule, + FormsModule, + ReactiveFormsModule, + MatCheckboxModule, + ], + declarations: EXAMPLES, + exports: EXAMPLES, +}) +export class MatSelectionExamplesModule { +} diff --git a/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.css b/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.css new file mode 100644 index 000000000000..cedd44731369 --- /dev/null +++ b/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.css @@ -0,0 +1,3 @@ +.example-table { + width: 100%; +} diff --git a/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.html b/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.html new file mode 100644 index 000000000000..b528c55fba87 --- /dev/null +++ b/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.html @@ -0,0 +1,30 @@ +Selected: {{selected}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
No. {{element.position}} Name {{element.name}} Weight {{element.weight}} Symbol {{element.symbol}}
diff --git a/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.ts b/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.ts new file mode 100644 index 000000000000..72b8eed687e4 --- /dev/null +++ b/src/components-examples/material-experimental/selection/mat-selection-column/mat-selection-column-example.ts @@ -0,0 +1,58 @@ +import {Component, OnDestroy} from '@angular/core'; +import {SelectionChange} from '@angular/material-experimental/selection'; +import {ReplaySubject} from 'rxjs'; + +/** + * @title Table that uses `matSelectionColumn` which allows users to select rows. + */ +@Component({ + selector: 'mat-selection-column-example', + templateUrl: 'mat-selection-column-example.html', + styleUrls: ['mat-selection-column-example.css'], +}) +export class MatSelectionColumnExample implements OnDestroy { + private readonly _destroyed = new ReplaySubject(1); + + displayedColumns: string[] = ['select', 'position', 'name', 'weight', 'symbol']; + dataSource = ELEMENT_DATA; + selected: string[] = []; + + ngOnDestroy() { + this._destroyed.next(); + this._destroyed.complete(); + } + + selectionChanged(event: SelectionChange) { + this.selected = event.after.map((select) => select.value.name); + } +} + +interface PeriodicElement { + name: string; + position: number; + weight: number; + symbol: string; +} + +const ELEMENT_DATA: PeriodicElement[] = [ + {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'}, + {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'}, + {position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li'}, + {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}, + {position: 5, name: 'Boron', weight: 10.811, symbol: 'B'}, + {position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C'}, + {position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N'}, + {position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O'}, + {position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F'}, + {position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne'}, + {position: 11, name: 'Sodium', weight: 22.9897, symbol: 'Na'}, + {position: 12, name: 'Magnesium', weight: 24.305, symbol: 'Mg'}, + {position: 13, name: 'Aluminum', weight: 26.9815, symbol: 'Al'}, + {position: 14, name: 'Silicon', weight: 28.0855, symbol: 'Si'}, + {position: 15, name: 'Phosphorus', weight: 30.9738, symbol: 'P'}, + {position: 16, name: 'Sulfur', weight: 32.065, symbol: 'S'}, + {position: 17, name: 'Chlorine', weight: 35.453, symbol: 'Cl'}, + {position: 18, name: 'Argon', weight: 39.948, symbol: 'Ar'}, + {position: 19, name: 'Potassium', weight: 39.0983, symbol: 'K'}, + {position: 20, name: 'Calcium', weight: 40.078, symbol: 'Ca'}, +]; diff --git a/src/components-examples/material-experimental/selection/mat-selection-list/mat-selection-list-example.html b/src/components-examples/material-experimental/selection/mat-selection-list/mat-selection-list-example.html new file mode 100644 index 000000000000..bec0b35b1cc5 --- /dev/null +++ b/src/components-examples/material-experimental/selection/mat-selection-list/mat-selection-list-example.html @@ -0,0 +1,45 @@ +

native input

+Selected: {{selected1}} + + +

mat-checkbox

+Selected: {{selected2}} + + +

Single select with mat-checkbox

+Selected: {{selected3}} + + +

with trackBy

+Selected: {{selected4}} + + + + diff --git a/src/components-examples/material-experimental/selection/mat-selection-list/mat-selection-list-example.ts b/src/components-examples/material-experimental/selection/mat-selection-list/mat-selection-list-example.ts new file mode 100644 index 000000000000..c9af7c0b300e --- /dev/null +++ b/src/components-examples/material-experimental/selection/mat-selection-list/mat-selection-list-example.ts @@ -0,0 +1,53 @@ +import {SelectionChange} from '@angular/cdk-experimental/selection'; +import {Component, OnDestroy} from '@angular/core'; +import {ReplaySubject} from 'rxjs'; + +/** + * @title Mat Selection on a simple list. + */ +@Component({ + selector: 'mat-selection-list-example', + templateUrl: 'mat-selection-list-example.html', +}) +export class MatSelectionListExample implements OnDestroy { + private readonly _destroyed = new ReplaySubject(1); + + data = ELEMENT_NAMES; + + selected1: string[] = []; + selected2: string[] = []; + selected3: string[] = []; + selected4: string[] = []; + + ngOnDestroy() { + this._destroyed.next(); + this._destroyed.complete(); + } + + getCurrentSelected(event: SelectionChange) { + return event.after.map((select) => select.value); + } + + trackByFn(index: number, value: string) { + return index; + } + + changeElementName() { + this.data = ELEMENT_SYMBOLS; + } + + reset() { + this.data = ELEMENT_NAMES; + } +} + +const ELEMENT_NAMES = [ + 'Hydrogen', 'Helium', 'Lithium', 'Beryllium', 'Boron', 'Carbon', 'Nitrogen', + 'Oxygen', 'Fluorine', 'Neon', 'Sodium', 'Magnesium', 'Aluminum', 'Silicon', + 'Phosphorus', 'Sulfur', 'Chlorine', 'Argon', 'Potassium', 'Calcium', +]; + +const ELEMENT_SYMBOLS = [ + 'H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', + 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca' +]; diff --git a/src/dev-app/example/example-list.ts b/src/dev-app/example/example-list.ts index d71d8863f2f9..05d5a43a366c 100644 --- a/src/dev-app/example/example-list.ts +++ b/src/dev-app/example/example-list.ts @@ -10,8 +10,6 @@ import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {EXAMPLE_COMPONENTS} from '@angular/components-examples'; import {Component, Input} from '@angular/core'; -console.log(EXAMPLE_COMPONENTS); - /** Displays a set of components-examples in a mat-accordion. */ @Component({ selector: 'material-example-list', diff --git a/src/dev-app/selection/BUILD.bazel b/src/dev-app/selection/BUILD.bazel index e3b3567853f5..264a3815636a 100644 --- a/src/dev-app/selection/BUILD.bazel +++ b/src/dev-app/selection/BUILD.bazel @@ -7,6 +7,7 @@ ng_module( srcs = glob(["**/*.ts"]), deps = [ "//src/components-examples/cdk-experimental/selection", + "//src/components-examples/material-experimental/selection", "//src/dev-app/example", "@npm//@angular/forms", "@npm//@angular/router", diff --git a/src/dev-app/selection/selection-demo-module.ts b/src/dev-app/selection/selection-demo-module.ts index 6c47adfd3d2e..8fe8841bab70 100644 --- a/src/dev-app/selection/selection-demo-module.ts +++ b/src/dev-app/selection/selection-demo-module.ts @@ -7,6 +7,8 @@ */ import {CdkSelectionExamplesModule} from '@angular/components-examples/cdk-experimental/selection'; +import {MatSelectionExamplesModule} from +'@angular/components-examples/material-experimental/selection'; import {NgModule} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; @@ -16,6 +18,7 @@ import {SelectionDemo} from './selection-demo'; @NgModule({ imports: [ CdkSelectionExamplesModule, + MatSelectionExamplesModule, FormsModule, RouterModule.forChild([{path: '', component: SelectionDemo}]), ], diff --git a/src/dev-app/selection/selection-demo.ts b/src/dev-app/selection/selection-demo.ts index f2666fb1753b..a7d8f1c4fa4b 100644 --- a/src/dev-app/selection/selection-demo.ts +++ b/src/dev-app/selection/selection-demo.ts @@ -15,6 +15,12 @@ import {Component} from '@angular/core';

CDK selection column and CDK row selection with CDK table

+ +

Mat selection with a list

+ + +

Mat selection column and Mat row selection with Mat table

+ `, }) export class SelectionDemo { diff --git a/src/material-experimental/config.bzl b/src/material-experimental/config.bzl index 8467738ff3c3..cf57e63518cc 100644 --- a/src/material-experimental/config.bzl +++ b/src/material-experimental/config.bzl @@ -27,6 +27,7 @@ entryPoints = [ "mdc-table", "mdc-tabs", "popover-edit", + "selection", ] # List of all non-testing entry-points of the Angular material-experimental package. diff --git a/src/material-experimental/selection/BUILD.bazel b/src/material-experimental/selection/BUILD.bazel new file mode 100644 index 000000000000..2289e9776998 --- /dev/null +++ b/src/material-experimental/selection/BUILD.bazel @@ -0,0 +1,35 @@ +package(default_visibility = ["//visibility:public"]) + +load("//tools:defaults.bzl", "ng_module", "sass_binary", "sass_library") + +ng_module( + name = "selection", + srcs = glob( + ["**/*.ts"], + exclude = ["**/*.spec.ts"], + ), + assets = [":selection_column_scss"], + module_name = "@angular/material-experimental/selection", + deps = [ + "//src/cdk-experimental/selection", + "//src/material/checkbox", + "//src/material/table", + "@npm//@angular/core", + ], +) + +sass_library( + name = "selection_scss_lib", + srcs = glob(["**/_*.scss"]), + deps = [], +) + +sass_binary( + name = "selection_column_scss", + src = "selection-column.scss", + include_paths = [ + "external/npm/node_modules", + ], + deps = [ + ], +) diff --git a/src/material-experimental/selection/_selection.scss b/src/material-experimental/selection/_selection.scss new file mode 100644 index 000000000000..14f7219a909f --- /dev/null +++ b/src/material-experimental/selection/_selection.scss @@ -0,0 +1,3 @@ +@mixin mat-selection-theme($theme) {} + +@mixin mat-selection-typography($config) {} diff --git a/src/material-experimental/selection/index.ts b/src/material-experimental/selection/index.ts new file mode 100644 index 000000000000..e1fc5bfc0361 --- /dev/null +++ b/src/material-experimental/selection/index.ts @@ -0,0 +1,10 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +export * from './public-api'; + diff --git a/src/material-experimental/selection/public-api.ts b/src/material-experimental/selection/public-api.ts new file mode 100644 index 000000000000..8cae343cd78d --- /dev/null +++ b/src/material-experimental/selection/public-api.ts @@ -0,0 +1,14 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +export * from './selection'; +export * from './select-all'; +export * from './selection-toggle'; +export * from './selection-column'; +export * from './row-selection'; +export * from './selection-module'; diff --git a/src/material-experimental/selection/row-selection.ts b/src/material-experimental/selection/row-selection.ts new file mode 100644 index 000000000000..518fb70e899c --- /dev/null +++ b/src/material-experimental/selection/row-selection.ts @@ -0,0 +1,34 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {CdkRowSelection} from '@angular/cdk-experimental/selection'; +import {Input, Directive} from '@angular/core'; + + +/** + * Applies `mat-selected` class and `aria-selected` to an element. + * + * Must be used within a parent `MatSelection` directive. + * Must be provided with the value. The index is required if `trackBy` is used on the `CdkSelection` + * directive. + */ +@Directive({ + selector: '[matRowSelection]', + host: { + '[class.mat-selected]': '_selection.isSelected(this.value, this.index)', + '[attr.aria-selected]': '_selection.isSelected(this.value, this.index)', + }, + providers: [{provide: CdkRowSelection, useExisting: MatRowSelection}] +}) +export class MatRowSelection extends CdkRowSelection { + /** The value that is associated with the row */ + @Input('matRowSelectionValue') value: T; + + /** The index of the value in the list. Required when used with `trackBy` */ + @Input('matRowSelectionIndex') index: number|undefined; +} diff --git a/src/material-experimental/selection/select-all.ts b/src/material-experimental/selection/select-all.ts new file mode 100644 index 000000000000..2501bb9dfce4 --- /dev/null +++ b/src/material-experimental/selection/select-all.ts @@ -0,0 +1,29 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {CdkSelectAll} from '@angular/cdk-experimental/selection'; +import {Directive} from '@angular/core'; + + +/** + * Makes the element a select-all toggle. + * + * Must be used within a parent `MatSelection` directive. It toggles the selection states + * of all the selection toggles connected with the `MatSelection` directive. + * If the element implements `ControlValueAccessor`, e.g. `MatCheckbox`, the directive + * automatically connects it with the select-all state provided by the `MatSelection` directive. If + * not, use `checked` to get the checked state, `indeterminate` to get the indeterminate state, + * and `toggle()` to change the selection state. + */ +@Directive({ + selector: '[matSelectAll]', + exportAs: 'matSelectAll', + providers: [{provide: CdkSelectAll, useExisting: MatSelectAll}] +}) +export class MatSelectAll extends CdkSelectAll { +} diff --git a/src/material-experimental/selection/selection-column.scss b/src/material-experimental/selection/selection-column.scss new file mode 100644 index 000000000000..81d4f297d7a7 --- /dev/null +++ b/src/material-experimental/selection/selection-column.scss @@ -0,0 +1,5 @@ +th.mat-selection-column-header, +td.mat-selection-column-cell { + text-align: center; + width: 48px; +} diff --git a/src/material-experimental/selection/selection-column.ts b/src/material-experimental/selection/selection-column.ts new file mode 100644 index 000000000000..074f0b091180 --- /dev/null +++ b/src/material-experimental/selection/selection-column.ts @@ -0,0 +1,101 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {MatCellDef, MatColumnDef, MatHeaderCellDef, MatTable} from '@angular/material/table'; +import { + Component, + Input, + isDevMode, + OnDestroy, + OnInit, + Optional, + ViewChild, + ChangeDetectionStrategy, + ViewEncapsulation, +} from '@angular/core'; + +import {MatSelection} from './selection'; + +/** + * Column that adds row selecting checkboxes and a select-all checkbox if `matSelectionMultiple` is + * `true`. + * + * Must be used within a parent `MatSelection` directive. + */ +@Component({ + selector: 'mat-selection-column', + template: ` + + + + + + + + + `, + changeDetection: ChangeDetectionStrategy.OnPush, + styleUrls: ['selection-column.css'], + encapsulation: ViewEncapsulation.None, +}) +export class MatSelectionColumn implements OnInit, OnDestroy { + /** Column name that should be used to reference this column. */ + @Input() + get name(): string { + return this._name; + } + set name(name: string) { + this._name = name; + + this._syncColumnDefName(); + } + private _name: string; + + @ViewChild(MatColumnDef, {static: true}) private readonly _columnDef: MatColumnDef; + @ViewChild(MatCellDef, {static: true}) private readonly _cell: MatCellDef; + @ViewChild(MatHeaderCellDef, {static: true}) private readonly _headerCell: MatHeaderCellDef; + + constructor( + @Optional() private _table: MatTable, + @Optional() readonly selection: MatSelection, + ) {} + + ngOnInit() { + if (!this.selection && isDevMode()) { + throw Error('MatSelectionColumn: missing MatSelection in the parent'); + } + + this._syncColumnDefName(); + + if (this._table) { + this._columnDef.cell = this._cell; + this._columnDef.headerCell = this._headerCell; + this._table.addColumnDef(this._columnDef); + } else if (isDevMode()) { + throw Error('MatSelectionColumn: missing parent table'); + } + } + + ngOnDestroy() { + if (this._table) { + this._table.removeColumnDef(this._columnDef); + } + } + + private _syncColumnDefName() { + if (this._columnDef) { + this._columnDef.name = this._name; + } + } +} diff --git a/src/material-experimental/selection/selection-module.ts b/src/material-experimental/selection/selection-module.ts new file mode 100644 index 000000000000..f8e90a2d0466 --- /dev/null +++ b/src/material-experimental/selection/selection-module.ts @@ -0,0 +1,43 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// TODO(yifange): Move the table-specific code to a separate module from the other selection +// behaviors once we move it out of experiemental. +import {CommonModule} from '@angular/common'; +import {NgModule} from '@angular/core'; +import {MatTableModule} from '@angular/material/table'; +import {MatCheckboxModule} from '@angular/material/checkbox'; +import {MatSelectAll} from './select-all'; +import {MatSelection} from './selection'; +import {MatSelectionToggle} from './selection-toggle'; +import {MatSelectionColumn} from './selection-column'; +import {MatRowSelection} from './row-selection'; + +@NgModule({ + imports: [ + CommonModule, + MatTableModule, + MatCheckboxModule, + ], + exports: [ + MatSelectAll, + MatSelection, + MatSelectionToggle, + MatSelectionColumn, + MatRowSelection, + ], + declarations: [ + 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 new file mode 100644 index 000000000000..32e36dd11d48 --- /dev/null +++ b/src/material-experimental/selection/selection-toggle.ts @@ -0,0 +1,33 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {CdkSelectionToggle} from '@angular/cdk-experimental/selection'; +import {Directive, Input} from '@angular/core'; + +/** + * Makes the element a selection toggle. + * + * Must be used within a parent `MatSelection` directive. + * Must be provided with the value. If `trackBy` is used on `MatSelection`, the index of the value + * is required. If the element implements `ControlValueAccessor`, e.g. `MatCheckbox`, the directive + * automatically connects it with the selection state provided by the `MatSelection` directive. If + * not, use `checked$` to get the checked state of the value, and `toggle()` to change the selection + * state. + */ +@Directive({ + selector: '[matSelectionToggle]', + exportAs: 'matSelectionToggle', + providers: [{provide: CdkSelectionToggle, useExisting: MatSelectionToggle}] +}) +export class MatSelectionToggle extends CdkSelectionToggle { + /** The value that is associated with the toggle */ + @Input('matSelectionToggleValue') value: T; + + /** The index of the value in the list. Required when used with `trackBy` */ + @Input('matSelectionToggleIndex') index: number|undefined; +} diff --git a/src/material-experimental/selection/selection.ts b/src/material-experimental/selection/selection.ts new file mode 100644 index 000000000000..62ab56468ec3 --- /dev/null +++ b/src/material-experimental/selection/selection.ts @@ -0,0 +1,35 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {CdkSelection, SelectionChange} from '@angular/cdk-experimental/selection'; +import {Directive, Input, Output, EventEmitter} from '@angular/core'; + + +/** + * Manages the selection states of the items and provides methods to check and update the selection + * states. + * It must be applied to the parent element if `matSelectionToggle`, `matSelectAll`, + * `matRowSelection` and `matSelectionColumn` are applied. + */ +@Directive({ + selector: '[matSelection]', + exportAs: 'matSelection', + providers: [{provide: CdkSelection, useExisting: MatSelection}] +}) +export class MatSelection extends CdkSelection { + /** Whether to support multiple selection */ + @Input('matSelectionMultiple') multiple: boolean; + + /** Emits when selection changes. */ + @Output('matSelectionChange') change = new EventEmitter>(); +} + +/** + * Represents the change in the selection set. + */ +export {SelectionChange} from '@angular/cdk-experimental/selection';