Skip to content

Commit

Permalink
feat(material/checkbox): switch implementation to use MDC (#25369)
Browse files Browse the repository at this point in the history
* feat(material/checkbox): switch implementation to MDC

* feat(material/checkbox): switch implementation to MDC
  • Loading branch information
andrewseguin committed Aug 4, 2022
1 parent 532454b commit 9ac264f
Show file tree
Hide file tree
Showing 166 changed files with 2,504 additions and 2,312 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -6,7 +6,7 @@
/src/material/button-toggle/** @andrewseguin
/src/material/button/** @andrewseguin
/src/material/legacy-card/** @andrewseguin
/src/material/checkbox/** @andrewseguin @devversion
/src/material/legacy-checkbox/** @andrewseguin @devversion
/src/material/chips/** @andrewseguin
/src/material/datepicker/** @mmalerba @crisbeto @zarend
/src/material/dialog/** @andrewseguin @crisbeto
Expand Down Expand Up @@ -113,7 +113,7 @@
/src/material/autocomplete/** @crisbeto
/src/material-experimental/mdc-button/** @andrewseguin
/src/material/card/** @mmalerba
/src/material-experimental/mdc-checkbox/** @mmalerba
/src/material/checkbox/** @mmalerba
/src/material-experimental/mdc-chips/** @mmalerba
/src/material-experimental/mdc-core/** @crisbeto
/src/material-experimental/mdc-dialog/** @devversion
Expand Down Expand Up @@ -321,7 +321,7 @@
/tools/public_api_guard/material/button-toggle** @andrewseguin
/tools/public_api_guard/material/button** @andrewseguin
/tools/public_api_guard/material/legacy-card** @andrewseguin
/tools/public_api_guard/material/checkbox** @andrewseguin @devversion
/tools/public_api_guard/material/legacy-checkbox** @andrewseguin @devversion
/tools/public_api_guard/material/chips** @andrewseguin
/tools/public_api_guard/material/chips/testing** @andrewseguin
/tools/public_api_guard/material/core** @andrewseguin
Expand Down
5 changes: 3 additions & 2 deletions .ng-dev/commit-message.mts
Expand Up @@ -42,7 +42,7 @@ export const commitMessage: CommitMessageConfig = {
'material-experimental/column-resize',
'material-experimental/mdc-button',
'material/card',
'material-experimental/mdc-checkbox',
'material/checkbox',
'material-experimental/mdc-chips',
'material-experimental/mdc-core',
'material-experimental/mdc-dialog',
Expand Down Expand Up @@ -73,7 +73,8 @@ export const commitMessage: CommitMessageConfig = {
'material/button',
'material/button-toggle',
'material/legacy-card',
'material/checkbox',
'material/legacy-checkbox',
'material/legacy-checkbox',
'material/chips',
'material/core',
'material/legacy-core',
Expand Down
2 changes: 1 addition & 1 deletion goldens/tsec-exemption.json
Expand Up @@ -3,7 +3,7 @@
"ban-element-innerhtml-assignments": ["../src/material/icon/icon-registry.ts"],
"ban-element-setattribute": [
"../src/cdk/a11y/aria-describer/aria-reference.ts",
"../src/material-experimental/mdc-checkbox/checkbox.ts",
"../src/material/checkbox/checkbox.ts",
"../src/material-experimental/mdc-list/interactive-list-base.ts",
"../src/material-experimental/mdc-progress-spinner/progress-spinner.ts",
"../src/material-experimental/mdc-slide-toggle/slide-toggle.ts",
Expand Down
2 changes: 1 addition & 1 deletion integration/mdc-migration/golden/src/app/app.module.ts
Expand Up @@ -7,7 +7,7 @@ import {ReactiveFormsModule} from '@angular/forms';
import {MatAutocompleteModule} from '@angular/material-experimental/mdc-autocomplete';
import {MatButtonModule} from '@angular/material-experimental/mdc-button';
import {MatCardModule} from '@angular/material-experimental/mdc-card';
import {MatCheckboxModule} from '@angular/material-experimental/mdc-checkbox';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatChipsModule} from '@angular/material-experimental/mdc-chips';
import {MatFormFieldModule} from '@angular/material-experimental/mdc-form-field';
import {MatIconModule} from '@angular/material/icon';
Expand Down
Expand Up @@ -13,7 +13,7 @@ ng_module(
"//src/cdk-experimental/selection",
"//src/cdk/collections",
"//src/cdk/table",
"//src/material/checkbox",
"//src/material/legacy-checkbox",
"@npm//@angular/forms",
],
)
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/cdk-experimental/selection/index.ts
Expand Up @@ -3,7 +3,7 @@ import {CdkTableModule} from '@angular/cdk/table';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';

import {CdkSelectionColumnExample} from './cdk-selection-column/cdk-selection-column-example';
import {CdkSelectionListExample} from './cdk-selection-list/cdk-selection-list-example';
Expand All @@ -19,7 +19,7 @@ const EXAMPLES = [CdkSelectionListExample, CdkSelectionColumnExample];
CommonModule,
FormsModule,
ReactiveFormsModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
],
declarations: EXAMPLES,
exports: EXAMPLES,
Expand Down
Expand Up @@ -20,9 +20,9 @@ ng_module(
"//src/material-experimental/mdc-table",
"//src/material/button",
"//src/material/button-toggle",
"//src/material/checkbox",
"//src/material/core",
"//src/material/icon",
"//src/material/legacy-checkbox",
"//src/material/legacy-input",
"//src/material/paginator",
"//src/material/progress-spinner",
Expand Down
Expand Up @@ -3,7 +3,7 @@ import {NgModule} from '@angular/core';
import {MatRippleModule} from '@angular/material/core';
import {MatButtonModule} from '@angular/material/button';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatIconModule} from '@angular/material/icon';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
import {MatPaginatorModule} from '@angular/material/paginator';
Expand Down Expand Up @@ -120,7 +120,7 @@ const EXAMPLES = [
CommonModule,
MatButtonModule,
MatButtonToggleModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
MatIconModule,
MatLegacyInputModule,
MatPaginatorModule,
Expand Down
Expand Up @@ -12,8 +12,8 @@ ng_module(
deps = [
"//src/material-experimental/popover-edit",
"//src/material/button",
"//src/material/checkbox",
"//src/material/icon",
"//src/material/legacy-checkbox",
"//src/material/legacy-input",
"//src/material/list",
"//src/material/snack-bar",
Expand Down
Expand Up @@ -3,7 +3,7 @@ import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {MatPopoverEditModule} from '@angular/material-experimental/popover-edit';
import {MatButtonModule} from '@angular/material/button';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatIconModule} from '@angular/material/icon';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
import {MatListModule} from '@angular/material/list';
Expand Down Expand Up @@ -32,7 +32,7 @@ const EXAMPLES = [
imports: [
CommonModule,
MatButtonModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
MatIconModule,
MatLegacyInputModule,
MatListModule,
Expand Down
Expand Up @@ -13,7 +13,7 @@ ng_module(
"//src/cdk/collections",
"//src/cdk/table",
"//src/material-experimental/selection",
"//src/material/checkbox",
"//src/material/legacy-checkbox",
"@npm//@angular/forms",
],
)
Expand Down
Expand Up @@ -3,7 +3,7 @@ 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 {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';

import {MatSelectionColumnExample} from './mat-selection-column/mat-selection-column-example';
import {MatSelectionListExample} from './mat-selection-list/mat-selection-list-example';
Expand All @@ -19,7 +19,7 @@ const EXAMPLES = [MatSelectionListExample, MatSelectionColumnExample];
CommonModule,
FormsModule,
ReactiveFormsModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
],
declarations: EXAMPLES,
exports: EXAMPLES,
Expand Down
8 changes: 4 additions & 4 deletions src/components-examples/material/checkbox/BUILD.bazel
Expand Up @@ -15,9 +15,9 @@ ng_module(
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/checkbox",
"//src/material/checkbox/testing",
"//src/material/legacy-card",
"//src/material/legacy-checkbox",
"//src/material/legacy-checkbox/testing",
"//src/material/radio",
"@npm//@angular/forms",
"@npm//@angular/platform-browser",
Expand All @@ -42,8 +42,8 @@ ng_test_library(
":checkbox",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/checkbox",
"//src/material/checkbox/testing",
"//src/material/legacy-checkbox",
"//src/material/legacy-checkbox/testing",
"@npm//@angular/forms",
"@npm//@angular/platform-browser-dynamic",
],
Expand Down
@@ -1,9 +1,9 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {MatCheckboxHarness} from '@angular/material/checkbox/testing';
import {MatLegacyCheckboxHarness} from '@angular/material/legacy-checkbox/testing';
import {HarnessLoader} from '@angular/cdk/testing';
import {ReactiveFormsModule} from '@angular/forms';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {CheckboxHarnessExample} from './checkbox-harness-example';

describe('CheckboxHarnessExample', () => {
Expand All @@ -12,7 +12,7 @@ describe('CheckboxHarnessExample', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MatCheckboxModule, ReactiveFormsModule],
imports: [MatLegacyCheckboxModule, ReactiveFormsModule],
declarations: [CheckboxHarnessExample],
}).compileComponents();
fixture = TestBed.createComponent(CheckboxHarnessExample);
Expand All @@ -21,31 +21,37 @@ describe('CheckboxHarnessExample', () => {
});

it('should load checkbox with name', async () => {
const checkboxes = await loader.getAllHarnesses(MatCheckboxHarness.with({name: 'first-name'}));
const checkboxes = await loader.getAllHarnesses(
MatLegacyCheckboxHarness.with({name: 'first-name'}),
);
expect(checkboxes.length).toBe(1);
expect(await checkboxes[0].getLabelText()).toBe('First');
});

it('should get checked state', async () => {
const [checkedCheckbox, uncheckedCheckbox] = await loader.getAllHarnesses(MatCheckboxHarness);
const [checkedCheckbox, uncheckedCheckbox] = await loader.getAllHarnesses(
MatLegacyCheckboxHarness,
);
expect(await checkedCheckbox.isChecked()).toBe(true);
expect(await uncheckedCheckbox.isChecked()).toBe(false);
});

it('should get name', async () => {
const checkbox = await loader.getHarness(MatCheckboxHarness.with({label: 'First'}));
const checkbox = await loader.getHarness(MatLegacyCheckboxHarness.with({label: 'First'}));
expect(await checkbox.getName()).toBe('first-name');
});

it('should get label text', async () => {
const [firstCheckbox, secondCheckbox] = await loader.getAllHarnesses(MatCheckboxHarness);
const [firstCheckbox, secondCheckbox] = await loader.getAllHarnesses(MatLegacyCheckboxHarness);
expect(await firstCheckbox.getLabelText()).toBe('First');
expect(await secondCheckbox.getLabelText()).toBe('Second');
});

it('should toggle checkbox', async () => {
fixture.componentInstance.disabled = false;
const [checkedCheckbox, uncheckedCheckbox] = await loader.getAllHarnesses(MatCheckboxHarness);
const [checkedCheckbox, uncheckedCheckbox] = await loader.getAllHarnesses(
MatLegacyCheckboxHarness,
);
await checkedCheckbox.toggle();
await uncheckedCheckbox.toggle();
expect(await checkedCheckbox.isChecked()).toBe(false);
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/material/checkbox/index.ts
Expand Up @@ -2,7 +2,7 @@ import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatLegacyCardModule} from '@angular/material/legacy-card';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatRadioModule} from '@angular/material/radio';
import {CheckboxConfigurableExample} from './checkbox-configurable/checkbox-configurable-example';
import {CheckboxHarnessExample} from './checkbox-harness/checkbox-harness-example';
Expand All @@ -27,7 +27,7 @@ const EXAMPLES = [
imports: [
CommonModule,
MatLegacyCardModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
MatRadioModule,
FormsModule,
ReactiveFormsModule,
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/material/core/BUILD.bazel
Expand Up @@ -11,8 +11,8 @@ ng_module(
]),
deps = [
"//src/material/button",
"//src/material/checkbox",
"//src/material/core",
"//src/material/legacy-checkbox",
"//src/material/legacy-input",
"@npm//@angular/forms",
],
Expand Down
10 changes: 8 additions & 2 deletions src/components-examples/material/core/index.ts
@@ -1,7 +1,7 @@
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatRippleModule} from '@angular/material/core';
import {MatLegacyInputModule} from '@angular/material/legacy-input';
import {ElevationOverviewExample} from './elevation-overview/elevation-overview-example';
Expand All @@ -12,7 +12,13 @@ export {ElevationOverviewExample, RippleOverviewExample};
const EXAMPLES = [ElevationOverviewExample, RippleOverviewExample];

@NgModule({
imports: [MatButtonModule, MatCheckboxModule, MatLegacyInputModule, MatRippleModule, FormsModule],
imports: [
MatButtonModule,
MatLegacyCheckboxModule,
MatLegacyInputModule,
MatRippleModule,
FormsModule,
],
declarations: EXAMPLES,
exports: EXAMPLES,
})
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/material/form-field/BUILD.bazel
Expand Up @@ -16,12 +16,12 @@ ng_module(
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/checkbox",
"//src/material/form-field",
"//src/material/form-field/testing",
"//src/material/icon",
"//src/material/input",
"//src/material/input/testing",
"//src/material/legacy-checkbox",
"//src/material/radio",
"//src/material/select",
"@npm//@angular/forms",
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/material/form-field/index.ts
Expand Up @@ -2,7 +2,7 @@ import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {MatButtonModule} from '@angular/material/button';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon';
import {MatInputModule} from '@angular/material/input';
Expand Down Expand Up @@ -50,7 +50,7 @@ const EXAMPLES = [
imports: [
CommonModule,
MatButtonModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/material/select/BUILD.bazel
Expand Up @@ -15,9 +15,9 @@ ng_module(
deps = [
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/checkbox",
"//src/material/form-field",
"//src/material/input",
"//src/material/legacy-checkbox",
"//src/material/select",
"//src/material/select/testing",
"@npm//@angular/forms",
Expand Down
4 changes: 2 additions & 2 deletions src/components-examples/material/select/index.ts
@@ -1,7 +1,7 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
import {MatInputModule} from '@angular/material/input';
import {MatSelectModule} from '@angular/material/select';
import {SelectCustomTriggerExample} from './select-custom-trigger/select-custom-trigger-example';
Expand Down Expand Up @@ -61,7 +61,7 @@ const EXAMPLES = [
imports: [
CommonModule,
FormsModule,
MatCheckboxModule,
MatLegacyCheckboxModule,
MatInputModule,
MatSelectModule,
ReactiveFormsModule,
Expand Down
2 changes: 1 addition & 1 deletion src/components-examples/material/sidenav/BUILD.bazel
Expand Up @@ -17,8 +17,8 @@ ng_module(
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/button",
"//src/material/checkbox",
"//src/material/icon",
"//src/material/legacy-checkbox",
"//src/material/legacy-select",
"//src/material/list",
"//src/material/radio",
Expand Down

0 comments on commit 9ac264f

Please sign in to comment.