-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
198 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @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, Input} from '@angular/core'; | ||
|
||
|
||
let nextUniqueId = 0; | ||
|
||
|
||
/** Single error message to be shown underneath the form field. */ | ||
@Directive({ | ||
selector: 'md-error, mat-error', | ||
host: { | ||
'class': 'mat-error', | ||
'role': 'alert', | ||
'[attr.id]': 'id', | ||
} | ||
}) | ||
export class MdError { | ||
@Input() id: string = `mat-error-${nextUniqueId++}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @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 {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 { | ||
/** | ||
* Stream that emits whenever the state of the control changes such that the parent `MdFormField` | ||
* needs to run change detection. | ||
*/ | ||
stateChanges: Observable<void>; | ||
|
||
/** The value of the control. */ | ||
value: any; | ||
|
||
/** Gets the element ID for this control. */ | ||
abstract getId(): string; | ||
|
||
/** Gets the placeholder for this control. */ | ||
abstract getPlaceholder(): string; | ||
|
||
/** Gets the NgControl for this control. */ | ||
abstract getNgControl(): NgControl | null; | ||
|
||
/** Whether the control is focused. */ | ||
abstract isFocused(): boolean; | ||
|
||
/** Whether the control is empty. */ | ||
abstract isEmpty(): boolean; | ||
|
||
/** Whether the control is required. */ | ||
abstract isRequired(): boolean; | ||
|
||
/** Whether the control is disabled. */ | ||
abstract isDisabled(): boolean; | ||
|
||
/** Whether the control is in an error state. */ | ||
abstract isErrorState(): boolean; | ||
|
||
/** Sets the list of element IDs that currently describe this control. */ | ||
abstract setDescribedByIds(ids: string[]): void; | ||
|
||
/** Focuses this control. */ | ||
abstract focus(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @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, Input} from '@angular/core'; | ||
|
||
|
||
let nextUniqueId = 0; | ||
|
||
|
||
/** Hint text to be shown underneath the form field control. */ | ||
@Directive({ | ||
selector: 'md-hint, mat-hint', | ||
host: { | ||
'class': 'mat-hint', | ||
'[class.mat-right]': 'align == "end"', | ||
'[attr.id]': 'id', | ||
// Remove align attribute to prevent it from interfering with layout. | ||
'[attr.align]': 'null', | ||
} | ||
}) | ||
export class MdHint { | ||
/** Whether to align the hint label at the start or end of the line. */ | ||
@Input() align: 'start' | 'end' = 'start'; | ||
|
||
/** Unique ID for the hint. Used for the aria-describedby on the form field control. */ | ||
@Input() id: string = `mat-hint-${nextUniqueId++}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} from '@angular/core'; | ||
|
||
|
||
/** The floating placeholder for an `MdFormField`. */ | ||
@Directive({ | ||
selector: 'md-placeholder, mat-placeholder' | ||
}) | ||
export class MdPlaceholder {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} from '@angular/core'; | ||
|
||
|
||
/** Prefix to be placed the the front of the form field. */ | ||
@Directive({ | ||
selector: '[mdPrefix], [matPrefix]', | ||
}) | ||
export class MdPrefix {} |
Oops, something went wrong.