From 311242a6e6065884465e94fc46a36a0747648ed8 Mon Sep 17 00:00:00 2001 From: emoralesb05 Date: Wed, 16 Aug 2017 15:30:30 -0700 Subject: [PATCH 001/575] feat(select): update the trigger width when select is opened --- src/cdk/overlay/overlay-directives.spec.ts | 36 ++++++++++++++++++++ src/cdk/overlay/overlay-directives.ts | 34 +++++++++++------- src/cdk/overlay/overlay-ref.ts | 25 ++++++++++++-- src/lib/autocomplete/autocomplete-trigger.ts | 7 ++-- src/lib/select/select.spec.ts | 28 +++++++++++++++ src/lib/select/select.ts | 6 ++-- 6 files changed, 116 insertions(+), 20 deletions(-) diff --git a/src/cdk/overlay/overlay-directives.spec.ts b/src/cdk/overlay/overlay-directives.spec.ts index e0876038d708..8bc2f8e7b027 100644 --- a/src/cdk/overlay/overlay-directives.spec.ts +++ b/src/cdk/overlay/overlay-directives.spec.ts @@ -135,6 +135,15 @@ describe('Overlay directives', () => { const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.width).toEqual('250px'); + + fixture.componentInstance.isOpen = false; + fixture.detectChanges(); + + fixture.componentInstance.width = 500; + fixture.componentInstance.isOpen = true; + fixture.detectChanges(); + + expect(pane.style.width).toEqual('500px'); }); it('should set the height', () => { @@ -144,6 +153,15 @@ describe('Overlay directives', () => { const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.height).toEqual('100vh'); + + fixture.componentInstance.isOpen = false; + fixture.detectChanges(); + + fixture.componentInstance.height = '50vh'; + fixture.componentInstance.isOpen = true; + fixture.detectChanges(); + + expect(pane.style.height).toEqual('50vh'); }); it('should set the min width', () => { @@ -153,6 +171,15 @@ describe('Overlay directives', () => { const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.minWidth).toEqual('250px'); + + fixture.componentInstance.isOpen = false; + fixture.detectChanges(); + + fixture.componentInstance.minWidth = 500; + fixture.componentInstance.isOpen = true; + fixture.detectChanges(); + + expect(pane.style.minWidth).toEqual('500px'); }); it('should set the min height', () => { @@ -162,6 +189,15 @@ describe('Overlay directives', () => { const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.minHeight).toEqual('500px'); + + fixture.componentInstance.isOpen = false; + fixture.detectChanges(); + + fixture.componentInstance.minHeight = 500; + fixture.componentInstance.isOpen = true; + fixture.detectChanges(); + + expect(pane.style.minHeight).toEqual('500px'); }); it('should create the backdrop if designated', () => { diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index 757ae1331fb4..357fedbb4721 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -274,6 +274,23 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { private _buildConfig(): OverlayState { let overlayConfig = new OverlayState(); + this._configureSize(overlayConfig); + + overlayConfig.hasBackdrop = this.hasBackdrop; + + if (this.backdropClass) { + overlayConfig.backdropClass = this.backdropClass; + } + + this._position = this._createPositionStrategy() as ConnectedPositionStrategy; + overlayConfig.positionStrategy = this._position; + overlayConfig.scrollStrategy = this.scrollStrategy; + + return overlayConfig; + } + + /** Configure the overlay size based on the directive's inputs */ + private _configureSize(overlayConfig: OverlayState): void { if (this.width || this.width === 0) { overlayConfig.width = this.width; } @@ -289,18 +306,6 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { if (this.minHeight || this.minHeight === 0) { overlayConfig.minHeight = this.minHeight; } - - overlayConfig.hasBackdrop = this.hasBackdrop; - - if (this.backdropClass) { - overlayConfig.backdropClass = this.backdropClass; - } - - this._position = this._createPositionStrategy() as ConnectedPositionStrategy; - overlayConfig.positionStrategy = this._position; - overlayConfig.scrollStrategy = this.scrollStrategy; - - return overlayConfig; } /** Returns the position strategy of the overlay to be set on the overlay config */ @@ -335,6 +340,11 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { private _attachOverlay() { if (!this._overlayRef) { this._createOverlay(); + } else { + // Update the overlay size, in case the directive's inputs have changed + const overlayState = new OverlayState(); + this._configureSize(overlayState); + this._overlayRef.updateSize(overlayState); } this._position.withDirection(this.dir); diff --git a/src/cdk/overlay/overlay-ref.ts b/src/cdk/overlay/overlay-ref.ts index 25bd7a07e4dc..1a7f7697f757 100644 --- a/src/cdk/overlay/overlay-ref.ts +++ b/src/cdk/overlay/overlay-ref.ts @@ -47,7 +47,7 @@ export class OverlayRef implements PortalHost { // Update the pane element with the given state configuration. this._updateStackingOrder(); - this.updateSize(); + this._setSizeStyles(); this.updateDirection(); this.updatePosition(); this._state.scrollStrategy.enable(); @@ -155,8 +155,29 @@ export class OverlayRef implements PortalHost { this._pane.setAttribute('dir', this._state.direction!); } + /** Updates the state size of the overlay */ + updateSize(state: OverlayState) { + if (state.width || state.width === 0) { + this._state.width = state.width; + } + + if (state.height || state.height === 0) { + this._state.height = state.height; + } + + if (state.minWidth || state.minWidth === 0) { + this._state.minWidth = state.minWidth; + } + + if (state.minHeight || state.minHeight === 0) { + this._state.minHeight = state.minHeight; + } + + this._setSizeStyles(); + } + /** Updates the size of the overlay based on the overlay config. */ - updateSize() { + private _setSizeStyles() { if (this._state.width || this._state.width === 0) { this._pane.style.width = formatCssUnit(this._state.width); } diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index d0da2c36bc66..92f0ed4ce85d 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -176,9 +176,10 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { if (!this._overlayRef) { this._createOverlay(); } else { - /** Update the panel width, in case the host width has changed */ - this._overlayRef.getState().width = this._getHostWidth(); - this._overlayRef.updateSize(); + // Update the panel width, in case the host width has changed + const overlayState = new OverlayState(); + overlayState.width = this._getHostWidth(); + this._overlayRef.updateSize(overlayState); } if (this._overlayRef && !this._overlayRef.hasAttached()) { diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index ee55075a76fe..ac8c25f821b5 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -2478,6 +2478,34 @@ describe('MdSelect', () => { }); })); + it('should set the width of the overlay based on the trigger and resize', async(() => { + trigger.style.width = '200px'; + fixture.detectChanges(); + fixture.whenStable().then(() => { + trigger.click(); + fixture.detectChanges(); + const pane = overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement; + expect(pane.style.minWidth).toBe('200px', + 'Expected pane minWidth to be 200px initially'); + + const backdrop = + overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement; + backdrop.click(); + fixture.detectChanges(); + fixture.whenStable().then(() => { + + trigger.style.width = '400px'; + fixture.detectChanges(); + fixture.whenStable().then(() => { + trigger.click(); + fixture.detectChanges(); + expect(pane.style.minWidth).toBe('400px', + 'Expected pane minWidth to be 400px after resize'); + }); + }); + }); + })); + }); describe('theming', () => { diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index ee179ceeb55b..59fd76d7f24d 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -466,9 +466,9 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On return; } - if (!this._triggerWidth) { - this._setTriggerWidth(); - } + // Always set the trigger width since we need to + // update the panel with its new minWidth when opening it + this._setTriggerWidth(); this._calculateOverlayPosition(); this._placeholderState = this._floatPlaceholderState(); From 87318bc7c83d249036837376609ea099e5aea2d9 Mon Sep 17 00:00:00 2001 From: Ji Won Shin Date: Thu, 31 Aug 2017 15:26:05 -0700 Subject: [PATCH 002/575] feat(stepper): initial version of stepper (#6594) --- src/cdk/stepper/index.ts | 9 + src/cdk/stepper/public_api.ts | 25 + src/cdk/stepper/step-label.ts | 16 + src/cdk/stepper/step.html | 1 + src/cdk/stepper/stepper-button.ts | 28 + src/cdk/stepper/stepper.ts | 263 +++++++ src/cdk/stepper/tsconfig-build.json | 13 + src/demo-app/demo-app/demo-app.ts | 1 + src/demo-app/demo-app/demo-module.ts | 2 + src/demo-app/demo-app/routes.ts | 2 + src/demo-app/demo-material-module.ts | 4 +- src/demo-app/stepper/stepper-demo.html | 197 +++++ src/demo-app/stepper/stepper-demo.ts | 53 ++ src/demo-app/system-config.ts | 1 + src/e2e-app/system-config.ts | 1 + src/lib/core/compatibility/compatibility.ts | 16 +- src/lib/core/theming/_all-theme.scss | 2 + src/lib/core/typography/_all-typography.scss | 2 + src/lib/module.ts | 4 +- src/lib/public_api.ts | 1 + src/lib/stepper/_stepper-theme.scss | 53 ++ src/lib/stepper/index.ts | 40 + src/lib/stepper/step-header.html | 17 + src/lib/stepper/step-header.scss | 42 + src/lib/stepper/step-header.ts | 73 ++ src/lib/stepper/step-label.ts | 22 + src/lib/stepper/step.html | 1 + src/lib/stepper/stepper-button.ts | 31 + src/lib/stepper/stepper-horizontal.html | 30 + src/lib/stepper/stepper-vertical.html | 28 + src/lib/stepper/stepper.md | 132 ++++ src/lib/stepper/stepper.scss | 122 +++ src/lib/stepper/stepper.spec.ts | 765 +++++++++++++++++++ src/lib/stepper/stepper.ts | 132 ++++ test/karma-test-shim.js | 1 + 35 files changed, 2126 insertions(+), 4 deletions(-) create mode 100644 src/cdk/stepper/index.ts create mode 100644 src/cdk/stepper/public_api.ts create mode 100644 src/cdk/stepper/step-label.ts create mode 100644 src/cdk/stepper/step.html create mode 100644 src/cdk/stepper/stepper-button.ts create mode 100644 src/cdk/stepper/stepper.ts create mode 100644 src/cdk/stepper/tsconfig-build.json create mode 100644 src/demo-app/stepper/stepper-demo.html create mode 100644 src/demo-app/stepper/stepper-demo.ts create mode 100644 src/lib/stepper/_stepper-theme.scss create mode 100644 src/lib/stepper/index.ts create mode 100644 src/lib/stepper/step-header.html create mode 100644 src/lib/stepper/step-header.scss create mode 100644 src/lib/stepper/step-header.ts create mode 100644 src/lib/stepper/step-label.ts create mode 100644 src/lib/stepper/step.html create mode 100644 src/lib/stepper/stepper-button.ts create mode 100644 src/lib/stepper/stepper-horizontal.html create mode 100644 src/lib/stepper/stepper-vertical.html create mode 100644 src/lib/stepper/stepper.md create mode 100644 src/lib/stepper/stepper.scss create mode 100644 src/lib/stepper/stepper.spec.ts create mode 100644 src/lib/stepper/stepper.ts diff --git a/src/cdk/stepper/index.ts b/src/cdk/stepper/index.ts new file mode 100644 index 000000000000..f93e7c31d564 --- /dev/null +++ b/src/cdk/stepper/index.ts @@ -0,0 +1,9 @@ +/** + * @license + * Copyright Google Inc. 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/cdk/stepper/public_api.ts b/src/cdk/stepper/public_api.ts new file mode 100644 index 000000000000..2ef3326db218 --- /dev/null +++ b/src/cdk/stepper/public_api.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright Google Inc. 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 {NgModule} from '@angular/core'; +import {CdkStepper, CdkStep} from './stepper'; +import {CommonModule} from '@angular/common'; +import {CdkStepLabel} from './step-label'; +import {CdkStepperNext, CdkStepperPrevious} from './stepper-button'; +import {BidiModule} from '@angular/cdk/bidi'; + +@NgModule({ + imports: [BidiModule, CommonModule], + exports: [CdkStep, CdkStepper, CdkStepLabel, CdkStepperNext, CdkStepperPrevious], + declarations: [CdkStep, CdkStepper, CdkStepLabel, CdkStepperNext, CdkStepperPrevious] +}) +export class CdkStepperModule {} + +export * from './stepper'; +export * from './step-label'; +export * from './stepper-button'; diff --git a/src/cdk/stepper/step-label.ts b/src/cdk/stepper/step-label.ts new file mode 100644 index 000000000000..e253b4bfcab5 --- /dev/null +++ b/src/cdk/stepper/step-label.ts @@ -0,0 +1,16 @@ +/** + * @license + * Copyright Google Inc. 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 {Directive, TemplateRef} from '@angular/core'; + +@Directive({ + selector: '[cdkStepLabel]', +}) +export class CdkStepLabel { + constructor(public template: TemplateRef) { } +} diff --git a/src/cdk/stepper/step.html b/src/cdk/stepper/step.html new file mode 100644 index 000000000000..cd48c06b9917 --- /dev/null +++ b/src/cdk/stepper/step.html @@ -0,0 +1 @@ + diff --git a/src/cdk/stepper/stepper-button.ts b/src/cdk/stepper/stepper-button.ts new file mode 100644 index 000000000000..c63d8c822eef --- /dev/null +++ b/src/cdk/stepper/stepper-button.ts @@ -0,0 +1,28 @@ +/** + * @license + * Copyright Google Inc. 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 {Directive} from '@angular/core'; +import {CdkStepper} from './stepper'; + +/** Button that moves to the next step in a stepper workflow. */ +@Directive({ + selector: 'button[cdkStepperNext]', + host: {'(click)': '_stepper.next()'} +}) +export class CdkStepperNext { + constructor(public _stepper: CdkStepper) { } +} + +/** Button that moves to the previous step in a stepper workflow. */ +@Directive({ + selector: 'button[cdkStepperPrevious]', + host: {'(click)': '_stepper.previous()'} +}) +export class CdkStepperPrevious { + constructor(public _stepper: CdkStepper) { } +} diff --git a/src/cdk/stepper/stepper.ts b/src/cdk/stepper/stepper.ts new file mode 100644 index 000000000000..24a02dc6545a --- /dev/null +++ b/src/cdk/stepper/stepper.ts @@ -0,0 +1,263 @@ +/** + * @license + * Copyright Google Inc. 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 { + ContentChildren, + EventEmitter, + Input, + Output, + QueryList, + Directive, + // This import is only used to define a generic type. The current TypeScript version incorrectly + // considers such imports as unused (https://github.com/Microsoft/TypeScript/issues/14953) + // tslint:disable-next-line:no-unused-variable + ElementRef, + Component, + ContentChild, + ViewChild, + TemplateRef, + ViewEncapsulation, + Optional, + Inject, + forwardRef +} from '@angular/core'; +import {LEFT_ARROW, RIGHT_ARROW, ENTER, SPACE} from '@angular/cdk/keycodes'; +import {CdkStepLabel} from './step-label'; +import {coerceBooleanProperty} from '@angular/cdk/coercion'; +import {AbstractControl} from '@angular/forms'; +import {Directionality} from '@angular/cdk/bidi'; + +/** Used to generate unique ID for each stepper component. */ +let nextId = 0; + +/** + * Position state of the content of each step in stepper that is used for transitioning + * the content into correct position upon step selection change. + */ +export type StepContentPositionState = 'previous' | 'current' | 'next'; + +/** Change event emitted on selection changes. */ +export class StepperSelectionEvent { + /** Index of the step now selected. */ + selectedIndex: number; + + /** Index of the step previously selected. */ + previouslySelectedIndex: number; + + /** The step instance now selected. */ + selectedStep: CdkStep; + + /** The step instance previously selected. */ + previouslySelectedStep: CdkStep; +} + +@Component({ + selector: 'cdk-step', + templateUrl: 'step.html', + encapsulation: ViewEncapsulation.None +}) +export class CdkStep { + /** Template for step label if it exists. */ + @ContentChild(CdkStepLabel) stepLabel: CdkStepLabel; + + /** Template for step content. */ + @ViewChild(TemplateRef) content: TemplateRef; + + /** The top level abstract control of the step. */ + @Input() stepControl: AbstractControl; + + /** Whether user has seen the expanded step content or not . */ + interacted = false; + + /** Label of the step. */ + @Input() + label: string; + + @Input() + get editable() { return this._editable; } + set editable(value: any) { + this._editable = coerceBooleanProperty(value); + } + private _editable = true; + + /** Whether the completion of step is optional or not. */ + @Input() + get optional() { return this._optional; } + set optional(value: any) { + this._optional = coerceBooleanProperty(value); + } + private _optional = false; + + /** Return whether step is completed or not. */ + @Input() + get completed() { + return this._customCompleted == null ? this._defaultCompleted : this._customCompleted; + } + set completed(value: any) { + this._customCompleted = coerceBooleanProperty(value); + } + private _customCompleted: boolean | null = null; + + private get _defaultCompleted() { + return this.stepControl ? this.stepControl.valid && this.interacted : this.interacted; + } + + constructor(@Inject(forwardRef(() => CdkStepper)) private _stepper: CdkStepper) { } + + /** Selects this step component. */ + select(): void { + this._stepper.selected = this; + } +} + +@Directive({ + selector: '[cdkStepper]', +}) +export class CdkStepper { + /** The list of step components that the stepper is holding. */ + @ContentChildren(CdkStep) _steps: QueryList; + + /** The list of step headers of the steps in the stepper. */ + _stepHeader: QueryList; + + /** Whether the validity of previous steps should be checked or not. */ + @Input() + get linear() { return this._linear; } + set linear(value: any) { this._linear = coerceBooleanProperty(value); } + private _linear = false; + + /** The index of the selected step. */ + @Input() + get selectedIndex() { return this._selectedIndex; } + set selectedIndex(index: number) { + if (this._anyControlsInvalid(index) + || index < this._selectedIndex && !this._steps.toArray()[index].editable) { + // remove focus from clicked step header if the step is not able to be selected + this._stepHeader.toArray()[index].nativeElement.blur(); + } else if (this._selectedIndex != index) { + this._emitStepperSelectionEvent(index); + this._focusIndex = this._selectedIndex; + } + } + private _selectedIndex: number = 0; + + /** The step that is selected. */ + @Input() + get selected() { return this._steps[this.selectedIndex]; } + set selected(step: CdkStep) { + let index = this._steps.toArray().indexOf(step); + this.selectedIndex = index; + } + + /** Event emitted when the selected step has changed. */ + @Output() selectionChange = new EventEmitter(); + + /** The index of the step that the focus can be set. */ + _focusIndex: number = 0; + + /** Used to track unique ID for each stepper component. */ + _groupId: number; + + constructor(@Optional() private _dir: Directionality) { + this._groupId = nextId++; + } + + /** Selects and focuses the next step in list. */ + next(): void { + this.selectedIndex = Math.min(this._selectedIndex + 1, this._steps.length - 1); + } + + /** Selects and focuses the previous step in list. */ + previous(): void { + this.selectedIndex = Math.max(this._selectedIndex - 1, 0); + } + + /** Returns a unique id for each step label element. */ + _getStepLabelId(i: number): string { + return `mat-step-label-${this._groupId}-${i}`; + } + + /** Returns unique id for each step content element. */ + _getStepContentId(i: number): string { + return `mat-step-content-${this._groupId}-${i}`; + } + + /** Returns position state of the step with the given index. */ + _getAnimationDirection(index: number): StepContentPositionState { + const position = index - this._selectedIndex; + if (position < 0) { + return 'previous'; + } else if (position > 0) { + return 'next'; + } else { + return 'current'; + } + } + + /** Returns the type of icon to be displayed. */ + _getIndicatorType(index: number): 'number' | 'edit' | 'done' { + const step = this._steps.toArray()[index]; + if (!step.completed || this._selectedIndex == index) { + return 'number'; + } else { + return step.editable ? 'edit' : 'done'; + } + } + + private _emitStepperSelectionEvent(newIndex: number): void { + const stepsArray = this._steps.toArray(); + this.selectionChange.emit({ + selectedIndex: newIndex, + previouslySelectedIndex: this._selectedIndex, + selectedStep: stepsArray[newIndex], + previouslySelectedStep: stepsArray[this._selectedIndex], + }); + this._selectedIndex = newIndex; + } + + _onKeydown(event: KeyboardEvent) { + switch (event.keyCode) { + case RIGHT_ARROW: + if (this._dir && this._dir.value === 'rtl') { + this._focusStep((this._focusIndex + this._steps.length - 1) % this._steps.length); + } else { + this._focusStep((this._focusIndex + 1) % this._steps.length); + } + break; + case LEFT_ARROW: + if (this._dir && this._dir.value === 'rtl') { + this._focusStep((this._focusIndex + 1) % this._steps.length); + } else { + this._focusStep((this._focusIndex + this._steps.length - 1) % this._steps.length); + } + break; + case SPACE: + case ENTER: + this.selectedIndex = this._focusIndex; + break; + default: + // Return to avoid calling preventDefault on keys that are not explicitly handled. + return; + } + event.preventDefault(); + } + + private _focusStep(index: number) { + this._focusIndex = index; + this._stepHeader.toArray()[this._focusIndex].nativeElement.focus(); + } + + private _anyControlsInvalid(index: number): boolean { + const stepsArray = this._steps.toArray(); + stepsArray[this._selectedIndex].interacted = true; + if (this._linear) { + return stepsArray.slice(0, index).some(step => step.stepControl.invalid); + } + return false; + } +} diff --git a/src/cdk/stepper/tsconfig-build.json b/src/cdk/stepper/tsconfig-build.json new file mode 100644 index 000000000000..4231d46ba702 --- /dev/null +++ b/src/cdk/stepper/tsconfig-build.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig-build", + "files": [ + "public_api.ts" + ], + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "strictMetadataEmit": true, + "flatModuleOutFile": "index.js", + "flatModuleId": "@angular/cdk/stepper", + "skipTemplateCodegen": true + } +} diff --git a/src/demo-app/demo-app/demo-app.ts b/src/demo-app/demo-app/demo-app.ts index 2938c6fe5400..8d35ac9bb93f 100644 --- a/src/demo-app/demo-app/demo-app.ts +++ b/src/demo-app/demo-app/demo-app.ts @@ -72,6 +72,7 @@ export class DemoApp { {name: 'Slider', route: '/slider'}, {name: 'Slide Toggle', route: '/slide-toggle'}, {name: 'Snack Bar', route: '/snack-bar'}, + {name: 'Stepper', route: 'stepper'}, {name: 'Table', route: '/table'}, {name: 'Tabs', route: '/tabs'}, {name: 'Toolbar', route: '/toolbar'}, diff --git a/src/demo-app/demo-app/demo-module.ts b/src/demo-app/demo-app/demo-module.ts index 7b5165b3fa35..79de0624a050 100644 --- a/src/demo-app/demo-app/demo-module.ts +++ b/src/demo-app/demo-app/demo-module.ts @@ -40,6 +40,7 @@ import {PeopleDatabase} from '../table/people-database'; import {DatepickerDemo} from '../datepicker/datepicker-demo'; import {TypographyDemo} from '../typography/typography-demo'; import {ExpansionDemo} from '../expansion/expansion-demo'; +import {StepperDemo} from '../stepper/stepper-demo'; import {DemoMaterialModule} from '../demo-material-module'; import { FullscreenOverlayContainer, @@ -92,6 +93,7 @@ import {TableHeaderDemo} from '../table/table-header-demo'; SliderDemo, SlideToggleDemo, SpagettiPanel, + StepperDemo, StyleDemo, TableHeaderDemo, ToolbarDemo, diff --git a/src/demo-app/demo-app/routes.ts b/src/demo-app/demo-app/routes.ts index ac5d752b0f5f..1a0b5eb5a389 100644 --- a/src/demo-app/demo-app/routes.ts +++ b/src/demo-app/demo-app/routes.ts @@ -36,6 +36,7 @@ import {DatepickerDemo} from '../datepicker/datepicker-demo'; import {TableDemo} from '../table/table-demo'; import {TypographyDemo} from '../typography/typography-demo'; import {ExpansionDemo} from '../expansion/expansion-demo'; +import {StepperDemo} from '../stepper/stepper-demo'; import {DemoApp} from './demo-app'; import {AccessibilityDemo} from '../a11y/a11y'; import {ACCESSIBILITY_DEMO_ROUTES} from '../a11y/routes'; @@ -78,6 +79,7 @@ export const DEMO_APP_ROUTES: Routes = [ {path: 'style', component: StyleDemo}, {path: 'typography', component: TypographyDemo}, {path: 'expansion', component: ExpansionDemo}, + {path: 'stepper', component: StepperDemo} ]} ]; diff --git a/src/demo-app/demo-material-module.ts b/src/demo-app/demo-material-module.ts index 74b1b5ce9e17..bf2ffc8cc2df 100644 --- a/src/demo-app/demo-material-module.ts +++ b/src/demo-app/demo-material-module.ts @@ -31,7 +31,8 @@ import { MdTabsModule, MdToolbarModule, MdTooltipModule, - StyleModule + StyleModule, + MdStepperModule, } from '@angular/material'; import {CdkTableModule} from '@angular/cdk/table'; import {A11yModule} from '@angular/cdk/a11y'; @@ -73,6 +74,7 @@ import {PortalModule} from '@angular/cdk/portal'; MdSliderModule, MdSnackBarModule, MdSortModule, + MdStepperModule, MdTabsModule, MdToolbarModule, MdTooltipModule, diff --git a/src/demo-app/stepper/stepper-demo.html b/src/demo-app/stepper/stepper-demo.html new file mode 100644 index 000000000000..11cda6eaea19 --- /dev/null +++ b/src/demo-app/stepper/stepper-demo.html @@ -0,0 +1,197 @@ +Disable linear mode + +

Linear Vertical Stepper Demo using a single form

+
+ + + Fill out your name + + + This field is required + + + + + This field is required + +
+ +
+
+ + + +
Fill out your email address
+
+ + + The input is invalid. + +
+ + +
+
+ + + Confirm your information + Everything seems correct. +
+ +
+
+
+
+ +

Linear Horizontal Stepper Demo using a different form for each step

+ + +
+ Fill out your name + + + This field is required + + + + This field is required + +
+ +
+
+
+ + +
+ Fill out your email address + + + The input is invalid + +
+ + +
+
+
+ + +
+ Confirm your information + Everything seems correct. +
+ +
+
+
+
+ +

Vertical Stepper Demo

+Make steps non-editable + + + Fill out your name + + + + + + + +
+ +
+
+ + + +
Fill out your phone number
+
+ + + +
+ + +
+
+ + + +
Fill out your address
+
+ + + +
+ + +
+
+ + + Confirm your information + Everything seems correct. +
+ +
+
+
+ +

Horizontal Stepper Demo with Text Label

+ + + + + + + + + +
+ +
+
+ + + + + +
+ + +
+
+ + + + + +
+ + +
+
+ + + Everything seems correct. +
+ +
+
+
+ +

Horizontal Stepper Demo with Templated Label

+ + + {{step.label}} + + + +
+ + +
+
+
diff --git a/src/demo-app/stepper/stepper-demo.ts b/src/demo-app/stepper/stepper-demo.ts new file mode 100644 index 000000000000..77cfb3535913 --- /dev/null +++ b/src/demo-app/stepper/stepper-demo.ts @@ -0,0 +1,53 @@ +import {Component} from '@angular/core'; +import {AbstractControl, FormBuilder, FormGroup, Validators} from '@angular/forms'; + +const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; + +@Component({ + moduleId: module.id, + selector: 'stepper-demo', + templateUrl: 'stepper-demo.html' +}) +export class StepperDemo { + formGroup: FormGroup; + isNonLinear = false; + isNonEditable = false; + + nameFormGroup: FormGroup; + emailFormGroup: FormGroup; + + steps = [ + {label: 'Confirm your name', content: 'Last name, First name.'}, + {label: 'Confirm your contact information', content: '123-456-7890'}, + {label: 'Confirm your address', content: '1600 Amphitheater Pkwy MTV'}, + {label: 'You are now done', content: 'Finished!'} + ]; + + /** Returns a FormArray with the name 'formArray'. */ + get formArray(): AbstractControl | null { return this.formGroup.get('formArray'); } + + constructor(private _formBuilder: FormBuilder) { } + + ngOnInit() { + this.formGroup = this._formBuilder.group({ + formArray: this._formBuilder.array([ + this._formBuilder.group({ + firstNameFormCtrl: ['', Validators.required], + lastNameFormCtrl: ['', Validators.required], + }), + this._formBuilder.group({ + emailFormCtrl: ['', Validators.pattern(EMAIL_REGEX)] + }), + ]) + }); + + this.nameFormGroup = this._formBuilder.group({ + firstNameCtrl: ['', Validators.required], + lastNameCtrl: ['', Validators.required], + }); + + this.emailFormGroup = this._formBuilder.group({ + emailCtrl: ['', Validators.pattern(EMAIL_REGEX)] + }); + } +} diff --git a/src/demo-app/system-config.ts b/src/demo-app/system-config.ts index 6965450053b8..38f8de2c2284 100644 --- a/src/demo-app/system-config.ts +++ b/src/demo-app/system-config.ts @@ -38,6 +38,7 @@ System.config({ '@angular/cdk/portal': 'dist/bundles/cdk-portal.umd.js', '@angular/cdk/rxjs': 'dist/bundles/cdk-rxjs.umd.js', '@angular/cdk/scrolling': 'dist/bundles/cdk-scrolling.umd.js', + '@angular/cdk/stepper': 'dist/bundles/cdk-stepper.umd.js', '@angular/cdk/table': 'dist/bundles/cdk-table.umd.js', '@angular/cdk/testing': 'dist/bundles/cdk-testing.umd.js', }, diff --git a/src/e2e-app/system-config.ts b/src/e2e-app/system-config.ts index 2360a995fe45..75700c38fcfc 100644 --- a/src/e2e-app/system-config.ts +++ b/src/e2e-app/system-config.ts @@ -38,6 +38,7 @@ System.config({ '@angular/cdk/portal': 'dist/bundles/cdk-portal.umd.js', '@angular/cdk/rxjs': 'dist/bundles/cdk-rxjs.umd.js', '@angular/cdk/scrolling': 'dist/bundles/cdk-scrolling.umd.js', + '@angular/cdk/stepper': 'dist/bundles/cdk-stepper.umd.js', '@angular/cdk/table': 'dist/bundles/cdk-table.umd.js', '@angular/cdk/testing': 'dist/bundles/cdk-testing.umd.js', '@angular/material-examples': 'dist/bundles/material-examples.umd.js', diff --git a/src/lib/core/compatibility/compatibility.ts b/src/lib/core/compatibility/compatibility.ts index 53ed876ff3d4..769e23fcb549 100644 --- a/src/lib/core/compatibility/compatibility.ts +++ b/src/lib/core/compatibility/compatibility.ts @@ -39,6 +39,9 @@ export const MAT_ELEMENTS_SELECTOR = ` [matHeaderRowDef], [matLine], [matRowDef], + [matStepLabel], + [matStepperNext], + [matStepperPrevious], [matTabLabel], [matTabLink], [matTabNav], @@ -73,6 +76,7 @@ export const MAT_ELEMENTS_SELECTOR = ` mat-header-cell, mat-header-row, mat-hint, + mat-horizontal-stepper, mat-icon, mat-input-container, mat-form-field, @@ -92,10 +96,12 @@ export const MAT_ELEMENTS_SELECTOR = ` mat-sidenav-container, mat-slider, mat-spinner, + mat-step, mat-tab, mat-table, mat-tab-group, - mat-toolbar`; + mat-toolbar, + mat-vertical-stepper`; /** Selector that matches all elements that may have style collisions with AngularJS Material. */ export const MD_ELEMENTS_SELECTOR = ` @@ -116,6 +122,9 @@ export const MD_ELEMENTS_SELECTOR = ` [mdHeaderRowDef], [mdLine], [mdRowDef], + [mdStepLabel], + [mdStepperNext], + [mdStepperPrevious], [mdTabLabel], [mdTabLink], [mdTabNav], @@ -150,6 +159,7 @@ export const MD_ELEMENTS_SELECTOR = ` md-header-cell, md-header-row, md-hint, + md-horizontal-stepper, md-icon, md-input-container, md-form-field, @@ -169,10 +179,12 @@ export const MD_ELEMENTS_SELECTOR = ` md-sidenav-container, md-slider, md-spinner, + md-step, md-tab, md-table, md-tab-group, - md-toolbar`; + md-toolbar, + md-vertical-stepper`; /** Directive that enforces that the `mat-` prefix cannot be used. */ @Directive({selector: MAT_ELEMENTS_SELECTOR}) diff --git a/src/lib/core/theming/_all-theme.scss b/src/lib/core/theming/_all-theme.scss index 4f808fca5ef1..a2ed3f9459ba 100644 --- a/src/lib/core/theming/_all-theme.scss +++ b/src/lib/core/theming/_all-theme.scss @@ -23,6 +23,7 @@ @import '../../sidenav/sidenav-theme'; @import '../../slide-toggle/slide-toggle-theme'; @import '../../slider/slider-theme'; +@import '../../stepper/stepper-theme'; @import '../../tabs/tabs-theme'; @import '../../toolbar/toolbar-theme'; @import '../../tooltip/tooltip-theme'; @@ -57,6 +58,7 @@ @include mat-sidenav-theme($theme); @include mat-slide-toggle-theme($theme); @include mat-slider-theme($theme); + @include mat-stepper-theme($theme); @include mat-tabs-theme($theme); @include mat-toolbar-theme($theme); @include mat-tooltip-theme($theme); diff --git a/src/lib/core/typography/_all-typography.scss b/src/lib/core/typography/_all-typography.scss index 4935de608bd2..a0766383a781 100644 --- a/src/lib/core/typography/_all-typography.scss +++ b/src/lib/core/typography/_all-typography.scss @@ -22,6 +22,7 @@ @import '../../sidenav/sidenav-theme'; @import '../../slide-toggle/slide-toggle-theme'; @import '../../slider/slider-theme'; +@import '../../stepper/stepper-theme'; @import '../../tabs/tabs-theme'; @import '../../toolbar/toolbar-theme'; @import '../../tooltip/tooltip-theme'; @@ -61,6 +62,7 @@ @include mat-sidenav-typography($config); @include mat-slide-toggle-typography($config); @include mat-slider-typography($config); + @include mat-stepper-typography($config); @include mat-tabs-typography($config); @include mat-toolbar-typography($config); @include mat-tooltip-typography($config); diff --git a/src/lib/module.ts b/src/lib/module.ts index 4cec7ca1de0c..66d460334b03 100644 --- a/src/lib/module.ts +++ b/src/lib/module.ts @@ -46,6 +46,7 @@ import {MdTableModule} from './table/index'; import {MdSortModule} from './sort/index'; import {MdPaginatorModule} from './paginator/index'; import {MdFormFieldModule} from './form-field/index'; +import {MdStepperModule} from './stepper/index'; const MATERIAL_MODULES = [ MdAutocompleteModule, @@ -75,6 +76,7 @@ const MATERIAL_MODULES = [ MdSlideToggleModule, MdSnackBarModule, MdSortModule, + MdStepperModule, MdTabsModule, MdToolbarModule, MdTooltipModule, @@ -85,7 +87,7 @@ const MATERIAL_MODULES = [ A11yModule, PlatformModule, MdCommonModule, - ObserversModule + ObserversModule, ]; /** @deprecated */ diff --git a/src/lib/public_api.ts b/src/lib/public_api.ts index 7c4bdffb425a..4156ab5191d0 100644 --- a/src/lib/public_api.ts +++ b/src/lib/public_api.ts @@ -46,3 +46,4 @@ export * from './tabs/index'; export * from './tabs/tab-nav-bar/index'; export * from './toolbar/index'; export * from './tooltip/index'; +export * from './stepper/index'; diff --git a/src/lib/stepper/_stepper-theme.scss b/src/lib/stepper/_stepper-theme.scss new file mode 100644 index 000000000000..fc4e339a49c0 --- /dev/null +++ b/src/lib/stepper/_stepper-theme.scss @@ -0,0 +1,53 @@ +@import '../core/theming/palette'; +@import '../core/theming/theming'; +@import '../core/typography/typography-utils'; + +@mixin mat-stepper-theme($theme) { + $foreground: map-get($theme, foreground); + $background: map-get($theme, background); + $primary: map-get($theme, primary); + + .mat-step-header { + &:focus, + &:hover { + background-color: mat-color($background, hover); + } + + .mat-step-label-active { + color: mat-color($foreground, text); + } + + .mat-step-label-inactive, + .mat-step-optional { + color: mat-color($foreground, disabled-text); + } + + .mat-step-icon { + background-color: mat-color($primary); + color: mat-color($primary, default-contrast); + } + + .mat-step-icon-not-touched { + background-color: mat-color($foreground, disabled-text); + color: mat-color($primary, default-contrast); + } + } + + .mat-stepper-horizontal, .mat-stepper-vertical { + background-color: mat-color($background, card); + } + + .mat-stepper-vertical-line::before { + border-left-color: mat-color($foreground, divider); + } + + .mat-stepper-horizontal-line { + border-top-color: mat-color($foreground, divider); + } +} + +@mixin mat-stepper-typography($config) { + .mat-stepper-vertical, .mat-stepper-horizontal { + font-family: mat-font-family($config); + } +} diff --git a/src/lib/stepper/index.ts b/src/lib/stepper/index.ts new file mode 100644 index 000000000000..a574fbc53997 --- /dev/null +++ b/src/lib/stepper/index.ts @@ -0,0 +1,40 @@ +/** + * @license + * Copyright Google Inc. 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 {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {PortalModule} from '@angular/cdk/portal'; +import {MdButtonModule} from '../button/index'; +import {MdStep, MdStepper, MdHorizontalStepper, MdVerticalStepper} from './stepper'; +import {CdkStepperModule} from '@angular/cdk/stepper'; +import {MdCommonModule} from '../core'; +import {MdStepLabel} from './step-label'; +import {MdStepperNext, MdStepperPrevious} from './stepper-button'; +import {MdIconModule} from '../icon/index'; +import {MdStepHeader} from './step-header'; + +@NgModule({ + imports: [ + MdCommonModule, + CommonModule, + PortalModule, + MdButtonModule, + CdkStepperModule, + MdIconModule + ], + exports: [MdCommonModule, MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper, + MdStepperNext, MdStepperPrevious, MdStepHeader], + declarations: [MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper, + MdStepperNext, MdStepperPrevious, MdStepHeader], +}) +export class MdStepperModule {} + +export * from './step-label'; +export * from './stepper'; +export * from './stepper-button'; +export * from './step-header'; diff --git a/src/lib/stepper/step-header.html b/src/lib/stepper/step-header.html new file mode 100644 index 000000000000..3f2310862f6f --- /dev/null +++ b/src/lib/stepper/step-header.html @@ -0,0 +1,17 @@ +
+ {{index + 1}} + create + done +
+
+ + + + +
{{label}}
+ +
Optional
+
+ diff --git a/src/lib/stepper/step-header.scss b/src/lib/stepper/step-header.scss new file mode 100644 index 000000000000..9313a57e4a48 --- /dev/null +++ b/src/lib/stepper/step-header.scss @@ -0,0 +1,42 @@ +$mat-stepper-label-header-height: 24px !default; +$mat-stepper-label-min-width: 50px !default; +$mat-stepper-side-gap: 24px !default; +$mat-vertical-stepper-content-margin: 36px !default; +$mat-stepper-line-gap: 8px !default; +$mat-step-optional-font-size: 12px; +$mat-step-header-icon-size: 16px !default; + +.mat-step-optional { + font-size: $mat-step-optional-font-size; +} + +.mat-step-icon, +.mat-step-icon-not-touched { + border-radius: 50%; + height: $mat-stepper-label-header-height; + width: $mat-stepper-label-header-height; + align-items: center; + justify-content: center; + display: flex; +} + +.mat-step-icon .mat-icon { + font-size: $mat-step-header-icon-size; + height: $mat-step-header-icon-size; + width: $mat-step-header-icon-size; +} + +.mat-step-label-active, +.mat-step-label-inactive { + display: inline-block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + min-width: $mat-stepper-label-min-width; + vertical-align: middle; +} + +.mat-step-text-label { + text-overflow: ellipsis; + overflow: hidden; +} diff --git a/src/lib/stepper/step-header.ts b/src/lib/stepper/step-header.ts new file mode 100644 index 000000000000..14901227f698 --- /dev/null +++ b/src/lib/stepper/step-header.ts @@ -0,0 +1,73 @@ +/** + * @license + * Copyright Google Inc. 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 {Component, Input, ViewEncapsulation} from '@angular/core'; +import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; +import {MdStepLabel} from './step-label'; + +@Component({ + selector: 'md-step-header, mat-step-header', + templateUrl: 'step-header.html', + styleUrls: ['step-header.css'], + host: { + 'class': 'mat-step-header', + 'role': 'tab', + }, + encapsulation: ViewEncapsulation.None +}) +export class MdStepHeader { + /** Icon for the given step. */ + @Input() + icon: string; + + /** Label of the given step. */ + @Input() + label: MdStepLabel | string; + + /** Index of the given step. */ + @Input() + get index() { return this._index; } + set index(value: any) { + this._index = coerceNumberProperty(value); + } + private _index: number; + + /** Whether the given step is selected. */ + @Input() + get selected() { return this._selected; } + set selected(value: any) { + this._selected = coerceBooleanProperty(value); + } + private _selected: boolean; + + /** Whether the given step label is active. */ + @Input() + get active() { return this._active; } + set active(value: any) { + this._active = coerceBooleanProperty(value); + } + private _active: boolean; + + /** Whether the given step is optional. */ + @Input() + get optional() { return this._optional; } + set optional(value: any) { + this._optional = coerceBooleanProperty(value); + } + private _optional: boolean; + + /** Returns string label of given step if it is a text label. */ + get _stringLabel(): string | null { + return this.label instanceof MdStepLabel ? null : this.label; + } + + /** Returns MdStepLabel if the label of given step is a template label. */ + get _templateLabel(): MdStepLabel | null { + return this.label instanceof MdStepLabel ? this.label : null; + } +} diff --git a/src/lib/stepper/step-label.ts b/src/lib/stepper/step-label.ts new file mode 100644 index 000000000000..62e1bc7f60e4 --- /dev/null +++ b/src/lib/stepper/step-label.ts @@ -0,0 +1,22 @@ +/** + * @license + * Copyright Google Inc. 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 {Directive, TemplateRef} from '@angular/core'; +import {CdkStepLabel} from '@angular/cdk/stepper'; + +/** Workaround for https://github.com/angular/angular/issues/17849 */ +export const _MdStepLabel = CdkStepLabel; + +@Directive({ + selector: '[mdStepLabel], [matStepLabel]', +}) +export class MdStepLabel extends _MdStepLabel { + constructor(template: TemplateRef) { + super(template); + } +} diff --git a/src/lib/stepper/step.html b/src/lib/stepper/step.html new file mode 100644 index 000000000000..cd48c06b9917 --- /dev/null +++ b/src/lib/stepper/step.html @@ -0,0 +1 @@ + diff --git a/src/lib/stepper/stepper-button.ts b/src/lib/stepper/stepper-button.ts new file mode 100644 index 000000000000..e1d5bb488bef --- /dev/null +++ b/src/lib/stepper/stepper-button.ts @@ -0,0 +1,31 @@ +/** + * @license + * Copyright Google Inc. 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 {Directive} from '@angular/core'; +import {CdkStepper, CdkStepperNext, CdkStepperPrevious} from '@angular/cdk/stepper'; +import {MdStepper} from './stepper'; + +/** Workaround for https://github.com/angular/angular/issues/17849 */ +export const _MdStepperNext = CdkStepperNext; +export const _MdStepperPrevious = CdkStepperPrevious; + +/** Button that moves to the next step in a stepper workflow. */ +@Directive({ + selector: 'button[mdStepperNext], button[matStepperNext]', + host: {'(click)': '_stepper.next()'}, + providers: [{provide: CdkStepper, useExisting: MdStepper}] +}) +export class MdStepperNext extends _MdStepperNext { } + +/** Button that moves to the previous step in a stepper workflow. */ +@Directive({ + selector: 'button[mdStepperPrevious], button[matStepperPrevious]', + host: {'(click)': '_stepper.previous()'}, + providers: [{provide: CdkStepper, useExisting: MdStepper}] +}) +export class MdStepperPrevious extends _MdStepperPrevious { } diff --git a/src/lib/stepper/stepper-horizontal.html b/src/lib/stepper/stepper-horizontal.html new file mode 100644 index 000000000000..5e2d2ea80fa7 --- /dev/null +++ b/src/lib/stepper/stepper-horizontal.html @@ -0,0 +1,30 @@ +
+ + + +
+
+
+ +
+
+ +
+
diff --git a/src/lib/stepper/stepper-vertical.html b/src/lib/stepper/stepper-vertical.html new file mode 100644 index 000000000000..b73bed61929b --- /dev/null +++ b/src/lib/stepper/stepper-vertical.html @@ -0,0 +1,28 @@ +
+ + + +
+
+
+ +
+
+
+
diff --git a/src/lib/stepper/stepper.md b/src/lib/stepper/stepper.md new file mode 100644 index 000000000000..54e273068cf5 --- /dev/null +++ b/src/lib/stepper/stepper.md @@ -0,0 +1,132 @@ +Angular Material's stepper provides a wizard-like workflow by dividing content into logical steps. + +Material stepper builds on the foundation of the CDK stepper that is responsible for the logic +that drives a stepped workflow. Material stepper extends the CDK stepper and has Material Design +styling. + +### Stepper variants +There are two stepper components: `md-horizontal-stepper` and `md-vertical-stepper`. They +can be used the same way. The only difference is the orientation of stepper. +`md-horizontal-stepper` selector can be used to create a horizontal stepper, and +`md-vertical-stepper` can be used to create a vertical stepper. `md-step` components need to be +placed inside either one of the two stepper components. + +### Labels +If a step's label is only text, then the `label` attribute can be used. +```html + + + Content 1 + + + Content 2 + + +``` + +For more complex labels, add a template with the `mdStepLabel` directive inside the +`md-step`. +```html + + + ... + ... + + +``` + +### Stepper buttons +There are two button directives to support navigation between different steps: +`mdStepperPrevious` and `mdStepperNext`. +```html + + + ... +
+ + +
+
+
+``` + +### Linear stepper +The `linear` attribute can be set on `md-horizontal-stepper` and `md-vertical-stepper` to create +a linear stepper that requires the user to complete previous steps before proceeding +to following steps. For each `md-step`, the `stepControl` attribute can be set to the top level +`AbstractControl` that is used to check the validity of the step. + +There are two possible approaches. One is using a single form for stepper, and the other is +using a different form for each step. + +#### Using a single form +When using a single form for the stepper, `mdStepperPrevious` and `mdStepperNext` have to be +set to `type="button"` in order to prevent submission of the form before all steps +are completed. + +```html +
+ + + ... +
+ +
+
+ + ... +
+ + +
+
+ ... +
+
+``` + +#### Using a different form for each step +```html + + +
+ ... +
+
+ +
+ ... +
+
+
+``` +### Types of steps + +#### Optional step +If completion of a step in linear stepper is not required, then the `optional` attribute can be set +on `md-step`. + +#### Editable step +By default, steps are editable, which means users can return to previously completed steps and +edit their responses. `editable="true"` can be set on `md-step` to change the default. + +#### Completed step +By default, the `completed` attribute of a step returns `true` if the step is valid (in case of +linear stepper) and the user has interacted with the step. The user, however, can also override +this default `completed` behavior by setting the `completed` attribute as needed. + +### Keyboard interaction +- LEFT_ARROW: Focuses the previous step header +- RIGHT_ARROW: Focuses the next step header +- ENTER, SPACE: Selects the step that the focus is currently on +- TAB: Focuses the next tabbable element +- TAB+SHIFT: Focuses the previous tabbable element + +### Accessibility +The stepper is treated as a tabbed view for accessibility purposes, so it is given +`role="tablist"` by default. The header of step that can be clicked to select the step +is given `role="tab"`, and the content that can be expanded upon selection is given +`role="tabpanel"`. `aria-selected` attribute of step header and `aria-expanded` attribute of +step content is automatically set based on step selection change. + +The stepper and each step should be given a meaningful label via `aria-label` or `aria-labelledby`. \ No newline at end of file diff --git a/src/lib/stepper/stepper.scss b/src/lib/stepper/stepper.scss new file mode 100644 index 000000000000..b05c8ef8672d --- /dev/null +++ b/src/lib/stepper/stepper.scss @@ -0,0 +1,122 @@ +@import '../core/style/variables'; + +$mat-horizontal-stepper-header-height: 72px !default; +$mat-stepper-label-header-height: 24px !default; +$mat-stepper-side-gap: 24px !default; +$mat-vertical-stepper-content-margin: 36px !default; +$mat-stepper-line-width: 1px !default; +$mat-stepper-line-gap: 8px !default; + +.mat-stepper-vertical, +.mat-stepper-horizontal { + display: block; +} + +.mat-step-header { + overflow: hidden; + outline: none; +} + +.mat-horizontal-stepper-header-container { + white-space: nowrap; + display: flex; + align-items: center; +} + +.mat-stepper-horizontal-line { + border-top-width: $mat-stepper-line-width; + border-top-style: solid; + flex: auto; + height: 0; + margin: 0 $mat-stepper-line-gap - $mat-stepper-side-gap; + min-width: $mat-stepper-line-gap + $mat-stepper-side-gap; +} + +.mat-horizontal-stepper-header { + display: flex; + height: $mat-horizontal-stepper-header-height; + overflow: hidden; + align-items: center; + padding: 0 $mat-stepper-side-gap; + + .mat-step-icon, + .mat-step-icon-not-touched { + margin-right: $mat-stepper-line-gap; + flex: none; + + [dir='rtl'] & { + margin-right: 0; + margin-left: $mat-stepper-line-gap; + } + } +} + +.mat-vertical-stepper-header { + display: flex; + align-items: center; + padding: $mat-stepper-side-gap; + max-height: $mat-stepper-label-header-height; + + .mat-step-icon, + .mat-step-icon-not-touched { + margin-right: $mat-vertical-stepper-content-margin - $mat-stepper-side-gap; + + [dir='rtl'] & { + margin-right: 0; + margin-left: $mat-vertical-stepper-content-margin - $mat-stepper-side-gap; + } + } +} + +.mat-horizontal-stepper-content { + overflow: hidden; + + &[aria-expanded='false'] { + height: 0; + } +} + +.mat-horizontal-content-container { + overflow: hidden; + padding: 0 $mat-stepper-side-gap $mat-stepper-side-gap $mat-stepper-side-gap; +} + +.mat-vertical-content-container { + margin-left: $mat-vertical-stepper-content-margin; + border: 0; + position: relative; + + [dir='rtl'] & { + margin-left: 0; + margin-right: $mat-vertical-stepper-content-margin; + } +} + +.mat-stepper-vertical-line::before { + content: ''; + position: absolute; + top: $mat-stepper-line-gap - $mat-stepper-side-gap; + bottom: $mat-stepper-line-gap - $mat-stepper-side-gap; + left: 0; + border-left-width: $mat-stepper-line-width; + border-left-style: solid; + + [dir='rtl'] & { + left: auto; + right: 0; + } +} + +.mat-vertical-stepper-content { + overflow: hidden; +} + +.mat-vertical-content { + padding: 0 $mat-stepper-side-gap $mat-stepper-side-gap $mat-stepper-side-gap; +} + +.mat-step:last-child { + .mat-vertical-content-container { + border: none; + } +} diff --git a/src/lib/stepper/stepper.spec.ts b/src/lib/stepper/stepper.spec.ts new file mode 100644 index 000000000000..b5965f9d4751 --- /dev/null +++ b/src/lib/stepper/stepper.spec.ts @@ -0,0 +1,765 @@ +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {Component, DebugElement} from '@angular/core'; +import {MdStepperModule} from './index'; +import {By} from '@angular/platform-browser'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms'; +import {MdStepperNext, MdStepperPrevious} from './stepper-button'; +import {dispatchKeyboardEvent} from '@angular/cdk/testing'; +import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes'; +import {MdStepper, MdHorizontalStepper, MdVerticalStepper} from './stepper'; + +const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; + +describe('MdHorizontalStepper', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [MdStepperModule, NoopAnimationsModule, ReactiveFormsModule], + declarations: [ + SimpleMdHorizontalStepperApp, + LinearMdHorizontalStepperApp + ] + }); + + TestBed.compileComponents(); + })); + + describe('basic horizontal stepper', () => { + let fixture: ComponentFixture; + let stepperComponent: MdHorizontalStepper; + + beforeEach(() => { + fixture = TestBed.createComponent(SimpleMdHorizontalStepperApp); + fixture.detectChanges(); + + stepperComponent = fixture.debugElement + .query(By.css('md-horizontal-stepper')).componentInstance; + }); + + it('should default to the first step', () => { + expect(stepperComponent.selectedIndex).toBe(0); + }); + + it('should change selected index on header click', () => { + let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-horizontal-stepper-header')); + assertSelectionChangeOnHeaderClick(stepperComponent, fixture, stepHeaders); + }); + + it('should set the "tablist" role on stepper', () => { + let stepperEl = fixture.debugElement.query(By.css('md-horizontal-stepper')).nativeElement; + expect(stepperEl.getAttribute('role')).toBe('tablist'); + }); + + it('should set aria-expanded of content correctly', () => { + let stepContents = fixture.debugElement.queryAll(By.css(`.mat-horizontal-stepper-content`)); + assertCorrectAriaExpandedAttribute(stepperComponent, fixture, stepContents); + }); + + it('should display the correct label', () => { + assertCorrectStepLabel(stepperComponent, fixture); + }); + + it('should go to next available step when the next button is clicked', () => { + assertNextStepperButtonClick(stepperComponent, fixture); + }); + + it('should go to previous available step when the previous button is clicked', () => { + assertPreviousStepperButtonClick(stepperComponent, fixture); + }); + + it('should set the correct step position for animation', () => { + assertCorrectStepPosition(stepperComponent, fixture); + }); + + it('should support keyboard events to move and select focus', () => { + let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-horizontal-stepper-header')); + assertCorrectKeyboardInteraction(stepperComponent, fixture, stepHeaders); + }); + + it('should not set focus on header of selected step if header is not clicked', () => { + assertStepHeaderFocusNotCalled(stepperComponent, fixture); + }); + + it('should only be able to return to a previous step if it is editable', () => { + assertEditableStepChange(stepperComponent, fixture); + }); + + it('should set create icon if step is editable and completed', () => { + assertCorrectStepIcon(stepperComponent, fixture, true, 'edit'); + }); + + it('should set done icon if step is not editable and is completed', () => { + assertCorrectStepIcon(stepperComponent, fixture, false, 'done'); + }); + }); + + describe('linear horizontal stepper', () => { + let fixture: ComponentFixture; + let testComponent: LinearMdHorizontalStepperApp; + let stepperComponent: MdHorizontalStepper; + + beforeEach(() => { + fixture = TestBed.createComponent(LinearMdHorizontalStepperApp); + fixture.detectChanges(); + + testComponent = fixture.componentInstance; + stepperComponent = fixture.debugElement + .query(By.css('md-horizontal-stepper')).componentInstance; + }); + + it('should have true linear attribute', () => { + expect(stepperComponent.linear).toBe(true); + }); + + it('should not move to next step if current step is not valid', () => { + expect(testComponent.oneGroup.get('oneCtrl')!.value).toBe(''); + expect(testComponent.oneGroup.get('oneCtrl')!.valid).toBe(false); + expect(testComponent.oneGroup.valid).toBe(false); + expect(stepperComponent.selectedIndex).toBe(0); + + let stepHeaderEl = fixture.debugElement + .queryAll(By.css('.mat-horizontal-stepper-header'))[1].nativeElement; + assertLinearStepperValidity(stepHeaderEl, stepperComponent, testComponent, fixture); + }); + + it('should not focus step header upon click if it is not able to be selected', () => { + assertStepHeaderBlurred(fixture); + }); + + it('should be able to move to next step even when invalid if current step is optional', () => { + assertOptionalStepValidity(stepperComponent, testComponent, fixture); + }); + }); +}); + +describe('MdVerticalStepper', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [MdStepperModule, NoopAnimationsModule, ReactiveFormsModule], + declarations: [ + SimpleMdVerticalStepperApp, + LinearMdVerticalStepperApp + ] + }); + + TestBed.compileComponents(); + })); + + describe('basic vertical stepper', () => { + let fixture: ComponentFixture; + let stepperComponent: MdVerticalStepper; + + beforeEach(() => { + fixture = TestBed.createComponent(SimpleMdVerticalStepperApp); + fixture.detectChanges(); + + stepperComponent = fixture.debugElement + .query(By.css('md-vertical-stepper')).componentInstance; + }); + + it('should default to the first step', () => { + expect(stepperComponent.selectedIndex).toBe(0); + }); + + it('should change selected index on header click', () => { + let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-vertical-stepper-header')); + assertSelectionChangeOnHeaderClick(stepperComponent, fixture, stepHeaders); + + }); + + it('should set the "tablist" role on stepper', () => { + let stepperEl = fixture.debugElement.query(By.css('md-vertical-stepper')).nativeElement; + expect(stepperEl.getAttribute('role')).toBe('tablist'); + }); + + it('should set aria-expanded of content correctly', () => { + let stepContents = fixture.debugElement.queryAll(By.css(`.mat-vertical-stepper-content`)); + assertCorrectAriaExpandedAttribute(stepperComponent, fixture, stepContents); + }); + + it('should display the correct label', () => { + assertCorrectStepLabel(stepperComponent, fixture); + }); + + it('should go to next available step when the next button is clicked', () => { + assertNextStepperButtonClick(stepperComponent, fixture); + }); + + it('should go to previous available step when the previous button is clicked', () => { + assertPreviousStepperButtonClick(stepperComponent, fixture); + }); + + it('should set the correct step position for animation', () => { + assertCorrectStepPosition(stepperComponent, fixture); + }); + + it('should support keyboard events to move and select focus', () => { + let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-vertical-stepper-header')); + assertCorrectKeyboardInteraction(stepperComponent, fixture, stepHeaders); + }); + + it('should not set focus on header of selected step if header is not clicked', () => { + assertStepHeaderFocusNotCalled(stepperComponent, fixture); + }); + + it('should only be able to return to a previous step if it is editable', () => { + assertEditableStepChange(stepperComponent, fixture); + }); + + it('should set create icon if step is editable and completed', () => { + assertCorrectStepIcon(stepperComponent, fixture, true, 'edit'); + }); + + it('should set done icon if step is not editable and is completed', () => { + assertCorrectStepIcon(stepperComponent, fixture, false, 'done'); + }); + }); + + describe('linear vertical stepper', () => { + let fixture: ComponentFixture; + let testComponent: LinearMdVerticalStepperApp; + let stepperComponent: MdVerticalStepper; + + beforeEach(() => { + fixture = TestBed.createComponent(LinearMdVerticalStepperApp); + fixture.detectChanges(); + + testComponent = fixture.componentInstance; + stepperComponent = fixture.debugElement + .query(By.css('md-vertical-stepper')).componentInstance; + }); + + it('should have true linear attribute', () => { + expect(stepperComponent.linear).toBe(true); + }); + + it('should not move to next step if current step is not valid', () => { + expect(testComponent.oneGroup.get('oneCtrl')!.value).toBe(''); + expect(testComponent.oneGroup.get('oneCtrl')!.valid).toBe(false); + expect(testComponent.oneGroup.valid).toBe(false); + expect(stepperComponent.selectedIndex).toBe(0); + + let stepHeaderEl = fixture.debugElement + .queryAll(By.css('.mat-vertical-stepper-header'))[1].nativeElement; + + assertLinearStepperValidity(stepHeaderEl, stepperComponent, testComponent, fixture); + }); + + it('should not focus step header upon click if it is not able to be selected', () => { + assertStepHeaderBlurred(fixture); + }); + + it('should be able to move to next step even when invalid if current step is optional', () => { + assertOptionalStepValidity(stepperComponent, testComponent, fixture); + }); + }); +}); + +/** Asserts that `selectedIndex` updates correctly when header of another step is clicked. */ +function assertSelectionChangeOnHeaderClick(stepperComponent: MdStepper, + fixture: ComponentFixture, + stepHeaders: DebugElement[]) { + expect(stepperComponent.selectedIndex).toBe(0); + + // select the second step + let stepHeaderEl = stepHeaders[1].nativeElement; + stepHeaderEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(1); + + // select the third step + stepHeaderEl = stepHeaders[2].nativeElement; + stepHeaderEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(2); +} + +/** Asserts that 'aria-expanded' attribute is correct for expanded content of step. */ +function assertCorrectAriaExpandedAttribute(stepperComponent: MdStepper, + fixture: ComponentFixture, + stepContents: DebugElement[]) { + let firstStepContentEl = stepContents[0].nativeElement; + expect(firstStepContentEl.getAttribute('aria-expanded')).toBe('true'); + + stepperComponent.selectedIndex = 1; + fixture.detectChanges(); + + expect(firstStepContentEl.getAttribute('aria-expanded')).toBe('false'); + let secondStepContentEl = stepContents[1].nativeElement; + expect(secondStepContentEl.getAttribute('aria-expanded')).toBe('true'); +} + +/** Asserts that step has correct label. */ +function assertCorrectStepLabel(stepperComponent: MdStepper, fixture: ComponentFixture) { + let selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]'); + expect(selectedLabel.textContent).toMatch('Step 1'); + + stepperComponent.selectedIndex = 2; + fixture.detectChanges(); + + selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]'); + expect(selectedLabel.textContent).toMatch('Step 3'); + + fixture.componentInstance.inputLabel = 'New Label'; + fixture.detectChanges(); + + selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]'); + expect(selectedLabel.textContent).toMatch('New Label'); +} + +/** Asserts that clicking on MdStepperNext button updates `selectedIndex` correctly. */ +function assertNextStepperButtonClick(stepperComponent: MdStepper, fixture: ComponentFixture) { + expect(stepperComponent.selectedIndex).toBe(0); + + let nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[0].nativeElement; + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(1); + + nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[1].nativeElement; + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(2); + + nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[2].nativeElement; + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(2); +} + +/** Asserts that clicking on MdStepperPrevious button updates `selectedIndex` correctly. */ +function assertPreviousStepperButtonClick(stepperComponent: MdStepper, + fixture: ComponentFixture) { + expect(stepperComponent.selectedIndex).toBe(0); + + stepperComponent.selectedIndex = 2; + let previousButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperPrevious))[2].nativeElement; + previousButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(1); + + previousButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperPrevious))[1].nativeElement; + previousButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(0); + + previousButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperPrevious))[0].nativeElement; + previousButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(0); +} + +/** Asserts that step position is correct for animation. */ +function assertCorrectStepPosition(stepperComponent: MdStepper, fixture: ComponentFixture) { + expect(stepperComponent._getAnimationDirection(0)).toBe('current'); + expect(stepperComponent._getAnimationDirection(1)).toBe('next'); + expect(stepperComponent._getAnimationDirection(2)).toBe('next'); + + stepperComponent.selectedIndex = 1; + fixture.detectChanges(); + + expect(stepperComponent._getAnimationDirection(0)).toBe('previous'); + expect(stepperComponent._getAnimationDirection(1)).toBe('current'); + expect(stepperComponent._getAnimationDirection(2)).toBe('next'); + + stepperComponent.selectedIndex = 2; + fixture.detectChanges(); + + expect(stepperComponent._getAnimationDirection(0)).toBe('previous'); + expect(stepperComponent._getAnimationDirection(1)).toBe('previous'); + expect(stepperComponent._getAnimationDirection(2)).toBe('current'); +} + +/** Asserts that keyboard interaction works correctly. */ +function assertCorrectKeyboardInteraction(stepperComponent: MdStepper, + fixture: ComponentFixture, + stepHeaders: DebugElement[]) { + expect(stepperComponent._focusIndex).toBe(0); + expect(stepperComponent.selectedIndex).toBe(0); + + let stepHeaderEl = stepHeaders[0].nativeElement; + dispatchKeyboardEvent(stepHeaderEl, 'keydown', RIGHT_ARROW); + fixture.detectChanges(); + + expect(stepperComponent._focusIndex) + .toBe(1, 'Expected index of focused step to be increased by 1 after RIGHT_ARROW event.'); + expect(stepperComponent.selectedIndex) + .toBe(0, 'Expected index of selected step to remain unchanged after RIGHT_ARROW event.'); + + stepHeaderEl = stepHeaders[1].nativeElement; + dispatchKeyboardEvent(stepHeaderEl, 'keydown', ENTER); + fixture.detectChanges(); + + expect(stepperComponent._focusIndex) + .toBe(1, 'Expected index of focused step to remain unchanged after ENTER event.'); + expect(stepperComponent.selectedIndex) + .toBe(1, + 'Expected index of selected step to change to index of focused step after EVENT event.'); + + stepHeaderEl = stepHeaders[1].nativeElement; + dispatchKeyboardEvent(stepHeaderEl, 'keydown', LEFT_ARROW); + fixture.detectChanges(); + + expect(stepperComponent._focusIndex) + .toBe(0, 'Expected index of focused step to decrease by 1 after LEFT_ARROW event.'); + expect(stepperComponent.selectedIndex) + .toBe(1, 'Expected index of selected step to remain unchanged after LEFT_ARROW event.'); + + // When the focus is on the last step and right arrow key is pressed, the focus should cycle + // through to the first step. + stepperComponent._focusIndex = 2; + stepHeaderEl = stepHeaders[2].nativeElement; + dispatchKeyboardEvent(stepHeaderEl, 'keydown', RIGHT_ARROW); + fixture.detectChanges(); + + expect(stepperComponent._focusIndex) + .toBe(0, + 'Expected index of focused step to cycle through to index 0 after RIGHT_ARROW event.'); + expect(stepperComponent.selectedIndex) + .toBe(1, 'Expected index of selected step to remain unchanged after RIGHT_ARROW event.'); + + stepHeaderEl = stepHeaders[0].nativeElement; + dispatchKeyboardEvent(stepHeaderEl, 'keydown', SPACE); + fixture.detectChanges(); + + expect(stepperComponent._focusIndex) + .toBe(0, 'Expected index of focused to remain unchanged after SPACE event.'); + expect(stepperComponent.selectedIndex) + .toBe(0, + 'Expected index of selected step to change to index of focused step after SPACE event.'); +} + +/** Asserts that step selection change using stepper buttons does not focus step header. */ +function assertStepHeaderFocusNotCalled(stepperComponent: MdStepper, + fixture: ComponentFixture) { + let stepHeaderEl = fixture.debugElement + .queryAll(By.css('md-step-header'))[1].nativeElement; + let nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[0].nativeElement; + spyOn(stepHeaderEl, 'focus'); + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(1); + expect(stepHeaderEl.focus).not.toHaveBeenCalled(); +} + +/** + * Asserts that linear stepper does not allow step selection change if current step is not valid. + */ +function assertLinearStepperValidity(stepHeaderEl: HTMLElement, + stepperComponent: MdStepper, + testComponent: + LinearMdHorizontalStepperApp | LinearMdVerticalStepperApp, + fixture: ComponentFixture) { + stepHeaderEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(0); + + let nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[0].nativeElement; + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(0); + + testComponent.oneGroup.get('oneCtrl')!.setValue('answer'); + stepHeaderEl.click(); + fixture.detectChanges(); + + expect(testComponent.oneGroup.valid).toBe(true); + expect(stepperComponent.selectedIndex).toBe(1); +} + +/** Asserts that step header focus is blurred if the step cannot be selected upon header click. */ +function assertStepHeaderBlurred(fixture: ComponentFixture) { + let stepHeaderEl = fixture.debugElement + .queryAll(By.css('md-step-header'))[1].nativeElement; + spyOn(stepHeaderEl, 'blur'); + stepHeaderEl.click(); + fixture.detectChanges(); + + expect(stepHeaderEl.blur).toHaveBeenCalled(); +} + +/** Asserts that it is only possible to go back to a previous step if the step is editable. */ +function assertEditableStepChange(stepperComponent: MdStepper, + fixture: ComponentFixture) { + stepperComponent.selectedIndex = 1; + stepperComponent._steps.toArray()[0].editable = false; + let previousButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperPrevious))[1].nativeElement; + previousButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(1); + + stepperComponent._steps.toArray()[0].editable = true; + previousButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(0); +} + +/** + * Asserts that it is possible to skip an optional step in linear stepper if there is no input + * or the input is valid. + */ +function assertOptionalStepValidity(stepperComponent: MdStepper, + testComponent: LinearMdHorizontalStepperApp | LinearMdVerticalStepperApp, + fixture: ComponentFixture) { + testComponent.oneGroup.get('oneCtrl')!.setValue('input'); + testComponent.twoGroup.get('twoCtrl')!.setValue('input'); + stepperComponent.selectedIndex = 2; + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex).toBe(2); + expect(testComponent.threeGroup.get('threeCtrl')!.valid).toBe(true); + + let nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[2].nativeElement; + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent.selectedIndex) + .toBe(3, 'Expected selectedIndex to change when optional step input is empty.'); + + stepperComponent.selectedIndex = 2; + testComponent.threeGroup.get('threeCtrl')!.setValue('input'); + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(testComponent.threeGroup.get('threeCtrl')!.valid).toBe(false); + expect(stepperComponent.selectedIndex) + .toBe(2, 'Expected selectedIndex to remain unchanged when optional step input is invalid.'); + + testComponent.threeGroup.get('threeCtrl')!.setValue('123@gmail.com'); + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(testComponent.threeGroup.get('threeCtrl')!.valid).toBe(true); + expect(stepperComponent.selectedIndex) + .toBe(3, 'Expected selectedIndex to change when optional step input is valid.'); +} + +/** Asserts that step header set the correct icon depending on the state of step. */ +function assertCorrectStepIcon(stepperComponent: MdStepper, + fixture: ComponentFixture, + isEditable: boolean, + icon: String) { + let nextButtonNativeEl = fixture.debugElement + .queryAll(By.directive(MdStepperNext))[0].nativeElement; + expect(stepperComponent._getIndicatorType(0)).toBe('number'); + stepperComponent._steps.toArray()[0].editable = isEditable; + nextButtonNativeEl.click(); + fixture.detectChanges(); + + expect(stepperComponent._getIndicatorType(0)).toBe(icon); +} + +@Component({ + template: ` + + + Step 1 + Content 1 +
+ + +
+
+ + Step 2 + Content 2 +
+ + +
+
+ + Content 3 +
+ + +
+
+
+ ` +}) +class SimpleMdHorizontalStepperApp { + inputLabel = 'Step 3'; +} + +@Component({ + template: ` + + +
+ Step one + + + +
+ + +
+
+
+ +
+ Step two + + + +
+ + +
+
+
+ +
+ Step two + + + +
+ + +
+
+
+ + Done + +
+ ` +}) +class LinearMdHorizontalStepperApp { + oneGroup: FormGroup; + twoGroup: FormGroup; + threeGroup: FormGroup; + + ngOnInit() { + this.oneGroup = new FormGroup({ + oneCtrl: new FormControl('', Validators.required) + }); + this.twoGroup = new FormGroup({ + twoCtrl: new FormControl('', Validators.required) + }); + this.threeGroup = new FormGroup({ + threeCtrl: new FormControl('', Validators.pattern(EMAIL_REGEX)) + }); + } +} + +@Component({ + template: ` + + + Step 1 + Content 1 +
+ + +
+
+ + Step 2 + Content 2 +
+ + +
+
+ + Content 3 +
+ + +
+
+
+ ` +}) +class SimpleMdVerticalStepperApp { + inputLabel = 'Step 3'; +} + +@Component({ + template: ` + + +
+ Step one + + + +
+ + +
+
+
+ +
+ Step two + + + +
+ + +
+
+
+ +
+ Step two + + + +
+ + +
+
+
+ + Done + +
+ ` +}) +class LinearMdVerticalStepperApp { + oneGroup: FormGroup; + twoGroup: FormGroup; + threeGroup: FormGroup; + + ngOnInit() { + this.oneGroup = new FormGroup({ + oneCtrl: new FormControl('', Validators.required) + }); + this.twoGroup = new FormGroup({ + twoCtrl: new FormControl('', Validators.required) + }); + this.threeGroup = new FormGroup({ + threeCtrl: new FormControl('', Validators.pattern(EMAIL_REGEX)) + }); + } +} diff --git a/src/lib/stepper/stepper.ts b/src/lib/stepper/stepper.ts new file mode 100644 index 000000000000..4ec7fd207d29 --- /dev/null +++ b/src/lib/stepper/stepper.ts @@ -0,0 +1,132 @@ +/** + * @license + * Copyright Google Inc. 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 {CdkStep, CdkStepper} from '@angular/cdk/stepper'; +import { + Component, + ContentChild, + ContentChildren, Directive, + // This import is only used to define a generic type. The current TypeScript version incorrectly + // considers such imports as unused (https://github.com/Microsoft/TypeScript/issues/14953) + // tslint:disable-next-line:no-unused-variable + ElementRef, + forwardRef, + Inject, + Optional, + QueryList, + SkipSelf, + ViewChildren, + ViewEncapsulation +} from '@angular/core'; +import {MdStepLabel} from './step-label'; +import { + defaultErrorStateMatcher, + ErrorOptions, + MD_ERROR_GLOBAL_OPTIONS, + ErrorStateMatcher +} from '../core/error/error-options'; +import {FormControl, FormGroupDirective, NgForm} from '@angular/forms'; +import {MdStepHeader} from './step-header'; +import {state, style, transition, trigger, animate} from '@angular/animations'; + +/** Workaround for https://github.com/angular/angular/issues/17849 */ +export const _MdStep = CdkStep; +export const _MdStepper = CdkStepper; + +@Component({ + moduleId: module.id, + selector: 'md-step, mat-step', + templateUrl: 'step.html', + providers: [{provide: MD_ERROR_GLOBAL_OPTIONS, useExisting: MdStep}], + encapsulation: ViewEncapsulation.None +}) +export class MdStep extends _MdStep implements ErrorOptions { + /** Content for step label given by or . */ + @ContentChild(MdStepLabel) stepLabel: MdStepLabel; + + /** Original ErrorStateMatcher that checks the validity of form control. */ + private _originalErrorStateMatcher: ErrorStateMatcher; + + constructor(@Inject(forwardRef(() => MdStepper)) mdStepper: MdStepper, + @Optional() @SkipSelf() @Inject(MD_ERROR_GLOBAL_OPTIONS) errorOptions: ErrorOptions) { + super(mdStepper); + this._originalErrorStateMatcher = + errorOptions ? errorOptions.errorStateMatcher || defaultErrorStateMatcher + : defaultErrorStateMatcher; + } + + /** Custom error state matcher that additionally checks for validity of interacted form. */ + errorStateMatcher = (control: FormControl, form: FormGroupDirective | NgForm) => { + let originalErrorState = this._originalErrorStateMatcher(control, form); + + // Custom error state checks for the validity of form that is not submitted or touched + // since user can trigger a form change by calling for another step without directly + // interacting with the current form. + let customErrorState = control.invalid && this.interacted; + + return originalErrorState || customErrorState; + } +} + +@Directive({ + selector: '[mdStepper]' +}) +export class MdStepper extends _MdStepper { + /** The list of step headers of the steps in the stepper. */ + @ViewChildren(MdStepHeader, {read: ElementRef}) _stepHeader: QueryList; + + /** Steps that the stepper holds. */ + @ContentChildren(MdStep) _steps: QueryList; +} + +@Component({ + moduleId: module.id, + selector: 'md-horizontal-stepper, mat-horizontal-stepper', + templateUrl: 'stepper-horizontal.html', + styleUrls: ['stepper.css'], + inputs: ['selectedIndex'], + host: { + 'class': 'mat-stepper-horizontal', + 'role': 'tablist', + }, + animations: [ + trigger('stepTransition', [ + state('previous', style({transform: 'translate3d(-100%, 0, 0)', visibility: 'hidden'})), + state('current', style({transform: 'translate3d(0%, 0, 0)', visibility: 'visible'})), + state('next', style({transform: 'translate3d(100%, 0, 0)', visibility: 'hidden'})), + transition('* => *', + animate('500ms cubic-bezier(0.35, 0, 0.25, 1)')) + ]) + ], + providers: [{provide: MdStepper, useExisting: MdHorizontalStepper}], + encapsulation: ViewEncapsulation.None +}) +export class MdHorizontalStepper extends MdStepper { } + +@Component({ + moduleId: module.id, + selector: 'md-vertical-stepper, mat-vertical-stepper', + templateUrl: 'stepper-vertical.html', + styleUrls: ['stepper.css'], + inputs: ['selectedIndex'], + host: { + 'class': 'mat-stepper-vertical', + 'role': 'tablist', + }, + animations: [ + trigger('stepTransition', [ + state('previous', style({height: '0px', visibility: 'hidden'})), + state('next', style({height: '0px', visibility: 'hidden'})), + state('current', style({height: '*', visibility: 'visible'})), + transition('* <=> current', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')) + ]) + ], + providers: [{provide: MdStepper, useExisting: MdVerticalStepper}], + encapsulation: ViewEncapsulation.None +}) +export class MdVerticalStepper extends MdStepper { } diff --git a/test/karma-test-shim.js b/test/karma-test-shim.js index 7790a25cd578..3dfeae04facc 100644 --- a/test/karma-test-shim.js +++ b/test/karma-test-shim.js @@ -60,6 +60,7 @@ System.config({ '@angular/cdk/portal': 'dist/packages/cdk/portal/index.js', '@angular/cdk/rxjs': 'dist/packages/cdk/rxjs/index.js', '@angular/cdk/scrolling': 'dist/packages/cdk/scrolling/index.js', + '@angular/cdk/stepper': 'dist/packages/cdk/stepper/index.js', '@angular/cdk/table': 'dist/packages/cdk/table/index.js', '@angular/cdk/testing': 'dist/packages/cdk/testing/index.js', }, From f375f92581b6318219cc225aeafc97124a840b26 Mon Sep 17 00:00:00 2001 From: Ji Won Shin Date: Thu, 31 Aug 2017 18:18:13 -0700 Subject: [PATCH 003/575] feat(stepper): add moduleId to components (#6780) --- src/cdk/stepper/stepper.ts | 1 + src/cdk/stepper/tsconfig-build.json | 3 ++- src/cdk/tsconfig-build.json | 3 ++- src/cdk/tsconfig-tests.json | 3 ++- src/cdk/typings.d.ts | 1 + src/lib/stepper/step-header.ts | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/cdk/typings.d.ts diff --git a/src/cdk/stepper/stepper.ts b/src/cdk/stepper/stepper.ts index 24a02dc6545a..089555589f21 100644 --- a/src/cdk/stepper/stepper.ts +++ b/src/cdk/stepper/stepper.ts @@ -57,6 +57,7 @@ export class StepperSelectionEvent { } @Component({ + moduleId: module.id, selector: 'cdk-step', templateUrl: 'step.html', encapsulation: ViewEncapsulation.None diff --git a/src/cdk/stepper/tsconfig-build.json b/src/cdk/stepper/tsconfig-build.json index 4231d46ba702..2f9f6e461859 100644 --- a/src/cdk/stepper/tsconfig-build.json +++ b/src/cdk/stepper/tsconfig-build.json @@ -1,7 +1,8 @@ { "extends": "../tsconfig-build", "files": [ - "public_api.ts" + "public_api.ts", + "../typings.d.ts" ], "angularCompilerOptions": { "annotateForClosureCompiler": true, diff --git a/src/cdk/tsconfig-build.json b/src/cdk/tsconfig-build.json index c74fa84aaa3e..2ce5c0ace94e 100644 --- a/src/cdk/tsconfig-build.json +++ b/src/cdk/tsconfig-build.json @@ -25,7 +25,8 @@ } }, "files": [ - "public_api.ts" + "public_api.ts", + "typings.d.ts" ], "angularCompilerOptions": { "annotateForClosureCompiler": true, diff --git a/src/cdk/tsconfig-tests.json b/src/cdk/tsconfig-tests.json index b834ba802df0..2b24877a7677 100644 --- a/src/cdk/tsconfig-tests.json +++ b/src/cdk/tsconfig-tests.json @@ -14,7 +14,8 @@ } }, "files": [ - "./testing/index.ts" + "./testing/index.ts", + "typings.d.ts" ], "include": [ // Include the index.ts for each secondary entry-point diff --git a/src/cdk/typings.d.ts b/src/cdk/typings.d.ts new file mode 100644 index 000000000000..ce4ae9b66cf0 --- /dev/null +++ b/src/cdk/typings.d.ts @@ -0,0 +1 @@ +declare var module: {id: string}; diff --git a/src/lib/stepper/step-header.ts b/src/lib/stepper/step-header.ts index 14901227f698..b6624e2424c5 100644 --- a/src/lib/stepper/step-header.ts +++ b/src/lib/stepper/step-header.ts @@ -11,6 +11,7 @@ import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion import {MdStepLabel} from './step-label'; @Component({ + moduleId: module.id, selector: 'md-step-header, mat-step-header', templateUrl: 'step-header.html', styleUrls: ['step-header.css'], From e318de6cd1e739e4ca284928506a604663ac6f48 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 1 Sep 2017 16:47:47 +0200 Subject: [PATCH 004/575] refactor: initialize to empty subscriptions (#6769) Initializes most subscriptions to empty ones, avoiding the need to null-check them before unsubscribing. --- src/cdk/a11y/list-key-manager.ts | 6 ++--- src/cdk/overlay/overlay-directives.ts | 30 ++++++--------------- src/lib/chips/chip-list.ts | 6 ++--- src/lib/datepicker/datepicker-input.ts | 6 ++--- src/lib/datepicker/datepicker.ts | 7 +++-- src/lib/expansion/expansion-panel-header.ts | 8 ++---- src/lib/list/selection-list.ts | 13 +++------ src/lib/menu/menu-directive.ts | 7 ++--- src/lib/menu/menu-trigger.ts | 16 +++++------ src/lib/select/select.ts | 21 +++++---------- src/lib/tabs/tab-group.ts | 18 ++++--------- src/lib/tabs/tab-header.ts | 7 ++--- src/lib/tabs/tab-nav-bar/tab-nav-bar.ts | 17 +++++------- 13 files changed, 50 insertions(+), 112 deletions(-) diff --git a/src/cdk/a11y/list-key-manager.ts b/src/cdk/a11y/list-key-manager.ts index 47fafcfa1856..cb8a1850518a 100644 --- a/src/cdk/a11y/list-key-manager.ts +++ b/src/cdk/a11y/list-key-manager.ts @@ -29,7 +29,7 @@ export class ListKeyManager { private _activeItem: T; private _wrap = false; private _letterKeyStream = new Subject(); - private _typeaheadSubscription: Subscription; + private _typeaheadSubscription = Subscription.EMPTY; // Buffer for the letters that the user has pressed when the typeahead option is turned on. private _pressedLetters: string[] = []; @@ -60,9 +60,7 @@ export class ListKeyManager { throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.'); } - if (this._typeaheadSubscription) { - this._typeaheadSubscription.unsubscribe(); - } + this._typeaheadSubscription.unsubscribe(); // Debounce the presses of non-navigational keys, collect the ones that correspond to letters // and convert those letters back into a string. Afterwards find the first item that starts diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index 5ab882e57d74..fdceb1dca129 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -95,12 +95,12 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { private _overlayRef: OverlayRef; private _templatePortal: TemplatePortal; private _hasBackdrop = false; - private _backdropSubscription: Subscription | null; - private _positionSubscription: Subscription; + private _backdropSubscription = Subscription.EMPTY; + private _positionSubscription = Subscription.EMPTY; private _offsetX: number = 0; private _offsetY: number = 0; private _position: ConnectedPositionStrategy; - private _escapeListener: Function; + private _escapeListener = () => {}; /** Origin for the connected overlay. */ @Input('cdkConnectedOverlayOrigin') origin: OverlayOrigin; @@ -360,14 +360,8 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { this.detach.emit(); } - if (this._backdropSubscription) { - this._backdropSubscription.unsubscribe(); - this._backdropSubscription = null; - } - - if (this._escapeListener) { - this._escapeListener(); - } + this._backdropSubscription.unsubscribe(); + this._escapeListener(); } /** Destroys the overlay created by this directive. */ @@ -376,17 +370,9 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { this._overlayRef.dispose(); } - if (this._backdropSubscription) { - this._backdropSubscription.unsubscribe(); - } - - if (this._positionSubscription) { - this._positionSubscription.unsubscribe(); - } - - if (this._escapeListener) { - this._escapeListener(); - } + this._backdropSubscription.unsubscribe(); + this._positionSubscription.unsubscribe(); + this._escapeListener(); } /** Sets the event listener that closes the overlay when pressing Escape. */ diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index a693b3cca20a..de830d015c0b 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -66,7 +66,7 @@ export class MdChipList implements AfterContentInit, OnDestroy { protected _chipSet: WeakMap = new WeakMap(); /** Subscription to tabbing out from the chip list. */ - private _tabOutSubscription: Subscription; + private _tabOutSubscription = Subscription.EMPTY; /** Whether or not the chip is selectable. */ protected _selectable: boolean = true; @@ -126,9 +126,7 @@ export class MdChipList implements AfterContentInit, OnDestroy { } ngOnDestroy(): void { - if (this._tabOutSubscription) { - this._tabOutSubscription.unsubscribe(); - } + this._tabOutSubscription.unsubscribe(); } /** diff --git a/src/lib/datepicker/datepicker-input.ts b/src/lib/datepicker/datepicker-input.ts index b3a90125c782..585a5bc8ad6b 100644 --- a/src/lib/datepicker/datepicker-input.ts +++ b/src/lib/datepicker/datepicker-input.ts @@ -171,7 +171,7 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces private _validatorOnChange = () => {}; - private _datepickerSubscription: Subscription; + private _datepickerSubscription = Subscription.EMPTY; /** The form control validator for whether the input parses. */ private _parseValidator: ValidatorFn = (): ValidationErrors | null => { @@ -235,9 +235,7 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces } ngOnDestroy() { - if (this._datepickerSubscription) { - this._datepickerSubscription.unsubscribe(); - } + this._datepickerSubscription.unsubscribe(); } registerOnValidatorChange(fn: () => void): void { diff --git a/src/lib/datepicker/datepicker.ts b/src/lib/datepicker/datepicker.ts index b1e9e3555836..9312ba22e3e4 100644 --- a/src/lib/datepicker/datepicker.ts +++ b/src/lib/datepicker/datepicker.ts @@ -200,7 +200,7 @@ export class MdDatepicker implements OnDestroy { /** The element that was focused before the datepicker was opened. */ private _focusedElementBeforeOpen: HTMLElement | null = null; - private _inputSubscription: Subscription; + private _inputSubscription = Subscription.EMPTY; constructor(private _dialog: MdDialog, private _overlay: Overlay, @@ -217,12 +217,11 @@ export class MdDatepicker implements OnDestroy { ngOnDestroy() { this.close(); + this._inputSubscription.unsubscribe(); + if (this._popupRef) { this._popupRef.dispose(); } - if (this._inputSubscription) { - this._inputSubscription.unsubscribe(); - } } /** Selects the given date */ diff --git a/src/lib/expansion/expansion-panel-header.ts b/src/lib/expansion/expansion-panel-header.ts index 2de7617f3851..56c4b4626156 100644 --- a/src/lib/expansion/expansion-panel-header.ts +++ b/src/lib/expansion/expansion-panel-header.ts @@ -72,7 +72,7 @@ import {Subscription} from 'rxjs/Subscription'; ], }) export class MdExpansionPanelHeader implements OnDestroy { - private _parentChangeSubscription: Subscription | null = null; + private _parentChangeSubscription = Subscription.EMPTY; constructor( @Host() public panel: MdExpansionPanel, @@ -135,11 +135,7 @@ export class MdExpansionPanelHeader implements OnDestroy { } ngOnDestroy() { - if (this._parentChangeSubscription) { - this._parentChangeSubscription.unsubscribe(); - this._parentChangeSubscription = null; - } - + this._parentChangeSubscription.unsubscribe(); this._focusOriginMonitor.stopMonitoring(this._element.nativeElement); } } diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index a1b3f508dda1..a1dd1b778136 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -196,10 +196,10 @@ export class MdSelectionList extends _MdSelectionListMixinBase _tabIndex = 0; /** Subscription to all list options' onFocus events */ - private _optionFocusSubscription: Subscription; + private _optionFocusSubscription = Subscription.EMPTY; /** Subscription to all list options' destroy events */ - private _optionDestroyStream: Subscription; + private _optionDestroyStream = Subscription.EMPTY; /** The FocusKeyManager which handles focus. */ _keyManager: FocusKeyManager; @@ -234,13 +234,8 @@ export class MdSelectionList extends _MdSelectionListMixinBase } ngOnDestroy(): void { - if (this._optionDestroyStream) { - this._optionDestroyStream.unsubscribe(); - } - - if (this._optionFocusSubscription) { - this._optionFocusSubscription.unsubscribe(); - } + this._optionDestroyStream.unsubscribe(); + this._optionFocusSubscription.unsubscribe(); } focus() { diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index a0344ba141ce..4dc9d57f469c 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -74,7 +74,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { private _previousElevation: string; /** Subscription to tab events on the menu panel */ - private _tabSubscription: Subscription; + private _tabSubscription = Subscription.EMPTY; /** Config object to be passed into the menu's ngClass */ _classList: any = {}; @@ -150,10 +150,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { } ngOnDestroy() { - if (this._tabSubscription) { - this._tabSubscription.unsubscribe(); - } - + this._tabSubscription.unsubscribe(); this.close.emit(); this.close.complete(); } diff --git a/src/lib/menu/menu-trigger.ts b/src/lib/menu/menu-trigger.ts index b2bda1683e12..db95674e750f 100644 --- a/src/lib/menu/menu-trigger.ts +++ b/src/lib/menu/menu-trigger.ts @@ -89,9 +89,9 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { private _portal: TemplatePortal; private _overlayRef: OverlayRef | null = null; private _menuOpen: boolean = false; - private _closeSubscription: Subscription; - private _positionSubscription: Subscription; - private _hoverSubscription: Subscription; + private _closeSubscription = Subscription.EMPTY; + private _positionSubscription = Subscription.EMPTY; + private _hoverSubscription = Subscription.EMPTY; // Tracking input type is necessary so it's possible to only auto-focus // the first item of the list when the menu is opened via the keyboard @@ -392,13 +392,9 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { /** Cleans up the active subscriptions. */ private _cleanUpSubscriptions(): void { - [ - this._closeSubscription, - this._positionSubscription, - this._hoverSubscription - ] - .filter(subscription => !!subscription) - .forEach(subscription => subscription.unsubscribe()); + this._closeSubscription.unsubscribe(); + this._positionSubscription.unsubscribe(); + this._hoverSubscription.unsubscribe(); } /** Returns a stream that emits whenever an action that should close the menu occurs. */ diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 6e89d0880289..97730a267f59 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -205,13 +205,13 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On private _panelOpen = false; /** Subscriptions to option events. */ - private _optionSubscription: Subscription | null; + private _optionSubscription = Subscription.EMPTY; /** Subscription to changes in the option list. */ - private _changeSubscription: Subscription; + private _changeSubscription = Subscription.EMPTY; /** Subscription to tab events while overlay is focused. */ - private _tabSubscription: Subscription; + private _tabSubscription = Subscription.EMPTY; /** Whether filling out the select is required in the form. */ private _required: boolean = false; @@ -466,14 +466,8 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On ngOnDestroy() { this._dropSubscriptions(); - - if (this._changeSubscription) { - this._changeSubscription.unsubscribe(); - } - - if (this._tabSubscription) { - this._tabSubscription.unsubscribe(); - } + this._changeSubscription.unsubscribe(); + this._tabSubscription.unsubscribe(); } /** Toggles the overlay panel open or closed. */ @@ -852,10 +846,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On /** Unsubscribes from all option subscriptions. */ private _dropSubscriptions(): void { - if (this._optionSubscription) { - this._optionSubscription.unsubscribe(); - this._optionSubscription = null; - } + this._optionSubscription.unsubscribe(); } /** Emits change event to set the model value. */ diff --git a/src/lib/tabs/tab-group.ts b/src/lib/tabs/tab-group.ts index 8205638fcdee..f3d40a01b0ec 100644 --- a/src/lib/tabs/tab-group.ts +++ b/src/lib/tabs/tab-group.ts @@ -89,10 +89,10 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit private _tabBodyWrapperHeight: number = 0; /** Subscription to tabs being added/removed. */ - private _tabsSubscription: Subscription; + private _tabsSubscription = Subscription.EMPTY; /** Subscription to changes in the tab labels. */ - private _tabLabelSubscription: Subscription; + private _tabLabelSubscription = Subscription.EMPTY; /** Whether the tab group should grow to the size of the active tab. */ @Input() @@ -199,13 +199,8 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit } ngOnDestroy() { - if (this._tabsSubscription) { - this._tabsSubscription.unsubscribe(); - } - - if (this._tabLabelSubscription) { - this._tabLabelSubscription.unsubscribe(); - } + this._tabsSubscription.unsubscribe(); + this._tabLabelSubscription.unsubscribe(); } /** @@ -236,10 +231,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit * manually. */ private _subscribeToTabLabels() { - if (this._tabLabelSubscription) { - this._tabLabelSubscription.unsubscribe(); - } - + this._tabLabelSubscription.unsubscribe(); this._tabLabelSubscription = merge(...this._tabs.map(tab => tab._labelChange)).subscribe(() => { this._changeDetectorRef.markForCheck(); }); diff --git a/src/lib/tabs/tab-header.ts b/src/lib/tabs/tab-header.ts index e57d9840050e..00f0987bc69e 100644 --- a/src/lib/tabs/tab-header.ts +++ b/src/lib/tabs/tab-header.ts @@ -92,7 +92,7 @@ export class MdTabHeader extends _MdTabHeaderMixinBase private _selectedIndexChanged = false; /** Combines listeners that will re-align the ink bar whenever they're invoked. */ - private _realignInkBar: Subscription | null = null; + private _realignInkBar = Subscription.EMPTY; /** Whether the controls for pagination should be displayed */ _showPaginationControls = false; @@ -195,10 +195,7 @@ export class MdTabHeader extends _MdTabHeaderMixinBase } ngOnDestroy() { - if (this._realignInkBar) { - this._realignInkBar.unsubscribe(); - this._realignInkBar = null; - } + this._realignInkBar.unsubscribe(); } /** diff --git a/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts b/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts index 8c51f8eec506..d247017fe418 100644 --- a/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts @@ -30,7 +30,6 @@ import {Directionality} from '@angular/cdk/bidi'; import {Platform} from '@angular/cdk/platform'; import {auditTime, takeUntil} from '@angular/cdk/rxjs'; import {Subject} from 'rxjs/Subject'; -import {Subscription} from 'rxjs/Subscription'; import {of as observableOf} from 'rxjs/observable/of'; import {merge} from 'rxjs/observable/merge'; import {fromEvent} from 'rxjs/observable/fromEvent'; @@ -78,9 +77,6 @@ export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, Ca @ContentChildren(forwardRef(() => MdTabLink), {descendants: true}) _tabLinks: QueryList; - /** Subscription for window.resize event **/ - private _resizeSubscription: Subscription; - /** Background color of the tab nav. */ @Input() get backgroundColor(): ThemePalette { return this._backgroundColor; } @@ -124,15 +120,17 @@ export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, Ca } ngAfterContentInit(): void { - this._resizeSubscription = this._ngZone.runOutsideAngular(() => { + this._ngZone.runOutsideAngular(() => { let dirChange = this._dir ? this._dir.change : observableOf(null); let resize = typeof window !== 'undefined' ? auditTime.call(fromEvent(window, 'resize'), 10) : observableOf(null); - return takeUntil.call(merge(dirChange, resize), this._onDestroy) - .subscribe(() => this._alignInkBar()); + return takeUntil.call(merge(dirChange, resize), this._onDestroy).subscribe(() => { + this._alignInkBar(); + }); }); + this._setLinkDisableRipple(); } @@ -146,10 +144,7 @@ export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, Ca ngOnDestroy() { this._onDestroy.next(); - - if (this._resizeSubscription) { - this._resizeSubscription.unsubscribe(); - } + this._onDestroy.complete(); } /** Aligns the ink bar to the active link. */ From 1272f0321590dcfe6d2cbbb08d8ece79f59aca3c Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 1 Sep 2017 16:48:18 +0200 Subject: [PATCH 005/575] fix(input): remove resize handle from non-textarea inputs (#6768) Fixes some input types getting a native resize handle, because we were setting the `resize: vertical` explicitly for all `.mat-input-element` instances. Fixes #6757. --- src/lib/input/input.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/input/input.scss b/src/lib/input/input.scss index b960fa972d02..d357326b973b 100644 --- a/src/lib/input/input.scss +++ b/src/lib/input/input.scss @@ -22,7 +22,6 @@ // Prevent textareas from being resized outside the form field. max-width: 100%; - resize: vertical; // Needed to make last line of the textarea line up with the baseline. vertical-align: bottom; @@ -45,5 +44,7 @@ // Prevents IE from always adding a scrollbar by default. textarea.mat-input-element { + // Only allow resizing along the Y axis. + resize: vertical; overflow: auto; } From 255611b1addb0dbafaf9a1ff1415e91c60562853 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 1 Sep 2017 16:49:13 +0200 Subject: [PATCH 006/575] fix(grid-list): avoid unnecessary calc declarations (#6745) For the cases where a tile's offset is 0, some of the `calc` expressions will always evaluate to 0. These changes make it so calc isn't used at all if it would evaluate to 0. --- src/lib/grid-list/grid-list.spec.ts | 12 ++++++++++++ src/lib/grid-list/tile-styler.ts | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/grid-list/grid-list.spec.ts b/src/lib/grid-list/grid-list.spec.ts index d3561a5077ce..6f556b40bbcc 100644 --- a/src/lib/grid-list/grid-list.spec.ts +++ b/src/lib/grid-list/grid-list.spec.ts @@ -253,6 +253,18 @@ describe('MdGridList', () => { let footer = fixture.debugElement.query(By.directive(MdGridTileText)); expect(footer.nativeElement.classList.contains('mat-2-line')).toBe(true); }); + + it('should not use calc() that evaluates to 0', () => { + const fixture = TestBed.createComponent(GirdListWithRowHeightRatio); + + fixture.componentInstance.heightRatio = '4:1'; + fixture.detectChanges(); + + const firstTile = fixture.debugElement.query(By.directive(MdGridTile)).nativeElement; + + expect(firstTile.style.marginTop).toBe('0px'); + expect(firstTile.style.left).toBe('0px'); + }); }); diff --git a/src/lib/grid-list/tile-styler.ts b/src/lib/grid-list/tile-styler.ts index dff694f9dd1e..6c781e3c7e67 100644 --- a/src/lib/grid-list/tile-styler.ts +++ b/src/lib/grid-list/tile-styler.ts @@ -51,7 +51,7 @@ export abstract class TileStyler { // edges, each tile only uses a fraction (gutterShare = numGutters / numCells) of the gutter // size. (Imagine having one gutter per tile, and then breaking up the extra gutter on the // edge evenly among the cells). - return `(${sizePercent}% - ( ${this._gutterSize} * ${gutterFraction} ))`; + return `(${sizePercent}% - (${this._gutterSize} * ${gutterFraction}))`; } @@ -64,7 +64,7 @@ export abstract class TileStyler { getTilePosition(baseSize: string, offset: number): string { // The position comes the size of a 1x1 tile plus gutter for each previous tile in the // row/column (offset). - return calc(`(${baseSize} + ${this._gutterSize}) * ${offset}`); + return offset === 0 ? '0' : calc(`(${baseSize} + ${this._gutterSize}) * ${offset}`); } From efe483afed1d9d0b80ff37ea79c5af29c10524c9 Mon Sep 17 00:00:00 2001 From: Kristofer Karlsson Date: Fri, 1 Sep 2017 16:50:36 +0200 Subject: [PATCH 007/575] fix(list): subheader margin being overwritten by typography (#6735) --- src/lib/list/list.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/list/list.scss b/src/lib/list/list.scss index 13e1baae8d1e..22db02fa92ee 100644 --- a/src/lib/list/list.scss +++ b/src/lib/list/list.scss @@ -118,7 +118,9 @@ $mat-dense-list-icon-size: 20px; // This needs slightly more specificity, because it // can be overwritten by the typography styles. - .mat-list & { + .mat-list &, + .mat-nav-list &, + .mat-selection-list & { margin: 0; } } From 2635cadf4b983546cc4018cf22aa3bb386a850c0 Mon Sep 17 00:00:00 2001 From: Ji Won Shin Date: Fri, 1 Sep 2017 07:51:06 -0700 Subject: [PATCH 008/575] fix(datepicker): Create a new injection token to avoid overriding LOCALE_ID (#6708) --- src/lib/core/datetime/date-adapter.ts | 8 +++++ src/lib/core/datetime/index.ts | 8 +++-- .../core/datetime/native-date-adapter.spec.ts | 30 +++++++++++++++++-- src/lib/core/datetime/native-date-adapter.ts | 10 +++---- src/lib/datepicker/datepicker.md | 7 +++-- 5 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/lib/core/datetime/date-adapter.ts b/src/lib/core/datetime/date-adapter.ts index 407ed09daeec..24172405d036 100644 --- a/src/lib/core/datetime/date-adapter.ts +++ b/src/lib/core/datetime/date-adapter.ts @@ -6,6 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ +import {InjectionToken, LOCALE_ID} from '@angular/core'; + +/** InjectionToken for datepicker that can be used to override default locale code. */ +export const MAT_DATE_LOCALE = new InjectionToken('MAT_DATE_LOCALE'); + +/** Provider for MAT_DATE_LOCALE injection token. */ +export const MAT_DATE_LOCALE_PROVIDER = {provide: MAT_DATE_LOCALE, useExisting: LOCALE_ID}; + /** Adapts type `D` to be usable as a date by cdk-based components that work with dates. */ export abstract class DateAdapter { /** The locale to use for all dates. */ diff --git a/src/lib/core/datetime/index.ts b/src/lib/core/datetime/index.ts index bdacc4d1f010..e16c8b39b197 100644 --- a/src/lib/core/datetime/index.ts +++ b/src/lib/core/datetime/index.ts @@ -7,12 +7,11 @@ */ import {NgModule} from '@angular/core'; -import {DateAdapter} from './date-adapter'; +import {DateAdapter, MAT_DATE_LOCALE_PROVIDER} from './date-adapter'; import {NativeDateAdapter} from './native-date-adapter'; import {MD_DATE_FORMATS} from './date-formats'; import {MD_NATIVE_DATE_FORMATS} from './native-date-formats'; - export * from './date-adapter'; export * from './date-formats'; export * from './native-date-adapter'; @@ -20,7 +19,10 @@ export * from './native-date-formats'; @NgModule({ - providers: [{provide: DateAdapter, useClass: NativeDateAdapter}], + providers: [ + {provide: DateAdapter, useClass: NativeDateAdapter}, + MAT_DATE_LOCALE_PROVIDER + ], }) export class NativeDateModule {} diff --git a/src/lib/core/datetime/native-date-adapter.spec.ts b/src/lib/core/datetime/native-date-adapter.spec.ts index 7f9931310614..cc03629e724e 100644 --- a/src/lib/core/datetime/native-date-adapter.spec.ts +++ b/src/lib/core/datetime/native-date-adapter.spec.ts @@ -1,8 +1,8 @@ import {TestBed, async, inject} from '@angular/core/testing'; -import {LOCALE_ID} from '@angular/core'; -import {NativeDateAdapter, NativeDateModule, DateAdapter} from './index'; +import {NativeDateAdapter, NativeDateModule, DateAdapter, MAT_DATE_LOCALE} from './index'; import {Platform} from '../platform/index'; import {DEC, FEB, JAN, MAR} from '../testing/month-constants'; +import {LOCALE_ID} from '@angular/core'; const SUPPORTS_INTL = typeof Intl != 'undefined'; @@ -334,6 +334,30 @@ describe('NativeDateAdapter', () => { }); +describe('NativeDateAdapter with MAT_DATE_LOCALE override', () => { + let adapter: NativeDateAdapter; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [NativeDateModule], + providers: [{provide: MAT_DATE_LOCALE, useValue: 'da-DK'}] + }).compileComponents(); + })); + + beforeEach(inject([DateAdapter], (d: NativeDateAdapter) => { + adapter = d; + })); + + it('should take the default locale id from the MAT_DATE_LOCALE injection token', () => { + const expectedValue = SUPPORTS_INTL ? + ['søndag', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'] : + ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + + expect(adapter.getDayOfWeekNames('long')).toEqual(expectedValue); + }); + +}); + describe('NativeDateAdapter with LOCALE_ID override', () => { let adapter: NativeDateAdapter; @@ -348,7 +372,7 @@ describe('NativeDateAdapter with LOCALE_ID override', () => { adapter = d; })); - it('should take the default locale id from the LOCALE_ID injection token', () => { + it('should cascade locale id from the LOCALE_ID injection token to MAT_DATE_LOCALE', () => { const expectedValue = SUPPORTS_INTL ? ['søndag', 'mandag', 'tirsdag', 'onsdag', 'torsdag', 'fredag', 'lørdag'] : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; diff --git a/src/lib/core/datetime/native-date-adapter.ts b/src/lib/core/datetime/native-date-adapter.ts index ce1a2c77653d..6eb459c17206 100644 --- a/src/lib/core/datetime/native-date-adapter.ts +++ b/src/lib/core/datetime/native-date-adapter.ts @@ -6,11 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {Inject, Injectable, Optional, LOCALE_ID} from '@angular/core'; -import {DateAdapter} from './date-adapter'; +import {Inject, Injectable, Optional} from '@angular/core'; +import {DateAdapter, MAT_DATE_LOCALE} from './date-adapter'; import {extendObject} from '../util/object-extend'; - // TODO(mmalerba): Remove when we no longer support safari 9. /** Whether the browser supports the Intl API. */ const SUPPORTS_INTL_API = typeof Intl != 'undefined'; @@ -48,13 +47,12 @@ function range(length: number, valueFunction: (index: number) => T): T[] { return valuesArray; } - /** Adapts the native JS Date for use with cdk-based components that work with dates. */ @Injectable() export class NativeDateAdapter extends DateAdapter { - constructor(@Optional() @Inject(LOCALE_ID) localeId: any) { + constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string) { super(); - super.setLocale(localeId); + super.setLocale(matDateLocale); } /** diff --git a/src/lib/datepicker/datepicker.md b/src/lib/datepicker/datepicker.md index a0d624f8d01f..b91d40265db4 100644 --- a/src/lib/datepicker/datepicker.md +++ b/src/lib/datepicker/datepicker.md @@ -116,13 +116,14 @@ three pieces via injection: 3. The message strings used in the datepicker's UI. #### Setting the locale code -By default the datepicker will use the locale code from the `LOCALE_ID` injection token from -`@angular/core`. If you want to override it, you can provide a new value for the token: +By default, the `MAT_DATE_LOCALE` injection token will use the existing `LOCALE_ID` locale code +from `@angular/core`. If you want to override it, you can provide a new value for the +`MAT_DATE_LOCALE` token: ```ts @NgModule({ providers: [ - {provide: LOCALE_ID, useValue: 'en-GB'}, + {provide: MAT_DATE_LOCALE, useValue: 'en-GB'}, ], }) export class MyApp {} From 8c4942280743b848701bb371af5180d5e508fe19 Mon Sep 17 00:00:00 2001 From: Ji Won Shin Date: Fri, 1 Sep 2017 07:53:20 -0700 Subject: [PATCH 009/575] fix(slider): update styles when focus and dir change (#6700) --- src/lib/slider/slider.spec.ts | 42 ++++++++++++++++++++++++++++++++++- src/lib/slider/slider.ts | 20 +++++++++++++---- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/lib/slider/slider.spec.ts b/src/lib/slider/slider.spec.ts index 3bdeff346d13..676929861740 100644 --- a/src/lib/slider/slider.spec.ts +++ b/src/lib/slider/slider.spec.ts @@ -16,7 +16,7 @@ import { UP_ARROW, BACKSPACE } from '../core/keyboard/keycodes'; -import {dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; +import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; describe('MdSlider without forms', () => { let gestureConfig: TestGestureConfig; @@ -141,6 +141,28 @@ describe('MdSlider without forms', () => { expect(sliderNativeElement.classList).not.toContain('mat-slider-sliding'); }); + it('should reset active state upon blur', () => { + sliderInstance._isActive = true; + + dispatchFakeEvent(sliderNativeElement, 'blur'); + fixture.detectChanges(); + + expect(sliderInstance._isActive).toBe(false); + }); + + it('should reset thumb gap when blurred on min value', () => { + sliderInstance._isActive = true; + sliderInstance.value = 0; + fixture.detectChanges(); + + expect(sliderInstance._thumbGap).toBe(10); + + dispatchFakeEvent(sliderNativeElement, 'blur'); + fixture.detectChanges(); + + expect(sliderInstance._thumbGap).toBe(7); + }); + it('should have thumb gap when at min value', () => { expect(trackFillElement.style.transform).toContain('translateX(-7px)'); }); @@ -958,6 +980,24 @@ describe('MdSlider without forms', () => { expect(sliderInstance.value).toBe(30); }); + it('should re-render slider with updated style upon directionality change', () => { + testComponent.dir = 'rtl'; + fixture.detectChanges(); + + let initialTrackFillStyles = sliderInstance._trackFillStyles; + let initialTicksContainerStyles = sliderInstance._ticksContainerStyles; + let initialTicksStyles = sliderInstance._ticksStyles; + let initialThumbContainerStyles = sliderInstance._thumbContainerStyles; + + testComponent.dir = 'ltr'; + fixture.detectChanges(); + + expect(initialTrackFillStyles).not.toEqual(sliderInstance._trackFillStyles); + expect(initialTicksContainerStyles).not.toEqual(sliderInstance._ticksContainerStyles); + expect(initialTicksStyles).not.toEqual(sliderInstance._ticksStyles); + expect(initialThumbContainerStyles).not.toEqual(sliderInstance._thumbContainerStyles); + }); + it('should increment inverted slider by 1 on right arrow pressed', () => { testComponent.invert = true; fixture.detectChanges(); diff --git a/src/lib/slider/slider.ts b/src/lib/slider/slider.ts index 701c08b3396c..e794e1f4575a 100644 --- a/src/lib/slider/slider.ts +++ b/src/lib/slider/slider.ts @@ -19,7 +19,7 @@ import { Output, Renderer2, ViewEncapsulation, - ViewChild, + ViewChild, OnInit, } from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; @@ -125,7 +125,7 @@ export const _MdSliderMixinBase = mixinColor(mixinDisabled(MdSliderBase), 'accen changeDetection: ChangeDetectionStrategy.OnPush, }) export class MdSlider extends _MdSliderMixinBase - implements ControlValueAccessor, OnDestroy, CanDisable, CanColor { + implements ControlValueAccessor, OnDestroy, CanDisable, CanColor, OnInit { /** Whether the slider is inverted. */ @Input() get invert() { return this._invert; } @@ -410,13 +410,25 @@ export class MdSlider extends _MdSliderMixinBase private _changeDetectorRef: ChangeDetectorRef, @Optional() private _dir: Directionality) { super(renderer, elementRef); + } + + ngOnInit() { this._focusOriginMonitor - .monitor(this._elementRef.nativeElement, renderer, true) - .subscribe((origin: FocusOrigin) => this._isActive = !!origin && origin !== 'keyboard'); + .monitor(this._elementRef.nativeElement, this._renderer, true) + .subscribe((origin: FocusOrigin) => { + this._isActive = !!origin && origin !== 'keyboard'; + this._changeDetectorRef.detectChanges(); + }); + if (this._dir) { + this._dir.change.subscribe(() => this._changeDetectorRef.markForCheck()); + } } ngOnDestroy() { this._focusOriginMonitor.stopMonitoring(this._elementRef.nativeElement); + if (this._dir) { + this._dir.change.unsubscribe(); + } } _onMouseenter() { From 82e14f8b71edba1abb50bde21fe77e977b142614 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 1 Sep 2017 16:53:49 +0200 Subject: [PATCH 010/575] fix(button-toggle): border radius ignored if option is selected (#6699) As per Material Design specifications, the button-toggle group should always have a border radius. This behavior has been implemented in the `md-button-toggle-group` component, but does not work properly if an option is selected or disabled. This happens because selected and disabled button-toggles receives a background color, which overflows the clipped button-toggle-group. Fixes #6689 --- src/lib/button-toggle/button-toggle.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/button-toggle/button-toggle.scss b/src/lib/button-toggle/button-toggle.scss index 0ce0a4f18ee8..d77f94181edc 100644 --- a/src/lib/button-toggle/button-toggle.scss +++ b/src/lib/button-toggle/button-toggle.scss @@ -18,6 +18,7 @@ $mat-button-toggle-border-radius: 2px !default; cursor: pointer; white-space: nowrap; + overflow: hidden; } .mat-button-toggle-vertical { From fbce67d219aaa6e903aec0d261634d16f5ae7dcc Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 1 Sep 2017 16:54:27 +0200 Subject: [PATCH 011/575] refactor(selection-list): use disable-ripple mixin (#6692) * Switches the `disableRipple` getter/setter with the `disableRipple` mixin from core. * Prefixes the `isRippleEnabled` method with an underscore to hide it from the API docs. * Switch `isRippleEnabled` to `_isRippleDisabled` --- src/lib/list/list-item.html | 2 +- src/lib/list/list-option.html | 2 +- src/lib/list/list.spec.ts | 10 ++++---- src/lib/list/list.ts | 4 ++-- src/lib/list/selection-list.ts | 42 +++++++++++++--------------------- 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/lib/list/list-item.html b/src/lib/list/list-item.html index bd0f404f5821..aef6a78c83ee 100644 --- a/src/lib/list/list-item.html +++ b/src/lib/list/list-item.html @@ -1,7 +1,7 @@
+ [mdRippleDisabled]="_isRippleDisabled()">
+ [mdRippleDisabled]="_isRippleDisabled()">
diff --git a/src/lib/list/list.spec.ts b/src/lib/list/list.spec.ts index 832afc7bf391..d9854cf1dfdf 100644 --- a/src/lib/list/list.spec.ts +++ b/src/lib/list/list.spec.ts @@ -125,7 +125,7 @@ describe('MdList', () => { const items: QueryList = fixture.debugElement.componentInstance.listItems; expect(items.length).toBeGreaterThan(0); - items.forEach(item => expect(item.isRippleEnabled()).toBe(false)); + items.forEach(item => expect(item._isRippleDisabled()).toBe(true)); }); it('should allow disabling ripples for specific nav-list items', () => { @@ -136,12 +136,12 @@ describe('MdList', () => { expect(items.length).toBeGreaterThan(0); // Ripples should be enabled by default, and can be disabled with a binding. - items.forEach(item => expect(item.isRippleEnabled()).toBe(true)); + items.forEach(item => expect(item._isRippleDisabled()).toBe(false)); fixture.componentInstance.disableItemRipple = true; fixture.detectChanges(); - items.forEach(item => expect(item.isRippleEnabled()).toBe(false)); + items.forEach(item => expect(item._isRippleDisabled()).toBe(true)); }); it('should allow disabling ripples for the whole nav-list', () => { @@ -152,12 +152,12 @@ describe('MdList', () => { expect(items.length).toBeGreaterThan(0); // Ripples should be enabled by default, and can be disabled with a binding. - items.forEach(item => expect(item.isRippleEnabled()).toBe(true)); + items.forEach(item => expect(item._isRippleDisabled()).toBe(false)); fixture.componentInstance.disableListRipple = true; fixture.detectChanges(); - items.forEach(item => expect(item.isRippleEnabled()).toBe(false)); + items.forEach(item => expect(item._isRippleDisabled()).toBe(true)); }); }); diff --git a/src/lib/list/list.ts b/src/lib/list/list.ts index a78156d71e34..7762facbc6a5 100644 --- a/src/lib/list/list.ts +++ b/src/lib/list/list.ts @@ -156,8 +156,8 @@ export class MdListItem extends _MdListItemMixinBase implements AfterContentInit } /** Whether this list item should show a ripple effect when clicked. */ - isRippleEnabled() { - return !this.disableRipple && this._isNavList && !this._list.disableRipple; + _isRippleDisabled() { + return !this._isNavList || this.disableRipple || this._list.disableRipple; } _handleFocus() { diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index a1dd1b778136..1e097ebdde1a 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -32,9 +32,13 @@ import {FocusableOption} from '../core/a11y/focus-key-manager'; import {CanDisable, mixinDisabled} from '../core/common-behaviors/disabled'; import {RxChain, switchMap, startWith} from '../core/rxjs/index'; import {merge} from 'rxjs/observable/merge'; +import {CanDisableRipple, mixinDisableRipple} from '../core/common-behaviors/disable-ripple'; export class MdSelectionListBase {} -export const _MdSelectionListMixinBase = mixinDisabled(MdSelectionListBase); +export const _MdSelectionListMixinBase = mixinDisableRipple(mixinDisabled(MdSelectionListBase)); + +export class MdListOptionBase {} +export const _MdListOptionMixinBase = mixinDisableRipple(MdListOptionBase); export interface MdSelectionListOptionEvent { @@ -51,6 +55,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; @Component({ moduleId: module.id, selector: 'md-list-option, mat-list-option', + inputs: ['disableRipple'], host: { 'role': 'option', 'class': 'mat-list-item mat-list-option', @@ -65,9 +70,10 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }) -export class MdListOption implements AfterContentInit, OnDestroy, FocusableOption { +export class MdListOption extends _MdListOptionMixinBase + implements AfterContentInit, OnDestroy, FocusableOption, CanDisableRipple { + private _lineSetter: MdLineSetter; - private _disableRipple: boolean = false; private _selected: boolean = false; /** Whether the checkbox is disabled. */ private _disabled: boolean = false; @@ -76,15 +82,6 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio /** Whether the option has focus. */ _hasFocus: boolean = false; - /** - * Whether the ripple effect on click should be disabled. This applies only to list items that are - * part of a selection list. The value of `disableRipple` on the `md-selection-list` overrides - * this flag - */ - @Input() - get disableRipple() { return this._disableRipple; } - set disableRipple(value: boolean) { this._disableRipple = coerceBooleanProperty(value); } - @ContentChildren(MdLine) _lines: QueryList; /** Whether the label should appear before or after the checkbox. Defaults to 'after' */ @@ -119,7 +116,9 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio private _element: ElementRef, private _changeDetector: ChangeDetectorRef, @Optional() @Inject(forwardRef(() => MdSelectionList)) - public selectionList: MdSelectionList) {} + public selectionList: MdSelectionList) { + super(); + } ngAfterContentInit() { this._lineSetter = new MdLineSetter(this._lines, this._renderer, this._element); @@ -146,8 +145,8 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio } /** Whether this list item should show a ripple effect when clicked. */ - isRippleEnabled() { - return !this.disableRipple && !this.selectionList.disableRipple; + _isRippleDisabled() { + return this.disableRipple || this.selectionList.disableRipple; } _handleClick() { @@ -175,7 +174,7 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio @Component({ moduleId: module.id, selector: 'md-selection-list, mat-selection-list', - inputs: ['disabled'], + inputs: ['disabled', 'disableRipple'], host: { 'role': 'listbox', '[attr.tabindex]': '_tabIndex', @@ -189,8 +188,7 @@ export class MdListOption implements AfterContentInit, OnDestroy, FocusableOptio changeDetection: ChangeDetectionStrategy.OnPush }) export class MdSelectionList extends _MdSelectionListMixinBase - implements FocusableOption, CanDisable, AfterContentInit, OnDestroy { - private _disableRipple: boolean = false; + implements FocusableOption, CanDisable, CanDisableRipple, AfterContentInit, OnDestroy { /** Tab index for the selection-list. */ _tabIndex = 0; @@ -210,14 +208,6 @@ export class MdSelectionList extends _MdSelectionListMixinBase /** options which are selected. */ selectedOptions: SelectionModel = new SelectionModel(true); - /** - * Whether the ripple effect should be disabled on the list-items or not. - * This flag only has an effect for `mat-selection-list` components. - */ - @Input() - get disableRipple() { return this._disableRipple; } - set disableRipple(value: boolean) { this._disableRipple = coerceBooleanProperty(value); } - constructor(private _element: ElementRef) { super(); } From 4191b4d66e4dc79fc1dfa446caf48e5d3224d4fa Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Fri, 1 Sep 2017 07:54:50 -0700 Subject: [PATCH 012/575] fix(form-field): add aria-owns to label element (#6683) --- src/lib/form-field/form-field.html | 3 +++ src/lib/input/input.spec.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/lib/form-field/form-field.html b/src/lib/form-field/form-field.html index d34e8b7c40f9..223cb79d0922 100644 --- a/src/lib/form-field/form-field.html +++ b/src/lib/form-field/form-field.html @@ -8,8 +8,11 @@ +
diff --git a/src/lib/button/button.ts b/src/lib/button/button.ts index ebfb6960d120..d11c1776b299 100644 --- a/src/lib/button/button.ts +++ b/src/lib/button/button.ts @@ -24,6 +24,7 @@ import { CanColor, CanDisable, CanDisableRipple, + MATERIAL_COMPATIBILITY_MODE, mixinColor, mixinDisabled, mixinDisableRipple @@ -130,6 +131,7 @@ export const _MdButtonMixinBase = mixinColor(mixinDisabled(mixinDisableRipple(Md encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdButton extends _MdButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple { diff --git a/src/lib/checkbox/checkbox.html b/src/lib/checkbox/checkbox.html index b6067c6e0833..f1185ea34a3f 100644 --- a/src/lib/checkbox/checkbox.html +++ b/src/lib/checkbox/checkbox.html @@ -15,10 +15,10 @@ [attr.aria-labelledby]="ariaLabelledby" (change)="_onInteractionEvent($event)" (click)="_onInputClick($event)"> -
+
- + - -
+
diff --git a/src/lib/core/option/option.ts b/src/lib/core/option/option.ts index ebb95a93330f..baf7353f70b1 100644 --- a/src/lib/core/option/option.ts +++ b/src/lib/core/option/option.ts @@ -13,7 +13,6 @@ import { Input, Output, ViewEncapsulation, - Inject, Optional, ChangeDetectionStrategy, ChangeDetectorRef, @@ -59,6 +58,7 @@ export class MdOptionSelectionChange { encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdOption { private _selected: boolean = false; @@ -107,8 +107,7 @@ export class MdOption { constructor( private _element: ElementRef, private _changeDetectorRef: ChangeDetectorRef, - @Optional() public readonly group: MdOptgroup, - @Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) public _isCompatibilityMode: boolean) {} + @Optional() public readonly group: MdOptgroup) {} /** * Whether or not the option is currently active and ready to be selected. diff --git a/src/lib/core/ripple/ripple.ts b/src/lib/core/ripple/ripple.ts index c232ec2fb02e..5b25c0a829f1 100644 --- a/src/lib/core/ripple/ripple.ts +++ b/src/lib/core/ripple/ripple.ts @@ -137,7 +137,7 @@ export class MdRipple implements OnChanges, OnDestroy { } ngOnChanges(changes: SimpleChanges) { - if (changes['trigger'] && this.trigger) { + if ((changes['trigger'] || changes['_matRippleTrigger']) && this.trigger) { this._rippleRenderer.setTriggerElement(this.trigger); } diff --git a/src/lib/datepicker/calendar.html b/src/lib/datepicker/calendar.html index 5bed9b3e0cf0..71d227291bd1 100644 --- a/src/lib/datepicker/calendar.html +++ b/src/lib/datepicker/calendar.html @@ -1,17 +1,6 @@
- - - - - - - - - @@ -52,11 +31,11 @@ (userSelection)="_userSelected()"> - - +
diff --git a/src/lib/datepicker/calendar.ts b/src/lib/datepicker/calendar.ts index eb47eb20a616..b66adc2ff4f3 100644 --- a/src/lib/datepicker/calendar.ts +++ b/src/lib/datepicker/calendar.ts @@ -60,6 +60,7 @@ import {MdDatepickerIntl} from './datepicker-intl'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdCalendar implements AfterContentInit, OnDestroy { private _intlChanges: Subscription; @@ -146,7 +147,6 @@ export class MdCalendar implements AfterContentInit, OnDestroy { constructor(private _elementRef: ElementRef, private _intl: MdDatepickerIntl, private _ngZone: NgZone, - @Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) public _isCompatibilityMode: boolean, @Optional() private _dateAdapter: DateAdapter, @Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats, changeDetectorRef: ChangeDetectorRef) { diff --git a/src/lib/datepicker/datepicker-content.html b/src/lib/datepicker/datepicker-content.html index 90fcc91b6097..fea716d55f61 100644 --- a/src/lib/datepicker/datepicker-content.html +++ b/src/lib/datepicker/datepicker-content.html @@ -1,4 +1,4 @@ - - + diff --git a/src/lib/datepicker/datepicker-toggle.html b/src/lib/datepicker/datepicker-toggle.html index 3335c2912d64..57546536b130 100644 --- a/src/lib/datepicker/datepicker-toggle.html +++ b/src/lib/datepicker/datepicker-toggle.html @@ -1,10 +1,10 @@ - diff --git a/src/lib/datepicker/datepicker-toggle.ts b/src/lib/datepicker/datepicker-toggle.ts index 006ee0cb7520..5968934ff4fc 100644 --- a/src/lib/datepicker/datepicker-toggle.ts +++ b/src/lib/datepicker/datepicker-toggle.ts @@ -22,6 +22,7 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {Subscription} from 'rxjs/Subscription'; import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; +import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; @Component({ @@ -34,6 +35,7 @@ import {of as observableOf} from 'rxjs/observable/of'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdDatepickerToggle implements OnChanges, OnDestroy { private _stateChanges = Subscription.EMPTY; diff --git a/src/lib/datepicker/datepicker.spec.ts b/src/lib/datepicker/datepicker.spec.ts index a5f4a93f99b9..cd0834f951d5 100644 --- a/src/lib/datepicker/datepicker.spec.ts +++ b/src/lib/datepicker/datepicker.spec.ts @@ -249,7 +249,7 @@ describe('MdDatepicker', () => { let ownedElement = document.getElementById(ownedElementId); expect(ownedElement).not.toBeNull(); - expect((ownedElement as Element).tagName.toLowerCase()).toBe('md-calendar'); + expect((ownedElement as Element).tagName.toLowerCase()).toBe('mat-calendar'); }); it('input should aria-owns calendar after opened in touch mode', () => { @@ -267,7 +267,7 @@ describe('MdDatepicker', () => { let ownedElement = document.getElementById(ownedElementId); expect(ownedElement).not.toBeNull(); - expect((ownedElement as Element).tagName.toLowerCase()).toBe('md-calendar'); + expect((ownedElement as Element).tagName.toLowerCase()).toBe('mat-calendar'); }); it('should throw when given wrong data type', () => { diff --git a/src/lib/datepicker/datepicker.ts b/src/lib/datepicker/datepicker.ts index 9f711fcea5dc..d0873f7f1980 100644 --- a/src/lib/datepicker/datepicker.ts +++ b/src/lib/datepicker/datepicker.ts @@ -36,7 +36,7 @@ import { ViewContainerRef, ViewEncapsulation, } from '@angular/core'; -import {DateAdapter} from '@angular/material/core'; +import {DateAdapter, MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; import {MdDialog, MdDialogRef} from '@angular/material/dialog'; import {DOCUMENT} from '@angular/platform-browser'; import {Subject} from 'rxjs/Subject'; @@ -88,6 +88,7 @@ export const MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER = { encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdDatepickerContent implements AfterContentInit { datepicker: MdDatepicker; diff --git a/src/lib/datepicker/month-view.html b/src/lib/datepicker/month-view.html index 4688b323ee8f..a371beaebdd7 100644 --- a/src/lib/datepicker/month-view.html +++ b/src/lib/datepicker/month-view.html @@ -3,7 +3,7 @@ {{day.narrow}} - implements AfterContentInit { /** diff --git a/src/lib/datepicker/year-view.html b/src/lib/datepicker/year-view.html index 4fd34e0c3b89..ca50a5b1cd64 100644 --- a/src/lib/datepicker/year-view.html +++ b/src/lib/datepicker/year-view.html @@ -2,7 +2,7 @@ - -
+
-
+ [matRippleTrigger]="_getHostElement()" + [matRippleDisabled]="_isRippleDisabled()">
- + [disabled]="disabled">
diff --git a/src/lib/list/list.ts b/src/lib/list/list.ts index 06051afc267a..183b8c81dd80 100644 --- a/src/lib/list/list.ts +++ b/src/lib/list/list.ts @@ -19,7 +19,7 @@ import { ViewEncapsulation, ChangeDetectionStrategy, } from '@angular/core'; -import {MdLine, MdLineSetter} from '@angular/material/core'; +import {MATERIAL_COMPATIBILITY_MODE, MdLine, MdLineSetter} from '@angular/material/core'; import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; // Boilerplate for applying mixins to MdList. @@ -132,6 +132,7 @@ export class MdListSubheaderCssMatStyler {} encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdListItem extends _MdListItemMixinBase implements AfterContentInit, CanDisableRipple { private _lineSetter: MdLineSetter; diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index 852eaf74d137..2603911a4905 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -83,7 +83,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - providers: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: false}], + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdListOption extends _MdListOptionMixinBase implements AfterContentInit, OnDestroy, FocusableOption, CanDisableRipple { diff --git a/src/lib/menu/menu-item.html b/src/lib/menu/menu-item.html index 86e13ecab855..ab3465eb526b 100644 --- a/src/lib/menu/menu-item.html +++ b/src/lib/menu/menu-item.html @@ -1,3 +1,3 @@ -
+
diff --git a/src/lib/menu/menu-item.ts b/src/lib/menu/menu-item.ts index b801dc6c2940..fe9ff3dcbb55 100644 --- a/src/lib/menu/menu-item.ts +++ b/src/lib/menu/menu-item.ts @@ -14,7 +14,7 @@ import { OnDestroy, ViewEncapsulation, } from '@angular/core'; -import {CanDisable, mixinDisabled} from '@angular/material/core'; +import {CanDisable, MATERIAL_COMPATIBILITY_MODE, mixinDisabled} from '@angular/material/core'; import {Subject} from 'rxjs/Subject'; // Boilerplate for applying mixins to MdMenuItem. @@ -46,6 +46,7 @@ export const _MdMenuItemMixinBase = mixinDisabled(MdMenuItemBase); preserveWhitespaces: false, templateUrl: 'menu-item.html', exportAs: 'mdMenuItem, matMenuItem', + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdMenuItem extends _MdMenuItemMixinBase implements FocusableOption, CanDisable, OnDestroy { diff --git a/src/lib/paginator/paginator.html b/src/lib/paginator/paginator.html index 515ab7981244..700efb48faaf 100644 --- a/src/lib/paginator/paginator.html +++ b/src/lib/paginator/paginator.html @@ -3,15 +3,15 @@ {{_intl.itemsPerPageLabel}}
- - + {{pageSizeOption}} - - + +
{{pageSize}}
@@ -20,21 +20,21 @@ {{_intl.getRangeLabel(pageIndex, pageSize, length)}}
- - diff --git a/src/lib/paginator/paginator.ts b/src/lib/paginator/paginator.ts index a0903e392cbf..22391029aaf9 100644 --- a/src/lib/paginator/paginator.ts +++ b/src/lib/paginator/paginator.ts @@ -52,9 +52,7 @@ export class PageEvent { host: { 'class': 'mat-paginator', }, - providers: [ - {provide: MATERIAL_COMPATIBILITY_MODE, useValue: false} - ], + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, diff --git a/src/lib/progress-spinner/progress-spinner.html b/src/lib/progress-spinner/progress-spinner.html index 3379dc08262a..bb27e80f90b6 100644 --- a/src/lib/progress-spinner/progress-spinner.html +++ b/src/lib/progress-spinner/progress-spinner.html @@ -1,6 +1,6 @@ diff --git a/src/lib/radio/radio.html b/src/lib/radio/radio.html index 2b455fd41516..c6280776061d 100644 --- a/src/lib/radio/radio.html +++ b/src/lib/radio/radio.html @@ -5,10 +5,10 @@
-
+
-
+
diff --git a/src/lib/slide-toggle/slide-toggle.ts b/src/lib/slide-toggle/slide-toggle.ts index d9e9c74233ea..114bf16e3184 100644 --- a/src/lib/slide-toggle/slide-toggle.ts +++ b/src/lib/slide-toggle/slide-toggle.ts @@ -26,15 +26,20 @@ import {Platform} from '@angular/cdk/platform'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import { applyCssTransform, + CanColor, + CanDisable, + CanDisableRipple, HammerInput, + HasTabIndex, + MATERIAL_COMPATIBILITY_MODE, MdRipple, + mixinColor, + mixinDisabled, + mixinDisableRipple, + mixinTabIndex, RippleRef, } from '@angular/material/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; -import {mixinDisabled, CanDisable} from '@angular/material/core'; -import {CanColor, mixinColor} from '@angular/material/core'; -import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; -import {HasTabIndex, mixinTabIndex} from '@angular/material/core'; import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; // Increasing integer for generating unique ids for slide-toggle components. @@ -74,10 +79,11 @@ export const _MdSlideToggleMixinBase = templateUrl: 'slide-toggle.html', styleUrls: ['slide-toggle.css'], providers: [MD_SLIDE_TOGGLE_VALUE_ACCESSOR], + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], inputs: ['disabled', 'disableRipple', 'color', 'tabIndex'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, }) export class MdSlideToggle extends _MdSlideToggleMixinBase implements OnDestroy, AfterContentInit, ControlValueAccessor, CanDisable, CanColor, HasTabIndex, CanDisableRipple { diff --git a/src/lib/stepper/step-header.html b/src/lib/stepper/step-header.html index b385c5b43974..57b983544512 100644 --- a/src/lib/stepper/step-header.html +++ b/src/lib/stepper/step-header.html @@ -2,8 +2,8 @@ [class.mat-step-icon-not-touched]="icon == 'number' && !selected" [ngSwitch]="icon"> {{index + 1}} - create - done + create + done
diff --git a/src/lib/stepper/step-header.ts b/src/lib/stepper/step-header.ts index d610db9a73b3..be0390fc7b58 100644 --- a/src/lib/stepper/step-header.ts +++ b/src/lib/stepper/step-header.ts @@ -23,7 +23,7 @@ import {MdStepLabel} from './step-label'; }, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, - providers: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: false}], + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdStepHeader { /** Icon for the given step. */ diff --git a/src/lib/stepper/stepper-horizontal.html b/src/lib/stepper/stepper-horizontal.html index 8b32e92e93a3..905f8dee8034 100644 --- a/src/lib/stepper/stepper-horizontal.html +++ b/src/lib/stepper/stepper-horizontal.html @@ -1,6 +1,6 @@
- - +
diff --git a/src/lib/stepper/stepper-vertical.html b/src/lib/stepper/stepper-vertical.html index bccd9bf5f4df..29a2f16f16fb 100644 --- a/src/lib/stepper/stepper-vertical.html +++ b/src/lib/stepper/stepper-vertical.html @@ -1,5 +1,5 @@
- - +
, /** Asserts that step selection change using stepper buttons does not focus step header. */ function assertStepHeaderFocusNotCalled(fixture: ComponentFixture) { let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; - let stepHeaderEl = fixture.debugElement.queryAll(By.css('md-step-header'))[1].nativeElement; + let stepHeaderEl = fixture.debugElement.queryAll(By.css('mat-step-header'))[1].nativeElement; let nextButtonNativeEl = fixture.debugElement .queryAll(By.directive(MdStepperNext))[0].nativeElement; spyOn(stepHeaderEl, 'focus'); @@ -577,7 +577,7 @@ function assertLinearStepperValidity(stepHeaderEl: HTMLElement, /** Asserts that step header focus is blurred if the step cannot be selected upon header click. */ function assertStepHeaderBlurred(fixture: ComponentFixture) { let stepHeaderEl = fixture.debugElement - .queryAll(By.css('md-step-header'))[1].nativeElement; + .queryAll(By.css('mat-step-header'))[1].nativeElement; spyOn(stepHeaderEl, 'blur'); stepHeaderEl.click(); fixture.detectChanges(); diff --git a/src/lib/stepper/stepper.ts b/src/lib/stepper/stepper.ts index 6c2098e5e065..1472de27a0fa 100644 --- a/src/lib/stepper/stepper.ts +++ b/src/lib/stepper/stepper.ts @@ -26,7 +26,7 @@ import {FormControl, FormGroupDirective, NgForm} from '@angular/forms'; import { defaultErrorStateMatcher, ErrorOptions, - ErrorStateMatcher, + ErrorStateMatcher, MATERIAL_COMPATIBILITY_MODE, MD_ERROR_GLOBAL_OPTIONS, } from '@angular/material/core'; import {MdStepHeader} from './step-header'; @@ -107,6 +107,7 @@ export class MdStepper extends _MdStepper { providers: [{provide: MdStepper, useExisting: MdHorizontalStepper}], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdHorizontalStepper extends MdStepper { } @@ -129,6 +130,7 @@ export class MdHorizontalStepper extends MdStepper { } ]) ], providers: [{provide: MdStepper, useExisting: MdVerticalStepper}], + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) diff --git a/src/lib/tabs/tab-group.html b/src/lib/tabs/tab-group.html index b352fa088a9c..baef20dfb1b8 100644 --- a/src/lib/tabs/tab-group.html +++ b/src/lib/tabs/tab-group.html @@ -1,9 +1,9 @@ - -
@@ -22,10 +22,10 @@ {{tab.textLabel}}
-
+
- - +
diff --git a/src/lib/tabs/tab-group.spec.ts b/src/lib/tabs/tab-group.spec.ts index a82befc61f89..651f465319e4 100644 --- a/src/lib/tabs/tab-group.spec.ts +++ b/src/lib/tabs/tab-group.spec.ts @@ -372,7 +372,7 @@ describe('MdTabGroup', () => { expect(tabLabelElement.classList.contains('mat-tab-label-active')).toBe(true); let tabContentElement = fixture.debugElement - .query(By.css(`md-tab-body:nth-of-type(${expectedIndex + 1})`)).nativeElement; + .query(By.css(`mat-tab-body:nth-of-type(${expectedIndex + 1})`)).nativeElement; expect(tabContentElement.classList.contains('mat-tab-body-active')).toBe(true); } diff --git a/src/lib/tabs/tab-group.ts b/src/lib/tabs/tab-group.ts index 5a7297cd89c3..a80bc765b5b6 100644 --- a/src/lib/tabs/tab-group.ts +++ b/src/lib/tabs/tab-group.ts @@ -28,7 +28,10 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {Subscription} from 'rxjs/Subscription'; import {MdTab} from './tab'; import {merge} from 'rxjs/observable/merge'; -import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; +import { + CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, + mixinDisableRipple +} from '@angular/material/core'; import {CanColor, mixinColor, ThemePalette} from '@angular/material/core'; @@ -69,7 +72,8 @@ export const _MdTabGroupMixinBase = mixinColor(mixinDisableRipple(MdTabGroupBase 'class': 'mat-tab-group', '[class.mat-tab-group-dynamic-height]': 'dynamicHeight', '[class.mat-tab-group-inverted-header]': 'headerPosition === "below"', - } + }, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit, AfterContentChecked, AfterViewChecked, OnDestroy, CanColor, CanDisableRipple { diff --git a/src/lib/tabs/tab-header.html b/src/lib/tabs/tab-header.html index 62a15bb6bed6..79f964eda21a 100644 --- a/src/lib/tabs/tab-header.html +++ b/src/lib/tabs/tab-header.html @@ -1,6 +1,6 @@
@@ -12,13 +12,13 @@
- +
diff --git a/src/lib/tabs/tab-header.ts b/src/lib/tabs/tab-header.ts index b92d9d15a77d..782c20284083 100644 --- a/src/lib/tabs/tab-header.ts +++ b/src/lib/tabs/tab-header.ts @@ -27,7 +27,10 @@ import { ViewChild, ViewEncapsulation, } from '@angular/core'; -import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; +import { + CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, + mixinDisableRipple +} from '@angular/material/core'; import {fromEvent} from 'rxjs/observable/fromEvent'; import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; @@ -74,7 +77,8 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase); 'class': 'mat-tab-header', '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls', '[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'", - } + }, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdTabHeader extends _MdTabHeaderMixinBase implements AfterContentChecked, AfterContentInit, OnDestroy, CanDisableRipple { diff --git a/src/lib/tabs/tab-nav-bar/tab-nav-bar.html b/src/lib/tabs/tab-nav-bar/tab-nav-bar.html index cf26352743fd..d842ff7060db 100644 --- a/src/lib/tabs/tab-nav-bar/tab-nav-bar.html +++ b/src/lib/tabs/tab-nav-bar/tab-nav-bar.html @@ -1,5 +1,5 @@
- +
diff --git a/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts b/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts index 506f0564f818..99eb7ecf993f 100644 --- a/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts @@ -33,7 +33,7 @@ import { import { CanColor, CanDisable, - CanDisableRipple, + CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, MD_RIPPLE_GLOBAL_OPTIONS, MdRipple, mixinColor, @@ -70,6 +70,7 @@ export const _MdTabNavMixinBase = mixinDisableRipple(mixinColor(MdTabNavBase, 'p encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, CanColor, CanDisableRipple, OnDestroy { diff --git a/src/lib/tabs/tab.html b/src/lib/tabs/tab.html index 398c819fa896..99442c1f1e37 100644 --- a/src/lib/tabs/tab.html +++ b/src/lib/tabs/tab.html @@ -1,4 +1,4 @@ - diff --git a/src/lib/toolbar/toolbar.html b/src/lib/toolbar/toolbar.html index e81e16e5d708..88eed7dbff08 100644 --- a/src/lib/toolbar/toolbar.html +++ b/src/lib/toolbar/toolbar.html @@ -1,6 +1,6 @@
- + - +
diff --git a/src/lib/toolbar/toolbar.ts b/src/lib/toolbar/toolbar.ts index de05bc8d1257..42c852af0460 100644 --- a/src/lib/toolbar/toolbar.ts +++ b/src/lib/toolbar/toolbar.ts @@ -14,7 +14,7 @@ import { ElementRef, Renderer2, } from '@angular/core'; -import {CanColor, mixinColor} from '@angular/material/core'; +import {CanColor, MATERIAL_COMPATIBILITY_MODE, mixinColor} from '@angular/material/core'; @Directive({ @@ -44,6 +44,7 @@ export const _MdToolbarMixinBase = mixinColor(MdToolbarBase); changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, + viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) export class MdToolbar extends _MdToolbarMixinBase implements CanColor { From f9b5ccd5373308f570e7c5bddca319a29ad050a4 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Thu, 21 Sep 2017 12:11:09 -0700 Subject: [PATCH 127/575] fix: remove cdk re-exports from @angular/material (#7112) --- src/{lib/core => cdk}/a11y/_a11y.scss | 0 src/cdk/a11y/focus-monitor.spec.ts | 10 ++-- src/cdk/a11y/focus-monitor.ts | 4 +- src/cdk/a11y/focus-trap.spec.ts | 6 +- src/cdk/a11y/interactivity-checker.spec.ts | 3 +- src/cdk/a11y/list-key-manager.spec.ts | 8 +-- .../core => cdk}/portal/portal-injector.ts | 0 src/cdk/portal/public_api.ts | 1 + src/demo-app/snack-bar/snack-bar-demo.ts | 6 +- src/lib/autocomplete/autocomplete.spec.ts | 30 +++++----- src/lib/button-toggle/button-toggle.scss | 1 - src/lib/button/button.scss | 2 +- src/lib/card/card.scss | 2 +- src/lib/chips/chip-input.spec.ts | 14 ++--- src/lib/chips/chip-input.ts | 11 +--- src/lib/chips/chip-list.spec.ts | 13 +---- src/lib/chips/chip-list.ts | 15 ++--- src/lib/chips/chip.spec.ts | 11 ++-- src/lib/chips/chip.ts | 57 +++++++++++-------- src/lib/chips/chips.scss | 2 +- src/lib/core/_core.scss | 2 +- src/lib/core/a11y/README.md | 1 - .../core/a11y/activedescendant-key-manager.ts | 9 --- src/lib/core/a11y/fake-mousedown.ts | 9 --- src/lib/core/a11y/focus-key-manager.ts | 9 --- src/lib/core/a11y/focus-trap.ts | 19 ------- src/lib/core/a11y/index.ts | 9 --- src/lib/core/a11y/interactivity-checker.ts | 9 --- src/lib/core/a11y/list-key-manager.ts | 9 --- src/lib/core/a11y/live-announcer.ts | 15 ----- src/lib/core/bidi/dir.ts | 10 ---- src/lib/core/bidi/directionality.ts | 15 ----- src/lib/core/bidi/index.ts | 16 ------ .../core/compatibility/compatibility.spec.ts | 4 +- .../core/datetime/native-date-adapter.spec.ts | 8 +-- src/lib/core/keyboard/keycodes.ts | 27 --------- src/lib/core/option/_option.scss | 2 +- src/lib/core/option/option.ts | 12 ++-- src/lib/core/overlay/index.ts | 9 --- src/lib/core/platform/features.ts | 9 --- src/lib/core/platform/index.ts | 11 ---- src/lib/core/platform/platform.ts | 9 --- src/lib/core/portal/README.md | 1 - src/lib/core/portal/dom-portal-host.ts | 8 --- src/lib/core/portal/portal-directives.ts | 9 --- src/lib/core/portal/portal.ts | 15 ----- src/lib/core/public_api.ts | 10 ---- src/lib/core/ripple/_ripple.scss | 2 +- src/lib/core/rxjs/index.ts | 10 ---- src/lib/core/rxjs/rx-chain.spec.ts | 41 ------------- src/lib/core/rxjs/rx-chain.ts | 9 --- src/lib/core/rxjs/rx-operators.ts | 47 --------------- src/lib/core/style/index.ts | 16 ------ src/lib/datepicker/calendar.spec.ts | 38 ++++++++----- src/lib/dialog/dialog.scss | 2 +- src/lib/dialog/dialog.ts | 5 +- src/lib/expansion/expansion-panel-header.ts | 26 ++++----- src/lib/form-field/form-field-module.ts | 4 +- src/lib/icon/icon-registry.ts | 10 +--- src/lib/icon/icon.ts | 6 +- src/lib/input/input-module.ts | 8 +-- src/lib/input/input.spec.ts | 28 ++++----- src/lib/list/selection-list.spec.ts | 10 ++-- src/lib/list/selection-list.ts | 6 +- src/lib/menu/menu-directive.ts | 29 +++++----- src/lib/menu/menu.scss | 2 +- src/lib/select/select.scss | 2 +- src/lib/sidenav/drawer.scss | 2 +- src/lib/sidenav/drawer.ts | 5 +- src/lib/slide-toggle/slide-toggle.scss | 2 +- src/lib/slider/slider-module.ts | 8 +-- src/lib/slider/slider.spec.ts | 19 ++++--- src/lib/snack-bar/snack-bar-container.scss | 2 +- src/lib/snack-bar/snack-bar.ts | 11 ++-- src/lib/sort/sort.spec.ts | 17 +++--- src/lib/stepper/stepper.spec.ts | 15 ++--- src/lib/tabs/tab-body.spec.ts | 11 ++-- src/lib/tabs/tab.ts | 5 +- src/lib/tooltip/tooltip.scss | 2 +- 79 files changed, 249 insertions(+), 613 deletions(-) rename src/{lib/core => cdk}/a11y/_a11y.scss (100%) rename src/{lib/core => cdk}/portal/portal-injector.ts (100%) delete mode 100644 src/lib/core/a11y/README.md delete mode 100644 src/lib/core/a11y/activedescendant-key-manager.ts delete mode 100644 src/lib/core/a11y/fake-mousedown.ts delete mode 100644 src/lib/core/a11y/focus-key-manager.ts delete mode 100644 src/lib/core/a11y/focus-trap.ts delete mode 100644 src/lib/core/a11y/index.ts delete mode 100644 src/lib/core/a11y/interactivity-checker.ts delete mode 100644 src/lib/core/a11y/list-key-manager.ts delete mode 100644 src/lib/core/a11y/live-announcer.ts delete mode 100644 src/lib/core/bidi/dir.ts delete mode 100644 src/lib/core/bidi/directionality.ts delete mode 100644 src/lib/core/bidi/index.ts delete mode 100644 src/lib/core/keyboard/keycodes.ts delete mode 100644 src/lib/core/overlay/index.ts delete mode 100644 src/lib/core/platform/features.ts delete mode 100644 src/lib/core/platform/index.ts delete mode 100755 src/lib/core/platform/platform.ts delete mode 100644 src/lib/core/portal/README.md delete mode 100644 src/lib/core/portal/dom-portal-host.ts delete mode 100644 src/lib/core/portal/portal-directives.ts delete mode 100644 src/lib/core/portal/portal.ts delete mode 100644 src/lib/core/rxjs/index.ts delete mode 100644 src/lib/core/rxjs/rx-chain.spec.ts delete mode 100644 src/lib/core/rxjs/rx-chain.ts delete mode 100644 src/lib/core/rxjs/rx-operators.ts diff --git a/src/lib/core/a11y/_a11y.scss b/src/cdk/a11y/_a11y.scss similarity index 100% rename from src/lib/core/a11y/_a11y.scss rename to src/cdk/a11y/_a11y.scss diff --git a/src/cdk/a11y/focus-monitor.spec.ts b/src/cdk/a11y/focus-monitor.spec.ts index a2b8fbfbb5a8..41370ab208ce 100644 --- a/src/cdk/a11y/focus-monitor.spec.ts +++ b/src/cdk/a11y/focus-monitor.spec.ts @@ -1,10 +1,10 @@ -import {ComponentFixture, inject, TestBed, fakeAsync, tick} from '@angular/core/testing'; -import {Component, Renderer2} from '@angular/core'; -import {A11yModule} from './index'; -import {By} from '@angular/platform-browser'; import {TAB} from '@angular/cdk/keycodes'; -import {FocusOrigin, FocusMonitor, TOUCH_BUFFER_MS} from './focus-monitor'; import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; +import {Component, Renderer2} from '@angular/core'; +import {ComponentFixture, fakeAsync, inject, TestBed, tick} from '@angular/core/testing'; +import {By} from '@angular/platform-browser'; +import {FocusMonitor, FocusOrigin, TOUCH_BUFFER_MS} from './focus-monitor'; +import {A11yModule} from './index'; describe('FocusMonitor', () => { diff --git a/src/cdk/a11y/focus-monitor.ts b/src/cdk/a11y/focus-monitor.ts index 6ed78b200df3..d3a5fd61c68a 100644 --- a/src/cdk/a11y/focus-monitor.ts +++ b/src/cdk/a11y/focus-monitor.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +import {Platform} from '@angular/cdk/platform'; import { Directive, ElementRef, @@ -18,11 +19,10 @@ import { Renderer2, SkipSelf, } from '@angular/core'; -import {Platform} from '@angular/cdk/platform'; import {Observable} from 'rxjs/Observable'; +import {of as observableOf} from 'rxjs/observable/of'; import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; -import {of as observableOf} from 'rxjs/observable/of'; // This is the value used by AngularJS Material. Through trial and error (on iPhone 6S) they found diff --git a/src/cdk/a11y/focus-trap.spec.ts b/src/cdk/a11y/focus-trap.spec.ts index 28d07e46842c..4ccae5688498 100644 --- a/src/cdk/a11y/focus-trap.spec.ts +++ b/src/cdk/a11y/focus-trap.spec.ts @@ -1,8 +1,8 @@ -import {ComponentFixture, TestBed, async} from '@angular/core/testing'; +import {Platform} from '@angular/cdk/platform'; import {Component, ViewChild} from '@angular/core'; -import {FocusTrapFactory, FocusTrapDirective, FocusTrap} from './focus-trap'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {FocusTrap, FocusTrapDirective, FocusTrapFactory} from './focus-trap'; import {InteractivityChecker} from './interactivity-checker'; -import {Platform} from '../platform/platform'; describe('FocusTrap', () => { diff --git a/src/cdk/a11y/interactivity-checker.spec.ts b/src/cdk/a11y/interactivity-checker.spec.ts index 3f28acb8b905..23473eb5ded6 100644 --- a/src/cdk/a11y/interactivity-checker.spec.ts +++ b/src/cdk/a11y/interactivity-checker.spec.ts @@ -1,5 +1,6 @@ +import {Platform} from '@angular/cdk/platform'; import {InteractivityChecker} from './interactivity-checker'; -import {Platform} from '../platform/platform'; + describe('InteractivityChecker', () => { let testContainerElement: HTMLElement; diff --git a/src/cdk/a11y/list-key-manager.spec.ts b/src/cdk/a11y/list-key-manager.spec.ts index 499b5a628266..012fa45d8e9b 100644 --- a/src/cdk/a11y/list-key-manager.spec.ts +++ b/src/cdk/a11y/list-key-manager.spec.ts @@ -1,11 +1,11 @@ +import {DOWN_ARROW, TAB, UP_ARROW} from '@angular/cdk/keycodes'; +import {first} from '@angular/cdk/rxjs'; import {QueryList} from '@angular/core'; import {fakeAsync, tick} from '@angular/core/testing'; +import {createKeyboardEvent} from '../testing/event-objects'; +import {ActiveDescendantKeyManager} from './activedescendant-key-manager'; import {FocusKeyManager} from './focus-key-manager'; -import {DOWN_ARROW, UP_ARROW, TAB} from '../keycodes/keycodes'; import {ListKeyManager} from './list-key-manager'; -import {ActiveDescendantKeyManager} from './activedescendant-key-manager'; -import {createKeyboardEvent} from '../testing/event-objects'; -import {first} from '../rxjs/index'; class FakeFocusable { diff --git a/src/lib/core/portal/portal-injector.ts b/src/cdk/portal/portal-injector.ts similarity index 100% rename from src/lib/core/portal/portal-injector.ts rename to src/cdk/portal/portal-injector.ts diff --git a/src/cdk/portal/public_api.ts b/src/cdk/portal/public_api.ts index 3006ee0af57d..253d39a60f41 100644 --- a/src/cdk/portal/public_api.ts +++ b/src/cdk/portal/public_api.ts @@ -9,3 +9,4 @@ export * from './portal'; export * from './dom-portal-host'; export * from './portal-directives'; +export * from './portal-injector'; diff --git a/src/demo-app/snack-bar/snack-bar-demo.ts b/src/demo-app/snack-bar/snack-bar-demo.ts index 8138d60796a1..334959021f81 100644 --- a/src/demo-app/snack-bar/snack-bar-demo.ts +++ b/src/demo-app/snack-bar/snack-bar-demo.ts @@ -1,12 +1,13 @@ +import {Dir} from '@angular/cdk/bidi'; import {Component, ViewEncapsulation} from '@angular/core'; import { MdSnackBar, MdSnackBarConfig, MdSnackBarHorizontalPosition, MdSnackBarVerticalPosition, - Dir, } from '@angular/material'; + @Component({ moduleId: module.id, selector: 'snack-bar-demo', @@ -25,7 +26,8 @@ export class SnackBarDemo { horizontalPosition: MdSnackBarHorizontalPosition = 'center'; verticalPosition: MdSnackBarVerticalPosition = 'bottom'; - constructor(public snackBar: MdSnackBar, private dir: Dir) { } + constructor(public snackBar: MdSnackBar, private dir: Dir) { + } open() { let config = new MdSnackBarConfig(); diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index 308382a9c0f9..e4886f42dd1d 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -1,4 +1,9 @@ -import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; +import {Direction, Directionality} from '@angular/cdk/bidi'; +import {DOWN_ARROW, ENTER, ESCAPE, SPACE, UP_ARROW} from '@angular/cdk/keycodes'; +import {OverlayContainer} from '@angular/cdk/overlay'; +import {map, RxChain, startWith} from '@angular/cdk/rxjs'; +import {ScrollDispatcher} from '@angular/cdk/scrolling'; +import {createKeyboardEvent, dispatchFakeEvent, typeInElement} from '@angular/cdk/testing'; import { ChangeDetectionStrategy, Component, @@ -8,28 +13,23 @@ import { ViewChild, ViewChildren, } from '@angular/core'; +import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; +import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {MdOption} from '@angular/material/core'; +import {MdFormField, MdFormFieldModule} from '@angular/material/form-field'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {ScrollDispatcher} from '@angular/cdk/scrolling'; -import {OverlayContainer} from '@angular/cdk/overlay'; -import {Direction, Directionality} from '@angular/cdk/bidi'; -import {map, RxChain, startWith} from '@angular/cdk/rxjs'; -import {createKeyboardEvent, dispatchFakeEvent, typeInElement} from '@angular/cdk/testing'; +import {Observable} from 'rxjs/Observable'; +import {Subject} from 'rxjs/Subject'; +import {Subscription} from 'rxjs/Subscription'; +import {MdInputModule} from '../input/index'; import { getMdAutocompleteMissingPanelError, MdAutocomplete, MdAutocompleteModule, - MdAutocompleteTrigger, MdAutocompleteSelectedEvent, + MdAutocompleteTrigger, } from './index'; -import {MdInputModule} from '../input/index'; -import {Subscription} from 'rxjs/Subscription'; -import {DOWN_ARROW, ENTER, ESCAPE, SPACE, UP_ARROW} from '@angular/material/core'; -import {MdOption} from '@angular/material/core'; -import {MdFormField, MdFormFieldModule} from '@angular/material/form-field'; -import {Observable} from 'rxjs/Observable'; -import {Subject} from 'rxjs/Subject'; describe('MdAutocomplete', () => { diff --git a/src/lib/button-toggle/button-toggle.scss b/src/lib/button-toggle/button-toggle.scss index d77f94181edc..ea408e5505bb 100644 --- a/src/lib/button-toggle/button-toggle.scss +++ b/src/lib/button-toggle/button-toggle.scss @@ -1,4 +1,3 @@ -@import '../core/a11y/a11y'; @import '../core/style/elevation'; @import '../core/style/vendor-prefixes'; @import '../core/style/layout-common'; diff --git a/src/lib/button/button.scss b/src/lib/button/button.scss index 89bf063c6bf7..277c0be3f9a7 100644 --- a/src/lib/button/button.scss +++ b/src/lib/button/button.scss @@ -1,7 +1,7 @@ // TODO(jelbourn): Measure perf benefits for translate3d and will-change. // TODO(jelbourn): Figure out if anchor hover underline actually happens in any browser. @import 'button-base'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; @import '../core/style/layout-common'; .mat-button, .mat-icon-button { diff --git a/src/lib/card/card.scss b/src/lib/card/card.scss index b1745820a26e..584fef8af43c 100644 --- a/src/lib/card/card.scss +++ b/src/lib/card/card.scss @@ -1,6 +1,6 @@ @import '../core/style/variables'; @import '../core/style/elevation'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; $mat-card-default-padding: 24px !default; diff --git a/src/lib/chips/chip-input.spec.ts b/src/lib/chips/chip-input.spec.ts index b50edcd4dbb9..62e9fd498a2b 100644 --- a/src/lib/chips/chip-input.spec.ts +++ b/src/lib/chips/chip-input.spec.ts @@ -1,13 +1,13 @@ -import {async, TestBed, ComponentFixture} from '@angular/core/testing'; -import {MdChipsModule} from './index'; +import {Directionality} from '@angular/cdk/bidi'; +import {ENTER} from '@angular/cdk/keycodes'; +import {PlatformModule} from '@angular/cdk/platform'; +import {createKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; -import {PlatformModule} from '../core/platform/index'; -import {MdChipInput, MdChipInputEvent} from './chip-input'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {Directionality} from '@angular/material/core'; -import {createKeyboardEvent} from '@angular/cdk/testing'; +import {MdChipInput, MdChipInputEvent} from './chip-input'; +import {MdChipsModule} from './index'; -import {ENTER} from '@angular/material/core'; const COMMA = 188; diff --git a/src/lib/chips/chip-input.ts b/src/lib/chips/chip-input.ts index 14684c9b0762..716d4d710b32 100644 --- a/src/lib/chips/chip-input.ts +++ b/src/lib/chips/chip-input.ts @@ -6,17 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import { - Directive, - ElementRef, - Output, - EventEmitter, - Input, -} from '@angular/core'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; -import {ENTER} from '@angular/material/core'; +import {ENTER} from '@angular/cdk/keycodes'; +import {Directive, ElementRef, EventEmitter, Input, Output,} from '@angular/core'; import {MdChipList} from './chip-list'; + export interface MdChipInputEvent { input: HTMLInputElement; value: string; diff --git a/src/lib/chips/chip-list.spec.ts b/src/lib/chips/chip-list.spec.ts index 947c59071f10..e4ef2f7d2de0 100644 --- a/src/lib/chips/chip-list.spec.ts +++ b/src/lib/chips/chip-list.spec.ts @@ -1,22 +1,13 @@ import {FocusKeyManager} from '@angular/cdk/a11y'; +import {Directionality} from '@angular/cdk/bidi'; +import {BACKSPACE, DELETE, ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE, TAB} from '@angular/cdk/keycodes'; import {createKeyboardEvent, dispatchFakeEvent, dispatchKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement, QueryList, ViewChild, ViewChildren} from '@angular/core'; import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import { - BACKSPACE, - DELETE, - Directionality, - ENTER, - LEFT_ARROW, - RIGHT_ARROW, - SPACE, - TAB, -} from '@angular/material/core'; import {MdFormFieldModule} from '@angular/material/form-field'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; - import {MdInputModule} from '../input/index'; import {MdChip} from './chip'; import {MdChipInputEvent} from './chip-input'; diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index 975208299ec2..caa58d318872 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -5,14 +5,17 @@ * 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 {FocusKeyManager} from '@angular/cdk/a11y'; +import {Directionality} from '@angular/cdk/bidi'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {SelectionModel} from '@angular/cdk/collections'; +import {BACKSPACE, DELETE, LEFT_ARROW, RIGHT_ARROW, UP_ARROW,} from '@angular/cdk/keycodes'; import {startWith} from '@angular/cdk/rxjs'; import { AfterContentInit, - ChangeDetectorRef, ChangeDetectionStrategy, + ChangeDetectorRef, Component, ContentChildren, ElementRef, @@ -28,21 +31,11 @@ import { ViewEncapsulation, } from '@angular/core'; import {ControlValueAccessor, FormGroupDirective, NgControl, NgForm} from '@angular/forms'; -import { - BACKSPACE, - DELETE, - Directionality, - LEFT_ARROW, - RIGHT_ARROW, - UP_ARROW -} from '@angular/material/core'; import {MdFormFieldControl} from '@angular/material/form-field'; - import {Observable} from 'rxjs/Observable'; import {merge} from 'rxjs/observable/merge'; import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; - import {MdChip, MdChipEvent, MdChipSelectionChange} from './chip'; import {MdChipInput} from './chip-input'; diff --git a/src/lib/chips/chip.spec.ts b/src/lib/chips/chip.spec.ts index 240ceec898d6..51ade187196a 100644 --- a/src/lib/chips/chip.spec.ts +++ b/src/lib/chips/chip.spec.ts @@ -1,10 +1,11 @@ +import {Directionality} from '@angular/cdk/bidi'; +import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes'; +import {createKeyboardEvent} from '@angular/cdk/testing'; +import {Component, DebugElement} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {createKeyboardEvent} from '@angular/cdk/testing'; -import {MdChipList, MdChip, MdChipEvent, MdChipsModule, MdChipSelectionChange} from './index'; -import {SPACE, DELETE, BACKSPACE} from '@angular/material/core'; -import {Directionality} from '@angular/material/core'; +import {MdChip, MdChipEvent, MdChipList, MdChipSelectionChange, MdChipsModule} from './index'; + describe('Chips', () => { let fixture: ComponentFixture; diff --git a/src/lib/chips/chip.ts b/src/lib/chips/chip.ts index a7cdfaebb43b..003e1b9807a1 100644 --- a/src/lib/chips/chip.ts +++ b/src/lib/chips/chip.ts @@ -8,6 +8,7 @@ import {FocusableOption} from '@angular/cdk/a11y'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; +import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes'; import { Directive, ElementRef, @@ -17,17 +18,10 @@ import { Output, Renderer2, } from '@angular/core'; -import { - BACKSPACE, - CanColor, - CanDisable, - DELETE, - mixinColor, - mixinDisabled, - SPACE, -} from '@angular/material/core'; +import {CanColor, CanDisable, mixinColor, mixinDisabled} from '@angular/material/core'; import {Subject} from 'rxjs/Subject'; + export interface MdChipEvent { chip: MdChip; } @@ -41,8 +35,10 @@ export class MdChipSelectionChange { // Boilerplate for applying mixins to MdChip. /** @docs-private */ export class MdChipBase { - constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} + constructor(public _renderer: Renderer2, public _elementRef: ElementRef) { + } } + export const _MdChipMixinBase = mixinColor(mixinDisabled(MdChipBase), 'primary'); @@ -52,9 +48,10 @@ export const _MdChipMixinBase = mixinColor(mixinDisabled(MdChipBase), 'primary') */ @Directive({ selector: `md-basic-chip, [md-basic-chip], mat-basic-chip, [mat-basic-chip]`, - host: {'class': 'mat-basic-chip'} + host: {'class': 'mat-basic-chip'}, }) -export class MdBasicChip { } +export class MdBasicChip { +} /** * Material design styled Chip component. Used inside the MdChipList component. @@ -80,7 +77,7 @@ export class MdBasicChip { } }) export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestroy, CanColor, - CanDisable { + CanDisable { protected _value: any; @@ -95,7 +92,9 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr /** Whether the chip is selected. */ @Input() - get selected(): boolean { return this._selected; } + get selected(): boolean { + return this._selected; + } set selected(value: boolean) { this._selected = coerceBooleanProperty(value); this.selectionChange.emit({ @@ -104,7 +103,6 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr selected: value }); } - /** The value of the chip. Defaults to the content inside tags. */ @Input() get value(): any { @@ -112,22 +110,30 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr ? this._value : this._elementRef.nativeElement.textContent; } - set value(newValue: any) { this._value = newValue; } + set value(newValue: any) { this._value = newValue;} /** * Whether or not the chips are selectable. When a chip is not selectable, * changes to it's selected state are always ignored. */ - @Input() - get selectable(): boolean { return this._selectable; } - set selectable(value: boolean) { this._selectable = coerceBooleanProperty(value); } + @Input() get selectable(): boolean { + return this._selectable;} + + + set selectable(value: boolean) { + this._selectable = coerceBooleanProperty(value); + } /** * Determines whether or not the chip displays the remove styling and emits (remove) events. */ - @Input() - get removable(): boolean { return this._removable; } - set removable(value: boolean) { this._removable = coerceBooleanProperty(value); } + @Input() get removable(): boolean { + return this._removable;} + + + set removable(value: boolean) { + this._removable = coerceBooleanProperty(value); + } /** Emits when the chip is focused. */ _onFocus = new Subject(); @@ -293,11 +299,12 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr selector: '[mdChipRemove], [matChipRemove]', host: { 'class': 'mat-chip-remove', - '(click)': '_handleClick($event)' - } + '(click)': '_handleClick($event)', + }, }) export class MdChipRemove { - constructor(protected _parentChip: MdChip) {} + constructor(protected _parentChip: MdChip) { + } /** Calls the parent chip's public `remove()` method if applicable. */ _handleClick(): void { diff --git a/src/lib/chips/chips.scss b/src/lib/chips/chips.scss index 478caf88d71f..fc1b13a851b5 100644 --- a/src/lib/chips/chips.scss +++ b/src/lib/chips/chips.scss @@ -1,4 +1,4 @@ -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; @import '../core/style/elevation'; $mat-chip-vertical-padding: 7px; diff --git a/src/lib/core/_core.scss b/src/lib/core/_core.scss index b13dd35b4ea4..7ae874518a80 100644 --- a/src/lib/core/_core.scss +++ b/src/lib/core/_core.scss @@ -1,9 +1,9 @@ // We can use relative imports for imports from the cdk because we bundle everything // up into a single flat scss file for material. @import '../../cdk/overlay/overlay'; +@import '../../cdk/a11y/a11y'; // Core styles that can be used to apply material design treatments to any element. -@import 'a11y/a11y'; @import 'style/elevation'; @import 'ripple/ripple'; @import 'option/option'; diff --git a/src/lib/core/a11y/README.md b/src/lib/core/a11y/README.md deleted file mode 100644 index 45e45eac659a..000000000000 --- a/src/lib/core/a11y/README.md +++ /dev/null @@ -1 +0,0 @@ -See [cdk/a11y](../../../cdk/a11y/README.md) diff --git a/src/lib/core/a11y/activedescendant-key-manager.ts b/src/lib/core/a11y/activedescendant-key-manager.ts deleted file mode 100644 index 8ccabcab6c6a..000000000000 --- a/src/lib/core/a11y/activedescendant-key-manager.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {ActiveDescendantKeyManager, Highlightable} from '@angular/cdk/a11y'; diff --git a/src/lib/core/a11y/fake-mousedown.ts b/src/lib/core/a11y/fake-mousedown.ts deleted file mode 100644 index f3d2b68e6827..000000000000 --- a/src/lib/core/a11y/fake-mousedown.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {isFakeMousedownFromScreenReader} from '@angular/cdk/a11y'; diff --git a/src/lib/core/a11y/focus-key-manager.ts b/src/lib/core/a11y/focus-key-manager.ts deleted file mode 100644 index 0a603e1eba27..000000000000 --- a/src/lib/core/a11y/focus-key-manager.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {FocusKeyManager, FocusableOption} from '@angular/cdk/a11y'; diff --git a/src/lib/core/a11y/focus-trap.ts b/src/lib/core/a11y/focus-trap.ts deleted file mode 100644 index 7ee2f473073b..000000000000 --- a/src/lib/core/a11y/focus-trap.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - FocusTrap, - FocusTrapFactory, - FocusTrapDeprecatedDirective, - FocusTrapDirective -} from '@angular/cdk/a11y'; - - - - - diff --git a/src/lib/core/a11y/index.ts b/src/lib/core/a11y/index.ts deleted file mode 100644 index 50ef493946c2..000000000000 --- a/src/lib/core/a11y/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {A11yModule} from '@angular/cdk/a11y'; diff --git a/src/lib/core/a11y/interactivity-checker.ts b/src/lib/core/a11y/interactivity-checker.ts deleted file mode 100644 index def5fa2b1511..000000000000 --- a/src/lib/core/a11y/interactivity-checker.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {InteractivityChecker} from '@angular/cdk/a11y'; diff --git a/src/lib/core/a11y/list-key-manager.ts b/src/lib/core/a11y/list-key-manager.ts deleted file mode 100644 index 8710826427ee..000000000000 --- a/src/lib/core/a11y/list-key-manager.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {ListKeyManagerOption, ListKeyManager} from '@angular/cdk/a11y'; diff --git a/src/lib/core/a11y/live-announcer.ts b/src/lib/core/a11y/live-announcer.ts deleted file mode 100644 index 7965fd4cf102..000000000000 --- a/src/lib/core/a11y/live-announcer.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - AriaLivePoliteness, - LIVE_ANNOUNCER_ELEMENT_TOKEN, - LiveAnnouncer, - LIVE_ANNOUNCER_PROVIDER_FACTORY, - LIVE_ANNOUNCER_PROVIDER -} from '@angular/cdk/a11y'; diff --git a/src/lib/core/bidi/dir.ts b/src/lib/core/bidi/dir.ts deleted file mode 100644 index a264ca5780cb..000000000000 --- a/src/lib/core/bidi/dir.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {Dir} from '@angular/cdk/bidi'; - diff --git a/src/lib/core/bidi/directionality.ts b/src/lib/core/bidi/directionality.ts deleted file mode 100644 index 00f584c8c8ff..000000000000 --- a/src/lib/core/bidi/directionality.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - Direction, - DIR_DOCUMENT, - Directionality, - DIRECTIONALITY_PROVIDER_FACTORY, - DIRECTIONALITY_PROVIDER, -} from '@angular/cdk/bidi'; diff --git a/src/lib/core/bidi/index.ts b/src/lib/core/bidi/index.ts deleted file mode 100644 index df77755789b3..000000000000 --- a/src/lib/core/bidi/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - Directionality, - DIRECTIONALITY_PROVIDER, - DIR_DOCUMENT, - Direction, - Dir, - BidiModule, -} from '@angular/cdk/bidi'; diff --git a/src/lib/core/compatibility/compatibility.spec.ts b/src/lib/core/compatibility/compatibility.spec.ts index 091dad452dfd..b22fe0a9055a 100644 --- a/src/lib/core/compatibility/compatibility.spec.ts +++ b/src/lib/core/compatibility/compatibility.spec.ts @@ -90,10 +90,10 @@ describe('Style compatibility', () => { @Component({ template: `Hungry` }) -class ComponentWithMdCheckbox { } +export class ComponentWithMdCheckbox { } @Component({ template: `Hungry` }) -class ComponentWithMatCheckbox { } +export class ComponentWithMatCheckbox { } @NgModule({ diff --git a/src/lib/core/datetime/native-date-adapter.spec.ts b/src/lib/core/datetime/native-date-adapter.spec.ts index 8ec5202fa151..92371ee0742f 100644 --- a/src/lib/core/datetime/native-date-adapter.spec.ts +++ b/src/lib/core/datetime/native-date-adapter.spec.ts @@ -1,8 +1,8 @@ -import {TestBed, async, inject} from '@angular/core/testing'; -import {NativeDateAdapter, NativeDateModule, DateAdapter, MAT_DATE_LOCALE} from './index'; -import {Platform} from '../platform/index'; -import {DEC, FEB, JAN, MAR} from '../testing/month-constants'; +import {Platform} from '@angular/cdk/platform'; import {LOCALE_ID} from '@angular/core'; +import {async, inject, TestBed} from '@angular/core/testing'; +import {DEC, FEB, JAN, MAR} from '../testing/month-constants'; +import {DateAdapter, MAT_DATE_LOCALE, NativeDateAdapter, NativeDateModule} from './index'; const SUPPORTS_INTL = typeof Intl != 'undefined'; diff --git a/src/lib/core/keyboard/keycodes.ts b/src/lib/core/keyboard/keycodes.ts deleted file mode 100644 index 3aef9a4baa83..000000000000 --- a/src/lib/core/keyboard/keycodes.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - UP_ARROW, - DOWN_ARROW, - RIGHT_ARROW, - LEFT_ARROW, - PAGE_UP, - PAGE_DOWN, - HOME, - END, - ENTER, - SPACE, - TAB, - ESCAPE, - BACKSPACE, - DELETE, - A, - Z, -} from '@angular/cdk/keycodes'; diff --git a/src/lib/core/option/_option.scss b/src/lib/core/option/_option.scss index 4bd536b08e3f..bf9e20c2d3f5 100644 --- a/src/lib/core/option/_option.scss +++ b/src/lib/core/option/_option.scss @@ -1,6 +1,6 @@ @import '../style/menu-common'; @import '../style/vendor-prefixes'; -@import '../a11y/a11y'; +@import '../../../cdk/a11y/a11y'; @import '../style/layout-common'; /** diff --git a/src/lib/core/option/option.ts b/src/lib/core/option/option.ts index baf7353f70b1..8174c0b5f9fc 100644 --- a/src/lib/core/option/option.ts +++ b/src/lib/core/option/option.ts @@ -6,20 +6,20 @@ * found in the LICENSE file at https://angular.io/license */ +import {coerceBooleanProperty} from '@angular/cdk/coercion'; +import {ENTER, SPACE} from '@angular/cdk/keycodes'; import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, - Output, - ViewEncapsulation, Optional, - ChangeDetectionStrategy, - ChangeDetectorRef, + Output, QueryList, + ViewEncapsulation, } from '@angular/core'; -import {ENTER, SPACE} from '../keyboard/keycodes'; -import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {MATERIAL_COMPATIBILITY_MODE} from '../compatibility/compatibility'; import {MdOptgroup} from './optgroup'; diff --git a/src/lib/core/overlay/index.ts b/src/lib/core/overlay/index.ts deleted file mode 100644 index 621bec001c17..000000000000 --- a/src/lib/core/overlay/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 '@angular/cdk/overlay'; diff --git a/src/lib/core/platform/features.ts b/src/lib/core/platform/features.ts deleted file mode 100644 index 04844f624ef6..000000000000 --- a/src/lib/core/platform/features.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {getSupportedInputTypes} from '@angular/cdk/platform'; diff --git a/src/lib/core/platform/index.ts b/src/lib/core/platform/index.ts deleted file mode 100644 index e8f8a33331cc..000000000000 --- a/src/lib/core/platform/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {PlatformModule} from '@angular/cdk/platform'; -export * from './platform'; -export * from './features'; diff --git a/src/lib/core/platform/platform.ts b/src/lib/core/platform/platform.ts deleted file mode 100755 index 648567b59d24..000000000000 --- a/src/lib/core/platform/platform.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {Platform} from '@angular/cdk/platform'; diff --git a/src/lib/core/portal/README.md b/src/lib/core/portal/README.md deleted file mode 100644 index f9e84739173a..000000000000 --- a/src/lib/core/portal/README.md +++ /dev/null @@ -1 +0,0 @@ -See [cdk/portal](../../../cdk/portal/portal.md) diff --git a/src/lib/core/portal/dom-portal-host.ts b/src/lib/core/portal/dom-portal-host.ts deleted file mode 100644 index 45424d674bbd..000000000000 --- a/src/lib/core/portal/dom-portal-host.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {DomPortalHost} from '@angular/cdk/portal'; diff --git a/src/lib/core/portal/portal-directives.ts b/src/lib/core/portal/portal-directives.ts deleted file mode 100644 index e2eed6c434aa..000000000000 --- a/src/lib/core/portal/portal-directives.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {TemplatePortalDirective, PortalHostDirective, PortalModule} from '@angular/cdk/portal'; diff --git a/src/lib/core/portal/portal.ts b/src/lib/core/portal/portal.ts deleted file mode 100644 index 91ac14adaeab..000000000000 --- a/src/lib/core/portal/portal.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - Portal, - PortalHost, - BasePortalHost, - ComponentPortal, - TemplatePortal -} from '@angular/cdk/portal'; diff --git a/src/lib/core/public_api.ts b/src/lib/core/public_api.ts index e0d835d549e8..4a540f7e1cf6 100644 --- a/src/lib/core/public_api.ts +++ b/src/lib/core/public_api.ts @@ -6,9 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -export * from './a11y/index'; export * from './animation/animation'; -export * from './bidi/index'; export * from './common-behaviors/index'; export * from './compatibility/compatibility'; export * from './coordination/unique-selection-dispatcher'; @@ -16,18 +14,10 @@ export * from './datetime/index'; export * from './error/error-options'; export * from './gestures/gesture-annotations'; export * from './gestures/gesture-config'; -export * from './keyboard/keycodes'; export * from './line/line'; export * from './option/index'; -export * from './overlay/index'; export * from './placeholder/placeholder-options'; -export * from './platform/index'; -export * from './portal/portal'; -export * from './portal/dom-portal-host'; -export * from './portal/portal-directives'; -export * from './portal/portal-injector'; export * from './ripple/index'; -export * from './rxjs/index'; export * from './selection/index'; export * from './style/index'; export * from './util/object-extend'; diff --git a/src/lib/core/ripple/_ripple.scss b/src/lib/core/ripple/_ripple.scss index 47623e1497fc..257df0e8ba69 100644 --- a/src/lib/core/ripple/_ripple.scss +++ b/src/lib/core/ripple/_ripple.scss @@ -1,5 +1,5 @@ @import '../theming/theming'; -@import '../a11y/a11y'; +@import '../../../cdk/a11y/a11y'; $mat-ripple-color-opacity: 0.1; diff --git a/src/lib/core/rxjs/index.ts b/src/lib/core/rxjs/index.ts deleted file mode 100644 index a6f22e575d8e..000000000000 --- a/src/lib/core/rxjs/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 './rx-chain'; -export * from './rx-operators'; diff --git a/src/lib/core/rxjs/rx-chain.spec.ts b/src/lib/core/rxjs/rx-chain.spec.ts deleted file mode 100644 index e9bc10ec5401..000000000000 --- a/src/lib/core/rxjs/rx-chain.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {Observable} from 'rxjs/Observable'; -import {of as observableOf} from 'rxjs/observable/of'; -import {RxChain, map, filter, first} from './index'; - -describe('RxChain', () => { - it('should call all of the operators in the chain', () => { - let operators = { map, filter, first }; - - spyOn(operators, 'map'); - spyOn(operators, 'filter'); - spyOn(operators, 'first'); - - RxChain.from(observableOf(1, 2, 3)) - .call(operators.map, i => i * 2) - .call(operators.filter, i => i % 2 === 0) - .call(operators.first); - - expect(operators.map).toHaveBeenCalled(); - expect(operators.filter).toHaveBeenCalled(); - expect(operators.first).toHaveBeenCalled(); - }); - - it('should be able to subscribe', () => { - const spy = jasmine.createSpy('subscription spy'); - - RxChain.from(observableOf(1, 2)) - .call(map, i => i * 2) - .call(first) - .subscribe(spy); - - expect(spy).toHaveBeenCalledWith(2); - }); - - it('should be able to return the result observable', () => { - const chain = RxChain.from(observableOf(1, 2)) - .call(map, i => i * 2) - .call(first); - - expect(chain.result() instanceof Observable).toBe(true); - }); -}); diff --git a/src/lib/core/rxjs/rx-chain.ts b/src/lib/core/rxjs/rx-chain.ts deleted file mode 100644 index fa3f771efcf7..000000000000 --- a/src/lib/core/rxjs/rx-chain.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {RxChain} from '@angular/cdk/rxjs'; diff --git a/src/lib/core/rxjs/rx-operators.ts b/src/lib/core/rxjs/rx-operators.ts deleted file mode 100644 index 864b6be10b2f..000000000000 --- a/src/lib/core/rxjs/rx-operators.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - StrictRxChain, - FinallyBrand, - CatchBrand, - DoBrand, - MapBrand, - FilterBrand, - ShareBrand, - FirstBrand, - SwitchMapBrand, - StartWithBrand, - DebounceTimeBrand, - AuditTimeBrand, - TakeUntilBrand, - finallyOperatorType, - catchOperatorType, - doOperatorType, - mapOperatorType, - filterOperatorType, - shareOperatorType, - firstOperatorType, - switchMapOperatorType, - startWithOperatorType, - debounceTimeOperatorType, - auditTimeOperatorType, - takeUntilOperatorType, - finallyOperator, - catchOperator, - doOperator, - map, - filter, - share, - first, - switchMap, - startWith, - debounceTime, - auditTime, - takeUntil, -} from '@angular/cdk/rxjs'; diff --git a/src/lib/core/style/index.ts b/src/lib/core/style/index.ts index 54ed99b4b68a..c97f88c2e49e 100644 --- a/src/lib/core/style/index.ts +++ b/src/lib/core/style/index.ts @@ -6,20 +6,4 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgModule} from '@angular/core'; -import {A11yModule} from '@angular/cdk/a11y'; - -/** @deprecated */ -@NgModule({ - imports: [A11yModule], - exports: [A11yModule], -}) -export class StyleModule {} - -export { - CdkMonitorFocus, - FocusMonitor, - FOCUS_MONITOR_PROVIDER, - FocusOrigin, -} from '@angular/cdk/a11y'; export * from './apply-transform'; diff --git a/src/lib/datepicker/calendar.spec.ts b/src/lib/datepicker/calendar.spec.ts index 867a44c7616a..686fa406de13 100644 --- a/src/lib/datepicker/calendar.spec.ts +++ b/src/lib/datepicker/calendar.spec.ts @@ -1,11 +1,3 @@ -import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; -import {Component} from '@angular/core'; -import {MdCalendar} from './calendar'; -import {By} from '@angular/platform-browser'; -import {MdMonthView} from './month-view'; -import {MdYearView} from './year-view'; -import {MdCalendarBody} from './calendar-body'; -import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; import { DOWN_ARROW, END, @@ -15,13 +7,33 @@ import { PAGE_DOWN, PAGE_UP, RIGHT_ARROW, - UP_ARROW + UP_ARROW, +} from '@angular/cdk/keycodes'; +import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; +import {Component} from '@angular/core'; +import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; +import { + AUG, + DEC, + FEB, + JAN, + JUL, + JUN, + MAR, + MAY, + MdNativeDateModule, + NoConflictStyleCompatibilityMode, + NOV, + SEP, } from '@angular/material/core'; -import {MdDatepickerIntl} from './datepicker-intl'; -import {MdNativeDateModule} from '@angular/material/core'; -import {NoConflictStyleCompatibilityMode} from '@angular/material/core'; +import {By} from '@angular/platform-browser'; import {MdButtonModule} from '../button/index'; -import {AUG, DEC, FEB, JAN, JUL, NOV, MAR, MAY, JUN, SEP} from '@angular/material/core'; +import {MdCalendar} from './calendar'; +import {MdCalendarBody} from './calendar-body'; +import {MdDatepickerIntl} from './datepicker-intl'; +import {MdMonthView} from './month-view'; +import {MdYearView} from './year-view'; + describe('MdCalendar', () => { beforeEach(async(() => { diff --git a/src/lib/dialog/dialog.scss b/src/lib/dialog/dialog.scss index 8ef8eea9df4c..2f04aec0b4cb 100644 --- a/src/lib/dialog/dialog.scss +++ b/src/lib/dialog/dialog.scss @@ -1,6 +1,6 @@ @import '../core/style/elevation'; @import '../core/style/vendor-prefixes'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; $mat-dialog-padding: 24px !default; diff --git a/src/lib/dialog/dialog.ts b/src/lib/dialog/dialog.ts index 5ff66f717a0b..0fa02226f787 100644 --- a/src/lib/dialog/dialog.ts +++ b/src/lib/dialog/dialog.ts @@ -14,7 +14,7 @@ import { OverlayConfig, ScrollStrategy, } from '@angular/cdk/overlay'; -import {ComponentPortal, ComponentType, TemplatePortal} from '@angular/cdk/portal'; +import {ComponentPortal, ComponentType, PortalInjector, TemplatePortal} from '@angular/cdk/portal'; import {startWith} from '@angular/cdk/rxjs'; import {Location} from '@angular/common'; import { @@ -27,7 +27,7 @@ import { SkipSelf, TemplateRef, } from '@angular/core'; -import {extendObject, PortalInjector} from '@angular/material/core'; +import {extendObject} from '@angular/material/core'; import {Observable} from 'rxjs/Observable'; import {defer} from 'rxjs/observable/defer'; import {Subject} from 'rxjs/Subject'; @@ -35,6 +35,7 @@ import {MdDialogConfig} from './dialog-config'; import {MdDialogContainer} from './dialog-container'; import {MdDialogRef} from './dialog-ref'; + export const MD_DIALOG_DATA = new InjectionToken('MdDialogData'); diff --git a/src/lib/expansion/expansion-panel-header.ts b/src/lib/expansion/expansion-panel-header.ts index e18cfe61a67b..3b0799fef527 100644 --- a/src/lib/expansion/expansion-panel-header.ts +++ b/src/lib/expansion/expansion-panel-header.ts @@ -6,31 +6,25 @@ * found in the LICENSE file at https://angular.io/license */ +import {animate, state, style, transition, trigger} from '@angular/animations'; +import {FocusMonitor} from '@angular/cdk/a11y'; +import {ENTER, SPACE} from '@angular/cdk/keycodes'; +import {filter} from '@angular/cdk/rxjs'; import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, Directive, + ElementRef, Host, - ViewEncapsulation, - ChangeDetectionStrategy, - ChangeDetectorRef, + Input, OnDestroy, Renderer2, - ElementRef, - Input, + ViewEncapsulation, } from '@angular/core'; -import { - trigger, - state, - style, - transition, - animate, -} from '@angular/animations'; -import {SPACE, ENTER} from '@angular/material/core'; -import {MdExpansionPanel, EXPANSION_PANEL_ANIMATION_TIMING} from './expansion-panel'; -import {filter} from '@angular/material/core'; -import {FocusMonitor} from '@angular/cdk/a11y'; import {merge} from 'rxjs/observable/merge'; import {Subscription} from 'rxjs/Subscription'; +import {EXPANSION_PANEL_ANIMATION_TIMING, MdExpansionPanel} from './expansion-panel'; /** diff --git a/src/lib/form-field/form-field-module.ts b/src/lib/form-field/form-field-module.ts index 6cb8d7ccdea8..46f51cd12a8e 100644 --- a/src/lib/form-field/form-field-module.ts +++ b/src/lib/form-field/form-field-module.ts @@ -6,15 +6,15 @@ * found in the LICENSE file at https://angular.io/license */ +import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; +import {PlatformModule} from '@angular/cdk/platform'; import {MdError} from './error'; import {MdFormField} from './form-field'; import {MdHint} from './hint'; import {MdPlaceholder} from './placeholder'; import {MdPrefix} from './prefix'; import {MdSuffix} from './suffix'; -import {CommonModule} from '@angular/common'; -import {PlatformModule} from '@angular/material/core'; @NgModule({ diff --git a/src/lib/icon/icon-registry.ts b/src/lib/icon/icon-registry.ts index 3507ef0f30f0..7ff669fc292d 100644 --- a/src/lib/icon/icon-registry.ts +++ b/src/lib/icon/icon-registry.ts @@ -6,22 +6,16 @@ * found in the LICENSE file at https://angular.io/license */ +import {catchOperator, doOperator, finallyOperator, map, RxChain, share} from '@angular/cdk/rxjs'; import {Injectable, Optional, SecurityContext, SkipSelf} from '@angular/core'; import {Http} from '@angular/http'; -import { - catchOperator, - doOperator, - finallyOperator, - map, - RxChain, - share, -} from '@angular/material/core'; import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser'; import {Observable} from 'rxjs/Observable'; import {forkJoin} from 'rxjs/observable/forkJoin'; import {of as observableOf} from 'rxjs/observable/of'; import {_throw as observableThrow} from 'rxjs/observable/throw'; + /** * Returns an exception to be thrown in the case when attempting to * load an icon with a name that cannot be found. diff --git a/src/lib/icon/icon.ts b/src/lib/icon/icon.ts index f27d46ea5d29..f5a001d0ee01 100644 --- a/src/lib/icon/icon.ts +++ b/src/lib/icon/icon.ts @@ -6,7 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ +import {first} from '@angular/cdk/rxjs'; import { + Attribute, ChangeDetectionStrategy, Component, ElementRef, @@ -16,11 +18,9 @@ import { Renderer2, SimpleChanges, ViewEncapsulation, - Attribute, } from '@angular/core'; -import {MdIconRegistry} from './icon-registry'; import {CanColor, mixinColor} from '@angular/material/core'; -import {first} from '@angular/material/core'; +import {MdIconRegistry} from './icon-registry'; // Boilerplate for applying mixins to MdIcon. diff --git a/src/lib/input/input-module.ts b/src/lib/input/input-module.ts index 0e6f22491e62..c114e4d0c2fe 100644 --- a/src/lib/input/input-module.ts +++ b/src/lib/input/input-module.ts @@ -6,12 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgModule} from '@angular/core'; -import {MdInput} from './input'; -import {MdTextareaAutosize} from './autosize'; +import {PlatformModule} from '@angular/cdk/platform'; import {CommonModule} from '@angular/common'; -import {PlatformModule} from '@angular/material/core'; +import {NgModule} from '@angular/core'; import {MdFormFieldModule} from '@angular/material/form-field'; +import {MdTextareaAutosize} from './autosize'; +import {MdInput} from './input'; @NgModule({ diff --git a/src/lib/input/input.spec.ts b/src/lib/input/input.spec.ts index a960c88017e3..ba534a980a7e 100644 --- a/src/lib/input/input.spec.ts +++ b/src/lib/input/input.spec.ts @@ -1,5 +1,7 @@ +import {Platform, PlatformModule} from '@angular/cdk/platform'; +import {createFakeEvent, dispatchFakeEvent, wrappedErrorMessage} from '@angular/cdk/testing'; +import {ChangeDetectionStrategy, Component, ViewChild} from '@angular/core'; import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; -import {Component, ViewChild, ChangeDetectionStrategy} from '@angular/core'; import { FormControl, FormGroup, @@ -7,24 +9,24 @@ import { FormsModule, NgForm, ReactiveFormsModule, - Validators + Validators, } from '@angular/forms'; -import {By} from '@angular/platform-browser'; -import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdInputModule} from './index'; -import {MdInput} from './input'; -import {Platform} from '@angular/material/core'; -import {PlatformModule} from '@angular/material/core'; -import {wrappedErrorMessage, dispatchFakeEvent, createFakeEvent} from '@angular/cdk/testing'; import { - MdFormField, - MdFormFieldModule, + MD_ERROR_GLOBAL_OPTIONS, + MD_PLACEHOLDER_GLOBAL_OPTIONS, + showOnDirtyErrorStateMatcher, +} from '@angular/material/core'; +import { getMdFormFieldDuplicatedHintError, getMdFormFieldMissingControlError, getMdFormFieldPlaceholderConflictError, + MdFormField, + MdFormFieldModule, } from '@angular/material/form-field'; -import {MD_PLACEHOLDER_GLOBAL_OPTIONS} from '@angular/material/core'; -import {MD_ERROR_GLOBAL_OPTIONS, showOnDirtyErrorStateMatcher} from '@angular/material/core'; +import {By} from '@angular/platform-browser'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {MdInputModule} from './index'; +import {MdInput} from './input'; describe('MdInput without forms', function () { beforeEach(async(() => { diff --git a/src/lib/list/selection-list.spec.ts b/src/lib/list/selection-list.spec.ts index 623cde717a65..bb3752c3fdd9 100644 --- a/src/lib/list/selection-list.spec.ts +++ b/src/lib/list/selection-list.spec.ts @@ -1,10 +1,10 @@ -import {async, TestBed, ComponentFixture, inject} from '@angular/core/testing'; +import {DOWN_ARROW, SPACE, UP_ARROW} from '@angular/cdk/keycodes'; +import {Platform} from '@angular/cdk/platform'; +import {createKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; +import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {MdSelectionList, MdListOption, MdListModule} from './index'; -import {createKeyboardEvent} from '@angular/cdk/testing'; -import {UP_ARROW, DOWN_ARROW, SPACE} from '@angular/material/core'; -import {Platform} from '@angular/material/core'; +import {MdListModule, MdListOption, MdSelectionList} from './index'; describe('MdSelectionList', () => { diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index 2603911a4905..5cd645a33c1d 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -9,6 +9,8 @@ import {FocusableOption, FocusKeyManager} from '@angular/cdk/a11y'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {SelectionModel} from '@angular/cdk/collections'; +import {SPACE} from '@angular/cdk/keycodes'; +import {RxChain, startWith, switchMap} from '@angular/cdk/rxjs'; import { AfterContentInit, ChangeDetectionStrategy, @@ -35,10 +37,6 @@ import { MdLineSetter, mixinDisabled, mixinDisableRipple, - RxChain, - SPACE, - startWith, - switchMap, } from '@angular/material/core'; import {merge} from 'rxjs/observable/merge'; import {Subscription} from 'rxjs/Subscription'; diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index 594de4d5e5e0..aa7d1c8dfef1 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -6,11 +6,20 @@ * found in the LICENSE file at https://angular.io/license */ +import {AnimationEvent} from '@angular/animations'; +import {FocusKeyManager} from '@angular/cdk/a11y'; +import {Direction} from '@angular/cdk/bidi'; +import {ESCAPE, LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes'; +import {RxChain, startWith, switchMap} from '@angular/cdk/rxjs'; import { AfterContentInit, + ChangeDetectionStrategy, Component, ContentChildren, + ElementRef, EventEmitter, + Inject, + InjectionToken, Input, OnDestroy, Output, @@ -18,24 +27,16 @@ import { TemplateRef, ViewChild, ViewEncapsulation, - ElementRef, - ChangeDetectionStrategy, - InjectionToken, - Inject, } from '@angular/core'; -import {AnimationEvent} from '@angular/animations'; -import {MenuPositionX, MenuPositionY} from './menu-positions'; +import {Observable} from 'rxjs/Observable'; +import {merge} from 'rxjs/observable/merge'; +import {Subscription} from 'rxjs/Subscription'; +import {fadeInItems, transformMenu} from './menu-animations'; import {throwMdMenuInvalidPositionX, throwMdMenuInvalidPositionY} from './menu-errors'; import {MdMenuItem} from './menu-item'; -import {FocusKeyManager} from '@angular/cdk/a11y'; import {MdMenuPanel} from './menu-panel'; -import {Subscription} from 'rxjs/Subscription'; -import {transformMenu, fadeInItems} from './menu-animations'; -import {ESCAPE, LEFT_ARROW, RIGHT_ARROW} from '@angular/material/core'; -import {merge} from 'rxjs/observable/merge'; -import {Observable} from 'rxjs/Observable'; -import {Direction} from '@angular/cdk/bidi'; -import {RxChain, startWith, switchMap} from '@angular/cdk/rxjs'; +import {MenuPositionX, MenuPositionY} from './menu-positions'; + /** Default `md-menu` options that can be overridden. */ export interface MdMenuDefaultOptions { diff --git a/src/lib/menu/menu.scss b/src/lib/menu/menu.scss index 04cfcc38a1fa..5fcc8a889650 100644 --- a/src/lib/menu/menu.scss +++ b/src/lib/menu/menu.scss @@ -3,7 +3,7 @@ @import '../core/style/button-common'; @import '../core/style/layout-common'; @import '../core/style/menu-common'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; @import '../core/style/layout-common'; $mat-menu-vertical-padding: 8px !default; diff --git a/src/lib/select/select.scss b/src/lib/select/select.scss index 9b57b49d63ea..1056cef91149 100644 --- a/src/lib/select/select.scss +++ b/src/lib/select/select.scss @@ -2,7 +2,7 @@ @import '../core/style/list-common'; @import '../core/style/variables'; @import '../core/style/vendor-prefixes'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; $mat-select-trigger-height: 30px !default; $mat-select-trigger-min-width: 112px !default; diff --git a/src/lib/sidenav/drawer.scss b/src/lib/sidenav/drawer.scss index 26800af1f258..9d46906c21fd 100644 --- a/src/lib/sidenav/drawer.scss +++ b/src/lib/sidenav/drawer.scss @@ -1,7 +1,7 @@ @import '../core/style/variables'; @import '../core/style/elevation'; @import '../core/style/layout-common'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; // stylelint-disable max-line-length // Mixin that creates a new stacking context. diff --git a/src/lib/sidenav/drawer.ts b/src/lib/sidenav/drawer.ts index 52271e625fc7..ef241cacd3fa 100644 --- a/src/lib/sidenav/drawer.ts +++ b/src/lib/sidenav/drawer.ts @@ -10,6 +10,7 @@ import {animate, AnimationEvent, state, style, transition, trigger} from '@angul import {FocusTrap, FocusTrapFactory} from '@angular/cdk/a11y'; import {Directionality} from '@angular/cdk/bidi'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; +import {ESCAPE} from '@angular/cdk/keycodes'; import { AfterContentInit, ChangeDetectionStrategy, @@ -28,9 +29,11 @@ import { Renderer2, ViewEncapsulation, } from '@angular/core'; -import {ESCAPE, first, startWith, takeUntil} from '@angular/material/core'; import {DOCUMENT} from '@angular/platform-browser'; import {merge} from 'rxjs/observable/merge'; +import {first} from 'rxjs/operator/first'; +import {startWith} from 'rxjs/operator/startWith'; +import {takeUntil} from 'rxjs/operator/takeUntil'; import {Subscription} from 'rxjs/Subscription'; diff --git a/src/lib/slide-toggle/slide-toggle.scss b/src/lib/slide-toggle/slide-toggle.scss index 62f3298d78a4..8fd0e11da000 100644 --- a/src/lib/slide-toggle/slide-toggle.scss +++ b/src/lib/slide-toggle/slide-toggle.scss @@ -2,7 +2,7 @@ @import '../core/ripple/ripple'; @import '../core/style/elevation'; @import '../core/style/vendor-prefixes'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; $mat-slide-toggle-thumb-size: 20px !default; $mat-slide-toggle-bar-border-radius: 8px !default; diff --git a/src/lib/slider/slider-module.ts b/src/lib/slider/slider-module.ts index 2d669c54d4ab..979859b91a12 100644 --- a/src/lib/slider/slider-module.ts +++ b/src/lib/slider/slider-module.ts @@ -6,13 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ +import {A11yModule} from '@angular/cdk/a11y'; +import {BidiModule} from '@angular/cdk/bidi'; +import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; +import {GestureConfig, MdCommonModule} from '@angular/material/core'; import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser'; -import {CommonModule} from '@angular/common'; -import {MdCommonModule, GestureConfig} from '@angular/material/core'; import {MdSlider} from './slider'; -import {BidiModule} from '@angular/material/core'; -import {A11yModule} from '@angular/cdk/a11y'; @NgModule({ diff --git a/src/lib/slider/slider.spec.ts b/src/lib/slider/slider.spec.ts index e8962601f00b..72e0ef7d9a06 100644 --- a/src/lib/slider/slider.spec.ts +++ b/src/lib/slider/slider.spec.ts @@ -1,11 +1,6 @@ -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {Component, DebugElement, ViewChild} from '@angular/core'; -import {By, HAMMER_GESTURE_CONFIG} from '@angular/platform-browser'; -import {MdSlider, MdSliderModule} from './index'; -import {TestGestureConfig} from './test-gesture-config'; -import {BidiModule} from '@angular/material/core'; +import {BidiModule} from '@angular/cdk/bidi'; import { + BACKSPACE, DOWN_ARROW, END, HOME, @@ -14,9 +9,15 @@ import { PAGE_UP, RIGHT_ARROW, UP_ARROW, - BACKSPACE -} from '@angular/material/core'; +} from '@angular/cdk/keycodes'; import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing'; +import {Component, DebugElement, ViewChild} from '@angular/core'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {By, HAMMER_GESTURE_CONFIG} from '@angular/platform-browser'; +import {MdSlider, MdSliderModule} from './index'; +import {TestGestureConfig} from './test-gesture-config'; + describe('MdSlider without forms', () => { let gestureConfig: TestGestureConfig; diff --git a/src/lib/snack-bar/snack-bar-container.scss b/src/lib/snack-bar/snack-bar-container.scss index 164040d9b079..72e1ae221690 100644 --- a/src/lib/snack-bar/snack-bar-container.scss +++ b/src/lib/snack-bar/snack-bar-container.scss @@ -1,4 +1,4 @@ -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; $mat-snack-bar-padding: 14px 24px !default; $mat-snack-bar-min-width: 288px !default; diff --git a/src/lib/snack-bar/snack-bar.ts b/src/lib/snack-bar/snack-bar.ts index e4e3a13a3d86..293e2c903e95 100644 --- a/src/lib/snack-bar/snack-bar.ts +++ b/src/lib/snack-bar/snack-bar.ts @@ -6,16 +6,15 @@ * found in the LICENSE file at https://angular.io/license */ -import {ComponentRef, Injectable, Injector, Optional, SkipSelf } from '@angular/core'; -import {Overlay, OverlayRef, OverlayConfig} from '@angular/cdk/overlay'; -import {ComponentPortal, ComponentType} from '@angular/cdk/portal'; import {LiveAnnouncer} from '@angular/cdk/a11y'; -import {PortalInjector} from '@angular/material/core'; +import {Overlay, OverlayConfig, OverlayRef} from '@angular/cdk/overlay'; +import {ComponentPortal, ComponentType, PortalInjector} from '@angular/cdk/portal'; +import {ComponentRef, Injectable, Injector, Optional, SkipSelf} from '@angular/core'; import {extendObject} from '@angular/material/core'; +import {SimpleSnackBar} from './simple-snack-bar'; import {MD_SNACK_BAR_DATA, MdSnackBarConfig} from './snack-bar-config'; -import {MdSnackBarRef} from './snack-bar-ref'; import {MdSnackBarContainer} from './snack-bar-container'; -import {SimpleSnackBar} from './simple-snack-bar'; +import {MdSnackBarRef} from './snack-bar-ref'; /** diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index d4a5d40b53b1..36038f4d0d70 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -1,19 +1,20 @@ -import {async, ComponentFixture, TestBed, inject} from '@angular/core/testing'; +import {CollectionViewer, DataSource} from '@angular/cdk/collections'; +import {CdkTableModule} from '@angular/cdk/table'; +import {dispatchMouseEvent, wrappedErrorMessage} from '@angular/cdk/testing'; import {Component, ElementRef, ViewChild} from '@angular/core'; +import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdSort, MdSortHeader, Sort, SortDirection, MdSortModule, MdSortHeaderIntl} from './index'; -import {DataSource, CollectionViewer} from '@angular/cdk/collections'; -import {CdkTableModule} from '@angular/cdk/table'; import {Observable} from 'rxjs/Observable'; +import {map} from 'rxjs/operator/map'; +import {MdTableModule} from '../table/index'; +import {MdSort, MdSortHeader, MdSortHeaderIntl, MdSortModule, Sort, SortDirection} from './index'; import { getMdSortDuplicateMdSortableIdError, getMdSortHeaderMissingIdError, - getMdSortHeaderNotContainedWithinMdSortError + getMdSortHeaderNotContainedWithinMdSortError, } from './sort-errors'; -import {wrappedErrorMessage, dispatchMouseEvent} from '@angular/cdk/testing'; -import {map} from '@angular/material/core'; -import {MdTableModule} from '../table/index'; + describe('MdSort', () => { let fixture: ComponentFixture; diff --git a/src/lib/stepper/stepper.spec.ts b/src/lib/stepper/stepper.spec.ts index 5662e317bc89..ec042211fd71 100644 --- a/src/lib/stepper/stepper.spec.ts +++ b/src/lib/stepper/stepper.spec.ts @@ -1,14 +1,15 @@ -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {Directionality} from '@angular/cdk/bidi'; +import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes'; +import {dispatchKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; -import {MdStepperModule} from './index'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms'; +import {MdStepperModule} from './index'; +import {MdHorizontalStepper, MdStepper, MdVerticalStepper} from './stepper'; import {MdStepperNext, MdStepperPrevious} from './stepper-button'; -import {dispatchKeyboardEvent} from '@angular/cdk/testing'; -import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes'; -import {MdStepper, MdHorizontalStepper, MdVerticalStepper} from './stepper'; -import {Directionality} from '@angular/material/core'; + const VALID_REGEX = /valid/; diff --git a/src/lib/tabs/tab-body.spec.ts b/src/lib/tabs/tab-body.spec.ts index bd7592f97a36..cead88350898 100644 --- a/src/lib/tabs/tab-body.spec.ts +++ b/src/lib/tabs/tab-body.spec.ts @@ -1,12 +1,11 @@ -import {Component, ViewChild, TemplateRef, ViewContainerRef} from '@angular/core'; +import {Direction, Directionality} from '@angular/cdk/bidi'; +import {PortalModule, TemplatePortal} from '@angular/cdk/portal'; import {CommonModule} from '@angular/common'; -import {PortalModule} from '@angular/cdk/portal'; -import {async, ComponentFixture, TestBed, flushMicrotasks, fakeAsync} from '@angular/core/testing'; +import {Component, TemplateRef, ViewChild, ViewContainerRef} from '@angular/core'; +import {async, ComponentFixture, fakeAsync, flushMicrotasks, TestBed} from '@angular/core/testing'; +import {MdRippleModule} from '@angular/material/core'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {Direction, Directionality} from '@angular/material/core'; -import {TemplatePortal} from '@angular/material/core'; import {MdTabBody} from './tab-body'; -import {MdRippleModule} from '@angular/material/core'; describe('MdTabBody', () => { diff --git a/src/lib/tabs/tab.ts b/src/lib/tabs/tab.ts index a8499dba0e29..852c9aa84d92 100644 --- a/src/lib/tabs/tab.ts +++ b/src/lib/tabs/tab.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {TemplatePortal} from '@angular/material/core'; +import {TemplatePortal} from '@angular/cdk/portal'; import { ChangeDetectionStrategy, Component, @@ -22,8 +22,9 @@ import { ViewEncapsulation, } from '@angular/core'; import {CanDisable, mixinDisabled} from '@angular/material/core'; -import {MdTabLabel} from './tab-label'; import {Subject} from 'rxjs/Subject'; +import {MdTabLabel} from './tab-label'; + // Boilerplate for applying mixins to MdTab. /** @docs-private */ diff --git a/src/lib/tooltip/tooltip.scss b/src/lib/tooltip/tooltip.scss index 1b69d057673f..e3bb19b162ab 100644 --- a/src/lib/tooltip/tooltip.scss +++ b/src/lib/tooltip/tooltip.scss @@ -1,5 +1,5 @@ @import '../core/style/variables'; -@import '../core/a11y/a11y'; +@import '../../cdk/a11y/a11y'; $mat-tooltip-horizontal-padding: 8px; $mat-tooltip-max-width: 250px; From d914cc4ea13ae7080fd0afe5bb55159caff7796e Mon Sep 17 00:00:00 2001 From: mmalerba Date: Thu, 21 Sep 2017 12:20:52 -0700 Subject: [PATCH 128/575] feat(select): make select work inside form-field (#6488) --- src/demo-app/a11y/select/select-a11y.html | 100 ++- src/demo-app/baseline/baseline-demo.html | 18 +- src/demo-app/dialog/dialog-demo.html | 12 +- src/demo-app/select/select-demo.html | 105 ++- src/demo-app/select/select-demo.scss | 4 + src/demo-app/snack-bar/snack-bar-demo.html | 26 +- src/lib/chips/chip-list.ts | 9 + src/lib/core/option/_option.scss | 8 + src/lib/core/option/option.html | 3 +- src/lib/form-field/_form-field-theme.scss | 33 +- src/lib/form-field/form-field-control.ts | 14 +- src/lib/form-field/form-field.html | 5 +- src/lib/form-field/form-field.scss | 46 +- src/lib/form-field/form-field.ts | 16 +- src/lib/input/input.spec.ts | 24 +- src/lib/input/input.ts | 13 +- src/lib/paginator/paginator.html | 19 +- src/lib/select/_select-theme.scss | 64 +- src/lib/select/public_api.ts | 2 +- src/lib/select/select-animations.ts | 19 - src/lib/select/select.html | 39 +- src/lib/select/select.md | 47 +- src/lib/select/select.scss | 115 +-- src/lib/select/select.spec.ts | 846 ++++++++++-------- src/lib/select/select.ts | 351 ++++---- .../select-form/select-form-example.html | 12 +- .../select-overview-example.html | 12 +- .../tooltip-position-example.html | 18 +- .../kitchen-sink/kitchen-sink.html | 12 +- 29 files changed, 1038 insertions(+), 954 deletions(-) diff --git a/src/demo-app/a11y/select/select-a11y.html b/src/demo-app/a11y/select/select-a11y.html index 26599933be10..4ca8f71378dd 100644 --- a/src/demo-app/a11y/select/select-a11y.html +++ b/src/demo-app/a11y/select/select-a11y.html @@ -2,71 +2,89 @@

Single selection

Select your favorite color

- - - {{ color.label }} - - + + + + {{ color.label }} + + +

Multiple selection

Pick toppings for your pizza

- - - {{ topping.label }} - - + + + + {{ topping.label }} + + +

Grouped options

Pick your Pokemon

- - - - {{ creature.label }} - - - + + + + + {{ creature.label }} + + + +

Colors

- - 2000 - 2100 - + + + 2000 + 2100 + + - - Alaska - Alabama - + + + Alaska + Alabama + + - - English - Spanish - + + + English + Spanish + +
- - Mihiramon - Sandiramon - + + + Mihiramon + Sandiramon + + - - Water - Coke - + + + Water + Coke + + - - Light - Dark - + + + Light + Dark + +
diff --git a/src/demo-app/baseline/baseline-demo.html b/src/demo-app/baseline/baseline-demo.html index fa30ca0d8aaf..ba4568cb36d5 100644 --- a/src/demo-app/baseline/baseline-demo.html +++ b/src/demo-app/baseline/baseline-demo.html @@ -14,9 +14,12 @@ | Text 5 | - - Option - + + + Option + This option is really really really long + + | Text 6 | @@ -42,9 +45,12 @@

| Text 5 | - - Option - + + + Option + This option is really really really long + + | Text 6 | diff --git a/src/demo-app/dialog/dialog-demo.html b/src/demo-app/dialog/dialog-demo.html index 37efd6e028f7..e5d40ad94b34 100644 --- a/src/demo-app/dialog/dialog-demo.html +++ b/src/demo-app/dialog/dialog-demo.html @@ -56,11 +56,13 @@

Dialog backdrop

Other options

- - Start - End - Center - + + + Start + End + Center + +

diff --git a/src/demo-app/select/select-demo.html b/src/demo-app/select/select-demo.html index 8fad21eb8a7c..c673924d5933 100644 --- a/src/demo-app/select/select-demo.html +++ b/src/demo-app/select/select-demo.html @@ -6,13 +6,18 @@ ngModel - - None - - {{ drink.viewValue }} - - + + + None + + {{ drink.viewValue }} + + + local_drink + Pick a drink! + You must make a selection +

Value: {{ currentDrink }}

Touched: {{ drinkControl.touched }}

Dirty: {{ drinkControl.dirty }}

@@ -28,7 +33,9 @@

@@ -42,12 +49,14 @@ Multiple selection - - - {{ creature.viewValue }} - - + + + + {{ creature.viewValue }} + + +

Value: {{ currentPokemon }}

Touched: {{ pokemonControl.touched }}

Dirty: {{ pokemonControl.dirty }}

@@ -68,12 +77,14 @@ Without Angular forms - - None - - {{ creature.viewValue }} - - + + + None + + {{ creature.viewValue }} + + +

Value: {{ currentDigimon }}

@@ -85,14 +96,16 @@ Option groups - - - - {{ creature.viewValue }} - - - + + + + + {{ creature.viewValue }} + + + +
@@ -100,15 +113,17 @@ compareWith - - - {{ drink.viewValue }} - - + + + + {{ drink.viewValue }} + + +

Value: {{ currentDrinkObject | json }}

Touched: {{ drinkObjectControl.touched }}

Dirty: {{ drinkObjectControl.dirty }}

@@ -130,9 +145,11 @@ formControl - - {{ food.viewValue }} - + + + {{ food.viewValue }} + +

Value: {{ foodControl.value }}

Touched: {{ foodControl.touched }}

Dirty: {{ foodControl.dirty }}

@@ -149,9 +166,11 @@ Change event - - {{ creature.viewValue }} - + + + {{ creature.viewValue }} + +

Change event value: {{ latestChangeEvent?.value }}

diff --git a/src/demo-app/select/select-demo.scss b/src/demo-app/select/select-demo.scss index 8380da8d2be2..f87b50cbe96b 100644 --- a/src/demo-app/select/select-demo.scss +++ b/src/demo-app/select/select-demo.scss @@ -7,4 +7,8 @@ margin: 24px; } + .demo-drink-icon { + vertical-align: bottom; + padding-right: 0.25em; + } } diff --git a/src/demo-app/snack-bar/snack-bar-demo.html b/src/demo-app/snack-bar/snack-bar-demo.html index 4d0634e59b74..c2f8171c1cc4 100644 --- a/src/demo-app/snack-bar/snack-bar-demo.html +++ b/src/demo-app/snack-bar/snack-bar-demo.html @@ -5,17 +5,21 @@

SnackBar demo

Position in page:
- - Start - End - Left - Right - Center - - - Top - Bottom - + + + Start + End + Left + Right + Center + + + + + Top + Bottom + +
diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index caa58d318872..487dceacdf3c 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -81,6 +81,7 @@ export class MdChipListChange { }) export class MdChipList implements MdFormFieldControl, ControlValueAccessor, AfterContentInit, OnInit, OnDestroy { + readonly controlType = 'mat-chip-list'; /** * Stream that emits whenever the state of the input changes such that the wrapping `MdFormField` @@ -238,6 +239,10 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor return (!this._chipInput || this._chipInput.empty) && this.chips.length === 0; } + get shouldPlaceholderFloat(): boolean { + return this.empty; + } + /** Whether this chip-list is disabled. */ @Input() get disabled() { return this.ngControl ? this.ngControl.disabled : this._disabled; } @@ -387,6 +392,10 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor this.stateChanges.next(); } + onContainerClick() { + this.focus(); + } + /** * Focuses the the first non-disabled chip in this chip list, or the associated input when there * are no eligible chips. diff --git a/src/lib/core/option/_option.scss b/src/lib/core/option/_option.scss index bf9e20c2d3f5..109f1ecc3d99 100644 --- a/src/lib/core/option/_option.scss +++ b/src/lib/core/option/_option.scss @@ -29,6 +29,14 @@ } } + // Collapses unwanted whitespace created by newlines in code like the following: + // + // {{value}} + // + .mat-option-text { + display: inline-block; + } + .mat-option-ripple { @include mat-fill; diff --git a/src/lib/core/option/option.html b/src/lib/core/option/option.html index a9b7b2e63374..7bf76128c4aa 100644 --- a/src/lib/core/option/option.html +++ b/src/lib/core/option/option.html @@ -3,7 +3,8 @@ [state]="selected ? 'checked' : ''" [disabled]="disabled"> - + +
diff --git a/src/lib/form-field/_form-field-theme.scss b/src/lib/form-field/_form-field-theme.scss index 9576bfa0e29a..010b6b368ce5 100644 --- a/src/lib/form-field/_form-field-theme.scss +++ b/src/lib/form-field/_form-field-theme.scss @@ -14,7 +14,7 @@ // Placeholder colors. Required is used for the `*` star shown in the placeholder. $placeholder-color: mat-color($foreground, secondary-text); - $floating-placeholder-color: mat-color($primary); + $focused-placeholder-color: mat-color($primary); $required-placeholder-color: mat-color($accent); // Underline colors. @@ -38,7 +38,7 @@ } .mat-focused .mat-form-field-placeholder { - color: $floating-placeholder-color; + color: $focused-placeholder-color; &.mat-accent { color: $underline-color-accent; @@ -49,11 +49,8 @@ } } - .mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-placeholder, - .mat-focused .mat-form-field-placeholder.mat-form-field-float { - .mat-form-field-required-marker { - color: $required-placeholder-color; - } + .mat-focused .mat-form-field-required-marker { + color: $required-placeholder-color; } .mat-form-field-underline { @@ -84,7 +81,7 @@ color: $underline-color-warn; &.mat-accent, - &.mat-form-field-float .mat-form-field-required-marker { + .mat-form-field-required-marker { color: $underline-color-warn; } } @@ -109,8 +106,7 @@ translateZ(0.001px); // The tricks above used to smooth out the animation on chrome and firefox actually make things // worse on IE, so we don't include them in the IE version. - -ms-transform: translateY(-$infix-margin-top - $infix-padding) - scale($font-scale); + -ms-transform: translateY(-$infix-margin-top - $infix-padding) scale($font-scale); width: 100% / $font-scale; } @@ -184,11 +180,17 @@ border-top: $infix-margin-top solid transparent; } - .mat-form-field-autofill-control { - &:-webkit-autofill + .mat-form-field-placeholder-wrapper .mat-form-field-float { + .mat-form-field-can-float { + &.mat-form-field-should-float .mat-form-field-placeholder { @include _mat-form-field-placeholder-floating( $subscript-font-scale, $infix-padding, $infix-margin-top); } + + .mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-placeholder-wrapper + .mat-form-field-placeholder { + @include _mat-form-field-placeholder-floating( + $subscript-font-scale, $infix-padding, $infix-margin-top); + } } .mat-form-field-placeholder-wrapper { @@ -198,13 +200,6 @@ .mat-form-field-placeholder { top: $infix-margin-top + $infix-padding; - - // Show the placeholder above the control when it's not empty, or focused. - &.mat-form-field-float:not(.mat-form-field-empty), - .mat-focused &.mat-form-field-float { - @include _mat-form-field-placeholder-floating($subscript-font-scale, - $infix-padding, $infix-margin-top); - } } .mat-form-field-underline { diff --git a/src/lib/form-field/form-field-control.ts b/src/lib/form-field/form-field-control.ts index 98a6ea02089b..8bbf3b6cf12c 100644 --- a/src/lib/form-field/form-field-control.ts +++ b/src/lib/form-field/form-field-control.ts @@ -36,6 +36,9 @@ export abstract class MdFormFieldControl { /** Whether the control is empty. */ readonly empty: boolean; + /** Whether the `MdFormField` label should try to float. */ + readonly shouldPlaceholderFloat: boolean; + /** Whether the control is required. */ readonly required: boolean; @@ -45,9 +48,16 @@ export abstract class MdFormFieldControl { /** Whether the control is in an error state. */ readonly errorState: boolean; + /** + * An optional name for the control type that can be used to distinguish `md-form-field` elements + * based on their control type. The form field will add a class, + * `mat-form-field-type-{{controlType}}` to its root element. + */ + readonly controlType?: string; + /** Sets the list of element IDs that currently describe this control. */ abstract setDescribedByIds(ids: string[]): void; - /** Focuses this control. */ - abstract focus(): void; + /** Handles a click on the control's container. */ + abstract onContainerClick(event: MouseEvent): void; } diff --git a/src/lib/form-field/form-field.html b/src/lib/form-field/form-field.html index 223cb79d0922..4bf46aec7a8a 100644 --- a/src/lib/form-field/form-field.html +++ b/src/lib/form-field/form-field.html @@ -1,5 +1,6 @@
-
+
@@ -15,8 +16,6 @@ [attr.aria-owns]="_control.id" [class.mat-empty]="_control.empty && !_shouldAlwaysFloat" [class.mat-form-field-empty]="_control.empty && !_shouldAlwaysFloat" - [class.mat-float]="_canPlaceholderFloat" - [class.mat-form-field-float]="_canPlaceholderFloat" [class.mat-accent]="color == 'accent'" [class.mat-warn]="color == 'warn'" #placeholder diff --git a/src/lib/form-field/form-field.scss b/src/lib/form-field/form-field.scss index 449f60ecb7db..33de45151f6e 100644 --- a/src/lib/form-field/form-field.scss +++ b/src/lib/form-field/form-field.scss @@ -59,23 +59,7 @@ $mat-form-field-underline-height: 1px !default; display: block; position: relative; flex: auto; -} - -// Pseudo-class for Chrome and Safari auto-fill to move the placeholder to the floating position. -// This is necessary because these browsers do not actually fire any events when a form auto-fill is -// occurring. Once the autofill is committed, a change event happen and the regular md-form-field -// classes take over to fulfill this behaviour. Assumes the autofill is non-empty. -.mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-placeholder-wrapper { - // The control is still technically empty at this point, so we need to hide non-floating - // placeholders to prevent overlapping with the autofilled value. - .mat-form-field-placeholder { - display: none; - } - - .mat-form-field-float { - display: block; - transition: none; - } + min-width: 0; } // Used to hide the placeholder overflow on IE, since IE doesn't take transform into account when @@ -120,12 +104,6 @@ $mat-form-field-underline-height: 1px !default; // Hide the placeholder initially, and only show it when it's floating or the control is empty. display: none; - &.mat-form-field-empty, - &.mat-form-field-float:not(.mat-form-field-empty), - .mat-focused &.mat-form-field-float { - display: block; - } - [dir='rtl'] & { transform-origin: 100% 0; left: auto; @@ -133,6 +111,28 @@ $mat-form-field-underline-height: 1px !default; } } +.mat-form-field-empty.mat-form-field-placeholder, +.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-placeholder { + display: block; +} + +// Pseudo-class for Chrome and Safari auto-fill to move the placeholder to the floating position. +// This is necessary because these browsers do not actually fire any events when a form auto-fill is +// occurring. Once the autofill is committed, a change event happen and the regular md-form-field +// classes take over to fulfill this behaviour. +.mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-placeholder-wrapper + .mat-form-field-placeholder { + // The form field will be considered empty if it is autofilled, and therefore the placeholder will + // be shown. Therefore we need to override it to hidden... + display: none; + + // ...and re-show it only if it's able to float. + .mat-form-field-can-float & { + display: block; + transition: none; + } +} + // Disable the placeholder animation when the control is not empty (this prevents placeholder // animating up when the value is set programmatically). .mat-form-field-placeholder:not(.mat-form-field-empty) { diff --git a/src/lib/form-field/form-field.ts b/src/lib/form-field/form-field.ts index c0644f2abdae..8d320f2f7fbc 100644 --- a/src/lib/form-field/form-field.ts +++ b/src/lib/form-field/form-field.ts @@ -22,7 +22,7 @@ import { Inject, Input, Optional, - QueryList, + QueryList, Renderer2, ViewChild, ViewEncapsulation, } from '@angular/core'; @@ -72,7 +72,12 @@ let nextUniqueId = 0; 'class': 'mat-input-container mat-form-field', '[class.mat-input-invalid]': '_control.errorState', '[class.mat-form-field-invalid]': '_control.errorState', + '[class.mat-form-field-can-float]': '_canPlaceholderFloat', + '[class.mat-form-field-should-float]': '_control.shouldPlaceholderFloat || _shouldAlwaysFloat', '[class.mat-focused]': '_control.focused', + '[class.mat-primary]': 'color == "primary"', + '[class.mat-accent]': 'color == "accent"', + '[class.mat-warn]': 'color == "warn"', '[class.ng-untouched]': '_shouldForward("untouched")', '[class.ng-touched]': '_shouldForward("touched")', '[class.ng-pristine]': '_shouldForward("pristine")', @@ -80,7 +85,6 @@ let nextUniqueId = 0; '[class.ng-valid]': '_shouldForward("valid")', '[class.ng-invalid]': '_shouldForward("invalid")', '[class.ng-pending]': '_shouldForward("pending")', - '(click)': '_control.focus()', }, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, @@ -155,7 +159,9 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten @ContentChildren(MdSuffix) _suffixChildren: QueryList; constructor( - public _elementRef: ElementRef, private _changeDetectorRef: ChangeDetectorRef, + public _elementRef: ElementRef, + private _renderer: Renderer2, + private _changeDetectorRef: ChangeDetectorRef, @Optional() @Inject(MD_PLACEHOLDER_GLOBAL_OPTIONS) placeholderOptions: PlaceholderOptions) { this._placeholderOptions = placeholderOptions ? placeholderOptions : {}; this.floatPlaceholder = this._placeholderOptions.float || 'auto'; @@ -163,6 +169,10 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten ngAfterContentInit() { this._validateControlChild(); + if (this._control.controlType) { + this._renderer.addClass( + this._elementRef.nativeElement, `mat-form-field-type-${this._control.controlType}`); + } // Subscribe to changes in the child control state in order to update the form field UI. startWith.call(this._control.stateChanges, null).subscribe(() => { diff --git a/src/lib/input/input.spec.ts b/src/lib/input/input.spec.ts index ba534a980a7e..5c083fdd825b 100644 --- a/src/lib/input/input.spec.ts +++ b/src/lib/input/input.spec.ts @@ -529,16 +529,16 @@ describe('MdInput without forms', function () { fixture.detectChanges(); let inputEl = fixture.debugElement.query(By.css('input')).nativeElement; - let labelEl = fixture.debugElement.query(By.css('label')).nativeElement; + let formFieldEl = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement; - expect(labelEl.classList).not.toContain('mat-form-field-empty'); - expect(labelEl.classList).toContain('mat-form-field-float'); + expect(formFieldEl.classList).toContain('mat-form-field-can-float'); + expect(formFieldEl.classList).toContain('mat-form-field-should-float'); fixture.componentInstance.shouldFloat = 'auto'; fixture.detectChanges(); - expect(labelEl.classList).toContain('mat-form-field-empty'); - expect(labelEl.classList).toContain('mat-form-field-float'); + expect(formFieldEl.classList).toContain('mat-form-field-can-float'); + expect(formFieldEl.classList).not.toContain('mat-form-field-should-float'); // Update the value of the input. inputEl.value = 'Text'; @@ -546,8 +546,8 @@ describe('MdInput without forms', function () { // Fake behavior of the `(input)` event which should trigger a change detection. fixture.detectChanges(); - expect(labelEl.classList).not.toContain('mat-form-field-empty'); - expect(labelEl.classList).toContain('mat-form-field-float'); + expect(formFieldEl.classList).toContain('mat-form-field-can-float'); + expect(formFieldEl.classList).toContain('mat-form-field-should-float'); }); it('should always float the placeholder when floatPlaceholder is set to true', () => { @@ -555,10 +555,10 @@ describe('MdInput without forms', function () { fixture.detectChanges(); let inputEl = fixture.debugElement.query(By.css('input')).nativeElement; - let labelEl = fixture.debugElement.query(By.css('label')).nativeElement; + let formFieldEl = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement; - expect(labelEl.classList).not.toContain('mat-form-field-empty'); - expect(labelEl.classList).toContain('mat-form-field-float'); + expect(formFieldEl.classList).toContain('mat-form-field-can-float'); + expect(formFieldEl.classList).toContain('mat-form-field-should-float'); fixture.detectChanges(); @@ -568,8 +568,8 @@ describe('MdInput without forms', function () { // Fake behavior of the `(input)` event which should trigger a change detection. fixture.detectChanges(); - expect(labelEl.classList).not.toContain('mat-form-field-empty'); - expect(labelEl.classList).toContain('mat-form-field-float'); + expect(formFieldEl.classList).toContain('mat-form-field-can-float'); + expect(formFieldEl.classList).toContain('mat-form-field-should-float'); }); diff --git a/src/lib/input/input.ts b/src/lib/input/input.ts index 6f02784aee05..85b47dce9dc5 100644 --- a/src/lib/input/input.ts +++ b/src/lib/input/input.ts @@ -55,7 +55,7 @@ let nextUniqueId = 0; 'class': 'mat-input-element mat-form-field-autofill-control', // Native input properties that are overwritten by Angular inputs need to be synced with // the native input element. Otherwise property bindings for those don't work. - '[id]': 'id', + '[attr.id]': 'id', '[placeholder]': 'placeholder', '[disabled]': 'disabled', '[required]': 'required', @@ -92,6 +92,9 @@ export class MdInput implements MdFormFieldControl, OnChanges, OnDestroy, D */ stateChanges = new Subject(); + /** A name for this control that can be used by `md-form-field`. */ + controlType = 'mat-input'; + /** Whether the element is disabled. */ @Input() get disabled() { return this.ngControl ? this.ngControl.disabled : this._disabled; } @@ -129,6 +132,7 @@ export class MdInput implements MdFormFieldControl, OnChanges, OnDestroy, D @Input() errorStateMatcher: ErrorStateMatcher; /** The input element's value. */ + @Input() get value() { return this._elementRef.nativeElement.value; } set value(value: string) { if (value !== this.value) { @@ -197,6 +201,8 @@ export class MdInput implements MdFormFieldControl, OnChanges, OnDestroy, D } } + focus() { this._elementRef.nativeElement.focus(); } + /** Callback for the cases where the focused state of the input changes. */ _focusChanged(isFocused: boolean) { if (isFocused !== this.focused) { @@ -278,9 +284,12 @@ export class MdInput implements MdFormFieldControl, OnChanges, OnDestroy, D !this._isBadInput(); } + // Implemented as part of MdFormFieldControl. + get shouldPlaceholderFloat(): boolean { return this.focused || !this.empty; } + // Implemented as part of MdFormFieldControl. setDescribedByIds(ids: string[]) { this._ariaDescribedby = ids.join(' '); } // Implemented as part of MdFormFieldControl. - focus() { this._elementRef.nativeElement.focus(); } + onContainerClick() { this.focus(); } } diff --git a/src/lib/paginator/paginator.html b/src/lib/paginator/paginator.html index 700efb48faaf..06297e5fb288 100644 --- a/src/lib/paginator/paginator.html +++ b/src/lib/paginator/paginator.html @@ -3,15 +3,16 @@ {{_intl.itemsPerPageLabel}}
- - - {{pageSizeOption}} - - + + + + {{pageSizeOption}} + + +
{{pageSize}}
diff --git a/src/lib/select/_select-theme.scss b/src/lib/select/_select-theme.scss index de7432ff3c30..685f8f2b82a1 100644 --- a/src/lib/select/_select-theme.scss +++ b/src/lib/select/_select-theme.scss @@ -3,17 +3,6 @@ @import '../core/style/form-common'; @import '../core/typography/typography-utils'; -@mixin _mat-select-inner-content-theme($palette) { - $color: mat-color($palette); - - .mat-select-trigger, .mat-select-arrow { - color: $color; - } - - .mat-select-underline { - background-color: $color; - } -} @mixin mat-select-theme($theme) { $foreground: map-get($theme, foreground); @@ -22,25 +11,9 @@ $accent: map-get($theme, accent); $warn: map-get($theme, warn); $is-dark-theme: map-get($theme, is-dark); - $underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.7, 0.42)); - - .mat-select-trigger, - .mat-select-arrow { - color: mat-color($foreground, secondary-text); - } - - .mat-select-underline { - background-color: $underline-color; - } - - [aria-disabled='true'] .mat-select-underline { - // Since this is a dotted line, we need to make it slightly darker to get it to stand out. - @include mat-control-disabled-underline($underline-color); - } .mat-select-disabled .mat-select-value, - .mat-select-arrow, - .mat-select-trigger { + .mat-select-arrow { color: mat-color($foreground, secondary-text); } @@ -58,35 +31,44 @@ } } - .mat-select:focus:not(.mat-select-disabled) { - &.mat-primary { - @include _mat-select-inner-content-theme($primary); - } + .mat-form-field { + &.mat-focused { + &.mat-primary .mat-select-arrow { + color: mat-color($primary); + } + + &.mat-accent .mat-select-arrow { + color: mat-color($accent); + } - &.mat-accent { - @include _mat-select-inner-content-theme($accent); + &.mat-warn .mat-select-arrow { + color: mat-color($warn); + } } - &.mat-select-required .mat-select-placeholder::after { + .mat-select.mat-select-invalid .mat-select-arrow { color: mat-color($warn); } + + .mat-select.mat-select-disabled .mat-select-arrow { + color: mat-color($foreground, secondary-text); + } } - .mat-select:focus:not(.mat-select-disabled).mat-warn, .mat-select-invalid { - @include _mat-select-inner-content-theme($warn); + .mat-select.mat-select-disabled .mat-select-arrow { + color: mat-color($warn); } } @mixin mat-select-typography($config) { - $trigger-font-size: mat-font-size($config, subheading-2); + // The unit-less line-height from the font config. + $line-height: mat-line-height($config, input); .mat-select { - // Reserve enough space for the floating placeholder. - padding-top: $trigger-font-size; font-family: mat-font-family($config); } .mat-select-trigger { - font-size: $trigger-font-size; + height: $line-height * 1em; } } diff --git a/src/lib/select/public_api.ts b/src/lib/select/public_api.ts index ff3282c457e2..01ccc2f3e727 100644 --- a/src/lib/select/public_api.ts +++ b/src/lib/select/public_api.ts @@ -8,5 +8,5 @@ export * from './select-module'; export * from './select'; -export {fadeInContent, transformPanel, transformPlaceholder} from './select-animations'; +export * from './select-animations'; export * from './mat-exports'; diff --git a/src/lib/select/select-animations.ts b/src/lib/select/select-animations.ts index e92230508043..2813519212ef 100644 --- a/src/lib/select/select-animations.ts +++ b/src/lib/select/select-animations.ts @@ -22,25 +22,6 @@ import { * The values below match the implementation of the AngularJS Material md-select animation. */ -/** - * This animation shrinks the placeholder text to 75% of its normal size and translates - * it to either the top left corner (ltr) or top right corner (rtl) of the trigger, - * depending on the text direction of the application. - */ -export const transformPlaceholder: AnimationTriggerMetadata = trigger('transformPlaceholder', [ - state('floating-ltr', style({ - top: '-22px', - left: '-2px', - transform: 'scale(0.75)' - })), - state('floating-rtl', style({ - top: '-22px', - left: '2px', - transform: 'scale(0.75)' - })), - transition('* => *', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)')) -]); - /** * This animation transforms the select's overlay panel on and off the page. * diff --git a/src/lib/select/select.html b/src/lib/select/select.html index e3c5823eea05..9379f0980a2e 100644 --- a/src/lib/select/select.html +++ b/src/lib/select/select.html @@ -1,26 +1,22 @@ -
- {{ placeholder }} - - - +
+
+ + {{'\xa0'}} + {{ triggerValue }} - +
- - +
+ [class.mat-select-panel-done-animating]="_panelDoneAnimating" + [style.font-size.px]="_triggerFontSize">
diff --git a/src/lib/select/select.md b/src/lib/select/select.md index 787c97235e3b..389060fb44c0 100644 --- a/src/lib/select/select.md +++ b/src/lib/select/select.md @@ -1,6 +1,7 @@ `` is a form control for selecting a value from a set of options, similar to the native ` + + + + End Side Drawer +
+ +
+ +
+

My Content

+ +
+
Drawer
+ + +
+ + + + +
+ + +

Drawer Already Opened

+ + + + Drawer + + +
+ +
+
+ +

Dynamic Position Drawer

+ + + Start + End + +
+ + +
+
+ +

Drawer with focus attributes

+ + + + + Link + Focus region start + Link + Initially focused + Focus region end + Link + + + +
+

My Content

+ +
+
Drawer
+ +
+
+
diff --git a/src/demo-app/drawer/drawer-demo.scss b/src/demo-app/drawer/drawer-demo.scss new file mode 100644 index 000000000000..1bf747c0615b --- /dev/null +++ b/src/demo-app/drawer/drawer-demo.scss @@ -0,0 +1,7 @@ +.demo-drawer-container { + border: 3px solid black; +} + +.demo-drawer-content { + padding: 15px; +} diff --git a/src/demo-app/drawer/drawer-demo.ts b/src/demo-app/drawer/drawer-demo.ts new file mode 100644 index 000000000000..87a740988f7e --- /dev/null +++ b/src/demo-app/drawer/drawer-demo.ts @@ -0,0 +1,14 @@ +import {Component, ViewEncapsulation} from '@angular/core'; + + +@Component({ + moduleId: module.id, + selector: 'drawer-demo', + templateUrl: 'drawer-demo.html', + styleUrls: ['drawer-demo.css'], + encapsulation: ViewEncapsulation.None, + preserveWhitespaces: false, +}) +export class DrawerDemo { + invert = false; +} diff --git a/src/demo-app/sidenav/sidenav-demo.html b/src/demo-app/sidenav/sidenav-demo.html index bdddd69c381a..fdc13d483172 100644 --- a/src/demo-app/sidenav/sidenav-demo.html +++ b/src/demo-app/sidenav/sidenav-demo.html @@ -1,87 +1,60 @@ -

Basic Use Case

- - - - Start Side Drawer -
- -
- -
- -
Mode: {{start.mode}}
-
- -
- - - End Side Drawer -
- -
- -
-

My Content

- -
-
Sidenav
- - -
- - - - -
-
- -

Sidenav Already Opened

- - - - Drawer - - -
- -
-
- -

Dynamic Position Sidenav

- - - Start - End - -
- - -
-
- -

Sidenav with focus attributes

- - - - - Link - Focus region start - Link - Initially focused - Focus region end - Link - - - -
-

My Content

- -
-
Sidenav
- -
-
-
+ + +
+ Header + + + Start Side Sidenav +
+ +
+ +
+ +
Mode: {{start.mode}}
+
+ +
Filler Content
+
+ + + End Side Sidenav +
+ +
Filler Content
+
+ + + Header +
+
+ +
+ +
+

Sidenav

+ + + Fixed mode + Sidenav covers header/footer +
+ +
+

Header / Footer

+ Show header + Show footer +
+ +
Filler Content
+
+ Footer +
+
+ Footer +
diff --git a/src/demo-app/sidenav/sidenav-demo.scss b/src/demo-app/sidenav/sidenav-demo.scss index a04b3bb58124..b9b359f85460 100644 --- a/src/demo-app/sidenav/sidenav-demo.scss +++ b/src/demo-app/sidenav/sidenav-demo.scss @@ -1,11 +1,25 @@ -.demo-sidenav-container { - border: 3px solid black; +.demo-sidenav-area { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + display: flex; + flex-direction: column; - .mat-sidenav-focus-trap > .cdk-focus-trap-content { - padding: 10px; + .mat-toolbar { + flex: 0; + } + + .mat-sidenav-container { + flex: 1; } -} -.demo-sidenav-content { - padding: 15px; + .demo-sidenav-content { + padding: 32px; + } + + .demo-filler-content { + padding: 60px; + } } diff --git a/src/demo-app/sidenav/sidenav-demo.ts b/src/demo-app/sidenav/sidenav-demo.ts index 60be081c2a85..37a8873aad82 100644 --- a/src/demo-app/sidenav/sidenav-demo.ts +++ b/src/demo-app/sidenav/sidenav-demo.ts @@ -7,8 +7,16 @@ import {Component, ViewEncapsulation} from '@angular/core'; templateUrl: 'sidenav-demo.html', styleUrls: ['sidenav-demo.css'], encapsulation: ViewEncapsulation.None, - preserveWhitespaces: false, }) export class SidenavDemo { - invert = false; + isLaunched = false; + fillerContent = Array(30); + fixed = false; + coverHeader = false; + showHeader = false; + showFooter = false; + modeIndex = 0; + get mode() { return ['side', 'over', 'push'][this.modeIndex]; } + get fixedTop() { return this.fixed && this.showHeader && !this.coverHeader ? 64 : 0; } + get fixedBottom() { return this.fixed && this.showFooter && !this.coverHeader ? 64 : 0; } } diff --git a/src/lib/sidenav/drawer-container.html b/src/lib/sidenav/drawer-container.html index f305c0545a87..a7f8457f08ca 100644 --- a/src/lib/sidenav/drawer-container.html +++ b/src/lib/sidenav/drawer-container.html @@ -1,8 +1,10 @@
- + -
+ + + -
+ diff --git a/src/lib/sidenav/drawer-transitions.scss b/src/lib/sidenav/drawer-transitions.scss index f14d83784f24..7be6e763b610 100644 --- a/src/lib/sidenav/drawer-transitions.scss +++ b/src/lib/sidenav/drawer-transitions.scss @@ -6,7 +6,7 @@ transition: { duration: $swift-ease-out-duration; timing-function: $swift-ease-out-timing-function; - property: transform, margin-left, margin-right; + property: margin-left, margin-right; } } diff --git a/src/lib/sidenav/drawer.html b/src/lib/sidenav/drawer.html deleted file mode 100644 index 6dbc74306383..000000000000 --- a/src/lib/sidenav/drawer.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/lib/sidenav/drawer.scss b/src/lib/sidenav/drawer.scss index 9d46906c21fd..d3efaa66d351 100644 --- a/src/lib/sidenav/drawer.scss +++ b/src/lib/sidenav/drawer.scss @@ -3,15 +3,21 @@ @import '../core/style/layout-common'; @import '../../cdk/a11y/a11y'; +$mat-drawer-content-z-index: 1; +$mat-drawer-side-drawer-z-index: 2; +$mat-drawer-backdrop-z-index: 3; +$mat-drawer-over-drawer-z-index: 4; + // stylelint-disable max-line-length // Mixin that creates a new stacking context. // see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context // stylelint-enable -@mixin mat-drawer-stacking-context() { +@mixin mat-drawer-stacking-context($z-index:1) { position: relative; - // Use a transform to create a new stacking context. - transform: translate3d(0, 0, 0); + // Use a z-index to create a new stacking context. (We can't use transform because it breaks fixed + // positioning inside of the transformed element). + z-index: $z-index; } .mat-drawer-container { @@ -47,7 +53,7 @@ // Because of the new stacking context, the z-index stack is new and we can use our own // numbers. - z-index: 2; + z-index: $mat-drawer-backdrop-z-index; // We use 'visibility: hidden | visible' because 'display: none' will not animate any // transitions, while visibility will interpolate transitions properly. @@ -65,7 +71,7 @@ } .mat-drawer-content { - @include mat-drawer-stacking-context(); + @include mat-drawer-stacking-context($mat-drawer-content-z-index); display: block; height: 100%; @@ -73,7 +79,7 @@ } .mat-drawer { - @include mat-drawer-stacking-context(); + @include mat-drawer-stacking-context($mat-drawer-over-drawer-z-index); display: block; position: absolute; @@ -83,12 +89,11 @@ min-width: 5vw; outline: 0; box-sizing: border-box; - height: 100%; overflow-y: auto; // TODO(kara): revisit scrolling behavior for drawers transform: translate3d(-100%, 0, 0); &.mat-drawer-side { - z-index: 1; + z-index: $mat-drawer-side-drawer-z-index; } &.mat-drawer-end { @@ -114,3 +119,7 @@ } } } + +.mat-sidenav-fixed { + position: fixed; +} diff --git a/src/lib/sidenav/drawer.spec.ts b/src/lib/sidenav/drawer.spec.ts index 6d0a5171a06b..d858a6a2d8a1 100644 --- a/src/lib/sidenav/drawer.spec.ts +++ b/src/lib/sidenav/drawer.spec.ts @@ -76,6 +76,8 @@ describe('MdDrawer', () => { it('should emit the backdropClick event when the backdrop is clicked', fakeAsync(() => { let fixture = TestBed.createComponent(BasicTestApp); + fixture.detectChanges(); + let testComponent: BasicTestApp = fixture.debugElement.componentInstance; let openButtonElement = fixture.debugElement.query(By.css('.open')).nativeElement; diff --git a/src/lib/sidenav/drawer.ts b/src/lib/sidenav/drawer.ts index ef241cacd3fa..3d306303fac0 100644 --- a/src/lib/sidenav/drawer.ts +++ b/src/lib/sidenav/drawer.ts @@ -16,9 +16,11 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + ContentChild, ContentChildren, ElementRef, EventEmitter, + forwardRef, Inject, Input, NgZone, @@ -34,6 +36,7 @@ import {merge} from 'rxjs/observable/merge'; import {first} from 'rxjs/operator/first'; import {startWith} from 'rxjs/operator/startWith'; import {takeUntil} from 'rxjs/operator/takeUntil'; +import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; @@ -51,6 +54,42 @@ export class MdDrawerToggleResult { constructor(public type: 'open' | 'close', public animationFinished: boolean) {} } + +@Component({ + moduleId: module.id, + selector: 'md-drawer-content, mat-drawer-content', + template: '', + host: { + 'class': 'mat-drawer-content', + '[style.marginLeft.px]': '_margins.left', + '[style.marginRight.px]': '_margins.right', + }, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, + preserveWhitespaces: false, +}) +export class MdDrawerContent implements AfterContentInit { + /** + * Margins to be applied to the content. These are used to push / shrink the drawer content when a + * drawer is open. We use margin rather than transform even for push mode because transform breaks + * fixed position elements inside of the transformed element. + */ + _margins: {left: number, right: number} = {left: 0, right: 0}; + + constructor( + private _changeDetectorRef: ChangeDetectorRef, + @Inject(forwardRef(() => MdDrawerContainer)) private _container: MdDrawerContainer) { + } + + ngAfterContentInit() { + this._container._contentMargins.subscribe(margins => { + this._margins = margins; + this._changeDetectorRef.markForCheck(); + }); + } +} + + /** * component. * @@ -61,7 +100,7 @@ export class MdDrawerToggleResult { @Component({ moduleId: module.id, selector: 'md-drawer, mat-drawer', - templateUrl: 'drawer.html', + template: '', animations: [ trigger('transform', [ state('open, open-instant', style({ @@ -121,7 +160,13 @@ export class MdDrawer implements AfterContentInit, OnDestroy { set align(value) { this.position = value; } /** Mode of the drawer; one of 'over', 'push' or 'side'. */ - @Input() mode: 'over' | 'push' | 'side' = 'over'; + @Input() + get mode() { return this._mode; } + set mode(value) { + this._mode = value; + this._modeChanged.next(); + } + private _mode: 'over' | 'push' | 'side' = 'over'; /** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */ @Input() @@ -160,6 +205,12 @@ export class MdDrawer implements AfterContentInit, OnDestroy { /** @deprecated */ @Output('align-changed') onAlignChanged = new EventEmitter(); + /** + * An observable that emits when the drawer mode changes. This is used by the drawer container to + * to know when to when the mode changes so it can adapt the margins on the content. + */ + _modeChanged = new Subject(); + get isFocusTrapEnabled() { // The focus trap is only enabled when the drawer is open in any mode other than side. return this.opened && this.mode !== 'side'; @@ -298,6 +349,7 @@ export class MdDrawer implements AfterContentInit, OnDestroy { } } + /** * component. * @@ -322,6 +374,8 @@ export class MdDrawer implements AfterContentInit, OnDestroy { export class MdDrawerContainer implements AfterContentInit, OnDestroy { @ContentChildren(MdDrawer) _drawers: QueryList; + @ContentChild(MdDrawerContent) _content: MdDrawerContent; + /** The drawer child with the `start` position. */ get start() { return this._start; } @@ -347,8 +401,7 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy { /** Subscription to the Directionality change EventEmitter. */ private _dirChangeSubscription = Subscription.EMPTY; - /** Inline styles to be applied to the container. */ - _styles: { marginLeft: string; marginRight: string; transform: string; }; + _contentMargins = new Subject<{left: number, right: number}>(); constructor(@Optional() private _dir: Directionality, private _element: ElementRef, private _renderer: Renderer2, private _ngZone: NgZone, @@ -366,6 +419,7 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy { this._drawers.forEach((drawer: MdDrawer) => { this._watchDrawerToggle(drawer); this._watchDrawerPosition(drawer); + this._watchDrawerMode(drawer); }); }); } @@ -394,7 +448,7 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy { // Set the transition class on the container so that the animations occur. This should not // be set initially because animations should only be triggered via a change in state. this._renderer.addClass(this._element.nativeElement, 'mat-drawer-transition'); - this._updateStyles(); + this._updateContentMargins(); this._changeDetectorRef.markForCheck(); }); @@ -421,6 +475,16 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy { }); } + /** Subscribes to changes in drawer mode so we can run change detection. */ + private _watchDrawerMode(drawer: MdDrawer): void { + if (drawer) { + takeUntil.call(drawer._modeChanged, this._drawers.changes).subscribe(() => { + this._updateContentMargins(); + this._changeDetectorRef.markForCheck(); + }); + } + } + /** Toggles the 'mat-drawer-opened' class on the main 'md-drawer-container' element. */ private _setContainerClass(isAdd: boolean): void { if (isAdd) { @@ -483,29 +547,40 @@ export class MdDrawerContainer implements AfterContentInit, OnDestroy { } /** - * Return the width of the drawer, if it's in the proper mode and opened. - * This may relayout the view, so do not call this often. - * @param drawer - * @param mode + * Recalculates and updates the inline styles for the content. Note that this should be used + * sparingly, because it causes a reflow. */ - private _getDrawerEffectiveWidth(drawer: MdDrawer, mode: string): number { - return (this._isDrawerOpen(drawer) && drawer.mode == mode) ? drawer._width : 0; - } + private _updateContentMargins() { + // 1. For drawers in `over` mode, they don't affect the content. + // 2. For drawers in `side` mode they should shrink the content. We do this by adding to the + // left margin (for left drawer) or right margin (for right the drawer). + // 3. For drawers in `push` mode the should shift the content without resizing it. We do this by + // adding to the left or right margin and simultaneously subtracting the same amount of + // margin from the other side. + + let left = 0; + let right = 0; + + if (this._left && this._left.opened) { + if (this._left.mode == 'side') { + left += this._left._width; + } else if (this._left.mode == 'push') { + let width = this._left._width; + left += width; + right -= width; + } + } - /** - * Recalculates and updates the inline styles. Note that this - * should be used sparingly, because it causes a reflow. - */ - private _updateStyles() { - const marginLeft = this._left ? this._getDrawerEffectiveWidth(this._left, 'side') : 0; - const marginRight = this._right ? this._getDrawerEffectiveWidth(this._right, 'side') : 0; - const leftWidth = this._left ? this._getDrawerEffectiveWidth(this._left, 'push') : 0; - const rightWidth = this._right ? this._getDrawerEffectiveWidth(this._right, 'push') : 0; - - this._styles = { - marginLeft: `${marginLeft}px`, - marginRight: `${marginRight}px`, - transform: `translate3d(${leftWidth - rightWidth}px, 0, 0)` - }; + if (this._right && this._right.opened) { + if (this._right.mode == 'side') { + right += this._right._width; + } else if (this._right.mode == 'push') { + let width = this._right._width; + right += width; + left -= width; + } + } + + this._contentMargins.next({left, right}); } } diff --git a/src/lib/sidenav/sidenav-container.html b/src/lib/sidenav/sidenav-container.html new file mode 100644 index 000000000000..7068bbdf4382 --- /dev/null +++ b/src/lib/sidenav/sidenav-container.html @@ -0,0 +1,10 @@ +
+ + + + + + + + diff --git a/src/lib/sidenav/sidenav-module.ts b/src/lib/sidenav/sidenav-module.ts index 16f14d9d98fc..577f9205826c 100644 --- a/src/lib/sidenav/sidenav-module.ts +++ b/src/lib/sidenav/sidenav-module.ts @@ -6,18 +6,33 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; import {A11yModule} from '@angular/cdk/a11y'; import {OverlayModule} from '@angular/cdk/overlay'; +import {CommonModule} from '@angular/common'; +import {NgModule} from '@angular/core'; import {MdCommonModule} from '@angular/material/core'; -import {MdDrawer, MdDrawerContainer} from './drawer'; -import {MdSidenav, MdSidenavContainer} from './sidenav'; +import {MdDrawer, MdDrawerContainer, MdDrawerContent} from './drawer'; +import {MdSidenav, MdSidenavContainer, MdSidenavContent} from './sidenav'; @NgModule({ imports: [CommonModule, MdCommonModule, A11yModule, OverlayModule], - exports: [MdDrawerContainer, MdDrawer, MdSidenavContainer, MdSidenav, MdCommonModule], - declarations: [MdDrawerContainer, MdDrawer, MdSidenavContainer, MdSidenav], + exports: [ + MdCommonModule, + MdDrawer, + MdDrawerContainer, + MdDrawerContent, + MdSidenav, + MdSidenavContainer, + MdSidenavContent, + ], + declarations: [ + MdDrawer, + MdDrawerContainer, + MdDrawerContent, + MdSidenav, + MdSidenavContainer, + MdSidenavContent, + ], }) export class MdSidenavModule {} diff --git a/src/lib/sidenav/sidenav.spec.ts b/src/lib/sidenav/sidenav.spec.ts new file mode 100644 index 000000000000..0de4571a2638 --- /dev/null +++ b/src/lib/sidenav/sidenav.spec.ts @@ -0,0 +1,67 @@ +import {Component} from '@angular/core'; +import {async, TestBed, ComponentFixture} from '@angular/core/testing'; +import {MdSidenav, MdSidenavModule} from './index'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; +import {By} from '@angular/platform-browser'; + + +describe('MdSidenav', () => { + let fixture: ComponentFixture; + let sidenavEl: HTMLElement; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [MdSidenavModule, NoopAnimationsModule], + declarations: [SidenavWithFixedPosition], + }); + + TestBed.compileComponents(); + + fixture = TestBed.createComponent(SidenavWithFixedPosition); + fixture.detectChanges(); + + sidenavEl = fixture.debugElement.query(By.directive(MdSidenav)).nativeElement; + })); + + it('should be fixed position when in fixed mode', () => { + expect(sidenavEl.classList).toContain('mat-sidenav-fixed'); + + fixture.componentInstance.fixed = false; + fixture.detectChanges(); + + expect(sidenavEl.classList).not.toContain('mat-sidenav-fixed'); + }); + + it('should set fixed bottom and top when in fixed mode', () => { + expect(sidenavEl.style.top).toBe('20px'); + expect(sidenavEl.style.bottom).toBe('30px'); + + fixture.componentInstance.fixed = false; + fixture.detectChanges(); + + expect(sidenavEl.style.top).toBeFalsy(); + expect(sidenavEl.style.bottom).toBeFalsy(); + }); +}); + + +@Component({ + template: ` + + + Drawer. + + + Some content. + + `, +}) +class SidenavWithFixedPosition { + fixed = true; + fixedTop = 20; + fixedBottom = 30; +} diff --git a/src/lib/sidenav/sidenav.ts b/src/lib/sidenav/sidenav.ts index 12e8b925bcfa..aff0a5b25137 100644 --- a/src/lib/sidenav/sidenav.ts +++ b/src/lib/sidenav/sidenav.ts @@ -7,19 +7,42 @@ */ import { - ChangeDetectionStrategy, - Component, - ContentChildren, + ChangeDetectionStrategy, ChangeDetectorRef, + Component, ContentChild, + ContentChildren, forwardRef, Inject, Input, ViewEncapsulation } from '@angular/core'; -import {MdDrawer, MdDrawerContainer} from './drawer'; +import {MdDrawer, MdDrawerContainer, MdDrawerContent} from './drawer'; import {animate, state, style, transition, trigger} from '@angular/animations'; +import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; + + +@Component({ + moduleId: module.id, + selector: 'md-sidenav-content, mat-sidenav-content', + template: '', + host: { + 'class': 'mat-drawer-content mat-sidenav-content', + '[style.marginLeft.px]': '_margins.left', + '[style.marginRight.px]': '_margins.right', + }, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, + preserveWhitespaces: false, +}) +export class MdSidenavContent extends MdDrawerContent { + constructor( + changeDetectorRef: ChangeDetectorRef, + @Inject(forwardRef(() => MdSidenavContainer)) container: MdSidenavContainer) { + super(changeDetectorRef, container); + } +} @Component({ moduleId: module.id, selector: 'md-sidenav, mat-sidenav', - templateUrl: 'drawer.html', + template: '', animations: [ trigger('transform', [ state('open, open-instant', style({ @@ -36,6 +59,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations'; ], host: { 'class': 'mat-drawer mat-sidenav', + 'tabIndex': '-1', '[@transform]': '_animationState', '(@transform.start)': '_onAnimationStart()', '(@transform.done)': '_onAnimationEnd($event)', @@ -46,19 +70,45 @@ import {animate, state, style, transition, trigger} from '@angular/animations'; '[class.mat-drawer-over]': 'mode === "over"', '[class.mat-drawer-push]': 'mode === "push"', '[class.mat-drawer-side]': 'mode === "side"', - 'tabIndex': '-1', + '[class.mat-sidenav-fixed]': 'fixedInViewport', + '[style.top.px]': 'fixedInViewport ? fixedTopGap : null', + '[style.bottom.px]': 'fixedInViewport ? fixedBottomGap : null', }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdSidenav extends MdDrawer {} +export class MdSidenav extends MdDrawer { + /** Whether the sidenav is fixed in the viewport. */ + @Input() + get fixedInViewport() { return this._fixedInViewport; } + set fixedInViewport(value) { this._fixedInViewport = coerceBooleanProperty(value); } + private _fixedInViewport = false; + + /** + * The gap between the top of the sidenav and the top of the viewport when the sidenav is in fixed + * mode. + */ + @Input() + get fixedTopGap() { return this._fixedTopGap; } + set fixedTopGap(value) { this._fixedTopGap = coerceNumberProperty(value); } + private _fixedTopGap = 0; + + /** + * The gap between the bottom of the sidenav and the bottom of the viewport when the sidenav is in + * fixed mode. + */ + @Input() + get fixedBottomGap() { return this._fixedBottomGap; } + set fixedBottomGap(value) { this._fixedBottomGap = coerceNumberProperty(value); } + private _fixedBottomGap = 0; +} @Component({ moduleId: module.id, selector: 'md-sidenav-container, mat-sidenav-container', - templateUrl: 'drawer-container.html', + templateUrl: 'sidenav-container.html', styleUrls: [ 'drawer.css', 'drawer-transitions.css', @@ -72,4 +122,6 @@ export class MdSidenav extends MdDrawer {} }) export class MdSidenavContainer extends MdDrawerContainer { @ContentChildren(MdSidenav) _drawers; + + @ContentChild(MdSidenavContent) _content; } From 3571f68a2de0833ee4741af8a0eb24d1da174f38 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Thu, 21 Sep 2017 15:18:57 -0700 Subject: [PATCH 131/575] chore: add changelog for beta.11 (#7239) --- CHANGELOG.md | 136 ++++++++++++++++++ package-lock.json | 62 ++++---- .../stepper-overview-example.html | 1 - tools/dgeni/index.js | 1 + 4 files changed, 168 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e330f4ecb0c..530770803df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,139 @@ + +# [2.0.0-beta.11 carapace-parapet](https://github.com/angular/material2/compare/2.0.0-beta.10...2.0.0-beta.11) (2017-09-21) + + +### Highlights +* Each `@angular/material` component is now bundled into its own javascript file. This will allow +tools like webpack to more easily load _only_ the components being used in an application. +* New stepper component! The base behavior lives in `@angular/cdk` with Material Design flavors in +`@angular/material`. + + +### Breaking changes + +* Angular Material now requires **Angular 4.4.3 or greater** +* `MaterialModule` has been removed. ([cf1ece0](https://github.com/angular/material2/commit/cf1ece0)) (#6803) +[See the deprecation notice from beta.3 for more information](https://github.com/angular/material2/blob/master/CHANGELOG.md#materialmodule). +* `MdCoreModule` has been removed. Most of its functionality has been moved to `@angular/cdk` over +the last few releases. +* `FocusOriginMonitor` has been renamed to `FocusMonitor` and moved to `@angular/cdk`. +* **chip-list:** The outputs `select` and `deselect` have been removed in favor of a single + `onSelectionChange` output. +* **overlay:** OverlayState has been renamed to OverlayConfig +* **overlay:** Now that the Overlay is part of the cdk rather than Angular Material directly, +the `themeClass` property has been removed. To add a class to the +overlay for theming, you can do +```ts +overlayContainer.getContainerElement().classList.add('my-theme-class'); +``` +* DateAdapter method `getISODateString` has been renamed to `toIso8601` and a new method +`fromIso8601` has been added. + + +### Deprecation of "md" prefix. + +In earlier betas, we've had a compatibility mode that allowed people to use either "md" or "mat" +as the selector for Angular Material components. This was created so that these components could +live side-by-side with [AngularJS Material](https://material.angularjs.org) without CSS from +the two libraries colliding. + +For beta.11, we've made the decision to deprecate the "md" prefix completely and use "mat" moving +forward. This affects all class names, properties, inputs, outputs, and selectors (CSS classes were +changed back in February). The "md" prefixes will be removed in the next beta release. + +[You can automatically update your projects with the angular-material-prefix-updater tool.](https://www.npmjs.com/package/angular-material-prefix-updater) +Check out the tool's page for instructions on how to run. + +#### Why are we doing this? +We like the "md" prefix too! We added compatibility mode in order to keep "md" around, but over +time we found that there were too many downsides to continue supporting both prefixes at the same +time: +* Many users found the fact that the CSS used "mat" while templates used "md" confusing. +* Users in compatibility mode found that having "mat" in their templates while TypeScript class +names remained "Md" to be unfriendly. +* Making both prefixes available consistently through templates required [adding many +getters/setters that aliased the "true" property](https://github.com/angular/material2/blob/1cfce8d9ab047d447465bd4e233fd26893830328/src/lib/tooltip/tooltip.ts#L171-L198). +This ends up increasing payload size and complexity of the source code. +* Compatiblity mode itself used [broad directive selectors](https://github.com/angular/material2/blob/87318bc7c83d249036837376609ea099e5aea2d9/src/lib/core/compatibility/compatibility.ts#L107-L187) +to enforce that only one prefix was used at a time. This causes a problem where this broad selector +prevents Angular from throwing an error if an application uses a component without importing its +`NgModule`. + +#### Why not change the styles in AngularJS Material? +We explored this option early on (before creating compatibility mode). We found that changing the +library's styles such that they wouldn't affect the Angular Material components would increase +the specificity. This would have been a significant breaking change, as it would have potentially +broken countless custom styles that relied on a particular specificity working. + + +### Bug Fixes + +* **autocomplete,select:** inconsistent disabled option coloring ([#6640](https://github.com/angular/material2/issues/6640)) ([454781d](https://github.com/angular/material2/commit/454781d)), closes [#6638](https://github.com/angular/material2/issues/6638) +* **autosize:** not resizing on programmatic changes ([#6654](https://github.com/angular/material2/issues/6654)) ([89fea50](https://github.com/angular/material2/commit/89fea50)), closes [#5247](https://github.com/angular/material2/issues/5247) +* **button-toggle:** border radius ignored if option is selected ([#6699](https://github.com/angular/material2/issues/6699)) ([82e14f8](https://github.com/angular/material2/commit/82e14f8)), closes [#6689](https://github.com/angular/material2/issues/6689) +* **checkbox:** label content should not wrap ([#6674](https://github.com/angular/material2/issues/6674)) ([9acab86](https://github.com/angular/material2/commit/9acab86)), closes [#6671](https://github.com/angular/material2/issues/6671) +* **chips:** set appropriate aria-orientation ([#6464](https://github.com/angular/material2/issues/6464)) ([a37aa6a](https://github.com/angular/material2/commit/a37aa6a)) +* **datepicker:** allow date or datetime strings in fromIso8601 ([#7220](https://github.com/angular/material2/issues/7220)) ([8436f8c](https://github.com/angular/material2/commit/8436f8c)) +* **datepicker:** allow ISO 8601 strings as inputs ([#7091](https://github.com/angular/material2/issues/7091)) ([d2ceb2c](https://github.com/angular/material2/commit/d2ceb2c)) +* **datepicker:** backdrop class should be mat- ([#7056](https://github.com/angular/material2/issues/7056)) ([2b61eb6](https://github.com/angular/material2/commit/2b61eb6)) +* **datepicker:** Create a new injection token to avoid overriding LOCALE_ID ([#6708](https://github.com/angular/material2/issues/6708)) ([2635cad](https://github.com/angular/material2/commit/2635cad)) +* **datepicker:** fix wrong datepicker-input value for non MM/DD/YYYY locales ([#6798](https://github.com/angular/material2/issues/6798)) ([29399b8](https://github.com/angular/material2/commit/29399b8)) +* **datepicker:** makes sure the datepickerInput is registered ([#7049](https://github.com/angular/material2/issues/7049)) ([e4d48d7](https://github.com/angular/material2/commit/e4d48d7)) +* **datepicker:** toggle not reacting to disabled state changes in datepicker or input ([#6964](https://github.com/angular/material2/issues/6964)) ([85993d3](https://github.com/angular/material2/commit/85993d3)) +* **expansion-panel:** dark theme header hover color ([#6616](https://github.com/angular/material2/issues/6616)) ([21c68ad](https://github.com/angular/material2/commit/21c68ad)) +* **form-field:** add aria-owns to label element ([#6683](https://github.com/angular/material2/issues/6683)) ([4191b4d](https://github.com/angular/material2/commit/4191b4d)) +* **form-field:** placeholder not floating if autofilled ([#6839](https://github.com/angular/material2/issues/6839)) ([602a861](https://github.com/angular/material2/commit/602a861)), closes [#6837](https://github.com/angular/material2/issues/6837) +* **grid-list:** avoid unnecessary calc declarations ([#6745](https://github.com/angular/material2/issues/6745)) ([255611b](https://github.com/angular/material2/commit/255611b)) +* **grid-list:** styles not cleared when switching to a different styling mode ([#6660](https://github.com/angular/material2/issues/6660)) ([87d607e](https://github.com/angular/material2/commit/87d607e)), closes [#4047](https://github.com/angular/material2/issues/4047) +* **input:** remove resize handle from non-textarea inputs ([#6768](https://github.com/angular/material2/issues/6768)) ([1272f03](https://github.com/angular/material2/commit/1272f03)), closes [#6757](https://github.com/angular/material2/issues/6757) +* **list:** subheader margin being overwritten by typography ([#6735](https://github.com/angular/material2/issues/6735)) ([efe483a](https://github.com/angular/material2/commit/efe483a)) +* **menu:** multiple close events for a single close ([#6961](https://github.com/angular/material2/issues/6961)) ([1cccd4b](https://github.com/angular/material2/commit/1cccd4b)) +* **menu:** nested menu hover not working when trigger is added lazily ([#6807](https://github.com/angular/material2/issues/6807)) ([6b5100b](https://github.com/angular/material2/commit/6b5100b)), closes [#6731](https://github.com/angular/material2/issues/6731) +* **menu:** nested trigger staying highlighted after click ([#6853](https://github.com/angular/material2/issues/6853)) ([04bf3d1](https://github.com/angular/material2/commit/04bf3d1)), closes [#6838](https://github.com/angular/material2/issues/6838) +* **overlay:** rename OverlayState to OverlayConfig ([#6972](https://github.com/angular/material2/issues/6972)) ([1cfce8d](https://github.com/angular/material2/commit/1cfce8d)) +* **progress-bar:** query mode not reversing direction in rtl ([#6922](https://github.com/angular/material2/issues/6922)) ([8a21881](https://github.com/angular/material2/commit/8a21881)) +* **select:** extra whitespace around placeholder ([#6955](https://github.com/angular/material2/issues/6955)) ([9fe6386](https://github.com/angular/material2/commit/9fe6386)), closes [#6923](https://github.com/angular/material2/issues/6923) +* **selection-list:** do not coerece option value to boolean ([#6983](https://github.com/angular/material2/issues/6983)) ([dfe01f2](https://github.com/angular/material2/commit/dfe01f2)) +* **selection-list:** proper style for disabled options ([#6829](https://github.com/angular/material2/issues/6829)) ([547d11f](https://github.com/angular/material2/commit/547d11f)) +* **slide-toggle:** remove side-margin if slide-toggle label is empty ([#6881](https://github.com/angular/material2/issues/6881)) ([a1ec81a](https://github.com/angular/material2/commit/a1ec81a)), closes [#6868](https://github.com/angular/material2/issues/6868) +* **slide-toggle:** support native tabindex attribute ([#6613](https://github.com/angular/material2/issues/6613)) ([8f9f3c8](https://github.com/angular/material2/commit/8f9f3c8)) +* **slider:** thumb disappearing on disabled element with thumb label ([#6641](https://github.com/angular/material2/issues/6641)) ([8243b16](https://github.com/angular/material2/commit/8243b16)), closes [#6631](https://github.com/angular/material2/issues/6631) +* **slider:** update styles when focus and dir change ([#6700](https://github.com/angular/material2/issues/6700)) ([8c49422](https://github.com/angular/material2/commit/8c49422)) +* **slider, drawer:** unsubscribe from directionaly change subject ([#6907](https://github.com/angular/material2/issues/6907)) ([a7ce31e](https://github.com/angular/material2/commit/a7ce31e)), closes [#6892](https://github.com/angular/material2/issues/6892) [#6903](https://github.com/angular/material2/issues/6903) +* **snack-bar:** animation not starting for subsequent snack bars ([#6649](https://github.com/angular/material2/issues/6649)) ([730e7ae](https://github.com/angular/material2/commit/730e7ae)), closes [#6222](https://github.com/angular/material2/issues/6222) +* **sort:** reverse directions and better animation ([#6802](https://github.com/angular/material2/issues/6802)) ([6fa9e6f](https://github.com/angular/material2/commit/6fa9e6f)) +* **table:** gracefully handle undefined/null columns ([#6862](https://github.com/angular/material2/issues/6862)) ([3ddf65b](https://github.com/angular/material2/commit/3ddf65b)) +* **tabs:** fix infinite tab loop ([#6663](https://github.com/angular/material2/issues/6663)) ([67e02b0](https://github.com/angular/material2/commit/67e02b0)), closes [#4639](https://github.com/angular/material2/issues/4639) +* **tabs:** tab spacing on desktop incorrect ([#6681](https://github.com/angular/material2/issues/6681)) ([b678119](https://github.com/angular/material2/commit/b678119)), closes [#3347](https://github.com/angular/material2/issues/3347) +* **tooltip:** closing immediately when triggered on click ([#6590](https://github.com/angular/material2/issues/6590)) ([bcd026f](https://github.com/angular/material2/commit/bcd026f)) +* **tooltip:** ensure tooltip never passes undefined message to ([#7018](https://github.com/angular/material2/issues/7018)) ([f6d1078](https://github.com/angular/material2/commit/f6d1078)) +* add `mat` exportAs and class aliases ([#7106](https://github.com/angular/material2/issues/7106)) ([a96b545](https://github.com/angular/material2/commit/a96b545)) +* **tooltip:** error on trigger escape presses while closed ([#7028](https://github.com/angular/material2/issues/7028)) ([dcf3b27](https://github.com/angular/material2/commit/dcf3b27)), closes [#7009](https://github.com/angular/material2/issues/7009) + +### Features + +* **chip-list:** implement FormFieldControl and ControlValueAccessor ([#6686](https://github.com/angular/material2/issues/6686)) ([7a42706](https://github.com/angular/material2/commit/7a42706)) +* **datepicker:** Add Moment.js adapter ([#6860](https://github.com/angular/material2/issues/6860)) ([9545427](https://github.com/angular/material2/commit/9545427)) +* **dialog:** add afterOpen to MdDialogRef ([#6887](https://github.com/angular/material2/issues/6887)) ([27cbe47](https://github.com/angular/material2/commit/27cbe47)) +* **expansion-panel:** allow for the panel header height to be customized ([#6643](https://github.com/angular/material2/issues/6643)) ([11e2239](https://github.com/angular/material2/commit/11e2239)), closes [#5641](https://github.com/angular/material2/issues/5641) +* **overlay:** replace OverlayContainer themeClass w/ addClass/removeClass methods ([#6975](https://github.com/angular/material2/issues/6975)) ([a944f6e](https://github.com/angular/material2/commit/a944f6e)) +* **selection-list:** add selectAll and deselectAll functions ([#6971](https://github.com/angular/material2/issues/6971)) ([dc9679d](https://github.com/angular/material2/commit/dc9679d)), closes [#6969](https://github.com/angular/material2/issues/6969) +* **sort:** add sorting indicator animation ([#5831](https://github.com/angular/material2/issues/5831)) ([70bd5fc](https://github.com/angular/material2/commit/70bd5fc)) +* **stepper:** Add e2e test ([#6776](https://github.com/angular/material2/issues/6776)) ([bef6271](https://github.com/angular/material2/commit/bef6271)) +* **stepper:** add moduleId to components ([#6780](https://github.com/angular/material2/issues/6780)) ([f375f92](https://github.com/angular/material2/commit/f375f92)) +* **stepper:** Address previous comments + add directionality support ([#6775](https://github.com/angular/material2/issues/6775)) ([c396596](https://github.com/angular/material2/commit/c396596)) +* **stepper:** initial version of stepper ([#6594](https://github.com/angular/material2/issues/6594)) ([87318bc](https://github.com/angular/material2/commit/87318bc)) +* **viewport-ruler:** add common window resize handler ([#6680](https://github.com/angular/material2/issues/6680)) ([881630f](https://github.com/angular/material2/commit/881630f)) +* add `preserveWhitespaces: false` to all components ([#7115](https://github.com/angular/material2/issues/7115)) ([2b0315d](https://github.com/angular/material2/commit/2b0315d)) +* move FocusMonitor into cdk ([#6921](https://github.com/angular/material2/issues/6921)) ([6cfe5c4](https://github.com/angular/material2/commit/6cfe5c4)) + + +### Performance Improvements + +* **dialog:** avoid repaintin dialog content element on scroll ([#6890](https://github.com/angular/material2/issues/6890)) ([51396d0](https://github.com/angular/material2/commit/51396d0)), closes [#6878](https://github.com/angular/material2/issues/6878) +* memory leak when subscribing to zone events ([#6918](https://github.com/angular/material2/issues/6918)) ([f6c9172](https://github.com/angular/material2/commit/f6c9172)), closes [#6905](https://github.com/angular/material2/issues/6905) + + # [2.0.0-beta.10 découpage-panjandrum](https://github.com/angular/material2/compare/2.0.0-beta.8...2.0.0-beta.10) (2017-08-29) diff --git a/package-lock.json b/package-lock.json index 261f668ec5a4..6cf8c6caee81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -675,6 +675,16 @@ "@types/node": "7.0.34" } }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abab": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.3.tgz", @@ -2286,8 +2296,8 @@ "integrity": "sha1-4ye1MZThp61dxjR57pCZpSsCSGU=", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.1.1", @@ -4555,6 +4565,7 @@ "dev": true, "requires": { "@google-cloud/functions-emulator": "1.0.0-alpha.21", + "JSONStream": "1.3.1", "archiver": "0.16.0", "chalk": "1.1.3", "cjson": "0.3.3", @@ -4572,7 +4583,6 @@ "fstream-ignore": "1.0.5", "inquirer": "0.12.0", "jsonschema": "1.1.1", - "JSONStream": "1.3.1", "jsonwebtoken": "5.7.0", "lodash": "4.17.4", "open": "0.0.5", @@ -9170,6 +9180,16 @@ "through2": "0.6.5" }, "dependencies": { + "JSONStream": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", + "integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=", + "dev": true, + "requires": { + "jsonparse": "0.0.5", + "through": "2.3.8" + } + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -9182,16 +9202,6 @@ "integrity": "sha1-MwVCrT8KZUZlt3jz6y2an6UHrGQ=", "dev": true }, - "JSONStream": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", - "integrity": "sha1-kWV9/m/4V0gwZhMrRhi2Lo9Ih70=", - "dev": true, - "requires": { - "jsonparse": "0.0.5", - "through": "2.3.8" - } - }, "readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", @@ -9256,16 +9266,6 @@ "integrity": "sha1-PO3o4+QR03eHLu+8n98mODy8Ptk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsonwebtoken": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-7.4.1.tgz", @@ -13566,15 +13566,6 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-format-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/string-format-obj/-/string-format-obj-1.1.0.tgz", @@ -13608,6 +13599,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringify-object": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-0.1.8.tgz", diff --git a/src/material-examples/stepper-overview/stepper-overview-example.html b/src/material-examples/stepper-overview/stepper-overview-example.html index 4e4408a1bec0..adff42f6f8ba 100644 --- a/src/material-examples/stepper-overview/stepper-overview-example.html +++ b/src/material-examples/stepper-overview/stepper-overview-example.html @@ -1,4 +1,3 @@ -
diff --git a/tools/dgeni/index.js b/tools/dgeni/index.js index e5a105470b65..a5b6d765a510 100644 --- a/tools/dgeni/index.js +++ b/tools/dgeni/index.js @@ -121,6 +121,7 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps) 'lib/slider/index.ts', 'lib/snack-bar/index.ts', 'lib/sort/index.ts', + 'lib/stepper/index.ts', 'lib/table/index.ts', 'lib/tabs/index.ts', 'lib/toolbar/index.ts', From 20a23f16e8ac1ced29172709cc837fa500b6377b Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Thu, 28 Sep 2017 13:45:03 -0700 Subject: [PATCH 132/575] fix: remove all md prefixes (#7241) --- CODING_STANDARDS.md | 16 +- e2e/components/button-toggle-e2e.spec.ts | 2 +- e2e/components/card-e2e.spec.ts | 4 +- e2e/components/dialog-e2e.spec.ts | 20 +- e2e/components/grid-list-e2e.spec.ts | 4 +- e2e/components/list-e2e.spec.ts | 4 +- e2e/components/menu-e2e.spec.ts | 2 +- e2e/components/progress-bar-e2e.spec.ts | 8 +- e2e/components/progress-spinner-e2e.spec.ts | 6 +- e2e/components/sidenav-e2e.spec.ts | 2 +- e2e/components/slide-toggle-e2e.spec.ts | 2 +- e2e/components/stepper-e2e.spec.ts | 14 +- e2e/components/tabs-e2e.spec.ts | 4 +- e2e/components/toolbar-e2e.spec.ts | 4 +- guides/cdk-table.md | 2 +- guides/customizing-component-styles.md | 2 +- guides/getting-started.md | 16 +- guides/theming.md | 2 +- package-lock.json | 4 +- src/cdk/a11y/interactivity-checker.spec.ts | 4 +- src/cdk/bidi/directionality.ts | 2 +- src/cdk/collections/selection.ts | 2 +- src/cdk/observers/observe-content.spec.ts | 4 +- src/cdk/observers/observe-content.ts | 6 +- src/cdk/overlay/overlay-directives.ts | 14 +- src/cdk/overlay/public_api.ts | 4 +- .../overlay/scroll/close-scroll-strategy.ts | 4 +- .../scroll/reposition-scroll-strategy.ts | 4 +- src/cdk/overlay/scroll/scroll-strategy.ts | 2 +- src/cdk/table/row.ts | 2 +- src/cdk/table/table.ts | 2 +- .../a11y/autocomplete/autocomplete-a11y.html | 14 +- .../button-toggle/button-toggle-a11y.html | 74 +-- src/demo-app/a11y/button/button-a11y.html | 40 +- src/demo-app/a11y/button/button-a11y.ts | 4 +- src/demo-app/a11y/card/card-a11y.html | 84 +-- src/demo-app/a11y/card/card-a11y.ts | 4 +- src/demo-app/a11y/checkbox/checkbox-a11y.html | 22 +- src/demo-app/a11y/chips/chips-a11y.html | 62 +- src/demo-app/a11y/chips/chips-a11y.ts | 6 +- .../a11y/datepicker/datepicker-a11y.html | 114 ++-- src/demo-app/a11y/dialog/dialog-a11y.html | 8 +- src/demo-app/a11y/dialog/dialog-a11y.ts | 6 +- .../a11y/dialog/dialog-address-form-a11y.html | 64 +- .../a11y/dialog/dialog-fruit-a11y.html | 10 +- .../a11y/dialog/dialog-neptune-a11y.html | 16 +- .../dialog/dialog-neptune-iframe-a11y.html | 12 +- .../a11y/dialog/dialog-welcome-a11y.html | 2 +- .../a11y/grid-list/grid-list-a11y.html | 40 +- src/demo-app/a11y/icon/icon-a11y.html | 12 +- src/demo-app/a11y/icon/icon-a11y.ts | 4 +- src/demo-app/a11y/input/input-a11y.html | 62 +- src/demo-app/a11y/menu/menu-a11y.html | 44 +- .../a11y/progress-bar/progress-bar-a11y.html | 14 +- .../progress-spinner-a11y.html | 12 +- src/demo-app/a11y/radio/radio-a11y.html | 32 +- src/demo-app/a11y/select/select-a11y.html | 112 ++-- .../a11y/slide-toggle/slide-toggle-a11y.html | 14 +- .../a11y/slide-toggle/slide-toggle-a11y.ts | 4 +- src/demo-app/a11y/slider/slider-a11y.html | 12 +- .../a11y/snack-bar/snack-bar-a11y.html | 4 +- src/demo-app/a11y/snack-bar/snack-bar-a11y.ts | 4 +- src/demo-app/a11y/tabs/tabs-a11y.html | 14 +- src/demo-app/a11y/toolbar/toolbar-a11y.html | 24 +- src/demo-app/a11y/tooltip/tooltip-a11y.html | 36 +- .../autocomplete/autocomplete-demo.html | 94 +-- src/demo-app/baseline/baseline-demo.html | 84 +-- .../button-toggle/button-toggle-demo.html | 60 +- src/demo-app/button/button-demo.html | 122 ++-- src/demo-app/card/card-demo.html | 98 +-- src/demo-app/checkbox/checkbox-demo.html | 20 +- src/demo-app/checkbox/checkbox-demo.ts | 6 +- src/demo-app/checkbox/nested-checklist.html | 8 +- src/demo-app/chips/chips-demo.html | 154 ++--- src/demo-app/chips/chips-demo.scss | 2 +- src/demo-app/chips/chips-demo.ts | 4 +- src/demo-app/datepicker/datepicker-demo.html | 106 +-- src/demo-app/datepicker/datepicker-demo.scss | 2 +- src/demo-app/datepicker/datepicker-demo.ts | 6 +- src/demo-app/demo-app/demo-app.html | 34 +- src/demo-app/demo-app/demo-module.ts | 4 +- src/demo-app/demo-material-module.ts | 126 ++-- src/demo-app/dialog/dialog-demo.html | 86 +-- src/demo-app/dialog/dialog-demo.ts | 50 +- src/demo-app/drawer/drawer-demo.html | 74 +-- src/demo-app/expansion/expansion-demo.html | 82 +-- src/demo-app/expansion/expansion-demo.scss | 2 +- src/demo-app/grid-list/grid-list-demo.html | 142 ++-- src/demo-app/icon/icon-demo.html | 22 +- src/demo-app/icon/icon-demo.ts | 8 +- src/demo-app/index.html | 2 +- src/demo-app/input/input-demo.html | 496 +++++++------- src/demo-app/list/list-demo.html | 156 ++--- .../live-announcer/live-announcer-demo.html | 2 +- src/demo-app/menu/menu-demo.html | 200 +++--- .../progress-bar/progress-bar-demo.html | 34 +- .../progress-bar/progress-bar-demo.scss | 2 +- .../progress-spinner-demo.html | 30 +- src/demo-app/radio/radio-demo.html | 38 +- src/demo-app/ripple/ripple-demo.html | 66 +- src/demo-app/ripple/ripple-demo.ts | 4 +- src/demo-app/select/select-demo.html | 204 +++--- src/demo-app/select/select-demo.ts | 4 +- src/demo-app/sidenav/sidenav-demo.html | 48 +- .../slide-toggle/slide-toggle-demo.html | 18 +- .../slide-toggle/slide-toggle-demo.scss | 2 +- src/demo-app/slider/slider-demo.html | 50 +- src/demo-app/snack-bar/snack-bar-demo.html | 56 +- src/demo-app/snack-bar/snack-bar-demo.ts | 16 +- src/demo-app/stepper/stepper-demo.html | 258 ++++---- src/demo-app/table/person-data-source.ts | 6 +- src/demo-app/table/table-demo.html | 86 +-- src/demo-app/table/table-demo.scss | 2 +- src/demo-app/table/table-demo.ts | 6 +- src/demo-app/table/table-header-demo.html | 16 +- src/demo-app/tabs/tabs-demo.html | 170 ++--- src/demo-app/toolbar/toolbar-demo.html | 50 +- src/demo-app/tooltip/tooltip-demo.html | 58 +- src/e2e-app/button/button-e2e.html | 18 +- src/e2e-app/checkbox/checkbox-e2e.html | 2 +- src/e2e-app/dialog/dialog-e2e.ts | 10 +- src/e2e-app/e2e-app-module.ts | 68 +- src/e2e-app/e2e-app/e2e-app.html | 46 +- src/e2e-app/fullscreen/fullscreen-e2e.ts | 8 +- src/e2e-app/grid-list/grid-list-e2e.html | 12 +- src/e2e-app/icon/icon-e2e.html | 2 +- src/e2e-app/index.html | 2 +- src/e2e-app/input/input-e2e.html | 24 +- src/e2e-app/menu/menu-e2e.html | 40 +- .../progress-bar/progress-bar-e2e.html | 8 +- src/e2e-app/progress-bar/progress-bar-e2e.ts | 2 +- .../progress-spinner-e2e.html | 6 +- src/e2e-app/radio/radio-e2e.html | 10 +- src/e2e-app/sidenav/sidenav-e2e.html | 6 +- .../slide-toggle/slide-toggle-e2e.html | 4 +- src/e2e-app/tabs/tabs-e2e.html | 22 +- src/lib/autocomplete/autocomplete-module.ts | 18 +- src/lib/autocomplete/autocomplete-trigger.ts | 69 +- src/lib/autocomplete/autocomplete.md | 48 +- src/lib/autocomplete/autocomplete.scss | 2 +- src/lib/autocomplete/autocomplete.spec.ts | 240 +++---- src/lib/autocomplete/autocomplete.ts | 30 +- src/lib/autocomplete/mat-exports.ts | 27 - src/lib/autocomplete/public_api.ts | 2 +- .../button-toggle/_button-toggle-theme.scss | 2 +- src/lib/button-toggle/button-toggle-module.ts | 18 +- src/lib/button-toggle/button-toggle.md | 10 +- src/lib/button-toggle/button-toggle.spec.ts | 130 ++-- src/lib/button-toggle/button-toggle.ts | 68 +- src/lib/button-toggle/mat-exports.ts | 26 - src/lib/button-toggle/public_api.ts | 2 +- src/lib/button/_button-theme.scss | 4 +- src/lib/button/button-module.ts | 52 +- src/lib/button/button.html | 2 +- src/lib/button/button.md | 14 +- src/lib/button/button.spec.ts | 58 +- src/lib/button/button.ts | 65 +- src/lib/button/mat-exports.ts | 29 - src/lib/button/public_api.ts | 2 +- src/lib/card/card-header.html | 7 +- src/lib/card/card-module.ts | 70 +- src/lib/card/card-title-group.html | 5 +- src/lib/card/card.html | 2 +- src/lib/card/card.md | 46 +- src/lib/card/card.ts | 72 +-- src/lib/card/mat-exports.ts | 42 -- src/lib/card/public_api.ts | 2 +- src/lib/checkbox/checkbox-module.ts | 14 +- .../checkbox/checkbox-required-validator.ts | 16 +- src/lib/checkbox/checkbox.html | 2 +- src/lib/checkbox/checkbox.md | 14 +- src/lib/checkbox/checkbox.spec.ts | 94 +-- src/lib/checkbox/checkbox.ts | 45 +- src/lib/checkbox/mat-exports.ts | 28 - src/lib/checkbox/public_api.ts | 2 +- src/lib/chips/chip-input.spec.ts | 28 +- src/lib/chips/chip-input.ts | 30 +- src/lib/chips/chip-list.spec.ts | 142 ++-- src/lib/chips/chip-list.ts | 66 +- src/lib/chips/chip-remove.spec.ts | 8 +- src/lib/chips/chip.spec.ts | 46 +- src/lib/chips/chip.ts | 59 +- src/lib/chips/chips-module.ts | 12 +- src/lib/chips/chips.md | 50 +- src/lib/chips/mat-exports.ts | 24 - src/lib/chips/public_api.ts | 2 +- src/lib/core/_core.scss | 2 +- .../core/common-behaviors/common-module.ts | 6 +- src/lib/core/common-behaviors/index.ts | 2 +- .../core/compatibility/compatibility.spec.ts | 104 --- src/lib/core/compatibility/compatibility.ts | 40 +- src/lib/core/datetime/date-formats.ts | 4 +- src/lib/core/datetime/index.ts | 8 +- src/lib/core/datetime/native-date-formats.ts | 4 +- src/lib/core/error/error-options.ts | 3 +- src/lib/core/line/line.ts | 20 +- src/lib/core/mat-exports.ts | 49 -- src/lib/core/option/_option.scss | 4 +- src/lib/core/option/index.ts | 16 +- src/lib/core/option/optgroup.html | 2 +- src/lib/core/option/optgroup.ts | 12 +- src/lib/core/option/option.spec.ts | 12 +- src/lib/core/option/option.ts | 28 +- .../core/placeholder/placeholder-options.ts | 4 +- src/lib/core/public_api.ts | 2 +- src/lib/core/ripple/README.md | 24 +- src/lib/core/ripple/_ripple.scss | 2 +- src/lib/core/ripple/index.ts | 14 +- src/lib/core/ripple/ripple.spec.ts | 42 +- src/lib/core/ripple/ripple.ts | 61 +- src/lib/core/selection/index.ts | 8 +- .../pseudo-checkbox/pseudo-checkbox.ts | 10 +- src/lib/core/style/_menu-common.scss | 2 +- src/lib/datepicker/calendar-body.spec.ts | 16 +- src/lib/datepicker/calendar-body.ts | 10 +- src/lib/datepicker/calendar.html | 4 +- src/lib/datepicker/calendar.spec.ts | 84 +-- src/lib/datepicker/calendar.ts | 20 +- .../datepicker/coerce-date-property.spec.ts | 4 +- src/lib/datepicker/datepicker-content.scss | 46 +- src/lib/datepicker/datepicker-errors.ts | 4 +- src/lib/datepicker/datepicker-input.ts | 76 +-- src/lib/datepicker/datepicker-intl.ts | 2 +- src/lib/datepicker/datepicker-module.ts | 72 +-- src/lib/datepicker/datepicker-toggle.ts | 22 +- src/lib/datepicker/datepicker.md | 84 +-- src/lib/datepicker/datepicker.spec.ts | 203 +++--- src/lib/datepicker/datepicker.ts | 65 +- src/lib/datepicker/mat-exports.ts | 48 -- src/lib/datepicker/month-view.spec.ts | 22 +- src/lib/datepicker/month-view.ts | 22 +- src/lib/datepicker/public_api.ts | 2 +- src/lib/datepicker/year-view.spec.ts | 24 +- src/lib/datepicker/year-view.ts | 18 +- src/lib/dialog/dialog-config.ts | 4 +- src/lib/dialog/dialog-container.ts | 14 +- src/lib/dialog/dialog-content-directives.ts | 36 +- src/lib/dialog/dialog-module.ts | 46 +- src/lib/dialog/dialog-ref.ts | 10 +- src/lib/dialog/dialog.md | 46 +- src/lib/dialog/dialog.spec.ts | 152 ++--- src/lib/dialog/dialog.ts | 80 +-- src/lib/dialog/mat-exports.ts | 40 -- src/lib/dialog/public_api.ts | 2 +- src/lib/expansion/accordion.spec.ts | 20 +- src/lib/expansion/accordion.ts | 10 +- src/lib/expansion/expansion-module.ts | 40 +- src/lib/expansion/expansion-panel-header.html | 4 +- src/lib/expansion/expansion-panel-header.ts | 28 +- src/lib/expansion/expansion-panel.html | 4 +- src/lib/expansion/expansion-panel.ts | 30 +- src/lib/expansion/expansion.md | 68 +- src/lib/expansion/expansion.spec.ts | 26 +- src/lib/expansion/mat-exports.ts | 31 - src/lib/expansion/public_api.ts | 18 +- src/lib/form-field/error.ts | 4 +- src/lib/form-field/form-field-control.ts | 10 +- src/lib/form-field/form-field-errors.ts | 10 +- src/lib/form-field/form-field-module.ts | 38 +- src/lib/form-field/form-field.html | 12 +- src/lib/form-field/form-field.scss | 2 +- src/lib/form-field/form-field.ts | 68 +- src/lib/form-field/hint.ts | 4 +- src/lib/form-field/mat-exports.ts | 28 - src/lib/form-field/placeholder.ts | 6 +- src/lib/form-field/prefix.ts | 4 +- src/lib/form-field/public_api.ts | 2 +- src/lib/form-field/suffix.ts | 4 +- src/lib/grid-list/grid-list-module.ts | 40 +- src/lib/grid-list/grid-list.md | 12 +- src/lib/grid-list/grid-list.spec.ts | 176 ++--- src/lib/grid-list/grid-list.ts | 16 +- src/lib/grid-list/grid-tile-text.html | 4 +- src/lib/grid-list/grid-tile.ts | 28 +- src/lib/grid-list/mat-exports.ts | 16 - src/lib/grid-list/public_api.ts | 4 +- src/lib/grid-list/tile-coordinator.ts | 10 +- src/lib/grid-list/tile-styler.ts | 32 +- src/lib/icon/icon-module.ts | 12 +- src/lib/icon/icon-registry.ts | 44 +- src/lib/icon/icon.md | 38 +- src/lib/icon/icon.spec.ts | 144 ++--- src/lib/icon/icon.ts | 38 +- src/lib/icon/mat-exports.ts | 17 - src/lib/icon/public_api.ts | 2 +- src/lib/input/autosize.spec.ts | 26 +- src/lib/input/autosize.ts | 19 +- src/lib/input/input-errors.ts | 4 +- src/lib/input/input-module.ts | 24 +- src/lib/input/input.md | 58 +- src/lib/input/input.spec.ts | 606 +++++++++--------- src/lib/input/input.ts | 38 +- src/lib/input/mat-exports.ts | 16 - src/lib/input/public_api.ts | 2 +- src/lib/list/list-item.html | 6 +- src/lib/list/list-module.ts | 82 +-- src/lib/list/list.md | 146 ++--- src/lib/list/list.spec.ts | 140 ++-- src/lib/list/list.ts | 69 +- src/lib/list/mat-exports.ts | 48 -- src/lib/list/public_api.ts | 2 +- src/lib/list/selection-list.spec.ts | 124 ++-- src/lib/list/selection-list.ts | 62 +- src/lib/menu/mat-exports.ts | 26 - src/lib/menu/menu-animations.ts | 2 +- src/lib/menu/menu-directive.ts | 46 +- src/lib/menu/menu-errors.ts | 18 +- src/lib/menu/menu-item.ts | 19 +- src/lib/menu/menu-module.ts | 24 +- src/lib/menu/menu-panel.ts | 4 +- src/lib/menu/menu-trigger.ts | 71 +- src/lib/menu/menu.md | 82 +-- src/lib/menu/menu.spec.ts | 188 +++--- src/lib/menu/menu.ts | 8 +- src/lib/menu/public_api.ts | 4 +- src/lib/paginator/mat-exports.ts | 16 - src/lib/paginator/paginator-intl.ts | 4 +- src/lib/paginator/paginator-module.ts | 24 +- src/lib/paginator/paginator.md | 6 +- src/lib/paginator/paginator.spec.ts | 66 +- src/lib/paginator/paginator.ts | 10 +- src/lib/paginator/public_api.ts | 2 +- src/lib/progress-bar/mat-exports.ts | 14 - src/lib/progress-bar/progress-bar-module.ts | 12 +- src/lib/progress-bar/progress-bar.md | 2 +- src/lib/progress-bar/progress-bar.scss | 6 +- src/lib/progress-bar/progress-bar.spec.ts | 20 +- src/lib/progress-bar/progress-bar.ts | 6 +- src/lib/progress-bar/public_api.ts | 2 +- src/lib/progress-spinner/mat-exports.ts | 22 - .../progress-spinner-module.ts | 26 +- src/lib/progress-spinner/progress-spinner.md | 4 +- .../progress-spinner/progress-spinner.spec.ts | 46 +- src/lib/progress-spinner/progress-spinner.ts | 24 +- src/lib/progress-spinner/public_api.ts | 2 +- src/lib/radio/mat-exports.ts | 26 - src/lib/radio/public_api.ts | 2 +- src/lib/radio/radio-module.ts | 14 +- src/lib/radio/radio.md | 12 +- src/lib/radio/radio.spec.ts | 94 +-- src/lib/radio/radio.ts | 95 +-- src/lib/select/mat-exports.ts | 28 - src/lib/select/public_api.ts | 1 - src/lib/select/select-animations.ts | 4 +- src/lib/select/select-errors.ts | 6 +- src/lib/select/select-module.ts | 16 +- src/lib/select/select.html | 2 +- src/lib/select/select.md | 68 +- src/lib/select/select.spec.ts | 537 ++++++++-------- src/lib/select/select.ts | 108 ++-- src/lib/sidenav/README.md | 64 +- src/lib/sidenav/drawer-container.html | 8 +- src/lib/sidenav/drawer.scss | 2 +- src/lib/sidenav/drawer.spec.ts | 106 +-- src/lib/sidenav/drawer.ts | 70 +- src/lib/sidenav/mat-exports.ts | 19 - src/lib/sidenav/public_api.ts | 2 +- src/lib/sidenav/sidenav-container.html | 8 +- src/lib/sidenav/sidenav-module.ts | 36 +- src/lib/sidenav/sidenav.md | 40 +- src/lib/sidenav/sidenav.spec.ts | 20 +- src/lib/sidenav/sidenav.ts | 20 +- src/lib/slide-toggle/mat-exports.ts | 22 - src/lib/slide-toggle/public_api.ts | 2 +- src/lib/slide-toggle/slide-toggle-module.ts | 14 +- src/lib/slide-toggle/slide-toggle.md | 14 +- src/lib/slide-toggle/slide-toggle.spec.ts | 58 +- src/lib/slide-toggle/slide-toggle.ts | 36 +- src/lib/slider/mat-exports.ts | 22 - src/lib/slider/public_api.ts | 2 +- src/lib/slider/slider-module.ts | 12 +- src/lib/slider/slider.md | 14 +- src/lib/slider/slider.spec.ts | 136 ++-- src/lib/slider/slider.ts | 34 +- src/lib/snack-bar/mat-exports.ts | 21 - src/lib/snack-bar/public_api.ts | 2 +- src/lib/snack-bar/simple-snack-bar.ts | 8 +- src/lib/snack-bar/snack-bar-config.ts | 20 +- src/lib/snack-bar/snack-bar-container.ts | 6 +- src/lib/snack-bar/snack-bar-module.ts | 18 +- src/lib/snack-bar/snack-bar-ref.ts | 8 +- src/lib/snack-bar/snack-bar.md | 16 +- src/lib/snack-bar/snack-bar.spec.ts | 100 +-- src/lib/snack-bar/snack-bar.ts | 44 +- src/lib/sort/mat-exports.ts | 19 - src/lib/sort/public_api.ts | 2 +- src/lib/sort/sort-errors.ts | 12 +- src/lib/sort/sort-header-intl.ts | 4 +- src/lib/sort/sort-header.ts | 26 +- src/lib/sort/sort-module.ts | 14 +- src/lib/sort/sort.md | 18 +- src/lib/sort/sort.spec.ts | 217 ++++--- src/lib/sort/sort.ts | 75 +-- src/lib/stepper/mat-exports.ts | 29 - src/lib/stepper/public_api.ts | 2 +- src/lib/stepper/step-header.ts | 18 +- src/lib/stepper/step-label.ts | 6 +- src/lib/stepper/stepper-button.ts | 18 +- src/lib/stepper/stepper-module.ts | 44 +- src/lib/stepper/stepper.md | 86 +-- src/lib/stepper/stepper.spec.ts | 307 ++++----- src/lib/stepper/stepper.ts | 51 +- src/lib/table/cell.ts | 49 +- src/lib/table/mat-exports.ts | 23 - src/lib/table/public_api.ts | 2 +- src/lib/table/row.ts | 40 +- src/lib/table/table-module.ts | 22 +- src/lib/table/table.md | 12 +- src/lib/table/table.spec.ts | 44 +- src/lib/table/table.ts | 6 +- src/lib/tabs/ink-bar.ts | 4 +- src/lib/tabs/mat-exports.ts | 34 - src/lib/tabs/public_api.ts | 16 +- src/lib/tabs/tab-body.spec.ts | 42 +- src/lib/tabs/tab-body.ts | 14 +- src/lib/tabs/tab-group.scss | 2 +- src/lib/tabs/tab-group.spec.ts | 150 ++--- src/lib/tabs/tab-group.ts | 70 +- src/lib/tabs/tab-header.spec.ts | 112 ++-- src/lib/tabs/tab-header.ts | 26 +- src/lib/tabs/tab-label-wrapper.ts | 12 +- src/lib/tabs/tab-label.ts | 6 +- src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts | 22 +- src/lib/tabs/tab-nav-bar/tab-nav-bar.ts | 47 +- src/lib/tabs/tab.ts | 20 +- src/lib/tabs/tabs-module.ts | 54 +- src/lib/tabs/tabs.md | 40 +- src/lib/toolbar/mat-exports.ts | 16 - src/lib/toolbar/public_api.ts | 2 +- src/lib/toolbar/toolbar-module.ts | 12 +- src/lib/toolbar/toolbar.html | 2 +- src/lib/toolbar/toolbar.md | 24 +- src/lib/toolbar/toolbar.spec.ts | 10 +- src/lib/toolbar/toolbar.ts | 21 +- src/lib/tooltip/mat-exports.ts | 23 - src/lib/tooltip/public_api.ts | 2 +- src/lib/tooltip/tooltip-module.ts | 14 +- src/lib/tooltip/tooltip.md | 8 +- src/lib/tooltip/tooltip.spec.ts | 46 +- src/lib/tooltip/tooltip.ts | 77 +-- .../autocomplete-display-example.html | 14 +- .../autocomplete-filter-example.html | 14 +- .../autocomplete-overview-example.html | 18 +- .../autocomplete-simple-example.html | 14 +- .../button-overview-example.html | 2 +- .../button-toggle-exclusive-example.html | 28 +- .../button-toggle-overview-example.html | 2 +- .../button-types/button-types-example.html | 76 +-- .../card-fancy/card-fancy-example.html | 28 +- .../card-overview/card-overview-example.html | 2 +- .../checkbox-configurable-example.html | 34 +- .../checkbox-overview-example.html | 2 +- .../chips-input/chips-input-example.html | 24 +- .../chips-input/chips-input-example.ts | 4 +- .../chips-overview-example.html | 12 +- .../chips-stacked/chips-stacked-example.css | 2 +- .../chips-stacked/chips-stacked-example.html | 8 +- .../datepicker-api-example.html | 10 +- .../datepicker-filter-example.html | 10 +- .../datepicker-min-max-example.html | 10 +- .../datepicker-overview-example.html | 10 +- .../datepicker-start-view-example.html | 10 +- .../datepicker-touch-example.html | 10 +- .../dialog-content-example-dialog.html | 14 +- .../dialog-content-example.html | 2 +- .../dialog-content/dialog-content-example.ts | 4 +- .../dialog-data-example-dialog.html | 4 +- .../dialog-data/dialog-data-example.html | 2 +- .../dialog-data/dialog-data-example.ts | 6 +- .../dialog-elements-example-dialog.html | 8 +- .../dialog-elements-example.html | 2 +- .../dialog-elements-example.ts | 4 +- .../dialog-overview-example-dialog.html | 16 +- .../dialog-overview-example.html | 8 +- .../dialog-overview-example.ts | 8 +- .../expansion-overview-example.html | 28 +- .../expansion-steps-example.html | 106 +-- .../grid-list-dynamic-example.html | 8 +- .../grid-list-overview-example.css | 2 +- .../grid-list-overview-example.html | 12 +- .../icon-overview/icon-overview-example.html | 2 +- .../icon-svg-example/icon-svg-example.html | 2 +- .../icon-svg-example/icon-svg-example.ts | 4 +- .../input-clearable-example.html | 10 +- .../input-errors/input-errors-example.html | 14 +- .../input-form/input-form-example.html | 50 +- .../input-hint/input-hint-example.html | 10 +- .../input-overview-example.html | 6 +- .../input-prefix-suffix-example.html | 10 +- .../list-overview/list-overview-example.html | 10 +- .../list-sections/list-sections-example.html | 30 +- .../list-selection-example.html | 8 +- src/material-examples/material-module.ts | 74 +-- .../menu-icons/menu-icons-example.html | 20 +- .../menu-overview/menu-overview-example.html | 10 +- .../nested-menu/nested-menu-example.html | 82 +-- .../paginator-configurable-example.html | 22 +- .../paginator-configurable-example.ts | 4 +- .../paginator-overview-example.html | 4 +- .../progress-bar-configurable-example.html | 60 +- .../progress-bar-overview-example.html | 2 +- ...progress-spinner-configurable-example.html | 50 +- .../progress-spinner-overview-example.html | 2 +- .../radio-ng-model-example.html | 8 +- .../radio-overview-example.html | 8 +- .../select-form/select-form-example.html | 12 +- .../select-overview-example.html | 12 +- .../sidenav-fab/sidenav-fab-example.css | 4 +- .../sidenav-fab/sidenav-fab-example.html | 16 +- .../sidenav-overview-example.html | 10 +- .../slide-toggle-configurable-example.html | 40 +- .../slide-toggle-forms-example.css | 2 +- .../slide-toggle-forms-example.html | 14 +- .../slide-toggle-overview-example.html | 2 +- .../slider-configurable-example.html | 64 +- .../slider-overview-example.css | 2 +- .../slider-overview-example.html | 2 +- .../snack-bar-component-example.html | 2 +- .../snack-bar-component-example.ts | 4 +- .../snack-bar-overview-example.html | 14 +- .../snack-bar-overview-example.ts | 4 +- .../sort-overview/sort-overview-example.html | 12 +- .../stepper-overview-example.html | 42 +- .../table-basic/table-basic-example.html | 32 +- .../table-filtering-example.html | 38 +- .../table-http/table-http-example.html | 44 +- .../table-http/table-http-example.ts | 10 +- .../table-overview-example.html | 62 +- .../table-overview/table-overview-example.ts | 10 +- .../table-pagination-example.html | 36 +- .../table-pagination-example.ts | 6 +- .../table-sorting/table-sorting-example.html | 32 +- .../table-sorting/table-sorting-example.ts | 6 +- .../tabs-overview/tabs-overview-example.html | 8 +- .../tabs-template-label-example.html | 30 +- .../toolbar-multirow-example.html | 18 +- .../toolbar-overview-example.html | 2 +- .../tooltip-overview-example.html | 2 +- .../tooltip-position-example.html | 22 +- src/material-moment-adapter/adapter/index.ts | 8 +- .../adapter/moment-date-formats.ts | 4 +- .../kitchen-sink/kitchen-sink.html | 302 ++++----- .../kitchen-sink/kitchen-sink.ts | 120 ++-- test/protractor.conf.js | 4 +- .../app/coverage-chart/coverage-chart.html | 2 +- tools/dashboard/src/app/dashboard-app.html | 24 +- tools/dashboard/src/app/dashboard-module.ts | 8 +- .../src/app/payload-chart/payload-chart.html | 2 +- tools/dgeni/processors/categorizer.js | 2 +- .../src/app/nav/nav.component.html | 8 +- .../src/app/pixacto.dashboard.module.ts | 18 +- .../src/app/result/result.component.html | 42 +- .../src/app/viewer/viewer.component.html | 34 +- .../src/app/viewer/viewer.component.ts | 4 +- 554 files changed, 8545 insertions(+), 9735 deletions(-) delete mode 100644 src/lib/autocomplete/mat-exports.ts delete mode 100644 src/lib/button-toggle/mat-exports.ts delete mode 100644 src/lib/button/mat-exports.ts delete mode 100644 src/lib/card/mat-exports.ts delete mode 100644 src/lib/checkbox/mat-exports.ts delete mode 100644 src/lib/chips/mat-exports.ts delete mode 100644 src/lib/core/mat-exports.ts delete mode 100644 src/lib/datepicker/mat-exports.ts delete mode 100644 src/lib/dialog/mat-exports.ts delete mode 100644 src/lib/expansion/mat-exports.ts delete mode 100644 src/lib/form-field/mat-exports.ts delete mode 100644 src/lib/grid-list/mat-exports.ts delete mode 100644 src/lib/icon/mat-exports.ts delete mode 100644 src/lib/input/mat-exports.ts delete mode 100644 src/lib/list/mat-exports.ts delete mode 100644 src/lib/menu/mat-exports.ts delete mode 100644 src/lib/paginator/mat-exports.ts delete mode 100644 src/lib/progress-bar/mat-exports.ts delete mode 100644 src/lib/progress-spinner/mat-exports.ts delete mode 100644 src/lib/radio/mat-exports.ts delete mode 100644 src/lib/select/mat-exports.ts delete mode 100644 src/lib/sidenav/mat-exports.ts delete mode 100644 src/lib/slide-toggle/mat-exports.ts delete mode 100644 src/lib/slider/mat-exports.ts delete mode 100644 src/lib/snack-bar/mat-exports.ts delete mode 100644 src/lib/sort/mat-exports.ts delete mode 100644 src/lib/stepper/mat-exports.ts delete mode 100644 src/lib/table/mat-exports.ts delete mode 100644 src/lib/tabs/mat-exports.ts delete mode 100644 src/lib/toolbar/mat-exports.ts delete mode 100644 src/lib/tooltip/mat-exports.ts diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md index aff6f30f3c25..b9cde2891ae0 100644 --- a/CODING_STANDARDS.md +++ b/CODING_STANDARDS.md @@ -49,16 +49,16 @@ In HTML code, use `` comments, which will be stripped when packaging For example, rather than doing this: ```html -Basic button -FAB -pony +Basic button +FAB +pony ``` do this: ```html -Basic button -FAB -pony +Basic button +FAB +pony ``` #### Prefer small, focused modules @@ -191,7 +191,7 @@ and the return value: * @param config Dialog configuration options. * @returns Reference to the newly-opened dialog. */ - open(component: ComponentType, config?: MdDialogConfig): MdDialogRef { ... } + open(component: ComponentType, config?: MatDialogConfig): MatDialogRef { ... } ``` Boolean properties and return values should use "Whether..." as opposed to "True if...": @@ -229,7 +229,7 @@ class UniqueSelectionDispatcher { } Avoid suffixing a class with "Service", as it communicates nothing about what the class does. Try to think of the class name as a person's job title. -Classes that correspond to a directive with an `md-` prefix should also be prefixed with `Md`. +Classes that correspond to a directive with an `mat-` prefix should also be prefixed with `Mat`. CDK classes should only have a `Cdk` prefix when the class is a directive with a `cdk` selector prefix. diff --git a/e2e/components/button-toggle-e2e.spec.ts b/e2e/components/button-toggle-e2e.spec.ts index 8f8b1b3e60c0..b302ee63b556 100644 --- a/e2e/components/button-toggle-e2e.spec.ts +++ b/e2e/components/button-toggle-e2e.spec.ts @@ -6,7 +6,7 @@ describe('button-toggle', () => { beforeEach(() => browser.get('/button-toggle')); it('should show a button-toggle', async () => { - expect(element(by.tagName('md-button-toggle'))).toBeDefined(); + expect(element(by.tagName('mat-button-toggle'))).toBeDefined(); screenshot(); }); diff --git a/e2e/components/card-e2e.spec.ts b/e2e/components/card-e2e.spec.ts index aac7d38abd39..14f0cd6e3b6b 100644 --- a/e2e/components/card-e2e.spec.ts +++ b/e2e/components/card-e2e.spec.ts @@ -1,12 +1,12 @@ import {browser, by, element} from 'protractor'; import {screenshot} from '../screenshot'; -describe('md-card', () => { +describe('mat-card', () => { beforeEach(() => browser.get('/cards')); it('should show a card', async () => { - const card = element(by.tagName('md-card')); + const card = element(by.tagName('mat-card')); expect(card).toBeDefined(); screenshot('fancy card example'); diff --git a/e2e/components/dialog-e2e.spec.ts b/e2e/components/dialog-e2e.spec.ts index d3887c7e0649..b5a9b3ab0a45 100644 --- a/e2e/components/dialog-e2e.spec.ts +++ b/e2e/components/dialog-e2e.spec.ts @@ -14,7 +14,7 @@ describe('dialog', () => { it('should open a dialog', () => { element(by.id('default')).click(); - expectToExist('md-dialog-container'); + expectToExist('mat-dialog-container'); screenshot('simple dialog opened'); }); @@ -29,7 +29,7 @@ describe('dialog', () => { await waitForDialog(); clickOnBackrop(); - expectToExist('md-dialog-container', false); + expectToExist('mat-dialog-container', false); }); it('should close by pressing escape', async () => { @@ -37,7 +37,7 @@ describe('dialog', () => { await waitForDialog(); pressKeys(Key.ESCAPE); - expectToExist('md-dialog-container', false); + expectToExist('mat-dialog-container', false); }); it('should close by pressing escape when the first tabbable element has lost focus', @@ -45,9 +45,9 @@ describe('dialog', () => { element(by.id('default')).click(); await waitForDialog(); - clickElementAtPoint('md-dialog-container', { x: 0, y: 0 }); + clickElementAtPoint('mat-dialog-container', { x: 0, y: 0 }); pressKeys(Key.ESCAPE); - expectToExist('md-dialog-container', false); + expectToExist('mat-dialog-container', false); }); it('should close by clicking on the "close" button', async () => { @@ -55,14 +55,14 @@ describe('dialog', () => { await waitForDialog(); element(by.id('close')).click(); - expectToExist('md-dialog-container', false); + expectToExist('mat-dialog-container', false); }); it('should focus the first focusable element', async () => { element(by.id('default')).click(); await waitForDialog(); - expectFocusOn('md-dialog-container input'); + expectFocusOn('mat-dialog-container input'); }); it('should restore focus to the element that opened the dialog', async () => { @@ -88,7 +88,7 @@ describe('dialog', () => { await waitForDialog(); clickOnBackrop(); - expectToExist('md-dialog-container'); + expectToExist('mat-dialog-container'); }); it('should be able to prevent closing by pressing escape', async () => { @@ -96,11 +96,11 @@ describe('dialog', () => { await waitForDialog(); pressKeys(Key.ESCAPE); - expectToExist('md-dialog-container'); + expectToExist('mat-dialog-container'); }); function waitForDialog() { - return waitForElement('md-dialog-container'); + return waitForElement('mat-dialog-container'); } function clickOnBackrop() { diff --git a/e2e/components/grid-list-e2e.spec.ts b/e2e/components/grid-list-e2e.spec.ts index a70c8176c8ee..d4f0858099fa 100644 --- a/e2e/components/grid-list-e2e.spec.ts +++ b/e2e/components/grid-list-e2e.spec.ts @@ -6,11 +6,11 @@ describe('grid-list', () => { beforeEach(() => browser.get('/grid-list')); it('should render a grid list container', () => { - expectToExist('md-grid-list'); + expectToExist('mat-grid-list'); screenshot(); }); it('should render list items inside the grid list container', () => { - expectToExist('md-grid-list md-grid-tile'); + expectToExist('mat-grid-list mat-grid-tile'); }); }); diff --git a/e2e/components/list-e2e.spec.ts b/e2e/components/list-e2e.spec.ts index bdb541373d8f..e0016fd6fa4b 100644 --- a/e2e/components/list-e2e.spec.ts +++ b/e2e/components/list-e2e.spec.ts @@ -6,11 +6,11 @@ describe('list', () => { beforeEach(() => browser.get('/list')); it('should render a list container', () => { - expectToExist('md-list'); + expectToExist('mat-list'); screenshot(); }); it('should render list items inside the list container', () => { - expectToExist('md-list md-list-item'); + expectToExist('mat-list mat-list-item'); }); }); diff --git a/e2e/components/menu-e2e.spec.ts b/e2e/components/menu-e2e.spec.ts index f9e442180c1a..f1b3a3dec680 100644 --- a/e2e/components/menu-e2e.spec.ts +++ b/e2e/components/menu-e2e.spec.ts @@ -207,7 +207,7 @@ export class MenuPage { trigger = () => element(by.id('trigger')); triggerTwo = () => element(by.id('trigger-two')); backdrop = () => element(by.css('.cdk-overlay-backdrop')); - items = (index: number) => element.all(by.css('[md-menu-item]')).get(index); + items = (index: number) => element.all(by.css('[mat-menu-item]')).get(index); textArea = () => element(by.id('text')); beforeTrigger = () => element(by.id('before-t')); aboveTrigger = () => element(by.id('above-t')); diff --git a/e2e/components/progress-bar-e2e.spec.ts b/e2e/components/progress-bar-e2e.spec.ts index aa62334f7235..3bf454764820 100644 --- a/e2e/components/progress-bar-e2e.spec.ts +++ b/e2e/components/progress-bar-e2e.spec.ts @@ -5,18 +5,18 @@ describe('progress-bar', () => { beforeEach(() => browser.get('/progress-bar')); it('should render a determinate progress bar', () => { - expectToExist('md-progress-bar[mode="determinate"]'); + expectToExist('mat-progress-bar[mode="determinate"]'); }); it('should render a buffer progress bar', () => { - expectToExist('md-progress-bar[mode="buffer"]'); + expectToExist('mat-progress-bar[mode="buffer"]'); }); it('should render a query progress bar', () => { - expectToExist('md-progress-bar[mode="query"]'); + expectToExist('mat-progress-bar[mode="query"]'); }); it('should render a indeterminate progress bar', () => { - expectToExist('md-progress-bar[mode="indeterminate"]'); + expectToExist('mat-progress-bar[mode="indeterminate"]'); }); }); diff --git a/e2e/components/progress-spinner-e2e.spec.ts b/e2e/components/progress-spinner-e2e.spec.ts index a8e5238cb9ae..c415636ef8db 100644 --- a/e2e/components/progress-spinner-e2e.spec.ts +++ b/e2e/components/progress-spinner-e2e.spec.ts @@ -4,14 +4,14 @@ describe('progress-spinner', () => { beforeEach(() => browser.get('/progress-spinner')); it('should render a determinate progress spinner', () => { - expect(element(by.css('md-progress-spinner')).isPresent()).toBe(true); + expect(element(by.css('mat-progress-spinner')).isPresent()).toBe(true); }); it('should render an indeterminate progress spinner', () => { - expect(element(by.css('md-progress-spinner[mode="indeterminate"]')).isPresent()).toBe(true); + expect(element(by.css('mat-progress-spinner[mode="indeterminate"]')).isPresent()).toBe(true); }); it('should render a spinner', () => { - expect(element(by.css('md-spinner')).isPresent()).toBe(true); + expect(element(by.css('mat-spinner')).isPresent()).toBe(true); }); }); diff --git a/e2e/components/sidenav-e2e.spec.ts b/e2e/components/sidenav-e2e.spec.ts index 445d8bf63b76..9f90e4403652 100644 --- a/e2e/components/sidenav-e2e.spec.ts +++ b/e2e/components/sidenav-e2e.spec.ts @@ -6,7 +6,7 @@ describe('sidenav', () => { beforeEach(() => { browser.get('/sidenav'); - sidenav = element(by.tagName('md-sidenav')); + sidenav = element(by.tagName('mat-sidenav')); }); it('should be closed', () => { diff --git a/e2e/components/slide-toggle-e2e.spec.ts b/e2e/components/slide-toggle-e2e.spec.ts index 2780cb91a008..a8c232d06d54 100644 --- a/e2e/components/slide-toggle-e2e.spec.ts +++ b/e2e/components/slide-toggle-e2e.spec.ts @@ -10,7 +10,7 @@ describe('slide-toggle', () => { beforeEach(() => browser.get('slide-toggle')); it('should render a slide-toggle', () => { - expectToExist('md-slide-toggle'); + expectToExist('mat-slide-toggle'); screenshot(); }); diff --git a/e2e/components/stepper-e2e.spec.ts b/e2e/components/stepper-e2e.spec.ts index cd9b4b3d8211..d4745dcbde0d 100644 --- a/e2e/components/stepper-e2e.spec.ts +++ b/e2e/components/stepper-e2e.spec.ts @@ -10,8 +10,8 @@ describe('stepper', () => { beforeEach(() => browser.get('/stepper')); it('should render a stepper', () => { - expectToExist('md-horizontal-stepper'); - screenshot('md-horizontal-stepper'); + expectToExist('mat-horizontal-stepper'); + screenshot('mat-horizontal-stepper'); }); describe('basic behavior', () => { @@ -19,13 +19,13 @@ describe('stepper', () => { const previousButton = element.all(by.buttonText('Back')); const nextButton = element.all(by.buttonText('Next')); - expect(element(by.css('md-step-header[aria-selected="true"]')).getText()) + expect(element(by.css('mat-step-header[aria-selected="true"]')).getText()) .toBe('1\nFill out your name'); screenshot('start'); nextButton.get(0).click(); - expect(element(by.css('md-step-header[aria-selected="true"]')).getText()) + expect(element(by.css('mat-step-header[aria-selected="true"]')).getText()) .toBe('2\nFill out your address'); await browser.wait(ExpectedConditions.not( @@ -34,7 +34,7 @@ describe('stepper', () => { previousButton.get(0).click(); - expect(element(by.css('md-step-header[aria-selected="true"]')).getText()) + expect(element(by.css('mat-step-header[aria-selected="true"]')).getText()) .toBe('1\nFill out your name'); await browser.wait(ExpectedConditions.not( @@ -43,7 +43,7 @@ describe('stepper', () => { }); it('should change focus with keyboard interaction', () => { - let stepHeaders = element.all(by.css('md-step-header')); + let stepHeaders = element.all(by.css('mat-step-header')); stepHeaders.get(0).click(); expectFocusOn(stepHeaders.get(0)); @@ -77,7 +77,7 @@ describe('stepper', () => { let nextButton = element.all(by.buttonText('Next')); nextButton.get(0).click(); - expect(element(by.css('md-step-header[aria-selected="true"]')).getText()) + expect(element(by.css('mat-step-header[aria-selected="true"]')).getText()) .toBe('1\nFill out your name'); }); }); diff --git a/e2e/components/tabs-e2e.spec.ts b/e2e/components/tabs-e2e.spec.ts index a2df986deed6..8fc2971b85d5 100644 --- a/e2e/components/tabs-e2e.spec.ts +++ b/e2e/components/tabs-e2e.spec.ts @@ -19,9 +19,9 @@ describe('tabs', () => { beforeEach(() => { browser.get('/tabs'); - tabGroup = element(by.css('md-tab-group')); + tabGroup = element(by.css('mat-tab-group')); tabLabels = element.all(by.css('.mat-tab-label')); - tabBodies = element.all(by.css('md-tab-body')); + tabBodies = element.all(by.css('mat-tab-body')); }); it('should change tabs when the label is clicked', async () => { diff --git a/e2e/components/toolbar-e2e.spec.ts b/e2e/components/toolbar-e2e.spec.ts index 6b03e4abcb56..eaabb2c36aaa 100644 --- a/e2e/components/toolbar-e2e.spec.ts +++ b/e2e/components/toolbar-e2e.spec.ts @@ -1,12 +1,12 @@ import {browser, by, element} from 'protractor'; import {screenshot} from '../screenshot'; -describe('md-toolbar', () => { +describe('mat-toolbar', () => { beforeEach(() => browser.get('/toolbar')); it('should show a toolbar', async () => { - expect(element(by.tagName('md-toolbar'))).toBeDefined(); + expect(element(by.tagName('mat-toolbar'))).toBeDefined(); screenshot('multiple toolbar components'); }); diff --git a/guides/cdk-table.md b/guides/cdk-table.md index 08a7027b3bfd..365ac59234c7 100644 --- a/guides/cdk-table.md +++ b/guides/cdk-table.md @@ -7,7 +7,7 @@ built. Because it enforces no opinions on these matters, developers have full co interaction patterns associated with the table. For a Material Design styled table, see the -[documentation for ``](https://material.angular.io/components/table) which builds on +[documentation for ``](https://material.angular.io/components/table) which builds on top of the CDK data-table. diff --git a/guides/customizing-component-styles.md b/guides/customizing-component-styles.md index a5db1a459e51..5a3a641578ac 100644 --- a/guides/customizing-component-styles.md +++ b/guides/customizing-component-styles.md @@ -30,7 +30,7 @@ You can read more about specificity and how it is calculated on the ##### Component location -Some Angular Material components, specifically overlay-based ones like MdDialog, MdSnackbar, etc., +Some Angular Material components, specifically overlay-based ones like MatDialog, MatSnackbar, etc., do not exist as children of your component. Often they are injected elsewhere in the DOM. This is important to keep in mind, since even using high specificity and shadow-piercing selectors will not target elements that are not direct children of your component. Global styles are recommended diff --git a/guides/getting-started.md b/guides/getting-started.md index d7d28ba9b550..21d9d8172e97 100644 --- a/guides/getting-started.md +++ b/guides/getting-started.md @@ -55,11 +55,11 @@ export class PizzaPartyAppModule { } Import the NgModule for each component you want to use: ```ts -import {MdButtonModule, MdCheckboxModule} from '@angular/material'; +import {MatButtonModule, MatCheckboxModule} from '@angular/material'; @NgModule({ ... - imports: [MdButtonModule, MdCheckboxModule], + imports: [MatButtonModule, MatCheckboxModule], ... }) export class PizzaPartyAppModule { } @@ -70,11 +70,11 @@ Angular Material components that you will use in your application. You can then include this module wherever you'd like to use the components. ```ts -import {MdButtonModule, MdCheckboxModule} from '@angular/material'; +import {MatButtonModule, MatCheckboxModule} from '@angular/material'; @NgModule({ - imports: [MdButtonModule, MdCheckboxModule], - exports: [MdButtonModule, MdCheckboxModule], + imports: [MatButtonModule, MatCheckboxModule], + exports: [MatButtonModule, MatCheckboxModule], }) export class MyOwnCustomMaterialModule { } ``` @@ -100,7 +100,7 @@ For more information on theming and instructions on how to create a custom theme ### Step 5: Gesture Support -Some components (`md-slide-toggle`, `md-slider`, `mdTooltip`) rely on +Some components (`mat-slide-toggle`, `mat-slider`, `matTooltip`) rely on [HammerJS](http://hammerjs.github.io/) for gestures. In order to get the full feature-set of these components, HammerJS must be loaded into the application. @@ -120,7 +120,7 @@ import 'hammerjs'; ### Step 6 (Optional): Add Material Icons -If you want to use the `md-icon` component with the official +If you want to use the `mat-icon` component with the official [Material Design Icons](https://material.io/icons/), load the icon font in your `index.html`. ```html @@ -130,7 +130,7 @@ If you want to use the `md-icon` component with the official For more information on using Material Icons, check out the [Material Icons Guide](https://google.github.io/material-design-icons/). -Note that `md-icon` supports any font or svg icons; using Material Icons is one of many options. +Note that `mat-icon` supports any font or svg icons; using Material Icons is one of many options. ### Appendix: Configuring SystemJS diff --git a/guides/theming.md b/guides/theming.md index 22a103bd0380..aca2e50fc65c 100644 --- a/guides/theming.md +++ b/guides/theming.md @@ -46,7 +46,7 @@ The actual path will depend on your server setup. You can also concatenate the file with the rest of your application's css. -Finally, if your app's content **is not** placed inside of a `md-sidenav-container` element, you +Finally, if your app's content **is not** placed inside of a `mat-sidenav-container` element, you need to add the `mat-app-background` class to your wrapper element (for example the `body`). This ensures that the proper theme background is applied to your page. diff --git a/package-lock.json b/package-lock.json index 6cf8c6caee81..064d1fcfb498 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5247,7 +5247,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -15735,7 +15735,7 @@ "write-file-atomic": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.1.0.tgz", - "integrity": "sha512-0TZ20a+xcIl4u0+Mj5xDH2yOWdmQiXlKf9Hm+TgDXjTMsEYb+gDrmb8e8UNAzMCitX8NBqG4Z/FUQIyzv/R1JQ==", + "integrity": "sha1-F2n0tVHu3OQZ8FBd6uLiZ2NULTc=", "dev": true, "requires": { "graceful-fs": "4.1.11", diff --git a/src/cdk/a11y/interactivity-checker.spec.ts b/src/cdk/a11y/interactivity-checker.spec.ts index 23473eb5ded6..e5fcdc61950d 100644 --- a/src/cdk/a11y/interactivity-checker.spec.ts +++ b/src/cdk/a11y/interactivity-checker.spec.ts @@ -21,7 +21,7 @@ describe('InteractivityChecker', () => { describe('isDisabled', () => { it('should return true for disabled elements', () => { - let elements = createElements('input', 'textarea', 'select', 'button', 'md-checkbox'); + let elements = createElements('input', 'textarea', 'select', 'button', 'mat-checkbox'); elements.forEach(el => el.setAttribute('disabled', '')); appendElements(elements); @@ -32,7 +32,7 @@ describe('InteractivityChecker', () => { }); it('should return false for elements without disabled', () => { - let elements = createElements('input', 'textarea', 'select', 'button', 'md-checkbox'); + let elements = createElements('input', 'textarea', 'select', 'button', 'mat-checkbox'); appendElements(elements); elements.forEach(el => { diff --git a/src/cdk/bidi/directionality.ts b/src/cdk/bidi/directionality.ts index 76c6985aa61c..c04962b3c85d 100644 --- a/src/cdk/bidi/directionality.ts +++ b/src/cdk/bidi/directionality.ts @@ -29,7 +29,7 @@ export type Direction = 'ltr' | 'rtl'; * We also can't re-provide the DOCUMENT token from platform-brower because the unit tests * themselves use things like `querySelector` in test code. */ -export const DIR_DOCUMENT = new InjectionToken('md-dir-doc'); +export const DIR_DOCUMENT = new InjectionToken('mat-dir-doc'); /** * The directionality (LTR / RTL) context for the application (or a subtree of it). diff --git a/src/cdk/collections/selection.ts b/src/cdk/collections/selection.ts index b2c199cfc9ef..c249544d4a33 100644 --- a/src/cdk/collections/selection.ts +++ b/src/cdk/collections/selection.ts @@ -165,7 +165,7 @@ export class SelectionModel { } /** - * Describes an event emitted when the value of a MdSelectionModel has changed. + * Describes an event emitted when the value of a MatSelectionModel has changed. * @docs-private */ export class SelectionChange { diff --git a/src/cdk/observers/observe-content.spec.ts b/src/cdk/observers/observe-content.spec.ts index 4f05369ea9c3..99e655470843 100644 --- a/src/cdk/observers/observe-content.spec.ts +++ b/src/cdk/observers/observe-content.spec.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {async, TestBed, ComponentFixture, fakeAsync, tick} from '@angular/core/testing'; -import {ObserversModule, MdMutationObserverFactory} from './observe-content'; +import {ObserversModule, MatMutationObserverFactory} from './observe-content'; // TODO(elad): `ProxyZone` doesn't seem to capture the events raised by // `MutationObserver` and needs to be investigated @@ -61,7 +61,7 @@ describe('Observe content', () => { imports: [ObserversModule], declarations: [ComponentWithDebouncedListener], providers: [{ - provide: MdMutationObserverFactory, + provide: MatMutationObserverFactory, useValue: { create: function(callback: Function) { callbacks.push(callback); diff --git a/src/cdk/observers/observe-content.ts b/src/cdk/observers/observe-content.ts index 04871646290c..c0b8dff10ecb 100644 --- a/src/cdk/observers/observe-content.ts +++ b/src/cdk/observers/observe-content.ts @@ -26,7 +26,7 @@ import {RxChain, debounceTime} from '@angular/cdk/rxjs'; * @docs-private */ @Injectable() -export class MdMutationObserverFactory { +export class MatMutationObserverFactory { create(callback): MutationObserver | null { return typeof MutationObserver === 'undefined' ? null : new MutationObserver(callback); } @@ -52,7 +52,7 @@ export class ObserveContent implements AfterContentInit, OnDestroy { @Input() debounce: number; constructor( - private _mutationObserverFactory: MdMutationObserverFactory, + private _mutationObserverFactory: MatMutationObserverFactory, private _elementRef: ElementRef, private _ngZone: NgZone) { } @@ -95,6 +95,6 @@ export class ObserveContent implements AfterContentInit, OnDestroy { @NgModule({ exports: [ObserveContent], declarations: [ObserveContent], - providers: [MdMutationObserverFactory] + providers: [MatMutationObserverFactory] }) export class ObserversModule {} diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index 1e1c3abcd9f1..bda7b7661274 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -52,20 +52,20 @@ const defaultPositionList = [ ]; /** Injection token that determines the scroll handling while the connected overlay is open. */ -export const MD_CONNECTED_OVERLAY_SCROLL_STRATEGY = - new InjectionToken<() => ScrollStrategy>('md-connected-overlay-scroll-strategy'); +export const MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY = + new InjectionToken<() => ScrollStrategy>('mat-connected-overlay-scroll-strategy'); /** @docs-private */ -export function MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): +export function MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy { return () => overlay.scrollStrategies.reposition(); } /** @docs-private */ -export const MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = { - provide: MD_CONNECTED_OVERLAY_SCROLL_STRATEGY, +export const MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = { + provide: MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY, deps: [Overlay], - useFactory: MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY, + useFactory: MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY, }; @@ -236,7 +236,7 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { private _renderer: Renderer2, templateRef: TemplateRef, viewContainerRef: ViewContainerRef, - @Inject(MD_CONNECTED_OVERLAY_SCROLL_STRATEGY) private _scrollStrategy, + @Inject(MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY) private _scrollStrategy, @Optional() private _dir: Directionality) { this._templatePortal = new TemplatePortal(templateRef, viewContainerRef); } diff --git a/src/cdk/overlay/public_api.ts b/src/cdk/overlay/public_api.ts index bc93276afde6..ec4c15d534bf 100644 --- a/src/cdk/overlay/public_api.ts +++ b/src/cdk/overlay/public_api.ts @@ -11,7 +11,7 @@ import {Overlay} from './overlay'; import {ScrollDispatchModule, VIEWPORT_RULER_PROVIDER} from '@angular/cdk/scrolling'; import { ConnectedOverlayDirective, - MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER, + MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER, OverlayOrigin, } from './overlay-directives'; import {OverlayPositionBuilder} from './position/overlay-position-builder'; @@ -24,7 +24,7 @@ export const OVERLAY_PROVIDERS: Provider[] = [ OverlayPositionBuilder, VIEWPORT_RULER_PROVIDER, OVERLAY_CONTAINER_PROVIDER, - MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER, + MAT_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER, ]; @NgModule({ diff --git a/src/cdk/overlay/scroll/close-scroll-strategy.ts b/src/cdk/overlay/scroll/close-scroll-strategy.ts index 7f6b6bf10d73..7d445ac49953 100644 --- a/src/cdk/overlay/scroll/close-scroll-strategy.ts +++ b/src/cdk/overlay/scroll/close-scroll-strategy.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ScrollStrategy, getMdScrollStrategyAlreadyAttachedError} from './scroll-strategy'; +import {ScrollStrategy, getMatScrollStrategyAlreadyAttachedError} from './scroll-strategy'; import {OverlayRef} from '../overlay-ref'; import {Subscription} from 'rxjs/Subscription'; import {ScrollDispatcher} from '@angular/cdk/scrolling'; @@ -23,7 +23,7 @@ export class CloseScrollStrategy implements ScrollStrategy { attach(overlayRef: OverlayRef) { if (this._overlayRef) { - throw getMdScrollStrategyAlreadyAttachedError(); + throw getMatScrollStrategyAlreadyAttachedError(); } this._overlayRef = overlayRef; diff --git a/src/cdk/overlay/scroll/reposition-scroll-strategy.ts b/src/cdk/overlay/scroll/reposition-scroll-strategy.ts index 69128998b801..9ef899cf384d 100644 --- a/src/cdk/overlay/scroll/reposition-scroll-strategy.ts +++ b/src/cdk/overlay/scroll/reposition-scroll-strategy.ts @@ -7,7 +7,7 @@ */ import {Subscription} from 'rxjs/Subscription'; -import {ScrollStrategy, getMdScrollStrategyAlreadyAttachedError} from './scroll-strategy'; +import {ScrollStrategy, getMatScrollStrategyAlreadyAttachedError} from './scroll-strategy'; import {OverlayRef} from '../overlay-ref'; import {ScrollDispatcher} from '@angular/cdk/scrolling'; @@ -31,7 +31,7 @@ export class RepositionScrollStrategy implements ScrollStrategy { attach(overlayRef: OverlayRef) { if (this._overlayRef) { - throw getMdScrollStrategyAlreadyAttachedError(); + throw getMatScrollStrategyAlreadyAttachedError(); } this._overlayRef = overlayRef; diff --git a/src/cdk/overlay/scroll/scroll-strategy.ts b/src/cdk/overlay/scroll/scroll-strategy.ts index d9a6bf533247..fe49d67e45f3 100644 --- a/src/cdk/overlay/scroll/scroll-strategy.ts +++ b/src/cdk/overlay/scroll/scroll-strategy.ts @@ -21,6 +21,6 @@ export interface ScrollStrategy { /** * Returns an error to be thrown when attempting to attach an already-attached scroll strategy. */ -export function getMdScrollStrategyAlreadyAttachedError(): Error { +export function getMatScrollStrategyAlreadyAttachedError(): Error { return Error(`Scroll strategy has already been attached.`); } diff --git a/src/cdk/table/row.ts b/src/cdk/table/row.ts index a15f379679c5..989355a209dd 100644 --- a/src/cdk/table/row.ts +++ b/src/cdk/table/row.ts @@ -21,7 +21,7 @@ import { import {CdkCellDef} from './cell'; /** - * The row template that can be used by the md-table. Should not be used outside of the + * The row template that can be used by the mat-table. Should not be used outside of the * material library. */ export const CDK_ROW_TEMPLATE = ``; diff --git a/src/cdk/table/table.ts b/src/cdk/table/table.ts index e00568d29961..a76b8afed00d 100644 --- a/src/cdk/table/table.ts +++ b/src/cdk/table/table.ts @@ -57,7 +57,7 @@ export class HeaderRowPlaceholder { } /** - * The table template that can be used by the md-table. Should not be used outside of the + * The table template that can be used by the mat-table. Should not be used outside of the * material library. */ export const CDK_TABLE_TEMPLATE = ` diff --git a/src/demo-app/a11y/autocomplete/autocomplete-a11y.html b/src/demo-app/a11y/autocomplete/autocomplete-a11y.html index f2a6ee6c926c..e84762443315 100644 --- a/src/demo-app/a11y/autocomplete/autocomplete-a11y.html +++ b/src/demo-app/a11y/autocomplete/autocomplete-a11y.html @@ -1,15 +1,15 @@

Filtering and selection

Select your favorite state

- - + - - + + {{ state.name }} - - - + + +

Selected value: {{ value }}

diff --git a/src/demo-app/a11y/button-toggle/button-toggle-a11y.html b/src/demo-app/a11y/button-toggle/button-toggle-a11y.html index 8f6677b7284f..4286a815e610 100644 --- a/src/demo-app/a11y/button-toggle/button-toggle-a11y.html +++ b/src/demo-app/a11y/button-toggle/button-toggle-a11y.html @@ -1,62 +1,62 @@

Single button toggle

- Yes + Yes

Button toggles with icons

- - - format_align_left - - - format_align_center - - - format_align_right - - - format_align_justify - - + + + format_align_left + + + format_align_center + + + format_align_right + + + format_align_justify + +

Multi-selection button toggle group

- - Flour - Eggs - Sugar - Milk - + + Flour + Eggs + Sugar + Milk +

Exclusive selection button toggle group

- - + + {{pie}} - - + +

Your favorite type of pie is: {{favoritePie}}

Disabled button toggle group

- - Flour - Eggs - Sugar - Milk - + + Flour + Eggs + Sugar + Milk +

Vertical button toggle group

- - Flour - Eggs - Sugar - Milk - + + Flour + Eggs + Sugar + Milk +
\ No newline at end of file diff --git a/src/demo-app/a11y/button/button-a11y.html b/src/demo-app/a11y/button/button-a11y.html index 999a9c1e7b44..71c5a7d8a086 100644 --- a/src/demo-app/a11y/button/button-a11y.html +++ b/src/demo-app/a11y/button/button-a11y.html @@ -3,50 +3,50 @@

Button elements

Click on the buttons to increase the button counter.

Current number of clicks: {{counter}}

- - - + + - -

Anchor elements

- Google search - YouTube - Google search + YouTube + - search + search - - search + search - - search + search

Buttons in different colors

- - - + + +

Disabled button

The following "cancel" button is disabled

- +
diff --git a/src/demo-app/a11y/button/button-a11y.ts b/src/demo-app/a11y/button/button-a11y.ts index aab2e3858c75..8a9398858a89 100644 --- a/src/demo-app/a11y/button/button-a11y.ts +++ b/src/demo-app/a11y/button/button-a11y.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; @Component({ moduleId: module.id, @@ -10,7 +10,7 @@ import {MdSnackBar} from '@angular/material'; export class ButtonAccessibilityDemo { counter: number = 0; - constructor(public snackBar: MdSnackBar) {} + constructor(public snackBar: MatSnackBar) {} openSnackBar(message: string) { this.snackBar.open(message, '', { diff --git a/src/demo-app/a11y/card/card-a11y.html b/src/demo-app/a11y/card/card-a11y.html index 6a1961f088ce..c896216f530c 100644 --- a/src/demo-app/a11y/card/card-a11y.html +++ b/src/demo-app/a11y/card/card-a11y.html @@ -1,8 +1,8 @@

Dogs group

Showing a card with a group of content

- - + +

Herding Group

Hound Group

Non-Sporting Group

@@ -12,25 +12,25 @@

Dogs group

Working Group

Foundation Stock Service

Miscellaneous Class

-
-
+ +

Husky

Showing a card with title only

- + Siberian Husky - +

Malamute

Showing a Card with title and subtitle.

- - Alaskan Malamute - Dog breed - + + Alaskan Malamute + Dog breed +
@@ -39,55 +39,55 @@

German Shepherd

Showing a card with title, subtitle, and a footer.

- - Dog breed - German Shepherd - + + Dog breed + German Shepherd + The German Shepherd is a breed of medium to large-sized working dog that originated in Germany. The breed's officially recognized name is German Shepherd Dog in the English language. The breed is also known as the Alsatian in Britain and Ireland. - - + + People also search for Rottweiler, Siberian Husky, Labrador Retriever, Doberman Pinscher - - + +

Dachshund

Showing a card with title, subtitle, and avatar as header and a card image.

- - - - Dachshund - Dog breed - - + + + Dachshund + Dog breed + + - + The dachshund is a short-legged, long-bodied, hound-type dog breed. - - + +

Shiba Inu

Showing a card with header, content, image, and two action buttons: "share" and "like".

- - - - Shiba Inu - Dog Breed - - - + + + + Shiba Inu + Dog Breed + + + The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan. A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was originally bred for hunting. - - - - - - + + + + + +
diff --git a/src/demo-app/a11y/card/card-a11y.ts b/src/demo-app/a11y/card/card-a11y.ts index 613d72d3af4f..1794ec63212b 100644 --- a/src/demo-app/a11y/card/card-a11y.ts +++ b/src/demo-app/a11y/card/card-a11y.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; @Component({ moduleId: module.id, @@ -10,7 +10,7 @@ import {MdSnackBar} from '@angular/material'; export class CardAccessibilityDemo { showProgress: boolean = false; - constructor(private snackBar: MdSnackBar) {} + constructor(private snackBar: MatSnackBar) {} openSnackbar(message: string) { this.snackBar.open(message, '', {duration: 2000}); diff --git a/src/demo-app/a11y/checkbox/checkbox-a11y.html b/src/demo-app/a11y/checkbox/checkbox-a11y.html index 56eca75a04f6..ecf6a3e8aa2e 100644 --- a/src/demo-app/a11y/checkbox/checkbox-a11y.html +++ b/src/demo-app/a11y/checkbox/checkbox-a11y.html @@ -1,34 +1,34 @@

Checkbox without label

- +

Standalone checkbox

- Yes, I agree to the terms and conditions + Yes, I agree to the terms and conditions
- No, I do not agree to the terms and conditions + No, I do not agree to the terms and conditions
- A partially done task + A partially done task

Nested checklist

- {{task.name}} - +
- + {{subtask.name}} - +
@@ -36,7 +36,7 @@

Nested checklist

Colored checkboxes

- Primary - Accent - Warn + Primary + Accent + Warn
diff --git a/src/demo-app/a11y/chips/chips-a11y.html b/src/demo-app/a11y/chips/chips-a11y.html index 466003f84aec..481039952be2 100644 --- a/src/demo-app/a11y/chips/chips-a11y.html +++ b/src/demo-app/a11y/chips/chips-a11y.html @@ -1,57 +1,57 @@

Basic chips

- - Carnation - Irises - Buttercup - + + Carnation + Irises + Buttercup +

Unstyled chips

- - Husky - Golden Retriever - Border Collie - + + Husky + Golden Retriever + Border Collie +

Removable chips in a form field

- - - + + + {{person.name}} - cancel - - - cancel + + + - + [matChipInputFor]="chipList" + [matChipInputAddOnBlur]="addOnBlur" + (matChipInputTokenEnd)="add($event)" /> +

Colored chips

This example is good for contrast-radio checking.

- - Primary - Accent - Warn - + + Primary + Accent + Warn +

Stacked chips

- - Lemon - Lime - Grapefruit - + + Lemon + Lime + Grapefruit +
diff --git a/src/demo-app/a11y/chips/chips-a11y.ts b/src/demo-app/a11y/chips/chips-a11y.ts index ca356a88de27..19388f77ef77 100644 --- a/src/demo-app/a11y/chips/chips-a11y.ts +++ b/src/demo-app/a11y/chips/chips-a11y.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdChipInputEvent, MdSnackBar} from '@angular/material'; +import {MatChipInputEvent, MatSnackBar} from '@angular/material'; export interface Person { @@ -36,13 +36,13 @@ export class ChipsAccessibilityDemo { { name: 'Warn', color: 'warn' } ]; - constructor(public snackBar: MdSnackBar) {} + constructor(public snackBar: MatSnackBar) {} displayMessage(message: string): void { this.message = message; } - add(event: MdChipInputEvent): void { + add(event: MatChipInputEvent): void { let input = event.input; let value = event.value; diff --git a/src/demo-app/a11y/datepicker/datepicker-a11y.html b/src/demo-app/a11y/datepicker/datepicker-a11y.html index aef7740b4bb8..ad89bde33077 100644 --- a/src/demo-app/a11y/datepicker/datepicker-a11y.html +++ b/src/demo-app/a11y/datepicker/datepicker-a11y.html @@ -1,112 +1,112 @@

Choose a date (e.g. choose your date of birth)

- - + - - - + + + Please choose a date. - - + + Please choose an earlier date. - - + +

Choose a date with touch UI (e.g. choose a payment date on mobile)

When would you like to schedule your payment?

- - + - - - + + + Please choose a date. - - + + Please choose a later date. - - + +

Choose date with startAt, min and max (e.g. schedule a departing and returning flight)

- - + - - - + + + Please choose a date. - - + + Please choose a later date. - - + + Please choose an earlier date. - - - - + + + - - - + + + Please choose a later date. - - + + Please choose a date after your departure. - - + + Please choose an earlier date. - - + +

Choose date with date filter (e.g. schedule a doctor appointment)

- - + - - - + + + Please choose a date. - - + + No appointments available on this date. - - + +
diff --git a/src/demo-app/a11y/dialog/dialog-a11y.html b/src/demo-app/a11y/dialog/dialog-a11y.html index e1593db566ad..150980cc9def 100644 --- a/src/demo-app/a11y/dialog/dialog-a11y.html +++ b/src/demo-app/a11y/dialog/dialog-a11y.html @@ -1,13 +1,13 @@

Welcome message

Activate the button to see a welcome dialog with a simple message and a close button.

- +

Choose a fruit

Active the button to choose apple or peach in a dialog.

- +

You chose: {{fruitSelectedOption}}

@@ -19,7 +19,7 @@

Neptune

Active the button to see a dialog showing information of Neptune. A Wikipedia page can be opened either in a new tab or in a stacked dialog.

- +
@@ -27,5 +27,5 @@

Address form

Active the button to fill out shipping address information in a dialog.

- +
diff --git a/src/demo-app/a11y/dialog/dialog-a11y.ts b/src/demo-app/a11y/dialog/dialog-a11y.ts index 73fb3fe565fc..4798798d45ae 100644 --- a/src/demo-app/a11y/dialog/dialog-a11y.ts +++ b/src/demo-app/a11y/dialog/dialog-a11y.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdDialog} from '@angular/material'; +import {MatDialog} from '@angular/material'; @Component({ @@ -11,7 +11,7 @@ import {MdDialog} from '@angular/material'; export class DialogAccessibilityDemo { fruitSelectedOption: string = ''; - constructor(public dialog: MdDialog) {} + constructor(public dialog: MatDialog) {} openFruitDialog() { let dialogRef = this.dialog.open(DialogFruitExampleDialog); @@ -53,7 +53,7 @@ export class DialogWelcomeExampleDialog {} templateUrl: './dialog-neptune-a11y.html' }) export class DialogNeptuneExampleDialog { - constructor(public dialog: MdDialog) { } + constructor(public dialog: MatDialog) { } showInStackedDialog() { this.dialog.open(DialogNeptuneIFrameDialog); diff --git a/src/demo-app/a11y/dialog/dialog-address-form-a11y.html b/src/demo-app/a11y/dialog/dialog-address-form-a11y.html index fd3a29c9fa53..8a95e7a89be5 100644 --- a/src/demo-app/a11y/dialog/dialog-address-form-a11y.html +++ b/src/demo-app/a11y/dialog/dialog-address-form-a11y.html @@ -1,45 +1,45 @@ -

Company

+

Company

- + - - - + + + - - + +
- - - - + + + +

- - - - - - + + + + + +

- - - + + +
- - - - - - {{postalCode.value.length}} / 5 - + + + + + + {{postalCode.value.length}} / 5 +
-
+ - - - - + + + + diff --git a/src/demo-app/a11y/dialog/dialog-fruit-a11y.html b/src/demo-app/a11y/dialog/dialog-fruit-a11y.html index f3086a812c28..cb303d41d829 100644 --- a/src/demo-app/a11y/dialog/dialog-fruit-a11y.html +++ b/src/demo-app/a11y/dialog/dialog-fruit-a11y.html @@ -1,6 +1,6 @@ -

Fruit

-
Which would you like to choose?
-
- - +

Fruit

+
Which would you like to choose?
+
+ +
diff --git a/src/demo-app/a11y/dialog/dialog-neptune-a11y.html b/src/demo-app/a11y/dialog/dialog-neptune-a11y.html index e247e83c7714..fd9e67a2e941 100644 --- a/src/demo-app/a11y/dialog/dialog-neptune-a11y.html +++ b/src/demo-app/a11y/dialog/dialog-neptune-a11y.html @@ -1,6 +1,6 @@ -

Neptune

+

Neptune

- + Neptune @@ -13,15 +13,15 @@

Neptune

astronomical units (4.50×109 km). It is named after the Roman god of the sea and has the astronomical symbol ♆, a stylised version of the god Neptune's trident.

-
+ - - + + - + Read more on Wikipedia - - + diff --git a/src/demo-app/a11y/dialog/dialog-neptune-iframe-a11y.html b/src/demo-app/a11y/dialog/dialog-neptune-iframe-a11y.html index a51b3ad5a958..da7cf120ad29 100644 --- a/src/demo-app/a11y/dialog/dialog-neptune-iframe-a11y.html +++ b/src/demo-app/a11y/dialog/dialog-neptune-iframe-a11y.html @@ -1,9 +1,9 @@ -

Neptune

+

Neptune

- + - + - - - + + + diff --git a/src/demo-app/a11y/dialog/dialog-welcome-a11y.html b/src/demo-app/a11y/dialog/dialog-welcome-a11y.html index 25c8355f7f5f..f1d0cf3074f6 100644 --- a/src/demo-app/a11y/dialog/dialog-welcome-a11y.html +++ b/src/demo-app/a11y/dialog/dialog-welcome-a11y.html @@ -10,4 +10,4 @@

Welcome to Angular Material dialog demo page!

be accessible, enabling people with disabilities to participate equally on the Web.

- + diff --git a/src/demo-app/a11y/grid-list/grid-list-a11y.html b/src/demo-app/a11y/grid-list/grid-list-a11y.html index 0316771a2c52..3627a0948176 100644 --- a/src/demo-app/a11y/grid-list/grid-list-a11y.html +++ b/src/demo-app/a11y/grid-list/grid-list-a11y.html @@ -1,42 +1,42 @@

Types of coffee (fix-height grid-list)

- - + {{tile.text}} - - + +

Types of coffee (ratio-height grid list)

- - + + {{tile.text}} - - + +

Types of coffee (fit-height grid list)

- - + {{tile.text}} - - + +

Angular team dogs (Grid list with header and footer)

- - - {{dog.name}} + + + {{dog.name}} Photo of {{dog.name}} - - Human: {{dog.human}} - - - + + Human: {{dog.human}} + + +
diff --git a/src/demo-app/a11y/icon/icon-a11y.html b/src/demo-app/a11y/icon/icon-a11y.html index 3b8bc223aa41..9c01019db4f8 100644 --- a/src/demo-app/a11y/icon/icon-a11y.html +++ b/src/demo-app/a11y/icon/icon-a11y.html @@ -1,30 +1,30 @@

Fingerprint status

Showing a status message with a purely decorative icon

- fingerprint + fingerprint Your fingerprint was recorded!

Delete icon button

Showing a button with interactive icon which can perform an action

-

Home link

Showing a link with interactive icon

- - home + + home

Done status

Showing a status indicator with an indicator icon

- done + done Done Tasks
diff --git a/src/demo-app/a11y/icon/icon-a11y.ts b/src/demo-app/a11y/icon/icon-a11y.ts index 9a5ae09bd96e..9d5d92acee14 100644 --- a/src/demo-app/a11y/icon/icon-a11y.ts +++ b/src/demo-app/a11y/icon/icon-a11y.ts @@ -1,5 +1,5 @@ import {Component, ViewEncapsulation} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; @Component({ moduleId: module.id, @@ -9,7 +9,7 @@ import {MdSnackBar} from '@angular/material'; preserveWhitespaces: false, }) export class IconAccessibilityDemo { - constructor(private snackBar: MdSnackBar) {} + constructor(private snackBar: MatSnackBar) {} deleteIcon() { this.snackBar.open('Item deleted', '', {duration: 2000}); diff --git a/src/demo-app/a11y/input/input-a11y.html b/src/demo-app/a11y/input/input-a11y.html index dabc8dc3b78a..8129ee38d788 100644 --- a/src/demo-app/a11y/input/input-a11y.html +++ b/src/demo-app/a11y/input/input-a11y.html @@ -1,57 +1,57 @@

Basic input box (e.g. name field)

- - - - - - + + + + + +

Input with hint (e.g. password field)

- - + - - Hint: favorite color - You must enter your password. - + Hint: favorite color + You must enter your password. +

Input with error message (e.g. email field)

- - + - You must enter your email. - Not a valid email address. - + You must enter your email. + Not a valid email address. +

Input with prefix & suffix (e.g. currency converter)

- - - $ - + + + $ + = - - - ‎¥‎ - + + + ‎¥‎ + (as of 7/31/2017)

Textarea input (e.g. comment box)

- - - Leave us a comment! - {{commentCount}}/{{commentMax}} - + Leave us a comment! + {{commentCount}}/{{commentMax}} +
diff --git a/src/demo-app/a11y/menu/menu-a11y.html b/src/demo-app/a11y/menu/menu-a11y.html index 250143c1a87d..0b810c70e2f7 100644 --- a/src/demo-app/a11y/menu/menu-a11y.html +++ b/src/demo-app/a11y/menu/menu-a11y.html @@ -2,52 +2,52 @@

Icon Trigger

- - - - + + + + -

Menu with Icons

- - - - - - +

Menu with links

- - - + + Angular - + Angular Material - +
diff --git a/src/demo-app/a11y/progress-bar/progress-bar-a11y.html b/src/demo-app/a11y/progress-bar/progress-bar-a11y.html index 60c14531c45d..416f7e64e237 100644 --- a/src/demo-app/a11y/progress-bar/progress-bar-a11y.html +++ b/src/demo-app/a11y/progress-bar/progress-bar-a11y.html @@ -1,24 +1,24 @@

Survey progress (Determinate progress bar)

- - +

Video progress (Progress bar with buffer)

- - +

Loading content progress (Indeterminate progress bar)

- - + +

Search progress (Query progress bar)

- +
diff --git a/src/demo-app/a11y/progress-spinner/progress-spinner-a11y.html b/src/demo-app/a11y/progress-spinner/progress-spinner-a11y.html index ea7809a443eb..acf69bb60136 100644 --- a/src/demo-app/a11y/progress-spinner/progress-spinner-a11y.html +++ b/src/demo-app/a11y/progress-spinner/progress-spinner-a11y.html @@ -1,16 +1,16 @@

Loading indicator (Indeterminate progress spinner)

- - + +

Portion of pizza eaten (Determinate progress spinner)

- - - + - +
diff --git a/src/demo-app/a11y/radio/radio-a11y.html b/src/demo-app/a11y/radio/radio-a11y.html index 7ae213f85fed..8a349a95f967 100644 --- a/src/demo-app/a11y/radio/radio-a11y.html +++ b/src/demo-app/a11y/radio/radio-a11y.html @@ -1,19 +1,19 @@

Radio buttons in group

- - + + {{season}} - - + +

Radio buttons with align-end label position

- - Toast - Biscuit - Bagel - + + Toast + Biscuit + Bagel +
@@ -22,15 +22,15 @@

Disabled radio buttons

This section contains three radio buttons for "Yes", "No", and "Maybe". The "Maybe" radio button is disabled.

- Yes - No - Maybe + Yes + No + Maybe

Radio buttons with different colors

- Default (accent) - Primary - Accent - Warn + Default (accent) + Primary + Accent + Warn
diff --git a/src/demo-app/a11y/select/select-a11y.html b/src/demo-app/a11y/select/select-a11y.html index 4ca8f71378dd..829809d74987 100644 --- a/src/demo-app/a11y/select/select-a11y.html +++ b/src/demo-app/a11y/select/select-a11y.html @@ -2,89 +2,89 @@

Single selection

Select your favorite color

- - - + + + {{ color.label }} - - - + + +

Multiple selection

Pick toppings for your pizza

- - - + + + {{ topping.label }} - - - + + +

Grouped options

Pick your Pokemon

- - - - + + + + {{ creature.label }} - - - - + + + +

Colors

- - - 2000 - 2100 - - + + + 2000 + 2100 + + - - - Alaska - Alabama - - + + + Alaska + Alabama + + - - - English - Spanish - - + + + English + Spanish + +
- - - Mihiramon - Sandiramon - - + + + Mihiramon + Sandiramon + + - - - Water - Coke - - + + + Water + Coke + + - - - Light - Dark - - + + + Light + Dark + +
diff --git a/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.html b/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.html index 3fe2d1ef16be..80ae889df807 100644 --- a/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.html +++ b/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.html @@ -1,28 +1,28 @@

Receive email update

Showing a toggle to manage whether receive email update.

- + Receive email update - +

Music

Showing a disabled toggle to control music on/off status.

- + Music {{musicToggle ? 'on' : 'off'}} (disabled) - +

Terms and conditions

Showing a required toggle to accept terms and conditions in a form.

- + I agree to terms and conditions - +

- +

diff --git a/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.ts b/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.ts index 6975bcfcd8ba..58c3ff2c6a3f 100644 --- a/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.ts +++ b/src/demo-app/a11y/slide-toggle/slide-toggle-a11y.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; @Component({ @@ -12,7 +12,7 @@ export class SlideToggleAccessibilityDemo { termsToggle: boolean = false; musicToggle: boolean = false; - constructor(private snackBar: MdSnackBar) {} + constructor(private snackBar: MatSnackBar) {} onFormSubmit() { this.snackBar.open('Terms and condistions accepted!', '', {duration: 2000}); diff --git a/src/demo-app/a11y/slider/slider-a11y.html b/src/demo-app/a11y/slider/slider-a11y.html index b4d31868b510..baa781c32f0c 100644 --- a/src/demo-app/a11y/slider/slider-a11y.html +++ b/src/demo-app/a11y/slider/slider-a11y.html @@ -5,15 +5,15 @@

Continuous slider (e.g. color component sliders)

- +
- +
- +
@@ -23,7 +23,7 @@

Continuous slider (e.g. color component sliders)

Discrete slider (e.g. rate a product)

Please rate our product on a scale of 1 (not satisfied) to 5 (extremely satisfied).

- +
@@ -31,9 +31,9 @@

Vertical slider (e.g. volume control)

Use the slider to adjust the volume.

- +
diff --git a/src/demo-app/a11y/snack-bar/snack-bar-a11y.html b/src/demo-app/a11y/snack-bar/snack-bar-a11y.html index 0065282adccb..45e955476faf 100644 --- a/src/demo-app/a11y/snack-bar/snack-bar-a11y.html +++ b/src/demo-app/a11y/snack-bar/snack-bar-a11y.html @@ -1,7 +1,7 @@

Notification

Showing a notification by snack bar without showing actions

-
@@ -9,5 +9,5 @@

Notification

Disco party

Showing a notification by snack bar with a dismiss button

- +
diff --git a/src/demo-app/a11y/snack-bar/snack-bar-a11y.ts b/src/demo-app/a11y/snack-bar/snack-bar-a11y.ts index 8a4953fc8061..b36ad0bc69b1 100644 --- a/src/demo-app/a11y/snack-bar/snack-bar-a11y.ts +++ b/src/demo-app/a11y/snack-bar/snack-bar-a11y.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; @Component({ moduleId: module.id, @@ -7,7 +7,7 @@ import {MdSnackBar} from '@angular/material'; templateUrl: 'snack-bar-a11y.html', }) export class SnackBarAccessibilityDemo { - constructor(private snackBar: MdSnackBar) {} + constructor(private snackBar: MatSnackBar) {} openDiscoPartySnackBar() { this.snackBar.open('Disco party!', 'Dismiss', {duration: 5000}); diff --git a/src/demo-app/a11y/tabs/tabs-a11y.html b/src/demo-app/a11y/tabs/tabs-a11y.html index af66c3b2889e..d391431dc90a 100644 --- a/src/demo-app/a11y/tabs/tabs-a11y.html +++ b/src/demo-app/a11y/tabs/tabs-a11y.html @@ -2,8 +2,8 @@

Weather

Switch tabs to navigate

-
- + Weather

Dog breeds

Dynamic height tabs

- - - {{tab.label}} + + + {{tab.label}}
{{tab.content}}
@@ -57,7 +57,7 @@

Dog breeds


- - + + diff --git a/src/demo-app/a11y/toolbar/toolbar-a11y.html b/src/demo-app/a11y/toolbar/toolbar-a11y.html index d50e35d6ccc3..064da06c75d9 100644 --- a/src/demo-app/a11y/toolbar/toolbar-a11y.html +++ b/src/demo-app/a11y/toolbar/toolbar-a11y.html @@ -1,40 +1,40 @@

Basic Toolbar with Text (e.g. Only display app’s name)

- +

My App

-
+

Hello World!

Multiple Lines Toolbar

- +

Settings

-
- + +

Profile

-
+

My profile

Toolbar with favorite icon

- +

My App

- -
+

Hello World!

Toolbar colors

- +

My App

-
+

Hello World!

diff --git a/src/demo-app/a11y/tooltip/tooltip-a11y.html b/src/demo-app/a11y/tooltip/tooltip-a11y.html index 14c2307cd09b..699f019dfcee 100644 --- a/src/demo-app/a11y/tooltip/tooltip-a11y.html +++ b/src/demo-app/a11y/tooltip/tooltip-a11y.html @@ -1,14 +1,14 @@

Mouse over or tab to trigger a tooltip

Mouse over or focus the button to show and hide the tooltip

- +

Click to trigger a tooltip

- - + +
@@ -16,30 +16,30 @@

Click to trigger a tooltip

Different tooltip positions

+ mat-raised-button + matTooltip="This tooltip appears below the trigger" + matTooltipPosition="below">Below + mat-raised-button + matTooltip="This tooltip appears above the trigger" + matTooltipPosition="above">Above + mat-raised-button + matTooltip="This tooltip appears to the left of the trigger" + matTooltipPosition="left">Left + mat-raised-button + matTooltip="This tooltip appears to the right of the trigger" + matTooltipPosition="right">Right

Delayed tooltip

+ mat-raised-button + matTooltip="This tooltip will show up after a delay" + [matTooltipShowDelay]="2000">What is this?
diff --git a/src/demo-app/autocomplete/autocomplete-demo.html b/src/demo-app/autocomplete/autocomplete-demo.html index 5ca27f2a5d0b..e31478d10b25 100644 --- a/src/demo-app/autocomplete/autocomplete-demo.html +++ b/src/demo-app/autocomplete/autocomplete-demo.html @@ -1,87 +1,87 @@ Space above cards:
- + Reactive length: {{ reactiveStates.length }}
Reactive value: {{ stateCtrl.value | json }}
Reactive dirty: {{ stateCtrl.dirty }}
- - - - + + + + {{ state.name }} ({{state.code}}) - - - + + + - - - - + + - + -
+ - +
Template-driven value (currentState): {{ currentState }}
Template-driven dirty: {{ modelDir ? modelDir.dirty : false }}
- - + - - + + {{ state.name }} - - - + + + - - - - + + - + -
+ - +
Option groups (currentGroupedState): {{ currentGroupedState }}
- + - -
+ +
- - + + {{ state.name }} ({{state.code}}) - - + + - - + + {{ state.name }} - - + + - - + - {{ state.name }} - - + {{ state.name }} + + diff --git a/src/demo-app/baseline/baseline-demo.html b/src/demo-app/baseline/baseline-demo.html index ba4568cb36d5..8a695ce1c7f4 100644 --- a/src/demo-app/baseline/baseline-demo.html +++ b/src/demo-app/baseline/baseline-demo.html @@ -1,61 +1,61 @@ - - Basic Forms - + + Basic Forms + Text Before | - Checkbox Label + Checkbox Label | Text 1 | - Radio 1 + Radio 1 | Text 2 | - Radio 2 + Radio 2 | Text 3 | - Radio 3 + Radio 3 | Text 4 | - - - + + + | Text 5 | - - - Option - This option is really really really long - - + + + Option + This option is really really really long + + | Text 6 | - - - + + + | Text After - - + + - - Headers - + + Headers +

Text Before | - Checkbox Label + Checkbox Label | Text 1 | - Radio 1 + Radio 1 | Text 2 | - Radio 2 + Radio 2 | Text 3 | - Radio 3 + Radio 3 | Text 4 | - - - + + + | Text 5 | - - - Option - This option is really really really long - - + + + Option + This option is really really really long + + | Text 6 | - - - + + + | Text After

-
-
+ + diff --git a/src/demo-app/button-toggle/button-toggle-demo.html b/src/demo-app/button-toggle/button-toggle-demo.html index 0d158c21ecc3..3d81775b284e 100644 --- a/src/demo-app/button-toggle/button-toggle-demo.html +++ b/src/demo-app/button-toggle/button-toggle-demo.html @@ -1,57 +1,57 @@

- Show Button Toggles Vertical + Show Button Toggles Vertical

- Disable Button Toggle Items + Disable Button Toggle Items

Exclusive Selection

- - format_align_left - format_align_center - format_align_right - format_align_justify - + + format_align_left + format_align_center + format_align_right + format_align_justify +

Disabled Group

- - - format_bold - - - format_italic - - - format_underline - - + + + format_bold + + + format_italic + + + format_underline + +

Multiple Selection

- - Flour - Eggs - Sugar - Milk - + + Flour + Eggs + Sugar + Milk +

Single Toggle

-Yes +Yes

Dynamic Exclusive Selection

- - + + {{pie}} - - + +

Your favorite type of pie is: {{favoritePie}}

diff --git a/src/demo-app/button/button-demo.html b/src/demo-app/button/button-demo.html index 98a31e38b9a1..38ffdfd83e83 100644 --- a/src/demo-app/button/button-demo.html +++ b/src/demo-app/button/button-demo.html @@ -1,113 +1,113 @@
- - - + + - - Link - check - + Link + check + - - Link + + Link
- SEARCH - SEARCH - - check + SEARCH + SEARCH + + check - - check + + check
- - - + + +
- - - + + +
- - -
- - -

isDisabled: {{isDisabled}}, clickCounter: {{clickCounter}}

- - - - + + +
- - - off - - + + off + + -
- SEARCH - + SEARCH +
- SEARCH - + SEARCH +
- - - - + + + +
- - - - + + + +
- - + +
diff --git a/src/demo-app/card/card-demo.html b/src/demo-app/card/card-demo.html index 98cc322d20e3..599e37891553 100644 --- a/src/demo-app/card/card-demo.html +++ b/src/demo-app/card/card-demo.html @@ -1,61 +1,61 @@
- + Hello - + - - - Card with title - Subtitle - - - + + + Card with title + Subtitle + + + - - Subtitle - Card with title and footer - + + Subtitle + Card with title and footer +

This is supporting text.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

-
- - - - - - - -
+ + + + + + + + + - - - Content Title - + + + Content Title +

Here is some content

-
- - - - -
+ + + + + + - - - - Header title - Header subtitle - - - + + + + Header title + Header subtitle + + +

Here is some content

-
-
+ + - - Easily customizable - - - - - + + Easily customizable + + + + +
diff --git a/src/demo-app/checkbox/checkbox-demo.html b/src/demo-app/checkbox/checkbox-demo.html index 28760dac161c..0faf25ebd0fb 100644 --- a/src/demo-app/checkbox/checkbox-demo.html +++ b/src/demo-app/checkbox/checkbox-demo.html @@ -1,6 +1,6 @@ -

md-checkbox: Basic Example

+

mat-checkbox: Basic Example

-md-checkbox: Basic Example [align]="alignment"> Do you want to foobar the bazquux? - - {{printResult()}} + - {{printResult()}}
md-checkbox: Basic Example

Pseudo checkboxes

- - + + - - + + - - + +

Nested Checklist

- + diff --git a/src/demo-app/checkbox/checkbox-demo.ts b/src/demo-app/checkbox/checkbox-demo.ts index 9e507ea2506e..e7331d047770 100644 --- a/src/demo-app/checkbox/checkbox-demo.ts +++ b/src/demo-app/checkbox/checkbox-demo.ts @@ -9,7 +9,7 @@ export interface Task { @Component({ moduleId: module.id, - selector: 'md-checkbox-demo-nested-checklist', + selector: 'mat-checkbox-demo-nested-checklist', styles: [` li { margin-bottom: 4px; @@ -17,7 +17,7 @@ export interface Task { `], templateUrl: 'nested-checklist.html', }) -export class MdCheckboxDemoNestedChecklist { +export class MatCheckboxDemoNestedChecklist { tasks: Task[] = [ { name: 'Reminders', @@ -63,7 +63,7 @@ export class MdCheckboxDemoNestedChecklist { @Component({ moduleId: module.id, - selector: 'md-checkbox-demo', + selector: 'mat-checkbox-demo', templateUrl: 'checkbox-demo.html', styleUrls: ['checkbox-demo.css'], }) diff --git a/src/demo-app/checkbox/nested-checklist.html b/src/demo-app/checkbox/nested-checklist.html index 71c77d83f2e5..6a4ab3e617ab 100644 --- a/src/demo-app/checkbox/nested-checklist.html +++ b/src/demo-app/checkbox/nested-checklist.html @@ -1,17 +1,17 @@

Tasks

  • -

    {{task.name}}

    -
    +
    • - + {{subtask.name}} - +
  • diff --git a/src/demo-app/chips/chips-demo.html b/src/demo-app/chips/chips-demo.html index 4673b48b256a..6df231e28ee0 100644 --- a/src/demo-app/chips/chips-demo.html +++ b/src/demo-app/chips/chips-demo.html @@ -1,104 +1,104 @@
    - - Static Chips + + Static Chips - +

    Simple

    - - Chip 1 - Chip 2 - Chip 3 - + + Chip 1 + Chip 2 + Chip 3 +

    Unstyled

    - - Basic Chip 1 - Basic Chip 2 - Basic Chip 3 - + + Basic Chip 1 + Basic Chip 2 + Basic Chip 3 +

    Advanced

    - - Selected/Colored + + Selected/Colored - With Events - cancel - - + cancel + +
    {{message}}
    -
    -
    + + - - Dynamic Chips + + Dynamic Chips - +

    Form Field

    - You can easily put the the <md-chip-list> inside of an - <md-form-field>. + You can easily put the the <mat-chip-list> inside of an + <mat-form-field>.

    - - - - + + {{person.name}} - cancel - + cancel + - - + [matChipInputFor]="chipList1" + [matChipInputSeparatorKeyCodes]="separatorKeysCodes" + [matChipInputAddOnBlur]="false" + (matChipInputTokenEnd)="add($event)" /> + +

    - You can also put <md-form-field> outside of an md-chip-list. - With mdChipInput the input work with chip-list + You can also put <mat-form-field> outside of an mat-chip-list. + With matChipInput the input work with chip-list

    - - - + + {{person.name}} - cancel - - + cancel + + - + [matChipInputFor]="chipList2" + [matChipInputSeparatorKeyCodes]="separatorKeysCodes" + [matChipInputAddOnBlur]="addOnBlur" + (matChipInputTokenEnd)="add($event)" /> +

    Chips list without input

    - - - + + {{person.name}} - cancel - - - + cancel + + +

    @@ -108,9 +108,9 @@

    Form Field

    Options

    - Selectable - Removable - Add on Blur + Selectable + Removable + Add on Blur

    Stacked Chips

    @@ -120,34 +120,34 @@

    Stacked Chips

    (focus) event to run custom code.

    - - + {{aColor.name}} - - + +

    NgModel with chip list

    - - + {{aColor.name}} - cancel - - + cancel + + The selected colors are {{color}}.

    NgModel with single selection chip list

    - - + {{aColor.name}} - cancel - - + cancel + + The selected color is {{selectedColor}}. -
    -
    + +
    diff --git a/src/demo-app/chips/chips-demo.scss b/src/demo-app/chips/chips-demo.scss index 5928eef7375b..648001486a03 100644 --- a/src/demo-app/chips/chips-demo.scss +++ b/src/demo-app/chips/chips-demo.scss @@ -21,7 +21,7 @@ margin: auto 10px; } - md-chip-list input { + mat-chip-list input { width: 150px; } } diff --git a/src/demo-app/chips/chips-demo.ts b/src/demo-app/chips/chips-demo.ts index 4d5995aed4a3..ad3620047c67 100644 --- a/src/demo-app/chips/chips-demo.ts +++ b/src/demo-app/chips/chips-demo.ts @@ -1,6 +1,6 @@ import {ENTER} from '@angular/cdk/keycodes'; import {Component} from '@angular/core'; -import {MdChipInputEvent} from '@angular/material'; +import {MatChipInputEvent} from '@angular/material'; const COMMA = 188; @@ -53,7 +53,7 @@ export class ChipsDemo { this.message = message; } - add(event: MdChipInputEvent): void { + add(event: MatChipInputEvent): void { let input = event.input; let value = event.value; diff --git a/src/demo-app/datepicker/datepicker-demo.html b/src/demo-app/datepicker/datepicker-demo.html index 9f55b0820c61..127c5ec2bc8d 100644 --- a/src/demo-app/datepicker/datepicker-demo.html +++ b/src/demo-app/datepicker/datepicker-demo.html @@ -1,107 +1,107 @@

    Options

    - Use touch UI - Filter odd months and dates - Start in year view - Disable datepicker - Disable input + Use touch UI + Filter odd months and dates + Start in year view + Disable datepicker + Disable input

    - - + - - - - - + + + + - - - + + +

    - - + - - - + + +

    Result

    - - - + + - - - - "{{resultPickerModel.getError('mdDatepickerParse').text}}" is not a valid date! - - Too early! - Too late! - Date unavailable! - + + + "{{resultPickerModel.getError('matDatepickerParse').text}}" is not a valid date! + + Too early! + Too late! + Date unavailable! +

    Last input: {{lastDateInput}}

    Last change: {{lastDateChange}}


    - - + - +

    Input disabled datepicker

    - - - + + - - + +

    Input disabled, datepicker popup enabled

    - - - + + - - + +

    diff --git a/src/demo-app/datepicker/datepicker-demo.scss b/src/demo-app/datepicker/datepicker-demo.scss index c98cba687f8c..9672ffb589e1 100644 --- a/src/demo-app/datepicker/datepicker-demo.scss +++ b/src/demo-app/datepicker/datepicker-demo.scss @@ -1,3 +1,3 @@ -md-calendar { +mat-calendar { width: 300px; } diff --git a/src/demo-app/datepicker/datepicker-demo.ts b/src/demo-app/datepicker/datepicker-demo.ts index 3fc61b0b3144..fe363d322b5e 100644 --- a/src/demo-app/datepicker/datepicker-demo.ts +++ b/src/demo-app/datepicker/datepicker-demo.ts @@ -1,5 +1,5 @@ import {ChangeDetectionStrategy, Component} from '@angular/core'; -import {MdDatepickerInputEvent} from '@angular/material'; +import {MatDatepickerInputEvent} from '@angular/material'; @Component({ @@ -24,6 +24,6 @@ export class DatepickerDemo { dateFilter = (date: Date) => date.getMonth() % 2 == 1 && date.getDate() % 2 == 0; - onDateInput = (e: MdDatepickerInputEvent) => this.lastDateInput = e.value; - onDateChange = (e: MdDatepickerInputEvent) => this.lastDateChange = e.value; + onDateInput = (e: MatDatepickerInputEvent) => this.lastDateInput = e.value; + onDateChange = (e: MatDatepickerInputEvent) => this.lastDateChange = e.value; } diff --git a/src/demo-app/demo-app/demo-app.html b/src/demo-app/demo-app/demo-app.html index 7138842d1a48..496b93d96346 100644 --- a/src/demo-app/demo-app/demo-app.html +++ b/src/demo-app/demo-app/demo-app.html @@ -1,8 +1,8 @@ - - - + + + - Baseline - - - + + +
    - -

    Angular Material Demos

    - - - +
    -
    +
    -
    + diff --git a/src/demo-app/demo-app/demo-module.ts b/src/demo-app/demo-app/demo-module.ts index 80e21dbe5c26..b73d8c9dd38b 100644 --- a/src/demo-app/demo-app/demo-module.ts +++ b/src/demo-app/demo-app/demo-module.ts @@ -8,7 +8,7 @@ import {BaselineDemo} from '../baseline/baseline-demo'; import {ButtonToggleDemo} from '../button-toggle/button-toggle-demo'; import {ButtonDemo} from '../button/button-demo'; import {CardDemo} from '../card/card-demo'; -import {CheckboxDemo, MdCheckboxDemoNestedChecklist} from '../checkbox/checkbox-demo'; +import {CheckboxDemo, MatCheckboxDemoNestedChecklist} from '../checkbox/checkbox-demo'; import {ChipsDemo} from '../chips/chips-demo'; import {DatepickerDemo} from '../datepicker/datepicker-demo'; import {DemoMaterialModule} from '../demo-material-module'; @@ -79,7 +79,7 @@ import {DEMO_APP_ROUTES} from './routes'; JazzDialog, ListDemo, LiveAnnouncerDemo, - MdCheckboxDemoNestedChecklist, + MatCheckboxDemoNestedChecklist, MenuDemo, OverlayDemo, PlatformDemo, diff --git a/src/demo-app/demo-material-module.ts b/src/demo-app/demo-material-module.ts index 1cf016b7a2dc..4da1bc2e0575 100644 --- a/src/demo-app/demo-material-module.ts +++ b/src/demo-app/demo-material-module.ts @@ -1,37 +1,37 @@ import {NgModule} from '@angular/core'; import { - MdAutocompleteModule, - MdButtonModule, - MdButtonToggleModule, - MdCardModule, - MdCheckboxModule, - MdChipsModule, - MdDatepickerModule, - MdDialogModule, - MdExpansionModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdPaginatorModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdSelectModule, - MdSidenavModule, - MdSliderModule, - MdSlideToggleModule, - MdSnackBarModule, - MdSortModule, - MdTableModule, - MdTabsModule, - MdToolbarModule, - MdTooltipModule, - MdStepperModule, + MatAutocompleteModule, + MatButtonModule, + MatButtonToggleModule, + MatCardModule, + MatCheckboxModule, + MatChipsModule, + MatDatepickerModule, + MatDialogModule, + MatExpansionModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatPaginatorModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatSelectModule, + MatSidenavModule, + MatSliderModule, + MatSlideToggleModule, + MatSnackBarModule, + MatSortModule, + MatTableModule, + MatTabsModule, + MatToolbarModule, + MatTooltipModule, + MatStepperModule, } from '@angular/material'; -import {MdNativeDateModule, MdRippleModule} from '@angular/material'; +import {MatNativeDateModule, MatRippleModule} from '@angular/material'; import {CdkTableModule} from '@angular/cdk/table'; import {A11yModule} from '@angular/cdk/a11y'; import {BidiModule} from '@angular/cdk/bidi'; @@ -45,38 +45,38 @@ import {PortalModule} from '@angular/cdk/portal'; */ @NgModule({ exports: [ - MdAutocompleteModule, - MdButtonModule, - MdButtonToggleModule, - MdCardModule, - MdCheckboxModule, - MdChipsModule, - MdTableModule, - MdDatepickerModule, - MdDialogModule, - MdExpansionModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdPaginatorModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdRippleModule, - MdSelectModule, - MdSidenavModule, - MdSlideToggleModule, - MdSliderModule, - MdSnackBarModule, - MdSortModule, - MdStepperModule, - MdTabsModule, - MdToolbarModule, - MdTooltipModule, - MdNativeDateModule, + MatAutocompleteModule, + MatButtonModule, + MatButtonToggleModule, + MatCardModule, + MatCheckboxModule, + MatChipsModule, + MatTableModule, + MatDatepickerModule, + MatDialogModule, + MatExpansionModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatPaginatorModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatRippleModule, + MatSelectModule, + MatSidenavModule, + MatSlideToggleModule, + MatSliderModule, + MatSnackBarModule, + MatSortModule, + MatStepperModule, + MatTabsModule, + MatToolbarModule, + MatTooltipModule, + MatNativeDateModule, CdkTableModule, A11yModule, BidiModule, diff --git a/src/demo-app/dialog/dialog-demo.html b/src/demo-app/dialog/dialog-demo.html index e5d40ad94b34..ffceaaae13bf 100644 --- a/src/demo-app/dialog/dialog-demo.html +++ b/src/demo-app/dialog/dialog-demo.html @@ -1,81 +1,81 @@

    Dialog demo

    - - - - - + +

    Dialog dimensions

    - - - - - - + + + + + +

    Dialog position

    - - - - - - + + + + + +

    - - - - - - + + + + + +

    Dialog backdrop

    - - - + + +

    - Has backdrop + Has backdrop

    Other options

    - - - Start - End - Center - - + + + Start + End + Center + +

    - - - + + +

    - Disable close + Disable close

    -
    -
    + +

    Last afterClosed result: {{lastAfterClosedResult}}

    Last beforeClose result: {{lastBeforeCloseResult}}

    @@ -85,9 +85,9 @@

    Other options

    It's Jazz!

    - - - + + +

    {{ data.message }}

    diff --git a/src/demo-app/dialog/dialog-demo.ts b/src/demo-app/dialog/dialog-demo.ts index 339fcbffa018..87c67b151e18 100644 --- a/src/demo-app/dialog/dialog-demo.ts +++ b/src/demo-app/dialog/dialog-demo.ts @@ -1,6 +1,6 @@ import {Component, Inject, ViewChild, TemplateRef} from '@angular/core'; import {DOCUMENT} from '@angular/platform-browser'; -import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material'; +import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; @Component({ @@ -10,7 +10,7 @@ import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material'; styleUrls: ['dialog-demo.css'], }) export class DialogDemo { - dialogRef: MdDialogRef | null; + dialogRef: MatDialogRef | null; lastAfterClosedResult: string; lastBeforeCloseResult: string; actionsAlignment: string; @@ -35,7 +35,7 @@ export class DialogDemo { @ViewChild(TemplateRef) template: TemplateRef; - constructor(public dialog: MdDialog, @Inject(DOCUMENT) doc: any) { + constructor(public dialog: MatDialog, @Inject(DOCUMENT) doc: any) { // Possible useful example for the open and closeAll events. // Adding a class to the body if a dialog opens and // removing it after all open dialogs are closed @@ -78,9 +78,9 @@ export class DialogDemo { template: `

    It's Jazz!

    - - - + + +

    {{ data.message }}

    @@ -90,8 +90,8 @@ export class JazzDialog { private _dimesionToggle = false; constructor( - public dialogRef: MdDialogRef, - @Inject(MD_DIALOG_DATA) public data: any) { } + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { } togglePosition(): void { this._dimesionToggle = !this._dimesionToggle; @@ -117,9 +117,9 @@ export class JazzDialog { }` ], template: ` -

    Neptune

    +

    Neptune

    - +

    @@ -131,32 +131,32 @@ export class JazzDialog { astronomical units (4.50×109 km). It is named after the Roman god of the sea and has the astronomical symbol ♆, a stylised version of the god Neptune's trident.

    -
    + - + + mat-dialog-close>Close Read more on Wikipedia - + ` }) export class ContentElementDialog { actionsAlignment: string; - constructor(public dialog: MdDialog) { } + constructor(public dialog: MatDialog) { } showInStackedDialog() { this.dialog.open(IFrameDialog); @@ -171,18 +171,18 @@ export class ContentElementDialog { }` ], template: ` -

    Neptune

    +

    Neptune

    - + - + - + - + mat-dialog-close>Close + ` }) export class IFrameDialog { diff --git a/src/demo-app/drawer/drawer-demo.html b/src/demo-app/drawer/drawer-demo.html index 3a2dddc4d1d2..a7f54541bc12 100644 --- a/src/demo-app/drawer/drawer-demo.html +++ b/src/demo-app/drawer/drawer-demo.html @@ -1,58 +1,58 @@

    Basic Use Case

    - - + + Start Side Drawer
    - +
    - +
    -
    Mode: {{start.mode}}

    -
    + - + End Side Drawer
    - -
    + +

    My Content

    Drawer
    - - + +
    - - - + + +
    -
    +

    Drawer Already Opened

    - - + + Drawer - +
    - +
    -
    +

    Dynamic Position Drawer

    - - Start - End + + Start + End
    -
    +

    Drawer with focus attributes

    - - - - Link - Focus region start - Link - Initially focused - Focus region end - Link - - + + + + Link + Focus region start + Link + Initially focused + Focus region end + Link + +

    My Content

    Drawer
    - +
    -
    + diff --git a/src/demo-app/expansion/expansion-demo.html b/src/demo-app/expansion/expansion-demo.html index e22b96339de9..b14c6434c650 100644 --- a/src/demo-app/expansion/expansion-demo.html +++ b/src/demo-app/expansion/expansion-demo.html @@ -1,64 +1,64 @@

    Single Expansion Panel

    - - + + This is a panel description. Panel Title - + This is the content text that makes sense here. - - - - - + + + + +
    - - - + + + - - - + + +

    Accordion

    Accordion Options

    - Allow Multi Expansion - Hide Indicators - Disable Panel 2 - Show Panel 3 + Allow Multi Expansion + Hide Indicators + Disable Panel 2 + Show Panel 3

    Accordion Style

    - - Default - Flat - + + Default + Flat +

    Accordion Panel(s)

    - Panel 1 - Panel 2 + Panel 1 + Panel 2

    - - - Section 1 + + + Section 1

    This is the content text that makes sense here.

    -
    - - Section 2 + + + Section 2

    This is the content text that makes sense here.

    -
    - - Section 3 - Reveal Buttons Below - - - - - -
    + + + Section 3 + Reveal Buttons Below + + + + + + diff --git a/src/demo-app/expansion/expansion-demo.scss b/src/demo-app/expansion/expansion-demo.scss index df5591b49721..b8ef2d203d35 100644 --- a/src/demo-app/expansion/expansion-demo.scss +++ b/src/demo-app/expansion/expansion-demo.scss @@ -1,4 +1,4 @@ -.md-expansion-demo-width { +.mat-expansion-demo-width { width: 600px; display: block; } diff --git a/src/demo-app/grid-list/grid-list-demo.html b/src/demo-app/grid-list/grid-list-demo.html index 6a915d77f7d1..a9e869cfcc69 100644 --- a/src/demo-app/grid-list/grid-list-demo.html +++ b/src/demo-app/grid-list/grid-list-demo.html @@ -1,91 +1,91 @@
    - - Basic grid list - - - One - Two - Three - Four - - - + + Basic grid list + + + One + Two + Three + Four + + + - - Fixed-height grid list - - - + Fixed-height grid list + + + {{tile.text}} - - - - + + + +

    Change list cols:

    Change row height:

    - -
    -
    + + + - - Ratio-height grid list - - - + + Ratio-height grid list + + + {{tile.text}} - - - - + + + +

    Change ratio:

    -
    -
    + + - - Fit-height grid list - - + Fit-height grid list + + - + {{tile.text}} - - - - + + + +

    Change list height:

    Change gutter:

    -
    -
    + + - - Grid list with header - - - - - info_outline + + Grid list with header + + + + + info_outline {{dog.name}} - - - - - + + + + + - - Grid list with footer - - - + + Grid list with footer + + + - -

    {{dog.name}}

    - Human: {{dog.human}} - star_border -
    -
    -
    -
    -
    + +

    {{dog.name}}

    + Human: {{dog.human}} + star_border +
    + + + +
    diff --git a/src/demo-app/icon/icon-demo.html b/src/demo-app/icon/icon-demo.html index 338c4717ff9f..6067745806b6 100644 --- a/src/demo-app/icon/icon-demo.html +++ b/src/demo-app/icon/icon-demo.html @@ -4,32 +4,32 @@

    - By name registered with MdIconProvider: - - + By name registered with MatIconProvider: + +

    From icon set: - - - + + +

    Ligature from Material Icons font: - home + home

    Using a theme: - home - home - home + home + home + home

    Custom icon font and CSS: - +

diff --git a/src/demo-app/icon/icon-demo.ts b/src/demo-app/icon/icon-demo.ts index e5975d672a2d..1c66bb8b557e 100644 --- a/src/demo-app/icon/icon-demo.ts +++ b/src/demo-app/icon/icon-demo.ts @@ -1,18 +1,18 @@ import {Component, ViewEncapsulation} from '@angular/core'; import {DomSanitizer} from '@angular/platform-browser'; -import {MdIconRegistry} from '@angular/material'; +import {MatIconRegistry} from '@angular/material'; @Component({ moduleId: module.id, - selector: 'md-icon-demo', + selector: 'mat-icon-demo', templateUrl: 'icon-demo.html', styleUrls: ['icon-demo.css'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) export class IconDemo { - constructor(mdIconRegistry: MdIconRegistry, sanitizer: DomSanitizer) { - mdIconRegistry + constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) { + iconRegistry .addSvgIcon('thumb-up', sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg')) .addSvgIconSetInNamespace('core', diff --git a/src/demo-app/index.html b/src/demo-app/index.html index 706848123e5d..b8669924fdb5 100644 --- a/src/demo-app/index.html +++ b/src/demo-app/index.html @@ -11,7 +11,7 @@ - + diff --git a/src/demo-app/input/input-demo.html b/src/demo-app/input/input-demo.html index 1a171440ca20..deeb7cdaf4cd 100644 --- a/src/demo-app/input/input-demo.html +++ b/src/demo-app/input/input-demo.html @@ -1,342 +1,342 @@ - - Basic - + + Basic +
- - - + + +
- - - + + + - - - + + +

- - - - - - + + + + + +

- - - + + + - - - + + + - - + - - mode_edit + + mode_edit {{postalCode.value.length}} / 5 - - + +
-
-
+ + - - Error messages - + + Error messages +

Regular

- - - This field is required - + + + This field is required + - - - + + + This field is required - - + + Please enter a valid email address - - + +

With hint

- - - This field is required - Please type something here - + + + This field is required + Please type something here +

Inside a form

- - + - This field is required - + This field is required + - +

With a custom error function

- - + - This field is required - + This field is required + -
-
+ + - - Prefix + Suffix - + + Prefix + Suffix +

Text

- - - $  - .00 - + + + $  + .00 +

Icons

- - - attach_money - mode_edit - + + + attach_money + mode_edit +

Icon buttons

- - - - - -
-
+ + + + + + + - - Divider Colors - + + Divider Colors +

Input

- - - - - - - - - + + + + + + + + +

Textarea

- - - - - - - - - + + + + + + + + +

With error

- - - This field is required - - - - This field is required - - - - This field is required - -
-
+ + + This field is required + + + + This field is required + + + + This field is required + + + - - Hints - + + Hints +

Input

- - + - + {{characterCountInputHintExample.value.length}} / 100 - - + +

Textarea

- - - + {{characterCountTextareaHintExample.value.length}} / 100 - - + +

-
-
+ + - - + + Hello  - - - , + + + , how are you? - - + +

- - - - - - + + + + + +

- - - + + +

- - - {{input.value.length}} / 100 - + + + {{input.value.length}} / 100 +

- - - + + +

- - - - I favorite bold placeholder - - - I also home italic hint labels - - + + + + I favorite bold placeholder + + + I also home italic hint labels + +

- - - {{hintLabelWithCharCount.value.length}} - + + + {{hintLabelWithCharCount.value.length}} +

- - - + + + Enter some text to count how many characters are in it. The character count is shown on the right. - - + + Length: {{longHint.value.length}} - - + +

- Check to change the color: - - - + Check to change the color: + + +

- Check to make required: - - Check to make required: + + - +

- Check to hide the required marker: - - Check to hide the required marker: + + - +

- - Auto Float - Always Float - Never Float - + + Auto Float + Always Float + Never Float +

- - - + + +

- - -

Example: 
- - - - .00 € - + + +
Example: 
+
+ + + .00 € +
Both: - - - email  -  @gmail.com - + + + email  +  @gmail.com +

- Empty: - + Empty: +

-
-
+ + - - Number Inputs - + + Number Inputs + @@ -350,13 +350,13 @@

Textarea

Table
{{i+1}} - - + - + @@ -364,46 +364,46 @@

Textarea

{{item.value}}
-
-
+ + - - Forms - - - - - - - -
- - - + + +
-
-
+ + - - Textarea Autosize - + + Textarea Autosize +

Regular <textarea>

- + -

<textarea> with md-form-field

+

<textarea> with mat-form-field

- - - +

<textarea> with ngModel

@@ -412,7 +412,7 @@

<textarea> with ngModel

- - + + diff --git a/src/demo-app/list/list-demo.html b/src/demo-app/list/list-demo.html index 5109f4cd2647..347d5c24732b 100644 --- a/src/demo-app/list/list-demo.html +++ b/src/demo-app/list/list-demo.html @@ -1,122 +1,122 @@ -

md-list demo

+

mat-list demo

- +

Normal lists

- -

Items

- + +

Items

+ {{item}} -
-
+ + - - -

{{contact.name}}

-

extra line

-

{{contact.headline}}

-
-
+ + +

{{contact.name}}

+

extra line

+

{{contact.headline}}

+
+
- -

Today

- - Image of {{message.from}} -

{{message.from}}

-

+ +

Today

+ + Image of {{message.from}} +

{{message.from}}

+

{{message.subject}} -- {{message.message}}

-
- - -

{{message.from}}

-

{{message.subject}}

-

{{message.message}}

-
-
+ + + +

{{message.from}}

+

{{message.subject}}

+

{{message.message}}

+
+

Dense lists

- -

Items

- + +

Items

+ {{item}} -
-
+ + - - -

{{contact.name}}

-

{{contact.headline}}

-
-
+ + +

{{contact.name}}

+

{{contact.headline}}

+
+
- -

Today

- - Image of {{message.from}} -

{{message.from}}

-

{{message.subject}}

-

{{message.message}}

-
-
+ +

Today

+ + Image of {{message.from}} +

{{message.from}}

+

{{message.subject}}

+

{{message.message}}

+
+

Nav lists

- - + + {{ link.name }} - +
More info!
- - - {{ link.name }} - - - - - - folder - {{ link.name }} - Description + + + + + folder + {{ link.name }} + Description - - - - {{ link.name }} - - - + +

Selection list

- -

Groceries

+ +

Groceries

- + {{item}} - -
+ +

Selected: {{groceries.selectedOptions.selected.length}}

- - + +

diff --git a/src/demo-app/live-announcer/live-announcer-demo.html b/src/demo-app/live-announcer/live-announcer-demo.html index 4aa01f5ef659..ce59732387be 100644 --- a/src/demo-app/live-announcer/live-announcer-demo.html +++ b/src/demo-app/live-announcer/live-announcer-demo.html @@ -1,5 +1,5 @@
- +
\ No newline at end of file diff --git a/src/demo-app/menu/menu-demo.html b/src/demo-app/menu/menu-demo.html index 502050bf9ddf..86c9baf2849d 100644 --- a/src/demo-app/menu/menu-demo.html +++ b/src/demo-app/menu/menu-demo.html @@ -2,118 +2,118 @@

You clicked on: {{ selected }}

- - - + - - - +

Nested menu

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Clicking these will navigate:

- - - + - - + + {{ item.text }} - +

Position x: before

- - - + - - - +

Position y: above

- - - + - - - +
@@ -121,49 +121,49 @@

overlapTrigger: false

- - - + - - - +

Position x: before, overlapTrigger: false

- - - + - - - +

Position y: above, overlapTrigger: false

- - - + - - - +
diff --git a/src/demo-app/progress-bar/progress-bar-demo.html b/src/demo-app/progress-bar/progress-bar-demo.html index 7c1e558e8c37..62acae8389ec 100644 --- a/src/demo-app/progress-bar/progress-bar-demo.html +++ b/src/demo-app/progress-bar/progress-bar-demo.html @@ -1,45 +1,45 @@ - - Primary Color - Accent Color - Warn Color - + + Primary Color + Accent Color + Warn Color +

Determinate

Value: {{determinateProgressValue}} - - + +
- - + +

Buffer

Value: {{bufferProgressValue}} - - + + Buffer Value: {{bufferBufferValue}} - - + +
- +

Indeterminate

- +

Query

- +
diff --git a/src/demo-app/progress-bar/progress-bar-demo.scss b/src/demo-app/progress-bar/progress-bar-demo.scss index f78bb2d8a226..b83828a6417e 100644 --- a/src/demo-app/progress-bar/progress-bar-demo.scss +++ b/src/demo-app/progress-bar/progress-bar-demo.scss @@ -1,7 +1,7 @@ .demo-progress-bar-container { width: 100%; - md-progress-bar { + mat-progress-bar { margin: 20px 0; } } diff --git a/src/demo-app/progress-spinner/progress-spinner-demo.html b/src/demo-app/progress-spinner/progress-spinner-demo.html index 07a04390dc8c..27a9dfcec7c3 100644 --- a/src/demo-app/progress-spinner/progress-spinner-demo.html +++ b/src/demo-app/progress-spinner/progress-spinner-demo.html @@ -2,29 +2,29 @@

Determinate

Value: {{progressValue}}

- - - Is determinate + + + Is determinate
- - + +

Indeterminate

- - Primary Color - Accent Color - Warn Color - + + Primary Color + Accent Color + Warn Color +
- - - + + +
diff --git a/src/demo-app/radio/radio-demo.html b/src/demo-app/radio/radio-demo.html index 043690f4b7e5..09ecd1a2782a 100644 --- a/src/demo-app/radio/radio-demo.html +++ b/src/demo-app/radio/radio-demo.html @@ -1,52 +1,52 @@

Basic Example

- Option 1 - Option 2 - Option 3 (disabled) + Option 1 + Option 2 + Option 3 (disabled)

Color Example

- Default (accent) - Primary - Accent - Warn + Default (accent) + Primary + Accent + Warn

Dynamic Example

isDisabled: {{isDisabled}} -
isRequired: {{isRequired}} -
- Align end + Align end
- - Option 1 - Option 2 - Option 3 - + Option 1 + Option 2 + Option 3 +

Favorite Season Example

Dynamic Example with two-way data-binding

- - + + {{season}} - - + +

Your favorite season is: {{favoriteSeason}}

diff --git a/src/demo-app/ripple/ripple-demo.html b/src/demo-app/ripple/ripple-demo.html index 8517723177b3..98feef4e9d23 100644 --- a/src/demo-app/ripple/ripple-demo.html +++ b/src/demo-app/ripple/ripple-demo.html @@ -1,55 +1,55 @@ - +
- Disable button ripples - - - + + -
-
Centered
-
Unbounded
-
Disabled
-
Rounded container (flaky in Firefox)
+
Centered
+
Unbounded
+
Disabled
+
Rounded container (flaky in Firefox)
Speed - - Slow - Normal - Fast - + + Slow + Normal + Fast +
- - - - - - + + + + + +
- - - + + +
+ mat-ripple + [matRippleCentered]="centered" + [matRippleDisabled]="disabled" + [matRippleUnbounded]="unbounded" + [matRippleRadius]="radius" + [matRippleColor]="rippleColor" + [matRippleSpeedFactor]="rippleSpeed"> Click me
diff --git a/src/demo-app/ripple/ripple-demo.ts b/src/demo-app/ripple/ripple-demo.ts index f75ce343f591..ec9a69b828e1 100644 --- a/src/demo-app/ripple/ripple-demo.ts +++ b/src/demo-app/ripple/ripple-demo.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {MdRipple} from '@angular/material'; +import {MatRipple} from '@angular/material'; @Component({ @@ -9,7 +9,7 @@ import {MdRipple} from '@angular/material'; styleUrls: ['ripple-demo.css'], }) export class RippleDemo { - @ViewChild(MdRipple) ripple: MdRipple; + @ViewChild(MatRipple) ripple: MatRipple; centered = false; disabled = false; diff --git a/src/demo-app/select/select-demo.html b/src/demo-app/select/select-demo.html index c673924d5933..1ce8ef756f15 100644 --- a/src/demo-app/select/select-demo.html +++ b/src/demo-app/select/select-demo.html @@ -1,23 +1,23 @@ Space above cards: - +
- - ngModel + + ngModel - - + - None - + None + {{ drink.viewValue }} - - - local_drink - Pick a drink! - You must make a selection - + + + local_drink + Pick a drink! + You must make a selection +

Value: {{ currentDrink }}

Touched: {{ drinkControl.touched }}

Dirty: {{ drinkControl.dirty }}

@@ -39,24 +39,24 @@

- - - - -
+ + + + + - - Multiple selection + + Multiple selection - - - + + - + {{ creature.viewValue }} - - - + + +

Value: {{ currentPokemon }}

Touched: {{ pokemonControl.touched }}

Dirty: {{ pokemonControl.dirty }}

@@ -67,114 +67,114 @@

- - - - -
-
- - - Without Angular forms - - - - None - + + + + + + + + + Without Angular forms + + + + None + {{ creature.viewValue }} - - - + + +

Value: {{ currentDigimon }}

- - -
+ + + - - Option groups + + Option groups - - - - + + + - + {{ creature.viewValue }} - - - - - - - - - - compareWith - - - + + + + + + + + + compareWith + + + - + {{ drink.viewValue }} - - - + + +

Value: {{ currentDrinkObject | json }}

Touched: {{ drinkObjectControl.touched }}

Dirty: {{ drinkObjectControl.dirty }}

Status: {{ drinkObjectControl.control?.status }}

Comparison Mode: {{ compareByValue ? 'VALUE' : 'REFERENCE' }}

- - - - -
-
+ + + + +
- - formControl - - - - - {{ food.viewValue }} - - + + formControl + + + + + {{ food.viewValue }} + +

Value: {{ foodControl.value }}

Touched: {{ foodControl.touched }}

Dirty: {{ foodControl.dirty }}

Status: {{ foodControl.status }}

- - - -
-
+ + + + +
- - Change event + + Change event - - - - {{ creature.viewValue }} - - + + + + {{ creature.viewValue }} + +

Change event value: {{ latestChangeEvent?.value }}

-
-
+ +
diff --git a/src/demo-app/select/select-demo.ts b/src/demo-app/select/select-demo.ts index 48490643dbdf..1967e60f7c43 100644 --- a/src/demo-app/select/select-demo.ts +++ b/src/demo-app/select/select-demo.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {FormControl} from '@angular/forms'; -import {MdSelectChange} from '@angular/material'; +import {MatSelectChange} from '@angular/material'; @Component({ moduleId: module.id, @@ -20,7 +20,7 @@ export class SelectDemo { currentPokemon: string[]; currentPokemonFromGroup: string; currentDigimon: string; - latestChangeEvent: MdSelectChange; + latestChangeEvent: MatSelectChange; floatPlaceholder: string = 'auto'; foodControl = new FormControl('pizza-1'); topHeightCtrl = new FormControl(0); diff --git a/src/demo-app/sidenav/sidenav-demo.html b/src/demo-app/sidenav/sidenav-demo.html index fdc13d483172..3603f87421aa 100644 --- a/src/demo-app/sidenav/sidenav-demo.html +++ b/src/demo-app/sidenav/sidenav-demo.html @@ -1,60 +1,60 @@ -
- Header - - Header + + Start Side Sidenav
- +
- +
- +
Mode: {{start.mode}}

Filler Content
-
+ - End Side Sidenav
- +
Filler Content
-
+ - - Header + + Header
-

Sidenav

- - - Fixed mode - Sidenav covers header/footer + + + Fixed mode + Sidenav covers header/footer

Header / Footer

- Show header - Show footer + Show header + Show footer
Filler Content
- Footer -
-
- Footer + Footer + + + Footer
diff --git a/src/demo-app/slide-toggle/slide-toggle-demo.html b/src/demo-app/slide-toggle/slide-toggle-demo.html index 7338520a84b8..9239217593a9 100644 --- a/src/demo-app/slide-toggle/slide-toggle-demo.html +++ b/src/demo-app/slide-toggle/slide-toggle-demo.html @@ -1,27 +1,27 @@
- + Default Slide Toggle - + - + Disabled Slide Toggle - + - + Disable Bound - +

Example where the slide toggle is required inside of a form.

- + Slide Toggle - +

- +

diff --git a/src/demo-app/slide-toggle/slide-toggle-demo.scss b/src/demo-app/slide-toggle/slide-toggle-demo.scss index a7429af3ff56..a178e139b106 100644 --- a/src/demo-app/slide-toggle/slide-toggle-demo.scss +++ b/src/demo-app/slide-toggle/slide-toggle-demo.scss @@ -3,7 +3,7 @@ flex-direction: column; align-items: flex-start; - md-slide-toggle { + mat-slide-toggle { margin: 6px 0; } } diff --git a/src/demo-app/slider/slider-demo.html b/src/demo-app/slider/slider-demo.html index 2641eae973a1..624cbd78b3f2 100644 --- a/src/demo-app/slider/slider-demo.html +++ b/src/demo-app/slider/slider-demo.html @@ -1,60 +1,60 @@

Default Slider

-Label +Label {{slidey.value}}

Colors

- - - + + +

Slider with Min and Max

- - + + {{slider2.value}}

Disabled Slider

- - + +

Slider with set value

- +

Slider with step defined

- + {{slider5.value}}

Slider with set tick interval

- - + +

Slider with Thumb Label

- +

Slider with one-way binding

- +

Slider with two-way binding

- +

Inverted slider

- +

Vertical slider

- - + +

Inverted vertical slider

- - + - - - - - + + + + + diff --git a/src/demo-app/snack-bar/snack-bar-demo.html b/src/demo-app/snack-bar/snack-bar-demo.html index c2f8171c1cc4..1bdb4819e7aa 100644 --- a/src/demo-app/snack-bar/snack-bar-demo.html +++ b/src/demo-app/snack-bar/snack-bar-demo.html @@ -1,53 +1,53 @@

SnackBar demo

- Message: + Message:
Position in page:
- - - Start - End - Left - Right - Center - - - - - Top - Bottom - - + + + Start + End + Left + Right + Center + + + + + Top + Bottom + +
- +

Show button on snack bar

- - + - -
+ +
- +

Auto hide after duration

- - + - -
+ +

- Add extra class to container + Add extra class to container

- + diff --git a/src/demo-app/snack-bar/snack-bar-demo.ts b/src/demo-app/snack-bar/snack-bar-demo.ts index 334959021f81..94bffbcc0acf 100644 --- a/src/demo-app/snack-bar/snack-bar-demo.ts +++ b/src/demo-app/snack-bar/snack-bar-demo.ts @@ -1,10 +1,10 @@ import {Dir} from '@angular/cdk/bidi'; import {Component, ViewEncapsulation} from '@angular/core'; import { - MdSnackBar, - MdSnackBarConfig, - MdSnackBarHorizontalPosition, - MdSnackBarVerticalPosition, + MatSnackBar, + MatSnackBarConfig, + MatSnackBarHorizontalPosition, + MatSnackBarVerticalPosition, } from '@angular/material'; @@ -23,14 +23,14 @@ export class SnackBarDemo { setAutoHide: boolean = true; autoHide: number = 10000; addExtraClass: boolean = false; - horizontalPosition: MdSnackBarHorizontalPosition = 'center'; - verticalPosition: MdSnackBarVerticalPosition = 'bottom'; + horizontalPosition: MatSnackBarHorizontalPosition = 'center'; + verticalPosition: MatSnackBarVerticalPosition = 'bottom'; - constructor(public snackBar: MdSnackBar, private dir: Dir) { + constructor(public snackBar: MatSnackBar, private dir: Dir) { } open() { - let config = new MdSnackBarConfig(); + let config = new MatSnackBarConfig(); config.verticalPosition = this.verticalPosition; config.horizontalPosition = this.horizontalPosition; config.duration = this.autoHide; diff --git a/src/demo-app/stepper/stepper-demo.html b/src/demo-app/stepper/stepper-demo.html index 11cda6eaea19..61d8cd9cde99 100644 --- a/src/demo-app/stepper/stepper-demo.html +++ b/src/demo-app/stepper/stepper-demo.html @@ -1,197 +1,197 @@ -Disable linear mode +Disable linear mode

Linear Vertical Stepper Demo using a single form

- - - Fill out your name - - - This field is required - - - - - This field is required - + + + Fill out your name + + + This field is required + + + + + This field is required +
- +
-
+ - - + +
Fill out your email address
- - - The input is invalid. - + + + The input is invalid. +
- - + +
-
+ - - Confirm your information + + Confirm your information Everything seems correct.
- +
-
-
+ +

Linear Horizontal Stepper Demo using a different form for each step

- - + +
- Fill out your name - - - This field is required - - - - This field is required - + Fill out your name + + + This field is required + + + + This field is required +
- +
-
+ - +
- Fill out your email address - - - The input is invalid - + Fill out your email address + + + The input is invalid +
- - + +
-
+ - +
- Confirm your information + Confirm your information Everything seems correct.
- +
-
-
+ +

Vertical Stepper Demo

-Make steps non-editable - - - Fill out your name - - - - - - - +Make steps non-editable + + + Fill out your name + + + + + + +
- +
-
+ - - + +
Fill out your phone number
- - - + + +
- - + +
-
+ - - + +
Fill out your address
- - - + + +
- - + +
-
+ - - Confirm your information + + Confirm your information Everything seems correct.
- +
-
-
+ +

Horizontal Stepper Demo with Text Label

- - - - - - - - - + + + + + + + + +
- +
-
+ - - - - + + + +
- - + +
-
+ - - - - + + + +
- - + +
-
+ - + Everything seems correct.
- +
-
-
+ +

Horizontal Stepper Demo with Templated Label

- - - {{step.label}} - - - + + + {{step.label}} + + +
- - + +
-
-
+ + diff --git a/src/demo-app/table/person-data-source.ts b/src/demo-app/table/person-data-source.ts index 6bf96511be1d..cc74bb243afe 100644 --- a/src/demo-app/table/person-data-source.ts +++ b/src/demo-app/table/person-data-source.ts @@ -1,4 +1,4 @@ -import {MdPaginator, MdSort} from '@angular/material'; +import {MatPaginator, MatSort} from '@angular/material'; import {DataSource} from '@angular/cdk/collections'; import {Observable} from 'rxjs/Observable'; import {PeopleDatabase, UserData} from './people-database'; @@ -7,8 +7,8 @@ import 'rxjs/add/operator/map'; export class PersonDataSource extends DataSource { constructor(private _peopleDatabase: PeopleDatabase, - private _paginator: MdPaginator, - private _sort: MdSort) { + private _paginator: MatPaginator, + private _sort: MatSort) { super(); } diff --git a/src/demo-app/table/table-demo.html b/src/demo-app/table/table-demo.html index 563a70f3ea0b..1741dc26d2be 100644 --- a/src/demo-app/table/table-demo.html +++ b/src/demo-app/table/table-demo.html @@ -1,34 +1,34 @@
- - + +
- - Change references + + Change references
Track By
- - Reference - ID - Index - + + Reference + ID + Index +
- +

CdkTable With Dynamic Column Def
- -

[style.opacity]="getOpacity(row.progress)" [style.width.%]="row.progress">
- + - - Name - {{row.name}} + + Name + {{row.name}} - - Color - {{row.color}} + + Color + {{row.color}} - - + + - + - - +
diff --git a/src/demo-app/table/table-demo.scss b/src/demo-app/table/table-demo.scss index 2f6ce9cb5478..e968dc3b8e98 100644 --- a/src/demo-app/table/table-demo.scss +++ b/src/demo-app/table/table-demo.scss @@ -67,7 +67,7 @@ display: flex; flex-direction: column; - md-table { + mat-table { overflow: auto; } } diff --git a/src/demo-app/table/table-demo.ts b/src/demo-app/table/table-demo.ts index 887f33960aa7..79067958ae25 100644 --- a/src/demo-app/table/table-demo.ts +++ b/src/demo-app/table/table-demo.ts @@ -1,7 +1,7 @@ import {Component, ViewChild} from '@angular/core'; import {PeopleDatabase, UserData} from './people-database'; import {PersonDataSource} from './person-data-source'; -import {MdPaginator, MdSort} from '@angular/material'; +import {MatPaginator, MatSort} from '@angular/material'; export type UserProperties = 'userId' | 'userName' | 'progress' | 'color' | undefined; @@ -25,9 +25,9 @@ export class TableDemo { dynamicColumnDefs: any[] = []; dynamicColumnIds: string[] = []; - @ViewChild(MdPaginator) _paginator: MdPaginator; + @ViewChild(MatPaginator) _paginator: MatPaginator; - @ViewChild(MdSort) sort: MdSort; + @ViewChild(MatSort) sort: MatSort; constructor(public _peopleDatabase: PeopleDatabase) { } diff --git a/src/demo-app/table/table-header-demo.html b/src/demo-app/table/table-header-demo.html index e03ccb1e682f..9ab9197006e6 100644 --- a/src/demo-app/table/table-header-demo.html +++ b/src/demo-app/table/table-header-demo.html @@ -3,17 +3,17 @@
- - - - - +
diff --git a/src/demo-app/tabs/tabs-demo.html b/src/demo-app/tabs/tabs-demo.html index e600753a33e8..759a92e70a9c 100644 --- a/src/demo-app/tabs/tabs-demo.html +++ b/src/demo-app/tabs/tabs-demo.html @@ -1,20 +1,20 @@

Tab Nav Bar

- - - - + + + +
-
- + {{tabLink.label}} - Disabled Link + Disabled Link
@@ -24,37 +24,37 @@

Tab Group Demo - Dynamic Tabs

Selected tab index: - - - + + +
- - Add New Tab - - + + Add New Tab + + Include extra content - - + + Select after adding - +
Position: - - - + + +
- -
-
+ + - - - {{tab.label}} + + + {{tab.label}}
{{tab.content}}
@@ -88,25 +88,25 @@

Tab Group Demo - Dynamic Tabs



- - - + + +

-
- - + +

Tab Group Demo - Dynamic Height

- - - {{tab.label}} + + + {{tab.label}}
{{tab.content}}
@@ -140,19 +140,19 @@

Tab Group Demo - Dynamic Height



- - - + + + -
-
+ +

Tab Group Demo - Fixed Height

- - - {{tab.label}} + + + {{tab.label}}
{{tab.content}}
@@ -186,94 +186,94 @@

Tab Group Demo - Fixed Height



- - - + + + -
-
+ +

Stretched Tabs

- - - {{tab.label}} + + + {{tab.label}}
{{tab.content}}
-
-
+ +

Async Tabs

- - - {{tab.label}} + + + {{tab.label}}
{{tab.content}}


- - - + + +
-
-
+ +

Tabs with simplified api

- - + +
This tab is about the Earth!
-
- + + This tab is about combustion! - -
+ +

Inverted tabs

- - + +
This tab is about the Earth!
-
- + +
This tab is about combustion!
-
-
+ +

Accent tabs

- - + +
This tab is about the Earth!
-
- + +
This tab is about combustion!
-
-
+ +

Tabs with background color

- - + +
This tab is about the Earth!
-
- + +
This tab is about combustion!
-
-
+ + diff --git a/src/demo-app/toolbar/toolbar-demo.html b/src/demo-app/toolbar/toolbar-demo.html index e6d3f30c5172..a7a434c97ded 100644 --- a/src/demo-app/toolbar/toolbar-demo.html +++ b/src/demo-app/toolbar/toolbar-demo.html @@ -1,68 +1,68 @@

- - menu + + menu Default Toolbar - code - + code +

- - menu + + menu Primary Toolbar - code - + code +

- - menu + + menu Accent Toolbar - code - + code +

- + Custom Toolbar - + Second Line - - + +

- + Custom Toolbar - + Second Line - verified_user - + verified_user + - + Third Line - favorite - delete - - + favorite + delete + +

\ No newline at end of file diff --git a/src/demo-app/tooltip/tooltip-demo.html b/src/demo-app/tooltip/tooltip-demo.html index 32845a31bf0f..2d8094231b48 100644 --- a/src/demo-app/tooltip/tooltip-demo.html +++ b/src/demo-app/tooltip/tooltip-demo.html @@ -1,4 +1,4 @@ - + @@ -6,15 +6,15 @@

Tooltip Demo

-
Scroll down while tooltip is open to see it hide automatically
@@ -22,50 +22,50 @@

Tooltip Demo

- - Below - Above - Left - Right - Before - After - + + Below + Above + Left + Right + Before + After +

Message: - +

Disabled: - +

Show Delay (ms): - - - + + +

Hide Delay (ms): - - - + + +

Mouse over to - - - - diff --git a/src/e2e-app/button/button-e2e.html b/src/e2e-app/button/button-e2e.html index 96170713001b..74510d8c9015 100644 --- a/src/e2e-app/button/button-e2e.html +++ b/src/e2e-app/button/button-e2e.html @@ -5,32 +5,32 @@ isDisabled: {{isDisabled}}, clickCounter: {{clickCounter}}

- - - - + off - - - diff --git a/src/e2e-app/checkbox/checkbox-e2e.html b/src/e2e-app/checkbox/checkbox-e2e.html index 5d78249c6d97..5ad9f8a36d70 100644 --- a/src/e2e-app/checkbox/checkbox-e2e.html +++ b/src/e2e-app/checkbox/checkbox-e2e.html @@ -1 +1 @@ -Check this button +Check this button diff --git a/src/e2e-app/dialog/dialog-e2e.ts b/src/e2e-app/dialog/dialog-e2e.ts index 717297e2aef3..b7bac051ef5f 100644 --- a/src/e2e-app/dialog/dialog-e2e.ts +++ b/src/e2e-app/dialog/dialog-e2e.ts @@ -1,5 +1,5 @@ import {Component, ViewChild, TemplateRef} from '@angular/core'; -import {MdDialog, MdDialogRef, MdDialogConfig} from '@angular/material'; +import {MatDialog, MatDialogRef, MatDialogConfig} from '@angular/material'; @Component({ selector: 'dialog-e2e', @@ -7,13 +7,13 @@ import {MdDialog, MdDialogRef, MdDialogConfig} from '@angular/material'; templateUrl: 'dialog-e2e.html' }) export class DialogE2E { - dialogRef: MdDialogRef | null; + dialogRef: MatDialogRef | null; @ViewChild(TemplateRef) templateRef: TemplateRef; - constructor (private _dialog: MdDialog) { } + constructor (private _dialog: MatDialog) { } - private _openDialog(config?: MdDialogConfig) { + private _openDialog(config?: MatDialogConfig) { this.dialogRef = this._dialog.open(TestDialog, config); this.dialogRef.afterClosed().subscribe(() => this.dialogRef = null); } @@ -41,5 +41,5 @@ export class DialogE2E { ` }) export class TestDialog { - constructor(public dialogRef: MdDialogRef) { } + constructor(public dialogRef: MatDialogRef) { } } diff --git a/src/e2e-app/e2e-app-module.ts b/src/e2e-app/e2e-app-module.ts index e80b8c0a7817..a9fd3f395e7c 100644 --- a/src/e2e-app/e2e-app-module.ts +++ b/src/e2e-app/e2e-app-module.ts @@ -20,23 +20,23 @@ import {InputE2E} from './input/input-e2e'; import {SidenavE2E} from './sidenav/sidenav-e2e'; import {BlockScrollStrategyE2E} from './block-scroll-strategy/block-scroll-strategy-e2e'; import { - MdButtonModule, - MdCheckboxModule, - MdDialogModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdNativeDateModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdSidenavModule, - MdSlideToggleModule, - MdStepperModule, - MdTabsModule, + MatButtonModule, + MatCheckboxModule, + MatDialogModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatNativeDateModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatSidenavModule, + MatSlideToggleModule, + MatStepperModule, + MatTabsModule, } from '@angular/material'; import {FullscreenOverlayContainer, OverlayContainer} from '@angular/cdk/overlay'; import {ExampleModule} from '@angular/material-examples'; @@ -47,23 +47,23 @@ import {ReactiveFormsModule} from '@angular/forms'; */ @NgModule({ exports: [ - MdButtonModule, - MdCheckboxModule, - MdDialogModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdSidenavModule, - MdSlideToggleModule, - MdStepperModule, - MdTabsModule, - MdNativeDateModule, + MatButtonModule, + MatCheckboxModule, + MatDialogModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatSidenavModule, + MatSlideToggleModule, + MatStepperModule, + MatTabsModule, + MatNativeDateModule, ] }) export class E2eMaterialModule {} diff --git a/src/e2e-app/e2e-app/e2e-app.html b/src/e2e-app/e2e-app/e2e-app.html index e3631595618d..1a142abe75ab 100644 --- a/src/e2e-app/e2e-app/e2e-app.html +++ b/src/e2e-app/e2e-app/e2e-app.html @@ -1,28 +1,28 @@ - - Block scroll strategy - Button - Button Toggle - Checkbox - Dialog - Expansion - Fullscreen - Grid list - Icon - Input - List - Menu - Progress bar - Progress Spinner - Radios - Sidenav - Slide Toggle - Stepper - Tabs - Cards - Toolbar - + + Block scroll strategy + Button + Button Toggle + Checkbox + Dialog + Expansion + Fullscreen + Grid list + Icon + Input + List + Menu + Progress bar + Progress Spinner + Radios + Sidenav + Slide Toggle + Stepper + Tabs + Cards + Toolbar +
diff --git a/src/e2e-app/fullscreen/fullscreen-e2e.ts b/src/e2e-app/fullscreen/fullscreen-e2e.ts index 0db67b5d6974..3bf543d9c965 100644 --- a/src/e2e-app/fullscreen/fullscreen-e2e.ts +++ b/src/e2e-app/fullscreen/fullscreen-e2e.ts @@ -1,5 +1,5 @@ import {Component, ElementRef, Output, EventEmitter} from '@angular/core'; -import {MdDialog, MdDialogRef} from '@angular/material'; +import {MatDialog, MatDialogRef} from '@angular/material'; @Component({ moduleId: module.id, @@ -8,9 +8,9 @@ import {MdDialog, MdDialogRef} from '@angular/material'; }) export class FullscreenE2E { - dialogRef: MdDialogRef | null; + dialogRef: MatDialogRef | null; - constructor (private _element: ElementRef, private _dialog: MdDialog) { } + constructor (private _element: ElementRef, private _dialog: MatDialog) { } openDialog() { this.dialogRef = this._dialog.open(TestDialog); @@ -58,5 +58,5 @@ export class TestDialog { @Output() openFullscreen = new EventEmitter(); @Output() exitFullscreen = new EventEmitter(); - constructor(public dialogRef: MdDialogRef) {} + constructor(public dialogRef: MatDialogRef) {} } diff --git a/src/e2e-app/grid-list/grid-list-e2e.html b/src/e2e-app/grid-list/grid-list-e2e.html index d0e7037eb867..7ba581a491c8 100644 --- a/src/e2e-app/grid-list/grid-list-e2e.html +++ b/src/e2e-app/grid-list/grid-list-e2e.html @@ -1,6 +1,6 @@ - - One - Two - Three - Four - + + One + Two + Three + Four + diff --git a/src/e2e-app/icon/icon-e2e.html b/src/e2e-app/icon/icon-e2e.html index cf538e71481d..65a0e62c71e9 100644 --- a/src/e2e-app/icon/icon-e2e.html +++ b/src/e2e-app/icon/icon-e2e.html @@ -1,3 +1,3 @@
- favorite + favorite
\ No newline at end of file diff --git a/src/e2e-app/index.html b/src/e2e-app/index.html index 0fa9e0cf5568..855ef3b086a7 100644 --- a/src/e2e-app/index.html +++ b/src/e2e-app/index.html @@ -11,7 +11,7 @@ - + diff --git a/src/e2e-app/input/input-e2e.html b/src/e2e-app/input/input-e2e.html index b47fa322a9ba..ee908d25449e 100644 --- a/src/e2e-app/input/input-e2e.html +++ b/src/e2e-app/input/input-e2e.html @@ -1,23 +1,23 @@

- - - + + +

- - - + + +

- - - + + +

- - - +

diff --git a/src/e2e-app/menu/menu-e2e.html b/src/e2e-app/menu/menu-e2e.html index bd80754a8dc6..6c07798831a5 100644 --- a/src/e2e-app/menu/menu-e2e.html +++ b/src/e2e-app/menu/menu-e2e.html @@ -2,35 +2,35 @@
{{ selected }}
- - + + - - - - - - + + + + + + - - - - + + +
- - - - + + + + - - - - + + +
diff --git a/src/e2e-app/progress-bar/progress-bar-e2e.html b/src/e2e-app/progress-bar/progress-bar-e2e.html index 79d6660603b0..b1218f154b26 100644 --- a/src/e2e-app/progress-bar/progress-bar-e2e.html +++ b/src/e2e-app/progress-bar/progress-bar-e2e.html @@ -1,4 +1,4 @@ - - - - + + + + diff --git a/src/e2e-app/progress-bar/progress-bar-e2e.ts b/src/e2e-app/progress-bar/progress-bar-e2e.ts index 7371b2afadb7..a8bdeb2bc100 100644 --- a/src/e2e-app/progress-bar/progress-bar-e2e.ts +++ b/src/e2e-app/progress-bar/progress-bar-e2e.ts @@ -6,7 +6,7 @@ import {Component} from '@angular/core'; selector: 'progress-bar-e2e', templateUrl: 'progress-bar-e2e.html', styles: [` - md-progress-bar { + mat-progress-bar { margin-bottom: 10px; } `] diff --git a/src/e2e-app/progress-spinner/progress-spinner-e2e.html b/src/e2e-app/progress-spinner/progress-spinner-e2e.html index 9a7709ebf8b3..7971277ec758 100644 --- a/src/e2e-app/progress-spinner/progress-spinner-e2e.html +++ b/src/e2e-app/progress-spinner/progress-spinner-e2e.html @@ -1,3 +1,3 @@ - - - + + + diff --git a/src/e2e-app/radio/radio-e2e.html b/src/e2e-app/radio/radio-e2e.html index d14f9cead519..28ba53e3541b 100644 --- a/src/e2e-app/radio/radio-e2e.html +++ b/src/e2e-app/radio/radio-e2e.html @@ -1,12 +1,12 @@
- - Charmander - Squirtle - Bulbasaur + Charmander + Squirtle + Bulbasaur - +
diff --git a/src/e2e-app/sidenav/sidenav-e2e.html b/src/e2e-app/sidenav/sidenav-e2e.html index 254ae42cfc0c..67deac6a0e7c 100644 --- a/src/e2e-app/sidenav/sidenav-e2e.html +++ b/src/e2e-app/sidenav/sidenav-e2e.html @@ -1,8 +1,8 @@
- - Drawer content + + Drawer content - +
diff --git a/src/e2e-app/slide-toggle/slide-toggle-e2e.html b/src/e2e-app/slide-toggle/slide-toggle-e2e.html index 13ce7328669d..c8bc16b7c38d 100644 --- a/src/e2e-app/slide-toggle/slide-toggle-e2e.html +++ b/src/e2e-app/slide-toggle/slide-toggle-e2e.html @@ -1,2 +1,2 @@ -Slide Toggle -Disabled Slide Toggle \ No newline at end of file +Slide Toggle +Disabled Slide Toggle \ No newline at end of file diff --git a/src/e2e-app/tabs/tabs-e2e.html b/src/e2e-app/tabs/tabs-e2e.html index 9e9431af0cc0..1b21b9f58ca7 100644 --- a/src/e2e-app/tabs/tabs-e2e.html +++ b/src/e2e-app/tabs/tabs-e2e.html @@ -1,16 +1,16 @@
- - - One + + + One First tab's content - - - Two + + + Two Second tab's content - - - Three + + + Three Third tab's content - - + +
diff --git a/src/lib/autocomplete/autocomplete-module.ts b/src/lib/autocomplete/autocomplete-module.ts index 4fbc35f2f31b..96029b6c2bd5 100644 --- a/src/lib/autocomplete/autocomplete-module.ts +++ b/src/lib/autocomplete/autocomplete-module.ts @@ -9,17 +9,17 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {OverlayModule} from '@angular/cdk/overlay'; -import {MdOptionModule, MdCommonModule} from '@angular/material/core'; -import {MdAutocomplete} from './autocomplete'; +import {MatOptionModule, MatCommonModule} from '@angular/material/core'; +import {MatAutocomplete} from './autocomplete'; import { - MdAutocompleteTrigger, - MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER, + MatAutocompleteTrigger, + MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER, } from './autocomplete-trigger'; @NgModule({ - imports: [MdOptionModule, OverlayModule, MdCommonModule, CommonModule], - exports: [MdAutocomplete, MdOptionModule, MdAutocompleteTrigger, MdCommonModule], - declarations: [MdAutocomplete, MdAutocompleteTrigger], - providers: [MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER], + imports: [MatOptionModule, OverlayModule, MatCommonModule, CommonModule], + exports: [MatAutocomplete, MatOptionModule, MatAutocompleteTrigger, MatCommonModule], + declarations: [MatAutocomplete, MatAutocompleteTrigger], + providers: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER], }) -export class MdAutocompleteModule {} +export class MatAutocompleteModule {} diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index 89e8d3487b90..33d5510dcc61 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -34,15 +34,15 @@ import { ViewContainerRef, } from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; -import {MdOption, MdOptionSelectionChange} from '@angular/material/core'; -import {MdFormField} from '@angular/material/form-field'; +import {MatOption, MatOptionSelectionChange} from '@angular/material/core'; +import {MatFormField} from '@angular/material/form-field'; import {DOCUMENT} from '@angular/platform-browser'; import {Observable} from 'rxjs/Observable'; import {fromEvent} from 'rxjs/observable/fromEvent'; import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; import {Subscription} from 'rxjs/Subscription'; -import {MdAutocomplete} from './autocomplete'; +import {MatAutocomplete} from './autocomplete'; /** @@ -58,44 +58,43 @@ export const AUTOCOMPLETE_OPTION_HEIGHT = 48; export const AUTOCOMPLETE_PANEL_HEIGHT = 256; /** Injection token that determines the scroll handling while the autocomplete panel is open. */ -export const MD_AUTOCOMPLETE_SCROLL_STRATEGY = - new InjectionToken<() => ScrollStrategy>('md-autocomplete-scroll-strategy'); +export const MAT_AUTOCOMPLETE_SCROLL_STRATEGY = + new InjectionToken<() => ScrollStrategy>('mat-autocomplete-scroll-strategy'); /** @docs-private */ -export function MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): +export function MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy { return () => overlay.scrollStrategies.reposition(); } /** @docs-private */ -export const MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER = { - provide: MD_AUTOCOMPLETE_SCROLL_STRATEGY, +export const MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER = { + provide: MAT_AUTOCOMPLETE_SCROLL_STRATEGY, deps: [Overlay], - useFactory: MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY, + useFactory: MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY, }; /** * Provider that allows the autocomplete to register as a ControlValueAccessor. * @docs-private */ -export const MD_AUTOCOMPLETE_VALUE_ACCESSOR: any = { +export const MAT_AUTOCOMPLETE_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdAutocompleteTrigger), + useExisting: forwardRef(() => MatAutocompleteTrigger), multi: true }; /** * Creates an error to be thrown when attempting to use an autocomplete trigger without a panel. */ -export function getMdAutocompleteMissingPanelError(): Error { - return Error('Attempting to open an undefined instance of `md-autocomplete`. ' + - 'Make sure that the id passed to the `mdAutocomplete` is correct and that ' + +export function getMatAutocompleteMissingPanelError(): Error { + return Error('Attempting to open an undefined instance of `mat-autocomplete`. ' + + 'Make sure that the id passed to the `matAutocomplete` is correct and that ' + 'you\'re attempting to open it after the ngAfterContentInit hook.'); } @Directive({ - selector: `input[mdAutocomplete], input[matAutocomplete], - textarea[mdAutocomplete], textarea[matAutocomplete]`, + selector: `input[matAutocomplete], textarea[matAutocomplete]`, host: { 'role': 'combobox', 'autocomplete': 'off', @@ -111,9 +110,9 @@ export function getMdAutocompleteMissingPanelError(): Error { '(input)': '_handleInput($event)', '(keydown)': '_handleKeydown($event)', }, - providers: [MD_AUTOCOMPLETE_VALUE_ACCESSOR] + providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR] }) -export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { +export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { private _overlayRef: OverlayRef | null; private _portal: TemplatePortal; private _panelOpen: boolean = false; @@ -134,25 +133,15 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { _onTouched = () => {}; /* The autocomplete panel to be attached to this trigger. */ - @Input('mdAutocomplete') autocomplete: MdAutocomplete; - - /** Property with mat- prefix for no-conflict mode. */ - @Input('matAutocomplete') - get _matAutocomplete(): MdAutocomplete { - return this.autocomplete; - } - - set _matAutocomplete(autocomplete: MdAutocomplete) { - this.autocomplete = autocomplete; - } + @Input('matAutocomplete') autocomplete: MatAutocomplete; constructor(private _element: ElementRef, private _overlay: Overlay, private _viewContainerRef: ViewContainerRef, private _zone: NgZone, private _changeDetectorRef: ChangeDetectorRef, - @Inject(MD_AUTOCOMPLETE_SCROLL_STRATEGY) private _scrollStrategy, + @Inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY) private _scrollStrategy, @Optional() private _dir: Directionality, - @Optional() @Host() private _formField: MdFormField, + @Optional() @Host() private _formField: MatFormField, @Optional() @Inject(DOCUMENT) private _document: any) {} ngOnDestroy() { @@ -194,7 +183,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { * A stream of actions that should close the autocomplete panel, including * when an option is selected, on blur, and when TAB is pressed. */ - get panelClosingActions(): Observable { + get panelClosingActions(): Observable { return merge( this.optionSelections, this.autocomplete._keyManager.tabOut, @@ -203,12 +192,12 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { } /** Stream of autocomplete option selections. */ - get optionSelections(): Observable { + get optionSelections(): Observable { return merge(...this.autocomplete.options.map(option => option.onSelectionChange)); } - /** The currently active option, coerced to MdOption type. */ - get activeOption(): MdOption | null { + /** The currently active option, coerced to MatOption type. */ + get activeOption(): MatOption | null { if (this.autocomplete && this.autocomplete._keyManager) { return this.autocomplete._keyManager.activeItem; } @@ -348,7 +337,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { */ private _scrollToOption(): void { const activeOptionIndex = this.autocomplete._keyManager.activeItemIndex || 0; - const labelCount = MdOption.countGroupLabelsBeforeOption(activeOptionIndex, + const labelCount = MatOption.countGroupLabelsBeforeOption(activeOptionIndex, this.autocomplete.options, this.autocomplete.optionGroups); const optionOffset = (activeOptionIndex + labelCount) * AUTOCOMPLETE_OPTION_HEIGHT; const panelTop = this.autocomplete._getScrollTop(); @@ -404,7 +393,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { // The display value can also be the number zero and shouldn't fall back to an empty string. const inputValue = toDisplay != null ? toDisplay : ''; - // If it's used within a `MdFormField`, we should set it through the property so it can go + // If it's used within a `MatFormField`, we should set it through the property so it can go // through change detection. if (this._formField) { this._formField._control.value = inputValue; @@ -418,7 +407,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { * control to that value. It will also mark the control as dirty if this interaction * stemmed from the user. */ - private _setValueAndClose(event: MdOptionSelectionChange | null): void { + private _setValueAndClose(event: MatOptionSelectionChange | null): void { if (event && event.source) { this._clearPreviousSelectedOption(event.source); this._setTriggerValue(event.source.value); @@ -433,7 +422,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { /** * Clear any previous selected option and emit a selection change event for this option */ - private _clearPreviousSelectedOption(skip: MdOption) { + private _clearPreviousSelectedOption(skip: MatOption) { this.autocomplete.options.forEach(option => { if (option != skip && option.selected) { option.deselect(); @@ -443,7 +432,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { private _attachOverlay(): void { if (!this.autocomplete) { - throw getMdAutocompleteMissingPanelError(); + throw getMatAutocompleteMissingPanelError(); } if (!this._overlayRef) { diff --git a/src/lib/autocomplete/autocomplete.md b/src/lib/autocomplete/autocomplete.md index cee71e488c8d..4989442172c7 100644 --- a/src/lib/autocomplete/autocomplete.md +++ b/src/lib/autocomplete/autocomplete.md @@ -3,44 +3,44 @@ You can read more about autocompletes in the [Material Design spec](https://mate ### Simple autocomplete -Start by adding a regular `mdInput` to the page. Let's assume you're using the `formControl` +Start by adding a regular `matInput` to the page. Let's assume you're using the `formControl` directive from the `@angular/forms` module to track the value of the input. *my-comp.html* ```html - - - + + + ``` Next, create the autocomplete panel and the options displayed inside it. Each option should be -defined by an `md-option` tag. Set each option's value property to whatever you'd like the value +defined by an `mat-option` tag. Set each option's value property to whatever you'd like the value of the text input to be upon that option's selection. *my-comp.html* ```html - - + + {{ option }} - - + + ``` Now we'll need to link the text input to its panel. We can do this by exporting the autocomplete panel instance into a local template variable (here we called it "auto"), and binding that variable -to the input's `mdAutocomplete` property. +to the input's `matAutocomplete` property. *my-comp.html* ```html - - - + + + - - + + {{ option }} - - + + ``` @@ -84,16 +84,16 @@ desired display value. Then bind it to the autocomplete's `displayWith` property - ENTER: Select currently active item. #### Option groups -`md-option` can be collected into groups using the `md-optgroup` element: +`mat-option` can be collected into groups using the `mat-optgroup` element: ```html - - - + + + {{ option.name }} - - - + + + ``` ### Accessibility diff --git a/src/lib/autocomplete/autocomplete.scss b/src/lib/autocomplete/autocomplete.scss index 03d7e62f7b53..afcfabb00ded 100644 --- a/src/lib/autocomplete/autocomplete.scss +++ b/src/lib/autocomplete/autocomplete.scss @@ -1,7 +1,7 @@ @import '../core/style/menu-common'; /** - * The max-height of the panel, currently matching md-select value. + * The max-height of the panel, currently matching mat-select value. * TODO: Check value with MD team. */ $mat-autocomplete-panel-max-height: 256px !default; diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index e4886f42dd1d..eb3e117a2d15 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -15,24 +15,24 @@ import { } from '@angular/core'; import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {MdOption} from '@angular/material/core'; -import {MdFormField, MdFormFieldModule} from '@angular/material/form-field'; +import {MatOption} from '@angular/material/core'; +import {MatFormField, MatFormFieldModule} from '@angular/material/form-field'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {Observable} from 'rxjs/Observable'; import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; -import {MdInputModule} from '../input/index'; +import {MatInputModule} from '../input/index'; import { - getMdAutocompleteMissingPanelError, - MdAutocomplete, - MdAutocompleteModule, - MdAutocompleteSelectedEvent, - MdAutocompleteTrigger, + getMatAutocompleteMissingPanelError, + MatAutocomplete, + MatAutocompleteModule, + MatAutocompleteSelectedEvent, + MatAutocompleteTrigger, } from './index'; -describe('MdAutocomplete', () => { +describe('MatAutocomplete', () => { let overlayContainerElement: HTMLElement; let dir: Direction; let scrolledSubject = new Subject(); @@ -41,9 +41,9 @@ describe('MdAutocomplete', () => { dir = 'ltr'; TestBed.configureTestingModule({ imports: [ - MdAutocompleteModule, - MdFormFieldModule, - MdInputModule, + MatAutocompleteModule, + MatFormFieldModule, + MatInputModule, FormsModule, ReactiveFormsModule, NoopAnimationsModule @@ -183,7 +183,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - const option = overlayContainerElement.querySelector('md-option') as HTMLElement; + const option = overlayContainerElement.querySelector('mat-option') as HTMLElement; option.click(); fixture.detectChanges(); @@ -204,7 +204,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); let options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[0].click(); // Changing value from 'Alabama' to 'al' to re-populate the option list, @@ -214,7 +214,7 @@ describe('MdAutocomplete', () => { fixture.whenStable().then(() => { options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -286,7 +286,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -319,7 +319,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -340,7 +340,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -440,7 +440,7 @@ describe('MdAutocomplete', () => { fixture.whenStable().then(() => { const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -456,7 +456,7 @@ describe('MdAutocomplete', () => { fixture.whenStable().then(() => { const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -474,7 +474,7 @@ describe('MdAutocomplete', () => { fixture.whenStable().then(() => { const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -493,7 +493,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -568,7 +568,7 @@ describe('MdAutocomplete', () => { fixture.whenStable().then(() => { const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -648,7 +648,7 @@ describe('MdAutocomplete', () => { it('should set the active item to the first option when DOWN key is pressed', fakeAsync(() => { tick(); const optionEls = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; fixture.componentInstance.trigger._handleKeydown(DOWN_ARROW_EVENT); tick(); @@ -680,7 +680,7 @@ describe('MdAutocomplete', () => { it('should set the active item to the last option when UP key is pressed', fakeAsync(() => { tick(); const optionEls = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; fixture.componentInstance.trigger._handleKeydown(UP_ARROW_EVENT); tick(); @@ -721,7 +721,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); const optionEls = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; expect(fixture.componentInstance.trigger.activeOption) .toBe(fixture.componentInstance.options.first, @@ -1196,7 +1196,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - const option = overlayContainerElement.querySelector('md-option') as HTMLElement; + const option = overlayContainerElement.querySelector('mat-option') as HTMLElement; // Focus the option manually since the synthetic click may not do it. option.focus(); @@ -1309,7 +1309,7 @@ describe('MdAutocomplete', () => { it('should deselect any other selected option', async(() => { let options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[0].click(); fixture.detectChanges(); @@ -1321,7 +1321,7 @@ describe('MdAutocomplete', () => { .toBe(true, `Clicked option should be selected.`); options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -1335,7 +1335,7 @@ describe('MdAutocomplete', () => { it('should call deselect only on the previous selected option', async(() => { let options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[0].click(); fixture.detectChanges(); @@ -1349,7 +1349,7 @@ describe('MdAutocomplete', () => { .toBe(true, `Clicked option should be selected.`); options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; options[1].click(); fixture.detectChanges(); @@ -1359,7 +1359,7 @@ describe('MdAutocomplete', () => { })); }); - describe('without mdInput', () => { + describe('without matInput', () => { let fixture: ComponentFixture; beforeEach(() => { @@ -1389,7 +1389,7 @@ describe('MdAutocomplete', () => { fixture.detectChanges(); const options = - overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; expect(options.length).toBe(1); }).not.toThrowError(); }); @@ -1455,7 +1455,7 @@ describe('MdAutocomplete', () => { typeInElement('o', input); fixture.detectChanges(); - expect(fixture.componentInstance.mdOptions.length).toBe(2); + expect(fixture.componentInstance.matOptions.length).toBe(2); })); it('should throw if the user attempts to open the panel too early', async(() => { @@ -1464,7 +1464,7 @@ describe('MdAutocomplete', () => { expect(() => { fixture.componentInstance.trigger.openPanel(); - }).toThrow(getMdAutocompleteMissingPanelError()); + }).toThrow(getMatAutocompleteMissingPanelError()); })); it('should hide the placeholder with a preselected form control value ' + @@ -1559,7 +1559,7 @@ describe('MdAutocomplete', () => { tick(); fixture.detectChanges(); - let options = overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + let options = overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; let spy = fixture.componentInstance.optionSelected; options[1].click(); @@ -1568,7 +1568,7 @@ describe('MdAutocomplete', () => { expect(spy).toHaveBeenCalledTimes(1); - let event = spy.calls.mostRecent().args[0] as MdAutocompleteSelectedEvent; + let event = spy.calls.mostRecent().args[0] as MatAutocompleteSelectedEvent; expect(event.source).toBe(fixture.componentInstance.autocomplete); expect(event.option.value).toBe('Washington'); @@ -1585,7 +1585,7 @@ describe('MdAutocomplete', () => { fixture.componentInstance.states.push('Puerto Rico'); fixture.detectChanges(); - let options = overlayContainerElement.querySelectorAll('md-option') as NodeListOf; + let options = overlayContainerElement.querySelectorAll('mat-option') as NodeListOf; let spy = fixture.componentInstance.optionSelected; options[3].click(); @@ -1594,7 +1594,7 @@ describe('MdAutocomplete', () => { expect(spy).toHaveBeenCalledTimes(1); - let event = spy.calls.mostRecent().args[0] as MdAutocompleteSelectedEvent; + let event = spy.calls.mostRecent().args[0] as MatAutocompleteSelectedEvent; expect(event.source).toBe(fixture.componentInstance.autocomplete); expect(event.option.value).toBe('Puerto Rico'); @@ -1603,15 +1603,15 @@ describe('MdAutocomplete', () => { @Component({ template: ` - - - + + + - - + + {{ state.code }}: {{ state.name }} - - + + ` }) class SimpleAutocomplete implements OnDestroy { @@ -1621,10 +1621,10 @@ class SimpleAutocomplete implements OnDestroy { placeholder = 'auto'; width: number; - @ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger; - @ViewChild(MdAutocomplete) panel: MdAutocomplete; - @ViewChild(MdFormField) formField: MdFormField; - @ViewChildren(MdOption) options: QueryList; + @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; + @ViewChild(MatAutocomplete) panel: MatAutocomplete; + @ViewChild(MatFormField) formField: MatFormField; + @ViewChildren(MatOption) options: QueryList; states = [ {code: 'AL', name: 'Alabama'}, @@ -1661,15 +1661,15 @@ class SimpleAutocomplete implements OnDestroy { @Component({ template: ` - - - + + + - - + + {{option}} - - + + ` }) class NgIfAutocomplete { @@ -1678,8 +1678,8 @@ class NgIfAutocomplete { isVisible = true; options = ['One', 'Two', 'Three']; - @ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger; - @ViewChildren(MdOption) mdOptions: QueryList; + @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; + @ViewChildren(MatOption) matOptions: QueryList; constructor() { this.filteredOptions = RxChain.from(this.optionCtrl.valueChanges) @@ -1695,16 +1695,16 @@ class NgIfAutocomplete { @Component({ template: ` - - + - + - - + + {{ state }} - - + + ` }) class AutocompleteWithoutForms { @@ -1723,16 +1723,16 @@ class AutocompleteWithoutForms { @Component({ template: ` - - + - + - - + + {{ state }} - - + + ` }) class AutocompleteWithNgModel { @@ -1751,15 +1751,15 @@ class AutocompleteWithNgModel { @Component({ template: ` - - - + + + - - + + {{ number }} - - + + ` }) class AutocompleteWithNumbers { @@ -1770,13 +1770,13 @@ class AutocompleteWithNumbers { @Component({ changeDetection: ChangeDetectionStrategy.OnPush, template: ` - - - + + + - - {{ option }} - + + {{ option }} + ` }) class AutocompleteWithOnPushDelay implements OnInit { @@ -1791,13 +1791,13 @@ class AutocompleteWithOnPushDelay implements OnInit { @Component({ template: ` - + - - + + {{option}} - - + + ` }) class AutocompleteWithNativeInput { @@ -1805,8 +1805,8 @@ class AutocompleteWithNativeInput { filteredOptions: Observable; options = ['En', 'To', 'Tre', 'Fire', 'Fem']; - @ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger; - @ViewChildren(MdOption) mdOptions: QueryList; + @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; + @ViewChildren(MatOption) matOptions: QueryList; constructor() { this.filteredOptions = RxChain.from(this.optionCtrl.valueChanges) @@ -1821,22 +1821,22 @@ class AutocompleteWithNativeInput { @Component({ - template: `` + template: `` }) class AutocompleteWithoutPanel { - @ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger; + @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; } @Component({ template: ` - - - + + + - - California - + + California + ` }) class AutocompleteWithFormsAndNonfloatingPlaceholder { @@ -1846,21 +1846,21 @@ class AutocompleteWithFormsAndNonfloatingPlaceholder { @Component({ template: ` - - - + + + - - - + + + {{ state }} - - - + + + ` }) class AutocompleteWithGroups { - @ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger; + @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; selectedState: string; stateGroups = [ { @@ -1880,15 +1880,15 @@ class AutocompleteWithGroups { @Component({ template: ` - - - + + + - - + + {{ state }} - - + + ` }) class AutocompleteWithSelectEvent { @@ -1896,6 +1896,6 @@ class AutocompleteWithSelectEvent { states = ['New York', 'Washington', 'Oregon']; optionSelected = jasmine.createSpy('optionSelected callback'); - @ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger; - @ViewChild(MdAutocomplete) autocomplete: MdAutocomplete; + @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; + @ViewChild(MatAutocomplete) autocomplete: MatAutocomplete; } diff --git a/src/lib/autocomplete/autocomplete.ts b/src/lib/autocomplete/autocomplete.ts index 24c29d411fd7..86b415352932 100644 --- a/src/lib/autocomplete/autocomplete.ts +++ b/src/lib/autocomplete/autocomplete.ts @@ -21,7 +21,7 @@ import { EventEmitter, Output, } from '@angular/core'; -import {MdOption, MdOptgroup} from '@angular/material/core'; +import {MatOption, MatOptgroup} from '@angular/material/core'; import {ActiveDescendantKeyManager} from '@angular/cdk/a11y'; @@ -32,28 +32,28 @@ import {ActiveDescendantKeyManager} from '@angular/cdk/a11y'; let _uniqueAutocompleteIdCounter = 0; /** Event object that is emitted when an autocomplete option is selected */ -export class MdAutocompleteSelectedEvent { - constructor(public source: MdAutocomplete, public option: MdOption) { } +export class MatAutocompleteSelectedEvent { + constructor(public source: MatAutocomplete, public option: MatOption) { } } @Component({ moduleId: module.id, - selector: 'md-autocomplete, mat-autocomplete', + selector: 'mat-autocomplete', templateUrl: 'autocomplete.html', styleUrls: ['autocomplete.css'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - exportAs: 'mdAutocomplete, matAutocomplete', + exportAs: 'matAutocomplete', host: { 'class': 'mat-autocomplete' } }) -export class MdAutocomplete implements AfterContentInit { +export class MatAutocomplete implements AfterContentInit { /** Manages active item in option list based on key events. */ - _keyManager: ActiveDescendantKeyManager; + _keyManager: ActiveDescendantKeyManager; /** Whether the autocomplete panel should be visible, depending on option length. */ showPanel = false; @@ -65,25 +65,25 @@ export class MdAutocomplete implements AfterContentInit { @ViewChild('panel') panel: ElementRef; /** @docs-private */ - @ContentChildren(MdOption, { descendants: true }) options: QueryList; + @ContentChildren(MatOption, { descendants: true }) options: QueryList; /** @docs-private */ - @ContentChildren(MdOptgroup) optionGroups: QueryList; + @ContentChildren(MatOptgroup) optionGroups: QueryList; /** Function that maps an option's control value to its display value in the trigger. */ @Input() displayWith: ((value: any) => string) | null = null; /** Event that is emitted whenever an option from the list is selected. */ - @Output() optionSelected: EventEmitter = - new EventEmitter(); + @Output() optionSelected: EventEmitter = + new EventEmitter(); /** Unique ID to be used by autocomplete trigger's "aria-owns" property. */ - id: string = `md-autocomplete-${_uniqueAutocompleteIdCounter++}`; + id: string = `mat-autocomplete-${_uniqueAutocompleteIdCounter++}`; constructor(private _changeDetectorRef: ChangeDetectorRef) { } ngAfterContentInit() { - this._keyManager = new ActiveDescendantKeyManager(this.options).withWrap(); + this._keyManager = new ActiveDescendantKeyManager(this.options).withWrap(); } /** @@ -110,8 +110,8 @@ export class MdAutocomplete implements AfterContentInit { } /** Emits the `select` event. */ - _emitSelectEvent(option: MdOption): void { - const event = new MdAutocompleteSelectedEvent(this, option); + _emitSelectEvent(option: MatOption): void { + const event = new MatAutocompleteSelectedEvent(this, option); this.optionSelected.emit(event); } diff --git a/src/lib/autocomplete/mat-exports.ts b/src/lib/autocomplete/mat-exports.ts deleted file mode 100644 index adf1f587a717..000000000000 --- a/src/lib/autocomplete/mat-exports.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdAutocomplete} from './autocomplete'; -import {MdAutocompleteModule} from './autocomplete-module'; -import { - MD_AUTOCOMPLETE_SCROLL_STRATEGY, - MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER, - MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY, - MD_AUTOCOMPLETE_VALUE_ACCESSOR, - MdAutocompleteTrigger, -} from './autocomplete-trigger'; - - -/* tslint:disable:max-line-length */ -export {MD_AUTOCOMPLETE_SCROLL_STRATEGY as MAT_AUTOCOMPLETE_SCROLL_STRATEGY}; -export {MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER as MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER}; -export {MD_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY as MAT_AUTOCOMPLETE_SCROLL_STRATEGY_PROVIDER_FACTORY}; -export {MD_AUTOCOMPLETE_VALUE_ACCESSOR as MAT_AUTOCOMPLETE_VALUE_ACCESSOR}; -export {MdAutocomplete as MatAutocomplete}; -export {MdAutocompleteModule as MatAutocompleteModule}; -export {MdAutocompleteTrigger as MatAutocompleteTrigger}; diff --git a/src/lib/autocomplete/public_api.ts b/src/lib/autocomplete/public_api.ts index ce1e1dfacde8..dab3c54fc9d8 100644 --- a/src/lib/autocomplete/public_api.ts +++ b/src/lib/autocomplete/public_api.ts @@ -9,4 +9,4 @@ export * from './autocomplete'; export * from './autocomplete-module'; export * from './autocomplete-trigger'; -export * from './mat-exports'; + diff --git a/src/lib/button-toggle/_button-toggle-theme.scss b/src/lib/button-toggle/_button-toggle-theme.scss index 83715baa6f7c..f381958472f9 100644 --- a/src/lib/button-toggle/_button-toggle-theme.scss +++ b/src/lib/button-toggle/_button-toggle-theme.scss @@ -2,7 +2,7 @@ @import '../core/theming/theming'; @import '../core/typography/typography-utils'; -// Applies a focus style to an md-button-toggle element for each of the supported palettes. +// Applies a focus style to an mat-button-toggle element for each of the supported palettes. @mixin _mat-button-toggle-focus-color($theme) { $background: map-get($theme, background); diff --git a/src/lib/button-toggle/button-toggle-module.ts b/src/lib/button-toggle/button-toggle-module.ts index e14857e5b6a2..f3e6271430ce 100644 --- a/src/lib/button-toggle/button-toggle-module.ts +++ b/src/lib/button-toggle/button-toggle-module.ts @@ -7,20 +7,20 @@ */ import {NgModule} from '@angular/core'; -import {MdButtonToggleGroup, MdButtonToggleGroupMultiple, MdButtonToggle} from './button-toggle'; -import {UNIQUE_SELECTION_DISPATCHER_PROVIDER, MdCommonModule} from '@angular/material/core'; +import {MatButtonToggleGroup, MatButtonToggleGroupMultiple, MatButtonToggle} from './button-toggle'; +import {UNIQUE_SELECTION_DISPATCHER_PROVIDER, MatCommonModule} from '@angular/material/core'; import {A11yModule} from '@angular/cdk/a11y'; @NgModule({ - imports: [MdCommonModule, A11yModule], + imports: [MatCommonModule, A11yModule], exports: [ - MdButtonToggleGroup, - MdButtonToggleGroupMultiple, - MdButtonToggle, - MdCommonModule, + MatButtonToggleGroup, + MatButtonToggleGroupMultiple, + MatButtonToggle, + MatCommonModule, ], - declarations: [MdButtonToggleGroup, MdButtonToggleGroupMultiple, MdButtonToggle], + declarations: [MatButtonToggleGroup, MatButtonToggleGroupMultiple, MatButtonToggle], providers: [UNIQUE_SELECTION_DISPATCHER_PROVIDER] }) -export class MdButtonToggleModule {} +export class MatButtonToggleModule {} diff --git a/src/lib/button-toggle/button-toggle.md b/src/lib/button-toggle/button-toggle.md index 2d63576f1f83..da133c4d223c 100644 --- a/src/lib/button-toggle/button-toggle.md +++ b/src/lib/button-toggle/button-toggle.md @@ -1,17 +1,17 @@ -`` are on/off toggles with the appearance of a button. These toggles can be +`` are on/off toggles with the appearance of a button. These toggles can be configured to behave as either radio-buttons or checkboxes. While they can be standalone, they are -typically part of a `md-button-toggle-group`. +typically part of a `mat-button-toggle-group`. ### Exclusive selection vs. multiple selection -By default, `md-button-toggle-group` acts like a radio-button group- only one item can be selected. -In this mode, the `value` of the `md-button-toggle-group` will reflect the value of the selected +By default, `mat-button-toggle-group` acts like a radio-button group- only one item can be selected. +In this mode, the `value` of the `mat-button-toggle-group` will reflect the value of the selected button and `ngModel` is supported. Adding the `multiple` attribute allows multiple items to be selected (checkbox behavior). In this -mode the values of the the toggles are not used, the `md-button-toggle-group` does not have a value, +mode the values of the the toggles are not used, the `mat-button-toggle-group` does not have a value, and `ngModel` is not supported. ### Accessibility diff --git a/src/lib/button-toggle/button-toggle.spec.ts b/src/lib/button-toggle/button-toggle.spec.ts index 48fd73fe1b28..fa793edd8a39 100644 --- a/src/lib/button-toggle/button-toggle.spec.ts +++ b/src/lib/button-toggle/button-toggle.spec.ts @@ -9,19 +9,19 @@ import {NgModel, FormsModule, ReactiveFormsModule, FormControl} from '@angular/f import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; import { - MdButtonToggleGroup, - MdButtonToggle, - MdButtonToggleGroupMultiple, - MdButtonToggleChange, - MdButtonToggleModule, + MatButtonToggleGroup, + MatButtonToggle, + MatButtonToggleGroupMultiple, + MatButtonToggleChange, + MatButtonToggleModule, } from './index'; -describe('MdButtonToggle with forms', () => { +describe('MatButtonToggle with forms', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdButtonToggleModule, FormsModule, ReactiveFormsModule], + imports: [MatButtonToggleModule, FormsModule, ReactiveFormsModule], declarations: [ ButtonToggleGroupWithNgModel, ButtonToggleGroupWithFormControl, @@ -34,7 +34,7 @@ describe('MdButtonToggle with forms', () => { describe('using FormControl', () => { let fixture: ComponentFixture; let groupDebugElement: DebugElement; - let groupInstance: MdButtonToggleGroup; + let groupInstance: MatButtonToggleGroup; let testComponent: ButtonToggleGroupWithFormControl; beforeEach(async(() => { @@ -43,8 +43,8 @@ describe('MdButtonToggle with forms', () => { testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdButtonToggleGroup)); - groupInstance = groupDebugElement.injector.get(MdButtonToggleGroup); + groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup)); + groupInstance = groupDebugElement.injector.get(MatButtonToggleGroup); })); it('should toggle the disabled state', () => { @@ -83,8 +83,8 @@ describe('MdButtonToggle with forms', () => { let groupNativeElement: HTMLElement; let buttonToggleDebugElements: DebugElement[]; let buttonToggleNativeElements: HTMLElement[]; - let groupInstance: MdButtonToggleGroup; - let buttonToggleInstances: MdButtonToggle[]; + let groupInstance: MatButtonToggleGroup; + let buttonToggleInstances: MatButtonToggle[]; let testComponent: ButtonToggleGroupWithNgModel; let groupNgModel: NgModel; let buttonToggleLabels: HTMLElement[]; @@ -94,12 +94,12 @@ describe('MdButtonToggle with forms', () => { fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdButtonToggleGroup)); + groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup)); groupNativeElement = groupDebugElement.nativeElement; - groupInstance = groupDebugElement.injector.get(MdButtonToggleGroup); + groupInstance = groupDebugElement.injector.get(MatButtonToggleGroup); groupNgModel = groupDebugElement.injector.get(NgModel); - buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MdButtonToggle)); + buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MatButtonToggle)); buttonToggleNativeElements = buttonToggleDebugElements.map(debugEl => debugEl.nativeElement); buttonToggleInstances = buttonToggleDebugElements.map(debugEl => debugEl.componentInstance); @@ -181,11 +181,11 @@ describe('MdButtonToggle with forms', () => { }); -describe('MdButtonToggle without forms', () => { +describe('MatButtonToggle without forms', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdButtonToggleModule], + imports: [MatButtonToggleModule], declarations: [ ButtonTogglesInsideButtonToggleGroup, ButtonTogglesInsideButtonToggleGroupMultiple, @@ -207,8 +207,8 @@ describe('MdButtonToggle without forms', () => { let buttonToggleDebugElements: DebugElement[]; let buttonToggleNativeElements: HTMLElement[]; let buttonToggleLabelElements: HTMLLabelElement[]; - let groupInstance: MdButtonToggleGroup; - let buttonToggleInstances: MdButtonToggle[]; + let groupInstance: MatButtonToggleGroup; + let buttonToggleInstances: MatButtonToggle[]; let testComponent: ButtonTogglesInsideButtonToggleGroup; beforeEach(() => { @@ -217,11 +217,11 @@ describe('MdButtonToggle without forms', () => { testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdButtonToggleGroup)); + groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup)); groupNativeElement = groupDebugElement.nativeElement; - groupInstance = groupDebugElement.injector.get(MdButtonToggleGroup); + groupInstance = groupDebugElement.injector.get(MatButtonToggleGroup); - buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MdButtonToggle)); + buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MatButtonToggle)); buttonToggleNativeElements = buttonToggleDebugElements .map(debugEl => debugEl.nativeElement); @@ -366,9 +366,9 @@ describe('MdButtonToggle without forms', () => { it('should not fire an initial change event', () => { let fixture = TestBed.createComponent(ButtonToggleGroupWithInitialValue); let testComponent = fixture.debugElement.componentInstance; - let groupDebugElement = fixture.debugElement.query(By.directive(MdButtonToggleGroup)); - let groupInstance: MdButtonToggleGroup = groupDebugElement.injector - .get(MdButtonToggleGroup); + let groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup)); + let groupInstance: MatButtonToggleGroup = groupDebugElement.injector + .get(MatButtonToggleGroup); fixture.detectChanges(); @@ -391,8 +391,8 @@ describe('MdButtonToggle without forms', () => { let buttonToggleDebugElements: DebugElement[]; let buttonToggleNativeElements: HTMLElement[]; let buttonToggleLabelElements: HTMLLabelElement[]; - let groupInstance: MdButtonToggleGroupMultiple; - let buttonToggleInstances: MdButtonToggle[]; + let groupInstance: MatButtonToggleGroupMultiple; + let buttonToggleInstances: MatButtonToggle[]; let testComponent: ButtonTogglesInsideButtonToggleGroupMultiple; beforeEach(async(() => { @@ -401,12 +401,12 @@ describe('MdButtonToggle without forms', () => { testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdButtonToggleGroupMultiple)); + groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroupMultiple)); groupNativeElement = groupDebugElement.nativeElement; - groupInstance = groupDebugElement.injector.get( - MdButtonToggleGroupMultiple); + groupInstance = groupDebugElement.injector.get( + MatButtonToggleGroupMultiple); - buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MdButtonToggle)); + buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MatButtonToggle)); buttonToggleNativeElements = buttonToggleDebugElements .map(debugEl => debugEl.nativeElement); buttonToggleLabelElements = fixture.debugElement.queryAll(By.css('label')) @@ -499,7 +499,7 @@ describe('MdButtonToggle without forms', () => { let buttonToggleDebugElement: DebugElement; let buttonToggleNativeElement: HTMLElement; let buttonToggleLabelElement: HTMLLabelElement; - let buttonToggleInstance: MdButtonToggle; + let buttonToggleInstance: MatButtonToggle; let testComponent: StandaloneButtonToggle; beforeEach(async(() => { @@ -508,7 +508,7 @@ describe('MdButtonToggle without forms', () => { testComponent = fixture.debugElement.componentInstance; - buttonToggleDebugElement = fixture.debugElement.query(By.directive(MdButtonToggle)); + buttonToggleDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle)); buttonToggleNativeElement = buttonToggleDebugElement.nativeElement; buttonToggleLabelElement = fixture.debugElement.query(By.css('label')).nativeElement; buttonToggleInstance = buttonToggleDebugElement.componentInstance; @@ -567,7 +567,7 @@ describe('MdButtonToggle without forms', () => { it('should use the provided aria-label', () => { let fixture = TestBed.createComponent(ButtonToggleWithAriaLabel); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdButtonToggle)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input') as HTMLInputElement; @@ -583,7 +583,7 @@ describe('MdButtonToggle without forms', () => { it('should use the provided aria-labelledby', () => { let fixture = TestBed.createComponent(ButtonToggleWithAriaLabelledby); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdButtonToggle)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input') as HTMLInputElement; @@ -593,7 +593,7 @@ describe('MdButtonToggle without forms', () => { it('should not assign aria-labelledby if none is provided', () => { let fixture = TestBed.createComponent(StandaloneButtonToggle); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdButtonToggle)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input') as HTMLInputElement; @@ -605,11 +605,13 @@ describe('MdButtonToggle without forms', () => { @Component({ template: ` - - Test1 - Test2 - Test3 - + + Test1 + Test2 + Test3 + ` }) class ButtonTogglesInsideButtonToggleGroup { @@ -620,11 +622,11 @@ class ButtonTogglesInsideButtonToggleGroup { @Component({ template: ` - - + + {{option.label}} - - + + ` }) class ButtonToggleGroupWithNgModel { @@ -634,16 +636,16 @@ class ButtonToggleGroupWithNgModel { {label: 'Green', value: 'green'}, {label: 'Blue', value: 'blue'}, ]; - lastEvent: MdButtonToggleChange; + lastEvent: MatButtonToggleChange; } @Component({ template: ` - - Eggs - Flour - Sugar - + + Eggs + Flour + Sugar + ` }) class ButtonTogglesInsideButtonToggleGroupMultiple { @@ -653,30 +655,30 @@ class ButtonTogglesInsideButtonToggleGroupMultiple { @Component({ template: ` - Yes + Yes ` }) class StandaloneButtonToggle { } @Component({ template: ` - - Value Red - Value Green - + + Value Red + Value Green + ` }) class ButtonToggleGroupWithInitialValue { - lastEvent: MdButtonToggleChange; + lastEvent: MatButtonToggleChange; } @Component({ template: ` - - Value Red - Value Green - Value Blue - + + Value Red + Value Green + Value Blue + ` }) class ButtonToggleGroupWithFormControl { @@ -685,12 +687,12 @@ class ButtonToggleGroupWithFormControl { /** Simple test component with an aria-label set. */ @Component({ - template: `` + template: `` }) class ButtonToggleWithAriaLabel { } /** Simple test component with an aria-label set. */ @Component({ - template: `` + template: `` }) class ButtonToggleWithAriaLabelledby {} diff --git a/src/lib/button-toggle/button-toggle.ts b/src/lib/button-toggle/button-toggle.ts index cb45c07dec00..7bc8fa72da90 100644 --- a/src/lib/button-toggle/button-toggle.ts +++ b/src/lib/button-toggle/button-toggle.ts @@ -34,58 +34,58 @@ import {FocusMonitor} from '@angular/cdk/a11y'; /** Acceptable types for a button toggle. */ export type ToggleType = 'checkbox' | 'radio'; -// Boilerplate for applying mixins to MdButtonToggleGroup and MdButtonToggleGroupMultiple +// Boilerplate for applying mixins to MatButtonToggleGroup and MatButtonToggleGroupMultiple /** @docs-private */ -export class MdButtonToggleGroupBase {} -export const _MdButtonToggleGroupMixinBase = mixinDisabled(MdButtonToggleGroupBase); +export class MatButtonToggleGroupBase {} +export const _MatButtonToggleGroupMixinBase = mixinDisabled(MatButtonToggleGroupBase); /** - * Provider Expression that allows md-button-toggle-group to register as a ControlValueAccessor. + * Provider Expression that allows mat-button-toggle-group to register as a ControlValueAccessor. * This allows it to support [(ngModel)]. * @docs-private */ -export const MD_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR: any = { +export const MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdButtonToggleGroup), + useExisting: forwardRef(() => MatButtonToggleGroup), multi: true }; let _uniqueIdCounter = 0; -/** Change event object emitted by MdButtonToggle. */ -export class MdButtonToggleChange { - /** The MdButtonToggle that emits the event. */ - source: MdButtonToggle | null; - /** The value assigned to the MdButtonToggle. */ +/** Change event object emitted by MatButtonToggle. */ +export class MatButtonToggleChange { + /** The MatButtonToggle that emits the event. */ + source: MatButtonToggle | null; + /** The value assigned to the MatButtonToggle. */ value: any; } /** Exclusive selection button toggle group that behaves like a radio-button group. */ @Directive({ - selector: 'md-button-toggle-group:not([multiple]), mat-button-toggle-group:not([multiple])', - providers: [MD_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR], + selector: 'mat-button-toggle-group:not([multiple])', + providers: [MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR], inputs: ['disabled'], host: { 'role': 'radiogroup', 'class': 'mat-button-toggle-group', '[class.mat-button-toggle-vertical]': 'vertical' }, - exportAs: 'mdButtonToggleGroup, matButtonToggleGroup', + exportAs: 'matButtonToggleGroup', }) -export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase +export class MatButtonToggleGroup extends _MatButtonToggleGroupMixinBase implements ControlValueAccessor, CanDisable { /** The value for the button toggle group. Should match currently selected button toggle. */ private _value: any = null; /** The HTML name attribute applied to toggles in this group. */ - private _name: string = `md-button-toggle-group-${_uniqueIdCounter++}`; + private _name: string = `mat-button-toggle-group-${_uniqueIdCounter++}`; /** Whether the button toggle group should be vertical. */ private _vertical: boolean = false; /** The currently selected button toggle, should match the value. */ - private _selected: MdButtonToggle | null = null; + private _selected: MatButtonToggle | null = null; /** * The method to be called in order to update ngModel. @@ -97,7 +97,7 @@ export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase onTouched: () => any = () => {}; /** Child button toggle buttons. */ - @ContentChildren(forwardRef(() => MdButtonToggle)) _buttonToggles: QueryList; + @ContentChildren(forwardRef(() => MatButtonToggle)) _buttonToggles: QueryList; /** `name` attribute for the underlying `input` element. */ @Input() @@ -139,7 +139,7 @@ export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase return this._selected; } - set selected(selected: MdButtonToggle | null) { + set selected(selected: MatButtonToggle | null) { this._selected = selected; this.value = selected ? selected.value : null; @@ -149,7 +149,7 @@ export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase } /** Event emitted when the group's value changes. */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); constructor(private _changeDetector: ChangeDetectorRef) { super(); @@ -184,7 +184,7 @@ export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase /** Dispatch change event with current selection and group value. */ _emitChangeEvent(): void { - let event = new MdButtonToggleChange(); + let event = new MatButtonToggleChange(); event.source = this._selected; event.value = this._value; this._controlValueAccessorChangeFn(event.value); @@ -229,8 +229,8 @@ export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase /** Multiple selection button-toggle group. `ngModel` is not supported in this mode. */ @Directive({ - selector: 'md-button-toggle-group[multiple], mat-button-toggle-group[multiple]', - exportAs: 'mdButtonToggleGroup, matButtonToggleGroup', + selector: 'mat-button-toggle-group[multiple]', + exportAs: 'matButtonToggleGroup', inputs: ['disabled'], host: { 'class': 'mat-button-toggle-group', @@ -238,7 +238,7 @@ export class MdButtonToggleGroup extends _MdButtonToggleGroupMixinBase 'role': 'group' } }) -export class MdButtonToggleGroupMultiple extends _MdButtonToggleGroupMixinBase +export class MatButtonToggleGroupMultiple extends _MatButtonToggleGroupMixinBase implements CanDisable { /** Whether the button toggle group should be vertical. */ @@ -258,7 +258,7 @@ export class MdButtonToggleGroupMultiple extends _MdButtonToggleGroupMixinBase /** Single button inside of a toggle group. */ @Component({ moduleId: module.id, - selector: 'md-button-toggle, mat-button-toggle', + selector: 'mat-button-toggle', templateUrl: 'button-toggle.html', styleUrls: ['button-toggle.css'], encapsulation: ViewEncapsulation.None, @@ -272,7 +272,7 @@ export class MdButtonToggleGroupMultiple extends _MdButtonToggleGroupMixinBase '[attr.id]': 'id', } }) -export class MdButtonToggle implements OnInit, OnDestroy { +export class MatButtonToggle implements OnInit, OnDestroy { /** * Attached to the aria-label attribute of the host element. In most cases, arial-labelledby will * take precedence so this may be omitted. @@ -305,10 +305,10 @@ export class MdButtonToggle implements OnInit, OnDestroy { @ViewChild('input') _inputElement: ElementRef; /** The parent button toggle group (exclusive selection). Optional. */ - buttonToggleGroup: MdButtonToggleGroup; + buttonToggleGroup: MatButtonToggleGroup; /** The parent button toggle group (multiple selection). Optional. */ - buttonToggleGroupMultiple: MdButtonToggleGroupMultiple; + buttonToggleGroupMultiple: MatButtonToggleGroupMultiple; /** Unique ID for the underlying `input` element. */ get inputId(): string { @@ -338,7 +338,7 @@ export class MdButtonToggle implements OnInit, OnDestroy { } } - /** MdButtonToggleGroup reads this to assign its own value. */ + /** MatButtonToggleGroup reads this to assign its own value. */ @Input() get value(): any { return this._value; @@ -365,10 +365,10 @@ export class MdButtonToggle implements OnInit, OnDestroy { } /** Event emitted when the group value changes. */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); - constructor(@Optional() toggleGroup: MdButtonToggleGroup, - @Optional() toggleGroupMultiple: MdButtonToggleGroupMultiple, + constructor(@Optional() toggleGroup: MatButtonToggleGroup, + @Optional() toggleGroupMultiple: MatButtonToggleGroupMultiple, private _changeDetectorRef: ChangeDetectorRef, private _buttonToggleDispatcher: UniqueSelectionDispatcher, private _renderer: Renderer2, @@ -400,7 +400,7 @@ export class MdButtonToggle implements OnInit, OnDestroy { ngOnInit() { if (this.id == null) { - this.id = `md-button-toggle-${_uniqueIdCounter++}`; + this.id = `mat-button-toggle-${_uniqueIdCounter++}`; } if (this.buttonToggleGroup && this._value == this.buttonToggleGroup.value) { @@ -454,7 +454,7 @@ export class MdButtonToggle implements OnInit, OnDestroy { /** Dispatch change event with current value. */ private _emitChangeEvent(): void { - let event = new MdButtonToggleChange(); + let event = new MatButtonToggleChange(); event.source = this; event.value = this._value; this.change.emit(event); diff --git a/src/lib/button-toggle/mat-exports.ts b/src/lib/button-toggle/mat-exports.ts deleted file mode 100644 index cc90bd8db34c..000000000000 --- a/src/lib/button-toggle/mat-exports.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR, - MdButtonToggle, - MdButtonToggleChange, - MdButtonToggleGroup, - MdButtonToggleGroupBase, - MdButtonToggleGroupMultiple, -} from './button-toggle'; -import {MdButtonToggleModule} from './button-toggle-module'; - - -export {MD_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR as MAT_BUTTON_TOGGLE_GROUP_VALUE_ACCESSOR}; -export {MdButtonToggle as MatButtonToggle}; -export {MdButtonToggleChange as MatButtonToggleChange}; -export {MdButtonToggleGroup as MatButtonToggleGroup}; -export {MdButtonToggleGroupBase as MatButtonToggleGroupBase}; -export {MdButtonToggleGroupMultiple as MatButtonToggleGroupMultiple}; -export {MdButtonToggleModule as MatButtonToggleModule}; diff --git a/src/lib/button-toggle/public_api.ts b/src/lib/button-toggle/public_api.ts index 22b48b8b9e18..1912abb6d7e3 100644 --- a/src/lib/button-toggle/public_api.ts +++ b/src/lib/button-toggle/public_api.ts @@ -8,4 +8,4 @@ export * from './button-toggle'; export * from './button-toggle-module'; -export * from './mat-exports'; + diff --git a/src/lib/button/_button-theme.scss b/src/lib/button/_button-theme.scss index 53e182b2b245..661cb8015bec 100644 --- a/src/lib/button/_button-theme.scss +++ b/src/lib/button/_button-theme.scss @@ -1,7 +1,7 @@ @import '../core/theming/theming'; @import '../core/typography/typography-utils'; -// Applies a focus style to an md-button element for each of the supported palettes. +// Applies a focus style to an mat-button element for each of the supported palettes. @mixin _mat-button-focus-color($theme) { $primary: map-get($theme, primary); $accent: map-get($theme, accent); @@ -42,7 +42,7 @@ } } -// Applies a property to an md-button element for each of the supported palettes. +// Applies a property to an mat-button element for each of the supported palettes. @mixin _mat-button-theme-color($theme, $property, $color: 'default') { $primary: map-get($theme, primary); $accent: map-get($theme, accent); diff --git a/src/lib/button/button-module.ts b/src/lib/button/button-module.ts index c32e3fa71ace..b72265dc739d 100644 --- a/src/lib/button/button-module.ts +++ b/src/lib/button/button-module.ts @@ -8,44 +8,44 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {MdCommonModule, MdRippleModule} from '@angular/material/core'; +import {MatCommonModule, MatRippleModule} from '@angular/material/core'; import {A11yModule} from '@angular/cdk/a11y'; import { - MdAnchor, - MdButton, - MdMiniFab, - MdButtonCssMatStyler, - MdFab, - MdIconButtonCssMatStyler, - MdRaisedButtonCssMatStyler + MatAnchor, + MatButton, + MatMiniFab, + MatButtonCssMatStyler, + MatFab, + MatIconButtonCssMatStyler, + MatRaisedButtonCssMatStyler } from './button'; @NgModule({ imports: [ CommonModule, - MdRippleModule, - MdCommonModule, + MatRippleModule, + MatCommonModule, A11yModule, ], exports: [ - MdButton, - MdAnchor, - MdMiniFab, - MdFab, - MdCommonModule, - MdButtonCssMatStyler, - MdRaisedButtonCssMatStyler, - MdIconButtonCssMatStyler, + MatButton, + MatAnchor, + MatMiniFab, + MatFab, + MatCommonModule, + MatButtonCssMatStyler, + MatRaisedButtonCssMatStyler, + MatIconButtonCssMatStyler, ], declarations: [ - MdButton, - MdAnchor, - MdMiniFab, - MdFab, - MdButtonCssMatStyler, - MdRaisedButtonCssMatStyler, - MdIconButtonCssMatStyler, + MatButton, + MatAnchor, + MatMiniFab, + MatFab, + MatButtonCssMatStyler, + MatRaisedButtonCssMatStyler, + MatIconButtonCssMatStyler, ], }) -export class MdButtonModule {} +export class MatButtonModule {} diff --git a/src/lib/button/button.html b/src/lib/button/button.html index e7caa601203c..a9af6ab8b4c7 100644 --- a/src/lib/button/button.html +++ b/src/lib/button/button.html @@ -1,5 +1,5 @@ -
` element should be used for any interaction that _perform current page_. The `` element should be used for any interaction that _navigates to another view_. -Buttons or links containing only icons (such as `md-fab`, `md-mini-fab`, and `md-icon-button`) should +Buttons or links containing only icons (such as `mat-fab`, `mat-mini-fab`, and `mat-icon-button`) should be given a meaningful label via `aria-label` or `aria-labelledby`. diff --git a/src/lib/button/button.spec.ts b/src/lib/button/button.spec.ts index a7707a08d207..3aed8f7fafac 100644 --- a/src/lib/button/button.spec.ts +++ b/src/lib/button/button.spec.ts @@ -3,15 +3,15 @@ import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; import {ViewportRuler} from '@angular/cdk/scrolling'; import {FakeViewportRuler} from '@angular/cdk/testing'; -import {MdButtonModule} from './index'; -import {MdRipple} from '@angular/material/core'; +import {MatButtonModule} from './index'; +import {MatRipple} from '@angular/material/core'; -describe('MdButton', () => { +describe('MatButton', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdButtonModule], + imports: [MatButtonModule], declarations: [TestApp], providers: [ {provide: ViewportRuler, useClass: FakeViewportRuler}, @@ -67,10 +67,10 @@ describe('MdButton', () => { expect(buttonDebugElement.nativeElement.classList.contains('custom-class')).toBe(true); }); - describe('button[md-fab]', () => { + describe('button[mat-fab]', () => { it('should have accent palette by default', () => { const fixture = TestBed.createComponent(TestApp); - const fabButtonDebugEl = fixture.debugElement.query(By.css('button[md-fab]')); + const fabButtonDebugEl = fixture.debugElement.query(By.css('button[mat-fab]')); fixture.detectChanges(); @@ -79,10 +79,10 @@ describe('MdButton', () => { }); }); - describe('button[md-mini-fab]', () => { + describe('button[mat-mini-fab]', () => { it('should have accent palette by default', () => { const fixture = TestBed.createComponent(TestApp); - const miniFabButtonDebugEl = fixture.debugElement.query(By.css('button[md-mini-fab]')); + const miniFabButtonDebugEl = fixture.debugElement.query(By.css('button[mat-mini-fab]')); fixture.detectChanges(); @@ -92,7 +92,7 @@ describe('MdButton', () => { }); // Regular button tests - describe('button[md-button]', () => { + describe('button[mat-button]', () => { it('should handle a click on the button', () => { let fixture = TestBed.createComponent(TestApp); let testComponent = fixture.debugElement.componentInstance; @@ -128,7 +128,7 @@ describe('MdButton', () => { }); // Anchor button tests - describe('a[md-button]', () => { + describe('a[mat-button]', () => { it('should not redirect if disabled', () => { let fixture = TestBed.createComponent(TestApp); let testComponent = fixture.debugElement.componentInstance; @@ -188,10 +188,10 @@ describe('MdButton', () => { let testComponent: TestApp; let buttonDebugElement: DebugElement; let buttonRippleDebugElement: DebugElement; - let buttonRippleInstance: MdRipple; + let buttonRippleInstance: MatRipple; let anchorDebugElement: DebugElement; let anchorRippleDebugElement: DebugElement; - let anchorRippleInstance: MdRipple; + let anchorRippleInstance: MatRipple; beforeEach(() => { fixture = TestBed.createComponent(TestApp); @@ -199,16 +199,16 @@ describe('MdButton', () => { testComponent = fixture.componentInstance; - buttonDebugElement = fixture.debugElement.query(By.css('button[md-button]')); - buttonRippleDebugElement = buttonDebugElement.query(By.directive(MdRipple)); - buttonRippleInstance = buttonRippleDebugElement.injector.get(MdRipple); + buttonDebugElement = fixture.debugElement.query(By.css('button[mat-button]')); + buttonRippleDebugElement = buttonDebugElement.query(By.directive(MatRipple)); + buttonRippleInstance = buttonRippleDebugElement.injector.get(MatRipple); - anchorDebugElement = fixture.debugElement.query(By.css('a[md-button]')); - anchorRippleDebugElement = anchorDebugElement.query(By.directive(MdRipple)); - anchorRippleInstance = anchorRippleDebugElement.injector.get(MdRipple); + anchorDebugElement = fixture.debugElement.query(By.css('a[mat-button]')); + anchorRippleDebugElement = anchorDebugElement.query(By.directive(MatRipple)); + anchorRippleInstance = anchorRippleDebugElement.injector.get(MatRipple); }); - it('should disable the ripple if mdRippleDisabled input is set', () => { + it('should disable the ripple if matRippleDisabled input is set', () => { expect(buttonRippleInstance.disabled).toBeFalsy(); testComponent.rippleDisabled = true; @@ -219,36 +219,38 @@ describe('MdButton', () => { it('should disable the ripple when the button is disabled', () => { expect(buttonRippleInstance.disabled).toBeFalsy( - 'Expected an enabled button[md-button] to have an enabled ripple' + 'Expected an enabled button[mat-button] to have an enabled ripple' ); expect(anchorRippleInstance.disabled).toBeFalsy( - 'Expected an enabled a[md-button] to have an enabled ripple' + 'Expected an enabled a[mat-button] to have an enabled ripple' ); testComponent.isDisabled = true; fixture.detectChanges(); expect(buttonRippleInstance.disabled).toBeTruthy( - 'Expected a disabled button[md-button] not to have an enabled ripple' + 'Expected a disabled button[mat-button] not to have an enabled ripple' ); expect(anchorRippleInstance.disabled).toBeTruthy( - 'Expected a disabled a[md-button] not to have an enabled ripple' + 'Expected a disabled a[mat-button] not to have an enabled ripple' ); }); }); }); -/** Test component that contains an MdButton. */ +/** Test component that contains an MatButton. */ @Component({ selector: 'test-app', template: ` - - Link - - + + Link + + + ` }) class TestApp { diff --git a/src/lib/button/button.ts b/src/lib/button/button.ts index d11c1776b299..3d498f4189c1 100644 --- a/src/lib/button/button.ts +++ b/src/lib/button/button.ts @@ -24,7 +24,6 @@ import { CanColor, CanDisable, CanDisableRipple, - MATERIAL_COMPATIBILITY_MODE, mixinColor, mixinDisabled, mixinDisableRipple @@ -34,7 +33,7 @@ import {FocusMonitor} from '@angular/cdk/a11y'; // TODO(kara): Convert attribute selectors to classes when attr maps become available -/** Default color palette for round buttons (md-fab and md-mini-fab) */ +/** Default color palette for round buttons (mat-fab and mat-mini-fab) */ const DEFAULT_ROUND_BUTTON_COLOR = 'accent'; @@ -43,46 +42,43 @@ const DEFAULT_ROUND_BUTTON_COLOR = 'accent'; * @docs-private */ @Directive({ - selector: 'button[md-button], button[mat-button], a[md-button], a[mat-button]', + selector: 'button[mat-button], a[mat-button]', host: {'class': 'mat-button'} }) -export class MdButtonCssMatStyler {} +export class MatButtonCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: - 'button[md-raised-button], button[mat-raised-button], ' + - 'a[md-raised-button], a[mat-raised-button]', + selector: 'button[mat-raised-button], a[mat-raised-button]', host: {'class': 'mat-raised-button'} }) -export class MdRaisedButtonCssMatStyler {} +export class MatRaisedButtonCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: - 'button[md-icon-button], button[mat-icon-button], a[md-icon-button], a[mat-icon-button]', + selector: 'button[mat-icon-button], a[mat-icon-button]', host: {'class': 'mat-icon-button'} }) -export class MdIconButtonCssMatStyler {} +export class MatIconButtonCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: 'button[md-fab], button[mat-fab], a[md-fab], a[mat-fab]', + selector: 'button[mat-fab], a[mat-fab]', host: {'class': 'mat-fab'} }) -export class MdFab { - constructor(@Self() @Optional() @Inject(forwardRef(() => MdButton)) button: MdButton, - @Self() @Optional() @Inject(forwardRef(() => MdAnchor)) anchor: MdAnchor) { - // Set the default color palette for the md-fab components. +export class MatFab { + constructor(@Self() @Optional() @Inject(forwardRef(() => MatButton)) button: MatButton, + @Self() @Optional() @Inject(forwardRef(() => MatAnchor)) anchor: MatAnchor) { + // Set the default color palette for the mat-fab components. (button || anchor).color = DEFAULT_ROUND_BUTTON_COLOR; } } @@ -93,24 +89,24 @@ export class MdFab { * @docs-private */ @Directive({ - selector: 'button[md-mini-fab], button[mat-mini-fab], a[md-mini-fab], a[mat-mini-fab]', + selector: 'button[mat-mini-fab], a[mat-mini-fab]', host: {'class': 'mat-mini-fab'} }) -export class MdMiniFab { - constructor(@Self() @Optional() @Inject(forwardRef(() => MdButton)) button: MdButton, - @Self() @Optional() @Inject(forwardRef(() => MdAnchor)) anchor: MdAnchor) { - // Set the default color palette for the md-mini-fab components. +export class MatMiniFab { + constructor(@Self() @Optional() @Inject(forwardRef(() => MatButton)) button: MatButton, + @Self() @Optional() @Inject(forwardRef(() => MatAnchor)) anchor: MatAnchor) { + // Set the default color palette for the mat-mini-fab components. (button || anchor).color = DEFAULT_ROUND_BUTTON_COLOR; } } -// Boilerplate for applying mixins to MdButton. +// Boilerplate for applying mixins to MatButton. /** @docs-private */ -export class MdButtonBase { +export class MatButtonBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdButtonMixinBase = mixinColor(mixinDisabled(mixinDisableRipple(MdButtonBase))); +export const _MatButtonMixinBase = mixinColor(mixinDisabled(mixinDisableRipple(MatButtonBase))); /** @@ -118,9 +114,7 @@ export const _MdButtonMixinBase = mixinColor(mixinDisabled(mixinDisableRipple(Md */ @Component({ moduleId: module.id, - selector: `button[md-button], button[md-raised-button], button[md-icon-button], - button[md-fab], button[md-mini-fab], - button[mat-button], button[mat-raised-button], button[mat-icon-button], + selector: `button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab]`, host: { '[disabled]': 'disabled || null', @@ -131,9 +125,8 @@ export const _MdButtonMixinBase = mixinColor(mixinDisabled(mixinDisableRipple(Md encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdButton extends _MdButtonMixinBase +export class MatButton extends _MatButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple { /** Whether the button is round. */ @@ -167,10 +160,7 @@ export class MdButton extends _MdButtonMixinBase return this.disableRipple || this.disabled; } - /** - * Gets whether the button has one of the given attributes - * with either an 'md-' or 'mat-' prefix. - */ + /** Gets whether the button has one of the given attributes with a 'mat-' prefix. */ _hasAttributeWithPrefix(...unprefixedAttributeNames: string[]) { // If not on the browser, say that there are none of the attributes present. // Since these only affect how the ripple displays (and ripples only happen on the client), @@ -180,9 +170,7 @@ export class MdButton extends _MdButtonMixinBase } return unprefixedAttributeNames.some(suffix => { - const el = this._getHostElement(); - - return el.hasAttribute('md-' + suffix) || el.hasAttribute('mat-' + suffix); + return this._getHostElement().hasAttribute('mat-' + suffix); }); } } @@ -192,8 +180,7 @@ export class MdButton extends _MdButtonMixinBase */ @Component({ moduleId: module.id, - selector: `a[md-button], a[md-raised-button], a[md-icon-button], a[md-fab], a[md-mini-fab], - a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab]`, + selector: `a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab]`, host: { '[attr.tabindex]': 'disabled ? -1 : 0', '[attr.disabled]': 'disabled || null', @@ -207,7 +194,7 @@ export class MdButton extends _MdButtonMixinBase preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdAnchor extends MdButton { +export class MatAnchor extends MatButton { constructor( platform: Platform, focusMonitor: FocusMonitor, diff --git a/src/lib/button/mat-exports.ts b/src/lib/button/mat-exports.ts deleted file mode 100644 index 61e08fd808dd..000000000000 --- a/src/lib/button/mat-exports.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MdAnchor, - MdButton, - MdButtonBase, - MdButtonCssMatStyler, - MdFab, - MdIconButtonCssMatStyler, - MdMiniFab, - MdRaisedButtonCssMatStyler, -} from './button'; -import {MdButtonModule} from './button-module'; - -export {MdButton as MatButton}; -export {MdButtonBase as MatButtonBase}; -export {MdButtonCssMatStyler as MatButtonCssMatStyler}; -export {MdButtonModule as MatButtonModule}; -export {MdAnchor as MatAnchor}; -export {MdIconButtonCssMatStyler as MatIconButtonCssMatStyler}; -export {MdFab as MatFab}; -export {MdMiniFab as MatMiniFab}; -export {MdRaisedButtonCssMatStyler as MatRaisedButtonCssMatStyler}; diff --git a/src/lib/button/public_api.ts b/src/lib/button/public_api.ts index 7867a26b0db3..b8b9355bf302 100644 --- a/src/lib/button/public_api.ts +++ b/src/lib/button/public_api.ts @@ -8,4 +8,4 @@ export * from './button-module'; export * from './button'; -export * from './mat-exports'; + diff --git a/src/lib/card/card-header.html b/src/lib/card/card-header.html index 42cbd1b14252..74371726e671 100644 --- a/src/lib/card/card-header.html +++ b/src/lib/card/card-header.html @@ -1,7 +1,6 @@ - +
- + +
diff --git a/src/lib/card/card-module.ts b/src/lib/card/card-module.ts index 3843333c7fd5..e30a338ff45e 100644 --- a/src/lib/card/card-module.ts +++ b/src/lib/card/card-module.ts @@ -7,48 +7,48 @@ */ import {NgModule} from '@angular/core'; -import {MdCommonModule} from '@angular/material/core'; +import {MatCommonModule} from '@angular/material/core'; import { - MdCard, - MdCardHeader, - MdCardTitleGroup, - MdCardContent, - MdCardTitle, - MdCardSubtitle, - MdCardActions, - MdCardFooter, - MdCardSmImage, - MdCardMdImage, - MdCardLgImage, - MdCardImage, - MdCardXlImage, - MdCardAvatar, + MatCard, + MatCardHeader, + MatCardTitleGroup, + MatCardContent, + MatCardTitle, + MatCardSubtitle, + MatCardActions, + MatCardFooter, + MatCardSmImage, + MatCardMdImage, + MatCardLgImage, + MatCardImage, + MatCardXlImage, + MatCardAvatar, } from './card'; @NgModule({ - imports: [MdCommonModule], + imports: [MatCommonModule], exports: [ - MdCard, - MdCardHeader, - MdCardTitleGroup, - MdCardContent, - MdCardTitle, - MdCardSubtitle, - MdCardActions, - MdCardFooter, - MdCardSmImage, - MdCardMdImage, - MdCardLgImage, - MdCardImage, - MdCardXlImage, - MdCardAvatar, - MdCommonModule, + MatCard, + MatCardHeader, + MatCardTitleGroup, + MatCardContent, + MatCardTitle, + MatCardSubtitle, + MatCardActions, + MatCardFooter, + MatCardSmImage, + MatCardMdImage, + MatCardLgImage, + MatCardImage, + MatCardXlImage, + MatCardAvatar, + MatCommonModule, ], declarations: [ - MdCard, MdCardHeader, MdCardTitleGroup, MdCardContent, MdCardTitle, MdCardSubtitle, - MdCardActions, MdCardFooter, MdCardSmImage, MdCardMdImage, MdCardLgImage, MdCardImage, - MdCardXlImage, MdCardAvatar, + MatCard, MatCardHeader, MatCardTitleGroup, MatCardContent, MatCardTitle, MatCardSubtitle, + MatCardActions, MatCardFooter, MatCardSmImage, MatCardMdImage, MatCardLgImage, MatCardImage, + MatCardXlImage, MatCardAvatar, ], }) -export class MdCardModule {} +export class MatCardModule {} diff --git a/src/lib/card/card-title-group.html b/src/lib/card/card-title-group.html index 4e1d758f7f69..af6035693bdc 100644 --- a/src/lib/card/card-title-group.html +++ b/src/lib/card/card-title-group.html @@ -1,7 +1,6 @@
- + +
diff --git a/src/lib/card/card.html b/src/lib/card/card.html index d26c09f7bd43..3a56f6c2fe37 100644 --- a/src/lib/card/card.html +++ b/src/lib/card/card.html @@ -1,2 +1,2 @@ - + diff --git a/src/lib/card/card.md b/src/lib/card/card.md index 37ae6fe3e9b2..fe3a6b33b328 100644 --- a/src/lib/card/card.md +++ b/src/lib/card/card.md @@ -1,58 +1,58 @@ -`` is a content container for text, photos, and actions in the context of a single subject. +`` is a content container for text, photos, and actions in the context of a single subject. ### Basic card sections -The most basic card needs only an `` element with some content. However, Angular Material -provides a number of preset sections that you can use inside of an ``: +The most basic card needs only an `` element with some content. However, Angular Material +provides a number of preset sections that you can use inside of an ``: | Element | Description | |-----------------------|--------------------------------------------------------------------------| -| `` | Card title | -| `` | Card subtitle | -| `` | Primary card content. Intended for blocks of text | -| `` | Card image. Stretches the image to the container width | -| `` | Container for buttons at the bottom of the card | -| `` | Section anchored to the bottom of the card | +| `` | Card title | +| `` | Card subtitle | +| `` | Primary card content. Intended for blocks of text | +| `` | Card image. Stretches the image to the container width | +| `` | Container for buttons at the bottom of the card | +| `` | Section anchored to the bottom of the card | These elements primary serve as pre-styled content containers without any additional APIs. -However, the `align` property on `` can be used to position the actions at the +However, the `align` property on `` can be used to position the actions at the `'start'` or `'end` of the container. ### Card headers -In addition to the aforementioned sections, `` gives the ability to add a rich +In addition to the aforementioned sections, `` gives the ability to add a rich header to a card. This header can contain: | Element | Description | |------------------------|-------------------------------------------------------------------------| -| `` | A title within the header | -| `` | A subtitle within the header | -| `` | An image used as an avatar within the header | +| `` | A title within the header | +| `` | A subtitle within the header | +| `` | An image used as an avatar within the header | ### Title groups -`` can be used to combine a title, subtitle, and image into a single section. +`` can be used to combine a title, subtitle, and image into a single section. This element can contain: -* `` -* `` +* `` +* `` * One of: - * `` - * `` - * `` + * `` + * `` + * `` ### Accessibility Cards can be used in a wide variety of scenarios and can contain many different types of content. -Due to this dynamic nature, the appropriate accessibility treatment depends on how `` is +Due to this dynamic nature, the appropriate accessibility treatment depends on how `` is used. #### Group, region, and landmarks There are several ARIA roles that communicate that a portion of the UI represents some semantically meaningful whole. Depending on what the content of the card means to your application, [`role="group"`][0], [`role="region"`][1], or [one of the landmark roles][3] should typically be -applied to the `` element. +applied to the `` element. A role is not necessary when the card is used as a purely decorative container that does not convey a meaningful grouping of related content for a single subject. In these cases, the content @@ -60,7 +60,7 @@ of the card should follow standard practices for document content. #### Focus -Depending on how cards are used, it may be appropriate to apply a `tabindex` to the `` +Depending on how cards are used, it may be appropriate to apply a `tabindex` to the `` element. If cards are a primary mechanism through which user interact with the application, `tabindex="0"` is appropriate. If attention can be sent to the card, but it's not part of the document flow, `tabindex="-1"` is appropriate. diff --git a/src/lib/card/card.ts b/src/lib/card/card.ts index 2ec494d2b118..fc1e7a34ace3 100644 --- a/src/lib/card/card.ts +++ b/src/lib/card/card.ts @@ -20,49 +20,47 @@ import { * @docs-private */ @Directive({ - selector: 'md-card-content, mat-card-content', + selector: 'mat-card-content', host: {'class': 'mat-card-content'} }) -export class MdCardContent {} +export class MatCardContent {} /** * Title of a card, needed as it's used as a selector in the API. * @docs-private */ @Directive({ - selector: `md-card-title, mat-card-title, [md-card-title], [mat-card-title], - [mdCardTitle], [matCardTitle]`, + selector: `mat-card-title, [mat-card-title], [matCardTitle]`, host: { 'class': 'mat-card-title' } }) -export class MdCardTitle {} +export class MatCardTitle {} /** * Sub-title of a card, needed as it's used as a selector in the API. * @docs-private */ @Directive({ - selector: `md-card-subtitle, mat-card-subtitle, [md-card-subtitle], [mat-card-subtitle], - [mdCardSubtitle], [matCardSubtitle]`, + selector: `mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]`, host: { 'class': 'mat-card-subtitle' } }) -export class MdCardSubtitle {} +export class MatCardSubtitle {} /** * Action section of a card, needed as it's used as a selector in the API. * @docs-private */ @Directive({ - selector: 'md-card-actions, mat-card-actions', + selector: 'mat-card-actions', host: { 'class': 'mat-card-actions', '[class.mat-card-actions-align-end]': 'align === "end"', } }) -export class MdCardActions { +export class MatCardActions { /** Position of the actions inside the card. */ @Input() align: 'start' | 'end' = 'start'; } @@ -72,70 +70,70 @@ export class MdCardActions { * @docs-private */ @Directive({ - selector: 'md-card-footer, mat-card-footer', + selector: 'mat-card-footer', host: {'class': 'mat-card-footer'} }) -export class MdCardFooter {} +export class MatCardFooter {} /** * Image used in a card, needed to add the mat- CSS styling. * @docs-private */ @Directive({ - selector: '[md-card-image], [mat-card-image], [mdCardImage], [matCardImage]', + selector: '[mat-card-image], [matCardImage]', host: {'class': 'mat-card-image'} }) -export class MdCardImage {} +export class MatCardImage {} /** * Image used in a card, needed to add the mat- CSS styling. * @docs-private */ @Directive({ - selector: '[md-card-sm-image], [mat-card-sm-image], [mdCardImageSmall], [matCardImageSmall]', + selector: '[mat-card-sm-image], [matCardImageSmall]', host: {'class': 'mat-card-sm-image'} }) -export class MdCardSmImage {} +export class MatCardSmImage {} /** * Image used in a card, needed to add the mat- CSS styling. * @docs-private */ @Directive({ - selector: '[md-card-md-image], [mat-card-md-image], [mdCardImageMedium], [matCardImageMedium]', + selector: '[mat-card-md-image], [matCardImageMedium]', host: {'class': 'mat-card-md-image'} }) -export class MdCardMdImage {} +export class MatCardMdImage {} /** * Image used in a card, needed to add the mat- CSS styling. * @docs-private */ @Directive({ - selector: '[md-card-lg-image], [mat-card-lg-image], [mdCardImageLarge], [matCardImageLarge]', + selector: '[mat-card-lg-image], [matCardImageLarge]', host: {'class': 'mat-card-lg-image'} }) -export class MdCardLgImage {} +export class MatCardLgImage {} /** * Large image used in a card, needed to add the mat- CSS styling. * @docs-private */ @Directive({ - selector: '[md-card-xl-image], [mat-card-xl-image], [mdCardImageXLarge], [matCardImageXLarge]', + selector: '[mat-card-xl-image], [matCardImageXLarge]', host: {'class': 'mat-card-xl-image'} }) -export class MdCardXlImage {} +export class MatCardXlImage {} /** * Avatar image used in a card, needed to add the mat- CSS styling. * @docs-private */ @Directive({ - selector: '[md-card-avatar], [mat-card-avatar], [mdCardAvatar], [matCardAvatar]', + selector: '[mat-card-avatar], [matCardAvatar]', host: {'class': 'mat-card-avatar'} }) -export class MdCardAvatar {} +export class MatCardAvatar {} /** @@ -143,15 +141,15 @@ export class MdCardAvatar {} * * While this component can be used alone, it also provides a number * of preset styles for common card sections, including: - * - md-card-title - * - md-card-subtitle - * - md-card-content - * - md-card-actions - * - md-card-footer + * - mat-card-title + * - mat-card-subtitle + * - mat-card-content + * - mat-card-actions + * - mat-card-footer */ @Component({ moduleId: module.id, - selector: 'md-card, mat-card', + selector: 'mat-card', templateUrl: 'card.html', styleUrls: ['card.css'], encapsulation: ViewEncapsulation.None, @@ -159,38 +157,38 @@ export class MdCardAvatar {} changeDetection: ChangeDetectionStrategy.OnPush, host: {'class': 'mat-card'} }) -export class MdCard {} +export class MatCard {} /** - * Component intended to be used within the `` component. It adds styles for a + * Component intended to be used within the `` component. It adds styles for a * preset header section (i.e. a title, subtitle, and avatar layout). * @docs-private */ @Component({ moduleId: module.id, - selector: 'md-card-header, mat-card-header', + selector: 'mat-card-header', templateUrl: 'card-header.html', encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, host: {'class': 'mat-card-header'} }) -export class MdCardHeader {} +export class MatCardHeader {} /** - * Component intended to be used within the component. It adds styles for a preset + * Component intended to be used within the component. It adds styles for a preset * layout that groups an image with a title section. * @docs-private */ @Component({ moduleId: module.id, - selector: 'md-card-title-group, mat-card-title-group', + selector: 'mat-card-title-group', templateUrl: 'card-title-group.html', encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, host: {'class': 'mat-card-title-group'} }) -export class MdCardTitleGroup {} +export class MatCardTitleGroup {} diff --git a/src/lib/card/mat-exports.ts b/src/lib/card/mat-exports.ts deleted file mode 100644 index d4b22e577da0..000000000000 --- a/src/lib/card/mat-exports.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MdCard, - MdCardActions, - MdCardAvatar, - MdCardContent, - MdCardFooter, - MdCardHeader, - MdCardImage, - MdCardLgImage, - MdCardMdImage, - MdCardSmImage, - MdCardSubtitle, - MdCardTitle, - MdCardTitleGroup, - MdCardXlImage, -} from './card'; -import {MdCardModule} from './card-module'; - - -export {MdCard as MatCard}; -export {MdCardActions as MatCardActions}; -export {MdCardAvatar as MatCardAvatar}; -export {MdCardContent as MatCardContent}; -export {MdCardFooter as MatCardFooter}; -export {MdCardHeader as MatCardHeader}; -export {MdCardImage as MatCardImage}; -export {MdCardLgImage as MatCardLgImage}; -export {MdCardMdImage as MatCardMatImage}; -export {MdCardModule as MatCardModule}; -export {MdCardSmImage as MatCardSmImage}; -export {MdCardSubtitle as MatCardSubtitle}; -export {MdCardTitle as MatCardTitle}; -export {MdCardTitleGroup as MatCardTitleGroup}; -export {MdCardXlImage as MatCardXlImage}; diff --git a/src/lib/card/public_api.ts b/src/lib/card/public_api.ts index 863f34d9a5c7..8917e375f934 100644 --- a/src/lib/card/public_api.ts +++ b/src/lib/card/public_api.ts @@ -8,4 +8,4 @@ export * from './card'; export * from './card-module'; -export * from './mat-exports'; + diff --git a/src/lib/checkbox/checkbox-module.ts b/src/lib/checkbox/checkbox-module.ts index 49ff7562c8e0..90bf880804c8 100644 --- a/src/lib/checkbox/checkbox-module.ts +++ b/src/lib/checkbox/checkbox-module.ts @@ -9,14 +9,14 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {ObserversModule} from '@angular/cdk/observers'; -import {MdRippleModule, MdCommonModule} from '@angular/material/core'; -import {MdCheckbox} from './checkbox'; -import {MdCheckboxRequiredValidator} from './checkbox-required-validator'; +import {MatRippleModule, MatCommonModule} from '@angular/material/core'; +import {MatCheckbox} from './checkbox'; +import {MatCheckboxRequiredValidator} from './checkbox-required-validator'; import {A11yModule} from '@angular/cdk/a11y'; @NgModule({ - imports: [CommonModule, MdRippleModule, MdCommonModule, ObserversModule, A11yModule], - exports: [MdCheckbox, MdCheckboxRequiredValidator, MdCommonModule], - declarations: [MdCheckbox, MdCheckboxRequiredValidator], + imports: [CommonModule, MatRippleModule, MatCommonModule, ObserversModule, A11yModule], + exports: [MatCheckbox, MatCheckboxRequiredValidator, MatCommonModule], + declarations: [MatCheckbox, MatCheckboxRequiredValidator], }) -export class MdCheckboxModule {} +export class MatCheckboxModule {} diff --git a/src/lib/checkbox/checkbox-required-validator.ts b/src/lib/checkbox/checkbox-required-validator.ts index bd9172d0d781..41ab27739504 100644 --- a/src/lib/checkbox/checkbox-required-validator.ts +++ b/src/lib/checkbox/checkbox-required-validator.ts @@ -16,25 +16,23 @@ import { NG_VALIDATORS, } from '@angular/forms'; -export const _MdCheckboxRequiredValidator = CheckboxRequiredValidator; +export const _MatCheckboxRequiredValidator = CheckboxRequiredValidator; -export const MD_CHECKBOX_REQUIRED_VALIDATOR: Provider = { +export const MAT_CHECKBOX_REQUIRED_VALIDATOR: Provider = { provide: NG_VALIDATORS, - useExisting: forwardRef(() => MdCheckboxRequiredValidator), + useExisting: forwardRef(() => MatCheckboxRequiredValidator), multi: true }; /** * Validator for Material checkbox's required attribute in template-driven checkbox. * Current CheckboxRequiredValidator only work with `input type=checkbox` and does not - * work with `md-checkbox`. + * work with `mat-checkbox`. */ @Directive({ - selector: `md-checkbox[required][formControlName], - mat-checkbox[required][formControlName], - md-checkbox[required][formControl], md-checkbox[required][ngModel], + selector: `mat-checkbox[required][formControlName], mat-checkbox[required][formControl], mat-checkbox[required][ngModel]`, - providers: [MD_CHECKBOX_REQUIRED_VALIDATOR], + providers: [MAT_CHECKBOX_REQUIRED_VALIDATOR], host: {'[attr.required]': 'required ? "" : null'} }) -export class MdCheckboxRequiredValidator extends _MdCheckboxRequiredValidator {} +export class MatCheckboxRequiredValidator extends _MatCheckboxRequiredValidator {} diff --git a/src/lib/checkbox/checkbox.html b/src/lib/checkbox/checkbox.html index f1185ea34a3f..1361d9362485 100644 --- a/src/lib/checkbox/checkbox.html +++ b/src/lib/checkbox/checkbox.html @@ -15,7 +15,7 @@ [attr.aria-labelledby]="ariaLabelledby" (change)="_onInteractionEvent($event)" (click)="_onInputClick($event)"> -
diff --git a/src/lib/checkbox/checkbox.md b/src/lib/checkbox/checkbox.md index 7fae30d246e5..0ae96cf7939e 100644 --- a/src/lib/checkbox/checkbox.md +++ b/src/lib/checkbox/checkbox.md @@ -1,10 +1,10 @@ -`` provides the same functionality as a native `` +`` provides the same functionality as a native `` enhanced with Material Design styling and animations. ### Checkbox label -The checkbox label is provided as the content to the `` element. The label can be +The checkbox label is provided as the content to the `` element. The label can be positioned before or after the checkbox by setting the `labelPosition` property to `'before'` or `'after'`. @@ -14,23 +14,23 @@ If you don't want the label to appear next to the checkbox, you can use specify an appropriate label. ### Use with `@angular/forms` -`` is compatible with `@angular/forms` and supports both `FormsModule` +`` is compatible with `@angular/forms` and supports both `FormsModule` and `ReactiveFormsModule`. ### Indeterminate state -`` supports an `indeterminate` state, similar to the native ``. +`` supports an `indeterminate` state, similar to the native ``. While the `indeterminate` property of the checkbox is true, it will render as indeterminate regardless of the `checked` value. Any interaction with the checkbox by a user (i.e., clicking) will remove the indeterminate state. ### Theming -The color of a `` can be changed by using the `color` property. By default, checkboxes +The color of a `` can be changed by using the `color` property. By default, checkboxes use the theme's accent color. This can be changed to `'primary'` or `'warn'`. ### Accessibility -The `` uses an internal `` to provide an accessible experience. +The `` uses an internal `` to provide an accessible experience. This internal checkbox receives focus and is automatically labelled by the text content of the -`` element. +`` element. Checkboxes without text or labels should be given a meaningful label via `aria-label` or `aria-labelledby`. diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index d6d829f37c0f..73b6f50177f6 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -11,16 +11,16 @@ import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; import {ViewportRuler} from '@angular/cdk/scrolling'; import {dispatchFakeEvent, FakeViewportRuler} from '@angular/cdk/testing'; -import {MdCheckbox, MdCheckboxChange, MdCheckboxModule} from './index'; +import {MatCheckbox, MatCheckboxChange, MatCheckboxModule} from './index'; import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '@angular/material/core'; -describe('MdCheckbox', () => { +describe('MatCheckbox', () => { let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdCheckboxModule, FormsModule, ReactiveFormsModule], + imports: [MatCheckboxModule, FormsModule, ReactiveFormsModule], declarations: [ SingleCheckbox, CheckboxWithFormDirectives, @@ -45,7 +45,7 @@ describe('MdCheckbox', () => { describe('basic behaviors', () => { let checkboxDebugElement: DebugElement; let checkboxNativeElement: HTMLElement; - let checkboxInstance: MdCheckbox; + let checkboxInstance: MatCheckbox; let testComponent: SingleCheckbox; let inputElement: HTMLInputElement; let labelElement: HTMLLabelElement; @@ -54,7 +54,7 @@ describe('MdCheckbox', () => { fixture = TestBed.createComponent(SingleCheckbox); fixture.detectChanges(); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; checkboxInstance = checkboxDebugElement.componentInstance; testComponent = fixture.debugElement.componentInstance; @@ -273,7 +273,7 @@ describe('MdCheckbox', () => { testComponent.checkboxId = null; fixture.detectChanges(); - expect(checkboxInstance.inputId).toMatch(/md-checkbox-\d+/); + expect(checkboxInstance.inputId).toMatch(/mat-checkbox-\d+/); expect(inputElement.id).toBe(checkboxInstance.inputId); }); @@ -436,7 +436,7 @@ describe('MdCheckbox', () => { expect(checkboxNativeElement.querySelectorAll('.mat-ripple-element').length).toBe(1); }); - it('should remove ripple if mdRippleDisabled input is set', () => { + it('should remove ripple if matRippleDisabled input is set', () => { testComponent.disableRipple = true; fixture.detectChanges(); @@ -531,14 +531,14 @@ describe('MdCheckbox', () => { it('should not apply transition classes when there is no state change', () => { testComponent.isChecked = checkboxInstance.checked; fixture.detectChanges(); - expect(checkboxNativeElement).not.toMatch(/^md\-checkbox\-anim/g); + expect(checkboxNativeElement).not.toMatch(/^mat\-checkbox\-anim/g); testComponent.isIndeterminate = checkboxInstance.indeterminate; - expect(checkboxNativeElement).not.toMatch(/^md\-checkbox\-anim/g); + expect(checkboxNativeElement).not.toMatch(/^mat\-checkbox\-anim/g); }); it('should not initially have any transition classes', () => { - expect(checkboxNativeElement).not.toMatch(/^md\-checkbox\-anim/g); + expect(checkboxNativeElement).not.toMatch(/^mat\-checkbox\-anim/g); }); }); }); @@ -546,7 +546,7 @@ describe('MdCheckbox', () => { describe('with change event and no initial value', () => { let checkboxDebugElement: DebugElement; let checkboxNativeElement: HTMLElement; - let checkboxInstance: MdCheckbox; + let checkboxInstance: MatCheckbox; let testComponent: CheckboxWithChangeEvent; let inputElement: HTMLInputElement; let labelElement: HTMLLabelElement; @@ -555,7 +555,7 @@ describe('MdCheckbox', () => { fixture = TestBed.createComponent(CheckboxWithChangeEvent); fixture.detectChanges(); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; checkboxInstance = checkboxDebugElement.componentInstance; testComponent = fixture.debugElement.componentInstance; @@ -605,7 +605,7 @@ describe('MdCheckbox', () => { it('should use the provided aria-label', () => { fixture = TestBed.createComponent(CheckboxWithAriaLabel); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input'); @@ -621,7 +621,7 @@ describe('MdCheckbox', () => { it('should use the provided aria-labelledby', () => { fixture = TestBed.createComponent(CheckboxWithAriaLabelledby); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input'); @@ -631,7 +631,7 @@ describe('MdCheckbox', () => { it('should not assign aria-labelledby if none is provided', () => { fixture = TestBed.createComponent(SingleCheckbox); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input'); @@ -652,7 +652,7 @@ describe('MdCheckbox', () => { fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; inputElement = checkboxNativeElement.querySelector('input'); labelElement = checkboxNativeElement.querySelector('label'); @@ -685,11 +685,11 @@ describe('MdCheckbox', () => { it('should assign a unique id to each checkbox', () => { let [firstId, secondId] = - fixture.debugElement.queryAll(By.directive(MdCheckbox)) + fixture.debugElement.queryAll(By.directive(MatCheckbox)) .map(debugElement => debugElement.nativeElement.querySelector('input').id); - expect(firstId).toMatch(/md-checkbox-\d+-input/); - expect(secondId).toMatch(/md-checkbox-\d+-input/); + expect(firstId).toMatch(/mat-checkbox-\d+-input/); + expect(secondId).toMatch(/mat-checkbox-\d+-input/); expect(firstId).not.toEqual(secondId); }); }); @@ -697,14 +697,14 @@ describe('MdCheckbox', () => { describe('with ngModel', () => { let checkboxDebugElement: DebugElement; let checkboxNativeElement: HTMLElement; - let checkboxInstance: MdCheckbox; + let checkboxInstance: MatCheckbox; let inputElement: HTMLInputElement; beforeEach(() => { fixture = TestBed.createComponent(CheckboxWithFormDirectives); fixture.detectChanges(); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxNativeElement = checkboxDebugElement.nativeElement; checkboxInstance = checkboxDebugElement.componentInstance; inputElement = checkboxNativeElement.querySelector('input'); @@ -713,7 +713,7 @@ describe('MdCheckbox', () => { it('should be in pristine, untouched, and valid states initially', fakeAsync(() => { flushMicrotasks(); - let checkboxElement = fixture.debugElement.query(By.directive(MdCheckbox)); + let checkboxElement = fixture.debugElement.query(By.directive(MatCheckbox)); let ngModel = checkboxElement.injector.get(NgModel); expect(ngModel.valid).toBe(true); @@ -740,7 +740,7 @@ describe('MdCheckbox', () => { }); describe('with required ngModel', () => { - let checkboxInstance: MdCheckbox; + let checkboxInstance: MatCheckbox; let inputElement: HTMLInputElement; let testComponent: CheckboxWithNgModel; @@ -748,7 +748,7 @@ describe('MdCheckbox', () => { fixture = TestBed.createComponent(CheckboxWithNgModel); fixture.detectChanges(); - let checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + let checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); let checkboxNativeElement = checkboxDebugElement.nativeElement; testComponent = fixture.debugElement.componentInstance; checkboxInstance = checkboxDebugElement.componentInstance; @@ -756,7 +756,7 @@ describe('MdCheckbox', () => { }); it('should validate with RequiredTrue validator', () => { - let checkboxElement = fixture.debugElement.query(By.directive(MdCheckbox)); + let checkboxElement = fixture.debugElement.query(By.directive(MatCheckbox)); let ngModel = checkboxElement.injector.get(NgModel); testComponent.isRequired = true; @@ -781,7 +781,7 @@ describe('MdCheckbox', () => { }); it('should forward name value to input element', () => { - let checkboxElement = fixture.debugElement.query(By.directive(MdCheckbox)); + let checkboxElement = fixture.debugElement.query(By.directive(MatCheckbox)); let inputElement = checkboxElement.nativeElement.querySelector('input'); expect(inputElement.getAttribute('name')).toBe('test-name'); @@ -790,7 +790,7 @@ describe('MdCheckbox', () => { describe('with form control', () => { let checkboxDebugElement: DebugElement; - let checkboxInstance: MdCheckbox; + let checkboxInstance: MatCheckbox; let testComponent: CheckboxWithFormControl; let inputElement: HTMLInputElement; @@ -798,7 +798,7 @@ describe('MdCheckbox', () => { fixture = TestBed.createComponent(CheckboxWithFormControl); fixture.detectChanges(); - checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox)); + checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox)); checkboxInstance = checkboxDebugElement.componentInstance; testComponent = fixture.debugElement.componentInstance; inputElement = checkboxDebugElement.nativeElement.querySelector('input'); @@ -829,7 +829,7 @@ describe('MdCheckbox', () => { beforeEach(() => { fixture = TestBed.createComponent(CheckboxWithoutLabel); - const checkboxDebugEl = fixture.debugElement.query(By.directive(MdCheckbox)); + const checkboxDebugEl = fixture.debugElement.query(By.directive(MatCheckbox)); testComponent = fixture.componentInstance; checkboxElement = checkboxDebugEl.nativeElement; @@ -880,7 +880,7 @@ describe('MdCheckbox', () => { @Component({ template: `
- { (click)="onCheckboxClick($event)" (change)="onCheckboxChange($event)"> Simple checkbox - +
` }) class SingleCheckbox { @@ -910,14 +910,14 @@ class SingleCheckbox { checkboxValue: string = 'single_checkbox'; onCheckboxClick: (event?: Event) => void = () => {}; - onCheckboxChange: (event?: MdCheckboxChange) => void = () => {}; + onCheckboxChange: (event?: MatCheckboxChange) => void = () => {}; } -/** Simple component for testing an MdCheckbox with ngModel in a form. */ +/** Simple component for testing an MatCheckbox with ngModel in a form. */ @Component({ template: `
- Be good + Be good
`, }) @@ -925,9 +925,9 @@ class CheckboxWithFormDirectives { isGood: boolean = false; } -/** Simple component for testing an MdCheckbox with required ngModel. */ +/** Simple component for testing an MatCheckbox with required ngModel. */ @Component({ - template: `Be good`, + template: `Be good`, }) class CheckboxWithNgModel { isGood: boolean = false; @@ -937,8 +937,8 @@ class CheckboxWithNgModel { /** Simple test component with multiple checkboxes. */ @Component(({ template: ` - Option 1 - Option 2 + Option 1 + Option 2 ` })) class MultipleCheckboxes { } @@ -947,10 +947,10 @@ class MultipleCheckboxes { } /** Simple test component with tabIndex */ @Component({ template: ` - - `, +
`, }) class CheckboxWithTabIndex { customTabIndex: number = 7; @@ -959,33 +959,33 @@ class CheckboxWithTabIndex { /** Simple test component with an aria-label set. */ @Component({ - template: `` + template: `` }) class CheckboxWithAriaLabel { } /** Simple test component with an aria-label set. */ @Component({ - template: `` + template: `` }) class CheckboxWithAriaLabelledby {} /** Simple test component with name attribute */ @Component({ - template: `` + template: `` }) class CheckboxWithNameAttribute {} /** Simple test component with change event */ @Component({ - template: `` + template: `` }) class CheckboxWithChangeEvent { - lastEvent: MdCheckboxChange; + lastEvent: MatCheckboxChange; } /** Test component with reactive forms */ @Component({ - template: `` + template: `` }) class CheckboxWithFormControl { formControl = new FormControl(); @@ -993,7 +993,7 @@ class CheckboxWithFormControl { /** Test component without label */ @Component({ - template: `{{ label }}` + template: `{{ label }}` }) class CheckboxWithoutLabel { label: string; diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index 86096cd2861d..97ffec3de20d 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -26,8 +26,8 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import { CanColor, CanDisable, - CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, - MdRipple, + CanDisableRipple, + MatRipple, mixinColor, mixinDisabled, mixinDisableRipple, @@ -40,13 +40,13 @@ import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; let nextUniqueId = 0; /** - * Provider Expression that allows md-checkbox to register as a ControlValueAccessor. + * Provider Expression that allows mat-checkbox to register as a ControlValueAccessor. * This allows it to support [(ngModel)]. * @docs-private */ -export const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR: any = { +export const MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdCheckbox), + useExisting: forwardRef(() => MatCheckbox), multi: true }; @@ -65,26 +65,26 @@ export enum TransitionCheckState { Indeterminate } -/** Change event object emitted by MdCheckbox. */ -export class MdCheckboxChange { - /** The source MdCheckbox of the event. */ - source: MdCheckbox; +/** Change event object emitted by MatCheckbox. */ +export class MatCheckboxChange { + /** The source MatCheckbox of the event. */ + source: MatCheckbox; /** The new `checked` value of the checkbox. */ checked: boolean; } -// Boilerplate for applying mixins to MdCheckbox. +// Boilerplate for applying mixins to MatCheckbox. /** @docs-private */ -export class MdCheckboxBase { +export class MatCheckboxBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdCheckboxMixinBase = - mixinColor(mixinDisableRipple(mixinDisabled(MdCheckboxBase)), 'accent'); +export const _MatCheckboxMixinBase = + mixinColor(mixinDisableRipple(mixinDisabled(MatCheckboxBase)), 'accent'); /** * A material design checkbox component. Supports all of the functionality of an HTML5 checkbox, - * and exposes a similar API. A MdCheckbox can be either checked, unchecked, indeterminate, or + * and exposes a similar API. A MatCheckbox can be either checked, unchecked, indeterminate, or * disabled. Note that all additional accessibility attributes are taken care of by the component, * so there is no need to provide them yourself. However, if you want to omit a label and still * have the checkbox be accessible, you may supply an [aria-label] input. @@ -92,7 +92,7 @@ export const _MdCheckboxMixinBase = */ @Component({ moduleId: module.id, - selector: 'md-checkbox, mat-checkbox', + selector: 'mat-checkbox', templateUrl: 'checkbox.html', styleUrls: ['checkbox.css'], host: { @@ -103,15 +103,14 @@ export const _MdCheckboxMixinBase = '[class.mat-checkbox-disabled]': 'disabled', '[class.mat-checkbox-label-before]': 'labelPosition == "before"', }, - providers: [MD_CHECKBOX_CONTROL_VALUE_ACCESSOR], - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], + providers: [MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR], inputs: ['disabled', 'disableRipple', 'color'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush }) -export class MdCheckbox extends _MdCheckboxMixinBase implements ControlValueAccessor, AfterViewInit, - OnDestroy, CanColor, CanDisable, CanDisableRipple { +export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAccessor, + AfterViewInit, OnDestroy, CanColor, CanDisable, CanDisableRipple { /** * Attached to the aria-label attribute of the host element. In most cases, arial-labelledby will @@ -124,7 +123,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase implements ControlValueAcce */ @Input('aria-labelledby') ariaLabelledby: string | null = null; - private _uniqueId: string = `md-checkbox-${++nextUniqueId}`; + private _uniqueId: string = `mat-checkbox-${++nextUniqueId}`; /** A unique id for the checkbox input. If none is supplied, it will be auto-generated. */ @Input() id: string = this._uniqueId; @@ -164,7 +163,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase implements ControlValueAcce @Input() name: string | null = null; /** Event emitted when the checkbox's `checked` value changes. */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** Event emitted when the checkbox's `indeterminate` value changes. */ @Output() indeterminateChange: EventEmitter = new EventEmitter(); @@ -176,7 +175,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase implements ControlValueAcce @ViewChild('input') _inputElement: ElementRef; /** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */ - @ViewChild(MdRipple) _ripple: MdRipple; + @ViewChild(MatRipple) _ripple: MatRipple; /** * Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. @@ -322,7 +321,7 @@ export class MdCheckbox extends _MdCheckboxMixinBase implements ControlValueAcce } private _emitChangeEvent() { - let event = new MdCheckboxChange(); + let event = new MatCheckboxChange(); event.source = this; event.checked = this.checked; diff --git a/src/lib/checkbox/mat-exports.ts b/src/lib/checkbox/mat-exports.ts deleted file mode 100644 index 6b3089901f56..000000000000 --- a/src/lib/checkbox/mat-exports.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_CHECKBOX_CONTROL_VALUE_ACCESSOR, - MdCheckbox, - MdCheckboxBase, - MdCheckboxChange, -} from './checkbox'; -import {MdCheckboxModule} from './checkbox-module'; -import { - MD_CHECKBOX_REQUIRED_VALIDATOR, - MdCheckboxRequiredValidator, -} from './checkbox-required-validator'; - - -export {MD_CHECKBOX_CONTROL_VALUE_ACCESSOR as MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR}; -export {MD_CHECKBOX_REQUIRED_VALIDATOR as MAT_CHECKBOX_REQUIRED_VALIDATOR}; -export {MdCheckbox as MatCheckbox}; -export {MdCheckboxBase as MatCheckboxBase}; -export {MdCheckboxChange as MatCheckboxChange}; -export {MdCheckboxModule as MatCheckboxModule}; -export {MdCheckboxRequiredValidator as MatCheckboxRequiredValidator}; diff --git a/src/lib/checkbox/public_api.ts b/src/lib/checkbox/public_api.ts index 7a6132ac2ed2..89bc5a134764 100644 --- a/src/lib/checkbox/public_api.ts +++ b/src/lib/checkbox/public_api.ts @@ -9,4 +9,4 @@ export * from './checkbox'; export * from './checkbox-module'; export * from './checkbox-required-validator'; -export * from './mat-exports'; + diff --git a/src/lib/chips/chip-input.spec.ts b/src/lib/chips/chip-input.spec.ts index 62e9fd498a2b..da845439823f 100644 --- a/src/lib/chips/chip-input.spec.ts +++ b/src/lib/chips/chip-input.spec.ts @@ -5,24 +5,24 @@ import {createKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {MdChipInput, MdChipInputEvent} from './chip-input'; -import {MdChipsModule} from './index'; +import {MatChipInput, MatChipInputEvent} from './chip-input'; +import {MatChipsModule} from './index'; const COMMA = 188; -describe('MdChipInput', () => { +describe('MatChipInput', () => { let fixture: ComponentFixture; let testChipInput: TestChipInput; let inputDebugElement: DebugElement; let inputNativeElement: HTMLElement; - let chipInputDirective: MdChipInput; + let chipInputDirective: MatChipInput; let dir = 'ltr'; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdChipsModule, PlatformModule], + imports: [MatChipsModule, PlatformModule], declarations: [TestChipInput], providers: [{ provide: Directionality, useFactory: () => { @@ -39,8 +39,8 @@ describe('MdChipInput', () => { testChipInput = fixture.debugElement.componentInstance; fixture.detectChanges(); - inputDebugElement = fixture.debugElement.query(By.directive(MdChipInput)); - chipInputDirective = inputDebugElement.injector.get(MdChipInput) as MdChipInput; + inputDebugElement = fixture.debugElement.query(By.directive(MatChipInput)); + chipInputDirective = inputDebugElement.injector.get(MatChipInput) as MatChipInput; inputNativeElement = inputDebugElement.nativeElement; })); @@ -104,18 +104,18 @@ describe('MdChipInput', () => { @Component({ template: ` - - - + + + ` }) class TestChipInput { addOnBlur: boolean = false; separatorKeys: number[] = [ENTER]; - add(_: MdChipInputEvent) { + add(_: MatChipInputEvent) { } } diff --git a/src/lib/chips/chip-input.ts b/src/lib/chips/chip-input.ts index c4c61ae2856f..b014dd52b756 100644 --- a/src/lib/chips/chip-input.ts +++ b/src/lib/chips/chip-input.ts @@ -9,20 +9,20 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {ENTER} from '@angular/cdk/keycodes'; import {Directive, ElementRef, EventEmitter, Input, Output} from '@angular/core'; -import {MdChipList} from './chip-list'; +import {MatChipList} from './chip-list'; -export interface MdChipInputEvent { +export interface MatChipInputEvent { input: HTMLInputElement; value: string; } /** - * Directive that adds chip-specific behaviors to an input element inside . - * May be placed inside or outside of an . + * Directive that adds chip-specific behaviors to an input element inside . + * May be placed inside or outside of an . */ @Directive({ - selector: 'input[mdChipInputFor], input[matChipInputFor]', + selector: 'input[matChipInputFor]', host: { 'class': 'mat-chip-input mat-input-element', '(keydown)': '_keydown($event)', @@ -30,13 +30,13 @@ export interface MdChipInputEvent { '(focus)': '_focus()', } }) -export class MdChipInput { +export class MatChipInput { focused: boolean = false; - _chipList: MdChipList; + _chipList: MatChipList; /** Register input for chip list */ - @Input('mdChipInputFor') - set chipList(value: MdChipList) { + @Input('matChipInputFor') + set chipList(value: MatChipList) { if (value) { this._chipList = value; this._chipList.registerInput(this); @@ -46,7 +46,7 @@ export class MdChipInput { /** * Whether or not the chipEnd event will be emitted when the input is blurred. */ - @Input('mdChipInputAddOnBlur') + @Input('matChipInputAddOnBlur') get addOnBlur() { return this._addOnBlur; } set addOnBlur(value) { this._addOnBlur = coerceBooleanProperty(value); } _addOnBlur: boolean = false; @@ -57,16 +57,14 @@ export class MdChipInput { * Defaults to `[ENTER]`. */ // TODO(tinayuangao): Support Set here - @Input('mdChipInputSeparatorKeyCodes') separatorKeyCodes: number[] = [ENTER]; + @Input('matChipInputSeparatorKeyCodes') separatorKeyCodes: number[] = [ENTER]; /** Emitted when a chip is to be added. */ - @Output('mdChipInputTokenEnd') - chipEnd = new EventEmitter(); - - @Output('matChipInputTokenEnd') _matChipInputTokenEnd = this.chipEnd; + @Output('matChipInputTokenEnd') + chipEnd = new EventEmitter(); @Input('matChipInputFor') - set matChipList(value: MdChipList) { this.chipList = value; } + set matChipList(value: MatChipList) { this.chipList = value; } @Input('matChipInputAddOnBlur') get matAddOnBlur() { return this._addOnBlur; } diff --git a/src/lib/chips/chip-list.spec.ts b/src/lib/chips/chip-list.spec.ts index e4ef2f7d2de0..bb9a5b33eb71 100644 --- a/src/lib/chips/chip-list.spec.ts +++ b/src/lib/chips/chip-list.spec.ts @@ -5,23 +5,23 @@ import {createKeyboardEvent, dispatchFakeEvent, dispatchKeyboardEvent} from '@an import {Component, DebugElement, QueryList, ViewChild, ViewChildren} from '@angular/core'; import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {MdFormFieldModule} from '@angular/material/form-field'; +import {MatFormFieldModule} from '@angular/material/form-field'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdInputModule} from '../input/index'; -import {MdChip} from './chip'; -import {MdChipInputEvent} from './chip-input'; -import {MdChipList, MdChipsModule} from './index'; +import {MatInputModule} from '../input/index'; +import {MatChip} from './chip'; +import {MatChipInputEvent} from './chip-input'; +import {MatChipList, MatChipsModule} from './index'; -describe('MdChipList', () => { +describe('MatChipList', () => { let fixture: ComponentFixture; let chipListDebugElement: DebugElement; let chipListNativeElement: HTMLElement; - let chipListInstance: MdChipList; + let chipListInstance: MatChipList; let testComponent: StandardChipList; let chips: QueryList; - let manager: FocusKeyManager; + let manager: FocusKeyManager; let dir = 'ltr'; beforeEach(async(() => { @@ -29,9 +29,9 @@ describe('MdChipList', () => { imports: [ FormsModule, ReactiveFormsModule, - MdChipsModule, - MdFormFieldModule, - MdInputModule, + MatChipsModule, + MatFormFieldModule, + MatInputModule, NoopAnimationsModule ], declarations: [ @@ -141,7 +141,7 @@ describe('MdChipList', () => { })); it('should focus previous item when press LEFT ARROW', () => { - let nativeChips = chipListNativeElement.querySelectorAll('md-chip'); + let nativeChips = chipListNativeElement.querySelectorAll('mat-chip'); let lastNativeChip = nativeChips[nativeChips.length - 1] as HTMLElement; let LEFT_EVENT = createKeyboardEvent('keydown', LEFT_ARROW, lastNativeChip); @@ -162,7 +162,7 @@ describe('MdChipList', () => { }); it('should focus next item when press RIGHT ARROW', () => { - let nativeChips = chipListNativeElement.querySelectorAll('md-chip'); + let nativeChips = chipListNativeElement.querySelectorAll('mat-chip'); let firstNativeChip = nativeChips[0] as HTMLElement; let RIGHT_EVENT: KeyboardEvent = @@ -192,7 +192,7 @@ describe('MdChipList', () => { })); it('should focus previous item when press RIGHT ARROW', () => { - let nativeChips = chipListNativeElement.querySelectorAll('md-chip'); + let nativeChips = chipListNativeElement.querySelectorAll('mat-chip'); let lastNativeChip = nativeChips[nativeChips.length - 1] as HTMLElement; let RIGHT_EVENT: KeyboardEvent = @@ -214,7 +214,7 @@ describe('MdChipList', () => { }); it('should focus next item when press LEFT ARROW', () => { - let nativeChips = chipListNativeElement.querySelectorAll('md-chip'); + let nativeChips = chipListNativeElement.querySelectorAll('mat-chip'); let firstNativeChip = nativeChips[0] as HTMLElement; let LEFT_EVENT: KeyboardEvent = @@ -327,11 +327,11 @@ describe('MdChipList', () => { fixture.detectChanges(); formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement; - nativeChips = fixture.debugElement.queryAll(By.css('md-chip')) + nativeChips = fixture.debugElement.queryAll(By.css('mat-chip')) .map((chip) => chip.nativeElement); - chipListDebugElement = fixture.debugElement.query(By.directive(MdChipList)); + chipListDebugElement = fixture.debugElement.query(By.directive(MatChipList)); chipListInstance = chipListDebugElement.componentInstance; chips = chipListInstance.chips; @@ -366,7 +366,7 @@ describe('MdChipList', () => { fixture.componentInstance.foods.push({viewValue: 'Potatoes', value: 'potatoes-8'}); fixture.detectChanges(); - nativeChips = fixture.debugElement.queryAll(By.css('md-chip')) + nativeChips = fixture.debugElement.queryAll(By.css('mat-chip')) .map((chip) => chip.nativeElement); const lastChip = nativeChips[8]; dispatchKeyboardEvent(lastChip, 'keydown', SPACE); @@ -403,7 +403,7 @@ describe('MdChipList', () => { fixture.detectChanges(); formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement; - nativeChips = fixture.debugElement.queryAll(By.css('md-chip')) + nativeChips = fixture.debugElement.queryAll(By.css('mat-chip')) .map((chip) => chip.nativeElement); chips = fixture.componentInstance.chips; }); @@ -556,7 +556,7 @@ describe('MdChipList', () => { fixture.detectChanges(); formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement; - nativeChips = fixture.debugElement.queryAll(By.css('md-chip')) + nativeChips = fixture.debugElement.queryAll(By.css('mat-chip')) .map((chip) => chip.nativeElement); chips = fixture.componentInstance.chips; }); @@ -641,7 +641,7 @@ describe('MdChipList', () => { fixture.detectChanges(); formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement; - nativeChips = fixture.debugElement.queryAll(By.css('md-chip')) + nativeChips = fixture.debugElement.queryAll(By.css('mat-chip')) .map((chip) => chip.nativeElement); }); @@ -778,7 +778,7 @@ describe('MdChipList', () => { beforeEach(() => { fixture = TestBed.createComponent(InputChipList); fixture.detectChanges(); - chipListDebugElement = fixture.debugElement.query(By.directive(MdChipList)); + chipListDebugElement = fixture.debugElement.query(By.directive(MatChipList)); chipListInstance = chipListDebugElement.componentInstance; chips = chipListInstance.chips; manager = fixture.componentInstance.chipList._keyManager; @@ -828,7 +828,7 @@ describe('MdChipList', () => { fixture = TestBed.createComponent(StandardChipList); fixture.detectChanges(); - chipListDebugElement = fixture.debugElement.query(By.directive(MdChipList)); + chipListDebugElement = fixture.debugElement.query(By.directive(MatChipList)); chipListNativeElement = chipListDebugElement.nativeElement; chipListInstance = chipListDebugElement.componentInstance; testComponent = fixture.debugElement.componentInstance; @@ -839,7 +839,7 @@ describe('MdChipList', () => { fixture = TestBed.createComponent(FormFieldChipList); fixture.detectChanges(); - chipListDebugElement = fixture.debugElement.query(By.directive(MdChipList)); + chipListDebugElement = fixture.debugElement.query(By.directive(MatChipList)); chipListNativeElement = chipListDebugElement.nativeElement; chipListInstance = chipListDebugElement.componentInstance; testComponent = fixture.debugElement.componentInstance; @@ -850,15 +850,15 @@ describe('MdChipList', () => { @Component({ template: ` - +
- + {{name}} {{i + 1}} - +
-
` +
` }) class StandardChipList { name: string = 'Test'; @@ -871,14 +871,14 @@ class StandardChipList { @Component({ template: ` - - - Chip 1 - Chip 1 - Chip 1 - - - + + + Chip 1 + Chip 1 + Chip 1 + + + ` }) class FormFieldChipList { @@ -888,14 +888,14 @@ class FormFieldChipList { @Component({ selector: 'basic-chip-list', template: ` - - + - + {{ food.viewValue }} - - - + + +
` }) class BasicChipList { @@ -914,23 +914,23 @@ class BasicChipList { tabIndexOverride: number; selectable: boolean; - @ViewChild(MdChipList) chipList: MdChipList; - @ViewChildren(MdChip) chips: QueryList; + @ViewChild(MatChipList) chipList: MatChipList; + @ViewChildren(MatChip) chips: QueryList; } @Component({ selector: 'multi-selection-chip-list', template: ` - - + - + {{ food.viewValue }} - - - + + + ` }) class MultiSelectionChipList { @@ -949,26 +949,26 @@ class MultiSelectionChipList { tabIndexOverride: number; selectable: boolean; - @ViewChild(MdChipList) chipList: MdChipList; - @ViewChildren(MdChip) chips: QueryList; + @ViewChild(MatChipList) chipList: MatChipList; + @ViewChildren(MatChip) chips: QueryList; } @Component({ selector: 'input-chip-list', template: ` - - + - + {{ food.viewValue }} - - + + /> - + [matChipInputFor]="chipList1" + [matChipInputSeparatorKeyCodes]="separatorKeyCodes" + [matChipInputAddOnBlur]="addOnBlur" + (matChipInputTokenEnd)="add($event)" />/> + ` }) class InputChipList { @@ -988,7 +988,7 @@ class InputChipList { addOnBlur: boolean = true; isRequired: boolean; - add(event: MdChipInputEvent): void { + add(event: MatChipInputEvent): void { let input = event.input; let value = event.value; @@ -1006,17 +1006,17 @@ class InputChipList { } } - @ViewChild(MdChipList) chipList: MdChipList; - @ViewChildren(MdChip) chips: QueryList; + @ViewChild(MatChipList) chipList: MatChipList; + @ViewChildren(MatChip) chips: QueryList; } @Component({ template: ` - - - {{ food.viewValue }} - - + + + {{ food.viewValue }} + + ` }) class FalsyValueChipList { @@ -1025,5 +1025,5 @@ class FalsyValueChipList { { value: 1, viewValue: 'Pizza' }, ]; control = new FormControl(); - @ViewChildren(MdChip) chips: QueryList; + @ViewChildren(MatChip) chips: QueryList; } diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index 5555824873d6..ae7bdfe0b177 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -31,20 +31,20 @@ import { ViewEncapsulation, } from '@angular/core'; import {ControlValueAccessor, FormGroupDirective, NgControl, NgForm} from '@angular/forms'; -import {MdFormFieldControl} from '@angular/material/form-field'; +import {MatFormFieldControl} from '@angular/material/form-field'; import {Observable} from 'rxjs/Observable'; import {merge} from 'rxjs/observable/merge'; import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; -import {MdChip, MdChipEvent, MdChipSelectionChange} from './chip'; -import {MdChipInput} from './chip-input'; +import {MatChip, MatChipEvent, MatChipSelectionChange} from './chip'; +import {MatChipInput} from './chip-input'; // Increasing integer for generating unique ids for chip-list components. let nextUniqueId = 0; /** Change event object that is emitted when the chip list value has changed. */ -export class MdChipListChange { - constructor(public source: MdChipList, public value: any) { } +export class MatChipListChange { + constructor(public source: MatChipList, public value: any) { } } @@ -53,9 +53,9 @@ export class MdChipListChange { */ @Component({ moduleId: module.id, - selector: 'md-chip-list, mat-chip-list', + selector: 'mat-chip-list', template: `
`, - exportAs: 'mdChipList, matChipList', + exportAs: 'matChipList', host: { '[attr.tabindex]': '_tabIndex', '[attr.aria-describedby]': '_ariaDescribedby || null', @@ -73,18 +73,18 @@ export class MdChipListChange { '(blur)': '_blur()', '(keydown)': '_keydown($event)' }, - providers: [{provide: MdFormFieldControl, useExisting: MdChipList}], + providers: [{provide: MatFormFieldControl, useExisting: MatChipList}], styleUrls: ['chips.css'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush }) -export class MdChipList implements MdFormFieldControl, ControlValueAccessor, +export class MatChipList implements MatFormFieldControl, ControlValueAccessor, AfterContentInit, OnInit, OnDestroy { readonly controlType = 'mat-chip-list'; /** - * Stream that emits whenever the state of the input changes such that the wrapping `MdFormField` + * Stream that emits whenever the state of the input changes such that the wrapping `MatFormField` * needs to run change detection. */ stateChanges = new Subject(); @@ -93,7 +93,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor protected _lastDestroyedIndex: number|null = null; /** Track which chips we're listening to for focus/destruction. */ - protected _chipSet: WeakMap = new WeakMap(); + protected _chipSet: WeakMap = new WeakMap(); /** Subscription to tabbing out from the chip list. */ private _tabOutSubscription = Subscription.EMPTY; @@ -120,7 +120,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor private _multiple: boolean = false; /** The chip input to add more chips */ - protected _chipInput: MdChipInput; + protected _chipInput: MatChipInput; /** The aria-describedby attribute on the chip list for improved a11y. */ protected _ariaDescribedby: string; @@ -129,7 +129,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor protected _id: string; /** Uid of the chip list */ - protected _uid: string = `md-chip-list-${nextUniqueId++}`; + protected _uid: string = `mat-chip-list-${nextUniqueId++}`; /** Whether this is required */ protected _required: boolean = false; @@ -139,7 +139,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor protected _value: any; - /** Placeholder for the chip list. Alternatively, placeholder can be set on MdChipInput */ + /** Placeholder for the chip list. Alternatively, placeholder can be set on MatChipInput */ protected _placeholder: string; /** Tab index for the chip list. */ @@ -152,7 +152,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor _userTabIndex: number | null = null; /** The FocusKeyManager which handles focus. */ - _keyManager: FocusKeyManager; + _keyManager: FocusKeyManager; /** Function when touched */ _onTouched = () => {}; @@ -160,13 +160,13 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor /** Function when changed */ _onChange: (value: any) => void = () => {}; - _selectionModel: SelectionModel; + _selectionModel: SelectionModel; /** Comparison function to specify which option is displayed. Defaults to object equality. */ private _compareWith = (o1: any, o2: any) => o1 === o2; /** The array of selected chips inside chip list. */ - get selected(): MdChip[] | MdChip { + get selected(): MatChip[] | MatChip { return this.multiple ? this._selectionModel.selected : this._selectionModel.selected[0]; } @@ -228,13 +228,13 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor return this._chipInput ? this._chipInput.placeholder : this._placeholder; } - /** Whether any chips or the mdChipInput inside of this chip-list has focus. */ + /** Whether any chips or the matChipInput inside of this chip-list has focus. */ get focused() { return this.chips.some(chip => chip._hasFocus) || (this._chipInput && this._chipInput.focused); } - /** Whether this chip-list contains no chips and no mdChipInput. */ + /** Whether this chip-list contains no chips and no matChipInput. */ get empty(): boolean { return (!this._chipInput || this._chipInput.empty) && this.chips.length === 0; } @@ -275,27 +275,27 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor } /** Combined stream of all of the child chips' selection change events. */ - get chipSelectionChanges(): Observable { + get chipSelectionChanges(): Observable { return merge(...this.chips.map(chip => chip.selectionChange)); } /** Combined stream of all of the child chips' focus change events. */ - get chipFocusChanges(): Observable { + get chipFocusChanges(): Observable { return merge(...this.chips.map(chip => chip._onFocus)); } /** Combined stream of all of the child chips' blur change events. */ - get chipBlurChanges(): Observable { + get chipBlurChanges(): Observable { return merge(...this.chips.map(chip => chip._onBlur)); } /** Combined stream of all of the child chips' remove change events. */ - get chipRemoveChanges(): Observable { + get chipRemoveChanges(): Observable { return merge(...this.chips.map(chip => chip.destroy)); } /** Event emitted when the selected chip list value has been changed by the user. */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** * Event that emits whenever the raw value of the chip-list changes. This is here primarily @@ -305,7 +305,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor @Output() valueChange = new EventEmitter(); /** The chip components contained within this chip list. */ - @ContentChildren(MdChip) chips: QueryList; + @ContentChildren(MatChip) chips: QueryList; constructor(protected _renderer: Renderer2, protected _elementRef: ElementRef, @@ -321,7 +321,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor ngAfterContentInit(): void { - this._keyManager = new FocusKeyManager(this.chips).withWrap(); + this._keyManager = new FocusKeyManager(this.chips).withWrap(); // Prevents the chip list from capturing focus and redirecting // it back to the first chip when the user tabs out. @@ -346,7 +346,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor } ngOnInit() { - this._selectionModel = new SelectionModel(this.multiple, undefined, false); + this._selectionModel = new SelectionModel(this.multiple, undefined, false); this.stateChanges.next(); } @@ -361,11 +361,11 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor /** Associates an HTML input element with this chip list. */ - registerInput(inputElement: MdChipInput) { + registerInput(inputElement: MatChipInput) { this._chipInput = inputElement; } - // Implemented as part of MdFormFieldControl. + // Implemented as part of MatFormFieldControl. setDescribedByIds(ids: string[]) { this._ariaDescribedby = ids.join(' '); } // Implemented as part of ControlValueAccessor @@ -471,7 +471,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor * Otherwise focus the next chip in the list. * Save `_lastDestroyedIndex` so we can set the correct focus. */ - protected _updateKeyManager(chip: MdChip) { + protected _updateKeyManager(chip: MatChip) { let chipIndex: number = this.chips.toArray().indexOf(chip); if (this._isValidIndex(chipIndex)) { if (chip._hasFocus) { @@ -554,7 +554,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor * Finds and selects the chip based on its value. * @returns Chip that has the corresponding value. */ - private _selectValue(value: any, isUserInput: boolean = true): MdChip | undefined { + private _selectValue(value: any, isUserInput: boolean = true): MatChip | undefined { const correspondingChip = this.chips.find(chip => { return chip.value != null && this._compareWith(chip.value, value); @@ -581,7 +581,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor * Deselects every chip in the list. * @param skip Chip that should not be deselected. */ - private _clearSelection(skip?: MdChip): void { + private _clearSelection(skip?: MatChip): void { this._selectionModel.clear(); this.chips.forEach(chip => { if (chip !== skip) { @@ -618,7 +618,7 @@ export class MdChipList implements MdFormFieldControl, ControlValueAccessor valueToEmit = this.selected ? this.selected.value : fallbackValue; } this._value = valueToEmit; - this.change.emit(new MdChipListChange(this, valueToEmit)); + this.change.emit(new MatChipListChange(this, valueToEmit)); this.valueChange.emit(valueToEmit); this._onChange(valueToEmit); this._changeDetectorRef.markForCheck(); diff --git a/src/lib/chips/chip-remove.spec.ts b/src/lib/chips/chip-remove.spec.ts index 39450a639438..b8fabef214dc 100644 --- a/src/lib/chips/chip-remove.spec.ts +++ b/src/lib/chips/chip-remove.spec.ts @@ -1,7 +1,7 @@ import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import {MdChip, MdChipsModule} from './index'; +import {MatChip, MatChipsModule} from './index'; describe('Chip Remove', () => { let fixture: ComponentFixture; @@ -11,7 +11,7 @@ describe('Chip Remove', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdChipsModule], + imports: [MatChipsModule], declarations: [ TestChip ] @@ -25,7 +25,7 @@ describe('Chip Remove', () => { testChip = fixture.debugElement.componentInstance; fixture.detectChanges(); - chipDebugElement = fixture.debugElement.query(By.directive(MdChip)); + chipDebugElement = fixture.debugElement.query(By.directive(MatChip)); chipNativeElement = chipDebugElement.nativeElement; })); @@ -53,7 +53,7 @@ describe('Chip Remove', () => { @Component({ template: ` - + ` }) class TestChip { diff --git a/src/lib/chips/chip.spec.ts b/src/lib/chips/chip.spec.ts index 51ade187196a..e5bdd5023bab 100644 --- a/src/lib/chips/chip.spec.ts +++ b/src/lib/chips/chip.spec.ts @@ -4,7 +4,7 @@ import {createKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {MdChip, MdChipEvent, MdChipList, MdChipSelectionChange, MdChipsModule} from './index'; +import {MatChip, MatChipEvent, MatChipList, MatChipSelectionChange, MatChipsModule} from './index'; describe('Chips', () => { @@ -12,13 +12,13 @@ describe('Chips', () => { let chipDebugElement: DebugElement; let chipListNativeElement: HTMLElement; let chipNativeElement: HTMLElement; - let chipInstance: MdChip; + let chipInstance: MatChip; let dir = 'ltr'; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdChipsModule], + imports: [MatChipsModule], declarations: [ BasicChip, SingleChip ], @@ -32,15 +32,15 @@ describe('Chips', () => { TestBed.compileComponents(); })); - describe('MdBasicChip', () => { + describe('MatBasicChip', () => { beforeEach(() => { fixture = TestBed.createComponent(BasicChip); fixture.detectChanges(); - chipDebugElement = fixture.debugElement.query(By.directive(MdChip)); + chipDebugElement = fixture.debugElement.query(By.directive(MatChip)); chipNativeElement = chipDebugElement.nativeElement; - chipInstance = chipDebugElement.injector.get(MdChip); + chipInstance = chipDebugElement.injector.get(MatChip); document.body.appendChild(chipNativeElement); }); @@ -55,17 +55,17 @@ describe('Chips', () => { }); }); - describe('MdChip', () => { + describe('MatChip', () => { let testComponent: SingleChip; beforeEach(() => { fixture = TestBed.createComponent(SingleChip); fixture.detectChanges(); - chipDebugElement = fixture.debugElement.query(By.directive(MdChip)); - chipListNativeElement = fixture.debugElement.query(By.directive(MdChipList)).nativeElement; + chipDebugElement = fixture.debugElement.query(By.directive(MatChip)); + chipListNativeElement = fixture.debugElement.query(By.directive(MatChipList)).nativeElement; chipNativeElement = chipDebugElement.nativeElement; - chipInstance = chipDebugElement.injector.get(MdChip); + chipInstance = chipDebugElement.injector.get(MatChip); testComponent = fixture.debugElement.componentInstance; document.body.appendChild(chipNativeElement); @@ -77,7 +77,7 @@ describe('Chips', () => { describe('basic behaviors', () => { - it('adds the `md-chip` class', () => { + it('adds the `mat-chip` class', () => { expect(chipNativeElement.classList).toContain('mat-chip'); }); @@ -122,7 +122,7 @@ describe('Chips', () => { expect(chipNativeElement.classList).toContain('mat-chip-selected'); expect(testComponent.chipSelectionChange) - .toHaveBeenCalledWith({source: chipInstance, isUserInput: false, selected: true}); + .toHaveBeenCalledWith({source: chipInstance, isUserInput: false, selected: true}); }); it('allows removal', () => { @@ -145,13 +145,13 @@ describe('Chips', () => { it('should selects/deselects the currently focused chip on SPACE', () => { const SPACE_EVENT: KeyboardEvent = createKeyboardEvent('keydown', SPACE) as KeyboardEvent; - const CHIP_SELECTED_EVENT: MdChipSelectionChange = { + const CHIP_SELECTED_EVENT: MatChipSelectionChange = { source: chipInstance, isUserInput: true, selected: true }; - const CHIP_DESELECTED_EVENT: MdChipSelectionChange = { + const CHIP_DESELECTED_EVENT: MatChipSelectionChange = { source: chipInstance, isUserInput: true, selected: false @@ -287,17 +287,17 @@ describe('Chips', () => { @Component({ template: ` - +
- {{name}} - +
-
` + ` }) class SingleChip { disabled: boolean = false; @@ -308,14 +308,14 @@ class SingleChip { removable: boolean = true; shouldShow: boolean = true; - chipFocus: (event?: MdChipEvent) => void = () => {}; - chipDestroy: (event?: MdChipEvent) => void = () => {}; - chipSelectionChange: (event?: MdChipSelectionChange) => void = () => {}; - chipRemove: (event?: MdChipEvent) => void = () => {}; + chipFocus: (event?: MatChipEvent) => void = () => {}; + chipDestroy: (event?: MatChipEvent) => void = () => {}; + chipSelectionChange: (event?: MatChipSelectionChange) => void = () => {}; + chipRemove: (event?: MatChipEvent) => void = () => {}; } @Component({ - template: `{{name}}` + template: `{{name}}` }) class BasicChip { } diff --git a/src/lib/chips/chip.ts b/src/lib/chips/chip.ts index 5b2690816e30..8d8c3c6c7ace 100644 --- a/src/lib/chips/chip.ts +++ b/src/lib/chips/chip.ts @@ -22,24 +22,24 @@ import {CanColor, CanDisable, mixinColor, mixinDisabled} from '@angular/material import {Subject} from 'rxjs/Subject'; -export interface MdChipEvent { - chip: MdChip; +export interface MatChipEvent { + chip: MatChip; } -/** Event object emitted by MdChip when selected or deselected. */ -export class MdChipSelectionChange { - constructor(public source: MdChip, public selected: boolean, public isUserInput = false) { } +/** Event object emitted by MatChip when selected or deselected. */ +export class MatChipSelectionChange { + constructor(public source: MatChip, public selected: boolean, public isUserInput = false) { } } -// Boilerplate for applying mixins to MdChip. +// Boilerplate for applying mixins to MatChip. /** @docs-private */ -export class MdChipBase { +export class MatChipBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) { } } -export const _MdChipMixinBase = mixinColor(mixinDisabled(MdChipBase), 'primary'); +export const _MatChipMixinBase = mixinColor(mixinDisabled(MatChipBase), 'primary'); /** @@ -47,20 +47,19 @@ export const _MdChipMixinBase = mixinColor(mixinDisabled(MdChipBase), 'primary') * @docs-private */ @Directive({ - selector: `md-basic-chip, [md-basic-chip], mat-basic-chip, [mat-basic-chip]`, + selector: `mat-basic-chip, [mat-basic-chip]`, host: {'class': 'mat-basic-chip'}, }) -export class MdBasicChip { +export class MatBasicChip { } /** - * Material design styled Chip component. Used inside the MdChipList component. + * Material design styled Chip component. Used inside the MatChipList component. */ @Directive({ - selector: `md-basic-chip, [md-basic-chip], md-chip, [md-chip], - mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]`, + selector: `mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]`, inputs: ['color', 'disabled'], - exportAs: 'mdChip, matChip', + exportAs: 'matChip', host: { 'class': 'mat-chip', 'tabindex': '-1', @@ -76,7 +75,7 @@ export class MdBasicChip { }, }) -export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestroy, CanColor, +export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDestroy, CanColor, CanDisable { protected _value: any; @@ -103,7 +102,7 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr selected: value }); } - /** The value of the chip. Defaults to the content inside tags. */ + /** The value of the chip. Defaults to the content inside tags. */ @Input() get value(): any { return this._value != undefined @@ -140,16 +139,16 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr } /** Emits when the chip is focused. */ - _onFocus = new Subject(); + _onFocus = new Subject(); /** Emits when the chip is blured. */ - _onBlur = new Subject(); + _onBlur = new Subject(); /** Emitted when the chip is selected or deselected. */ - @Output() selectionChange = new EventEmitter(); + @Output() selectionChange = new EventEmitter(); /** Emitted when the chip is destroyed. */ - @Output() destroyed = new EventEmitter(); + @Output() destroyed = new EventEmitter(); /** * Emitted when the chip is destroyed. @@ -158,7 +157,7 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr @Output() destroy = this.destroyed; /** Emitted when a chip is to be removed. */ - @Output() removed = new EventEmitter(); + @Output() removed = new EventEmitter(); /** * Emitted when a chip is to be removed. @@ -229,7 +228,7 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr } /** - * Allows for programmatic removal of the chip. Called by the MdChipList when the DELETE or + * Allows for programmatic removal of the chip. Called by the MatChipList when the DELETE or * BACKSPACE keys are pressed. * * Informs any listeners of the removal request. Does not remove the chip from the DOM. @@ -292,22 +291,22 @@ export class MdChip extends _MdChipMixinBase implements FocusableOption, OnDestr * * Example: * - * - * cancel - * + * + * cancel + * * - * You *may* use a custom icon, but you may need to override the `md-chip-remove` positioning styles - * to properly center the icon within the chip. + * You *may* use a custom icon, but you may need to override the `mat-chip-remove` positioning + * styles to properly center the icon within the chip. */ @Directive({ - selector: '[mdChipRemove], [matChipRemove]', + selector: '[matChipRemove]', host: { 'class': 'mat-chip-remove', '(click)': '_handleClick($event)', }, }) -export class MdChipRemove { - constructor(protected _parentChip: MdChip) { +export class MatChipRemove { + constructor(protected _parentChip: MatChip) { } /** Calls the parent chip's public `remove()` method if applicable. */ diff --git a/src/lib/chips/chips-module.ts b/src/lib/chips/chips-module.ts index b87aac229dc8..e74b17793131 100644 --- a/src/lib/chips/chips-module.ts +++ b/src/lib/chips/chips-module.ts @@ -7,14 +7,14 @@ */ import {NgModule} from '@angular/core'; -import {MdChipList} from './chip-list'; -import {MdBasicChip, MdChip, MdChipRemove} from './chip'; -import {MdChipInput} from './chip-input'; +import {MatChipList} from './chip-list'; +import {MatBasicChip, MatChip, MatChipRemove} from './chip'; +import {MatChipInput} from './chip-input'; @NgModule({ imports: [], - exports: [MdChipList, MdChip, MdChipInput, MdChipRemove, MdChipRemove, MdBasicChip], - declarations: [MdChipList, MdChip, MdChipInput, MdChipRemove, MdChipRemove, MdBasicChip] + exports: [MatChipList, MatChip, MatChipInput, MatChipRemove, MatChipRemove, MatBasicChip], + declarations: [MatChipList, MatChip, MatChipInput, MatChipRemove, MatChipRemove, MatBasicChip] }) -export class MdChipsModule {} +export class MatChipsModule {} diff --git a/src/lib/chips/chips.md b/src/lib/chips/chips.md index db4dfdeef6be..180e4a326bcd 100644 --- a/src/lib/chips/chips.md +++ b/src/lib/chips/chips.md @@ -1,26 +1,26 @@ -`` displays a list of values as individual, keyboard accessible, chips. +`` displays a list of values as individual, keyboard accessible, chips. _Note: chips are still early in their development and more features are being actively worked on._ ```html - - Papadum - Naan - Dal - + + Papadum + Naan + Dal + ``` ### Unstyled chips -By default, `` has Material Design styles applied. For a chip with no styles applied, -use ``. You can then customize the chip appearance by adding your own CSS. +By default, `` has Material Design styles applied. For a chip with no styles applied, +use ``. You can then customize the chip appearance by adding your own CSS. -_Hint: `` receives the `mat-basic-chip` CSS class in addition to the `mat-chip` class._ +_Hint: `` receives the `mat-basic-chip` CSS class in addition to the `mat-chip` class._ ### Selection Chips can be selected via the `selected` property. Selection can be disabled by setting -`selectable` to `false` on the ``. +`selectable` to `false` on the ``. Whenever the selection state changes, a `ChipSelectionChange` event will be emitted via `(selectionChange)`. @@ -30,9 +30,9 @@ Individual chips may be disabled by applying the `disabled` attribute to the chi chips are neither selectable nor focusable. Currently, disabled chips receive no special styling. ### Chip input -The `MdChipInput` directive can be used together with a chip-list to streamline the interaction +The `MatChipInput` directive can be used together with a chip-list to streamline the interaction between the two components. This directive adds chip-specific behaviors to the input element -within `` for adding and removing chips. The `` with `MdChipInput` can +within `` for adding and removing chips. The `` with `MatChipInput` can be placed inside or outside the chip-list element. An exmaple of chip input placed inside the chip-list element. @@ -41,13 +41,13 @@ An exmaple of chip input placed inside the chip-list element. An example of chip input placed outside the chip-list element. ```html - - - Chip 1 - Chip 2 - - - + + + Chip 1 + Chip 2 + + + ``` ### Keyboard interaction @@ -59,15 +59,15 @@ If you want the chips in the list to be stacked vertically, instead of horizonta the `mat-chip-list-stacked` class, as well as the `aria-orientation="vertical"` attribute: ```html - - Papadum - Naan - Dal - + + Papadum + Naan + Dal + ``` ### Theming -The selected color of an `` can be changed by using the `color` property. By default, chips +The selected color of an `` can be changed by using the `color` property. By default, chips use a neutral background color based on the current theme (light or dark). This can be changed to `'primary'`, `'accent'`, or `'warn'`. diff --git a/src/lib/chips/mat-exports.ts b/src/lib/chips/mat-exports.ts deleted file mode 100644 index 73ccd86cd58f..000000000000 --- a/src/lib/chips/mat-exports.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdBasicChip, MdChip, MdChipBase, MdChipEvent, MdChipRemove} from './chip'; -import {MdChipInput, MdChipInputEvent} from './chip-input'; -import {MdChipList, MdChipListChange} from './chip-list'; -import {MdChipsModule} from './chips-module'; - - -export {MdBasicChip as MatBasicChip}; -export {MdChip as MatChip}; -export {MdChipBase as MatChipBase}; -export {MdChipEvent as MatChipEvent}; -export {MdChipInput as MatChipInput}; -export {MdChipInputEvent as MatChipInputEvent}; -export {MdChipListChange as MatChipListChange}; -export {MdChipList as MatChipList}; -export {MdChipRemove as MatChipRemove}; -export {MdChipsModule as MatChipsModule}; diff --git a/src/lib/chips/public_api.ts b/src/lib/chips/public_api.ts index d7a19a1e5240..dfff919ca34f 100644 --- a/src/lib/chips/public_api.ts +++ b/src/lib/chips/public_api.ts @@ -10,4 +10,4 @@ export * from './chips-module'; export * from './chip-list'; export * from './chip'; export * from './chip-input'; -export * from './mat-exports'; + diff --git a/src/lib/core/_core.scss b/src/lib/core/_core.scss index 7ae874518a80..7a4372719261 100644 --- a/src/lib/core/_core.scss +++ b/src/lib/core/_core.scss @@ -40,7 +40,7 @@ @include mat-pseudo-checkbox-theme($theme); // Wrapper element that provides the theme background when the - // user's content isn't inside of a `md-sidenav-container`. + // user's content isn't inside of a `mat-sidenav-container`. .mat-app-background { $background: map-get($theme, background); background-color: mat-color($background, background); diff --git a/src/lib/core/common-behaviors/common-module.ts b/src/lib/core/common-behaviors/common-module.ts index dcc15f4b33c6..5262c8e6b6a9 100644 --- a/src/lib/core/common-behaviors/common-module.ts +++ b/src/lib/core/common-behaviors/common-module.ts @@ -13,14 +13,14 @@ import {CompatibilityModule} from '../compatibility/compatibility'; /** Injection token that configures whether the Material sanity checks are enabled. */ -export const MATERIAL_SANITY_CHECKS = new InjectionToken('md-sanity-checks'); +export const MATERIAL_SANITY_CHECKS = new InjectionToken('mat-sanity-checks'); /** * Module that captures anything that should be loaded and/or run for *all* Angular Material * components. This includes Bidi, compatibility mode, etc. * - * This module should be imported to each top-level component module (e.g., MdTabsModule). + * This module should be imported to each top-level component module (e.g., MatTabsModule). */ @NgModule({ imports: [CompatibilityModule, BidiModule], @@ -29,7 +29,7 @@ export const MATERIAL_SANITY_CHECKS = new InjectionToken('md-sanity-che provide: MATERIAL_SANITY_CHECKS, useValue: true, }], }) -export class MdCommonModule { +export class MatCommonModule { /** Whether we've done the global sanity checks (e.g. a theme is loaded, there is a doctype). */ private _hasDoneGlobalChecks = false; diff --git a/src/lib/core/common-behaviors/index.ts b/src/lib/core/common-behaviors/index.ts index 80e6e0c694d1..8ec520969ad7 100644 --- a/src/lib/core/common-behaviors/index.ts +++ b/src/lib/core/common-behaviors/index.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -export {MdCommonModule, MATERIAL_SANITY_CHECKS} from './common-module'; +export {MatCommonModule, MATERIAL_SANITY_CHECKS} from './common-module'; export {CanDisable, mixinDisabled} from './disabled'; export {CanColor, mixinColor, ThemePalette} from './color'; export {CanDisableRipple, mixinDisableRipple} from './disable-ripple'; diff --git a/src/lib/core/compatibility/compatibility.spec.ts b/src/lib/core/compatibility/compatibility.spec.ts index b22fe0a9055a..e69de29bb2d1 100644 --- a/src/lib/core/compatibility/compatibility.spec.ts +++ b/src/lib/core/compatibility/compatibility.spec.ts @@ -1,104 +0,0 @@ -import {Component, NgModule} from '@angular/core'; -import {async, TestBed} from '@angular/core/testing'; -import {MdCheckboxModule} from '../../checkbox/index'; -import { - NoConflictStyleCompatibilityMode, - MAT_ELEMENTS_SELECTOR, - MD_ELEMENTS_SELECTOR, - getMdCompatibilityInvalidPrefixError, -} from './compatibility'; -import {wrappedErrorMessage} from '@angular/cdk/testing'; - - -describe('Style compatibility', () => { - - describe('selectors', () => { - it('should have the same selectors in the same order for compatibility mode', () => { - expect(MAT_ELEMENTS_SELECTOR.replace(/(\s|\[)mat/g, '$1md').trim()) - .toBe(MD_ELEMENTS_SELECTOR.trim()); - expect(MD_ELEMENTS_SELECTOR.replace(/(\s|\[)md/g, '$1mat').trim()) - .toBe(MAT_ELEMENTS_SELECTOR.trim()); - }); - }); - - describe('in default mode', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - // Specifically do *not* directly import the DefaultStyleCompatibilityModeModule - // to ensure that it is the default behavior. - imports: [MdCheckboxModule], - declarations: [ComponentWithMdCheckbox, ComponentWithMatCheckbox], - }); - - TestBed.compileComponents(); - })); - - it('should throw an error when trying to use the "mat-" prefix', () => { - const expectedError = getMdCompatibilityInvalidPrefixError('mat', 'mat-checkbox'); - - expect(() => { - TestBed.createComponent(ComponentWithMatCheckbox); - }).toThrowError(wrappedErrorMessage(expectedError)); - }); - }); - - describe('in no-conflict mode', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [MdCheckboxModule, NoConflictStyleCompatibilityMode], - declarations: [ComponentWithMdCheckbox, ComponentWithMatCheckbox], - }); - - TestBed.compileComponents(); - })); - - it('should not throw an error when trying to use the "mat-" prefix', () => { - TestBed.createComponent(ComponentWithMatCheckbox); - }); - - it('should throw an error when trying to use the "md-" prefix', () => { - const expectedError = getMdCompatibilityInvalidPrefixError('md', 'md-checkbox'); - - expect(() => { - TestBed.createComponent(ComponentWithMdCheckbox); - }).toThrowError(wrappedErrorMessage(expectedError)); - }); - }); - - describe('with no-conflict mode at root and component module imported in app sub-module', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [TestAppSubModule, NoConflictStyleCompatibilityMode], - }); - - TestBed.compileComponents(); - })); - - it('should throw an error when using the "md-" prefix', () => { - const expectedError = getMdCompatibilityInvalidPrefixError('md', 'md-checkbox'); - - expect(() => { - TestBed.createComponent(ComponentWithMdCheckbox); - }).toThrowError(wrappedErrorMessage(expectedError)); - }); - - it('should not throw an error when using the "mat-" prefix', () => { - TestBed.createComponent(ComponentWithMatCheckbox); - }); - }); -}); - - -@Component({ template: `Hungry` }) -export class ComponentWithMdCheckbox { } - -@Component({ template: `Hungry` }) -export class ComponentWithMatCheckbox { } - - -@NgModule({ - imports: [MdCheckboxModule], - exports: [ComponentWithMdCheckbox, ComponentWithMatCheckbox], - declarations: [ComponentWithMdCheckbox, ComponentWithMatCheckbox], -}) -export class TestAppSubModule {} diff --git a/src/lib/core/compatibility/compatibility.ts b/src/lib/core/compatibility/compatibility.ts index 769e23fcb549..eaaaacf16241 100644 --- a/src/lib/core/compatibility/compatibility.ts +++ b/src/lib/core/compatibility/compatibility.ts @@ -6,20 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgModule, Directive, Inject, Optional, ElementRef, InjectionToken} from '@angular/core'; +import {Directive, InjectionToken, NgModule} from '@angular/core'; export const MATERIAL_COMPATIBILITY_MODE = new InjectionToken('md-compatibility-mode'); -/** - * Returns an exception to be thrown if the consumer has used - * an invalid Material prefix on a component. - * @docs-private - */ -export function getMdCompatibilityInvalidPrefixError(prefix: string, nodeName: string) { - return Error(`The "${prefix}-" prefix cannot be used in ng-material v1 compatibility mode. ` + - `It was used on an "${nodeName.toLowerCase()}" element.`); -} - /** Selector that matches all elements that may have style collisions with AngularJS Material. */ export const MAT_ELEMENTS_SELECTOR = ` [mat-button], @@ -188,29 +178,11 @@ export const MD_ELEMENTS_SELECTOR = ` /** Directive that enforces that the `mat-` prefix cannot be used. */ @Directive({selector: MAT_ELEMENTS_SELECTOR}) -export class MatPrefixRejector { - constructor( - @Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) isCompatibilityMode: boolean, - elementRef: ElementRef) { - - if (!isCompatibilityMode) { - throw getMdCompatibilityInvalidPrefixError('mat', elementRef.nativeElement.nodeName); - } - } -} +export class MatPrefixRejector {} /** Directive that enforces that the `md-` prefix cannot be used. */ @Directive({selector: MD_ELEMENTS_SELECTOR}) -export class MdPrefixRejector { - constructor( - @Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) isCompatibilityMode: boolean, - elementRef: ElementRef) { - - if (isCompatibilityMode) { - throw getMdCompatibilityInvalidPrefixError('md', elementRef.nativeElement.nodeName); - } - } -} +export class MdPrefixRejector {} /** @@ -229,9 +201,5 @@ export class CompatibilityModule {} * Module that enforces "no-conflict" compatibility mode settings. When this module is loaded, * it will throw an error if there are any uses of the `md-` prefix. */ -@NgModule({ - providers: [{ - provide: MATERIAL_COMPATIBILITY_MODE, useValue: true, - }], -}) +@NgModule() export class NoConflictStyleCompatibilityMode {} diff --git a/src/lib/core/datetime/date-formats.ts b/src/lib/core/datetime/date-formats.ts index 9ea86e42bbae..2a0a15361916 100644 --- a/src/lib/core/datetime/date-formats.ts +++ b/src/lib/core/datetime/date-formats.ts @@ -9,7 +9,7 @@ import {InjectionToken} from '@angular/core'; -export type MdDateFormats = { +export type MatDateFormats = { parse: { dateInput: any }, @@ -22,4 +22,4 @@ export type MdDateFormats = { }; -export const MD_DATE_FORMATS = new InjectionToken('md-date-formats'); +export const MAT_DATE_FORMATS = new InjectionToken('mat-date-formats'); diff --git a/src/lib/core/datetime/index.ts b/src/lib/core/datetime/index.ts index e16c8b39b197..a7035f4b62b6 100644 --- a/src/lib/core/datetime/index.ts +++ b/src/lib/core/datetime/index.ts @@ -9,8 +9,8 @@ import {NgModule} from '@angular/core'; import {DateAdapter, MAT_DATE_LOCALE_PROVIDER} from './date-adapter'; import {NativeDateAdapter} from './native-date-adapter'; -import {MD_DATE_FORMATS} from './date-formats'; -import {MD_NATIVE_DATE_FORMATS} from './native-date-formats'; +import {MAT_DATE_FORMATS} from './date-formats'; +import {MAT_NATIVE_DATE_FORMATS} from './native-date-formats'; export * from './date-adapter'; export * from './date-formats'; @@ -29,6 +29,6 @@ export class NativeDateModule {} @NgModule({ imports: [NativeDateModule], - providers: [{provide: MD_DATE_FORMATS, useValue: MD_NATIVE_DATE_FORMATS}], + providers: [{provide: MAT_DATE_FORMATS, useValue: MAT_NATIVE_DATE_FORMATS}], }) -export class MdNativeDateModule {} +export class MatNativeDateModule {} diff --git a/src/lib/core/datetime/native-date-formats.ts b/src/lib/core/datetime/native-date-formats.ts index 631cfcb010b5..2c8bd3e494ba 100644 --- a/src/lib/core/datetime/native-date-formats.ts +++ b/src/lib/core/datetime/native-date-formats.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {MdDateFormats} from './date-formats'; +import {MatDateFormats} from './date-formats'; -export const MD_NATIVE_DATE_FORMATS: MdDateFormats = { +export const MAT_NATIVE_DATE_FORMATS: MatDateFormats = { parse: { dateInput: null, }, diff --git a/src/lib/core/error/error-options.ts b/src/lib/core/error/error-options.ts index e4d1bb4d16f2..fc0945955f0d 100644 --- a/src/lib/core/error/error-options.ts +++ b/src/lib/core/error/error-options.ts @@ -10,7 +10,8 @@ import {InjectionToken} from '@angular/core'; import {FormControl, FormGroupDirective, NgForm} from '@angular/forms'; /** Injection token that can be used to specify the global error options. */ -export const MD_ERROR_GLOBAL_OPTIONS = new InjectionToken('md-error-global-options'); +export const MAT_ERROR_GLOBAL_OPTIONS = + new InjectionToken('mat-error-global-options'); export type ErrorStateMatcher = (control: FormControl, form: FormGroupDirective | NgForm) => boolean; diff --git a/src/lib/core/line/line.ts b/src/lib/core/line/line.ts index 747adc0ccdeb..fa76897daa17 100644 --- a/src/lib/core/line/line.ts +++ b/src/lib/core/line/line.ts @@ -13,26 +13,26 @@ import { ElementRef, QueryList, } from '@angular/core'; -import {MdCommonModule} from '../common-behaviors/common-module'; +import {MatCommonModule} from '../common-behaviors/common-module'; /** * Shared directive to count lines inside a text area, such as a list item. - * Line elements can be extracted with a @ContentChildren(MdLine) query, then + * Line elements can be extracted with a @ContentChildren(MatLine) query, then * counted by checking the query list's length. */ @Directive({ - selector: '[md-line], [mat-line], [mdLine], [matLine]', + selector: '[mat-line], [matLine]', host: {'class': 'mat-line'} }) -export class MdLine {} +export class MatLine {} /** * Helper that takes a query list of lines and sets the correct class on the host. * @docs-private */ -export class MdLineSetter { - constructor(private _lines: QueryList, private _renderer: Renderer2, +export class MatLineSetter { + constructor(private _lines: QueryList, private _renderer: Renderer2, private _element: ElementRef) { this._setLineClass(this._lines.length); @@ -67,8 +67,8 @@ export class MdLineSetter { } @NgModule({ - imports: [MdCommonModule], - exports: [MdLine, MdCommonModule], - declarations: [MdLine], + imports: [MatCommonModule], + exports: [MatLine, MatCommonModule], + declarations: [MatLine], }) -export class MdLineModule { } +export class MatLineModule { } diff --git a/src/lib/core/mat-exports.ts b/src/lib/core/mat-exports.ts deleted file mode 100644 index b38a9c583c59..000000000000 --- a/src/lib/core/mat-exports.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdCommonModule} from './common-behaviors/common-module'; -import { - MD_DATE_FORMATS, - MD_NATIVE_DATE_FORMATS, - MdDateFormats, - MdNativeDateModule, -} from './datetime/index'; -import {MD_ERROR_GLOBAL_OPTIONS} from './error/error-options'; -import {MdLine, MdLineModule, MdLineSetter} from './line/line'; -import { - MdOptgroup, - MdOptgroupBase, - MdOption, - MdOptionModule, - MdOptionSelectionChange, -} from './option/index'; -import {MD_PLACEHOLDER_GLOBAL_OPTIONS} from './placeholder/placeholder-options'; -import {MD_RIPPLE_GLOBAL_OPTIONS, MdRipple, MdRippleModule} from './ripple/index'; -import {MdPseudoCheckbox, MdPseudoCheckboxModule, MdPseudoCheckboxState} from './selection/index'; - -export {MD_DATE_FORMATS as MAT_DATE_FORMATS}; -export {MD_RIPPLE_GLOBAL_OPTIONS as MAT_RIPPLE_GLOBAL_OPTIONS}; -export {MD_NATIVE_DATE_FORMATS as MAT_NATIVE_DATE_FORMATS}; -export {MD_PLACEHOLDER_GLOBAL_OPTIONS as MAT_PLACEHOLDER_GLOBAL_OPTIONS}; -export {MD_ERROR_GLOBAL_OPTIONS as MAT_ERROR_GLOBAL_OPTIONS}; -export {MdCommonModule as MatCommonModule}; -export {MdDateFormats as MatDateFormats}; -export {MdLine as MatLine}; -export {MdLineModule as MatLineModule}; -export {MdLineSetter as MatLineSetter}; -export {MdOptgroup as MatOptgroup}; -export {MdOptgroupBase as MatOptgroupBase}; -export {MdOption as MatOption}; -export {MdOptionModule as MatOptionModule}; -export {MdOptionSelectionChange as MatOptionSelectionChange}; -export {MdNativeDateModule as MatNativeDateModule}; -export {MdPseudoCheckbox as MatPseudoCheckbox}; -export {MdPseudoCheckboxModule as MatPseudoCheckboxModule}; -export {MdPseudoCheckboxState as MatPseudoCheckboxState}; -export {MdRipple as MatRipple}; -export {MdRippleModule as MatRippleModule}; diff --git a/src/lib/core/option/_option.scss b/src/lib/core/option/_option.scss index 109f1ecc3d99..6cbae7e330ed 100644 --- a/src/lib/core/option/_option.scss +++ b/src/lib/core/option/_option.scss @@ -30,9 +30,9 @@ } // Collapses unwanted whitespace created by newlines in code like the following: - // + // // {{value}} - // + // .mat-option-text { display: inline-block; } diff --git a/src/lib/core/option/index.ts b/src/lib/core/option/index.ts index 2150e97f094b..cb72fc3876ff 100644 --- a/src/lib/core/option/index.ts +++ b/src/lib/core/option/index.ts @@ -8,18 +8,18 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {MdRippleModule} from '../ripple/index'; -import {MdPseudoCheckboxModule} from '../selection/index'; -import {MdOption} from './option'; -import {MdOptgroup} from './optgroup'; +import {MatRippleModule} from '../ripple/index'; +import {MatPseudoCheckboxModule} from '../selection/index'; +import {MatOption} from './option'; +import {MatOptgroup} from './optgroup'; @NgModule({ - imports: [MdRippleModule, CommonModule, MdPseudoCheckboxModule], - exports: [MdOption, MdOptgroup], - declarations: [MdOption, MdOptgroup] + imports: [MatRippleModule, CommonModule, MatPseudoCheckboxModule], + exports: [MatOption, MatOptgroup], + declarations: [MatOption, MatOptgroup] }) -export class MdOptionModule {} +export class MatOptionModule {} export * from './option'; diff --git a/src/lib/core/option/optgroup.html b/src/lib/core/option/optgroup.html index 62e7c987b446..5e1054f77639 100644 --- a/src/lib/core/option/optgroup.html +++ b/src/lib/core/option/optgroup.html @@ -1,2 +1,2 @@ - + diff --git a/src/lib/core/option/optgroup.ts b/src/lib/core/option/optgroup.ts index f904895ac8d2..7315448e8421 100644 --- a/src/lib/core/option/optgroup.ts +++ b/src/lib/core/option/optgroup.ts @@ -9,20 +9,20 @@ import {Component, ViewEncapsulation, Input, ChangeDetectionStrategy} from '@angular/core'; import {mixinDisabled, CanDisable} from '../common-behaviors/disabled'; -// Boilerplate for applying mixins to MdOptgroup. +// Boilerplate for applying mixins to MatOptgroup. /** @docs-private */ -export class MdOptgroupBase { } -export const _MdOptgroupMixinBase = mixinDisabled(MdOptgroupBase); +export class MatOptgroupBase { } +export const _MatOptgroupMixinBase = mixinDisabled(MatOptgroupBase); // Counter for unique group ids. let _uniqueOptgroupIdCounter = 0; /** - * Component that is used to group instances of `md-option`. + * Component that is used to group instances of `mat-option`. */ @Component({ moduleId: module.id, - selector: 'md-optgroup, mat-optgroup', + selector: 'mat-optgroup', templateUrl: 'optgroup.html', encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, @@ -36,7 +36,7 @@ let _uniqueOptgroupIdCounter = 0; '[attr.aria-labelledby]': '_labelId', } }) -export class MdOptgroup extends _MdOptgroupMixinBase implements CanDisable { +export class MatOptgroup extends _MatOptgroupMixinBase implements CanDisable { /** Label for the option group. */ @Input() label: string; diff --git a/src/lib/core/option/option.spec.ts b/src/lib/core/option/option.spec.ts index d0a9c79470d3..f03c47f8e30c 100644 --- a/src/lib/core/option/option.spec.ts +++ b/src/lib/core/option/option.spec.ts @@ -2,13 +2,13 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; import {dispatchFakeEvent} from '@angular/cdk/testing'; -import {MdOption, MdOptionModule} from './index'; +import {MatOption, MatOptionModule} from './index'; -describe('MdOption component', () => { +describe('MatOption component', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdOptionModule], + imports: [MatOptionModule], declarations: [OptionWithDisable] }).compileComponents(); })); @@ -17,13 +17,13 @@ describe('MdOption component', () => { let fixture: ComponentFixture; let optionDebugElement: DebugElement; let optionNativeElement: HTMLElement; - let optionInstance: MdOption; + let optionInstance: MatOption; beforeEach(() => { fixture = TestBed.createComponent(OptionWithDisable); fixture.detectChanges(); - optionDebugElement = fixture.debugElement.query(By.directive(MdOption)); + optionDebugElement = fixture.debugElement.query(By.directive(MatOption)); optionNativeElement = optionDebugElement.nativeElement; optionInstance = optionDebugElement.componentInstance; }); @@ -73,7 +73,7 @@ describe('MdOption component', () => { }); @Component({ - template: `` + template: `` }) export class OptionWithDisable { disabled: boolean; diff --git a/src/lib/core/option/option.ts b/src/lib/core/option/option.ts index 8174c0b5f9fc..b7061303225c 100644 --- a/src/lib/core/option/option.ts +++ b/src/lib/core/option/option.ts @@ -20,8 +20,7 @@ import { QueryList, ViewEncapsulation, } from '@angular/core'; -import {MATERIAL_COMPATIBILITY_MODE} from '../compatibility/compatibility'; -import {MdOptgroup} from './optgroup'; +import {MatOptgroup} from './optgroup'; /** * Option IDs need to be unique across components, so this counter exists outside of @@ -29,17 +28,17 @@ import {MdOptgroup} from './optgroup'; */ let _uniqueIdCounter = 0; -/** Event object emitted by MdOption when selected or deselected. */ -export class MdOptionSelectionChange { - constructor(public source: MdOption, public isUserInput = false) { } +/** Event object emitted by MatOption when selected or deselected. */ +export class MatOptionSelectionChange { + constructor(public source: MatOption, public isUserInput = false) { } } /** - * Single option inside of a `` element. + * Single option inside of a `` element. */ @Component({ moduleId: module.id, - selector: 'md-option, mat-option', + selector: 'mat-option', host: { 'role': 'option', '[attr.tabindex]': '_getTabIndex()', @@ -58,9 +57,8 @@ export class MdOptionSelectionChange { encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdOption { +export class MatOption { private _selected: boolean = false; private _active: boolean = false; private _multiple: boolean = false; @@ -69,7 +67,7 @@ export class MdOption { /** Whether the option is disabled. */ private _disabled: boolean = false; - private _id: string = `md-option-${_uniqueIdCounter++}`; + private _id: string = `mat-option-${_uniqueIdCounter++}`; /** Whether the wrapping component is in multiple selection mode. */ get multiple() { return this._multiple; } @@ -102,12 +100,12 @@ export class MdOption { } /** Event emitted when the option is selected or deselected. */ - @Output() onSelectionChange = new EventEmitter(); + @Output() onSelectionChange = new EventEmitter(); constructor( private _element: ElementRef, private _changeDetectorRef: ChangeDetectorRef, - @Optional() public readonly group: MdOptgroup) {} + @Optional() public readonly group: MatOptgroup) {} /** * Whether or not the option is currently active and ready to be selected. @@ -214,7 +212,7 @@ export class MdOption { /** Emits the selection change event. */ private _emitSelectionChangeEvent(isUserInput = false): void { - this.onSelectionChange.emit(new MdOptionSelectionChange(this, isUserInput)); + this.onSelectionChange.emit(new MatOptionSelectionChange(this, isUserInput)); } /** @@ -223,8 +221,8 @@ export class MdOption { * @param options Flat list of all of the options. * @param optionGroups Flat list of all of the option groups. */ - static countGroupLabelsBeforeOption(optionIndex: number, options: QueryList, - optionGroups: QueryList): number { + static countGroupLabelsBeforeOption(optionIndex: number, options: QueryList, + optionGroups: QueryList): number { if (optionGroups.length) { let optionsArray = options.toArray(); diff --git a/src/lib/core/placeholder/placeholder-options.ts b/src/lib/core/placeholder/placeholder-options.ts index ee79b824fa86..ba024ad3cfd2 100644 --- a/src/lib/core/placeholder/placeholder-options.ts +++ b/src/lib/core/placeholder/placeholder-options.ts @@ -9,8 +9,8 @@ import { InjectionToken } from '@angular/core'; /** InjectionToken that can be used to specify the global placeholder options. */ -export const MD_PLACEHOLDER_GLOBAL_OPTIONS = - new InjectionToken('md-placeholder-global-options'); +export const MAT_PLACEHOLDER_GLOBAL_OPTIONS = + new InjectionToken('mat-placeholder-global-options'); /** Type for the available floatPlaceholder values. */ export type FloatPlaceholderType = 'always' | 'never' | 'auto'; diff --git a/src/lib/core/public_api.ts b/src/lib/core/public_api.ts index 4a540f7e1cf6..c059cace3f96 100644 --- a/src/lib/core/public_api.ts +++ b/src/lib/core/public_api.ts @@ -21,7 +21,7 @@ export * from './ripple/index'; export * from './selection/index'; export * from './style/index'; export * from './util/object-extend'; -export * from './mat-exports'; + // TODO: don't have this export * from './testing/month-constants'; diff --git a/src/lib/core/ripple/README.md b/src/lib/core/ripple/README.md index 3ec6f266617f..2cbcbe44a147 100644 --- a/src/lib/core/ripple/README.md +++ b/src/lib/core/ripple/README.md @@ -1,10 +1,10 @@ -# md-ripple +# mat-ripple -`md-ripple` defines an area in which a ripple animates, usually in response to user action. It is used as an attribute directive, for example `
...
`. +`mat-ripple` defines an area in which a ripple animates, usually in response to user action. It is used as an attribute directive, for example `
...
`. -By default, a ripple is activated when the host element of the `md-ripple` directive receives mouse or touch events. On a mousedown or touch start, the ripple background fades in. When the click event completes, a circular foreground ripple fades in and expands from the event location to cover the host element bounds. +By default, a ripple is activated when the host element of the `mat-ripple` directive receives mouse or touch events. On a mousedown or touch start, the ripple background fades in. When the click event completes, a circular foreground ripple fades in and expands from the event location to cover the host element bounds. -Ripples can also be triggered programmatically by getting a reference to the MdRipple directive and calling its `start` and `end` methods. +Ripples can also be triggered programmatically by getting a reference to the MatRipple directive and calling its `start` and `end` methods. ### Global options @@ -12,7 +12,7 @@ Developers are able to specify options for all ripples inside of their applicati The speed of the ripples can be adjusted and the ripples can be disabled globally as well. -Global ripple options can be specified by setting the `MD_RIPPLE_GLOBAL_OPTIONS` provider. +Global ripple options can be specified by setting the `MAT_RIPPLE_GLOBAL_OPTIONS` provider. ```ts const globalRippleConfig: RippleGlobalOptions = { @@ -22,7 +22,7 @@ const globalRippleConfig: RippleGlobalOptions = { @NgModule({ providers: [ - {provide: MD_RIPPLE_GLOBAL_OPTIONS, useValue: globalRippleConfig} + {provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: globalRippleConfig} ] }) ``` @@ -40,9 +40,9 @@ Properties: | Name | Type | Description | | --- | --- | --- | -| `mdRippleTrigger` | Element | The DOM element that triggers the ripple when clicked. Defaults to the parent of the `md-ripple`. -| `mdRippleColor` | string | Custom color for foreground ripples -| `mdRippleCentered` | boolean | If true, the ripple animation originates from the center of the `md-ripple` bounds rather than from the location of the click event. -| `mdRippleRadius` | number | Optional fixed radius of foreground ripples when fully expanded. Mainly used in conjunction with `unbounded` attribute. If not set, ripples will expand from their origin to the most distant corner of the component's bounding rectangle. -| `mdRippleUnbounded` | boolean | If true, foreground ripples will be visible outside the component's bounds. -| `mdRippleDisabled` | boolean | If true, click events on the trigger element will not activate ripples. The `start` and `end` methods can still be called to programmatically create ripples. +| `matRippleTrigger` | Element | The DOM element that triggers the ripple when clicked. Defaults to the parent of the `mat-ripple`. +| `matRippleColor` | string | Custom color for foreground ripples +| `matRippleCentered` | boolean | If true, the ripple animation originates from the center of the `mat-ripple` bounds rather than from the location of the click event. +| `matRippleRadius` | number | Optional fixed radius of foreground ripples when fully expanded. Mainly used in conjunction with `unbounded` attribute. If not set, ripples will expand from their origin to the most distant corner of the component's bounding rectangle. +| `matRippleUnbounded` | boolean | If true, foreground ripples will be visible outside the component's bounds. +| `matRippleDisabled` | boolean | If true, click events on the trigger element will not activate ripples. The `start` and `end` methods can still be called to programmatically create ripples. diff --git a/src/lib/core/ripple/_ripple.scss b/src/lib/core/ripple/_ripple.scss index 257df0e8ba69..6c03b9ae0980 100644 --- a/src/lib/core/ripple/_ripple.scss +++ b/src/lib/core/ripple/_ripple.scss @@ -4,7 +4,7 @@ $mat-ripple-color-opacity: 0.1; @mixin mat-ripple() { - // The host element of an md-ripple directive should always have a position of "absolute" or + // The host element of an mat-ripple directive should always have a position of "absolute" or // "relative" so that the ripple divs it creates inside itself are correctly positioned. .mat-ripple { overflow: hidden; diff --git a/src/lib/core/ripple/index.ts b/src/lib/core/ripple/index.ts index 4a16b4b3b288..046815308345 100644 --- a/src/lib/core/ripple/index.ts +++ b/src/lib/core/ripple/index.ts @@ -9,17 +9,17 @@ import {NgModule} from '@angular/core'; import {ScrollDispatchModule, VIEWPORT_RULER_PROVIDER} from '@angular/cdk/scrolling'; import {PlatformModule} from '@angular/cdk/platform'; -import {MdCommonModule} from '../common-behaviors/common-module'; -import {MdRipple} from './ripple'; +import {MatCommonModule} from '../common-behaviors/common-module'; +import {MatRipple} from './ripple'; -export {MdRipple, RippleGlobalOptions, MD_RIPPLE_GLOBAL_OPTIONS} from './ripple'; +export {MatRipple, RippleGlobalOptions, MAT_RIPPLE_GLOBAL_OPTIONS} from './ripple'; export {RippleRef, RippleState} from './ripple-ref'; export {RippleConfig, RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from './ripple-renderer'; @NgModule({ - imports: [MdCommonModule, PlatformModule, ScrollDispatchModule], - exports: [MdRipple, MdCommonModule], - declarations: [MdRipple], + imports: [MatCommonModule, PlatformModule, ScrollDispatchModule], + exports: [MatRipple, MatCommonModule], + declarations: [MatRipple], providers: [VIEWPORT_RULER_PROVIDER], }) -export class MdRippleModule {} +export class MatRippleModule {} diff --git a/src/lib/core/ripple/ripple.spec.ts b/src/lib/core/ripple/ripple.spec.ts index 5fb8608a8fe9..765637567fe8 100644 --- a/src/lib/core/ripple/ripple.spec.ts +++ b/src/lib/core/ripple/ripple.spec.ts @@ -5,11 +5,11 @@ import {ViewportRuler} from '@angular/cdk/scrolling'; import {dispatchMouseEvent} from '@angular/cdk/testing'; import {RIPPLE_FADE_OUT_DURATION, RIPPLE_FADE_IN_DURATION} from './ripple-renderer'; import { - MdRipple, MdRippleModule, MD_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions + MatRipple, MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions } from './index'; -describe('MdRipple', () => { +describe('MatRipple', () => { let fixture: ComponentFixture; let rippleTarget: HTMLElement; let originalBodyMargin: string | null; @@ -23,7 +23,7 @@ describe('MdRipple', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [MdRippleModule], + imports: [MatRippleModule], declarations: [ BasicRippleContainer, RippleContainerWithInputBindings, @@ -47,7 +47,7 @@ describe('MdRipple', () => { }); describe('basic ripple', () => { - let rippleDirective: MdRipple; + let rippleDirective: MatRipple; const TARGET_HEIGHT = 200; const TARGET_WIDTH = 300; @@ -285,7 +285,7 @@ describe('MdRipple', () => { }); describe('manual ripples', () => { - let rippleDirective: MdRipple; + let rippleDirective: MatRipple; beforeEach(() => { fixture = TestBed.createComponent(BasicRippleContainer); @@ -359,7 +359,7 @@ describe('MdRipple', () => { }); describe('global ripple options', () => { - let rippleDirective: MdRipple; + let rippleDirective: MatRipple; function createTestComponent(rippleConfig: RippleGlobalOptions, testComponent: any = BasicRippleContainer) { @@ -367,9 +367,9 @@ describe('MdRipple', () => { // The testing module has been initialized in the root describe group for the ripples. TestBed.resetTestingModule(); TestBed.configureTestingModule({ - imports: [MdRippleModule], + imports: [MatRippleModule], declarations: [testComponent], - providers: [{ provide: MD_RIPPLE_GLOBAL_OPTIONS, useValue: rippleConfig }] + providers: [{ provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: rippleConfig }] }); fixture = TestBed.createComponent(testComponent); @@ -456,7 +456,7 @@ describe('MdRipple', () => { describe('configuring behavior', () => { let controller: RippleContainerWithInputBindings; - let rippleComponent: MdRipple; + let rippleComponent: MatRipple; beforeEach(() => { fixture = TestBed.createComponent(RippleContainerWithInputBindings); @@ -570,25 +570,25 @@ describe('MdRipple', () => { @Component({ template: ` -
`, }) class BasicRippleContainer { - @ViewChild('ripple') ripple: MdRipple; + @ViewChild('ripple') ripple: MatRipple; } @Component({ template: `
+ [matRippleSpeedFactor]="0" + [matRippleTrigger]="trigger" + [matRippleCentered]="centered" + [matRippleRadius]="radius" + [matRippleDisabled]="disabled" + [matRippleColor]="color">
`, @@ -599,17 +599,17 @@ class RippleContainerWithInputBindings { disabled = false; radius = 0; color = ''; - @ViewChild(MdRipple) ripple: MdRipple; + @ViewChild(MatRipple) ripple: MatRipple; } @Component({ - template: `
`, + template: `
`, }) class RippleContainerWithoutBindings {} -@Component({ template: `
` }) class RippleContainerWithNgIf { - @ViewChild(MdRipple) ripple: MdRipple; + @ViewChild(MatRipple) ripple: MatRipple; isDestroyed = false; } diff --git a/src/lib/core/ripple/ripple.ts b/src/lib/core/ripple/ripple.ts index 5b25c0a829f1..76e3bcec6b2e 100644 --- a/src/lib/core/ripple/ripple.ts +++ b/src/lib/core/ripple/ripple.ts @@ -29,18 +29,18 @@ export interface RippleGlobalOptions { } /** Injection token that can be used to specify the global ripple options. */ -export const MD_RIPPLE_GLOBAL_OPTIONS = - new InjectionToken('md-ripple-global-options'); +export const MAT_RIPPLE_GLOBAL_OPTIONS = + new InjectionToken('mat-ripple-global-options'); @Directive({ - selector: '[md-ripple], [mat-ripple], [mdRipple], [matRipple]', - exportAs: 'mdRipple, matRipple', + selector: '[mat-ripple], [matRipple]', + exportAs: 'matRipple', host: { 'class': 'mat-ripple', '[class.mat-ripple-unbounded]': 'unbounded' } }) -export class MdRipple implements OnChanges, OnDestroy { +export class MatRipple implements OnChanges, OnDestroy { /** * The element that triggers the ripple when click events are received. Defaults to the @@ -48,74 +48,39 @@ export class MdRipple implements OnChanges, OnDestroy { */ // Prevent TS metadata emit from referencing HTMLElement in ripple.js // Otherwise running this code in a Node environment (e.g Universal) will not work. - @Input('mdRippleTrigger') trigger: HTMLElement|HTMLElement; + @Input('matRippleTrigger') trigger: HTMLElement|HTMLElement; /** * Whether the ripple always originates from the center of the host element's bounds, rather * than originating from the location of the click event. */ - @Input('mdRippleCentered') centered: boolean; + @Input('matRippleCentered') centered: boolean; /** * Whether click events will not trigger the ripple. Ripples can be still launched manually * by using the `launch()` method. */ - @Input('mdRippleDisabled') disabled: boolean; + @Input('matRippleDisabled') disabled: boolean; /** * If set, the radius in pixels of foreground ripples when fully expanded. If unset, the radius * will be the distance from the center of the ripple to the furthest corner of the host element's * bounding rectangle. */ - @Input('mdRippleRadius') radius: number = 0; + @Input('matRippleRadius') radius: number = 0; /** * If set, the normal duration of ripple animations is divided by this value. For example, * setting it to 0.5 will cause the animations to take twice as long. * A changed speedFactor will not modify the fade-out duration of the ripples. */ - @Input('mdRippleSpeedFactor') speedFactor: number = 1; + @Input('matRippleSpeedFactor') speedFactor: number = 1; /** Custom color for ripples. */ - @Input('mdRippleColor') color: string; + @Input('matRippleColor') color: string; /** Whether foreground ripples should be visible outside the component's bounds. */ - @Input('mdRippleUnbounded') unbounded: boolean; - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleTrigger') - get _matRippleTrigger() { return this.trigger; } - set _matRippleTrigger(v) { this.trigger = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleCentered') - get _matRippleCentered() { return this.centered; } - set _matRippleCentered(v) { this.centered = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleDisabled') - get _matRippleDisabled() { return this.disabled; } - set _matRippleDisabled(v) { this.disabled = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleRadius') - get _matRippleRadius() { return this.radius; } - set _matRippleRadius(v) { this.radius = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleSpeedFactor') - get _matRippleSpeedFactor() { return this.speedFactor; } - set _matRippleSpeedFactor(v) { this.speedFactor = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleColor') - get _matRippleColor() { return this.color; } - set _matRippleColor(v) { this.color = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matRippleUnbounded') - get _matRippleUnbounded() { return this.unbounded; } - set _matRippleUnbounded(v) { this.unbounded = v; } + @Input('matRippleUnbounded') unbounded: boolean; /** Renderer for the ripple DOM manipulations. */ private _rippleRenderer: RippleRenderer; @@ -128,7 +93,7 @@ export class MdRipple implements OnChanges, OnDestroy { ngZone: NgZone, ruler: ViewportRuler, platform: Platform, - @Optional() @Inject(MD_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions + @Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions ) { this._rippleRenderer = new RippleRenderer(elementRef, ngZone, ruler, platform); this._globalOptions = globalOptions ? globalOptions : {}; diff --git a/src/lib/core/selection/index.ts b/src/lib/core/selection/index.ts index cb3ef436abcb..48df48afef60 100644 --- a/src/lib/core/selection/index.ts +++ b/src/lib/core/selection/index.ts @@ -7,14 +7,14 @@ */ import {NgModule} from '@angular/core'; -import {MdPseudoCheckbox} from './pseudo-checkbox/pseudo-checkbox'; +import {MatPseudoCheckbox} from './pseudo-checkbox/pseudo-checkbox'; @NgModule({ - exports: [MdPseudoCheckbox], - declarations: [MdPseudoCheckbox] + exports: [MatPseudoCheckbox], + declarations: [MatPseudoCheckbox] }) -export class MdPseudoCheckboxModule { } +export class MatPseudoCheckboxModule { } export * from './pseudo-checkbox/pseudo-checkbox'; diff --git a/src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.ts b/src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.ts index db3e5331b153..b7188b2c3927 100644 --- a/src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.ts +++ b/src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.ts @@ -8,7 +8,7 @@ import {Component, ViewEncapsulation, Input, ChangeDetectionStrategy} from '@angular/core'; -export type MdPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; +export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; /** * Component that shows a simplified checkbox without including any kind of "real" checkbox. @@ -18,7 +18,7 @@ export type MdPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; * `mat-primary .mat-pseudo-checkbox`. * * Note that this component will be completely invisible to screen-reader users. This is *not* - * interchangeable with and should *not* be used if the user would directly interact + * interchangeable with and should *not* be used if the user would directly interact * with the checkbox. The pseudo-checkbox should only be used as an implementation detail of * more complex components that appropriately handle selected / checked state. * @docs-private @@ -28,7 +28,7 @@ export type MdPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - selector: 'md-pseudo-checkbox, mat-pseudo-checkbox', + selector: 'mat-pseudo-checkbox', styleUrls: ['pseudo-checkbox.css'], template: '', host: { @@ -38,9 +38,9 @@ export type MdPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate'; '[class.mat-pseudo-checkbox-disabled]': 'disabled', }, }) -export class MdPseudoCheckbox { +export class MatPseudoCheckbox { /** Display state of the checkbox. */ - @Input() state: MdPseudoCheckboxState = 'unchecked'; + @Input() state: MatPseudoCheckboxState = 'unchecked'; /** Whether the checkbox is disabled. */ @Input() disabled: boolean = false; diff --git a/src/lib/core/style/_menu-common.scss b/src/lib/core/style/_menu-common.scss index 9dc35940cfb9..ba363b1bcaa9 100644 --- a/src/lib/core/style/_menu-common.scss +++ b/src/lib/core/style/_menu-common.scss @@ -2,7 +2,7 @@ @import './elevation'; @import './list-common'; -/** The mixins below are shared between md-menu and md-select */ +/** The mixins below are shared between mat-menu and mat-select */ // menu width must be a multiple of 56px $mat-menu-overlay-min-width: 112px !default; // 56 * 2 diff --git a/src/lib/datepicker/calendar-body.spec.ts b/src/lib/datepicker/calendar-body.spec.ts index 08c34dec4c84..ea5052d7b66c 100644 --- a/src/lib/datepicker/calendar-body.spec.ts +++ b/src/lib/datepicker/calendar-body.spec.ts @@ -1,14 +1,14 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {Component} from '@angular/core'; -import {MdCalendarBody, MdCalendarCell} from './calendar-body'; +import {MatCalendarBody, MatCalendarCell} from './calendar-body'; import {By} from '@angular/platform-browser'; -describe('MdCalendarBody', () => { +describe('MatCalendarBody', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ - MdCalendarBody, + MatCalendarBody, // Test components. StandardCalendarBody, @@ -37,7 +37,7 @@ describe('MdCalendarBody', () => { fixture = TestBed.createComponent(StandardCalendarBody); fixture.detectChanges(); - let calendarBodyDebugElement = fixture.debugElement.query(By.directive(MdCalendarBody)); + let calendarBodyDebugElement = fixture.debugElement.query(By.directive(MatCalendarBody)); calendarBodyNativeElement = calendarBodyDebugElement.nativeElement; testComponent = fixture.componentInstance; @@ -102,7 +102,7 @@ describe('MdCalendarBody', () => { fixture = TestBed.createComponent(CalendarBodyWithDisabledCells); fixture.detectChanges(); - let calendarBodyDebugElement = fixture.debugElement.query(By.directive(MdCalendarBody)); + let calendarBodyDebugElement = fixture.debugElement.query(By.directive(MatCalendarBody)); calendarBodyNativeElement = calendarBodyDebugElement.nativeElement; testComponent = fixture.componentInstance; cellEls = calendarBodyNativeElement.querySelectorAll('.mat-calendar-body-cell'); @@ -127,7 +127,7 @@ describe('MdCalendarBody', () => { @Component({ - template: ` @@ -171,5 +171,5 @@ class CalendarBodyWithDisabledCells { function createCell(value: number) { - return new MdCalendarCell(value, `${value}`, `${value}-label`, true); + return new MatCalendarCell(value, `${value}`, `${value}-label`, true); } diff --git a/src/lib/datepicker/calendar-body.ts b/src/lib/datepicker/calendar-body.ts index c6a2d70d2bd0..6272f5d8799c 100644 --- a/src/lib/datepicker/calendar-body.ts +++ b/src/lib/datepicker/calendar-body.ts @@ -20,7 +20,7 @@ import { * An internal class that represents the data corresponding to a single calendar cell. * @docs-private */ -export class MdCalendarCell { +export class MatCalendarCell { constructor(public value: number, public displayValue: string, public ariaLabel: string, @@ -34,7 +34,7 @@ export class MdCalendarCell { */ @Component({ moduleId: module.id, - selector: '[md-calendar-body], [mat-calendar-body]', + selector: '[mat-calendar-body]', templateUrl: 'calendar-body.html', styleUrls: ['calendar-body.css'], host: { @@ -44,12 +44,12 @@ export class MdCalendarCell { preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdCalendarBody { +export class MatCalendarBody { /** The label for the table. (e.g. "Jan 2017"). */ @Input() label: string; /** The cells to display in the table. */ - @Input() rows: MdCalendarCell[][]; + @Input() rows: MatCalendarCell[][]; /** The value in the table that corresponds to today. */ @Input() todayValue: number; @@ -78,7 +78,7 @@ export class MdCalendarBody { /** Emits when a new value is selected. */ @Output() selectedValueChange = new EventEmitter(); - _cellClicked(cell: MdCalendarCell): void { + _cellClicked(cell: MatCalendarCell): void { if (!this.allowDisabledSelection && !cell.enabled) { return; } diff --git a/src/lib/datepicker/calendar.html b/src/lib/datepicker/calendar.html index 71d227291bd1..0af5479a9709 100644 --- a/src/lib/datepicker/calendar.html +++ b/src/lib/datepicker/calendar.html @@ -22,14 +22,14 @@
- - + { +describe('MatCalendar', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MdButtonModule, - MdNativeDateModule, + MatButtonModule, + MatNativeDateModule, ], declarations: [ - MdCalendar, - MdCalendarBody, - MdMonthView, - MdYearView, + MatCalendar, + MatCalendarBody, + MatMonthView, + MatYearView, // Test components. StandardCalendar, @@ -54,7 +53,7 @@ describe('MdCalendar', () => { CalendarWithDateFilter, ], providers: [ - MdDatepickerIntl, + MatDatepickerIntl, ], }); @@ -68,13 +67,13 @@ describe('MdCalendar', () => { let periodButton: HTMLElement; let prevButton: HTMLElement; let nextButton: HTMLElement; - let calendarInstance: MdCalendar; + let calendarInstance: MatCalendar; beforeEach(() => { fixture = TestBed.createComponent(StandardCalendar); fixture.detectChanges(); - let calendarDebugElement = fixture.debugElement.query(By.directive(MdCalendar)); + let calendarDebugElement = fixture.debugElement.query(By.directive(MatCalendar)); calendarElement = calendarDebugElement.nativeElement; periodButton = calendarElement.querySelector('.mat-calendar-period-button') as HTMLElement; prevButton = calendarElement.querySelector('.mat-calendar-previous-button') as HTMLElement; @@ -161,7 +160,7 @@ describe('MdCalendar', () => { }); it('should re-render when the i18n labels have changed', - inject([MdDatepickerIntl], (intl: MdDatepickerIntl) => { + inject([MatDatepickerIntl], (intl: MatDatepickerIntl) => { const button = fixture.debugElement.nativeElement .querySelector('.mat-calendar-period-button'); @@ -461,12 +460,12 @@ describe('MdCalendar', () => { let fixture: ComponentFixture; let testComponent: CalendarWithMinMax; let calendarElement: HTMLElement; - let calendarInstance: MdCalendar; + let calendarInstance: MatCalendar; beforeEach(() => { fixture = TestBed.createComponent(CalendarWithMinMax); - let calendarDebugElement = fixture.debugElement.query(By.directive(MdCalendar)); + let calendarDebugElement = fixture.debugElement.query(By.directive(MatCalendar)); calendarElement = calendarDebugElement.nativeElement; calendarInstance = calendarDebugElement.componentInstance; testComponent = fixture.componentInstance; @@ -535,13 +534,13 @@ describe('MdCalendar', () => { let fixture: ComponentFixture; let testComponent: CalendarWithDateFilter; let calendarElement: HTMLElement; - let calendarInstance: MdCalendar; + let calendarInstance: MatCalendar; beforeEach(() => { fixture = TestBed.createComponent(CalendarWithDateFilter); fixture.detectChanges(); - let calendarDebugElement = fixture.debugElement.query(By.directive(MdCalendar)); + let calendarDebugElement = fixture.debugElement.query(By.directive(MatCalendar)); calendarElement = calendarDebugElement.nativeElement; calendarInstance = calendarDebugElement.componentInstance; testComponent = fixture.componentInstance; @@ -602,40 +601,9 @@ describe('MdCalendar', () => { }); }); -describe('MdCalendar in compatibility mode', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - MdButtonModule, - MdNativeDateModule, - NoConflictStyleCompatibilityMode, - ], - declarations: [ - MdCalendar, - MdCalendarBody, - MdMonthView, - MdYearView, - - // Test components. - StandardCalendar, - ], - providers: [ - MdDatepickerIntl, - ], - }); - - TestBed.compileComponents(); - })); - - it('should not throw on creation', () => { - let fixture = TestBed.createComponent(StandardCalendar); - expect(() => fixture.detectChanges()).not.toThrow(); - }); -}); - @Component({ - template: `` + template: `` }) class StandardCalendar { selected: Date; @@ -645,7 +613,7 @@ class StandardCalendar { @Component({ template: ` - + ` }) class CalendarWithMinMax { @@ -657,8 +625,8 @@ class CalendarWithMinMax { @Component({ template: ` - - + + ` }) class CalendarWithDateFilter { diff --git a/src/lib/datepicker/calendar.ts b/src/lib/datepicker/calendar.ts index b66adc2ff4f3..a046757fdbce 100644 --- a/src/lib/datepicker/calendar.ts +++ b/src/lib/datepicker/calendar.ts @@ -32,17 +32,12 @@ import { Output, ViewEncapsulation, } from '@angular/core'; -import { - DateAdapter, - MATERIAL_COMPATIBILITY_MODE, - MD_DATE_FORMATS, - MdDateFormats, -} from '@angular/material/core'; +import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {first} from 'rxjs/operator/first'; import {Subscription} from 'rxjs/Subscription'; import {coerceDateProperty} from './coerce-date-property'; import {createMissingDateImplError} from './datepicker-errors'; -import {MdDatepickerIntl} from './datepicker-intl'; +import {MatDatepickerIntl} from './datepicker-intl'; /** @@ -51,7 +46,7 @@ import {MdDatepickerIntl} from './datepicker-intl'; */ @Component({ moduleId: module.id, - selector: 'md-calendar, mat-calendar', + selector: 'mat-calendar', templateUrl: 'calendar.html', styleUrls: ['calendar.css'], host: { @@ -60,9 +55,8 @@ import {MdDatepickerIntl} from './datepicker-intl'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdCalendar implements AfterContentInit, OnDestroy { +export class MatCalendar implements AfterContentInit, OnDestroy { private _intlChanges: Subscription; /** A date representing the period (month or year) to start the calendar in. */ @@ -145,10 +139,10 @@ export class MdCalendar implements AfterContentInit, OnDestroy { } constructor(private _elementRef: ElementRef, - private _intl: MdDatepickerIntl, + private _intl: MatDatepickerIntl, private _ngZone: NgZone, @Optional() private _dateAdapter: DateAdapter, - @Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats, + @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, changeDetectorRef: ChangeDetectorRef) { if (!this._dateAdapter) { @@ -156,7 +150,7 @@ export class MdCalendar implements AfterContentInit, OnDestroy { } if (!this._dateFormats) { - throw createMissingDateImplError('MD_DATE_FORMATS'); + throw createMissingDateImplError('MAT_DATE_FORMATS'); } this._intlChanges = _intl.changes.subscribe(() => changeDetectorRef.markForCheck()); diff --git a/src/lib/datepicker/coerce-date-property.spec.ts b/src/lib/datepicker/coerce-date-property.spec.ts index 52c15b36655e..cad4486f843c 100644 --- a/src/lib/datepicker/coerce-date-property.spec.ts +++ b/src/lib/datepicker/coerce-date-property.spec.ts @@ -1,5 +1,5 @@ import {async, inject, TestBed} from '@angular/core/testing'; -import {DateAdapter, JAN, MdNativeDateModule} from '@angular/material/core'; +import {DateAdapter, JAN, MatNativeDateModule} from '@angular/material/core'; import {coerceDateProperty} from './index'; @@ -8,7 +8,7 @@ describe('coerceDateProperty', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdNativeDateModule], + imports: [MatNativeDateModule], }); TestBed.compileComponents(); diff --git a/src/lib/datepicker/datepicker-content.scss b/src/lib/datepicker/datepicker-content.scss index 44fcbd387196..386ec6dac95e 100644 --- a/src/lib/datepicker/datepicker-content.scss +++ b/src/lib/datepicker/datepicker-content.scss @@ -1,27 +1,27 @@ @import '../core/style/elevation'; -$md-datepicker-calendar-padding: 8px; -$md-datepicker-non-touch-calendar-cell-size: 40px; -$md-datepicker-non-touch-calendar-width: - $md-datepicker-non-touch-calendar-cell-size * 7 + $md-datepicker-calendar-padding * 2; +$mat-datepicker-calendar-padding: 8px; +$mat-datepicker-non-touch-calendar-cell-size: 40px; +$mat-datepicker-non-touch-calendar-width: + $mat-datepicker-non-touch-calendar-cell-size * 7 + $mat-datepicker-calendar-padding * 2; // Based on the natural height of the calendar in a month with 6 rows of dates // (largest the calendar will get). -$md-datepicker-non-touch-calendar-height: 354px; +$mat-datepicker-non-touch-calendar-height: 354px; // Ideally the calendar would have a constant aspect ratio, no matter its size, and we would base // these measurements off the aspect ratio. Unfortunately, the aspect ratio does change a little as // the calendar grows, since some of the elements have pixel-based sizes. These numbers have been // chosen to minimize extra whitespace at larger sizes, while still ensuring we won't need // scrollbars at smaller sizes. -$md-datepicker-touch-landscape-width: 64vh; -$md-datepicker-touch-landscape-height: 80vh; -$md-datepicker-touch-portrait-width: 80vw; -$md-datepicker-touch-portrait-height: 100vw; -$md-datepicker-touch-min-width: 250px; -$md-datepicker-touch-min-height: 312px; -$md-datepicker-touch-max-width: 750px; -$md-datepicker-touch-max-height: 788px; +$mat-datepicker-touch-landscape-width: 64vh; +$mat-datepicker-touch-landscape-height: 80vh; +$mat-datepicker-touch-portrait-width: 80vw; +$mat-datepicker-touch-portrait-height: 100vw; +$mat-datepicker-touch-min-width: 250px; +$mat-datepicker-touch-min-height: 312px; +$mat-datepicker-touch-max-width: 750px; +$mat-datepicker-touch-max-height: 788px; .mat-datepicker-content { @@ -31,8 +31,8 @@ $md-datepicker-touch-max-height: 788px; } .mat-calendar { - width: $md-datepicker-non-touch-calendar-width; - height: $md-datepicker-non-touch-calendar-height; + width: $mat-datepicker-non-touch-calendar-width; + height: $mat-datepicker-non-touch-calendar-height; } .mat-datepicker-content-touch { @@ -48,23 +48,23 @@ $md-datepicker-touch-max-height: 788px; margin: -24px; .mat-calendar { - min-width: $md-datepicker-touch-min-width; - min-height: $md-datepicker-touch-min-height; - max-width: $md-datepicker-touch-max-width; - max-height: $md-datepicker-touch-max-height; + min-width: $mat-datepicker-touch-min-width; + min-height: $mat-datepicker-touch-min-height; + max-width: $mat-datepicker-touch-max-width; + max-height: $mat-datepicker-touch-max-height; } } @media all and (orientation: landscape) { .mat-datepicker-content-touch .mat-calendar { - width: $md-datepicker-touch-landscape-width; - height: $md-datepicker-touch-landscape-height; + width: $mat-datepicker-touch-landscape-width; + height: $mat-datepicker-touch-landscape-height; } } @media all and (orientation: portrait) { .mat-datepicker-content-touch .mat-calendar { - width: $md-datepicker-touch-portrait-width; - height: $md-datepicker-touch-portrait-height; + width: $mat-datepicker-touch-portrait-width; + height: $mat-datepicker-touch-portrait-height; } } diff --git a/src/lib/datepicker/datepicker-errors.ts b/src/lib/datepicker/datepicker-errors.ts index c9ac18a8263e..18eb6f2f912f 100644 --- a/src/lib/datepicker/datepicker-errors.ts +++ b/src/lib/datepicker/datepicker-errors.ts @@ -9,6 +9,6 @@ /** @docs-private */ export function createMissingDateImplError(provider: string) { return Error( - `MdDatepicker: No provider found for ${provider}. You must import one of the following ` + - `modules at your application root: MdNativeDateModule, or provide a custom implementation.`); + `MatDatepicker: No provider found for ${provider}. You must import one of the following ` + + `modules at your application root: MatNativeDateModule, or provide a custom implementation.`); } diff --git a/src/lib/datepicker/datepicker-input.ts b/src/lib/datepicker/datepicker-input.ts index 6116ad87c219..fc3fee065f54 100644 --- a/src/lib/datepicker/datepicker-input.ts +++ b/src/lib/datepicker/datepicker-input.ts @@ -31,24 +31,24 @@ import { ValidatorFn, Validators, } from '@angular/forms'; -import {DateAdapter, MD_DATE_FORMATS, MdDateFormats} from '@angular/material/core'; -import {MdFormField} from '@angular/material/form-field'; +import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; +import {MatFormField} from '@angular/material/form-field'; import {Subscription} from 'rxjs/Subscription'; import {coerceDateProperty} from './coerce-date-property'; -import {MdDatepicker} from './datepicker'; +import {MatDatepicker} from './datepicker'; import {createMissingDateImplError} from './datepicker-errors'; -export const MD_DATEPICKER_VALUE_ACCESSOR: any = { +export const MAT_DATEPICKER_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdDatepickerInput), + useExisting: forwardRef(() => MatDatepickerInput), multi: true }; -export const MD_DATEPICKER_VALIDATORS: any = { +export const MAT_DATEPICKER_VALIDATORS: any = { provide: NG_VALIDATORS, - useExisting: forwardRef(() => MdDatepickerInput), + useExisting: forwardRef(() => MatDatepickerInput), multi: true }; @@ -56,22 +56,22 @@ export const MD_DATEPICKER_VALIDATORS: any = { /** * An event used for datepicker input and change events. We don't always have access to a native * input or change event because the event may have been triggered by the user clicking on the - * calendar popup. For consistency, we always use MdDatepickerInputEvent instead. + * calendar popup. For consistency, we always use MatDatepickerInputEvent instead. */ -export class MdDatepickerInputEvent { +export class MatDatepickerInputEvent { /** The new value for the target datepicker input. */ value: D | null; - constructor(public target: MdDatepickerInput, public targetElement: HTMLElement) { + constructor(public target: MatDatepickerInput, public targetElement: HTMLElement) { this.value = this.target.value; } } -/** Directive used to connect an input to a MdDatepicker. */ +/** Directive used to connect an input to a MatDatepicker. */ @Directive({ - selector: 'input[mdDatepicker], input[matDatepicker]', - providers: [MD_DATEPICKER_VALUE_ACCESSOR, MD_DATEPICKER_VALIDATORS], + selector: 'input[matDatepicker]', + providers: [MAT_DATEPICKER_VALUE_ACCESSOR, MAT_DATEPICKER_VALIDATORS], host: { '[attr.aria-haspopup]': 'true', '[attr.aria-owns]': '(_datepicker?.opened && _datepicker.id) || null', @@ -83,40 +83,30 @@ export class MdDatepickerInputEvent { '(blur)': '_onTouched()', '(keydown)': '_onKeydown($event)', }, - exportAs: 'mdDatepickerInput, matDatepickerInput', + exportAs: 'matDatepickerInput', }) -export class MdDatepickerInput implements AfterContentInit, ControlValueAccessor, OnDestroy, +export class MatDatepickerInput implements AfterContentInit, ControlValueAccessor, OnDestroy, Validator { /** The datepicker that this input is associated with. */ @Input() - set mdDatepicker(value: MdDatepicker) { + set matDatepicker(value: MatDatepicker) { this.registerDatepicker(value); } - _datepicker: MdDatepicker; + _datepicker: MatDatepicker; - private registerDatepicker(value: MdDatepicker) { + private registerDatepicker(value: MatDatepicker) { if (value) { this._datepicker = value; this._datepicker._registerInput(this); } } - @Input() set matDatepicker(value: MdDatepicker) { - // Note that we don't set `this.mdDatepicker = value` here, - // because that line gets stripped by the JS compiler. - this.registerDatepicker(value); - } - - @Input() set mdDatepickerFilter(filter: (date: D | null) => boolean) { + @Input() set matDatepickerFilter(filter: (date: D | null) => boolean) { this._dateFilter = filter; this._validatorOnChange(); } _dateFilter: (date: D | null) => boolean; - @Input() set matDatepickerFilter(filter: (date: D | null) => boolean) { - this.mdDatepickerFilter = filter; - } - /** The value of the input. */ @Input() get value(): D | null { @@ -169,10 +159,10 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces private _disabled: boolean; /** Emits when a `change` event is fired on this ``. */ - @Output() dateChange = new EventEmitter>(); + @Output() dateChange = new EventEmitter>(); /** Emits when an `input` event is fired on this ``. */ - @Output() dateInput = new EventEmitter>(); + @Output() dateInput = new EventEmitter>(); /** Emits when the value changes (either due to user input or programmatic change). */ _valueChange = new EventEmitter(); @@ -193,7 +183,7 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces /** The form control validator for whether the input parses. */ private _parseValidator: ValidatorFn = (): ValidationErrors | null => { return this._lastValueValid ? - null : {'mdDatepickerParse': {'text': this._elementRef.nativeElement.value}}; + null : {'matDatepickerParse': {'text': this._elementRef.nativeElement.value}}; } /** The form control validator for the min date. */ @@ -201,7 +191,7 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces const controlValue = coerceDateProperty(this._dateAdapter, control.value); return (!this.min || !controlValue || this._dateAdapter.compareDate(this.min, controlValue) <= 0) ? - null : {'mdDatepickerMin': {'min': this.min, 'actual': controlValue}}; + null : {'matDatepickerMin': {'min': this.min, 'actual': controlValue}}; } /** The form control validator for the max date. */ @@ -209,14 +199,14 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces const controlValue = coerceDateProperty(this._dateAdapter, control.value); return (!this.max || !controlValue || this._dateAdapter.compareDate(this.max, controlValue) >= 0) ? - null : {'mdDatepickerMax': {'max': this.max, 'actual': controlValue}}; + null : {'matDatepickerMax': {'max': this.max, 'actual': controlValue}}; } /** The form control validator for the date filter. */ private _filterValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => { const controlValue = coerceDateProperty(this._dateAdapter, control.value); return !this._dateFilter || !controlValue || this._dateFilter(controlValue) ? - null : {'mdDatepickerFilter': true}; + null : {'matDatepickerFilter': true}; } /** The combined form control validator for this input. */ @@ -231,13 +221,13 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces private _elementRef: ElementRef, private _renderer: Renderer2, @Optional() private _dateAdapter: DateAdapter, - @Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats, - @Optional() private _mdFormField: MdFormField) { + @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, + @Optional() private _formField: MatFormField) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); } if (!this._dateFormats) { - throw createMissingDateImplError('MD_DATE_FORMATS'); + throw createMissingDateImplError('MAT_DATE_FORMATS'); } // Update the displayed date when the locale changes. @@ -253,8 +243,8 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces this.value = selected; this._cvaOnChange(selected); this._onTouched(); - this.dateInput.emit(new MdDatepickerInputEvent(this, this._elementRef.nativeElement)); - this.dateChange.emit(new MdDatepickerInputEvent(this, this._elementRef.nativeElement)); + this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement)); + this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement)); }); } } @@ -279,7 +269,7 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces * @return The element to connect the popup to. */ getPopupConnectionElementRef(): ElementRef { - return this._mdFormField ? this._mdFormField.underlineRef : this._elementRef; + return this._formField ? this._formField.underlineRef : this._elementRef; } // Implemented as part of ControlValueAccessor @@ -316,11 +306,11 @@ export class MdDatepickerInput implements AfterContentInit, ControlValueAcces this._value = date; this._cvaOnChange(date); this._valueChange.emit(date); - this.dateInput.emit(new MdDatepickerInputEvent(this, this._elementRef.nativeElement)); + this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement)); } _onChange() { - this.dateChange.emit(new MdDatepickerInputEvent(this, this._elementRef.nativeElement)); + this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement)); } /** diff --git a/src/lib/datepicker/datepicker-intl.ts b/src/lib/datepicker/datepicker-intl.ts index c52f0fb0ce8e..377db19cbf95 100644 --- a/src/lib/datepicker/datepicker-intl.ts +++ b/src/lib/datepicker/datepicker-intl.ts @@ -12,7 +12,7 @@ import {Subject} from 'rxjs/Subject'; /** Datepicker data that requires internationalization. */ @Injectable() -export class MdDatepickerIntl { +export class MatDatepickerIntl { /** * Stream that emits whenever the labels here are changed. Use this to notify * components if the labels have changed after initialization. diff --git a/src/lib/datepicker/datepicker-module.ts b/src/lib/datepicker/datepicker-module.ts index 36272d381b14..4b34d46bcdd5 100644 --- a/src/lib/datepicker/datepicker-module.ts +++ b/src/lib/datepicker/datepicker-module.ts @@ -10,58 +10,58 @@ import {A11yModule} from '@angular/cdk/a11y'; import {OverlayModule} from '@angular/cdk/overlay'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {MdButtonModule} from '@angular/material/button'; -import {MdDialogModule} from '@angular/material/dialog'; -import {MdIconModule} from '@angular/material/icon'; -import {MdCalendar} from './calendar'; -import {MdCalendarBody} from './calendar-body'; +import {MatButtonModule} from '@angular/material/button'; +import {MatDialogModule} from '@angular/material/dialog'; +import {MatIconModule} from '@angular/material/icon'; +import {MatCalendar} from './calendar'; +import {MatCalendarBody} from './calendar-body'; import { - MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER, - MdDatepicker, - MdDatepickerContent, + MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER, + MatDatepicker, + MatDatepickerContent, } from './datepicker'; -import {MdDatepickerInput} from './datepicker-input'; -import {MdDatepickerIntl} from './datepicker-intl'; -import {MdDatepickerToggle} from './datepicker-toggle'; -import {MdMonthView} from './month-view'; -import {MdYearView} from './year-view'; +import {MatDatepickerInput} from './datepicker-input'; +import {MatDatepickerIntl} from './datepicker-intl'; +import {MatDatepickerToggle} from './datepicker-toggle'; +import {MatMonthView} from './month-view'; +import {MatYearView} from './year-view'; @NgModule({ imports: [ CommonModule, - MdButtonModule, - MdDialogModule, - MdIconModule, + MatButtonModule, + MatDialogModule, + MatIconModule, OverlayModule, A11yModule, ], exports: [ - MdCalendar, - MdCalendarBody, - MdDatepicker, - MdDatepickerContent, - MdDatepickerInput, - MdDatepickerToggle, - MdMonthView, - MdYearView, + MatCalendar, + MatCalendarBody, + MatDatepicker, + MatDatepickerContent, + MatDatepickerInput, + MatDatepickerToggle, + MatMonthView, + MatYearView, ], declarations: [ - MdCalendar, - MdCalendarBody, - MdDatepicker, - MdDatepickerContent, - MdDatepickerInput, - MdDatepickerToggle, - MdMonthView, - MdYearView, + MatCalendar, + MatCalendarBody, + MatDatepicker, + MatDatepickerContent, + MatDatepickerInput, + MatDatepickerToggle, + MatMonthView, + MatYearView, ], providers: [ - MdDatepickerIntl, - MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER, + MatDatepickerIntl, + MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER, ], entryComponents: [ - MdDatepickerContent, + MatDatepickerContent, ] }) -export class MdDatepickerModule {} +export class MatDatepickerModule {} diff --git a/src/lib/datepicker/datepicker-toggle.ts b/src/lib/datepicker/datepicker-toggle.ts index 5968934ff4fc..c9988235b132 100644 --- a/src/lib/datepicker/datepicker-toggle.ts +++ b/src/lib/datepicker/datepicker-toggle.ts @@ -8,26 +8,25 @@ import { ChangeDetectionStrategy, + ChangeDetectorRef, Component, Input, - ViewEncapsulation, - OnDestroy, OnChanges, + OnDestroy, SimpleChanges, - ChangeDetectorRef, + ViewEncapsulation, } from '@angular/core'; -import {MdDatepicker} from './datepicker'; -import {MdDatepickerIntl} from './datepicker-intl'; +import {MatDatepicker} from './datepicker'; +import {MatDatepickerIntl} from './datepicker-intl'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {Subscription} from 'rxjs/Subscription'; import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; -import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; @Component({ moduleId: module.id, - selector: 'md-datepicker-toggle, mat-datepicker-toggle', + selector: 'mat-datepicker-toggle', templateUrl: 'datepicker-toggle.html', host: { 'class': 'mat-datepicker-toggle', @@ -35,13 +34,12 @@ import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdDatepickerToggle implements OnChanges, OnDestroy { +export class MatDatepickerToggle implements OnChanges, OnDestroy { private _stateChanges = Subscription.EMPTY; /** Datepicker instance that the button will toggle. */ - @Input('for') datepicker: MdDatepicker; + @Input('for') datepicker: MatDatepicker; /** Whether the toggle button is disabled. */ @Input() @@ -54,12 +52,12 @@ export class MdDatepickerToggle implements OnChanges, OnDestroy { private _disabled: boolean; constructor( - public _intl: MdDatepickerIntl, + public _intl: MatDatepickerIntl, private _changeDetectorRef: ChangeDetectorRef) {} ngOnChanges(changes: SimpleChanges) { if (changes.datepicker) { - const datepicker: MdDatepicker = changes.datepicker.currentValue; + const datepicker: MatDatepicker = changes.datepicker.currentValue; const datepickerDisabled = datepicker ? datepicker._disabledChange : observableOf(); const inputDisabled = datepicker && datepicker._datepickerInput ? datepicker._datepickerInput._disabledChange : diff --git a/src/lib/datepicker/datepicker.md b/src/lib/datepicker/datepicker.md index 47f5a0f22b3b..6a3ee7a32861 100644 --- a/src/lib/datepicker/datepicker.md +++ b/src/lib/datepicker/datepicker.md @@ -13,42 +13,42 @@ There are many more features that will be added in future iterations, including: * Built in support for [Moment.js](https://momentjs.com/) dates ### Connecting a datepicker to an input -A datepicker is composed of a text input and a calendar pop-up, connected via the `mdDatepicker` +A datepicker is composed of a text input and a calendar pop-up, connected via the `matDatepicker` property on the text input. ```html - - + + ``` An optional datepicker toggle button is available. A toggle can be added to the example above: ```html - - - + + + ``` -This works exactly the same with an input that is part of an `` and the toggle +This works exactly the same with an input that is part of an `` and the toggle can easily be used as a prefix or suffix on the material input: ```html - - - - - + + + + + ``` ### Setting the calendar starting view By default the calendar will open in month view, this can be changed by setting the `startView` -property of `md-datepicker` to `"year"`. In year view the user will see all months of the year and +property of `mat-datepicker` to `"year"`. In year view the user will see all months of the year and then proceed to month view after choosing a month. The month or year that the calendar opens to is determined by first checking if any date is currently selected, if so it will open to the month or year containing that date. Otherwise it will open to the month or year containing today's date. This behavior can be overridden by using the -`startAt` property of `md-datepicker`. In this case the calendar will open to the month or year +`startAt` property of `mat-datepicker`. In this case the calendar will open to the month or year containing the `startAt` date. @@ -62,13 +62,13 @@ from advancing the calendar past the `month` or `year` (depending on current vie -The second way to add date validation is using the `mdDatepickerFilter` property of the datepicker +The second way to add date validation is using the `matDatepickerFilter` property of the datepicker input. This property accepts a function of ` => boolean` (where `` is the date type used by the datepicker, see section on [choosing a date implementation](#choosing-a-date-implementation-and-date-format-settings)). A result of `true` indicates that the date is valid and a result of `false` indicates that it is not. Again this will also disable the dates on the calendar that are invalid. However, one important -difference between using `mdDatepickerFilter` vs using `min` or `max` is that filtering out all +difference between using `matDatepickerFilter` vs using `min` or `max` is that filtering out all dates before or after a certain point, will not prevent the user from advancing the calendar past that point. @@ -79,9 +79,9 @@ They will not be able to go further back in the calendar than 2000. If they manu that is before the min, after the max, or filtered out, the input will have validation errors. Each validation property has a different error that can be checked: - * A value that violates the `min` property will have a `mdDatepickerMin` error. - * A value that violates the `max` property will have a `mdDatepickerMax` error. - * A value that violates the `mdDatepickerFilter` property will have a `mdDatepickerFilter` error. + * A value that violates the `min` property will have a `matDatepickerMin` error. + * A value that violates the `max` property will have a `matDatepickerMax` error. + * A value that violates the `matDatepickerFilter` property will have a `matDatepickerFilter` error. ### Input and change events The input's native `input` and `change` events will only trigger due to user interaction with the @@ -90,21 +90,21 @@ this limitation, the datepicker input also has support for `dateInput` and `date These trigger when the user interacts with either the input or the popup. ```html - - + + ``` ### Touch UI mode The datepicker normally opens as a popup under the input. However this is not ideal for touch devices that don't have as much screen real estate and need bigger click targets. For this reason -`md-datepicker` has a `touchUi` property that can be set to `true` in order to enable a more touch +`mat-datepicker` has a `touchUi` property that can be set to `true` in order to enable a more touch friendly UI where the calendar opens in a large dialog. ### Manually opening and closing the calendar The calendar popup can be programmatically controlled using the `open` and `close` methods on the -`md-datepicker`. It also has an `opened` property that reflects the status of the popup. +`mat-datepicker`. It also has an `opened` property that reflects the status of the popup. @@ -150,20 +150,20 @@ The datepicker was built to be date implementation agnostic. This means that it with a variety of different date implementations. However it also means that developers need to make sure to provide the appropriate pieces for the datepicker to work with their chosen implementation. The easiest way to ensure this is just to import one of the pre-made modules (currently -`MdNativeDateModule` is the only implementation that ships with material, but there are plans to add +`MatNativeDateModule` is the only implementation that ships with material, but there are plans to add a module for Moment.js support): - * `MdNativeDateModule` - support for native JavaScript Date object + * `MatNativeDateModule` - support for native JavaScript Date object -These modules include providers for `DateAdapter` and `MD_DATE_FORMATS` +These modules include providers for `DateAdapter` and `MAT_DATE_FORMATS` ```ts @NgModule({ - imports: [MdDatepickerModule, MdNativeDateModule], + imports: [MatDatepickerModule, MatNativeDateModule], }) export class MyApp {} ``` -Because `DateAdapter` is a generic class, `MdDatepicker` and `MdDatepickerInput` also need to be +Because `DateAdapter` is a generic class, `MatDatepicker` and `MatDatepickerInput` also need to be made generic. When working with these classes (for example as a `ViewChild`) you should include the appropriate generic type that corresponds to the `DateAdapter` implementation you are using. For example: @@ -171,11 +171,11 @@ example: ```ts @Component({...}) export class MyComponent { - @ViewChild(MdDatepicker) datepicker: MdDatepicker; + @ViewChild(MatDatepicker) datepicker: MatDatepicker; } ``` -*Please note: `MdNativeDateModule` is based off of the functionality available in JavaScript's +*Please note: `MatNativeDateModule` is based off of the functionality available in JavaScript's native `Date` object, and is thus not suitable for many locales. One of the biggest shortcomings of the native `Date` object is the inability to set the parse format. We highly recommend using a custom `DateAdapter` that works with the formatting/parsing library of your choice.* @@ -183,22 +183,22 @@ custom `DateAdapter` that works with the formatting/parsing library of your choi #### Customizing the date implementation The datepicker does all of its interaction with date objects via the `DateAdapter`. Making the datepicker work with a different date implementation is as easy as extending `DateAdapter`, and -using your subclass as the provider. You will also want to make sure that the `MD_DATE_FORMATS` +using your subclass as the provider. You will also want to make sure that the `MAT_DATE_FORMATS` provided in your app are formats that can be understood by your date implementation. ```ts @NgModule({ - imports: [MdDatepickerModule], + imports: [MatDatepickerModule], providers: [ {provide: DateAdapter, useClass: MyDateAdapter}, - {provide: MD_DATE_FORMATS, useValue: MY_DATE_FORMATS}, + {provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS}, ], }) export class MyApp {} ``` #### Customizing the parse and display formats -The `MD_DATE_FORMATS` object is just a collection of formats that the datepicker uses when parsing +The `MAT_DATE_FORMATS` object is just a collection of formats that the datepicker uses when parsing and displaying dates. These formats are passed through to the `DateAdapter` so you will want to make sure that the format objects you're using are compatible with the `DateAdapter` used in your app. This example shows how to use the native `Date` implementation from material, but with custom @@ -206,36 +206,36 @@ formats. ```ts @NgModule({ - imports: [MdDatepickerModule], + imports: [MatDatepickerModule], providers: [ {provide: DateAdapter, useClass: NativeDateAdapter}, - {provide: MD_DATE_FORMATS, useValue: MY_NATIVE_DATE_FORMATS}, + {provide: MAT_DATE_FORMATS, useValue: MY_NATIVE_DATE_FORMATS}, ], }) export class MyApp {} ``` #### Localizing labels and messages -The various text strings used by the datepicker are provided through `MdDatepickerIntl`. +The various text strings used by the datepicker are provided through `MatDatepickerIntl`. Localization of these messages can be done by providing a subclass with translated values in your application root module. ```ts @NgModule({ - imports: [MdDatepickerModule, MdNativeDateModule], + imports: [MatDatepickerModule, MatNativeDateModule], providers: [ - {provide: MdDatepickerIntl, useClass: MyIntl}, + {provide: MatDatepickerIntl, useClass: MyIntl}, ], }) export class MyApp {} ``` ### Accessibility -The `MdDatepickerInput` directive adds `aria-haspopup` attribute to the native input element, and it +The `MatDatepickerInput` directive adds `aria-haspopup` attribute to the native input element, and it triggers a calendar dialog with `role="dialog"`. -`MdDatepickerIntl` includes strings that are used for `aria-label`s. The datepicker input +`MatDatepickerIntl` includes strings that are used for `aria-label`s. The datepicker input should have a placeholder or be given a meaningful label via `aria-label`, `aria-labelledby` or -`MdDatepickerIntl`. +`MatDatepickerIntl`. #### Keyboard shortcuts The keyboard shortcuts to handle datepicker are: diff --git a/src/lib/datepicker/datepicker.spec.ts b/src/lib/datepicker/datepicker.spec.ts index cd0834f951d5..3f87fc50749d 100644 --- a/src/lib/datepicker/datepicker.spec.ts +++ b/src/lib/datepicker/datepicker.spec.ts @@ -15,33 +15,33 @@ import { JUL, JUN, MAT_DATE_LOCALE, - MdNativeDateModule, + MatNativeDateModule, NativeDateModule, SEP, } from '@angular/material/core'; -import {MdFormFieldModule} from '@angular/material/form-field'; +import {MatFormFieldModule} from '@angular/material/form-field'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdInputModule} from '../input/index'; -import {MdDatepicker} from './datepicker'; -import {MdDatepickerInput} from './datepicker-input'; -import {MdDatepickerIntl, MdDatepickerModule} from './index'; +import {MatInputModule} from '../input/index'; +import {MatDatepicker} from './datepicker'; +import {MatDatepickerInput} from './datepicker-input'; +import {MatDatepickerIntl, MatDatepickerModule} from './index'; -describe('MdDatepicker', () => { +describe('MatDatepicker', () => { afterEach(inject([OverlayContainer], (container: OverlayContainer) => { container.getContainerElement().parentNode!.removeChild(container.getContainerElement()); })); - describe('with MdNativeDateModule', () => { + describe('with MatNativeDateModule', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ FormsModule, - MdDatepickerModule, - MdFormFieldModule, - MdInputModule, - MdNativeDateModule, + MatDatepickerModule, + MatFormFieldModule, + MatInputModule, + MatNativeDateModule, NoopAnimationsModule, ReactiveFormsModule, ], @@ -94,12 +94,12 @@ describe('MdDatepicker', () => { testComponent.touch = true; fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); testComponent.datepicker.open(); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).not.toBeNull(); + expect(document.querySelector('mat-dialog-container')).not.toBeNull(); }); it('open in disabled mode should not open the calendar', () => { @@ -107,13 +107,13 @@ describe('MdDatepicker', () => { fixture.detectChanges(); expect(document.querySelector('.cdk-overlay-pane')).toBeNull(); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); testComponent.datepicker.open(); fixture.detectChanges(); expect(document.querySelector('.cdk-overlay-pane')).toBeNull(); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); }); it('disabled datepicker input should open the calendar if datepicker is enabled', () => { @@ -149,7 +149,7 @@ describe('MdDatepicker', () => { testComponent.datepicker.open(); fixture.detectChanges(); - let content = document.querySelector('.cdk-overlay-pane md-datepicker-content')!; + let content = document.querySelector('.cdk-overlay-pane mat-datepicker-content')!; expect(content).toBeTruthy('Expected datepicker to be open.'); const keyboardEvent = createKeyboardEvent('keydown', ESCAPE); @@ -158,7 +158,7 @@ describe('MdDatepicker', () => { dispatchEvent(content, keyboardEvent); fixture.detectChanges(); - content = document.querySelector('.cdk-overlay-pane md-datepicker-content')!; + content = document.querySelector('.cdk-overlay-pane mat-datepicker-content')!; expect(content).toBeFalsy('Expected datepicker to be closed.'); expect(stopPropagationSpy).toHaveBeenCalled(); @@ -173,13 +173,13 @@ describe('MdDatepicker', () => { testComponent.datepicker.open(); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).not.toBeNull(); + expect(document.querySelector('mat-dialog-container')).not.toBeNull(); testComponent.datepicker.close(); fixture.detectChanges(); fixture.whenStable().then(() => { - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); }); }); @@ -190,7 +190,7 @@ describe('MdDatepicker', () => { testComponent.datepicker.open(); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).not.toBeNull(); + expect(document.querySelector('mat-dialog-container')).not.toBeNull(); expect(testComponent.datepickerInput.value).toEqual(new Date(2020, JAN, 1)); let cells = document.querySelectorAll('.mat-calendar-body-cell'); @@ -198,7 +198,7 @@ describe('MdDatepicker', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); expect(testComponent.datepickerInput.value).toEqual(new Date(2020, JAN, 2)); }); }); @@ -212,7 +212,7 @@ describe('MdDatepicker', () => { testComponent.datepicker.open(); fixture.detectChanges(); - expect(document.querySelector('md-datepicker-content')).not.toBeNull(); + expect(document.querySelector('mat-datepicker-content')).not.toBeNull(); expect(testComponent.datepickerInput.value).toEqual(new Date(2020, JAN, currentDay)); let cells = document.querySelectorAll('.mat-calendar-body-cell'); @@ -222,7 +222,7 @@ describe('MdDatepicker', () => { fixture.whenStable().then(() => { expect(selectedChangedSpy.calls.count()).toEqual(1); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); expect(testComponent.datepickerInput.value).toEqual(new Date(2020, JAN, 2)); }); }); @@ -536,7 +536,7 @@ describe('MdDatepicker', () => { }); }); - describe('datepicker with md-datepicker-toggle', () => { + describe('datepicker with mat-datepicker-toggle', () => { let fixture: ComponentFixture; let testComponent: DatepickerWithToggle; @@ -553,13 +553,13 @@ describe('MdDatepicker', () => { })); it('should open calendar when toggle clicked', () => { - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); let toggle = fixture.debugElement.query(By.css('button')); dispatchMouseEvent(toggle.nativeElement, 'click'); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).not.toBeNull(); + expect(document.querySelector('mat-dialog-container')).not.toBeNull(); }); it('should not open calendar when toggle clicked if datepicker is disabled', () => { @@ -568,12 +568,12 @@ describe('MdDatepicker', () => { const toggle = fixture.debugElement.query(By.css('button')).nativeElement; expect(toggle.hasAttribute('disabled')).toBe(true); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); dispatchMouseEvent(toggle, 'click'); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); }); it('should not open calendar when toggle clicked if input is disabled', () => { @@ -584,12 +584,12 @@ describe('MdDatepicker', () => { const toggle = fixture.debugElement.query(By.css('button')).nativeElement; expect(toggle.hasAttribute('disabled')).toBe(true); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); dispatchMouseEvent(toggle, 'click'); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).toBeNull(); + expect(document.querySelector('mat-dialog-container')).toBeNull(); }); it('should set the `button` type on the trigger to prevent form submissions', () => { @@ -627,7 +627,7 @@ describe('MdDatepicker', () => { }); it('should re-render when the i18n labels change', - inject([MdDatepickerIntl], (intl: MdDatepickerIntl) => { + inject([MatDatepickerIntl], (intl: MatDatepickerIntl) => { const toggle = fixture.debugElement.query(By.css('button')).nativeElement; intl.openCalendarLabel = 'Open the calendar, perhaps?'; @@ -638,7 +638,7 @@ describe('MdDatepicker', () => { })); }); - describe('datepicker inside md-form-field', () => { + describe('datepicker inside mat-form-field', () => { let fixture: ComponentFixture; let testComponent: FormFieldDatepicker; @@ -654,10 +654,10 @@ describe('MdDatepicker', () => { fixture.detectChanges(); })); - it('should attach popup to md-form-field underline', () => { + it('should attach popup to mat-form-field underline', () => { let attachToRef = testComponent.datepickerInput.getPopupConnectionElementRef(); expect(attachToRef.nativeElement.classList.contains('mat-form-field-underline')) - .toBe(true, 'popup should be attached to md-form-field underline'); + .toBe(true, 'popup should be attached to mat-form-field underline'); }); }); @@ -787,7 +787,7 @@ describe('MdDatepicker', () => { testComponent.datepicker.open(); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).not.toBeNull(); + expect(document.querySelector('mat-dialog-container')).not.toBeNull(); let cells = document.querySelectorAll('.mat-calendar-body-cell'); expect(cells[0].classList).toContain('mat-calendar-body-disabled'); @@ -857,7 +857,7 @@ describe('MdDatepicker', () => { testComponent.datepicker.open(); fixture.detectChanges(); - expect(document.querySelector('md-dialog-container')).not.toBeNull(); + expect(document.querySelector('mat-dialog-container')).not.toBeNull(); let cells = document.querySelectorAll('.mat-calendar-body-cell'); dispatchMouseEvent(cells[0], 'click'); @@ -897,14 +897,14 @@ describe('MdDatepicker', () => { }); }); - describe('with missing DateAdapter and MD_DATE_FORMATS', () => { + describe('with missing DateAdapter and MAT_DATE_FORMATS', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ FormsModule, - MdDatepickerModule, - MdFormFieldModule, - MdInputModule, + MatDatepickerModule, + MatFormFieldModule, + MatInputModule, NoopAnimationsModule, ReactiveFormsModule, ], @@ -916,7 +916,7 @@ describe('MdDatepicker', () => { it('should throw when created', () => { expect(() => TestBed.createComponent(StandardDatepicker)) - .toThrowError(/MdDatepicker: No provider found for .*/); + .toThrowError(/MatDatepicker: No provider found for .*/); }); }); @@ -928,10 +928,10 @@ describe('MdDatepicker', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MdDatepickerModule, - MdFormFieldModule, - MdInputModule, - MdNativeDateModule, + MatDatepickerModule, + MatFormFieldModule, + MatInputModule, + MatNativeDateModule, NoopAnimationsModule ], declarations: [StandardDatepicker], @@ -1010,10 +1010,10 @@ describe('MdDatepicker', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MdDatepickerModule, - MdFormFieldModule, - MdInputModule, - MdNativeDateModule, + MatDatepickerModule, + MatFormFieldModule, + MatInputModule, + MatNativeDateModule, NoopAnimationsModule, NativeDateModule, FormsModule @@ -1045,120 +1045,123 @@ describe('MdDatepicker', () => { @Component({ template: ` - - + + `, }) class StandardDatepicker { touch = false; disabled = false; date: Date | null = new Date(2020, JAN, 1); - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) datepickerInput: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) datepickerInput: MatDatepickerInput; } @Component({ template: ` - + `, }) class MultiInputDatepicker {} @Component({ - template: ``, + template: ``, }) class NoInputDatepicker { - @ViewChild('d') datepicker: MdDatepicker; + @ViewChild('d') datepicker: MatDatepicker; } @Component({ template: ` - - + + `, }) class DatepickerWithStartAt { date = new Date(2020, JAN, 1); startDate = new Date(2010, JAN, 1); - @ViewChild('d') datepicker: MdDatepicker; + @ViewChild('d') datepicker: MatDatepicker; } @Component({ template: ` - - + + `, }) class DatepickerWithStartView { date = new Date(2020, JAN, 1); - @ViewChild('d') datepicker: MdDatepicker; + @ViewChild('d') datepicker: MatDatepicker; } @Component({ - template: ``, + template: ` + + + `, }) class DatepickerWithNgModel { selected: Date | null = null; - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) datepickerInput: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) datepickerInput: MatDatepickerInput; } @Component({ template: ` - - + + `, }) class DatepickerWithFormControl { formControl = new FormControl(); - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) datepickerInput: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) datepickerInput: MatDatepickerInput; } @Component({ template: ` - - - + + + `, }) class DatepickerWithToggle { - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) input: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) input: MatDatepickerInput; touchUI = true; } @Component({ template: ` - - - - + + + + `, }) class FormFieldDatepicker { - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) datepickerInput: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) datepickerInput: MatDatepickerInput; } @Component({ template: ` - - - + + + `, }) class DatepickerWithMinAndMaxValidation { - @ViewChild('d') datepicker: MdDatepicker; + @ViewChild('d') datepicker: MatDatepicker; date: Date | null; minDate = new Date(2010, JAN, 1); maxDate = new Date(2020, JAN, 1); @@ -1167,13 +1170,13 @@ class DatepickerWithMinAndMaxValidation { @Component({ template: ` - - - + + + `, }) class DatepickerWithFilterAndValidation { - @ViewChild('d') datepicker: MdDatepicker; + @ViewChild('d') datepicker: MatDatepicker; date: Date; filter = (date: Date) => date.getDate() != 1; } @@ -1181,13 +1184,13 @@ class DatepickerWithFilterAndValidation { @Component({ template: ` - - + ` }) class DatepickerWithChangeAndInputEvents { - @ViewChild('d') datepicker: MdDatepicker; + @ViewChild('d') datepicker: MatDatepicker; onChange() {} @@ -1200,20 +1203,20 @@ class DatepickerWithChangeAndInputEvents { @Component({ template: ` - - + + ` }) class DatepickerWithi18n { date: Date | null = new Date(2010, JAN, 1); - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) datepickerInput: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) datepickerInput: MatDatepickerInput; } @Component({ template: ` - - + + ` }) class DatepickerWithISOStrings { @@ -1221,6 +1224,6 @@ class DatepickerWithISOStrings { min = new Date(2017, JAN, 1).toISOString(); max = new Date (2017, DEC, 31).toISOString(); startAt = new Date(2017, JUL, 1).toISOString(); - @ViewChild('d') datepicker: MdDatepicker; - @ViewChild(MdDatepickerInput) datepickerInput: MdDatepickerInput; + @ViewChild('d') datepicker: MatDatepicker; + @ViewChild(MatDatepickerInput) datepickerInput: MatDatepickerInput; } diff --git a/src/lib/datepicker/datepicker.ts b/src/lib/datepicker/datepicker.ts index d0873f7f1980..8c9d10adafb3 100644 --- a/src/lib/datepicker/datepicker.ts +++ b/src/lib/datepicker/datepicker.ts @@ -11,8 +11,8 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {ESCAPE} from '@angular/cdk/keycodes'; import { Overlay, - OverlayRef, OverlayConfig, + OverlayRef, PositionStrategy, RepositionScrollStrategy, ScrollStrategy, @@ -36,48 +36,48 @@ import { ViewContainerRef, ViewEncapsulation, } from '@angular/core'; -import {DateAdapter, MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; -import {MdDialog, MdDialogRef} from '@angular/material/dialog'; +import {DateAdapter} from '@angular/material/core'; +import {MatDialog, MatDialogRef} from '@angular/material/dialog'; import {DOCUMENT} from '@angular/platform-browser'; import {Subject} from 'rxjs/Subject'; import {Subscription} from 'rxjs/Subscription'; -import {MdCalendar} from './calendar'; +import {MatCalendar} from './calendar'; import {coerceDateProperty} from './coerce-date-property'; import {createMissingDateImplError} from './datepicker-errors'; -import {MdDatepickerInput} from './datepicker-input'; +import {MatDatepickerInput} from './datepicker-input'; /** Used to generate a unique ID for each datepicker instance. */ let datepickerUid = 0; /** Injection token that determines the scroll handling while the calendar is open. */ -export const MD_DATEPICKER_SCROLL_STRATEGY = - new InjectionToken<() => ScrollStrategy>('md-datepicker-scroll-strategy'); +export const MAT_DATEPICKER_SCROLL_STRATEGY = + new InjectionToken<() => ScrollStrategy>('mat-datepicker-scroll-strategy'); /** @docs-private */ -export function MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): +export function MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy { return () => overlay.scrollStrategies.reposition(); } /** @docs-private */ -export const MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER = { - provide: MD_DATEPICKER_SCROLL_STRATEGY, +export const MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER = { + provide: MAT_DATEPICKER_SCROLL_STRATEGY, deps: [Overlay], - useFactory: MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY, + useFactory: MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY, }; /** * Component used as the content for the datepicker dialog and popup. We use this instead of using - * MdCalendar directly as the content so we can control the initial focus. This also gives us a + * MatCalendar directly as the content so we can control the initial focus. This also gives us a * place to put additional features of the popup that are not part of the calendar itself in the * future. (e.g. confirmation buttons). * @docs-private */ @Component({ moduleId: module.id, - selector: 'md-datepicker-content, mat-datepicker-content', + selector: 'mat-datepicker-content', templateUrl: 'datepicker-content.html', styleUrls: ['datepicker-content.css'], host: { @@ -88,12 +88,11 @@ export const MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER = { encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdDatepickerContent implements AfterContentInit { - datepicker: MdDatepicker; +export class MatDatepickerContent implements AfterContentInit { + datepicker: MatDatepicker; - @ViewChild(MdCalendar) _calendar: MdCalendar; + @ViewChild(MatCalendar) _calendar: MatCalendar; ngAfterContentInit() { this._calendar._focusActiveCell(); @@ -114,18 +113,18 @@ export class MdDatepickerContent implements AfterContentInit { // TODO(mmalerba): We use a component instead of a directive here so the user can use implicit -// template reference variables (e.g. #d vs #d="mdDatepicker"). We can change this to a directive if -// angular adds support for `exportAs: '$implicit'` on directives. +// template reference variables (e.g. #d vs #d="matDatepicker"). We can change this to a directive +// if angular adds support for `exportAs: '$implicit'` on directives. /** Component responsible for managing the datepicker popup/dialog. */ @Component({ moduleId: module.id, - selector: 'md-datepicker, mat-datepicker', + selector: 'mat-datepicker', template: '', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdDatepicker implements OnDestroy { +export class MatDatepicker implements OnDestroy { /** The date to open the calendar to initially. */ @Input() get startAt(): D | null { @@ -170,7 +169,7 @@ export class MdDatepicker implements OnDestroy { opened = false; /** The id for the datepicker calendar. */ - id = `md-datepicker-${datepickerUid++}`; + id = `mat-datepicker-${datepickerUid++}`; /** The currently selected date. */ get _selected(): D | null { return this._validSelected; } @@ -195,10 +194,10 @@ export class MdDatepicker implements OnDestroy { private _popupRef: OverlayRef; /** A reference to the dialog when the calendar is opened as a dialog. */ - private _dialogRef: MdDialogRef | null; + private _dialogRef: MatDialogRef | null; /** A portal containing the calendar for this datepicker. */ - private _calendarPortal: ComponentPortal>; + private _calendarPortal: ComponentPortal>; /** The element that was focused before the datepicker was opened. */ private _focusedElementBeforeOpen: HTMLElement | null = null; @@ -206,16 +205,16 @@ export class MdDatepicker implements OnDestroy { private _inputSubscription = Subscription.EMPTY; /** The input element this datepicker is associated with. */ - _datepickerInput: MdDatepickerInput; + _datepickerInput: MatDatepickerInput; /** Emits when the datepicker is disabled. */ _disabledChange = new Subject(); - constructor(private _dialog: MdDialog, + constructor(private _dialog: MatDialog, private _overlay: Overlay, private _ngZone: NgZone, private _viewContainerRef: ViewContainerRef, - @Inject(MD_DATEPICKER_SCROLL_STRATEGY) private _scrollStrategy, + @Inject(MAT_DATEPICKER_SCROLL_STRATEGY) private _scrollStrategy, @Optional() private _dateAdapter: DateAdapter, @Optional() private _dir: Directionality, @Optional() @Inject(DOCUMENT) private _document: any) { @@ -247,9 +246,9 @@ export class MdDatepicker implements OnDestroy { * Register an input with this datepicker. * @param input The datepicker input to register with this datepicker. */ - _registerInput(input: MdDatepickerInput): void { + _registerInput(input: MatDatepickerInput): void { if (this._datepickerInput) { - throw Error('An MdDatepicker can only be associated with a single input.'); + throw Error('An MatDatepicker can only be associated with a single input.'); } this._datepickerInput = input; this._inputSubscription = @@ -262,7 +261,7 @@ export class MdDatepicker implements OnDestroy { return; } if (!this._datepickerInput) { - throw Error('Attempted to open an MdDatepicker with no associated input.'); + throw Error('Attempted to open an MatDatepicker with no associated input.'); } if (this._document) { this._focusedElementBeforeOpen = this._document.activeElement; @@ -299,7 +298,7 @@ export class MdDatepicker implements OnDestroy { /** Open the calendar as a dialog. */ private _openAsDialog(): void { - this._dialogRef = this._dialog.open(MdDatepickerContent, { + this._dialogRef = this._dialog.open(MatDatepickerContent, { direction: this._dir ? this._dir.value : 'ltr', viewContainerRef: this._viewContainerRef, }); @@ -310,7 +309,7 @@ export class MdDatepicker implements OnDestroy { /** Open the calendar as a popup. */ private _openAsPopup(): void { if (!this._calendarPortal) { - this._calendarPortal = new ComponentPortal(MdDatepickerContent, this._viewContainerRef); + this._calendarPortal = new ComponentPortal(MatDatepickerContent, this._viewContainerRef); } if (!this._popupRef) { @@ -318,7 +317,7 @@ export class MdDatepicker implements OnDestroy { } if (!this._popupRef.hasAttached()) { - let componentRef: ComponentRef> = + let componentRef: ComponentRef> = this._popupRef.attach(this._calendarPortal); componentRef.instance.datepicker = this; diff --git a/src/lib/datepicker/mat-exports.ts b/src/lib/datepicker/mat-exports.ts deleted file mode 100644 index 71e214bcd1f0..000000000000 --- a/src/lib/datepicker/mat-exports.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdCalendar} from './calendar'; -import {MdCalendarBody, MdCalendarCell} from './calendar-body'; -import { - MD_DATEPICKER_SCROLL_STRATEGY, - MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER, - MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY, - MdDatepicker, - MdDatepickerContent, -} from './datepicker'; -import { - MD_DATEPICKER_VALIDATORS, - MD_DATEPICKER_VALUE_ACCESSOR, - MdDatepickerInput, - MdDatepickerInputEvent, -} from './datepicker-input'; -import {MdDatepickerIntl} from './datepicker-intl'; -import {MdDatepickerModule} from './datepicker-module'; -import {MdDatepickerToggle} from './datepicker-toggle'; -import {MdMonthView} from './month-view'; -import {MdYearView} from './year-view'; - - -/* tslint:disable:max-line-length */ -export {MD_DATEPICKER_SCROLL_STRATEGY as MAT_DATEPICKER_SCROLL_STRATEGY}; -export {MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER as MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER}; -export {MD_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY as MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER_FACTORY}; -export {MD_DATEPICKER_VALIDATORS as MAT_DATEPICKER_VALIDATORS}; -export {MD_DATEPICKER_VALUE_ACCESSOR as MAT_DATEPICKER_VALUE_ACCESSOR}; -export {MdCalendar as MatCalendar}; -export {MdCalendarBody as MatCalendarBody}; -export {MdCalendarCell as MatCalendarCell}; -export {MdDatepicker as MatDatepicker}; -export {MdDatepickerContent as MatDatepickerContent}; -export {MdDatepickerInput as MatDatepickerInput}; -export {MdDatepickerInputEvent as MatDatepickerInputEvent}; -export {MdDatepickerIntl as MatDatepickerIntl}; -export {MdDatepickerModule as MatDatepickerModule}; -export {MdDatepickerToggle as MatDatepickerToggle}; -export {MdMonthView as MatMonthView}; -export {MdYearView as MatYearView}; diff --git a/src/lib/datepicker/month-view.spec.ts b/src/lib/datepicker/month-view.spec.ts index 8b97849a85e8..b54cb400d5a5 100644 --- a/src/lib/datepicker/month-view.spec.ts +++ b/src/lib/datepicker/month-view.spec.ts @@ -1,20 +1,20 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {Component} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {MdMonthView} from './month-view'; -import {MdCalendarBody} from './calendar-body'; -import {MdNativeDateModule} from '@angular/material/core'; +import {MatMonthView} from './month-view'; +import {MatCalendarBody} from './calendar-body'; +import {MatNativeDateModule} from '@angular/material/core'; import {JAN, MAR} from '@angular/material/core'; -describe('MdMonthView', () => { +describe('MatMonthView', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MdNativeDateModule, + MatNativeDateModule, ], declarations: [ - MdCalendarBody, - MdMonthView, + MatCalendarBody, + MatMonthView, // Test components. StandardMonthView, @@ -34,7 +34,7 @@ describe('MdMonthView', () => { fixture = TestBed.createComponent(StandardMonthView); fixture.detectChanges(); - let monthViewDebugElement = fixture.debugElement.query(By.directive(MdMonthView)); + let monthViewDebugElement = fixture.debugElement.query(By.directive(MatMonthView)); monthViewNativeElement = monthViewDebugElement.nativeElement; testComponent = fixture.componentInstance; }); @@ -87,7 +87,7 @@ describe('MdMonthView', () => { fixture = TestBed.createComponent(MonthViewWithDateFilter); fixture.detectChanges(); - let monthViewDebugElement = fixture.debugElement.query(By.directive(MdMonthView)); + let monthViewDebugElement = fixture.debugElement.query(By.directive(MatMonthView)); monthViewNativeElement = monthViewDebugElement.nativeElement; testComponent = fixture.componentInstance; }); @@ -102,7 +102,7 @@ describe('MdMonthView', () => { @Component({ - template: ``, + template: ``, }) class StandardMonthView { date = new Date(2017, JAN, 5); @@ -111,7 +111,7 @@ class StandardMonthView { @Component({ - template: `` + template: `` }) class MonthViewWithDateFilter { activeDate = new Date(2017, JAN, 1); diff --git a/src/lib/datepicker/month-view.ts b/src/lib/datepicker/month-view.ts index 6030f1a45de4..4ac52fe8b251 100644 --- a/src/lib/datepicker/month-view.ts +++ b/src/lib/datepicker/month-view.ts @@ -17,11 +17,8 @@ import { Output, ViewEncapsulation, } from '@angular/core'; -import { - DateAdapter, MATERIAL_COMPATIBILITY_MODE, MD_DATE_FORMATS, - MdDateFormats -} from '@angular/material/core'; -import {MdCalendarCell} from './calendar-body'; +import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; +import {MatCalendarCell} from './calendar-body'; import {coerceDateProperty} from './coerce-date-property'; import {createMissingDateImplError} from './datepicker-errors'; @@ -35,14 +32,13 @@ const DAYS_PER_WEEK = 7; */ @Component({ moduleId: module.id, - selector: 'md-month-view', + selector: 'mat-month-view', templateUrl: 'month-view.html', encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdMonthView implements AfterContentInit { +export class MatMonthView implements AfterContentInit { /** * The date to display in this month view (everything other than the month and year is ignored). */ @@ -79,7 +75,7 @@ export class MdMonthView implements AfterContentInit { _monthLabel: string; /** Grid of calendar cells representing the dates of the month. */ - _weeks: MdCalendarCell[][]; + _weeks: MatCalendarCell[][]; /** The number of blank cells in the first row before the 1st of the month. */ _firstWeekOffset: number; @@ -97,12 +93,12 @@ export class MdMonthView implements AfterContentInit { _weekdays: {long: string, narrow: string}[]; constructor(@Optional() public _dateAdapter: DateAdapter, - @Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats) { + @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); } if (!this._dateFormats) { - throw createMissingDateImplError('MD_DATE_FORMATS'); + throw createMissingDateImplError('MAT_DATE_FORMATS'); } const firstDayOfWeek = this._dateAdapter.getFirstDayOfWeek(); @@ -152,7 +148,7 @@ export class MdMonthView implements AfterContentInit { this._createWeekCells(); } - /** Creates MdCalendarCells for the dates in this month. */ + /** Creates MatCalendarCells for the dates in this month. */ private _createWeekCells() { let daysInMonth = this._dateAdapter.getNumDaysInMonth(this.activeDate); let dateNames = this._dateAdapter.getDateNames(); @@ -169,7 +165,7 @@ export class MdMonthView implements AfterContentInit { this.dateFilter(date); let ariaLabel = this._dateAdapter.format(date, this._dateFormats.display.dateA11yLabel); this._weeks[this._weeks.length - 1] - .push(new MdCalendarCell(i + 1, dateNames[i], ariaLabel, enabled)); + .push(new MatCalendarCell(i + 1, dateNames[i], ariaLabel, enabled)); } } diff --git a/src/lib/datepicker/public_api.ts b/src/lib/datepicker/public_api.ts index 89d5bac6d09b..661e07c2aac0 100644 --- a/src/lib/datepicker/public_api.ts +++ b/src/lib/datepicker/public_api.ts @@ -16,4 +16,4 @@ export * from './datepicker-intl'; export * from './datepicker-toggle'; export * from './month-view'; export * from './year-view'; -export * from './mat-exports'; + diff --git a/src/lib/datepicker/year-view.spec.ts b/src/lib/datepicker/year-view.spec.ts index ee68a91e7134..4b44066a7a63 100644 --- a/src/lib/datepicker/year-view.spec.ts +++ b/src/lib/datepicker/year-view.spec.ts @@ -1,20 +1,20 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {Component, ViewChild} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {MdYearView} from './year-view'; -import {MdCalendarBody} from './calendar-body'; -import {MdNativeDateModule} from '@angular/material/core'; +import {MatYearView} from './year-view'; +import {MatCalendarBody} from './calendar-body'; +import {MatNativeDateModule} from '@angular/material/core'; import {FEB, JAN, JUL, JUN, MAR} from '@angular/material/core'; -describe('MdYearView', () => { +describe('MatYearView', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MdNativeDateModule, + MatNativeDateModule, ], declarations: [ - MdCalendarBody, - MdYearView, + MatCalendarBody, + MatYearView, // Test components. StandardYearView, @@ -34,7 +34,7 @@ describe('MdYearView', () => { fixture = TestBed.createComponent(StandardYearView); fixture.detectChanges(); - let yearViewDebugElement = fixture.debugElement.query(By.directive(MdYearView)); + let yearViewDebugElement = fixture.debugElement.query(By.directive(MatYearView)); yearViewNativeElement = yearViewDebugElement.nativeElement; testComponent = fixture.componentInstance; }); @@ -97,7 +97,7 @@ describe('MdYearView', () => { fixture = TestBed.createComponent(YearViewWithDateFilter); fixture.detectChanges(); - let yearViewDebugElement = fixture.debugElement.query(By.directive(MdYearView)); + let yearViewDebugElement = fixture.debugElement.query(By.directive(MatYearView)); yearViewNativeElement = yearViewDebugElement.nativeElement; testComponent = fixture.componentInstance; }); @@ -113,18 +113,18 @@ describe('MdYearView', () => { @Component({ template: ` - `, + `, }) class StandardYearView { date = new Date(2017, JAN, 5); selected = new Date(2017, MAR, 10); - @ViewChild(MdYearView) yearView: MdYearView; + @ViewChild(MatYearView) yearView: MatYearView; } @Component({ - template: `` + template: `` }) class YearViewWithDateFilter { activeDate = new Date(2017, JAN, 1); diff --git a/src/lib/datepicker/year-view.ts b/src/lib/datepicker/year-view.ts index db7699df0491..11f95149e317 100644 --- a/src/lib/datepicker/year-view.ts +++ b/src/lib/datepicker/year-view.ts @@ -17,8 +17,8 @@ import { Output, ViewEncapsulation, } from '@angular/core'; -import {DateAdapter, MD_DATE_FORMATS, MdDateFormats} from '@angular/material/core'; -import {MdCalendarCell} from './calendar-body'; +import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; +import {MatCalendarCell} from './calendar-body'; import {coerceDateProperty} from './coerce-date-property'; import {createMissingDateImplError} from './datepicker-errors'; @@ -29,13 +29,13 @@ import {createMissingDateImplError} from './datepicker-errors'; */ @Component({ moduleId: module.id, - selector: 'md-year-view, mat-year-view', + selector: 'mat-year-view', templateUrl: 'year-view.html', encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdYearView implements AfterContentInit { +export class MatYearView implements AfterContentInit { /** The date to display in this year view (everything other than the year is ignored). */ @Input() get activeDate(): D { return this._activeDate; } @@ -64,7 +64,7 @@ export class MdYearView implements AfterContentInit { @Output() selectedChange = new EventEmitter(); /** Grid of calendar cells representing the months of the year. */ - _months: MdCalendarCell[][]; + _months: MatCalendarCell[][]; /** The label for this year (e.g. "2017"). */ _yearLabel: string; @@ -79,12 +79,12 @@ export class MdYearView implements AfterContentInit { _selectedMonth: number | null; constructor(@Optional() public _dateAdapter: DateAdapter, - @Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats) { + @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); } if (!this._dateFormats) { - throw createMissingDateImplError('MD_DATE_FORMATS'); + throw createMissingDateImplError('MAT_DATE_FORMATS'); } this._activeDate = this._dateAdapter.today(); @@ -124,12 +124,12 @@ export class MdYearView implements AfterContentInit { this._dateAdapter.getMonth(date) : null; } - /** Creates an MdCalendarCell for the given month. */ + /** Creates an MatCalendarCell for the given month. */ private _createCellForMonth(month: number, monthName: string) { let ariaLabel = this._dateAdapter.format( this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, 1), this._dateFormats.display.monthYearA11yLabel); - return new MdCalendarCell( + return new MatCalendarCell( month, monthName.toLocaleUpperCase(), ariaLabel, this._isMonthEnabled(month)); } diff --git a/src/lib/dialog/dialog-config.ts b/src/lib/dialog/dialog-config.ts index a9a53e8826f3..f2dc3e0bd500 100644 --- a/src/lib/dialog/dialog-config.ts +++ b/src/lib/dialog/dialog-config.ts @@ -21,9 +21,9 @@ export interface DialogPosition { } /** - * Configuration for opening a modal dialog with the MdDialog service. + * Configuration for opening a modal dialog with the MatDialog service. */ -export class MdDialogConfig { +export class MatDialogConfig { /** * Where the attached component should live in Angular's *logical* component tree. diff --git a/src/lib/dialog/dialog-container.ts b/src/lib/dialog/dialog-container.ts index 0fc71833df46..372e21ee072a 100644 --- a/src/lib/dialog/dialog-container.ts +++ b/src/lib/dialog/dialog-container.ts @@ -27,7 +27,7 @@ import { TemplatePortal } from '@angular/cdk/portal'; import {FocusTrap, FocusTrapFactory} from '@angular/cdk/a11y'; -import {MdDialogConfig} from './dialog-config'; +import {MatDialogConfig} from './dialog-config'; /** @@ -35,7 +35,7 @@ import {MdDialogConfig} from './dialog-config'; * attached to a DomPortalHost without an origin. * @docs-private */ -export function throwMdDialogContentAlreadyAttachedError() { +export function throwMatDialogContentAlreadyAttachedError() { throw Error('Attempting to attach dialog content after content is already attached'); } @@ -46,7 +46,7 @@ export function throwMdDialogContentAlreadyAttachedError() { */ @Component({ moduleId: module.id, - selector: 'md-dialog-container, mat-dialog-container', + selector: 'mat-dialog-container', templateUrl: 'dialog-container.html', styleUrls: ['dialog.css'], encapsulation: ViewEncapsulation.None, @@ -74,7 +74,7 @@ export function throwMdDialogContentAlreadyAttachedError() { '(@slideDialog.done)': '_onAnimationDone($event)', }, }) -export class MdDialogContainer extends BasePortalHost { +export class MatDialogContainer extends BasePortalHost { /** The portal host inside of this container into which the dialog content will be loaded. */ @ViewChild(PortalHostDirective) _portalHost: PortalHostDirective; @@ -85,7 +85,7 @@ export class MdDialogContainer extends BasePortalHost { private _elementFocusedBeforeDialogWasOpened: HTMLElement | null = null; /** The dialog configuration. */ - _config: MdDialogConfig; + _config: MatDialogConfig; /** State of the dialog animation. */ _state: 'void' | 'enter' | 'exit' = 'enter'; @@ -114,7 +114,7 @@ export class MdDialogContainer extends BasePortalHost { */ attachComponentPortal(portal: ComponentPortal): ComponentRef { if (this._portalHost.hasAttached()) { - throwMdDialogContentAlreadyAttachedError(); + throwMatDialogContentAlreadyAttachedError(); } this._savePreviouslyFocusedElement(); @@ -127,7 +127,7 @@ export class MdDialogContainer extends BasePortalHost { */ attachTemplatePortal(portal: TemplatePortal): EmbeddedViewRef { if (this._portalHost.hasAttached()) { - throwMdDialogContentAlreadyAttachedError(); + throwMatDialogContentAlreadyAttachedError(); } this._savePreviouslyFocusedElement(); diff --git a/src/lib/dialog/dialog-content-directives.ts b/src/lib/dialog/dialog-content-directives.ts index c87e24a86f4b..99dd5c900c02 100644 --- a/src/lib/dialog/dialog-content-directives.ts +++ b/src/lib/dialog/dialog-content-directives.ts @@ -7,8 +7,8 @@ */ import {Directive, Input, OnChanges, OnInit, Optional, SimpleChanges} from '@angular/core'; -import {MdDialogRef} from './dialog-ref'; -import {MdDialogContainer} from './dialog-container'; +import {MatDialogRef} from './dialog-ref'; +import {MatDialogContainer} from './dialog-container'; /** Counter used to generate unique IDs for dialog elements. */ let dialogElementUid = 0; @@ -17,30 +17,26 @@ let dialogElementUid = 0; * Button that will close the current dialog. */ @Directive({ - selector: `button[md-dialog-close], button[mat-dialog-close], - button[mdDialogClose], button[matDialogClose]`, + selector: `button[mat-dialog-close], button[matDialogClose]`, host: { '(click)': 'dialogRef.close(dialogResult)', '[attr.aria-label]': 'ariaLabel', 'type': 'button', // Prevents accidental form submits. } }) -export class MdDialogClose implements OnChanges { +export class MatDialogClose implements OnChanges { /** Screenreader label for the button. */ @Input('aria-label') ariaLabel: string = 'Close dialog'; /** Dialog close input. */ - @Input('md-dialog-close') dialogResult: any; + @Input('mat-dialog-close') dialogResult: any; @Input('matDialogClose') _matDialogClose: any; - @Input('mdDialogClose') _mdDialogClose: any; - @Input('mat-dialog-close') _matDialogCloseResult: any; - constructor(public dialogRef: MdDialogRef) { } + constructor(public dialogRef: MatDialogRef) { } ngOnChanges(changes: SimpleChanges) { - const proxiedChange = changes._matDialogClose || changes._mdDialogClose || - changes._matDialogCloseResult; + const proxiedChange = changes._matDialogClose || changes._matDialogCloseResult; if (proxiedChange) { this.dialogResult = proxiedChange.currentValue; @@ -52,16 +48,16 @@ export class MdDialogClose implements OnChanges { * Title of a dialog element. Stays fixed to the top of the dialog when scrolling. */ @Directive({ - selector: '[md-dialog-title], [mat-dialog-title], [mdDialogTitle], [matDialogTitle]', + selector: '[mat-dialog-title], [matDialogTitle]', host: { 'class': 'mat-dialog-title', '[id]': 'id', }, }) -export class MdDialogTitle implements OnInit { - @Input() id = `md-dialog-title-${dialogElementUid++}`; +export class MatDialogTitle implements OnInit { + @Input() id = `mat-dialog-title-${dialogElementUid++}`; - constructor(@Optional() private _container: MdDialogContainer) { } + constructor(@Optional() private _container: MatDialogContainer) { } ngOnInit() { if (this._container && !this._container._ariaLabelledBy) { @@ -75,11 +71,10 @@ export class MdDialogTitle implements OnInit { * Scrollable content container of a dialog. */ @Directive({ - selector: `[md-dialog-content], md-dialog-content, [mat-dialog-content], mat-dialog-content, - [mdDialogContent], [matDialogContent]`, + selector: `[mat-dialog-content], mat-dialog-content, [matDialogContent]`, host: {'class': 'mat-dialog-content'} }) -export class MdDialogContent { } +export class MatDialogContent { } /** @@ -87,8 +82,7 @@ export class MdDialogContent { } * Stays fixed to the bottom when scrolling. */ @Directive({ - selector: `[md-dialog-actions], md-dialog-actions, [mat-dialog-actions], mat-dialog-actions, - [mdDialogActions], [matDialogActions]`, + selector: `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]`, host: {'class': 'mat-dialog-actions'} }) -export class MdDialogActions { } +export class MatDialogActions { } diff --git a/src/lib/dialog/dialog-module.ts b/src/lib/dialog/dialog-module.ts index c587faf42df2..ef6e7a236080 100644 --- a/src/lib/dialog/dialog-module.ts +++ b/src/lib/dialog/dialog-module.ts @@ -11,14 +11,14 @@ import {CommonModule} from '@angular/common'; import {OverlayModule} from '@angular/cdk/overlay'; import {PortalModule} from '@angular/cdk/portal'; import {A11yModule} from '@angular/cdk/a11y'; -import {MdCommonModule} from '@angular/material/core'; -import {MdDialog, MD_DIALOG_SCROLL_STRATEGY_PROVIDER} from './dialog'; -import {MdDialogContainer} from './dialog-container'; +import {MatCommonModule} from '@angular/material/core'; +import {MatDialog, MAT_DIALOG_SCROLL_STRATEGY_PROVIDER} from './dialog'; +import {MatDialogContainer} from './dialog-container'; import { - MdDialogClose, - MdDialogContent, - MdDialogTitle, - MdDialogActions + MatDialogClose, + MatDialogContent, + MatDialogTitle, + MatDialogActions } from './dialog-content-directives'; @@ -28,27 +28,27 @@ import { OverlayModule, PortalModule, A11yModule, - MdCommonModule, + MatCommonModule, ], exports: [ - MdDialogContainer, - MdDialogClose, - MdDialogTitle, - MdDialogContent, - MdDialogActions, - MdCommonModule, + MatDialogContainer, + MatDialogClose, + MatDialogTitle, + MatDialogContent, + MatDialogActions, + MatCommonModule, ], declarations: [ - MdDialogContainer, - MdDialogClose, - MdDialogTitle, - MdDialogActions, - MdDialogContent, + MatDialogContainer, + MatDialogClose, + MatDialogTitle, + MatDialogActions, + MatDialogContent, ], providers: [ - MdDialog, - MD_DIALOG_SCROLL_STRATEGY_PROVIDER, + MatDialog, + MAT_DIALOG_SCROLL_STRATEGY_PROVIDER, ], - entryComponents: [MdDialogContainer], + entryComponents: [MatDialogContainer], }) -export class MdDialogModule {} +export class MatDialogModule {} diff --git a/src/lib/dialog/dialog-ref.ts b/src/lib/dialog/dialog-ref.ts index d4839bb486d0..98f1c5914ca6 100644 --- a/src/lib/dialog/dialog-ref.ts +++ b/src/lib/dialog/dialog-ref.ts @@ -11,7 +11,7 @@ import {filter, first, RxChain} from '@angular/cdk/rxjs'; import {DialogPosition} from './dialog-config'; import {Observable} from 'rxjs/Observable'; import {Subject} from 'rxjs/Subject'; -import {MdDialogContainer} from './dialog-container'; +import {MatDialogContainer} from './dialog-container'; // TODO(jelbourn): resizing @@ -20,9 +20,9 @@ import {MdDialogContainer} from './dialog-container'; let uniqueId = 0; /** - * Reference to a dialog opened via the MdDialog service. + * Reference to a dialog opened via the MatDialog service. */ -export class MdDialogRef { +export class MatDialogRef { /** The instance of component opened into the dialog. */ componentInstance: T; @@ -43,8 +43,8 @@ export class MdDialogRef { constructor( private _overlayRef: OverlayRef, - private _containerInstance: MdDialogContainer, - public readonly id: string = `md-dialog-${uniqueId++}`) { + private _containerInstance: MatDialogContainer, + public readonly id: string = `mat-dialog-${uniqueId++}`) { // Emit when opening animation completes RxChain.from(_containerInstance._animationStateChanged) diff --git a/src/lib/dialog/dialog.md b/src/lib/dialog/dialog.md index f2d42df5f1cd..c20447c35b56 100644 --- a/src/lib/dialog/dialog.md +++ b/src/lib/dialog/dialog.md @@ -1,10 +1,10 @@ -The `MdDialog` service can be used to open modal dialogs with Material Design styling and +The `MatDialog` service can be used to open modal dialogs with Material Design styling and animations. A dialog is opened by calling the `open` method with a component to be loaded and an optional -config object. The `open` method will return an instance of `MdDialogRef`: +config object. The `open` method will return an instance of `MatDialogRef`: ```ts let dialogRef = dialog.open(UserProfileComponent, { @@ -13,7 +13,7 @@ let dialogRef = dialog.open(UserProfileComponent, { }); ``` -The `MdDialogRef` provides a handle on the opened dialog. It can be used to close the dialog and to +The `MatDialogRef` provides a handle on the opened dialog. It can be used to close the dialog and to receive notification when the dialog has been closed. ```ts @@ -24,14 +24,14 @@ dialogRef.afterClosed().subscribe(result => { dialogRef.close('Pizza!'); ``` -Components created via `MdDialog` can _inject_ `MdDialogRef` and use it to close the dialog +Components created via `MatDialog` can _inject_ `MatDialogRef` and use it to close the dialog in which they are contained. When closing, an optional result value can be provided. This result value is forwarded as the result of the `afterClosed` promise. ```ts @Component({/* ... */}) export class YourDialog { - constructor(public dialogRef: MdDialogRef) { } + constructor(public dialogRef: MatDialogRef) { } closeDialog() { this.dialogRef.close('Pizza!'); @@ -48,18 +48,18 @@ let dialogRef = dialog.open(YourDialog, { }); ``` -To access the data in your dialog component, you have to use the MD_DIALOG_DATA injection token: +To access the data in your dialog component, you have to use the MAT_DIALOG_DATA injection token: ```ts import {Component, Inject} from '@angular/core'; -import {MD_DIALOG_DATA} from '@angular/material'; +import {MAT_DIALOG_DATA} from '@angular/material'; @Component({ selector: 'your-dialog', template: 'passed in {{ data.name }}', }) export class YourDialog { - constructor(@Inject(MD_DIALOG_DATA) public data: any) { } + constructor(@Inject(MAT_DIALOG_DATA) public data: any) { } } ``` @@ -70,20 +70,20 @@ Several directives are available to make it easier to structure your dialog cont | Name | Description | |-----------------------|---------------------------------------------------------------------------------------------------------------| -| `md-dialog-title` | \[Attr] Dialog title, applied to a heading element (e.g., `

`, `

`) | -| `` | Primary scrollable content of the dialog | -| `` | Container for action buttons at the bottom of the dialog | -| `md-dialog-close` | \[Attr] Added to a ` +

Delete all

+Are you sure? + + - -
+ + ``` Once a dialog opens, the dialog will automatically focus the first tabbable element. @@ -91,14 +91,14 @@ Once a dialog opens, the dialog will automatically focus the first tabbable elem You can control which elements are tab stops with the `tabindex` attribute ```html - + ``` ### AOT Compilation -Due to the dynamic nature of the `MdDialog`, and its usage of `ViewContainerRef#createComponent()` +Due to the dynamic nature of the `MatDialog`, and its usage of `ViewContainerRef#createComponent()` to create the component on the fly, the AOT compiler will not know to create the proper `ComponentFactory` for your dialog component by default. @@ -109,7 +109,7 @@ that the AOT compiler knows to create the `ComponentFactory` for it. @NgModule({ imports: [ // ... - MdDialogModule + MatDialogModule ], declarations: [ @@ -129,10 +129,10 @@ export class AppModule() {} ### Accessibility By default, each dialog has `role="dialog"` on the root element. The role can be changed to -`alertdialog` via the `MdDialogConfig` when opening. +`alertdialog` via the `MatDialogConfig` when opening. The `aria-label`, `aria-labelledby`, and `aria-describedby` attributes can all be set to the -dialog element via the `MdDialogConfig` as well. Each dialog should typically have a label +dialog element via the `MatDialogConfig` as well. Each dialog should typically have a label set via `aria-label` or `aria-labelledby`. #### Focus management diff --git a/src/lib/dialog/dialog.spec.ts b/src/lib/dialog/dialog.spec.ts index 70c09652081d..dcd1489553d2 100644 --- a/src/lib/dialog/dialog.spec.ts +++ b/src/lib/dialog/dialog.spec.ts @@ -1,36 +1,36 @@ import { - inject, async, + ComponentFixture, fakeAsync, flushMicrotasks, - ComponentFixture, + inject, TestBed, tick, } from '@angular/core/testing'; import { - NgModule, + ChangeDetectionStrategy, Component, Directive, - ViewChild, - ViewContainerRef, - Injector, Inject, - ChangeDetectionStrategy, - TemplateRef + Injector, + NgModule, + TemplateRef, + ViewChild, + ViewContainerRef } from '@angular/core'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {Location} from '@angular/common'; import {SpyLocation} from '@angular/common/testing'; -import {MdDialogContainer} from './dialog-container'; +import {MatDialogContainer} from './dialog-container'; import {OverlayContainer} from '@angular/cdk/overlay'; import {ESCAPE} from '@angular/cdk/keycodes'; import {dispatchKeyboardEvent} from '@angular/cdk/testing'; -import {MdDialogModule, MdDialogRef, MdDialog, MD_DIALOG_DATA} from './index'; +import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from './index'; -describe('MdDialog', () => { - let dialog: MdDialog; +describe('MatDialog', () => { + let dialog: MatDialog; let overlayContainerElement: HTMLElement; let testViewContainerRef: ViewContainerRef; @@ -39,7 +39,7 @@ describe('MdDialog', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdDialogModule, DialogTestModule], + imports: [MatDialogModule, DialogTestModule], providers: [ {provide: OverlayContainer, useFactory: () => { overlayContainerElement = document.createElement('div'); @@ -52,7 +52,7 @@ describe('MdDialog', () => { TestBed.compileComponents(); })); - beforeEach(inject([MdDialog, Location], (d: MdDialog, l: Location) => { + beforeEach(inject([MatDialog, Location], (d: MatDialog, l: Location) => { dialog = d; mockLocation = l as SpyLocation; })); @@ -76,7 +76,7 @@ describe('MdDialog', () => { expect(dialogRef.componentInstance.dialogRef).toBe(dialogRef); viewContainerFixture.detectChanges(); - let dialogContainerElement = overlayContainerElement.querySelector('md-dialog-container')!; + let dialogContainerElement = overlayContainerElement.querySelector('mat-dialog-container')!; expect(dialogContainerElement.getAttribute('role')).toBe('dialog'); }); @@ -96,7 +96,7 @@ describe('MdDialog', () => { viewContainerFixture.detectChanges(); - let dialogContainerElement = overlayContainerElement.querySelector('md-dialog-container')!; + let dialogContainerElement = overlayContainerElement.querySelector('mat-dialog-container')!; expect(dialogContainerElement.getAttribute('role')).toBe('dialog'); dialogRef.close(); @@ -142,7 +142,7 @@ describe('MdDialog', () => { expect(dialogRef.componentInstance.dialogRef).toBe(dialogRef); viewContainerFixture.detectChanges(); - let dialogContainerElement = overlayContainerElement.querySelector('md-dialog-container')!; + let dialogContainerElement = overlayContainerElement.querySelector('mat-dialog-container')!; expect(dialogContainerElement.getAttribute('role')).toBe('dialog'); }); @@ -151,7 +151,7 @@ describe('MdDialog', () => { viewContainerFixture.detectChanges(); - let dialogContainerElement = overlayContainerElement.querySelector('md-dialog-container')!; + let dialogContainerElement = overlayContainerElement.querySelector('mat-dialog-container')!; expect(dialogContainerElement.getAttribute('role')).toBe('alertdialog'); }); @@ -160,7 +160,7 @@ describe('MdDialog', () => { viewContainerFixture.detectChanges(); - let dialogContainerElement = overlayContainerElement.querySelector('md-dialog-container')!; + let dialogContainerElement = overlayContainerElement.querySelector('mat-dialog-container')!; expect(dialogContainerElement.getAttribute('aria-describedby')).toBe('description-element'); }); @@ -174,7 +174,7 @@ describe('MdDialog', () => { viewContainerFixture.whenStable().then(() => { expect(afterCloseCallback).toHaveBeenCalledWith('Charmander'); - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeNull(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeNull(); }); })); @@ -183,7 +183,7 @@ describe('MdDialog', () => { // beforeClose should emit before dialog container is destroyed const beforeCloseHandler = jasmine.createSpy('beforeClose callback').and.callFake(() => { - expect(overlayContainerElement.querySelector('md-dialog-container')) + expect(overlayContainerElement.querySelector('mat-dialog-container')) .not.toBeNull('dialog container exists when beforeClose is called'); }); @@ -193,7 +193,7 @@ describe('MdDialog', () => { viewContainerFixture.whenStable().then(() => { expect(beforeCloseHandler).toHaveBeenCalledWith('Bulbasaurus'); - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeNull(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeNull(); }); })); @@ -206,7 +206,7 @@ describe('MdDialog', () => { viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeNull(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeNull(); }); })); @@ -223,7 +223,7 @@ describe('MdDialog', () => { onPushFixture.detectChanges(); flushMicrotasks(); - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length) + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length) .toBe(1, 'Expected one open dialog.'); dialogRef.close(); @@ -231,7 +231,7 @@ describe('MdDialog', () => { onPushFixture.detectChanges(); tick(500); - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length) + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length) .toBe(0, 'Expected no open dialogs.'); })); @@ -248,7 +248,7 @@ describe('MdDialog', () => { viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeFalsy(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeFalsy(); }); })); @@ -438,20 +438,20 @@ describe('MdDialog', () => { dialog.open(PizzaMsg); dialog.open(PizzaMsg); - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length).toBe(3); + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length).toBe(3); dialog.closeAll(); viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length).toBe(0); + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length).toBe(0); }); })); it('should set the proper animation states', () => { let dialogRef = dialog.open(PizzaMsg, { viewContainerRef: testViewContainerRef }); - let dialogContainer: MdDialogContainer = - viewContainerFixture.debugElement.query(By.directive(MdDialogContainer)).componentInstance; + let dialogContainer: MatDialogContainer = + viewContainerFixture.debugElement.query(By.directive(MatDialogContainer)).componentInstance; expect(dialogContainer._state).toBe('enter'); @@ -464,13 +464,13 @@ describe('MdDialog', () => { dialog.open(PizzaMsg); dialog.open(PizzaMsg); - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length).toBe(2); + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length).toBe(2); mockLocation.simulateUrlPop(''); viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length).toBe(0); + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length).toBe(0); }); })); @@ -478,13 +478,13 @@ describe('MdDialog', () => { dialog.open(PizzaMsg); dialog.open(PizzaMsg); - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length).toBe(2); + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length).toBe(2); mockLocation.simulateHashChange(''); viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { - expect(overlayContainerElement.querySelectorAll('md-dialog-container').length).toBe(0); + expect(overlayContainerElement.querySelectorAll('mat-dialog-container').length).toBe(0); }); })); @@ -583,7 +583,7 @@ describe('MdDialog', () => { let backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement; backdrop.click(); - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeTruthy(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeTruthy(); }); it('should prevent closing via the escape key', () => { @@ -595,7 +595,7 @@ describe('MdDialog', () => { viewContainerFixture.detectChanges(); dispatchKeyboardEvent(document, 'keydown', ESCAPE); - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeTruthy(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeTruthy(); }); it('should allow for the disableClose option to be updated while open', async(() => { @@ -609,14 +609,14 @@ describe('MdDialog', () => { let backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement; backdrop.click(); - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeTruthy(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeTruthy(); dialogRef.disableClose = false; backdrop.click(); viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeFalsy(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeFalsy(); }); })); }); @@ -768,13 +768,13 @@ describe('MdDialog', () => { flushMicrotasks(); expect(document.activeElement.tagName) - .toBe('MD-DIALOG-CONTAINER', 'Expected dialog container to be focused.'); + .toBe('MAT-DIALOG-CONTAINER', 'Expected dialog container to be focused.'); })); }); describe('dialog content elements', () => { - let dialogRef: MdDialogRef; + let dialogRef: MatDialogRef; beforeEach(() => { dialogRef = dialog.open(ContentElementDialog); @@ -784,7 +784,7 @@ describe('MdDialog', () => { it('should close the dialog when clicking on the close button', async(() => { expect(overlayContainerElement.querySelectorAll('.mat-dialog-container').length).toBe(1); - (overlayContainerElement.querySelector('button[md-dialog-close]') as HTMLElement).click(); + (overlayContainerElement.querySelector('button[mat-dialog-close]') as HTMLElement).click(); viewContainerFixture.detectChanges(); viewContainerFixture.whenStable().then(() => { @@ -792,16 +792,16 @@ describe('MdDialog', () => { }); })); - it('should not close the dialog if [md-dialog-close] is applied on a non-button node', () => { + it('should not close the dialog if [mat-dialog-close] is applied on a non-button node', () => { expect(overlayContainerElement.querySelectorAll('.mat-dialog-container').length).toBe(1); - (overlayContainerElement.querySelector('div[md-dialog-close]') as HTMLElement).click(); + (overlayContainerElement.querySelector('div[mat-dialog-close]') as HTMLElement).click(); expect(overlayContainerElement.querySelectorAll('.mat-dialog-container').length).toBe(1); }); it('should allow for a user-specified aria-label on the close button', async(() => { - let button = overlayContainerElement.querySelector('button[md-dialog-close]')!; + let button = overlayContainerElement.querySelector('button[mat-dialog-close]')!; dialogRef.componentInstance.closeButtonAriaLabel = 'Best close button ever'; viewContainerFixture.detectChanges(); @@ -812,12 +812,12 @@ describe('MdDialog', () => { })); it('should override the "type" attribute of the close button', () => { - let button = overlayContainerElement.querySelector('button[md-dialog-close]')!; + let button = overlayContainerElement.querySelector('button[mat-dialog-close]')!; expect(button.getAttribute('type')).toBe('button'); }); - it('should return the [md-dialog-close] result when clicking on the close button', async(() => { + it('should return the [mat-dialog-close] result when clicking the close button', async(() => { let afterCloseCallback = jasmine.createSpy('afterClose callback'); dialogRef.afterClosed().subscribe(afterCloseCallback); @@ -830,8 +830,8 @@ describe('MdDialog', () => { })); it('should set the aria-labelledby attribute to the id of the title', async(() => { - let title = overlayContainerElement.querySelector('[md-dialog-title]')!; - let container = overlayContainerElement.querySelector('md-dialog-container')!; + let title = overlayContainerElement.querySelector('[mat-dialog-title]')!; + let container = overlayContainerElement.querySelector('mat-dialog-container')!; viewContainerFixture.whenStable().then(() => { expect(title.id).toBeTruthy('Expected title element to have an id.'); @@ -843,16 +843,16 @@ describe('MdDialog', () => { }); }); -describe('MdDialog with a parent MdDialog', () => { - let parentDialog: MdDialog; - let childDialog: MdDialog; +describe('MatDialog with a parent MatDialog', () => { + let parentDialog: MatDialog; + let childDialog: MatDialog; let overlayContainerElement: HTMLElement; - let fixture: ComponentFixture; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdDialogModule, DialogTestModule], - declarations: [ComponentThatProvidesMdDialog], + imports: [MatDialogModule, DialogTestModule], + declarations: [ComponentThatProvidesMatDialog], providers: [ {provide: OverlayContainer, useFactory: () => { overlayContainerElement = document.createElement('div'); @@ -865,10 +865,10 @@ describe('MdDialog with a parent MdDialog', () => { TestBed.compileComponents(); })); - beforeEach(inject([MdDialog], (d: MdDialog) => { + beforeEach(inject([MatDialog], (d: MatDialog) => { parentDialog = d; - fixture = TestBed.createComponent(ComponentThatProvidesMdDialog); + fixture = TestBed.createComponent(ComponentThatProvidesMatDialog); childDialog = fixture.componentInstance.dialog; fixture.detectChanges(); })); @@ -877,7 +877,7 @@ describe('MdDialog with a parent MdDialog', () => { overlayContainerElement.innerHTML = ''; }); - it('should close dialogs opened by a parent when calling closeAll on a child MdDialog', + it('should close dialogs opened by a parent when calling closeAll on a child MatDialog', async(() => { parentDialog.open(PizzaMsg); fixture.detectChanges(); @@ -890,11 +890,11 @@ describe('MdDialog with a parent MdDialog', () => { fixture.whenStable().then(() => { expect(overlayContainerElement.textContent!.trim()) - .toBe('', 'Expected closeAll on child MdDialog to close dialog opened by parent'); + .toBe('', 'Expected closeAll on child MatDialog to close dialog opened by parent'); }); })); - it('should close dialogs opened by a child when calling closeAll on a parent MdDialog', + it('should close dialogs opened by a child when calling closeAll on a parent MatDialog', async(() => { childDialog.open(PizzaMsg); fixture.detectChanges(); @@ -907,7 +907,7 @@ describe('MdDialog with a parent MdDialog', () => { fixture.whenStable().then(() => { expect(overlayContainerElement.textContent!.trim()) - .toBe('', 'Expected closeAll on parent MdDialog to close dialog opened by child'); + .toBe('', 'Expected closeAll on parent MatDialog to close dialog opened by child'); }); })); @@ -918,7 +918,7 @@ describe('MdDialog with a parent MdDialog', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - expect(overlayContainerElement.querySelector('md-dialog-container')).toBeNull(); + expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeNull(); }); })); }); @@ -956,11 +956,11 @@ class ComponentWithChildViewContainer { }) class ComponentWithTemplateRef { localValue: string; - dialogRef: MdDialogRef; + dialogRef: MatDialogRef; @ViewChild(TemplateRef) templateRef: TemplateRef; - setDialogRef(dialogRef: MdDialogRef): string { + setDialogRef(dialogRef: MatDialogRef): string { this.dialogRef = dialogRef; return ''; } @@ -969,19 +969,19 @@ class ComponentWithTemplateRef { /** Simple component for testing ComponentPortal. */ @Component({template: '

Pizza

'}) class PizzaMsg { - constructor(public dialogRef: MdDialogRef, + constructor(public dialogRef: MatDialogRef, public dialogInjector: Injector) {} } @Component({ template: ` -

This is the title

- Lorem ipsum dolor sit amet. - - - -
Should not close
-
+

This is the title

+ Lorem ipsum dolor sit amet. + + + +
Should not close
+
` }) class ContentElementDialog { @@ -990,16 +990,16 @@ class ContentElementDialog { @Component({ template: '', - providers: [MdDialog] + providers: [MatDialog] }) -class ComponentThatProvidesMdDialog { - constructor(public dialog: MdDialog) {} +class ComponentThatProvidesMatDialog { + constructor(public dialog: MatDialog) {} } /** Simple component for testing ComponentPortal. */ @Component({template: ''}) class DialogWithInjectedData { - constructor(@Inject(MD_DIALOG_DATA) public data: any) { } + constructor(@Inject(MAT_DIALOG_DATA) public data: any) { } } @Component({template: '

Pasta

'}) @@ -1019,7 +1019,7 @@ const TEST_DIRECTIVES = [ ]; @NgModule({ - imports: [MdDialogModule, NoopAnimationsModule], + imports: [MatDialogModule, NoopAnimationsModule], exports: TEST_DIRECTIVES, declarations: TEST_DIRECTIVES, entryComponents: [ diff --git a/src/lib/dialog/dialog.ts b/src/lib/dialog/dialog.ts index 0fa02226f787..7bbb1793cbb2 100644 --- a/src/lib/dialog/dialog.ts +++ b/src/lib/dialog/dialog.ts @@ -31,29 +31,29 @@ import {extendObject} from '@angular/material/core'; import {Observable} from 'rxjs/Observable'; import {defer} from 'rxjs/observable/defer'; import {Subject} from 'rxjs/Subject'; -import {MdDialogConfig} from './dialog-config'; -import {MdDialogContainer} from './dialog-container'; -import {MdDialogRef} from './dialog-ref'; +import {MatDialogConfig} from './dialog-config'; +import {MatDialogContainer} from './dialog-container'; +import {MatDialogRef} from './dialog-ref'; -export const MD_DIALOG_DATA = new InjectionToken('MdDialogData'); +export const MAT_DIALOG_DATA = new InjectionToken('MatDialogData'); /** Injection token that determines the scroll handling while the dialog is open. */ -export const MD_DIALOG_SCROLL_STRATEGY = - new InjectionToken<() => ScrollStrategy>('md-dialog-scroll-strategy'); +export const MAT_DIALOG_SCROLL_STRATEGY = + new InjectionToken<() => ScrollStrategy>('mat-dialog-scroll-strategy'); /** @docs-private */ -export function MD_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): +export function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => BlockScrollStrategy { return () => overlay.scrollStrategies.block(); } /** @docs-private */ -export const MD_DIALOG_SCROLL_STRATEGY_PROVIDER = { - provide: MD_DIALOG_SCROLL_STRATEGY, +export const MAT_DIALOG_SCROLL_STRATEGY_PROVIDER = { + provide: MAT_DIALOG_SCROLL_STRATEGY, deps: [Overlay], - useFactory: MD_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY, + useFactory: MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY, }; @@ -61,19 +61,19 @@ export const MD_DIALOG_SCROLL_STRATEGY_PROVIDER = { * Service to open Material Design modal dialogs. */ @Injectable() -export class MdDialog { - private _openDialogsAtThisLevel: MdDialogRef[] = []; +export class MatDialog { + private _openDialogsAtThisLevel: MatDialogRef[] = []; private _afterAllClosedAtThisLevel = new Subject(); - private _afterOpenAtThisLevel = new Subject>(); + private _afterOpenAtThisLevel = new Subject>(); private _boundKeydown = this._handleKeydown.bind(this); /** Keeps track of the currently-open dialogs. */ - get openDialogs(): MdDialogRef[] { + get openDialogs(): MatDialogRef[] { return this._parentDialog ? this._parentDialog.openDialogs : this._openDialogsAtThisLevel; } /** Stream that emits when a dialog has been opened. */ - get afterOpen(): Subject> { + get afterOpen(): Subject> { return this._parentDialog ? this._parentDialog.afterOpen : this._afterOpenAtThisLevel; } @@ -94,8 +94,8 @@ export class MdDialog { private _overlay: Overlay, private _injector: Injector, @Optional() location: Location, - @Inject(MD_DIALOG_SCROLL_STRATEGY) private _scrollStrategy, - @Optional() @SkipSelf() private _parentDialog: MdDialog) { + @Inject(MAT_DIALOG_SCROLL_STRATEGY) private _scrollStrategy, + @Optional() @SkipSelf() private _parentDialog: MatDialog) { // Close all of the dialogs when the user goes forwards/backwards in history or when the // location hash changes. Note that this usually doesn't include clicking on links (unless @@ -113,7 +113,7 @@ export class MdDialog { * @returns Reference to the newly-opened dialog. */ open(componentOrTemplateRef: ComponentType | TemplateRef, - config?: MdDialogConfig): MdDialogRef { + config?: MatDialogConfig): MatDialogRef { const inProgressDialog = this.openDialogs.find(dialog => dialog._isAnimating()); @@ -163,7 +163,7 @@ export class MdDialog { * Finds an open dialog by its id. * @param id ID to use when looking up the dialog. */ - getDialogById(id: string): MdDialogRef | undefined { + getDialogById(id: string): MatDialogRef | undefined { return this.openDialogs.find(dialog => dialog.id === id); } @@ -172,7 +172,7 @@ export class MdDialog { * @param config The dialog configuration. * @returns A promise resolving to the OverlayRef for the created overlay. */ - private _createOverlay(config: MdDialogConfig): OverlayRef { + private _createOverlay(config: MatDialogConfig): OverlayRef { const overlayState = this._getOverlayState(config); return this._overlay.create(overlayState); } @@ -182,7 +182,7 @@ export class MdDialog { * @param dialogConfig The dialog configuration. * @returns The overlay configuration. */ - private _getOverlayState(dialogConfig: MdDialogConfig): OverlayConfig { + private _getOverlayState(dialogConfig: MatDialogConfig): OverlayConfig { const state = new OverlayConfig({ positionStrategy: this._overlay.position().global(), scrollStrategy: this._scrollStrategy(), @@ -199,37 +199,37 @@ export class MdDialog { } /** - * Attaches an MdDialogContainer to a dialog's already-created overlay. + * Attaches an MatDialogContainer to a dialog's already-created overlay. * @param overlay Reference to the dialog's underlying overlay. * @param config The dialog configuration. * @returns A promise resolving to a ComponentRef for the attached container. */ - private _attachDialogContainer(overlay: OverlayRef, config: MdDialogConfig): MdDialogContainer { - let containerPortal = new ComponentPortal(MdDialogContainer, config.viewContainerRef); - let containerRef: ComponentRef = overlay.attach(containerPortal); + private _attachDialogContainer(overlay: OverlayRef, config: MatDialogConfig): MatDialogContainer { + let containerPortal = new ComponentPortal(MatDialogContainer, config.viewContainerRef); + let containerRef: ComponentRef = overlay.attach(containerPortal); containerRef.instance._config = config; return containerRef.instance; } /** - * Attaches the user-provided component to the already-created MdDialogContainer. + * Attaches the user-provided component to the already-created MatDialogContainer. * @param componentOrTemplateRef The type of component being loaded into the dialog, * or a TemplateRef to instantiate as the content. - * @param dialogContainer Reference to the wrapping MdDialogContainer. + * @param dialogContainer Reference to the wrapping MatDialogContainer. * @param overlayRef Reference to the overlay in which the dialog resides. * @param config The dialog configuration. - * @returns A promise resolving to the MdDialogRef that should be returned to the user. + * @returns A promise resolving to the MatDialogRef that should be returned to the user. */ private _attachDialogContent( componentOrTemplateRef: ComponentType | TemplateRef, - dialogContainer: MdDialogContainer, + dialogContainer: MatDialogContainer, overlayRef: OverlayRef, - config: MdDialogConfig): MdDialogRef { + config: MatDialogConfig): MatDialogRef { // Create a reference to the dialog we're creating in order to give the user a handle // to modify and close it. - const dialogRef = new MdDialogRef(overlayRef, dialogContainer, config.id); + const dialogRef = new MatDialogRef(overlayRef, dialogContainer, config.id); // When the dialog backdrop is clicked, we want to close it. if (config.hasBackdrop) { @@ -267,16 +267,16 @@ export class MdDialog { * @returns The custom injector that can be used inside the dialog. */ private _createInjector( - config: MdDialogConfig, - dialogRef: MdDialogRef, - dialogContainer: MdDialogContainer): PortalInjector { + config: MatDialogConfig, + dialogRef: MatDialogRef, + dialogContainer: MatDialogContainer): PortalInjector { const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector; const injectionTokens = new WeakMap(); - injectionTokens.set(MdDialogRef, dialogRef); - injectionTokens.set(MdDialogContainer, dialogContainer); - injectionTokens.set(MD_DIALOG_DATA, config.data); + injectionTokens.set(MatDialogRef, dialogRef); + injectionTokens.set(MatDialogContainer, dialogContainer); + injectionTokens.set(MAT_DIALOG_DATA, config.data); return new PortalInjector(userInjector || this._injector, injectionTokens); } @@ -285,7 +285,7 @@ export class MdDialog { * Removes a dialog from the array of open dialogs. * @param dialogRef Dialog to be removed. */ - private _removeOpenDialog(dialogRef: MdDialogRef) { + private _removeOpenDialog(dialogRef: MatDialogRef) { const index = this.openDialogs.indexOf(dialogRef); if (index > -1) { @@ -318,6 +318,6 @@ export class MdDialog { * @param config Config to be modified. * @returns The new configuration object. */ -function _applyConfigDefaults(config?: MdDialogConfig): MdDialogConfig { - return extendObject(new MdDialogConfig(), config); +function _applyConfigDefaults(config?: MatDialogConfig): MatDialogConfig { + return extendObject(new MatDialogConfig(), config); } diff --git a/src/lib/dialog/mat-exports.ts b/src/lib/dialog/mat-exports.ts deleted file mode 100644 index ce9f2daf51c3..000000000000 --- a/src/lib/dialog/mat-exports.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_DIALOG_DATA, - MD_DIALOG_SCROLL_STRATEGY, - MD_DIALOG_SCROLL_STRATEGY_PROVIDER, - MD_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY, - MdDialog, -} from './dialog'; -import {MdDialogConfig} from './dialog-config'; -import {MdDialogContainer} from './dialog-container'; -import { - MdDialogActions, - MdDialogClose, - MdDialogContent, - MdDialogTitle, -} from './dialog-content-directives'; -import {MdDialogModule} from './dialog-module'; -import {MdDialogRef} from './dialog-ref'; - - -export {MD_DIALOG_DATA as MAT_DIALOG_DATA}; -export {MD_DIALOG_SCROLL_STRATEGY as MAT_DIALOG_SCROLL_STRATEGY}; -export {MD_DIALOG_SCROLL_STRATEGY_PROVIDER as MAT_DIALOG_SCROLL_STRATEGY_PROVIDER}; -export {MD_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY as MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY}; -export {MdDialog as MatDialog}; -export {MdDialogActions as MatDialogActions}; -export {MdDialogClose as MatDialogClose}; -export {MdDialogConfig as MatDialogConfig}; -export {MdDialogContainer as MatDialogContainer}; -export {MdDialogContent as MatDialogContent}; -export {MdDialogModule as MatDialogModule}; -export {MdDialogRef as MatDialogRef}; -export {MdDialogTitle as MatDialogTitle}; diff --git a/src/lib/dialog/public_api.ts b/src/lib/dialog/public_api.ts index 040eb5aff84f..39d91ce6af2e 100644 --- a/src/lib/dialog/public_api.ts +++ b/src/lib/dialog/public_api.ts @@ -12,4 +12,4 @@ export * from './dialog-container'; export * from './dialog-content-directives'; export * from './dialog-config'; export * from './dialog-ref'; -export * from './mat-exports'; + diff --git a/src/lib/expansion/accordion.spec.ts b/src/lib/expansion/accordion.spec.ts index f29dd5e5ab5e..f1f1e6047788 100644 --- a/src/lib/expansion/accordion.spec.ts +++ b/src/lib/expansion/accordion.spec.ts @@ -2,7 +2,7 @@ import {async, TestBed} from '@angular/core/testing'; import {Component} from '@angular/core'; import {By} from '@angular/platform-browser'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; -import {MdExpansionModule} from './index'; +import {MatExpansionModule} from './index'; describe('CdkAccordion', () => { @@ -10,7 +10,7 @@ describe('CdkAccordion', () => { TestBed.configureTestingModule({ imports: [ BrowserAnimationsModule, - MdExpansionModule + MatExpansionModule ], declarations: [ SetOfItems @@ -49,16 +49,16 @@ describe('CdkAccordion', () => { @Component({template: ` - - - Summary + + + Summary

Content

-
- - Summary + + + Summary

Content

-
-
`}) + + `}) class SetOfItems { multi: boolean = false; firstPanelExpanded: boolean = false; diff --git a/src/lib/expansion/accordion.ts b/src/lib/expansion/accordion.ts index 8439c30d83af..17c72e0a2831 100644 --- a/src/lib/expansion/accordion.ts +++ b/src/lib/expansion/accordion.ts @@ -9,8 +9,8 @@ import {Directive, Input} from '@angular/core'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; -/** MdAccordion's display modes. */ -export type MdAccordionDisplayMode = 'default' | 'flat'; +/** MatAccordion's display modes. */ +export type MatAccordionDisplayMode = 'default' | 'flat'; /** Unique ID counter */ let nextId = 0; @@ -43,16 +43,16 @@ export class CdkAccordion { * flat - no spacing is placed around expanded panels, showing all panels at the same * elevation. */ - @Input() displayMode: MdAccordionDisplayMode = 'default'; + @Input() displayMode: MatAccordionDisplayMode = 'default'; } /** * Directive for a Material Design Accordion. */ @Directive({ - selector: 'mat-accordion, md-accordion', + selector: 'mat-accordion', host: { class: 'mat-accordion' } }) -export class MdAccordion extends CdkAccordion {} +export class MatAccordion extends CdkAccordion {} diff --git a/src/lib/expansion/expansion-module.ts b/src/lib/expansion/expansion-module.ts index 80119c2c93cf..156b774476ac 100644 --- a/src/lib/expansion/expansion-module.ts +++ b/src/lib/expansion/expansion-module.ts @@ -8,37 +8,37 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {CompatibilityModule, UNIQUE_SELECTION_DISPATCHER_PROVIDER} from '@angular/material/core'; +import {UNIQUE_SELECTION_DISPATCHER_PROVIDER} from '@angular/material/core'; import {A11yModule} from '@angular/cdk/a11y'; -import {CdkAccordion, MdAccordion} from './accordion'; -import {MdExpansionPanel, MdExpansionPanelActionRow} from './expansion-panel'; +import {CdkAccordion, MatAccordion} from './accordion'; +import {MatExpansionPanel, MatExpansionPanelActionRow} from './expansion-panel'; import { - MdExpansionPanelDescription, - MdExpansionPanelHeader, - MdExpansionPanelTitle, + MatExpansionPanelDescription, + MatExpansionPanelHeader, + MatExpansionPanelTitle, } from './expansion-panel-header'; @NgModule({ - imports: [CompatibilityModule, CommonModule, A11yModule], + imports: [CommonModule, A11yModule], exports: [ CdkAccordion, - MdAccordion, - MdExpansionPanel, - MdExpansionPanelActionRow, - MdExpansionPanelHeader, - MdExpansionPanelTitle, - MdExpansionPanelDescription + MatAccordion, + MatExpansionPanel, + MatExpansionPanelActionRow, + MatExpansionPanelHeader, + MatExpansionPanelTitle, + MatExpansionPanelDescription ], declarations: [ CdkAccordion, - MdAccordion, - MdExpansionPanel, - MdExpansionPanelActionRow, - MdExpansionPanelHeader, - MdExpansionPanelTitle, - MdExpansionPanelDescription + MatAccordion, + MatExpansionPanel, + MatExpansionPanelActionRow, + MatExpansionPanelHeader, + MatExpansionPanelTitle, + MatExpansionPanelDescription ], providers: [UNIQUE_SELECTION_DISPATCHER_PROVIDER] }) -export class MdExpansionModule {} +export class MatExpansionModule {} diff --git a/src/lib/expansion/expansion-panel-header.html b/src/lib/expansion/expansion-panel-header.html index 20373a9cb3ef..41c329965859 100644 --- a/src/lib/expansion/expansion-panel-header.html +++ b/src/lib/expansion/expansion-panel-header.html @@ -1,6 +1,6 @@ - - + + component. + * component. * - * This component corresponds to the header element of an . + * This component corresponds to the header element of an . * * Please refer to README.md for examples on how to use it. */ @Component({ moduleId: module.id, - selector: 'md-expansion-panel-header, mat-expansion-panel-header', + selector: 'mat-expansion-panel-header', styleUrls: ['./expansion-panel-header.css'], templateUrl: './expansion-panel-header.html', encapsulation: ViewEncapsulation.None, @@ -81,12 +81,12 @@ import {EXPANSION_PANEL_ANIMATION_TIMING, MdExpansionPanel} from './expansion-pa ]), ], }) -export class MdExpansionPanelHeader implements OnDestroy { +export class MatExpansionPanelHeader implements OnDestroy { private _parentChangeSubscription = Subscription.EMPTY; constructor( renderer: Renderer2, - @Host() public panel: MdExpansionPanel, + @Host() public panel: MatExpansionPanel, private _element: ElementRef, private _focusMonitor: FocusMonitor, private _changeDetectorRef: ChangeDetectorRef) { @@ -157,27 +157,27 @@ export class MdExpansionPanelHeader implements OnDestroy { } /** - * directive. + * directive. * - * This direction is to be used inside of the MdExpansionPanelHeader component. + * This direction is to be used inside of the MatExpansionPanelHeader component. */ @Directive({ - selector: 'md-panel-description, mat-panel-description', + selector: 'mat-panel-description', host : { class: 'mat-expansion-panel-header-description' } }) -export class MdExpansionPanelDescription {} +export class MatExpansionPanelDescription {} /** - * directive. + * directive. * - * This direction is to be used inside of the MdExpansionPanelHeader component. + * This direction is to be used inside of the MatExpansionPanelHeader component. */ @Directive({ - selector: 'md-panel-title, mat-panel-title', + selector: 'mat-panel-title', host : { class: 'mat-expansion-panel-header-title' } }) -export class MdExpansionPanelTitle {} +export class MatExpansionPanelTitle {} diff --git a/src/lib/expansion/expansion-panel.html b/src/lib/expansion/expansion-panel.html index 751e5176a0ab..93e8f6f8e47e 100644 --- a/src/lib/expansion/expansion-panel.html +++ b/src/lib/expansion/expansion-panel.html @@ -1,8 +1,8 @@ - +
- +
diff --git a/src/lib/expansion/expansion-panel.ts b/src/lib/expansion/expansion-panel.ts index 5ed09e2fcf79..cf4a209f4c9d 100644 --- a/src/lib/expansion/expansion-panel.ts +++ b/src/lib/expansion/expansion-panel.ts @@ -23,29 +23,29 @@ import { } from '@angular/core'; import {CanDisable, mixinDisabled, UniqueSelectionDispatcher} from '@angular/material/core'; import {Subject} from 'rxjs/Subject'; -import {MdAccordion} from './accordion'; +import {MatAccordion} from './accordion'; import {AccordionItem} from './accordion-item'; -// Boilerplate for applying mixins to MdExpansionPanel. +// Boilerplate for applying mixins to MatExpansionPanel. /** @docs-private */ -export class MdExpansionPanelBase extends AccordionItem { - constructor(accordion: MdAccordion, +export class MatExpansionPanelBase extends AccordionItem { + constructor(accordion: MatAccordion, _changeDetectorRef: ChangeDetectorRef, _uniqueSelectionDispatcher: UniqueSelectionDispatcher) { super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher); } } -export const _MdExpansionPanelMixinBase = mixinDisabled(MdExpansionPanelBase); +export const _MatExpansionPanelMixinBase = mixinDisabled(MatExpansionPanelBase); -/** MdExpansionPanel's states. */ -export type MdExpansionPanelState = 'expanded' | 'collapsed'; +/** MatExpansionPanel's states. */ +export type MatExpansionPanelState = 'expanded' | 'collapsed'; /** Time and timing curve for expansion panel animations. */ export const EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2,1)'; /** - * component. + * component. * * This component can be used as a single element to show expandable content, or as one of * multiple children of an element with the CdkAccordion directive attached. @@ -55,7 +55,7 @@ export const EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2, @Component({ moduleId: module.id, styleUrls: ['./expansion-panel.css'], - selector: 'md-expansion-panel, mat-expansion-panel', + selector: 'mat-expansion-panel', templateUrl: './expansion-panel.html', encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, @@ -67,7 +67,7 @@ export const EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2, '[class.mat-expansion-panel-spacing]': '_hasSpacing()', }, providers: [ - {provide: AccordionItem, useExisting: forwardRef(() => MdExpansionPanel)} + {provide: AccordionItem, useExisting: forwardRef(() => MatExpansionPanel)} ], animations: [ trigger('bodyExpansion', [ @@ -77,7 +77,7 @@ export const EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2, ]), ], }) -export class MdExpansionPanel extends _MdExpansionPanelMixinBase +export class MatExpansionPanel extends _MatExpansionPanelMixinBase implements CanDisable, OnChanges, OnDestroy { /** Whether the toggle indicator should be hidden. */ @Input() hideToggle: boolean = false; @@ -85,7 +85,7 @@ export class MdExpansionPanel extends _MdExpansionPanelMixinBase /** Stream that emits for changes in `@Input` properties. */ _inputChanges = new Subject(); - constructor(@Optional() @Host() accordion: MdAccordion, + constructor(@Optional() @Host() accordion: MatAccordion, _changeDetectorRef: ChangeDetectorRef, _uniqueSelectionDispatcher: UniqueSelectionDispatcher) { super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher); @@ -109,7 +109,7 @@ export class MdExpansionPanel extends _MdExpansionPanelMixinBase } /** Gets the expanded state string. */ - _getExpandedState(): MdExpansionPanelState { + _getExpandedState(): MatExpansionPanelState { return this.expanded ? 'expanded' : 'collapsed'; } @@ -123,9 +123,9 @@ export class MdExpansionPanel extends _MdExpansionPanelMixinBase } @Directive({ - selector: 'mat-action-row, md-action-row', + selector: 'mat-action-row', host: { class: 'mat-action-row' } }) -export class MdExpansionPanelActionRow {} +export class MatExpansionPanelActionRow {} diff --git a/src/lib/expansion/expansion.md b/src/lib/expansion/expansion.md index 14ad08aaacee..e52b1f069d2d 100644 --- a/src/lib/expansion/expansion.md +++ b/src/lib/expansion/expansion.md @@ -1,4 +1,4 @@ -`` provides an expandable details-summary view. +`` provides an expandable details-summary view. @@ -8,9 +8,9 @@ Each expansion-panel must include a header and may optionally include an action #### Header -The `` shows a summary of the panel content and acts +The `` shows a summary of the panel content and acts as the control for expanding and collapsing. This header may optionally contain an -`` and an ``, which format the content of the +`` and an ``, which format the content of the header to align with Material Design specifications. By default, the expansion-panel header includes a toggle icon at the end of the @@ -18,19 +18,19 @@ header to indicate the expansion state. This icon can be hidden via the `hideToggle` property. ```html - - - + + + This is the expansion title - - + + This is a summary of the content - - +
+

This is the primary content of the panel.

- + ``` #### Action bar @@ -39,17 +39,17 @@ Actions may optionally be included at the bottom of the panel, visible only when is in its expanded state. ```html - - + + This is the expansion title - +

This is the primary content of the panel.

- - - -
+ + + + ``` #### Disabling a panel @@ -58,14 +58,14 @@ Expansion panels can be disabled using the `disabled` attribute. A disabled expa be toggled by the user, but can still be manipulated using programmatically. ```html - - + + This is the expansion title - - + + This is a summary of the content - - + + ``` @@ -76,27 +76,27 @@ expansions state to be set independently of each other. When `multi="false"` (de panel can be expanded at a given time: ```html - + - - + + This is the expansion 1 title - + This the expansion 1 content - + - - + + This is the expansion 2 title - + This the expansion 2 content - + - + ``` ### Accessibility diff --git a/src/lib/expansion/expansion.spec.ts b/src/lib/expansion/expansion.spec.ts index 5c0033a326e4..53a0cae367c4 100644 --- a/src/lib/expansion/expansion.spec.ts +++ b/src/lib/expansion/expansion.spec.ts @@ -2,15 +2,15 @@ import {async, TestBed, fakeAsync, tick, ComponentFixture} from '@angular/core/t import {Component, ViewChild} from '@angular/core'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdExpansionModule, MdExpansionPanel} from './index'; +import {MatExpansionModule, MatExpansionPanel} from './index'; -describe('MdExpansionPanel', () => { +describe('MatExpansionPanel', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ NoopAnimationsModule, - MdExpansionModule + MatExpansionModule ], declarations: [ PanelWithContent, @@ -82,7 +82,7 @@ describe('MdExpansionPanel', () => { let fixture = TestBed.createComponent(PanelWithCustomMargin); fixture.detectChanges(); - let panel = fixture.debugElement.query(By.css('md-expansion-panel')); + let panel = fixture.debugElement.query(By.css('mat-expansion-panel')); let styles = getComputedStyle(panel.nativeElement); expect(panel.componentInstance._hasSpacing()).toBe(false); @@ -146,8 +146,8 @@ describe('MdExpansionPanel', () => { beforeEach(() => { fixture = TestBed.createComponent(PanelWithContent); fixture.detectChanges(); - panel = fixture.debugElement.query(By.css('md-expansion-panel')).nativeElement; - header = fixture.debugElement.query(By.css('md-expansion-panel-header')).nativeElement; + panel = fixture.debugElement.query(By.css('mat-expansion-panel')).nativeElement; + header = fixture.debugElement.query(By.css('mat-expansion-panel-header')).nativeElement; }); it('should toggle the aria-disabled attribute on the header', () => { @@ -202,15 +202,15 @@ describe('MdExpansionPanel', () => { @Component({ template: ` - - Panel Title + Panel Title

Some content

-
` + ` }) class PanelWithContent { expanded = false; @@ -218,21 +218,21 @@ class PanelWithContent { disabled = false; openCallback = jasmine.createSpy('openCallback'); closeCallback = jasmine.createSpy('closeCallback'); - @ViewChild(MdExpansionPanel) panel: MdExpansionPanel; + @ViewChild(MatExpansionPanel) panel: MatExpansionPanel; } @Component({ styles: [ - `md-expansion-panel { + `mat-expansion-panel { margin: 13px 37px; }` ], template: ` - + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores officia, aliquam dicta corrupti maxime voluptate accusamus impedit atque incidunt pariatur. - ` + ` }) class PanelWithCustomMargin { expanded: boolean = false; diff --git a/src/lib/expansion/mat-exports.ts b/src/lib/expansion/mat-exports.ts deleted file mode 100644 index be1bed20796f..000000000000 --- a/src/lib/expansion/mat-exports.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdAccordion, MdAccordionDisplayMode} from './accordion'; -import {MdExpansionModule} from './expansion-module'; -import { - MdExpansionPanel, - MdExpansionPanelActionRow, - MdExpansionPanelState, -} from './expansion-panel'; -import { - MdExpansionPanelDescription, - MdExpansionPanelHeader, - MdExpansionPanelTitle, -} from './expansion-panel-header'; - - -export {MdAccordion as MatAccordion}; -export {MdAccordionDisplayMode as MatAccordionDisplayMode}; -export {MdExpansionModule as MatExpansionModule}; -export {MdExpansionPanel as MatExpansionPanel}; -export {MdExpansionPanelActionRow as MatExpansionPanelActionRow}; -export {MdExpansionPanelDescription as MatExpansionPanelDescription}; -export {MdExpansionPanelHeader as MatExpansionPanelHeader}; -export {MdExpansionPanelState as MatExpansionPanelState}; -export {MdExpansionPanelTitle as MatExpansionPanelTitle}; diff --git a/src/lib/expansion/public_api.ts b/src/lib/expansion/public_api.ts index d2e7b1224299..919561d57005 100644 --- a/src/lib/expansion/public_api.ts +++ b/src/lib/expansion/public_api.ts @@ -9,19 +9,19 @@ export * from './expansion-module'; export { CdkAccordion, - MdAccordion, - MdAccordionDisplayMode + MatAccordion, + MatAccordionDisplayMode } from './accordion'; export {AccordionItem} from './accordion-item'; export { - MdExpansionPanel, - MdExpansionPanelState, - MdExpansionPanelActionRow + MatExpansionPanel, + MatExpansionPanelState, + MatExpansionPanelActionRow } from './expansion-panel'; export { - MdExpansionPanelHeader, - MdExpansionPanelDescription, - MdExpansionPanelTitle + MatExpansionPanelHeader, + MatExpansionPanelDescription, + MatExpansionPanelTitle } from './expansion-panel-header'; -export * from './mat-exports'; + diff --git a/src/lib/form-field/error.ts b/src/lib/form-field/error.ts index 40d5bb1762ec..21c659d5dd55 100644 --- a/src/lib/form-field/error.ts +++ b/src/lib/form-field/error.ts @@ -14,13 +14,13 @@ let nextUniqueId = 0; /** Single error message to be shown underneath the form field. */ @Directive({ - selector: 'md-error, mat-error', + selector: 'mat-error', host: { 'class': 'mat-error', 'role': 'alert', '[attr.id]': 'id', } }) -export class MdError { +export class MatError { @Input() id: string = `mat-error-${nextUniqueId++}`; } diff --git a/src/lib/form-field/form-field-control.ts b/src/lib/form-field/form-field-control.ts index 8bbf3b6cf12c..f2f006421a44 100644 --- a/src/lib/form-field/form-field-control.ts +++ b/src/lib/form-field/form-field-control.ts @@ -10,13 +10,13 @@ import {Observable} from 'rxjs/Observable'; import {NgControl} from '@angular/forms'; -/** An interface which allows a control to work inside of a `MdFormField`. */ -export abstract class MdFormFieldControl { +/** An interface which allows a control to work inside of a `MatFormField`. */ +export abstract class MatFormFieldControl { /** The value of the control. */ value: T; /** - * Stream that emits whenever the state of the control changes such that the parent `MdFormField` + * Stream that emits whenever the state of the control changes such that the parent `MatFormField` * needs to run change detection. */ readonly stateChanges: Observable; @@ -36,7 +36,7 @@ export abstract class MdFormFieldControl { /** Whether the control is empty. */ readonly empty: boolean; - /** Whether the `MdFormField` label should try to float. */ + /** Whether the `MatFormField` label should try to float. */ readonly shouldPlaceholderFloat: boolean; /** Whether the control is required. */ @@ -49,7 +49,7 @@ export abstract class MdFormFieldControl { readonly errorState: boolean; /** - * An optional name for the control type that can be used to distinguish `md-form-field` elements + * An optional name for the control type that can be used to distinguish `mat-form-field` elements * based on their control type. The form field will add a class, * `mat-form-field-type-{{controlType}}` to its root element. */ diff --git a/src/lib/form-field/form-field-errors.ts b/src/lib/form-field/form-field-errors.ts index 008393915e4c..21869d7fc271 100644 --- a/src/lib/form-field/form-field-errors.ts +++ b/src/lib/form-field/form-field-errors.ts @@ -7,17 +7,17 @@ */ /** @docs-private */ -export function getMdFormFieldPlaceholderConflictError(): Error { +export function getMatFormFieldPlaceholderConflictError(): Error { return Error('Placeholder attribute and child element were both specified.'); } /** @docs-private */ -export function getMdFormFieldDuplicatedHintError(align: string): Error { +export function getMatFormFieldDuplicatedHintError(align: string): Error { return Error(`A hint was already declared for 'align="${align}"'.`); } /** @docs-private */ -export function getMdFormFieldMissingControlError(): Error { - return Error('md-form-field must contain a MdFormFieldControl. ' + - 'Did you forget to add mdInput to the native input or textarea element?'); +export function getMatFormFieldMissingControlError(): Error { + return Error('mat-form-field must contain a MatFormFieldControl. ' + + 'Did you forget to add matInput to the native input or textarea element?'); } diff --git a/src/lib/form-field/form-field-module.ts b/src/lib/form-field/form-field-module.ts index 46f51cd12a8e..eecad6ddb328 100644 --- a/src/lib/form-field/form-field-module.ts +++ b/src/lib/form-field/form-field-module.ts @@ -9,34 +9,34 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import {PlatformModule} from '@angular/cdk/platform'; -import {MdError} from './error'; -import {MdFormField} from './form-field'; -import {MdHint} from './hint'; -import {MdPlaceholder} from './placeholder'; -import {MdPrefix} from './prefix'; -import {MdSuffix} from './suffix'; +import {MatError} from './error'; +import {MatFormField} from './form-field'; +import {MatHint} from './hint'; +import {MatPlaceholder} from './placeholder'; +import {MatPrefix} from './prefix'; +import {MatSuffix} from './suffix'; @NgModule({ declarations: [ - MdError, - MdHint, - MdFormField, - MdPlaceholder, - MdPrefix, - MdSuffix, + MatError, + MatHint, + MatFormField, + MatPlaceholder, + MatPrefix, + MatSuffix, ], imports: [ CommonModule, PlatformModule, ], exports: [ - MdError, - MdHint, - MdFormField, - MdPlaceholder, - MdPrefix, - MdSuffix, + MatError, + MatHint, + MatFormField, + MatPlaceholder, + MatPrefix, + MatSuffix, ], }) -export class MdFormFieldModule {} +export class MatFormFieldModule {} diff --git a/src/lib/form-field/form-field.html b/src/lib/form-field/form-field.html index 4bf46aec7a8a..3ab526ce0e7e 100644 --- a/src/lib/form-field/form-field.html +++ b/src/lib/form-field/form-field.html @@ -2,7 +2,7 @@
- +
@@ -20,7 +20,7 @@ [class.mat-warn]="color == 'warn'" #placeholder *ngIf="_hasPlaceholder()"> - + {{_control.placeholder}}
- +
@@ -45,16 +45,16 @@
- +
{{hintLabel}}
- +
- +
diff --git a/src/lib/form-field/form-field.scss b/src/lib/form-field/form-field.scss index 33de45151f6e..a3e5bbf295d2 100644 --- a/src/lib/form-field/form-field.scss +++ b/src/lib/form-field/form-field.scss @@ -118,7 +118,7 @@ $mat-form-field-underline-height: 1px !default; // Pseudo-class for Chrome and Safari auto-fill to move the placeholder to the floating position. // This is necessary because these browsers do not actually fire any events when a form auto-fill is -// occurring. Once the autofill is committed, a change event happen and the regular md-form-field +// occurring. Once the autofill is committed, a change event happen and the regular mat-form-field // classes take over to fulfill this behaviour. .mat-form-field-autofill-control:-webkit-autofill + .mat-form-field-placeholder-wrapper .mat-form-field-placeholder { diff --git a/src/lib/form-field/form-field.ts b/src/lib/form-field/form-field.ts index 8d320f2f7fbc..75c2991d6b5f 100644 --- a/src/lib/form-field/form-field.ts +++ b/src/lib/form-field/form-field.ts @@ -28,21 +28,21 @@ import { } from '@angular/core'; import { FloatPlaceholderType, - MD_PLACEHOLDER_GLOBAL_OPTIONS, + MAT_PLACEHOLDER_GLOBAL_OPTIONS, PlaceholderOptions, } from '@angular/material/core'; import {fromEvent} from 'rxjs/observable/fromEvent'; -import {MdError} from './error'; -import {MdFormFieldControl} from './form-field-control'; +import {MatError} from './error'; +import {MatFormFieldControl} from './form-field-control'; import { - getMdFormFieldDuplicatedHintError, - getMdFormFieldMissingControlError, - getMdFormFieldPlaceholderConflictError, + getMatFormFieldDuplicatedHintError, + getMatFormFieldMissingControlError, + getMatFormFieldPlaceholderConflictError, } from './form-field-errors'; -import {MdHint} from './hint'; -import {MdPlaceholder} from './placeholder'; -import {MdPrefix} from './prefix'; -import {MdSuffix} from './suffix'; +import {MatHint} from './hint'; +import {MatPlaceholder} from './placeholder'; +import {MatPrefix} from './prefix'; +import {MatSuffix} from './suffix'; let nextUniqueId = 0; @@ -52,11 +52,11 @@ let nextUniqueId = 0; @Component({ moduleId: module.id, // TODO(mmalerba): the input-container selectors and classes are deprecated and will be removed. - selector: 'md-input-container, mat-input-container, md-form-field, mat-form-field', + selector: 'mat-input-container, mat-form-field', templateUrl: 'form-field.html', - // MdInput is a directive and can't have styles, so we need to include its styles here. - // The MdInput styles are fairly minimal so it shouldn't be a big deal for people who aren't using - // MdInput. + // MatInput is a directive and can't have styles, so we need to include its styles here. + // The MatInput styles are fairly minimal so it shouldn't be a big deal for people who + // aren't using MatInput. styleUrls: ['form-field.css', '../input/input.css'], animations: [ // TODO(mmalerba): Use angular animations for placeholder animation as well. @@ -91,7 +91,7 @@ let nextUniqueId = 0; changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdFormField implements AfterViewInit, AfterContentInit, AfterContentChecked { +export class MatFormField implements AfterViewInit, AfterContentInit, AfterContentChecked { private _placeholderOptions: PlaceholderOptions; /** Color of the form field underline, based on the theme. */ @@ -121,7 +121,7 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten /** Whether the placeholder can float or not. */ get _canPlaceholderFloat() { return this._floatPlaceholder !== 'never'; } - /** State of the md-hint and md-error animations. */ + /** State of the mat-hint and mat-error animations. */ _subscriptAnimationState: string = ''; /** Text for the form field hint. */ @@ -134,7 +134,7 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten private _hintLabel = ''; // Unique id for the hint label. - _hintLabelId: string = `md-hint-${nextUniqueId++}`; + _hintLabelId: string = `mat-hint-${nextUniqueId++}`; /** Whether the placeholder should always float, never float or float as the user types. */ @Input() @@ -151,18 +151,18 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten @ViewChild('underline') underlineRef: ElementRef; @ViewChild('connectionContainer') _connectionContainerRef: ElementRef; @ViewChild('placeholder') private _placeholder: ElementRef; - @ContentChild(MdFormFieldControl) _control: MdFormFieldControl; - @ContentChild(MdPlaceholder) _placeholderChild: MdPlaceholder; - @ContentChildren(MdError) _errorChildren: QueryList; - @ContentChildren(MdHint) _hintChildren: QueryList; - @ContentChildren(MdPrefix) _prefixChildren: QueryList; - @ContentChildren(MdSuffix) _suffixChildren: QueryList; + @ContentChild(MatFormFieldControl) _control: MatFormFieldControl; + @ContentChild(MatPlaceholder) _placeholderChild: MatPlaceholder; + @ContentChildren(MatError) _errorChildren: QueryList; + @ContentChildren(MatHint) _hintChildren: QueryList; + @ContentChildren(MatPrefix) _prefixChildren: QueryList; + @ContentChildren(MatSuffix) _suffixChildren: QueryList; constructor( public _elementRef: ElementRef, private _renderer: Renderer2, private _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(MD_PLACEHOLDER_GLOBAL_OPTIONS) placeholderOptions: PlaceholderOptions) { + @Optional() @Inject(MAT_PLACEHOLDER_GLOBAL_OPTIONS) placeholderOptions: PlaceholderOptions) { this._placeholderOptions = placeholderOptions ? placeholderOptions : {}; this.floatPlaceholder = this._placeholderOptions.float || 'auto'; } @@ -244,11 +244,11 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten /** * Ensure that there is only one placeholder (either `placeholder` attribute on the child control - * or child element with the `md-placeholder` directive). + * or child element with the `mat-placeholder` directive). */ private _validatePlaceholders() { if (this._control.placeholder && this._placeholderChild) { - throw getMdFormFieldPlaceholderConflictError(); + throw getMatFormFieldPlaceholderConflictError(); } } @@ -259,22 +259,22 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten } /** - * Ensure that there is a maximum of one of each `` alignment specified, with the + * Ensure that there is a maximum of one of each `` alignment specified, with the * attribute being considered as `align="start"`. */ private _validateHints() { if (this._hintChildren) { - let startHint: MdHint; - let endHint: MdHint; - this._hintChildren.forEach((hint: MdHint) => { + let startHint: MatHint; + let endHint: MatHint; + this._hintChildren.forEach((hint: MatHint) => { if (hint.align == 'start') { if (startHint || this.hintLabel) { - throw getMdFormFieldDuplicatedHintError('start'); + throw getMatFormFieldDuplicatedHintError('start'); } startHint = hint; } else if (hint.align == 'end') { if (endHint) { - throw getMdFormFieldDuplicatedHintError('end'); + throw getMatFormFieldDuplicatedHintError('end'); } endHint = hint; } @@ -306,7 +306,7 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten ids.push(endHint.id); } } else if (this._errorChildren) { - ids = this._errorChildren.map(mdError => mdError.id); + ids = this._errorChildren.map(error => error.id); } this._control.setDescribedByIds(ids); @@ -316,7 +316,7 @@ export class MdFormField implements AfterViewInit, AfterContentInit, AfterConten /** Throws an error if the form field's control is missing. */ protected _validateControlChild() { if (!this._control) { - throw getMdFormFieldMissingControlError(); + throw getMatFormFieldMissingControlError(); } } } diff --git a/src/lib/form-field/hint.ts b/src/lib/form-field/hint.ts index 3a5e21857aeb..8b0079d84f0e 100644 --- a/src/lib/form-field/hint.ts +++ b/src/lib/form-field/hint.ts @@ -14,7 +14,7 @@ let nextUniqueId = 0; /** Hint text to be shown underneath the form field control. */ @Directive({ - selector: 'md-hint, mat-hint', + selector: 'mat-hint', host: { 'class': 'mat-hint', '[class.mat-right]': 'align == "end"', @@ -23,7 +23,7 @@ let nextUniqueId = 0; '[attr.align]': 'null', } }) -export class MdHint { +export class MatHint { /** Whether to align the hint label at the start or end of the line. */ @Input() align: 'start' | 'end' = 'start'; diff --git a/src/lib/form-field/mat-exports.ts b/src/lib/form-field/mat-exports.ts deleted file mode 100644 index 788c9b4452d2..000000000000 --- a/src/lib/form-field/mat-exports.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MdFormField, -} from './form-field'; -import {MdError} from './error'; -import {MdHint} from './hint'; -import {MdFormFieldModule} from './form-field-module'; -import {MdPrefix} from './prefix'; -import {MdSuffix} from './suffix'; -import {MdPlaceholder} from './placeholder'; -import {MdFormFieldControl} from './form-field-control'; - - -export {MdFormFieldModule as MatFormFieldModule}; -export {MdError as MatError}; -export {MdFormField as MatFormField}; -export {MdFormFieldControl as MatFormFieldControl}; -export {MdHint as MatHint}; -export {MdPlaceholder as MatPlaceholder}; -export {MdPrefix as MatPrefix}; -export {MdSuffix as MatSuffix}; diff --git a/src/lib/form-field/placeholder.ts b/src/lib/form-field/placeholder.ts index 260a4b8fef91..12473820043d 100644 --- a/src/lib/form-field/placeholder.ts +++ b/src/lib/form-field/placeholder.ts @@ -9,8 +9,8 @@ import {Directive} from '@angular/core'; -/** The floating placeholder for an `MdFormField`. */ +/** The floating placeholder for an `MatFormField`. */ @Directive({ - selector: 'md-placeholder, mat-placeholder' + selector: 'mat-placeholder' }) -export class MdPlaceholder {} +export class MatPlaceholder {} diff --git a/src/lib/form-field/prefix.ts b/src/lib/form-field/prefix.ts index 3ac184b14331..8bb192de1864 100644 --- a/src/lib/form-field/prefix.ts +++ b/src/lib/form-field/prefix.ts @@ -11,6 +11,6 @@ import {Directive} from '@angular/core'; /** Prefix to be placed the the front of the form field. */ @Directive({ - selector: '[mdPrefix], [matPrefix]', + selector: '[matPrefix]', }) -export class MdPrefix {} +export class MatPrefix {} diff --git a/src/lib/form-field/public_api.ts b/src/lib/form-field/public_api.ts index 4edf1173bbe0..0ef3a74f0654 100644 --- a/src/lib/form-field/public_api.ts +++ b/src/lib/form-field/public_api.ts @@ -15,4 +15,4 @@ export * from './hint'; export * from './placeholder'; export * from './prefix'; export * from './suffix'; -export * from './mat-exports'; + diff --git a/src/lib/form-field/suffix.ts b/src/lib/form-field/suffix.ts index be70eec03959..8f707f93a996 100644 --- a/src/lib/form-field/suffix.ts +++ b/src/lib/form-field/suffix.ts @@ -11,6 +11,6 @@ import {Directive} from '@angular/core'; /** Suffix to be placed at the end of the form field. */ @Directive({ - selector: '[mdSuffix], [matSuffix]', + selector: '[matSuffix]', }) -export class MdSuffix {} +export class MatSuffix {} diff --git a/src/lib/grid-list/grid-list-module.ts b/src/lib/grid-list/grid-list-module.ts index d57f8b80b5b0..f8206cd014cb 100644 --- a/src/lib/grid-list/grid-list-module.ts +++ b/src/lib/grid-list/grid-list-module.ts @@ -7,33 +7,33 @@ */ import {NgModule} from '@angular/core'; -import {MdLineModule, MdCommonModule} from '@angular/material/core'; +import {MatLineModule, MatCommonModule} from '@angular/material/core'; import { - MdGridTile, MdGridTileText, MdGridTileFooterCssMatStyler, - MdGridTileHeaderCssMatStyler, MdGridAvatarCssMatStyler + MatGridTile, MatGridTileText, MatGridTileFooterCssMatStyler, + MatGridTileHeaderCssMatStyler, MatGridAvatarCssMatStyler } from './grid-tile'; -import {MdGridList} from './grid-list'; +import {MatGridList} from './grid-list'; @NgModule({ - imports: [MdLineModule, MdCommonModule], + imports: [MatLineModule, MatCommonModule], exports: [ - MdGridList, - MdGridTile, - MdGridTileText, - MdLineModule, - MdCommonModule, - MdGridTileHeaderCssMatStyler, - MdGridTileFooterCssMatStyler, - MdGridAvatarCssMatStyler + MatGridList, + MatGridTile, + MatGridTileText, + MatLineModule, + MatCommonModule, + MatGridTileHeaderCssMatStyler, + MatGridTileFooterCssMatStyler, + MatGridAvatarCssMatStyler ], declarations: [ - MdGridList, - MdGridTile, - MdGridTileText, - MdGridTileHeaderCssMatStyler, - MdGridTileFooterCssMatStyler, - MdGridAvatarCssMatStyler + MatGridList, + MatGridTile, + MatGridTileText, + MatGridTileHeaderCssMatStyler, + MatGridTileFooterCssMatStyler, + MatGridAvatarCssMatStyler ], }) -export class MdGridListModule {} +export class MatGridListModule {} diff --git a/src/lib/grid-list/grid-list.md b/src/lib/grid-list/grid-list.md index 6cc3bde1ed73..0142c9d0a77e 100644 --- a/src/lib/grid-list/grid-list.md +++ b/src/lib/grid-list/grid-list.md @@ -1,11 +1,11 @@ -`md-grid-list` is a two-dimensional list view that arranges cells into grid-based layout. +`mat-grid-list` is a two-dimensional list view that arranges cells into grid-based layout. See Material Design spec [here](https://www.google.com/design/spec/components/grid-lists.html). ### Setting the number of columns -An `md-grid-list` must specify a `cols` attribute which sets the number of columns in the grid. The +An `mat-grid-list` must specify a `cols` attribute which sets the number of columns in the grid. The number of rows will be automatically determined based on the number of columns and the number of items. @@ -32,15 +32,15 @@ units are specified, `px` units are assumed. By default the gutter size is `1px` ### Adding tiles that span multiple rows or columns -It is possible to set the rowspan and colspan of each `md-grid-tile` individually, using the +It is possible to set the rowspan and colspan of each `mat-grid-tile` individually, using the `rowspan` and `colspan` properties. If not set, they both default to `1`. The `colspan` must not -exceed the number of `cols` in the `md-grid-list`. There is no such restriction on the `rowspan` +exceed the number of `cols` in the `mat-grid-list`. There is no such restriction on the `rowspan` however, more rows will simply be added for it the tile to fill. ### Tile headers and footers -A header and footer can be added to an `md-grid-tile` using the `md-grid-tile-header` and -`md-grid-tile-footer` elements respectively. +A header and footer can be added to an `mat-grid-tile` using the `mat-grid-tile-header` and +`mat-grid-tile-footer` elements respectively. ### Accessibility By default, the grid-list assumes that it will be used in a purely decorative fashion and thus sets diff --git a/src/lib/grid-list/grid-list.spec.ts b/src/lib/grid-list/grid-list.spec.ts index 048d430d8545..4ccf274839a8 100644 --- a/src/lib/grid-list/grid-list.spec.ts +++ b/src/lib/grid-list/grid-list.spec.ts @@ -1,14 +1,14 @@ import {async, TestBed} from '@angular/core/testing'; import {Component, DebugElement} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {MdGridList, MdGridListModule} from './index'; -import {MdGridTile, MdGridTileText} from './grid-tile'; +import {MatGridList, MatGridListModule} from './index'; +import {MatGridTile, MatGridTileText} from './grid-tile'; -describe('MdGridList', () => { +describe('MatGridList', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdGridListModule], + imports: [MatGridListModule], declarations: [ GridListWithoutCols, GridListWithInvalidRowHeightRatio, @@ -55,7 +55,7 @@ describe('MdGridList', () => { it('should default to 1:1 row height if undefined ', () => { let fixture = TestBed.createComponent(GridListWithUnspecifiedRowHeight); fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); // In ratio mode, heights are set using the padding-top property. expect(getStyle(tile, 'padding-top')).toBe('200px'); @@ -67,7 +67,7 @@ describe('MdGridList', () => { fixture.componentInstance.rowHeight = '4:1'; fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); expect(getStyle(tile, 'padding-top')).toBe('100px'); fixture.componentInstance.rowHeight = '2:1'; @@ -81,7 +81,7 @@ describe('MdGridList', () => { fixture.componentInstance.totalHeight = '300px'; fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); // 149.5 * 2 = 299px + 1px gutter = 300px expect(getStyle(tile, 'height')).toBe('149.5px'); @@ -99,7 +99,7 @@ describe('MdGridList', () => { fixture.componentInstance.rowHeight = '100px'; fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); expect(getStyle(tile, 'height')).toBe('100px'); fixture.componentInstance.rowHeight = '200px'; @@ -112,7 +112,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithUnitlessFixedRowHeight); fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); expect(getStyle(tile, 'height')).toBe('100px'); }); @@ -120,7 +120,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithUnspecifiedGutterSize); fixture.detectChanges(); - let tiles = fixture.debugElement.queryAll(By.css('md-grid-tile')); + let tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile')); // check horizontal gutter expect(getStyle(tiles[0], 'width')).toBe('99.5px'); @@ -135,7 +135,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithGutterSize); fixture.detectChanges(); - let tiles = fixture.debugElement.queryAll(By.css('md-grid-tile')); + let tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile')); // check horizontal gutter expect(getStyle(tiles[0], 'width')).toBe('99px'); @@ -150,7 +150,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithUnitlessGutterSize); fixture.detectChanges(); - let tiles = fixture.debugElement.queryAll(By.css('md-grid-tile')); + let tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile')); // check horizontal gutter expect(getStyle(tiles[0], 'width')).toBe('99px'); @@ -165,7 +165,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithRatioHeightAndMulipleRows); fixture.detectChanges(); - let list = fixture.debugElement.query(By.directive(MdGridList)); + let list = fixture.debugElement.query(By.directive(MatGridList)); expect(getStyle(list, 'padding-bottom')).toBe('201px'); }); @@ -173,7 +173,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithFixRowHeightAndMultipleRows); fixture.detectChanges(); - let list = fixture.debugElement.query(By.directive(MdGridList)); + let list = fixture.debugElement.query(By.directive(MatGridList)); expect(getStyle(list, 'height')).toBe('201px'); }); @@ -182,7 +182,7 @@ describe('MdGridList', () => { fixture.componentInstance.colspan = 2; fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); expect(getStyle(tile, 'width')).toBe('199.5px'); fixture.componentInstance.colspan = 3; @@ -196,7 +196,7 @@ describe('MdGridList', () => { fixture.componentInstance.rowspan = 2; fixture.detectChanges(); - let tile = fixture.debugElement.query(By.directive(MdGridTile)); + let tile = fixture.debugElement.query(By.directive(MatGridTile)); expect(getStyle(tile, 'height')).toBe('201px'); fixture.componentInstance.rowspan = 3; @@ -215,7 +215,7 @@ describe('MdGridList', () => { ]; fixture.detectChanges(); - let tiles = fixture.debugElement.queryAll(By.css('md-grid-tile')); + let tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile')); expect(getStyle(tiles[0], 'width')).toBe('299.75px'); expect(getStyle(tiles[0], 'height')).toBe('100px'); @@ -242,7 +242,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithFootersWithoutLines); fixture.detectChanges(); - let footer = fixture.debugElement.query(By.directive(MdGridTileText)); + let footer = fixture.debugElement.query(By.directive(MatGridTileText)); expect(footer.nativeElement.classList.contains('mat-2-line')).toBe(false); }); @@ -250,7 +250,7 @@ describe('MdGridList', () => { let fixture = TestBed.createComponent(GridListWithFooterContainingTwoLines); fixture.detectChanges(); - let footer = fixture.debugElement.query(By.directive(MdGridTileText)); + let footer = fixture.debugElement.query(By.directive(MatGridTileText)); expect(footer.nativeElement.classList.contains('mat-2-line')).toBe(true); }); @@ -260,7 +260,7 @@ describe('MdGridList', () => { fixture.componentInstance.rowHeight = '4:1'; fixture.detectChanges(); - const firstTile = fixture.debugElement.query(By.directive(MdGridTile)).nativeElement; + const firstTile = fixture.debugElement.query(By.directive(MatGridTile)).nativeElement; expect(firstTile.style.marginTop).toBe('0px'); expect(firstTile.style.left).toBe('0px'); @@ -272,8 +272,8 @@ describe('MdGridList', () => { fixture.componentInstance.rowHeight = '4:1'; fixture.detectChanges(); - const list = fixture.debugElement.query(By.directive(MdGridList)); - const tile = fixture.debugElement.query(By.directive(MdGridTile)); + const list = fixture.debugElement.query(By.directive(MatGridList)); + const tile = fixture.debugElement.query(By.directive(MatGridTile)); expect(getStyle(tile, 'padding-top')).toBe('100px'); expect(getStyle(list, 'padding-bottom')).toBe('100px'); @@ -308,153 +308,153 @@ function getComputedLeft(element: DebugElement): number { -@Component({template: ''}) +@Component({template: ''}) class GridListWithoutCols { } -@Component({template: ''}) +@Component({template: ''}) class GridListWithInvalidRowHeightRatio { } @Component({template: - ''}) + ''}) class GridListWithTooWideColspan { } @Component({template: `
- - - + + +
`}) class GridListWithUnspecifiedRowHeight { } @Component({template: `
- - - + + +
`}) class GirdListWithRowHeightRatio { rowHeight: string; } @Component({template: ` - - - - `}) + + + + `}) class GridListWithFitRowHeightMode { totalHeight: string; } @Component({template: ` - - - `}) + + + `}) class GridListWithFixedRowHeightMode { rowHeight: string; } @Component({template: ` - - - `}) + + + `}) class GridListWithUnitlessFixedRowHeight { rowHeight: string; } @Component({template: `
- - - - - + + + + +
`}) class GridListWithUnspecifiedGutterSize { } @Component({template: `
- - - - - + + + + +
`}) class GridListWithGutterSize { } @Component({template: `
- - - - - + + + + +
`}) class GridListWithUnitlessGutterSize { } @Component({template: `
- - - - + + + +
`}) class GridListWithRatioHeightAndMulipleRows { } @Component({template: ` - - - - `}) + + + + `}) class GridListWithFixRowHeightAndMultipleRows { } @Component({template: `
- - - + + +
`}) class GridListWithColspanBinding { colspan: number; } @Component({template: ` - - - `}) + + + `}) class GridListWithRowspanBinding { rowspan: number; } @Component({template: `
- - + {{tile.text}} - - + +
`}) class GridListWithComplexLayout { tiles: any[]; } @Component({template: ` - - - + + + I'm a footer! - - - `}) + + + `}) class GridListWithFootersWithoutLines { } @Component({template: ` - - - -

First line

- Second line -
-
-
`}) + + + +

First line

+ Second line +
+
+
`}) class GridListWithFooterContainingTwoLines { } diff --git a/src/lib/grid-list/grid-list.ts b/src/lib/grid-list/grid-list.ts index bfa2c9a802b3..dbd3b2a74bd2 100644 --- a/src/lib/grid-list/grid-list.ts +++ b/src/lib/grid-list/grid-list.ts @@ -19,7 +19,7 @@ import { Optional, ChangeDetectionStrategy, } from '@angular/core'; -import {MdGridTile} from './grid-tile'; +import {MatGridTile} from './grid-tile'; import {TileCoordinator} from './tile-coordinator'; import {TileStyler, FitTileStyler, RatioTileStyler, FixedTileStyler} from './tile-styler'; import {Directionality} from '@angular/cdk/bidi'; @@ -33,11 +33,11 @@ import { // TODO(kara): Re-layout on window resize / media change (debounced). // TODO(kara): gridTileHeader and gridTileFooter. -const MD_FIT_MODE = 'fit'; +const MAT_FIT_MODE = 'fit'; @Component({ moduleId: module.id, - selector: 'md-grid-list, mat-grid-list', + selector: 'mat-grid-list', templateUrl: 'grid-list.html', styleUrls: ['grid-list.css'], host: { @@ -47,7 +47,7 @@ const MD_FIT_MODE = 'fit'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdGridList implements OnInit, AfterContentChecked { +export class MatGridList implements OnInit, AfterContentChecked { /** Number of columns being rendered. */ private _cols: number; @@ -66,7 +66,7 @@ export class MdGridList implements OnInit, AfterContentChecked { private _tileStyler: TileStyler; /** Query list of tiles that are being rendered. */ - @ContentChildren(MdGridTile) _tiles: QueryList; + @ContentChildren(MatGridTile) _tiles: QueryList; constructor( private _renderer: Renderer2, @@ -110,8 +110,8 @@ export class MdGridList implements OnInit, AfterContentChecked { /** Throw a friendly error if cols property is missing */ private _checkCols() { if (!this.cols) { - throw Error(`md-grid-list: must pass in number of columns. ` + - `Example: `); + throw Error(`mat-grid-list: must pass in number of columns. ` + + `Example: `); } } @@ -128,7 +128,7 @@ export class MdGridList implements OnInit, AfterContentChecked { this._tileStyler.reset(this); } - if (rowHeight === MD_FIT_MODE) { + if (rowHeight === MAT_FIT_MODE) { this._tileStyler = new FitTileStyler(); } else if (rowHeight && rowHeight.indexOf(':') > -1) { this._tileStyler = new RatioTileStyler(rowHeight); diff --git a/src/lib/grid-list/grid-tile-text.html b/src/lib/grid-list/grid-tile-text.html index 03c27a703a66..ec16bf917e16 100644 --- a/src/lib/grid-list/grid-tile-text.html +++ b/src/lib/grid-list/grid-tile-text.html @@ -1,3 +1,3 @@ - -
+ +
diff --git a/src/lib/grid-list/grid-tile.ts b/src/lib/grid-list/grid-tile.ts index 62443ef026e6..7f0e14f3780a 100644 --- a/src/lib/grid-list/grid-tile.ts +++ b/src/lib/grid-list/grid-tile.ts @@ -18,12 +18,12 @@ import { Directive, ChangeDetectionStrategy, } from '@angular/core'; -import {MdLine, MdLineSetter} from '@angular/material/core'; +import {MatLine, MatLineSetter} from '@angular/material/core'; import {coerceToNumber} from './grid-list-measure'; @Component({ moduleId: module.id, - selector: 'md-grid-tile, mat-grid-tile', + selector: 'mat-grid-tile', host: { 'class': 'mat-grid-tile', }, @@ -33,7 +33,7 @@ import {coerceToNumber} from './grid-list-measure'; preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdGridTile { +export class MatGridTile { _rowspan: number = 1; _colspan: number = 1; @@ -60,24 +60,24 @@ export class MdGridTile { @Component({ moduleId: module.id, - selector: 'md-grid-tile-header, mat-grid-tile-header, md-grid-tile-footer, mat-grid-tile-footer', + selector: 'mat-grid-tile-header, mat-grid-tile-footer', templateUrl: 'grid-tile-text.html', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdGridTileText implements AfterContentInit { +export class MatGridTileText implements AfterContentInit { /** * Helper that watches the number of lines in a text area and sets * a class on the host element that matches the line count. */ - _lineSetter: MdLineSetter; - @ContentChildren(MdLine) _lines: QueryList; + _lineSetter: MatLineSetter; + @ContentChildren(MatLine) _lines: QueryList; constructor(private _renderer: Renderer2, private _element: ElementRef) {} ngAfterContentInit() { - this._lineSetter = new MdLineSetter(this._lines, this._renderer, this._element); + this._lineSetter = new MatLineSetter(this._lines, this._renderer, this._element); } } @@ -86,27 +86,27 @@ export class MdGridTileText implements AfterContentInit { * @docs-private */ @Directive({ - selector: '[md-grid-avatar], [mat-grid-avatar], [mdGridAvatar], [matGridAvatar]', + selector: '[mat-grid-avatar], [matGridAvatar]', host: {'class': 'mat-grid-avatar'} }) -export class MdGridAvatarCssMatStyler {} +export class MatGridAvatarCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: 'md-grid-tile-header, mat-grid-tile-header', + selector: 'mat-grid-tile-header', host: {'class': 'mat-grid-tile-header'} }) -export class MdGridTileHeaderCssMatStyler {} +export class MatGridTileHeaderCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: 'md-grid-tile-footer, mat-grid-tile-footer', + selector: 'mat-grid-tile-footer', host: {'class': 'mat-grid-tile-footer'} }) -export class MdGridTileFooterCssMatStyler {} +export class MatGridTileFooterCssMatStyler {} diff --git a/src/lib/grid-list/mat-exports.ts b/src/lib/grid-list/mat-exports.ts deleted file mode 100644 index 0590465d4b71..000000000000 --- a/src/lib/grid-list/mat-exports.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdGridList} from './grid-list'; -import {MdGridListModule} from './grid-list-module'; -import {MdGridTile} from './grid-tile'; - - -export {MdGridList as MatGridList}; -export {MdGridListModule as MatGridListModule}; -export {MdGridTile as MatGridTile}; diff --git a/src/lib/grid-list/public_api.ts b/src/lib/grid-list/public_api.ts index 5329b294b274..dadf36d92a04 100644 --- a/src/lib/grid-list/public_api.ts +++ b/src/lib/grid-list/public_api.ts @@ -8,5 +8,5 @@ export * from './grid-list-module'; export * from './grid-list'; -export {MdGridTile} from './grid-tile'; -export * from './mat-exports'; +export {MatGridTile} from './grid-tile'; + diff --git a/src/lib/grid-list/tile-coordinator.ts b/src/lib/grid-list/tile-coordinator.ts index 7610ef154bba..281db2482fc9 100644 --- a/src/lib/grid-list/tile-coordinator.ts +++ b/src/lib/grid-list/tile-coordinator.ts @@ -7,7 +7,7 @@ */ import {QueryList} from '@angular/core'; -import {MdGridTile} from './grid-tile'; +import {MatGridTile} from './grid-tile'; /** * Class for determining, from a list of tiles, the (row, col) position of each of those tiles @@ -51,7 +51,7 @@ export class TileCoordinator { /** The computed (row, col) position of each tile (the output). */ positions: TilePosition[]; - constructor(numColumns: number, tiles: QueryList) { + constructor(numColumns: number, tiles: QueryList) { this.tracker = new Array(numColumns); this.tracker.fill(0, 0, this.tracker.length); @@ -59,7 +59,7 @@ export class TileCoordinator { } /** Calculates the row and col position of a tile. */ - private _trackTile(tile: MdGridTile): TilePosition { + private _trackTile(tile: MatGridTile): TilePosition { // Find a gap large enough for this tile. let gapStartIndex = this._findMatchingGap(tile.colspan); @@ -76,7 +76,7 @@ export class TileCoordinator { /** Finds the next available space large enough to fit the tile. */ private _findMatchingGap(tileCols: number): number { if (tileCols > this.tracker.length) { - throw Error(`md-grid-list: tile with colspan ${tileCols} is wider than ` + + throw Error(`mat-grid-list: tile with colspan ${tileCols} is wider than ` + `grid with cols="${this.tracker.length}".`); } @@ -138,7 +138,7 @@ export class TileCoordinator { } /** Update the tile tracker to account for the given tile in the given space. */ - private _markTilePosition(start: number, tile: MdGridTile): void { + private _markTilePosition(start: number, tile: MatGridTile): void { for (let i = 0; i < tile.colspan; i++) { this.tracker[start + i] = tile.rowspan; } diff --git a/src/lib/grid-list/tile-styler.ts b/src/lib/grid-list/tile-styler.ts index 36a897e1d583..1be3f05e54f8 100644 --- a/src/lib/grid-list/tile-styler.ts +++ b/src/lib/grid-list/tile-styler.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {MdGridList} from './grid-list'; -import {MdGridTile} from './grid-tile'; +import {MatGridList} from './grid-list'; +import {MatGridTile} from './grid-tile'; import {TileCoordinator} from './tile-coordinator'; /** @@ -86,7 +86,7 @@ export abstract class TileStyler { * @param rowIndex Index of the tile's row. * @param colIndex Index of the tile's column. */ - setStyle(tile: MdGridTile, rowIndex: number, colIndex: number): void { + setStyle(tile: MatGridTile, rowIndex: number, colIndex: number): void { // Percent of the available horizontal space that one column takes up. let percentWidthPerTile = 100 / this._cols; @@ -99,7 +99,7 @@ export abstract class TileStyler { } /** Sets the horizontal placement of the tile in the list. */ - setColStyles(tile: MdGridTile, colIndex: number, percentWidth: number, + setColStyles(tile: MatGridTile, colIndex: number, percentWidth: number, gutterWidth: number) { // Base horizontal size of a column. let baseTileWidth = this.getBaseTileSize(percentWidth, gutterWidth); @@ -131,7 +131,7 @@ export abstract class TileStyler { * This method will be implemented by each type of TileStyler. * @docs-private */ - abstract setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, + abstract setRowStyles(tile: MatGridTile, rowIndex: number, percentWidth: number, gutterWidth: number); /** @@ -146,13 +146,13 @@ export abstract class TileStyler { * @param list Grid list that the styler was attached to. * @docs-private */ - abstract reset(list: MdGridList); + abstract reset(list: MatGridList); } /** * This type of styler is instantiated when the user passes in a fixed row height. - * Example + * Example * @docs-private */ export class FixedTileStyler extends TileStyler { @@ -164,7 +164,7 @@ export class FixedTileStyler extends TileStyler { this.fixedRowHeight = normalizeUnits(this.fixedRowHeight); } - setRowStyles(tile: MdGridTile, rowIndex: number): void { + setRowStyles(tile: MatGridTile, rowIndex: number): void { tile._setStyle('top', this.getTilePosition(this.fixedRowHeight, rowIndex)); tile._setStyle('height', calc(this.getTileSize(this.fixedRowHeight, tile.rowspan))); } @@ -175,7 +175,7 @@ export class FixedTileStyler extends TileStyler { ]; } - reset(list: MdGridList) { + reset(list: MatGridList) { list._setListStyle(['height', null]); list._tiles.forEach(tile => { @@ -188,7 +188,7 @@ export class FixedTileStyler extends TileStyler { /** * This type of styler is instantiated when the user passes in a width:height ratio - * for the row height. Example + * for the row height. Example * @docs-private */ export class RatioTileStyler extends TileStyler { @@ -202,7 +202,7 @@ export class RatioTileStyler extends TileStyler { this._parseRatio(value); } - setRowStyles(tile: MdGridTile, rowIndex: number, percentWidth: number, + setRowStyles(tile: MatGridTile, rowIndex: number, percentWidth: number, gutterWidth: number): void { let percentHeightPerTile = percentWidth / this.rowHeightRatio; this.baseTileHeight = this.getBaseTileSize(percentHeightPerTile, gutterWidth); @@ -220,7 +220,7 @@ export class RatioTileStyler extends TileStyler { ]; } - reset(list: MdGridList) { + reset(list: MatGridList) { list._setListStyle(['padding-bottom', null]); list._tiles.forEach(tile => { @@ -233,7 +233,7 @@ export class RatioTileStyler extends TileStyler { const ratioParts = value.split(':'); if (ratioParts.length !== 2) { - throw Error(`md-grid-list: invalid ratio given for row-height: "${value}"`); + throw Error(`mat-grid-list: invalid ratio given for row-height: "${value}"`); } this.rowHeightRatio = parseFloat(ratioParts[0]) / parseFloat(ratioParts[1]); @@ -243,13 +243,13 @@ export class RatioTileStyler extends TileStyler { /** * This type of styler is instantiated when the user selects a "fit" row height mode. * In other words, the row height will reflect the total height of the container divided - * by the number of rows. Example + * by the number of rows. Example * * @docs-private */ export class FitTileStyler extends TileStyler { - setRowStyles(tile: MdGridTile, rowIndex: number): void { + setRowStyles(tile: MatGridTile, rowIndex: number): void { // Percent of the available vertical space that one row takes up. let percentHeightPerTile = 100 / this._rowspan; @@ -263,7 +263,7 @@ export class FitTileStyler extends TileStyler { tile._setStyle('height', calc(this.getTileSize(baseTileHeight, tile.rowspan))); } - reset(list: MdGridList) { + reset(list: MatGridList) { list._tiles.forEach(tile => { tile._setStyle('top', null); tile._setStyle('height', null); diff --git a/src/lib/icon/icon-module.ts b/src/lib/icon/icon-module.ts index 1104d7a29429..75a0d144810b 100644 --- a/src/lib/icon/icon-module.ts +++ b/src/lib/icon/icon-module.ts @@ -7,15 +7,15 @@ */ import {NgModule} from '@angular/core'; -import {MdCommonModule} from '@angular/material/core'; -import {MdIcon} from './icon'; +import {MatCommonModule} from '@angular/material/core'; +import {MatIcon} from './icon'; import {ICON_REGISTRY_PROVIDER} from './icon-registry'; @NgModule({ - imports: [MdCommonModule], - exports: [MdIcon, MdCommonModule], - declarations: [MdIcon], + imports: [MatCommonModule], + exports: [MatIcon, MatCommonModule], + declarations: [MatIcon], providers: [ICON_REGISTRY_PROVIDER], }) -export class MdIconModule {} +export class MatIconModule {} diff --git a/src/lib/icon/icon-registry.ts b/src/lib/icon/icon-registry.ts index 7ff669fc292d..f0f2a06e70c1 100644 --- a/src/lib/icon/icon-registry.ts +++ b/src/lib/icon/icon-registry.ts @@ -21,17 +21,17 @@ import {_throw as observableThrow} from 'rxjs/observable/throw'; * load an icon with a name that cannot be found. * @docs-private */ -export function getMdIconNameNotFoundError(iconName: string): Error { +export function getMatIconNameNotFoundError(iconName: string): Error { return Error(`Unable to find icon with the name "${iconName}"`); } /** * Returns an exception to be thrown when the consumer attempts to use - * `` without including @angular/http. + * `` without including @angular/http. * @docs-private */ -export function getMdIconNoHttpProviderError(): Error { +export function getMatIconNoHttpProviderError(): Error { return Error('Could not find Http provider for use with Angular Material icons. ' + 'Please include the HttpModule from @angular/http in your app imports.'); } @@ -42,8 +42,8 @@ export function getMdIconNoHttpProviderError(): Error { * @param url URL that was attempted to be sanitized. * @docs-private */ -export function getMdIconFailedToSanitizeError(url: SafeResourceUrl): Error { - return Error(`The URL provided to MdIconRegistry was not trusted as a resource URL ` + +export function getMatIconFailedToSanitizeError(url: SafeResourceUrl): Error { + return Error(`The URL provided to MatIconRegistry was not trusted as a resource URL ` + `via Angular's DomSanitizer. Attempted URL was "${url}".`); } @@ -57,14 +57,14 @@ class SvgIconConfig { } /** - * Service to register and display icons used by the component. + * Service to register and display icons used by the component. * - Registers icon URLs by namespace and name. * - Registers icon set URLs by namespace. * - Registers aliases for CSS classes, for use with icon fonts. * - Loads icons from URLs and extracts individual icons from icon sets. */ @Injectable() -export class MdIconRegistry { +export class MatIconRegistry { /** * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]". */ @@ -86,7 +86,7 @@ export class MdIconRegistry { private _fontCssClassesByAlias = new Map(); /** - * The CSS class to apply when an component has no icon name, url, or font specified. + * The CSS class to apply when an component has no icon name, url, or font specified. * The default 'material-icons' value assumes that the material icon font has been loaded as * described at http://google.github.io/material-design-icons/#icon-font-for-the-web */ @@ -141,9 +141,9 @@ export class MdIconRegistry { } /** - * Defines an alias for a CSS class name to be used for icon fonts. Creating an mdIcon + * Defines an alias for a CSS class name to be used for icon fonts. Creating an matIcon * component with the alias as the fontSet input will cause the class name to be applied - * to the element. + * to the element. * * @param alias Alias for the font. * @param className Class name override to be used instead of the alias. @@ -162,7 +162,7 @@ export class MdIconRegistry { } /** - * Sets the CSS class name to be used for icon fonts when an component does not + * Sets the CSS class name to be used for icon fonts when an component does not * have a fontSet input value, and is not loading an icon by name or URL. * * @param className @@ -173,7 +173,7 @@ export class MdIconRegistry { } /** - * Returns the CSS class name to be used for icon fonts when an component does not + * Returns the CSS class name to be used for icon fonts when an component does not * have a fontSet input value, and is not loading an icon by name or URL. */ getDefaultFontSetClass(): string { @@ -192,7 +192,7 @@ export class MdIconRegistry { let url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl); if (!url) { - throw getMdIconFailedToSanitizeError(safeUrl); + throw getMatIconFailedToSanitizeError(safeUrl); } let cachedIcon = this._cachedIconsByUrl.get(url); @@ -231,7 +231,7 @@ export class MdIconRegistry { return this._getSvgFromIconSetConfigs(name, iconSetConfigs); } - return observableThrow(getMdIconNameNotFoundError(key)); + return observableThrow(getMatIconNameNotFoundError(key)); } /** @@ -300,7 +300,7 @@ export class MdIconRegistry { const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs); if (!foundIcon) { - throw getMdIconNameNotFoundError(name); + throw getMatIconNameNotFoundError(name); } return foundIcon; @@ -443,13 +443,13 @@ export class MdIconRegistry { */ private _fetchUrl(safeUrl: SafeResourceUrl): Observable { if (!this._http) { - throw getMdIconNoHttpProviderError(); + throw getMatIconNoHttpProviderError(); } const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl); if (!url) { - throw getMdIconFailedToSanitizeError(safeUrl); + throw getMatIconFailedToSanitizeError(safeUrl); } // Store in-progress fetches to avoid sending a duplicate request for a URL when there is @@ -476,15 +476,15 @@ export class MdIconRegistry { /** @docs-private */ export function ICON_REGISTRY_PROVIDER_FACTORY( - parentRegistry: MdIconRegistry, http: Http, sanitizer: DomSanitizer) { - return parentRegistry || new MdIconRegistry(http, sanitizer); + parentRegistry: MatIconRegistry, http: Http, sanitizer: DomSanitizer) { + return parentRegistry || new MatIconRegistry(http, sanitizer); } /** @docs-private */ export const ICON_REGISTRY_PROVIDER = { - // If there is already an MdIconRegistry available, use that. Otherwise, provide a new one. - provide: MdIconRegistry, - deps: [[new Optional(), new SkipSelf(), MdIconRegistry], [new Optional(), Http], DomSanitizer], + // If there is already an MatIconRegistry available, use that. Otherwise, provide a new one. + provide: MatIconRegistry, + deps: [[new Optional(), new SkipSelf(), MatIconRegistry], [new Optional(), Http], DomSanitizer], useFactory: ICON_REGISTRY_PROVIDER_FACTORY }; diff --git a/src/lib/icon/icon.md b/src/lib/icon/icon.md index 15dfa0dfa27f..6a08ac010789 100644 --- a/src/lib/icon/icon.md +++ b/src/lib/icon/icon.md @@ -1,26 +1,26 @@ -`md-icon` makes it easier to use _vector-based_ icons in your app. This directive supports both +`mat-icon` makes it easier to use _vector-based_ icons in your app. This directive supports both icon fonts and SVG icons, but not bitmap-based formats (png, jpg, etc.). ### Registering icons -`MdIconRegistry` is an injectable service that allows you to associate icon names with SVG URLs and +`MatIconRegistry` is an injectable service that allows you to associate icon names with SVG URLs and define aliases for CSS font classes. Its methods are discussed below and listed in the API summary. ### Font icons with ligatures Some fonts are designed to show icons by using [ligatures](https://en.wikipedia.org/wiki/Typographic_ligature), for example by rendering the text -"home" as a home image. To use a ligature icon, put its text in the content of the `md-icon` +"home" as a home image. To use a ligature icon, put its text in the content of the `mat-icon` component. -By default, `` expects the +By default, `` expects the [Material icons font](http://google.github.io/material-design-icons/#icon-font-for-the-web). (You will still need to include the HTML to load the font and its CSS, as described in the link). You can specify a different font by setting the `fontSet` input to either the CSS class to apply to use the desired font, or to an alias previously registered with -`MdIconRegistry.registerFontClassAlias`. +`MatIconRegistry.registerFontClassAlias`. ### Font icons with CSS @@ -28,23 +28,23 @@ Fonts can also display icons by defining a CSS class for each icon glyph, which `:before` selector to cause the icon to appear. [FontAwesome](https://fortawesome.github.io/Font-Awesome/examples/) uses this approach to display its icons. To use such a font, set the `fontSet` input to the font's CSS class (either the class -itself or an alias registered with `MdIconRegistry.registerFontClassAlias`), and set the `fontIcon` +itself or an alias registered with `MatIconRegistry.registerFontClassAlias`), and set the `fontIcon` input to the class for the specific icon to show. For both types of font icons, you can specify the default font class to use when `fontSet` is not -explicitly set by calling `MdIconRegistry.setDefaultFontSetClass`. +explicitly set by calling `MatIconRegistry.setDefaultFontSetClass`. ### SVG icons -When an `md-icon` component displays an SVG icon, it does so by directly inlining the SVG content +When an `mat-icon` component displays an SVG icon, it does so by directly inlining the SVG content into the page as a child of the component. (Rather than using an tag or a div background image). This makes it easier to apply CSS styles to SVG icons. For example, the default color of the SVG content is the CSS [currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentColor_keyword) value. This makes SVG icons by default have the same color as surrounding text, and allows you to -change the color by setting the "color" style on the `md-icon` element. +change the color by setting the "color" style on the `mat-icon` element. -In order to prevent XSS vulnerabilities, any SVG URLs passed to the `MdIconRegistry` must be +In order to prevent XSS vulnerabilities, any SVG URLs passed to the `MatIconRegistry` must be marked as trusted resource URLs by using Angular's `DomSanitizer` service. Also note that all SVG icons are fetched via XmlHttpRequest, and due to the same-origin policy, @@ -54,7 +54,7 @@ to allow cross-domain access. #### Named icons To associate a name with an icon URL, use the `addSvgIcon` or `addSvgIconInNamespace` methods of -`MdIconRegistry`. After registering an icon, it can be displayed by setting the `svgIcon` input. +`MatIconRegistry`. After registering an icon, it can be displayed by setting the `svgIcon` input. For an icon in the default namespace, use the name directly. For a non-default namespace, use the format `[namespace]:[name]`. @@ -65,7 +65,7 @@ root `` tag that contains multiple nested `` tags in its `` sect nested tags is identified with an `id` attribute. This `id` is used as the name of the icon. Icon sets are registered using the `addSvgIconSet` or `addSvgIconSetInNamespace` methods of -`MdIconRegistry`. After an icon set is registered, each of its embedded icons can be accessed by +`MatIconRegistry`. After an icon set is registered, each of its embedded icons can be accessed by their `id` attributes. To display an icon from an icon set, use the `svgIcon` input in the same way as for individually registered icons. @@ -81,8 +81,8 @@ match the current theme's colors using the `color` attribute. This can be change ### Accessibility Similar to an `` element, an icon alone does not convey any useful information for a -screen-reader user. The user of `` must provide additional information pertaining to how -the icon is used. Based on the use-cases described below, `md-icon` is marked as +screen-reader user. The user of `` must provide additional information pertaining to how +the icon is used. Based on the use-cases described below, `mat-icon` is marked as `aria-hidden="true"` by default, but this can be overriden by adding `aria-hidden="false"` to the element. @@ -92,22 +92,22 @@ In thinking about accessibility, it is useful to place icon use into one of thre 3. **Indicator**: the icon is not interactive, but it conveys some information, such as a status. #### Decorative icons -When the icon is puely cosmetic and conveys no real semantic meaning, the `` element +When the icon is puely cosmetic and conveys no real semantic meaning, the `` element should be marked with `aria-hidden="true"`. #### Interactive icons Icons alone are not interactive elements for screen-reader users; when the user would interact with some icon on the page, a more appropriate element should "own" the interaction: -* The `` element should be a child of a `

- + -
+
diff --git a/src/lib/list/list-module.ts b/src/lib/list/list-module.ts index 177bec5758b9..509f5ea0ad7e 100644 --- a/src/lib/list/list-module.ts +++ b/src/lib/list/list-module.ts @@ -9,55 +9,55 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import { - MdCommonModule, - MdLineModule, - MdPseudoCheckboxModule, - MdRippleModule, + MatCommonModule, + MatLineModule, + MatPseudoCheckboxModule, + MatRippleModule, } from '@angular/material/core'; import { - MdDividerCssMatStyler, - MdList, - MdListAvatarCssMatStyler, - MdListCssMatStyler, - MdListDivider, - MdListIconCssMatStyler, - MdListItem, - MdListSubheaderCssMatStyler, - MdNavListCssMatStyler, + MatDividerCssMatStyler, + MatList, + MatListAvatarCssMatStyler, + MatListCssMatStyler, + MatListDivider, + MatListIconCssMatStyler, + MatListItem, + MatListSubheaderCssMatStyler, + MatNavListCssMatStyler, } from './list'; -import {MdListOption, MdSelectionList} from './selection-list'; +import {MatListOption, MatSelectionList} from './selection-list'; @NgModule({ - imports: [MdLineModule, MdRippleModule, MdCommonModule, MdPseudoCheckboxModule, CommonModule], + imports: [MatLineModule, MatRippleModule, MatCommonModule, MatPseudoCheckboxModule, CommonModule], exports: [ - MdList, - MdListItem, - MdListDivider, - MdListAvatarCssMatStyler, - MdLineModule, - MdCommonModule, - MdListIconCssMatStyler, - MdListCssMatStyler, - MdNavListCssMatStyler, - MdDividerCssMatStyler, - MdListSubheaderCssMatStyler, - MdPseudoCheckboxModule, - MdSelectionList, - MdListOption + MatList, + MatListItem, + MatListDivider, + MatListAvatarCssMatStyler, + MatLineModule, + MatCommonModule, + MatListIconCssMatStyler, + MatListCssMatStyler, + MatNavListCssMatStyler, + MatDividerCssMatStyler, + MatListSubheaderCssMatStyler, + MatPseudoCheckboxModule, + MatSelectionList, + MatListOption ], declarations: [ - MdList, - MdListItem, - MdListDivider, - MdListAvatarCssMatStyler, - MdListIconCssMatStyler, - MdListCssMatStyler, - MdNavListCssMatStyler, - MdDividerCssMatStyler, - MdListSubheaderCssMatStyler, - MdSelectionList, - MdListOption + MatList, + MatListItem, + MatListDivider, + MatListAvatarCssMatStyler, + MatListIconCssMatStyler, + MatListCssMatStyler, + MatNavListCssMatStyler, + MatDividerCssMatStyler, + MatListSubheaderCssMatStyler, + MatSelectionList, + MatListOption ], }) -export class MdListModule {} +export class MatListModule {} diff --git a/src/lib/list/list.md b/src/lib/list/list.md index f9ad2ae169dd..b26595f5becf 100644 --- a/src/lib/list/list.md +++ b/src/lib/list/list.md @@ -1,4 +1,4 @@ -`` is a container component that wraps and formats a series of line items. As the base +`` is a container component that wraps and formats a series of line items. As the base list component, it provides Material Design styling, but no behavior of its own. @@ -6,40 +6,40 @@ list component, it provides Material Design styling, but no behavior of its own. ### Simple lists -An `` element contains a number of `` elements. +An `` element contains a number of `` elements. ```html - - Pepper - Salt - Paprika - + + Pepper + Salt + Paprika + ``` ### Navigation lists -Use `md-nav-list` tags for navigation lists (i.e. lists that have anchor tags). +Use `mat-nav-list` tags for navigation lists (i.e. lists that have anchor tags). -Simple navigation lists can use the `md-list-item` attribute on anchor tag elements directly: +Simple navigation lists can use the `mat-list-item` attribute on anchor tag elements directly: ```html - -
{{ link }} - + + {{ link }} + ``` For more complex navigation lists (e.g. with more than one target per item), wrap the anchor -element in an ``. +element in an ``. ```html - - - {{ link }} - - - + + ``` ### Selection lists @@ -52,101 +52,101 @@ as buttons and anchors. ### Multi-line lists -For lists that require multiple lines per item, annotate each line with an `mdLine` attribute. +For lists that require multiple lines per item, annotate each line with an `matLine` attribute. Whichever heading tag is appropriate for your DOM hierarchy should be used (not necessarily `

` as shown in the example). ```html - - -

{{message.from}}

-

+ + +

{{message.from}}

+

{{message.subject}} -- {{message.content}}

-
-
+ + - - -

{{message.from}}

-

{{message.subject}}

-

{{message.content}}

-
-
+ + +

{{message.from}}

+

{{message.subject}}

+

{{message.content}}

+
+
``` ### Lists with icons -To add an icon to your list item, use the `mdListIcon` attribute. +To add an icon to your list item, use the `matListIcon` attribute. ```html - - - folder -

{{message.from}}

-

+ + + folder +

{{message.from}}

+

{{message.subject}} -- {{message.content}}

-
-
+ + ``` ### Lists with avatars -To include an avatar image, add an image tag with an `mdListAvatar` attribute. +To include an avatar image, add an image tag with an `matListAvatar` attribute. ```html - - - ... -

{{message.from}}

-

+ + + ... +

{{message.from}}

+

{{message.subject}} -- {{message.content}}

-
-
+ + ``` ### Dense lists Lists are also available in "dense layout" mode, which shrinks the font size and height of the list to suit UIs that may need to display more information. To enable this mode, add a `dense` attribute -to the main `md-list` tag. +to the main `mat-list` tag. ```html - - Pepper - Salt - Paprika - + + Pepper + Salt + Paprika + ``` ### Lists with multiple sections -Subheader can be added to a list by annotating a heading tag with an `mdSubheader` attribute. -To add a divider, use ``. +Subheader can be added to a list by annotating a heading tag with an `matSubheader` attribute. +To add a divider, use ``. ```html - -

Folders

- - folder -

{{folder.name}}

-

{{folder.updated}}

-
- -

Notes

- - note -

{{note.name}}

-

{{note.updated}}

-
-
+ +

Folders

+ + folder +

{{folder.name}}

+

{{folder.updated}}

+
+ +

Notes

+ + note +

{{note.name}}

+

{{note.updated}}

+
+
``` diff --git a/src/lib/list/list.spec.ts b/src/lib/list/list.spec.ts index d9854cf1dfdf..f2b60c500aef 100644 --- a/src/lib/list/list.spec.ts +++ b/src/lib/list/list.spec.ts @@ -1,14 +1,14 @@ import {async, TestBed} from '@angular/core/testing'; import {Component, QueryList, ViewChildren} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {MdListItem, MdListModule} from './index'; +import {MatListItem, MatListModule} from './index'; -describe('MdList', () => { +describe('MatList', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdListModule], + imports: [MatListModule], declarations: [ ListWithOneAnchorItem, ListWithOneItem, @@ -29,7 +29,7 @@ describe('MdList', () => { it('should add and remove focus class on focus/blur', () => { let fixture = TestBed.createComponent(ListWithOneAnchorItem); fixture.detectChanges(); - let listItem = fixture.debugElement.query(By.directive(MdListItem)); + let listItem = fixture.debugElement.query(By.directive(MatListItem)); let listItemEl = fixture.debugElement.query(By.css('.mat-list-item')); expect(listItemEl.nativeElement.classList).not.toContain('mat-list-item-focus'); @@ -45,7 +45,7 @@ describe('MdList', () => { it('should not apply any additional class to a list without lines', () => { let fixture = TestBed.createComponent(ListWithOneItem); - let listItem = fixture.debugElement.query(By.css('md-list-item')); + let listItem = fixture.debugElement.query(By.css('mat-list-item')); fixture.detectChanges(); expect(listItem.nativeElement.className).toBe('mat-list-item'); }); @@ -54,7 +54,7 @@ describe('MdList', () => { let fixture = TestBed.createComponent(ListWithTwoLineItem); fixture.detectChanges(); - let listItems = fixture.debugElement.children[0].queryAll(By.css('md-list-item')); + let listItems = fixture.debugElement.children[0].queryAll(By.css('mat-list-item')); expect(listItems[0].nativeElement.className).toContain('mat-2-line'); expect(listItems[1].nativeElement.className).toContain('mat-2-line'); }); @@ -63,7 +63,7 @@ describe('MdList', () => { let fixture = TestBed.createComponent(ListWithThreeLineItem); fixture.detectChanges(); - let listItems = fixture.debugElement.children[0].queryAll(By.css('md-list-item')); + let listItems = fixture.debugElement.children[0].queryAll(By.css('mat-list-item')); expect(listItems[0].nativeElement.className).toContain('mat-3-line'); expect(listItems[1].nativeElement.className).toContain('mat-3-line'); }); @@ -72,7 +72,7 @@ describe('MdList', () => { let fixture = TestBed.createComponent(ListWithManyLines); fixture.detectChanges(); - let listItems = fixture.debugElement.children[0].queryAll(By.css('md-list-item')); + let listItems = fixture.debugElement.children[0].queryAll(By.css('mat-list-item')); expect(listItems[0].nativeElement.className).toContain('mat-multi-line'); expect(listItems[1].nativeElement.className).toContain('mat-multi-line'); }); @@ -81,7 +81,7 @@ describe('MdList', () => { let fixture = TestBed.createComponent(ListWithAvatar); fixture.detectChanges(); - let listItems = fixture.debugElement.children[0].queryAll(By.css('md-list-item')); + let listItems = fixture.debugElement.children[0].queryAll(By.css('mat-list-item')); expect(listItems[0].nativeElement.className).toContain('mat-list-item-avatar'); expect(listItems[1].nativeElement.className).not.toContain('mat-list-item-avatar'); }); @@ -90,7 +90,7 @@ describe('MdList', () => { let fixture = TestBed.createComponent(ListWithItemWithCssClass); fixture.detectChanges(); - let listItems = fixture.debugElement.children[0].queryAll(By.css('md-list-item')); + let listItems = fixture.debugElement.children[0].queryAll(By.css('mat-list-item')); expect(listItems[0].nativeElement.classList.contains('test-class')).toBe(true); }); @@ -99,7 +99,7 @@ describe('MdList', () => { fixture.debugElement.componentInstance.showThirdLine = false; fixture.detectChanges(); - let listItem = fixture.debugElement.children[0].query(By.css('md-list-item')); + let listItem = fixture.debugElement.children[0].query(By.css('mat-list-item')); expect(listItem.nativeElement.classList.length).toBe(2); expect(listItem.nativeElement.classList).toContain('mat-2-line'); expect(listItem.nativeElement.classList).toContain('mat-list-item'); @@ -114,7 +114,7 @@ describe('MdList', () => { fixture.detectChanges(); let list = fixture.debugElement.children[0]; - let listItem = fixture.debugElement.children[0].query(By.css('md-list-item')); + let listItem = fixture.debugElement.children[0].query(By.css('mat-list-item')); expect(list.nativeElement.getAttribute('role')).toBe('list'); expect(listItem.nativeElement.getAttribute('role')).toBe('listitem'); }); @@ -123,7 +123,7 @@ describe('MdList', () => { let fixture = TestBed.createComponent(ListWithOneAnchorItem); fixture.detectChanges(); - const items: QueryList = fixture.debugElement.componentInstance.listItems; + const items: QueryList = fixture.debugElement.componentInstance.listItems; expect(items.length).toBeGreaterThan(0); items.forEach(item => expect(item._isRippleDisabled()).toBe(true)); }); @@ -172,103 +172,103 @@ class BaseTestList { } @Component({template: ` - - + + Paprika - `}) + `}) class ListWithOneAnchorItem extends BaseTestList { // This needs to be declared directly on the class; if declared on the BaseTestList superclass, // it doesn't get populated. - @ViewChildren(MdListItem) listItems: QueryList; + @ViewChildren(MatListItem) listItems: QueryList; } @Component({template: ` - - + + Paprika - `}) + `}) class NavListWithOneAnchorItem extends BaseTestList { - @ViewChildren(MdListItem) listItems: QueryList; + @ViewChildren(MatListItem) listItems: QueryList; disableItemRipple: boolean = false; disableListRipple: boolean = false; } @Component({template: ` - - + + Paprika - - `}) + + `}) class ListWithOneItem extends BaseTestList { } @Component({template: ` - - + + -

{{item.name}}

-

{{item.description}}

-
-
`}) +

{{item.name}}

+

{{item.description}}

+ + `}) class ListWithTwoLineItem extends BaseTestList { } @Component({template: ` - - -

{{item.name}}

-

{{item.description}}

-

Some other text

-
-
`}) + + +

{{item.name}}

+

{{item.description}}

+

Some other text

+
+
`}) class ListWithThreeLineItem extends BaseTestList { } @Component({template: ` - - -

Line 1

-

Line 2

-

Line 3

-

Line 4

-
-
`}) + + +

Line 1

+

Line 2

+

Line 3

+

Line 4

+
+
`}) class ListWithManyLines extends BaseTestList { } @Component({template: ` - - - + + + Paprika - - + + Pepper - - `}) + + `}) class ListWithAvatar extends BaseTestList { } @Component({template: ` - - -

{{item.name}}

-

{{item.description}}

-
-
`}) + + +

{{item.name}}

+

{{item.description}}

+
+
`}) class ListWithItemWithCssClass extends BaseTestList { } @Component({template: ` - - -

{{item.name}}

-

{{item.description}}

-

Some other text

-
-
`}) + + +

{{item.name}}

+

{{item.description}}

+

Some other text

+
+
`}) class ListWithDynamicNumberOfLines extends BaseTestList { } @Component({template: ` - - + + {{item.name}} - - `}) + + `}) class ListWithMultipleItems extends BaseTestList { } diff --git a/src/lib/list/list.ts b/src/lib/list/list.ts index 183b8c81dd80..ab7d90daa514 100644 --- a/src/lib/list/list.ts +++ b/src/lib/list/list.ts @@ -8,6 +8,7 @@ import { AfterContentInit, + ChangeDetectionStrategy, Component, ContentChild, ContentChildren, @@ -17,36 +18,34 @@ import { QueryList, Renderer2, ViewEncapsulation, - ChangeDetectionStrategy, } from '@angular/core'; -import {MATERIAL_COMPATIBILITY_MODE, MdLine, MdLineSetter} from '@angular/material/core'; -import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; +import {CanDisableRipple, MatLine, MatLineSetter, mixinDisableRipple} from '@angular/material/core'; -// Boilerplate for applying mixins to MdList. +// Boilerplate for applying mixins to MatList. /** @docs-private */ -export class MdListBase {} -export const _MdListMixinBase = mixinDisableRipple(MdListBase); +export class MatListBase {} +export const _MatListMixinBase = mixinDisableRipple(MatListBase); -// Boilerplate for applying mixins to MdListItem. +// Boilerplate for applying mixins to MatListItem. /** @docs-private */ -export class MdListItemBase {} -export const _MdListItemMixinBase = mixinDisableRipple(MdListItemBase); +export class MatListItemBase {} +export const _MatListItemMixinBase = mixinDisableRipple(MatListItemBase); /** Divider between items within a list. */ @Directive({ - selector: 'md-divider, mat-divider', + selector: 'mat-divider', host: { 'role': 'separator', 'aria-orientation': 'horizontal' } }) -export class MdListDivider {} +export class MatListDivider {} /** A Material Design list component. */ @Component({ moduleId: module.id, - selector: 'md-list, mat-list, md-nav-list, mat-nav-list', + selector: 'mat-list, mat-nav-list', host: {'role': 'list'}, template: '', styleUrls: ['list.css'], @@ -55,72 +54,72 @@ export class MdListDivider {} preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdList extends _MdListMixinBase implements CanDisableRipple {} +export class MatList extends _MatListMixinBase implements CanDisableRipple {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: 'md-list, mat-list', + selector: 'mat-list', host: {'class': 'mat-list'} }) -export class MdListCssMatStyler {} +export class MatListCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: 'md-nav-list, mat-nav-list', + selector: 'mat-nav-list', host: {'class': 'mat-nav-list'} }) -export class MdNavListCssMatStyler {} +export class MatNavListCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: 'md-divider, mat-divider', + selector: 'mat-divider', host: {'class': 'mat-divider'} }) -export class MdDividerCssMatStyler {} +export class MatDividerCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: '[md-list-avatar], [mat-list-avatar], [mdListAvatar], [matListAvatar]', + selector: '[mat-list-avatar], [matListAvatar]', host: {'class': 'mat-list-avatar'} }) -export class MdListAvatarCssMatStyler {} +export class MatListAvatarCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: '[md-list-icon], [mat-list-icon], [mdListIcon], [matListIcon]', + selector: '[mat-list-icon], [matListIcon]', host: {'class': 'mat-list-icon'} }) -export class MdListIconCssMatStyler {} +export class MatListIconCssMatStyler {} /** * Directive whose purpose is to add the mat- CSS styling to this selector. * @docs-private */ @Directive({ - selector: '[md-subheader], [mat-subheader], [mdSubheader], [matSubheader]', + selector: '[mat-subheader], [matSubheader]', host: {'class': 'mat-subheader'} }) -export class MdListSubheaderCssMatStyler {} +export class MatListSubheaderCssMatStyler {} /** An item within a Material Design list. */ @Component({ moduleId: module.id, - selector: 'md-list-item, mat-list-item, a[md-list-item], a[mat-list-item]', + selector: 'mat-list-item, a[mat-list-item]', host: { 'role': 'listitem', 'class': 'mat-list-item', @@ -132,16 +131,16 @@ export class MdListSubheaderCssMatStyler {} encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdListItem extends _MdListItemMixinBase implements AfterContentInit, CanDisableRipple { - private _lineSetter: MdLineSetter; +export class MatListItem extends _MatListItemMixinBase implements AfterContentInit, + CanDisableRipple { + private _lineSetter: MatLineSetter; private _isNavList: boolean = false; - @ContentChildren(MdLine) _lines: QueryList; + @ContentChildren(MatLine) _lines: QueryList; - @ContentChild(MdListAvatarCssMatStyler) - set _hasAvatar(avatar: MdListAvatarCssMatStyler) { + @ContentChild(MatListAvatarCssMatStyler) + set _hasAvatar(avatar: MatListAvatarCssMatStyler) { if (avatar != null) { this._renderer.addClass(this._element.nativeElement, 'mat-list-item-avatar'); } else { @@ -151,14 +150,14 @@ export class MdListItem extends _MdListItemMixinBase implements AfterContentInit constructor(private _renderer: Renderer2, private _element: ElementRef, - @Optional() private _list: MdList, - @Optional() navList: MdNavListCssMatStyler) { + @Optional() private _list: MatList, + @Optional() navList: MatNavListCssMatStyler) { super(); this._isNavList = !!navList; } ngAfterContentInit() { - this._lineSetter = new MdLineSetter(this._lines, this._renderer, this._element); + this._lineSetter = new MatLineSetter(this._lines, this._renderer, this._element); } /** Whether this list item should show a ripple effect when clicked. */ diff --git a/src/lib/list/mat-exports.ts b/src/lib/list/mat-exports.ts deleted file mode 100644 index e8f8a9e89e40..000000000000 --- a/src/lib/list/mat-exports.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MdDividerCssMatStyler, - MdList, - MdListAvatarCssMatStyler, - MdListBase, - MdListCssMatStyler, - MdListDivider, - MdListIconCssMatStyler, - MdListItem, - MdListItemBase, - MdListSubheaderCssMatStyler, - MdNavListCssMatStyler, -} from './list'; -import { - MdListOption, - MdListOptionBase, - MdSelectionList, - MdSelectionListBase, - MdSelectionListOptionEvent, -} from './selection-list'; -import {MdListModule} from './list-module'; - - -export {MdDividerCssMatStyler as MatDividerCssMatStyler}; -export {MdList as MatList}; -export {MdListAvatarCssMatStyler as MatListAvatarCssMatStyler}; -export {MdListBase as MatListBase}; -export {MdListCssMatStyler as MatListCssMatStyler}; -export {MdListDivider as MatListDivider}; -export {MdListIconCssMatStyler as MatListIconCssMatStyler}; -export {MdListItem as MatListItem}; -export {MdListItemBase as MatListItemBase}; -export {MdListModule as MatListModule}; -export {MdListOption as MatListOption}; -export {MdListOptionBase as MatListOptionBase}; -export {MdListSubheaderCssMatStyler as MatListSubheaderCssMatStyler}; -export {MdNavListCssMatStyler as MatNavListCssMatStyler}; -export {MdSelectionList as MatSelectionList}; -export {MdSelectionListBase as MatSelectionListBase}; -export {MdSelectionListOptionEvent as MatSelectionListOptionEvent}; diff --git a/src/lib/list/public_api.ts b/src/lib/list/public_api.ts index 98b17cb93de7..bea6b187f243 100644 --- a/src/lib/list/public_api.ts +++ b/src/lib/list/public_api.ts @@ -9,4 +9,4 @@ export * from './list-module'; export * from './list'; export * from './selection-list'; -export * from './mat-exports'; + diff --git a/src/lib/list/selection-list.spec.ts b/src/lib/list/selection-list.spec.ts index bb3752c3fdd9..457d0b1532ea 100644 --- a/src/lib/list/selection-list.spec.ts +++ b/src/lib/list/selection-list.spec.ts @@ -4,10 +4,10 @@ import {createKeyboardEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {MdListModule, MdListOption, MdSelectionList} from './index'; +import {MatListModule, MatListOption, MatSelectionList} from './index'; -describe('MdSelectionList', () => { +describe('MatSelectionList', () => { describe('with list option', () => { let fixture: ComponentFixture; let listOption: DebugElement[]; @@ -16,7 +16,7 @@ describe('MdSelectionList', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdListModule], + imports: [MatListModule], declarations: [ SelectionListWithListOptions, SelectionListWithCheckboxPositionAfter, @@ -30,9 +30,9 @@ describe('MdSelectionList', () => { beforeEach(async(() => { fixture = TestBed.createComponent(SelectionListWithListOptions); - listOption = fixture.debugElement.queryAll(By.directive(MdListOption)); + listOption = fixture.debugElement.queryAll(By.directive(MatListOption)); listItemEl = fixture.debugElement.query(By.css('.mat-list-item')); - selectionList = fixture.debugElement.query(By.directive(MdSelectionList)); + selectionList = fixture.debugElement.query(By.directive(MatSelectionList)); fixture.detectChanges(); })); @@ -57,8 +57,9 @@ describe('MdSelectionList', () => { }); it('should be able to dispatch one selected item', () => { - let testListItem = listOption[2].injector.get(MdListOption); - let selectList = selectionList.injector.get(MdSelectionList).selectedOptions; + let testListItem = listOption[2].injector.get(MatListOption); + let selectList = + selectionList.injector.get(MatSelectionList).selectedOptions; expect(selectList.selected.length).toBe(0); expect(listOption[2].nativeElement.getAttribute('aria-selected')).toBe('false'); @@ -72,9 +73,10 @@ describe('MdSelectionList', () => { }); it('should be able to dispatch multiple selected items', () => { - let testListItem = listOption[2].injector.get(MdListOption); - let testListItem2 = listOption[1].injector.get(MdListOption); - let selectList = selectionList.injector.get(MdSelectionList).selectedOptions; + let testListItem = listOption[2].injector.get(MatListOption); + let testListItem2 = listOption[1].injector.get(MatListOption); + let selectList = + selectionList.injector.get(MatSelectionList).selectedOptions; expect(selectList.selected.length).toBe(0); expect(listOption[2].nativeElement.getAttribute('aria-selected')).toBe('false'); @@ -94,8 +96,9 @@ describe('MdSelectionList', () => { }); it('should be able to deselect an option', () => { - let testListItem = listOption[2].injector.get(MdListOption); - let selectList = selectionList.injector.get(MdSelectionList).selectedOptions; + let testListItem = listOption[2].injector.get(MatListOption); + let selectList = + selectionList.injector.get(MatSelectionList).selectedOptions; expect(selectList.selected.length).toBe(0); @@ -111,8 +114,9 @@ describe('MdSelectionList', () => { }); it('should not allow selection of disabled items', () => { - let testListItem = listOption[0].injector.get(MdListOption); - let selectList = selectionList.injector.get(MdSelectionList).selectedOptions; + let testListItem = listOption[0].injector.get(MatListOption); + let selectList = + selectionList.injector.get(MatSelectionList).selectedOptions; expect(selectList.selected.length).toBe(0); expect(listOption[0].nativeElement.getAttribute('aria-disabled')).toBe('true'); @@ -124,7 +128,7 @@ describe('MdSelectionList', () => { }); it('should be able to un-disable disabled items', () => { - let testListItem = listOption[0].injector.get(MdListOption); + let testListItem = listOption[0].injector.get(MatListOption); expect(listOption[0].nativeElement.getAttribute('aria-disabled')).toBe('true'); @@ -138,7 +142,8 @@ describe('MdSelectionList', () => { let testListItem = listOption[1].nativeElement as HTMLElement; let SPACE_EVENT: KeyboardEvent = createKeyboardEvent('keydown', SPACE, testListItem); - let selectList = selectionList.injector.get(MdSelectionList).selectedOptions; + let selectList = + selectionList.injector.get(MatSelectionList).selectedOptions; let options = selectionList.componentInstance.options; let array = options.toArray(); let focusItem = array[1]; @@ -191,7 +196,7 @@ describe('MdSelectionList', () => { }); it('should be able to select all options', () => { - const list: MdSelectionList = selectionList.componentInstance; + const list: MatSelectionList = selectionList.componentInstance; expect(list.options.toArray().every(option => option.selected)).toBe(false); @@ -202,7 +207,7 @@ describe('MdSelectionList', () => { }); it('should be able to deselect all options', () => { - const list: MdSelectionList = selectionList.componentInstance; + const list: MatSelectionList = selectionList.componentInstance; list.options.forEach(option => option.toggle()); expect(list.options.toArray().every(option => option.selected)).toBe(true); @@ -223,7 +228,7 @@ describe('MdSelectionList', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdListModule], + imports: [MatListModule], declarations: [ SelectionListWithListOptions, SelectionListWithCheckboxPositionAfter, @@ -237,9 +242,9 @@ describe('MdSelectionList', () => { beforeEach(async(() => { fixture = TestBed.createComponent(SelectionListWithOnlyOneOption); - listOption = fixture.debugElement.query(By.directive(MdListOption)); + listOption = fixture.debugElement.query(By.directive(MatListOption)); listItemEl = fixture.debugElement.query(By.css('.mat-list-item')); - selectionList = fixture.debugElement.query(By.directive(MdSelectionList)); + selectionList = fixture.debugElement.query(By.directive(MatSelectionList)); fixture.detectChanges(); })); @@ -266,11 +271,11 @@ describe('MdSelectionList', () => { describe('with option disabled', () => { let fixture: ComponentFixture; let listOptionEl: HTMLElement; - let listOption: MdListOption; + let listOption: MatListOption; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdListModule], + imports: [MatListModule], declarations: [SelectionListWithDisabledOption] }); @@ -280,7 +285,7 @@ describe('MdSelectionList', () => { beforeEach(async(() => { fixture = TestBed.createComponent(SelectionListWithDisabledOption); - const listOptionDebug = fixture.debugElement.query(By.directive(MdListOption)); + const listOptionDebug = fixture.debugElement.query(By.directive(MatListOption)); listOption = listOptionDebug.componentInstance; listOptionEl = listOptionDebug.nativeElement; @@ -317,7 +322,7 @@ describe('MdSelectionList', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdListModule], + imports: [MatListModule], declarations: [ SelectionListWithListOptions, SelectionListWithCheckboxPositionAfter, @@ -331,15 +336,16 @@ describe('MdSelectionList', () => { beforeEach(async(() => { fixture = TestBed.createComponent(SelectionListWithListDisabled); - listOption = fixture.debugElement.queryAll(By.directive(MdListOption)); + listOption = fixture.debugElement.queryAll(By.directive(MatListOption)); listItemEl = fixture.debugElement.query(By.css('.mat-list-item')); - selectionList = fixture.debugElement.query(By.directive(MdSelectionList)); + selectionList = fixture.debugElement.query(By.directive(MatSelectionList)); fixture.detectChanges(); })); it('should not allow selection on disabled selection-list', () => { - let testListItem = listOption[2].injector.get(MdListOption); - let selectList = selectionList.injector.get(MdSelectionList).selectedOptions; + let testListItem = listOption[2].injector.get(MatListOption); + let selectList = + selectionList.injector.get(MatSelectionList).selectedOptions; expect(selectList.selected.length).toBe(0); @@ -358,7 +364,7 @@ describe('MdSelectionList', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdListModule], + imports: [MatListModule], declarations: [ SelectionListWithListOptions, SelectionListWithCheckboxPositionAfter, @@ -372,9 +378,9 @@ describe('MdSelectionList', () => { beforeEach(async(() => { fixture = TestBed.createComponent(SelectionListWithCheckboxPositionAfter); - listOption = fixture.debugElement.queryAll(By.directive(MdListOption)); + listOption = fixture.debugElement.queryAll(By.directive(MatListOption)); listItemEl = fixture.debugElement.query(By.css('.mat-list-item')); - selectionList = fixture.debugElement.query(By.directive(MdSelectionList)); + selectionList = fixture.debugElement.query(By.directive(MatSelectionList)); fixture.detectChanges(); })); @@ -388,62 +394,62 @@ describe('MdSelectionList', () => { @Component({template: ` - + Inbox (disabled selection-option) - - + Starred - - + + Sent Mail - - + + Drafts - + `}) class SelectionListWithListOptions { } @Component({template: ` - + Inbox (disabled selection-option) - - + + Starred - - + + Sent Mail - - + + Drafts - + `}) class SelectionListWithCheckboxPositionAfter { } @Component({template: ` - + Inbox (disabled selection-option) - - + + Starred - - + + Sent Mail - - + + Drafts - + `}) class SelectionListWithListDisabled { } @Component({template: ` - Item + Item `}) class SelectionListWithDisabledOption { @@ -452,9 +458,9 @@ class SelectionListWithDisabledOption { @Component({template: ` - + Inbox - + `}) class SelectionListWithOnlyOneOption { } diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index 5cd645a33c1d..3f939fa600c7 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -32,9 +32,8 @@ import { import { CanDisable, CanDisableRipple, - MATERIAL_COMPATIBILITY_MODE, - MdLine, - MdLineSetter, + MatLine, + MatLineSetter, mixinDisabled, mixinDisableRipple, } from '@angular/material/core'; @@ -43,16 +42,16 @@ import {Subscription} from 'rxjs/Subscription'; /** @docs-private */ -export class MdSelectionListBase {} -export const _MdSelectionListMixinBase = mixinDisableRipple(mixinDisabled(MdSelectionListBase)); +export class MatSelectionListBase {} +export const _MatSelectionListMixinBase = mixinDisableRipple(mixinDisabled(MatSelectionListBase)); /** @docs-private */ -export class MdListOptionBase {} -export const _MdListOptionMixinBase = mixinDisableRipple(MdListOptionBase); +export class MatListOptionBase {} +export const _MatListOptionMixinBase = mixinDisableRipple(MatListOptionBase); /** Event emitted by a selection-list whenever the state of an option is changed. */ -export interface MdSelectionListOptionEvent { - option: MdListOption; +export interface MatSelectionListOptionEvent { + option: MatListOption; } const FOCUSED_STYLE: string = 'mat-list-item-focus'; @@ -64,7 +63,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; */ @Component({ moduleId: module.id, - selector: 'md-list-option, mat-list-option', + selector: 'mat-list-option', inputs: ['disableRipple'], host: { 'role': 'option', @@ -81,19 +80,18 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdListOption extends _MdListOptionMixinBase +export class MatListOption extends _MatListOptionMixinBase implements AfterContentInit, OnDestroy, FocusableOption, CanDisableRipple { - private _lineSetter: MdLineSetter; + private _lineSetter: MatLineSetter; private _selected: boolean = false; private _disabled: boolean = false; /** Whether the option has focus. */ _hasFocus: boolean = false; - @ContentChildren(MdLine) _lines: QueryList; + @ContentChildren(MatLine) _lines: QueryList; /** Whether the label should appear before or after the checkbox. Defaults to 'after' */ @Input() checkboxPosition: 'before' | 'after' = 'after'; @@ -112,27 +110,27 @@ export class MdListOption extends _MdListOptionMixinBase set selected(value: boolean) { this._selected = coerceBooleanProperty(value); } /** Emitted when the option is focused. */ - onFocus = new EventEmitter(); + onFocus = new EventEmitter(); /** Emitted when the option is selected. */ - @Output() selectChange = new EventEmitter(); + @Output() selectChange = new EventEmitter(); /** Emitted when the option is deselected. */ - @Output() deselected = new EventEmitter(); + @Output() deselected = new EventEmitter(); /** Emitted when the option is destroyed. */ - @Output() destroyed = new EventEmitter(); + @Output() destroyed = new EventEmitter(); constructor(private _renderer: Renderer2, private _element: ElementRef, private _changeDetector: ChangeDetectorRef, - @Optional() @Inject(forwardRef(() => MdSelectionList)) - public selectionList: MdSelectionList) { + @Optional() @Inject(forwardRef(() => MatSelectionList)) + public selectionList: MatSelectionList) { super(); } ngAfterContentInit() { - this._lineSetter = new MdLineSetter(this._lines, this._renderer, this._element); + this._lineSetter = new MatLineSetter(this._lines, this._renderer, this._element); if (this.selectionList.disabled) { this.disabled = true; @@ -188,7 +186,7 @@ export class MdListOption extends _MdListOptionMixinBase */ @Component({ moduleId: module.id, - selector: 'md-selection-list, mat-selection-list', + selector: 'mat-selection-list', inputs: ['disabled', 'disableRipple'], host: { 'role': 'listbox', @@ -203,7 +201,7 @@ export class MdListOption extends _MdListOptionMixinBase preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush }) -export class MdSelectionList extends _MdSelectionListMixinBase +export class MatSelectionList extends _MatSelectionListMixinBase implements FocusableOption, CanDisable, CanDisableRipple, AfterContentInit, OnDestroy { /** Tab index for the selection-list. */ @@ -216,20 +214,20 @@ export class MdSelectionList extends _MdSelectionListMixinBase private _optionDestroyStream = Subscription.EMPTY; /** The FocusKeyManager which handles focus. */ - _keyManager: FocusKeyManager; + _keyManager: FocusKeyManager; /** The option components contained within this selection-list. */ - @ContentChildren(MdListOption) options: QueryList; + @ContentChildren(MatListOption) options: QueryList; /** The currently selected options. */ - selectedOptions: SelectionModel = new SelectionModel(true); + selectedOptions: SelectionModel = new SelectionModel(true); constructor(private _element: ElementRef) { super(); } ngAfterContentInit(): void { - this._keyManager = new FocusKeyManager(this.options).withWrap(); + this._keyManager = new FocusKeyManager(this.options).withWrap(); if (this.disabled) { this._tabIndex = -1; @@ -271,9 +269,9 @@ export class MdSelectionList extends _MdSelectionListMixinBase private _onDestroySubscription(): Subscription { return RxChain.from(this.options.changes) .call(startWith, this.options) - .call(switchMap, (options: MdListOption[]) => { + .call(switchMap, (options: MatListOption[]) => { return merge(...options.map(option => option.destroyed)); - }).subscribe((e: MdSelectionListOptionEvent) => { + }).subscribe((e: MatSelectionListOptionEvent) => { let optionIndex: number = this.options.toArray().indexOf(e.option); if (e.option._hasFocus) { // Check whether the option is the last item @@ -291,9 +289,9 @@ export class MdSelectionList extends _MdSelectionListMixinBase private _onFocusSubscription(): Subscription { return RxChain.from(this.options.changes) .call(startWith, this.options) - .call(switchMap, (options: MdListOption[]) => { + .call(switchMap, (options: MatListOption[]) => { return merge(...options.map(option => option.onFocus)); - }).subscribe((e: MdSelectionListOptionEvent) => { + }).subscribe((e: MatSelectionListOptionEvent) => { let optionIndex: number = this.options.toArray().indexOf(e.option); this._keyManager.updateActiveItemIndex(optionIndex); }); @@ -317,7 +315,7 @@ export class MdSelectionList extends _MdSelectionListMixinBase let focusedIndex = this._keyManager.activeItemIndex; if (focusedIndex != null && this._isValidIndex(focusedIndex)) { - let focusedOption: MdListOption = this.options.toArray()[focusedIndex]; + let focusedOption: MatListOption = this.options.toArray()[focusedIndex]; if (focusedOption) { focusedOption.toggle(); diff --git a/src/lib/menu/mat-exports.ts b/src/lib/menu/mat-exports.ts deleted file mode 100644 index 1c123fbebf03..000000000000 --- a/src/lib/menu/mat-exports.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_MENU_DEFAULT_OPTIONS, - MdMenu, - MdMenuDefaultOptions, - MdMenuItem, - MdMenuPanel, - MdMenuTrigger, -} from './menu'; -import {MdMenuModule} from './menu-module'; - - -export {MD_MENU_DEFAULT_OPTIONS as MAT_MENU_DEFAULT_OPTIONS}; -export {MdMenu as MatMenu}; -export {MdMenuDefaultOptions as MatMenuDefaultOptions}; -export {MdMenuItem as MatMenuItem}; -export {MdMenuModule as MatMenuModule}; -export {MdMenuPanel as MatMenuPanel}; -export {MdMenuTrigger as MatMenuTrigger}; diff --git a/src/lib/menu/menu-animations.ts b/src/lib/menu/menu-animations.ts index ff709feb4b18..7a594819fc85 100644 --- a/src/lib/menu/menu-animations.ts +++ b/src/lib/menu/menu-animations.ts @@ -16,7 +16,7 @@ import{ } from '@angular/animations'; /** - * Below are all the animations for the md-menu component. + * Below are all the animations for the mat-menu component. * Animation duration and timing values are based on: * https://material.io/guidelines/components/menus.html#menus-usage */ diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index aa7d1c8dfef1..81243ac07b97 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -32,33 +32,33 @@ import {Observable} from 'rxjs/Observable'; import {merge} from 'rxjs/observable/merge'; import {Subscription} from 'rxjs/Subscription'; import {fadeInItems, transformMenu} from './menu-animations'; -import {throwMdMenuInvalidPositionX, throwMdMenuInvalidPositionY} from './menu-errors'; -import {MdMenuItem} from './menu-item'; -import {MdMenuPanel} from './menu-panel'; +import {throwMatMenuInvalidPositionX, throwMatMenuInvalidPositionY} from './menu-errors'; +import {MatMenuItem} from './menu-item'; +import {MatMenuPanel} from './menu-panel'; import {MenuPositionX, MenuPositionY} from './menu-positions'; -/** Default `md-menu` options that can be overridden. */ -export interface MdMenuDefaultOptions { +/** Default `mat-menu` options that can be overridden. */ +export interface MatMenuDefaultOptions { xPosition: MenuPositionX; yPosition: MenuPositionY; overlapTrigger: boolean; } -/** Injection token to be used to override the default options for `md-menu`. */ -export const MD_MENU_DEFAULT_OPTIONS = - new InjectionToken('md-menu-default-options'); +/** Injection token to be used to override the default options for `mat-menu`. */ +export const MAT_MENU_DEFAULT_OPTIONS = + new InjectionToken('mat-menu-default-options'); /** * Start elevation for the menu panel. * @docs-private */ -const MD_MENU_BASE_ELEVATION = 2; +const MAT_MENU_BASE_ELEVATION = 2; @Component({ moduleId: module.id, - selector: 'md-menu, mat-menu', + selector: 'mat-menu', templateUrl: 'menu.html', styleUrls: ['menu.css'], changeDetection: ChangeDetectionStrategy.OnPush, @@ -68,10 +68,10 @@ const MD_MENU_BASE_ELEVATION = 2; transformMenu, fadeInItems ], - exportAs: 'mdMenu, matMenu' + exportAs: 'matMenu' }) -export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { - private _keyManager: FocusKeyManager; +export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy { + private _keyManager: FocusKeyManager; private _xPosition: MenuPositionX = this._defaultOptions.xPosition; private _yPosition: MenuPositionY = this._defaultOptions.yPosition; private _previousElevation: string; @@ -86,7 +86,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { _panelAnimationState: 'void' | 'enter-start' | 'enter' = 'void'; /** Parent menu of the current menu panel. */ - parentMenu: MdMenuPanel | undefined; + parentMenu: MatMenuPanel | undefined; /** Layout direction of the menu. */ direction: Direction; @@ -96,7 +96,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { get xPosition() { return this._xPosition; } set xPosition(value: MenuPositionX) { if (value !== 'before' && value !== 'after') { - throwMdMenuInvalidPositionX(); + throwMatMenuInvalidPositionX(); } this._xPosition = value; this.setPositionClasses(); @@ -107,7 +107,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { get yPosition() { return this._yPosition; } set yPosition(value: MenuPositionY) { if (value !== 'above' && value !== 'below') { - throwMdMenuInvalidPositionY(); + throwMatMenuInvalidPositionY(); } this._yPosition = value; this.setPositionClasses(); @@ -116,13 +116,13 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { @ViewChild(TemplateRef) templateRef: TemplateRef; /** List of the items inside of a menu. */ - @ContentChildren(MdMenuItem) items: QueryList; + @ContentChildren(MatMenuItem) items: QueryList; /** Whether the menu should overlap its trigger. */ @Input() overlapTrigger = this._defaultOptions.overlapTrigger; /** - * This method takes classes set on the host md-menu element and applies them on the + * This method takes classes set on the host mat-menu element and applies them on the * menu template that displays in the overlay container. Otherwise, it's difficult * to style the containing menu from outside the component. * @param classes list of class names @@ -145,10 +145,10 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { constructor( private _elementRef: ElementRef, - @Inject(MD_MENU_DEFAULT_OPTIONS) private _defaultOptions: MdMenuDefaultOptions) { } + @Inject(MAT_MENU_DEFAULT_OPTIONS) private _defaultOptions: MatMenuDefaultOptions) { } ngAfterContentInit() { - this._keyManager = new FocusKeyManager(this.items).withWrap(); + this._keyManager = new FocusKeyManager(this.items).withWrap(); this._tabSubscription = this._keyManager.tabOut.subscribe(() => this.close.emit('keydown')); } @@ -159,10 +159,10 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { } /** Stream that emits whenever the hovered menu item changes. */ - hover(): Observable { + hover(): Observable { return RxChain.from(this.items.changes) .call(startWith, this.items) - .call(switchMap, (items: MdMenuItem[]) => merge(...items.map(item => item.hover))) + .call(switchMap, (items: MatMenuItem[]) => merge(...items.map(item => item.hover))) .result(); } @@ -213,7 +213,7 @@ export class MdMenu implements AfterContentInit, MdMenuPanel, OnDestroy { */ setElevation(depth: number): void { // The elevation starts at the base and increases by one for each level. - const newElevation = `mat-elevation-z${MD_MENU_BASE_ELEVATION + depth}`; + const newElevation = `mat-elevation-z${MAT_MENU_BASE_ELEVATION + depth}`; const customElevation = Object.keys(this._classList).find(c => c.startsWith('mat-elevation-z')); if (!customElevation || customElevation === this._previousElevation) { diff --git a/src/lib/menu/menu-errors.ts b/src/lib/menu/menu-errors.ts index 4090e71fa812..0ab32e469c05 100644 --- a/src/lib/menu/menu-errors.ts +++ b/src/lib/menu/menu-errors.ts @@ -7,15 +7,15 @@ */ /** - * Throws an exception for the case when menu trigger doesn't have a valid md-menu instance + * Throws an exception for the case when menu trigger doesn't have a valid mat-menu instance * @docs-private */ -export function throwMdMenuMissingError() { - throw Error(`md-menu-trigger: must pass in an md-menu instance. +export function throwMatMenuMissingError() { + throw Error(`mat-menu-trigger: must pass in an mat-menu instance. Example: - - `); + + `); } /** @@ -23,9 +23,9 @@ export function throwMdMenuMissingError() { * In other words, it doesn't match 'before' or 'after'. * @docs-private */ -export function throwMdMenuInvalidPositionX() { +export function throwMatMenuInvalidPositionX() { throw Error(`x-position value must be either 'before' or after'. - Example: `); + Example: `); } /** @@ -33,7 +33,7 @@ export function throwMdMenuInvalidPositionX() { * In other words, it doesn't match 'above' or 'below'. * @docs-private */ -export function throwMdMenuInvalidPositionY() { +export function throwMatMenuInvalidPositionY() { throw Error(`y-position value must be either 'above' or below'. - Example: `); + Example: `); } diff --git a/src/lib/menu/menu-item.ts b/src/lib/menu/menu-item.ts index fe9ff3dcbb55..c08a7e39cf3a 100644 --- a/src/lib/menu/menu-item.ts +++ b/src/lib/menu/menu-item.ts @@ -14,21 +14,21 @@ import { OnDestroy, ViewEncapsulation, } from '@angular/core'; -import {CanDisable, MATERIAL_COMPATIBILITY_MODE, mixinDisabled} from '@angular/material/core'; +import {CanDisable, mixinDisabled} from '@angular/material/core'; import {Subject} from 'rxjs/Subject'; -// Boilerplate for applying mixins to MdMenuItem. +// Boilerplate for applying mixins to MatMenuItem. /** @docs-private */ -export class MdMenuItemBase {} -export const _MdMenuItemMixinBase = mixinDisabled(MdMenuItemBase); +export class MatMenuItemBase {} +export const _MatMenuItemMixinBase = mixinDisabled(MatMenuItemBase); /** - * This directive is intended to be used inside an md-menu tag. + * This directive is intended to be used inside an mat-menu tag. * It exists mostly to set the role attribute. */ @Component({ moduleId: module.id, - selector: '[md-menu-item], [mat-menu-item]', + selector: '[mat-menu-item]', inputs: ['disabled'], host: { 'role': 'menuitem', @@ -45,14 +45,13 @@ export const _MdMenuItemMixinBase = mixinDisabled(MdMenuItemBase); encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, templateUrl: 'menu-item.html', - exportAs: 'mdMenuItem, matMenuItem', - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], + exportAs: 'matMenuItem', }) -export class MdMenuItem extends _MdMenuItemMixinBase implements FocusableOption, CanDisable, +export class MatMenuItem extends _MatMenuItemMixinBase implements FocusableOption, CanDisable, OnDestroy { /** Stream that emits when the menu item is hovered. */ - hover: Subject = new Subject(); + hover: Subject = new Subject(); /** Whether the menu item is highlighted. */ _highlighted: boolean = false; diff --git a/src/lib/menu/menu-module.ts b/src/lib/menu/menu-module.ts index 2ebfabe5a916..3c35206d6e46 100644 --- a/src/lib/menu/menu-module.ts +++ b/src/lib/menu/menu-module.ts @@ -8,27 +8,27 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {MdCommonModule} from '@angular/material/core'; +import {MatCommonModule} from '@angular/material/core'; import {OverlayModule} from '@angular/cdk/overlay'; -import {MdMenu, MD_MENU_DEFAULT_OPTIONS} from './menu-directive'; -import {MdMenuItem} from './menu-item'; -import {MdMenuTrigger, MD_MENU_SCROLL_STRATEGY_PROVIDER} from './menu-trigger'; -import {MdRippleModule} from '@angular/material/core'; +import {MatMenu, MAT_MENU_DEFAULT_OPTIONS} from './menu-directive'; +import {MatMenuItem} from './menu-item'; +import {MatMenuTrigger, MAT_MENU_SCROLL_STRATEGY_PROVIDER} from './menu-trigger'; +import {MatRippleModule} from '@angular/material/core'; @NgModule({ imports: [ OverlayModule, CommonModule, - MdRippleModule, - MdCommonModule, + MatRippleModule, + MatCommonModule, ], - exports: [MdMenu, MdMenuItem, MdMenuTrigger, MdCommonModule], - declarations: [MdMenu, MdMenuItem, MdMenuTrigger], + exports: [MatMenu, MatMenuItem, MatMenuTrigger, MatCommonModule], + declarations: [MatMenu, MatMenuItem, MatMenuTrigger], providers: [ - MD_MENU_SCROLL_STRATEGY_PROVIDER, + MAT_MENU_SCROLL_STRATEGY_PROVIDER, { - provide: MD_MENU_DEFAULT_OPTIONS, + provide: MAT_MENU_DEFAULT_OPTIONS, useValue: { overlapTrigger: true, xPosition: 'after', @@ -37,4 +37,4 @@ import {MdRippleModule} from '@angular/material/core'; } ], }) -export class MdMenuModule {} +export class MatMenuModule {} diff --git a/src/lib/menu/menu-panel.ts b/src/lib/menu/menu-panel.ts index 073d40805267..3f1a6eb18492 100644 --- a/src/lib/menu/menu-panel.ts +++ b/src/lib/menu/menu-panel.ts @@ -10,13 +10,13 @@ import {EventEmitter, TemplateRef} from '@angular/core'; import {MenuPositionX, MenuPositionY} from './menu-positions'; import {Direction} from '@angular/cdk/bidi'; -export interface MdMenuPanel { +export interface MatMenuPanel { xPosition: MenuPositionX; yPosition: MenuPositionY; overlapTrigger: boolean; templateRef: TemplateRef; close: EventEmitter; - parentMenu?: MdMenuPanel | undefined; + parentMenu?: MatMenuPanel | undefined; direction?: Direction; focusFirstItem: () => void; setPositionClasses: (x: MenuPositionX, y: MenuPositionY) => void; diff --git a/src/lib/menu/menu-trigger.ts b/src/lib/menu/menu-trigger.ts index 09d2e9c63764..32e520353ee6 100644 --- a/src/lib/menu/menu-trigger.ts +++ b/src/lib/menu/menu-trigger.ts @@ -38,28 +38,28 @@ import { import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; import {Subscription} from 'rxjs/Subscription'; -import {MdMenu} from './menu-directive'; -import {throwMdMenuMissingError} from './menu-errors'; -import {MdMenuItem} from './menu-item'; -import {MdMenuPanel} from './menu-panel'; +import {MatMenu} from './menu-directive'; +import {throwMatMenuMissingError} from './menu-errors'; +import {MatMenuItem} from './menu-item'; +import {MatMenuPanel} from './menu-panel'; import {MenuPositionX, MenuPositionY} from './menu-positions'; /** Injection token that determines the scroll handling while the menu is open. */ -export const MD_MENU_SCROLL_STRATEGY = - new InjectionToken<() => ScrollStrategy>('md-menu-scroll-strategy'); +export const MAT_MENU_SCROLL_STRATEGY = + new InjectionToken<() => ScrollStrategy>('mat-menu-scroll-strategy'); /** @docs-private */ -export function MD_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): +export function MAT_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy { return () => overlay.scrollStrategies.reposition(); } /** @docs-private */ -export const MD_MENU_SCROLL_STRATEGY_PROVIDER = { - provide: MD_MENU_SCROLL_STRATEGY, +export const MAT_MENU_SCROLL_STRATEGY_PROVIDER = { + provide: MAT_MENU_SCROLL_STRATEGY, deps: [Overlay], - useFactory: MD_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY, + useFactory: MAT_MENU_SCROLL_STRATEGY_PROVIDER_FACTORY, }; @@ -69,21 +69,20 @@ export const MD_MENU_SCROLL_STRATEGY_PROVIDER = { export const MENU_PANEL_TOP_PADDING = 8; /** - * This directive is intended to be used in conjunction with an md-menu tag. It is + * This directive is intended to be used in conjunction with an mat-menu tag. It is * responsible for toggling the display of the provided menu instance. */ @Directive({ - selector: `[md-menu-trigger-for], [mat-menu-trigger-for], - [mdMenuTriggerFor], [matMenuTriggerFor]`, + selector: `[mat-menu-trigger-for], [matMenuTriggerFor]`, host: { 'aria-haspopup': 'true', '(mousedown)': '_handleMousedown($event)', '(keydown)': '_handleKeydown($event)', '(click)': '_handleClick($event)', }, - exportAs: 'mdMenuTrigger, matMenuTrigger' + exportAs: 'matMenuTrigger' }) -export class MdMenuTrigger implements AfterViewInit, OnDestroy { +export class MatMenuTrigger implements AfterViewInit, OnDestroy { private _portal: TemplatePortal; private _overlayRef: OverlayRef | null = null; private _menuOpen: boolean = false; @@ -95,38 +94,18 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { // the first item of the list when the menu is opened via the keyboard private _openedByMouse: boolean = false; - /** @deprecated */ - @Input('md-menu-trigger-for') - get _deprecatedMdMenuTriggerFor(): MdMenuPanel { - return this.menu; - } - - set _deprecatedMdMenuTriggerFor(v: MdMenuPanel) { - this.menu = v; - } - /** @deprecated */ @Input('mat-menu-trigger-for') - get _deprecatedMatMenuTriggerFor(): MdMenuPanel { - return this.menu; - } - - set _deprecatedMatMenuTriggerFor(v: MdMenuPanel) { - this.menu = v; - } - - // Trigger input for compatibility mode - @Input('matMenuTriggerFor') - get _matMenuTriggerFor(): MdMenuPanel { + get _deprecatedMatMenuTriggerFor(): MatMenuPanel { return this.menu; } - set _matMenuTriggerFor(v: MdMenuPanel) { + set _deprecatedMatMenuTriggerFor(v: MatMenuPanel) { this.menu = v; } /** References the menu instance that the trigger is associated with. */ - @Input('mdMenuTriggerFor') menu: MdMenuPanel; + @Input('matMenuTriggerFor') menu: MatMenuPanel; /** Event emitted when the associated menu is opened. */ @Output() onMenuOpen = new EventEmitter(); @@ -137,9 +116,9 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { constructor(private _overlay: Overlay, private _element: ElementRef, private _viewContainerRef: ViewContainerRef, - @Inject(MD_MENU_SCROLL_STRATEGY) private _scrollStrategy, - @Optional() private _parentMenu: MdMenu, - @Optional() @Self() private _menuItemInstance: MdMenuItem, + @Inject(MAT_MENU_SCROLL_STRATEGY) private _scrollStrategy, + @Optional() private _parentMenu: MatMenu, + @Optional() @Self() private _menuItemInstance: MatMenuItem, @Optional() private _dir: Directionality) { if (_menuItemInstance) { @@ -206,7 +185,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { this._closeSubscription = this._menuClosingActions().subscribe(() => this.menu.close.emit()); this._initMenu(); - if (this.menu instanceof MdMenu) { + if (this.menu instanceof MatMenu) { this.menu._startAnimation(); } } @@ -220,7 +199,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { this._closeSubscription.unsubscribe(); this.menu.close.emit(); - if (this.menu instanceof MdMenu) { + if (this.menu instanceof MatMenu) { this.menu._resetAnimation(); } } @@ -291,12 +270,12 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy { } /** - * This method checks that a valid instance of MdMenu has been passed into - * mdMenuTriggerFor. If not, an exception is thrown. + * This method checks that a valid instance of MatMenu has been passed into + * matMenuTriggerFor. If not, an exception is thrown. */ private _checkMenu() { if (!this.menu) { - throwMdMenuMissingError(); + throwMatMenuMissingError(); } } diff --git a/src/lib/menu/menu.md b/src/lib/menu/menu.md index 70529834470e..f202c21ce9c5 100644 --- a/src/lib/menu/menu.md +++ b/src/lib/menu/menu.md @@ -1,28 +1,28 @@ -`` is a floating panel containing list of options. +`` is a floating panel containing list of options. -By itself, the `` element does not render anything. The menu is attached to and opened -via application of the `mdMenuTriggerFor` directive: +By itself, the `` element does not render anything. The menu is attached to and opened +via application of the `matMenuTriggerFor` directive: ```html - - - - + + + + - ``` ### Toggling the menu programmatically The menu exposes an API to open/close programmatically. Please note that in this case, an -`mdMenuTriggerFor` directive is still necessary to attach the menu to a trigger element in the DOM. +`matMenuTriggerFor` directive is still necessary to attach the menu to a trigger element in the DOM. ```ts class MyComponent { - @ViewChild(MdMenuTrigger) trigger: MdMenuTrigger; + @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; someMethod() { this.trigger.openMenu(); @@ -31,24 +31,24 @@ class MyComponent { ``` ### Icons -Menus support displaying `md-icon` elements before the menu item text. +Menus support displaying `mat-icon` elements before the menu item text. *my-comp.html* ```html - - - - - + ``` ### Customizing menu position @@ -59,36 +59,36 @@ The position can be changed using the `xPosition` (`before | after`) and `yPosit `[overlapTrigger]="false"` attribute. ```html - - - - + + + + - ``` ### Nested menu -Material supports the ability for an `md-menu-item` to open a sub-menu. To do so, you have to define -your root menu and sub-menus, in addition to setting the `[mdMenuTriggerFor]` on the `md-menu-item` +Material supports the ability for an `mat-menu-item` to open a sub-menu. To do so, you have to define +your root menu and sub-menus, in addition to setting the `[matMenuTriggerFor]` on the `mat-menu-item` that should trigger the sub-menu: ```html - - - - - - - - - - - - + + + + + + + + + + ``` diff --git a/src/lib/menu/menu.spec.ts b/src/lib/menu/menu.spec.ts index 8b07cf95975c..1b82873a61d3 100644 --- a/src/lib/menu/menu.spec.ts +++ b/src/lib/menu/menu.spec.ts @@ -14,11 +14,11 @@ import {Direction, Directionality} from '@angular/cdk/bidi'; import {OverlayContainer} from '@angular/cdk/overlay'; import {ESCAPE, LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes'; import { - MD_MENU_DEFAULT_OPTIONS, - MdMenu, - MdMenuModule, - MdMenuPanel, - MdMenuTrigger, + MAT_MENU_DEFAULT_OPTIONS, + MatMenu, + MatMenuModule, + MatMenuPanel, + MatMenuTrigger, MenuPositionX, MenuPositionY, } from './index'; @@ -33,14 +33,14 @@ import { } from '@angular/cdk/testing'; -describe('MdMenu', () => { +describe('MatMenu', () => { let overlayContainerElement: HTMLElement; let dir: Direction; beforeEach(async(() => { dir = 'ltr'; TestBed.configureTestingModule({ - imports: [MdMenuModule, NoopAnimationsModule], + imports: [MatMenuModule, NoopAnimationsModule], declarations: [ SimpleMenu, PositionedMenu, @@ -145,7 +145,7 @@ describe('MdMenu', () => { fixture.detectChanges(); fixture.componentInstance.trigger.openMenu(); - const menuEl = fixture.debugElement.query(By.css('md-menu')).nativeElement; + const menuEl = fixture.debugElement.query(By.css('mat-menu')).nativeElement; const panel = overlayContainerElement.querySelector('.mat-menu-panel')!; expect(menuEl.classList).not.toContain('custom-one'); @@ -489,7 +489,7 @@ describe('MdMenu', () => { }); it('should emit an event when a menu item is clicked', () => { - const menuItem = overlayContainerElement.querySelector('[md-menu-item]') as HTMLElement; + const menuItem = overlayContainerElement.querySelector('[mat-menu-item]') as HTMLElement; menuItem.click(); fixture.detectChanges(); @@ -576,7 +576,7 @@ describe('MdMenu', () => { const spy = jasmine.createSpy('hover spy'); const subscription = instance.rootMenu.hover().subscribe(spy); - const menuItems = overlay.querySelectorAll('[md-menu-item]'); + const menuItems = overlay.querySelectorAll('[mat-menu-item]'); dispatchMouseEvent(menuItems[0], 'mouseenter'); fixture.detectChanges(); @@ -597,7 +597,7 @@ describe('MdMenu', () => { fixture.detectChanges(); expect(overlay.querySelectorAll('.mat-menu-panel').length).toBe(1, 'Expected one open menu'); - const items = Array.from(overlay.querySelectorAll('.mat-menu-panel [md-menu-item]')); + const items = Array.from(overlay.querySelectorAll('.mat-menu-panel [mat-menu-item]')); const levelOneTrigger = overlay.querySelector('#level-one-trigger')!; dispatchMouseEvent(levelOneTrigger, 'mouseenter'); @@ -621,7 +621,7 @@ describe('MdMenu', () => { instance.rootTriggerEl.nativeElement.click(); fixture.detectChanges(); - const items = Array.from(overlay.querySelectorAll('.mat-menu-panel [md-menu-item]')); + const items = Array.from(overlay.querySelectorAll('.mat-menu-panel [mat-menu-item]')); const levelOneTrigger = overlay.querySelector('#level-one-trigger')!; dispatchMouseEvent(levelOneTrigger, 'mouseenter'); @@ -895,7 +895,7 @@ describe('MdMenu', () => { instance.rootTrigger.openMenu(); fixture.detectChanges(); - const menuItems = overlay.querySelectorAll('[md-menu-item]'); + const menuItems = overlay.querySelectorAll('[mat-menu-item]'); expect(menuItems[0].classList).toContain('mat-menu-item-submenu-trigger'); expect(menuItems[1].classList).not.toContain('mat-menu-item-submenu-trigger'); @@ -1025,7 +1025,7 @@ describe('MdMenu', () => { Object.defineProperty(event, 'buttons', {get: () => 1}); event.preventDefault = jasmine.createSpy('preventDefault spy'); - dispatchMouseEvent(overlay.querySelector('[md-menu-item]')!, 'mousedown', 0, 0, event); + dispatchMouseEvent(overlay.querySelector('[mat-menu-item]')!, 'mousedown', 0, 0, event); expect(event.preventDefault).toHaveBeenCalled(); }); @@ -1033,13 +1033,13 @@ describe('MdMenu', () => { }); -describe('MdMenu default overrides', () => { +describe('MatMenu default overrides', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdMenuModule, NoopAnimationsModule], + imports: [MatMenuModule, NoopAnimationsModule], declarations: [SimpleMenu], providers: [{ - provide: MD_MENU_DEFAULT_OPTIONS, + provide: MAT_MENU_DEFAULT_OPTIONS, useValue: {overlapTrigger: false, xPosition: 'before', yPosition: 'above'}, }], }).compileComponents(); @@ -1058,50 +1058,50 @@ describe('MdMenu default overrides', () => { @Component({ template: ` - - - - - + + + + + ` }) class SimpleMenu { - @ViewChild(MdMenuTrigger) trigger: MdMenuTrigger; + @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; @ViewChild('triggerEl') triggerEl: ElementRef; - @ViewChild(MdMenu) menu: MdMenu; + @ViewChild(MatMenu) menu: MatMenu; closeCallback = jasmine.createSpy('menu closed callback'); } @Component({ template: ` - - - - + + + + ` }) class PositionedMenu { - @ViewChild(MdMenuTrigger) trigger: MdMenuTrigger; + @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; @ViewChild('triggerEl') triggerEl: ElementRef; xPosition: MenuPositionX = 'before'; yPosition: MenuPositionY = 'above'; } interface TestableMenu { - trigger: MdMenuTrigger; + trigger: MatMenuTrigger; triggerEl: ElementRef; } @Component({ template: ` - - - - + + + + ` }) class OverlapMenu implements TestableMenu { @Input() overlapTrigger: boolean; - @ViewChild(MdMenuTrigger) trigger: MdMenuTrigger; + @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; @ViewChild('triggerEl') triggerEl: ElementRef; } @@ -1113,14 +1113,14 @@ class OverlapMenu implements TestableMenu { `, - exportAs: 'mdCustomMenu, matCustomMenu' + exportAs: 'matCustomMenu' }) -class CustomMenuPanel implements MdMenuPanel { +class CustomMenuPanel implements MatMenuPanel { direction: Direction; xPosition: MenuPositionX = 'after'; yPosition: MenuPositionY = 'below'; overlapTrigger = true; - parentMenu: MdMenuPanel; + parentMenu: MatMenuPanel; @ViewChild(TemplateRef) templateRef: TemplateRef; @Output() close = new EventEmitter(); @@ -1130,96 +1130,96 @@ class CustomMenuPanel implements MdMenuPanel { @Component({ template: ` - - - + + + ` }) class CustomMenu { - @ViewChild(MdMenuTrigger) trigger: MdMenuTrigger; + @ViewChild(MatMenuTrigger) trigger: MatMenuTrigger; } @Component({ template: ` + [matMenuTriggerFor]="levelTwo" + #alternateTrigger="matMenuTrigger">Toggle alternate menu - - - - + + - + [matMenuTriggerFor]="lazy" + #lazyTrigger="matMenuTrigger">Three + - - - + - - - - - - - - - - - - - - + [matMenuTriggerFor]="levelTwo" + #levelTwoTrigger="matMenuTrigger">Five + + + + + + + + + + + + + + ` }) class NestedMenu { - @ViewChild('root') rootMenu: MdMenu; - @ViewChild('rootTrigger') rootTrigger: MdMenuTrigger; + @ViewChild('root') rootMenu: MatMenu; + @ViewChild('rootTrigger') rootTrigger: MatMenuTrigger; @ViewChild('rootTriggerEl') rootTriggerEl: ElementRef; - @ViewChild('alternateTrigger') alternateTrigger: MdMenuTrigger; + @ViewChild('alternateTrigger') alternateTrigger: MatMenuTrigger; - @ViewChild('levelOne') levelOneMenu: MdMenu; - @ViewChild('levelOneTrigger') levelOneTrigger: MdMenuTrigger; + @ViewChild('levelOne') levelOneMenu: MatMenu; + @ViewChild('levelOneTrigger') levelOneTrigger: MatMenuTrigger; - @ViewChild('levelTwo') levelTwoMenu: MdMenu; - @ViewChild('levelTwoTrigger') levelTwoTrigger: MdMenuTrigger; + @ViewChild('levelTwo') levelTwoMenu: MatMenu; + @ViewChild('levelTwoTrigger') levelTwoTrigger: MatMenuTrigger; - @ViewChild('lazy') lazyMenu: MdMenu; - @ViewChild('lazyTrigger') lazyTrigger: MdMenuTrigger; + @ViewChild('lazy') lazyMenu: MatMenu; + @ViewChild('lazyTrigger') lazyTrigger: MatMenuTrigger; showLazy = false; } @Component({ template: ` - + - - - + + + - - - + + + ` }) class NestedMenuCustomElevation { - @ViewChild('rootTrigger') rootTrigger: MdMenuTrigger; - @ViewChild('levelOneTrigger') levelOneTrigger: MdMenuTrigger; + @ViewChild('rootTrigger') rootTrigger: MatMenuTrigger; + @ViewChild('levelOneTrigger') levelOneTrigger: MatMenuTrigger; } diff --git a/src/lib/menu/menu.ts b/src/lib/menu/menu.ts index 1eff665c413b..4d0993cd6763 100644 --- a/src/lib/menu/menu.ts +++ b/src/lib/menu/menu.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -export {MdMenu, MdMenuDefaultOptions, MD_MENU_DEFAULT_OPTIONS} from './menu-directive'; -export {MdMenuItem} from './menu-item'; -export {MdMenuTrigger} from './menu-trigger'; -export {MdMenuPanel} from './menu-panel'; +export {MatMenu, MatMenuDefaultOptions, MAT_MENU_DEFAULT_OPTIONS} from './menu-directive'; +export {MatMenuItem} from './menu-item'; +export {MatMenuTrigger} from './menu-trigger'; +export {MatMenuPanel} from './menu-panel'; export {MenuPositionX, MenuPositionY} from './menu-positions'; diff --git a/src/lib/menu/public_api.ts b/src/lib/menu/public_api.ts index 21d9f21df158..39c6fdda609b 100644 --- a/src/lib/menu/public_api.ts +++ b/src/lib/menu/public_api.ts @@ -8,6 +8,6 @@ export * from './menu-module'; export * from './menu'; -export {MD_MENU_SCROLL_STRATEGY} from './menu-trigger'; +export {MAT_MENU_SCROLL_STRATEGY} from './menu-trigger'; export {fadeInItems, transformMenu} from './menu-animations'; -export * from './mat-exports'; + diff --git a/src/lib/paginator/mat-exports.ts b/src/lib/paginator/mat-exports.ts deleted file mode 100644 index 26c46461f0bb..000000000000 --- a/src/lib/paginator/mat-exports.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdPaginator} from './paginator'; -import {MdPaginatorIntl} from './paginator-intl'; -import {MdPaginatorModule} from './paginator-module'; - - -export {MdPaginator as MatPaginator}; -export {MdPaginatorIntl as MatPaginatorIntl}; -export {MdPaginatorModule as MatPaginatorModule}; diff --git a/src/lib/paginator/paginator-intl.ts b/src/lib/paginator/paginator-intl.ts index 1c9f6ec4c6f8..5e0bac5dda7e 100644 --- a/src/lib/paginator/paginator-intl.ts +++ b/src/lib/paginator/paginator-intl.ts @@ -10,11 +10,11 @@ import {Injectable} from '@angular/core'; import {Subject} from 'rxjs/Subject'; /** - * To modify the labels and text displayed, create a new instance of MdPaginatorIntl and + * To modify the labels and text displayed, create a new instance of MatPaginatorIntl and * include it in a custom provider */ @Injectable() -export class MdPaginatorIntl { +export class MatPaginatorIntl { /** * Stream that emits whenever the labels here are changed. Use this to notify * components if the labels have changed after initialization. diff --git a/src/lib/paginator/paginator-module.ts b/src/lib/paginator/paginator-module.ts index a9873e73e2da..c5eede24e2ff 100644 --- a/src/lib/paginator/paginator-module.ts +++ b/src/lib/paginator/paginator-module.ts @@ -8,22 +8,22 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {MdButtonModule} from '@angular/material/button'; -import {MdSelectModule} from '@angular/material/select'; -import {MdTooltipModule} from '@angular/material/tooltip'; -import {MdPaginator} from './paginator'; -import {MdPaginatorIntl} from './paginator-intl'; +import {MatButtonModule} from '@angular/material/button'; +import {MatSelectModule} from '@angular/material/select'; +import {MatTooltipModule} from '@angular/material/tooltip'; +import {MatPaginator} from './paginator'; +import {MatPaginatorIntl} from './paginator-intl'; @NgModule({ imports: [ CommonModule, - MdButtonModule, - MdSelectModule, - MdTooltipModule, + MatButtonModule, + MatSelectModule, + MatTooltipModule, ], - exports: [MdPaginator], - declarations: [MdPaginator], - providers: [MdPaginatorIntl], + exports: [MatPaginator], + declarations: [MatPaginator], + providers: [MatPaginatorIntl], }) -export class MdPaginatorModule {} +export class MatPaginatorModule {} diff --git a/src/lib/paginator/paginator.md b/src/lib/paginator/paginator.md index a744fb95002d..7284bb8829eb 100644 --- a/src/lib/paginator/paginator.md +++ b/src/lib/paginator/paginator.md @@ -1,4 +1,4 @@ -`` provides navigation for paged information, typically used with a table. +`` provides navigation for paged information, typically used with a table. @@ -19,11 +19,11 @@ dropdown can be set via `pageSizeOptions` The current pageSize will always appear in the dropdown, even if it is not included in pageSizeOptions. ### Internationalization -The labels for the paginator can be customized by providing your own instance of `MdPaginatorIntl`. +The labels for the paginator can be customized by providing your own instance of `MatPaginatorIntl`. This will allow you to change the following: 1. The label for the length of each page. 2. The range text displayed to the user. 3. The tooltip messages on the navigation buttons. ### Accessibility -The `aria-label`s for next page and previous page buttons can be set in `MdPaginatorIntl`. +The `aria-label`s for next page and previous page buttons can be set in `MatPaginatorIntl`. diff --git a/src/lib/paginator/paginator.spec.ts b/src/lib/paginator/paginator.spec.ts index bf3d9cd96ef0..234b5f32808e 100644 --- a/src/lib/paginator/paginator.spec.ts +++ b/src/lib/paginator/paginator.spec.ts @@ -1,37 +1,37 @@ import {async, ComponentFixture, TestBed, inject} from '@angular/core/testing'; -import {MdPaginatorModule} from './index'; -import {MdPaginator, PageEvent} from './paginator'; +import {MatPaginatorModule} from './index'; +import {MatPaginator, PageEvent} from './paginator'; import {Component, ViewChild} from '@angular/core'; -import {MdPaginatorIntl} from './paginator-intl'; +import {MatPaginatorIntl} from './paginator-intl'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {dispatchMouseEvent} from '@angular/cdk/testing'; -describe('MdPaginator', () => { - let fixture: ComponentFixture; - let component: MdPaginatorApp; - let paginator: MdPaginator; +describe('MatPaginator', () => { + let fixture: ComponentFixture; + let component: MatPaginatorApp; + let paginator: MatPaginator; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - MdPaginatorModule, + MatPaginatorModule, NoopAnimationsModule, ], declarations: [ - MdPaginatorApp, - MdPaginatorWithoutPageSizeApp, - MdPaginatorWithoutOptionsApp, - MdPaginatorWithoutInputsApp, + MatPaginatorApp, + MatPaginatorWithoutPageSizeApp, + MatPaginatorWithoutOptionsApp, + MatPaginatorWithoutInputsApp, ], - providers: [MdPaginatorIntl] + providers: [MatPaginatorIntl] }).compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(MdPaginatorApp); + fixture = TestBed.createComponent(MatPaginatorApp); component = fixture.componentInstance; - paginator = component.mdPaginator; + paginator = component.paginator; fixture.detectChanges(); }); @@ -92,7 +92,7 @@ describe('MdPaginator', () => { }); it('should re-render when the i18n labels change', - inject([MdPaginatorIntl], (intl: MdPaginatorIntl) => { + inject([MatPaginatorIntl], (intl: MatPaginatorIntl) => { const label = fixture.nativeElement.querySelector('.mat-paginator-page-size-label'); intl.itemsPerPageLabel = '1337 items per page'; @@ -175,18 +175,18 @@ describe('MdPaginator', () => { }); it('should default the page size options to the page size if no options provided', () => { - const withoutOptionsAppFixture = TestBed.createComponent(MdPaginatorWithoutOptionsApp); + const withoutOptionsAppFixture = TestBed.createComponent(MatPaginatorWithoutOptionsApp); withoutOptionsAppFixture.detectChanges(); - expect(withoutOptionsAppFixture.componentInstance.mdPaginator._displayedPageSizeOptions) + expect(withoutOptionsAppFixture.componentInstance.paginator._displayedPageSizeOptions) .toEqual([10]); }); it('should default the page size to the first page size option if not provided', () => { - const withoutPageSizeAppFixture = TestBed.createComponent(MdPaginatorWithoutPageSizeApp); + const withoutPageSizeAppFixture = TestBed.createComponent(MatPaginatorWithoutPageSizeApp); withoutPageSizeAppFixture.detectChanges(); - expect(withoutPageSizeAppFixture.componentInstance.mdPaginator.pageSize).toEqual(10); + expect(withoutPageSizeAppFixture.componentInstance.paginator.pageSize).toEqual(10); }); it('should show a sorted list of page size options including the current page size', () => { @@ -263,15 +263,15 @@ function getNextButton(fixture: ComponentFixture) { @Component({ template: ` - - + `, }) -class MdPaginatorApp { +class MatPaginatorApp { pageIndex = 0; pageSize = 10; pageSizeOptions = [5, 10, 25, 100]; @@ -279,7 +279,7 @@ class MdPaginatorApp { latestPageEvent: PageEvent | null; - @ViewChild(MdPaginator) mdPaginator: MdPaginator; + @ViewChild(MatPaginator) paginator: MatPaginator; goToLastPage() { this.pageIndex = Math.ceil(this.length / this.pageSize); @@ -288,27 +288,27 @@ class MdPaginatorApp { @Component({ template: ` - + `, }) -class MdPaginatorWithoutInputsApp { - @ViewChild(MdPaginator) mdPaginator: MdPaginator; +class MatPaginatorWithoutInputsApp { + @ViewChild(MatPaginator) paginator: MatPaginator; } @Component({ template: ` - + `, }) -class MdPaginatorWithoutPageSizeApp { - @ViewChild(MdPaginator) mdPaginator: MdPaginator; +class MatPaginatorWithoutPageSizeApp { + @ViewChild(MatPaginator) paginator: MatPaginator; } @Component({ template: ` - + `, }) -class MdPaginatorWithoutOptionsApp { - @ViewChild(MdPaginator) mdPaginator: MdPaginator; +class MatPaginatorWithoutOptionsApp { + @ViewChild(MatPaginator) paginator: MatPaginator; } diff --git a/src/lib/paginator/paginator.ts b/src/lib/paginator/paginator.ts index 22391029aaf9..5e45fd2a1205 100644 --- a/src/lib/paginator/paginator.ts +++ b/src/lib/paginator/paginator.ts @@ -17,9 +17,8 @@ import { Output, ViewEncapsulation, } from '@angular/core'; -import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; import {Subscription} from 'rxjs/Subscription'; -import {MdPaginatorIntl} from './paginator-intl'; +import {MatPaginatorIntl} from './paginator-intl'; /** The default page size if there is no page size and there are no provided page size options. */ const DEFAULT_PAGE_SIZE = 50; @@ -46,18 +45,17 @@ export class PageEvent { */ @Component({ moduleId: module.id, - selector: 'md-paginator, mat-paginator', + selector: 'mat-paginator', templateUrl: 'paginator.html', styleUrls: ['paginator.css'], host: { 'class': 'mat-paginator', }, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdPaginator implements OnInit, OnDestroy { +export class MatPaginator implements OnInit, OnDestroy { private _initialized: boolean; private _intlChanges: Subscription; @@ -103,7 +101,7 @@ export class MdPaginator implements OnInit, OnDestroy { /** Displayed set of page size options. Will be sorted and include current page size. */ _displayedPageSizeOptions: number[]; - constructor(public _intl: MdPaginatorIntl, + constructor(public _intl: MatPaginatorIntl, private _changeDetectorRef: ChangeDetectorRef) { this._intlChanges = _intl.changes.subscribe(() => this._changeDetectorRef.markForCheck()); } diff --git a/src/lib/paginator/public_api.ts b/src/lib/paginator/public_api.ts index f8689f8d2280..0dc5a6a5505c 100644 --- a/src/lib/paginator/public_api.ts +++ b/src/lib/paginator/public_api.ts @@ -9,4 +9,4 @@ export * from './paginator-module'; export * from './paginator'; export * from './paginator-intl'; -export * from './mat-exports'; + diff --git a/src/lib/progress-bar/mat-exports.ts b/src/lib/progress-bar/mat-exports.ts deleted file mode 100644 index 7550fc80e7df..000000000000 --- a/src/lib/progress-bar/mat-exports.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdProgressBar} from './progress-bar'; -import {MdProgressBarModule} from './progress-bar-module'; - - -export {MdProgressBar as MatProgressBar}; -export {MdProgressBarModule as MatProgressBarModule}; diff --git a/src/lib/progress-bar/progress-bar-module.ts b/src/lib/progress-bar/progress-bar-module.ts index c67dbcd654b7..0d8bf6c1086c 100644 --- a/src/lib/progress-bar/progress-bar-module.ts +++ b/src/lib/progress-bar/progress-bar-module.ts @@ -8,13 +8,13 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {MdCommonModule} from '@angular/material/core'; -import {MdProgressBar} from './progress-bar'; +import {MatCommonModule} from '@angular/material/core'; +import {MatProgressBar} from './progress-bar'; @NgModule({ - imports: [CommonModule, MdCommonModule], - exports: [MdProgressBar, MdCommonModule], - declarations: [MdProgressBar], + imports: [CommonModule, MatCommonModule], + exports: [MatProgressBar, MatCommonModule], + declarations: [MatProgressBar], }) -export class MdProgressBarModule {} +export class MatProgressBarModule {} diff --git a/src/lib/progress-bar/progress-bar.md b/src/lib/progress-bar/progress-bar.md index a6ceee2cfd62..98c3d301913f 100644 --- a/src/lib/progress-bar/progress-bar.md +++ b/src/lib/progress-bar/progress-bar.md @@ -1,4 +1,4 @@ -`` is a horizontal progress-bar for indicating progress and activity. +`` is a horizontal progress-bar for indicating progress and activity. diff --git a/src/lib/progress-bar/progress-bar.scss b/src/lib/progress-bar/progress-bar.scss index cf537f16bcde..1d82aadfb7e3 100644 --- a/src/lib/progress-bar/progress-bar.scss +++ b/src/lib/progress-bar/progress-bar.scss @@ -7,11 +7,11 @@ $mat-progress-bar-piece-animation-duration: 250ms !default; .mat-progress-bar { display: block; - // Height is provided for md-progress-bar to act as a default. + // Height is provided for mat-progress-bar to act as a default. height: $mat-progress-bar-height; overflow: hidden; position: relative; - // translateZ is added to force the md-progress-bar into its own GPU layer. + // translateZ is added to force the mat-progress-bar into its own GPU layer. transform: translateZ(0); transition: opacity $mat-progress-bar-piece-animation-duration linear; width: 100%; @@ -110,7 +110,7 @@ $mat-progress-bar-piece-animation-duration: 250ms !default; } -// The values used for animations in md-progress-bar, both timing and transformation, can be +// The values used for animations in mat-progress-bar, both timing and transformation, can be // considered magic values. They are sourced from the Material Design example spec and duplicate // the values of the original designers definitions. // diff --git a/src/lib/progress-bar/progress-bar.spec.ts b/src/lib/progress-bar/progress-bar.spec.ts index f5208b321f65..be8337dcbd14 100644 --- a/src/lib/progress-bar/progress-bar.spec.ts +++ b/src/lib/progress-bar/progress-bar.spec.ts @@ -1,14 +1,14 @@ import {TestBed, async, ComponentFixture} from '@angular/core/testing'; import {Component} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {MdProgressBarModule} from './index'; +import {MatProgressBarModule} from './index'; -describe('MdProgressBar', () => { +describe('MatProgressBar', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdProgressBarModule], + imports: [MatProgressBarModule], declarations: [ BasicProgressBar, BufferProgressBar, @@ -28,18 +28,18 @@ describe('MdProgressBar', () => { }); it('should apply a mode of "determinate" if no mode is provided.', () => { - let progressElement = fixture.debugElement.query(By.css('md-progress-bar')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-bar')); expect(progressElement.componentInstance.mode).toBe('determinate'); }); it('should define default values for value and bufferValue attributes', () => { - let progressElement = fixture.debugElement.query(By.css('md-progress-bar')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-bar')); expect(progressElement.componentInstance.value).toBe(0); expect(progressElement.componentInstance.bufferValue).toBe(0); }); it('should clamp value and bufferValue between 0 and 100', () => { - let progressElement = fixture.debugElement.query(By.css('md-progress-bar')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-bar')); let progressComponent = progressElement.componentInstance; progressComponent.value = 50; @@ -62,7 +62,7 @@ describe('MdProgressBar', () => { }); it('should return the transform attribute for bufferValue and mode', () => { - let progressElement = fixture.debugElement.query(By.css('md-progress-bar')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-bar')); let progressComponent = progressElement.componentInstance; expect(progressComponent._primaryTransform()).toEqual({transform: 'scaleX(0)'}); @@ -98,15 +98,15 @@ describe('MdProgressBar', () => { }); it('should not modify the mode if a valid mode is provided.', () => { - let progressElement = fixture.debugElement.query(By.css('md-progress-bar')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-bar')); expect(progressElement.componentInstance.mode).toBe('buffer'); }); }); }); -@Component({template: ''}) +@Component({template: ''}) class BasicProgressBar { } -@Component({template: ''}) +@Component({template: ''}) class BufferProgressBar { } diff --git a/src/lib/progress-bar/progress-bar.ts b/src/lib/progress-bar/progress-bar.ts index 36bdc00aa7d5..2396d693e012 100644 --- a/src/lib/progress-bar/progress-bar.ts +++ b/src/lib/progress-bar/progress-bar.ts @@ -13,11 +13,11 @@ import {Component, ChangeDetectionStrategy, Input, ViewEncapsulation} from '@ang /** - * component. + * component. */ @Component({ moduleId: module.id, - selector: 'md-progress-bar, mat-progress-bar', + selector: 'mat-progress-bar', host: { 'role': 'progressbar', 'aria-valuemin': '0', @@ -35,7 +35,7 @@ import {Component, ChangeDetectionStrategy, Input, ViewEncapsulation} from '@ang encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdProgressBar { +export class MatProgressBar { /** Color of the progress bar. */ @Input() color: 'primary' | 'accent' | 'warn' = 'primary'; diff --git a/src/lib/progress-bar/public_api.ts b/src/lib/progress-bar/public_api.ts index e4284632b898..4d60aeebce2a 100644 --- a/src/lib/progress-bar/public_api.ts +++ b/src/lib/progress-bar/public_api.ts @@ -8,4 +8,4 @@ export * from './progress-bar-module'; export * from './progress-bar'; -export * from './mat-exports'; + diff --git a/src/lib/progress-spinner/mat-exports.ts b/src/lib/progress-spinner/mat-exports.ts deleted file mode 100644 index 6b1c3708aa8d..000000000000 --- a/src/lib/progress-spinner/mat-exports.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MdProgressSpinner, - MdProgressSpinnerBase, - MdProgressSpinnerCssMatStyler, - MdSpinner, -} from './progress-spinner'; -import {MdProgressSpinnerModule} from './progress-spinner-module'; - - -export {MdProgressSpinner as MatProgressSpinner}; -export {MdProgressSpinnerBase as MatProgressSpinnerBase}; -export {MdProgressSpinnerCssMatStyler as MatProgressSpinnerCssMatStyler}; -export {MdProgressSpinnerModule as MatProgressSpinnerModule}; -export {MdSpinner as MatSpinner}; diff --git a/src/lib/progress-spinner/progress-spinner-module.ts b/src/lib/progress-spinner/progress-spinner-module.ts index cb106eaee75b..11e7e841acab 100644 --- a/src/lib/progress-spinner/progress-spinner-module.ts +++ b/src/lib/progress-spinner/progress-spinner-module.ts @@ -7,26 +7,26 @@ */ import {NgModule} from '@angular/core'; -import {MdCommonModule} from '@angular/material/core'; +import {MatCommonModule} from '@angular/material/core'; import { - MdProgressSpinner, - MdSpinner, - MdProgressSpinnerCssMatStyler, + MatProgressSpinner, + MatSpinner, + MatProgressSpinnerCssMatStyler, } from './progress-spinner'; @NgModule({ - imports: [MdCommonModule], + imports: [MatCommonModule], exports: [ - MdProgressSpinner, - MdSpinner, - MdCommonModule, - MdProgressSpinnerCssMatStyler + MatProgressSpinner, + MatSpinner, + MatCommonModule, + MatProgressSpinnerCssMatStyler ], declarations: [ - MdProgressSpinner, - MdSpinner, - MdProgressSpinnerCssMatStyler + MatProgressSpinner, + MatSpinner, + MatProgressSpinnerCssMatStyler ], }) -export class MdProgressSpinnerModule {} +export class MatProgressSpinnerModule {} diff --git a/src/lib/progress-spinner/progress-spinner.md b/src/lib/progress-spinner/progress-spinner.md index 1843e1fe40b4..0b591738df9c 100644 --- a/src/lib/progress-spinner/progress-spinner.md +++ b/src/lib/progress-spinner/progress-spinner.md @@ -1,10 +1,10 @@ -`` and `` are a circular indicators of progress and activity. +`` and `` are a circular indicators of progress and activity. ### Progress mode The progress-spinner supports two modes, "determinate" and "indeterminate". -The `` component is an alias for ``. +The `` component is an alias for ``. | Mode | Description | |---------------|----------------------------------------------------------------------------------| diff --git a/src/lib/progress-spinner/progress-spinner.spec.ts b/src/lib/progress-spinner/progress-spinner.spec.ts index fc8efd45a373..755b499398b1 100644 --- a/src/lib/progress-spinner/progress-spinner.spec.ts +++ b/src/lib/progress-spinner/progress-spinner.spec.ts @@ -1,15 +1,15 @@ import {TestBed, async} from '@angular/core/testing'; import {Component} from '@angular/core'; import {By} from '@angular/platform-browser'; -import {MdProgressSpinnerModule} from './index'; +import {MatProgressSpinnerModule} from './index'; import {PROGRESS_SPINNER_STROKE_WIDTH} from './progress-spinner'; -describe('MdProgressSpinner', () => { +describe('MatProgressSpinner', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdProgressSpinnerModule], + imports: [MatProgressSpinnerModule], declarations: [ BasicProgressSpinner, IndeterminateProgressSpinner, @@ -29,7 +29,7 @@ describe('MdProgressSpinner', () => { let fixture = TestBed.createComponent(BasicProgressSpinner); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(progressElement.componentInstance.mode).toBe('determinate'); }); @@ -37,7 +37,7 @@ describe('MdProgressSpinner', () => { let fixture = TestBed.createComponent(IndeterminateProgressSpinner); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(progressElement.componentInstance.mode).toBe('indeterminate'); }); @@ -45,13 +45,13 @@ describe('MdProgressSpinner', () => { let fixture = TestBed.createComponent(BasicProgressSpinner); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(progressElement.componentInstance.value).toBeUndefined(); }); it('should set the value to 0 when the mode is set to indeterminate', () => { let fixture = TestBed.createComponent(ProgressSpinnerWithValueAndBoundMode); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); fixture.componentInstance.mode = 'determinate'; fixture.detectChanges(); @@ -65,7 +65,7 @@ describe('MdProgressSpinner', () => { let fixture = TestBed.createComponent(BasicProgressSpinner); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); let progressComponent = progressElement.componentInstance; progressComponent.value = 50; @@ -88,7 +88,7 @@ describe('MdProgressSpinner', () => { let fixture = TestBed.createComponent(IndeterminateProgressSpinnerWithNgIf); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(progressElement.componentInstance.interdeterminateInterval).toBeTruthy(); fixture.componentInstance.isHidden = true; @@ -100,7 +100,7 @@ describe('MdProgressSpinner', () => { let fixture = TestBed.createComponent(SpinnerWithNgIf); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-spinner')); expect(progressElement.componentInstance.interdeterminateInterval).toBeTruthy(); @@ -131,11 +131,11 @@ describe('MdProgressSpinner', () => { .toBe(40, 'Expected the custom stroke width to be applied to the path element.'); }); - it('should set the color class on the md-spinner', () => { + it('should set the color class on the mat-spinner', () => { let fixture = TestBed.createComponent(SpinnerWithColor); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-spinner')); expect(progressElement.nativeElement.classList).toContain('mat-primary'); @@ -146,11 +146,11 @@ describe('MdProgressSpinner', () => { expect(progressElement.nativeElement.classList).not.toContain('mat-primary'); }); - it('should set the color class on the md-progress-spinner', () => { + it('should set the color class on the mat-progress-spinner', () => { let fixture = TestBed.createComponent(ProgressSpinnerWithColor); fixture.detectChanges(); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')); + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')); expect(progressElement.nativeElement.classList).toContain('mat-primary'); @@ -163,7 +163,7 @@ describe('MdProgressSpinner', () => { it('should re-render the circle when switching from indeterminate to determinate mode', () => { let fixture = TestBed.createComponent(ProgressSpinnerWithValueAndBoundMode); - let progressElement = fixture.debugElement.query(By.css('md-progress-spinner')).nativeElement; + let progressElement = fixture.debugElement.query(By.css('mat-progress-spinner')).nativeElement; fixture.componentInstance.mode = 'indeterminate'; fixture.detectChanges(); @@ -189,29 +189,29 @@ describe('MdProgressSpinner', () => { }); -@Component({template: ''}) +@Component({template: ''}) class BasicProgressSpinner {} -@Component({template: ''}) +@Component({template: ''}) class ProgressSpinnerCustomStrokeWidth { strokeWidth: number; } -@Component({template: ''}) +@Component({template: ''}) class IndeterminateProgressSpinner { } -@Component({template: ''}) +@Component({template: ''}) class ProgressSpinnerWithValueAndBoundMode { mode = 'indeterminate'; } @Component({template: ` - `}) + `}) class IndeterminateProgressSpinnerWithNgIf { isHidden = false; } -@Component({template: ``}) +@Component({template: ``}) class SpinnerWithNgIf { isHidden = false; } -@Component({template: ``}) +@Component({template: ``}) class SpinnerWithColor { color: string = 'primary'; } -@Component({template: ``}) +@Component({template: ``}) class ProgressSpinnerWithColor { color: string = 'primary'; } diff --git a/src/lib/progress-spinner/progress-spinner.ts b/src/lib/progress-spinner/progress-spinner.ts index 136a18335815..56b4f1e872f8 100644 --- a/src/lib/progress-spinner/progress-spinner.ts +++ b/src/lib/progress-spinner/progress-spinner.ts @@ -51,24 +51,24 @@ type EasingFn = (currentTime: number, startValue: number, * @docs-private */ @Directive({ - selector: 'md-progress-spinner, mat-progress-spinner', + selector: 'mat-progress-spinner', host: {'class': 'mat-progress-spinner'} }) -export class MdProgressSpinnerCssMatStyler {} +export class MatProgressSpinnerCssMatStyler {} -// Boilerplate for applying mixins to MdProgressSpinner. +// Boilerplate for applying mixins to MatProgressSpinner. /** @docs-private */ -export class MdProgressSpinnerBase { +export class MatProgressSpinnerBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdProgressSpinnerMixinBase = mixinColor(MdProgressSpinnerBase, 'primary'); +export const _MatProgressSpinnerMixinBase = mixinColor(MatProgressSpinnerBase, 'primary'); /** - * component. + * component. */ @Component({ moduleId: module.id, - selector: 'md-progress-spinner, mat-progress-spinner', + selector: 'mat-progress-spinner', host: { 'role': 'progressbar', 'class': 'mat-progress-spinner', @@ -84,7 +84,7 @@ export const _MdProgressSpinnerMixinBase = mixinColor(MdProgressSpinnerBase, 'pr encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdProgressSpinner extends _MdProgressSpinnerMixinBase +export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements OnDestroy, CanColor { /** The id of the last requested animation. */ @@ -272,14 +272,14 @@ export class MdProgressSpinner extends _MdProgressSpinnerMixinBase /** - * component. + * component. * * This is a component definition to be used as a convenience reference to create an - * indeterminate instance. + * indeterminate instance. */ @Component({ moduleId: module.id, - selector: 'md-spinner, mat-spinner', + selector: 'mat-spinner', host: { 'role': 'progressbar', 'mode': 'indeterminate', @@ -292,7 +292,7 @@ export class MdProgressSpinner extends _MdProgressSpinnerMixinBase encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdSpinner extends MdProgressSpinner { +export class MatSpinner extends MatProgressSpinner { constructor(elementRef: ElementRef, ngZone: NgZone, renderer: Renderer2) { super(renderer, elementRef, ngZone); this.mode = 'indeterminate'; diff --git a/src/lib/progress-spinner/public_api.ts b/src/lib/progress-spinner/public_api.ts index 563453f03d91..fc42969ad9c2 100644 --- a/src/lib/progress-spinner/public_api.ts +++ b/src/lib/progress-spinner/public_api.ts @@ -8,4 +8,4 @@ export * from './progress-spinner-module'; export * from './progress-spinner'; -export * from './mat-exports'; + diff --git a/src/lib/radio/mat-exports.ts b/src/lib/radio/mat-exports.ts deleted file mode 100644 index 75ef35bdb6f4..000000000000 --- a/src/lib/radio/mat-exports.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR, - MdRadioButton, - MdRadioButtonBase, - MdRadioChange, - MdRadioGroup, - MdRadioGroupBase, -} from './radio'; -import {MdRadioModule} from './radio-module'; - - -export {MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR as MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR}; -export {MdRadioButton as MatRadioButton}; -export {MdRadioButtonBase as MatRadioButtonBase}; -export {MdRadioChange as MatRadioChange}; -export {MdRadioGroup as MatRadioGroup}; -export {MdRadioGroupBase as MatRadioGroupBase}; -export {MdRadioModule as MatRadioModule}; diff --git a/src/lib/radio/public_api.ts b/src/lib/radio/public_api.ts index 0d89666ce7db..0456641c48fa 100644 --- a/src/lib/radio/public_api.ts +++ b/src/lib/radio/public_api.ts @@ -8,4 +8,4 @@ export * from './radio-module'; export * from './radio'; -export * from './mat-exports'; + diff --git a/src/lib/radio/radio-module.ts b/src/lib/radio/radio-module.ts index 114970a7ff10..59238a1682f1 100644 --- a/src/lib/radio/radio-module.ts +++ b/src/lib/radio/radio-module.ts @@ -10,17 +10,17 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {VIEWPORT_RULER_PROVIDER} from '@angular/cdk/overlay'; import { - MdRippleModule, - MdCommonModule, + MatRippleModule, + MatCommonModule, UNIQUE_SELECTION_DISPATCHER_PROVIDER, } from '@angular/material/core'; -import {MdRadioGroup, MdRadioButton} from './radio'; +import {MatRadioGroup, MatRadioButton} from './radio'; import {A11yModule} from '@angular/cdk/a11y'; @NgModule({ - imports: [CommonModule, MdRippleModule, MdCommonModule, A11yModule], - exports: [MdRadioGroup, MdRadioButton, MdCommonModule], + imports: [CommonModule, MatRippleModule, MatCommonModule, A11yModule], + exports: [MatRadioGroup, MatRadioButton, MatCommonModule], providers: [UNIQUE_SELECTION_DISPATCHER_PROVIDER, VIEWPORT_RULER_PROVIDER], - declarations: [MdRadioGroup, MdRadioButton], + declarations: [MatRadioGroup, MatRadioButton], }) -export class MdRadioModule {} +export class MatRadioModule {} diff --git a/src/lib/radio/radio.md b/src/lib/radio/radio.md index da7b56704516..4a50e8c72c9e 100644 --- a/src/lib/radio/radio.md +++ b/src/lib/radio/radio.md @@ -1,4 +1,4 @@ -`` provides the same functionality as a native `` enhanced with +`` provides the same functionality as a native `` enhanced with Material Design styling and animations. @@ -6,7 +6,7 @@ Material Design styling and animations. All radio-buttons with the same `name` comprise a set from which only one may be selected at a time. ### Radio-button label -The radio-button label is provided as the content to the `` element. The label can +The radio-button label is provided as the content to the `` element. The label can be positioned before or after the radio-button by setting the `labelPosition` property to `'before'` or `'after'`. @@ -17,7 +17,7 @@ specify an appropriate label. ### Radio groups -Radio-buttons should typically be placed inside of an `` unless the DOM structure +Radio-buttons should typically be placed inside of an `` unless the DOM structure would make that impossible (e.g., radio-buttons inside of table cells). The radio-group has a `value` property that reflects the currently selected radio-button inside of the group. @@ -25,12 +25,12 @@ Individual radio-buttons inside of a radio-group will inherit the `name` of the ### Use with `@angular/forms` -`` is compatible with `@angular/forms` and supports both `FormsModule` +`` is compatible with `@angular/forms` and supports both `FormsModule` and `ReactiveFormsModule`. ### Accessibility -The `` uses an internal `` to provide an accessible experience. +The `` uses an internal `` to provide an accessible experience. This internal radio button receives focus and is automatically labelled by the text content of the -`` element. +`` element. Radio button groups should should be given a meaningful label via `aria-label` or `aria-labelledby`. diff --git a/src/lib/radio/radio.spec.ts b/src/lib/radio/radio.spec.ts index d87f5a623271..96f0447a9f37 100644 --- a/src/lib/radio/radio.spec.ts +++ b/src/lib/radio/radio.spec.ts @@ -5,13 +5,13 @@ import {By} from '@angular/platform-browser'; import {ViewportRuler} from '@angular/cdk/scrolling'; import {dispatchFakeEvent, FakeViewportRuler} from '@angular/cdk/testing'; import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '@angular/material/core'; -import {MdRadioButton, MdRadioChange, MdRadioGroup, MdRadioModule} from './index'; +import {MatRadioButton, MatRadioChange, MatRadioGroup, MatRadioModule} from './index'; -describe('MdRadio', () => { +describe('MatRadio', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdRadioModule, FormsModule, ReactiveFormsModule], + imports: [MatRadioModule, FormsModule, ReactiveFormsModule], declarations: [ FocusableRadioButton, RadiosInsideRadioGroup, @@ -35,8 +35,8 @@ describe('MdRadio', () => { let radioNativeElements: HTMLElement[]; let radioLabelElements: HTMLLabelElement[]; let radioInputElements: HTMLInputElement[]; - let groupInstance: MdRadioGroup; - let radioInstances: MdRadioButton[]; + let groupInstance: MatRadioGroup; + let radioInstances: MatRadioButton[]; let testComponent: RadiosInsideRadioGroup; beforeEach(async(() => { @@ -45,11 +45,11 @@ describe('MdRadio', () => { testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdRadioGroup)); + groupDebugElement = fixture.debugElement.query(By.directive(MatRadioGroup)); groupNativeElement = groupDebugElement.nativeElement; - groupInstance = groupDebugElement.injector.get(MdRadioGroup); + groupInstance = groupDebugElement.injector.get(MatRadioGroup); - radioDebugElements = fixture.debugElement.queryAll(By.directive(MdRadioButton)); + radioDebugElements = fixture.debugElement.queryAll(By.directive(MatRadioButton)); radioNativeElements = radioDebugElements.map(debugEl => debugEl.nativeElement); radioInstances = radioDebugElements.map(debugEl => debugEl.componentInstance); @@ -269,7 +269,7 @@ describe('MdRadio', () => { .toBe(1, 'Expected an enabled radio button to show ripples'); }); - it('should not show ripples if mdRippleDisabled input is set', () => { + it('should not show ripples if matRippleDisabled input is set', () => { testComponent.disableRipple = true; fixture.detectChanges(); @@ -385,8 +385,8 @@ describe('MdRadio', () => { let radioDebugElements: DebugElement[]; let innerRadios: DebugElement[]; let radioLabelElements: HTMLLabelElement[]; - let groupInstance: MdRadioGroup; - let radioInstances: MdRadioButton[]; + let groupInstance: MatRadioGroup; + let radioInstances: MatRadioButton[]; let testComponent: RadioGroupWithNgModel; let groupNgModel: NgModel; @@ -396,12 +396,12 @@ describe('MdRadio', () => { testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdRadioGroup)); + groupDebugElement = fixture.debugElement.query(By.directive(MatRadioGroup)); groupNativeElement = groupDebugElement.nativeElement; - groupInstance = groupDebugElement.injector.get(MdRadioGroup); + groupInstance = groupDebugElement.injector.get(MatRadioGroup); groupNgModel = groupDebugElement.injector.get(NgModel); - radioDebugElements = fixture.debugElement.queryAll(By.directive(MdRadioButton)); + radioDebugElements = fixture.debugElement.queryAll(By.directive(MatRadioButton)); radioInstances = radioDebugElements.map(debugEl => debugEl.componentInstance); innerRadios = fixture.debugElement.queryAll(By.css('input[type="radio"]')); @@ -494,7 +494,7 @@ describe('MdRadio', () => { describe('group with FormControl', () => { let fixture: ComponentFixture; let groupDebugElement: DebugElement; - let groupInstance: MdRadioGroup; + let groupInstance: MatRadioGroup; let testComponent: RadioGroupWithFormControl; beforeEach(() => { @@ -502,8 +502,8 @@ describe('MdRadio', () => { fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; - groupDebugElement = fixture.debugElement.query(By.directive(MdRadioGroup)); - groupInstance = groupDebugElement.injector.get(MdRadioGroup); + groupDebugElement = fixture.debugElement.query(By.directive(MatRadioGroup)); + groupInstance = groupDebugElement.injector.get(MatRadioGroup); }); it('should toggle the disabled state', () => { @@ -524,9 +524,9 @@ describe('MdRadio', () => { describe('as standalone', () => { let fixture: ComponentFixture; let radioDebugElements: DebugElement[]; - let seasonRadioInstances: MdRadioButton[]; - let weatherRadioInstances: MdRadioButton[]; - let fruitRadioInstances: MdRadioButton[]; + let seasonRadioInstances: MatRadioButton[]; + let weatherRadioInstances: MatRadioButton[]; + let fruitRadioInstances: MatRadioButton[]; let fruitRadioNativeInputs: HTMLElement[]; let testComponent: StandaloneRadioButtons; @@ -536,7 +536,7 @@ describe('MdRadio', () => { testComponent = fixture.debugElement.componentInstance; - radioDebugElements = fixture.debugElement.queryAll(By.directive(MdRadioButton)); + radioDebugElements = fixture.debugElement.queryAll(By.directive(MatRadioButton)); seasonRadioInstances = radioDebugElements .filter(debugEl => debugEl.componentInstance.name == 'season') .map(debugEl => debugEl.componentInstance); @@ -665,22 +665,22 @@ describe('MdRadio', () => { @Component({ template: ` - - Charmander - - + + Squirtle - - + + Bulbasaur - - + + ` }) class RadiosInsideRadioGroup { @@ -696,21 +696,21 @@ class RadiosInsideRadioGroup { @Component({ template: ` - Spring - Summer - Autumn + Spring + Summer + Autumn - Spring - Summer - Autumn + Spring + Summer + Autumn Baby Banana - - - Raspberry + + Raspberry ` }) class StandaloneRadioButtons { @@ -721,11 +721,11 @@ class StandaloneRadioButtons { @Component({ template: ` - - + + {{option.label}} - - + + ` }) class RadioGroupWithNgModel { @@ -735,14 +735,14 @@ class RadioGroupWithNgModel { {label: 'Chocolate', value: 'chocolate'}, {label: 'Strawberry', value: 'strawberry'}, ]; - lastEvent: MdRadioChange; + lastEvent: MatRadioChange; } @Component({ template: ` - - One - + + One + ` }) class RadioGroupWithFormControl { @@ -750,6 +750,6 @@ class RadioGroupWithFormControl { } @Component({ - template: `` + template: `` }) class FocusableRadioButton {} diff --git a/src/lib/radio/radio.ts b/src/lib/radio/radio.ts index 406dd39f715a..530c77f85a0b 100644 --- a/src/lib/radio/radio.ts +++ b/src/lib/radio/radio.ts @@ -8,78 +8,81 @@ import { AfterContentInit, + AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, Directive, ElementRef, - Renderer2, EventEmitter, + forwardRef, Input, + OnDestroy, OnInit, Optional, Output, QueryList, - ViewEncapsulation, - forwardRef, + Renderer2, ViewChild, - OnDestroy, - AfterViewInit, + ViewEncapsulation, } from '@angular/core'; -import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms'; +import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import { + CanColor, + CanDisable, + CanDisableRipple, + MatRipple, + mixinColor, + mixinDisabled, + mixinDisableRipple, RippleRef, UniqueSelectionDispatcher, - MdRipple, MATERIAL_COMPATIBILITY_MODE, } from '@angular/material/core'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; -import {mixinDisabled, CanDisable} from '@angular/material/core'; -import {CanColor, mixinColor} from '@angular/material/core'; -import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; // Increasing integer for generating unique ids for radio components. let nextUniqueId = 0; /** - * Provider Expression that allows md-radio-group to register as a ControlValueAccessor. This + * Provider Expression that allows mat-radio-group to register as a ControlValueAccessor. This * allows it to support [(ngModel)] and ngControl. * @docs-private */ -export const MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = { +export const MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdRadioGroup), + useExisting: forwardRef(() => MatRadioGroup), multi: true }; -/** Change event object emitted by MdRadio and MdRadioGroup. */ -export class MdRadioChange { - /** The MdRadioButton that emits the change event. */ - source: MdRadioButton | null; - /** The value of the MdRadioButton. */ +/** Change event object emitted by MatRadio and MatRadioGroup. */ +export class MatRadioChange { + /** The MatRadioButton that emits the change event. */ + source: MatRadioButton | null; + /** The value of the MatRadioButton. */ value: any; } -// Boilerplate for applying mixins to MdRadioGroup. +// Boilerplate for applying mixins to MatRadioGroup. /** @docs-private */ -export class MdRadioGroupBase { } -export const _MdRadioGroupMixinBase = mixinDisabled(MdRadioGroupBase); +export class MatRadioGroupBase { } +export const _MatRadioGroupMixinBase = mixinDisabled(MatRadioGroupBase); /** - * A group of radio buttons. May contain one or more `` elements. + * A group of radio buttons. May contain one or more `` elements. */ @Directive({ - selector: 'md-radio-group, mat-radio-group', - providers: [MD_RADIO_GROUP_CONTROL_VALUE_ACCESSOR], + selector: 'mat-radio-group', + providers: [MAT_RADIO_GROUP_CONTROL_VALUE_ACCESSOR], host: { 'role': 'radiogroup', 'class': 'mat-radio-group', }, inputs: ['disabled'], }) -export class MdRadioGroup extends _MdRadioGroupMixinBase +export class MatRadioGroup extends _MatRadioGroupMixinBase implements AfterContentInit, ControlValueAccessor, CanDisable { /** * Selected value for group. Should equal the value of the selected radio button if there *is* @@ -90,10 +93,10 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase private _value: any = null; /** The HTML name attribute applied to radio buttons in this group. */ - private _name: string = `md-radio-group-${nextUniqueId++}`; + private _name: string = `mat-radio-group-${nextUniqueId++}`; /** The currently selected radio button. Should match value. */ - private _selected: MdRadioButton | null = null; + private _selected: MatRadioButton | null = null; /** Whether the `value` has been set to its initial value. */ private _isInitialized: boolean = false; @@ -121,10 +124,10 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase * Change events are only emitted when the value changes due to user interaction with * a radio button (the same behavior as ``). */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** Child radio buttons. */ - @ContentChildren(forwardRef(() => MdRadioButton)) _radios: QueryList; + @ContentChildren(forwardRef(() => MatRadioButton)) _radios: QueryList; /** Name of the radio button group. All radio buttons inside this group will use this name. */ @Input() @@ -183,7 +186,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase /** Whether the radio button is selected. */ @Input() get selected() { return this._selected; } - set selected(selected: MdRadioButton | null) { + set selected(selected: MatRadioButton | null) { this._selected = selected; this.value = selected ? selected.value : null; this._checkSelectedRadioButton(); @@ -215,8 +218,8 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase */ ngAfterContentInit() { // Mark this component as initialized in AfterContentInit because the initial value can - // possibly be set by NgModel on MdRadioGroup, and it is possible that the OnInit of the - // NgModel occurs *after* the OnInit of the MdRadioGroup. + // possibly be set by NgModel on MatRadioGroup, and it is possible that the OnInit of the + // NgModel occurs *after* the OnInit of the MatRadioGroup. this._isInitialized = true; } @@ -257,7 +260,7 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase /** Dispatch change event with current selection and group value. */ _emitChangeEvent(): void { if (this._isInitialized) { - const event = new MdRadioChange(); + const event = new MatRadioChange(); event.source = this._selected; event.value = this._value; this.change.emit(event); @@ -307,21 +310,22 @@ export class MdRadioGroup extends _MdRadioGroupMixinBase } } -// Boilerplate for applying mixins to MdRadioButton. +// Boilerplate for applying mixins to MatRadioButton. /** @docs-private */ -export class MdRadioButtonBase { +export class MatRadioButtonBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } // As per Material design specifications the selection control radio should use the accent color // palette by default. https://material.io/guidelines/components/selection-controls.html -export const _MdRadioButtonMixinBase = mixinColor(mixinDisableRipple(MdRadioButtonBase), 'accent'); +export const _MatRadioButtonMixinBase = + mixinColor(mixinDisableRipple(MatRadioButtonBase), 'accent'); /** * A radio-button. May be inside of */ @Component({ moduleId: module.id, - selector: 'md-radio-button, mat-radio-button', + selector: 'mat-radio-button', templateUrl: 'radio.html', styleUrls: ['radio.css'], inputs: ['color', 'disableRipple'], @@ -338,12 +342,11 @@ export const _MdRadioButtonMixinBase = mixinColor(mixinDisableRipple(MdRadioButt '(focus)': '_inputElement.nativeElement.focus()', }, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdRadioButton extends _MdRadioButtonMixinBase +export class MatRadioButton extends _MatRadioButtonMixinBase implements OnInit, AfterViewInit, OnDestroy, CanColor, CanDisableRipple { - private _uniqueId: string = `md-radio-${++nextUniqueId}`; + private _uniqueId: string = `mat-radio-${++nextUniqueId}`; /** The unique ID for the radio button. */ @Input() id: string = this._uniqueId; @@ -454,12 +457,12 @@ export class MdRadioButton extends _MdRadioButtonMixinBase * Change events are only emitted when the value changes due to user interaction with * the radio button (the same behavior as ``). */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** The parent radio group. May or may not be present. */ - radioGroup: MdRadioGroup; + radioGroup: MatRadioGroup; - /** ID of the native input element inside `` */ + /** ID of the native input element inside `` */ get inputId(): string { return `${this.id || this._uniqueId}-input`; } /** Whether this radio is checked. */ @@ -475,7 +478,7 @@ export class MdRadioButton extends _MdRadioButtonMixinBase private _value: any = null; /** The child ripple instance. */ - @ViewChild(MdRipple) _ripple: MdRipple; + @ViewChild(MatRipple) _ripple: MatRipple; /** Reference to the current focus ripple. */ private _focusRipple: RippleRef | null; @@ -486,7 +489,7 @@ export class MdRadioButton extends _MdRadioButtonMixinBase /** The native `` element */ @ViewChild('input') _inputElement: ElementRef; - constructor(@Optional() radioGroup: MdRadioGroup, + constructor(@Optional() radioGroup: MatRadioGroup, elementRef: ElementRef, renderer: Renderer2, private _changeDetector: ChangeDetectorRef, @@ -544,7 +547,7 @@ export class MdRadioButton extends _MdRadioButtonMixinBase /** Dispatch change event with current value. */ private _emitChangeEvent(): void { - const event = new MdRadioChange(); + const event = new MatRadioChange(); event.source = this; event.value = this._value; this.change.emit(event); diff --git a/src/lib/select/mat-exports.ts b/src/lib/select/mat-exports.ts deleted file mode 100644 index 4028df76cc0b..000000000000 --- a/src/lib/select/mat-exports.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_SELECT_SCROLL_STRATEGY, - MD_SELECT_SCROLL_STRATEGY_PROVIDER, - MD_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY, - MdSelect, - MdSelectBase, - MdSelectChange, - MdSelectTrigger, -} from './select'; -import {MdSelectModule} from './select-module'; - - -export {MD_SELECT_SCROLL_STRATEGY as MAT_SELECT_SCROLL_STRATEGY}; -export {MD_SELECT_SCROLL_STRATEGY_PROVIDER as MAT_SELECT_SCROLL_STRATEGY_PROVIDER}; -export {MD_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY as MAT_SELECT_SCROLL_STRATEGY_PROVIDER_FACTORY}; -export {MdSelect as MatSelect}; -export {MdSelectBase as MatSelectBase}; -export {MdSelectChange as MatSelectChange}; -export {MdSelectModule as MatSelectModule}; -export {MdSelectTrigger as MatSelectTrigger}; diff --git a/src/lib/select/public_api.ts b/src/lib/select/public_api.ts index 01ccc2f3e727..b51fac91de9a 100644 --- a/src/lib/select/public_api.ts +++ b/src/lib/select/public_api.ts @@ -9,4 +9,3 @@ export * from './select-module'; export * from './select'; export * from './select-animations'; -export * from './mat-exports'; diff --git a/src/lib/select/select-animations.ts b/src/lib/select/select-animations.ts index 2813519212ef..870081304b46 100644 --- a/src/lib/select/select-animations.ts +++ b/src/lib/select/select-animations.ts @@ -16,10 +16,10 @@ import { } from '@angular/animations'; /** - * The following are all the animations for the md-select component, with each + * The following are all the animations for the mat-select component, with each * const containing the metadata for one animation. * - * The values below match the implementation of the AngularJS Material md-select animation. + * The values below match the implementation of the AngularJS Material mat-select animation. */ /** diff --git a/src/lib/select/select-errors.ts b/src/lib/select/select-errors.ts index f0578131858b..8075a08d2452 100644 --- a/src/lib/select/select-errors.ts +++ b/src/lib/select/select-errors.ts @@ -11,7 +11,7 @@ * after initialization. * @docs-private */ -export function getMdSelectDynamicMultipleError(): Error { +export function getMatSelectDynamicMultipleError(): Error { return Error('Cannot change `multiple` mode of select after initialization.'); } @@ -21,7 +21,7 @@ export function getMdSelectDynamicMultipleError(): Error { * resetting the value. * @docs-private */ -export function getMdSelectNonArrayValueError(): Error { +export function getMatSelectNonArrayValueError(): Error { return Error('Cannot assign truthy non-array value to select in `multiple` mode.'); } @@ -30,6 +30,6 @@ export function getMdSelectNonArrayValueError(): Error { * used to determine if a value corresponds to an option. Note that whether the function * actually takes two values and returns a boolean is not checked. */ -export function getMdSelectNonFunctionValueError(): Error { +export function getMatSelectNonFunctionValueError(): Error { return Error('Cannot assign a non-function value to `compareWith`.'); } diff --git a/src/lib/select/select-module.ts b/src/lib/select/select-module.ts index 0b0c397b3680..99b154bfc2e0 100644 --- a/src/lib/select/select-module.ts +++ b/src/lib/select/select-module.ts @@ -8,8 +8,8 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; -import {MdSelect, MdSelectTrigger, MD_SELECT_SCROLL_STRATEGY_PROVIDER} from './select'; -import {MdCommonModule, MdOptionModule} from '@angular/material/core'; +import {MatSelect, MatSelectTrigger, MAT_SELECT_SCROLL_STRATEGY_PROVIDER} from './select'; +import {MatCommonModule, MatOptionModule} from '@angular/material/core'; import {OverlayModule} from '@angular/cdk/overlay'; @@ -17,11 +17,11 @@ import {OverlayModule} from '@angular/cdk/overlay'; imports: [ CommonModule, OverlayModule, - MdOptionModule, - MdCommonModule, + MatOptionModule, + MatCommonModule, ], - exports: [MdSelect, MdSelectTrigger, MdOptionModule, MdCommonModule], - declarations: [MdSelect, MdSelectTrigger], - providers: [MD_SELECT_SCROLL_STRATEGY_PROVIDER] + exports: [MatSelect, MatSelectTrigger, MatOptionModule, MatCommonModule], + declarations: [MatSelect, MatSelectTrigger], + providers: [MAT_SELECT_SCROLL_STRATEGY_PROVIDER] }) -export class MdSelectModule {} +export class MatSelectModule {} diff --git a/src/lib/select/select.html b/src/lib/select/select.html index 9379f0980a2e..b16a0b2e959e 100644 --- a/src/lib/select/select.html +++ b/src/lib/select/select.html @@ -12,7 +12,7 @@ {{'\xa0'}} {{ triggerValue }} - + diff --git a/src/lib/select/select.md b/src/lib/select/select.md index 389060fb44c0..1a0014e929c6 100644 --- a/src/lib/select/select.md +++ b/src/lib/select/select.md @@ -1,23 +1,23 @@ -`` is a form control for selecting a value from a set of options, similar to the native +`` is a form control for selecting a value from a set of options, similar to the native `` to provide an accessible +The `` uses an internal `` to provide an accessible experience. This internal checkbox receives focus and is automatically labelled by the text content -of the `` element. +of the `` element. Slide toggles without text or labels should be given a meaningful label via `aria-label` or `aria-labelledby`. diff --git a/src/lib/slide-toggle/slide-toggle.spec.ts b/src/lib/slide-toggle/slide-toggle.spec.ts index 14794ab96555..bf50e88ec225 100644 --- a/src/lib/slide-toggle/slide-toggle.spec.ts +++ b/src/lib/slide-toggle/slide-toggle.spec.ts @@ -5,17 +5,17 @@ import { flushMicrotasks } from '@angular/core/testing'; import {NgModel, FormsModule, ReactiveFormsModule, FormControl} from '@angular/forms'; -import {MdSlideToggle, MdSlideToggleChange, MdSlideToggleModule} from './index'; +import {MatSlideToggle, MatSlideToggleChange, MatSlideToggleModule} from './index'; import {TestGestureConfig} from '../slider/test-gesture-config'; import {dispatchFakeEvent} from '@angular/cdk/testing'; import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '@angular/material/core'; -describe('MdSlideToggle without forms', () => { +describe('MatSlideToggle without forms', () => { let gestureConfig: TestGestureConfig; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSlideToggleModule], + imports: [MatSlideToggleModule], declarations: [ SlideToggleBasic, SlideToggleWithTabindexAttr, @@ -33,7 +33,7 @@ describe('MdSlideToggle without forms', () => { let fixture: ComponentFixture; let testComponent: SlideToggleBasic; - let slideToggle: MdSlideToggle; + let slideToggle: MatSlideToggle; let slideToggleElement: HTMLElement; let labelElement: HTMLLabelElement; let inputElement: HTMLInputElement; @@ -50,7 +50,7 @@ describe('MdSlideToggle without forms', () => { // Initialize the slide-toggle component, by triggering the first change detection cycle. fixture.detectChanges(); - const slideToggleDebug = fixture.debugElement.query(By.css('md-slide-toggle')); + const slideToggleDebug = fixture.debugElement.query(By.css('mat-slide-toggle')); testComponent = fixture.debugElement.componentInstance; slideToggle = slideToggleDebug.componentInstance; @@ -180,7 +180,7 @@ describe('MdSlideToggle without forms', () => { fixture.detectChanges(); // Once the id binding is set to null, the id property should auto-generate a unique id. - expect(inputElement.id).toMatch(/md-slide-toggle-\d+-input/); + expect(inputElement.id).toMatch(/mat-slide-toggle-\d+-input/); }); it('should forward the tabIndex to the underlying input', () => { @@ -248,7 +248,7 @@ describe('MdSlideToggle without forms', () => { })); it('should support subscription on the change observable', () => { - slideToggle.change.subscribe((event: MdSlideToggleChange) => { + slideToggle.change.subscribe((event: MatSlideToggleChange) => { expect(event.checked).toBe(true); }); @@ -344,7 +344,7 @@ describe('MdSlideToggle without forms', () => { fixture.detectChanges(); const slideToggle = fixture.debugElement - .query(By.directive(MdSlideToggle)).componentInstance as MdSlideToggle; + .query(By.directive(MatSlideToggle)).componentInstance as MatSlideToggle; expect(slideToggle.tabIndex) .toBe(5, 'Expected tabIndex property to have been set based on the native attribute'); @@ -355,7 +355,7 @@ describe('MdSlideToggle without forms', () => { let fixture: ComponentFixture; let testComponent: SlideToggleBasic; - let slideToggle: MdSlideToggle; + let slideToggle: MatSlideToggle; let slideToggleElement: HTMLElement; let slideThumbContainer: HTMLElement; let inputElement: HTMLInputElement; @@ -364,7 +364,7 @@ describe('MdSlideToggle without forms', () => { fixture = TestBed.createComponent(SlideToggleBasic); fixture.detectChanges(); - const slideToggleDebug = fixture.debugElement.query(By.css('md-slide-toggle')); + const slideToggleDebug = fixture.debugElement.query(By.css('mat-slide-toggle')); const thumbContainerDebug = slideToggleDebug .query(By.css('.mat-slide-toggle-thumb-container')); @@ -507,7 +507,7 @@ describe('MdSlideToggle without forms', () => { beforeEach(() => { fixture = TestBed.createComponent(SlideToggleWithoutLabel); - const slideToggleDebugEl = fixture.debugElement.query(By.directive(MdSlideToggle)); + const slideToggleDebugEl = fixture.debugElement.query(By.directive(MatSlideToggle)); testComponent = fixture.componentInstance; slideToggleElement = slideToggleDebugEl.nativeElement; @@ -555,11 +555,11 @@ describe('MdSlideToggle without forms', () => { }); }); -describe('MdSlideToggle with forms', () => { +describe('MatSlideToggle with forms', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSlideToggleModule, FormsModule, ReactiveFormsModule], + imports: [MatSlideToggleModule, FormsModule, ReactiveFormsModule], declarations: [ SlideToggleWithForm, SlideToggleWithModel, @@ -574,7 +574,7 @@ describe('MdSlideToggle with forms', () => { let fixture: ComponentFixture; let testComponent: SlideToggleWithModel; - let slideToggle: MdSlideToggle; + let slideToggle: MatSlideToggle; let slideToggleElement: HTMLElement; let slideToggleModel: NgModel; let inputElement: HTMLInputElement; @@ -585,7 +585,7 @@ describe('MdSlideToggle with forms', () => { fixture = TestBed.createComponent(SlideToggleWithModel); fixture.detectChanges(); - const slideToggleDebug = fixture.debugElement.query(By.directive(MdSlideToggle)); + const slideToggleDebug = fixture.debugElement.query(By.directive(MatSlideToggle)); testComponent = fixture.debugElement.componentInstance; slideToggle = slideToggleDebug.componentInstance; @@ -681,7 +681,7 @@ describe('MdSlideToggle with forms', () => { it('should update checked state on click if control is checked initially', fakeAsync(() => { fixture = TestBed.createComponent(SlideToggleWithModel); - slideToggle = fixture.debugElement.query(By.directive(MdSlideToggle)).componentInstance; + slideToggle = fixture.debugElement.query(By.directive(MatSlideToggle)).componentInstance; labelElement = fixture.debugElement.query(By.css('label')).nativeElement; fixture.componentInstance.modelValue = true; @@ -710,7 +710,7 @@ describe('MdSlideToggle with forms', () => { fixture.componentInstance.modelValue = true; fixture.detectChanges(); - const debugElement = fixture.debugElement.query(By.directive(MdSlideToggle)); + const debugElement = fixture.debugElement.query(By.directive(MatSlideToggle)); const modelInstance = debugElement.injector.get(NgModel); // Flush the microtasks because the forms module updates the model state asynchronously. @@ -724,7 +724,7 @@ describe('MdSlideToggle with forms', () => { let fixture: ComponentFixture; let testComponent: SlideToggleWithFormControl; - let slideToggle: MdSlideToggle; + let slideToggle: MatSlideToggle; let inputElement: HTMLInputElement; beforeEach(() => { @@ -732,7 +732,7 @@ describe('MdSlideToggle with forms', () => { fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; - slideToggle = fixture.debugElement.query(By.directive(MdSlideToggle)).componentInstance; + slideToggle = fixture.debugElement.query(By.directive(MatSlideToggle)).componentInstance; inputElement = fixture.debugElement.query(By.css('input')).nativeElement; }); @@ -799,7 +799,7 @@ describe('MdSlideToggle with forms', () => { @Component({ template: ` - { (change)="onSlideChange($event)" (click)="onSlideClick($event)"> Test Slide Toggle - `, + `, }) class SlideToggleBasic { isDisabled: boolean = false; @@ -826,17 +826,17 @@ class SlideToggleBasic { slideLabel: string | null; slideLabelledBy: string | null; slideTabindex: number; - lastEvent: MdSlideToggleChange; + lastEvent: MatSlideToggleChange; labelPosition: string; onSlideClick: (event?: Event) => void = () => {}; - onSlideChange = (event: MdSlideToggleChange) => this.lastEvent = event; + onSlideChange = (event: MatSlideToggleChange) => this.lastEvent = event; } @Component({ template: `
- Required + Required ` }) @@ -846,7 +846,7 @@ class SlideToggleWithForm { } @Component({ - template: `` + template: `` }) class SlideToggleWithModel { modelValue = false; @@ -854,21 +854,21 @@ class SlideToggleWithModel { @Component({ template: ` - + Test Slide Toggle - `, +
`, }) class SlideToggleWithFormControl { formControl = new FormControl(); } @Component({ - template: `` + template: `` }) class SlideToggleWithTabindexAttr {} @Component({ - template: `{{label}}` + template: `{{label}}` }) class SlideToggleWithoutLabel { label: string; diff --git a/src/lib/slide-toggle/slide-toggle.ts b/src/lib/slide-toggle/slide-toggle.ts index 114bf16e3184..1bd02ed5ed40 100644 --- a/src/lib/slide-toggle/slide-toggle.ts +++ b/src/lib/slide-toggle/slide-toggle.ts @@ -31,8 +31,7 @@ import { CanDisableRipple, HammerInput, HasTabIndex, - MATERIAL_COMPATIBILITY_MODE, - MdRipple, + MatRipple, mixinColor, mixinDisabled, mixinDisableRipple, @@ -45,30 +44,30 @@ import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; // Increasing integer for generating unique ids for slide-toggle components. let nextUniqueId = 0; -export const MD_SLIDE_TOGGLE_VALUE_ACCESSOR: any = { +export const MAT_SLIDE_TOGGLE_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdSlideToggle), + useExisting: forwardRef(() => MatSlideToggle), multi: true }; -/** Change event object emitted by a MdSlideToggle. */ -export class MdSlideToggleChange { - source: MdSlideToggle; +/** Change event object emitted by a MatSlideToggle. */ +export class MatSlideToggleChange { + source: MatSlideToggle; checked: boolean; } -// Boilerplate for applying mixins to MdSlideToggle. +// Boilerplate for applying mixins to MatSlideToggle. /** @docs-private */ -export class MdSlideToggleBase { +export class MatSlideToggleBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdSlideToggleMixinBase = - mixinTabIndex(mixinColor(mixinDisableRipple(mixinDisabled(MdSlideToggleBase)), 'accent')); +export const _MatSlideToggleMixinBase = + mixinTabIndex(mixinColor(mixinDisableRipple(mixinDisabled(MatSlideToggleBase)), 'accent')); /** Represents a slidable "switch" toggle that can be moved between on and off. */ @Component({ moduleId: module.id, - selector: 'md-slide-toggle, mat-slide-toggle', + selector: 'mat-slide-toggle', host: { 'class': 'mat-slide-toggle', '[id]': 'id', @@ -78,20 +77,19 @@ export const _MdSlideToggleMixinBase = }, templateUrl: 'slide-toggle.html', styleUrls: ['slide-toggle.css'], - providers: [MD_SLIDE_TOGGLE_VALUE_ACCESSOR], - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], + providers: [MAT_SLIDE_TOGGLE_VALUE_ACCESSOR], inputs: ['disabled', 'disableRipple', 'color', 'tabIndex'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdSlideToggle extends _MdSlideToggleMixinBase implements OnDestroy, AfterContentInit, +export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestroy, AfterContentInit, ControlValueAccessor, CanDisable, CanColor, HasTabIndex, CanDisableRipple { private onChange = (_: any) => {}; private onTouched = () => {}; - private _uniqueId: string = `md-slide-toggle-${++nextUniqueId}`; + private _uniqueId: string = `mat-slide-toggle-${++nextUniqueId}`; private _slideRenderer: SlideToggleRenderer; private _required: boolean = false; private _checked: boolean = false; @@ -129,7 +127,7 @@ export class MdSlideToggle extends _MdSlideToggleMixinBase implements OnDestroy, this._changeDetectorRef.markForCheck(); } /** An event will be dispatched each time the slide-toggle changes its value. */ - @Output() change: EventEmitter = new EventEmitter(); + @Output() change: EventEmitter = new EventEmitter(); /** Returns the unique id for the visual hidden input. */ get inputId(): string { return `${this.id || this._uniqueId}-input`; } @@ -138,7 +136,7 @@ export class MdSlideToggle extends _MdSlideToggleMixinBase implements OnDestroy, @ViewChild('input') _inputElement: ElementRef; /** Reference to the ripple directive on the thumb container. */ - @ViewChild(MdRipple) _ripple: MdRipple; + @ViewChild(MatRipple) _ripple: MatRipple; constructor(elementRef: ElementRef, renderer: Renderer2, @@ -250,7 +248,7 @@ export class MdSlideToggle extends _MdSlideToggleMixinBase implements OnDestroy, * Emits a change event on the `change` output. Also notifies the FormControl about the change. */ private _emitChangeEvent() { - let event = new MdSlideToggleChange(); + let event = new MatSlideToggleChange(); event.source = this; event.checked = this.checked; this.change.emit(event); diff --git a/src/lib/slider/mat-exports.ts b/src/lib/slider/mat-exports.ts deleted file mode 100644 index 99bad0cf9260..000000000000 --- a/src/lib/slider/mat-exports.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_SLIDER_VALUE_ACCESSOR, - MdSlider, - MdSliderBase, - MdSliderChange, -} from './slider'; -import {MdSliderModule} from './slider-module'; - - -export {MD_SLIDER_VALUE_ACCESSOR as MAT_SLIDER_VALUE_ACCESSOR}; -export {MdSlider as MatSlider}; -export {MdSliderBase as MatSliderBase}; -export {MdSliderChange as MatSliderChange}; -export {MdSliderModule as MatSliderModule}; diff --git a/src/lib/slider/public_api.ts b/src/lib/slider/public_api.ts index 96bbf656a58d..b448421096c6 100644 --- a/src/lib/slider/public_api.ts +++ b/src/lib/slider/public_api.ts @@ -8,4 +8,4 @@ export * from './slider-module'; export * from './slider'; -export * from './mat-exports'; + diff --git a/src/lib/slider/slider-module.ts b/src/lib/slider/slider-module.ts index 979859b91a12..64f6679adb4f 100644 --- a/src/lib/slider/slider-module.ts +++ b/src/lib/slider/slider-module.ts @@ -10,15 +10,15 @@ import {A11yModule} from '@angular/cdk/a11y'; import {BidiModule} from '@angular/cdk/bidi'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {GestureConfig, MdCommonModule} from '@angular/material/core'; +import {GestureConfig, MatCommonModule} from '@angular/material/core'; import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser'; -import {MdSlider} from './slider'; +import {MatSlider} from './slider'; @NgModule({ - imports: [CommonModule, MdCommonModule, BidiModule, A11yModule], - exports: [MdSlider, MdCommonModule], - declarations: [MdSlider], + imports: [CommonModule, MatCommonModule, BidiModule, A11yModule], + exports: [MatSlider, MatCommonModule], + declarations: [MatSlider], providers: [{provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}] }) -export class MdSliderModule {} +export class MatSliderModule {} diff --git a/src/lib/slider/slider.md b/src/lib/slider/slider.md index d64fb7daf111..9c0dac948c67 100644 --- a/src/lib/slider/slider.md +++ b/src/lib/slider/slider.md @@ -1,4 +1,4 @@ -`` allows for the selection of a value from a range via mouse, touch, or keyboard, +`` allows for the selection of a value from a range via mouse, touch, or keyboard, similar to ``. @@ -12,7 +12,7 @@ in increments of `1`. These values can be changed by setting the `min`, `max`, a respectively. The initial value is set to the minimum value unless otherwise specified. ```html - + ``` ### Orientation @@ -22,7 +22,7 @@ right. The `vertical` attribute can be added to a slider to make it vertical wit on bottom and the maximum value on top. ```html - + ``` An `invert` attribute is also available which can be specified to flip the axis that the thumb moves @@ -31,7 +31,7 @@ on the left, while an inverted vertical slider will have the minimum value on to value on bottom. ```html - + ``` ### Thumb label @@ -43,7 +43,7 @@ The [Material Design spec](https://material.google.com/components/sliders.html) discrete value (such as a 1-5 rating). ```html - + ``` ### Tick marks @@ -53,14 +53,14 @@ of steps between between ticks. For example a `tickInterval` of `3` with a `step tick marks at every `3` steps, which is the same as every `12` values. ```html - + ``` The `tickInterval` can also be set to `auto` which will automatically choose the number of steps such that there is at least `30px` of space between ticks. ```html - + ``` The slider will always show a tick at the beginning and end of the track. If the remaining space diff --git a/src/lib/slider/slider.spec.ts b/src/lib/slider/slider.spec.ts index 72e0ef7d9a06..c8afaa626383 100644 --- a/src/lib/slider/slider.spec.ts +++ b/src/lib/slider/slider.spec.ts @@ -15,16 +15,16 @@ import {Component, DebugElement, ViewChild} from '@angular/core'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {By, HAMMER_GESTURE_CONFIG} from '@angular/platform-browser'; -import {MdSlider, MdSliderModule} from './index'; +import {MatSlider, MatSliderModule} from './index'; import {TestGestureConfig} from './test-gesture-config'; -describe('MdSlider without forms', () => { +describe('MatSlider without forms', () => { let gestureConfig: TestGestureConfig; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSliderModule, ReactiveFormsModule, FormsModule, BidiModule], + imports: [MatSliderModule, ReactiveFormsModule, FormsModule, BidiModule], declarations: [ StandardSlider, DisabledSlider, @@ -56,7 +56,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let trackFillElement: HTMLElement; let sliderWrapperElement: HTMLElement; @@ -64,7 +64,7 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(StandardSlider); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderInstance = sliderDebugElement.componentInstance; @@ -186,14 +186,14 @@ describe('MdSlider without forms', () => { let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; let sliderWrapperElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let trackFillElement: HTMLElement; beforeEach(() => { fixture = TestBed.createComponent(DisabledSlider); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); sliderInstance = sliderDebugElement.componentInstance; @@ -247,7 +247,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let trackFillElement: HTMLElement; let ticksContainerElement: HTMLElement; @@ -258,10 +258,10 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithMinAndMax); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); testComponent = fixture.debugElement.componentInstance; sliderNativeElement = sliderDebugElement.nativeElement; - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); trackFillElement = sliderNativeElement.querySelector('.mat-slider-track-fill'); ticksContainerElement = @@ -347,16 +347,16 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; beforeEach(() => { fixture = TestBed.createComponent(SliderWithValue); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); }); @@ -385,7 +385,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let trackFillElement: HTMLElement; @@ -393,9 +393,9 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithStep); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); trackFillElement = sliderNativeElement.querySelector('.mat-slider-track-fill'); }); @@ -467,7 +467,7 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithAutoTickInterval); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; ticksContainerElement = sliderNativeElement.querySelector('.mat-slider-ticks-container'); @@ -497,7 +497,7 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithSetTickInterval); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; ticksContainerElement = sliderNativeElement.querySelector('.mat-slider-ticks-container'); @@ -532,7 +532,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let thumbLabelTextElement: Element; @@ -540,7 +540,7 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithThumbLabel); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderInstance = sliderDebugElement.componentInstance; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); @@ -576,7 +576,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let testComponent: SliderWithOneWayBinding; let trackFillElement: HTMLElement; @@ -587,9 +587,9 @@ describe('MdSlider without forms', () => { testComponent = fixture.debugElement.componentInstance; - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); trackFillElement = sliderNativeElement.querySelector('.mat-slider-track-fill'); }); @@ -612,7 +612,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let trackFillElement: HTMLElement; @@ -620,7 +620,7 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithValueSmallerThanMin); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderInstance = sliderDebugElement.componentInstance; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); @@ -642,7 +642,7 @@ describe('MdSlider without forms', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let trackFillElement: HTMLElement; @@ -650,7 +650,7 @@ describe('MdSlider without forms', () => { fixture = TestBed.createComponent(SliderWithValueGreaterThanMax); fixture.detectChanges(); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderInstance = sliderDebugElement.componentInstance; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); @@ -683,7 +683,7 @@ describe('MdSlider without forms', () => { spyOn(testComponent, 'onChange'); spyOn(testComponent, 'onInput'); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); }); @@ -756,7 +756,7 @@ describe('MdSlider without forms', () => { spyOn(testComponent, 'onInput'); spyOn(testComponent, 'onChange'); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); }); @@ -796,7 +796,7 @@ describe('MdSlider without forms', () => { let sliderNativeElement: HTMLElement; let sliderWrapperElement: HTMLElement; let testComponent: SliderWithChangeHandler; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; beforeEach(() => { fixture = TestBed.createComponent(SliderWithChangeHandler); @@ -806,10 +806,10 @@ describe('MdSlider without forms', () => { spyOn(testComponent, 'onInput'); spyOn(testComponent, 'onChange'); - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); }); it('should increment slider by 1 on up arrow pressed', () => { @@ -936,7 +936,7 @@ describe('MdSlider without forms', () => { let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; let sliderWrapperElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let testComponent: SliderWithDirAndInvert; beforeEach(() => { @@ -944,8 +944,8 @@ describe('MdSlider without forms', () => { fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderNativeElement = sliderDebugElement.nativeElement; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); }); @@ -1079,7 +1079,7 @@ describe('MdSlider without forms', () => { let sliderNativeElement: HTMLElement; let sliderWrapperElement: HTMLElement; let trackFillElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let testComponent: VerticalSlider; beforeEach(() => { @@ -1087,8 +1087,8 @@ describe('MdSlider without forms', () => { fixture.detectChanges(); testComponent = fixture.debugElement.componentInstance; - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderNativeElement = sliderDebugElement.nativeElement; sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); trackFillElement = sliderNativeElement.querySelector('.mat-slider-track-fill'); @@ -1138,12 +1138,12 @@ describe('MdSlider without forms', () => { }); }); -describe('MdSlider with forms module', () => { +describe('MatSlider with forms module', () => { let gestureConfig: TestGestureConfig; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSliderModule, ReactiveFormsModule, FormsModule, BidiModule], + imports: [MatSliderModule, ReactiveFormsModule, FormsModule, BidiModule], declarations: [ SliderWithFormControl, SliderWithNgModel, @@ -1163,7 +1163,7 @@ describe('MdSlider with forms module', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let testComponent: SliderWithNgModel; @@ -1173,9 +1173,9 @@ describe('MdSlider with forms module', () => { testComponent = fixture.debugElement.componentInstance; - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); }); @@ -1211,7 +1211,7 @@ describe('MdSlider with forms module', () => { let fixture: ComponentFixture; let sliderDebugElement: DebugElement; let sliderNativeElement: HTMLElement; - let sliderInstance: MdSlider; + let sliderInstance: MatSlider; let sliderWrapperElement: HTMLElement; let testComponent: SliderWithFormControl; @@ -1221,9 +1221,9 @@ describe('MdSlider with forms module', () => { testComponent = fixture.debugElement.componentInstance; - sliderDebugElement = fixture.debugElement.query(By.directive(MdSlider)); + sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); sliderNativeElement = sliderDebugElement.nativeElement; - sliderInstance = sliderDebugElement.injector.get(MdSlider); + sliderInstance = sliderDebugElement.injector.get(MatSlider); sliderWrapperElement = sliderNativeElement.querySelector('.mat-slider-wrapper'); }); @@ -1320,19 +1320,19 @@ const styles = ` `; @Component({ - template: ``, + template: ``, styles: [styles], }) class StandardSlider { } @Component({ - template: ``, + template: ``, styles: [styles], }) class DisabledSlider { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithMinAndMax { @@ -1341,13 +1341,13 @@ class SliderWithMinAndMax { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithValue { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithStep { @@ -1355,13 +1355,13 @@ class SliderWithStep { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithAutoTickInterval { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithSetTickInterval { @@ -1369,13 +1369,13 @@ class SliderWithSetTickInterval { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithThumbLabel { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithOneWayBinding { @@ -1383,7 +1383,7 @@ class SliderWithOneWayBinding { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithFormControl { @@ -1391,7 +1391,7 @@ class SliderWithFormControl { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithNgModel { @@ -1399,30 +1399,30 @@ class SliderWithNgModel { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithValueSmallerThanMin { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithValueGreaterThanMax { } @Component({ - template: ``, + template: ``, styles: [styles], }) class SliderWithChangeHandler { onChange() { } onInput() { } - @ViewChild(MdSlider) slider: MdSlider; + @ViewChild(MatSlider) slider: MatSlider; } @Component({ - template: `
`, + template: `
`, styles: [styles], }) class SliderWithDirAndInvert { @@ -1431,7 +1431,7 @@ class SliderWithDirAndInvert { } @Component({ - template: ``, + template: ``, styles: [styles], }) class VerticalSlider { @@ -1441,7 +1441,7 @@ class VerticalSlider { /** * Dispatches a click event sequence (consisting of moueseenter, click) from an element. * Note: The mouse event truncates the position for the click. - * @param sliderElement The md-slider element from which the event will be dispatched. + * @param sliderElement The mat-slider element from which the event will be dispatched. * @param percentage The percentage of the slider where the click should occur. Used to find the * physical location of the click. */ @@ -1457,7 +1457,7 @@ function dispatchClickEventSequence(sliderElement: HTMLElement, percentage: numb /** * Dispatches a slide event sequence (consisting of slidestart, slide, slideend) from an element. - * @param sliderElement The md-slider element from which the event will be dispatched. + * @param sliderElement The mat-slider element from which the event will be dispatched. * @param startPercent The percentage of the slider where the slide will begin. * @param endPercent The percentage of the slider where the slide will end. * @param gestureConfig The gesture config for the test to handle emitting the slide events. @@ -1473,7 +1473,7 @@ function dispatchSlideEventSequence(sliderElement: HTMLElement, startPercent: nu /** * Dispatches a slide event from an element. - * @param sliderElement The md-slider element from which the event will be dispatched. + * @param sliderElement The mat-slider element from which the event will be dispatched. * @param percent The percentage of the slider where the slide will happen. * @param gestureConfig The gesture config for the test to handle emitting the slide events. */ @@ -1492,7 +1492,7 @@ function dispatchSlideEvent(sliderElement: HTMLElement, percent: number, /** * Dispatches a slidestart event from an element. - * @param sliderElement The md-slider element from which the event will be dispatched. + * @param sliderElement The mat-slider element from which the event will be dispatched. * @param percent The percentage of the slider where the slide will begin. * @param gestureConfig The gesture config for the test to handle emitting the slide events. */ @@ -1513,7 +1513,7 @@ function dispatchSlideStartEvent(sliderElement: HTMLElement, percent: number, /** * Dispatches a slideend event from an element. - * @param sliderElement The md-slider element from which the event will be dispatched. + * @param sliderElement The mat-slider element from which the event will be dispatched. * @param percent The percentage of the slider where the slide will end. * @param gestureConfig The gesture config for the test to handle emitting the slide events. */ diff --git a/src/lib/slider/slider.ts b/src/lib/slider/slider.ts index 25dda65e0354..e3d2a838327a 100644 --- a/src/lib/slider/slider.ts +++ b/src/lib/slider/slider.ts @@ -61,31 +61,31 @@ const MIN_VALUE_NONACTIVE_THUMB_GAP = 7; const MIN_VALUE_ACTIVE_THUMB_GAP = 10; /** - * Provider Expression that allows md-slider to register as a ControlValueAccessor. + * Provider Expression that allows mat-slider to register as a ControlValueAccessor. * This allows it to support [(ngModel)] and [formControl]. */ -export const MD_SLIDER_VALUE_ACCESSOR: any = { +export const MAT_SLIDER_VALUE_ACCESSOR: any = { provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => MdSlider), + useExisting: forwardRef(() => MatSlider), multi: true }; -/** A simple change event emitted by the MdSlider component. */ -export class MdSliderChange { - /** The MdSlider that changed. */ - source: MdSlider; +/** A simple change event emitted by the MatSlider component. */ +export class MatSliderChange { + /** The MatSlider that changed. */ + source: MatSlider; /** The new value of the source slider. */ value: number | null; } -// Boilerplate for applying mixins to MdSlider. +// Boilerplate for applying mixins to MatSlider. /** @docs-private */ -export class MdSliderBase { +export class MatSliderBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdSliderMixinBase = mixinColor(mixinDisabled(MdSliderBase), 'accent'); +export const _MatSliderMixinBase = mixinColor(mixinDisabled(MatSliderBase), 'accent'); /** * Allows users to select from a range of values by moving the slider thumb. It is similar in @@ -93,8 +93,8 @@ export const _MdSliderMixinBase = mixinColor(mixinDisabled(MdSliderBase), 'accen */ @Component({ moduleId: module.id, - selector: 'md-slider, mat-slider', - providers: [MD_SLIDER_VALUE_ACCESSOR], + selector: 'mat-slider', + providers: [MAT_SLIDER_VALUE_ACCESSOR], host: { '(focus)': '_onFocus()', '(blur)': '_onBlur()', @@ -130,7 +130,7 @@ export const _MdSliderMixinBase = mixinColor(mixinDisabled(MdSliderBase), 'accen preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdSlider extends _MdSliderMixinBase +export class MatSlider extends _MatSliderMixinBase implements ControlValueAccessor, OnDestroy, CanDisable, CanColor, OnInit { /** Whether the slider is inverted. */ @Input() @@ -246,10 +246,10 @@ export class MdSlider extends _MdSliderMixinBase private _vertical = false; /** Event emitted when the slider value has changed. */ - @Output() change = new EventEmitter(); + @Output() change = new EventEmitter(); /** Event emitted when the slider thumb moves. */ - @Output() input = new EventEmitter(); + @Output() input = new EventEmitter(); /** The value to be used for display purposes. */ get displayValue(): string | number { @@ -644,8 +644,8 @@ export class MdSlider extends _MdSliderMixinBase } /** Creates a slider change object from the specified value. */ - private _createChangeEvent(value = this.value): MdSliderChange { - let event = new MdSliderChange(); + private _createChangeEvent(value = this.value): MatSliderChange { + let event = new MatSliderChange(); event.source = this; event.value = value; diff --git a/src/lib/snack-bar/mat-exports.ts b/src/lib/snack-bar/mat-exports.ts deleted file mode 100644 index 04dd5838aed8..000000000000 --- a/src/lib/snack-bar/mat-exports.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdSnackBar} from './snack-bar'; -import {MD_SNACK_BAR_DATA, MdSnackBarConfig} from './snack-bar-config'; -import {MdSnackBarContainer} from './snack-bar-container'; -import {MdSnackBarModule} from './snack-bar-module'; -import {MdSnackBarRef} from './snack-bar-ref'; - - -export {MD_SNACK_BAR_DATA as MAT_SNACK_BAR_DATA}; -export {MdSnackBar as MatSnackBar}; -export {MdSnackBarConfig as MatSnackBarConfig}; -export {MdSnackBarContainer as MatSnackBarContainer}; -export {MdSnackBarModule as MatSnackBarModule}; -export {MdSnackBarRef as MatSnackBarRef}; diff --git a/src/lib/snack-bar/public_api.ts b/src/lib/snack-bar/public_api.ts index 6799827122dd..14496ed504b4 100644 --- a/src/lib/snack-bar/public_api.ts +++ b/src/lib/snack-bar/public_api.ts @@ -12,4 +12,4 @@ export * from './snack-bar-container'; export * from './snack-bar-config'; export * from './snack-bar-ref'; export * from './simple-snack-bar'; -export * from './mat-exports'; + diff --git a/src/lib/snack-bar/simple-snack-bar.ts b/src/lib/snack-bar/simple-snack-bar.ts index e0236fd0e4c8..a10c004c61d8 100644 --- a/src/lib/snack-bar/simple-snack-bar.ts +++ b/src/lib/snack-bar/simple-snack-bar.ts @@ -7,8 +7,8 @@ */ import {Component, ViewEncapsulation, Inject, ChangeDetectionStrategy} from '@angular/core'; -import {MdSnackBarRef} from './snack-bar-ref'; -import {MD_SNACK_BAR_DATA} from './snack-bar-config'; +import {MatSnackBarRef} from './snack-bar-ref'; +import {MAT_SNACK_BAR_DATA} from './snack-bar-config'; /** @@ -32,8 +32,8 @@ export class SimpleSnackBar { data: { message: string, action: string }; constructor( - public snackBarRef: MdSnackBarRef, - @Inject(MD_SNACK_BAR_DATA) data: any) { + public snackBarRef: MatSnackBarRef, + @Inject(MAT_SNACK_BAR_DATA) data: any) { this.data = data; } diff --git a/src/lib/snack-bar/snack-bar-config.ts b/src/lib/snack-bar/snack-bar-config.ts index 4f0f2c1fa9cc..44a6844ef769 100644 --- a/src/lib/snack-bar/snack-bar-config.ts +++ b/src/lib/snack-bar/snack-bar-config.ts @@ -10,22 +10,22 @@ import {ViewContainerRef, InjectionToken} from '@angular/core'; import {AriaLivePoliteness} from '@angular/cdk/a11y'; import {Direction} from '@angular/cdk/bidi'; -export const MD_SNACK_BAR_DATA = new InjectionToken('MdSnackBarData'); +export const MAT_SNACK_BAR_DATA = new InjectionToken('MatSnackBarData'); -/** Possible values for horizontalPosition on MdSnackBarConfig. */ -export type MdSnackBarHorizontalPosition = 'start' | 'center' | 'end' | 'left' | 'right'; +/** Possible values for horizontalPosition on MatSnackBarConfig. */ +export type MatSnackBarHorizontalPosition = 'start' | 'center' | 'end' | 'left' | 'right'; -/** Possible values for verticalPosition on MdSnackBarConfig. */ -export type MdSnackBarVerticalPosition = 'top' | 'bottom'; +/** Possible values for verticalPosition on MatSnackBarConfig. */ +export type MatSnackBarVerticalPosition = 'top' | 'bottom'; /** * Configuration used when opening a snack-bar. */ -export class MdSnackBarConfig { - /** The politeness level for the MdAriaLiveAnnouncer announcement. */ +export class MatSnackBarConfig { + /** The politeness level for the MatAriaLiveAnnouncer announcement. */ politeness?: AriaLivePoliteness = 'assertive'; - /** Message to be announced by the MdAriaLiveAnnouncer */ + /** Message to be announced by the MatAriaLiveAnnouncer */ announcementMessage?: string = ''; /** The view container to place the overlay for the snack bar into. */ @@ -44,8 +44,8 @@ export class MdSnackBarConfig { data?: any = null; /** The horizontal position to place the snack bar. */ - horizontalPosition?: MdSnackBarHorizontalPosition = 'center'; + horizontalPosition?: MatSnackBarHorizontalPosition = 'center'; /** The vertical position to place the snack bar. */ - verticalPosition?: MdSnackBarVerticalPosition = 'bottom'; + verticalPosition?: MatSnackBarVerticalPosition = 'bottom'; } diff --git a/src/lib/snack-bar/snack-bar-container.ts b/src/lib/snack-bar/snack-bar-container.ts index 79688edc6731..15288df08ef1 100644 --- a/src/lib/snack-bar/snack-bar-container.ts +++ b/src/lib/snack-bar/snack-bar-container.ts @@ -35,7 +35,7 @@ import { import {first} from '@angular/cdk/rxjs'; import {Observable} from 'rxjs/Observable'; import {Subject} from 'rxjs/Subject'; -import {MdSnackBarConfig} from './snack-bar-config'; +import {MatSnackBarConfig} from './snack-bar-config'; export type SnackBarState = 'visible' | 'hidden' | 'void'; @@ -79,7 +79,7 @@ export const HIDE_ANIMATION = '195ms cubic-bezier(0.0,0.0,0.2,1)'; ]) ], }) -export class MdSnackBarContainer extends BasePortalHost implements OnDestroy { +export class MatSnackBarContainer extends BasePortalHost implements OnDestroy { /** Whether the component has been destroyed. */ private _destroyed = false; @@ -96,7 +96,7 @@ export class MdSnackBarContainer extends BasePortalHost implements OnDestroy { private _animationState: SnackBarState; /** The snack bar configuration. */ - snackBarConfig: MdSnackBarConfig; + snackBarConfig: MatSnackBarConfig; constructor( private _ngZone: NgZone, diff --git a/src/lib/snack-bar/snack-bar-module.ts b/src/lib/snack-bar/snack-bar-module.ts index d436a4da504c..7d3da1c1b4d8 100644 --- a/src/lib/snack-bar/snack-bar-module.ts +++ b/src/lib/snack-bar/snack-bar-module.ts @@ -11,9 +11,9 @@ import {CommonModule} from '@angular/common'; import {OverlayModule} from '@angular/cdk/overlay'; import {PortalModule} from '@angular/cdk/portal'; import {LIVE_ANNOUNCER_PROVIDER} from '@angular/cdk/a11y'; -import {MdCommonModule} from '@angular/material/core'; -import {MdSnackBar} from './snack-bar'; -import {MdSnackBarContainer} from './snack-bar-container'; +import {MatCommonModule} from '@angular/material/core'; +import {MatSnackBar} from './snack-bar'; +import {MatSnackBarContainer} from './snack-bar-container'; import {SimpleSnackBar} from './simple-snack-bar'; @@ -22,11 +22,11 @@ import {SimpleSnackBar} from './simple-snack-bar'; OverlayModule, PortalModule, CommonModule, - MdCommonModule, + MatCommonModule, ], - exports: [MdSnackBarContainer, MdCommonModule], - declarations: [MdSnackBarContainer, SimpleSnackBar], - entryComponents: [MdSnackBarContainer, SimpleSnackBar], - providers: [MdSnackBar, LIVE_ANNOUNCER_PROVIDER] + exports: [MatSnackBarContainer, MatCommonModule], + declarations: [MatSnackBarContainer, SimpleSnackBar], + entryComponents: [MatSnackBarContainer, SimpleSnackBar], + providers: [MatSnackBar, LIVE_ANNOUNCER_PROVIDER] }) -export class MdSnackBarModule {} +export class MatSnackBarModule {} diff --git a/src/lib/snack-bar/snack-bar-ref.ts b/src/lib/snack-bar/snack-bar-ref.ts index b9a5c4dc50ee..b329f5e54c07 100644 --- a/src/lib/snack-bar/snack-bar-ref.ts +++ b/src/lib/snack-bar/snack-bar-ref.ts @@ -9,12 +9,12 @@ import {OverlayRef} from '@angular/cdk/overlay'; import {Observable} from 'rxjs/Observable'; import {Subject} from 'rxjs/Subject'; -import {MdSnackBarContainer} from './snack-bar-container'; +import {MatSnackBarContainer} from './snack-bar-container'; /** * Reference to a snack bar dispatched from the snack bar service. */ -export class MdSnackBarRef { +export class MatSnackBarRef { /** The instance of the component making up the content of the snack bar. */ instance: T; @@ -22,7 +22,7 @@ export class MdSnackBarRef { * The instance of the component making up the content of the snack bar. * @docs-private */ - containerInstance: MdSnackBarContainer; + containerInstance: MatSnackBarContainer; /** Subject for notifying the user that the snack bar has closed. */ private _afterClosed = new Subject(); @@ -39,7 +39,7 @@ export class MdSnackBarRef { */ private _durationTimeoutId: number; - constructor(containerInstance: MdSnackBarContainer, + constructor(containerInstance: MatSnackBarContainer, private _overlayRef: OverlayRef) { this.containerInstance = containerInstance; // Dismiss snackbar on action. diff --git a/src/lib/snack-bar/snack-bar.md b/src/lib/snack-bar/snack-bar.md index a468dfa3718a..eee50987e6a8 100644 --- a/src/lib/snack-bar/snack-bar.md +++ b/src/lib/snack-bar/snack-bar.md @@ -1,4 +1,4 @@ -`MdSnackBar` is a service for displaying snack-bar notifications. +`MatSnackBar` is a service for displaying snack-bar notifications. @@ -15,11 +15,11 @@ let snackBarRef = snackBar.open('Message archived', 'Undo'); let snackBarRef = snackbar.openFromComponent(MessageArchivedComponent); ``` -In either case, a `MdSnackBarRef` is returned. This can be used to dismiss the snack-bar or to +In either case, a `MatSnackBarRef` is returned. This can be used to dismiss the snack-bar or to receive notification of when the snack-bar is dismissed. For simple messages with an action, the -`MdSnackBarRef` exposes an observable for when the action is triggered. +`MatSnackBarRef` exposes an observable for when the action is triggered. If you want to close a custom snack-bar that was opened via `openFromComponent`, from within the -component itself, you can inject the `MdSnackBarRef`. +component itself, you can inject the `MatSnackBarRef`. ```ts snackBarRef.afterDismissed().subscribe(() => { @@ -35,7 +35,7 @@ snackBarRef.dismiss(); ``` ### Dismissal -A snack-bar can be dismissed manually by calling the `dismiss` method on the `MdSnackBarRef` +A snack-bar can be dismissed manually by calling the `dismiss` method on the `MatSnackBarRef` returned from the call to `open`. Only one snack-bar can ever be opened at one time. If a new snackbar is opened while a previous @@ -58,18 +58,18 @@ snackbar.openFromComponent(MessageArchivedComponent, { }); ``` -To access the data in your component, you have to use the `MD_SNACK_BAR_DATA` injection token: +To access the data in your component, you have to use the `MAT_SNACK_BAR_DATA` injection token: ```ts import {Component, Inject} from '@angular/core'; -import {MD_SNACK_BAR_DATA} from '@angular/material'; +import {MAT_SNACK_BAR_DATA} from '@angular/material'; @Component({ selector: 'your-snack-bar', template: 'passed in {{ data }}', }) export class MessageArchivedComponent { - constructor(@Inject(MD_SNACK_BAR_DATA) public data: any) { } + constructor(@Inject(MAT_SNACK_BAR_DATA) public data: any) { } } ``` ### Accessibility diff --git a/src/lib/snack-bar/snack-bar.spec.ts b/src/lib/snack-bar/snack-bar.spec.ts index fdd1da844e82..91f6adb70f0b 100644 --- a/src/lib/snack-bar/snack-bar.spec.ts +++ b/src/lib/snack-bar/snack-bar.spec.ts @@ -13,17 +13,17 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {OverlayContainer} from '@angular/cdk/overlay'; import {LiveAnnouncer} from '@angular/cdk/a11y'; import { - MdSnackBarModule, - MdSnackBar, - MdSnackBarConfig, - MdSnackBarRef, + MatSnackBarModule, + MatSnackBar, + MatSnackBarConfig, + MatSnackBarRef, SimpleSnackBar, - MD_SNACK_BAR_DATA, + MAT_SNACK_BAR_DATA, } from './index'; -describe('MdSnackBar', () => { - let snackBar: MdSnackBar; +describe('MatSnackBar', () => { + let snackBar: MatSnackBar; let liveAnnouncer: LiveAnnouncer; let overlayContainerElement: HTMLElement; @@ -35,7 +35,7 @@ describe('MdSnackBar', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSnackBarModule, SnackBarTestModule, NoopAnimationsModule], + imports: [MatSnackBarModule, SnackBarTestModule, NoopAnimationsModule], providers: [ {provide: OverlayContainer, useFactory: () => { overlayContainerElement = document.createElement('div'); @@ -46,7 +46,7 @@ describe('MdSnackBar', () => { TestBed.compileComponents(); })); - beforeEach(inject([MdSnackBar, LiveAnnouncer], (sb: MdSnackBar, la: LiveAnnouncer) => { + beforeEach(inject([MatSnackBar, LiveAnnouncer], (sb: MatSnackBar, la: LiveAnnouncer) => { snackBar = sb; liveAnnouncer = la; })); @@ -64,7 +64,7 @@ describe('MdSnackBar', () => { }); it('should have the role of alert', () => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; snackBar.open(simpleMessage, simpleActionLabel, config); let containerElement = overlayContainerElement.querySelector('snack-bar-container')!; @@ -90,7 +90,7 @@ describe('MdSnackBar', () => { })); it('should open a simple message with a button', () => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let snackBarRef = snackBar.open(simpleMessage, simpleActionLabel, config); viewContainerFixture.detectChanges(); @@ -114,7 +114,7 @@ describe('MdSnackBar', () => { }); it('should open a simple message with no button', () => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let snackBarRef = snackBar.open(simpleMessage, undefined, config); viewContainerFixture.detectChanges(); @@ -132,7 +132,7 @@ describe('MdSnackBar', () => { }); it('should dismiss the snack bar and remove itself from the view', async(() => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let dismissObservableCompleted = false; let snackBarRef = snackBar.open(simpleMessage, undefined, config); @@ -182,7 +182,7 @@ describe('MdSnackBar', () => { })); it('should set the animation state to visible on entry', () => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let snackBarRef = snackBar.open(simpleMessage, undefined, config); viewContainerFixture.detectChanges(); @@ -196,7 +196,7 @@ describe('MdSnackBar', () => { }); it('should set the animation state to complete on exit', () => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let snackBarRef = snackBar.open(simpleMessage, undefined, config); snackBarRef.dismiss(); @@ -207,7 +207,7 @@ describe('MdSnackBar', () => { it(`should set the old snack bar animation state to complete and the new snack bar animation state to visible on entry of new snack bar`, async(() => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let snackBarRef = snackBar.open(simpleMessage, undefined, config); let dismissObservableCompleted = false; @@ -233,7 +233,7 @@ describe('MdSnackBar', () => { })); it('should open a new snackbar after dismissing a previous snackbar', async(() => { - let config: MdSnackBarConfig = {viewContainerRef: testViewContainerRef}; + let config: MatSnackBarConfig = {viewContainerRef: testViewContainerRef}; let snackBarRef = snackBar.open(simpleMessage, 'Dismiss', config); viewContainerFixture.detectChanges(); @@ -337,7 +337,7 @@ describe('MdSnackBar', () => { it('should dismiss automatically after a specified timeout', fakeAsync(() => { let dismissObservableCompleted = false; - let config = new MdSnackBarConfig(); + let config = new MatSnackBarConfig(); config.duration = 250; let snackBarRef = snackBar.open('content', 'test', config); snackBarRef.afterDismissed().subscribe(() => { @@ -355,7 +355,7 @@ describe('MdSnackBar', () => { })); it('should clear the dismiss timeout when dismissed before timeout expiration', fakeAsync(() => { - let config = new MdSnackBarConfig(); + let config = new MatSnackBarConfig(); config.duration = 1000; snackBar.open('content', 'test', config); @@ -443,17 +443,17 @@ describe('MdSnackBar', () => { }); -describe('MdSnackBar with parent MdSnackBar', () => { - let parentSnackBar: MdSnackBar; - let childSnackBar: MdSnackBar; +describe('MatSnackBar with parent MatSnackBar', () => { + let parentSnackBar: MatSnackBar; + let childSnackBar: MatSnackBar; let overlayContainerElement: HTMLElement; - let fixture: ComponentFixture; + let fixture: ComponentFixture; let liveAnnouncer: LiveAnnouncer; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSnackBarModule, SnackBarTestModule, NoopAnimationsModule], - declarations: [ComponentThatProvidesMdSnackBar], + imports: [MatSnackBarModule, SnackBarTestModule, NoopAnimationsModule], + declarations: [ComponentThatProvidesMatSnackBar], providers: [ {provide: OverlayContainer, useFactory: () => { overlayContainerElement = document.createElement('div'); @@ -465,11 +465,11 @@ describe('MdSnackBar with parent MdSnackBar', () => { TestBed.compileComponents(); })); - beforeEach(inject([MdSnackBar, LiveAnnouncer], (sb: MdSnackBar, la: LiveAnnouncer) => { + beforeEach(inject([MatSnackBar, LiveAnnouncer], (sb: MatSnackBar, la: LiveAnnouncer) => { parentSnackBar = sb; liveAnnouncer = la; - fixture = TestBed.createComponent(ComponentThatProvidesMdSnackBar); + fixture = TestBed.createComponent(ComponentThatProvidesMatSnackBar); childSnackBar = fixture.componentInstance.snackBar; fixture.detectChanges(); })); @@ -479,7 +479,7 @@ describe('MdSnackBar with parent MdSnackBar', () => { liveAnnouncer.ngOnDestroy(); }); - it('should close snackBars opened by parent when opening from child MdSnackBar', fakeAsync(() => { + it('should close snackBars opened by parent when opening from child', fakeAsync(() => { parentSnackBar.open('Pizza'); fixture.detectChanges(); tick(1000); @@ -495,7 +495,7 @@ describe('MdSnackBar with parent MdSnackBar', () => { .toContain('Taco', 'Expected parent snackbar msg to be dismissed by opening from child'); })); - it('should close snackBars opened by child when opening from parent MdSnackBar', fakeAsync(() => { + it('should close snackBars opened by child when opening from parent', fakeAsync(() => { childSnackBar.open('Pizza'); fixture.detectChanges(); tick(1000); @@ -513,8 +513,8 @@ describe('MdSnackBar with parent MdSnackBar', () => { }); -describe('MdSnackBar Positioning', () => { - let snackBar: MdSnackBar; +describe('MatSnackBar Positioning', () => { + let snackBar: MatSnackBar; let liveAnnouncer: LiveAnnouncer; let overlayContainerEl: HTMLElement; @@ -526,7 +526,7 @@ describe('MdSnackBar Positioning', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSnackBarModule, SnackBarTestModule, NoopAnimationsModule], + imports: [MatSnackBarModule, SnackBarTestModule, NoopAnimationsModule], providers: [ {provide: OverlayContainer, useFactory: () => { overlayContainerEl = document.createElement('div'); @@ -537,7 +537,7 @@ describe('MdSnackBar Positioning', () => { TestBed.compileComponents(); })); - beforeEach(inject([MdSnackBar, LiveAnnouncer], (sb: MdSnackBar, la: LiveAnnouncer) => { + beforeEach(inject([MatSnackBar, LiveAnnouncer], (sb: MatSnackBar, la: LiveAnnouncer) => { snackBar = sb; liveAnnouncer = la; })); @@ -555,7 +555,7 @@ describe('MdSnackBar Positioning', () => { }); it('should default to bottom center', () => { - let config: MdSnackBarConfig = {}; + let config: MatSnackBarConfig = {}; snackBar.open(simpleMessage, simpleActionLabel, config); let containerEl = overlayContainerEl.querySelector('snack-bar-container') as HTMLElement; let overlayPaneEl = overlayContainerEl.querySelector('.cdk-overlay-pane') as HTMLElement; @@ -569,7 +569,7 @@ describe('MdSnackBar Positioning', () => { }); it('should be in the bottom left corner', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'bottom', horizontalPosition: 'left' }; @@ -586,7 +586,7 @@ describe('MdSnackBar Positioning', () => { }); it('should be in the bottom right corner', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'bottom', horizontalPosition: 'right' }; @@ -603,7 +603,7 @@ describe('MdSnackBar Positioning', () => { }); it('should be in the bottom center', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'bottom', horizontalPosition: 'center' }; @@ -620,7 +620,7 @@ describe('MdSnackBar Positioning', () => { }); it('should be in the top left corner', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'left' }; @@ -637,7 +637,7 @@ describe('MdSnackBar Positioning', () => { }); it('should be in the top right corner', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'right' }; @@ -654,7 +654,7 @@ describe('MdSnackBar Positioning', () => { }); it('should be in the top center', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'center' }; @@ -671,7 +671,7 @@ describe('MdSnackBar Positioning', () => { }); it('should handle start based on direction (rtl)', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'start', direction: 'rtl', @@ -689,7 +689,7 @@ describe('MdSnackBar Positioning', () => { }); it('should handle start based on direction (ltr)', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'start', direction: 'ltr', @@ -708,7 +708,7 @@ describe('MdSnackBar Positioning', () => { it('should handle end based on direction (rtl)', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'end', direction: 'rtl', @@ -726,7 +726,7 @@ describe('MdSnackBar Positioning', () => { }); it('should handle end based on direction (ltr)', () => { - let config: MdSnackBarConfig = { + let config: MatSnackBarConfig = { verticalPosition: 'top', horizontalPosition: 'end', direction: 'ltr', @@ -769,17 +769,17 @@ class ComponentWithChildViewContainer { @Component({template: '

Burritos are on the way.

'}) class BurritosNotification { constructor( - public snackBarRef: MdSnackBarRef, - @Inject(MD_SNACK_BAR_DATA) public data: any) { } + public snackBarRef: MatSnackBarRef, + @Inject(MAT_SNACK_BAR_DATA) public data: any) { } } @Component({ template: '', - providers: [MdSnackBar] + providers: [MatSnackBar] }) -class ComponentThatProvidesMdSnackBar { - constructor(public snackBar: MdSnackBar) {} +class ComponentThatProvidesMatSnackBar { + constructor(public snackBar: MatSnackBar) {} } @@ -791,7 +791,7 @@ const TEST_DIRECTIVES = [ComponentWithChildViewContainer, BurritosNotification, DirectiveWithViewContainer]; @NgModule({ - imports: [CommonModule, MdSnackBarModule], + imports: [CommonModule, MatSnackBarModule], exports: TEST_DIRECTIVES, declarations: TEST_DIRECTIVES, entryComponents: [ComponentWithChildViewContainer, BurritosNotification], diff --git a/src/lib/snack-bar/snack-bar.ts b/src/lib/snack-bar/snack-bar.ts index 293e2c903e95..25635acfddd8 100644 --- a/src/lib/snack-bar/snack-bar.ts +++ b/src/lib/snack-bar/snack-bar.ts @@ -12,30 +12,30 @@ import {ComponentPortal, ComponentType, PortalInjector} from '@angular/cdk/porta import {ComponentRef, Injectable, Injector, Optional, SkipSelf} from '@angular/core'; import {extendObject} from '@angular/material/core'; import {SimpleSnackBar} from './simple-snack-bar'; -import {MD_SNACK_BAR_DATA, MdSnackBarConfig} from './snack-bar-config'; -import {MdSnackBarContainer} from './snack-bar-container'; -import {MdSnackBarRef} from './snack-bar-ref'; +import {MAT_SNACK_BAR_DATA, MatSnackBarConfig} from './snack-bar-config'; +import {MatSnackBarContainer} from './snack-bar-container'; +import {MatSnackBarRef} from './snack-bar-ref'; /** * Service to dispatch Material Design snack bar messages. */ @Injectable() -export class MdSnackBar { +export class MatSnackBar { /** * Reference to the current snack bar in the view *at this level* (in the Angular injector tree). * If there is a parent snack-bar service, all operations should delegate to that parent * via `_openedSnackBarRef`. */ - private _snackBarRefAtThisLevel: MdSnackBarRef | null = null; + private _snackBarRefAtThisLevel: MatSnackBarRef | null = null; /** Reference to the currently opened snackbar at *any* level. */ - get _openedSnackBarRef(): MdSnackBarRef | null { + get _openedSnackBarRef(): MatSnackBarRef | null { const parent = this._parentSnackBar; return parent ? parent._openedSnackBarRef : this._snackBarRefAtThisLevel; } - set _openedSnackBarRef(value: MdSnackBarRef | null) { + set _openedSnackBarRef(value: MatSnackBarRef | null) { if (this._parentSnackBar) { this._parentSnackBar._openedSnackBarRef = value; } else { @@ -47,7 +47,7 @@ export class MdSnackBar { private _overlay: Overlay, private _live: LiveAnnouncer, private _injector: Injector, - @Optional() @SkipSelf() private _parentSnackBar: MdSnackBar) {} + @Optional() @SkipSelf() private _parentSnackBar: MatSnackBar) {} /** * Creates and dispatches a snack bar with a custom component for the content, removing any @@ -56,7 +56,7 @@ export class MdSnackBar { * @param component Component to be instantiated. * @param config Extra configuration for the snack bar. */ - openFromComponent(component: ComponentType, config?: MdSnackBarConfig): MdSnackBarRef { + openFromComponent(component: ComponentType, config?: MatSnackBarConfig): MatSnackBarRef { const _config = _applyConfigDefaults(config); const snackBarRef = this._attach(component, _config); @@ -99,7 +99,7 @@ export class MdSnackBar { * @param action The label for the snackbar action. * @param config Additional configuration options for the snackbar. */ - open(message: string, action = '', config?: MdSnackBarConfig): MdSnackBarRef { + open(message: string, action = '', config?: MatSnackBarConfig): MatSnackBarRef { const _config = _applyConfigDefaults(config); // Since the user doesn't have access to the component, we can @@ -123,9 +123,9 @@ export class MdSnackBar { * Attaches the snack bar container component to the overlay. */ private _attachSnackBarContainer(overlayRef: OverlayRef, - config: MdSnackBarConfig): MdSnackBarContainer { - const containerPortal = new ComponentPortal(MdSnackBarContainer, config.viewContainerRef); - const containerRef: ComponentRef = overlayRef.attach(containerPortal); + config: MatSnackBarConfig): MatSnackBarContainer { + const containerPortal = new ComponentPortal(MatSnackBarContainer, config.viewContainerRef); + const containerRef: ComponentRef = overlayRef.attach(containerPortal); containerRef.instance.snackBarConfig = config; return containerRef.instance; } @@ -133,10 +133,10 @@ export class MdSnackBar { /** * Places a new component as the content of the snack bar container. */ - private _attach(component: ComponentType, config: MdSnackBarConfig): MdSnackBarRef { + private _attach(component: ComponentType, config: MatSnackBarConfig): MatSnackBarRef { const overlayRef = this._createOverlay(config); const container = this._attachSnackBarContainer(overlayRef, config); - const snackBarRef = new MdSnackBarRef(container, overlayRef); + const snackBarRef = new MatSnackBarRef(container, overlayRef); const injector = this._createInjector(config, snackBarRef); const portal = new ComponentPortal(component, undefined, injector); const contentRef = container.attachComponentPortal(portal); @@ -151,7 +151,7 @@ export class MdSnackBar { * Creates a new overlay and places it in the correct location. * @param config The user-specified snack bar config. */ - private _createOverlay(config: MdSnackBarConfig): OverlayRef { + private _createOverlay(config: MatSnackBarConfig): OverlayRef { const state = new OverlayConfig(); state.direction = config.direction; @@ -187,14 +187,14 @@ export class MdSnackBar { * @param snackBarRef Reference to the snack bar. */ private _createInjector( - config: MdSnackBarConfig, - snackBarRef: MdSnackBarRef): PortalInjector { + config: MatSnackBarConfig, + snackBarRef: MatSnackBarRef): PortalInjector { const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector; const injectionTokens = new WeakMap(); - injectionTokens.set(MdSnackBarRef, snackBarRef); - injectionTokens.set(MD_SNACK_BAR_DATA, config.data); + injectionTokens.set(MatSnackBarRef, snackBarRef); + injectionTokens.set(MAT_SNACK_BAR_DATA, config.data); return new PortalInjector(userInjector || this._injector, injectionTokens); } @@ -205,6 +205,6 @@ export class MdSnackBar { * @param config The configuration to which the defaults will be applied. * @returns The new configuration object with defaults applied. */ -function _applyConfigDefaults(config?: MdSnackBarConfig): MdSnackBarConfig { - return extendObject(new MdSnackBarConfig(), config); +function _applyConfigDefaults(config?: MatSnackBarConfig): MatSnackBarConfig { + return extendObject(new MatSnackBarConfig(), config); } diff --git a/src/lib/sort/mat-exports.ts b/src/lib/sort/mat-exports.ts deleted file mode 100644 index 44a7b1ccb49c..000000000000 --- a/src/lib/sort/mat-exports.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdSort, MdSortable} from './sort'; -import {MdSortHeader} from './sort-header'; -import {MdSortHeaderIntl} from './sort-header-intl'; -import {MdSortModule} from './sort-module'; - - -export {MdSort as MatSort}; -export {MdSortable as MatSortable}; -export {MdSortHeader as MatSortHeader}; -export {MdSortHeaderIntl as MatSortHeaderIntl}; -export {MdSortModule as MatSortModule}; diff --git a/src/lib/sort/public_api.ts b/src/lib/sort/public_api.ts index a9cb88a5c038..382f6c9168da 100644 --- a/src/lib/sort/public_api.ts +++ b/src/lib/sort/public_api.ts @@ -11,4 +11,4 @@ export * from './sort-direction'; export * from './sort-header'; export * from './sort-header-intl'; export * from './sort'; -export * from './mat-exports'; + diff --git a/src/lib/sort/sort-errors.ts b/src/lib/sort/sort-errors.ts index f9eb38da6204..5fb61c38ca34 100644 --- a/src/lib/sort/sort-errors.ts +++ b/src/lib/sort/sort-errors.ts @@ -7,16 +7,16 @@ */ /** @docs-private */ -export function getMdSortDuplicateMdSortableIdError(id: string): Error { - return Error(`Cannot have two MdSortables with the same id (${id}).`); +export function getSortDuplicateSortableIdError(id: string): Error { + return Error(`Cannot have two MatSortables with the same id (${id}).`); } /** @docs-private */ -export function getMdSortHeaderNotContainedWithinMdSortError(): Error { - return Error(`MdSortHeader must be placed within a parent element with the MdSort directive.`); +export function getSortHeaderNotContainedWithinSortError(): Error { + return Error(`MatSortHeader must be placed within a parent element with the MatSort directive.`); } /** @docs-private */ -export function getMdSortHeaderMissingIdError(): Error { - return Error(`MdSortHeader must be provided with a unique id.`); +export function getSortHeaderMissingIdError(): Error { + return Error(`MatSortHeader must be provided with a unique id.`); } diff --git a/src/lib/sort/sort-header-intl.ts b/src/lib/sort/sort-header-intl.ts index 48c38d0dbd28..35c45470c4c1 100644 --- a/src/lib/sort/sort-header-intl.ts +++ b/src/lib/sort/sort-header-intl.ts @@ -11,11 +11,11 @@ import {Subject} from 'rxjs/Subject'; import {SortDirection} from './sort-direction'; /** - * To modify the labels and text displayed, create a new instance of MdSortHeaderIntl and + * To modify the labels and text displayed, create a new instance of MatSortHeaderIntl and * include it in a custom provider. */ @Injectable() -export class MdSortHeaderIntl { +export class MatSortHeaderIntl { /** * Stream that emits whenever the labels here are changed. Use this to notify * components if the labels have changed after initialization. diff --git a/src/lib/sort/sort-header.ts b/src/lib/sort/sort-header.ts index 5547cce09be1..b516ee6f6649 100644 --- a/src/lib/sort/sort-header.ts +++ b/src/lib/sort/sort-header.ts @@ -25,9 +25,9 @@ import { import {CdkColumnDef} from '@angular/cdk/table'; import {Subscription} from 'rxjs/Subscription'; import {merge} from 'rxjs/observable/merge'; -import {MdSort, MdSortable} from './sort'; -import {MdSortHeaderIntl} from './sort-header-intl'; -import {getMdSortHeaderNotContainedWithinMdSortError} from './sort-errors'; +import {MatSort, MatSortable} from './sort'; +import {MatSortHeaderIntl} from './sort-header-intl'; +import {getSortHeaderNotContainedWithinSortError} from './sort-errors'; import {AnimationCurves, AnimationDurations} from '@angular/material/core'; const SORT_ANIMATION_TRANSITION = @@ -37,14 +37,14 @@ const SORT_ANIMATION_TRANSITION = * Applies sorting behavior (click to change sort) and styles to an element, including an * arrow to display the current sort direction. * - * Must be provided with an id and contained within a parent MdSort directive. + * Must be provided with an id and contained within a parent MatSort directive. * * If used on header cells in a CdkTable, it will automatically default its id from its containing * column definition. */ @Component({ moduleId: module.id, - selector: '[md-sort-header], [mat-sort-header]', + selector: '[mat-sort-header]', templateUrl: 'sort-header.html', styleUrls: ['sort-header.css'], host: { @@ -73,22 +73,22 @@ const SORT_ANIMATION_TRANSITION = ]) ] }) -export class MdSortHeader implements MdSortable { +export class MatSortHeader implements MatSortable { private _rerenderSubscription: Subscription; /** * ID of this sort header. If used within the context of a CdkColumnDef, this will default to * the column's name. */ - @Input('md-sort-header') id: string; + @Input('mat-sort-header') id: string; /** Sets the position of the arrow that displays when sorted. */ @Input() arrowPosition: 'before' | 'after' = 'after'; - /** Overrides the sort start value of the containing MdSort for this MdSortable. */ + /** Overrides the sort start value of the containing MatSort for this MatSortable. */ @Input('start') start: 'asc' | 'desc'; - /** Overrides the disable clear value of the containing MdSort for this MdSortable. */ + /** Overrides the disable clear value of the containing MatSort for this MatSortable. */ @Input() get disableClear() { return this._disableClear; } set disableClear(v) { this._disableClear = coerceBooleanProperty(v); } @@ -98,12 +98,12 @@ export class MdSortHeader implements MdSortable { get _id() { return this.id; } set _id(v: string) { this.id = v; } - constructor(public _intl: MdSortHeaderIntl, + constructor(public _intl: MatSortHeaderIntl, changeDetectorRef: ChangeDetectorRef, - @Optional() public _sort: MdSort, + @Optional() public _sort: MatSort, @Optional() public _cdkColumnDef: CdkColumnDef) { if (!_sort) { - throw getMdSortHeaderNotContainedWithinMdSortError(); + throw getSortHeaderNotContainedWithinSortError(); } this._rerenderSubscription = merge(_sort.sortChange, _intl.changes).subscribe(() => { @@ -124,7 +124,7 @@ export class MdSortHeader implements MdSortable { this._rerenderSubscription.unsubscribe(); } - /** Whether this MdSortHeader is currently sorted in either ascending or descending order. */ + /** Whether this MatSortHeader is currently sorted in either ascending or descending order. */ _isSorted() { return this._sort.active == this.id && this._sort.direction; } diff --git a/src/lib/sort/sort-module.ts b/src/lib/sort/sort-module.ts index 3f8cb960f55c..df4ad12434e1 100644 --- a/src/lib/sort/sort-module.ts +++ b/src/lib/sort/sort-module.ts @@ -7,16 +7,16 @@ */ import {NgModule} from '@angular/core'; -import {MdSortHeader} from './sort-header'; -import {MdSort} from './sort'; -import {MdSortHeaderIntl} from './sort-header-intl'; +import {MatSortHeader} from './sort-header'; +import {MatSort} from './sort'; +import {MatSortHeaderIntl} from './sort-header-intl'; import {CommonModule} from '@angular/common'; @NgModule({ imports: [CommonModule], - exports: [MdSort, MdSortHeader], - declarations: [MdSort, MdSortHeader], - providers: [MdSortHeaderIntl] + exports: [MatSort, MatSortHeader], + declarations: [MatSort, MatSortHeader], + providers: [MatSortHeaderIntl] }) -export class MdSortModule {} +export class MatSortModule {} diff --git a/src/lib/sort/sort.md b/src/lib/sort/sort.md index fb228e645821..5b331deeb797 100644 --- a/src/lib/sort/sort.md +++ b/src/lib/sort/sort.md @@ -1,17 +1,17 @@ -The `mdSort` and `md-sort-header` are used, respectively, to add sorting state and display +The `matSort` and `mat-sort-header` are used, respectively, to add sorting state and display to tabular data. ### Adding sort to table headers -To add sorting behavior and styling to a set of table headers, add the `` component +To add sorting behavior and styling to a set of table headers, add the `` component to each header and provide an `id` that will identify it. These headers should be contained within a -parent element with the `mdSort` directive, which will emit an `mdSortChange` event when the user +parent element with the `matSort` directive, which will emit an `matSortChange` event when the user triggers sorting on the header. Users can trigger the sort header through a mouse click or keyboard action. When this happens, the -`mdSort` will emit an `mdSortChange` event that contains the ID of the header triggered and the +`matSort` will emit an `matSortChange` event that contains the ID of the header triggered and the direction to sort (`asc` or `desc`). #### Changing the sort order @@ -19,20 +19,20 @@ direction to sort (`asc` or `desc`). By default, a sort header starts its sorting at `asc` and then `desc`. Triggering the sort header after `desc` will remove sorting. -To reverse the sort order for all headers, set the `mdSortStart` to `desc` on the `mdSort` +To reverse the sort order for all headers, set the `matSortStart` to `desc` on the `matSort` directive. To reverse the order only for a specific header, set the `start` input only on the header instead. To prevent the user from clearing the sort sort state from an already sorted column, set -`mdSortDisableClear` to `true` on the `mdSort` to affect all headers, or set `disableClear` to +`matSortDisableClear` to `true` on the `matSort` to affect all headers, or set `disableClear` to `true` on a specific header. -#### Using sort with the md-table +#### Using sort with the mat-table -When used on an `md-table` header, it is not required to set an `md-sort-header` id on because +When used on an `mat-table` header, it is not required to set an `mat-sort-header` id on because by default it will use the id of the column. ### Accessibility -The `aria-label` for the sort button can be set in `MdSortHeaderIntl`. +The `aria-label` for the sort button can be set in `MatSortHeaderIntl`. diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index 36038f4d0d70..4bc46e516d45 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -7,72 +7,79 @@ import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {Observable} from 'rxjs/Observable'; import {map} from 'rxjs/operator/map'; -import {MdTableModule} from '../table/index'; -import {MdSort, MdSortHeader, MdSortHeaderIntl, MdSortModule, Sort, SortDirection} from './index'; +import {MatTableModule} from '../table/index'; import { - getMdSortDuplicateMdSortableIdError, - getMdSortHeaderMissingIdError, - getMdSortHeaderNotContainedWithinMdSortError, + MatSort, + MatSortHeader, + MatSortHeaderIntl, + MatSortModule, + Sort, + SortDirection +} from './index'; +import { + getSortDuplicateSortableIdError, + getSortHeaderMissingIdError, + getSortHeaderNotContainedWithinSortError, } from './sort-errors'; -describe('MdSort', () => { - let fixture: ComponentFixture; +describe('MatSort', () => { + let fixture: ComponentFixture; - let component: SimpleMdSortApp; + let component: SimpleMatSortApp; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdSortModule, MdTableModule, CdkTableModule, NoopAnimationsModule], + imports: [MatSortModule, MatTableModule, CdkTableModule, NoopAnimationsModule], declarations: [ - SimpleMdSortApp, - CdkTableMdSortApp, - MdTableMdSortApp, - MdSortHeaderMissingMdSortApp, - MdSortDuplicateMdSortableIdsApp, - MdSortableMissingIdApp + SimpleMatSortApp, + CdkTableMatSortApp, + MatTableMatSortApp, + MatSortHeaderMissingMatSortApp, + MatSortDuplicateMatSortableIdsApp, + MatSortableMissingIdApp ], }).compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(SimpleMdSortApp); + fixture = TestBed.createComponent(SimpleMatSortApp); component = fixture.componentInstance; fixture.detectChanges(); }); it('should have the sort headers register and deregister themselves', () => { - const sortables = component.mdSort.sortables; + const sortables = component.matSort.sortables; expect(sortables.size).toBe(4); - expect(sortables.get('defaultSortHeaderA')).toBe(component.mdSortHeaderDefaultA); - expect(sortables.get('defaultSortHeaderB')).toBe(component.mdSortHeaderDefaultB); + expect(sortables.get('defaultSortHeaderA')).toBe(component.matSortHeaderDefaultA); + expect(sortables.get('defaultSortHeaderB')).toBe(component.matSortHeaderDefaultB); fixture.destroy(); expect(sortables.size).toBe(0); }); it('should use the column definition if used within a cdk table', () => { - let cdkTableMdSortAppFixture = TestBed.createComponent(CdkTableMdSortApp); - let cdkTableMdSortAppComponent = cdkTableMdSortAppFixture.componentInstance; + let cdkTableMatSortAppFixture = TestBed.createComponent(CdkTableMatSortApp); + let cdkTableMatSortAppComponent = cdkTableMatSortAppFixture.componentInstance; - cdkTableMdSortAppFixture.detectChanges(); - cdkTableMdSortAppFixture.detectChanges(); + cdkTableMatSortAppFixture.detectChanges(); + cdkTableMatSortAppFixture.detectChanges(); - const sortables = cdkTableMdSortAppComponent.mdSort.sortables; + const sortables = cdkTableMatSortAppComponent.matSort.sortables; expect(sortables.size).toBe(3); expect(sortables.has('column_a')).toBe(true); expect(sortables.has('column_b')).toBe(true); expect(sortables.has('column_c')).toBe(true); }); - it('should use the column definition if used within an md table', () => { - let mdTableMdSortAppFixture = TestBed.createComponent(MdTableMdSortApp); - let mdTableMdSortAppComponent = mdTableMdSortAppFixture.componentInstance; + it('should use the column definition if used within an mat table', () => { + let matTableMatSortAppFixture = TestBed.createComponent(MatTableMatSortApp); + let matTableMatSortAppComponent = matTableMatSortAppFixture.componentInstance; - mdTableMdSortAppFixture.detectChanges(); - mdTableMdSortAppFixture.detectChanges(); + matTableMatSortAppFixture.detectChanges(); + matTableMatSortAppFixture.detectChanges(); - const sortables = mdTableMdSortAppComponent.mdSort.sortables; + const sortables = matTableMatSortAppComponent.matSort.sortables; expect(sortables.size).toBe(3); expect(sortables.has('column_a')).toBe(true); expect(sortables.has('column_b')).toBe(true); @@ -102,34 +109,34 @@ describe('MdSort', () => { it('should reset sort direction when a different column is sorted', () => { component.sort('defaultSortHeaderA'); - expect(component.mdSort.active).toBe('defaultSortHeaderA'); - expect(component.mdSort.direction).toBe('asc'); + expect(component.matSort.active).toBe('defaultSortHeaderA'); + expect(component.matSort.direction).toBe('asc'); component.sort('defaultSortHeaderA'); - expect(component.mdSort.active).toBe('defaultSortHeaderA'); - expect(component.mdSort.direction).toBe('desc'); + expect(component.matSort.active).toBe('defaultSortHeaderA'); + expect(component.matSort.direction).toBe('desc'); component.sort('defaultSortHeaderB'); - expect(component.mdSort.active).toBe('defaultSortHeaderB'); - expect(component.mdSort.direction).toBe('asc'); + expect(component.matSort.active).toBe('defaultSortHeaderB'); + expect(component.matSort.direction).toBe('asc'); }); - it('should throw an error if an MdSortable is not contained within an MdSort directive', () => { - expect(() => TestBed.createComponent(MdSortHeaderMissingMdSortApp).detectChanges()) - .toThrowError(wrappedErrorMessage(getMdSortHeaderNotContainedWithinMdSortError())); + it('should throw an error if an MatSortable is not contained within an MatSort directive', () => { + expect(() => TestBed.createComponent(MatSortHeaderMissingMatSortApp).detectChanges()) + .toThrowError(wrappedErrorMessage(getSortHeaderNotContainedWithinSortError())); }); - it('should throw an error if two MdSortables have the same id', () => { - expect(() => TestBed.createComponent(MdSortDuplicateMdSortableIdsApp).detectChanges()) - .toThrowError(wrappedErrorMessage(getMdSortDuplicateMdSortableIdError('duplicateId'))); + it('should throw an error if two MatSortables have the same id', () => { + expect(() => TestBed.createComponent(MatSortDuplicateMatSortableIdsApp).detectChanges()) + .toThrowError(wrappedErrorMessage(getSortDuplicateSortableIdError('duplicateId'))); }); - it('should throw an error if an MdSortable is missing an id', () => { - expect(() => TestBed.createComponent(MdSortableMissingIdApp).detectChanges()) - .toThrowError(wrappedErrorMessage(getMdSortHeaderMissingIdError())); + it('should throw an error if an MatSortable is missing an id', () => { + expect(() => TestBed.createComponent(MatSortableMissingIdApp).detectChanges()) + .toThrowError(wrappedErrorMessage(getSortHeaderMissingIdError())); }); - it('should allow let MdSortable override the default sort parameters', () => { + it('should allow let MatSortable override the default sort parameters', () => { testSingleColumnSortDirectionSequence( fixture, ['asc', 'desc', '']); @@ -146,8 +153,8 @@ describe('MdSort', () => { }); it('should re-render when the i18n labels have changed', - inject([MdSortHeaderIntl], (intl: MdSortHeaderIntl) => { - const header = fixture.debugElement.query(By.directive(MdSortHeader)).nativeElement; + inject([MatSortHeaderIntl], (intl: MatSortHeaderIntl) => { + const header = fixture.debugElement.query(By.directive(MatSortHeader)).nativeElement; const button = header.querySelector('.mat-sort-header-button'); intl.sortButtonLabel = () => 'Sort all of the things'; @@ -161,54 +168,58 @@ describe('MdSort', () => { /** * Performs a sequence of sorting on a single column to see if the sort directions are * consistent with expectations. Detects any changes in the fixture to reflect any changes in - * the inputs and resets the MdSort to remove any side effects from previous tests. + * the inputs and resets the MatSort to remove any side effects from previous tests. */ -function testSingleColumnSortDirectionSequence(fixture: ComponentFixture, +function testSingleColumnSortDirectionSequence(fixture: ComponentFixture, expectedSequence: SortDirection[], id: string = 'defaultSortHeaderA') { // Detect any changes that were made in preparation for this sort sequence fixture.detectChanges(); - // Reset the md sort to make sure there are no side affects from previous tests + // Reset the sort to make sure there are no side affects from previous tests const component = fixture.componentInstance; - component.mdSort.active = ''; - component.mdSort.direction = ''; + component.matSort.active = ''; + component.matSort.direction = ''; // Run through the sequence to confirm the order let actualSequence = expectedSequence.map(() => { component.sort(id); - // Check that the sort event's active sort is consistent with the MdSort - expect(component.mdSort.active).toBe(id); + // Check that the sort event's active sort is consistent with the MatSort + expect(component.matSort.active).toBe(id); expect(component.latestSortEvent.active).toBe(id); - // Check that the sort event's direction is consistent with the MdSort - expect(component.mdSort.direction).toBe(component.latestSortEvent.direction); - return component.mdSort.direction; + // Check that the sort event's direction is consistent with the MatSort + expect(component.matSort.direction).toBe(component.latestSortEvent.direction); + return component.matSort.direction; }); expect(actualSequence).toEqual(expectedSequence); // Expect that performing one more sort will loop it back to the beginning. component.sort(id); - expect(component.mdSort.direction).toBe(expectedSequence[0]); + expect(component.matSort.direction).toBe(expectedSequence[0]); } @Component({ template: ` -
-
A
-
B
-
D
-
E
+
+
+ A +
+
+ B +
+
D
+
E
` }) -class SimpleMdSortApp { +class SimpleMatSortApp { latestSortEvent: Sort; active: string; @@ -216,9 +227,9 @@ class SimpleMdSortApp { direction: SortDirection = ''; disableClear: boolean; - @ViewChild(MdSort) mdSort: MdSort; - @ViewChild('defaultSortHeaderA') mdSortHeaderDefaultA: MdSortHeader; - @ViewChild('defaultSortHeaderB') mdSortHeaderDefaultB: MdSortHeader; + @ViewChild(MatSort) matSort: MatSort; + @ViewChild('defaultSortHeaderA') matSortHeaderDefaultA: MatSortHeader; + @ViewChild('defaultSortHeaderB') matSortHeaderDefaultB: MatSortHeader; constructor (public elementRef: ElementRef) { } @@ -238,19 +249,19 @@ class FakeDataSource extends DataSource { @Component({ template: ` - + - Column A + Column A {{row.a}} - Column B + Column B {{row.b}} - Column C + Column C {{row.c}} @@ -259,8 +270,8 @@ class FakeDataSource extends DataSource { ` }) -class CdkTableMdSortApp { - @ViewChild(MdSort) mdSort: MdSort; +class CdkTableMatSortApp { + @ViewChild(MatSort) matSort: MatSort; dataSource = new FakeDataSource(); columnsToRender = ['column_a', 'column_b', 'column_c']; @@ -268,29 +279,29 @@ class CdkTableMdSortApp { @Component({ template: ` - - - Column A - {{row.a}} + + + Column A + {{row.a}} - - Column B - {{row.b}} + + Column B + {{row.b}} - - Column C - {{row.c}} + + Column C + {{row.c}} - - - + + + ` }) -class MdTableMdSortApp { - @ViewChild(MdSort) mdSort: MdSort; +class MatTableMatSortApp { + @ViewChild(MatSort) matSort: MatSort; dataSource = new FakeDataSource(); columnsToRender = ['column_a', 'column_b', 'column_c']; @@ -298,27 +309,27 @@ class MdTableMdSortApp { @Component({ - template: `
A
` + template: `
A
` }) -class MdSortHeaderMissingMdSortApp { } +class MatSortHeaderMissingMatSortApp { } @Component({ template: ` -
-
A
-
A
+
+
A
+
A
` }) -class MdSortDuplicateMdSortableIdsApp { } +class MatSortDuplicateMatSortableIdsApp { } @Component({ template: ` -
-
A
+
+
A
` }) -class MdSortableMissingIdApp { } +class MatSortableMissingIdApp { } diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index c0151361bfe3..3c5f7078dacf 100644 --- a/src/lib/sort/sort.ts +++ b/src/lib/sort/sort.ts @@ -9,9 +9,9 @@ import {Directive, EventEmitter, Input, Output} from '@angular/core'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {SortDirection} from './sort-direction'; -import {getMdSortDuplicateMdSortableIdError, getMdSortHeaderMissingIdError} from './sort-errors'; +import {getSortDuplicateSortableIdError, getSortHeaderMissingIdError} from './sort-errors'; -export interface MdSortable { +export interface MatSortable { id: string; start: 'asc' | 'desc'; disableClear: boolean; @@ -22,86 +22,63 @@ export interface Sort { direction: SortDirection; } -/** Container for MdSortables to manage the sort state and provide default sort parameters. */ +/** Container for MatSortables to manage the sort state and provide default sort parameters. */ @Directive({ - selector: '[mdSort], [matSort]', + selector: '[matSort]', }) -export class MdSort { +export class MatSort { /** Collection of all registered sortables that this directive manages. */ - sortables = new Map(); + sortables = new Map(); - /** The id of the most recently sorted MdSortable. */ - @Input('mdSortActive') active: string; + /** The id of the most recently sorted MatSortable. */ + @Input('matSortActive') active: string; /** - * The direction to set when an MdSortable is initially sorted. - * May be overriden by the MdSortable's sort start. + * The direction to set when an MatSortable is initially sorted. + * May be overriden by the MatSortable's sort start. */ - @Input('mdSortStart') start: 'asc' | 'desc' = 'asc'; + @Input('matSortStart') start: 'asc' | 'desc' = 'asc'; - /** The sort direction of the currently active MdSortable. */ - @Input('mdSortDirection') direction: SortDirection = ''; + /** The sort direction of the currently active MatSortable. */ + @Input('matSortDirection') direction: SortDirection = ''; /** * Whether to disable the user from clearing the sort by finishing the sort direction cycle. - * May be overriden by the MdSortable's disable clear input. + * May be overriden by the MatSortable's disable clear input. */ - @Input('mdSortDisableClear') + @Input('matSortDisableClear') get disableClear() { return this._disableClear; } set disableClear(v) { this._disableClear = coerceBooleanProperty(v); } private _disableClear: boolean; - // Properties with `mat-` prefix for noconflict mode. - @Input('matSortActive') - get _matSortActive() { return this.active; } - set _matSortActive(v) { this.active = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matSortStart') - get _matSortStart() { return this.start; } - set _matSortStart(v) { this.start = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matSortDirection') - get _matSortDirection() { return this.direction; } - set _matSortDirection(v) { this.direction = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matSortDisableClear') - get _matSortDisableClear() { return this.disableClear; } - set _matSortDisableClear(v) { this.disableClear = v; } - /** Event emitted when the user changes either the active sort or sort direction. */ - @Output('mdSortChange') readonly sortChange = new EventEmitter(); - - @Output('matSortChange') - get _matSortChange(): EventEmitter { return this.sortChange; } + @Output('matSortChange') readonly sortChange = new EventEmitter(); /** - * Register function to be used by the contained MdSortables. Adds the MdSortable to the - * collection of MdSortables. + * Register function to be used by the contained MatSortables. Adds the MatSortable to the + * collection of MatSortables. */ - register(sortable: MdSortable) { + register(sortable: MatSortable) { if (!sortable.id) { - throw getMdSortHeaderMissingIdError(); + throw getSortHeaderMissingIdError(); } if (this.sortables.has(sortable.id)) { - throw getMdSortDuplicateMdSortableIdError(sortable.id); + throw getSortDuplicateSortableIdError(sortable.id); } this.sortables.set(sortable.id, sortable); } /** - * Unregister function to be used by the contained MdSortables. Removes the MdSortable from the - * collection of contained MdSortables. + * Unregister function to be used by the contained MatSortables. Removes the MatSortable from the + * collection of contained MatSortables. */ - deregister(sortable: MdSortable) { + deregister(sortable: MatSortable) { this.sortables.delete(sortable.id); } /** Sets the active sort id and determines the new sort direction. */ - sort(sortable: MdSortable) { + sort(sortable: MatSortable) { if (this.active != sortable.id) { this.active = sortable.id; this.direction = sortable.start ? sortable.start : this.start; @@ -113,7 +90,7 @@ export class MdSort { } /** Returns the next sort direction of the active sortable, checking for potential overrides. */ - getNextSortDirection(sortable: MdSortable): SortDirection { + getNextSortDirection(sortable: MatSortable): SortDirection { if (!sortable) { return ''; } // Get the sort direction cycle with the potential sortable overrides. diff --git a/src/lib/stepper/mat-exports.ts b/src/lib/stepper/mat-exports.ts deleted file mode 100644 index f561023416b9..000000000000 --- a/src/lib/stepper/mat-exports.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MdHorizontalStepper, - MdStep, - MdStepper, - MdVerticalStepper, -} from './stepper'; -import {MdStepHeader} from './step-header'; -import {MdStepLabel} from './step-label'; -import {MdStepperNext, MdStepperPrevious} from './stepper-button'; -import {MdStepperModule} from './stepper-module'; - - -export {MdStep as MatStep}; -export {MdStepHeader as MatStepHeader}; -export {MdStepLabel as MatStepLabel}; -export {MdStepper as MatStepper}; -export {MdHorizontalStepper as MatHorizontalStepper}; -export {MdStepperModule as MatStepperModule}; -export {MdVerticalStepper as MatVerticalStepper}; -export {MdStepperPrevious as MatStepperPrevious}; -export {MdStepperNext as MatStepperNext}; diff --git a/src/lib/stepper/public_api.ts b/src/lib/stepper/public_api.ts index f55f0ffc768d..3fa16f569ac9 100644 --- a/src/lib/stepper/public_api.ts +++ b/src/lib/stepper/public_api.ts @@ -11,4 +11,4 @@ export * from './step-label'; export * from './stepper'; export * from './stepper-button'; export * from './step-header'; -export * from './mat-exports'; + diff --git a/src/lib/stepper/step-header.ts b/src/lib/stepper/step-header.ts index be0390fc7b58..3b87ea8d4932 100644 --- a/src/lib/stepper/step-header.ts +++ b/src/lib/stepper/step-header.ts @@ -8,13 +8,12 @@ import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; import {Component, Input, ViewEncapsulation} from '@angular/core'; -import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; -import {MdStepLabel} from './step-label'; +import {MatStepLabel} from './step-label'; @Component({ moduleId: module.id, - selector: 'md-step-header, mat-step-header', + selector: 'mat-step-header', templateUrl: 'step-header.html', styleUrls: ['step-header.css'], host: { @@ -23,14 +22,13 @@ import {MdStepLabel} from './step-label'; }, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdStepHeader { +export class MatStepHeader { /** Icon for the given step. */ @Input() icon: string; /** Label of the given step. */ - @Input() label: MdStepLabel | string; + @Input() label: MatStepLabel | string; /** Index of the given step. */ @Input() @@ -66,11 +64,11 @@ export class MdStepHeader { /** Returns string label of given step if it is a text label. */ _stringLabel(): string | null { - return this.label instanceof MdStepLabel ? null : this.label; + return this.label instanceof MatStepLabel ? null : this.label; } - /** Returns MdStepLabel if the label of given step is a template label. */ - _templateLabel(): MdStepLabel | null { - return this.label instanceof MdStepLabel ? this.label : null; + /** Returns MatStepLabel if the label of given step is a template label. */ + _templateLabel(): MatStepLabel | null { + return this.label instanceof MatStepLabel ? this.label : null; } } diff --git a/src/lib/stepper/step-label.ts b/src/lib/stepper/step-label.ts index 62e1bc7f60e4..e4f166057a10 100644 --- a/src/lib/stepper/step-label.ts +++ b/src/lib/stepper/step-label.ts @@ -10,12 +10,12 @@ import {Directive, TemplateRef} from '@angular/core'; import {CdkStepLabel} from '@angular/cdk/stepper'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdStepLabel = CdkStepLabel; +export const _MatStepLabel = CdkStepLabel; @Directive({ - selector: '[mdStepLabel], [matStepLabel]', + selector: '[matStepLabel]', }) -export class MdStepLabel extends _MdStepLabel { +export class MatStepLabel extends _MatStepLabel { constructor(template: TemplateRef) { super(template); } diff --git a/src/lib/stepper/stepper-button.ts b/src/lib/stepper/stepper-button.ts index e1d5bb488bef..46d209710bfd 100644 --- a/src/lib/stepper/stepper-button.ts +++ b/src/lib/stepper/stepper-button.ts @@ -8,24 +8,24 @@ import {Directive} from '@angular/core'; import {CdkStepper, CdkStepperNext, CdkStepperPrevious} from '@angular/cdk/stepper'; -import {MdStepper} from './stepper'; +import {MatStepper} from './stepper'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdStepperNext = CdkStepperNext; -export const _MdStepperPrevious = CdkStepperPrevious; +export const _MatStepperNext = CdkStepperNext; +export const _MatStepperPrevious = CdkStepperPrevious; /** Button that moves to the next step in a stepper workflow. */ @Directive({ - selector: 'button[mdStepperNext], button[matStepperNext]', + selector: 'button[matStepperNext]', host: {'(click)': '_stepper.next()'}, - providers: [{provide: CdkStepper, useExisting: MdStepper}] + providers: [{provide: CdkStepper, useExisting: MatStepper}] }) -export class MdStepperNext extends _MdStepperNext { } +export class MatStepperNext extends _MatStepperNext { } /** Button that moves to the previous step in a stepper workflow. */ @Directive({ - selector: 'button[mdStepperPrevious], button[matStepperPrevious]', + selector: 'button[matStepperPrevious]', host: {'(click)': '_stepper.previous()'}, - providers: [{provide: CdkStepper, useExisting: MdStepper}] + providers: [{provide: CdkStepper, useExisting: MatStepper}] }) -export class MdStepperPrevious extends _MdStepperPrevious { } +export class MatStepperPrevious extends _MatStepperPrevious { } diff --git a/src/lib/stepper/stepper-module.ts b/src/lib/stepper/stepper-module.ts index 5737a20e61e8..31d0751b644d 100644 --- a/src/lib/stepper/stepper-module.ts +++ b/src/lib/stepper/stepper-module.ts @@ -10,36 +10,36 @@ import {PortalModule} from '@angular/cdk/portal'; import {CdkStepperModule} from '@angular/cdk/stepper'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {MdButtonModule} from '@angular/material/button'; -import {MdCommonModule} from '@angular/material/core'; -import {MdIconModule} from '@angular/material/icon'; -import {MdStepHeader} from './step-header'; -import {MdStepLabel} from './step-label'; -import {MdHorizontalStepper, MdStep, MdStepper, MdVerticalStepper} from './stepper'; -import {MdStepperNext, MdStepperPrevious} from './stepper-button'; +import {MatButtonModule} from '@angular/material/button'; +import {MatCommonModule} from '@angular/material/core'; +import {MatIconModule} from '@angular/material/icon'; +import {MatStepHeader} from './step-header'; +import {MatStepLabel} from './step-label'; +import {MatHorizontalStepper, MatStep, MatStepper, MatVerticalStepper} from './stepper'; +import {MatStepperNext, MatStepperPrevious} from './stepper-button'; @NgModule({ imports: [ - MdCommonModule, + MatCommonModule, CommonModule, PortalModule, - MdButtonModule, + MatButtonModule, CdkStepperModule, - MdIconModule + MatIconModule ], exports: [ - MdCommonModule, - MdHorizontalStepper, - MdVerticalStepper, - MdStep, - MdStepLabel, - MdStepper, - MdStepperNext, - MdStepperPrevious, - MdStepHeader + MatCommonModule, + MatHorizontalStepper, + MatVerticalStepper, + MatStep, + MatStepLabel, + MatStepper, + MatStepperNext, + MatStepperPrevious, + MatStepHeader ], - declarations: [MdHorizontalStepper, MdVerticalStepper, MdStep, MdStepLabel, MdStepper, - MdStepperNext, MdStepperPrevious, MdStepHeader], + declarations: [MatHorizontalStepper, MatVerticalStepper, MatStep, MatStepLabel, MatStepper, + MatStepperNext, MatStepperPrevious, MatStepHeader], }) -export class MdStepperModule {} +export class MatStepperModule {} diff --git a/src/lib/stepper/stepper.md b/src/lib/stepper/stepper.md index cf3381330478..e41d89b68c39 100644 --- a/src/lib/stepper/stepper.md +++ b/src/lib/stepper/stepper.md @@ -7,110 +7,110 @@ that drives a stepped workflow. Material stepper extends the CDK stepper and has styling. ### Stepper variants -There are two stepper components: `md-horizontal-stepper` and `md-vertical-stepper`. They +There are two stepper components: `mat-horizontal-stepper` and `mat-vertical-stepper`. They can be used the same way. The only difference is the orientation of stepper. -`md-horizontal-stepper` selector can be used to create a horizontal stepper, and -`md-vertical-stepper` can be used to create a vertical stepper. `md-step` components need to be +`mat-horizontal-stepper` selector can be used to create a horizontal stepper, and +`mat-vertical-stepper` can be used to create a vertical stepper. `mat-step` components need to be placed inside either one of the two stepper components. ### Labels If a step's label is only text, then the `label` attribute can be used. ```html - - + + Content 1 - - + + Content 2 - - + + ``` -For more complex labels, add a template with the `mdStepLabel` directive inside the -`md-step`. +For more complex labels, add a template with the `matStepLabel` directive inside the +`mat-step`. ```html - - - ... + + + ... ... - - + + ``` ### Stepper buttons There are two button directives to support navigation between different steps: -`mdStepperPrevious` and `mdStepperNext`. +`matStepperPrevious` and `matStepperNext`. ```html - - + + ...
- - + +
-
-
+ + ``` ### Linear stepper -The `linear` attribute can be set on `md-horizontal-stepper` and `md-vertical-stepper` to create +The `linear` attribute can be set on `mat-horizontal-stepper` and `mat-vertical-stepper` to create a linear stepper that requires the user to complete previous steps before proceeding -to following steps. For each `md-step`, the `stepControl` attribute can be set to the top level +to following steps. For each `mat-step`, the `stepControl` attribute can be set to the top level `AbstractControl` that is used to check the validity of the step. There are two possible approaches. One is using a single form for stepper, and the other is using a different form for each step. #### Using a single form -When using a single form for the stepper, `mdStepperPrevious` and `mdStepperNext` have to be +When using a single form for the stepper, `matStepperPrevious` and `matStepperNext` have to be set to `type="button"` in order to prevent submission of the form before all steps are completed. ```html
- - + + ...
- +
-
- + + ...
- - + +
-
+ ... -
+ ``` #### Using a different form for each step ```html - - + +
... -
- + +
... -
-
+ + ``` ### Types of steps #### Optional step If completion of a step in linear stepper is not required, then the `optional` attribute can be set -on `md-step`. +on `mat-step`. #### Editable step By default, steps are editable, which means users can return to previously completed steps and -edit their responses. `editable="true"` can be set on `md-step` to change the default. +edit their responses. `editable="true"` can be set on `mat-step` to change the default. #### Completed step By default, the `completed` attribute of a step returns `true` if the step is valid (in case of diff --git a/src/lib/stepper/stepper.spec.ts b/src/lib/stepper/stepper.spec.ts index ec042211fd71..eebd89f6dee9 100644 --- a/src/lib/stepper/stepper.spec.ts +++ b/src/lib/stepper/stepper.spec.ts @@ -6,22 +6,22 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdStepperModule} from './index'; -import {MdHorizontalStepper, MdStepper, MdVerticalStepper} from './stepper'; -import {MdStepperNext, MdStepperPrevious} from './stepper-button'; +import {MatStepperModule} from './index'; +import {MatHorizontalStepper, MatStepper, MatVerticalStepper} from './stepper'; +import {MatStepperNext, MatStepperPrevious} from './stepper-button'; const VALID_REGEX = /valid/; -describe('MdHorizontalStepper', () => { +describe('MatHorizontalStepper', () => { let dir = 'ltr'; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdStepperModule, NoopAnimationsModule, ReactiveFormsModule], + imports: [MatStepperModule, NoopAnimationsModule, ReactiveFormsModule], declarations: [ - SimpleMdHorizontalStepperApp, - LinearMdHorizontalStepperApp + SimpleMatHorizontalStepperApp, + LinearMatHorizontalStepperApp ], providers: [ {provide: Directionality, useFactory: () => ({value: dir})} @@ -32,16 +32,16 @@ describe('MdHorizontalStepper', () => { })); describe('basic horizontal stepper', () => { - let fixture: ComponentFixture; + let fixture: ComponentFixture; beforeEach(() => { - fixture = TestBed.createComponent(SimpleMdHorizontalStepperApp); + fixture = TestBed.createComponent(SimpleMatHorizontalStepperApp); fixture.detectChanges(); }); it('should default to the first step', () => { let stepperComponent = fixture.debugElement - .query(By.css('md-horizontal-stepper')).componentInstance; + .query(By.css('mat-horizontal-stepper')).componentInstance; expect(stepperComponent.selectedIndex).toBe(0); }); @@ -51,7 +51,7 @@ describe('MdHorizontalStepper', () => { }); it('should set the "tablist" role on stepper', () => { - let stepperEl = fixture.debugElement.query(By.css('md-horizontal-stepper')).nativeElement; + let stepperEl = fixture.debugElement.query(By.css('mat-horizontal-stepper')).nativeElement; expect(stepperEl.getAttribute('role')).toBe('tablist'); }); @@ -99,11 +99,11 @@ describe('MdHorizontalStepper', () => { }); describe('RTL', () => { - let fixture: ComponentFixture; + let fixture: ComponentFixture; beforeEach(() => { dir = 'rtl'; - fixture = TestBed.createComponent(SimpleMdHorizontalStepperApp); + fixture = TestBed.createComponent(SimpleMatHorizontalStepperApp); fixture.detectChanges(); }); @@ -118,17 +118,17 @@ describe('MdHorizontalStepper', () => { }); describe('linear horizontal stepper', () => { - let fixture: ComponentFixture; - let testComponent: LinearMdHorizontalStepperApp; - let stepperComponent: MdHorizontalStepper; + let fixture: ComponentFixture; + let testComponent: LinearMatHorizontalStepperApp; + let stepperComponent: MatHorizontalStepper; beforeEach(() => { - fixture = TestBed.createComponent(LinearMdHorizontalStepperApp); + fixture = TestBed.createComponent(LinearMatHorizontalStepperApp); fixture.detectChanges(); testComponent = fixture.componentInstance; stepperComponent = fixture.debugElement - .query(By.css('md-horizontal-stepper')).componentInstance; + .query(By.css('mat-horizontal-stepper')).componentInstance; }); it('should have true linear attribute', () => { @@ -156,15 +156,15 @@ describe('MdHorizontalStepper', () => { }); }); -describe('MdVerticalStepper', () => { +describe('MatVerticalStepper', () => { let dir = 'ltr'; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdStepperModule, NoopAnimationsModule, ReactiveFormsModule], + imports: [MatStepperModule, NoopAnimationsModule, ReactiveFormsModule], declarations: [ - SimpleMdVerticalStepperApp, - LinearMdVerticalStepperApp + SimpleMatVerticalStepperApp, + LinearMatVerticalStepperApp ], providers: [ {provide: Directionality, useFactory: () => ({value: dir})} @@ -175,16 +175,16 @@ describe('MdVerticalStepper', () => { })); describe('basic vertical stepper', () => { - let fixture: ComponentFixture; + let fixture: ComponentFixture; beforeEach(() => { - fixture = TestBed.createComponent(SimpleMdVerticalStepperApp); + fixture = TestBed.createComponent(SimpleMatVerticalStepperApp); fixture.detectChanges(); }); it('should default to the first step', () => { let stepperComponent = fixture.debugElement - .query(By.css('md-vertical-stepper')).componentInstance; + .query(By.css('mat-vertical-stepper')).componentInstance; expect(stepperComponent.selectedIndex).toBe(0); }); @@ -195,7 +195,7 @@ describe('MdVerticalStepper', () => { }); it('should set the "tablist" role on stepper', () => { - let stepperEl = fixture.debugElement.query(By.css('md-vertical-stepper')).nativeElement; + let stepperEl = fixture.debugElement.query(By.css('mat-vertical-stepper')).nativeElement; expect(stepperEl.getAttribute('role')).toBe('tablist'); }); @@ -243,11 +243,11 @@ describe('MdVerticalStepper', () => { }); describe('RTL', () => { - let fixture: ComponentFixture; + let fixture: ComponentFixture; beforeEach(() => { dir = 'rtl'; - fixture = TestBed.createComponent(SimpleMdVerticalStepperApp); + fixture = TestBed.createComponent(SimpleMatVerticalStepperApp); fixture.detectChanges(); }); @@ -262,17 +262,17 @@ describe('MdVerticalStepper', () => { }); describe('linear vertical stepper', () => { - let fixture: ComponentFixture; - let testComponent: LinearMdVerticalStepperApp; - let stepperComponent: MdVerticalStepper; + let fixture: ComponentFixture; + let testComponent: LinearMatVerticalStepperApp; + let stepperComponent: MatVerticalStepper; beforeEach(() => { - fixture = TestBed.createComponent(LinearMdVerticalStepperApp); + fixture = TestBed.createComponent(LinearMatVerticalStepperApp); fixture.detectChanges(); testComponent = fixture.componentInstance; stepperComponent = fixture.debugElement - .query(By.css('md-vertical-stepper')).componentInstance; + .query(By.css('mat-vertical-stepper')).componentInstance; }); it('should have true linear attribute', () => { @@ -304,7 +304,7 @@ describe('MdVerticalStepper', () => { /** Asserts that `selectedIndex` updates correctly when header of another step is clicked. */ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture, stepHeaders: DebugElement[]) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent.selectedIndex).toBe(0); @@ -326,7 +326,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture, /** Asserts that 'aria-expanded' attribute is correct for expanded content of step. */ function assertCorrectAriaExpandedAttribute(fixture: ComponentFixture, stepContents: DebugElement[]) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; let firstStepContentEl = stepContents[0].nativeElement; expect(firstStepContentEl.getAttribute('aria-expanded')).toBe('true'); @@ -340,7 +340,7 @@ function assertCorrectAriaExpandedAttribute(fixture: ComponentFixture, /** Asserts that step has correct label. */ function assertCorrectStepLabel(fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; let selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]'); expect(selectedLabel.textContent).toMatch('Step 1'); @@ -357,57 +357,57 @@ function assertCorrectStepLabel(fixture: ComponentFixture) { expect(selectedLabel.textContent).toMatch('New Label'); } -/** Asserts that clicking on MdStepperNext button updates `selectedIndex` correctly. */ +/** Asserts that clicking on MatStepperNext button updates `selectedIndex` correctly. */ function assertNextStepperButtonClick(fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent.selectedIndex).toBe(0); let nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[0].nativeElement; + .queryAll(By.directive(MatStepperNext))[0].nativeElement; nextButtonNativeEl.click(); fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(1); nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[1].nativeElement; + .queryAll(By.directive(MatStepperNext))[1].nativeElement; nextButtonNativeEl.click(); fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(2); nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[2].nativeElement; + .queryAll(By.directive(MatStepperNext))[2].nativeElement; nextButtonNativeEl.click(); fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(2); } -/** Asserts that clicking on MdStepperPrevious button updates `selectedIndex` correctly. */ +/** Asserts that clicking on MatStepperPrevious button updates `selectedIndex` correctly. */ function assertPreviousStepperButtonClick(fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent.selectedIndex).toBe(0); stepperComponent.selectedIndex = 2; let previousButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperPrevious))[2].nativeElement; + .queryAll(By.directive(MatStepperPrevious))[2].nativeElement; previousButtonNativeEl.click(); fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(1); previousButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperPrevious))[1].nativeElement; + .queryAll(By.directive(MatStepperPrevious))[1].nativeElement; previousButtonNativeEl.click(); fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(0); previousButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperPrevious))[0].nativeElement; + .queryAll(By.directive(MatStepperPrevious))[0].nativeElement; previousButtonNativeEl.click(); fixture.detectChanges(); @@ -416,7 +416,7 @@ function assertPreviousStepperButtonClick(fixture: ComponentFixture) { /** Asserts that step position is correct for animation. */ function assertCorrectStepAnimationDirection(fixture: ComponentFixture, rtl?: 'rtl') { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent._getAnimationDirection(0)).toBe('current'); if (rtl === 'rtl') { @@ -455,7 +455,7 @@ function assertCorrectStepAnimationDirection(fixture: ComponentFixture, rtl /** Asserts that keyboard interaction works correctly. */ function assertCorrectKeyboardInteraction(fixture: ComponentFixture, stepHeaders: DebugElement[]) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent._focusIndex).toBe(0); expect(stepperComponent.selectedIndex).toBe(0); @@ -514,10 +514,10 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture, /** Asserts that step selection change using stepper buttons does not focus step header. */ function assertStepHeaderFocusNotCalled(fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; let stepHeaderEl = fixture.debugElement.queryAll(By.css('mat-step-header'))[1].nativeElement; let nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[0].nativeElement; + .queryAll(By.directive(MatStepperNext))[0].nativeElement; spyOn(stepHeaderEl, 'focus'); nextButtonNativeEl.click(); fixture.detectChanges(); @@ -529,7 +529,7 @@ function assertStepHeaderFocusNotCalled(fixture: ComponentFixture) { /** Asserts that arrow key direction works correctly in RTL mode. */ function assertArrowKeyInteractionInRtl(fixture: ComponentFixture, stepHeaders: DebugElement[]) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent._focusIndex).toBe(0); @@ -551,9 +551,10 @@ function assertArrowKeyInteractionInRtl(fixture: ComponentFixture, */ function assertLinearStepperValidity(stepHeaderEl: HTMLElement, testComponent: - LinearMdHorizontalStepperApp | LinearMdVerticalStepperApp, + LinearMatHorizontalStepperApp | + LinearMatVerticalStepperApp, fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; stepHeaderEl.click(); fixture.detectChanges(); @@ -561,7 +562,7 @@ function assertLinearStepperValidity(stepHeaderEl: HTMLElement, expect(stepperComponent.selectedIndex).toBe(0); let nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[0].nativeElement; + .queryAll(By.directive(MatStepperNext))[0].nativeElement; nextButtonNativeEl.click(); fixture.detectChanges(); @@ -588,12 +589,12 @@ function assertStepHeaderBlurred(fixture: ComponentFixture) { /** Asserts that it is only possible to go back to a previous step if the step is editable. */ function assertEditableStepChange(fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; stepperComponent.selectedIndex = 1; stepperComponent._steps.toArray()[0].editable = false; let previousButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperPrevious))[1].nativeElement; + .queryAll(By.directive(MatStepperPrevious))[1].nativeElement; previousButtonNativeEl.click(); fixture.detectChanges(); @@ -611,9 +612,9 @@ function assertEditableStepChange(fixture: ComponentFixture) { * or the input is valid. */ function assertOptionalStepValidity(testComponent: - LinearMdHorizontalStepperApp | LinearMdVerticalStepperApp, + LinearMatHorizontalStepperApp | LinearMatVerticalStepperApp, fixture: ComponentFixture) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; testComponent.oneGroup.get('oneCtrl')!.setValue('input'); testComponent.twoGroup.get('twoCtrl')!.setValue('input'); @@ -624,7 +625,7 @@ function assertOptionalStepValidity(testComponent: expect(testComponent.threeGroup.get('threeCtrl')!.valid).toBe(true); let nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[2].nativeElement; + .queryAll(By.directive(MatStepperNext))[2].nativeElement; nextButtonNativeEl.click(); fixture.detectChanges(); @@ -653,9 +654,9 @@ function assertOptionalStepValidity(testComponent: function assertCorrectStepIcon(fixture: ComponentFixture, isEditable: boolean, icon: String) { - let stepperComponent = fixture.debugElement.query(By.directive(MdStepper)).componentInstance; + let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; let nextButtonNativeEl = fixture.debugElement - .queryAll(By.directive(MdStepperNext))[0].nativeElement; + .queryAll(By.directive(MatStepperNext))[0].nativeElement; expect(stepperComponent._getIndicatorType(0)).toBe('number'); stepperComponent._steps.toArray()[0].editable = isEditable; nextButtonNativeEl.click(); @@ -666,83 +667,83 @@ function assertCorrectStepIcon(fixture: ComponentFixture, @Component({ template: ` - - - Step 1 + + + Step 1 Content 1
- - + +
-
- - Step 2 + + + Step 2 Content 2
- - + +
-
- + + Content 3
- - + +
-
-
+ + ` }) -class SimpleMdHorizontalStepperApp { +class SimpleMatHorizontalStepperApp { inputLabel = 'Step 3'; } @Component({ template: ` - - + +
- Step one - - - + Step one + + +
- - + +
-
- + +
- Step two - - - + Step two + + +
- - + +
-
- + +
- Step two - - - + Step two + + +
- - + +
-
- + + Done - -
+ + ` }) -class LinearMdHorizontalStepperApp { +class LinearMatHorizontalStepperApp { oneGroup: FormGroup; twoGroup: FormGroup; threeGroup: FormGroup; @@ -762,83 +763,83 @@ class LinearMdHorizontalStepperApp { @Component({ template: ` - - - Step 1 + + + Step 1 Content 1
- - + +
-
- - Step 2 + + + Step 2 Content 2
- - + +
-
- + + Content 3
- - + +
-
-
+ + ` }) -class SimpleMdVerticalStepperApp { +class SimpleMatVerticalStepperApp { inputLabel = 'Step 3'; } @Component({ template: ` - - + +
- Step one - - - + Step one + + +
- - + +
-
- + +
- Step two - - - + Step two + + +
- - + +
-
- + +
- Step two - - - + Step two + + +
- - + +
-
- + + Done - -
+ + ` }) -class LinearMdVerticalStepperApp { +class LinearMatVerticalStepperApp { oneGroup: FormGroup; twoGroup: FormGroup; threeGroup: FormGroup; diff --git a/src/lib/stepper/stepper.ts b/src/lib/stepper/stepper.ts index 1472de27a0fa..120e6dad7923 100644 --- a/src/lib/stepper/stepper.ts +++ b/src/lib/stepper/stepper.ts @@ -26,34 +26,35 @@ import {FormControl, FormGroupDirective, NgForm} from '@angular/forms'; import { defaultErrorStateMatcher, ErrorOptions, - ErrorStateMatcher, MATERIAL_COMPATIBILITY_MODE, - MD_ERROR_GLOBAL_OPTIONS, + ErrorStateMatcher, + MAT_ERROR_GLOBAL_OPTIONS, } from '@angular/material/core'; -import {MdStepHeader} from './step-header'; -import {MdStepLabel} from './step-label'; +import {MatStepHeader} from './step-header'; +import {MatStepLabel} from './step-label'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdStep = CdkStep; -export const _MdStepper = CdkStepper; +export const _MatStep = CdkStep; +export const _MatStepper = CdkStepper; @Component({ moduleId: module.id, - selector: 'md-step, mat-step', + selector: 'mat-step', templateUrl: 'step.html', - providers: [{provide: MD_ERROR_GLOBAL_OPTIONS, useExisting: MdStep}], + providers: [{provide: MAT_ERROR_GLOBAL_OPTIONS, useExisting: MatStep}], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdStep extends _MdStep implements ErrorOptions { - /** Content for step label given by or . */ - @ContentChild(MdStepLabel) stepLabel: MdStepLabel; +export class MatStep extends _MatStep implements ErrorOptions { + /** Content for step label given by . */ + @ContentChild(MatStepLabel) stepLabel: MatStepLabel; /** Original ErrorStateMatcher that checks the validity of form control. */ private _originalErrorStateMatcher: ErrorStateMatcher; - constructor(@Inject(forwardRef(() => MdStepper)) mdStepper: MdStepper, - @Optional() @SkipSelf() @Inject(MD_ERROR_GLOBAL_OPTIONS) errorOptions: ErrorOptions) { - super(mdStepper); + constructor(@Inject(forwardRef(() => MatStepper)) stepper: MatStepper, + @Optional() @SkipSelf() @Inject(MAT_ERROR_GLOBAL_OPTIONS) + errorOptions: ErrorOptions) { + super(stepper); if (errorOptions && errorOptions.errorStateMatcher) { this._originalErrorStateMatcher = errorOptions.errorStateMatcher; } else { @@ -75,19 +76,19 @@ export class MdStep extends _MdStep implements ErrorOptions { } @Directive({ - selector: '[mdStepper]' + selector: '[matStepper]' }) -export class MdStepper extends _MdStepper { +export class MatStepper extends _MatStepper { /** The list of step headers of the steps in the stepper. */ - @ViewChildren(MdStepHeader, {read: ElementRef}) _stepHeader: QueryList; + @ViewChildren(MatStepHeader, {read: ElementRef}) _stepHeader: QueryList; /** Steps that the stepper holds. */ - @ContentChildren(MdStep) _steps: QueryList; + @ContentChildren(MatStep) _steps: QueryList; } @Component({ moduleId: module.id, - selector: 'md-horizontal-stepper, mat-horizontal-stepper', + selector: 'mat-horizontal-stepper', templateUrl: 'stepper-horizontal.html', styleUrls: ['stepper.css'], inputs: ['selectedIndex'], @@ -104,16 +105,15 @@ export class MdStepper extends _MdStepper { animate('500ms cubic-bezier(0.35, 0, 0.25, 1)')) ]) ], - providers: [{provide: MdStepper, useExisting: MdHorizontalStepper}], + providers: [{provide: MatStepper, useExisting: MatHorizontalStepper}], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdHorizontalStepper extends MdStepper { } +export class MatHorizontalStepper extends MatStepper { } @Component({ moduleId: module.id, - selector: 'md-vertical-stepper, mat-vertical-stepper', + selector: 'mat-vertical-stepper', templateUrl: 'stepper-vertical.html', styleUrls: ['stepper.css'], inputs: ['selectedIndex'], @@ -129,9 +129,8 @@ export class MdHorizontalStepper extends MdStepper { } transition('* <=> current', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')) ]) ], - providers: [{provide: MdStepper, useExisting: MdVerticalStepper}], - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], + providers: [{provide: MatStepper, useExisting: MatVerticalStepper}], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdVerticalStepper extends MdStepper { } +export class MatVerticalStepper extends MatStepper { } diff --git a/src/lib/table/cell.ts b/src/lib/table/cell.ts index 089103fdfc5e..f7e7fc0407e7 100644 --- a/src/lib/table/cell.ts +++ b/src/lib/table/cell.ts @@ -16,59 +16,54 @@ import { } from '@angular/cdk/table'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdCellDef = CdkCellDef; -export const _MdHeaderCellDef = CdkHeaderCellDef; -export const _MdColumnDef = CdkColumnDef; -export const _MdHeaderCell = CdkHeaderCell; -export const _MdCell = CdkCell; +export const _MatCellDef = CdkCellDef; +export const _MatHeaderCellDef = CdkHeaderCellDef; +export const _MatColumnDef = CdkColumnDef; +export const _MatHeaderCell = CdkHeaderCell; +export const _MatCell = CdkCell; /** - * Cell definition for the md-table. + * Cell definition for the mat-table. * Captures the template of a column's data row cell as well as cell-specific properties. */ @Directive({ - selector: '[mdCellDef], [matCellDef]', - providers: [{provide: CdkCellDef, useExisting: MdCellDef}] + selector: '[matCellDef]', + providers: [{provide: CdkCellDef, useExisting: MatCellDef}] }) -export class MdCellDef extends _MdCellDef { } +export class MatCellDef extends _MatCellDef { } /** - * Header cell definition for the md-table. + * Header cell definition for the mat-table. * Captures the template of a column's header cell and as well as cell-specific properties. */ @Directive({ - selector: '[mdHeaderCellDef], [matHeaderCellDef]', - providers: [{provide: CdkHeaderCellDef, useExisting: MdHeaderCellDef}] + selector: '[matHeaderCellDef]', + providers: [{provide: CdkHeaderCellDef, useExisting: MatHeaderCellDef}] }) -export class MdHeaderCellDef extends _MdHeaderCellDef { } +export class MatHeaderCellDef extends _MatHeaderCellDef { } /** - * Column definition for the md-table. + * Column definition for the mat-table. * Defines a set of cells available for a table column. */ @Directive({ - selector: '[mdColumnDef], [matColumnDef]', - providers: [{provide: CdkColumnDef, useExisting: MdColumnDef}], + selector: '[matColumnDef]', + providers: [{provide: CdkColumnDef, useExisting: MatColumnDef}], }) -export class MdColumnDef extends _MdColumnDef { +export class MatColumnDef extends _MatColumnDef { /** Unique name for this column. */ - @Input('mdColumnDef') name: string; - - // Properties with `mat-` prefix for noconflict mode. - @Input('matColumnDef') - get _matColumnDefName() { return this.name; } - set _matColumnDefName(name) { this.name = name; } + @Input('matColumnDef') name: string; } /** Header cell template container that adds the right classes and role. */ @Directive({ - selector: 'md-header-cell, mat-header-cell', + selector: 'mat-header-cell', host: { 'class': 'mat-header-cell', 'role': 'columnheader', }, }) -export class MdHeaderCell extends _MdHeaderCell { +export class MatHeaderCell extends _MatHeaderCell { constructor(columnDef: CdkColumnDef, elementRef: ElementRef, renderer: Renderer2) { @@ -79,13 +74,13 @@ export class MdHeaderCell extends _MdHeaderCell { /** Cell template container that adds the right classes and role. */ @Directive({ - selector: 'md-cell, mat-cell', + selector: 'mat-cell', host: { 'class': 'mat-cell', 'role': 'gridcell', }, }) -export class MdCell extends _MdCell { +export class MatCell extends _MatCell { constructor(columnDef: CdkColumnDef, elementRef: ElementRef, renderer: Renderer2) { diff --git a/src/lib/table/mat-exports.ts b/src/lib/table/mat-exports.ts deleted file mode 100644 index 9554e6695834..000000000000 --- a/src/lib/table/mat-exports.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdCell, MdCellDef, MdColumnDef, MdHeaderCell, MdHeaderCellDef} from './cell'; -import {MdHeaderRow, MdRow} from './row'; -import {MdTable} from './table'; -import {MdTableModule} from './table-module'; - - -export {MdCell as MatCell}; -export {MdCellDef as MatCellDef}; -export {MdColumnDef as MatColumnDef}; -export {MdHeaderCell as MatHeaderCell}; -export {MdHeaderCellDef as MatHeaderCellDef}; -export {MdHeaderRow as MatHeaderRow}; -export {MdRow as MatRow}; -export {MdTable as MatTable}; -export {MdTableModule as MatTableModule}; diff --git a/src/lib/table/public_api.ts b/src/lib/table/public_api.ts index 8626940dc2e6..50da1057bc1c 100644 --- a/src/lib/table/public_api.ts +++ b/src/lib/table/public_api.ts @@ -10,4 +10,4 @@ export * from './table-module'; export * from './cell'; export * from './table'; export * from './row'; -export * from './mat-exports'; + diff --git a/src/lib/table/row.ts b/src/lib/table/row.ts index 20857c9ca12a..6fb1b2bbd7ed 100644 --- a/src/lib/table/row.ts +++ b/src/lib/table/row.ts @@ -16,53 +16,37 @@ import { } from '@angular/cdk/table'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdHeaderRowDef = CdkHeaderRowDef; -export const _MdCdkRowDef = CdkRowDef; -export const _MdHeaderRow = CdkHeaderRow; -export const _MdRow = CdkRow; +export const _MatHeaderRowDef = CdkHeaderRowDef; +export const _MatCdkRowDef = CdkRowDef; +export const _MatHeaderRow = CdkHeaderRow; +export const _MatRow = CdkRow; /** - * Header row definition for the md-table. + * Header row definition for the mat-table. * Captures the header row's template and other header properties such as the columns to display. */ -@Directive({ - selector: '[mdHeaderRowDef]', - providers: [{provide: CdkHeaderRowDef, useExisting: MdHeaderRowDef}], - inputs: ['columns: mdHeaderRowDef'], -}) -export class MdHeaderRowDef extends _MdHeaderRowDef { } - -/** Mat-compatible version of MdHeaderRowDef */ @Directive({ selector: '[matHeaderRowDef]', providers: [{provide: CdkHeaderRowDef, useExisting: MatHeaderRowDef}], inputs: ['columns: matHeaderRowDef'], }) -export class MatHeaderRowDef extends _MdHeaderRowDef { } +export class MatHeaderRowDef extends _MatHeaderRowDef { } /** - * Data row definition for the md-table. + * Data row definition for the mat-table. * Captures the header row's template and other row properties such as the columns to display. */ -@Directive({ - selector: '[mdRowDef]', - providers: [{provide: CdkRowDef, useExisting: MdRowDef}], - inputs: ['columns: mdRowDefColumns'], -}) -export class MdRowDef extends _MdCdkRowDef { } - -/** Mat-compatible version of MdRowDef */ @Directive({ selector: '[matRowDef]', providers: [{provide: CdkRowDef, useExisting: MatRowDef}], inputs: ['columns: matRowDefColumns'], }) -export class MatRowDef extends _MdCdkRowDef { } +export class MatRowDef extends _MatCdkRowDef { } /** Header template container that contains the cell outlet. Adds the right class and role. */ @Component({ moduleId: module.id, - selector: 'md-header-row, mat-header-row', + selector: 'mat-header-row', template: CDK_ROW_TEMPLATE, host: { 'class': 'mat-header-row', @@ -72,12 +56,12 @@ export class MatRowDef extends _MdCdkRowDef { } encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdHeaderRow extends _MdHeaderRow { } +export class MatHeaderRow extends _MatHeaderRow { } /** Data row template container that contains the cell outlet. Adds the right class and role. */ @Component({ moduleId: module.id, - selector: 'md-row, mat-row', + selector: 'mat-row', template: CDK_ROW_TEMPLATE, host: { 'class': 'mat-row', @@ -87,4 +71,4 @@ export class MdHeaderRow extends _MdHeaderRow { } encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MdRow extends _MdRow { } +export class MatRow extends _MatRow { } diff --git a/src/lib/table/table-module.ts b/src/lib/table/table-module.ts index 791d0317b60d..378e92aac47d 100644 --- a/src/lib/table/table-module.ts +++ b/src/lib/table/table-module.ts @@ -7,22 +7,20 @@ */ import {NgModule} from '@angular/core'; -import {MdTable} from './table'; +import {MatTable} from './table'; import {CdkTableModule} from '@angular/cdk/table'; -import {MdCell, MdHeaderCell, MdCellDef, MdHeaderCellDef, MdColumnDef} from './cell'; -import {MdHeaderRow, MdRow, MdHeaderRowDef, MdRowDef, MatHeaderRowDef, MatRowDef} from './row'; +import {MatCell, MatHeaderCell, MatCellDef, MatHeaderCellDef, MatColumnDef} from './cell'; +import {MatHeaderRow, MatRow, MatHeaderRowDef, MatRowDef} from './row'; import {CommonModule} from '@angular/common'; -import {MdCommonModule} from '@angular/material/core'; +import {MatCommonModule} from '@angular/material/core'; @NgModule({ - imports: [CdkTableModule, CommonModule, MdCommonModule], - exports: [MdTable, MdCellDef, MdHeaderCellDef, MdColumnDef, - MdHeaderRowDef, MdRowDef, - MdHeaderCell, MdCell, MdHeaderRow, MdRow, + imports: [CdkTableModule, CommonModule, MatCommonModule], + exports: [MatTable, MatCellDef, MatHeaderCellDef, MatColumnDef, + MatHeaderCell, MatCell, MatHeaderRow, MatRow, MatHeaderRowDef, MatRowDef], - declarations: [MdTable, MdCellDef, MdHeaderCellDef, MdColumnDef, - MdHeaderRowDef, MdRowDef, - MdHeaderCell, MdCell, MdHeaderRow, MdRow, + declarations: [MatTable, MatCellDef, MatHeaderCellDef, MatColumnDef, + MatHeaderCell, MatCell, MatHeaderRow, MatRow, MatHeaderRowDef, MatRowDef], }) -export class MdTableModule {} +export class MatTableModule {} diff --git a/src/lib/table/table.md b/src/lib/table/table.md index 8b4a89d4de27..8fbb3601ee11 100644 --- a/src/lib/table/table.md +++ b/src/lib/table/table.md @@ -1,9 +1,9 @@ -The `md-table` provides a Material Design styled data-table that can be used to display rows of +The `mat-table` provides a Material Design styled data-table that can be used to display rows of data. This table builds on the foundation of the CDK data-table and uses a similar interface for its data source input and template, except that its element and attribute selectors will be prefixed -with `md-` instead of `cdk-`. +with `mat-` instead of `cdk-`. For more information on the interface and how it works, see the [guide covering the CDK data-table](https://material.angular.io/guide/cdk-table). @@ -12,7 +12,7 @@ For more information on the interface and how it works, see the ### Features -The `` itself only deals with the rendering of a table structure (rows and cells). +The `` itself only deals with the rendering of a table structure (rows and cells). Additional features can be built on top of the table by adding behavior inside cell templates (e.g., sort headers) or next to the table (e.g. a paginator). Interactions that affect the rendered data (such as sorting and pagination) should be propagated through the table's data source. @@ -20,14 +20,14 @@ rendered data (such as sorting and pagination) should be propagated through the #### Pagination -The `` adds a pagination UI that can be used in conjunction with the ``. The +The `` adds a pagination UI that can be used in conjunction with the ``. The paginator emits events that can be used to trigger an update via the table's data source. #### Sorting -Use the `mdSort` directive and `` adds a sorting UI the table's column headers. The +Use the `matSort` directive and `` adds a sorting UI the table's column headers. The sort headers emit events that can be used to trigger an update via the table's data source. @@ -52,5 +52,5 @@ Tables without text or labels should be given a meaningful label via `aria-label Table's default role is `grid`, and it can be changed to `treegrid` through `role` attribute. -`md-table` does not manage any focus/keyboard interaction on its own. Users can add desired +`mat-table` does not manage any focus/keyboard interaction on its own. Users can add desired focus/keyboard interactions in their application. diff --git a/src/lib/table/table.spec.ts b/src/lib/table/table.spec.ts index 00ec04b84b7b..64b8ff5f1c65 100644 --- a/src/lib/table/table.spec.ts +++ b/src/lib/table/table.spec.ts @@ -3,21 +3,21 @@ import {Component, ViewChild} from '@angular/core'; import {DataSource} from '@angular/cdk/collections'; import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {Observable} from 'rxjs/Observable'; -import {MdTableModule} from './index'; -import {MdTable} from './table'; +import {MatTableModule} from './index'; +import {MatTable} from './table'; -describe('MdTable', () => { - let fixture: ComponentFixture; +describe('MatTable', () => { + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdTableModule], - declarations: [SimpleMdTableApp], + imports: [MatTableModule], + declarations: [SimpleMatTableApp], }).compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(SimpleMdTableApp); + fixture = TestBed.createComponent(SimpleMatTableApp); fixture.detectChanges(); fixture.detectChanges(); }); @@ -85,31 +85,31 @@ class FakeDataSource extends DataSource { @Component({ template: ` - - - Column A - {{row.a}} + + + Column A + {{row.a}} - - Column B - {{row.b}} + + Column B + {{row.b}} - - Column C - {{row.c}} + + Column C + {{row.c}} - - - + + + ` }) -class SimpleMdTableApp { +class SimpleMatTableApp { dataSource: FakeDataSource | null = new FakeDataSource(); columnsToRender = ['column_a', 'column_b', 'column_c']; - @ViewChild(MdTable) table: MdTable; + @ViewChild(MatTable) table: MatTable; } diff --git a/src/lib/table/table.ts b/src/lib/table/table.ts index d0ecc92bede3..97f936f1046c 100644 --- a/src/lib/table/table.ts +++ b/src/lib/table/table.ts @@ -10,14 +10,14 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co import {CDK_TABLE_TEMPLATE, CdkTable} from '@angular/cdk/table'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdTable = CdkTable; +export const _MatTable = CdkTable; /** * Wrapper for the CdkTable with Material design styles. */ @Component({ moduleId: module.id, - selector: 'md-table, mat-table', + selector: 'mat-table', template: CDK_TABLE_TEMPLATE, styleUrls: ['table.css'], host: { @@ -27,4 +27,4 @@ export const _MdTable = CdkTable; preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MdTable extends _MdTable { } +export class MatTable extends _MatTable { } diff --git a/src/lib/tabs/ink-bar.ts b/src/lib/tabs/ink-bar.ts index b5ec5d72ea97..363fe443f1ac 100644 --- a/src/lib/tabs/ink-bar.ts +++ b/src/lib/tabs/ink-bar.ts @@ -14,12 +14,12 @@ import {Directive, Renderer2, ElementRef, NgZone} from '@angular/core'; * @docs-private */ @Directive({ - selector: 'md-ink-bar, mat-ink-bar', + selector: 'mat-ink-bar', host: { 'class': 'mat-ink-bar', }, }) -export class MdInkBar { +export class MatInkBar { constructor( private _renderer: Renderer2, private _elementRef: ElementRef, diff --git a/src/lib/tabs/mat-exports.ts b/src/lib/tabs/mat-exports.ts deleted file mode 100644 index b859f73cff3e..000000000000 --- a/src/lib/tabs/mat-exports.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdInkBar} from './ink-bar'; -import {MdTab} from './tab'; -import {MdTabBody, MdTabBodyOriginState, MdTabBodyPositionState} from './tab-body'; -import {MdTabChangeEvent, MdTabGroup, MdTabGroupBase, MdTabHeaderPosition} from './tab-group'; -import {MdTabHeader} from './tab-header'; -import {MdTabLabel} from './tab-label'; -import {MdTabLabelWrapper} from './tab-label-wrapper'; -import {MdTabLink, MdTabNav} from './tab-nav-bar/index'; -import {MdTabsModule} from './tabs-module'; - - -export {MdInkBar as MatInkBar}; -export {MdTab as MatTab}; -export {MdTabBody as MatTabBody}; -export {MdTabBodyOriginState as MatTabBodyOriginState}; -export {MdTabBodyPositionState as MatTabBodyPositionState}; -export {MdTabChangeEvent as MatTabChangeEvent}; -export {MdTabGroup as MatTabGroup}; -export {MdTabGroupBase as MatTabGroupBase}; -export {MdTabHeader as MatTabHeader}; -export {MdTabHeaderPosition as MatTabHeaderPosition}; -export {MdTabLabel as MatTabLabel}; -export {MdTabLabelWrapper as MatTabLabelWrapper}; -export {MdTabLink as MatTabLink}; -export {MdTabNav as MatTabNav}; -export {MdTabsModule as MatTabsModule}; diff --git a/src/lib/tabs/public_api.ts b/src/lib/tabs/public_api.ts index 75d1ff5c1acc..eaa78fceb60b 100644 --- a/src/lib/tabs/public_api.ts +++ b/src/lib/tabs/public_api.ts @@ -8,12 +8,12 @@ export * from './tabs-module'; export * from './tab-group'; -export {MdInkBar} from './ink-bar'; -export {MdTabBody, MdTabBodyOriginState, MdTabBodyPositionState} from './tab-body'; -export {MdTabHeader, ScrollDirection} from './tab-header'; -export {MdTabLabelWrapper} from './tab-label-wrapper'; -export {MdTab} from './tab'; -export {MdTabLabel} from './tab-label'; -export {MdTabNav, MdTabLink} from './tab-nav-bar/index'; +export {MatInkBar} from './ink-bar'; +export {MatTabBody, MatTabBodyOriginState, MatTabBodyPositionState} from './tab-body'; +export {MatTabHeader, ScrollDirection} from './tab-header'; +export {MatTabLabelWrapper} from './tab-label-wrapper'; +export {MatTab} from './tab'; +export {MatTabLabel} from './tab-label'; +export {MatTabNav, MatTabLink} from './tab-nav-bar/index'; + -export * from './mat-exports'; diff --git a/src/lib/tabs/tab-body.spec.ts b/src/lib/tabs/tab-body.spec.ts index cead88350898..83cf647816a4 100644 --- a/src/lib/tabs/tab-body.spec.ts +++ b/src/lib/tabs/tab-body.spec.ts @@ -3,20 +3,20 @@ import {PortalModule, TemplatePortal} from '@angular/cdk/portal'; import {CommonModule} from '@angular/common'; import {Component, TemplateRef, ViewChild, ViewContainerRef} from '@angular/core'; import {async, ComponentFixture, fakeAsync, flushMicrotasks, TestBed} from '@angular/core/testing'; -import {MdRippleModule} from '@angular/material/core'; +import {MatRippleModule} from '@angular/material/core'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {MdTabBody} from './tab-body'; +import {MatTabBody} from './tab-body'; -describe('MdTabBody', () => { +describe('MatTabBody', () => { let dir: Direction = 'ltr'; beforeEach(async(() => { dir = 'ltr'; TestBed.configureTestingModule({ - imports: [CommonModule, PortalModule, MdRippleModule, NoopAnimationsModule], + imports: [CommonModule, PortalModule, MatRippleModule, NoopAnimationsModule], declarations: [ - MdTabBody, + MatTabBody, SimpleTabBodyApp, ], providers: [ @@ -40,7 +40,7 @@ describe('MdTabBody', () => { fixture.componentInstance.position = 0; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('center'); + expect(fixture.componentInstance.tabBody._position).toBe('center'); }); it('should be left-origin-center position with negative or zero origin', () => { @@ -48,7 +48,7 @@ describe('MdTabBody', () => { fixture.componentInstance.origin = 0; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('left-origin-center'); + expect(fixture.componentInstance.tabBody._position).toBe('left-origin-center'); }); it('should be right-origin-center position with positive nonzero origin', () => { @@ -56,7 +56,7 @@ describe('MdTabBody', () => { fixture.componentInstance.origin = 1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('right-origin-center'); + expect(fixture.componentInstance.tabBody._position).toBe('right-origin-center'); }); }); @@ -71,7 +71,7 @@ describe('MdTabBody', () => { fixture.componentInstance.origin = 0; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('right-origin-center'); + expect(fixture.componentInstance.tabBody._position).toBe('right-origin-center'); }); it('should be left-origin-center position with positive nonzero origin', () => { @@ -79,7 +79,7 @@ describe('MdTabBody', () => { fixture.componentInstance.origin = 1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('left-origin-center'); + expect(fixture.componentInstance.tabBody._position).toBe('left-origin-center'); }); }); }); @@ -97,21 +97,21 @@ describe('MdTabBody', () => { fixture.componentInstance.position = -1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('left'); + expect(fixture.componentInstance.tabBody._position).toBe('left'); }); it('to be center position with zero position', () => { fixture.componentInstance.position = 0; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('center'); + expect(fixture.componentInstance.tabBody._position).toBe('center'); }); it('to be left position with positive position', () => { fixture.componentInstance.position = 1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('right'); + expect(fixture.componentInstance.tabBody._position).toBe('right'); }); }); @@ -128,21 +128,21 @@ describe('MdTabBody', () => { fixture.componentInstance.position = -1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('right'); + expect(fixture.componentInstance.tabBody._position).toBe('right'); }); it('to be center position with zero position', () => { fixture.componentInstance.position = 0; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('center'); + expect(fixture.componentInstance.tabBody._position).toBe('center'); }); it('to be left position with positive position', () => { fixture.componentInstance.position = 1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._position).toBe('left'); + expect(fixture.componentInstance.tabBody._position).toBe('left'); }); }); @@ -156,16 +156,16 @@ describe('MdTabBody', () => { it('should attach the content when centered and detach when not', fakeAsync(() => { fixture.componentInstance.position = 1; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._portalHost.hasAttached()).toBe(false); + expect(fixture.componentInstance.tabBody._portalHost.hasAttached()).toBe(false); fixture.componentInstance.position = 0; fixture.detectChanges(); - expect(fixture.componentInstance.mdTabBody._portalHost.hasAttached()).toBe(true); + expect(fixture.componentInstance.tabBody._portalHost.hasAttached()).toBe(true); fixture.componentInstance.position = 1; fixture.detectChanges(); flushMicrotasks(); // Finish animation and let it detach in animation done handler - expect(fixture.componentInstance.mdTabBody._portalHost.hasAttached()).toBe(false); + expect(fixture.componentInstance.tabBody._portalHost.hasAttached()).toBe(false); })); }); @@ -175,7 +175,7 @@ describe('MdTabBody', () => { @Component({ template: ` Tab Body Content - + ` }) class SimpleTabBodyApp { @@ -183,7 +183,7 @@ class SimpleTabBodyApp { position: number; origin: number; - @ViewChild(MdTabBody) mdTabBody: MdTabBody; + @ViewChild(MatTabBody) tabBody: MatTabBody; @ViewChild(TemplateRef) template: TemplateRef; constructor(private _viewContainerRef: ViewContainerRef) { } diff --git a/src/lib/tabs/tab-body.ts b/src/lib/tabs/tab-body.ts index 7af7a6e8593f..0d738582d7a1 100644 --- a/src/lib/tabs/tab-body.ts +++ b/src/lib/tabs/tab-body.ts @@ -41,7 +41,7 @@ import {Directionality, Direction} from '@angular/cdk/bidi'; * then left-origin-center or right-origin-center can be used, which will use left or right as its * psuedo-prior state. */ -export type MdTabBodyPositionState = +export type MatTabBodyPositionState = 'left' | 'center' | 'right' | 'left-origin-center' | 'right-origin-center'; /** @@ -50,7 +50,7 @@ export type MdTabBodyPositionState = * set to 1, and a new tab is created and selected at index 2, then the tab body would have an * origin of right because its index was greater than the prior selected index. */ -export type MdTabBodyOriginState = 'left' | 'right'; +export type MatTabBodyOriginState = 'left' | 'right'; /** * Wrapper for the contents of a tab. @@ -58,7 +58,7 @@ export type MdTabBodyOriginState = 'left' | 'right'; */ @Component({ moduleId: module.id, - selector: 'md-tab-body, mat-tab-body', + selector: 'mat-tab-body', templateUrl: 'tab-body.html', styleUrls: ['tab-body.css'], encapsulation: ViewEncapsulation.None, @@ -88,7 +88,7 @@ export type MdTabBodyOriginState = 'left' | 'right'; ]) ] }) -export class MdTabBody implements OnInit, AfterViewChecked { +export class MatTabBody implements OnInit, AfterViewChecked { /** The portal host inside of this container into which the tab body content will be loaded. */ @ViewChild(PortalHostDirective) _portalHost: PortalHostDirective; @@ -102,7 +102,7 @@ export class MdTabBody implements OnInit, AfterViewChecked { @Input('content') _content: TemplatePortal; /** The shifted index position of the tab body, where zero represents the active center tab. */ - _position: MdTabBodyPositionState; + _position: MatTabBodyPositionState; @Input('position') set position(position: number) { if (position < 0) { this._position = this._getLayoutDirection() == 'ltr' ? 'left' : 'right'; @@ -114,7 +114,7 @@ export class MdTabBody implements OnInit, AfterViewChecked { } /** The origin position from which this tab should appear when it is centered into view. */ - _origin: MdTabBodyOriginState; + _origin: MatTabBodyOriginState; /** The origin position from which this tab should appear when it is centered into view. */ @Input('origin') set origin(origin: number) { @@ -175,7 +175,7 @@ export class MdTabBody implements OnInit, AfterViewChecked { } /** Whether the provided position state is considered center, regardless of origin. */ - private _isCenterPosition(position: MdTabBodyPositionState|string): boolean { + private _isCenterPosition(position: MatTabBodyPositionState|string): boolean { return position == 'center' || position == 'left-origin-center' || position == 'right-origin-center'; diff --git a/src/lib/tabs/tab-group.scss b/src/lib/tabs/tab-group.scss index 7fdd9a0d57a8..cbd42d7388f0 100644 --- a/src/lib/tabs/tab-group.scss +++ b/src/lib/tabs/tab-group.scss @@ -29,7 +29,7 @@ } } -.mat-tab-group[md-stretch-tabs] .mat-tab-label, +.mat-tab-group[mat-stretch-tabs] .mat-tab-label, .mat-tab-group[mat-stretch-tabs] .mat-tab-label { flex-basis: 0; flex-grow: 1; diff --git a/src/lib/tabs/tab-group.spec.ts b/src/lib/tabs/tab-group.spec.ts index 651f465319e4..f6c4668c0fb5 100644 --- a/src/lib/tabs/tab-group.spec.ts +++ b/src/lib/tabs/tab-group.spec.ts @@ -5,13 +5,13 @@ import {By} from '@angular/platform-browser'; import {ViewportRuler} from '@angular/cdk/scrolling'; import {dispatchFakeEvent, FakeViewportRuler} from '@angular/cdk/testing'; import {Observable} from 'rxjs/Observable'; -import {MdTab, MdTabGroup, MdTabHeaderPosition, MdTabsModule} from './index'; +import {MatTab, MatTabGroup, MatTabHeaderPosition, MatTabsModule} from './index'; -describe('MdTabGroup', () => { +describe('MatTabGroup', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdTabsModule, NoopAnimationsModule], + imports: [MatTabsModule, NoopAnimationsModule], declarations: [ SimpleTabsTestApp, SimpleDynamicTabsTestApp, @@ -91,7 +91,7 @@ describe('MdTabGroup', () => { it('should change tabs based on selectedIndex', fakeAsync(() => { let component = fixture.componentInstance; - let tabComponent = fixture.debugElement.query(By.css('md-tab-group')).componentInstance; + let tabComponent = fixture.debugElement.query(By.css('mat-tab-group')).componentInstance; spyOn(component, 'handleSelection').and.callThrough(); @@ -108,9 +108,9 @@ describe('MdTabGroup', () => { it('should update tab positions when selected index is changed', () => { fixture.detectChanges(); - const component: MdTabGroup = - fixture.debugElement.query(By.css('md-tab-group')).componentInstance; - const tabs: MdTab[] = component._tabs.toArray(); + const component: MatTabGroup = + fixture.debugElement.query(By.css('mat-tab-group')).componentInstance; + const tabs: MatTab[] = component._tabs.toArray(); expect(tabs[0].position).toBeLessThan(0); expect(tabs[1].position).toBe(0); @@ -133,8 +133,8 @@ describe('MdTabGroup', () => { it('should clamp the selected index to the size of the number of tabs', () => { fixture.detectChanges(); - const component: MdTabGroup = - fixture.debugElement.query(By.css('md-tab-group')).componentInstance; + const component: MatTabGroup = + fixture.debugElement.query(By.css('mat-tab-group')).componentInstance; // Set the index to be negative, expect first tab selected fixture.componentInstance.selectedIndex = -1; @@ -246,10 +246,10 @@ describe('MdTabGroup', () => { it('should be able to add a new tab, select it, and have correct origin position', () => { fixture.detectChanges(); - const component: MdTabGroup = - fixture.debugElement.query(By.css('md-tab-group')).componentInstance; + const component: MatTabGroup = + fixture.debugElement.query(By.css('mat-tab-group')).componentInstance; - let tabs: MdTab[] = component._tabs.toArray(); + let tabs: MatTab[] = component._tabs.toArray(); expect(tabs[0].origin).toBe(null); expect(tabs[1].origin).toBe(0); expect(tabs[2].origin).toBe(null); @@ -274,8 +274,8 @@ describe('MdTabGroup', () => { it('should update selected index if the last tab removed while selected', () => { fixture.detectChanges(); - const component: MdTabGroup = - fixture.debugElement.query(By.css('md-tab-group')).componentInstance; + const component: MatTabGroup = + fixture.debugElement.query(By.css('mat-tab-group')).componentInstance; const numberOfTabs = component._tabs.length; fixture.componentInstance.selectedIndex = numberOfTabs - 1; @@ -312,14 +312,14 @@ describe('MdTabGroup', () => { describe('with simple api', () => { let fixture: ComponentFixture; - let tabGroup: MdTabGroup; + let tabGroup: MatTabGroup; beforeEach(() => { fixture = TestBed.createComponent(TabGroupWithSimpleApi); fixture.detectChanges(); tabGroup = - fixture.debugElement.query(By.directive(MdTabGroup)).componentInstance as MdTabGroup; + fixture.debugElement.query(By.directive(MatTabGroup)).componentInstance as MatTabGroup; }); it('should support a tab-group with the simple api', () => { @@ -345,7 +345,7 @@ describe('MdTabGroup', () => { }); it('should support setting the header position', () => { - let tabGroupNode = fixture.debugElement.query(By.css('md-tab-group')).nativeElement; + let tabGroupNode = fixture.debugElement.query(By.css('mat-tab-group')).nativeElement; expect(tabGroupNode.classList).not.toContain('mat-tab-group-inverted-header'); @@ -363,8 +363,8 @@ describe('MdTabGroup', () => { function checkSelectedIndex(expectedIndex: number, fixture: ComponentFixture) { fixture.detectChanges(); - let tabComponent: MdTabGroup = fixture.debugElement - .query(By.css('md-tab-group')).componentInstance; + let tabComponent: MatTabGroup = fixture.debugElement + .query(By.css('mat-tab-group')).componentInstance; expect(tabComponent.selectedIndex).toBe(expectedIndex); let tabLabelElement = fixture.debugElement @@ -386,10 +386,10 @@ describe('MdTabGroup', () => { }); -describe('nested MdTabGroup with enabled animations', () => { +describe('nested MatTabGroup with enabled animations', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdTabsModule, BrowserAnimationsModule], + imports: [MatTabsModule, BrowserAnimationsModule], declarations: [NestedTabs] }); @@ -407,34 +407,34 @@ describe('nested MdTabGroup with enabled animations', () => { @Component({ template: ` - - - Tab One + + Tab One Tab one content - - - Tab Two + + + Tab Two Tab two content - - - Tab Three + + + Tab Three Tab three content - - + + ` }) class SimpleTabsTestApp { - @ViewChildren(MdTab) tabs: QueryList; + @ViewChildren(MatTab) tabs: QueryList; selectedIndex: number = 1; focusEvent: any; selectEvent: any; disableRipple: boolean = false; - headerPosition: MdTabHeaderPosition = 'above'; + headerPosition: MatTabHeaderPosition = 'above'; handleFocus(event: any) { this.focusEvent = event; } @@ -445,15 +445,15 @@ class SimpleTabsTestApp { @Component({ template: ` - - - {{tab.label}} + + {{tab.label}} {{tab.content}} - - + + ` }) class SimpleDynamicTabsTestApp { @@ -475,11 +475,11 @@ class SimpleDynamicTabsTestApp { @Component({ template: ` - - + + {{tab.content}} - - + + ` }) class BindedTabsTestApp { @@ -501,35 +501,35 @@ class BindedTabsTestApp { @Component({ selector: 'test-app', template: ` - - - Tab One + + + Tab One Tab one content - - - Tab Two + + + Tab Two Tab two content - - - Tab Three + + + Tab Three Tab three content - - + + `, }) class DisabledTabsTestApp { - @ViewChildren(MdTab) tabs: QueryList; + @ViewChildren(MatTab) tabs: QueryList; isDisabled = false; } @Component({ template: ` - - - {{ tab.label }} + + + {{ tab.label }} {{ tab.content }} - - + + ` }) class AsyncTabsTestApp { @@ -551,12 +551,12 @@ class AsyncTabsTestApp { @Component({ template: ` - - Pizza, fries - Broccoli, spinach - {{otherContent}} -

Peanuts

-
+ + Pizza, fries + Broccoli, spinach + {{otherContent}} +

Peanuts

+
` }) class TabGroupWithSimpleApi { @@ -569,16 +569,16 @@ class TabGroupWithSimpleApi { @Component({ selector: 'nested-tabs', template: ` - - Tab one content - + + Tab one content + Tab two content - - Inner content one - Inner content two - - - + + Inner content one + Inner content two + + + `, }) class NestedTabs {} diff --git a/src/lib/tabs/tab-group.ts b/src/lib/tabs/tab-group.ts index a80bc765b5b6..0d232cc2b3ed 100644 --- a/src/lib/tabs/tab-group.ts +++ b/src/lib/tabs/tab-group.ts @@ -7,52 +7,54 @@ */ import { - ViewChild, + AfterContentChecked, + AfterContentInit, + AfterViewChecked, + ChangeDetectionStrategy, + ChangeDetectorRef, Component, + ContentChildren, + ElementRef, + EventEmitter, Input, + OnDestroy, Output, - EventEmitter, QueryList, - ContentChildren, - ElementRef, Renderer2, - ChangeDetectionStrategy, - ChangeDetectorRef, - AfterViewChecked, - AfterContentInit, - AfterContentChecked, - OnDestroy, + ViewChild, ViewEncapsulation, } from '@angular/core'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {Subscription} from 'rxjs/Subscription'; -import {MdTab} from './tab'; +import {MatTab} from './tab'; import {merge} from 'rxjs/observable/merge'; import { - CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, - mixinDisableRipple + CanColor, + CanDisableRipple, + mixinColor, + mixinDisableRipple, + ThemePalette } from '@angular/material/core'; -import {CanColor, mixinColor, ThemePalette} from '@angular/material/core'; /** Used to generate unique ID's for each tab component */ let nextId = 0; /** A simple change event emitted on focus or selection changes. */ -export class MdTabChangeEvent { +export class MatTabChangeEvent { index: number; - tab: MdTab; + tab: MatTab; } /** Possible positions for the tab header. */ -export type MdTabHeaderPosition = 'above' | 'below'; +export type MatTabHeaderPosition = 'above' | 'below'; -// Boilerplate for applying mixins to MdTabGroup. +// Boilerplate for applying mixins to MatTabGroup. /** @docs-private */ -export class MdTabGroupBase { +export class MatTabGroupBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdTabGroupMixinBase = mixinColor(mixinDisableRipple(MdTabGroupBase), 'primary'); +export const _MatTabGroupMixinBase = mixinColor(mixinDisableRipple(MatTabGroupBase), 'primary'); /** * Material design tab-group component. Supports basic tab pairs (label + content) and includes @@ -61,7 +63,7 @@ export const _MdTabGroupMixinBase = mixinColor(mixinDisableRipple(MdTabGroupBase */ @Component({ moduleId: module.id, - selector: 'md-tab-group, mat-tab-group', + selector: 'mat-tab-group', templateUrl: 'tab-group.html', styleUrls: ['tab-group.css'], encapsulation: ViewEncapsulation.None, @@ -73,12 +75,11 @@ export const _MdTabGroupMixinBase = mixinColor(mixinDisableRipple(MdTabGroupBase '[class.mat-tab-group-dynamic-height]': 'dynamicHeight', '[class.mat-tab-group-inverted-header]': 'headerPosition === "below"', }, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit, +export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentInit, AfterContentChecked, AfterViewChecked, OnDestroy, CanColor, CanDisableRipple { - @ContentChildren(MdTab) _tabs: QueryList; + @ContentChildren(MatTab) _tabs: QueryList; @ViewChild('tabBodyWrapper') _tabBodyWrapper: ElementRef; @@ -104,7 +105,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit private _dynamicHeight: boolean = false; /** @deprecated */ - @Input('md-dynamic-height') + @Input('mat-dynamic-height') get _dynamicHeightDeprecated(): boolean { return this._dynamicHeight; } set _dynamicHeightDeprecated(value: boolean) { this._dynamicHeight = value; } @@ -115,7 +116,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit private _selectedIndex: number | null = null; /** Position of the tab header. */ - @Input() headerPosition: MdTabHeaderPosition = 'above'; + @Input() headerPosition: MatTabHeaderPosition = 'above'; /** Background color of the tab group. */ @Input() @@ -137,10 +138,11 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit @Output() selectedIndexChange: EventEmitter = new EventEmitter(); /** Event emitted when focus has changed within a tab group. */ - @Output() focusChange: EventEmitter = new EventEmitter(); + @Output() focusChange: EventEmitter = new EventEmitter(); /** Event emitted when the tab selection has changed. */ - @Output() selectChange: EventEmitter = new EventEmitter(true); + @Output() selectChange: EventEmitter = + new EventEmitter(true); private _groupId: number; @@ -175,7 +177,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit } // Setup the position for each tab and optionally setup an origin on the next selected tab. - this._tabs.forEach((tab: MdTab, index: number) => { + this._tabs.forEach((tab: MatTab, index: number) => { tab.position = index - indexToSelect; tab.isActive = index === indexToSelect; @@ -220,8 +222,8 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit this.focusChange.emit(this._createChangeEvent(index)); } - private _createChangeEvent(index: number): MdTabChangeEvent { - const event = new MdTabChangeEvent; + private _createChangeEvent(index: number): MatTabChangeEvent { + const event = new MatTabChangeEvent; event.index = index; if (this._tabs && this._tabs.length) { event.tab = this._tabs.toArray()[index]; @@ -231,7 +233,7 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit /** * Subscribes to changes in the tab labels. This is needed, because the @Input for the label is - * on the MdTab component, whereas the data binding is inside the MdTabGroup. In order for the + * on the MatTab component, whereas the data binding is inside the MatTabGroup. In order for the * binding to be updated, we need to subscribe to changes in it and trigger change detection * manually. */ @@ -249,12 +251,12 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit /** Returns a unique id for each tab label element */ _getTabLabelId(i: number): string { - return `md-tab-label-${this._groupId}-${i}`; + return `mat-tab-label-${this._groupId}-${i}`; } /** Returns a unique id for each tab content element */ _getTabContentId(i: number): string { - return `md-tab-content-${this._groupId}-${i}`; + return `mat-tab-content-${this._groupId}-${i}`; } /** diff --git a/src/lib/tabs/tab-header.spec.ts b/src/lib/tabs/tab-header.spec.ts index d3a2aceea4e2..19e6f2d67199 100644 --- a/src/lib/tabs/tab-header.spec.ts +++ b/src/lib/tabs/tab-header.spec.ts @@ -9,15 +9,15 @@ import {PortalModule} from '@angular/cdk/portal'; import {ViewportRuler} from '@angular/cdk/scrolling'; import {Direction, Directionality} from '@angular/cdk/bidi'; import {dispatchFakeEvent, dispatchKeyboardEvent, FakeViewportRuler} from '@angular/cdk/testing'; -import {MdTabHeader} from './tab-header'; -import {MdRippleModule} from '@angular/material/core'; -import {MdInkBar} from './ink-bar'; -import {MdTabLabelWrapper} from './tab-label-wrapper'; +import {MatTabHeader} from './tab-header'; +import {MatRippleModule} from '@angular/material/core'; +import {MatInkBar} from './ink-bar'; +import {MatTabLabelWrapper} from './tab-label-wrapper'; import {Subject} from 'rxjs/Subject'; -describe('MdTabHeader', () => { +describe('MatTabHeader', () => { let dir: Direction = 'ltr'; let change = new Subject(); let fixture: ComponentFixture; @@ -26,11 +26,11 @@ describe('MdTabHeader', () => { beforeEach(async(() => { dir = 'ltr'; TestBed.configureTestingModule({ - imports: [CommonModule, PortalModule, MdRippleModule], + imports: [CommonModule, PortalModule, MatRippleModule], declarations: [ - MdTabHeader, - MdInkBar, - MdTabLabelWrapper, + MatTabHeader, + MatInkBar, + MatTabLabelWrapper, SimpleTabHeaderApp, ], providers: [ @@ -52,71 +52,71 @@ describe('MdTabHeader', () => { it('should initialize to the selected index', () => { fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(appComponent.selectedIndex); + expect(appComponent.tabHeader.focusIndex).toBe(appComponent.selectedIndex); }); it('should send focus change event', () => { - appComponent.mdTabHeader.focusIndex = 2; + appComponent.tabHeader.focusIndex = 2; fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(2); + expect(appComponent.tabHeader.focusIndex).toBe(2); }); it('should not set focus a disabled tab', () => { - appComponent.mdTabHeader.focusIndex = 0; + appComponent.tabHeader.focusIndex = 0; fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(0); + expect(appComponent.tabHeader.focusIndex).toBe(0); // Set focus on the disabled tab, but focus should remain 0 - appComponent.mdTabHeader.focusIndex = appComponent.disabledTabIndex; + appComponent.tabHeader.focusIndex = appComponent.disabledTabIndex; fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(0); + expect(appComponent.tabHeader.focusIndex).toBe(0); }); it('should move focus right and skip disabled tabs', () => { - appComponent.mdTabHeader.focusIndex = 0; + appComponent.tabHeader.focusIndex = 0; fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(0); + expect(appComponent.tabHeader.focusIndex).toBe(0); // Move focus right, verify that the disabled tab is 1 and should be skipped expect(appComponent.disabledTabIndex).toBe(1); - appComponent.mdTabHeader._focusNextTab(); + appComponent.tabHeader._focusNextTab(); fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(2); + expect(appComponent.tabHeader.focusIndex).toBe(2); // Move focus right to index 3 - appComponent.mdTabHeader._focusNextTab(); + appComponent.tabHeader._focusNextTab(); fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(3); + expect(appComponent.tabHeader.focusIndex).toBe(3); }); it('should move focus left and skip disabled tabs', () => { - appComponent.mdTabHeader.focusIndex = 3; + appComponent.tabHeader.focusIndex = 3; fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(3); + expect(appComponent.tabHeader.focusIndex).toBe(3); // Move focus left to index 3 - appComponent.mdTabHeader._focusPreviousTab(); + appComponent.tabHeader._focusPreviousTab(); fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(2); + expect(appComponent.tabHeader.focusIndex).toBe(2); // Move focus left, verify that the disabled tab is 1 and should be skipped expect(appComponent.disabledTabIndex).toBe(1); - appComponent.mdTabHeader._focusPreviousTab(); + appComponent.tabHeader._focusPreviousTab(); fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(0); + expect(appComponent.tabHeader.focusIndex).toBe(0); }); it('should support key down events to move and select focus', () => { - appComponent.mdTabHeader.focusIndex = 0; + appComponent.tabHeader.focusIndex = 0; fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(0); + expect(appComponent.tabHeader.focusIndex).toBe(0); - let tabListContainer = appComponent.mdTabHeader._tabListContainer.nativeElement; + let tabListContainer = appComponent.tabHeader._tabListContainer.nativeElement; // Move focus right to 2 dispatchKeyboardEvent(tabListContainer, 'keydown', RIGHT_ARROW); fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(2); + expect(appComponent.tabHeader.focusIndex).toBe(2); // Select the focused index 2 expect(appComponent.selectedIndex).toBe(0); @@ -128,7 +128,7 @@ describe('MdTabHeader', () => { // Move focus right to 0 dispatchKeyboardEvent(tabListContainer, 'keydown', LEFT_ARROW); fixture.detectChanges(); - expect(appComponent.mdTabHeader.focusIndex).toBe(0); + expect(appComponent.tabHeader.focusIndex).toBe(0); // Select the focused 0 using space. expect(appComponent.selectedIndex).toBe(2); @@ -151,37 +151,37 @@ describe('MdTabHeader', () => { it('should show width when tab list width exceeds container', () => { fixture.detectChanges(); - expect(appComponent.mdTabHeader._showPaginationControls).toBe(false); + expect(appComponent.tabHeader._showPaginationControls).toBe(false); // Add enough tabs that it will obviously exceed the width appComponent.addTabsForScrolling(); fixture.detectChanges(); - expect(appComponent.mdTabHeader._showPaginationControls).toBe(true); + expect(appComponent.tabHeader._showPaginationControls).toBe(true); }); it('should scroll to show the focused tab label', () => { appComponent.addTabsForScrolling(); fixture.detectChanges(); - expect(appComponent.mdTabHeader.scrollDistance).toBe(0); + expect(appComponent.tabHeader.scrollDistance).toBe(0); // Focus on the last tab, expect this to be the maximum scroll distance. - appComponent.mdTabHeader.focusIndex = appComponent.tabs.length - 1; + appComponent.tabHeader.focusIndex = appComponent.tabs.length - 1; fixture.detectChanges(); - expect(appComponent.mdTabHeader.scrollDistance) - .toBe(appComponent.mdTabHeader._getMaxScrollDistance()); + expect(appComponent.tabHeader.scrollDistance) + .toBe(appComponent.tabHeader._getMaxScrollDistance()); // Focus on the first tab, expect this to be the maximum scroll distance. - appComponent.mdTabHeader.focusIndex = 0; + appComponent.tabHeader.focusIndex = 0; fixture.detectChanges(); - expect(appComponent.mdTabHeader.scrollDistance).toBe(0); + expect(appComponent.tabHeader.scrollDistance).toBe(0); }); it('should show ripples for pagination buttons', () => { appComponent.addTabsForScrolling(); fixture.detectChanges(); - expect(appComponent.mdTabHeader._showPaginationControls).toBe(true); + expect(appComponent.tabHeader._showPaginationControls).toBe(true); const buttonAfter = fixture.debugElement.query(By.css('.mat-tab-header-pagination-after')); @@ -200,7 +200,7 @@ describe('MdTabHeader', () => { appComponent.disableRipple = true; fixture.detectChanges(); - expect(appComponent.mdTabHeader._showPaginationControls).toBe(true); + expect(appComponent.tabHeader._showPaginationControls).toBe(true); const buttonAfter = fixture.debugElement.query(By.css('.mat-tab-header-pagination-after')); @@ -229,25 +229,25 @@ describe('MdTabHeader', () => { it('should scroll to show the focused tab label', () => { appComponent.addTabsForScrolling(); fixture.detectChanges(); - expect(appComponent.mdTabHeader.scrollDistance).toBe(0); + expect(appComponent.tabHeader.scrollDistance).toBe(0); // Focus on the last tab, expect this to be the maximum scroll distance. - appComponent.mdTabHeader.focusIndex = appComponent.tabs.length - 1; + appComponent.tabHeader.focusIndex = appComponent.tabs.length - 1; fixture.detectChanges(); - expect(appComponent.mdTabHeader.scrollDistance) - .toBe(appComponent.mdTabHeader._getMaxScrollDistance()); + expect(appComponent.tabHeader.scrollDistance) + .toBe(appComponent.tabHeader._getMaxScrollDistance()); // Focus on the first tab, expect this to be the maximum scroll distance. - appComponent.mdTabHeader.focusIndex = 0; + appComponent.tabHeader.focusIndex = 0; fixture.detectChanges(); - expect(appComponent.mdTabHeader.scrollDistance).toBe(0); + expect(appComponent.tabHeader.scrollDistance).toBe(0); }); }); it('should re-align the ink bar when the direction changes', () => { fixture = TestBed.createComponent(SimpleTabHeaderApp); - const inkBar = fixture.componentInstance.mdTabHeader._inkBar; + const inkBar = fixture.componentInstance.tabHeader._inkBar; spyOn(inkBar, 'alignToElement'); fixture.detectChanges(); @@ -262,7 +262,7 @@ describe('MdTabHeader', () => { fixture = TestBed.createComponent(SimpleTabHeaderApp); fixture.detectChanges(); - const inkBar = fixture.componentInstance.mdTabHeader._inkBar; + const inkBar = fixture.componentInstance.tabHeader._inkBar; spyOn(inkBar, 'alignToElement'); @@ -277,7 +277,7 @@ describe('MdTabHeader', () => { it('should update arrows when the window is resized', fakeAsync(() => { fixture = TestBed.createComponent(SimpleTabHeaderApp); - const header = fixture.componentInstance.mdTabHeader; + const header = fixture.componentInstance.tabHeader; spyOn(header, '_checkPaginationEnabled'); @@ -300,16 +300,16 @@ interface Tab { @Component({ template: `
- -
{{tab.label}}
-
+
`, styles: [` @@ -326,7 +326,7 @@ class SimpleTabHeaderApp { tabs: Tab[] = [{label: 'tab one'}, {label: 'tab one'}, {label: 'tab one'}, {label: 'tab one'}]; dir: Direction = 'ltr'; - @ViewChild(MdTabHeader) mdTabHeader: MdTabHeader; + @ViewChild(MatTabHeader) tabHeader: MatTabHeader; constructor() { this.tabs[this.disabledTabIndex].disabled = true; diff --git a/src/lib/tabs/tab-header.ts b/src/lib/tabs/tab-header.ts index 782c20284083..8132ebf6ab3a 100644 --- a/src/lib/tabs/tab-header.ts +++ b/src/lib/tabs/tab-header.ts @@ -27,16 +27,13 @@ import { ViewChild, ViewEncapsulation, } from '@angular/core'; -import { - CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, - mixinDisableRipple -} from '@angular/material/core'; +import {CanDisableRipple, mixinDisableRipple} from '@angular/material/core'; import {fromEvent} from 'rxjs/observable/fromEvent'; import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; import {Subscription} from 'rxjs/Subscription'; -import {MdInkBar} from './ink-bar'; -import {MdTabLabelWrapper} from './tab-label-wrapper'; +import {MatInkBar} from './ink-bar'; +import {MatTabLabelWrapper} from './tab-label-wrapper'; /** @@ -52,10 +49,10 @@ export type ScrollDirection = 'after' | 'before'; */ const EXAGGERATED_OVERSCROLL = 60; -// Boilerplate for applying mixins to MdTabHeader. +// Boilerplate for applying mixins to MatTabHeader. /** @docs-private */ -export class MdTabHeaderBase {} -export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase); +export class MatTabHeaderBase {} +export const _MatTabHeaderMixinBase = mixinDisableRipple(MatTabHeaderBase); /** * The header of the tab group which displays a list of all the tabs in the tab group. Includes @@ -66,7 +63,7 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase); */ @Component({ moduleId: module.id, - selector: 'md-tab-header, mat-tab-header', + selector: 'mat-tab-header', templateUrl: 'tab-header.html', styleUrls: ['tab-header.css'], inputs: ['disableRipple'], @@ -78,13 +75,12 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase); '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls', '[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'", }, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdTabHeader extends _MdTabHeaderMixinBase +export class MatTabHeader extends _MatTabHeaderMixinBase implements AfterContentChecked, AfterContentInit, OnDestroy, CanDisableRipple { - @ContentChildren(MdTabLabelWrapper) _labelWrappers: QueryList; - @ViewChild(MdInkBar) _inkBar: MdInkBar; + @ContentChildren(MatTabLabelWrapper) _labelWrappers: QueryList; + @ViewChild(MatInkBar) _inkBar: MatInkBar; @ViewChild('tabListContainer') _tabListContainer: ElementRef; @ViewChild('tabList') _tabList: ElementRef; @@ -277,7 +273,7 @@ export class MdTabHeader extends _MdTabHeaderMixinBase */ _moveFocus(offset: number) { if (this._labelWrappers) { - const tabs: MdTabLabelWrapper[] = this._labelWrappers.toArray(); + const tabs: MatTabLabelWrapper[] = this._labelWrappers.toArray(); for (let i = this.focusIndex + offset; i < tabs.length && i >= 0; i += offset) { if (this._isValidIndex(i)) { diff --git a/src/lib/tabs/tab-label-wrapper.ts b/src/lib/tabs/tab-label-wrapper.ts index 6dcc39f556bf..eecb69e12b9b 100644 --- a/src/lib/tabs/tab-label-wrapper.ts +++ b/src/lib/tabs/tab-label-wrapper.ts @@ -9,23 +9,23 @@ import {Directive, ElementRef} from '@angular/core'; import {CanDisable, mixinDisabled} from '@angular/material/core'; -// Boilerplate for applying mixins to MdTabLabelWrapper. +// Boilerplate for applying mixins to MatTabLabelWrapper. /** @docs-private */ -export class MdTabLabelWrapperBase {} -export const _MdTabLabelWrapperMixinBase = mixinDisabled(MdTabLabelWrapperBase); +export class MatTabLabelWrapperBase {} +export const _MatTabLabelWrapperMixinBase = mixinDisabled(MatTabLabelWrapperBase); /** - * Used in the `md-tab-group` view to display tab labels. + * Used in the `mat-tab-group` view to display tab labels. * @docs-private */ @Directive({ - selector: '[mdTabLabelWrapper], [matTabLabelWrapper]', + selector: '[matTabLabelWrapper]', inputs: ['disabled'], host: { '[class.mat-tab-disabled]': 'disabled' } }) -export class MdTabLabelWrapper extends _MdTabLabelWrapperMixinBase implements CanDisable { +export class MatTabLabelWrapper extends _MatTabLabelWrapperMixinBase implements CanDisable { constructor(public elementRef: ElementRef) { super(); } diff --git a/src/lib/tabs/tab-label.ts b/src/lib/tabs/tab-label.ts index 216feff44efb..6704220f8e08 100644 --- a/src/lib/tabs/tab-label.ts +++ b/src/lib/tabs/tab-label.ts @@ -10,13 +10,13 @@ import {Directive, TemplateRef, ViewContainerRef} from '@angular/core'; import {TemplatePortalDirective} from '@angular/cdk/portal'; /** Workaround for https://github.com/angular/angular/issues/17849 */ -export const _MdTabLabelBaseClass = TemplatePortalDirective; +export const _MatTabLabelBaseClass = TemplatePortalDirective; /** Used to flag tab labels for use with the portal directive */ @Directive({ - selector: '[md-tab-label], [mat-tab-label], [mdTabLabel], [matTabLabel]', + selector: '[mat-tab-label], [matTabLabel]', }) -export class MdTabLabel extends _MdTabLabelBaseClass { +export class MatTabLabel extends _MatTabLabelBaseClass { constructor(templateRef: TemplateRef, viewContainerRef: ViewContainerRef) { super(templateRef, viewContainerRef); } diff --git a/src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts b/src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts index e38e006ad6a0..19eb376cd0db 100644 --- a/src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts +++ b/src/lib/tabs/tab-nav-bar/tab-nav-bar.spec.ts @@ -5,16 +5,16 @@ import {ViewportRuler} from '@angular/cdk/scrolling'; import {dispatchFakeEvent, dispatchMouseEvent, FakeViewportRuler} from '@angular/cdk/testing'; import {Direction, Directionality} from '@angular/cdk/bidi'; import {Subject} from 'rxjs/Subject'; -import {MdTabNav, MdTabsModule, MdTabLink} from '../index'; +import {MatTabNav, MatTabsModule, MatTabLink} from '../index'; -describe('MdTabNavBar', () => { +describe('MatTabNavBar', () => { let dir: Direction = 'ltr'; let dirChange = new Subject(); beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdTabsModule], + imports: [MatTabsModule], declarations: [ SimpleTabNavBarTestApp, TabLinkWithNgIf, @@ -80,8 +80,8 @@ describe('MdTabNavBar', () => { }); it('should update the disableRipple property on each tab link', () => { - const tabLinkElements = fixture.debugElement.queryAll(By.directive(MdTabLink)) - .map(tabLinkDebug => tabLinkDebug.componentInstance) as MdTabLink[]; + const tabLinkElements = fixture.debugElement.queryAll(By.directive(MatTabLink)) + .map(tabLinkDebug => tabLinkDebug.componentInstance) as MatTabLink[]; expect(tabLinkElements.every(tabLink => !tabLink.disableRipple)) .toBe(true, 'Expected every tab link to have ripples enabled'); @@ -120,7 +120,7 @@ describe('MdTabNavBar', () => { it('should be able to disable ripples on a tab link', () => { const tabLinkDebug = fixture.debugElement.query(By.css('a')); const tabLinkElement = tabLinkDebug.nativeElement; - const tabLinkInstance = tabLinkDebug.injector.get(MdTabLink); + const tabLinkInstance = tabLinkDebug.injector.get(MatTabLink); tabLinkInstance.disableRipple = true; @@ -199,8 +199,8 @@ describe('MdTabNavBar', () => { @Component({ selector: 'test-app', template: ` -
- + { ` }) class SimpleTabNavBarTestApp { - @ViewChild(MdTabNav) tabNavBar: MdTabNav; + @ViewChild(MatTabNav) tabNavBar: MatTabNav; label = ''; disabled: boolean = false; @@ -223,8 +223,8 @@ class SimpleTabNavBarTestApp { @Component({ template: ` -
- Link +
+ Link
` }) diff --git a/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts b/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts index 99eb7ecf993f..8ab3170ce8cd 100644 --- a/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/lib/tabs/tab-nav-bar/tab-nav-bar.ts @@ -33,9 +33,9 @@ import { import { CanColor, CanDisable, - CanDisableRipple, MATERIAL_COMPATIBILITY_MODE, - MD_RIPPLE_GLOBAL_OPTIONS, - MdRipple, + CanDisableRipple, + MAT_RIPPLE_GLOBAL_OPTIONS, + MatRipple, mixinColor, mixinDisabled, mixinDisableRipple, @@ -46,15 +46,15 @@ import {fromEvent} from 'rxjs/observable/fromEvent'; import {merge} from 'rxjs/observable/merge'; import {of as observableOf} from 'rxjs/observable/of'; import {Subject} from 'rxjs/Subject'; -import {MdInkBar} from '../ink-bar'; +import {MatInkBar} from '../ink-bar'; -// Boilerplate for applying mixins to MdTabNav. +// Boilerplate for applying mixins to MatTabNav. /** @docs-private */ -export class MdTabNavBase { +export class MatTabNavBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdTabNavMixinBase = mixinDisableRipple(mixinColor(MdTabNavBase, 'primary')); +export const _MatTabNavMixinBase = mixinDisableRipple(mixinColor(MatTabNavBase, 'primary')); /** * Navigation component matching the styles of the tab group header. @@ -62,7 +62,7 @@ export const _MdTabNavMixinBase = mixinDisableRipple(mixinColor(MdTabNavBase, 'p */ @Component({ moduleId: module.id, - selector: '[md-tab-nav-bar], [mat-tab-nav-bar]', + selector: '[mat-tab-nav-bar]', inputs: ['color', 'disableRipple'], templateUrl: 'tab-nav-bar.html', styleUrls: ['tab-nav-bar.css'], @@ -70,9 +70,8 @@ export const _MdTabNavMixinBase = mixinDisableRipple(mixinColor(MdTabNavBase, 'p encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, CanColor, +export class MatTabNav extends _MatTabNavMixinBase implements AfterContentInit, CanColor, CanDisableRipple, OnDestroy { /** Subject that emits when the component has been destroyed. */ @@ -81,11 +80,11 @@ export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, Ca _activeLinkChanged: boolean; _activeLinkElement: ElementRef; - @ViewChild(MdInkBar) _inkBar: MdInkBar; + @ViewChild(MatInkBar) _inkBar: MatInkBar; /** Query list of all tab links of the tab navigation. */ - @ContentChildren(forwardRef(() => MdTabLink), {descendants: true}) - _tabLinks: QueryList; + @ContentChildren(forwardRef(() => MatTabLink), {descendants: true}) + _tabLinks: QueryList; /** Background color of the tab nav. */ @Input() @@ -173,15 +172,15 @@ export class MdTabNav extends _MdTabNavMixinBase implements AfterContentInit, Ca } -// Boilerplate for applying mixins to MdTabLink. -export class MdTabLinkBase {} -export const _MdTabLinkMixinBase = mixinDisabled(MdTabLinkBase); +// Boilerplate for applying mixins to MatTabLink. +export class MatTabLinkBase {} +export const _MatTabLinkMixinBase = mixinDisabled(MatTabLinkBase); /** - * Link inside of a `md-tab-nav-bar`. + * Link inside of a `mat-tab-nav-bar`. */ @Directive({ - selector: '[md-tab-link], [mat-tab-link], [mdTabLink], [matTabLink]', + selector: '[mat-tab-link], [matTabLink]', inputs: ['disabled'], host: { 'class': 'mat-tab-link', @@ -190,7 +189,7 @@ export const _MdTabLinkMixinBase = mixinDisabled(MdTabLinkBase); '[class.mat-tab-disabled]': 'disabled' } }) -export class MdTabLink extends _MdTabLinkMixinBase implements OnDestroy, CanDisable { +export class MatTabLink extends _MatTabLinkMixinBase implements OnDestroy, CanDisable { /** Whether the tab link is active or not. */ private _isActive: boolean = false; @@ -198,7 +197,7 @@ export class MdTabLink extends _MdTabLinkMixinBase implements OnDestroy, CanDisa private _disableRipple: boolean = false; /** Reference to the instance of the ripple for the tab link. */ - private _tabLinkRipple: MdRipple; + private _tabLinkRipple: MatRipple; /** Whether the link is active. */ @Input() @@ -206,7 +205,7 @@ export class MdTabLink extends _MdTabLinkMixinBase implements OnDestroy, CanDisa set active(value: boolean) { this._isActive = value; if (value) { - this._mdTabNavBar.updateActiveLink(this._elementRef); + this._tabNavBar.updateActiveLink(this._elementRef); } } @@ -223,17 +222,17 @@ export class MdTabLink extends _MdTabLinkMixinBase implements OnDestroy, CanDisa return this.disabled ? -1 : 0; } - constructor(private _mdTabNavBar: MdTabNav, + constructor(private _tabNavBar: MatTabNav, private _elementRef: ElementRef, ngZone: NgZone, ruler: ViewportRuler, platform: Platform, - @Optional() @Inject(MD_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions) { + @Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalOptions: RippleGlobalOptions) { super(); // Manually create a ripple instance that uses the tab link element as trigger element. // Notice that the lifecycle hooks for the ripple config won't be called anymore. - this._tabLinkRipple = new MdRipple(_elementRef, ngZone, ruler, platform, globalOptions); + this._tabLinkRipple = new MatRipple(_elementRef, ngZone, ruler, platform, globalOptions); } ngOnDestroy() { diff --git a/src/lib/tabs/tab.ts b/src/lib/tabs/tab.ts index 852c9aa84d92..f1a29aa84d3f 100644 --- a/src/lib/tabs/tab.ts +++ b/src/lib/tabs/tab.ts @@ -23,29 +23,29 @@ import { } from '@angular/core'; import {CanDisable, mixinDisabled} from '@angular/material/core'; import {Subject} from 'rxjs/Subject'; -import {MdTabLabel} from './tab-label'; +import {MatTabLabel} from './tab-label'; -// Boilerplate for applying mixins to MdTab. +// Boilerplate for applying mixins to MatTab. /** @docs-private */ -export class MdTabBase {} -export const _MdTabMixinBase = mixinDisabled(MdTabBase); +export class MatTabBase {} +export const _MatTabMixinBase = mixinDisabled(MatTabBase); @Component({ moduleId: module.id, - selector: 'md-tab, mat-tab', + selector: 'mat-tab', templateUrl: 'tab.html', inputs: ['disabled'], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, - exportAs: 'mdTab, matTab', + exportAs: 'matTab', }) -export class MdTab extends _MdTabMixinBase implements OnInit, CanDisable, OnChanges, OnDestroy { - /** Content for the tab label given by . */ - @ContentChild(MdTabLabel) templateLabel: MdTabLabel; +export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnChanges, OnDestroy { + /** Content for the tab label given by . */ + @ContentChild(MatTabLabel) templateLabel: MatTabLabel; - /** Template inside the MdTab view that contains an . */ + /** Template inside the MatTab view that contains an . */ @ViewChild(TemplateRef) _content: TemplateRef; /** The plain text label for the tab, used when there is no template label. */ diff --git a/src/lib/tabs/tabs-module.ts b/src/lib/tabs/tabs-module.ts index ee93f03ec4f4..9c0f0e3c514b 100644 --- a/src/lib/tabs/tabs-module.ts +++ b/src/lib/tabs/tabs-module.ts @@ -11,46 +11,46 @@ import {PortalModule} from '@angular/cdk/portal'; import {ScrollDispatchModule, VIEWPORT_RULER_PROVIDER} from '@angular/cdk/scrolling'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {MdCommonModule, MdRippleModule} from '@angular/material/core'; -import {MdInkBar} from './ink-bar'; -import {MdTab} from './tab'; -import {MdTabBody} from './tab-body'; -import {MdTabGroup} from './tab-group'; -import {MdTabHeader} from './tab-header'; -import {MdTabLabel} from './tab-label'; -import {MdTabLabelWrapper} from './tab-label-wrapper'; -import {MdTabLink, MdTabNav} from './tab-nav-bar/tab-nav-bar'; +import {MatCommonModule, MatRippleModule} from '@angular/material/core'; +import {MatInkBar} from './ink-bar'; +import {MatTab} from './tab'; +import {MatTabBody} from './tab-body'; +import {MatTabGroup} from './tab-group'; +import {MatTabHeader} from './tab-header'; +import {MatTabLabel} from './tab-label'; +import {MatTabLabelWrapper} from './tab-label-wrapper'; +import {MatTabLink, MatTabNav} from './tab-nav-bar/tab-nav-bar'; @NgModule({ imports: [ CommonModule, - MdCommonModule, + MatCommonModule, PortalModule, - MdRippleModule, + MatRippleModule, ObserversModule, ScrollDispatchModule, ], // Don't export all components because some are only to be used internally. exports: [ - MdCommonModule, - MdTabGroup, - MdTabLabel, - MdTab, - MdTabNav, - MdTabLink, + MatCommonModule, + MatTabGroup, + MatTabLabel, + MatTab, + MatTabNav, + MatTabLink, ], declarations: [ - MdTabGroup, - MdTabLabel, - MdTab, - MdInkBar, - MdTabLabelWrapper, - MdTabNav, - MdTabLink, - MdTabBody, - MdTabHeader + MatTabGroup, + MatTabLabel, + MatTab, + MatInkBar, + MatTabLabelWrapper, + MatTabNav, + MatTabLink, + MatTabBody, + MatTabHeader ], providers: [VIEWPORT_RULER_PROVIDER], }) -export class MdTabsModule {} +export class MatTabsModule {} diff --git a/src/lib/tabs/tabs.md b/src/lib/tabs/tabs.md index 06070051fe68..44eae40a5ddf 100644 --- a/src/lib/tabs/tabs.md +++ b/src/lib/tabs/tabs.md @@ -20,37 +20,37 @@ the header, usually through keyboard navigation. If a tab's label is only text then the simple tab-group API can be used. ```html - - + +

Some tab content

...

-
- + +

Some more tab content

...

-
-
+ + ``` -For more complex labels, add a template with the `md-tab-label` directive inside the `md-tab`. +For more complex labels, add a template with the `mat-tab-label` directive inside the `mat-tab`. ```html - - - + + + The best pasta

Best pasta restaurants

...

-
- - - thumb_down The worst sushi + + + + thumb_down The worst sushi

Terrible sushi restaurants

...

-
-
+ + ``` ### Dynamic Height @@ -60,11 +60,11 @@ change this, set the `dynamicHeight` input to true. The tab body will animate it to the height of the active tab. ### Tabs and navigation -While `` is used to switch between views within a single route, `
` +While `` is used to switch between views within a single route, `
` provides a tab-like UI for navigating between routes. ```html -
- + ` element should have a label as well. +`aria-labelledby`. For `MatTabNav`, the `
` element should have a label as well. #### Keyboard shortcuts diff --git a/src/lib/toolbar/mat-exports.ts b/src/lib/toolbar/mat-exports.ts deleted file mode 100644 index 3e69041d0ebd..000000000000 --- a/src/lib/toolbar/mat-exports.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 {MdToolbar, MdToolbarBase, MdToolbarRow} from './toolbar'; -import {MdToolbarModule} from './toolbar-module'; - - -export {MdToolbar as MatToolbar}; -export {MdToolbarBase as MatToolbarBase}; -export {MdToolbarModule as MatToolbarModule}; -export {MdToolbarRow as MatToolbarRow}; diff --git a/src/lib/toolbar/public_api.ts b/src/lib/toolbar/public_api.ts index 24b5e4c62462..6a4d6c7635ed 100644 --- a/src/lib/toolbar/public_api.ts +++ b/src/lib/toolbar/public_api.ts @@ -8,4 +8,4 @@ export * from './toolbar-module'; export * from './toolbar'; -export * from './mat-exports'; + diff --git a/src/lib/toolbar/toolbar-module.ts b/src/lib/toolbar/toolbar-module.ts index b4eee3b54a58..b974fd224417 100644 --- a/src/lib/toolbar/toolbar-module.ts +++ b/src/lib/toolbar/toolbar-module.ts @@ -7,13 +7,13 @@ */ import {NgModule} from '@angular/core'; -import {MdCommonModule} from '@angular/material/core'; -import {MdToolbar, MdToolbarRow} from './toolbar'; +import {MatCommonModule} from '@angular/material/core'; +import {MatToolbar, MatToolbarRow} from './toolbar'; @NgModule({ - imports: [MdCommonModule], - exports: [MdToolbar, MdToolbarRow, MdCommonModule], - declarations: [MdToolbar, MdToolbarRow], + imports: [MatCommonModule], + exports: [MatToolbar, MatToolbarRow, MatCommonModule], + declarations: [MatToolbar, MatToolbarRow], }) -export class MdToolbarModule {} +export class MatToolbarModule {} diff --git a/src/lib/toolbar/toolbar.html b/src/lib/toolbar/toolbar.html index 88eed7dbff08..a9f577369010 100644 --- a/src/lib/toolbar/toolbar.html +++ b/src/lib/toolbar/toolbar.html @@ -2,5 +2,5 @@ - +
diff --git a/src/lib/toolbar/toolbar.md b/src/lib/toolbar/toolbar.md index cfc2879b0c17..c6bebe838470 100644 --- a/src/lib/toolbar/toolbar.md +++ b/src/lib/toolbar/toolbar.md @@ -1,24 +1,24 @@ -`` is a container for headers, titles, or actions. +`` is a container for headers, titles, or actions. ### Multiple rows -Toolbars can have multiple rows using `` elements. Any content outside of an -`` element are automatically placed inside of one at the beginning of the toolbar. +Toolbars can have multiple rows using `` elements. Any content outside of an +`` element are automatically placed inside of one at the beginning of the toolbar. Each toolbar row is a `display: flex` container. ```html - + First Row - + Second Row - + - + Third Row - - + + ``` ### Positioning toolbar content @@ -28,14 +28,14 @@ position the content as it suits their application. A common pattern is to position a title on the left with some actions on the right. This can be easily accomplished with `display: flex`: ```html - + Application Title Right Aligned Text - + ``` ```scss .example-fill-remaining-space { @@ -46,7 +46,7 @@ easily accomplished with `display: flex`: ``` ### Theming -The color of a `` can be changed by using the `color` property. By default, toolbars +The color of a `` can be changed by using the `color` property. By default, toolbars use a neutral background color based on the current theme (light or dark). This can be changed to `'primary'`, `'accent'`, or `'warn'`. diff --git a/src/lib/toolbar/toolbar.spec.ts b/src/lib/toolbar/toolbar.spec.ts index 6e0c6d4da7cd..bfe43e7d0c2c 100644 --- a/src/lib/toolbar/toolbar.spec.ts +++ b/src/lib/toolbar/toolbar.spec.ts @@ -1,10 +1,10 @@ import {Component} from '@angular/core'; import {TestBed, async, ComponentFixture} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; -import {MdToolbarModule} from './index'; +import {MatToolbarModule} from './index'; -describe('MdToolbar', () => { +describe('MatToolbar', () => { let fixture: ComponentFixture; let testComponent: TestApp; @@ -12,7 +12,7 @@ describe('MdToolbar', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdToolbarModule], + imports: [MatToolbarModule], declarations: [TestApp], }); @@ -22,7 +22,7 @@ describe('MdToolbar', () => { beforeEach(() => { fixture = TestBed.createComponent(TestApp); testComponent = fixture.debugElement.componentInstance; - toolbarElement = fixture.debugElement.query(By.css('md-toolbar')).nativeElement; + toolbarElement = fixture.debugElement.query(By.css('mat-toolbar')).nativeElement; }); it('should apply class based on color attribute', () => { @@ -51,7 +51,7 @@ describe('MdToolbar', () => { }); -@Component({template: `Test Toolbar`}) +@Component({template: `Test Toolbar`}) class TestApp { toolbarColor: string; } diff --git a/src/lib/toolbar/toolbar.ts b/src/lib/toolbar/toolbar.ts index 42c852af0460..b27331206107 100644 --- a/src/lib/toolbar/toolbar.ts +++ b/src/lib/toolbar/toolbar.ts @@ -7,33 +7,33 @@ */ import { - Component, ChangeDetectionStrategy, - ViewEncapsulation, + Component, Directive, ElementRef, Renderer2, + ViewEncapsulation, } from '@angular/core'; -import {CanColor, MATERIAL_COMPATIBILITY_MODE, mixinColor} from '@angular/material/core'; +import {CanColor, mixinColor} from '@angular/material/core'; @Directive({ - selector: 'md-toolbar-row, mat-toolbar-row', + selector: 'mat-toolbar-row', host: {'class': 'mat-toolbar-row'}, }) -export class MdToolbarRow {} +export class MatToolbarRow {} -// Boilerplate for applying mixins to MdToolbar. +// Boilerplate for applying mixins to MatToolbar. /** @docs-private */ -export class MdToolbarBase { +export class MatToolbarBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } -export const _MdToolbarMixinBase = mixinColor(MdToolbarBase); +export const _MatToolbarMixinBase = mixinColor(MatToolbarBase); @Component({ moduleId: module.id, - selector: 'md-toolbar, mat-toolbar', + selector: 'mat-toolbar', templateUrl: 'toolbar.html', styleUrls: ['toolbar.css'], inputs: ['color'], @@ -44,9 +44,8 @@ export const _MdToolbarMixinBase = mixinColor(MdToolbarBase); changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, - viewProviders: [{provide: MATERIAL_COMPATIBILITY_MODE, useValue: true}], }) -export class MdToolbar extends _MdToolbarMixinBase implements CanColor { +export class MatToolbar extends _MatToolbarMixinBase implements CanColor { constructor(renderer: Renderer2, elementRef: ElementRef) { super(renderer, elementRef); diff --git a/src/lib/tooltip/mat-exports.ts b/src/lib/tooltip/mat-exports.ts deleted file mode 100644 index 080519017a01..000000000000 --- a/src/lib/tooltip/mat-exports.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright Google Inc. 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 { - MD_TOOLTIP_SCROLL_STRATEGY, - MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER, - MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY, - MdTooltip, -} from './tooltip'; -import {MdTooltipModule} from './tooltip-module'; - - -/* tslint:disable:max-line-length */ -export {MdTooltip as MatTooltip}; -export {MdTooltipModule as MatTooltipModule}; -export {MD_TOOLTIP_SCROLL_STRATEGY as MAT_TOOLTIP_SCROLL_STRATEGY}; -export {MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER as MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER}; -export {MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY as MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY}; diff --git a/src/lib/tooltip/public_api.ts b/src/lib/tooltip/public_api.ts index 2de9d7df0b3d..7bb70a658c74 100644 --- a/src/lib/tooltip/public_api.ts +++ b/src/lib/tooltip/public_api.ts @@ -8,4 +8,4 @@ export * from './tooltip-module'; export * from './tooltip'; -export * from './mat-exports'; + diff --git a/src/lib/tooltip/tooltip-module.ts b/src/lib/tooltip/tooltip-module.ts index 3ea824d9d0f9..8c49d490fd41 100644 --- a/src/lib/tooltip/tooltip-module.ts +++ b/src/lib/tooltip/tooltip-module.ts @@ -11,21 +11,21 @@ import {OverlayModule} from '@angular/cdk/overlay'; import {PlatformModule} from '@angular/cdk/platform'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; -import {MdCommonModule} from '@angular/material/core'; -import {MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER, MdTooltip, TooltipComponent} from './tooltip'; +import {MatCommonModule} from '@angular/material/core'; +import {MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER, MatTooltip, TooltipComponent} from './tooltip'; @NgModule({ imports: [ CommonModule, OverlayModule, - MdCommonModule, + MatCommonModule, PlatformModule, A11yModule, ], - exports: [MdTooltip, TooltipComponent, MdCommonModule], - declarations: [MdTooltip, TooltipComponent], + exports: [MatTooltip, TooltipComponent, MatCommonModule], + declarations: [MatTooltip, TooltipComponent], entryComponents: [TooltipComponent], - providers: [MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER, ARIA_DESCRIBER_PROVIDER], + providers: [MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER, ARIA_DESCRIBER_PROVIDER], }) -export class MdTooltipModule {} +export class MatTooltipModule {} diff --git a/src/lib/tooltip/tooltip.md b/src/lib/tooltip/tooltip.md index 5359617aebcd..d9efd12ad87a 100644 --- a/src/lib/tooltip/tooltip.md +++ b/src/lib/tooltip/tooltip.md @@ -5,7 +5,7 @@ over or longpresses an element. ### Positioning -The tooltip will be displayed below the element but this can be configured using the `mdTooltipPosition` +The tooltip will be displayed below the element but this can be configured using the `matTooltipPosition` input. The tooltip can be displayed above, below, left, or right of the element. By default the position will be below. If the tooltip should switch left/right positions in an RTL layout direction, then @@ -25,7 +25,7 @@ the positions `before` and `after` should be used instead of `left` and `right`, The tooltip is immediately shown when the user's mouse hovers over the element and immediately hides when the user's mouse leaves. A delay in showing or hiding the tooltip can be added through -the inputs `mdTooltipShowDelay` and `mdTooltipHideDelay`. +the inputs `matTooltipShowDelay` and `matTooltipHideDelay`. On mobile, the tooltip is displayed when the user longpresses the element and hides after a delay of 1500ms. The longpress behavior requires HammerJS to be loaded on the page. @@ -33,11 +33,11 @@ delay of 1500ms. The longpress behavior requires HammerJS to be loaded on the pa The tooltip can also be shown and hidden through the `show` and `hide` directive methods, which both accept a number in milliseconds to delay before applying the display change. -To turn off the tooltip and prevent it from showing to the user, use the `mdTooltipDisabled` input flag. +To turn off the tooltip and prevent it from showing to the user, use the `matTooltipDisabled` input flag. ### Accessibility -Elements with the `mdTooltip` will add an `aria-describedby` label that provides a reference +Elements with the `matTooltip` will add an `aria-describedby` label that provides a reference to a visually hidden element containing the tooltip's message. This provides screenreaders the information needed to read out the tooltip's contents when the end-user focuses on the element triggering the tooltip. \ No newline at end of file diff --git a/src/lib/tooltip/tooltip.spec.ts b/src/lib/tooltip/tooltip.spec.ts index 1ab5abae667d..26e8f67bf331 100644 --- a/src/lib/tooltip/tooltip.spec.ts +++ b/src/lib/tooltip/tooltip.spec.ts @@ -22,8 +22,8 @@ import {Platform} from '@angular/cdk/platform'; import {dispatchFakeEvent, dispatchKeyboardEvent} from '@angular/cdk/testing'; import {ESCAPE} from '@angular/cdk/keycodes'; import { - MdTooltip, - MdTooltipModule, + MatTooltip, + MatTooltipModule, SCROLL_THROTTLE_MS, TOOLTIP_PANEL_CLASS, TooltipPosition @@ -32,13 +32,13 @@ import { const initialTooltipMessage = 'initial tooltip message'; -describe('MdTooltip', () => { +describe('MatTooltip', () => { let overlayContainerElement: HTMLElement; let dir: {value: Direction}; beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [MdTooltipModule, OverlayModule, NoopAnimationsModule], + imports: [MatTooltipModule, OverlayModule, NoopAnimationsModule], declarations: [ BasicTooltipDemo, ScrollableTooltipDemo, @@ -69,14 +69,14 @@ describe('MdTooltip', () => { let fixture: ComponentFixture; let buttonDebugElement: DebugElement; let buttonElement: HTMLButtonElement; - let tooltipDirective: MdTooltip; + let tooltipDirective: MatTooltip; beforeEach(() => { fixture = TestBed.createComponent(BasicTooltipDemo); fixture.detectChanges(); buttonDebugElement = fixture.debugElement.query(By.css('button')); buttonElement = buttonDebugElement.nativeElement; - tooltipDirective = buttonDebugElement.injector.get(MdTooltip); + tooltipDirective = buttonDebugElement.injector.get(MatTooltip); }); it('should show and hide the tooltip', fakeAsync(() => { @@ -273,9 +273,9 @@ describe('MdTooltip', () => { // Make sure classes aren't prematurely added let tooltipElement = overlayContainerElement.querySelector('.mat-tooltip') as HTMLElement; expect(tooltipElement.classList).not.toContain('custom-one', - 'Expected to not have the class before enabling mdTooltipClass'); + 'Expected to not have the class before enabling matTooltipClass'); expect(tooltipElement.classList).not.toContain('custom-two', - 'Expected to not have the class before enabling mdTooltipClass'); + 'Expected to not have the class before enabling matTooltipClass'); // Enable the classes via ngClass syntax fixture.componentInstance.showTooltipClass = true; @@ -284,9 +284,9 @@ describe('MdTooltip', () => { // Make sure classes are correctly added tooltipElement = overlayContainerElement.querySelector('.mat-tooltip') as HTMLElement; expect(tooltipElement.classList).toContain('custom-one', - 'Expected to have the class after enabling mdTooltipClass'); + 'Expected to have the class after enabling matTooltipClass'); expect(tooltipElement.classList).toContain('custom-two', - 'Expected to have the class after enabling mdTooltipClass'); + 'Expected to have the class after enabling matTooltipClass'); })); it('should be removed after parent destroyed', fakeAsync(() => { @@ -483,14 +483,14 @@ describe('MdTooltip', () => { let fixture: ComponentFixture; let buttonDebugElement: DebugElement; let buttonElement: HTMLButtonElement; - let tooltipDirective: MdTooltip; + let tooltipDirective: MatTooltip; beforeEach(() => { fixture = TestBed.createComponent(ScrollableTooltipDemo); fixture.detectChanges(); buttonDebugElement = fixture.debugElement.query(By.css('button')); buttonElement = buttonDebugElement.nativeElement; - tooltipDirective = buttonDebugElement.injector.get(MdTooltip); + tooltipDirective = buttonDebugElement.injector.get(MatTooltip); }); it('should hide tooltip if clipped after changing positions', fakeAsync(() => { @@ -524,14 +524,14 @@ describe('MdTooltip', () => { let fixture: ComponentFixture; let buttonDebugElement: DebugElement; let buttonElement: HTMLButtonElement; - let tooltipDirective: MdTooltip; + let tooltipDirective: MatTooltip; beforeEach(() => { fixture = TestBed.createComponent(OnPushTooltipDemo); fixture.detectChanges(); buttonDebugElement = fixture.debugElement.query(By.css('button')); buttonElement = buttonDebugElement.nativeElement; - tooltipDirective = buttonDebugElement.injector.get(MdTooltip); + tooltipDirective = buttonDebugElement.injector.get(MatTooltip); }); it('should show and hide the tooltip', fakeAsync(() => { @@ -582,9 +582,9 @@ describe('MdTooltip', () => { selector: 'app', template: ` ` }) @@ -593,7 +593,7 @@ class BasicTooltipDemo { message: any = initialTooltipMessage; showButton: boolean = true; showTooltipClass = false; - @ViewChild(MdTooltip) tooltip: MdTooltip; + @ViewChild(MatTooltip) tooltip: MatTooltip; } @Component({ @@ -602,8 +602,8 @@ class BasicTooltipDemo {
` @@ -629,8 +629,8 @@ class ScrollableTooltipDemo { @Component({ selector: 'app', template: ` - `, changeDetection: ChangeDetectionStrategy.OnPush @@ -645,7 +645,7 @@ class OnPushTooltipDemo { selector: 'app', template: ` `, }) diff --git a/src/lib/tooltip/tooltip.ts b/src/lib/tooltip/tooltip.ts index 8fcfabef129f..4c54b6b9cce5 100644 --- a/src/lib/tooltip/tooltip.ts +++ b/src/lib/tooltip/tooltip.ts @@ -56,25 +56,25 @@ export const SCROLL_THROTTLE_MS = 20; export const TOOLTIP_PANEL_CLASS = 'mat-tooltip-panel'; /** Creates an error to be thrown if the user supplied an invalid tooltip position. */ -export function getMdTooltipInvalidPositionError(position: string) { +export function getMatTooltipInvalidPositionError(position: string) { return Error(`Tooltip position "${position}" is invalid.`); } /** Injection token that determines the scroll handling while a tooltip is visible. */ -export const MD_TOOLTIP_SCROLL_STRATEGY = - new InjectionToken<() => ScrollStrategy>('md-tooltip-scroll-strategy'); +export const MAT_TOOLTIP_SCROLL_STRATEGY = + new InjectionToken<() => ScrollStrategy>('mat-tooltip-scroll-strategy'); /** @docs-private */ -export function MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): +export function MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Overlay): () => RepositionScrollStrategy { return () => overlay.scrollStrategies.reposition({ scrollThrottle: SCROLL_THROTTLE_MS }); } /** @docs-private */ -export const MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER = { - provide: MD_TOOLTIP_SCROLL_STRATEGY, +export const MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER = { + provide: MAT_TOOLTIP_SCROLL_STRATEGY, deps: [Overlay], - useFactory: MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY + useFactory: MAT_TOOLTIP_SCROLL_STRATEGY_PROVIDER_FACTORY }; /** * Directive that attaches a material design tooltip to the host element. Animates the showing and @@ -83,7 +83,7 @@ export const MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER = { * https://material.google.com/components/tooltips.html */ @Directive({ - selector: '[md-tooltip], [mdTooltip], [mat-tooltip], [matTooltip]', + selector: '[mat-tooltip], [matTooltip]', host: { '(longpress)': 'show()', '(focus)': 'show()', @@ -91,9 +91,9 @@ export const MD_TOOLTIP_SCROLL_STRATEGY_PROVIDER = { '(keydown)': '_handleKeydown($event)', '(touchend)': 'hide(' + TOUCHEND_HIDE_DELAY + ')', }, - exportAs: 'mdTooltip, matTooltip', + exportAs: 'matTooltip', }) -export class MdTooltip implements OnDestroy { +export class MatTooltip implements OnDestroy { _overlayRef: OverlayRef | null; _tooltipInstance: TooltipComponent | null; @@ -102,7 +102,7 @@ export class MdTooltip implements OnDestroy { private _tooltipClass: string|string[]|Set|{[key: string]: any}; /** Allows the user to define the position of the tooltip relative to the parent element */ - @Input('mdTooltipPosition') + @Input('matTooltipPosition') get position(): TooltipPosition { return this._position; } set position(value: TooltipPosition) { if (value !== this._position) { @@ -117,7 +117,7 @@ export class MdTooltip implements OnDestroy { } /** Disables the display of the tooltip. */ - @Input('mdTooltipDisabled') + @Input('matTooltipDisabled') get disabled(): boolean { return this._disabled; } set disabled(value) { this._disabled = coerceBooleanProperty(value); @@ -134,15 +134,15 @@ export class MdTooltip implements OnDestroy { set _positionDeprecated(value: TooltipPosition) { this._position = value; } /** The default delay in ms before showing the tooltip after show is called */ - @Input('mdTooltipShowDelay') showDelay = 0; + @Input('matTooltipShowDelay') showDelay = 0; /** The default delay in ms before hiding the tooltip after hide is called */ - @Input('mdTooltipHideDelay') hideDelay = 0; + @Input('matTooltipHideDelay') hideDelay = 0; private _message = ''; /** The message to be displayed in the tooltip */ - @Input('mdTooltip') get message() { return this._message; } + @Input('matTooltip') get message() { return this._message; } set message(value: string) { this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message); @@ -153,7 +153,7 @@ export class MdTooltip implements OnDestroy { } /** Classes to be passed to the tooltip. Supports the same syntax as `ngClass`. */ - @Input('mdTooltipClass') + @Input('matTooltipClass') get tooltipClass() { return this._tooltipClass; } set tooltipClass(value: string|string[]|Set|{[key: string]: any}) { this._tooltipClass = value; @@ -162,41 +162,6 @@ export class MdTooltip implements OnDestroy { } } - /** @deprecated */ - @Input('md-tooltip') - get _deprecatedMessage(): string { return this.message; } - set _deprecatedMessage(v: string) { this.message = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matTooltip') - get _matMessage() { return this.message; } - set _matMessage(v) { this.message = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matTooltipPosition') - get _matPosition() { return this.position; } - set _matPosition(v) { this.position = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matTooltipDisabled') - get _matDisabled() { return this.disabled; } - set _matDisabled(v) { this.disabled = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matTooltipHideDelay') - get _matHideDelay() { return this.hideDelay; } - set _matHideDelay(v) { this.hideDelay = v; } - - // Properties with `mat-` prefix for noconflict mode. - @Input('matTooltipShowDelay') - get _matShowDelay() { return this.showDelay; } - set _matShowDelay(v) { this.showDelay = v; } - - // Properties with `mat-` prefix for nonconflict mode. - @Input('matTooltipClass') - get _matClass() { return this.tooltipClass; } - set _matClass(v) { this.tooltipClass = v; } - private _enterListener: Function; private _leaveListener: Function; @@ -209,7 +174,7 @@ export class MdTooltip implements OnDestroy { private _ngZone: NgZone, private _platform: Platform, private _ariaDescriber: AriaDescriber, - @Inject(MD_TOOLTIP_SCROLL_STRATEGY) private _scrollStrategy, + @Inject(MAT_TOOLTIP_SCROLL_STRATEGY) private _scrollStrategy, @Optional() private _dir: Directionality) { // The mouse events shouldn't be bound on iOS devices, because @@ -350,7 +315,7 @@ export class MdTooltip implements OnDestroy { return {originX: 'end', originY: 'center'}; } - throw getMdTooltipInvalidPositionError(this.position); + throw getMatTooltipInvalidPositionError(this.position); } /** Returns the overlay position based on the user's preference */ @@ -376,7 +341,7 @@ export class MdTooltip implements OnDestroy { return {overlayX: 'start', overlayY: 'center'}; } - throw getMdTooltipInvalidPositionError(this.position); + throw getMatTooltipInvalidPositionError(this.position); } /** Updates the tooltip message and repositions the overlay according to the new message length */ @@ -412,7 +377,7 @@ export type TooltipVisibility = 'initial' | 'visible' | 'hidden'; */ @Component({ moduleId: module.id, - selector: 'md-tooltip-component, mat-tooltip-component', + selector: 'mat-tooltip-component', templateUrl: 'tooltip.html', styleUrls: ['tooltip.css'], encapsulation: ViewEncapsulation.None, @@ -526,7 +491,7 @@ export class TooltipComponent { case 'right': this._transformOrigin = 'left'; break; case 'above': this._transformOrigin = 'bottom'; break; case 'below': this._transformOrigin = 'top'; break; - default: throw getMdTooltipInvalidPositionError(value); + default: throw getMatTooltipInvalidPositionError(value); } } diff --git a/src/material-examples/autocomplete-display/autocomplete-display-example.html b/src/material-examples/autocomplete-display/autocomplete-display-example.html index 176d13dcfbb2..6f7be4623bd0 100644 --- a/src/material-examples/autocomplete-display/autocomplete-display-example.html +++ b/src/material-examples/autocomplete-display/autocomplete-display-example.html @@ -1,10 +1,10 @@
- - - - + + + + {{ option.name }} - - - + + + diff --git a/src/material-examples/autocomplete-filter/autocomplete-filter-example.html b/src/material-examples/autocomplete-filter/autocomplete-filter-example.html index 13c64139ea30..3e685d80a233 100644 --- a/src/material-examples/autocomplete-filter/autocomplete-filter-example.html +++ b/src/material-examples/autocomplete-filter/autocomplete-filter-example.html @@ -1,10 +1,10 @@
- - - - + + + + {{ option }} - - - + + + diff --git a/src/material-examples/autocomplete-overview/autocomplete-overview-example.html b/src/material-examples/autocomplete-overview/autocomplete-overview-example.html index 78370e44a246..9b6179e74bc5 100644 --- a/src/material-examples/autocomplete-overview/autocomplete-overview-example.html +++ b/src/material-examples/autocomplete-overview/autocomplete-overview-example.html @@ -1,20 +1,20 @@
- - - - + + + + {{ state.name }} | Population: {{state.population}} - - - + + +
- Disable Input? - + diff --git a/src/material-examples/autocomplete-simple/autocomplete-simple-example.html b/src/material-examples/autocomplete-simple/autocomplete-simple-example.html index 3c440f4b319e..57a309431f85 100644 --- a/src/material-examples/autocomplete-simple/autocomplete-simple-example.html +++ b/src/material-examples/autocomplete-simple/autocomplete-simple-example.html @@ -1,10 +1,10 @@
- - - - + + + + {{ option }} - - - + + + diff --git a/src/material-examples/button-overview/button-overview-example.html b/src/material-examples/button-overview/button-overview-example.html index 56f6fa44fb6b..0dcb901d1d1c 100644 --- a/src/material-examples/button-overview/button-overview-example.html +++ b/src/material-examples/button-overview/button-overview-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/button-toggle-exclusive/button-toggle-exclusive-example.html b/src/material-examples/button-toggle-exclusive/button-toggle-exclusive-example.html index dd5cd2771788..d6f123c2a561 100644 --- a/src/material-examples/button-toggle-exclusive/button-toggle-exclusive-example.html +++ b/src/material-examples/button-toggle-exclusive/button-toggle-exclusive-example.html @@ -1,15 +1,15 @@ - - - format_align_left - - - format_align_center - - - format_align_right - - - format_align_justify - - + + + format_align_left + + + format_align_center + + + format_align_right + + + format_align_justify + +
Selected value: {{group.value}}
diff --git a/src/material-examples/button-toggle-overview/button-toggle-overview-example.html b/src/material-examples/button-toggle-overview/button-toggle-overview-example.html index bb215d5b5425..858458d64280 100644 --- a/src/material-examples/button-toggle-overview/button-toggle-overview-example.html +++ b/src/material-examples/button-toggle-overview/button-toggle-overview-example.html @@ -1 +1 @@ -Toggle me! +Toggle me! diff --git a/src/material-examples/button-types/button-types-example.html b/src/material-examples/button-types/button-types-example.html index 1a9b5b2015a7..2e06c96f7913 100644 --- a/src/material-examples/button-types/button-types-example.html +++ b/src/material-examples/button-types/button-types-example.html @@ -1,64 +1,64 @@

Basic Buttons

- - - - - - Link + + + + + + Link

Raised Buttons

- - - - - - Link + + + + + + Link

Icon Buttons

- - - - -

Fab Buttons

- - - - - - + + + + + - Link + Link

Mini Fab Buttons

- - - - - - + + + + + - Link + Link
diff --git a/src/material-examples/card-fancy/card-fancy-example.html b/src/material-examples/card-fancy/card-fancy-example.html index 45211a831f4f..c80c1bbc495c 100644 --- a/src/material-examples/card-fancy/card-fancy-example.html +++ b/src/material-examples/card-fancy/card-fancy-example.html @@ -1,19 +1,19 @@ - - -
- Shiba Inu - Dog Breed -
- Photo of a Shiba Inu - + + +
+ Shiba Inu + Dog Breed +
+ Photo of a Shiba Inu +

The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan. A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was originally bred for hunting.

-
- - - - -
+ + + + + + diff --git a/src/material-examples/card-overview/card-overview-example.html b/src/material-examples/card-overview/card-overview-example.html index 5e0c2b6dfe13..774531539915 100644 --- a/src/material-examples/card-overview/card-overview-example.html +++ b/src/material-examples/card-overview/card-overview-example.html @@ -1 +1 @@ -Simple card +Simple card diff --git a/src/material-examples/checkbox-configurable/checkbox-configurable-example.html b/src/material-examples/checkbox-configurable/checkbox-configurable-example.html index 7b8fb4c2290e..e39d6e8e1aaf 100644 --- a/src/material-examples/checkbox-configurable/checkbox-configurable-example.html +++ b/src/material-examples/checkbox-configurable/checkbox-configurable-example.html @@ -1,40 +1,40 @@ - - + +

Checkbox configuration

- Checked - Indeterminate + Checked + Indeterminate
- - Start - End - + + Start + End +
- Disabled + Disabled
-
-
+ + - - + +

Result

- I'm a checkbox - +
-
-
+ + diff --git a/src/material-examples/checkbox-overview/checkbox-overview-example.html b/src/material-examples/checkbox-overview/checkbox-overview-example.html index c301bbe5ccc2..b5b049fae683 100644 --- a/src/material-examples/checkbox-overview/checkbox-overview-example.html +++ b/src/material-examples/checkbox-overview/checkbox-overview-example.html @@ -1 +1 @@ -Check me! +Check me! diff --git a/src/material-examples/chips-input/chips-input-example.html b/src/material-examples/chips-input/chips-input-example.html index f80ef3152670..3d118fcbfd30 100644 --- a/src/material-examples/chips-input/chips-input-example.html +++ b/src/material-examples/chips-input/chips-input-example.html @@ -1,14 +1,14 @@ - - - + + {{fruit.name}} - cancel - - - - + cancel + + + + diff --git a/src/material-examples/chips-input/chips-input-example.ts b/src/material-examples/chips-input/chips-input-example.ts index 89adf943c181..934fdcdc83d3 100644 --- a/src/material-examples/chips-input/chips-input-example.ts +++ b/src/material-examples/chips-input/chips-input-example.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdChipInputEvent} from '@angular/material'; +import {MatChipInputEvent} from '@angular/material'; import {ENTER} from '@angular/cdk/keycodes'; const COMMA = 188; @@ -28,7 +28,7 @@ export class ChipsInputExample { ]; - add(event: MdChipInputEvent): void { + add(event: MatChipInputEvent): void { let input = event.input; let value = event.value; diff --git a/src/material-examples/chips-overview/chips-overview-example.html b/src/material-examples/chips-overview/chips-overview-example.html index bb0410569251..3228bc87b2d3 100644 --- a/src/material-examples/chips-overview/chips-overview-example.html +++ b/src/material-examples/chips-overview/chips-overview-example.html @@ -1,6 +1,6 @@ - - One fish - Two fish - Primary fish - Accent fish - + + One fish + Two fish + Primary fish + Accent fish + diff --git a/src/material-examples/chips-stacked/chips-stacked-example.css b/src/material-examples/chips-stacked/chips-stacked-example.css index dfb2f8c00aa2..3c84f24c152f 100644 --- a/src/material-examples/chips-stacked/chips-stacked-example.css +++ b/src/material-examples/chips-stacked/chips-stacked-example.css @@ -1,3 +1,3 @@ -md-chip { +mat-chip { max-width: 200px; } diff --git a/src/material-examples/chips-stacked/chips-stacked-example.html b/src/material-examples/chips-stacked/chips-stacked-example.html index 27677b1c6e6d..aa429ab3a8a6 100644 --- a/src/material-examples/chips-stacked/chips-stacked-example.html +++ b/src/material-examples/chips-stacked/chips-stacked-example.html @@ -1,7 +1,7 @@ - - + {{chipColor.name}} - - + + diff --git a/src/material-examples/datepicker-api/datepicker-api-example.html b/src/material-examples/datepicker-api/datepicker-api-example.html index a41723d81cbb..453fe29805a5 100644 --- a/src/material-examples/datepicker-api/datepicker-api-example.html +++ b/src/material-examples/datepicker-api/datepicker-api-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/datepicker-filter/datepicker-filter-example.html b/src/material-examples/datepicker-filter/datepicker-filter-example.html index 4fc367dba397..6a44973b048e 100644 --- a/src/material-examples/datepicker-filter/datepicker-filter-example.html +++ b/src/material-examples/datepicker-filter/datepicker-filter-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/datepicker-min-max/datepicker-min-max-example.html b/src/material-examples/datepicker-min-max/datepicker-min-max-example.html index 216fcd260a2c..4ee60cdfdd86 100644 --- a/src/material-examples/datepicker-min-max/datepicker-min-max-example.html +++ b/src/material-examples/datepicker-min-max/datepicker-min-max-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/datepicker-overview/datepicker-overview-example.html b/src/material-examples/datepicker-overview/datepicker-overview-example.html index 41a2ba3c9ca4..f82880547b24 100644 --- a/src/material-examples/datepicker-overview/datepicker-overview-example.html +++ b/src/material-examples/datepicker-overview/datepicker-overview-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/datepicker-start-view/datepicker-start-view-example.html b/src/material-examples/datepicker-start-view/datepicker-start-view-example.html index 0391c9be8ff5..e10afcab6d26 100644 --- a/src/material-examples/datepicker-start-view/datepicker-start-view-example.html +++ b/src/material-examples/datepicker-start-view/datepicker-start-view-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/datepicker-touch/datepicker-touch-example.html b/src/material-examples/datepicker-touch/datepicker-touch-example.html index a9579710205a..7cec1f8e330a 100644 --- a/src/material-examples/datepicker-touch/datepicker-touch-example.html +++ b/src/material-examples/datepicker-touch/datepicker-touch-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/dialog-content/dialog-content-example-dialog.html b/src/material-examples/dialog-content/dialog-content-example-dialog.html index 46c978dae389..2ecde77595ea 100644 --- a/src/material-examples/dialog-content/dialog-content-example-dialog.html +++ b/src/material-examples/dialog-content/dialog-content-example-dialog.html @@ -1,5 +1,5 @@ -

Install Angular

- +

Install Angular

+

DEVELOP ACROSS ALL PLATFORMS

Learn one way to build applications with Angular and reuse your code and abilities to build apps for any deployment target. For web, mobile web, native mobile and native desktop.

@@ -18,8 +18,8 @@

INCREDIBLE TOOLING

LOVED BY MILLIONS

From prototype through global deployment, Angular delivers the productivity and scalable infrastructure that supports Google's largest applications.

-
- - - - + + + + + diff --git a/src/material-examples/dialog-content/dialog-content-example.html b/src/material-examples/dialog-content/dialog-content-example.html index 176a3c411e7f..cdfc2fb33b2a 100644 --- a/src/material-examples/dialog-content/dialog-content-example.html +++ b/src/material-examples/dialog-content/dialog-content-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/dialog-content/dialog-content-example.ts b/src/material-examples/dialog-content/dialog-content-example.ts index 39b0d453ddf7..8cd5c6e942f1 100644 --- a/src/material-examples/dialog-content/dialog-content-example.ts +++ b/src/material-examples/dialog-content/dialog-content-example.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdDialog} from '@angular/material'; +import {MatDialog} from '@angular/material'; /** * @title Dialog with header, scrollable content and actions @@ -9,7 +9,7 @@ import {MdDialog} from '@angular/material'; templateUrl: 'dialog-content-example.html', }) export class DialogContentExample { - constructor(public dialog: MdDialog) {} + constructor(public dialog: MatDialog) {} openDialog() { const dialogRef = this.dialog.open(DialogContentExampleDialog, { diff --git a/src/material-examples/dialog-data/dialog-data-example-dialog.html b/src/material-examples/dialog-data/dialog-data-example-dialog.html index aa9b428ef8ce..6d263bacf3c9 100644 --- a/src/material-examples/dialog-data/dialog-data-example-dialog.html +++ b/src/material-examples/dialog-data/dialog-data-example-dialog.html @@ -1,5 +1,5 @@ -

Favorite Animal

-
+

Favorite Animal

+
My favorite animal is:
  • diff --git a/src/material-examples/dialog-data/dialog-data-example.html b/src/material-examples/dialog-data/dialog-data-example.html index 176a3c411e7f..cdfc2fb33b2a 100644 --- a/src/material-examples/dialog-data/dialog-data-example.html +++ b/src/material-examples/dialog-data/dialog-data-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/dialog-data/dialog-data-example.ts b/src/material-examples/dialog-data/dialog-data-example.ts index bdd0f4bc119f..08b00d08de46 100644 --- a/src/material-examples/dialog-data/dialog-data-example.ts +++ b/src/material-examples/dialog-data/dialog-data-example.ts @@ -1,5 +1,5 @@ import {Component, Inject} from '@angular/core'; -import {MdDialog, MD_DIALOG_DATA} from '@angular/material'; +import {MatDialog, MAT_DIALOG_DATA} from '@angular/material'; /** * @title Injecting data when opening a dialog @@ -9,7 +9,7 @@ import {MdDialog, MD_DIALOG_DATA} from '@angular/material'; templateUrl: 'dialog-data-example.html', }) export class DialogDataExample { - constructor(public dialog: MdDialog) {} + constructor(public dialog: MatDialog) {} openDialog() { this.dialog.open(DialogDataExampleDialog, { @@ -25,5 +25,5 @@ export class DialogDataExample { templateUrl: 'dialog-data-example-dialog.html', }) export class DialogDataExampleDialog { - constructor(@Inject(MD_DIALOG_DATA) public data: any) {} + constructor(@Inject(MAT_DIALOG_DATA) public data: any) {} } diff --git a/src/material-examples/dialog-elements/dialog-elements-example-dialog.html b/src/material-examples/dialog-elements/dialog-elements-example-dialog.html index 5238b0eb6c19..1bddf5bfdaa6 100644 --- a/src/material-examples/dialog-elements/dialog-elements-example-dialog.html +++ b/src/material-examples/dialog-elements/dialog-elements-example-dialog.html @@ -1,5 +1,5 @@ -

    Dialog with elements

    -
    This dialog showcases the title, close, content and actions elements.
    -
    - +

    Dialog with elements

    +
    This dialog showcases the title, close, content and actions elements.
    +
    +
    diff --git a/src/material-examples/dialog-elements/dialog-elements-example.html b/src/material-examples/dialog-elements/dialog-elements-example.html index 40637c4bd638..cf2103810fc9 100644 --- a/src/material-examples/dialog-elements/dialog-elements-example.html +++ b/src/material-examples/dialog-elements/dialog-elements-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/dialog-elements/dialog-elements-example.ts b/src/material-examples/dialog-elements/dialog-elements-example.ts index 37f3703e3aa4..b179ee54b54f 100644 --- a/src/material-examples/dialog-elements/dialog-elements-example.ts +++ b/src/material-examples/dialog-elements/dialog-elements-example.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdDialog} from '@angular/material'; +import {MatDialog} from '@angular/material'; /** * @title Dialog elements @@ -9,7 +9,7 @@ import {MdDialog} from '@angular/material'; templateUrl: 'dialog-elements-example.html', }) export class DialogElementsExample { - constructor(public dialog: MdDialog) { } + constructor(public dialog: MatDialog) { } openDialog() { this.dialog.open(DialogElementsExampleDialog); diff --git a/src/material-examples/dialog-overview/dialog-overview-example-dialog.html b/src/material-examples/dialog-overview/dialog-overview-example-dialog.html index b4214fbf1f9f..fbd80e3c287d 100644 --- a/src/material-examples/dialog-overview/dialog-overview-example-dialog.html +++ b/src/material-examples/dialog-overview/dialog-overview-example-dialog.html @@ -1,11 +1,11 @@ -

    Hi {{data.name}}

    -
    +

    Hi {{data.name}}

    +

    What's your favorite animal?

    - - - + + +
    -
    - - +
    + +
    diff --git a/src/material-examples/dialog-overview/dialog-overview-example.html b/src/material-examples/dialog-overview/dialog-overview-example.html index b6911190f152..00e14854f5ca 100644 --- a/src/material-examples/dialog-overview/dialog-overview-example.html +++ b/src/material-examples/dialog-overview/dialog-overview-example.html @@ -1,11 +1,11 @@
    1. - - - + + +
    2. - +
    3. You chose: {{animal}} diff --git a/src/material-examples/dialog-overview/dialog-overview-example.ts b/src/material-examples/dialog-overview/dialog-overview-example.ts index 5dec934d877e..53f7db3a5529 100644 --- a/src/material-examples/dialog-overview/dialog-overview-example.ts +++ b/src/material-examples/dialog-overview/dialog-overview-example.ts @@ -1,5 +1,5 @@ import {Component, Inject} from '@angular/core'; -import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material'; +import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material'; /** * @title Dialog Overview @@ -13,7 +13,7 @@ export class DialogOverviewExample { animal: string; name: string; - constructor(public dialog: MdDialog) {} + constructor(public dialog: MatDialog) {} openDialog(): void { let dialogRef = this.dialog.open(DialogOverviewExampleDialog, { @@ -36,8 +36,8 @@ export class DialogOverviewExample { export class DialogOverviewExampleDialog { constructor( - public dialogRef: MdDialogRef, - @Inject(MD_DIALOG_DATA) public data: any) { } + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { } onNoClick(): void { this.dialogRef.close(); diff --git a/src/material-examples/expansion-overview/expansion-overview-example.html b/src/material-examples/expansion-overview/expansion-overview-example.html index 48c0cc50bf86..9d105bef4d64 100644 --- a/src/material-examples/expansion-overview/expansion-overview-example.html +++ b/src/material-examples/expansion-overview/expansion-overview-example.html @@ -1,18 +1,18 @@ - - - + + + Personal data - - + + Type your name and age - - + + - - - + + + - - - - + + + + diff --git a/src/material-examples/expansion-steps/expansion-steps-example.html b/src/material-examples/expansion-steps/expansion-steps-example.html index e81ede44445c..1a4880c2cdc8 100644 --- a/src/material-examples/expansion-steps/expansion-steps-example.html +++ b/src/material-examples/expansion-steps/expansion-steps-example.html @@ -1,69 +1,69 @@ - - - - + + + + Personal data - - + + Type your name and age - account_circle - - + account_circle + + - - - + + + - - - + + + - - - - + + + + - - - + + + Destination - - + + Type the country name - map - - + map + + - - - + + + - - - - - + + + + + - - - + + + Day of the trip - - + + Inform the date you wish to travel - date_range - - + date_range + + - - - - + + + + - - - - - + + + + + - + diff --git a/src/material-examples/grid-list-dynamic/grid-list-dynamic-example.html b/src/material-examples/grid-list-dynamic/grid-list-dynamic-example.html index 19c84dd5b853..c79507b49a6f 100644 --- a/src/material-examples/grid-list-dynamic/grid-list-dynamic-example.html +++ b/src/material-examples/grid-list-dynamic/grid-list-dynamic-example.html @@ -1,9 +1,9 @@ - - + {{tile.text}} - - + + diff --git a/src/material-examples/grid-list-overview/grid-list-overview-example.css b/src/material-examples/grid-list-overview/grid-list-overview-example.css index 2598f58f5190..fdb01abc34f0 100644 --- a/src/material-examples/grid-list-overview/grid-list-overview-example.css +++ b/src/material-examples/grid-list-overview/grid-list-overview-example.css @@ -1,3 +1,3 @@ -md-grid-tile { +mat-grid-tile { background: lightblue; } diff --git a/src/material-examples/grid-list-overview/grid-list-overview-example.html b/src/material-examples/grid-list-overview/grid-list-overview-example.html index 6651887f603f..ae338547cedb 100644 --- a/src/material-examples/grid-list-overview/grid-list-overview-example.html +++ b/src/material-examples/grid-list-overview/grid-list-overview-example.html @@ -1,6 +1,6 @@ - - 1 - 2 - 3 - 4 - + + 1 + 2 + 3 + 4 + diff --git a/src/material-examples/icon-overview/icon-overview-example.html b/src/material-examples/icon-overview/icon-overview-example.html index dd46af80f6cb..7afdf57b1631 100644 --- a/src/material-examples/icon-overview/icon-overview-example.html +++ b/src/material-examples/icon-overview/icon-overview-example.html @@ -1 +1 @@ -home +home diff --git a/src/material-examples/icon-svg-example/icon-svg-example.html b/src/material-examples/icon-svg-example/icon-svg-example.html index ac74cf7908dd..ed7e8eb9b50e 100644 --- a/src/material-examples/icon-svg-example/icon-svg-example.html +++ b/src/material-examples/icon-svg-example/icon-svg-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/icon-svg-example/icon-svg-example.ts b/src/material-examples/icon-svg-example/icon-svg-example.ts index 53775feb59fe..c9a4b5f67b38 100644 --- a/src/material-examples/icon-svg-example/icon-svg-example.ts +++ b/src/material-examples/icon-svg-example/icon-svg-example.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core'; import {DomSanitizer} from '@angular/platform-browser'; -import {MdIconRegistry} from '@angular/material'; +import {MatIconRegistry} from '@angular/material'; /** * @title SVG icons @@ -10,7 +10,7 @@ import {MdIconRegistry} from '@angular/material'; templateUrl: 'icon-svg-example.html', }) export class IconSvgExample { - constructor(iconRegistry: MdIconRegistry, sanitizer: DomSanitizer) { + constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) { iconRegistry.addSvgIcon( 'thumbs-up', sanitizer.bypassSecurityTrustResourceUrl('assets/img/examples/thumbup-icon.svg')); diff --git a/src/material-examples/input-clearable/input-clearable-example.html b/src/material-examples/input-clearable/input-clearable-example.html index c8be13f98150..4e1721a0f44d 100644 --- a/src/material-examples/input-clearable/input-clearable-example.html +++ b/src/material-examples/input-clearable/input-clearable-example.html @@ -1,6 +1,6 @@ - - - - + diff --git a/src/material-examples/input-errors/input-errors-example.html b/src/material-examples/input-errors/input-errors-example.html index 4434b6ea941c..c8fbba32201c 100644 --- a/src/material-examples/input-errors/input-errors-example.html +++ b/src/material-examples/input-errors/input-errors-example.html @@ -1,11 +1,11 @@
      - - - + + + Please enter a valid email address - - + + Email is required - - + + diff --git a/src/material-examples/input-form/input-form-example.html b/src/material-examples/input-form/input-form-example.html index f7abf80888be..8cf31e056b62 100644 --- a/src/material-examples/input-form/input-form-example.html +++ b/src/material-examples/input-form/input-form-example.html @@ -1,36 +1,36 @@
      - - - + + +

- - + +
- - - - + + + +

- - - - - - + + + + + +

- - - + + +
- - - - - - {{postalCode.value.length}} / 5 - + + + + + + {{postalCode.value.length}} / 5 +
diff --git a/src/material-examples/input-hint/input-hint-example.html b/src/material-examples/input-hint/input-hint-example.html index f7e36d1ddb1d..b7595cfa636b 100644 --- a/src/material-examples/input-hint/input-hint-example.html +++ b/src/material-examples/input-hint/input-hint-example.html @@ -1,9 +1,9 @@
- - - Don't disclose personal info - {{message.value.length}} / 256 - + + + Don't disclose personal info + {{message.value.length}} / 256 +
diff --git a/src/material-examples/input-overview/input-overview-example.html b/src/material-examples/input-overview/input-overview-example.html index cae5b1f0f6c1..c4daebdcc9db 100644 --- a/src/material-examples/input-overview/input-overview-example.html +++ b/src/material-examples/input-overview/input-overview-example.html @@ -1,5 +1,5 @@
- - - + + +
diff --git a/src/material-examples/input-prefix-suffix/input-prefix-suffix-example.html b/src/material-examples/input-prefix-suffix/input-prefix-suffix-example.html index 25485d1fa1c3..7bff7e420fcd 100644 --- a/src/material-examples/input-prefix-suffix/input-prefix-suffix-example.html +++ b/src/material-examples/input-prefix-suffix/input-prefix-suffix-example.html @@ -1,9 +1,9 @@
- - +1   - - mode_edit - + + +1   + + mode_edit +
diff --git a/src/material-examples/list-overview/list-overview-example.html b/src/material-examples/list-overview/list-overview-example.html index ada715ee0acf..4c59db7aa84e 100644 --- a/src/material-examples/list-overview/list-overview-example.html +++ b/src/material-examples/list-overview/list-overview-example.html @@ -1,5 +1,5 @@ - - Item 1 - Item 2 - Item 3 - + + Item 1 + Item 2 + Item 3 + diff --git a/src/material-examples/list-sections/list-sections-example.html b/src/material-examples/list-sections/list-sections-example.html index 38d20f97eedc..ecb32bb2e8e6 100644 --- a/src/material-examples/list-sections/list-sections-example.html +++ b/src/material-examples/list-sections/list-sections-example.html @@ -1,15 +1,15 @@ - -

Folders

- - folder -

{{folder.name}}

-

{{folder.updated | date}}

-
- -

Notes

- - note -

{{note.name}}

-

{{note.updated | date}}

-
-
+ +

Folders

+ + folder +

{{folder.name}}

+

{{folder.updated | date}}

+
+ +

Notes

+ + note +

{{note.name}}

+

{{note.updated | date}}

+
+
diff --git a/src/material-examples/list-selection/list-selection-example.html b/src/material-examples/list-selection/list-selection-example.html index cd1d9f07353c..d068febecc21 100644 --- a/src/material-examples/list-selection/list-selection-example.html +++ b/src/material-examples/list-selection/list-selection-example.html @@ -1,8 +1,8 @@ - - + + {{shoe}} - - + +

Options selected: {{shoes.selectedOptions.selected.length}} diff --git a/src/material-examples/material-module.ts b/src/material-examples/material-module.ts index 34309d98dbbd..e399634d801f 100644 --- a/src/material-examples/material-module.ts +++ b/src/material-examples/material-module.ts @@ -2,48 +2,48 @@ import {NgModule} from '@angular/core'; import {CdkTableModule} from '@angular/cdk/table'; import { - MdAutocompleteModule, MdButtonModule, MdButtonToggleModule, MdPaginatorModule, - MdCardModule, MdCheckboxModule, MdChipsModule, MdDatepickerModule, - MdDialogModule, MdGridListModule, MdIconModule, MdInputModule, - MdListModule, MdMenuModule, MdProgressBarModule, MdProgressSpinnerModule, - MdRadioModule, MdSelectModule, MdSidenavModule, MdSliderModule, MdSortModule, - MdSlideToggleModule, MdSnackBarModule, MdTableModule, MdTabsModule, MdToolbarModule, - MdTooltipModule, MdFormFieldModule, MdExpansionModule, MdStepperModule + MatAutocompleteModule, MatButtonModule, MatButtonToggleModule, MatPaginatorModule, + MatCardModule, MatCheckboxModule, MatChipsModule, MatDatepickerModule, + MatDialogModule, MatGridListModule, MatIconModule, MatInputModule, + MatListModule, MatMenuModule, MatProgressBarModule, MatProgressSpinnerModule, + MatRadioModule, MatSelectModule, MatSidenavModule, MatSliderModule, MatSortModule, + MatSlideToggleModule, MatSnackBarModule, MatTableModule, MatTabsModule, MatToolbarModule, + MatTooltipModule, MatFormFieldModule, MatExpansionModule, MatStepperModule } from '@angular/material'; @NgModule({ exports: [ CdkTableModule, - MdAutocompleteModule, - MdButtonModule, - MdButtonToggleModule, - MdCardModule, - MdCheckboxModule, - MdChipsModule, - MdDatepickerModule, - MdDialogModule, - MdExpansionModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdSelectModule, - MdSlideToggleModule, - MdSliderModule, - MdSidenavModule, - MdSnackBarModule, - MdStepperModule, - MdTabsModule, - MdToolbarModule, - MdTooltipModule, - MdPaginatorModule, - MdSortModule, - MdTableModule + MatAutocompleteModule, + MatButtonModule, + MatButtonToggleModule, + MatCardModule, + MatCheckboxModule, + MatChipsModule, + MatDatepickerModule, + MatDialogModule, + MatExpansionModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatSelectModule, + MatSlideToggleModule, + MatSliderModule, + MatSidenavModule, + MatSnackBarModule, + MatStepperModule, + MatTabsModule, + MatToolbarModule, + MatTooltipModule, + MatPaginatorModule, + MatSortModule, + MatTableModule ] }) export class ExampleMaterialModule {} diff --git a/src/material-examples/menu-icons/menu-icons-example.html b/src/material-examples/menu-icons/menu-icons-example.html index e14942451644..a5ea164cf8d6 100644 --- a/src/material-examples/menu-icons/menu-icons-example.html +++ b/src/material-examples/menu-icons/menu-icons-example.html @@ -1,17 +1,17 @@ - - - - - - + diff --git a/src/material-examples/menu-overview/menu-overview-example.html b/src/material-examples/menu-overview/menu-overview-example.html index 2b5d246c298e..64f76da72b27 100644 --- a/src/material-examples/menu-overview/menu-overview-example.html +++ b/src/material-examples/menu-overview/menu-overview-example.html @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/src/material-examples/nested-menu/nested-menu-example.html b/src/material-examples/nested-menu/nested-menu-example.html index bd972629fb54..a9f430b12445 100644 --- a/src/material-examples/nested-menu/nested-menu-example.html +++ b/src/material-examples/nested-menu/nested-menu-example.html @@ -1,47 +1,47 @@ - + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + diff --git a/src/material-examples/paginator-configurable/paginator-configurable-example.html b/src/material-examples/paginator-configurable/paginator-configurable-example.html index e1ce734f74fe..665cacfab07c 100644 --- a/src/material-examples/paginator-configurable/paginator-configurable-example.html +++ b/src/material-examples/paginator-configurable/paginator-configurable-example.html @@ -1,24 +1,24 @@ - + List length: - - + + - + Page size: - - - + + + Page size options: - - + - - +

Page Change Event Properties
diff --git a/src/material-examples/paginator-configurable/paginator-configurable-example.ts b/src/material-examples/paginator-configurable/paginator-configurable-example.ts index ba3df8db743f..5ee316719e63 100644 --- a/src/material-examples/paginator-configurable/paginator-configurable-example.ts +++ b/src/material-examples/paginator-configurable/paginator-configurable-example.ts @@ -9,12 +9,12 @@ import {PageEvent} from '@angular/material'; templateUrl: 'paginator-configurable-example.html', }) export class PaginatorConfigurableExample { - // MdPaginator Inputs + // MatPaginator Inputs length = 100; pageSize = 10; pageSizeOptions = [5, 10, 25, 100]; - // MdPaginator Output + // MatPaginator Output pageEvent: PageEvent; setPageSizeOptions(setPageSizeOptionsInput: string) { diff --git a/src/material-examples/paginator-overview/paginator-overview-example.html b/src/material-examples/paginator-overview/paginator-overview-example.html index 010a9e5d4e45..9269f3b47380 100644 --- a/src/material-examples/paginator-overview/paginator-overview-example.html +++ b/src/material-examples/paginator-overview/paginator-overview-example.html @@ -1,4 +1,4 @@ - - + diff --git a/src/material-examples/progress-bar-configurable/progress-bar-configurable-example.html b/src/material-examples/progress-bar-configurable/progress-bar-configurable-example.html index 93937b77a8b8..bdde8c6126a9 100644 --- a/src/material-examples/progress-bar-configurable/progress-bar-configurable-example.html +++ b/src/material-examples/progress-bar-configurable/progress-bar-configurable-example.html @@ -1,63 +1,63 @@ - - + +

Progress bar configuration

- - + + Primary - - + + Accent - - + + Warn - - + +
- - + + Determinate - - + + Indeterminate - - + + Buffer - - + + Query - - + +
- +
- +
-
-
+ + - - + +

Result

- - +
-
-
+ + diff --git a/src/material-examples/progress-bar-overview/progress-bar-overview-example.html b/src/material-examples/progress-bar-overview/progress-bar-overview-example.html index 8ab16e9cfc13..f6ba0575d4ee 100644 --- a/src/material-examples/progress-bar-overview/progress-bar-overview-example.html +++ b/src/material-examples/progress-bar-overview/progress-bar-overview-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/progress-spinner-configurable/progress-spinner-configurable-example.html b/src/material-examples/progress-spinner-configurable/progress-spinner-configurable-example.html index 1ba3183acebf..538321c81938 100644 --- a/src/material-examples/progress-spinner-configurable/progress-spinner-configurable-example.html +++ b/src/material-examples/progress-spinner-configurable/progress-spinner-configurable-example.html @@ -1,49 +1,49 @@ - - + +

Progress spinner configuration

- - + + Primary - - + + Accent - - + + Warn - - + +
- - + + Determinate - - + + Indeterminate - - + +
- +
-
-
- - + + + +

Result

- - -
-
+ + + diff --git a/src/material-examples/progress-spinner-overview/progress-spinner-overview-example.html b/src/material-examples/progress-spinner-overview/progress-spinner-overview-example.html index cd768c67385c..34e51f70fc2f 100644 --- a/src/material-examples/progress-spinner-overview/progress-spinner-overview-example.html +++ b/src/material-examples/progress-spinner-overview/progress-spinner-overview-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/radio-ng-model/radio-ng-model-example.html b/src/material-examples/radio-ng-model/radio-ng-model-example.html index 108971b5739a..4dd923173b75 100644 --- a/src/material-examples/radio-ng-model/radio-ng-model-example.html +++ b/src/material-examples/radio-ng-model/radio-ng-model-example.html @@ -1,6 +1,6 @@ - - + + {{season}} - - + +
Your favorite season is: {{favoriteSeason}}
diff --git a/src/material-examples/radio-overview/radio-overview-example.html b/src/material-examples/radio-overview/radio-overview-example.html index 4038381cc49e..cadd1b6e8d59 100644 --- a/src/material-examples/radio-overview/radio-overview-example.html +++ b/src/material-examples/radio-overview/radio-overview-example.html @@ -1,4 +1,4 @@ - - Option 1 - Option 2 - + + Option 1 + Option 2 + diff --git a/src/material-examples/select-form/select-form-example.html b/src/material-examples/select-form/select-form-example.html index 31252dd70a66..484c7282bc44 100644 --- a/src/material-examples/select-form/select-form-example.html +++ b/src/material-examples/select-form/select-form-example.html @@ -1,11 +1,11 @@
- - - + + + {{food.viewValue}} - - - + + +

Selected value: {{selectedValue}}

diff --git a/src/material-examples/select-overview/select-overview-example.html b/src/material-examples/select-overview/select-overview-example.html index bf3897383572..f02b07a123ad 100644 --- a/src/material-examples/select-overview/select-overview-example.html +++ b/src/material-examples/select-overview/select-overview-example.html @@ -1,7 +1,7 @@ - - - + + + {{ food.viewValue }} - - - + + + diff --git a/src/material-examples/sidenav-fab/sidenav-fab-example.css b/src/material-examples/sidenav-fab/sidenav-fab-example.css index 6d58f0f24b13..80b88561b599 100644 --- a/src/material-examples/sidenav-fab/sidenav-fab-example.css +++ b/src/material-examples/sidenav-fab/sidenav-fab-example.css @@ -4,12 +4,12 @@ border: 1px solid rgba(0, 0, 0, 0.5); } -.example-sidenav-fab-container md-sidenav { +.example-sidenav-fab-container mat-sidenav { max-width: 200px; } .example-sidenav-fab-container .mat-sidenav-content, -.example-sidenav-fab-container md-sidenav { +.example-sidenav-fab-container mat-sidenav { display: flex; overflow: visible; } diff --git a/src/material-examples/sidenav-fab/sidenav-fab-example.html b/src/material-examples/sidenav-fab/sidenav-fab-example.html index f194c09852e2..9053ced258a3 100644 --- a/src/material-examples/sidenav-fab/sidenav-fab-example.html +++ b/src/material-examples/sidenav-fab/sidenav-fab-example.html @@ -1,7 +1,7 @@ - - -
Lorem ipsum dolor sit amet, pede a libero aenean phasellus, lectus metus sint ut risus, @@ -14,9 +14,9 @@ tristique vehicula nibh ipsum vivamus, proin proin. Porta commodo nibh quis libero amet. Taciti dui, sapien consectetuer.
-
-
Lorem ipsum dolor sit amet, pede a libero aenean phasellus, lectus metus sint ut risus, fusce @@ -29,4 +29,4 @@ ipsum vivamus, proin proin. Porta commodo nibh quis libero amet. Taciti dui, sapien consectetuer.
-
+ diff --git a/src/material-examples/sidenav-overview/sidenav-overview-example.html b/src/material-examples/sidenav-overview/sidenav-overview-example.html index 757e4b2d43f2..9069c886c896 100644 --- a/src/material-examples/sidenav-overview/sidenav-overview-example.html +++ b/src/material-examples/sidenav-overview/sidenav-overview-example.html @@ -1,12 +1,12 @@ - - + + Jolly good! - +
-
-
+ diff --git a/src/material-examples/slide-toggle-configurable/slide-toggle-configurable-example.html b/src/material-examples/slide-toggle-configurable/slide-toggle-configurable-example.html index 88099f4b0254..b7f41c0090c4 100644 --- a/src/material-examples/slide-toggle-configurable/slide-toggle-configurable-example.html +++ b/src/material-examples/slide-toggle-configurable/slide-toggle-configurable-example.html @@ -1,44 +1,44 @@ - - + +

Slider configuration

- - + + Primary - - + + Accent - - + + Warn - - + +
- Checked + Checked
- Disabled + Disabled
-
-
+ + - - + +

Result

- Slide me! - +
-
-
+ + diff --git a/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.css b/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.css index 8567e7f853bb..aaec1dbc305e 100644 --- a/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.css +++ b/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.css @@ -1,4 +1,4 @@ -.example-form md-slide-toggle { +.example-form mat-slide-toggle { margin: 8px 0; display: block; } diff --git a/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.html b/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.html index 0a2b897d22f8..3ce5f440b735 100644 --- a/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.html +++ b/src/material-examples/slide-toggle-forms/slide-toggle-forms-example.html @@ -1,25 +1,25 @@

Slide Toggle using a simple NgModel.

-Slide Toggle Checked: {{ isChecked }} +Slide Toggle Checked: {{ isChecked }}

Slide Toggle inside of a Template-driven form

- Enable Wifi - Accept Terms of Service + Enable Wifi + Accept Terms of Service - +

Slide Toggle inside of a Reactive form

- Enable Wifi - Accept Terms of Service + Enable Wifi + Accept Terms of Service

Form Group Status: {{ formGroup.status}}

- +
diff --git a/src/material-examples/slide-toggle-overview/slide-toggle-overview-example.html b/src/material-examples/slide-toggle-overview/slide-toggle-overview-example.html index 6b9586e148fc..d9d6ab193f34 100644 --- a/src/material-examples/slide-toggle-overview/slide-toggle-overview-example.html +++ b/src/material-examples/slide-toggle-overview/slide-toggle-overview-example.html @@ -1 +1 @@ -Slide me! +Slide me! diff --git a/src/material-examples/slider-configurable/slider-configurable-example.html b/src/material-examples/slider-configurable/slider-configurable-example.html index 5eb3214fd0a1..666753cdf4c6 100644 --- a/src/material-examples/slider-configurable/slider-configurable-example.html +++ b/src/material-examples/slider-configurable/slider-configurable-example.html @@ -1,53 +1,53 @@ - - + +

Slider configuration

- - - - - - - - - - - - + + + + + + + + + + + +
- Show ticks - + Show ticks + Auto ticks - - - - + + + +
- Show thumb label + Show thumb label
- Vertical - Inverted + Vertical + Inverted
- Disabled + Disabled
-
-
+ + - - + +

Result

- Result [tick-interval]="tickInterval" [value]="value" [vertical]="vertical"> - -
-
+ + + diff --git a/src/material-examples/slider-overview/slider-overview-example.css b/src/material-examples/slider-overview/slider-overview-example.css index 8dfe08ccc21d..90bd10ae0222 100644 --- a/src/material-examples/slider-overview/slider-overview-example.css +++ b/src/material-examples/slider-overview/slider-overview-example.css @@ -1,4 +1,4 @@ /** No CSS for this example */ -md-slider { +mat-slider { width: 300px; } diff --git a/src/material-examples/slider-overview/slider-overview-example.html b/src/material-examples/slider-overview/slider-overview-example.html index 9a92c8f867dd..49162f5fe3ec 100644 --- a/src/material-examples/slider-overview/slider-overview-example.html +++ b/src/material-examples/slider-overview/slider-overview-example.html @@ -1 +1 @@ - + diff --git a/src/material-examples/snack-bar-component/snack-bar-component-example.html b/src/material-examples/snack-bar-component/snack-bar-component-example.html index 69fe01bc3dcb..3c8c74b319a9 100644 --- a/src/material-examples/snack-bar-component/snack-bar-component-example.html +++ b/src/material-examples/snack-bar-component/snack-bar-component-example.html @@ -1,3 +1,3 @@ - diff --git a/src/material-examples/snack-bar-component/snack-bar-component-example.ts b/src/material-examples/snack-bar-component/snack-bar-component-example.ts index 8aac00a13153..7c685c53985a 100644 --- a/src/material-examples/snack-bar-component/snack-bar-component-example.ts +++ b/src/material-examples/snack-bar-component/snack-bar-component-example.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; /** * @title Snack-bar with a custom component @@ -9,7 +9,7 @@ import {MdSnackBar} from '@angular/material'; templateUrl: 'snack-bar-component-example.html', }) export class SnackBarComponentExample { - constructor(public snackBar: MdSnackBar) {} + constructor(public snackBar: MatSnackBar) {} openSnackBar() { this.snackBar.openFromComponent(PizzaPartyComponent, { diff --git a/src/material-examples/snack-bar-overview/snack-bar-overview-example.html b/src/material-examples/snack-bar-overview/snack-bar-overview-example.html index 757612c187f1..67065299a718 100644 --- a/src/material-examples/snack-bar-overview/snack-bar-overview-example.html +++ b/src/material-examples/snack-bar-overview/snack-bar-overview-example.html @@ -1,9 +1,9 @@ - - - + + + - - - + + + - + diff --git a/src/material-examples/snack-bar-overview/snack-bar-overview-example.ts b/src/material-examples/snack-bar-overview/snack-bar-overview-example.ts index 4d1980dc9d47..010634ef1dca 100644 --- a/src/material-examples/snack-bar-overview/snack-bar-overview-example.ts +++ b/src/material-examples/snack-bar-overview/snack-bar-overview-example.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {MdSnackBar} from '@angular/material'; +import {MatSnackBar} from '@angular/material'; /** * @title Basic snack-bar @@ -9,7 +9,7 @@ import {MdSnackBar} from '@angular/material'; templateUrl: 'snack-bar-overview-example.html', }) export class SnackBarOverviewExample { - constructor(public snackBar: MdSnackBar) {} + constructor(public snackBar: MatSnackBar) {} openSnackBar(message: string, action: string) { this.snackBar.open(message, action, { diff --git a/src/material-examples/sort-overview/sort-overview-example.html b/src/material-examples/sort-overview/sort-overview-example.html index 342f38554140..2b970af18c6a 100644 --- a/src/material-examples/sort-overview/sort-overview-example.html +++ b/src/material-examples/sort-overview/sort-overview-example.html @@ -1,10 +1,10 @@ - +
- - - - - + + + + + diff --git a/src/material-examples/stepper-overview/stepper-overview-example.html b/src/material-examples/stepper-overview/stepper-overview-example.html index adff42f6f8ba..433cabb09cd2 100644 --- a/src/material-examples/stepper-overview/stepper-overview-example.html +++ b/src/material-examples/stepper-overview/stepper-overview-example.html @@ -1,32 +1,32 @@ - - + +
- Fill out your name - - - + Fill out your name + + +
- +
-
- + +
- Fill out your address - - - + Fill out your address + + +
- - + +
-
- - Done + + + Done You are now done.
- +
-
-
+ + diff --git a/src/material-examples/table-basic/table-basic-example.html b/src/material-examples/table-basic/table-basic-example.html index 66dd020c6d55..35669c521e53 100644 --- a/src/material-examples/table-basic/table-basic-example.html +++ b/src/material-examples/table-basic/table-basic-example.html @@ -1,34 +1,34 @@
- + - - No. - {{element.position}} + + No. + {{element.position}} - - Name - {{element.name}} + + Name + {{element.name}} - - Weight - {{element.weight}} + + Weight + {{element.weight}} - - Symbol - {{element.symbol}} + + Symbol + {{element.symbol}} - - - + + +
diff --git a/src/material-examples/table-filtering/table-filtering-example.html b/src/material-examples/table-filtering/table-filtering-example.html index c3d8ca1d9773..0f1f6189d7c9 100644 --- a/src/material-examples/table-filtering/table-filtering-example.html +++ b/src/material-examples/table-filtering/table-filtering-example.html @@ -1,40 +1,40 @@
- - - + + +
- + - - ID - {{row.id}} + + ID + {{row.id}} - - Progress - {{row.progress}}% + + Progress + {{row.progress}}% - - Name - {{row.name}} + + Name + {{row.name}} - - Color - {{row.color}} + + Color + {{row.color}} - - - + + +
diff --git a/src/material-examples/table-http/table-http-example.html b/src/material-examples/table-http/table-http-example.html index b74b898a782c..a176f2f624f3 100644 --- a/src/material-examples/table-http/table-http-example.html +++ b/src/material-examples/table-http/table-http-example.html @@ -1,51 +1,51 @@
- +
GitHub's API rate limit has been reached. It will be reset in one minute.
- + - - # - {{ row.number }} + + # + {{ row.number }} - - Title - {{ row.title }} + + Title + {{ row.title }} - - State - {{ row.state }} + + State + {{ row.state }} - - + Created - - {{ row.created_at | date }} + + {{ row.created_at | date }} - - - + + + - - +
diff --git a/src/material-examples/table-http/table-http-example.ts b/src/material-examples/table-http/table-http-example.ts index bd3fac7c6bae..1283f2b890a2 100644 --- a/src/material-examples/table-http/table-http-example.ts +++ b/src/material-examples/table-http/table-http-example.ts @@ -1,7 +1,7 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {Http} from '@angular/http'; import {DataSource} from '@angular/cdk/collections'; -import {MdPaginator, MdSort} from '@angular/material'; +import {MatPaginator, MatSort} from '@angular/material'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/observable/merge'; import 'rxjs/add/observable/of'; @@ -23,8 +23,8 @@ export class TableHttpExample implements OnInit { exampleDatabase: ExampleHttpDao | null; dataSource: ExampleDataSource | null; - @ViewChild(MdPaginator) paginator: MdPaginator; - @ViewChild(MdSort) sort: MdSort; + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; constructor(private http: Http) {} @@ -75,8 +75,8 @@ export class ExampleDataSource extends DataSource { isRateLimitReached = false; constructor(private exampleDatabase: ExampleHttpDao, - private paginator: MdPaginator, - private sort: MdSort) { + private paginator: MatPaginator, + private sort: MatSort) { super(); } diff --git a/src/material-examples/table-overview/table-overview-example.html b/src/material-examples/table-overview/table-overview-example.html index 35a12176e456..847ec261256a 100644 --- a/src/material-examples/table-overview/table-overview-example.html +++ b/src/material-examples/table-overview/table-overview-example.html @@ -1,7 +1,7 @@
- - - + + +
@@ -12,67 +12,67 @@
- + - - - + + - - - - + + + - - + + - - ID - {{row.id}} + + ID + {{row.id}} - - Progress - {{row.progress}}% + + Progress + {{row.progress}}% - - Name - {{row.name}} + + Name + {{row.name}} - - Color - {{row.color}} + + Color + {{row.color}} - - + - - + +
No users found matching filter.
- - +
diff --git a/src/material-examples/table-overview/table-overview-example.ts b/src/material-examples/table-overview/table-overview-example.ts index 2fd7d0883e47..b9a3e0f30400 100644 --- a/src/material-examples/table-overview/table-overview-example.ts +++ b/src/material-examples/table-overview/table-overview-example.ts @@ -1,6 +1,6 @@ import {Component, ElementRef, ViewChild} from '@angular/core'; import {DataSource} from '@angular/cdk/collections'; -import {MdPaginator, MdSort} from '@angular/material'; +import {MatPaginator, MatSort} from '@angular/material'; import {SelectionModel} from '@angular/cdk/collections'; import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {Observable} from 'rxjs/Observable'; @@ -25,8 +25,8 @@ export class TableOverviewExample { selection = new SelectionModel(true, []); dataSource: ExampleDataSource | null; - @ViewChild(MdPaginator) paginator: MdPaginator; - @ViewChild(MdSort) sort: MdSort; + @ViewChild(MatPaginator) paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; @ViewChild('filter') filter: ElementRef; ngOnInit() { @@ -127,8 +127,8 @@ export class ExampleDataSource extends DataSource { renderedData: UserData[] = []; constructor(private _exampleDatabase: ExampleDatabase, - private _paginator: MdPaginator, - private _sort: MdSort) { + private _paginator: MatPaginator, + private _sort: MatSort) { super(); // Reset to the first page when the user changes the filter. diff --git a/src/material-examples/table-pagination/table-pagination-example.html b/src/material-examples/table-pagination/table-pagination-example.html index 6fa6eaad76b0..97f7d4ac8c17 100644 --- a/src/material-examples/table-pagination/table-pagination-example.html +++ b/src/material-examples/table-pagination/table-pagination-example.html @@ -1,42 +1,42 @@
- + - - ID - {{row.id}} + + ID + {{row.id}} - - Progress - {{row.progress}}% + + Progress + {{row.progress}}% - - Name - {{row.name}} + + Name + {{row.name}} - - Color - {{row.color}} + + Color + {{row.color}} - - - + + + - - +
diff --git a/src/material-examples/table-pagination/table-pagination-example.ts b/src/material-examples/table-pagination/table-pagination-example.ts index 1434c8f6acd9..3040bfec59d8 100644 --- a/src/material-examples/table-pagination/table-pagination-example.ts +++ b/src/material-examples/table-pagination/table-pagination-example.ts @@ -1,6 +1,6 @@ import {Component, ViewChild} from '@angular/core'; import {DataSource} from '@angular/cdk/collections'; -import {MdPaginator} from '@angular/material'; +import {MatPaginator} from '@angular/material'; import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/operator/startWith'; @@ -20,7 +20,7 @@ export class TablePaginationExample { exampleDatabase = new ExampleDatabase(); dataSource: ExampleDataSource | null; - @ViewChild(MdPaginator) paginator: MdPaginator; + @ViewChild(MatPaginator) paginator: MatPaginator; ngOnInit() { this.dataSource = new ExampleDataSource(this.exampleDatabase, this.paginator); @@ -82,7 +82,7 @@ export class ExampleDatabase { * should be rendered. */ export class ExampleDataSource extends DataSource { - constructor(private _exampleDatabase: ExampleDatabase, private _paginator: MdPaginator) { + constructor(private _exampleDatabase: ExampleDatabase, private _paginator: MatPaginator) { super(); } diff --git a/src/material-examples/table-sorting/table-sorting-example.html b/src/material-examples/table-sorting/table-sorting-example.html index cde414b641d7..ec3ed853501a 100644 --- a/src/material-examples/table-sorting/table-sorting-example.html +++ b/src/material-examples/table-sorting/table-sorting-example.html @@ -1,34 +1,34 @@
- + - - ID - {{row.id}} + + ID + {{row.id}} - - Progress - {{row.progress}}% + + Progress + {{row.progress}}% - - Name - {{row.name}} + + Name + {{row.name}} - - Color - {{row.color}} + + Color + {{row.color}} - - - + + +
diff --git a/src/material-examples/table-sorting/table-sorting-example.ts b/src/material-examples/table-sorting/table-sorting-example.ts index 36df176410c0..36c6eea972a6 100644 --- a/src/material-examples/table-sorting/table-sorting-example.ts +++ b/src/material-examples/table-sorting/table-sorting-example.ts @@ -1,6 +1,6 @@ import {Component, ViewChild} from '@angular/core'; import {DataSource} from '@angular/cdk/collections'; -import {MdSort} from '@angular/material'; +import {MatSort} from '@angular/material'; import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/operator/startWith'; @@ -20,7 +20,7 @@ export class TableSortingExample { exampleDatabase = new ExampleDatabase(); dataSource: ExampleDataSource | null; - @ViewChild(MdSort) sort: MdSort; + @ViewChild(MatSort) sort: MatSort; ngOnInit() { this.dataSource = new ExampleDataSource(this.exampleDatabase, this.sort); @@ -82,7 +82,7 @@ export class ExampleDatabase { * should be rendered. */ export class ExampleDataSource extends DataSource { - constructor(private _exampleDatabase: ExampleDatabase, private _sort: MdSort) { + constructor(private _exampleDatabase: ExampleDatabase, private _sort: MatSort) { super(); } diff --git a/src/material-examples/tabs-overview/tabs-overview-example.html b/src/material-examples/tabs-overview/tabs-overview-example.html index 173ece5dc477..2883cea104dd 100644 --- a/src/material-examples/tabs-overview/tabs-overview-example.html +++ b/src/material-examples/tabs-overview/tabs-overview-example.html @@ -1,4 +1,4 @@ - - Content 1 - Content 2 - + + Content 1 + Content 2 + diff --git a/src/material-examples/tabs-template-label/tabs-template-label-example.html b/src/material-examples/tabs-template-label/tabs-template-label-example.html index 75b5b19dafa0..d35bdb5ae63c 100644 --- a/src/material-examples/tabs-template-label/tabs-template-label-example.html +++ b/src/material-examples/tabs-template-label/tabs-template-label-example.html @@ -1,5 +1,5 @@ - - + +
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla venenatis ante augue. Phasellus volutpat neque ac dui mattis vulputate. Etiam consequat aliquam cursus. @@ -7,9 +7,9 @@ feugiat ultricies mi. Aliquam erat volutpat. Nam placerat, tortor in ultrices porttitor, orci enim rutrum enim, vel tempor sapien arcu a tellus.
-
- - + + + ⭐
@@ -19,11 +19,11 @@ feugiat ultricies mi. Aliquam erat volutpat. Nam placerat, tortor in ultrices porttitor, orci enim rutrum enim, vel tempor sapien arcu a tellus.
-
- + + No content - - + +
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla venenatis ante augue. Phasellus volutpat neque ac dui mattis vulputate. Etiam consequat aliquam cursus. @@ -38,11 +38,11 @@ feugiat ultricies mi. Aliquam erat volutpat. Nam placerat, tortor in ultrices porttitor, orci enim rutrum enim, vel tempor sapien arcu a tellus.
-
- + + No content - - + + No content - -
\ No newline at end of file + + \ No newline at end of file diff --git a/src/material-examples/toolbar-multirow/toolbar-multirow-example.html b/src/material-examples/toolbar-multirow/toolbar-multirow-example.html index 9b178a21249f..a0c0e9cfde84 100644 --- a/src/material-examples/toolbar-multirow/toolbar-multirow-example.html +++ b/src/material-examples/toolbar-multirow/toolbar-multirow-example.html @@ -1,16 +1,16 @@ - + Custom Toolbar - + Second Line - verified_user - + verified_user + - + Third Line - favorite - delete - - + favorite + delete + + diff --git a/src/material-examples/toolbar-overview/toolbar-overview-example.html b/src/material-examples/toolbar-overview/toolbar-overview-example.html index bf8cc3998630..05520fda8642 100644 --- a/src/material-examples/toolbar-overview/toolbar-overview-example.html +++ b/src/material-examples/toolbar-overview/toolbar-overview-example.html @@ -1 +1 @@ -My App +My App diff --git a/src/material-examples/tooltip-overview/tooltip-overview-example.html b/src/material-examples/tooltip-overview/tooltip-overview-example.html index 8319a8545846..3a2a27493673 100644 --- a/src/material-examples/tooltip-overview/tooltip-overview-example.html +++ b/src/material-examples/tooltip-overview/tooltip-overview-example.html @@ -1 +1 @@ -I have a tooltip +I have a tooltip diff --git a/src/material-examples/tooltip-position/tooltip-position-example.html b/src/material-examples/tooltip-position/tooltip-position-example.html index 2187a60c71f4..a0fa7759ce21 100644 --- a/src/material-examples/tooltip-position/tooltip-position-example.html +++ b/src/material-examples/tooltip-position/tooltip-position-example.html @@ -1,13 +1,13 @@ -
+
Show tooltip - - - Before - After - Above - Below - Left - Right - - + + + Before + After + Above + Below + Left + Right + +
diff --git a/src/material-moment-adapter/adapter/index.ts b/src/material-moment-adapter/adapter/index.ts index df84c7dabace..300f6e4e323f 100644 --- a/src/material-moment-adapter/adapter/index.ts +++ b/src/material-moment-adapter/adapter/index.ts @@ -11,10 +11,10 @@ import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_LOCALE_PROVIDER, - MD_DATE_FORMATS + MAT_DATE_FORMATS } from '@angular/material'; import {MomentDateAdapter} from './moment-date-adapter'; -import {MD_MOMENT_DATE_FORMATS} from './moment-date-formats'; +import {MAT_MOMENT_DATE_FORMATS} from './moment-date-formats'; export * from './moment-date-adapter'; export * from './moment-date-formats'; @@ -31,6 +31,6 @@ export class MomentDateModule {} @NgModule({ imports: [MomentDateModule], - providers: [{provide: MD_DATE_FORMATS, useValue: MD_MOMENT_DATE_FORMATS}], + providers: [{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS}], }) -export class MdMomentDateModule {} +export class MatMomentDateModule {} diff --git a/src/material-moment-adapter/adapter/moment-date-formats.ts b/src/material-moment-adapter/adapter/moment-date-formats.ts index 6f4747f0493c..caec58f8a603 100644 --- a/src/material-moment-adapter/adapter/moment-date-formats.ts +++ b/src/material-moment-adapter/adapter/moment-date-formats.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {MdDateFormats} from '@angular/material'; +import {MatDateFormats} from '@angular/material'; -export const MD_MOMENT_DATE_FORMATS: MdDateFormats = { +export const MAT_MOMENT_DATE_FORMATS: MatDateFormats = { parse: { dateInput: 'l', }, diff --git a/src/universal-app/kitchen-sink/kitchen-sink.html b/src/universal-app/kitchen-sink/kitchen-sink.html index 988a6d2cb34d..6d0d3a6b77f0 100644 --- a/src/universal-app/kitchen-sink/kitchen-sink.html +++ b/src/universal-app/kitchen-sink/kitchen-sink.html @@ -1,227 +1,227 @@

Kitchen sink app

Autocomplete

- - Grace Hopper - Anita Borg - Ada Lovelace - + + Grace Hopper + Anita Borg + Ada Lovelace +

Button

- - - - - + + + + + -Google -Google -Google -Google -Google +Google +Google +Google +Google +Google

Button toggle

Single selection

- - Ketchup - Mustard - Mayo - + + Ketchup + Mustard + Mayo +

Multi selection

- - Ketchup - Mustard - Mayo - + + Ketchup + Mustard + Mayo +

Standalone

-Hyperspinner enabled +Hyperspinner enabled

Card

- + Simple card - + - - Complicated card - Subtitle - + + Complicated card + Subtitle +

This is some stuff

And more stuff

-
- - - - - + + + + + + Hurray - -
+ +

Checkbox

-With a label -Without a label +With a label +Without a label

Chips

- - Barbeque Cheddar - Sea Salt and Vinegar - Manta Ray - + + Barbeque Cheddar + Sea Salt and Vinegar + Manta Ray + - - Tomato - Scallion - Cilantro - + + Tomato + Scallion + Cilantro +

Datepicker

- - - - - + + + + +

Grid list

- - Fry - Leela - Amy - Bender - + + Fry + Leela + Amy + Bender +

Icon

-ligature +ligature

Input

- - - $  - .00 - Dolla dolla bills - Recession - + + + $  + .00 + Dolla dolla bills + Recession +

List

- - Robot - Android - Cyborg - + + Robot + Android + Cyborg + - - Search - Find - Seek - + + Search + Find + Seek +

Menu

- - - - - - + + + + + +

Progress bar

- - - - + + + +

Radio buttons

Radio group

- - Charmander - Squirtle - Bulbasaur - + + Charmander + Squirtle + Bulbasaur +

Standalone radios

-White -Yellow -Green -Red +White +Yellow +Green +Red

Select

- - - Glass - Ceramic - Steel - - + + + Glass + Ceramic + Steel + +

Sidenav

- - On the side + + On the side Main content - +

Slide-toggle

-With a label -Without a label +With a label +Without a label

Slider

- - - + + +

Tabs

- - + + The overview - - - + + + API docs The API docs - - + + -
- Google - Also Google +
+ Google + Also Google

Paginator

- - +

Toolbar

-Basic toolbar - - Multi row - Toolbar - +Basic toolbar + + Multi row + Toolbar +

Sort

-
Dessert (100g)CaloriesFat (g)Carbs (g)Protein (g)Dessert (100g)CaloriesFat (g)Carbs (g)Protein (g)
+
- - - - - + + + + + @@ -235,20 +235,20 @@

Sort

Tooltip

- +

Autosize textarea

- +

Expansion Panel

- - + + This is a panel description. Panel Title - + This is the content text that makes sense here. - Action - + Action +

CDK Table

@@ -264,12 +264,12 @@

CDK Table

Material Table

- + - ID - {{row.userId}} + ID + {{row.userId}} - - - + + + diff --git a/src/universal-app/kitchen-sink/kitchen-sink.ts b/src/universal-app/kitchen-sink/kitchen-sink.ts index a2ae0f71140c..5fdda06149bb 100644 --- a/src/universal-app/kitchen-sink/kitchen-sink.ts +++ b/src/universal-app/kitchen-sink/kitchen-sink.ts @@ -3,35 +3,35 @@ import {ServerModule} from '@angular/platform-server'; import {BrowserModule} from '@angular/platform-browser'; import {Observable} from 'rxjs/Observable'; import { - MdAutocompleteModule, - MdButtonModule, - MdCardModule, - MdChipsModule, - MdDatepickerModule, - MdDialogModule, - MdExpansionModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdNativeDateModule, - MdPaginatorModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdRippleModule, - MdSelectModule, - MdSidenavModule, - MdSliderModule, - MdSlideToggleModule, - MdSnackBarModule, - MdSortModule, - MdTableModule, - MdTabsModule, - MdToolbarModule, - MdTooltipModule, + MatAutocompleteModule, + MatButtonModule, + MatCardModule, + MatChipsModule, + MatDatepickerModule, + MatDialogModule, + MatExpansionModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatNativeDateModule, + MatPaginatorModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatRippleModule, + MatSelectModule, + MatSidenavModule, + MatSliderModule, + MatSlideToggleModule, + MatSnackBarModule, + MatSortModule, + MatTableModule, + MatTabsModule, + MatToolbarModule, + MatTooltipModule, } from '@angular/material'; import { CdkTableModule, @@ -65,38 +65,38 @@ export class KitchenSink { @NgModule({ imports: [ BrowserModule.withServerTransition({appId: 'kitchen-sink'}), - MdAutocompleteModule, - MdButtonModule, + MatAutocompleteModule, + MatButtonModule, // Button toggle and checkbox can't work due to https://github.com/angular/angular/issues/17050 - // MdButtonToggleModule, - MdCardModule, - // MdCheckboxModule, - MdChipsModule, - MdDatepickerModule, - MdDialogModule, - MdFormFieldModule, - MdGridListModule, - MdIconModule, - MdInputModule, - MdListModule, - MdMenuModule, - MdNativeDateModule, - MdPaginatorModule, - MdProgressBarModule, - MdProgressSpinnerModule, - MdRadioModule, - MdRippleModule, - MdSelectModule, - MdSidenavModule, - MdSliderModule, - MdSlideToggleModule, - MdSnackBarModule, - MdTabsModule, - MdToolbarModule, - MdTooltipModule, - MdExpansionModule, - MdSortModule, - MdTableModule, + // MatButtonToggleModule, + MatCardModule, + // MatCheckboxModule, + MatChipsModule, + MatDatepickerModule, + MatDialogModule, + MatFormFieldModule, + MatGridListModule, + MatIconModule, + MatInputModule, + MatListModule, + MatMenuModule, + MatNativeDateModule, + MatPaginatorModule, + MatProgressBarModule, + MatProgressSpinnerModule, + MatRadioModule, + MatRippleModule, + MatSelectModule, + MatSidenavModule, + MatSliderModule, + MatSlideToggleModule, + MatSnackBarModule, + MatTabsModule, + MatToolbarModule, + MatTooltipModule, + MatExpansionModule, + MatSortModule, + MatTableModule, // CDK Modules CdkTableModule diff --git a/test/protractor.conf.js b/test/protractor.conf.js index 83fa1471839e..64c3c146f66b 100644 --- a/test/protractor.conf.js +++ b/test/protractor.conf.js @@ -25,8 +25,8 @@ const config = { path: '../tools/axe-protractor/axe-protractor.js', rules: [ - // Exclude md-menu elements because those are empty if not active. - { id: 'aria-required-children', selector: '*:not(md-menu)' }, + // Exclude mat-menu elements because those are empty if not active. + { id: 'aria-required-children', selector: '*:not(mat-menu)' }, // Disable color constrast checks since the final colors will vary based on the theme. { id: 'color-contrast', enabled: false }, diff --git a/tools/dashboard/src/app/coverage-chart/coverage-chart.html b/tools/dashboard/src/app/coverage-chart/coverage-chart.html index d566cbd5aea1..8779d008b6d6 100644 --- a/tools/dashboard/src/app/coverage-chart/coverage-chart.html +++ b/tools/dashboard/src/app/coverage-chart/coverage-chart.html @@ -14,4 +14,4 @@ [autoScale]="true"> - + diff --git a/tools/dashboard/src/app/dashboard-app.html b/tools/dashboard/src/app/dashboard-app.html index 59e513cdeb8b..484e468f3011 100644 --- a/tools/dashboard/src/app/dashboard-app.html +++ b/tools/dashboard/src/app/dashboard-app.html @@ -1,21 +1,21 @@ - + Angular Material - Board - +
- - Payload Size Chart - + + Payload Size Chart + - - + + - - Coverage Reports - + + Coverage Reports + - - + +
diff --git a/tools/dashboard/src/app/dashboard-module.ts b/tools/dashboard/src/app/dashboard-module.ts index 8d01d9af088a..7f7b55f679ce 100644 --- a/tools/dashboard/src/app/dashboard-module.ts +++ b/tools/dashboard/src/app/dashboard-module.ts @@ -4,7 +4,7 @@ import {AngularFireDatabaseModule} from 'angularfire2/database'; import {NgModule} from '@angular/core'; import {DashboardApp} from './dashboard-app'; import {environment} from '../environments/environment'; -import {MdCardModule, MdProgressSpinnerModule, MdToolbarModule} from '@angular/material'; +import {MatCardModule, MatProgressSpinnerModule, MatToolbarModule} from '@angular/material'; import {NgxChartsModule} from '@swimlane/ngx-charts'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {PayloadChart} from './payload-chart/payload-chart'; @@ -12,9 +12,9 @@ import {CoverageChart} from './coverage-chart/coverage-chart'; @NgModule({ exports: [ - MdCardModule, - MdToolbarModule, - MdProgressSpinnerModule + MatCardModule, + MatToolbarModule, + MatProgressSpinnerModule ] }) export class DashboardMaterialModule {} diff --git a/tools/dashboard/src/app/payload-chart/payload-chart.html b/tools/dashboard/src/app/payload-chart/payload-chart.html index a7b907d9bce3..0583940b4d97 100644 --- a/tools/dashboard/src/app/payload-chart/payload-chart.html +++ b/tools/dashboard/src/app/payload-chart/payload-chart.html @@ -14,4 +14,4 @@ [autoScale]="true"> - + diff --git a/tools/dgeni/processors/categorizer.js b/tools/dgeni/processors/categorizer.js index d10a92f9d00d..b10a947fa900 100644 --- a/tools/dgeni/processors/categorizer.js +++ b/tools/dgeni/processors/categorizer.js @@ -6,7 +6,7 @@ const SELECTOR_BLACKLIST = new Set([ '[portal]', '[portalHost]', - 'textarea[md-autosize]', + 'textarea[mat-autosize]', '[overlay-origin]', '[connected-overlay]', ]); diff --git a/tools/screenshot-test/src/app/nav/nav.component.html b/tools/screenshot-test/src/app/nav/nav.component.html index e7904d4f56ed..fd8bb87e70fe 100644 --- a/tools/screenshot-test/src/app/nav/nav.component.html +++ b/tools/screenshot-test/src/app/nav/nav.component.html @@ -1,6 +1,6 @@ - +
{{user.email}}
- - -
+ + + diff --git a/tools/screenshot-test/src/app/pixacto.dashboard.module.ts b/tools/screenshot-test/src/app/pixacto.dashboard.module.ts index 3cff5d19cf5d..03e1f733edb9 100644 --- a/tools/screenshot-test/src/app/pixacto.dashboard.module.ts +++ b/tools/screenshot-test/src/app/pixacto.dashboard.module.ts @@ -6,8 +6,8 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {FirebaseService} from './firebase.service'; import {routing} from './routes'; import { - MdToolbarModule, MdButtonModule, MdCardModule, MdButtonToggleModule, MdIconModule, - MdSnackBarModule, MdTooltipModule + MatToolbarModule, MatButtonModule, MatCardModule, MatButtonToggleModule, MatIconModule, + MatSnackBarModule, MatTooltipModule } from '@angular/material'; import {PixactoDashboardComponent} from './pixacto.dashboard.component'; @@ -17,13 +17,13 @@ import {NavComponent} from './nav/nav.component'; @NgModule({ exports: [ - MdToolbarModule, - MdButtonModule, - MdCardModule, - MdButtonToggleModule, - MdIconModule, - MdTooltipModule, - MdSnackBarModule + MatToolbarModule, + MatButtonModule, + MatCardModule, + MatButtonToggleModule, + MatIconModule, + MatTooltipModule, + MatSnackBarModule ] }) export class PixactoMaterialModule {} diff --git a/tools/screenshot-test/src/app/result/result.component.html b/tools/screenshot-test/src/app/result/result.component.html index cfe3312f2f71..112a188c523d 100644 --- a/tools/screenshot-test/src/app/result/result.component.html +++ b/tools/screenshot-test/src/app/result/result.component.html @@ -1,12 +1,12 @@ - - - - {{collapseIcon}} + + + + {{collapseIcon}} {{testName}} - - {{resultText}} - - + + {{resultText}} + +
Test image
@@ -21,19 +21,19 @@
-
- - - + + + + Diff - - + + Flip - - + + Side by side - - - - -
+ + + + + diff --git a/tools/screenshot-test/src/app/viewer/viewer.component.html b/tools/screenshot-test/src/app/viewer/viewer.component.html index 8de5f92b50e0..4e40617ac876 100644 --- a/tools/screenshot-test/src/app/viewer/viewer.component.html +++ b/tools/screenshot-test/src/app/viewer/viewer.component.html @@ -1,18 +1,18 @@
- +

- + Pull Request: {{screenshotResultSummary.prNumber}} - + Commit: {{screenshotResultSummary.sha}} - + Travis: {{screenshotResultSummary.travis}}

- @@ -21,23 +21,23 @@

- - + + Test images should be the same as golden images. Expand all to verify.

- - - {{githubIcon}} + + {{githubIcon}} - - refresh + + refresh
@@ -45,15 +45,15 @@ Once the PR checked in, the golds will be updated automatically.

- - - - -
+ +
{ this._service.prNumber = p['id']; From 657287925b0aa3eaa8e52e1fbf2637c8009bfedf Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 00:27:09 +0200 Subject: [PATCH 133/575] chore(tabs): fix e2e failures (#7360) Fixes a couple of e2e test failures in the tabs due to a wrong selector. From 3bbbb8a36f860aece65773a4027596248f96870d Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 00:27:25 +0200 Subject: [PATCH 134/575] chore: stepper e2e failures (#7237) Fixes some selectors that weren't renamed in the e2e tests. From f5d1a23ba11d0d9b9945b7a030bc0949de7d6b5a Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Thu, 28 Sep 2017 15:28:22 -0700 Subject: [PATCH 135/575] chore: update issue template & readme w/ stackblitz links (#7395) --- .github/ISSUE_TEMPLATE.md | 6 +++--- README.md | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 68123cd0c4a7..29524ffc3f7a 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -8,9 +8,9 @@ #### What are the steps to reproduce? - -Providing a Plunker (or similar) is the *best* way to get the team to see your issue. -Plunker template: https://goo.gl/DlHd6U +Providing a StackBlitz/Plunker (or similar) is the *best* way to get the team to see your issue.
+Plunker starter (using on `@master`): https://goo.gl/DlHd6U
+StackBlitz starter (using latest `npm` release): https://goo.gl/wwnhMV
#### What is the use-case or motivation for changing an existing behavior? diff --git a/README.md b/README.md index 44e1ab75a379..e8621baa8075 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ This is the home for the Angular team's Material Design components built for and [Documentation, demos, and guides][aio] | [Google group](https://groups.google.com/forum/#!forum/angular-material2) | [Contributing](https://github.com/angular/material2/blob/master/CONTRIBUTING.md) | -[Plunker Template](http://plnkr.co/edit/o077B6uEiiIgkC0S06dd?p=preview) +[Plunker Template](http://plnkr.co/edit/o077B6uEiiIgkC0S06dd?p=preview) | +[StackBlitz Template](https://stackblitz.com/edit/angular-material2-issue?file=app%2Fapp.component.ts) ### Getting started From aa6cd060a3d76aa31aabb022d9e5427654b0766f Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Thu, 28 Sep 2017 15:28:36 -0700 Subject: [PATCH 136/575] docs: add StyleModule deprecation to changelog (#7380) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 530770803df0..fe2c026729be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,10 @@ library's styles such that they wouldn't affect the Angular Material components the specificity. This would have been a significant breaking change, as it would have potentially broken countless custom styles that relied on a particular specificity working. +### Other deprecations +* `StyleModule` is deprecated. `FocusOriginMonitor` (the only thing it contained) has been renamed +to `FocusMonitor` and moved to `@angular/cdk/a11y` (`A11yModule`). + ### Bug Fixes From 822e71e69bfaafcc644ced0f8f39a36dd335f3dd Mon Sep 17 00:00:00 2001 From: Sean Harrington Date: Thu, 28 Sep 2017 18:29:43 -0400 Subject: [PATCH 137/575] docs(changelog): mention mdSortChange rename (#7362) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2c026729be..5a8ab702792d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ overlayContainer.getContainerElement().classList.add('my-theme-class'); ``` * DateAdapter method `getISODateString` has been renamed to `toIso8601` and a new method `fromIso8601` has been added. - +* **sort:** The sort-change stream `mdSortChange` has been renamed to `sortChange`. ### Deprecation of "md" prefix. From ae0791cabad144ae0df1b6436f2ac704ee4c9707 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 00:30:01 +0200 Subject: [PATCH 138/575] chore: remove dead link from demo app (#7343) Gets rid of the `/styles` link from the demo app since it was renamed to `/focus-origin` a few days ago. --- src/demo-app/demo-app/demo-app.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/demo-app/demo-app/demo-app.ts b/src/demo-app/demo-app/demo-app.ts index f1f9fa5cd178..7409cbccef3e 100644 --- a/src/demo-app/demo-app/demo-app.ts +++ b/src/demo-app/demo-app/demo-app.ts @@ -73,7 +73,6 @@ export class DemoApp { {name: 'Slider', route: '/slider'}, {name: 'Snack Bar', route: '/snack-bar'}, {name: 'Stepper', route: '/stepper'}, - {name: 'Style', route: '/style'}, {name: 'Table', route: '/table'}, {name: 'Tabs', route: '/tabs'}, {name: 'Toolbar', route: '/toolbar'}, From 40ec11cc493c3eae469285930ed710d7ddd88409 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:30:38 +0200 Subject: [PATCH 139/575] build: faster demo-app building (#7280) * The demo-app no longer builds every secondary entry-point separately. Now the everything of a package is built at the same time (as for the tests). This is significantly faster than before. * No longer builds the CDK package twice when building the tests or demo-app. --- src/demo-app/system-config.ts | 79 ++++++++++++++------ tools/gulp/packages.ts | 3 +- tools/gulp/tasks/aot.ts | 2 +- tools/gulp/tasks/development.ts | 34 ++++++--- tools/gulp/tasks/unit-test.ts | 2 +- tools/gulp/util/task_helpers.ts | 17 +---- tools/package-tools/gulp/build-tasks-gulp.ts | 4 +- tools/package-tools/gulp/watch-files.ts | 8 +- 8 files changed, 87 insertions(+), 62 deletions(-) diff --git a/src/demo-app/system-config.ts b/src/demo-app/system-config.ts index 96b0a3d3e9e3..1e2a4aabb251 100644 --- a/src/demo-app/system-config.ts +++ b/src/demo-app/system-config.ts @@ -1,10 +1,10 @@ /** Type declaration for ambient System. */ declare const System: any; -// Apply the CLI SystemJS configuration. +// Configure the base path and map the different node packages. System.config({ paths: { - 'node:*': 'node_modules/*', + 'node:*': 'node_modules/*' }, map: { 'rxjs': 'node:rxjs', @@ -17,36 +17,69 @@ System.config({ '@angular/compiler': 'node:@angular/compiler/bundles/compiler.umd.js', '@angular/http': 'node:@angular/http/bundles/http.umd.js', '@angular/forms': 'node:@angular/forms/bundles/forms.umd.js', - '@angular/router': 'node:@angular/router/bundles/router.umd.js', '@angular/animations': 'node:@angular/animations/bundles/animations.umd.js', + '@angular/router': 'node:@angular/router/bundles/router.umd.js', '@angular/animations/browser': 'node:@angular/animations/bundles/animations-browser.umd.js', - '@angular/platform-browser': 'node:@angular/platform-browser/bundles/platform-browser.umd.js', '@angular/platform-browser/animations': - 'node:@angular/platform-browser/bundles/platform-browser-animations.umd.js', + 'node:@angular/platform-browser/bundles/platform-browser-animations.umd', + '@angular/platform-browser': + 'node:@angular/platform-browser/bundles/platform-browser.umd.js', '@angular/platform-browser-dynamic': 'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', - '@angular/material': 'dist/bundles/material.umd.js', - '@angular/material-moment-adapter': 'dist/bundles/material-moment-adapter.umd.js', - '@angular/cdk': 'dist/bundles/cdk.umd.js', - '@angular/cdk/a11y': 'dist/bundles/cdk-a11y.umd.js', - '@angular/cdk/bidi': 'dist/bundles/cdk-bidi.umd.js', - '@angular/cdk/coercion': 'dist/bundles/cdk-coercion.umd.js', - '@angular/cdk/collections': 'dist/bundles/cdk-collections.umd.js', - '@angular/cdk/keycodes': 'dist/bundles/cdk-keycodes.umd.js', - '@angular/cdk/observers': 'dist/bundles/cdk-observers.umd.js', - '@angular/cdk/overlay': 'dist/bundles/cdk-overlay.umd.js', - '@angular/cdk/platform': 'dist/bundles/cdk-platform.umd.js', - '@angular/cdk/portal': 'dist/bundles/cdk-portal.umd.js', - '@angular/cdk/rxjs': 'dist/bundles/cdk-rxjs.umd.js', - '@angular/cdk/scrolling': 'dist/bundles/cdk-scrolling.umd.js', - '@angular/cdk/stepper': 'dist/bundles/cdk-stepper.umd.js', - '@angular/cdk/table': 'dist/bundles/cdk-table.umd.js', - '@angular/cdk/testing': 'dist/bundles/cdk-testing.umd.js', + // TODO(devversion): replace once the index.ts file for the Material package has been added. + '@angular/material': 'dist/packages/material/public_api.js', + '@angular/cdk': 'dist/packages/cdk/index.js', + '@angular/cdk/a11y': 'dist/packages/cdk/a11y/index.js', + '@angular/cdk/bidi': 'dist/packages/cdk/bidi/index.js', + '@angular/cdk/coercion': 'dist/packages/cdk/coercion/index.js', + '@angular/cdk/collections': 'dist/packages/cdk/collections/index.js', + '@angular/cdk/keycodes': 'dist/packages/cdk/keycodes/index.js', + '@angular/cdk/observers': 'dist/packages/cdk/observers/index.js', + '@angular/cdk/overlay': 'dist/packages/cdk/overlay/index.js', + '@angular/cdk/platform': 'dist/packages/cdk/platform/index.js', + '@angular/cdk/portal': 'dist/packages/cdk/portal/index.js', + '@angular/cdk/rxjs': 'dist/packages/cdk/rxjs/index.js', + '@angular/cdk/scrolling': 'dist/packages/cdk/scrolling/index.js', + '@angular/cdk/stepper': 'dist/packages/cdk/stepper/index.js', + '@angular/cdk/table': 'dist/packages/cdk/table/index.js', + + '@angular/material/autocomplete': 'dist/packages/material/autocomplete/index.js', + '@angular/material/button': 'dist/packages/material/button/index.js', + '@angular/material/button-toggle': 'dist/packages/material/button-toggle/index.js', + '@angular/material/card': 'dist/packages/material/card/index.js', + '@angular/material/checkbox': 'dist/packages/material/checkbox/index.js', + '@angular/material/chips': 'dist/packages/material/chips/index.js', + '@angular/material/core': 'dist/packages/material/core/index.js', + '@angular/material/datepicker': 'dist/packages/material/datepicker/index.js', + '@angular/material/dialog': 'dist/packages/material/dialog/index.js', + '@angular/material/expansion': 'dist/packages/material/expansion/index.js', + '@angular/material/form-field': 'dist/packages/material/form-field/index.js', + '@angular/material/grid-list': 'dist/packages/material/grid-list/index.js', + '@angular/material/icon': 'dist/packages/material/icon/index.js', + '@angular/material/input': 'dist/packages/material/input/index.js', + '@angular/material/list': 'dist/packages/material/list/index.js', + '@angular/material/menu': 'dist/packages/material/menu/index.js', + '@angular/material/paginator': 'dist/packages/material/paginator/index.js', + '@angular/material/progress-bar': 'dist/packages/material/progress-bar/index.js', + '@angular/material/progress-spinner': 'dist/packages/material/progress-spinner/index.js', + '@angular/material/radio': 'dist/packages/material/radio/index.js', + '@angular/material/select': 'dist/packages/material/select/index.js', + '@angular/material/sidenav': 'dist/packages/material/sidenav/index.js', + '@angular/material/slide-toggle': 'dist/packages/material/slide-toggle/index.js', + '@angular/material/slider': 'dist/packages/material/slider/index.js', + '@angular/material/snack-bar': 'dist/packages/material/snack-bar/index.js', + '@angular/material/sort': 'dist/packages/material/sort/index.js', + '@angular/material/stepper': 'dist/packages/material/stepper/index.js', + '@angular/material/table': 'dist/packages/material/table/index.js', + '@angular/material/tabs': 'dist/packages/material/tabs/index.js', + '@angular/material/toolbar': 'dist/packages/material/toolbar/index.js', + '@angular/material/tooltip': 'dist/packages/material/tooltip/index.js', }, packages: { // Thirdparty barrels. - 'rxjs': { main: 'index' }, + 'rxjs': {main: 'index'}, + // Set the default extension for the root package, because otherwise the demo-app can't // be built within the production mode. Due to missing file extensions. '.': { diff --git a/tools/gulp/packages.ts b/tools/gulp/packages.ts index 890c435f52ad..4186ee478d9e 100644 --- a/tools/gulp/packages.ts +++ b/tools/gulp/packages.ts @@ -4,8 +4,7 @@ import {join} from 'path'; export const cdkPackage = new BuildPackage('cdk'); export const materialPackage = new BuildPackage('material', [cdkPackage]); export const examplesPackage = new BuildPackage('material-examples', [materialPackage, cdkPackage]); -export const momentAdapterPackage = new BuildPackage('material-moment-adapter', - [materialPackage, cdkPackage]); +export const momentAdapterPackage = new BuildPackage('material-moment-adapter', [materialPackage]); // The material package re-exports its secondary entry-points at the root so that all of the // components can still be imported through `@angular/material`. diff --git a/tools/gulp/tasks/aot.ts b/tools/gulp/tasks/aot.ts index 425e95bebccd..379986f49336 100644 --- a/tools/gulp/tasks/aot.ts +++ b/tools/gulp/tasks/aot.ts @@ -32,7 +32,7 @@ task('aot:copy-release', () => { }); /** Build the demo-app and a release to confirm that the library is AOT-compatible. */ -task('aot:build', sequenceTask('aot:deps', 'aot:compiler-cli')); +task('aot:build', sequenceTask('clean', 'aot:deps', 'aot:compiler-cli')); /** Build the demo-app and a release to confirm that the library is AOT-compatible. */ task('aot:compiler-cli', execNodeTask( diff --git a/tools/gulp/tasks/development.ts b/tools/gulp/tasks/development.ts index cb3cec505951..1774098b4095 100644 --- a/tools/gulp/tasks/development.ts +++ b/tools/gulp/tasks/development.ts @@ -1,9 +1,10 @@ import {task} from 'gulp'; -import {tsBuildTask, copyTask, buildAppTask, serverTask} from '../util/task_helpers'; +import {tsBuildTask, copyTask, serverTask} from '../util/task_helpers'; import {join} from 'path'; import { buildConfig, copyFiles, buildScssTask, sequenceTask, watchFiles } from 'material2-build-tools'; +import {cdkPackage, materialPackage, momentAdapterPackage} from '../packages'; // These imports don't have any typings provided. const firebaseTools = require('firebase-tools'); @@ -16,9 +17,6 @@ const bundlesDir = join(outputDir, 'bundles'); const appDir = join(packagesDir, 'demo-app'); const outDir = join(outputDir, 'packages', 'demo-app'); -/** Path to the output of the Material package. */ -const materialOutPath = join(outDir, 'packages', 'material'); - /** Array of vendors that are required to serve the demo-app. */ const appVendors = [ '@angular', 'systemjs', 'zone.js', 'rxjs', 'hammerjs', 'core-js', 'web-animations-js', 'moment', @@ -32,9 +30,13 @@ task(':watch:devapp', () => { watchFiles(join(appDir, '**/*.scss'), [':build:devapp:scss']); watchFiles(join(appDir, '**/*.html'), [':build:devapp:assets']); - // The themes for the demo-app are built by the demo-app using the SCSS mixins from Material. - // Therefore when SCSS files have been changed, the custom theme needs to be rebuilt. - watchFiles(join(materialOutPath, '**/*.scss'), [':build:devapp:scss']); + // Custom watchers for the CDK, Material and Moment adapter package. This is necessary because + // we only want to build the package as a single entry-point (using the tests task). + watchFiles(join(cdkPackage.sourceDir, '**/*'), ['cdk:build-no-bundles']); + watchFiles(join(materialPackage.sourceDir, '**/!(*.scss)'), ['material:build-no-bundles']); + watchFiles(join(materialPackage.sourceDir, '**/*.scss'), [':build:devapp:material-with-styles']); + watchFiles(join(momentAdapterPackage.sourceDir, '**/*'), + ['material-moment-adapter:build-no-bundles']); }); /** Path to the demo-app tsconfig file. */ @@ -43,19 +45,27 @@ const tsconfigPath = join(appDir, 'tsconfig-build.json'); task(':build:devapp:ts', tsBuildTask(tsconfigPath)); task(':build:devapp:scss', buildScssTask(outDir, appDir)); task(':build:devapp:assets', copyTask(appDir, outDir)); -task('build:devapp', buildAppTask('devapp')); - task(':serve:devapp', serverTask(outDir, true)); -task('serve:devapp', ['build:devapp'], sequenceTask( - [':serve:devapp', 'material:watch', ':watch:devapp'] +// The themes for the demo-app are built by using the SCSS mixins from Material. +// Therefore when SCSS files have been changed, the custom theme needs to be rebuilt. +task(':build:devapp:material-with-styles', sequenceTask( + 'material:build-no-bundles', ':build:devapp:scss' )); +task('build:devapp', sequenceTask( + ['material-moment-adapter:build-no-bundles', ':build:devapp:assets'], + [':build:devapp:scss', ':build:devapp:ts'] +)); + +task('serve:devapp', ['build:devapp'], sequenceTask([':serve:devapp', ':watch:devapp'])); + /** Task that copies all vendors into the demo-app package. Allows hosting the app on firebase. */ task('stage-deploy:devapp', ['build:devapp'], () => { copyFiles(join(projectDir, 'node_modules'), vendorGlob, join(outDir, 'node_modules')); copyFiles(bundlesDir, '*.+(js|map)', join(outDir, 'dist/bundles')); - copyFiles(materialOutPath, '**/prebuilt/*.+(css|map)', join(outDir, 'dist/packages/material')); + copyFiles(materialPackage.outputDir, '**/prebuilt/*.+(css|map)', + join(outDir, 'dist/packages/material')); }); /** diff --git a/tools/gulp/tasks/unit-test.ts b/tools/gulp/tasks/unit-test.ts index 210f0f8b0929..3c70bd50f68d 100644 --- a/tools/gulp/tasks/unit-test.ts +++ b/tools/gulp/tasks/unit-test.ts @@ -12,7 +12,7 @@ task(':test:build', sequenceTask( 'clean', // Build tests for all different packages by just building the tests of the moment-adapter // package. All dependencies of that package (material, cdk) will be built as well. - 'material-moment-adapter:build-tests' + 'material-moment-adapter:build-no-bundles' )); /** diff --git a/tools/gulp/util/task_helpers.ts b/tools/gulp/util/task_helpers.ts index 8a109e8ae27b..2613cd101786 100644 --- a/tools/gulp/util/task_helpers.ts +++ b/tools/gulp/util/task_helpers.ts @@ -2,7 +2,7 @@ import * as child_process from 'child_process'; import * as fs from 'fs'; import * as gulp from 'gulp'; import * as path from 'path'; -import {buildConfig, sequenceTask} from 'material2-build-tools'; +import {buildConfig} from 'material2-build-tools'; /* Those imports lack typings. */ const gulpClean = require('gulp-clean'); @@ -122,21 +122,6 @@ export function cleanTask(glob: string) { return () => gulp.src(glob, { read: false }).pipe(gulpClean(null)); } - -/** Build an task that depends on all application build tasks. */ -export function buildAppTask(appName: string) { - const buildTasks = ['ts', 'scss', 'assets'] - .map(taskName => `:build:${appName}:${taskName}`) - .filter(taskName => gulp.hasTask(taskName)); - - return sequenceTask( - // Build all required packages for serving the devapp by just building the moment-adapter - // package. All dependencies of that package (material, cdk) will be built automatically. - 'material-moment-adapter:clean-build', - [...buildTasks] - ); -} - /** * Create a task that serves a given directory in the project. * The server rewrites all node_module/ or dist/ requests to the correct directory. diff --git a/tools/package-tools/gulp/build-tasks-gulp.ts b/tools/package-tools/gulp/build-tasks-gulp.ts index 94e610891175..39731bfed111 100644 --- a/tools/package-tools/gulp/build-tasks-gulp.ts +++ b/tools/package-tools/gulp/build-tasks-gulp.ts @@ -52,9 +52,9 @@ export function createPackageBuildTasks(buildPackage: BuildPackage) { `${taskName}:build:bundles`, )); - task(`${taskName}:build-tests`, sequenceTask( + task(`${taskName}:build-no-bundles`, sequenceTask( // Build all required tests before building. - ...dependencyNames.map(pkgName => `${pkgName}:build-tests`), + ...dependencyNames.map(pkgName => `${pkgName}:build-no-bundles`), // Build the ESM output that includes all test files. Also build assets for the package. [`${taskName}:build:esm:tests`, `${taskName}:assets`], // Inline assets into ESM output. diff --git a/tools/package-tools/gulp/watch-files.ts b/tools/package-tools/gulp/watch-files.ts index 174badf9caaa..73f34dfe23e1 100644 --- a/tools/package-tools/gulp/watch-files.ts +++ b/tools/package-tools/gulp/watch-files.ts @@ -1,13 +1,11 @@ import {watch} from 'gulp'; import {triggerLivereload} from './trigger-livereload'; -/** Options that will be passed to the watch function of Gulp.*/ -const gulpWatchOptions = { debounceDelay: 700 }; - /** * Function that watches a set of file globs and runs given Gulp tasks if a given file changes. * By default the livereload server will be also called on file change. */ -export function watchFiles(fileGlob: string | string[], tasks: string[], livereload = true) { - watch(fileGlob, gulpWatchOptions, [...tasks, () => livereload && triggerLivereload()]); +export function watchFiles(fileGlob: string | string[], tasks: string[], livereload = true, + debounceDelay = 700) { + watch(fileGlob, {debounceDelay}, [...tasks, () => livereload && triggerLivereload()]); } From 807ce38ae4bd8393fd9304e602b82de3c625b0b2 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:31:06 +0200 Subject: [PATCH 140/575] build: fix metadata exports for moment-adapter (#7272) Due to a re-export that uses the index shorthand, the exports inside of the bundled metadata file are empty. This seems to be caused by a bug in `@angular/compiler-cli`. A temporary fix is just using the expanded important. Fixes #7262 --- src/material-moment-adapter/public_api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material-moment-adapter/public_api.ts b/src/material-moment-adapter/public_api.ts index 8d50b96839d7..26149a398c2c 100644 --- a/src/material-moment-adapter/public_api.ts +++ b/src/material-moment-adapter/public_api.ts @@ -6,4 +6,4 @@ * found in the LICENSE file at https://angular.io/license */ -export * from './adapter'; +export * from './adapter/index'; From c54b83ba58ba963f9e240055c46440cb4244b398 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:31:55 +0200 Subject: [PATCH 141/575] chore: fix validate release task (#7359) Updates the `gulp validate-release` task to work with the current package structure. --- tools/gulp/tasks/validate-release.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/gulp/tasks/validate-release.ts b/tools/gulp/tasks/validate-release.ts index c538b0ed75ce..1c8a266865a2 100644 --- a/tools/gulp/tasks/validate-release.ts +++ b/tools/gulp/tasks/validate-release.ts @@ -37,7 +37,17 @@ task('validate-release:check-bundles', () => { /** Task that validates the given release package before releasing. */ function checkReleasePackage(packageName: string): string[] { - const bundlePath = join(releasesDir, packageName, '@angular', `${packageName}.js`); + return glob(join(releasesDir, packageName, 'esm2015/*.js')) + .reduce((failures: string[], bundlePath: string) => { + return failures.concat(checkEs2015ReleaseBundle(packageName, bundlePath)); + }, []); +} + +/** + * Checks an ES2015 bundle inside of a release package. Secondary entry-point bundles will be + * checked as well. + */ +function checkEs2015ReleaseBundle(packageName: string, bundlePath: string): string[] { const bundleContent = readFileSync(bundlePath, 'utf8'); let failures: string[] = []; From 128442db1c9df055da098bd7cc37a216aa9169b6 Mon Sep 17 00:00:00 2001 From: Will Howell Date: Thu, 28 Sep 2017 18:32:42 -0400 Subject: [PATCH 142/575] docs(bidi): update to secondary entry-points (#7332) --- guides/bidirectionality.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guides/bidirectionality.md b/guides/bidirectionality.md index 9b21647e416e..1b7bca1a2d76 100644 --- a/guides/bidirectionality.md +++ b/guides/bidirectionality.md @@ -9,9 +9,9 @@ All Angular Material components automatically reflect the LTR/RTL direction of their container. ### Reading the text-direction in your own components -`@angular/cdk` provides a `Directionality` injectable that can be used by any component +`@angular/cdk/bidi` provides a `Directionality` injectable that can be used by any component in your application. To consume this injectable, you must import `BidiModule` -from `@angular/cdk`. +from `@angular/cdk/bidi`. `Directionality` provides two useful properties: * `value`: the current text direction, either `'ltr'` or `'rtl'`. @@ -32,4 +32,4 @@ export class MyCustomComponent { }); } } -``` \ No newline at end of file +``` From 3bc9ae985429762c2d547ab44dbaaccdeabd9e7a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 00:33:13 +0200 Subject: [PATCH 143/575] build: add placeholder for Angular version (#7303) Adds the `0.0.0-NG` placeholder that will ensure that all published packages will have the same Angular requirements. --- build-config.js | 8 +++++++- src/cdk/package.json | 4 ++-- src/lib/package.json | 4 ++-- src/material-examples/package.json | 6 +++--- src/material-moment-adapter/package.json | 2 +- tools/package-tools/build-config.ts | 2 ++ tools/package-tools/version-placeholders.ts | 16 +++++++++++----- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/build-config.js b/build-config.js index 26b3f8199bc7..46438a76edb1 100644 --- a/build-config.js +++ b/build-config.js @@ -4,8 +4,13 @@ */ const {join} = require('path'); +const package = require('./package.json'); + /** Current version of the project*/ -const buildVersion = require('./package.json').version; +const buildVersion = package.version; + +/** Required Angular version for the project. */ +const angularVersion = package.dependencies['@angular/core']; /** License that will be placed inside of all created bundles. */ const buildLicense = `/** @@ -18,6 +23,7 @@ const buildLicense = `/** module.exports = { projectVersion: buildVersion, + angularVersion: angularVersion, projectDir: __dirname, packagesDir: join(__dirname, 'src'), outputDir: join(__dirname, 'dist'), diff --git a/src/cdk/package.json b/src/cdk/package.json index 58d20d0c69d9..b6345a26b6a7 100644 --- a/src/cdk/package.json +++ b/src/cdk/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://github.com/angular/material2#readme", "peerDependencies": { - "@angular/core": "^4.4.3", - "@angular/common": "^4.4.3" + "@angular/core": "0.0.0-NG", + "@angular/common": "0.0.0-NG" }, "dependencies": { "tslib": "^1.7.1" diff --git a/src/lib/package.json b/src/lib/package.json index 0f65801d568d..35915f831e4b 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -23,8 +23,8 @@ "homepage": "https://github.com/angular/material2#readme", "peerDependencies": { "@angular/cdk": "0.0.0-PLACEHOLDER", - "@angular/core": "^4.4.3", - "@angular/common": "^4.4.3" + "@angular/core": "0.0.0-NG", + "@angular/common": "0.0.0-NG" }, "dependencies": { "tslib": "^1.7.1" diff --git a/src/material-examples/package.json b/src/material-examples/package.json index bc7eb5584a7b..466b289923e1 100644 --- a/src/material-examples/package.json +++ b/src/material-examples/package.json @@ -24,9 +24,9 @@ "homepage": "https://github.com/angular/material2#readme", "peerDependencies": { "@angular/cdk": "0.0.0-PLACEHOLDER", - "@angular/core": "^4.4.3", - "@angular/common": "^4.4.3", - "@angular/http": "^4.4.3", + "@angular/core": "0.0.0-NG", + "@angular/common": "0.0.0-NG", + "@angular/http": "0.0.0-NG", "@angular/material": "0.0.0-PLACEHOLDER" }, "dependencies": { diff --git a/src/material-moment-adapter/package.json b/src/material-moment-adapter/package.json index 607510a6bb14..a7ac704cf2b9 100644 --- a/src/material-moment-adapter/package.json +++ b/src/material-moment-adapter/package.json @@ -17,7 +17,7 @@ "homepage": "https://github.com/angular/material2#readme", "peerDependencies": { "@angular/material": "0.0.0-PLACEHOLDER", - "@angular/core": "^4.4.3", + "@angular/core": "0.0.0-NG", "moment": "^2.18.1" }, "dependencies": { diff --git a/tools/package-tools/build-config.ts b/tools/package-tools/build-config.ts index 63229d97acf6..04f3411f1e6a 100644 --- a/tools/package-tools/build-config.ts +++ b/tools/package-tools/build-config.ts @@ -3,6 +3,8 @@ import {findBuildConfig} from './find-build-config'; export interface BuildConfig { /** Current version of the project. */ projectVersion: string; + /** Required Angular version for the project. */ + angularVersion: string; /** Path to the root of the project. */ projectDir: string; /** Path to the directory where all packages are living. */ diff --git a/tools/package-tools/version-placeholders.ts b/tools/package-tools/version-placeholders.ts index 497a8ea1da21..7af4c61dd06f 100644 --- a/tools/package-tools/version-placeholders.ts +++ b/tools/package-tools/version-placeholders.ts @@ -6,7 +6,13 @@ import {spawnSync} from 'child_process'; /** Variable that is set to the string for version placeholders. */ const versionPlaceholderText = '0.0.0-PLACEHOLDER'; +/** Placeholder that will be replaced with the required Angular version. */ +const ngVersionPlaceholderText = '0.0.0-NG'; + /** RegExp that matches version placeholders inside of a file. */ +const ngVersionPlaceholderRegex = new RegExp(ngVersionPlaceholderText, 'g'); + +/** Expression that matches Angular version placeholders within a file. */ const versionPlaceholderRegex = new RegExp(versionPlaceholderText, 'g'); /** @@ -21,9 +27,9 @@ export function replaceVersionPlaceholders(packageDir: string) { // Walk through every file that contains version placeholders and replace those with the current // version of the root package.json file. files.forEach(filePath => { - let fileContent = readFileSync(filePath, 'utf-8'); - - fileContent = fileContent.replace(versionPlaceholderRegex, buildConfig.projectVersion); + const fileContent = readFileSync(filePath, 'utf-8') + .replace(ngVersionPlaceholderRegex, buildConfig.angularVersion) + .replace(versionPlaceholderRegex, buildConfig.projectVersion); writeFileSync(filePath, fileContent); }); @@ -43,12 +49,12 @@ function buildPlaceholderFindCommand(packageDir: string) { if (platform() === 'win32') { return { binary: 'findstr', - args: ['/msi', `/c:${versionPlaceholderText}`, `${packageDir}\\*`] + args: ['/msi', `"${ngVersionPlaceholderText} ${versionPlaceholderText}"`, `${packageDir}\\*`] }; } else { return { binary: 'grep', - args: ['-ril', versionPlaceholderText, packageDir] + args: ['-ril', `"${ngVersionPlaceholderText}\\|${versionPlaceholderText}"`, packageDir] }; } } From 7cb7f384f5373495838628b5ac1ef43e655b1144 Mon Sep 17 00:00:00 2001 From: Will Howell Date: Thu, 28 Sep 2017 18:33:31 -0400 Subject: [PATCH 144/575] docs(tabs): fix inconsistency in tab-nav snippet (#7295) Also escapes a couple inline code elements --- src/lib/tabs/tabs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/tabs/tabs.md b/src/lib/tabs/tabs.md index 44eae40a5ddf..2a6f7465c007 100644 --- a/src/lib/tabs/tabs.md +++ b/src/lib/tabs/tabs.md @@ -66,17 +66,17 @@ provides a tab-like UI for navigating between routes.
- {{tabLink.label}} + {{link.label}}
``` -The tab-nav-bar is not tied to any particular router; it works with normal `` elements and uses +The `tab-nav-bar` is not tied to any particular router; it works with normal `` elements and uses the `active` property to determine which tab is currently active. The corresponding `` can be placed anywhere in the view. @@ -91,4 +91,4 @@ Tabs without text or labels should be given a meaningful label via `aria-label` |----------------------|----------------------------| | `LEFT_ARROW` | Move focus to previous tab | | `RIGHT_ARROW` | Move focus to next tab | -| `SPACE` or 'ENTER' | Switch to focused tab | +| `SPACE` or `ENTER` | Switch to focused tab | From 3982cc8b60facd3c1d6baf493c8de955ccd0682d Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 00:33:44 +0200 Subject: [PATCH 145/575] chore(select): avoid test flakes due to sub-pixel deviations (#7281) Fixes some tests that were failing when they're run against Chrome on Windows due to sub-pixel measurement differences. --- src/lib/select/select.spec.ts | 46 +++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 7f34d929f08c..5285279db833 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -1042,10 +1042,14 @@ describe('MatSelect', () => { // Extra trigger height beyond the font size caused by the fact that the line-height is // greater than 1em. const triggerExtraLineSpaceAbove = (1 - triggerLineHeightEm) * triggerFontSize / 2; + const topDifference = Math.floor(optionTop) - + Math.floor(triggerTop - triggerFontSize - triggerExtraLineSpaceAbove); - expect(Math.floor(optionTop)) - .toBe(Math.floor(triggerTop - triggerFontSize - triggerExtraLineSpaceAbove), - `Expected trigger to align with option ${index}.`); + // Expect the coordinates to be within a pixel of each other. We can't rely on comparing + // the exact value, because different browsers report the various sizes with slight (< 1px) + // deviations. + expect(Math.abs(topDifference) < 2) + .toBe(true, `Expected trigger to align with option ${index}.`); // For the animation to start at the option's center, its origin must be the distance // from the top of the overlay to the option top + half the option height (48/2 = 24). @@ -1218,8 +1222,8 @@ describe('MatSelect', () => { const scrollContainer = document.querySelector('.cdk-overlay-pane .mat-select-panel')!; fixture.whenStable().then(() => { - expect(scrollContainer.scrollTop) - .toEqual(idealScrollTop + 5, + expect(Math.ceil(scrollContainer.scrollTop)) + .toEqual(Math.ceil(idealScrollTop + 5), `Expected panel to adjust scroll position to fit in viewport.`); checkTriggerAlignedWithOption(4); @@ -1280,9 +1284,14 @@ describe('MatSelect', () => { // (56px from the bottom of the screen - 8px padding = 48px) // and the height of the panel below the option (113px). // 113px - 48px = 75px difference. Original scrollTop 88px - 75px = 23px - expect(scrollContainer.scrollTop) - .toEqual(idealScrollTop - expectedExtraScroll, - `Expected panel to adjust scroll position to fit in viewport.`); + const difference = Math.ceil(scrollContainer.scrollTop) - + Math.ceil(idealScrollTop - expectedExtraScroll); + + // Note that different browser/OS combinations report the different dimensions with + // slight deviations (< 1px). We round the expectation and check that the values + // are within a pixel of each other to avoid flakes. + expect(Math.abs(difference) < 2) + .toBe(true, `Expected panel to adjust scroll position to fit in viewport.`); checkTriggerAlignedWithOption(4); }); @@ -1309,9 +1318,12 @@ describe('MatSelect', () => { // Expect no scroll to be attempted expect(scrollContainer.scrollTop).toEqual(0, `Expected panel not to be scrolled.`); - expect(Math.floor(overlayBottom)) - .toEqual(Math.floor(triggerBottom), - `Expected trigger bottom to align with overlay bottom.`); + const difference = Math.floor(overlayBottom) - Math.floor(triggerBottom); + + // Check that the values are within a pixel of each other. This avoids sub-pixel + // deviations between OS and browser versions. + expect(Math.abs(difference) < 2) + .toEqual(true, `Expected trigger bottom to align with overlay bottom.`); expect(fixture.componentInstance.select._transformOrigin) .toContain(`bottom`, `Expected panel animation to originate at the bottom.`); @@ -1521,10 +1533,12 @@ describe('MatSelect', () => { const overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane')!; const triggerBottom = trigger.getBoundingClientRect().bottom; const overlayBottom = overlayPane.getBoundingClientRect().bottom; + const difference = Math.floor(overlayBottom) - Math.floor(triggerBottom); - expect(Math.floor(overlayBottom)) - .toEqual(Math.floor(triggerBottom), - `Expected trigger bottom to align with overlay bottom.`); + // Check that the values are within a pixel of each other. This avoids sub-pixel + // deviations between OS and browser versions. + expect(Math.abs(difference) < 2) + .toEqual(true, `Expected trigger bottom to align with overlay bottom.`); }); it('should fall back to "below" positioning properly when scrolled', () => { @@ -1731,8 +1745,8 @@ describe('MatSelect', () => { expect(difference) .toBeLessThan(0.1, 'Expected trigger to align with the first option.'); } else { - expect(optionTop + (menuItemHeight - triggerHeight) / 2) - .toBe(triggerTop, 'Expected trigger to align with the first option.'); + expect(Math.floor(optionTop + (menuItemHeight - triggerHeight) / 2)) + .toBe(Math.floor(triggerTop), 'Expected trigger to align with the first option.'); } }); })); From 1ac3fd25c97728224a2eac9e86a632fe0ed01b6e Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:39:40 +0200 Subject: [PATCH 146/575] chore: remove screenshot timeout check (#7206) Removes the screenshot timeout check, which will cancel the screenshot diff if the last action took longer than 6 minutes. Travis CI will automatically cancel the job if there was no console output for 10 minutes. --- tools/gulp/tasks/screenshots.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tools/gulp/tasks/screenshots.ts b/tools/gulp/tasks/screenshots.ts index e7475fc8d155..fd5ffbd1fffa 100644 --- a/tools/gulp/tasks/screenshots.ts +++ b/tools/gulp/tasks/screenshots.ts @@ -34,12 +34,6 @@ const FIREBASE_IMAGE = `${TEMP_FOLDER}/screenshot/images`; const FIREBASE_DATA_GOLDENS = `screenshot/goldens`; const FIREBASE_STORAGE_GOLDENS = 'goldens'; -/** Time in ms until the process will be exited if the last action took too long (6 minutes). */ -const lastActionTimeout = 1000 * 60 * 6; - -/** Time in ms that specifies how often the last action should be checked (45 seconds). */ -const lastActionRefreshInterval = 1000 * 45; - /** Task which upload screenshots generated from e2e test. */ task('screenshots', () => { const prNumber = process.env['TRAVIS_PULL_REQUEST']; @@ -52,16 +46,6 @@ task('screenshots', () => { const database = firebaseApp.database(); let lastActionTime = Date.now(); - // If the last action of the task takes longer than 6 minutes, close the firebase connection. - const timeoutId = setInterval(() => { - if (lastActionTime + lastActionTimeout <= Date.now()) { - clearTimeout(timeoutId); - console.error('Last action for screenshot tests did not finish in ' + - (lastActionTimeout / 1000 / 60) + ' minutes. Closing Firebase connection...'); - return firebaseApp.delete().then(() => process.exit(1)); - } - }, lastActionRefreshInterval); - console.log(` Starting screenshots task with results from e2e task...`); return uploadTravisJobInfo(database, prNumber) @@ -89,13 +73,11 @@ task('screenshots', () => { .then(() => { console.log(` Uploading results done (took ${Date.now() - lastActionTime}ms)`); firebaseApp.delete(); - clearTimeout(timeoutId); }) .catch((err: any) => { console.error(` Screenshot tests encountered an error!`); console.error(err); firebaseApp.delete(); - clearTimeout(timeoutId); }); } }); From afa92a8d6085efc9221dc389e995c743695b5d75 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:40:16 +0200 Subject: [PATCH 147/575] build: copy stylesheets to release output (#7204) * Copies stylesheets of secondary entry-points to the root of the release output * Better deduping for the `_theming.scss` file (currently includes multiple `cdk-a11y` mixins) * Removes unused `cdk-a11y` import in the `button-toggle` component. * Moves some logic out of the `BuildPackage` class (in favor of readability) --- src/cdk/a11y/a11y-prebuilt.scss | 3 + src/lib/button/button.scss | 2 +- src/lib/chips/chips.scss | 2 +- src/lib/core/option/_option.scss | 2 +- src/lib/menu/menu.scss | 3 +- tools/gulp/packages.ts | 5 ++ tools/gulp/tasks/material-release.ts | 4 +- tools/package-tools/build-package.ts | 65 ++++------------------ tools/package-tools/build-release.ts | 14 +++++ tools/package-tools/compile-entry-point.ts | 48 ++++++++++++++++ 10 files changed, 88 insertions(+), 60 deletions(-) create mode 100644 src/cdk/a11y/a11y-prebuilt.scss create mode 100644 tools/package-tools/compile-entry-point.ts diff --git a/src/cdk/a11y/a11y-prebuilt.scss b/src/cdk/a11y/a11y-prebuilt.scss new file mode 100644 index 000000000000..e30963e8ccf9 --- /dev/null +++ b/src/cdk/a11y/a11y-prebuilt.scss @@ -0,0 +1,3 @@ +@import './a11y'; + +@include cdk-a11y(); diff --git a/src/lib/button/button.scss b/src/lib/button/button.scss index 277c0be3f9a7..f698b24bbeea 100644 --- a/src/lib/button/button.scss +++ b/src/lib/button/button.scss @@ -1,8 +1,8 @@ // TODO(jelbourn): Measure perf benefits for translate3d and will-change. // TODO(jelbourn): Figure out if anchor hover underline actually happens in any browser. @import 'button-base'; -@import '../../cdk/a11y/a11y'; @import '../core/style/layout-common'; +@import '../../cdk/a11y/a11y'; .mat-button, .mat-icon-button { @extend %mat-button-base; diff --git a/src/lib/chips/chips.scss b/src/lib/chips/chips.scss index fc1b13a851b5..ba5a529a3767 100644 --- a/src/lib/chips/chips.scss +++ b/src/lib/chips/chips.scss @@ -1,5 +1,5 @@ -@import '../../cdk/a11y/a11y'; @import '../core/style/elevation'; +@import '../../cdk/a11y/a11y'; $mat-chip-vertical-padding: 7px; $mat-chip-horizontal-padding: 12px; diff --git a/src/lib/core/option/_option.scss b/src/lib/core/option/_option.scss index 6cbae7e330ed..c87b65e598d5 100644 --- a/src/lib/core/option/_option.scss +++ b/src/lib/core/option/_option.scss @@ -1,7 +1,7 @@ @import '../style/menu-common'; @import '../style/vendor-prefixes'; -@import '../../../cdk/a11y/a11y'; @import '../style/layout-common'; +@import '../../../cdk/a11y/a11y'; /** * This mixin contains shared option styles between the select and diff --git a/src/lib/menu/menu.scss b/src/lib/menu/menu.scss index 5fcc8a889650..b2173add544b 100644 --- a/src/lib/menu/menu.scss +++ b/src/lib/menu/menu.scss @@ -1,10 +1,9 @@ // TODO(kara): update vars for desktop when MD team responds - @import '../core/style/button-common'; @import '../core/style/layout-common'; @import '../core/style/menu-common'; -@import '../../cdk/a11y/a11y'; @import '../core/style/layout-common'; +@import '../../cdk/a11y/a11y'; $mat-menu-vertical-padding: 8px !default; $mat-menu-border-radius: 2px !default; diff --git a/tools/gulp/packages.ts b/tools/gulp/packages.ts index 4186ee478d9e..c65002dad845 100644 --- a/tools/gulp/packages.ts +++ b/tools/gulp/packages.ts @@ -12,3 +12,8 @@ materialPackage.exportsSecondaryEntryPointsAtRoot = true; // To avoid refactoring of the project the material package will map to the source path `lib/`. materialPackage.sourceDir = join(buildConfig.packagesDir, 'lib'); + +// Some CDK secondary entry-points include SCSS files that should be exposed individually at the +// release output root. This is different in the Material package because here a full SCSS bundle +// will be generated. +cdkPackage.copySecondaryEntryPointStylesToRoot = true; diff --git a/tools/gulp/tasks/material-release.ts b/tools/gulp/tasks/material-release.ts index 201ab1c17991..be3a259e1db4 100644 --- a/tools/gulp/tasks/material-release.ts +++ b/tools/gulp/tasks/material-release.ts @@ -22,8 +22,8 @@ const themingEntryPointPath = join(sourceDir, 'core', 'theming', '_all-theme.scs const themingBundlePath = join(releasePath, '_theming.scss'); // Matches all pre-built theme css files const prebuiltThemeGlob = join(outputDir, '**/theming/prebuilt/*.css?(.map)'); -// Matches all SCSS files in the library. -const allScssGlob = join(sourceDir, '**/*.scss'); +// Matches all SCSS files in the different packages. +const allScssGlob = join(buildConfig.packagesDir, '**/*.scss'); /** * Overwrite the release task for the material package. The material release will include special diff --git a/tools/package-tools/build-package.ts b/tools/package-tools/build-package.ts index 381955c58f7c..ba6b32276089 100644 --- a/tools/package-tools/build-package.ts +++ b/tools/package-tools/build-package.ts @@ -1,13 +1,9 @@ -import {red} from 'chalk'; -import {spawn} from 'child_process'; -import {readFileSync, writeFileSync} from 'fs'; -import {sync as glob} from 'glob'; -import {join, resolve as resolvePath} from 'path'; +import {join} from 'path'; import {main as ngc} from '@angular/tsc-wrapped'; import {PackageBundler} from './build-bundles'; import {buildConfig} from './build-config'; import {getSecondaryEntryPointsForPackage} from './secondary-entry-points'; - +import {compileEntryPoint, renamePrivateReExportsToBeUnique} from './compile-entry-point'; const {packagesDir, outputDir} = buildConfig; @@ -17,9 +13,6 @@ const buildTsconfigName = 'tsconfig-build.json'; /** Name of the tsconfig file that is responsible for building the tests. */ const testsTsconfigName = 'tsconfig-tests.json'; -/** Incrementing ID counter. */ -let nextId = 0; - export class BuildPackage { /** Path to the package sources. */ sourceDir: string; @@ -30,6 +23,9 @@ export class BuildPackage { /** Whether this package will re-export its secondary-entry points at the root module. */ exportsSecondaryEntryPointsAtRoot = false; + /** Whether the secondary entry-point styles should be copied to the release output. */ + copySecondaryEntryPointStylesToRoot = false; + /** Path to the entry file of the package in the output directory. */ readonly entryFilePath: string; @@ -39,22 +35,22 @@ export class BuildPackage { /** Path to the tsconfig file, which will be used to build the tests. */ private readonly tsconfigTests: string; - private _secondaryEntryPoints: string[]; - private _secondaryEntryPointsByDepth: string[][]; + /** Package bundler instance. */ + private bundler = new PackageBundler(this); /** Secondary entry-points partitioned by their build depth. */ private get secondaryEntryPointsByDepth(): string[][] { this.cacheSecondaryEntryPoints(); return this._secondaryEntryPointsByDepth; } - - private readonly bundler = new PackageBundler(this); + private _secondaryEntryPointsByDepth: string[][]; /** Secondary entry points for the package. */ get secondaryEntryPoints(): string[] { this.cacheSecondaryEntryPoints(); return this._secondaryEntryPoints; } + private _secondaryEntryPoints: string[]; constructor(public readonly name: string, public readonly dependencies: BuildPackage[] = []) { this.sourceDir = join(packagesDir, name); @@ -74,11 +70,11 @@ export class BuildPackage { // Depth 1: a11y, scrolling // Depth 2: overlay for (const entryPointGroup of this.secondaryEntryPointsByDepth) { - await Promise.all(entryPointGroup.map(p => this._compileEntryPoint(buildTsconfigName, p))); + await Promise.all(entryPointGroup.map(p => compileEntryPoint(this, buildTsconfigName, p))); } // Compile the primary entry-point. - await this._compileEntryPoint(buildTsconfigName); + await compileEntryPoint(this, buildTsconfigName); } /** Compiles the TypeScript test source files for the package. */ @@ -91,50 +87,13 @@ export class BuildPackage { await this.bundler.createBundles(); } - /** Compiles the TypeScript sources of a primary or secondary entry point. */ - private async _compileEntryPoint(tsconfigName: string, secondaryEntryPoint = '') { - const entryPointPath = join(this.sourceDir, secondaryEntryPoint); - const entryPointTsconfigPath = join(entryPointPath, tsconfigName); - - return new Promise((resolve, reject) => { - const ngcPath = resolvePath('./node_modules/.bin/ngc'); - const childProcess = spawn(ngcPath, ['-p', entryPointTsconfigPath], {shell: true}); - - // Pipe stdout and stderr from the child process. - childProcess.stdout.on('data', (data: any) => console.log(`${data}`)); - childProcess.stderr.on('data', (data: any) => console.error(red(`${data}`))); - - childProcess.on('exit', (exitCode: number) => exitCode === 0 ? resolve() : reject()); - }) - .catch(() => console.error(red(`Failed to compile ${secondaryEntryPoint}`))) - .then(() => this.renamePrivateReExportsToBeUnique(secondaryEntryPoint)); - } - /** Compiles the TypeScript sources of a primary or secondary entry point. */ private async _compileTestEntryPoint(tsconfigName: string, secondaryEntryPoint = '') { const entryPointPath = join(this.sourceDir, secondaryEntryPoint); const entryPointTsconfigPath = join(entryPointPath, tsconfigName); await ngc(entryPointTsconfigPath, {basePath: entryPointPath}); - this.renamePrivateReExportsToBeUnique(secondaryEntryPoint); - } - - /** Renames `ɵa`-style re-exports generated by Angular to be unique across compilation units. */ - private renamePrivateReExportsToBeUnique(secondaryEntryPoint = '') { - // When we compiled the typescript sources with ngc, we do entry-point individually. - // If the root-level module re-exports multiple of these entry-points, the private-export - // identifiers (e.g., `ɵa`) generated by ngc will collide. We work around this by suffixing - // each of these identifiers with an ID specific to this entry point. We make this - // replacement in the js, d.ts, and metadata output. - if (this.exportsSecondaryEntryPointsAtRoot && secondaryEntryPoint) { - const entryPointId = nextId++; - const outputPath = join(this.outputDir, secondaryEntryPoint); - glob(join(outputPath, '**/*.+(js|d.ts|metadata.json)')).forEach(filePath => { - let fileContent = readFileSync(filePath, 'utf-8'); - fileContent = fileContent.replace(/(ɵ[a-z]+)/g, `$1${entryPointId}`); - writeFileSync(filePath, fileContent, 'utf-8'); - }); - } + renamePrivateReExportsToBeUnique(this, secondaryEntryPoint); } /** Stores the secondary entry-points for this package if they haven't been computed already. */ diff --git a/tools/package-tools/build-release.ts b/tools/package-tools/build-release.ts index 9ddb0150f538..6eb7991e6869 100644 --- a/tools/package-tools/build-release.ts +++ b/tools/package-tools/build-release.ts @@ -54,6 +54,10 @@ export function composeRelease(buildPackage: BuildPackage) { createFilesForSecondaryEntryPoint(buildPackage, releasePath); } + if (buildPackage.copySecondaryEntryPointStylesToRoot) { + copySecondaryEntryPointStylesheets(buildPackage, releasePath); + } + if (buildPackage.exportsSecondaryEntryPointsAtRoot) { // Add re-exports to the root d.ts file to prevent errors of the form // "@angular/material/material has no exported member 'MATERIAL_SANITY_CHECKS." @@ -102,3 +106,13 @@ function createFilesForSecondaryEntryPoint(buildPackage: BuildPackage, releasePa createMetadataReexportFile(releasePath, `./${entryPointName}/index`, entryPointName); }); } + +/** Copies the stylesheets for secondary entry-points that generate one to the release output. */ +function copySecondaryEntryPointStylesheets(buildPackage: BuildPackage, releasePath: string) { + buildPackage.secondaryEntryPoints.forEach(entryPointName => { + const entryPointDir = join(buildPackage.outputDir, entryPointName); + + copyFiles(entryPointDir, `_${entryPointName}.scss`, releasePath); + copyFiles(entryPointDir, `${entryPointName}-prebuilt.css`, releasePath); + }); +} diff --git a/tools/package-tools/compile-entry-point.ts b/tools/package-tools/compile-entry-point.ts new file mode 100644 index 000000000000..40dd9b2d46b0 --- /dev/null +++ b/tools/package-tools/compile-entry-point.ts @@ -0,0 +1,48 @@ +import {join, resolve as resolvePath} from 'path'; +import {spawn} from 'child_process'; +import {writeFileSync, readFileSync} from 'fs'; +import {sync as glob} from 'glob'; +import {red} from 'chalk'; +import {BuildPackage} from './build-package'; + +/** Incrementing ID counter. */ +let nextId = 0; + +/** Compiles the TypeScript sources of a primary or secondary entry point. */ +export async function compileEntryPoint(buildPackage: BuildPackage, tsconfigName: string, + secondaryEntryPoint = '') { + const entryPointPath = join(buildPackage.sourceDir, secondaryEntryPoint); + const entryPointTsconfigPath = join(entryPointPath, tsconfigName); + + return new Promise((resolve, reject) => { + const ngcPath = resolvePath('./node_modules/.bin/ngc'); + const childProcess = spawn(ngcPath, ['-p', entryPointTsconfigPath], {shell: true}); + + // Pipe stdout and stderr from the child process. + childProcess.stdout.on('data', (data: any) => console.log(`${data}`)); + childProcess.stderr.on('data', (data: any) => console.error(red(`${data}`))); + + childProcess.on('exit', (exitCode: number) => exitCode === 0 ? resolve() : reject()); + }) + .catch(() => console.error(red(`Failed to compile ${secondaryEntryPoint}`))) + .then(() => renamePrivateReExportsToBeUnique(buildPackage, secondaryEntryPoint)); +} + +/** Renames `ɵa`-style re-exports generated by Angular to be unique across compilation units. */ +export function renamePrivateReExportsToBeUnique(buildPackage: BuildPackage, + secondaryEntryPoint = '') { + // When we compiled the typescript sources with ngc, we do entry-point individually. + // If the root-level module re-exports multiple of these entry-points, the private-export + // identifiers (e.g., `ɵa`) generated by ngc will collide. We work around this by suffixing + // each of these identifiers with an ID specific to this entry point. We make this + // replacement in the js, d.ts, and metadata output. + if (buildPackage.exportsSecondaryEntryPointsAtRoot && secondaryEntryPoint) { + const entryPointId = nextId++; + const outputPath = join(buildPackage.outputDir, secondaryEntryPoint); + glob(join(outputPath, '**/*.+(js|d.ts|metadata.json)')).forEach(filePath => { + let fileContent = readFileSync(filePath, 'utf-8'); + fileContent = fileContent.replace(/(ɵ[a-z]+)/g, `$1${entryPointId}`); + writeFileSync(filePath, fileContent, 'utf-8'); + }); + } +} From 13d0160c742cf834576407f9bfb4b8850dbeb949 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Thu, 28 Sep 2017 15:40:44 -0700 Subject: [PATCH 148/575] build: include typings/index in root metadata export (#7190) --- tools/package-tools/build-release.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/package-tools/build-release.ts b/tools/package-tools/build-release.ts index 6eb7991e6869..87f2c4668968 100644 --- a/tools/package-tools/build-release.ts +++ b/tools/package-tools/build-release.ts @@ -69,7 +69,7 @@ export function composeRelease(buildPackage: BuildPackage) { // re-exports everything. createMetadataReexportFile( releasePath, - buildPackage.secondaryEntryPoints.map(p => `./${p}`), + buildPackage.secondaryEntryPoints.concat(['typings/index']).map(p => `./${p}`), name); } } From 39c7b8124dfbdaa2db82cdcb0625b4579e3d97af Mon Sep 17 00:00:00 2001 From: tinayuangao Date: Fri, 29 Sep 2017 06:41:05 +0800 Subject: [PATCH 149/575] chore: make accessibility demo page focus goes to header after clicking on links (#7188) --- src/demo-app/a11y/a11y.html | 5 +++-- src/demo-app/a11y/a11y.ts | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/demo-app/a11y/a11y.html b/src/demo-app/a11y/a11y.html index fefa22fecac3..3a0f318264e9 100644 --- a/src/demo-app/a11y/a11y.html +++ b/src/demo-app/a11y/a11y.html @@ -2,11 +2,12 @@

Accessibility Demo

Skip navigation - + {{navItem.name}}
-
+
+

{{currentComponent}} Demo

diff --git a/src/demo-app/a11y/a11y.ts b/src/demo-app/a11y/a11y.ts index f522717c5b2e..c517d188282e 100644 --- a/src/demo-app/a11y/a11y.ts +++ b/src/demo-app/a11y/a11y.ts @@ -1,4 +1,5 @@ import {Component, ElementRef, ViewChild, ViewEncapsulation} from '@angular/core'; +import {NavigationEnd, Router} from '@angular/router'; @Component({ moduleId: module.id, @@ -16,7 +17,10 @@ export class AccessibilityHome {} preserveWhitespaces: false, }) export class AccessibilityDemo { + currentComponent: string = ''; + @ViewChild('maincontent') mainContent: ElementRef; + @ViewChild('header') sectionHeader: ElementRef; navItems = [ {name: 'Home', route: '.'}, @@ -44,8 +48,17 @@ export class AccessibilityDemo { {name: 'Tooltip', route: 'tooltip'}, ]; + constructor(private router: Router) { + router.events.subscribe(event => { + let nav = this.navItems.find(navItem => { + let fragments = (event as NavigationEnd).url.split('/'); + return fragments[fragments.length - 1] === navItem.route; + }); + this.currentComponent = nav ? nav.name : ''; + }); + } + skipNavigation() { - this.mainContent.nativeElement.scrollIntoView(); - this.mainContent.nativeElement.focus(); + (this.currentComponent ? this.sectionHeader : this.mainContent).nativeElement.focus(); } } From 3948381d64d5bc4b782510ff7be900b20a95ff9e Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:51:34 +0200 Subject: [PATCH 150/575] build: round payload size for comparison (#7174) In some cases the payload is still showing up in the CI even if there was no change to the library. This seems to be because the file sizes are not rounded and can sometimes be not very exact. Resulting in numbers like: `material_fesm_2014": 1004.1319999999998`. To have a better output in the GitHub statuses, the file size should be rounded --- tools/gulp/tasks/payload.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/gulp/tasks/payload.ts b/tools/gulp/tasks/payload.ts index 7c0023245749..70fd69962067 100644 --- a/tools/gulp/tasks/payload.ts +++ b/tools/gulp/tasks/payload.ts @@ -93,10 +93,10 @@ async function calculatePayloadDiff(database: firebaseAdmin.database.Database, c // Calculate the payload diffs by subtracting the previous size of the FESM ES2015 bundles. const cdkFullSize = currentPayload.cdk_fesm_2015; - const cdkDiff = cdkFullSize - previousPayload.cdk_fesm_2015; + const cdkDiff = roundFileSize(cdkFullSize - previousPayload.cdk_fesm_2015); const materialFullSize = currentPayload.material_fesm_2015; - const materialDiff = materialFullSize - previousPayload.material_fesm_2015; + const materialDiff = roundFileSize(materialFullSize - previousPayload.material_fesm_2015); // Set the Github statuses for the packages by sending a HTTP request to the dashboard functions. await Promise.all([ @@ -174,3 +174,8 @@ function getCommitFromPreviousPayloadUpload(): string { return spawnSync('git', ['rev-parse', process.env['TRAVIS_BRANCH']]).stdout.toString().trim(); } } + +/** Rounds the specified file size to two decimal places. */ +function roundFileSize(fileSize: number) { + return Math.round(fileSize * 100) / 100; +} From 248dee8265e6a82814a0bacc08e779776602b4b6 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 00:52:31 +0200 Subject: [PATCH 151/575] chore: remove cdk testing from rollup globals (#7169) Previously the `missingRollupGlobals` tslint rule checked every TS file in the `src/` directory. This meant that the `@angular/cdk/testing` package from spec files needs to be added there as well. With the recent switcht to Minimatch for our custom TSLint rules, the spec files are no longer linted and the testing package can be removed there. --- tools/package-tools/rollup-globals.ts | 8 ++------ tools/tslint-rules/tsLoaderRule.js | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/package-tools/rollup-globals.ts b/tools/package-tools/rollup-globals.ts index 3319cbb76465..e274f8d80498 100644 --- a/tools/package-tools/rollup-globals.ts +++ b/tools/package-tools/rollup-globals.ts @@ -42,7 +42,8 @@ export const rollupGlobals = { '@angular/common/testing': 'ng.common.testing', '@angular/http/testing': 'ng.http.testing', - + // Some packages are not really needed for the UMD bundles, but for the missingRollupGlobals rule. + '@angular/material-examples': 'ng.materialExamples', '@angular/material': 'ng.material', '@angular/cdk': 'ng.cdk', @@ -50,11 +51,6 @@ export const rollupGlobals = { ...rollupCdkEntryPoints, ...rollupMatEntryPoints, - // Some packages are not really needed for the UMD bundles, but for the missingRollupGlobals rule. - // TODO(devversion): remove by adding minimatch and better globbing to rules - '@angular/cdk/testing': 'ng.cdk.testing', - '@angular/material-examples': 'ng.materialExamples', - 'rxjs/BehaviorSubject': 'Rx', 'rxjs/Observable': 'Rx', 'rxjs/Subject': 'Rx', diff --git a/tools/tslint-rules/tsLoaderRule.js b/tools/tslint-rules/tsLoaderRule.js index 4ba565f1b9de..85cf80d6ea2a 100644 --- a/tools/tslint-rules/tsLoaderRule.js +++ b/tools/tslint-rules/tsLoaderRule.js @@ -10,4 +10,4 @@ require('ts-node').register({ // Add a noop rule so tslint doesn't complain. exports.Rule = class Rule extends Lint.Rules.AbstractRule { apply() {} -} +}; From c021e94fcec24bff89d93cbdeff62d82472f1452 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 01:05:46 +0200 Subject: [PATCH 152/575] chore(dashboard): http function to list pull requests with conflicts (#6675) Introduces a new http trigger in the Dashboard functions that returns all Pull Requests with merge conflicts. This allows us to show a list of PRs with merge conflicts in the dashboard. To ensure that the API calls are as fast as possible, the pull requests with conflicts are queried using Github's new GraphQL API. --- tools/dashboard/functions/functions.ts | 1 + .../dashboard/functions/github/github-api.ts | 22 ++++++++++ .../github/github-graphql-queries.ts | 43 +++++++++++++++++++ .../functions/github/github-status.ts | 30 +++---------- tools/dashboard/functions/package.json | 2 + .../functions/pull-requests-with-conflicts.ts | 13 ++++++ 6 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 tools/dashboard/functions/github/github-api.ts create mode 100644 tools/dashboard/functions/github/github-graphql-queries.ts create mode 100644 tools/dashboard/functions/pull-requests-with-conflicts.ts diff --git a/tools/dashboard/functions/functions.ts b/tools/dashboard/functions/functions.ts index ff59155dee72..82583391d20d 100644 --- a/tools/dashboard/functions/functions.ts +++ b/tools/dashboard/functions/functions.ts @@ -1 +1,2 @@ export {payloadGithubStatus} from './payload-github-status'; +export {pullRequestsWithConflicts} from './pull-requests-with-conflicts'; diff --git a/tools/dashboard/functions/github/github-api.ts b/tools/dashboard/functions/github/github-api.ts new file mode 100644 index 000000000000..0790045103cf --- /dev/null +++ b/tools/dashboard/functions/github/github-api.ts @@ -0,0 +1,22 @@ +import {GraphQLClient} from 'graphql-request'; +import {config} from 'firebase-functions'; +import * as GithubApi from 'github'; + +/** API token for the Github repository. Required to set the github status on commits and PRs. */ +const githubAccessToken = config().secret.github; + +/** API Endpoint for the Github API v4 using GraphQL. */ +const githubApiV4Endpoint = 'https://api.github.com/graphql'; + +/** Export the GitHub V3 API instance that is authenticated. */ +export const githubApiV3 = new GithubApi(); + +/** Export the GraphQL client that can be used to query the Github API v4. */ +export const githubApiV4 = new GraphQLClient(githubApiV4Endpoint, { + headers: { + Authorization: `Bearer ${githubAccessToken}`, + } +}); + +// Authenticate the Github API package with the user token. +githubApiV3.authenticate({type: 'token', token: githubAccessToken}); diff --git a/tools/dashboard/functions/github/github-graphql-queries.ts b/tools/dashboard/functions/github/github-graphql-queries.ts new file mode 100644 index 000000000000..a0aa582ce196 --- /dev/null +++ b/tools/dashboard/functions/github/github-graphql-queries.ts @@ -0,0 +1,43 @@ +import {githubApiV4} from './github-api'; + +/** GraphQL query that finds all Pull Requests and their mergeable state. */ +const getOpenPullRequestsWithMergeableStateQuery = ` + query getOpenPullRequestsWithMergeableState($lastCursor: String) { + repository(owner: "angular", name: "material2") { + pullRequests(states: OPEN, first: 100, after: $lastCursor) { + pageInfo { + hasNextPage, + endCursor + } + nodes { + number, + mergeable + } + } + } + }`; + +/** Pull Request node that will be returned by the Github V4 API. */ +export interface PullRequestWithMergeableState { + number: number; + mergeable: string; +} + +/** Queries the GitHub API to find all open pull requests and their mergeable state. */ +export async function getOpenPullRequestsWithMergeableState() + : Promise { + const nodes: PullRequestWithMergeableState[] = []; + let lastData: any|null = null; + + while (!lastData || lastData.repository.pullRequests.pageInfo.hasNextPage) { + lastData = await githubApiV4.request(getOpenPullRequestsWithMergeableStateQuery, { + lastCursor: lastData && lastData.repository.pullRequests.pageInfo.endCursor + }); + + nodes.push(...lastData.repository.pullRequests.nodes); + } + + return nodes; +} + + diff --git a/tools/dashboard/functions/github/github-status.ts b/tools/dashboard/functions/github/github-status.ts index ac02ee39787a..b0fd674ad3a2 100644 --- a/tools/dashboard/functions/github/github-status.ts +++ b/tools/dashboard/functions/github/github-status.ts @@ -1,10 +1,4 @@ -import {config} from 'firebase-functions'; - -const request = require('request'); -const {version, name} = require('../package.json'); - -/** API token for the Github repository. Required to set the github status on commits and PRs. */ -const repoToken = config().secret.github; +import {githubApiV3} from './github-api'; /** Data that must be specified to set a Github PR status. */ export type GithubStatusData = { @@ -18,25 +12,13 @@ export type GithubStatusData = { export function setGithubStatus(commitSHA: string, data: GithubStatusData) { const state = data.result ? 'success' : 'failure'; - const requestData = { + return githubApiV3.repos.createStatus({ + owner: 'angular', + repo: 'material2', + sha: commitSHA, state: state, target_url: data.url, + description: data.description, context: data.name, - description: data.description - }; - - const headers = { - 'Authorization': `token ${repoToken}`, - 'User-Agent': `${name}/${version}` - }; - - return new Promise((resolve, reject) => { - request({ - url: `https://api.github.com/repos/angular/material2/statuses/${commitSHA}`, - method: 'POST', - body: requestData, - headers: headers, - json: true - }, (error: any, response: any) => error ? reject(error) : resolve(response.statusCode)); }); } diff --git a/tools/dashboard/functions/package.json b/tools/dashboard/functions/package.json index 5ea08a76d2c0..b51fc4c4b057 100644 --- a/tools/dashboard/functions/package.json +++ b/tools/dashboard/functions/package.json @@ -6,6 +6,8 @@ "@types/jsonwebtoken": "^7.2.1", "firebase-admin": "~4.2.1", "firebase-functions": "^0.5.7", + "github": "^10.0.0", + "graphql-request": "^1.3.4", "jsonwebtoken": "^7.4.1", "request": "^2.81.0", "ts-node": "^3.0.6", diff --git a/tools/dashboard/functions/pull-requests-with-conflicts.ts b/tools/dashboard/functions/pull-requests-with-conflicts.ts new file mode 100644 index 000000000000..c0ddc7cb11a1 --- /dev/null +++ b/tools/dashboard/functions/pull-requests-with-conflicts.ts @@ -0,0 +1,13 @@ +import {https} from 'firebase-functions'; +import {getOpenPullRequestsWithMergeableState} from './github/github-graphql-queries'; + +/** + * Firebase HTTP trigger that responds with a list of Pull Requests that have merge conflicts. + */ +export const pullRequestsWithConflicts = https.onRequest(async (_request, response) => { + const pullRequests = (await getOpenPullRequestsWithMergeableState()) + .filter(pullRequest => pullRequest.mergeable === 'CONFLICTING'); + + response.status(200).json(pullRequests); +}); + From 1a7d0e3608f9b447c4258843baebf992eff5d92c Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 01:27:36 +0200 Subject: [PATCH 153/575] chore: re-add missing button to stepper e2e spec (#7400) Re-adds a button that was missing from the stepper e2e setup, causing one of the tests to fail. --- .../stepper-overview/stepper-overview-example.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/material-examples/stepper-overview/stepper-overview-example.html b/src/material-examples/stepper-overview/stepper-overview-example.html index 433cabb09cd2..2e4b12c42600 100644 --- a/src/material-examples/stepper-overview/stepper-overview-example.html +++ b/src/material-examples/stepper-overview/stepper-overview-example.html @@ -1,3 +1,5 @@ + +
From 53c42a45ca9c0c57609bcfc66446f64dec28058f Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Thu, 28 Sep 2017 16:45:21 -0700 Subject: [PATCH 154/575] chore: fix lint error in a11y demo (#7401) --- src/demo-app/a11y/a11y.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/demo-app/a11y/a11y.ts b/src/demo-app/a11y/a11y.ts index c517d188282e..63f6c7c63414 100644 --- a/src/demo-app/a11y/a11y.ts +++ b/src/demo-app/a11y/a11y.ts @@ -48,7 +48,7 @@ export class AccessibilityDemo { {name: 'Tooltip', route: 'tooltip'}, ]; - constructor(private router: Router) { + constructor(router: Router) { router.events.subscribe(event => { let nav = this.navItems.find(navItem => { let fragments = (event as NavigationEnd).url.split('/'); From 1823b2fa8e4c69f0a19a7be23a6cd30ae42d6d4c Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 21:58:12 +0200 Subject: [PATCH 155/575] fix(list-key-manager): don't focus disabled items in typeahead mode (#7382) Fixes the list key manager attempting to focus disabled items in typeahead mode. --- src/cdk/a11y/list-key-manager.spec.ts | 10 ++++++++++ src/cdk/a11y/list-key-manager.ts | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cdk/a11y/list-key-manager.spec.ts b/src/cdk/a11y/list-key-manager.spec.ts index 012fa45d8e9b..ac0e83a45e91 100644 --- a/src/cdk/a11y/list-key-manager.spec.ts +++ b/src/cdk/a11y/list-key-manager.spec.ts @@ -481,6 +481,16 @@ describe('Key managers', () => { expect(keyManager.activeItem).toBe(itemList.items[0]); })); + it('should not focus disabled items', fakeAsync(() => { + expect(keyManager.activeItem).toBeFalsy(); + + itemList.items[0].disabled = true; + keyManager.onKeydown(createKeyboardEvent('keydown', 79, undefined, 'o')); // types "o" + tick(debounceInterval); + + expect(keyManager.activeItem).toBeFalsy(); + })); + }); }); diff --git a/src/cdk/a11y/list-key-manager.ts b/src/cdk/a11y/list-key-manager.ts index cb8a1850518a..c3a3def7175e 100644 --- a/src/cdk/a11y/list-key-manager.ts +++ b/src/cdk/a11y/list-key-manager.ts @@ -74,7 +74,9 @@ export class ListKeyManager { const items = this._items.toArray(); for (let i = 0; i < items.length; i++) { - if (items[i].getLabel!().toUpperCase().trim().indexOf(inputString) === 0) { + let item = items[i]; + + if (!item.disabled && item.getLabel!().toUpperCase().trim().indexOf(inputString) === 0) { this.setActiveItem(i); break; } From cc6f39ea11be42c7b678380b095ef993dd11d3ec Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Fri, 29 Sep 2017 12:58:29 -0700 Subject: [PATCH 156/575] fix(sort): throw error on invalid direction (#7378) --- src/lib/sort/sort-errors.ts | 5 +++++ src/lib/sort/sort-header.ts | 3 ++- src/lib/sort/sort.spec.ts | 19 ++++++++++++++++++- src/lib/sort/sort.ts | 18 +++++++++++++++--- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/lib/sort/sort-errors.ts b/src/lib/sort/sort-errors.ts index 5fb61c38ca34..bcbc82d8f4e4 100644 --- a/src/lib/sort/sort-errors.ts +++ b/src/lib/sort/sort-errors.ts @@ -20,3 +20,8 @@ export function getSortHeaderNotContainedWithinSortError(): Error { export function getSortHeaderMissingIdError(): Error { return Error(`MatSortHeader must be provided with a unique id.`); } + +/** @docs-private */ +export function getSortInvalidDirectionError(direction: string): Error { + return Error(`${direction} is not a valid sort direction ('asc' or 'desc').`); +} diff --git a/src/lib/sort/sort-header.ts b/src/lib/sort/sort-header.ts index b516ee6f6649..5cf719da9017 100644 --- a/src/lib/sort/sort-header.ts +++ b/src/lib/sort/sort-header.ts @@ -126,6 +126,7 @@ export class MatSortHeader implements MatSortable { /** Whether this MatSortHeader is currently sorted in either ascending or descending order. */ _isSorted() { - return this._sort.active == this.id && this._sort.direction; + return this._sort.active == this.id && + this._sort.direction === 'asc' || this._sort.direction === 'desc'; } } diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index 4bc46e516d45..59d3f8df9c8a 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -20,6 +20,7 @@ import { getSortDuplicateSortableIdError, getSortHeaderMissingIdError, getSortHeaderNotContainedWithinSortError, + getSortInvalidDirectionError, } from './sort-errors'; @@ -37,7 +38,8 @@ describe('MatSort', () => { MatTableMatSortApp, MatSortHeaderMissingMatSortApp, MatSortDuplicateMatSortableIdsApp, - MatSortableMissingIdApp + MatSortableMissingIdApp, + MatSortableInvalidDirection ], }).compileComponents(); })); @@ -136,6 +138,11 @@ describe('MatSort', () => { .toThrowError(wrappedErrorMessage(getSortHeaderMissingIdError())); }); + it('should throw an error if the provided direction is invalid', () => { + expect(() => TestBed.createComponent(MatSortableInvalidDirection).detectChanges()) + .toThrowError(wrappedErrorMessage(getSortInvalidDirectionError('ascending'))); + }); + it('should allow let MatSortable override the default sort parameters', () => { testSingleColumnSortDirectionSequence( fixture, ['asc', 'desc', '']); @@ -333,3 +340,13 @@ class MatSortDuplicateMatSortableIdsApp { } ` }) class MatSortableMissingIdApp { } + + +@Component({ + template: ` +
+
A
+
+ ` +}) +class MatSortableInvalidDirection { } diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index 3c5f7078dacf..c9b1225f71b2 100644 --- a/src/lib/sort/sort.ts +++ b/src/lib/sort/sort.ts @@ -6,10 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import {Directive, EventEmitter, Input, Output} from '@angular/core'; +import {Directive, EventEmitter, Input, isDevMode, Output} from '@angular/core'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {SortDirection} from './sort-direction'; -import {getSortDuplicateSortableIdError, getSortHeaderMissingIdError} from './sort-errors'; +import { + getSortInvalidDirectionError, + getSortDuplicateSortableIdError, + getSortHeaderMissingIdError +} from './sort-errors'; export interface MatSortable { id: string; @@ -40,7 +44,15 @@ export class MatSort { @Input('matSortStart') start: 'asc' | 'desc' = 'asc'; /** The sort direction of the currently active MatSortable. */ - @Input('matSortDirection') direction: SortDirection = ''; + @Input('matSortDirection') + set direction(direction: SortDirection) { + if (isDevMode() && direction && direction !== 'asc' && direction !== 'desc') { + throw getSortInvalidDirectionError(direction); + } + this._direction = direction; + } + get direction(): SortDirection { return this._direction; } + private _direction: SortDirection = ''; /** * Whether to disable the user from clearing the sort by finishing the sort direction cycle. From 75f26e86a1b8b8c98b17f6bc8ce144dc3a971ad2 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Fri, 29 Sep 2017 12:59:15 -0700 Subject: [PATCH 157/575] fix(sort): style changes to fix IE (#7375) * fix(sort): style changes to fix IE * Update sort-header.scss --- src/lib/sort/sort-header.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/sort/sort-header.scss b/src/lib/sort/sort-header.scss index 53d333132555..25310804a255 100644 --- a/src/lib/sort/sort-header.scss +++ b/src/lib/sort/sort-header.scss @@ -54,6 +54,7 @@ $mat-sort-header-arrow-transition: 225ms cubic-bezier(0.4, 0, 0.2, 1); align-items: center; position: absolute; top: 0; + left: 0; transition: $mat-sort-header-arrow-transition; } @@ -72,6 +73,7 @@ $mat-sort-header-arrow-transition: 225ms cubic-bezier(0.4, 0, 0.2, 1); height: $mat-sort-header-arrow-thickness; transition: $mat-sort-header-arrow-transition; position: absolute; + top: 0; } .mat-sort-header-pointer-left { From b1ac7b096be0991611e2b7e2f8362ac3185d277c Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 21:59:34 +0200 Subject: [PATCH 158/575] refactor: rename all OverlayState references to match the new naming (#7367) Renames all of the "state" references in the overlays to refer to a "config" instead. This makes everything consistent with the recent rename of OverlayState to OverlayConfig. BREAKING CHANGE: The `OverlayRef.getState` method has been renamed to `OverlayRef.getConfig`. --- src/cdk/overlay/overlay-config.ts | 6 +- src/cdk/overlay/overlay-directives.spec.ts | 2 +- src/cdk/overlay/overlay-directives.ts | 2 +- src/cdk/overlay/overlay-ref.ts | 82 ++++++++++---------- src/cdk/overlay/overlay.spec.ts | 58 +++++++------- src/cdk/overlay/overlay.ts | 10 +-- src/lib/autocomplete/autocomplete-trigger.ts | 2 +- src/lib/datepicker/datepicker.ts | 4 +- src/lib/dialog/dialog-ref.ts | 2 +- src/lib/dialog/dialog.ts | 8 +- src/lib/snack-bar/snack-bar.ts | 8 +- 11 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/cdk/overlay/overlay-config.ts b/src/cdk/overlay/overlay-config.ts index b314847d65cb..cde1d5050da3 100644 --- a/src/cdk/overlay/overlay-config.ts +++ b/src/cdk/overlay/overlay-config.ts @@ -50,9 +50,9 @@ export class OverlayConfig { /** The direction of the text in the overlay panel. */ direction?: Direction = 'ltr'; - constructor(state?: OverlayConfig) { - if (state) { - Object.keys(state).forEach(key => this[key] = state[key]); + constructor(config?: OverlayConfig) { + if (config) { + Object.keys(config).forEach(key => this[key] = config[key]); } } } diff --git a/src/cdk/overlay/overlay-directives.spec.ts b/src/cdk/overlay/overlay-directives.spec.ts index e0876038d708..2e0830acb922 100644 --- a/src/cdk/overlay/overlay-directives.spec.ts +++ b/src/cdk/overlay/overlay-directives.spec.ts @@ -76,7 +76,7 @@ describe('Overlay directives', () => { let overlayDirective = testComponent.connectedOverlayDirective; let strategy = - overlayDirective.overlayRef.getState().positionStrategy; + overlayDirective.overlayRef.getConfig().positionStrategy; expect(strategy instanceof ConnectedPositionStrategy).toBe(true); let positions = strategy.positions; diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index bda7b7661274..67eb87452881 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -337,7 +337,7 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges { } this._position.withDirection(this.dir); - this._overlayRef.getState().direction = this.dir; + this._overlayRef.getConfig().direction = this.dir; this._initEscapeListener(); if (!this._overlayRef.hasAttached()) { diff --git a/src/cdk/overlay/overlay-ref.ts b/src/cdk/overlay/overlay-ref.ts index 8d1eae2687f1..915104dfb3f0 100644 --- a/src/cdk/overlay/overlay-ref.ts +++ b/src/cdk/overlay/overlay-ref.ts @@ -26,11 +26,11 @@ export class OverlayRef implements PortalHost { constructor( private _portalHost: PortalHost, private _pane: HTMLElement, - private _state: OverlayConfig, + private _config: OverlayConfig, private _ngZone: NgZone) { - if (_state.scrollStrategy) { - _state.scrollStrategy.attach(this); + if (_config.scrollStrategy) { + _config.scrollStrategy.attach(this); } } @@ -47,33 +47,33 @@ export class OverlayRef implements PortalHost { attach(portal: Portal): any { let attachResult = this._portalHost.attach(portal); - if (this._state.positionStrategy) { - this._state.positionStrategy.attach(this); + if (this._config.positionStrategy) { + this._config.positionStrategy.attach(this); } - // Update the pane element with the given state configuration. + // Update the pane element with the given configuration. this._updateStackingOrder(); this.updateSize(); this.updateDirection(); this.updatePosition(); - if (this._state.scrollStrategy) { - this._state.scrollStrategy.enable(); + if (this._config.scrollStrategy) { + this._config.scrollStrategy.enable(); } // Enable pointer events for the overlay pane element. this._togglePointerEvents(true); - if (this._state.hasBackdrop) { + if (this._config.hasBackdrop) { this._attachBackdrop(); } - if (this._state.panelClass) { + if (this._config.panelClass) { // We can't do a spread here, because IE doesn't support setting multiple classes. - if (Array.isArray(this._state.panelClass)) { - this._state.panelClass.forEach(cls => this._pane.classList.add(cls)); + if (Array.isArray(this._config.panelClass)) { + this._config.panelClass.forEach(cls => this._pane.classList.add(cls)); } else { - this._pane.classList.add(this._state.panelClass); + this._pane.classList.add(this._config.panelClass); } } @@ -95,8 +95,8 @@ export class OverlayRef implements PortalHost { // pointer events therefore. Depends on the position strategy and the applied pane boundaries. this._togglePointerEvents(false); - if (this._state.scrollStrategy) { - this._state.scrollStrategy.disable(); + if (this._config.scrollStrategy) { + this._config.scrollStrategy.disable(); } let detachmentResult = this._portalHost.detach(); @@ -111,12 +111,12 @@ export class OverlayRef implements PortalHost { * Cleans up the overlay from the DOM. */ dispose(): void { - if (this._state.positionStrategy) { - this._state.positionStrategy.dispose(); + if (this._config.positionStrategy) { + this._config.positionStrategy.dispose(); } - if (this._state.scrollStrategy) { - this._state.scrollStrategy.disable(); + if (this._config.scrollStrategy) { + this._config.scrollStrategy.disable(); } this.detachBackdrop(); @@ -152,48 +152,48 @@ export class OverlayRef implements PortalHost { } /** - * Gets the current state config of the overlay. + * Gets the current config of the overlay. */ - getState(): OverlayConfig { - return this._state; + getConfig(): OverlayConfig { + return this._config; } /** Updates the position of the overlay based on the position strategy. */ updatePosition() { - if (this._state.positionStrategy) { - this._state.positionStrategy.apply(); + if (this._config.positionStrategy) { + this._config.positionStrategy.apply(); } } /** Updates the text direction of the overlay panel. */ private updateDirection() { - this._pane.setAttribute('dir', this._state.direction!); + this._pane.setAttribute('dir', this._config.direction!); } /** Updates the size of the overlay based on the overlay config. */ updateSize() { - if (this._state.width || this._state.width === 0) { - this._pane.style.width = formatCssUnit(this._state.width); + if (this._config.width || this._config.width === 0) { + this._pane.style.width = formatCssUnit(this._config.width); } - if (this._state.height || this._state.height === 0) { - this._pane.style.height = formatCssUnit(this._state.height); + if (this._config.height || this._config.height === 0) { + this._pane.style.height = formatCssUnit(this._config.height); } - if (this._state.minWidth || this._state.minWidth === 0) { - this._pane.style.minWidth = formatCssUnit(this._state.minWidth); + if (this._config.minWidth || this._config.minWidth === 0) { + this._pane.style.minWidth = formatCssUnit(this._config.minWidth); } - if (this._state.minHeight || this._state.minHeight === 0) { - this._pane.style.minHeight = formatCssUnit(this._state.minHeight); + if (this._config.minHeight || this._config.minHeight === 0) { + this._pane.style.minHeight = formatCssUnit(this._config.minHeight); } - if (this._state.maxWidth || this._state.maxWidth === 0) { - this._pane.style.maxWidth = formatCssUnit(this._state.maxWidth); + if (this._config.maxWidth || this._config.maxWidth === 0) { + this._pane.style.maxWidth = formatCssUnit(this._config.maxWidth); } - if (this._state.maxHeight || this._state.maxHeight === 0) { - this._pane.style.maxHeight = formatCssUnit(this._state.maxHeight); + if (this._config.maxHeight || this._config.maxHeight === 0) { + this._pane.style.maxHeight = formatCssUnit(this._config.maxHeight); } } @@ -207,8 +207,8 @@ export class OverlayRef implements PortalHost { this._backdropElement = document.createElement('div'); this._backdropElement.classList.add('cdk-overlay-backdrop'); - if (this._state.backdropClass) { - this._backdropElement.classList.add(this._state.backdropClass); + if (this._config.backdropClass) { + this._backdropElement.classList.add(this._config.backdropClass); } // Insert the backdrop before the pane in the DOM order, @@ -261,8 +261,8 @@ export class OverlayRef implements PortalHost { backdropToDetach.classList.remove('cdk-overlay-backdrop-showing'); - if (this._state.backdropClass) { - backdropToDetach.classList.remove(this._state.backdropClass); + if (this._config.backdropClass) { + backdropToDetach.classList.remove(this._config.backdropClass); } backdropToDetach.addEventListener('transitionend', finishDetach); diff --git a/src/cdk/overlay/overlay.spec.ts b/src/cdk/overlay/overlay.spec.ts index 6763e9432262..e8af0f9ff4ab 100644 --- a/src/cdk/overlay/overlay.spec.ts +++ b/src/cdk/overlay/overlay.spec.ts @@ -133,9 +133,9 @@ describe('Overlay', () => { }); it('should set the direction', () => { - const state = new OverlayConfig({direction: 'rtl'}); + const config = new OverlayConfig({direction: 'rtl'}); - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.getAttribute('dir')).toEqual('rtl'); @@ -152,8 +152,8 @@ describe('Overlay', () => { }); it('should emit the attachment event after everything is added to the DOM', () => { - let state = new OverlayConfig({hasBackdrop: true}); - let overlayRef = overlay.create(state); + let config = new OverlayConfig({hasBackdrop: true}); + let overlayRef = overlay.create(config); overlayRef.attachments().subscribe(() => { expect(overlayContainerElement.querySelector('pizza')) @@ -220,99 +220,99 @@ describe('Overlay', () => { }); describe('positioning', () => { - let state: OverlayConfig; + let config: OverlayConfig; beforeEach(() => { - state = new OverlayConfig(); + config = new OverlayConfig(); }); it('should apply the positioning strategy', () => { - state.positionStrategy = new FakePositionStrategy(); + config.positionStrategy = new FakePositionStrategy(); - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); expect(overlayContainerElement.querySelectorAll('.fake-positioned').length).toBe(1); }); }); describe('size', () => { - let state: OverlayConfig; + let config: OverlayConfig; beforeEach(() => { - state = new OverlayConfig(); + config = new OverlayConfig(); }); it('should apply the width set in the config', () => { - state.width = 500; + config.width = 500; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.width).toEqual('500px'); }); it('should support using other units if a string width is provided', () => { - state.width = '200%'; + config.width = '200%'; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.width).toEqual('200%'); }); it('should apply the height set in the config', () => { - state.height = 500; + config.height = 500; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.height).toEqual('500px'); }); it('should support using other units if a string height is provided', () => { - state.height = '100vh'; + config.height = '100vh'; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.height).toEqual('100vh'); }); it('should apply the min width set in the config', () => { - state.minWidth = 200; + config.minWidth = 200; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.minWidth).toEqual('200px'); }); it('should apply the min height set in the config', () => { - state.minHeight = 500; + config.minHeight = 500; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.minHeight).toEqual('500px'); }); it('should apply the max width set in the config', () => { - state.maxWidth = 200; + config.maxWidth = 200; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.maxWidth).toEqual('200px'); }); it('should apply the max height set in the config', () => { - state.maxHeight = 500; + config.maxHeight = 500; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.maxHeight).toEqual('500px'); }); it('should support zero widths and heights', () => { - state.width = 0; - state.height = 0; + config.width = 0; + config.height = 0; - overlay.create(state).attach(componentPortal); + overlay.create(config).attach(componentPortal); const pane = overlayContainerElement.children[0] as HTMLElement; expect(pane.style.width).toEqual('0px'); expect(pane.style.height).toEqual('0px'); diff --git a/src/cdk/overlay/overlay.ts b/src/cdk/overlay/overlay.ts index 1de3690e71f0..651f7e6d4f2f 100644 --- a/src/cdk/overlay/overlay.ts +++ b/src/cdk/overlay/overlay.ts @@ -24,8 +24,8 @@ import {ScrollStrategyOptions} from './scroll/index'; /** Next overlay unique ID. */ let nextUniqueId = 0; -/** The default state for newly created overlays. */ -let defaultState = new OverlayConfig(); +/** The default config for newly created overlays. */ +let defaultConfig = new OverlayConfig(); /** @@ -48,13 +48,13 @@ export class Overlay { /** * Creates an overlay. - * @param state State to apply to the overlay. + * @param config Config to apply to the overlay. * @returns Reference to the created overlay. */ - create(state: OverlayConfig = defaultState): OverlayRef { + create(config: OverlayConfig = defaultConfig): OverlayRef { const pane = this._createPaneElement(); const portalHost = this._createPortalHost(pane); - return new OverlayRef(portalHost, pane, state, this._ngZone); + return new OverlayRef(portalHost, pane, config, this._ngZone); } /** diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index 33d5510dcc61..9fb0e8a763b1 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -440,7 +440,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { this._overlayRef = this._overlay.create(this._getOverlayConfig()); } else { /** Update the panel width, in case the host width has changed */ - this._overlayRef.getState().width = this._getHostWidth(); + this._overlayRef.getConfig().width = this._getHostWidth(); this._overlayRef.updateSize(); } diff --git a/src/lib/datepicker/datepicker.ts b/src/lib/datepicker/datepicker.ts index 8c9d10adafb3..cc25a957df13 100644 --- a/src/lib/datepicker/datepicker.ts +++ b/src/lib/datepicker/datepicker.ts @@ -332,7 +332,7 @@ export class MatDatepicker implements OnDestroy { /** Create the popup. */ private _createPopup(): void { - const overlayState = new OverlayConfig({ + const overlayConfig = new OverlayConfig({ positionStrategy: this._createPopupPositionStrategy(), hasBackdrop: true, backdropClass: 'mat-overlay-transparent-backdrop', @@ -340,7 +340,7 @@ export class MatDatepicker implements OnDestroy { scrollStrategy: this._scrollStrategy() }); - this._popupRef = this._overlay.create(overlayState); + this._popupRef = this._overlay.create(overlayConfig); } /** Create the popup PositionStrategy. */ diff --git a/src/lib/dialog/dialog-ref.ts b/src/lib/dialog/dialog-ref.ts index 98f1c5914ca6..0c45a1060888 100644 --- a/src/lib/dialog/dialog-ref.ts +++ b/src/lib/dialog/dialog-ref.ts @@ -157,6 +157,6 @@ export class MatDialogRef { /** Fetches the position strategy object from the overlay ref. */ private _getPositionStrategy(): GlobalPositionStrategy { - return this._overlayRef.getState().positionStrategy as GlobalPositionStrategy; + return this._overlayRef.getConfig().positionStrategy as GlobalPositionStrategy; } } diff --git a/src/lib/dialog/dialog.ts b/src/lib/dialog/dialog.ts index 7bbb1793cbb2..2f891d2372d1 100644 --- a/src/lib/dialog/dialog.ts +++ b/src/lib/dialog/dialog.ts @@ -173,16 +173,16 @@ export class MatDialog { * @returns A promise resolving to the OverlayRef for the created overlay. */ private _createOverlay(config: MatDialogConfig): OverlayRef { - const overlayState = this._getOverlayState(config); - return this._overlay.create(overlayState); + const overlayConfig = this._getOverlayConfig(config); + return this._overlay.create(overlayConfig); } /** - * Creates an overlay state from a dialog config. + * Creates an overlay config from a dialog config. * @param dialogConfig The dialog configuration. * @returns The overlay configuration. */ - private _getOverlayState(dialogConfig: MatDialogConfig): OverlayConfig { + private _getOverlayConfig(dialogConfig: MatDialogConfig): OverlayConfig { const state = new OverlayConfig({ positionStrategy: this._overlay.position().global(), scrollStrategy: this._scrollStrategy(), diff --git a/src/lib/snack-bar/snack-bar.ts b/src/lib/snack-bar/snack-bar.ts index 25635acfddd8..6fc6c9a147b9 100644 --- a/src/lib/snack-bar/snack-bar.ts +++ b/src/lib/snack-bar/snack-bar.ts @@ -152,8 +152,8 @@ export class MatSnackBar { * @param config The user-specified snack bar config. */ private _createOverlay(config: MatSnackBarConfig): OverlayRef { - const state = new OverlayConfig(); - state.direction = config.direction; + const overlayConfig = new OverlayConfig(); + overlayConfig.direction = config.direction; let positionStrategy = this._overlay.position().global(); // Set horizontal position. @@ -177,8 +177,8 @@ export class MatSnackBar { positionStrategy.bottom('0'); } - state.positionStrategy = positionStrategy; - return this._overlay.create(state); + overlayConfig.positionStrategy = positionStrategy; + return this._overlay.create(overlayConfig); } /** From 2e71cac8a7b5da246276c5bb919356ab21ff465b Mon Sep 17 00:00:00 2001 From: mmalerba Date: Fri, 29 Sep 2017 12:59:51 -0700 Subject: [PATCH 159/575] fix(select): prevent nbsp from getting butchered in AOT (#7363) --- src/lib/select/select.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/select/select.html b/src/lib/select/select.html index b16a0b2e959e..fca93137357a 100644 --- a/src/lib/select/select.html +++ b/src/lib/select/select.html @@ -9,7 +9,7 @@ TODO(mmalerba):   is currently broken in components with preserveWhitespace: false, so we evaluate it as a JS string binding instead. Change back to   once it works again. --> - {{'\xa0'}} + {{'\u00A0'}} {{ triggerValue }} From 505611049e3162d42e96cfa968d0a5a11c65062d Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 29 Sep 2017 16:00:07 -0400 Subject: [PATCH 160/575] chore(table): remove redundant condition (#7345) --- src/cdk/table/row.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdk/table/row.ts b/src/cdk/table/row.ts index 989355a209dd..e0c8b7bc3046 100644 --- a/src/cdk/table/row.ts +++ b/src/cdk/table/row.ts @@ -44,7 +44,7 @@ export abstract class BaseRowDef { // Create a new columns differ if one does not yet exist. Initialize it based on initial value // of the columns property or an empty array if none is provided. const columns = changes['columns'].currentValue || []; - if (!this._columnsDiffer && columns) { + if (!this._columnsDiffer) { this._columnsDiffer = this._differs.find(columns).create(); this._columnsDiffer.diff(columns); } From 6b70ca6ce3ab0d65964381a741d100a07c8dd7b0 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:00:40 +0200 Subject: [PATCH 161/575] fix(select): theme not being transferred to the panel (#7342) * Fixes the theme from the form field not being transferred to the panel, causing the options to have the wrong color. This seems to have happened during the switch to the form field, but interestingly AoT didn't catch us not having a `color` anymore (possible because it's in a binding expression). * Moves a test to another test suite since it doesn't belong with the theming tests. --- src/lib/select/select.html | 2 +- src/lib/select/select.spec.ts | 36 +++++++++++++++++++---------------- src/lib/select/select.ts | 8 +++++++- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/lib/select/select.html b/src/lib/select/select.html index fca93137357a..7782c2192349 100644 --- a/src/lib/select/select.html +++ b/src/lib/select/select.html @@ -34,7 +34,7 @@ (detach)="close()">
{ expect(() => fixture.componentInstance.select.triggerValue).not.toThrow(); }); + + it('should allow the user to customize the label', () => { + const fixture = TestBed.createComponent(SelectWithCustomTrigger); + fixture.detectChanges(); + + fixture.componentInstance.control.setValue('pizza-1'); + fixture.detectChanges(); + + const label = fixture.debugElement.query(By.css('.mat-select-value')).nativeElement; + + expect(label.textContent).toContain('azziP', + 'Expected the displayed text to be "Pizza" in reverse.'); + }); }); describe('change event', () => { @@ -2622,30 +2635,21 @@ describe('MatSelect', () => { describe('theming', () => { let fixture: ComponentFixture; - let testInstance: BasicSelectWithTheming; - let selectElement: HTMLElement; beforeEach(async(() => { fixture = TestBed.createComponent(BasicSelectWithTheming); - testInstance = fixture.componentInstance; fixture.detectChanges(); - - selectElement = fixture.debugElement.query(By.css('.mat-select')).nativeElement; })); - it('should allow the user to customize the label', () => { - fixture.destroy(); - - const labelFixture = TestBed.createComponent(SelectWithCustomTrigger); - labelFixture.detectChanges(); - - labelFixture.componentInstance.control.setValue('pizza-1'); - labelFixture.detectChanges(); + it('should transfer the theme to the select panel', () => { + fixture.componentInstance.theme = 'warn'; + fixture.detectChanges(); - const label = labelFixture.debugElement.query(By.css('.mat-select-value')).nativeElement; + fixture.componentInstance.select.open(); + fixture.detectChanges(); - expect(label.textContent).toContain('azziP', - 'Expected the displayed text to be "Pizza" in reverse.'); + const panel = overlayContainerElement.querySelector('.mat-select-panel')! as HTMLElement; + expect(panel.classList).toContain('mat-warn'); }); }); diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 7869b73dc543..7e5dfacbb073 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -55,7 +55,7 @@ import { mixinDisabled, mixinTabIndex, } from '@angular/material/core'; -import {MatFormFieldControl} from '@angular/material/form-field'; +import {MatFormField, MatFormFieldControl} from '@angular/material/form-field'; import {Observable} from 'rxjs/Observable'; import {merge} from 'rxjs/observable/merge'; import {Subject} from 'rxjs/Subject'; @@ -410,6 +410,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit, @Optional() private _dir: Directionality, @Optional() private _parentForm: NgForm, @Optional() private _parentFormGroup: FormGroupDirective, + @Optional() private _parentFormField: MatFormField, @Self() @Optional() public ngControl: NgControl, @Attribute('tabindex') tabIndex: string, @Inject(MAT_SELECT_SCROLL_STRATEGY) private _scrollStrategyFactory) { @@ -641,6 +642,11 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit, this._setScrollTop(); } + /** Returns the theme to be used on the panel. */ + _getPanelTheme(): string { + return this._parentFormField ? `mat-${this._parentFormField.color}` : ''; + } + /** Whether the select has a value. */ get empty(): boolean { return !this._selectionModel || this._selectionModel.isEmpty(); From f1664687a7a0ebd377e2a29bcd3f726f948a6d9a Mon Sep 17 00:00:00 2001 From: tinayuangao Date: Fri, 29 Sep 2017 13:00:52 -0700 Subject: [PATCH 162/575] fix(chips): fix chip list focus and keyboard behaviors (#7319) --- src/lib/chips/chip-list.spec.ts | 12 ++++++------ src/lib/chips/chip-list.ts | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/lib/chips/chip-list.spec.ts b/src/lib/chips/chip-list.spec.ts index bb9a5b33eb71..5b7e9e2e25e5 100644 --- a/src/lib/chips/chip-list.spec.ts +++ b/src/lib/chips/chip-list.spec.ts @@ -279,7 +279,7 @@ describe('MatChipList', () => { describe('when the input has focus', () => { - it('should focus the last chip when press DELETE', () => { + it('should not focus the last chip when press DELETE', () => { let nativeInput = fixture.nativeElement.querySelector('input'); let DELETE_EVENT: KeyboardEvent = createKeyboardEvent('keydown', DELETE, nativeInput); @@ -292,8 +292,8 @@ describe('MatChipList', () => { chipListInstance._keydown(DELETE_EVENT); fixture.detectChanges(); - // It focuses the last chip - expect(manager.activeItemIndex).toEqual(chips.length - 1); + // It doesn't focus the last chip + expect(manager.activeItemIndex).toEqual(-1); }); it('should focus the last chip when press BACKSPACE', () => { @@ -786,7 +786,7 @@ describe('MatChipList', () => { describe('when the input has focus', () => { - it('should focus the last chip when press DELETE', () => { + it('should not focus the last chip when press DELETE', () => { let nativeInput = fixture.nativeElement.querySelector('input'); let DELETE_EVENT: KeyboardEvent = createKeyboardEvent('keydown', DELETE, nativeInput); @@ -799,8 +799,8 @@ describe('MatChipList', () => { chipListInstance._keydown(DELETE_EVENT); fixture.detectChanges(); - // It focuses the last chip - expect(manager.activeItemIndex).toEqual(chips.length - 1); + // It doesn't focus the last chip + expect(manager.activeItemIndex).toEqual(-1); }); it('should focus the last chip when press BACKSPACE', () => { diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index ae7bdfe0b177..879d1cda432b 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -10,7 +10,7 @@ import {FocusKeyManager} from '@angular/cdk/a11y'; import {Directionality} from '@angular/cdk/bidi'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {SelectionModel} from '@angular/cdk/collections'; -import {BACKSPACE, DELETE, LEFT_ARROW, RIGHT_ARROW, UP_ARROW} from '@angular/cdk/keycodes'; +import {BACKSPACE, LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes'; import {startWith} from '@angular/cdk/rxjs'; import { AfterContentInit, @@ -432,8 +432,8 @@ export class MatChipList implements MatFormFieldControl, ControlValueAccess let isPrevKey = (code === (isRtl ? RIGHT_ARROW : LEFT_ARROW)); let isNextKey = (code === (isRtl ? LEFT_ARROW : RIGHT_ARROW)); - let isBackKey = (code === BACKSPACE || code == DELETE || code == UP_ARROW || isPrevKey); - // If they are on an empty input and hit backspace/delete/left arrow, focus the last chip + let isBackKey = code === BACKSPACE; + // If they are on an empty input and hit backspace, focus the last chip if (isInputEmpty && isBackKey) { this._keyManager.setLastItemActive(); event.preventDefault(); @@ -504,8 +504,6 @@ export class MatChipList implements MatFormFieldControl, ControlValueAccess if (focusChip) { focusChip.focus(); } - } else if (chipsArray.length === 0) { - this._focusInput(); } // Reset our destroyed index From d05dcfa492df3fb0fcf119ddfb72ffb94529ebeb Mon Sep 17 00:00:00 2001 From: mmalerba Date: Fri, 29 Sep 2017 13:01:22 -0700 Subject: [PATCH 163/575] fix(sidenav): change content from md- to mat- (#7307) From 92a868e40b998448c6bcd47aef83ed37514098ac Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:01:39 +0200 Subject: [PATCH 164/575] fix(button): allow for elevation to be overwritten (#7305) Allows for the consumer to set the button elevation through the elevation classes, similarly to the menu, card and expansion components. Fixes #7264. --- src/lib/button/_button-base.scss | 8 ++++---- src/lib/card/card.scss | 5 +---- src/lib/core/_core.scss | 2 +- src/lib/core/style/_elevation.scss | 11 +++++++++++ src/lib/core/style/_menu-common.scss | 7 +------ src/lib/expansion/expansion-panel.scss | 5 +---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/lib/button/_button-base.scss b/src/lib/button/_button-base.scss index cb15d5391fbb..44b9e39e3aa8 100644 --- a/src/lib/button/_button-base.scss +++ b/src/lib/button/_button-base.scss @@ -66,7 +66,7 @@ $mat-mini-fab-padding: 8px !default; %mat-raised-button { @extend %mat-button-base; - @include mat-elevation(2); + @include mat-overridable-elevation(2); // Force hardware acceleration. transform: translate3d(0, 0, 0); @@ -76,7 +76,7 @@ $mat-mini-fab-padding: 8px !default; mat-elevation-transition-property-value(); &:not([disabled]):active { - @include mat-elevation(8); + @include mat-overridable-elevation(8); } &[disabled] { @@ -88,7 +88,7 @@ $mat-mini-fab-padding: 8px !default; @mixin mat-fab($size, $padding) { @extend %mat-raised-button; - @include mat-elevation(6); + @include mat-overridable-elevation(6); // Reset the min-width from the button base. min-width: 0; @@ -101,7 +101,7 @@ $mat-mini-fab-padding: 8px !default; flex-shrink: 0; &:not([disabled]):active { - @include mat-elevation(12); + @include mat-overridable-elevation(12); } .mat-button-wrapper { diff --git a/src/lib/card/card.scss b/src/lib/card/card.scss index 584fef8af43c..cb627b841a9e 100644 --- a/src/lib/card/card.scss +++ b/src/lib/card/card.scss @@ -10,15 +10,12 @@ $mat-card-header-size: 40px !default; .mat-card { @include mat-elevation-transition; + @include mat-overridable-elevation(2); display: block; position: relative; padding: $mat-card-default-padding; border-radius: $mat-card-border-radius; - &:not([class*='mat-elevation-z']) { - @include mat-elevation(2); - } - @include cdk-high-contrast { outline: solid 1px; } diff --git a/src/lib/core/_core.scss b/src/lib/core/_core.scss index 7a4372719261..a4aef3daca70 100644 --- a/src/lib/core/_core.scss +++ b/src/lib/core/_core.scss @@ -19,7 +19,7 @@ // `mat-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the element is // elevated. @for $zValue from 0 through 24 { - .mat-elevation-z#{$zValue} { + .#{$_mat-elevation-prefix}#{$zValue} { @include mat-elevation($zValue); } } diff --git a/src/lib/core/style/_elevation.scss b/src/lib/core/style/_elevation.scss index 80dff61f1860..c8fa0de039ac 100644 --- a/src/lib/core/style/_elevation.scss +++ b/src/lib/core/style/_elevation.scss @@ -126,6 +126,9 @@ $mat-elevation-transition-duration: 280ms !default; // The default easing value for elevation transitions. $mat-elevation-transition-timing-function: $mat-fast-out-slow-in-timing-function; +// Prefix for elevation-related selectors. +$_mat-elevation-prefix: 'mat-elevation-z'; + // Applies the correct css rules to an element to give it the elevation specified by $zValue. // The $zValue must be between 0 and 24. @mixin mat-elevation($zValue) { @@ -141,6 +144,14 @@ $mat-elevation-transition-timing-function: $mat-fast-out-slow-in-timing-function #{map-get($_ambient-elevation-map, $zValue)}; } +// Applies the elevation to an element in a manner that allows +// consumers to override it via the Material elevation classes. +@mixin mat-overridable-elevation($zValue) { + &:not([class*='#{$_mat-elevation-prefix}']) { + @include mat-elevation($zValue); + } +} + // Returns a string that can be used as the value for a transition property for elevation. // Calling this function directly is useful in situations where a component needs to transition // more than one property. diff --git a/src/lib/core/style/_menu-common.scss b/src/lib/core/style/_menu-common.scss index ba363b1bcaa9..74800cfec21f 100644 --- a/src/lib/core/style/_menu-common.scss +++ b/src/lib/core/style/_menu-common.scss @@ -14,14 +14,9 @@ $mat-menu-icon-margin: 16px !default; @mixin mat-menu-base($default-elevation) { + @include mat-overridable-elevation($default-elevation); min-width: $mat-menu-overlay-min-width; max-width: $mat-menu-overlay-max-width; - - // Allow elevation to be overwritten. - &:not([class*='mat-elevation-z']) { - @include mat-elevation($default-elevation); - } - overflow: auto; -webkit-overflow-scrolling: touch; // for momentum scroll on mobile } diff --git a/src/lib/expansion/expansion-panel.scss b/src/lib/expansion/expansion-panel.scss index cbaa59dc7fbf..24215855ddeb 100644 --- a/src/lib/expansion/expansion-panel.scss +++ b/src/lib/expansion/expansion-panel.scss @@ -3,14 +3,11 @@ .mat-expansion-panel { @include mat-elevation-transition; + @include mat-overridable-elevation(2); box-sizing: content-box; display: block; margin: 0; transition: margin 225ms $mat-fast-out-slow-in-timing-function; - - &:not([class*='mat-elevation-z']) { - @include mat-elevation(2); - } } .mat-expansion-panel-content { From fe0864b8a9bce04a6cd50f4c8195ec2cfe013499 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:03:29 +0200 Subject: [PATCH 165/575] fix(ripple): handle touch events (#7299) * fix(ripple): handle touch events * Ripples are now launched on touchstart for touch devices. Before they were just launched after the click happened. Fixes #7062 * Address feedback --- src/cdk/testing/dispatch-events.ts | 12 +++++++- src/cdk/testing/event-objects.ts | 20 ++++++++++++- src/lib/core/ripple/ripple-renderer.ts | 41 +++++++++++++++++--------- src/lib/core/ripple/ripple.spec.ts | 16 +++++++++- 4 files changed, 72 insertions(+), 17 deletions(-) diff --git a/src/cdk/testing/dispatch-events.ts b/src/cdk/testing/dispatch-events.ts index f815fce1a4b9..9163c33db07f 100644 --- a/src/cdk/testing/dispatch-events.ts +++ b/src/cdk/testing/dispatch-events.ts @@ -6,7 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {createFakeEvent, createKeyboardEvent, createMouseEvent} from './event-objects'; +import { + createFakeEvent, + createKeyboardEvent, + createMouseEvent, + createTouchEvent +} from './event-objects'; /** Utility to dispatch any event on a Node. */ export function dispatchEvent(node: Node | Window, event: Event): Event { @@ -29,3 +34,8 @@ export function dispatchMouseEvent(node: Node, type: string, x = 0, y = 0, event = createMouseEvent(type, x, y)): MouseEvent { return dispatchEvent(node, event) as MouseEvent; } + +/** Shorthand to dispatch a touch event on the specified coordinates. */ +export function dispatchTouchEvent(node: Node, type: string, x = 0, y = 0) { + return dispatchEvent(node, createTouchEvent(type, x, y)); +} diff --git a/src/cdk/testing/event-objects.ts b/src/cdk/testing/event-objects.ts index 856aad2f09f4..7b2fe2407bc4 100644 --- a/src/cdk/testing/event-objects.ts +++ b/src/cdk/testing/event-objects.ts @@ -8,7 +8,7 @@ /** Creates a browser MouseEvent with the specified options. */ export function createMouseEvent(type: string, x = 0, y = 0) { - let event = document.createEvent('MouseEvent'); + const event = document.createEvent('MouseEvent'); event.initMouseEvent(type, false, /* canBubble */ @@ -29,6 +29,24 @@ export function createMouseEvent(type: string, x = 0, y = 0) { return event; } +/** Creates a browser TouchEvent with the specified pointer coordinates. */ +export function createTouchEvent(type: string, pageX = 0, pageY = 0) { + // In favor of creating events that work for most of the browsers, the event is created + // as a basic UI Event. The necessary details for the event will be set manually. + const event = document.createEvent('UIEvent'); + const touchDetails = {pageX, pageY}; + + event.initUIEvent(type, true, true, window, 0); + + // Most of the browsers don't have a "initTouchEvent" method that can be used to define + // the touch details. + Object.defineProperties(event, { + touches: {value: [touchDetails]} + }); + + return event; +} + /** Dispatches a keydown event from an element. */ export function createKeyboardEvent(type: string, keyCode: number, target?: Element, key?: string) { let event = document.createEvent('KeyboardEvent') as any; diff --git a/src/lib/core/ripple/ripple-renderer.ts b/src/lib/core/ripple/ripple-renderer.ts index b6875b691ac3..1ab8013123ee 100644 --- a/src/lib/core/ripple/ripple-renderer.ts +++ b/src/lib/core/ripple/ripple-renderer.ts @@ -41,8 +41,8 @@ export class RippleRenderer { /** Element which triggers the ripple elements on mouse events. */ private _triggerElement: HTMLElement | null; - /** Whether the mouse is currently down or not. */ - private _isMousedown: boolean = false; + /** Whether the pointer is currently being held on the trigger or not. */ + private _isPointerDown: boolean = false; /** Events to be registered on the trigger element. */ private _triggerEvents = new Map(); @@ -67,8 +67,12 @@ export class RippleRenderer { // Specify events which need to be registered on the trigger. this._triggerEvents.set('mousedown', this.onMousedown.bind(this)); - this._triggerEvents.set('mouseup', this.onMouseup.bind(this)); - this._triggerEvents.set('mouseleave', this.onMouseLeave.bind(this)); + this._triggerEvents.set('touchstart', this.onTouchstart.bind(this)); + + this._triggerEvents.set('mouseup', this.onPointerUp.bind(this)); + this._triggerEvents.set('touchend', this.onPointerUp.bind(this)); + + this._triggerEvents.set('mouseleave', this.onPointerLeave.bind(this)); // By default use the host element as trigger element. this.setTriggerElement(this._containerElement); @@ -128,7 +132,7 @@ export class RippleRenderer { this.runTimeoutOutsideZone(() => { rippleRef.state = RippleState.VISIBLE; - if (!config.persistent && !this._isMousedown) { + if (!config.persistent && !this._isPointerDown) { rippleRef.fadeOut(); } }, duration); @@ -181,17 +185,17 @@ export class RippleRenderer { this._triggerElement = element; } - /** Listener being called on mousedown event. */ + /** Function being called whenever the trigger is being pressed. */ private onMousedown(event: MouseEvent) { if (!this.rippleDisabled) { - this._isMousedown = true; + this._isPointerDown = true; this.fadeInRipple(event.pageX, event.pageY, this.rippleConfig); } } - /** Listener being called on mouseup event. */ - private onMouseup() { - this._isMousedown = false; + /** Function being called whenever the pointer is being released. */ + private onPointerUp() { + this._isPointerDown = false; // Fade-out all ripples that are completely visible and not persistent. this._activeRipples.forEach(ripple => { @@ -201,10 +205,19 @@ export class RippleRenderer { }); } - /** Listener being called on mouseleave event. */ - private onMouseLeave() { - if (this._isMousedown) { - this.onMouseup(); + /** Function being called whenever the pointer leaves the trigger. */ + private onPointerLeave() { + if (this._isPointerDown) { + this.onPointerUp(); + } + } + + /** Function being called whenever the trigger is being touched. */ + private onTouchstart(event: TouchEvent) { + if (!this.rippleDisabled) { + const {pageX, pageY} = event.touches[0]; + this._isPointerDown = true; + this.fadeInRipple(pageX, pageY, this.rippleConfig); } } diff --git a/src/lib/core/ripple/ripple.spec.ts b/src/lib/core/ripple/ripple.spec.ts index 765637567fe8..d12613b5fe66 100644 --- a/src/lib/core/ripple/ripple.spec.ts +++ b/src/lib/core/ripple/ripple.spec.ts @@ -2,7 +2,7 @@ import {TestBed, ComponentFixture, fakeAsync, tick, inject} from '@angular/core/ import {Component, ViewChild} from '@angular/core'; import {Platform} from '@angular/cdk/platform'; import {ViewportRuler} from '@angular/cdk/scrolling'; -import {dispatchMouseEvent} from '@angular/cdk/testing'; +import {dispatchMouseEvent, dispatchTouchEvent} from '@angular/cdk/testing'; import {RIPPLE_FADE_OUT_DURATION, RIPPLE_FADE_IN_DURATION} from './ripple-renderer'; import { MatRipple, MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions @@ -107,6 +107,20 @@ describe('MatRipple', () => { expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(2); }); + it('should launch ripples on touchstart', fakeAsync(() => { + dispatchTouchEvent(rippleTarget, 'touchstart'); + expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(1); + + tick(RIPPLE_FADE_IN_DURATION); + expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(1); + + dispatchTouchEvent(rippleTarget, 'touchend'); + + tick(RIPPLE_FADE_OUT_DURATION); + + expect(rippleTarget.querySelectorAll('.mat-ripple-element').length).toBe(0); + })); + it('removes ripple after timeout', fakeAsync(() => { dispatchMouseEvent(rippleTarget, 'mousedown'); dispatchMouseEvent(rippleTarget, 'mouseup'); From ce6cc0bb78d93c9dddbb5b34831092905e2af387 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 29 Sep 2017 13:03:44 -0700 Subject: [PATCH 166/575] Make `isFocusTrapEnabled` internal, removing it from docs. (#7298) BREAKING CHANGE: `isFocusTrapEnabled` is now properly marked internal. --- src/cdk/a11y/focus-trap.spec.ts | 6 +++--- src/lib/sidenav/drawer.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cdk/a11y/focus-trap.spec.ts b/src/cdk/a11y/focus-trap.spec.ts index 4ccae5688498..debc77a138f4 100644 --- a/src/cdk/a11y/focus-trap.spec.ts +++ b/src/cdk/a11y/focus-trap.spec.ts @@ -103,7 +103,7 @@ describe('FocusTrap', () => { expect(anchors.every(current => current.getAttribute('tabindex') === '0')).toBe(true); - fixture.componentInstance.isFocusTrapEnabled = false; + fixture.componentInstance._isFocusTrapEnabled = false; fixture.detectChanges(); expect(anchors.every(current => current.getAttribute('tabindex') === '-1')).toBe(true); @@ -172,7 +172,7 @@ class SimpleFocusTrap { @Component({ template: ` -
+
@@ -181,7 +181,7 @@ class SimpleFocusTrap { class FocusTrapWithBindings { @ViewChild(FocusTrapDirective) focusTrapDirective: FocusTrapDirective; renderFocusTrap = true; - isFocusTrapEnabled = true; + _isFocusTrapEnabled = true; } diff --git a/src/lib/sidenav/drawer.ts b/src/lib/sidenav/drawer.ts index 9cf024098eb5..deb90d49abb2 100644 --- a/src/lib/sidenav/drawer.ts +++ b/src/lib/sidenav/drawer.ts @@ -211,7 +211,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy { */ _modeChanged = new Subject(); - get isFocusTrapEnabled() { + get _isFocusTrapEnabled() { // The focus trap is only enabled when the drawer is open in any mode other than side. return this.opened && this.mode !== 'side'; } @@ -224,7 +224,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy { this._elementFocusedBeforeDrawerWasOpened = this._doc.activeElement as HTMLElement; } - if (this.isFocusTrapEnabled && this._focusTrap) { + if (this._isFocusTrapEnabled && this._focusTrap) { this._focusTrap.focusInitialElementWhenReady(); } }); @@ -251,7 +251,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy { ngAfterContentInit() { this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement); - this._focusTrap.enabled = this.isFocusTrapEnabled; + this._focusTrap.enabled = this._isFocusTrapEnabled; this._enableAnimations = true; } @@ -301,7 +301,7 @@ export class MatDrawer implements AfterContentInit, OnDestroy { }); if (this._focusTrap) { - this._focusTrap.enabled = this.isFocusTrapEnabled; + this._focusTrap.enabled = this._isFocusTrapEnabled; } } From 86bea9174b68c86a9c7bdd8c9c61be2d287014f9 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:04:13 +0200 Subject: [PATCH 167/575] fix(select): losing focus when selecting values through binding (#7296) Fixes an issue that caused focus to be lost after selecting a value on a select that doesn't use Angular forms. Fixes #7092. --- src/lib/select/select.spec.ts | 15 +++++++++++++++ src/lib/select/select.ts | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index e6fc6bbe910b..57e9d54b2cef 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -872,6 +872,21 @@ describe('MatSelect', () => { expect(trigger.textContent).toContain('Steak, Pizza, Sandwich'); }); + it('should restore focus to the host element', () => { + const fixture = TestBed.createComponent(BasicSelectWithoutForms); + + fixture.detectChanges(); + fixture.debugElement.query(By.css('.mat-select-trigger')).nativeElement.click(); + fixture.detectChanges(); + + (overlayContainerElement.querySelector('md-option') as HTMLElement).click(); + fixture.detectChanges(); + + const select = fixture.debugElement.nativeElement.querySelector('md-select'); + + expect(document.activeElement).toBe(select, 'Expected trigger to be focused.'); + }); + }); describe('disabled behavior', () => { diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 7e5dfacbb073..634617007a51 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -351,8 +351,10 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit, @Input() get value() { return this._value; } set value(newValue: any) { - this.writeValue(newValue); - this._value = newValue; + if (newValue !== this._value) { + this.writeValue(newValue); + this._value = newValue; + } } private _value: any; From d9ba13fc590294032c374ad822e6fa637b7d3fee Mon Sep 17 00:00:00 2001 From: tinayuangao Date: Fri, 29 Sep 2017 13:04:25 -0700 Subject: [PATCH 168/575] fix(chips): do not set chips value if there's no ngControl or value (#7285) --- src/lib/chips/chip-list.spec.ts | 34 +++++++++++++++++++++++++++++++++ src/lib/chips/chip-list.ts | 6 ++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/lib/chips/chip-list.spec.ts b/src/lib/chips/chip-list.spec.ts index 5b7e9e2e25e5..ba9ca9c80a43 100644 --- a/src/lib/chips/chip-list.spec.ts +++ b/src/lib/chips/chip-list.spec.ts @@ -41,6 +41,7 @@ describe('MatChipList', () => { InputChipList, MultiSelectionChipList, FalsyValueChipList, + SelectedChipList ], providers: [{ provide: Directionality, useFactory: () => { @@ -63,6 +64,21 @@ describe('MatChipList', () => { }); }); + describe('with selected chips', () => { + beforeEach(async(() => { + fixture = TestBed.createComponent(SelectedChipList); + fixture.detectChanges(); + })); + + it('should not override chips selected', () => { + const instanceChips = fixture.componentInstance.chips.toArray(); + + expect(instanceChips[0].selected).toBe(true, 'Expected first option to be selected.'); + expect(instanceChips[1].selected).toBe(false, 'Expected second option to be not selected.'); + expect(instanceChips[2].selected).toBe(true, 'Expected third option to be selected.'); + }); + }); + describe('focus behaviors', () => { beforeEach(async(() => { setupStandardList(); @@ -1027,3 +1043,21 @@ class FalsyValueChipList { control = new FormControl(); @ViewChildren(MatChip) chips: QueryList; } + +@Component({ + template: ` + + + {{ food.viewValue }} + + + ` +}) +class SelectedChipList { + foods: any[] = [ + { value: 0, viewValue: 'Steak', selected: true }, + { value: 1, viewValue: 'Pizza', selected: false }, + { value: 2, viewValue: 'Pasta', selected: true }, + ]; + @ViewChildren(MdChip) chips: QueryList; +} diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index 879d1cda432b..844315d01eb7 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -570,8 +570,10 @@ export class MatChipList implements MatFormFieldControl, ControlValueAccess // Defer setting the value in order to avoid the "Expression // has changed after it was checked" errors from Angular. Promise.resolve().then(() => { - this._setSelectionByValue(this.ngControl ? this.ngControl.value : this._value, false); - this.stateChanges.next(); + if (this.ngControl || this._value) { + this._setSelectionByValue(this.ngControl ? this.ngControl.value : this._value, false); + this.stateChanges.next(); + } }); } From 4122ae2b101bd7c2e5f16fa47bfc65403576dc96 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:04:33 +0200 Subject: [PATCH 169/575] fix(stepper): align appearance with spec (#7279) Aligns the stepper appearance closer to the spec by: * Removing the focused background when focused by mouse. Now it only shows up for programmatic and keyboard focus. * Adding ripples to the step header. * Using a slightly heavier font font the active step. * Using `cursor: pointer` to show that the step is clickable. Fixes #7260. --- src/lib/stepper/_stepper-theme.scss | 17 ++++++++++++++++- src/lib/stepper/step-header.html | 4 +++- src/lib/stepper/step-header.scss | 14 ++++++++++++++ src/lib/stepper/step-header.ts | 22 ++++++++++++++++++++-- src/lib/stepper/stepper-module.ts | 7 +++++-- src/lib/stepper/stepper.scss | 5 ----- 6 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/lib/stepper/_stepper-theme.scss b/src/lib/stepper/_stepper-theme.scss index c7b17278a122..47458fb80614 100644 --- a/src/lib/stepper/_stepper-theme.scss +++ b/src/lib/stepper/_stepper-theme.scss @@ -8,7 +8,8 @@ $primary: map-get($theme, primary); .mat-step-header { - &:focus, + &.cdk-keyboard-focused, + &.cdk-program-focused, &:hover { background-color: mat-color($background, hover); } @@ -50,4 +51,18 @@ .mat-stepper-vertical, .mat-stepper-horizontal { font-family: mat-font-family($config); } + + .mat-step-label { + font: { + size: mat-font-size($config, body-1); + weight: mat-font-weight($config, body-1); + }; + } + + .mat-step-label-selected { + font: { + size: mat-font-size($config, body-2); + weight: mat-font-weight($config, body-2); + }; + } } diff --git a/src/lib/stepper/step-header.html b/src/lib/stepper/step-header.html index 57b983544512..580a382e4b22 100644 --- a/src/lib/stepper/step-header.html +++ b/src/lib/stepper/step-header.html @@ -1,3 +1,4 @@ +
@@ -6,7 +7,8 @@ done
+ [class.mat-step-label-active]="active" + [class.mat-step-label-selected]="selected"> diff --git a/src/lib/stepper/step-header.scss b/src/lib/stepper/step-header.scss index 33cb813902ac..6d775486c4d0 100644 --- a/src/lib/stepper/step-header.scss +++ b/src/lib/stepper/step-header.scss @@ -1,3 +1,5 @@ +@import '../core/style/layout-common'; + $mat-stepper-label-header-height: 24px !default; $mat-stepper-label-min-width: 50px !default; $mat-stepper-side-gap: 24px !default; @@ -6,6 +8,13 @@ $mat-stepper-line-gap: 8px !default; $mat-step-optional-font-size: 12px; $mat-step-header-icon-size: 16px !default; +.mat-step-header { + overflow: hidden; + outline: none; + cursor: pointer; + position: relative; +} + .mat-step-optional { font-size: $mat-step-optional-font-size; } @@ -39,3 +48,8 @@ $mat-step-header-icon-size: 16px !default; text-overflow: ellipsis; overflow: hidden; } + +.mat-step-header-ripple { + @include mat-fill; + pointer-events: none; +} diff --git a/src/lib/stepper/step-header.ts b/src/lib/stepper/step-header.ts index 3b87ea8d4932..ccba9d7da358 100644 --- a/src/lib/stepper/step-header.ts +++ b/src/lib/stepper/step-header.ts @@ -6,8 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ +import {FocusMonitor} from '@angular/cdk/a11y'; import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; -import {Component, Input, ViewEncapsulation} from '@angular/core'; +import {Component, Input, ViewEncapsulation, ElementRef, OnDestroy, Renderer2} from '@angular/core'; +import {MATERIAL_COMPATIBILITY_MODE} from '@angular/material/core'; import {MatStepLabel} from './step-label'; @@ -23,7 +25,7 @@ import {MatStepLabel} from './step-label'; encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, }) -export class MatStepHeader { +export class MatStepHeader implements OnDestroy { /** Icon for the given step. */ @Input() icon: string; @@ -62,6 +64,17 @@ export class MatStepHeader { } private _optional: boolean; + constructor( + private _focusMonitor: FocusMonitor, + private _element: ElementRef, + renderer: Renderer2) { + _focusMonitor.monitor(_element.nativeElement, renderer, true); + } + + ngOnDestroy() { + this._focusMonitor.stopMonitoring(this._element.nativeElement); + } + /** Returns string label of given step if it is a text label. */ _stringLabel(): string | null { return this.label instanceof MatStepLabel ? null : this.label; @@ -71,4 +84,9 @@ export class MatStepHeader { _templateLabel(): MatStepLabel | null { return this.label instanceof MatStepLabel ? this.label : null; } + + /** Returns the host HTML element. */ + _getHostElement() { + return this._element.nativeElement; + } } diff --git a/src/lib/stepper/stepper-module.ts b/src/lib/stepper/stepper-module.ts index 31d0751b644d..02f8b4f65867 100644 --- a/src/lib/stepper/stepper-module.ts +++ b/src/lib/stepper/stepper-module.ts @@ -6,12 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ +import {A11yModule} from '@angular/cdk/a11y'; import {PortalModule} from '@angular/cdk/portal'; import {CdkStepperModule} from '@angular/cdk/stepper'; import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; -import {MatCommonModule} from '@angular/material/core'; +import {MatCommonModule, MatRippleModule} from '@angular/material/core'; import {MatIconModule} from '@angular/material/icon'; import {MatStepHeader} from './step-header'; import {MatStepLabel} from './step-label'; @@ -26,7 +27,9 @@ import {MatStepperNext, MatStepperPrevious} from './stepper-button'; PortalModule, MatButtonModule, CdkStepperModule, - MatIconModule + MatIconModule, + A11yModule, + MatRippleModule, ], exports: [ MatCommonModule, diff --git a/src/lib/stepper/stepper.scss b/src/lib/stepper/stepper.scss index b05c8ef8672d..3d207a2f3670 100644 --- a/src/lib/stepper/stepper.scss +++ b/src/lib/stepper/stepper.scss @@ -12,11 +12,6 @@ $mat-stepper-line-gap: 8px !default; display: block; } -.mat-step-header { - overflow: hidden; - outline: none; -} - .mat-horizontal-stepper-header-container { white-space: nowrap; display: flex; From 39543a3bf23b96f95677a3c0bde80d048ef1f854 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:05:08 +0200 Subject: [PATCH 170/575] fix(slider): change event is not being emitted (#7278) * In some situations, the change event of the `` is not being emitted if the user drags the thumb of the slider. This is because the `slidestart` event fires a second time before the sliding ends. This causes the slider to think that there was no value change. Fixes #7207 --- src/lib/slider/slider.spec.ts | 27 +++++++++++++++++++++++++++ src/lib/slider/slider.ts | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/lib/slider/slider.spec.ts b/src/lib/slider/slider.spec.ts index c8afaa626383..4846abddebe9 100644 --- a/src/lib/slider/slider.spec.ts +++ b/src/lib/slider/slider.spec.ts @@ -142,6 +142,33 @@ describe('MatSlider without forms', () => { expect(sliderNativeElement.classList).not.toContain('mat-slider-sliding'); }); + it('should not change value without emitting a change event', () => { + const onChangeSpy = jasmine.createSpy('slider onChange'); + + sliderInstance.change.subscribe(onChangeSpy); + sliderInstance.value = 50; + fixture.detectChanges(); + + dispatchSlideStartEvent(sliderNativeElement, 0, gestureConfig); + fixture.detectChanges(); + + dispatchSlideEvent(sliderNativeElement, 10, gestureConfig); + fixture.detectChanges(); + + // In some situations, HammerJS will fire a second "slidestart" event because the user + // holds the thumb and drags it around. This would mean that the `_valueOnSlideStart` + // value will be updated to the actual end value. Causing the slider to think that the value + // didn't change at all. + dispatchSlideStartEvent(sliderNativeElement, 10, gestureConfig); + fixture.detectChanges(); + + dispatchSlideEndEvent(sliderNativeElement, 10, gestureConfig); + fixture.detectChanges(); + + expect(sliderNativeElement.classList).not.toContain('mat-slider-sliding'); + expect(onChangeSpy).toHaveBeenCalledTimes(1); + }); + it('should reset active state upon blur', () => { sliderInstance._isActive = true; diff --git a/src/lib/slider/slider.ts b/src/lib/slider/slider.ts index e3d2a838327a..d9cf7dadac61 100644 --- a/src/lib/slider/slider.ts +++ b/src/lib/slider/slider.ts @@ -492,7 +492,7 @@ export class MatSlider extends _MatSliderMixinBase } _onSlideStart(event: HammerInput | null) { - if (this.disabled) { + if (this.disabled || this._isSliding) { return; } From f076390010bffe5a4640867ff85b237cf1e21562 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:05:19 +0200 Subject: [PATCH 171/575] fix(input): don't highlight container when readonly input is focused (#7273) Prevents readonly inputs from being highlighted when they're focused. This is consistent with the native input behavior. Note: This was introduced initially through #5776, but it looks like it didn't make it through the transition to `mat-form-field`. --- src/lib/input/input.spec.ts | 16 ++++++++++++++++ src/lib/input/input.ts | 8 +++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lib/input/input.spec.ts b/src/lib/input/input.spec.ts index 1743fca7fde3..b3ba3a3ded67 100644 --- a/src/lib/input/input.spec.ts +++ b/src/lib/input/input.spec.ts @@ -697,6 +697,22 @@ describe('MatInput without forms', function () { expect(inputContainer._shouldAlwaysFloat).toBe(true); expect(inputContainer.floatPlaceholder).toBe('always'); }); + + it('should not highlight when focusing a readonly input', () => { + let fixture = TestBed.createComponent(MatInputWithReadonlyInput); + fixture.detectChanges(); + + let input = fixture.debugElement.query(By.directive(MatInput)).injector.get(MatInput); + let container = fixture.debugElement.query(By.css('mat-form-field')).nativeElement; + + // Call the focus handler directly to avoid flakyness where + // browsers don't focus elements if the window is minimized. + input._focusChanged(true); + fixture.detectChanges(); + + expect(input.focused).toBe(false); + expect(container.classList).not.toContain('mat-focused'); + }); }); describe('MatInput with forms', () => { diff --git a/src/lib/input/input.ts b/src/lib/input/input.ts index c8f357117244..c1681a97c2bf 100644 --- a/src/lib/input/input.ts +++ b/src/lib/input/input.ts @@ -76,6 +76,7 @@ export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, protected _uid = `mat-input-${nextUniqueId++}`; protected _errorOptions: ErrorOptions; protected _previousNativeValue = this.value; + private _readonly = false; /** Whether the input is focused. */ focused = false; @@ -141,6 +142,11 @@ export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, } } + /** Whether the element is readonly. */ + @Input() + get readonly() { return this._readonly; } + set readonly(value: any) { this._readonly = coerceBooleanProperty(value); } + protected _neverEmptyInputTypes = [ 'date', 'datetime', @@ -205,7 +211,7 @@ export class MatInput implements MatFormFieldControl, OnChanges, OnDestroy, /** Callback for the cases where the focused state of the input changes. */ _focusChanged(isFocused: boolean) { - if (isFocused !== this.focused) { + if (isFocused !== this.focused && !this.readonly) { this.focused = isFocused; this.stateChanges.next(); } From 5f8615fdbcc52fe7ff9f3a9dad8adf7da390a1f4 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:05:49 +0200 Subject: [PATCH 172/575] fix(autocomplete): don't open panel for readonly inputs (#7271) Prevents the autocomplete panel from opening if the associated input is readonly. Fixes #7269. --- src/lib/autocomplete/autocomplete-trigger.ts | 6 ++++-- src/lib/autocomplete/autocomplete.spec.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index 9fb0e8a763b1..f4f27bfa2c9f 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -296,8 +296,10 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { } _handleFocus(): void { - this._attachOverlay(); - this._floatPlaceholder(true); + if (!this._element.nativeElement.readOnly) { + this._attachOverlay(); + this._floatPlaceholder(true); + } } /** diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index eb3e117a2d15..c5e5b007faa9 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -118,6 +118,20 @@ describe('MatAutocomplete', () => { }); })); + it('should not open the panel on focus if the input is readonly', async(() => { + const trigger = fixture.componentInstance.trigger; + input.readOnly = true; + fixture.detectChanges(); + + expect(trigger.panelOpen).toBe(false, 'Expected panel state to start out closed.'); + dispatchFakeEvent(input, 'focusin'); + + fixture.whenStable().then(() => { + fixture.detectChanges(); + expect(trigger.panelOpen).toBe(false, 'Expected panel to stay closed.'); + }); + })); + it('should open the panel programmatically', async(() => { expect(fixture.componentInstance.trigger.panelOpen) .toBe(false, `Expected panel state to start out closed.`); From 6be046261a14172e3a91a4a38400dd22d8fcfcfa Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:06:03 +0200 Subject: [PATCH 173/575] fix(autocomplete): empty not cleaning up on tab (#7270) Fixes an issue that caused the autocomplete not to be cleaned up when the user tabs away, if there were no results when the autocomplete was open. Fixes #7268. --- src/lib/autocomplete/autocomplete-trigger.ts | 12 ++++---- src/lib/autocomplete/autocomplete.spec.ts | 29 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index f4f27bfa2c9f..c353518e57ff 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -7,7 +7,7 @@ */ import {Directionality} from '@angular/cdk/bidi'; -import {DOWN_ARROW, ENTER, ESCAPE, UP_ARROW} from '@angular/cdk/keycodes'; +import {DOWN_ARROW, ENTER, ESCAPE, UP_ARROW, TAB} from '@angular/cdk/keycodes'; import { ConnectedPositionStrategy, Overlay, @@ -259,19 +259,21 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { } _handleKeydown(event: KeyboardEvent): void { - if (event.keyCode === ESCAPE && this.panelOpen) { + const keyCode = event.keyCode; + + if (keyCode === ESCAPE && this.panelOpen) { this._resetActiveItem(); this.closePanel(); event.stopPropagation(); - } else if (this.activeOption && event.keyCode === ENTER && this.panelOpen) { + } else if (this.activeOption && keyCode === ENTER && this.panelOpen) { this.activeOption._selectViaInteraction(); this._resetActiveItem(); event.preventDefault(); } else { const prevActiveItem = this.autocomplete._keyManager.activeItem; - const isArrowKey = event.keyCode === UP_ARROW || event.keyCode === DOWN_ARROW; + const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW; - if (this.panelOpen) { + if (this.panelOpen || keyCode === TAB) { this.autocomplete._keyManager.onKeydown(event); } else if (isArrowKey) { this.openPanel(); diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index c5e5b007faa9..a92d5b312668 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -1,9 +1,14 @@ import {Direction, Directionality} from '@angular/cdk/bidi'; -import {DOWN_ARROW, ENTER, ESCAPE, SPACE, UP_ARROW} from '@angular/cdk/keycodes'; +import {DOWN_ARROW, ENTER, ESCAPE, SPACE, UP_ARROW, TAB} from '@angular/cdk/keycodes'; import {OverlayContainer} from '@angular/cdk/overlay'; import {map, RxChain, startWith} from '@angular/cdk/rxjs'; import {ScrollDispatcher} from '@angular/cdk/scrolling'; -import {createKeyboardEvent, dispatchFakeEvent, typeInElement} from '@angular/cdk/testing'; +import { + createKeyboardEvent, + dispatchKeyboardEvent, + dispatchFakeEvent, + typeInElement, +} from '@angular/cdk/testing'; import { ChangeDetectionStrategy, Component, @@ -958,6 +963,26 @@ describe('MatAutocomplete', () => { }); })); + it('should close the panel when tabbing away from a trigger without results', async(() => { + const trigger = fixture.componentInstance.trigger; + + fixture.componentInstance.states = []; + fixture.componentInstance.filteredStates = []; + fixture.detectChanges(); + input.focus(); + + fixture.whenStable().then(() => { + expect(overlayContainerElement.querySelector('.mat-autocomplete-panel')) + .toBeTruthy('Expected panel to be rendered.'); + + dispatchKeyboardEvent(input, 'keydown', TAB); + fixture.detectChanges(); + + expect(overlayContainerElement.querySelector('.mat-autocomplete-panel')) + .toBeFalsy('Expected panel to be removed.'); + }); + })); + it('should reset the active option when closing with the escape key', fakeAsync(() => { const trigger = fixture.componentInstance.trigger; From eb012cc9b750684cf9796e193adfc39855e4a86b Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:06:18 +0200 Subject: [PATCH 174/575] fix(calendar): not reacting to min/max boundary changes (#7234) Fixes the calendar not re-rendering when the `minDate`, `maxDate` or `dateFilter` change. The issue was due to the fact that the `minDate`, `maxDate` and `dateFilter` weren't being passed down to the views via `@Input`. Fixes #7202. --- src/lib/datepicker/calendar.spec.ts | 51 +++++++++++++++++++++++++++++ src/lib/datepicker/calendar.ts | 25 +++++++++++++- src/lib/datepicker/month-view.ts | 7 ++-- src/lib/datepicker/year-view.ts | 7 ++-- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/lib/datepicker/calendar.spec.ts b/src/lib/datepicker/calendar.spec.ts index 35d1c4bcfeae..d5fe98145610 100644 --- a/src/lib/datepicker/calendar.spec.ts +++ b/src/lib/datepicker/calendar.spec.ts @@ -528,6 +528,57 @@ describe('MatCalendar', () => { expect(calendarInstance._activeDate).toEqual(new Date(2018, JAN, 1)); }); + + it('should re-render the month view when the minDate changes', () => { + fixture.detectChanges(); + spyOn(calendarInstance.monthView, '_init').and.callThrough(); + + testComponent.minDate = new Date(2017, NOV, 1); + fixture.detectChanges(); + + expect(calendarInstance.monthView._init).toHaveBeenCalled(); + }); + + it('should re-render the month view when the maxDate changes', () => { + fixture.detectChanges(); + spyOn(calendarInstance.monthView, '_init').and.callThrough(); + + testComponent.maxDate = new Date(2017, DEC, 1); + fixture.detectChanges(); + + expect(calendarInstance.monthView._init).toHaveBeenCalled(); + }); + + it('should re-render the year view when the minDate changes', () => { + fixture.detectChanges(); + const periodButton = + calendarElement.querySelector('.mat-calendar-period-button') as HTMLElement; + periodButton.click(); + fixture.detectChanges(); + + spyOn(calendarInstance.yearView, '_init').and.callThrough(); + + testComponent.minDate = new Date(2017, NOV, 1); + fixture.detectChanges(); + + expect(calendarInstance.yearView._init).toHaveBeenCalled(); + }); + + it('should re-render the year view when the maxDate changes', () => { + fixture.detectChanges(); + const periodButton = + calendarElement.querySelector('.mat-calendar-period-button') as HTMLElement; + periodButton.click(); + fixture.detectChanges(); + + spyOn(calendarInstance.yearView, '_init').and.callThrough(); + + testComponent.maxDate = new Date(2017, DEC, 1); + fixture.detectChanges(); + + expect(calendarInstance.yearView._init).toHaveBeenCalled(); + }); + }); describe('calendar with date filter', () => { diff --git a/src/lib/datepicker/calendar.ts b/src/lib/datepicker/calendar.ts index a046757fdbce..e73d36795b73 100644 --- a/src/lib/datepicker/calendar.ts +++ b/src/lib/datepicker/calendar.ts @@ -31,6 +31,9 @@ import { Optional, Output, ViewEncapsulation, + ViewChild, + OnChanges, + SimpleChanges, } from '@angular/core'; import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {first} from 'rxjs/operator/first'; @@ -38,6 +41,8 @@ import {Subscription} from 'rxjs/Subscription'; import {coerceDateProperty} from './coerce-date-property'; import {createMissingDateImplError} from './datepicker-errors'; import {MatDatepickerIntl} from './datepicker-intl'; +import {MatMonthView} from './month-view'; +import {MatYearView} from './year-view'; /** @@ -56,7 +61,7 @@ import {MatDatepickerIntl} from './datepicker-intl'; preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class MatCalendar implements AfterContentInit, OnDestroy { +export class MatCalendar implements AfterContentInit, OnDestroy, OnChanges { private _intlChanges: Subscription; /** A date representing the period (month or year) to start the calendar in. */ @@ -95,6 +100,12 @@ export class MatCalendar implements AfterContentInit, OnDestroy { /** Emits when any date is selected. */ @Output() userSelection = new EventEmitter(); + /** Reference to the current month view component. */ + @ViewChild(MatMonthView) monthView: MatMonthView; + + /** Reference to the current year view component. */ + @ViewChild(MatYearView) yearView: MatYearView; + /** Date filter for the month and year views. */ _dateFilterForViews = (date: D) => { return !!date && @@ -166,6 +177,18 @@ export class MatCalendar implements AfterContentInit, OnDestroy { this._intlChanges.unsubscribe(); } + ngOnChanges(changes: SimpleChanges) { + const change = changes.minDate || changes.maxDate || changes.dateFilter; + + if (change && !change.firstChange) { + const view = this.monthView || this.yearView; + + if (view) { + view._init(); + } + } + } + /** Handles date selection in the month view. */ _dateSelected(date: D): void { if (!this._dateAdapter.sameDate(date, this.selected)) { diff --git a/src/lib/datepicker/month-view.ts b/src/lib/datepicker/month-view.ts index 4ac52fe8b251..f7a4c2fc4ac8 100644 --- a/src/lib/datepicker/month-view.ts +++ b/src/lib/datepicker/month-view.ts @@ -16,6 +16,7 @@ import { Optional, Output, ViewEncapsulation, + ChangeDetectorRef, } from '@angular/core'; import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {MatCalendarCell} from './calendar-body'; @@ -93,7 +94,8 @@ export class MatMonthView implements AfterContentInit { _weekdays: {long: string, narrow: string}[]; constructor(@Optional() public _dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats) { + @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, + private _changeDetectorRef: ChangeDetectorRef) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); } @@ -132,7 +134,7 @@ export class MatMonthView implements AfterContentInit { } /** Initializes this month view. */ - private _init() { + _init() { this._selectedDate = this._getDateInCurrentMonth(this.selected); this._todayDate = this._getDateInCurrentMonth(this._dateAdapter.today()); this._monthLabel = @@ -146,6 +148,7 @@ export class MatMonthView implements AfterContentInit { this._dateAdapter.getFirstDayOfWeek()) % DAYS_PER_WEEK; this._createWeekCells(); + this._changeDetectorRef.markForCheck(); } /** Creates MatCalendarCells for the dates in this month. */ diff --git a/src/lib/datepicker/year-view.ts b/src/lib/datepicker/year-view.ts index 11f95149e317..36c3c1babade 100644 --- a/src/lib/datepicker/year-view.ts +++ b/src/lib/datepicker/year-view.ts @@ -16,6 +16,7 @@ import { Optional, Output, ViewEncapsulation, + ChangeDetectorRef, } from '@angular/core'; import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats} from '@angular/material/core'; import {MatCalendarCell} from './calendar-body'; @@ -79,7 +80,8 @@ export class MatYearView implements AfterContentInit { _selectedMonth: number | null; constructor(@Optional() public _dateAdapter: DateAdapter, - @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats) { + @Optional() @Inject(MAT_DATE_FORMATS) private _dateFormats: MatDateFormats, + private _changeDetectorRef: ChangeDetectorRef) { if (!this._dateAdapter) { throw createMissingDateImplError('DateAdapter'); } @@ -104,7 +106,7 @@ export class MatYearView implements AfterContentInit { } /** Initializes this month view. */ - private _init() { + _init() { this._selectedMonth = this._getMonthInCurrentYear(this.selected); this._todayMonth = this._getMonthInCurrentYear(this._dateAdapter.today()); this._yearLabel = this._dateAdapter.getYearName(this.activeDate); @@ -113,6 +115,7 @@ export class MatYearView implements AfterContentInit { // First row of months only contains 5 elements so we can fit the year label on the same row. this._months = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]].map(row => row.map( month => this._createCellForMonth(month, monthNames[month]))); + this._changeDetectorRef.markForCheck(); } /** From c7ab828b0a630b20b9499aa35207d63a198d4927 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:06:49 +0200 Subject: [PATCH 175/575] fix(select): multiple change events emitted when changing options of a closed select (#7232) Prevents two change events being fired the same change when selecting an option via the arrow keys on a closed select. Fixes #7227. --- src/lib/select/select.spec.ts | 8 ++++++++ src/lib/select/select.ts | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 57e9d54b2cef..8a8bb96260df 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -2336,6 +2336,14 @@ describe('MatSelect', () => { expect(fixture.componentInstance.changeListener).toHaveBeenCalledTimes(1); }); + + it('should only emit one event when pressing the arrow keys on a closed select', () => { + const select = fixture.debugElement.query(By.css('md-select')).nativeElement; + dispatchKeyboardEvent(select, 'keydown', DOWN_ARROW); + + expect(fixture.componentInstance.changeListener).toHaveBeenCalledTimes(1); + }); + }); describe('floatPlaceholder option', () => { diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 634617007a51..8a5f3d46259d 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -1135,7 +1135,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit, if (currentActiveItem !== prevActiveItem) { this._clearSelection(); this._setSelectionByValue(currentActiveItem.value, true); - this._propagateChanges(); } } } From ba5653db2098fe247b4594f641ac878ab95d4a33 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:06:57 +0200 Subject: [PATCH 176/575] fix(drawer): open event not firing on init (#7214) Fixes a regression that caused the drawer not to fire its `open` event if it is open on init. Fixes #7208. --- src/lib/sidenav/drawer.spec.ts | 15 +++++++++++++-- src/lib/sidenav/drawer.ts | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/sidenav/drawer.spec.ts b/src/lib/sidenav/drawer.spec.ts index d5e36955528a..f5f0b458b150 100644 --- a/src/lib/sidenav/drawer.spec.ts +++ b/src/lib/sidenav/drawer.spec.ts @@ -126,6 +126,15 @@ describe('MatDrawer', () => { expect(testComponent.closeCount).toBe(1, 'Expected one close event.'); })); + it('should fire the open event when open on init', fakeAsync(() => { + let fixture = TestBed.createComponent(DrawerSetToOpenedTrue); + + fixture.detectChanges(); + tick(); + + expect(fixture.componentInstance.openCallback).toHaveBeenCalledTimes(1); + })); + it('should not close by pressing escape when disableClose is set', fakeAsync(() => { let fixture = TestBed.createComponent(BasicTestApp); let testComponent = fixture.debugElement.componentInstance; @@ -430,12 +439,14 @@ class DrawerSetToOpenedFalse { } @Component({ template: ` - + Closed Drawer. `, }) -class DrawerSetToOpenedTrue { } +class DrawerSetToOpenedTrue { + openCallback = jasmine.createSpy('open callback'); +} @Component({ template: ` diff --git a/src/lib/sidenav/drawer.ts b/src/lib/sidenav/drawer.ts index deb90d49abb2..95b1ac23eece 100644 --- a/src/lib/sidenav/drawer.ts +++ b/src/lib/sidenav/drawer.ts @@ -329,9 +329,9 @@ export class MatDrawer implements AfterContentInit, OnDestroy { _onAnimationEnd(event: AnimationEvent) { const {fromState, toState} = event; - if (toState === 'open' && fromState === 'void') { + if (toState.indexOf('open') === 0 && fromState === 'void') { this.onOpen.emit(new MatDrawerToggleResult('open', true)); - } else if (toState === 'void' && fromState === 'open') { + } else if (toState === 'void' && fromState.indexOf('open') === 0) { this.onClose.emit(new MatDrawerToggleResult('close', true)); } From 217840c5b9c26a4584ea79306ba28b9d71d50859 Mon Sep 17 00:00:00 2001 From: NothingEverHappens Date: Fri, 29 Sep 2017 16:07:35 -0400 Subject: [PATCH 177/575] fix(stepper): selected is always undefined (#7213) --- src/cdk/stepper/stepper.ts | 2 +- src/lib/stepper/stepper.spec.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cdk/stepper/stepper.ts b/src/cdk/stepper/stepper.ts index 30b12781b759..d4637008ec1b 100644 --- a/src/cdk/stepper/stepper.ts +++ b/src/cdk/stepper/stepper.ts @@ -150,7 +150,7 @@ export class CdkStepper { /** The step that is selected. */ @Input() - get selected() { return this._steps[this.selectedIndex]; } + get selected() { return this._steps.toArray()[this.selectedIndex]; } set selected(step: CdkStep) { this.selectedIndex = this._steps.toArray().indexOf(step); } diff --git a/src/lib/stepper/stepper.spec.ts b/src/lib/stepper/stepper.spec.ts index eebd89f6dee9..76904b22a16a 100644 --- a/src/lib/stepper/stepper.spec.ts +++ b/src/lib/stepper/stepper.spec.ts @@ -10,7 +10,6 @@ import {MatStepperModule} from './index'; import {MatHorizontalStepper, MatStepper, MatVerticalStepper} from './stepper'; import {MatStepperNext, MatStepperPrevious} from './stepper-button'; - const VALID_REGEX = /valid/; describe('MatHorizontalStepper', () => { @@ -307,6 +306,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture, let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance; expect(stepperComponent.selectedIndex).toBe(0); + expect(stepperComponent.selected instanceof MdStep).toBe(true); // select the second step let stepHeaderEl = stepHeaders[1].nativeElement; @@ -314,6 +314,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture, fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(1); + expect(stepperComponent.selected instanceof MdStep).toBe(true); // select the third step stepHeaderEl = stepHeaders[2].nativeElement; @@ -321,6 +322,7 @@ function assertSelectionChangeOnHeaderClick(fixture: ComponentFixture, fixture.detectChanges(); expect(stepperComponent.selectedIndex).toBe(2); + expect(stepperComponent.selected instanceof MdStep).toBe(true); } /** Asserts that 'aria-expanded' attribute is correct for expanded content of step. */ From f19f19cf637f417f4dbf5662dd09c45f7d641999 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 29 Sep 2017 13:08:09 -0700 Subject: [PATCH 178/575] Set selected state of list option item in selection list OnInit. (#7189) --- src/lib/list/selection-list.spec.ts | 35 +++++++++++++++++++++++++++++ src/lib/list/selection-list.ts | 10 +++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/lib/list/selection-list.spec.ts b/src/lib/list/selection-list.spec.ts index 457d0b1532ea..0c692695d4a3 100644 --- a/src/lib/list/selection-list.spec.ts +++ b/src/lib/list/selection-list.spec.ts @@ -219,6 +219,34 @@ describe('MatSelectionList', () => { }); }); + describe('with list option selected', () => { + let fixture: ComponentFixture; + let listItemEl: DebugElement; + let selectionList: DebugElement; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [MdListModule], + declarations: [SelectionListWithSelecedOption], + }); + + TestBed.compileComponents(); + })); + + beforeEach(async(() => { + fixture = TestBed.createComponent(SelectionListWithSelecedOption); + listItemEl = fixture.debugElement.query(By.directive(MdListOption)); + selectionList = fixture.debugElement.query(By.directive(MdSelectionList)); + fixture.detectChanges(); + })); + + it('should set its initial selected state in the selectedOptions', () => { + let optionEl = listItemEl.injector.get(MdListOption); + let selectedOptions = selectionList.componentInstance.selectedOptions; + expect(selectedOptions.isSelected(optionEl)).toBeTruthy(); + }); + }); + describe('with single option', () => { let fixture: ComponentFixture; let listOption: DebugElement; @@ -456,6 +484,13 @@ class SelectionListWithDisabledOption { disableItem: boolean = false; } +@Component({template: ` + + Item + `}) +class SelectionListWithSelecedOption { +} + @Component({template: ` diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index 3f939fa600c7..f476fa95cd9a 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -23,6 +23,7 @@ import { Inject, Input, OnDestroy, + OnInit, Optional, Output, QueryList, @@ -82,8 +83,7 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class MatListOption extends _MatListOptionMixinBase - implements AfterContentInit, OnDestroy, FocusableOption, CanDisableRipple { - + implements AfterContentInit, OnInit, OnDestroy, FocusableOption, CanDisableRipple { private _lineSetter: MatLineSetter; private _selected: boolean = false; private _disabled: boolean = false; @@ -129,6 +129,12 @@ export class MatListOption extends _MatListOptionMixinBase super(); } + ngOnInit() { + if (this.selected) { + this.selectionList.selectedOptions.select(this); + } + } + ngAfterContentInit() { this._lineSetter = new MatLineSetter(this._lines, this._renderer, this._element); From 2d350a0893886481ed1cac13da79b4e0130605d5 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:08:25 +0200 Subject: [PATCH 179/575] feat(sort): add enter and leave arrow animations (#7180) Adds animations for when the sorting arrow is added and removed from the DOM. --- src/lib/sort/sort-header.html | 2 +- src/lib/sort/sort-header.ts | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/lib/sort/sort-header.html b/src/lib/sort/sort-header.html index bf16458d5038..b181902952cf 100644 --- a/src/lib/sort/sort-header.html +++ b/src/lib/sort/sort-header.html @@ -5,7 +5,7 @@ -
+
diff --git a/src/lib/sort/sort-header.ts b/src/lib/sort/sort-header.ts index 5cf719da9017..87f497d40c23 100644 --- a/src/lib/sort/sort-header.ts +++ b/src/lib/sort/sort-header.ts @@ -20,7 +20,8 @@ import { state, style, animate, - transition + transition, + keyframes, } from '@angular/animations'; import {CdkColumnDef} from '@angular/cdk/table'; import {Subscription} from 'rxjs/Subscription'; @@ -70,6 +71,24 @@ const SORT_ANIMATION_TRANSITION = state('asc', style({transform: 'rotate(45deg)'})), state('desc', style({transform: 'rotate(-45deg)'})), transition('asc <=> desc', animate(SORT_ANIMATION_TRANSITION)) + ]), + trigger('indicatorToggle', [ + transition('void => asc', animate(SORT_ANIMATION_TRANSITION, keyframes([ + style({transform: 'translateY(25%)', opacity: 0}), + style({transform: 'none', opacity: 1}) + ]))), + transition('asc => void', animate(SORT_ANIMATION_TRANSITION, keyframes([ + style({transform: 'none', opacity: 1}), + style({transform: 'translateY(-25%)', opacity: 0}) + ]))), + transition('void => desc', animate(SORT_ANIMATION_TRANSITION, keyframes([ + style({transform: 'translateY(-25%)', opacity: 0}), + style({transform: 'none', opacity: 1}) + ]))), + transition('desc => void', animate(SORT_ANIMATION_TRANSITION, keyframes([ + style({transform: 'none', opacity: 1}), + style({transform: 'translateY(25%)', opacity: 0}) + ]))), ]) ] }) From f8cd7906ff22dd7383aaca38cbd781ddb534ec0c Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:10:18 +0200 Subject: [PATCH 180/575] feat(autocomplete): add md-autocomplete classes to overlay panel (#7176) Transfers any classes added to `md-autocomplete` to the resulting panel, allowing for easier styling similarly to `md-menu`. Fixes #4196. --- src/lib/autocomplete/autocomplete.html | 2 +- src/lib/autocomplete/autocomplete.spec.ts | 21 +++++++++++++++++- src/lib/autocomplete/autocomplete.ts | 26 ++++++++++++++--------- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/lib/autocomplete/autocomplete.html b/src/lib/autocomplete/autocomplete.html index 41227961fe5c..aa27ebc27c47 100644 --- a/src/lib/autocomplete/autocomplete.html +++ b/src/lib/autocomplete/autocomplete.html @@ -1,5 +1,5 @@ -
+
diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index a92d5b312668..638745d29ef6 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -1521,6 +1521,25 @@ describe('MatAutocomplete', () => { expect(placeholder.classList).not.toContain('mat-form-field-empty'); })); + it('should transfer the mat-autocomplete classes to the panel element', fakeAsync(() => { + const fixture = TestBed.createComponent(SimpleAutocomplete); + fixture.detectChanges(); + + fixture.componentInstance.trigger.openPanel(); + tick(); + fixture.detectChanges(); + + const autocomplete = fixture.debugElement.nativeElement.querySelector('mat-autocomplete'); + const panel = overlayContainerElement.querySelector('.mat-autocomplete-panel')!; + + expect(autocomplete.classList).not.toContain('class-one'); + expect(autocomplete.classList).not.toContain('class-two'); + + expect(panel.classList).toContain('class-one'); + expect(panel.classList).toContain('class-two'); + })); + + }); it('should have correct width when opened', () => { @@ -1646,7 +1665,7 @@ describe('MatAutocomplete', () => { - + {{ state.code }}: {{ state.name }} diff --git a/src/lib/autocomplete/autocomplete.ts b/src/lib/autocomplete/autocomplete.ts index 86b415352932..8113bacb19c9 100644 --- a/src/lib/autocomplete/autocomplete.ts +++ b/src/lib/autocomplete/autocomplete.ts @@ -77,10 +77,23 @@ export class MatAutocomplete implements AfterContentInit { @Output() optionSelected: EventEmitter = new EventEmitter(); + /** + * Takes classes set on the host md-autocomplete element and applies them to the panel + * inside the overlay container to allow for easy styling. + */ + @Input('class') + set classList(classList: string) { + if (classList && classList.length) { + classList.split(' ').forEach(className => this._classList[className.trim()] = true); + this._elementRef.nativeElement.className = ''; + } + } + _classList: {[key: string]: boolean} = {}; + /** Unique ID to be used by autocomplete trigger's "aria-owns" property. */ id: string = `mat-autocomplete-${_uniqueAutocompleteIdCounter++}`; - constructor(private _changeDetectorRef: ChangeDetectorRef) { } + constructor(private _changeDetectorRef: ChangeDetectorRef, private _elementRef: ElementRef) { } ngAfterContentInit() { this._keyManager = new ActiveDescendantKeyManager(this.options).withWrap(); @@ -105,6 +118,8 @@ export class MatAutocomplete implements AfterContentInit { _setVisibility(): void { Promise.resolve().then(() => { this.showPanel = !!this.options.length; + this._classList['mat-autocomplete-visible'] = this.showPanel; + this._classList['mat-autocomplete-hidden'] = !this.showPanel; this._changeDetectorRef.markForCheck(); }); } @@ -114,14 +129,5 @@ export class MatAutocomplete implements AfterContentInit { const event = new MatAutocompleteSelectedEvent(this, option); this.optionSelected.emit(event); } - - /** Sets a class on the panel based on whether it is visible. */ - _getClassList() { - return { - 'mat-autocomplete-visible': this.showPanel, - 'mat-autocomplete-hidden': !this.showPanel - }; - } - } From c5c96d9f6d9b5df87e44873790d54b338a55e155 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 29 Sep 2017 13:10:30 -0700 Subject: [PATCH 181/575] - Remove extra `` blocks in example. (#7149) - Add isOpen attribute to `MdAutocomplete` component. --- src/demo-app/autocomplete/autocomplete-demo.html | 13 ------------- src/lib/autocomplete/autocomplete-trigger.ts | 4 ++-- src/lib/autocomplete/autocomplete.spec.ts | 11 +++++++++++ src/lib/autocomplete/autocomplete.ts | 8 ++++++++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/demo-app/autocomplete/autocomplete-demo.html b/src/demo-app/autocomplete/autocomplete-demo.html index e31478d10b25..3a844aa81a8a 100644 --- a/src/demo-app/autocomplete/autocomplete-demo.html +++ b/src/demo-app/autocomplete/autocomplete-demo.html @@ -66,19 +66,6 @@
- - - {{ state.name }} - ({{state.code}}) - - - - - - {{ state.name }} - - - diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index c353518e57ff..15cfe649a844 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -169,7 +169,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { this._resetPlaceholder(); if (this._panelOpen) { - this._panelOpen = false; + this.autocomplete._isOpen = this._panelOpen = false; // We need to trigger change detection manually, because // `fromEvent` doesn't seem to do it at the proper time. @@ -454,7 +454,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { } this.autocomplete._setVisibility(); - this._panelOpen = true; + this.autocomplete._isOpen = this._panelOpen = true; } private _getOverlayConfig(): OverlayConfig { diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index 638745d29ef6..3096f21e8fc2 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -409,6 +409,17 @@ describe('MatAutocomplete', () => { expect(inputContainer._animateAndLockPlaceholder).toHaveBeenCalled(); }); + it('should provide the open state of the panel', async(() => { + expect(fixture.componentInstance.panel.isOpen).toBeFalsy( + `Expected the panel to be unopened initially.`); + + dispatchFakeEvent(input, 'focusin'); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(fixture.componentInstance.panel.isOpen).toBeTruthy( + `Expected the panel to be opened on focus.`); + }); + })); }); it('should have the correct text direction in RTL', () => { diff --git a/src/lib/autocomplete/autocomplete.ts b/src/lib/autocomplete/autocomplete.ts index 8113bacb19c9..f1df42923710 100644 --- a/src/lib/autocomplete/autocomplete.ts +++ b/src/lib/autocomplete/autocomplete.ts @@ -58,6 +58,12 @@ export class MatAutocomplete implements AfterContentInit { /** Whether the autocomplete panel should be visible, depending on option length. */ showPanel = false; + /** Whether the autocomplete panel is open. */ + get isOpen(): boolean { + return this._isOpen && this.showPanel; + } + _isOpen: boolean = false; + /** @docs-private */ @ViewChild(TemplateRef) template: TemplateRef; @@ -97,6 +103,8 @@ export class MatAutocomplete implements AfterContentInit { ngAfterContentInit() { this._keyManager = new ActiveDescendantKeyManager(this.options).withWrap(); + // Set the initial visibiity state. + this._setVisibility(); } /** From c5e162b1b0b6cbf9a50f075651c13dcc9312062e Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:10:43 +0200 Subject: [PATCH 182/575] fix(radio): defaulting to invalid name attribute (#7131) Fixes the radio button defaulting to `name="undefined"` for the underlying input, if the consumer hasn't passed in a name. Relates to #7130. --- src/lib/radio/radio.html | 2 +- src/lib/radio/radio.spec.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/radio/radio.html b/src/lib/radio/radio.html index c6280776061d..bd68e10b34ff 100644 --- a/src/lib/radio/radio.html +++ b/src/lib/radio/radio.html @@ -15,7 +15,7 @@ [id]="inputId" [checked]="checked" [disabled]="disabled" - [name]="name" + [attr.name]="name" [required]="required" [attr.aria-label]="ariaLabel" [attr.aria-labelledby]="ariaLabelledby" diff --git a/src/lib/radio/radio.spec.ts b/src/lib/radio/radio.spec.ts index 96f0447a9f37..88c3b1175a85 100644 --- a/src/lib/radio/radio.spec.ts +++ b/src/lib/radio/radio.spec.ts @@ -638,6 +638,12 @@ describe('MatRadio', () => { expect(document.activeElement).toBe(fruitRadioNativeInputs[i]); } }); + + it('should not add the "name" attribute if it is not passed in', () => { + const radio = fixture.debugElement.nativeElement.querySelector('#nameless input'); + expect(radio.hasAttribute('name')).toBe(false); + }); + }); describe('with tabindex', () => { @@ -711,6 +717,7 @@ class RadiosInsideRadioGroup { [aria-labelledby]="ariaLabelledby"> Raspberry + No name ` }) class StandaloneRadioButtons { From 26788f19c77ce1061c405c62e8ad1f2696d185fe Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:11:08 +0200 Subject: [PATCH 183/575] fix(checkbox): defaulting to invalid name and value attributes (#7130) Fixes the checkbox defaulting to `name="null"` and `value="undefined"` for the underlying input, if the user hasn't passed them in. --- src/lib/checkbox/checkbox.html | 4 ++-- src/lib/checkbox/checkbox.spec.ts | 11 +++++++++++ src/lib/checkbox/checkbox.ts | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib/checkbox/checkbox.html b/src/lib/checkbox/checkbox.html index 1361d9362485..3174c6804464 100644 --- a/src/lib/checkbox/checkbox.html +++ b/src/lib/checkbox/checkbox.html @@ -6,9 +6,9 @@ [id]="inputId" [required]="required" [checked]="checked" - [value]="value" + [attr.value]="value" [disabled]="disabled" - [name]="name" + [attr.name]="name" [tabIndex]="tabIndex" [indeterminate]="indeterminate" [attr.aria-label]="ariaLabel" diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index 73b6f50177f6..d71a3daeb225 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -873,6 +873,17 @@ describe('MatCheckbox', () => { .not.toContain('mat-checkbox-inner-container-no-side-margin'); }, 1); })); + + it('should not add the "name" attribute if it is not passed in', () => { + fixture.detectChanges(); + expect(checkboxInnerContainer.querySelector('input')!.hasAttribute('name')).toBe(false); + }); + + it('should not add the "value" attribute if it is not passed in', () => { + fixture.detectChanges(); + expect(checkboxInnerContainer.querySelector('input')!.hasAttribute('value')).toBe(false); + }); + }); }); diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index 97ffec3de20d..c17cc728bc0d 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -169,7 +169,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc @Output() indeterminateChange: EventEmitter = new EventEmitter(); /** The value attribute of the native input element */ - @Input() value: string ; + @Input() value: string; /** The native ` element */ @ViewChild('input') _inputElement: ElementRef; From e05f93981aa1e966f265ec1c9691c04af63eb773 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:11:22 +0200 Subject: [PATCH 184/575] fix(selection-list): restore focus if active item is destroyed (#7125) * Removes the `destroyed` and `onFocus` observables and instead just calls methods on the injected `MdSelectionList` instance. * Fixes that the active item is not updating if the active item is being destroyed. --- src/lib/list/selection-list.spec.ts | 50 ++++++++++------- src/lib/list/selection-list.ts | 87 +++++++++-------------------- 2 files changed, 55 insertions(+), 82 deletions(-) diff --git a/src/lib/list/selection-list.spec.ts b/src/lib/list/selection-list.spec.ts index 0c692695d4a3..3fa335190d87 100644 --- a/src/lib/list/selection-list.spec.ts +++ b/src/lib/list/selection-list.spec.ts @@ -1,6 +1,6 @@ import {DOWN_ARROW, SPACE, UP_ARROW} from '@angular/cdk/keycodes'; import {Platform} from '@angular/cdk/platform'; -import {createKeyboardEvent} from '@angular/cdk/testing'; +import {createKeyboardEvent, dispatchFakeEvent} from '@angular/cdk/testing'; import {Component, DebugElement} from '@angular/core'; import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; @@ -28,24 +28,29 @@ describe('MatSelectionList', () => { TestBed.compileComponents(); })); + beforeEach(async(() => { fixture = TestBed.createComponent(SelectionListWithListOptions); + fixture.detectChanges(); + listOption = fixture.debugElement.queryAll(By.directive(MatListOption)); listItemEl = fixture.debugElement.query(By.css('.mat-list-item')); selectionList = fixture.debugElement.query(By.directive(MatSelectionList)); - fixture.detectChanges(); })); it('should add and remove focus class on focus/blur', () => { - expect(listItemEl.nativeElement.classList).not.toContain('mat-list-item-focus'); + // Use the second list item, because the first one is always disabled. + const listItem = listOption[1].nativeElement; - listOption[0].componentInstance._handleFocus(); + expect(listItem.classList).not.toContain('mat-list-item-focus'); + + dispatchFakeEvent(listItem, 'focus'); fixture.detectChanges(); - expect(listItemEl.nativeElement.className).toContain('mat-list-item-focus'); + expect(listItem.className).toContain('mat-list-item-focus'); - listOption[0].componentInstance._handleBlur(); + dispatchFakeEvent(listItem, 'blur'); fixture.detectChanges(); - expect(listItemEl.nativeElement.className).not.toContain('mat-list-item-focus'); + expect(listItem.className).not.toContain('mat-list-item-focus'); }); it('should be able to set a value on a list option', () => { @@ -144,12 +149,9 @@ describe('MatSelectionList', () => { createKeyboardEvent('keydown', SPACE, testListItem); let selectList = selectionList.injector.get(MatSelectionList).selectedOptions; - let options = selectionList.componentInstance.options; - let array = options.toArray(); - let focusItem = array[1]; expect(selectList.selected.length).toBe(0); - focusItem.focus(); + dispatchFakeEvent(testListItem, 'focus'); selectionList.componentInstance._keydown(SPACE_EVENT); fixture.detectChanges(); @@ -157,16 +159,26 @@ describe('MatSelectionList', () => { expect(selectList.selected.length).toBe(1); }); + it('should restore focus if active option is destroyed', () => { + const manager = selectionList.componentInstance._keyManager; + + listOption[3].componentInstance._handleFocus(); + + expect(manager.activeItemIndex).toBe(3); + + fixture.componentInstance.showLastOption = false; + fixture.detectChanges(); + + expect(manager.activeItemIndex).toBe(2); + }); + it('should focus previous item when press UP ARROW', () => { let testListItem = listOption[2].nativeElement as HTMLElement; let UP_EVENT: KeyboardEvent = createKeyboardEvent('keydown', UP_ARROW, testListItem); - let options = selectionList.componentInstance.options; - let array = options.toArray(); - let focusItem = array[2]; let manager = selectionList.componentInstance._keyManager; - focusItem.focus(); + dispatchFakeEvent(listOption[2].nativeElement, 'focus'); expect(manager.activeItemIndex).toEqual(2); selectionList.componentInstance._keydown(UP_EVENT); @@ -180,12 +192,9 @@ describe('MatSelectionList', () => { let testListItem = listOption[2].nativeElement as HTMLElement; let DOWN_EVENT: KeyboardEvent = createKeyboardEvent('keydown', DOWN_ARROW, testListItem); - let options = selectionList.componentInstance.options; - let array = options.toArray(); - let focusItem = array[2]; let manager = selectionList.componentInstance._keyManager; - focusItem.focus(); + dispatchFakeEvent(listOption[2].nativeElement, 'focus'); expect(manager.activeItemIndex).toEqual(2); selectionList.componentInstance._keydown(DOWN_EVENT); @@ -432,11 +441,12 @@ describe('MatSelectionList', () => { Sent Mail - + Drafts `}) class SelectionListWithListOptions { + showLastOption: boolean = true; } @Component({template: ` diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index f476fa95cd9a..80fe6de4eab8 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -10,7 +10,6 @@ import {FocusableOption, FocusKeyManager} from '@angular/cdk/a11y'; import {coerceBooleanProperty} from '@angular/cdk/coercion'; import {SelectionModel} from '@angular/cdk/collections'; import {SPACE} from '@angular/cdk/keycodes'; -import {RxChain, startWith, switchMap} from '@angular/cdk/rxjs'; import { AfterContentInit, ChangeDetectionStrategy, @@ -38,8 +37,6 @@ import { mixinDisabled, mixinDisableRipple, } from '@angular/material/core'; -import {merge} from 'rxjs/observable/merge'; -import {Subscription} from 'rxjs/Subscription'; /** @docs-private */ @@ -55,8 +52,6 @@ export interface MatSelectionListOptionEvent { option: MatListOption; } -const FOCUSED_STYLE: string = 'mat-list-item-focus'; - /** * Component for list-options of selection-list. Each list-option can automatically * generate a checkbox and can put current item into the selectionModel of selection-list @@ -70,10 +65,11 @@ const FOCUSED_STYLE: string = 'mat-list-item-focus'; 'role': 'option', 'class': 'mat-list-item mat-list-option', '(focus)': '_handleFocus()', - '(blur)': '_handleBlur()', + '(blur)': '_hasFocus = false', '(click)': '_handleClick()', 'tabindex': '-1', '[class.mat-list-item-disabled]': 'disabled', + '[class.mat-list-item-focus]': '_hasFocus', '[attr.aria-selected]': 'selected.toString()', '[attr.aria-disabled]': 'disabled.toString()', }, @@ -109,18 +105,12 @@ export class MatListOption extends _MatListOptionMixinBase get selected() { return this._selected; } set selected(value: boolean) { this._selected = coerceBooleanProperty(value); } - /** Emitted when the option is focused. */ - onFocus = new EventEmitter(); - /** Emitted when the option is selected. */ @Output() selectChange = new EventEmitter(); /** Emitted when the option is deselected. */ @Output() deselected = new EventEmitter(); - /** Emitted when the option is destroyed. */ - @Output() destroyed = new EventEmitter(); - constructor(private _renderer: Renderer2, private _element: ElementRef, private _changeDetector: ChangeDetectorRef, @@ -144,7 +134,7 @@ export class MatListOption extends _MatListOptionMixinBase } ngOnDestroy(): void { - this.destroyed.emit({option: this}); + this.selectionList._removeOptionFromList(this); } /** Toggles the selection state of the option. */ @@ -157,7 +147,6 @@ export class MatListOption extends _MatListOptionMixinBase /** Allows for programmatic focusing of the option. */ focus(): void { this._element.nativeElement.focus(); - this.onFocus.emit({option: this}); } /** Whether this list item should show a ripple effect when clicked. */ @@ -173,11 +162,7 @@ export class MatListOption extends _MatListOptionMixinBase _handleFocus() { this._hasFocus = true; - this._renderer.addClass(this._element.nativeElement, FOCUSED_STYLE); - } - - _handleBlur() { - this._renderer.removeClass(this._element.nativeElement, FOCUSED_STYLE); + this.selectionList._setFocusedOption(this); } /** Retrieves the DOM element of the component host. */ @@ -208,17 +193,11 @@ export class MatListOption extends _MatListOptionMixinBase changeDetection: ChangeDetectionStrategy.OnPush }) export class MatSelectionList extends _MatSelectionListMixinBase - implements FocusableOption, CanDisable, CanDisableRipple, AfterContentInit, OnDestroy { + implements FocusableOption, CanDisable, CanDisableRipple, AfterContentInit { /** Tab index for the selection-list. */ _tabIndex = 0; - /** Subscription to all list options' onFocus events */ - private _optionFocusSubscription = Subscription.EMPTY; - - /** Subscription to all list options' destroy events */ - private _optionDestroyStream = Subscription.EMPTY; - /** The FocusKeyManager which handles focus. */ _keyManager: FocusKeyManager; @@ -238,14 +217,6 @@ export class MatSelectionList extends _MatSelectionListMixinBase if (this.disabled) { this._tabIndex = -1; } - - this._optionFocusSubscription = this._onFocusSubscription(); - this._optionDestroyStream = this._onDestroySubscription(); - } - - ngOnDestroy(): void { - this._optionDestroyStream.unsubscribe(); - this._optionFocusSubscription.unsubscribe(); } /** Focus the selection-list. */ @@ -271,36 +242,23 @@ export class MatSelectionList extends _MatSelectionListMixinBase }); } - /** Map all the options' destroy event subscriptions and merge them into one stream. */ - private _onDestroySubscription(): Subscription { - return RxChain.from(this.options.changes) - .call(startWith, this.options) - .call(switchMap, (options: MatListOption[]) => { - return merge(...options.map(option => option.destroyed)); - }).subscribe((e: MatSelectionListOptionEvent) => { - let optionIndex: number = this.options.toArray().indexOf(e.option); - if (e.option._hasFocus) { - // Check whether the option is the last item - if (optionIndex < this.options.length - 1) { - this._keyManager.setActiveItem(optionIndex); - } else if (optionIndex - 1 >= 0) { - this._keyManager.setActiveItem(optionIndex - 1); - } - } - e.option.destroyed.unsubscribe(); - }); + /** Sets the focused option of the selection-list. */ + _setFocusedOption(option: MatListOption) { + this._keyManager.updateActiveItemIndex(this._getOptionIndex(option)); } - /** Map all the options' onFocus event subscriptions and merge them into one stream. */ - private _onFocusSubscription(): Subscription { - return RxChain.from(this.options.changes) - .call(startWith, this.options) - .call(switchMap, (options: MatListOption[]) => { - return merge(...options.map(option => option.onFocus)); - }).subscribe((e: MatSelectionListOptionEvent) => { - let optionIndex: number = this.options.toArray().indexOf(e.option); - this._keyManager.updateActiveItemIndex(optionIndex); - }); + /** Removes an option from the selection list and updates the active item. */ + _removeOptionFromList(option: MatListOption) { + if (option._hasFocus) { + const optionIndex = this._getOptionIndex(option); + + // Check whether the option is the last item + if (optionIndex > 0) { + this._keyManager.setPreviousItemActive(); + } else if (optionIndex === 0 && this.options.length > 1) { + this._keyManager.setNextItemActive(); + } + } } /** Passes relevant key presses to our key manager. */ @@ -338,4 +296,9 @@ export class MatSelectionList extends _MatSelectionListMixinBase private _isValidIndex(index: number): boolean { return index >= 0 && index < this.options.length; } + + /** Returns the index of the specified list option. */ + private _getOptionIndex(option: MatListOption): number { + return this.options.toArray().indexOf(option); + } } From daa388013b7fa477b99fcb54cc154e92e94ef05f Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:12:13 +0200 Subject: [PATCH 185/575] fix(dialog): directionality not injected into child components (#7111) Since the `direction` option from the overlay only sets the `dir` attribute, it means that any components that depend on the `Directionality` service (e.g. `md-slider`) won't be able to pick it up. These changes add the proper direction to the custom dialog injector. --- src/lib/dialog/dialog.spec.ts | 12 +++++++++++- src/lib/dialog/dialog.ts | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lib/dialog/dialog.spec.ts b/src/lib/dialog/dialog.spec.ts index dcd1489553d2..1ce22f92d319 100644 --- a/src/lib/dialog/dialog.spec.ts +++ b/src/lib/dialog/dialog.spec.ts @@ -22,6 +22,7 @@ import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {Location} from '@angular/common'; import {SpyLocation} from '@angular/common/testing'; +import {Directionality} from '@angular/cdk/bidi'; import {MatDialogContainer} from './dialog-container'; import {OverlayContainer} from '@angular/cdk/overlay'; import {ESCAPE} from '@angular/cdk/keycodes'; @@ -433,6 +434,14 @@ describe('MatDialog', () => { expect(overlayPane.getAttribute('dir')).toBe('rtl'); }); + it('should inject the correct layout direction in the component instance', () => { + const dialogRef = dialog.open(PizzaMsg, { direction: 'rtl' }); + + viewContainerFixture.detectChanges(); + + expect(dialogRef.componentInstance.directionality.value).toBe('rtl'); + }); + it('should close all of the dialogs', async(() => { dialog.open(PizzaMsg); dialog.open(PizzaMsg); @@ -970,7 +979,8 @@ class ComponentWithTemplateRef { @Component({template: '

Pizza

'}) class PizzaMsg { constructor(public dialogRef: MatDialogRef, - public dialogInjector: Injector) {} + public dialogInjector: Injector, + public directionality: Directionality) {} } @Component({ diff --git a/src/lib/dialog/dialog.ts b/src/lib/dialog/dialog.ts index 2f891d2372d1..38621ce96286 100644 --- a/src/lib/dialog/dialog.ts +++ b/src/lib/dialog/dialog.ts @@ -28,12 +28,14 @@ import { TemplateRef, } from '@angular/core'; import {extendObject} from '@angular/material/core'; +import {Directionality} from '@angular/cdk/bidi'; import {Observable} from 'rxjs/Observable'; import {defer} from 'rxjs/observable/defer'; import {Subject} from 'rxjs/Subject'; import {MatDialogConfig} from './dialog-config'; import {MatDialogContainer} from './dialog-container'; import {MatDialogRef} from './dialog-ref'; +import {of as observableOf} from 'rxjs/observable/of'; export const MAT_DIALOG_DATA = new InjectionToken('MatDialogData'); @@ -277,6 +279,10 @@ export class MatDialog { injectionTokens.set(MatDialogRef, dialogRef); injectionTokens.set(MatDialogContainer, dialogContainer); injectionTokens.set(MAT_DIALOG_DATA, config.data); + injectionTokens.set(Directionality, { + value: config.direction, + change: observableOf() + }); return new PortalInjector(userInjector || this._injector, injectionTokens); } From 6bd6b9f1ebb260eaa2670dfb45bef3702dbc76ed Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:12:25 +0200 Subject: [PATCH 186/575] fix(autocomplete): remove invalid aria markup (#7107) Removes the `aria-multiline` attribute, because it is not allowed on a `role="combobox"`. Fixes #7100. --- src/lib/autocomplete/autocomplete-trigger.ts | 1 - src/lib/autocomplete/autocomplete.spec.ts | 5 ----- 2 files changed, 6 deletions(-) diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index 15cfe649a844..abbc2c0fbda5 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -99,7 +99,6 @@ export function getMatAutocompleteMissingPanelError(): Error { 'role': 'combobox', 'autocomplete': 'off', 'aria-autocomplete': 'list', - 'aria-multiline': 'false', '[attr.aria-activedescendant]': 'activeOption?.id', '[attr.aria-expanded]': 'panelOpen.toString()', '[attr.aria-owns]': 'autocomplete?.id', diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index 3096f21e8fc2..9957cf4b03ba 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -1154,11 +1154,6 @@ describe('MatAutocomplete', () => { .toEqual('list', 'Expected aria-autocomplete attribute to equal list.'); }); - it('should set aria-multiline to false', () => { - expect(input.getAttribute('aria-multiline')) - .toEqual('false', 'Expected aria-multiline attribute to equal false.'); - }); - it('should set aria-activedescendant based on the active option', async(() => { fixture.componentInstance.trigger.openPanel(); fixture.detectChanges(); From 8e7726102b9d41c7bb7fcc08e58af9f276b9a8ab Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:12:47 +0200 Subject: [PATCH 187/575] fix(snack-bar): subsequent snack bars not opening; animation issues (#7086) * Fixes subsequent snack bars not showing up if they are opened while another snack bar is open. This was due to the latter snack bar getting closed immediately, because one of the animation events coming in is `void->void`. * Simplifies the logic for determining the animation state. Using the getter ended up passing returning an invalid state in some cases (e.g. `undefined-top` or `undefined-bottom`). Fixes #7063. --- src/lib/snack-bar/snack-bar-container.ts | 24 ++++++++---------------- src/lib/snack-bar/snack-bar.spec.ts | 14 +++++++------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/lib/snack-bar/snack-bar-container.ts b/src/lib/snack-bar/snack-bar-container.ts index 15288df08ef1..84eeeea76c53 100644 --- a/src/lib/snack-bar/snack-bar-container.ts +++ b/src/lib/snack-bar/snack-bar-container.ts @@ -38,8 +38,6 @@ import {Subject} from 'rxjs/Subject'; import {MatSnackBarConfig} from './snack-bar-config'; -export type SnackBarState = 'visible' | 'hidden' | 'void'; - // TODO(jelbourn): we can't use constants from animation.ts here because you can't use // a text interpolation in anything that is analyzed statically with ngc (for AoT compile). export const SHOW_ANIMATION = '225ms cubic-bezier(0.4,0.0,1,1)'; @@ -60,7 +58,7 @@ export const HIDE_ANIMATION = '195ms cubic-bezier(0.0,0.0,0.2,1)'; host: { 'role': 'alert', 'class': 'mat-snack-bar-container', - '[@state]': 'getAnimationState()', + '[@state]': '_animationState', '(@state.done)': 'onAnimationEnd($event)' }, animations: [ @@ -93,7 +91,7 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy { _onEnter: Subject = new Subject(); /** The state of the snack bar animations. */ - private _animationState: SnackBarState; + _animationState = 'void'; /** The snack bar configuration. */ snackBarConfig: MatSnackBarConfig; @@ -106,14 +104,6 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy { super(); } - /** - * Gets the current animation state both combining one of the possibilities from - * SnackBarState and the vertical location. - */ - getAnimationState(): string { - return `${this._animationState}-${this.snackBarConfig.verticalPosition}`; - } - /** Attach a component portal as content to this snack bar container. */ attachComponentPortal(portal: ComponentPortal): ComponentRef { if (this._portalHost.hasAttached()) { @@ -146,11 +136,13 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy { /** Handle end of animations, updating the state of the snackbar. */ onAnimationEnd(event: AnimationEvent) { - if (event.toState === 'void' || event.toState.startsWith('hidden')) { + const {fromState, toState} = event; + + if ((toState === 'void' && fromState !== 'void') || toState.startsWith('hidden')) { this._completeExit(); } - if (event.toState.startsWith('visible')) { + if (toState.startsWith('visible')) { // Note: we shouldn't use `this` inside the zone callback, // because it can cause a memory leak. const onEnter = this._onEnter; @@ -165,14 +157,14 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy { /** Begin animation of snack bar entrance into view. */ enter(): void { if (!this._destroyed) { - this._animationState = 'visible'; + this._animationState = `visible-${this.snackBarConfig.verticalPosition}`; this._changeDetectorRef.detectChanges(); } } /** Begin animation of the snack bar exiting from view. */ exit(): Observable { - this._animationState = 'hidden'; + this._animationState = `hidden-${this.snackBarConfig.verticalPosition}`; return this._onExit; } diff --git a/src/lib/snack-bar/snack-bar.spec.ts b/src/lib/snack-bar/snack-bar.spec.ts index 91f6adb70f0b..2133b84d810f 100644 --- a/src/lib/snack-bar/snack-bar.spec.ts +++ b/src/lib/snack-bar/snack-bar.spec.ts @@ -186,12 +186,12 @@ describe('MatSnackBar', () => { let snackBarRef = snackBar.open(simpleMessage, undefined, config); viewContainerFixture.detectChanges(); - expect(snackBarRef.containerInstance.getAnimationState()) + expect(snackBarRef.containerInstance._animationState) .toBe('visible-bottom', `Expected the animation state would be 'visible-bottom'.`); snackBarRef.dismiss(); viewContainerFixture.detectChanges(); - expect(snackBarRef.containerInstance.getAnimationState()) + expect(snackBarRef.containerInstance._animationState) .toBe('hidden-bottom', `Expected the animation state would be 'hidden-bottom'.`); }); @@ -201,7 +201,7 @@ describe('MatSnackBar', () => { snackBarRef.dismiss(); viewContainerFixture.detectChanges(); - expect(snackBarRef.containerInstance.getAnimationState()) + expect(snackBarRef.containerInstance._animationState) .toBe('hidden-bottom', `Expected the animation state would be 'hidden-bottom'.`); }); @@ -212,7 +212,7 @@ describe('MatSnackBar', () => { let dismissObservableCompleted = false; viewContainerFixture.detectChanges(); - expect(snackBarRef.containerInstance.getAnimationState()) + expect(snackBarRef.containerInstance._animationState) .toBe('visible-bottom', `Expected the animation state would be 'visible-bottom'.`); let config2 = {viewContainerRef: testViewContainerRef}; @@ -225,9 +225,9 @@ describe('MatSnackBar', () => { viewContainerFixture.whenStable().then(() => { expect(dismissObservableCompleted).toBe(true); - expect(snackBarRef.containerInstance.getAnimationState()) + expect(snackBarRef.containerInstance._animationState) .toBe('hidden-bottom', `Expected the animation state would be 'hidden-bottom'.`); - expect(snackBarRef2.containerInstance.getAnimationState()) + expect(snackBarRef2.containerInstance._animationState) .toBe('visible-bottom', `Expected the animation state would be 'visible-bottom'.`); }); })); @@ -248,7 +248,7 @@ describe('MatSnackBar', () => { // Wait for the snackbar open animation to finish. viewContainerFixture.whenStable().then(() => { - expect(snackBarRef.containerInstance.getAnimationState()) + expect(snackBarRef.containerInstance._animationState) .toBe('visible-bottom', `Expected the animation state would be 'visible-bottom'.`); }); }); From 504ba70abdeb7c3ecdf0eb53e5b8a23867325487 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:13:12 +0200 Subject: [PATCH 188/575] fix(autocomplete): error if panel is added asynchronously (#7078) Fixes an error that was thrown when an autocomplete trigger is initialized without a panel. Note that an error will still be thrown, but only if the user attempts to open the panel. Fixes #7069. --- src/lib/autocomplete/autocomplete-trigger.ts | 4 +++- src/lib/autocomplete/autocomplete.spec.ts | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/autocomplete/autocomplete-trigger.ts b/src/lib/autocomplete/autocomplete-trigger.ts index abbc2c0fbda5..f1622d6c93fc 100644 --- a/src/lib/autocomplete/autocomplete-trigger.ts +++ b/src/lib/autocomplete/autocomplete-trigger.ts @@ -390,7 +390,9 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { } private _setTriggerValue(value: any): void { - const toDisplay = this.autocomplete.displayWith ? this.autocomplete.displayWith(value) : value; + const toDisplay = this.autocomplete && this.autocomplete.displayWith ? + this.autocomplete.displayWith(value) : + value; // Simply falling back to an empty string if the display value is falsy does not work properly. // The display value can also be the number zero and shouldn't fall back to an empty string. diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index 9957cf4b03ba..ed23ad7f38e9 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -1512,6 +1512,15 @@ describe('MatAutocomplete', () => { }).toThrow(getMatAutocompleteMissingPanelError()); })); + it('should not throw on init, even if the panel is not defined', fakeAsync(() => { + expect(() => { + const fixture = TestBed.createComponent(AutocompleteWithoutPanel); + fixture.componentInstance.control.setValue('Something'); + fixture.detectChanges(); + tick(); + }).not.toThrow(); + })); + it('should hide the placeholder with a preselected form control value ' + 'and a disabled floating placeholder', fakeAsync(() => { const fixture = TestBed.createComponent(AutocompleteWithFormsAndNonfloatingPlaceholder); @@ -1885,10 +1894,11 @@ class AutocompleteWithNativeInput { @Component({ - template: `` + template: `` }) class AutocompleteWithoutPanel { @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; + control = new FormControl(); } From c82fca8626b8400861a0e79a57677d71e3ef5b4b Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:13:35 +0200 Subject: [PATCH 189/575] fix(slide-toggle): report change to model before firing a change event (#7076) Whenever the value of the slide-toggle changes through interaction, a `change` event will be emitted. The value change then will be reported to the `ControlValueAccessor` which fires the `ngModelChange` output. Right now the `ngModelChange` output fires after the normal `change` output. This should be the other way around because developers expect the two-way data binding to already reflect the change. Fixes #7074 --- src/lib/slide-toggle/slide-toggle.spec.ts | 29 ++++++++++++++++++++++- src/lib/slide-toggle/slide-toggle.ts | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/lib/slide-toggle/slide-toggle.spec.ts b/src/lib/slide-toggle/slide-toggle.spec.ts index bf50e88ec225..c4234540c725 100644 --- a/src/lib/slide-toggle/slide-toggle.spec.ts +++ b/src/lib/slide-toggle/slide-toggle.spec.ts @@ -563,7 +563,8 @@ describe('MatSlideToggle with forms', () => { declarations: [ SlideToggleWithForm, SlideToggleWithModel, - SlideToggleWithFormControl + SlideToggleWithFormControl, + SlideToggleWithModelAndChangeEvent, ] }); @@ -795,6 +796,24 @@ describe('MatSlideToggle with forms', () => { expect(testComponent.isSubmitted).toBe(true); }); }); + + describe('with model and change event', () => { + it('should report changes to NgModel before emitting change event', () => { + const fixture = TestBed.createComponent(SlideToggleWithModelAndChangeEvent); + fixture.detectChanges(); + + const labelEl = fixture.debugElement.query(By.css('label')).nativeElement; + + spyOn(fixture.componentInstance, 'onChange').and.callFake(() => { + expect(fixture.componentInstance.checked) + .toBe(true, 'Expected the model value to have changed before the change event fired.'); + }); + + labelEl.click(); + + expect(fixture.componentInstance.onChange).toHaveBeenCalledTimes(1); + }); + }); }); @Component({ @@ -873,3 +892,11 @@ class SlideToggleWithTabindexAttr {} class SlideToggleWithoutLabel { label: string; } + +@Component({ + template: `` +}) +class SlideToggleWithModelAndChangeEvent { + checked: boolean; + onChange: () => void = () => {}; +} diff --git a/src/lib/slide-toggle/slide-toggle.ts b/src/lib/slide-toggle/slide-toggle.ts index 1bd02ed5ed40..240052f138e4 100644 --- a/src/lib/slide-toggle/slide-toggle.ts +++ b/src/lib/slide-toggle/slide-toggle.ts @@ -251,8 +251,8 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro let event = new MatSlideToggleChange(); event.source = this; event.checked = this.checked; - this.change.emit(event); this.onChange(this.checked); + this.change.emit(event); } _onDragStart() { From b0b91f430799ed807bbdb011f054d743b5141ce3 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:13:50 +0200 Subject: [PATCH 190/575] fix(drawer): drawer container not reacting to drawer removal (#7060) Fixes the drawer container not reacting if one of the drawers is destroyed. Fixes #6271. --- src/lib/sidenav/drawer.spec.ts | 63 +++++++++++++++++++++++++++++++++- src/lib/sidenav/drawer.ts | 27 ++++++++++----- 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/src/lib/sidenav/drawer.spec.ts b/src/lib/sidenav/drawer.spec.ts index f5f0b458b150..d5e03ec8fa4e 100644 --- a/src/lib/sidenav/drawer.spec.ts +++ b/src/lib/sidenav/drawer.spec.ts @@ -323,7 +323,11 @@ describe('MatDrawerContainer', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [MatSidenavModule, A11yModule, PlatformModule, NoopAnimationsModule], - declarations: [DrawerContainerTwoDrawerTestApp, DrawerDelayed], + declarations: [ + DrawerContainerTwoDrawerTestApp, + DrawerDelayed, + DrawerContainerStateChangesTestApp, + ], }); TestBed.compileComponents(); @@ -372,6 +376,47 @@ describe('MatDrawerContainer', () => { expect(parseInt(contentElement.style.marginLeft)).toBeGreaterThan(0); })); + + it('should recalculate the margin if a drawer is destroyed', fakeAsync(() => { + const fixture = TestBed.createComponent(DrawerContainerStateChangesTestApp); + + fixture.detectChanges(); + fixture.componentInstance.drawer.open(); + fixture.detectChanges(); + tick(); + fixture.detectChanges(); + + const contentElement = fixture.debugElement.nativeElement.querySelector('.mat-drawer-content'); + const initialMargin = parseInt(contentElement.style.marginLeft); + + expect(initialMargin).toBeGreaterThan(0); + + fixture.componentInstance.renderDrawer = false; + fixture.detectChanges(); + + expect(parseInt(contentElement.style.marginLeft)).toBeLessThan(initialMargin); + })); + + it('should recalculate the margin if the drawer mode is changed', fakeAsync(() => { + const fixture = TestBed.createComponent(DrawerContainerStateChangesTestApp); + + fixture.detectChanges(); + fixture.componentInstance.drawer.open(); + fixture.detectChanges(); + tick(); + fixture.detectChanges(); + + const contentElement = fixture.debugElement.nativeElement.querySelector('.mat-drawer-content'); + const initialMargin = parseInt(contentElement.style.marginLeft); + + expect(initialMargin).toBeGreaterThan(0); + + fixture.componentInstance.mode = 'over'; + fixture.detectChanges(); + + expect(parseInt(contentElement.style.marginLeft)).toBeLessThan(initialMargin); + })); + }); @@ -485,3 +530,19 @@ class DrawerDelayed { @ViewChild(MatDrawer) drawer: MatDrawer; showDrawer = false; } + + +@Component({ + template: ` + + + `, +}) +class DrawerContainerStateChangesTestApp { + @ViewChild(MatDrawer) drawer: MatDrawer; + @ViewChild(MatDrawerContainer) drawerContainer: MatDrawerContainer; + + mode = 'side'; + renderDrawer = true; +} + diff --git a/src/lib/sidenav/drawer.ts b/src/lib/sidenav/drawer.ts index 95b1ac23eece..b17f9e03d162 100644 --- a/src/lib/sidenav/drawer.ts +++ b/src/lib/sidenav/drawer.ts @@ -398,8 +398,8 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy { private _left: MatDrawer | null; private _right: MatDrawer | null; - /** Subscription to the Directionality change EventEmitter. */ - private _dirChangeSubscription = Subscription.EMPTY; + /** Emits when the component is destroyed. */ + private _destroyed = new Subject(); _contentMargins = new Subject<{left: number, right: number}>(); @@ -409,23 +409,33 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy { // If a `Dir` directive exists up the tree, listen direction changes and update the left/right // properties to point to the proper start/end. if (_dir != null) { - this._dirChangeSubscription = _dir.change.subscribe(() => this._validateDrawers()); + takeUntil.call(_dir.change, this._destroyed).subscribe(() => this._validateDrawers()); } } ngAfterContentInit() { startWith.call(this._drawers.changes, null).subscribe(() => { this._validateDrawers(); + this._drawers.forEach((drawer: MatDrawer) => { this._watchDrawerToggle(drawer); this._watchDrawerPosition(drawer); this._watchDrawerMode(drawer); }); + + if (!this._drawers.length || + this._isDrawerOpen(this._start) || + this._isDrawerOpen(this._end)) { + this._updateContentMargins(); + } + + this._changeDetectorRef.markForCheck(); }); } ngOnDestroy() { - this._dirChangeSubscription.unsubscribe(); + this._destroyed.next(); + this._destroyed.complete(); } /** Calls `open` of both start and end drawers */ @@ -478,10 +488,11 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy { /** Subscribes to changes in drawer mode so we can run change detection. */ private _watchDrawerMode(drawer: MatDrawer): void { if (drawer) { - takeUntil.call(drawer._modeChanged, this._drawers.changes).subscribe(() => { - this._updateContentMargins(); - this._changeDetectorRef.markForCheck(); - }); + takeUntil.call(drawer._modeChanged, merge(this._drawers.changes, this._destroyed)) + .subscribe(() => { + this._updateContentMargins(); + this._changeDetectorRef.markForCheck(); + }); } } From 2dcb76c8f9661776c407313f4cbf753495b1c82c Mon Sep 17 00:00:00 2001 From: Philip Pham Date: Fri, 29 Sep 2017 13:14:22 -0700 Subject: [PATCH 191/575] fix(menu): multiple close events for a single close (#7037) Don't emit a closed event when another event will be emitted. Previously, if one clicked on a menu item, one would get two events: `undefined` and `click` in that order. One would see similar behavior for `keydown` or clicking the backdrop. Unit tests were updated to prevent a regression. --- src/lib/menu/menu-trigger.ts | 27 +++++++++++++---------- src/lib/menu/menu.spec.ts | 42 ++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/lib/menu/menu-trigger.ts b/src/lib/menu/menu-trigger.ts index 32e520353ee6..81808968e894 100644 --- a/src/lib/menu/menu-trigger.ts +++ b/src/lib/menu/menu-trigger.ts @@ -44,7 +44,6 @@ import {MatMenuItem} from './menu-item'; import {MatMenuPanel} from './menu-panel'; import {MenuPositionX, MenuPositionY} from './menu-positions'; - /** Injection token that determines the scroll handling while the menu is open. */ export const MAT_MENU_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrategy>('mat-menu-scroll-strategy'); @@ -130,7 +129,7 @@ export class MatMenuTrigger implements AfterViewInit, OnDestroy { this._checkMenu(); this.menu.close.subscribe(reason => { - this.closeMenu(); + this._destroyMenu(); // If a click closed the menu, we should close the entire chain of nested menus. if (reason === 'click' && this._parentMenu) { @@ -182,7 +181,9 @@ export class MatMenuTrigger implements AfterViewInit, OnDestroy { openMenu(): void { if (!this._menuOpen) { this._createOverlay().attach(this._portal); - this._closeSubscription = this._menuClosingActions().subscribe(() => this.menu.close.emit()); + this._closeSubscription = this._menuClosingActions().subscribe(() => { + this.menu.close.emit(); + }); this._initMenu(); if (this.menu instanceof MatMenu) { @@ -193,11 +194,20 @@ export class MatMenuTrigger implements AfterViewInit, OnDestroy { /** Closes the menu. */ closeMenu(): void { + this.menu.close.emit(); + } + + /** Focuses the menu trigger. */ + focus() { + this._element.nativeElement.focus(); + } + + /** Closes the menu and does the necessary cleanup. */ + private _destroyMenu() { if (this._overlayRef && this.menuOpen) { this._resetMenu(); this._overlayRef.detach(); this._closeSubscription.unsubscribe(); - this.menu.close.emit(); if (this.menu instanceof MatMenu) { this.menu._resetAnimation(); @@ -205,11 +215,6 @@ export class MatMenuTrigger implements AfterViewInit, OnDestroy { } } - /** Focuses the menu trigger. */ - focus() { - this._element.nativeElement.focus(); - } - /** * This method sets the menu state to open and focuses the first item if * the menu was opened via the keyboard. @@ -377,11 +382,11 @@ export class MatMenuTrigger implements AfterViewInit, OnDestroy { /** Returns a stream that emits whenever an action that should close the menu occurs. */ private _menuClosingActions() { const backdrop = this._overlayRef!.backdropClick(); - const parentClose = this._parentMenu ? this._parentMenu.close : observableOf(null); + const parentClose = this._parentMenu ? this._parentMenu.close : observableOf(); const hover = this._parentMenu ? RxChain.from(this._parentMenu.hover()) .call(filter, active => active !== this._menuItemInstance) .call(filter, () => this._menuOpen) - .result() : observableOf(null); + .result() : observableOf(); return merge(backdrop, parentClose, hover); } diff --git a/src/lib/menu/menu.spec.ts b/src/lib/menu/menu.spec.ts index 1b82873a61d3..0370cd13d8fb 100644 --- a/src/lib/menu/menu.spec.ts +++ b/src/lib/menu/menu.spec.ts @@ -98,7 +98,7 @@ describe('MatMenu', () => { expect(overlayContainerElement.textContent).toBe(''); })); - it('should close the menu when pressing escape', fakeAsync(() => { + it('should close the menu when pressing ESCAPE', fakeAsync(() => { const fixture = TestBed.createComponent(SimpleMenu); fixture.detectChanges(); fixture.componentInstance.trigger.openMenu(); @@ -494,26 +494,40 @@ describe('MatMenu', () => { menuItem.click(); fixture.detectChanges(); - expect(fixture.componentInstance.closeCallback).toHaveBeenCalled(); + expect(fixture.componentInstance.closeCallback).toHaveBeenCalledWith('click'); + expect(fixture.componentInstance.closeCallback).toHaveBeenCalledTimes(1); }); it('should emit a close event when the backdrop is clicked', () => { - const backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop'); + const backdrop = overlayContainerElement + .querySelector('.cdk-overlay-backdrop') as HTMLElement; backdrop.click(); fixture.detectChanges(); - expect(fixture.componentInstance.closeCallback).toHaveBeenCalled(); + expect(fixture.componentInstance.closeCallback).toHaveBeenCalledWith(undefined); + expect(fixture.componentInstance.closeCallback).toHaveBeenCalledTimes(1); + }); + + it('should emit an event when pressing ESCAPE', () => { + const menu = overlayContainerElement.querySelector('.mat-menu-panel') as HTMLElement; + + dispatchKeyboardEvent(menu, 'keydown', ESCAPE); + fixture.detectChanges(); + + expect(fixture.componentInstance.closeCallback).toHaveBeenCalledWith('keydown'); + expect(fixture.componentInstance.closeCallback).toHaveBeenCalledTimes(1); }); it('should complete the callback when the menu is destroyed', () => { - let emitCallback = jasmine.createSpy('emit callback'); - let completeCallback = jasmine.createSpy('complete callback'); + const emitCallback = jasmine.createSpy('emit callback'); + const completeCallback = jasmine.createSpy('complete callback'); fixture.componentInstance.menu.close.subscribe(emitCallback, null, completeCallback); fixture.destroy(); - expect(emitCallback).toHaveBeenCalled(); + expect(emitCallback).toHaveBeenCalledWith(undefined); + expect(emitCallback).toHaveBeenCalledTimes(1); expect(completeCallback).toHaveBeenCalled(); }); }); @@ -995,6 +1009,9 @@ describe('MatMenu', () => { tick(500); expect(overlay.querySelectorAll('.mat-menu-panel').length).toBe(0, 'Expected no open menus'); + expect(instance.rootCloseCallback).toHaveBeenCalledTimes(1); + expect(instance.levelOneCloseCallback).toHaveBeenCalledTimes(1); + expect(instance.levelTwoCloseCallback).toHaveBeenCalledTimes(1); })); it('should toggle a nested menu when its trigger is added after init', fakeAsync(() => { @@ -1059,7 +1076,7 @@ describe('MatMenu default overrides', () => { @Component({ template: ` - + @@ -1152,7 +1169,7 @@ class CustomMenu { [matMenuTriggerFor]="levelTwo" #alternateTrigger="matMenuTrigger">Toggle alternate menu - + - + - + @@ -1192,12 +1209,15 @@ class NestedMenu { @ViewChild('rootTrigger') rootTrigger: MatMenuTrigger; @ViewChild('rootTriggerEl') rootTriggerEl: ElementRef; @ViewChild('alternateTrigger') alternateTrigger: MatMenuTrigger; + readonly rootCloseCallback = jasmine.createSpy('root menu closed callback'); @ViewChild('levelOne') levelOneMenu: MatMenu; @ViewChild('levelOneTrigger') levelOneTrigger: MatMenuTrigger; + readonly levelOneCloseCallback = jasmine.createSpy('level one menu closed callback'); @ViewChild('levelTwo') levelTwoMenu: MatMenu; @ViewChild('levelTwoTrigger') levelTwoTrigger: MatMenuTrigger; + readonly levelTwoCloseCallback = jasmine.createSpy('level one menu closed callback'); @ViewChild('lazy') lazyMenu: MatMenu; @ViewChild('lazyTrigger') lazyTrigger: MatMenuTrigger; From 2129b7a7f9567480ab6e5d347ae4aa9fa02c323d Mon Sep 17 00:00:00 2001 From: mmalerba Date: Fri, 29 Sep 2017 13:14:42 -0700 Subject: [PATCH 192/575] fix(datepicker): make sure _datepickerInput exists before accessing its (#7033) * fix(datepicker): make sure _datepickerInput exists before accessing its disabled property. * add test --- src/lib/datepicker/datepicker.spec.ts | 4 ++++ src/lib/datepicker/datepicker.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/datepicker/datepicker.spec.ts b/src/lib/datepicker/datepicker.spec.ts index 3f87fc50749d..c9d0ff8768ee 100644 --- a/src/lib/datepicker/datepicker.spec.ts +++ b/src/lib/datepicker/datepicker.spec.ts @@ -304,6 +304,10 @@ describe('MatDatepicker', () => { fixture.detectChanges(); })); + it('should not throw when accessing disabled property', () => { + expect(() => testComponent.datepicker.disabled).not.toThrow(); + }); + it('should throw when opened with no registered inputs', async(() => { expect(() => testComponent.datepicker.open()).toThrow(); })); diff --git a/src/lib/datepicker/datepicker.ts b/src/lib/datepicker/datepicker.ts index cc25a957df13..cbd4c0da8cf7 100644 --- a/src/lib/datepicker/datepicker.ts +++ b/src/lib/datepicker/datepicker.ts @@ -147,7 +147,8 @@ export class MatDatepicker implements OnDestroy { /** Whether the datepicker pop-up should be disabled. */ @Input() get disabled() { - return this._disabled === undefined ? this._datepickerInput.disabled : this._disabled; + return this._disabled === undefined && this._datepickerInput ? + this._datepickerInput.disabled : this._disabled; } set disabled(value: any) { const newValue = coerceBooleanProperty(value); From 947d3e84d1c032a4f11a5c83a36e34b6bd5f45b1 Mon Sep 17 00:00:00 2001 From: Marcelo Luz Date: Fri, 29 Sep 2017 16:15:02 -0400 Subject: [PATCH 193/575] fix(select) aria-labelledby (#7022) aria-labelledby must not be in the DOM if it is empty this causes accessability bugs. --- src/lib/select/select.spec.ts | 9 +++++++++ src/lib/select/select.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 8a8bb96260df..93fafbcc1d1f 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -1802,6 +1802,15 @@ describe('MatSelect', () => { expect(select.getAttribute('aria-labelledby')).toBe('myLabelId'); }); + it('should not have aria-labelledby in the DOM if it`s not specified', async(() => { + + fixture.detectChanges(); + + fixture.whenStable().then(() => { + expect(select.hasAttribute('aria-labelledby')).toBeFalsy(); + }); + })); + it('should set the tabindex of the select to 0 by default', () => { expect(select.getAttribute('tabindex')).toEqual('0'); }); diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 8a5f3d46259d..1a5038a9b5f7 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -371,7 +371,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit, @Input('aria-label') ariaLabel: string = ''; /** Input that can be used to specify the `aria-labelledby` attribute. */ - @Input('aria-labelledby') ariaLabelledby: string = ''; + @Input('aria-labelledby') ariaLabelledby: string; /** Unique id of the element. */ @Input() From dcf107472bccd5b1dc1ddfc0c29a6185f5634b3d Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 29 Sep 2017 13:15:16 -0700 Subject: [PATCH 194/575] Handle overflow in .mat-expansion-panel-body. (#7012) --- src/lib/expansion/expansion-panel.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/expansion/expansion-panel.scss b/src/lib/expansion/expansion-panel.scss index 24215855ddeb..a0e8b91db776 100644 --- a/src/lib/expansion/expansion-panel.scss +++ b/src/lib/expansion/expansion-panel.scss @@ -15,7 +15,8 @@ } .mat-expansion-panel-body { - padding: 0 24px 16px; + margin: 0 24px 16px; + overflow: auto; } .mat-expansion-panel-spacing { From 5da9e64b36e3498c0a2e2e35a69a55c2b932ffe6 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:15:28 +0200 Subject: [PATCH 195/575] fix(common-module): check if computed styles are available (#7003) * fix(common-module): check if computed styles are available Due to a Firefox Bug (https://bugzilla.mozilla.org/show_bug.cgi?id=548397) the `getComputedStyle` call in the `MdCommonModule` will return `null` and cause a runtime exception because normally the computed styles are never `null` for the test element. Since this it's very uncommon that a developer places a Angular Material application inside of a hidden iframe, a simple null check should be enough to get the application running. Fixes #7000 * Add comment about Firefox case --- src/lib/core/common-behaviors/common-module.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/core/common-behaviors/common-module.ts b/src/lib/core/common-behaviors/common-module.ts index 5262c8e6b6a9..e2b1c6323af3 100644 --- a/src/lib/core/common-behaviors/common-module.ts +++ b/src/lib/core/common-behaviors/common-module.ts @@ -60,7 +60,12 @@ export class MatCommonModule { testElement.classList.add('mat-theme-loaded-marker'); this._document.body.appendChild(testElement); - if (getComputedStyle(testElement).display !== 'none') { + const computedStyle = getComputedStyle(testElement); + + // In some situations, the computed style of the test element can be null. For example in + // Firefox, the computed style is null if an application is running inside of a hidden iframe. + // See: https://bugzilla.mozilla.org/show_bug.cgi?id=548397 + if (computedStyle && computedStyle.display !== 'none') { console.warn( 'Could not find Angular Material core theme. Most Material ' + 'components may not work as expected. For more info refer ' + From e52beebbf3939f40471af6ef732821277271ee2c Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:15:51 +0200 Subject: [PATCH 196/575] feat(selection-model): de/select multiple values at the same time (#7001) * feat(selection-model): de/select multiple values at the same time Adds support for passing multiple values to the SelectionModel at the same time. This feature is described in the JSDoc already, but just wasn't implemented yet. This functionality gives us more control about the `onChange` event, which will otherwise fire every time if for example multiple values need to be selected. * Address comments --- src/cdk/collections/selection.spec.ts | 24 +++++++++++++++++++++-- src/cdk/collections/selection.ts | 28 +++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/cdk/collections/selection.spec.ts b/src/cdk/collections/selection.spec.ts index 146758053499..024192f97713 100644 --- a/src/cdk/collections/selection.spec.ts +++ b/src/cdk/collections/selection.spec.ts @@ -1,4 +1,4 @@ -import {SelectionModel} from './selection'; +import {getMultipleValuesInSingleSelectionError, SelectionModel} from './selection'; describe('SelectionModel', () => { @@ -22,6 +22,10 @@ describe('SelectionModel', () => { expect(model.isSelected(2)).toBe(true); }); + it('should throw an error if multiple values are passed to model', () => { + expect(() => model.select(1, 2)).toThrow(getMultipleValuesInSingleSelectionError()); + }); + it('should only preselect one value', () => { model = new SelectionModel(false, [1, 2]); @@ -36,13 +40,29 @@ describe('SelectionModel', () => { beforeEach(() => model = new SelectionModel(true)); - it('should be able to select multiple options at the same time', () => { + it('should be able to select multiple options', () => { + const onChangeSpy = jasmine.createSpy('onChange spy'); + + model.onChange!.subscribe(onChangeSpy); model.select(1); model.select(2); expect(model.selected.length).toBe(2); expect(model.isSelected(1)).toBe(true); expect(model.isSelected(2)).toBe(true); + expect(onChangeSpy).toHaveBeenCalledTimes(2); + }); + + it('should be able to select multiple options at the same time', () => { + const onChangeSpy = jasmine.createSpy('onChange spy'); + + model.onChange!.subscribe(onChangeSpy); + model.select(1, 2); + + expect(model.selected.length).toBe(2); + expect(model.isSelected(1)).toBe(true); + expect(model.isSelected(2)).toBe(true); + expect(onChangeSpy).toHaveBeenCalledTimes(1); }); it('should be able to preselect multiple options', () => { diff --git a/src/cdk/collections/selection.ts b/src/cdk/collections/selection.ts index c249544d4a33..eb789ca95b44 100644 --- a/src/cdk/collections/selection.ts +++ b/src/cdk/collections/selection.ts @@ -56,16 +56,18 @@ export class SelectionModel { /** * Selects a value or an array of values. */ - select(value: T): void { - this._markSelected(value); + select(...values: T[]): void { + this._verifyValueAssignment(values); + values.forEach(value => this._markSelected(value)); this._emitChangeEvent(); } /** * Deselects a value or an array of values. */ - deselect(value: T): void { - this._unmarkSelected(value); + deselect(...values: T[]): void { + this._verifyValueAssignment(values); + values.forEach(value => this._unmarkSelected(value)); this._emitChangeEvent(); } @@ -162,6 +164,16 @@ export class SelectionModel { this._selection.forEach(value => this._unmarkSelected(value)); } } + + /** + * Verifies the value assignment and throws an error if the specified value array is + * including multiple values while the selection model is not supporting multiple values. + */ + private _verifyValueAssignment(values: T[]) { + if (values.length > 1 && !this._isMulti) { + throw getMultipleValuesInSingleSelectionError(); + } + } } /** @@ -171,3 +183,11 @@ export class SelectionModel { export class SelectionChange { constructor(public added?: T[], public removed?: T[]) { } } + +/** + * Returns an error that reports that multiple values are passed into a selection model + * with a single value. + */ +export function getMultipleValuesInSingleSelectionError() { + return Error('Cannot pass multiple values into SelectionModel with single-value mode.'); +} From 6f487100fd217a95c5fcd156f8e95f5a51a908c4 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:16:02 +0200 Subject: [PATCH 197/575] fix(stepper): avoid blurry content on IE (#6992) Avoids IE potentially blurring the content inside of a horizontal stepper. Relates to #6954. --- src/lib/stepper/stepper.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib/stepper/stepper.ts b/src/lib/stepper/stepper.ts index 120e6dad7923..2cf8a8feecd5 100644 --- a/src/lib/stepper/stepper.ts +++ b/src/lib/stepper/stepper.ts @@ -99,10 +99,9 @@ export class MatStepper extends _MatStepper { animations: [ trigger('stepTransition', [ state('previous', style({transform: 'translate3d(-100%, 0, 0)', visibility: 'hidden'})), - state('current', style({transform: 'translate3d(0%, 0, 0)', visibility: 'visible'})), + state('current', style({transform: 'none', visibility: 'visible'})), state('next', style({transform: 'translate3d(100%, 0, 0)', visibility: 'hidden'})), - transition('* => *', - animate('500ms cubic-bezier(0.35, 0, 0.25, 1)')) + transition('* => *', animate('500ms cubic-bezier(0.35, 0, 0.25, 1)')) ]) ], providers: [{provide: MatStepper, useExisting: MatHorizontalStepper}], From b1ceeecd88aa8e53edd8d78adfa5390391899179 Mon Sep 17 00:00:00 2001 From: tinayuangao Date: Fri, 29 Sep 2017 13:16:12 -0700 Subject: [PATCH 198/575] Update button toggle group disabled (#6991) --- src/lib/button-toggle/button-toggle.spec.ts | 11 +++++++++++ src/lib/button-toggle/button-toggle.ts | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/lib/button-toggle/button-toggle.spec.ts b/src/lib/button-toggle/button-toggle.spec.ts index fa793edd8a39..6d67caa7e7df 100644 --- a/src/lib/button-toggle/button-toggle.spec.ts +++ b/src/lib/button-toggle/button-toggle.spec.ts @@ -245,6 +245,17 @@ describe('MatButtonToggle without forms', () => { buttonToggleNativeElements[0].click(); expect(buttonToggleInstances[0].checked).toBe(false); + expect(buttonToggleInstances[0].disabled).toBe(true); + + testComponent.isGroupDisabled = false; + fixture.detectChanges(); + + expect(buttonToggleInstances[0].disabled).toBe(false); + + buttonToggleLabelElements[0].click(); + fixture.detectChanges(); + + expect(buttonToggleInstances[0].checked).toBe(true); }); it('should update the group value when one of the toggles changes', () => { diff --git a/src/lib/button-toggle/button-toggle.ts b/src/lib/button-toggle/button-toggle.ts index 7bc8fa72da90..29f80c924468 100644 --- a/src/lib/button-toggle/button-toggle.ts +++ b/src/lib/button-toggle/button-toggle.ts @@ -224,6 +224,13 @@ export class MatButtonToggleGroup extends _MatButtonToggleGroupMixinBase */ setDisabledState(isDisabled: boolean): void { this.disabled = isDisabled; + this._markButtonTogglesForCheck(); + } + + private _markButtonTogglesForCheck() { + if (this._buttonToggles) { + this._buttonToggles.forEach((toggle) => toggle._markForCheck()); + } } } @@ -464,4 +471,15 @@ export class MatButtonToggle implements OnInit, OnDestroy { ngOnDestroy(): void { this._removeUniqueSelectionListener(); } + + /** + * Marks the button toggle as needing checking for change detection. + * This method is exposed because the parent button toggle group will directly + * update bound properties of the radio button. + */ + _markForCheck() { + // When group value changes, the button will not be notified. Use `markForCheck` to explicit + // update button toggle's status + this._changeDetectorRef.markForCheck(); + } } From 7a354a0958dd31379c49c17850c76816a88673ff Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:16:27 +0200 Subject: [PATCH 199/575] fix(tabs): blurry content in IE (#6954) Fixes the content of tabs being blurred on IE due to a `transform`. Fixes #6944. --- src/lib/tabs/tab-body.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/tabs/tab-body.ts b/src/lib/tabs/tab-body.ts index 0d738582d7a1..8999b60a83f8 100644 --- a/src/lib/tabs/tab-body.ts +++ b/src/lib/tabs/tab-body.ts @@ -69,11 +69,9 @@ export type MatTabBodyOriginState = 'left' | 'right'; }, animations: [ trigger('translateTab', [ - state('void', style({transform: 'translate3d(0%, 0, 0)'})), + // Note: transitions to `none` instead of 0, because some browsers might blur the content. + state('center, void, left-origin-center, right-origin-center', style({transform: 'none'})), state('left', style({transform: 'translate3d(-100%, 0, 0)'})), - state('left-origin-center', style({transform: 'translate3d(0%, 0, 0)'})), - state('right-origin-center', style({transform: 'translate3d(0%, 0, 0)'})), - state('center', style({transform: 'translate3d(0%, 0, 0)'})), state('right', style({transform: 'translate3d(100%, 0, 0)'})), transition('* => left, * => right, left => center, right => center', animate('500ms cubic-bezier(0.35, 0, 0.25, 1)')), From f8ed44251811493de4d5693f4c1dce33b33a138a Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:17:03 +0200 Subject: [PATCH 200/575] fix(common): don't log doctype warning when rendering server-side (#6833) Prevents the doctype warning from being logged when rendering server-side in development mode. Previously, while we did have a `document`, it was not the same as the client-side `document` and thus didn't have a `doctype`. We didn't notice this earlier, because we run the server-side rendering check in production mode where the sanity checks are disabled. Relates to #6292. --- src/lib/core/common-behaviors/common-module.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/core/common-behaviors/common-module.ts b/src/lib/core/common-behaviors/common-module.ts index e2b1c6323af3..30fdbfd92c2d 100644 --- a/src/lib/core/common-behaviors/common-module.ts +++ b/src/lib/core/common-behaviors/common-module.ts @@ -7,7 +7,6 @@ */ import {NgModule, InjectionToken, Optional, Inject, isDevMode} from '@angular/core'; -import {DOCUMENT} from '@angular/platform-browser'; import {BidiModule} from '@angular/cdk/bidi'; import {CompatibilityModule} from '../compatibility/compatibility'; @@ -33,11 +32,11 @@ export class MatCommonModule { /** Whether we've done the global sanity checks (e.g. a theme is loaded, there is a doctype). */ private _hasDoneGlobalChecks = false; - constructor( - @Optional() @Inject(DOCUMENT) private _document: any, - @Optional() @Inject(MATERIAL_SANITY_CHECKS) _sanityChecksEnabled: boolean) { + /** Reference to the global `document` object. */ + private _document = typeof document === 'object' && document ? document : null; - if (_sanityChecksEnabled && !this._hasDoneGlobalChecks && _document && isDevMode()) { + constructor(@Optional() @Inject(MATERIAL_SANITY_CHECKS) sanityChecksEnabled: boolean) { + if (sanityChecksEnabled && !this._hasDoneGlobalChecks && isDevMode()) { this._checkDoctype(); this._checkTheme(); this._hasDoneGlobalChecks = true; @@ -45,7 +44,7 @@ export class MatCommonModule { } private _checkDoctype(): void { - if (!this._document.doctype) { + if (this._document && !this._document.doctype) { console.warn( 'Current document does not have a doctype. This may cause ' + 'some Angular Material components not to behave as expected.' @@ -54,7 +53,7 @@ export class MatCommonModule { } private _checkTheme(): void { - if (typeof getComputedStyle === 'function') { + if (this._document && typeof getComputedStyle === 'function') { const testElement = this._document.createElement('div'); testElement.classList.add('mat-theme-loaded-marker'); From 0270cf5e478fc64a9fa916b9ebf21b57663bb7c1 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 29 Sep 2017 22:17:23 +0200 Subject: [PATCH 201/575] fix(checkbox): support native tabindex attribute (#6793) Currently the checkbox only allows changing the tabIndex using the tabIndex binding. Using the native tabindex attribute doesn't have any affect. With this change the native tabindex property will be respected. References #6465 --- src/lib/checkbox/checkbox.spec.ts | 21 +++++++++++++++++++++ src/lib/checkbox/checkbox.ts | 17 ++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index d71a3daeb225..7be933c085cb 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -33,6 +33,7 @@ describe('MatCheckbox', () => { CheckboxWithChangeEvent, CheckboxWithFormControl, CheckboxWithoutLabel, + CheckboxWithTabindexAttr, ], providers: [ {provide: ViewportRuler, useClass: FakeViewportRuler} @@ -677,6 +678,20 @@ describe('MatCheckbox', () => { }); + describe('with native tabindex attribute', () => { + + it('should properly detect native tabindex attribute', async(() => { + fixture = TestBed.createComponent(CheckboxWithTabindexAttr); + fixture.detectChanges(); + + const checkbox = fixture.debugElement + .query(By.directive(MatCheckbox)).componentInstance as MatCheckbox; + + expect(checkbox.tabIndex) + .toBe(5, 'Expected tabIndex property to have been set based on the native attribute'); + })); + }); + describe('with multiple checkboxes', () => { beforeEach(() => { fixture = TestBed.createComponent(MultipleCheckboxes); @@ -1009,3 +1024,9 @@ class CheckboxWithFormControl { class CheckboxWithoutLabel { label: string; } + +/** Test component with the native tabindex attribute. */ +@Component({ + template: `` +}) +class CheckboxWithTabindexAttr {} diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index c17cc728bc0d..8fdf69618351 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -9,6 +9,7 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion'; import { AfterViewInit, + Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, @@ -27,10 +28,12 @@ import { CanColor, CanDisable, CanDisableRipple, + HasTabIndex, MatRipple, mixinColor, mixinDisabled, mixinDisableRipple, + mixinTabIndex, RippleRef, } from '@angular/material/core'; import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; @@ -79,7 +82,7 @@ export class MatCheckboxBase { constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {} } export const _MatCheckboxMixinBase = - mixinColor(mixinDisableRipple(mixinDisabled(MatCheckboxBase)), 'accent'); + mixinTabIndex(mixinColor(mixinDisableRipple(mixinDisabled(MatCheckboxBase)), 'accent')); /** @@ -104,13 +107,13 @@ export const _MatCheckboxMixinBase = '[class.mat-checkbox-label-before]': 'labelPosition == "before"', }, providers: [MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR], - inputs: ['disabled', 'disableRipple', 'color'], + inputs: ['disabled', 'disableRipple', 'color', 'tabIndex'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush }) export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAccessor, - AfterViewInit, OnDestroy, CanColor, CanDisable, CanDisableRipple { + AfterViewInit, OnDestroy, CanColor, CanDisable, HasTabIndex, CanDisableRipple { /** * Attached to the aria-label attribute of the host element. In most cases, arial-labelledby will @@ -156,9 +159,6 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc /** Whether the label should appear after or before the checkbox. Defaults to 'after' */ @Input() labelPosition: 'before' | 'after' = 'after'; - /** Tabindex value that is passed to the underlying input element. */ - @Input() tabIndex: number = 0; - /** Name value will be applied to the input element if present */ @Input() name: string | null = null; @@ -199,8 +199,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc constructor(renderer: Renderer2, elementRef: ElementRef, private _changeDetectorRef: ChangeDetectorRef, - private _focusMonitor: FocusMonitor) { + private _focusMonitor: FocusMonitor, + @Attribute('tabindex') tabIndex: string) { super(renderer, elementRef); + + this.tabIndex = parseInt(tabIndex) || 0; } ngAfterViewInit() { From 7a9657040d9a75378ae5cb3f70e7c0c23c762b7f Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:17:44 +0200 Subject: [PATCH 202/575] fix(menu): nested menu error when items are rendered in a repeater (#6766) Fixes an error that was being thrown when the menu items that trigger a sub-menu are rendered in a repeater. Fixes #6765. --- src/lib/menu/menu-directive.ts | 20 ++++++++++++---- src/lib/menu/menu-trigger.ts | 6 ++--- src/lib/menu/menu.spec.ts | 43 +++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/src/lib/menu/menu-directive.ts b/src/lib/menu/menu-directive.ts index 81243ac07b97..aa14055003b7 100644 --- a/src/lib/menu/menu-directive.ts +++ b/src/lib/menu/menu-directive.ts @@ -10,7 +10,7 @@ import {AnimationEvent} from '@angular/animations'; import {FocusKeyManager} from '@angular/cdk/a11y'; import {Direction} from '@angular/cdk/bidi'; import {ESCAPE, LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes'; -import {RxChain, startWith, switchMap} from '@angular/cdk/rxjs'; +import {RxChain, startWith, switchMap, first} from '@angular/cdk/rxjs'; import { AfterContentInit, ChangeDetectionStrategy, @@ -27,10 +27,12 @@ import { TemplateRef, ViewChild, ViewEncapsulation, + NgZone, } from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {merge} from 'rxjs/observable/merge'; import {Subscription} from 'rxjs/Subscription'; +import {Subject} from 'rxjs/Subject'; import {fadeInItems, transformMenu} from './menu-animations'; import {throwMatMenuInvalidPositionX, throwMatMenuInvalidPositionY} from './menu-errors'; import {MatMenuItem} from './menu-item'; @@ -80,7 +82,7 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy { private _tabSubscription = Subscription.EMPTY; /** Config object to be passed into the menu's ngClass */ - _classList: any = {}; + _classList: {[key: string]: boolean} = {}; /** Current state of the panel animation. */ _panelAnimationState: 'void' | 'enter-start' | 'enter' = 'void'; @@ -145,6 +147,7 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy { constructor( private _elementRef: ElementRef, + private _ngZone: NgZone, @Inject(MAT_MENU_DEFAULT_OPTIONS) private _defaultOptions: MatMenuDefaultOptions) { } ngAfterContentInit() { @@ -160,9 +163,16 @@ export class MatMenu implements AfterContentInit, MatMenuPanel, OnDestroy { /** Stream that emits whenever the hovered menu item changes. */ hover(): Observable { - return RxChain.from(this.items.changes) - .call(startWith, this.items) - .call(switchMap, (items: MatMenuItem[]) => merge(...items.map(item => item.hover))) + if (this.items) { + return RxChain.from(this.items.changes) + .call(startWith, this.items) + .call(switchMap, (items: MatMenuItem[]) => merge(...items.map(item => item.hover))) + .result(); + } + + return RxChain.from(this._ngZone.onStable.asObservable()) + .call(first) + .call(switchMap, () => this.hover()) .result(); } diff --git a/src/lib/menu/menu-trigger.ts b/src/lib/menu/menu-trigger.ts index 81808968e894..a37c541f3e1e 100644 --- a/src/lib/menu/menu-trigger.ts +++ b/src/lib/menu/menu-trigger.ts @@ -22,7 +22,7 @@ import { import {TemplatePortal} from '@angular/cdk/portal'; import {filter, RxChain} from '@angular/cdk/rxjs'; import { - AfterViewInit, + AfterContentInit, Directive, ElementRef, EventEmitter, @@ -81,7 +81,7 @@ export const MENU_PANEL_TOP_PADDING = 8; }, exportAs: 'matMenuTrigger' }) -export class MatMenuTrigger implements AfterViewInit, OnDestroy { +export class MatMenuTrigger implements AfterContentInit, OnDestroy { private _portal: TemplatePortal; private _overlayRef: OverlayRef | null = null; private _menuOpen: boolean = false; @@ -125,7 +125,7 @@ export class MatMenuTrigger implements AfterViewInit, OnDestroy { } } - ngAfterViewInit() { + ngAfterContentInit() { this._checkMenu(); this.menu.close.subscribe(reason => { diff --git a/src/lib/menu/menu.spec.ts b/src/lib/menu/menu.spec.ts index 0370cd13d8fb..83b8cb8db4e7 100644 --- a/src/lib/menu/menu.spec.ts +++ b/src/lib/menu/menu.spec.ts @@ -48,7 +48,8 @@ describe('MatMenu', () => { CustomMenuPanel, CustomMenu, NestedMenu, - NestedMenuCustomElevation + NestedMenuCustomElevation, + NestedMenuRepeater ], providers: [ {provide: OverlayContainer, useFactory: () => { @@ -1046,6 +1047,21 @@ describe('MatMenu', () => { expect(event.preventDefault).toHaveBeenCalled(); }); + it('should handle the items being rendered in a repeater', fakeAsync(() => { + const repeaterFixture = TestBed.createComponent(NestedMenuRepeater); + overlay = overlayContainerElement; + + expect(() => repeaterFixture.detectChanges()).not.toThrow(); + + repeaterFixture.componentInstance.rootTriggerEl.nativeElement.click(); + repeaterFixture.detectChanges(); + expect(overlay.querySelectorAll('.mat-menu-panel').length).toBe(1, 'Expected one open menu'); + + dispatchMouseEvent(overlay.querySelector('.level-one-trigger')!, 'mouseenter'); + repeaterFixture.detectChanges(); + expect(overlay.querySelectorAll('.mat-menu-panel').length).toBe(2, 'Expected two open menus'); + })); + }); }); @@ -1243,3 +1259,28 @@ class NestedMenuCustomElevation { @ViewChild('rootTrigger') rootTrigger: MatMenuTrigger; @ViewChild('levelOneTrigger') levelOneTrigger: MatMenuTrigger; } + + +@Component({ + template: ` + + + + + + + + + + ` +}) +class NestedMenuRepeater { + @ViewChild('rootTriggerEl') rootTriggerEl: ElementRef; + @ViewChild('levelOneTrigger') levelOneTrigger: MatMenuTrigger; + + items = ['one', 'two', 'three']; +} From d5f96c87278ee2e4b500d7001cac0fb4c9a1b982 Mon Sep 17 00:00:00 2001 From: Ji Won Shin Date: Fri, 29 Sep 2017 23:18:08 +0300 Subject: [PATCH 203/575] Vertically align elements in mdSubheader (#6685) --- src/lib/list/list.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/list/list.scss b/src/lib/list/list.scss index bda2a254af52..314c70fb556b 100644 --- a/src/lib/list/list.scss +++ b/src/lib/list/list.scss @@ -112,9 +112,10 @@ $mat-dense-list-icon-size: 20px; } .mat-subheader { - display: block; + display: flex; box-sizing: border-box; padding: $mat-list-side-padding; + align-items: center; // This needs slightly more specificity, because it // can be overwritten by the typography styles. From c8ddd396a71bd39a79af369a7608d599ec585c09 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 29 Sep 2017 22:19:21 +0200 Subject: [PATCH 204/575] fix(tooltip): ensure tooltip stays within viewport (#6659) * Adds a fallback position to ensure that tooltips can't go outside the viewport. * Refactors the `transform-origin` logic to depend on the overlay position, instead of the tooltip position. Fixes #5428. --- src/lib/tooltip/tooltip.spec.ts | 87 +++++++++++++--- src/lib/tooltip/tooltip.ts | 172 ++++++++++++++++++++------------ 2 files changed, 180 insertions(+), 79 deletions(-) diff --git a/src/lib/tooltip/tooltip.spec.ts b/src/lib/tooltip/tooltip.spec.ts index 26e8f67bf331..95a5cb074ced 100644 --- a/src/lib/tooltip/tooltip.spec.ts +++ b/src/lib/tooltip/tooltip.spec.ts @@ -342,71 +342,81 @@ describe('MatTooltip', () => { it('should consistently position before and after overlay origin in ltr and rtl dir', () => { tooltipDirective.position = 'left'; - const leftOrigin = tooltipDirective._getOrigin(); + const leftOrigin = tooltipDirective._getOrigin().main; tooltipDirective.position = 'right'; - const rightOrigin = tooltipDirective._getOrigin(); + const rightOrigin = tooltipDirective._getOrigin().main; // Test expectations in LTR tooltipDirective.position = 'before'; - expect(tooltipDirective._getOrigin()).toEqual(leftOrigin); + expect(tooltipDirective._getOrigin().main).toEqual(leftOrigin); tooltipDirective.position = 'after'; - expect(tooltipDirective._getOrigin()).toEqual(rightOrigin); + expect(tooltipDirective._getOrigin().main).toEqual(rightOrigin); // Test expectations in LTR dir.value = 'rtl'; tooltipDirective.position = 'before'; - expect(tooltipDirective._getOrigin()).toEqual(rightOrigin); + expect(tooltipDirective._getOrigin().main).toEqual(rightOrigin); tooltipDirective.position = 'after'; - expect(tooltipDirective._getOrigin()).toEqual(leftOrigin); + expect(tooltipDirective._getOrigin().main).toEqual(leftOrigin); }); it('should consistently position before and after overlay position in ltr and rtl dir', () => { tooltipDirective.position = 'left'; - const leftOverlayPosition = tooltipDirective._getOverlayPosition(); + const leftOverlayPosition = tooltipDirective._getOverlayPosition().main; tooltipDirective.position = 'right'; - const rightOverlayPosition = tooltipDirective._getOverlayPosition(); + const rightOverlayPosition = tooltipDirective._getOverlayPosition().main; // Test expectations in LTR tooltipDirective.position = 'before'; - expect(tooltipDirective._getOverlayPosition()).toEqual(leftOverlayPosition); + expect(tooltipDirective._getOverlayPosition().main).toEqual(leftOverlayPosition); tooltipDirective.position = 'after'; - expect(tooltipDirective._getOverlayPosition()).toEqual(rightOverlayPosition); + expect(tooltipDirective._getOverlayPosition().main).toEqual(rightOverlayPosition); // Test expectations in LTR dir.value = 'rtl'; tooltipDirective.position = 'before'; - expect(tooltipDirective._getOverlayPosition()).toEqual(rightOverlayPosition); + expect(tooltipDirective._getOverlayPosition().main).toEqual(rightOverlayPosition); tooltipDirective.position = 'after'; - expect(tooltipDirective._getOverlayPosition()).toEqual(leftOverlayPosition); + expect(tooltipDirective._getOverlayPosition().main).toEqual(leftOverlayPosition); }); it('should have consistent left transform origin in any dir', () => { tooltipDirective.position = 'right'; tooltipDirective.show(); + fixture.detectChanges(); expect(tooltipDirective._tooltipInstance!._transformOrigin).toBe('left'); tooltipDirective.position = 'after'; tooltipDirective.show(); + fixture.detectChanges(); expect(tooltipDirective._tooltipInstance!._transformOrigin).toBe('left'); dir.value = 'rtl'; tooltipDirective.position = 'before'; tooltipDirective.show(); + fixture.detectChanges(); expect(tooltipDirective._tooltipInstance!._transformOrigin).toBe('left'); }); it('should have consistent right transform origin in any dir', () => { + // Move the button away from the edge of the screen so + // we don't get into the fallback positions. + fixture.componentInstance.button.nativeElement.style.margin = '200px'; + tooltipDirective.position = 'left'; tooltipDirective.show(); + fixture.detectChanges(); expect(tooltipDirective._tooltipInstance!._transformOrigin).toBe('right'); tooltipDirective.position = 'before'; tooltipDirective.show(); + fixture.detectChanges(); expect(tooltipDirective._tooltipInstance!._transformOrigin).toBe('right'); dir.value = 'rtl'; tooltipDirective.position = 'after'; tooltipDirective.show(); + fixture.detectChanges(); expect(tooltipDirective._tooltipInstance!._transformOrigin).toBe('right'); }); @@ -463,10 +473,8 @@ describe('MatTooltip', () => { document.body.click(); fixture.detectChanges(); - tick(500); - expect(tooltipDirective._isTooltipVisible()).toBe(true); expect(overlayContainerElement.textContent).toContain(initialTooltipMessage); })); @@ -479,6 +487,53 @@ describe('MatTooltip', () => { }); + describe('fallback positions', () => { + let fixture: ComponentFixture; + let tooltip: MatTooltip; + + beforeEach(() => { + fixture = TestBed.createComponent(BasicTooltipDemo); + fixture.detectChanges(); + tooltip = fixture.debugElement.query(By.css('button')).injector.get(MatTooltip); + }); + + it('should set a fallback origin position by inverting the main origin position', () => { + tooltip.position = 'left'; + expect(tooltip._getOrigin().main.originX).toBe('start'); + expect(tooltip._getOrigin().fallback.originX).toBe('end'); + + tooltip.position = 'right'; + expect(tooltip._getOrigin().main.originX).toBe('end'); + expect(tooltip._getOrigin().fallback.originX).toBe('start'); + + tooltip.position = 'above'; + expect(tooltip._getOrigin().main.originY).toBe('top'); + expect(tooltip._getOrigin().fallback.originY).toBe('bottom'); + + tooltip.position = 'below'; + expect(tooltip._getOrigin().main.originY).toBe('bottom'); + expect(tooltip._getOrigin().fallback.originY).toBe('top'); + }); + + it('should set a fallback overlay position by inverting the main overlay position', () => { + tooltip.position = 'left'; + expect(tooltip._getOverlayPosition().main.overlayX).toBe('end'); + expect(tooltip._getOverlayPosition().fallback.overlayX).toBe('start'); + + tooltip.position = 'right'; + expect(tooltip._getOverlayPosition().main.overlayX).toBe('start'); + expect(tooltip._getOverlayPosition().fallback.overlayX).toBe('end'); + + tooltip.position = 'above'; + expect(tooltip._getOverlayPosition().main.overlayY).toBe('bottom'); + expect(tooltip._getOverlayPosition().fallback.overlayY).toBe('top'); + + tooltip.position = 'below'; + expect(tooltip._getOverlayPosition().main.overlayY).toBe('top'); + expect(tooltip._getOverlayPosition().fallback.overlayY).toBe('bottom'); + }); + }); + describe('scrollable usage', () => { let fixture: ComponentFixture; let buttonDebugElement: DebugElement; @@ -581,7 +636,8 @@ describe('MatTooltip', () => { @Component({ selector: 'app', template: ` -
NameCaloriesFatCarbsProteinNameCaloriesFatCarbsProtein