Skip to content

Commit 987f84b

Browse files
committed
refactor(material/legacy-form-field): rename ts symbols
1 parent 197fa42 commit 987f84b

File tree

15 files changed

+109
-101
lines changed

15 files changed

+109
-101
lines changed

src/dev-app/legacy-input/legacy-input-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {MatButtonToggleModule} from '@angular/material/button-toggle';
1414
import {MatLegacyCardModule} from '@angular/material/legacy-card';
1515
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
1616
import {ErrorStateMatcher} from '@angular/material/core';
17-
import {FloatLabelType, MatLegacyFormFieldModule} from '@angular/material/legacy-form-field';
17+
import {LegacyFloatLabelType, MatLegacyFormFieldModule} from '@angular/material/legacy-form-field';
1818
import {MatIconModule} from '@angular/material/icon';
1919
import {MatLegacyInputModule} from '@angular/material/legacy-input';
2020
import {MatLegacySelectModule} from '@angular/material/legacy-select';
@@ -48,7 +48,7 @@ const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA
4848
],
4949
})
5050
export class LegacyInputDemo {
51-
floatingLabel: FloatLabelType = 'auto';
51+
floatingLabel: LegacyFloatLabelType = 'auto';
5252
color: boolean;
5353
requiredField: boolean;
5454
hideRequiredMarker: boolean;

src/dev-app/legacy-select/legacy-select-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
</mat-select>
242242
</mat-form-field>
243243

244-
<p> Change event value: {{ latestChangeEvent?.value }} </p>
244+
<p> Change event value: {{ latestChangeEvent.value }} </p>
245245
</mat-card-content>
246246
</mat-card>
247247
</div>

src/dev-app/legacy-select/legacy-select-demo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {MatLegacyButtonModule} from '@angular/material/legacy-button';
1313
import {MatLegacyCardModule} from '@angular/material/legacy-card';
1414
import {ErrorStateMatcher, ThemePalette} from '@angular/material/core';
1515
import {MatLegacyDialog, MatLegacyDialogModule} from '@angular/material/legacy-dialog';
16-
import {FloatLabelType, MatLegacyFormFieldModule} from '@angular/material/legacy-form-field';
16+
import {LegacyFloatLabelType, MatLegacyFormFieldModule} from '@angular/material/legacy-form-field';
1717
import {MatIconModule} from '@angular/material/icon';
1818
import {MatLegacyInputModule} from '@angular/material/legacy-input';
1919
import {MatSelectChange, MatLegacySelectModule} from '@angular/material/legacy-select';
@@ -59,8 +59,8 @@ export class LegacySelectDemo {
5959
currentPokemonFromGroup: string;
6060
currentDigimon: string;
6161
currentAppearanceValue: string | null;
62-
latestChangeEvent: MatSelectChange | undefined;
63-
floatLabel: FloatLabelType = 'auto';
62+
latestChangeEvent: MatSelectChange;
63+
floatLabel: LegacyFloatLabelType = 'auto';
6464
drinksWidth = 'default';
6565
foodControl = new FormControl('pizza-1');
6666
topHeightCtrl = new FormControl(0);

src/material/datepicker/date-range-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
import {
2626
MatLegacyFormFieldControl,
2727
MatLegacyFormField,
28-
MAT_FORM_FIELD,
28+
MAT_LEGACY_FORM_FIELD,
2929
} from '@angular/material/legacy-form-field';
3030
import {ThemePalette, DateAdapter} from '@angular/material/core';
3131
import {NgControl, ControlContainer} from '@angular/forms';
@@ -259,7 +259,7 @@ export class MatDateRangeInput<D>
259259
private _elementRef: ElementRef<HTMLElement>,
260260
@Optional() @Self() control: ControlContainer,
261261
@Optional() private _dateAdapter: DateAdapter<D>,
262-
@Optional() @Inject(MAT_FORM_FIELD) private _formField?: MatLegacyFormField,
262+
@Optional() @Inject(MAT_LEGACY_FORM_FIELD) private _formField?: MatLegacyFormField,
263263
) {
264264
if (!_dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) {
265265
throw createMissingDateImplError('DateAdapter');

src/material/datepicker/datepicker-input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {Directive, ElementRef, forwardRef, Inject, Input, OnDestroy, Optional} from '@angular/core';
1010
import {NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidatorFn, Validators} from '@angular/forms';
1111
import {DateAdapter, MAT_DATE_FORMATS, MatDateFormats, ThemePalette} from '@angular/material/core';
12-
import {MatLegacyFormField, MAT_FORM_FIELD} from '@angular/material/legacy-form-field';
12+
import {MatLegacyFormField, MAT_LEGACY_FORM_FIELD} from '@angular/material/legacy-form-field';
1313
import {MAT_INPUT_VALUE_ACCESSOR} from '@angular/material/legacy-input';
1414
import {Subscription} from 'rxjs';
1515
import {MatDatepickerInputBase, DateFilterFn} from './datepicker-input-base';
@@ -124,7 +124,7 @@ export class MatDatepickerInput<D>
124124
elementRef: ElementRef<HTMLInputElement>,
125125
@Optional() dateAdapter: DateAdapter<D>,
126126
@Optional() @Inject(MAT_DATE_FORMATS) dateFormats: MatDateFormats,
127-
@Optional() @Inject(MAT_FORM_FIELD) private _formField?: MatLegacyFormField,
127+
@Optional() @Inject(MAT_LEGACY_FORM_FIELD) private _formField?: MatLegacyFormField,
128128
) {
129129
super(elementRef, dateAdapter, dateFormats);
130130
this._validator = Validators.compose(super._getValidators());

src/material/legacy-form-field/form-field.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {CanColor, mixinColor, ThemePalette} from '@angular/material/core';
3232
import {fromEvent, merge, Subject} from 'rxjs';
3333
import {startWith, take, takeUntil} from 'rxjs/operators';
3434
import {MatLegacyError} from './error';
35-
import {_MAT_HINT, MatLegacyHint} from './hint';
35+
import {_MAT_LEGACY_HINT, MatLegacyHint} from './hint';
3636
import {MatLegacyLabel} from './label';
3737
import {MatLegacyPlaceholder} from './placeholder';
3838
import {MatLegacyPrefix} from './prefix';
@@ -71,7 +71,7 @@ const _MatFormFieldBase = mixinColor(
7171
export type MatLegacyFormFieldAppearance = 'legacy' | 'standard' | 'fill' | 'outline';
7272

7373
/** Possible values for the "floatLabel" form field input. */
74-
export type FloatLabelType = 'always' | 'never' | 'auto';
74+
export type LegacyFloatLabelType = 'always' | 'never' | 'auto';
7575

7676
/**
7777
* Represents the default options for the form field that can be configured
@@ -88,16 +88,15 @@ export interface MatLegacyFormFieldDefaultOptions {
8888
* Whether the label for form fields should by default float `always`,
8989
* `never`, or `auto` (only when necessary).
9090
*/
91-
floatLabel?: FloatLabelType;
91+
floatLabel?: LegacyFloatLabelType;
9292
}
9393

9494
/**
9595
* Injection token that can be used to configure the
9696
* default options for all form field within an app.
9797
*/
98-
export const MAT_FORM_FIELD_DEFAULT_OPTIONS = new InjectionToken<MatLegacyFormFieldDefaultOptions>(
99-
'MAT_FORM_FIELD_DEFAULT_OPTIONS',
100-
);
98+
export const MAT_LEGACY_FORM_FIELD_DEFAULT_OPTIONS =
99+
new InjectionToken<MatLegacyFormFieldDefaultOptions>('MAT_FORM_FIELD_DEFAULT_OPTIONS');
101100

102101
/** Container for form controls that applies Material Design styling and behavior. */
103102
@Component({
@@ -227,16 +226,16 @@ export class MatLegacyFormField
227226
* appearances the `never` option has been disabled in favor of just using the placeholder.
228227
*/
229228
@Input()
230-
get floatLabel(): FloatLabelType {
229+
get floatLabel(): LegacyFloatLabelType {
231230
return this.appearance !== 'legacy' && this._floatLabel === 'never' ? 'auto' : this._floatLabel;
232231
}
233-
set floatLabel(value: FloatLabelType) {
232+
set floatLabel(value: LegacyFloatLabelType) {
234233
if (value !== this._floatLabel) {
235234
this._floatLabel = value || this._getDefaultFloatLabelState();
236235
this._changeDetectorRef.markForCheck();
237236
}
238237
}
239-
private _floatLabel: FloatLabelType;
238+
private _floatLabel: LegacyFloatLabelType;
240239

241240
/** Whether the Angular animations are enabled. */
242241
_animationsEnabled: boolean;
@@ -262,7 +261,7 @@ export class MatLegacyFormField
262261
@ContentChild(MatLegacyPlaceholder) _placeholderChild: MatLegacyPlaceholder;
263262

264263
@ContentChildren(MAT_ERROR, {descendants: true}) _errorChildren: QueryList<MatLegacyError>;
265-
@ContentChildren(_MAT_HINT, {descendants: true}) _hintChildren: QueryList<MatLegacyHint>;
264+
@ContentChildren(_MAT_LEGACY_HINT, {descendants: true}) _hintChildren: QueryList<MatLegacyHint>;
266265
@ContentChildren(MAT_PREFIX, {descendants: true})
267266
_prefixChildren: QueryList<MatLegacyPrefix>;
268267
@ContentChildren(MAT_SUFFIX, {descendants: true})
@@ -273,7 +272,7 @@ export class MatLegacyFormField
273272
private _changeDetectorRef: ChangeDetectorRef,
274273
@Optional() private _dir: Directionality,
275274
@Optional()
276-
@Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS)
275+
@Inject(MAT_LEGACY_FORM_FIELD_DEFAULT_OPTIONS)
277276
private _defaults: MatLegacyFormFieldDefaultOptions,
278277
private _platform: Platform,
279278
private _ngZone: NgZone,
@@ -501,7 +500,7 @@ export class MatLegacyFormField
501500
}
502501

503502
/** Gets the default float label state. */
504-
private _getDefaultFloatLabelState(): FloatLabelType {
503+
private _getDefaultFloatLabelState(): LegacyFloatLabelType {
505504
return (this._defaults && this._defaults.floatLabel) || 'auto';
506505
}
507506

src/material/legacy-form-field/hint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let nextUniqueId = 0;
1818
* *Note*: This is not part of the public API as the MDC-based form-field will not
1919
* need a lightweight token for `MatHint` and we want to reduce breaking changes.
2020
*/
21-
export const _MAT_HINT = new InjectionToken<MatLegacyHint>('MatHint');
21+
export const _MAT_LEGACY_HINT = new InjectionToken<MatLegacyHint>('MatHint');
2222

2323
/** Hint text to be shown underneath the form field control. */
2424
@Directive({
@@ -30,7 +30,7 @@ export const _MAT_HINT = new InjectionToken<MatLegacyHint>('MatHint');
3030
// Remove align attribute to prevent it from interfering with layout.
3131
'[attr.align]': 'null',
3232
},
33-
providers: [{provide: _MAT_HINT, useExisting: MatLegacyHint}],
33+
providers: [{provide: _MAT_LEGACY_HINT, useExisting: MatLegacyHint}],
3434
})
3535
export class MatLegacyHint {
3636
/** Whether to align the hint label at the start or end of the line. */

src/material/legacy-form-field/public-api.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,29 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export * from './form-field-module';
10-
export * from './error';
11-
export * from './form-field';
12-
export * from './hint';
13-
export * from './placeholder';
14-
export * from './prefix';
15-
export * from './suffix';
16-
export * from './label';
9+
export {MatLegacyFormFieldModule} from './form-field-module';
10+
export {MatLegacyError} from './error';
11+
export {
12+
MatLegacyFormFieldAppearance,
13+
LegacyFloatLabelType,
14+
MatLegacyFormFieldDefaultOptions,
15+
MAT_LEGACY_FORM_FIELD_DEFAULT_OPTIONS,
16+
MatLegacyFormField,
17+
} from './form-field';
18+
export {_MAT_LEGACY_HINT, MatLegacyHint} from './hint';
19+
export {MatLegacyPlaceholder} from './placeholder';
20+
export {MatLegacyPrefix} from './prefix';
21+
export {MatLegacySuffix} from './suffix';
22+
export {MatLegacyLabel} from './label';
1723

1824
export {
19-
MAT_FORM_FIELD,
25+
MAT_FORM_FIELD as MAT_LEGACY_FORM_FIELD,
2026
MatFormFieldControl as MatLegacyFormFieldControl,
21-
getMatFormFieldDuplicatedHintError,
22-
getMatFormFieldMissingControlError,
23-
getMatFormFieldPlaceholderConflictError,
24-
matFormFieldAnimations,
25-
MAT_SUFFIX,
26-
MAT_ERROR,
27-
MAT_PREFIX,
27+
getMatFormFieldDuplicatedHintError as getMatLegacyFormFieldDuplicatedHintError,
28+
getMatFormFieldMissingControlError as getMatLegacyFormFieldMissingControlError,
29+
getMatFormFieldPlaceholderConflictError as getMatLegacyFormFieldPlaceholderConflictError,
30+
matFormFieldAnimations as matLegacyFormFieldAnimations,
31+
MAT_SUFFIX as MAT_LEGACY_SUFFIX,
32+
MAT_ERROR as MAT_LEGACY_ERROR,
33+
MAT_PREFIX as MAT_LEGACY_PREFIX,
2834
} from '@angular/material/form-field';

src/material/legacy-form-field/testing/form-field-harness.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import {MatLegacySelectHarness} from '@angular/material/legacy-select/testing';
2020

2121
// TODO(devversion): support support chip list harness
2222
/** Possible harnesses of controls which can be bound to a form-field. */
23-
export type FormFieldControlHarness =
23+
export type LegacyFormFieldControlHarness =
2424
| MatLegacyInputHarness
2525
| MatLegacySelectHarness
2626
| MatDatepickerInputHarness
2727
| MatDateRangeInputHarness;
2828

2929
/** Harness for interacting with a standard Material form-field's in tests. */
30-
export class MatLegacyFormFieldHarness extends _MatFormFieldHarnessBase<FormFieldControlHarness> {
30+
export class MatLegacyFormFieldHarness extends _MatFormFieldHarnessBase<LegacyFormFieldControlHarness> {
3131
static hostSelector = '.mat-form-field';
3232

3333
/**

src/material/legacy-form-field/testing/public-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Re-export the base control harness from the "form-field/testing/control" entry-point. To
1010
// avoid circular dependencies, harnesses for form-field controls (i.e. input, select)
1111
// need to import the base form-field control harness through a separate entry-point.
12-
export {MatFormFieldControlHarness} from '@angular/material/form-field/testing/control';
12+
export {MatFormFieldControlHarness as MatLegacyFormFieldControlHarness} from '@angular/material/form-field/testing/control';
1313

14-
export * from './form-field-harness';
15-
export {FormFieldHarnessFilters} from '@angular/material/form-field/testing';
14+
export {LegacyFormFieldControlHarness, MatLegacyFormFieldHarness} from './form-field-harness';
15+
export {FormFieldHarnessFilters as LegacyFormFieldHarnessFilters} from '@angular/material/form-field/testing';

0 commit comments

Comments
 (0)