Skip to content

refactor(input): rename input-container to form-field... #6331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/demo-app/a11y/datepicker/datepicker-a11y.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.mat-input-container {
.mat-form-field {
width: 250px;
}
2 changes: 1 addition & 1 deletion src/demo-app/autocomplete/autocomplete-demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
margin: 24px;
}

.mat-input-container {
.mat-form-field {
margin-top: 16px;
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/demo-app/datepicker/datepicker-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ <h2>Options</h2>
<md-input-container>
<input mdInput [mdDatepicker]="minDatePicker" [(ngModel)]="minDate" placeholder="Min date">
<md-datepicker-toggle mdSuffix [for]="minDatePicker"></md-datepicker-toggle>
<md-datepicker #minDatePicker [touchUi]="touch" [disabled]="datepickerDisabled"></md-datepicker>
</md-input-container>
<md-datepicker #minDatePicker [touchUi]="touch" [disabled]="datepickerDisabled"></md-datepicker>
<md-input-container>
<input mdInput [mdDatepicker]="maxDatePicker" [(ngModel)]="maxDate" placeholder="Max date">
<md-datepicker-toggle mdSuffix [for]="maxDatePicker"></md-datepicker-toggle>
<md-datepicker #maxDatePicker [touchUi]="touch" [disabled]="datepickerDisabled"></md-datepicker>
</md-input-container>
<md-datepicker #maxDatePicker [touchUi]="touch" [disabled]="datepickerDisabled"></md-datepicker>
</p>
<p>
<md-input-container>
<input mdInput [mdDatepicker]="startAtPicker" [(ngModel)]="startAt" placeholder="Start at date">
<md-datepicker-toggle mdSuffix [for]="startAtPicker"></md-datepicker-toggle>
<md-datepicker #startAtPicker [touchUi]="touch" [disabled]="datepickerDisabled"></md-datepicker>
</md-input-container>
<md-datepicker #startAtPicker [touchUi]="touch" [disabled]="datepickerDisabled"></md-datepicker>
</p>

<h2>Result</h2>
Expand All @@ -40,20 +40,20 @@ <h2>Result</h2>
placeholder="Pick a date"
(dateInput)="onDateInput($event)"
(dateChange)="onDateChange($event)">
<md-datepicker
#resultPicker
[touchUi]="touch"
[disabled]="datepickerDisabled"
[startAt]="startAt"
[startView]="yearView ? 'year' : 'month'">
</md-datepicker>
<md-error *ngIf="resultPickerModel.hasError('mdDatepickerParse')">
"{{resultPickerModel.getError('mdDatepickerParse').text}}" is not a valid date!
</md-error>
<md-error *ngIf="resultPickerModel.hasError('mdDatepickerMin')">Too early!</md-error>
<md-error *ngIf="resultPickerModel.hasError('mdDatepickerMax')">Too late!</md-error>
<md-error *ngIf="resultPickerModel.hasError('mdDatepickerFilter')">Date unavailable!</md-error>
</md-input-container>
<md-datepicker
#resultPicker
[touchUi]="touch"
[disabled]="datepickerDisabled"
[startAt]="startAt"
[startView]="yearView ? 'year' : 'month'">
</md-datepicker>
</p>
<p>Last input: {{lastDateInput}}</p>
<p>Last change: {{lastDateChange}}</p>
Expand Down Expand Up @@ -83,9 +83,9 @@ <h2>Input disabled datepicker</h2>
<input mdInput [mdDatepicker]="datePicker1" [(ngModel)]="date" [min]="minDate" [max]="maxDate"
[mdDatepickerFilter]="filterOdd ? dateFilter : null" [disabled]="true"
placeholder="Input disabled">
</md-input-container>
<md-datepicker #datePicker1 [touchUi]="touch" [startAt]="startAt"
<md-datepicker #datePicker1 [touchUi]="touch" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></md-datepicker>
</md-input-container>
</p>

<h2>Input disabled, datepicker popup enabled</h2>
Expand All @@ -95,7 +95,7 @@ <h2>Input disabled, datepicker popup enabled</h2>
<input mdInput disabled [mdDatepicker]="datePicker2" [(ngModel)]="date" [min]="minDate"
[max]="maxDate" [mdDatepickerFilter]="filterOdd ? dateFilter : null"
placeholder="Input disabled, datepicker enabled">
<md-datepicker #datePicker2 [touchUi]="touch" [disabled]="false" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></md-datepicker>
</md-input-container>
<md-datepicker #datePicker2 [touchUi]="touch" [disabled]="false" [startAt]="startAt"
[startView]="yearView ? 'year' : 'month'"></md-datepicker>
</p>
2 changes: 2 additions & 0 deletions src/demo-app/demo-material-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
MdDatepickerModule,
MdDialogModule,
MdExpansionModule,
MdFormFieldModule,
MdGridListModule,
MdIconModule,
MdInputModule,
Expand Down Expand Up @@ -50,6 +51,7 @@ import {CdkTableModule} from '@angular/cdk/table';
MdDatepickerModule,
MdDialogModule,
MdExpansionModule,
MdFormFieldModule,
MdGridListModule,
MdIconModule,
MdInputModule,
Expand Down
2 changes: 1 addition & 1 deletion src/demo-app/tabs/tabs-demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tabs-demo .mat-card {
margin-top: 8px;
}

.mat-input-container {
.mat-form-field {
width: 100px;
}

Expand Down
23 changes: 19 additions & 4 deletions src/e2e-app/e2e-app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ import {InputE2E} from './input/input-e2e';
import {SidenavE2E} from './sidenav/sidenav-e2e';
import {BlockScrollStrategyE2E} from './block-scroll-strategy/block-scroll-strategy-e2e';
import {
OverlayContainer, FullscreenOverlayContainer, MdGridListModule, MdProgressBarModule,
MdProgressSpinnerModule, MdTabsModule, MdRadioModule, MdSlideToggleModule, MdMenuModule,
MdListModule, MdInputModule, MdIconModule, MdDialogModule, MdCheckboxModule, MdButtonModule,
MdSidenavModule, MdNativeDateModule,
FullscreenOverlayContainer,
MdButtonModule,
MdCheckboxModule,
MdDialogModule,
MdFormFieldModule,
MdGridListModule,
MdIconModule,
MdInputModule,
MdListModule,
MdMenuModule,
MdNativeDateModule,
MdProgressBarModule,
MdProgressSpinnerModule,
MdRadioModule,
MdSidenavModule,
MdSlideToggleModule,
MdTabsModule,
OverlayContainer,
} from '@angular/material';
import {ExampleModule} from '@angular/material-examples';

Expand All @@ -35,6 +49,7 @@ import {ExampleModule} from '@angular/material-examples';
MdButtonModule,
MdCheckboxModule,
MdDialogModule,
MdFormFieldModule,
MdGridListModule,
MdIconModule,
MdInputModule,
Expand Down
10 changes: 6 additions & 4 deletions src/lib/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import {Observable} from 'rxjs/Observable';
import {MdOptionSelectionChange, MdOption} from '../core/option/option';
import {ENTER, UP_ARROW, DOWN_ARROW, ESCAPE} from '../core/keyboard/keycodes';
import {Directionality} from '../core/bidi/index';
import {MdInputContainer} from '../input/input-container';
import {MdFormField} from '../form-field/index';
import {MdInput} from '../input/input';
import {Subscription} from 'rxjs/Subscription';
import {merge} from 'rxjs/observable/merge';
import {fromEvent} from 'rxjs/observable/fromEvent';
Expand Down Expand Up @@ -153,7 +154,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
private _changeDetectorRef: ChangeDetectorRef,
@Inject(MD_AUTOCOMPLETE_SCROLL_STRATEGY) private _scrollStrategy,
@Optional() private _dir: Directionality,
@Optional() @Host() private _inputContainer: MdInputContainer,
@Optional() @Host() private _inputContainer: MdFormField,
@Optional() @Inject(DOCUMENT) private _document: any) {}

ngOnDestroy() {
Expand Down Expand Up @@ -410,8 +411,9 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {

// If it's used in a Material container, we should set it through
// the property so it can go through the change detection.
if (this._inputContainer) {
this._inputContainer._mdInputChild.value = inputValue;
if (this._inputContainer &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename _inputContainer to _formField?

this._inputContainer._control instanceof MdInput) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to check MdInput specifically now? Add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm now that I think about it, its probably better to make the value property part of the MdFormFieldControl interface so this doesn't have to be hardcoded for MdInput. I was only thinking aboutmdInput and md-select when I wrote this, but its reasonable to want autocomplete to work with a user's custom input control as well

this._inputContainer._control.value = inputValue;
} else {
this._element.nativeElement.value = inputValue;
}
Expand Down
11 changes: 6 additions & 5 deletions src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {Directionality, Direction} from '../core/bidi/index';
import {Subscription} from 'rxjs/Subscription';
import {ENTER, DOWN_ARROW, SPACE, UP_ARROW, ESCAPE} from '../core/keyboard/keycodes';
import {MdOption} from '../core/option/option';
import {MdInputContainer} from '../input/input-container';
import {MdFormField, MdFormFieldModule} from '../form-field/index';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {createKeyboardEvent, dispatchFakeEvent, typeInElement} from '@angular/cdk/testing';
Expand All @@ -41,6 +41,7 @@ describe('MdAutocomplete', () => {
TestBed.configureTestingModule({
imports: [
MdAutocompleteModule,
MdFormFieldModule,
MdInputModule,
FormsModule,
ReactiveFormsModule,
Expand Down Expand Up @@ -517,7 +518,7 @@ describe('MdAutocomplete', () => {

it('should disable input in view when disabled programmatically', () => {
const inputUnderline =
fixture.debugElement.query(By.css('.mat-input-underline')).nativeElement;
fixture.debugElement.query(By.css('.mat-form-field-underline')).nativeElement;

expect(input.disabled)
.toBe(false, `Expected input to start out enabled in view.`);
Expand Down Expand Up @@ -1319,10 +1320,10 @@ describe('MdAutocomplete', () => {
fixture.detectChanges();

const input = fixture.nativeElement.querySelector('input');
const placeholder = fixture.nativeElement.querySelector('.mat-input-placeholder');
const placeholder = fixture.nativeElement.querySelector('.mat-form-field-placeholder');

expect(input.value).toBe('California');
expect(placeholder.classList).not.toContain('mat-empty');
expect(placeholder.classList).not.toContain('mat-form-field-empty');
}));

});
Expand Down Expand Up @@ -1417,7 +1418,7 @@ class SimpleAutocomplete implements OnDestroy {

@ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger;
@ViewChild(MdAutocomplete) panel: MdAutocomplete;
@ViewChild(MdInputContainer) inputContainer: MdInputContainer;
@ViewChild(MdFormField) inputContainer: MdFormField;
@ViewChildren(MdOption) options: QueryList<MdOption>;

states = [
Expand Down
3 changes: 2 additions & 1 deletion src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {createKeyboardEvent} from '@angular/cdk/testing';
import {MdInputModule} from '../input/index';
import {LEFT_ARROW, RIGHT_ARROW, BACKSPACE, DELETE, TAB} from '../core/keyboard/keycodes';
import {Directionality} from '../core';
import {MdFormFieldModule} from '../form-field/index';

describe('MdChipList', () => {
let fixture: ComponentFixture<any>;
Expand All @@ -23,7 +24,7 @@ describe('MdChipList', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MdChipsModule, MdInputModule, NoopAnimationsModule],
imports: [MdChipsModule, MdFormFieldModule, MdInputModule, NoopAnimationsModule],
declarations: [
StandardChipList, InputContainerChipList
],
Expand Down
4 changes: 2 additions & 2 deletions src/lib/chips/chips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $mat-chips-chip-margin: 8px;
}
}

.mat-input-prefix & {
.mat-form-field-prefix & {
&:last-child {
margin-right: $mat-chips-chip-margin;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ $mat-chips-chip-margin: 8px;
}
}

.mat-input-prefix .mat-chip-list-wrapper {
.mat-form-field-prefix .mat-chip-list-wrapper {
margin-bottom: $mat-chips-chip-margin;
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/core/compatibility/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const MAT_ELEMENTS_SELECTOR = `
mat-hint,
mat-icon,
mat-input-container,
mat-form-field,
mat-list,
mat-list-item,
mat-menu,
Expand Down Expand Up @@ -151,6 +152,7 @@ export const MD_ELEMENTS_SELECTOR = `
md-hint,
md-icon,
md-input-container,
md-form-field,
md-list,
md-list-item,
md-menu,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/core/theming/_all-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@import '../../toolbar/toolbar-theme';
@import '../../tooltip/tooltip-theme';
@import '../../snack-bar/simple-snack-bar-theme';
@import '../../form-field/form-field-theme';


// Create a theme.
Expand All @@ -42,6 +43,7 @@
@include mat-datepicker-theme($theme);
@include mat-dialog-theme($theme);
@include mat-expansion-panel-theme($theme);
@include mat-form-field-theme($theme);
@include mat-grid-list-theme($theme);
@include mat-icon-theme($theme);
@include mat-input-theme($theme);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/core/typography/_all-typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@import '../../snack-bar/simple-snack-bar-theme';
@import '../option/option-theme';
@import '../option/optgroup-theme';
@import '../../form-field/form-field-theme';


// Includes all of the typographic styles.
Expand All @@ -47,6 +48,7 @@
@include mat-datepicker-typography($config);
@include mat-dialog-typography($config);
@include mat-expansion-panel-typography($config);
@include mat-form-field-typography($config);
@include mat-grid-list-typography($config);
@include mat-icon-typography($config);
@include mat-input-typography($config);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
Validators
} from '@angular/forms';
import {Subscription} from 'rxjs/Subscription';
import {MdInputContainer} from '../input/input-container';
import {MdFormField} from '../form-field/index';
import {DOWN_ARROW} from '../core/keyboard/keycodes';
import {DateAdapter} from '../core/datetime/index';
import {createMissingDateImplError} from './datepicker-errors';
Expand Down Expand Up @@ -212,7 +212,7 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
private _renderer: Renderer2,
@Optional() private _dateAdapter: DateAdapter<D>,
@Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats,
@Optional() private _mdInputContainer: MdInputContainer) {
@Optional() private _mdInputContainer: MdFormField) {
if (!this._dateAdapter) {
throw createMissingDateImplError('DateAdapter');
}
Expand Down
13 changes: 11 additions & 2 deletions src/lib/datepicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
createKeyboardEvent,
dispatchEvent,
} from '@angular/cdk/testing';
import {MdFormFieldModule} from '../form-field/index';

describe('MdDatepicker', () => {
afterEach(inject([OverlayContainer], (container: OverlayContainer) => {
Expand All @@ -28,6 +29,7 @@ describe('MdDatepicker', () => {
imports: [
FormsModule,
MdDatepickerModule,
MdFormFieldModule,
MdInputModule,
MdNativeDateModule,
NoopAnimationsModule,
Expand Down Expand Up @@ -596,7 +598,7 @@ describe('MdDatepicker', () => {

it('should attach popup to input-container underline', () => {
let attachToRef = testComponent.datepickerInput.getPopupConnectionElementRef();
expect(attachToRef.nativeElement.classList.contains('mat-input-underline'))
expect(attachToRef.nativeElement.classList.contains('mat-form-field-underline'))
.toBe(true, 'popup should be attached to input-container underline');
});
});
Expand Down Expand Up @@ -817,6 +819,7 @@ describe('MdDatepicker', () => {
imports: [
FormsModule,
MdDatepickerModule,
MdFormFieldModule,
MdInputModule,
NoopAnimationsModule,
ReactiveFormsModule,
Expand All @@ -840,7 +843,13 @@ describe('MdDatepicker', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MdDatepickerModule, MdInputModule, MdNativeDateModule, NoopAnimationsModule],
imports: [
MdDatepickerModule,
MdFormFieldModule,
MdInputModule,
MdNativeDateModule,
NoopAnimationsModule
],
declarations: [StandardDatepicker],
}).compileComponents();

Expand Down
Loading