Skip to content

Commit a063401

Browse files
committed
move everything from cdk to MatInputModule
1 parent dfbbd0f commit a063401

22 files changed

+91
-152
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
/src/cdk/bidi/** @jelbourn
6060
/src/cdk/coercion/** @jelbourn
6161
/src/cdk/collections/** @jelbourn @crisbeto @andrewseguin
62-
/src/cdk/input/** @mmalerba
6362
/src/cdk/keycodes/** @jelbourn
6463
/src/cdk/layout/** @josephperrott
6564
/src/cdk/observers/** @jelbourn @crisbeto

src/cdk/input/BUILD.bazel

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/cdk/input/_autofill.scss

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/cdk/input/autofill-prebuilt.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/cdk/input/index.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/cdk/input/input-module.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/cdk/input/public-api.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/cdk/input/tsconfig-build.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/demo-app/demo-material-module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import {A11yModule} from '@angular/cdk/a11y';
1010
import {CdkAccordionModule} from '@angular/cdk/accordion';
1111
import {BidiModule} from '@angular/cdk/bidi';
12-
import {InputModule} from '@angular/cdk/input';
1312
import {ObserversModule} from '@angular/cdk/observers';
1413
import {OverlayModule} from '@angular/cdk/overlay';
1514
import {PlatformModule} from '@angular/cdk/platform';
@@ -94,7 +93,6 @@ import {
9493
A11yModule,
9594
BidiModule,
9695
CdkAccordionModule,
97-
InputModule,
9896
ObserversModule,
9997
OverlayModule,
10098
PlatformModule,

src/demo-app/input/input-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ <h3>&lt;textarea&gt; with ngModel</h3>
641641
</mat-checkbox>
642642
<mat-form-field>
643643
<mat-label>Autofill monitored</mat-label>
644-
<input matInput (cdkAutofill)="isAutofilled = $event.isAutofilled" name="autofill"
644+
<input matInput (matAutofill)="isAutofilled = $event.isAutofilled" name="autofill"
645645
[class.demo-custom-autofill-style]="customAutofillStyle">
646646
</mat-form-field>
647647
<button color="primary" mat-raised-button>Submit</button>

src/demo-app/input/input-demo.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '../../../dist/packages/cdk/input/autofill';
1+
@import '../../../dist/packages/material/input/autofill';
22

33
.demo-basic {
44
padding: 0;
@@ -31,5 +31,5 @@
3131
}
3232

3333
.demo-custom-autofill-style {
34-
@include cdk-input-autofill-color(transparent, red);
34+
@include mat-input-autofill-color(transparent, red);
3535
}

src/demo-app/system-config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ System.config({
4848
'@angular/cdk/bidi': 'dist/packages/cdk/bidi/index.js',
4949
'@angular/cdk/coercion': 'dist/packages/cdk/coercion/index.js',
5050
'@angular/cdk/collections': 'dist/packages/cdk/collections/index.js',
51-
'@angular/cdk/input': 'dist/packages/cdk/input/index.js',
5251
'@angular/cdk/keycodes': 'dist/packages/cdk/keycodes/index.js',
5352
'@angular/cdk/layout': 'dist/packages/cdk/layout/index.js',
5453
'@angular/cdk/observers': 'dist/packages/cdk/observers/index.js',

src/e2e-app/system-config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ System.config({
3838
'@angular/cdk/bidi': 'dist/bundles/cdk-bidi.umd.js',
3939
'@angular/cdk/coercion': 'dist/bundles/cdk-coercion.umd.js',
4040
'@angular/cdk/collections': 'dist/bundles/cdk-collections.umd.js',
41-
'@angular/cdk/input': 'dist/bundles/cdk-input.umd.js',
4241
'@angular/cdk/keycodes': 'dist/bundles/cdk-keycodes.umd.js',
4342
'@angular/cdk/layout': 'dist/bundles/cdk-layout.umd.js',
4443
'@angular/cdk/observers': 'dist/bundles/cdk-observers.umd.js',

src/lib/core/_core.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// up into a single flat scss file for material.
33
@import '../../cdk/overlay/overlay';
44
@import '../../cdk/a11y/a11y';
5-
@import '../../cdk/input/autofill';
5+
@import '../input/autofill';
66

77
// Core styles that can be used to apply material design treatments to any element.
88
@import 'style/elevation';
@@ -27,7 +27,7 @@
2727
@include mat-ripple();
2828
@include cdk-a11y();
2929
@include cdk-overlay();
30-
@include cdk-input-autofill();
30+
@include mat-input-autofill();
3131
}
3232

3333
// Mixin that renders all of the core styles that depend on the theme.

src/lib/input/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ng_module(
88
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
99
module_name = "@angular/material/input",
1010
deps = [
11+
"@rxjs",
1112
"//src/lib/core",
1213
"//src/lib/form-field",
1314
"//src/cdk/coercion",

src/lib/input/_autofill.scss

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Core styles that enable monitoring autofill state of inputs.
2+
@mixin mat-input-autofill {
3+
// Keyframes that do nothing, but allow us to monitor when an input becomes autofilled.
4+
@keyframes mat-input-autofill-start {}
5+
@keyframes mat-input-autofill-end {}
6+
7+
.mat-input-autofill-monitored:-webkit-autofill {
8+
animation-name: mat-input-autofill-start;
9+
}
10+
11+
.mat-input-autofill-monitored:not(:-webkit-autofill) {
12+
animation-name: mat-input-autofill-end;
13+
}
14+
}
15+
16+
// Used to generate UIDs for keyframes used to change the input autofill styles.
17+
$mat-input-autofill-color-frame-count: 0;
18+
19+
// Mixin used to apply custom background and foreground colors to an autofilled input. Based on:
20+
// https://stackoverflow.com/questions/2781549/
21+
// removing-input-background-colour-for-chrome-autocomplete#answer-37432260
22+
@mixin mat-input-autofill-color($background, $foreground:'') {
23+
@keyframes mat-input-autofill-color-#{$mat-input-autofill-color-frame-count} {
24+
to {
25+
background: $background;
26+
@if $foreground != '' { color: $foreground; }
27+
}
28+
}
29+
30+
&:-webkit-autofill {
31+
animation-name: mat-input-autofill-color-#{$mat-input-autofill-color-frame-count};
32+
animation-fill-mode: both;
33+
}
34+
35+
&.mat-input-autofill-monitored:-webkit-autofill {
36+
animation-name: mat-input-autofill-start,
37+
mat-input-autofill-color-#{$mat-input-autofill-color-frame-count};
38+
}
39+
40+
$mat-input-autofill-color-frame-count: $mat-input-autofill-color-frame-count + 1 !global;
41+
}

src/lib/input/autofill-prebuilt.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import 'autofill';
2+
3+
@include mat-input-autofill();

src/cdk/input/autofill.spec.ts renamed to src/lib/input/autofill.spec.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {Component, ElementRef, ViewChild} from '@angular/core';
1010
import {ComponentFixture, inject, TestBed} from '@angular/core/testing';
1111
import {AutofillEvent, AutofillMonitor} from './autofill';
12-
import {InputModule} from './input-module';
12+
import {MatInputModule} from './input-module';
1313
import {empty as observableEmpty} from 'rxjs/observable/empty';
1414

1515
describe('AutofillMonitor', () => {
@@ -19,7 +19,7 @@ describe('AutofillMonitor', () => {
1919

2020
beforeEach(() => {
2121
TestBed.configureTestingModule({
22-
imports: [InputModule],
22+
imports: [MatInputModule],
2323
declarations: [Inputs],
2424
}).compileComponents();
2525
});
@@ -47,7 +47,7 @@ describe('AutofillMonitor', () => {
4747
expect(inputEl.addEventListener).not.toHaveBeenCalled();
4848

4949
autofillMonitor.monitor(inputEl);
50-
expect(inputEl.classList).toContain('cdk-input-autofill-monitored');
50+
expect(inputEl.classList).toContain('mat-input-autofill-monitored');
5151
expect(inputEl.addEventListener).toHaveBeenCalledWith('animationstart', jasmine.any(Function));
5252
});
5353

@@ -63,11 +63,11 @@ describe('AutofillMonitor', () => {
6363
it('should remove monitored class and listener upon stop monitoring', () => {
6464
const inputEl = testComponent.input1.nativeElement;
6565
autofillMonitor.monitor(inputEl);
66-
expect(inputEl.classList).toContain('cdk-input-autofill-monitored');
66+
expect(inputEl.classList).toContain('mat-input-autofill-monitored');
6767
expect(inputEl.removeEventListener).not.toHaveBeenCalled();
6868

6969
autofillMonitor.stopMonitoring(inputEl);
70-
expect(inputEl.classList).not.toContain('cdk-input-autofill-monitored');
70+
expect(inputEl.classList).not.toContain('mat-input-autofill-monitored');
7171
expect(inputEl.removeEventListener)
7272
.toHaveBeenCalledWith('animationstart', jasmine.any(Function));
7373
});
@@ -97,10 +97,10 @@ describe('AutofillMonitor', () => {
9797
const autofillStream = autofillMonitor.monitor(inputEl);
9898
autofillStream.subscribe(event => autofillStreamEvent = event);
9999
expect(autofillStreamEvent).toBeNull();
100-
expect(inputEl.classList).not.toContain('cdk-input-autofilled');
100+
expect(inputEl.classList).not.toContain('mat-input-autofilled');
101101

102-
animationStartCallback({animationName: 'cdk-input-autofill-start', target: inputEl});
103-
expect(inputEl.classList).toContain('cdk-input-autofilled');
102+
animationStartCallback({animationName: 'mat-input-autofill-start', target: inputEl});
103+
expect(inputEl.classList).toContain('mat-input-autofilled');
104104
expect(autofillStreamEvent).toEqual({target: inputEl, isAutofilled: true} as any);
105105
});
106106

@@ -111,12 +111,12 @@ describe('AutofillMonitor', () => {
111111
inputEl.addEventListener.and.callFake((_, cb) => animationStartCallback = cb);
112112
const autofillStream = autofillMonitor.monitor(inputEl);
113113
autofillStream.subscribe(event => autofillStreamEvent = event);
114-
animationStartCallback({animationName: 'cdk-input-autofill-start', target: inputEl});
115-
expect(inputEl.classList).toContain('cdk-input-autofilled');
114+
animationStartCallback({animationName: 'mat-input-autofill-start', target: inputEl});
115+
expect(inputEl.classList).toContain('mat-input-autofilled');
116116
expect(autofillStreamEvent).toEqual({target: inputEl, isAutofilled: true} as any);
117117

118-
animationStartCallback({animationName: 'cdk-input-autofill-end', target: inputEl});
119-
expect(inputEl.classList).not.toContain('cdk-input-autofilled');
118+
animationStartCallback({animationName: 'mat-input-autofill-end', target: inputEl});
119+
expect(inputEl.classList).not.toContain('mat-input-autofilled');
120120
expect(autofillStreamEvent).toEqual({target: inputEl, isAutofilled: false} as any);
121121
});
122122

@@ -125,31 +125,31 @@ describe('AutofillMonitor', () => {
125125
let animationStartCallback: Function = () => {};
126126
inputEl.addEventListener.and.callFake((_, cb) => animationStartCallback = cb);
127127
autofillMonitor.monitor(inputEl);
128-
animationStartCallback({animationName: 'cdk-input-autofill-start', target: inputEl});
129-
expect(inputEl.classList).toContain('cdk-input-autofilled');
128+
animationStartCallback({animationName: 'mat-input-autofill-start', target: inputEl});
129+
expect(inputEl.classList).toContain('mat-input-autofilled');
130130

131131
autofillMonitor.stopMonitoring(inputEl);
132-
expect(inputEl.classlist).not.toContain('cdk-input-autofilled');
132+
expect(inputEl.classlist).not.toContain('mat-input-autofilled');
133133
});
134134
});
135135

136-
describe('cdkAutofill', () => {
136+
describe('matAutofill', () => {
137137
let autofillMonitor: AutofillMonitor;
138-
let fixture: ComponentFixture<InputWithCdkAutofilled>;
139-
let testComponent: InputWithCdkAutofilled;
138+
let fixture: ComponentFixture<InputWithMatAutofilled>;
139+
let testComponent: InputWithMatAutofilled;
140140

141141
beforeEach(() => {
142142
TestBed.configureTestingModule({
143-
imports: [InputModule],
144-
declarations: [InputWithCdkAutofilled],
143+
imports: [MatInputModule],
144+
declarations: [InputWithMatAutofilled],
145145
}).compileComponents();
146146
});
147147

148148
beforeEach(inject([AutofillMonitor], (afm: AutofillMonitor) => {
149149
autofillMonitor = afm;
150150
spyOn(autofillMonitor, 'monitor').and.returnValue(observableEmpty());
151151
spyOn(autofillMonitor, 'stopMonitoring');
152-
fixture = TestBed.createComponent(InputWithCdkAutofilled);
152+
fixture = TestBed.createComponent(InputWithMatAutofilled);
153153
testComponent = fixture.componentInstance;
154154
fixture.detectChanges();
155155
}));
@@ -179,8 +179,8 @@ class Inputs {
179179
}
180180

181181
@Component({
182-
template: `<input #input cdkAutofill>`
182+
template: `<input #input matAutofill>`
183183
})
184-
class InputWithCdkAutofilled {
184+
class InputWithMatAutofilled {
185185
@ViewChild('input') input: ElementRef;
186186
}

0 commit comments

Comments
 (0)