1 | import { ObserversModule } from '@angular/cdk/observers';
|
---|
2 | import { CommonModule } from '@angular/common';
|
---|
3 | import { InjectionToken, Directive, Attribute, ElementRef, Input, Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, Inject, Optional, NgZone, ViewChild, ContentChild, ContentChildren, NgModule } from '@angular/core';
|
---|
4 | import { mixinColor, MatCommonModule } from '@angular/material/core';
|
---|
5 | import { Directionality } from '@angular/cdk/bidi';
|
---|
6 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
---|
7 | import { Subject, merge, fromEvent } from 'rxjs';
|
---|
8 | import { startWith, takeUntil, take } from 'rxjs/operators';
|
---|
9 | import { trigger, state, style, transition, animate } from '@angular/animations';
|
---|
10 | import { Platform } from '@angular/cdk/platform';
|
---|
11 | import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * @license
|
---|
15 | * Copyright Google LLC All Rights Reserved.
|
---|
16 | *
|
---|
17 | * Use of this source code is governed by an MIT-style license that can be
|
---|
18 | * found in the LICENSE file at https://angular.io/license
|
---|
19 | */
|
---|
20 | let nextUniqueId$2 = 0;
|
---|
21 | /**
|
---|
22 | * Injection token that can be used to reference instances of `MatError`. It serves as
|
---|
23 | * alternative token to the actual `MatError` class which could cause unnecessary
|
---|
24 | * retention of the class and its directive metadata.
|
---|
25 | */
|
---|
26 | const MAT_ERROR = new InjectionToken('MatError');
|
---|
27 | /** Single error message to be shown underneath the form field. */
|
---|
28 | class MatError {
|
---|
29 | constructor(ariaLive, elementRef) {
|
---|
30 | this.id = `mat-error-${nextUniqueId$2++}`;
|
---|
31 | // If no aria-live value is set add 'polite' as a default. This is preferred over setting
|
---|
32 | // role='alert' so that screen readers do not interrupt the current task to read this aloud.
|
---|
33 | if (!ariaLive) {
|
---|
34 | elementRef.nativeElement.setAttribute('aria-live', 'polite');
|
---|
35 | }
|
---|
36 | }
|
---|
37 | }
|
---|
38 | MatError.decorators = [
|
---|
39 | { type: Directive, args: [{
|
---|
40 | selector: 'mat-error',
|
---|
41 | host: {
|
---|
42 | 'class': 'mat-error',
|
---|
43 | '[attr.id]': 'id',
|
---|
44 | 'aria-atomic': 'true',
|
---|
45 | },
|
---|
46 | providers: [{ provide: MAT_ERROR, useExisting: MatError }],
|
---|
47 | },] }
|
---|
48 | ];
|
---|
49 | MatError.ctorParameters = () => [
|
---|
50 | { type: String, decorators: [{ type: Attribute, args: ['aria-live',] }] },
|
---|
51 | { type: ElementRef }
|
---|
52 | ];
|
---|
53 | MatError.propDecorators = {
|
---|
54 | id: [{ type: Input }]
|
---|
55 | };
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * @license
|
---|
59 | * Copyright Google LLC All Rights Reserved.
|
---|
60 | *
|
---|
61 | * Use of this source code is governed by an MIT-style license that can be
|
---|
62 | * found in the LICENSE file at https://angular.io/license
|
---|
63 | */
|
---|
64 | /**
|
---|
65 | * Animations used by the MatFormField.
|
---|
66 | * @docs-private
|
---|
67 | */
|
---|
68 | const matFormFieldAnimations = {
|
---|
69 | /** Animation that transitions the form field's error and hint messages. */
|
---|
70 | transitionMessages: trigger('transitionMessages', [
|
---|
71 | // TODO(mmalerba): Use angular animations for label animation as well.
|
---|
72 | state('enter', style({ opacity: 1, transform: 'translateY(0%)' })),
|
---|
73 | transition('void => enter', [
|
---|
74 | style({ opacity: 0, transform: 'translateY(-5px)' }),
|
---|
75 | animate('300ms cubic-bezier(0.55, 0, 0.55, 0.2)'),
|
---|
76 | ]),
|
---|
77 | ])
|
---|
78 | };
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * @license
|
---|
82 | * Copyright Google LLC All Rights Reserved.
|
---|
83 | *
|
---|
84 | * Use of this source code is governed by an MIT-style license that can be
|
---|
85 | * found in the LICENSE file at https://angular.io/license
|
---|
86 | */
|
---|
87 | /** An interface which allows a control to work inside of a `MatFormField`. */
|
---|
88 | class MatFormFieldControl {
|
---|
89 | }
|
---|
90 | MatFormFieldControl.decorators = [
|
---|
91 | { type: Directive }
|
---|
92 | ];
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * @license
|
---|
96 | * Copyright Google LLC All Rights Reserved.
|
---|
97 | *
|
---|
98 | * Use of this source code is governed by an MIT-style license that can be
|
---|
99 | * found in the LICENSE file at https://angular.io/license
|
---|
100 | */
|
---|
101 | /** @docs-private */
|
---|
102 | function getMatFormFieldPlaceholderConflictError() {
|
---|
103 | return Error('Placeholder attribute and child element were both specified.');
|
---|
104 | }
|
---|
105 | /** @docs-private */
|
---|
106 | function getMatFormFieldDuplicatedHintError(align) {
|
---|
107 | return Error(`A hint was already declared for 'align="${align}"'.`);
|
---|
108 | }
|
---|
109 | /** @docs-private */
|
---|
110 | function getMatFormFieldMissingControlError() {
|
---|
111 | return Error('mat-form-field must contain a MatFormFieldControl.');
|
---|
112 | }
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * @license
|
---|
116 | * Copyright Google LLC All Rights Reserved.
|
---|
117 | *
|
---|
118 | * Use of this source code is governed by an MIT-style license that can be
|
---|
119 | * found in the LICENSE file at https://angular.io/license
|
---|
120 | */
|
---|
121 | let nextUniqueId$1 = 0;
|
---|
122 | /**
|
---|
123 | * Injection token that can be used to reference instances of `MatHint`. It serves as
|
---|
124 | * alternative token to the actual `MatHint` class which could cause unnecessary
|
---|
125 | * retention of the class and its directive metadata.
|
---|
126 | *
|
---|
127 | * *Note*: This is not part of the public API as the MDC-based form-field will not
|
---|
128 | * need a lightweight token for `MatHint` and we want to reduce breaking changes.
|
---|
129 | */
|
---|
130 | const _MAT_HINT = new InjectionToken('MatHint');
|
---|
131 | /** Hint text to be shown underneath the form field control. */
|
---|
132 | class MatHint {
|
---|
133 | constructor() {
|
---|
134 | /** Whether to align the hint label at the start or end of the line. */
|
---|
135 | this.align = 'start';
|
---|
136 | /** Unique ID for the hint. Used for the aria-describedby on the form field control. */
|
---|
137 | this.id = `mat-hint-${nextUniqueId$1++}`;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | MatHint.decorators = [
|
---|
141 | { type: Directive, args: [{
|
---|
142 | selector: 'mat-hint',
|
---|
143 | host: {
|
---|
144 | 'class': 'mat-hint',
|
---|
145 | '[class.mat-form-field-hint-end]': 'align === "end"',
|
---|
146 | '[attr.id]': 'id',
|
---|
147 | // Remove align attribute to prevent it from interfering with layout.
|
---|
148 | '[attr.align]': 'null',
|
---|
149 | },
|
---|
150 | providers: [{ provide: _MAT_HINT, useExisting: MatHint }],
|
---|
151 | },] }
|
---|
152 | ];
|
---|
153 | MatHint.propDecorators = {
|
---|
154 | align: [{ type: Input }],
|
---|
155 | id: [{ type: Input }]
|
---|
156 | };
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * @license
|
---|
160 | * Copyright Google LLC All Rights Reserved.
|
---|
161 | *
|
---|
162 | * Use of this source code is governed by an MIT-style license that can be
|
---|
163 | * found in the LICENSE file at https://angular.io/license
|
---|
164 | */
|
---|
165 | /** The floating label for a `mat-form-field`. */
|
---|
166 | class MatLabel {
|
---|
167 | }
|
---|
168 | MatLabel.decorators = [
|
---|
169 | { type: Directive, args: [{
|
---|
170 | selector: 'mat-label'
|
---|
171 | },] }
|
---|
172 | ];
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * @license
|
---|
176 | * Copyright Google LLC All Rights Reserved.
|
---|
177 | *
|
---|
178 | * Use of this source code is governed by an MIT-style license that can be
|
---|
179 | * found in the LICENSE file at https://angular.io/license
|
---|
180 | */
|
---|
181 | /**
|
---|
182 | * The placeholder text for an `MatFormField`.
|
---|
183 | * @deprecated Use `<mat-label>` to specify the label and the `placeholder` attribute to specify the
|
---|
184 | * placeholder.
|
---|
185 | * @breaking-change 8.0.0
|
---|
186 | */
|
---|
187 | class MatPlaceholder {
|
---|
188 | }
|
---|
189 | MatPlaceholder.decorators = [
|
---|
190 | { type: Directive, args: [{
|
---|
191 | selector: 'mat-placeholder'
|
---|
192 | },] }
|
---|
193 | ];
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * @license
|
---|
197 | * Copyright Google LLC All Rights Reserved.
|
---|
198 | *
|
---|
199 | * Use of this source code is governed by an MIT-style license that can be
|
---|
200 | * found in the LICENSE file at https://angular.io/license
|
---|
201 | */
|
---|
202 | /**
|
---|
203 | * Injection token that can be used to reference instances of `MatPrefix`. It serves as
|
---|
204 | * alternative token to the actual `MatPrefix` class which could cause unnecessary
|
---|
205 | * retention of the class and its directive metadata.
|
---|
206 | */
|
---|
207 | const MAT_PREFIX = new InjectionToken('MatPrefix');
|
---|
208 | /** Prefix to be placed in front of the form field. */
|
---|
209 | class MatPrefix {
|
---|
210 | }
|
---|
211 | MatPrefix.decorators = [
|
---|
212 | { type: Directive, args: [{
|
---|
213 | selector: '[matPrefix]',
|
---|
214 | providers: [{ provide: MAT_PREFIX, useExisting: MatPrefix }],
|
---|
215 | },] }
|
---|
216 | ];
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * @license
|
---|
220 | * Copyright Google LLC All Rights Reserved.
|
---|
221 | *
|
---|
222 | * Use of this source code is governed by an MIT-style license that can be
|
---|
223 | * found in the LICENSE file at https://angular.io/license
|
---|
224 | */
|
---|
225 | /**
|
---|
226 | * Injection token that can be used to reference instances of `MatSuffix`. It serves as
|
---|
227 | * alternative token to the actual `MatSuffix` class which could cause unnecessary
|
---|
228 | * retention of the class and its directive metadata.
|
---|
229 | */
|
---|
230 | const MAT_SUFFIX = new InjectionToken('MatSuffix');
|
---|
231 | /** Suffix to be placed at the end of the form field. */
|
---|
232 | class MatSuffix {
|
---|
233 | }
|
---|
234 | MatSuffix.decorators = [
|
---|
235 | { type: Directive, args: [{
|
---|
236 | selector: '[matSuffix]',
|
---|
237 | providers: [{ provide: MAT_SUFFIX, useExisting: MatSuffix }],
|
---|
238 | },] }
|
---|
239 | ];
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * @license
|
---|
243 | * Copyright Google LLC All Rights Reserved.
|
---|
244 | *
|
---|
245 | * Use of this source code is governed by an MIT-style license that can be
|
---|
246 | * found in the LICENSE file at https://angular.io/license
|
---|
247 | */
|
---|
248 | let nextUniqueId = 0;
|
---|
249 | const floatingLabelScale = 0.75;
|
---|
250 | const outlineGapPadding = 5;
|
---|
251 | /**
|
---|
252 | * Boilerplate for applying mixins to MatFormField.
|
---|
253 | * @docs-private
|
---|
254 | */
|
---|
255 | const _MatFormFieldBase = mixinColor(class {
|
---|
256 | constructor(_elementRef) {
|
---|
257 | this._elementRef = _elementRef;
|
---|
258 | }
|
---|
259 | }, 'primary');
|
---|
260 | /**
|
---|
261 | * Injection token that can be used to configure the
|
---|
262 | * default options for all form field within an app.
|
---|
263 | */
|
---|
264 | const MAT_FORM_FIELD_DEFAULT_OPTIONS = new InjectionToken('MAT_FORM_FIELD_DEFAULT_OPTIONS');
|
---|
265 | /**
|
---|
266 | * Injection token that can be used to inject an instances of `MatFormField`. It serves
|
---|
267 | * as alternative token to the actual `MatFormField` class which would cause unnecessary
|
---|
268 | * retention of the `MatFormField` class and its component metadata.
|
---|
269 | */
|
---|
270 | const MAT_FORM_FIELD = new InjectionToken('MatFormField');
|
---|
271 | /** Container for form controls that applies Material Design styling and behavior. */
|
---|
272 | class MatFormField extends _MatFormFieldBase {
|
---|
273 | constructor(elementRef, _changeDetectorRef,
|
---|
274 | /**
|
---|
275 | * @deprecated `_labelOptions` parameter no longer being used. To be removed.
|
---|
276 | * @breaking-change 12.0.0
|
---|
277 | */
|
---|
278 | // Use `ElementRef` here so Angular has something to inject.
|
---|
279 | _labelOptions, _dir, _defaults, _platform, _ngZone, _animationMode) {
|
---|
280 | super(elementRef);
|
---|
281 | this._changeDetectorRef = _changeDetectorRef;
|
---|
282 | this._dir = _dir;
|
---|
283 | this._defaults = _defaults;
|
---|
284 | this._platform = _platform;
|
---|
285 | this._ngZone = _ngZone;
|
---|
286 | /**
|
---|
287 | * Whether the outline gap needs to be calculated
|
---|
288 | * immediately on the next change detection run.
|
---|
289 | */
|
---|
290 | this._outlineGapCalculationNeededImmediately = false;
|
---|
291 | /** Whether the outline gap needs to be calculated next time the zone has stabilized. */
|
---|
292 | this._outlineGapCalculationNeededOnStable = false;
|
---|
293 | this._destroyed = new Subject();
|
---|
294 | /** Override for the logic that disables the label animation in certain cases. */
|
---|
295 | this._showAlwaysAnimate = false;
|
---|
296 | /** State of the mat-hint and mat-error animations. */
|
---|
297 | this._subscriptAnimationState = '';
|
---|
298 | this._hintLabel = '';
|
---|
299 | // Unique id for the hint label.
|
---|
300 | this._hintLabelId = `mat-hint-${nextUniqueId++}`;
|
---|
301 | // Unique id for the label element.
|
---|
302 | this._labelId = `mat-form-field-label-${nextUniqueId++}`;
|
---|
303 | this.floatLabel = this._getDefaultFloatLabelState();
|
---|
304 | this._animationsEnabled = _animationMode !== 'NoopAnimations';
|
---|
305 | // Set the default through here so we invoke the setter on the first run.
|
---|
306 | this.appearance = (_defaults && _defaults.appearance) ? _defaults.appearance : 'legacy';
|
---|
307 | this._hideRequiredMarker = (_defaults && _defaults.hideRequiredMarker != null) ?
|
---|
308 | _defaults.hideRequiredMarker : false;
|
---|
309 | }
|
---|
310 | /** The form-field appearance style. */
|
---|
311 | get appearance() { return this._appearance; }
|
---|
312 | set appearance(value) {
|
---|
313 | const oldValue = this._appearance;
|
---|
314 | this._appearance = value || (this._defaults && this._defaults.appearance) || 'legacy';
|
---|
315 | if (this._appearance === 'outline' && oldValue !== value) {
|
---|
316 | this._outlineGapCalculationNeededOnStable = true;
|
---|
317 | }
|
---|
318 | }
|
---|
319 | /** Whether the required marker should be hidden. */
|
---|
320 | get hideRequiredMarker() { return this._hideRequiredMarker; }
|
---|
321 | set hideRequiredMarker(value) {
|
---|
322 | this._hideRequiredMarker = coerceBooleanProperty(value);
|
---|
323 | }
|
---|
324 | /** Whether the floating label should always float or not. */
|
---|
325 | _shouldAlwaysFloat() {
|
---|
326 | return this.floatLabel === 'always' && !this._showAlwaysAnimate;
|
---|
327 | }
|
---|
328 | /** Whether the label can float or not. */
|
---|
329 | _canLabelFloat() { return this.floatLabel !== 'never'; }
|
---|
330 | /** Text for the form field hint. */
|
---|
331 | get hintLabel() { return this._hintLabel; }
|
---|
332 | set hintLabel(value) {
|
---|
333 | this._hintLabel = value;
|
---|
334 | this._processHints();
|
---|
335 | }
|
---|
336 | /**
|
---|
337 | * Whether the label should always float, never float or float as the user types.
|
---|
338 | *
|
---|
339 | * Note: only the legacy appearance supports the `never` option. `never` was originally added as a
|
---|
340 | * way to make the floating label emulate the behavior of a standard input placeholder. However
|
---|
341 | * the form field now supports both floating labels and placeholders. Therefore in the non-legacy
|
---|
342 | * appearances the `never` option has been disabled in favor of just using the placeholder.
|
---|
343 | */
|
---|
344 | get floatLabel() {
|
---|
345 | return this.appearance !== 'legacy' && this._floatLabel === 'never' ? 'auto' : this._floatLabel;
|
---|
346 | }
|
---|
347 | set floatLabel(value) {
|
---|
348 | if (value !== this._floatLabel) {
|
---|
349 | this._floatLabel = value || this._getDefaultFloatLabelState();
|
---|
350 | this._changeDetectorRef.markForCheck();
|
---|
351 | }
|
---|
352 | }
|
---|
353 | get _control() {
|
---|
354 | // TODO(crisbeto): we need this workaround in order to support both Ivy and ViewEngine.
|
---|
355 | // We should clean this up once Ivy is the default renderer.
|
---|
356 | return this._explicitFormFieldControl || this._controlNonStatic || this._controlStatic;
|
---|
357 | }
|
---|
358 | set _control(value) {
|
---|
359 | this._explicitFormFieldControl = value;
|
---|
360 | }
|
---|
361 | /**
|
---|
362 | * Gets the id of the label element. If no label is present, returns `null`.
|
---|
363 | */
|
---|
364 | getLabelId() {
|
---|
365 | return this._hasFloatingLabel() ? this._labelId : null;
|
---|
366 | }
|
---|
367 | /**
|
---|
368 | * Gets an ElementRef for the element that a overlay attached to the form-field should be
|
---|
369 | * positioned relative to.
|
---|
370 | */
|
---|
371 | getConnectedOverlayOrigin() {
|
---|
372 | return this._connectionContainerRef || this._elementRef;
|
---|
373 | }
|
---|
374 | ngAfterContentInit() {
|
---|
375 | this._validateControlChild();
|
---|
376 | const control = this._control;
|
---|
377 | if (control.controlType) {
|
---|
378 | this._elementRef.nativeElement.classList.add(`mat-form-field-type-${control.controlType}`);
|
---|
379 | }
|
---|
380 | // Subscribe to changes in the child control state in order to update the form field UI.
|
---|
381 | control.stateChanges.pipe(startWith(null)).subscribe(() => {
|
---|
382 | this._validatePlaceholders();
|
---|
383 | this._syncDescribedByIds();
|
---|
384 | this._changeDetectorRef.markForCheck();
|
---|
385 | });
|
---|
386 | // Run change detection if the value changes.
|
---|
387 | if (control.ngControl && control.ngControl.valueChanges) {
|
---|
388 | control.ngControl.valueChanges
|
---|
389 | .pipe(takeUntil(this._destroyed))
|
---|
390 | .subscribe(() => this._changeDetectorRef.markForCheck());
|
---|
391 | }
|
---|
392 | // Note that we have to run outside of the `NgZone` explicitly,
|
---|
393 | // in order to avoid throwing users into an infinite loop
|
---|
394 | // if `zone-patch-rxjs` is included.
|
---|
395 | this._ngZone.runOutsideAngular(() => {
|
---|
396 | this._ngZone.onStable.pipe(takeUntil(this._destroyed)).subscribe(() => {
|
---|
397 | if (this._outlineGapCalculationNeededOnStable) {
|
---|
398 | this.updateOutlineGap();
|
---|
399 | }
|
---|
400 | });
|
---|
401 | });
|
---|
402 | // Run change detection and update the outline if the suffix or prefix changes.
|
---|
403 | merge(this._prefixChildren.changes, this._suffixChildren.changes).subscribe(() => {
|
---|
404 | this._outlineGapCalculationNeededOnStable = true;
|
---|
405 | this._changeDetectorRef.markForCheck();
|
---|
406 | });
|
---|
407 | // Re-validate when the number of hints changes.
|
---|
408 | this._hintChildren.changes.pipe(startWith(null)).subscribe(() => {
|
---|
409 | this._processHints();
|
---|
410 | this._changeDetectorRef.markForCheck();
|
---|
411 | });
|
---|
412 | // Update the aria-described by when the number of errors changes.
|
---|
413 | this._errorChildren.changes.pipe(startWith(null)).subscribe(() => {
|
---|
414 | this._syncDescribedByIds();
|
---|
415 | this._changeDetectorRef.markForCheck();
|
---|
416 | });
|
---|
417 | if (this._dir) {
|
---|
418 | this._dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => {
|
---|
419 | if (typeof requestAnimationFrame === 'function') {
|
---|
420 | this._ngZone.runOutsideAngular(() => {
|
---|
421 | requestAnimationFrame(() => this.updateOutlineGap());
|
---|
422 | });
|
---|
423 | }
|
---|
424 | else {
|
---|
425 | this.updateOutlineGap();
|
---|
426 | }
|
---|
427 | });
|
---|
428 | }
|
---|
429 | }
|
---|
430 | ngAfterContentChecked() {
|
---|
431 | this._validateControlChild();
|
---|
432 | if (this._outlineGapCalculationNeededImmediately) {
|
---|
433 | this.updateOutlineGap();
|
---|
434 | }
|
---|
435 | }
|
---|
436 | ngAfterViewInit() {
|
---|
437 | // Avoid animations on load.
|
---|
438 | this._subscriptAnimationState = 'enter';
|
---|
439 | this._changeDetectorRef.detectChanges();
|
---|
440 | }
|
---|
441 | ngOnDestroy() {
|
---|
442 | this._destroyed.next();
|
---|
443 | this._destroyed.complete();
|
---|
444 | }
|
---|
445 | /** Determines whether a class from the NgControl should be forwarded to the host element. */
|
---|
446 | _shouldForward(prop) {
|
---|
447 | const ngControl = this._control ? this._control.ngControl : null;
|
---|
448 | return ngControl && ngControl[prop];
|
---|
449 | }
|
---|
450 | _hasPlaceholder() {
|
---|
451 | return !!(this._control && this._control.placeholder || this._placeholderChild);
|
---|
452 | }
|
---|
453 | _hasLabel() {
|
---|
454 | return !!(this._labelChildNonStatic || this._labelChildStatic);
|
---|
455 | }
|
---|
456 | _shouldLabelFloat() {
|
---|
457 | return this._canLabelFloat() &&
|
---|
458 | ((this._control && this._control.shouldLabelFloat) || this._shouldAlwaysFloat());
|
---|
459 | }
|
---|
460 | _hideControlPlaceholder() {
|
---|
461 | // In the legacy appearance the placeholder is promoted to a label if no label is given.
|
---|
462 | return this.appearance === 'legacy' && !this._hasLabel() ||
|
---|
463 | this._hasLabel() && !this._shouldLabelFloat();
|
---|
464 | }
|
---|
465 | _hasFloatingLabel() {
|
---|
466 | // In the legacy appearance the placeholder is promoted to a label if no label is given.
|
---|
467 | return this._hasLabel() || this.appearance === 'legacy' && this._hasPlaceholder();
|
---|
468 | }
|
---|
469 | /** Determines whether to display hints or errors. */
|
---|
470 | _getDisplayedMessages() {
|
---|
471 | return (this._errorChildren && this._errorChildren.length > 0 &&
|
---|
472 | this._control.errorState) ? 'error' : 'hint';
|
---|
473 | }
|
---|
474 | /** Animates the placeholder up and locks it in position. */
|
---|
475 | _animateAndLockLabel() {
|
---|
476 | if (this._hasFloatingLabel() && this._canLabelFloat()) {
|
---|
477 | // If animations are disabled, we shouldn't go in here,
|
---|
478 | // because the `transitionend` will never fire.
|
---|
479 | if (this._animationsEnabled && this._label) {
|
---|
480 | this._showAlwaysAnimate = true;
|
---|
481 | fromEvent(this._label.nativeElement, 'transitionend').pipe(take(1)).subscribe(() => {
|
---|
482 | this._showAlwaysAnimate = false;
|
---|
483 | });
|
---|
484 | }
|
---|
485 | this.floatLabel = 'always';
|
---|
486 | this._changeDetectorRef.markForCheck();
|
---|
487 | }
|
---|
488 | }
|
---|
489 | /**
|
---|
490 | * Ensure that there is only one placeholder (either `placeholder` attribute on the child control
|
---|
491 | * or child element with the `mat-placeholder` directive).
|
---|
492 | */
|
---|
493 | _validatePlaceholders() {
|
---|
494 | if (this._control.placeholder && this._placeholderChild &&
|
---|
495 | (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
496 | throw getMatFormFieldPlaceholderConflictError();
|
---|
497 | }
|
---|
498 | }
|
---|
499 | /** Does any extra processing that is required when handling the hints. */
|
---|
500 | _processHints() {
|
---|
501 | this._validateHints();
|
---|
502 | this._syncDescribedByIds();
|
---|
503 | }
|
---|
504 | /**
|
---|
505 | * Ensure that there is a maximum of one of each `<mat-hint>` alignment specified, with the
|
---|
506 | * attribute being considered as `align="start"`.
|
---|
507 | */
|
---|
508 | _validateHints() {
|
---|
509 | if (this._hintChildren && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
510 | let startHint;
|
---|
511 | let endHint;
|
---|
512 | this._hintChildren.forEach((hint) => {
|
---|
513 | if (hint.align === 'start') {
|
---|
514 | if (startHint || this.hintLabel) {
|
---|
515 | throw getMatFormFieldDuplicatedHintError('start');
|
---|
516 | }
|
---|
517 | startHint = hint;
|
---|
518 | }
|
---|
519 | else if (hint.align === 'end') {
|
---|
520 | if (endHint) {
|
---|
521 | throw getMatFormFieldDuplicatedHintError('end');
|
---|
522 | }
|
---|
523 | endHint = hint;
|
---|
524 | }
|
---|
525 | });
|
---|
526 | }
|
---|
527 | }
|
---|
528 | /** Gets the default float label state. */
|
---|
529 | _getDefaultFloatLabelState() {
|
---|
530 | return (this._defaults && this._defaults.floatLabel) || 'auto';
|
---|
531 | }
|
---|
532 | /**
|
---|
533 | * Sets the list of element IDs that describe the child control. This allows the control to update
|
---|
534 | * its `aria-describedby` attribute accordingly.
|
---|
535 | */
|
---|
536 | _syncDescribedByIds() {
|
---|
537 | if (this._control) {
|
---|
538 | let ids = [];
|
---|
539 | // TODO(wagnermaciel): Remove the type check when we find the root cause of this bug.
|
---|
540 | if (this._control.userAriaDescribedBy &&
|
---|
541 | typeof this._control.userAriaDescribedBy === 'string') {
|
---|
542 | ids.push(...this._control.userAriaDescribedBy.split(' '));
|
---|
543 | }
|
---|
544 | if (this._getDisplayedMessages() === 'hint') {
|
---|
545 | const startHint = this._hintChildren ?
|
---|
546 | this._hintChildren.find(hint => hint.align === 'start') : null;
|
---|
547 | const endHint = this._hintChildren ?
|
---|
548 | this._hintChildren.find(hint => hint.align === 'end') : null;
|
---|
549 | if (startHint) {
|
---|
550 | ids.push(startHint.id);
|
---|
551 | }
|
---|
552 | else if (this._hintLabel) {
|
---|
553 | ids.push(this._hintLabelId);
|
---|
554 | }
|
---|
555 | if (endHint) {
|
---|
556 | ids.push(endHint.id);
|
---|
557 | }
|
---|
558 | }
|
---|
559 | else if (this._errorChildren) {
|
---|
560 | ids.push(...this._errorChildren.map(error => error.id));
|
---|
561 | }
|
---|
562 | this._control.setDescribedByIds(ids);
|
---|
563 | }
|
---|
564 | }
|
---|
565 | /** Throws an error if the form field's control is missing. */
|
---|
566 | _validateControlChild() {
|
---|
567 | if (!this._control && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
568 | throw getMatFormFieldMissingControlError();
|
---|
569 | }
|
---|
570 | }
|
---|
571 | /**
|
---|
572 | * Updates the width and position of the gap in the outline. Only relevant for the outline
|
---|
573 | * appearance.
|
---|
574 | */
|
---|
575 | updateOutlineGap() {
|
---|
576 | const labelEl = this._label ? this._label.nativeElement : null;
|
---|
577 | if (this.appearance !== 'outline' || !labelEl || !labelEl.children.length ||
|
---|
578 | !labelEl.textContent.trim()) {
|
---|
579 | return;
|
---|
580 | }
|
---|
581 | if (!this._platform.isBrowser) {
|
---|
582 | // getBoundingClientRect isn't available on the server.
|
---|
583 | return;
|
---|
584 | }
|
---|
585 | // If the element is not present in the DOM, the outline gap will need to be calculated
|
---|
586 | // the next time it is checked and in the DOM.
|
---|
587 | if (!this._isAttachedToDOM()) {
|
---|
588 | this._outlineGapCalculationNeededImmediately = true;
|
---|
589 | return;
|
---|
590 | }
|
---|
591 | let startWidth = 0;
|
---|
592 | let gapWidth = 0;
|
---|
593 | const container = this._connectionContainerRef.nativeElement;
|
---|
594 | const startEls = container.querySelectorAll('.mat-form-field-outline-start');
|
---|
595 | const gapEls = container.querySelectorAll('.mat-form-field-outline-gap');
|
---|
596 | if (this._label && this._label.nativeElement.children.length) {
|
---|
597 | const containerRect = container.getBoundingClientRect();
|
---|
598 | // If the container's width and height are zero, it means that the element is
|
---|
599 | // invisible and we can't calculate the outline gap. Mark the element as needing
|
---|
600 | // to be checked the next time the zone stabilizes. We can't do this immediately
|
---|
601 | // on the next change detection, because even if the element becomes visible,
|
---|
602 | // the `ClientRect` won't be reclaculated immediately. We reset the
|
---|
603 | // `_outlineGapCalculationNeededImmediately` flag some we don't run the checks twice.
|
---|
604 | if (containerRect.width === 0 && containerRect.height === 0) {
|
---|
605 | this._outlineGapCalculationNeededOnStable = true;
|
---|
606 | this._outlineGapCalculationNeededImmediately = false;
|
---|
607 | return;
|
---|
608 | }
|
---|
609 | const containerStart = this._getStartEnd(containerRect);
|
---|
610 | const labelChildren = labelEl.children;
|
---|
611 | const labelStart = this._getStartEnd(labelChildren[0].getBoundingClientRect());
|
---|
612 | let labelWidth = 0;
|
---|
613 | for (let i = 0; i < labelChildren.length; i++) {
|
---|
614 | labelWidth += labelChildren[i].offsetWidth;
|
---|
615 | }
|
---|
616 | startWidth = Math.abs(labelStart - containerStart) - outlineGapPadding;
|
---|
617 | gapWidth = labelWidth > 0 ? labelWidth * floatingLabelScale + outlineGapPadding * 2 : 0;
|
---|
618 | }
|
---|
619 | for (let i = 0; i < startEls.length; i++) {
|
---|
620 | startEls[i].style.width = `${startWidth}px`;
|
---|
621 | }
|
---|
622 | for (let i = 0; i < gapEls.length; i++) {
|
---|
623 | gapEls[i].style.width = `${gapWidth}px`;
|
---|
624 | }
|
---|
625 | this._outlineGapCalculationNeededOnStable =
|
---|
626 | this._outlineGapCalculationNeededImmediately = false;
|
---|
627 | }
|
---|
628 | /** Gets the start end of the rect considering the current directionality. */
|
---|
629 | _getStartEnd(rect) {
|
---|
630 | return (this._dir && this._dir.value === 'rtl') ? rect.right : rect.left;
|
---|
631 | }
|
---|
632 | /** Checks whether the form field is attached to the DOM. */
|
---|
633 | _isAttachedToDOM() {
|
---|
634 | const element = this._elementRef.nativeElement;
|
---|
635 | if (element.getRootNode) {
|
---|
636 | const rootNode = element.getRootNode();
|
---|
637 | // If the element is inside the DOM the root node will be either the document
|
---|
638 | // or the closest shadow root, otherwise it'll be the element itself.
|
---|
639 | return rootNode && rootNode !== element;
|
---|
640 | }
|
---|
641 | // Otherwise fall back to checking if it's in the document. This doesn't account for
|
---|
642 | // shadow DOM, however browser that support shadow DOM should support `getRootNode` as well.
|
---|
643 | return document.documentElement.contains(element);
|
---|
644 | }
|
---|
645 | }
|
---|
646 | MatFormField.decorators = [
|
---|
647 | { type: Component, args: [{
|
---|
648 | selector: 'mat-form-field',
|
---|
649 | exportAs: 'matFormField',
|
---|
650 | template: "<div class=\"mat-form-field-wrapper\">\n <div class=\"mat-form-field-flex\" #connectionContainer\n (click)=\"_control.onContainerClick && _control.onContainerClick($event)\">\n\n <!-- Outline used for outline appearance. -->\n <ng-container *ngIf=\"appearance == 'outline'\">\n <div class=\"mat-form-field-outline\">\n <div class=\"mat-form-field-outline-start\"></div>\n <div class=\"mat-form-field-outline-gap\"></div>\n <div class=\"mat-form-field-outline-end\"></div>\n </div>\n <div class=\"mat-form-field-outline mat-form-field-outline-thick\">\n <div class=\"mat-form-field-outline-start\"></div>\n <div class=\"mat-form-field-outline-gap\"></div>\n <div class=\"mat-form-field-outline-end\"></div>\n </div>\n </ng-container>\n\n <div class=\"mat-form-field-prefix\" *ngIf=\"_prefixChildren.length\">\n <ng-content select=\"[matPrefix]\"></ng-content>\n </div>\n\n <div class=\"mat-form-field-infix\" #inputContainer>\n <ng-content></ng-content>\n\n <span class=\"mat-form-field-label-wrapper\">\n <!-- We add aria-owns as a workaround for an issue in JAWS & NVDA where the label isn't\n read if it comes before the control in the DOM. -->\n <label class=\"mat-form-field-label\"\n (cdkObserveContent)=\"updateOutlineGap()\"\n [cdkObserveContentDisabled]=\"appearance != 'outline'\"\n [id]=\"_labelId\"\n [attr.for]=\"_control.id\"\n [attr.aria-owns]=\"_control.id\"\n [class.mat-empty]=\"_control.empty && !_shouldAlwaysFloat()\"\n [class.mat-form-field-empty]=\"_control.empty && !_shouldAlwaysFloat()\"\n [class.mat-accent]=\"color == 'accent'\"\n [class.mat-warn]=\"color == 'warn'\"\n #label\n *ngIf=\"_hasFloatingLabel()\"\n [ngSwitch]=\"_hasLabel()\">\n\n <!-- @breaking-change 8.0.0 remove in favor of mat-label element an placeholder attr. -->\n <ng-container *ngSwitchCase=\"false\">\n <ng-content select=\"mat-placeholder\"></ng-content>\n <span>{{_control.placeholder}}</span>\n </ng-container>\n\n <ng-content select=\"mat-label\" *ngSwitchCase=\"true\"></ng-content>\n\n <!-- @breaking-change 8.0.0 remove `mat-placeholder-required` class -->\n <span\n class=\"mat-placeholder-required mat-form-field-required-marker\"\n aria-hidden=\"true\"\n *ngIf=\"!hideRequiredMarker && _control.required && !_control.disabled\"> *</span>\n </label>\n </span>\n </div>\n\n <div class=\"mat-form-field-suffix\" *ngIf=\"_suffixChildren.length\">\n <ng-content select=\"[matSuffix]\"></ng-content>\n </div>\n </div>\n\n <!-- Underline used for legacy, standard, and box appearances. -->\n <div class=\"mat-form-field-underline\" #underline\n *ngIf=\"appearance != 'outline'\">\n <span class=\"mat-form-field-ripple\"\n [class.mat-accent]=\"color == 'accent'\"\n [class.mat-warn]=\"color == 'warn'\"></span>\n </div>\n\n <div class=\"mat-form-field-subscript-wrapper\"\n [ngSwitch]=\"_getDisplayedMessages()\">\n <div *ngSwitchCase=\"'error'\" [@transitionMessages]=\"_subscriptAnimationState\">\n <ng-content select=\"mat-error\"></ng-content>\n </div>\n\n <div class=\"mat-form-field-hint-wrapper\" *ngSwitchCase=\"'hint'\"\n [@transitionMessages]=\"_subscriptAnimationState\">\n <!-- TODO(mmalerba): use an actual <mat-hint> once all selectors are switched to mat-* -->\n <div *ngIf=\"hintLabel\" [id]=\"_hintLabelId\" class=\"mat-hint\">{{hintLabel}}</div>\n <ng-content select=\"mat-hint:not([align='end'])\"></ng-content>\n <div class=\"mat-form-field-hint-spacer\"></div>\n <ng-content select=\"mat-hint[align='end']\"></ng-content>\n </div>\n </div>\n</div>\n",
|
---|
651 | animations: [matFormFieldAnimations.transitionMessages],
|
---|
652 | host: {
|
---|
653 | 'class': 'mat-form-field',
|
---|
654 | '[class.mat-form-field-appearance-standard]': 'appearance == "standard"',
|
---|
655 | '[class.mat-form-field-appearance-fill]': 'appearance == "fill"',
|
---|
656 | '[class.mat-form-field-appearance-outline]': 'appearance == "outline"',
|
---|
657 | '[class.mat-form-field-appearance-legacy]': 'appearance == "legacy"',
|
---|
658 | '[class.mat-form-field-invalid]': '_control.errorState',
|
---|
659 | '[class.mat-form-field-can-float]': '_canLabelFloat()',
|
---|
660 | '[class.mat-form-field-should-float]': '_shouldLabelFloat()',
|
---|
661 | '[class.mat-form-field-has-label]': '_hasFloatingLabel()',
|
---|
662 | '[class.mat-form-field-hide-placeholder]': '_hideControlPlaceholder()',
|
---|
663 | '[class.mat-form-field-disabled]': '_control.disabled',
|
---|
664 | '[class.mat-form-field-autofilled]': '_control.autofilled',
|
---|
665 | '[class.mat-focused]': '_control.focused',
|
---|
666 | '[class.ng-untouched]': '_shouldForward("untouched")',
|
---|
667 | '[class.ng-touched]': '_shouldForward("touched")',
|
---|
668 | '[class.ng-pristine]': '_shouldForward("pristine")',
|
---|
669 | '[class.ng-dirty]': '_shouldForward("dirty")',
|
---|
670 | '[class.ng-valid]': '_shouldForward("valid")',
|
---|
671 | '[class.ng-invalid]': '_shouldForward("invalid")',
|
---|
672 | '[class.ng-pending]': '_shouldForward("pending")',
|
---|
673 | '[class._mat-animation-noopable]': '!_animationsEnabled',
|
---|
674 | },
|
---|
675 | inputs: ['color'],
|
---|
676 | encapsulation: ViewEncapsulation.None,
|
---|
677 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
678 | providers: [
|
---|
679 | { provide: MAT_FORM_FIELD, useExisting: MatFormField },
|
---|
680 | ],
|
---|
681 | styles: [".mat-form-field{display:inline-block;position:relative;text-align:left}[dir=rtl] .mat-form-field{text-align:right}.mat-form-field-wrapper{position:relative}.mat-form-field-flex{display:inline-flex;align-items:baseline;box-sizing:border-box;width:100%}.mat-form-field-prefix,.mat-form-field-suffix{white-space:nowrap;flex:none;position:relative}.mat-form-field-infix{display:block;position:relative;flex:auto;min-width:0;width:180px}.cdk-high-contrast-active .mat-form-field-infix{border-image:linear-gradient(transparent, transparent)}.mat-form-field-label-wrapper{position:absolute;left:0;box-sizing:content-box;width:100%;height:100%;overflow:hidden;pointer-events:none}[dir=rtl] .mat-form-field-label-wrapper{left:auto;right:0}.mat-form-field-label{position:absolute;left:0;font:inherit;pointer-events:none;width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;transform-origin:0 0;transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),color 400ms cubic-bezier(0.25, 0.8, 0.25, 1),width 400ms cubic-bezier(0.25, 0.8, 0.25, 1);display:none}[dir=rtl] .mat-form-field-label{transform-origin:100% 0;left:auto;right:0}.mat-form-field-empty.mat-form-field-label,.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-label{display:block}.mat-form-field-autofill-control:-webkit-autofill+.mat-form-field-label-wrapper .mat-form-field-label{display:none}.mat-form-field-can-float .mat-form-field-autofill-control:-webkit-autofill+.mat-form-field-label-wrapper .mat-form-field-label{display:block;transition:none}.mat-input-server:focus+.mat-form-field-label-wrapper .mat-form-field-label,.mat-input-server[placeholder]:not(:placeholder-shown)+.mat-form-field-label-wrapper .mat-form-field-label{display:none}.mat-form-field-can-float .mat-input-server:focus+.mat-form-field-label-wrapper .mat-form-field-label,.mat-form-field-can-float .mat-input-server[placeholder]:not(:placeholder-shown)+.mat-form-field-label-wrapper .mat-form-field-label{display:block}.mat-form-field-label:not(.mat-form-field-empty){transition:none}.mat-form-field-underline{position:absolute;width:100%;pointer-events:none;transform:scale3d(1, 1.0001, 1)}.mat-form-field-ripple{position:absolute;left:0;width:100%;transform-origin:50%;transform:scaleX(0.5);opacity:0;transition:background-color 300ms cubic-bezier(0.55, 0, 0.55, 0.2)}.mat-form-field.mat-focused .mat-form-field-ripple,.mat-form-field.mat-form-field-invalid .mat-form-field-ripple{opacity:1;transform:none;transition:transform 300ms cubic-bezier(0.25, 0.8, 0.25, 1),opacity 100ms cubic-bezier(0.25, 0.8, 0.25, 1),background-color 300ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-form-field-subscript-wrapper{position:absolute;box-sizing:border-box;width:100%;overflow:hidden}.mat-form-field-subscript-wrapper .mat-icon,.mat-form-field-label-wrapper .mat-icon{width:1em;height:1em;font-size:inherit;vertical-align:baseline}.mat-form-field-hint-wrapper{display:flex}.mat-form-field-hint-spacer{flex:1 0 1em}.mat-error{display:block}.mat-form-field-control-wrapper{position:relative}.mat-form-field-hint-end{order:1}.mat-form-field._mat-animation-noopable .mat-form-field-label,.mat-form-field._mat-animation-noopable .mat-form-field-ripple{transition:none}\n", ".mat-form-field-appearance-fill .mat-form-field-flex{border-radius:4px 4px 0 0;padding:.75em .75em 0 .75em}.cdk-high-contrast-active .mat-form-field-appearance-fill .mat-form-field-flex{outline:solid 1px}.cdk-high-contrast-active .mat-form-field-appearance-fill.mat-focused .mat-form-field-flex{outline:dashed 3px}.mat-form-field-appearance-fill .mat-form-field-underline::before{content:\"\";display:block;position:absolute;bottom:0;height:1px;width:100%}.mat-form-field-appearance-fill .mat-form-field-ripple{bottom:0;height:2px}.cdk-high-contrast-active .mat-form-field-appearance-fill .mat-form-field-ripple{height:0}.mat-form-field-appearance-fill:not(.mat-form-field-disabled) .mat-form-field-flex:hover~.mat-form-field-underline .mat-form-field-ripple{opacity:1;transform:none;transition:opacity 600ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-form-field-appearance-fill._mat-animation-noopable:not(.mat-form-field-disabled) .mat-form-field-flex:hover~.mat-form-field-underline .mat-form-field-ripple{transition:none}.mat-form-field-appearance-fill .mat-form-field-subscript-wrapper{padding:0 1em}\n", ".mat-input-element{font:inherit;background:transparent;color:currentColor;border:none;outline:none;padding:0;margin:0;width:100%;max-width:100%;vertical-align:bottom;text-align:inherit;box-sizing:content-box}.mat-input-element:-moz-ui-invalid{box-shadow:none}.mat-input-element::-ms-clear,.mat-input-element::-ms-reveal{display:none}.mat-input-element,.mat-input-element::-webkit-search-cancel-button,.mat-input-element::-webkit-search-decoration,.mat-input-element::-webkit-search-results-button,.mat-input-element::-webkit-search-results-decoration{-webkit-appearance:none}.mat-input-element::-webkit-contacts-auto-fill-button,.mat-input-element::-webkit-caps-lock-indicator,.mat-input-element:not([type=password])::-webkit-credentials-auto-fill-button{visibility:hidden}.mat-input-element[type=date],.mat-input-element[type=datetime],.mat-input-element[type=datetime-local],.mat-input-element[type=month],.mat-input-element[type=week],.mat-input-element[type=time]{line-height:1}.mat-input-element[type=date]::after,.mat-input-element[type=datetime]::after,.mat-input-element[type=datetime-local]::after,.mat-input-element[type=month]::after,.mat-input-element[type=week]::after,.mat-input-element[type=time]::after{content:\" \";white-space:pre;width:1px}.mat-input-element::-webkit-inner-spin-button,.mat-input-element::-webkit-calendar-picker-indicator,.mat-input-element::-webkit-clear-button{font-size:.75em}.mat-input-element::placeholder{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-input-element::placeholder:-ms-input-placeholder{-ms-user-select:text}.mat-input-element::-moz-placeholder{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-input-element::-moz-placeholder:-ms-input-placeholder{-ms-user-select:text}.mat-input-element::-webkit-input-placeholder{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-input-element::-webkit-input-placeholder:-ms-input-placeholder{-ms-user-select:text}.mat-input-element:-ms-input-placeholder{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-input-element:-ms-input-placeholder:-ms-input-placeholder{-ms-user-select:text}.mat-form-field-hide-placeholder .mat-input-element::placeholder{color:transparent !important;-webkit-text-fill-color:transparent;transition:none}.cdk-high-contrast-active .mat-form-field-hide-placeholder .mat-input-element::placeholder{opacity:0}.mat-form-field-hide-placeholder .mat-input-element::-moz-placeholder{color:transparent !important;-webkit-text-fill-color:transparent;transition:none}.cdk-high-contrast-active .mat-form-field-hide-placeholder .mat-input-element::-moz-placeholder{opacity:0}.mat-form-field-hide-placeholder .mat-input-element::-webkit-input-placeholder{color:transparent !important;-webkit-text-fill-color:transparent;transition:none}.cdk-high-contrast-active .mat-form-field-hide-placeholder .mat-input-element::-webkit-input-placeholder{opacity:0}.mat-form-field-hide-placeholder .mat-input-element:-ms-input-placeholder{color:transparent !important;-webkit-text-fill-color:transparent;transition:none}.cdk-high-contrast-active .mat-form-field-hide-placeholder .mat-input-element:-ms-input-placeholder{opacity:0}textarea.mat-input-element{resize:vertical;overflow:auto}textarea.mat-input-element.cdk-textarea-autosize{resize:none}textarea.mat-input-element{padding:2px 0;margin:-2px 0}select.mat-input-element{-moz-appearance:none;-webkit-appearance:none;position:relative;background-color:transparent;display:inline-flex;box-sizing:border-box;padding-top:1em;top:-1em;margin-bottom:-1em}select.mat-input-element::-ms-expand{display:none}select.mat-input-element::-moz-focus-inner{border:0}select.mat-input-element:not(:disabled){cursor:pointer}select.mat-input-element::-ms-value{color:inherit;background:none}.mat-focused .cdk-high-contrast-active select.mat-input-element::-ms-value{color:inherit}.mat-form-field-type-mat-native-select .mat-form-field-infix::after{content:\"\";width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid;position:absolute;top:50%;right:0;margin-top:-2.5px;pointer-events:none}[dir=rtl] .mat-form-field-type-mat-native-select .mat-form-field-infix::after{right:auto;left:0}.mat-form-field-type-mat-native-select .mat-input-element{padding-right:15px}[dir=rtl] .mat-form-field-type-mat-native-select .mat-input-element{padding-right:0;padding-left:15px}.mat-form-field-type-mat-native-select .mat-form-field-label-wrapper{max-width:calc(100% - 10px)}.mat-form-field-type-mat-native-select.mat-form-field-appearance-outline .mat-form-field-infix::after{margin-top:-5px}.mat-form-field-type-mat-native-select.mat-form-field-appearance-fill .mat-form-field-infix::after{margin-top:-10px}\n", ".mat-form-field-appearance-legacy .mat-form-field-label{transform:perspective(100px);-ms-transform:none}.mat-form-field-appearance-legacy .mat-form-field-prefix .mat-icon,.mat-form-field-appearance-legacy .mat-form-field-suffix .mat-icon{width:1em}.mat-form-field-appearance-legacy .mat-form-field-prefix .mat-icon-button,.mat-form-field-appearance-legacy .mat-form-field-suffix .mat-icon-button{font:inherit;vertical-align:baseline}.mat-form-field-appearance-legacy .mat-form-field-prefix .mat-icon-button .mat-icon,.mat-form-field-appearance-legacy .mat-form-field-suffix .mat-icon-button .mat-icon{font-size:inherit}.mat-form-field-appearance-legacy .mat-form-field-underline{height:1px}.cdk-high-contrast-active .mat-form-field-appearance-legacy .mat-form-field-underline{height:0;border-top:solid 1px}.mat-form-field-appearance-legacy .mat-form-field-ripple{top:0;height:2px;overflow:hidden}.cdk-high-contrast-active .mat-form-field-appearance-legacy .mat-form-field-ripple{height:0;border-top:solid 2px}.mat-form-field-appearance-legacy.mat-form-field-disabled .mat-form-field-underline{background-position:0;background-color:transparent}.cdk-high-contrast-active .mat-form-field-appearance-legacy.mat-form-field-disabled .mat-form-field-underline{border-top-style:dotted;border-top-width:2px}.mat-form-field-appearance-legacy.mat-form-field-invalid:not(.mat-focused) .mat-form-field-ripple{height:1px}\n", ".mat-form-field-appearance-outline .mat-form-field-wrapper{margin:.25em 0}.mat-form-field-appearance-outline .mat-form-field-flex{padding:0 .75em 0 .75em;margin-top:-0.25em;position:relative}.mat-form-field-appearance-outline .mat-form-field-prefix,.mat-form-field-appearance-outline .mat-form-field-suffix{top:.25em}.mat-form-field-appearance-outline .mat-form-field-outline{display:flex;position:absolute;top:.25em;left:0;right:0;bottom:0;pointer-events:none}.mat-form-field-appearance-outline .mat-form-field-outline-start,.mat-form-field-appearance-outline .mat-form-field-outline-end{border:1px solid currentColor;min-width:5px}.mat-form-field-appearance-outline .mat-form-field-outline-start{border-radius:5px 0 0 5px;border-right-style:none}[dir=rtl] .mat-form-field-appearance-outline .mat-form-field-outline-start{border-right-style:solid;border-left-style:none;border-radius:0 5px 5px 0}.mat-form-field-appearance-outline .mat-form-field-outline-end{border-radius:0 5px 5px 0;border-left-style:none;flex-grow:1}[dir=rtl] .mat-form-field-appearance-outline .mat-form-field-outline-end{border-left-style:solid;border-right-style:none;border-radius:5px 0 0 5px}.mat-form-field-appearance-outline .mat-form-field-outline-gap{border-radius:.000001px;border:1px solid currentColor;border-left-style:none;border-right-style:none}.mat-form-field-appearance-outline.mat-form-field-can-float.mat-form-field-should-float .mat-form-field-outline-gap{border-top-color:transparent}.mat-form-field-appearance-outline .mat-form-field-outline-thick{opacity:0}.mat-form-field-appearance-outline .mat-form-field-outline-thick .mat-form-field-outline-start,.mat-form-field-appearance-outline .mat-form-field-outline-thick .mat-form-field-outline-end,.mat-form-field-appearance-outline .mat-form-field-outline-thick .mat-form-field-outline-gap{border-width:2px}.mat-form-field-appearance-outline.mat-focused .mat-form-field-outline,.mat-form-field-appearance-outline.mat-form-field-invalid .mat-form-field-outline{opacity:0;transition:opacity 100ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-form-field-appearance-outline.mat-focused .mat-form-field-outline-thick,.mat-form-field-appearance-outline.mat-form-field-invalid .mat-form-field-outline-thick{opacity:1}.cdk-high-contrast-active .mat-form-field-appearance-outline.mat-focused .mat-form-field-outline-thick{border:3px dashed}.mat-form-field-appearance-outline:not(.mat-form-field-disabled) .mat-form-field-flex:hover .mat-form-field-outline{opacity:0;transition:opacity 600ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-form-field-appearance-outline:not(.mat-form-field-disabled) .mat-form-field-flex:hover .mat-form-field-outline-thick{opacity:1}.mat-form-field-appearance-outline .mat-form-field-subscript-wrapper{padding:0 1em}.mat-form-field-appearance-outline._mat-animation-noopable:not(.mat-form-field-disabled) .mat-form-field-flex:hover~.mat-form-field-outline,.mat-form-field-appearance-outline._mat-animation-noopable .mat-form-field-outline,.mat-form-field-appearance-outline._mat-animation-noopable .mat-form-field-outline-start,.mat-form-field-appearance-outline._mat-animation-noopable .mat-form-field-outline-end,.mat-form-field-appearance-outline._mat-animation-noopable .mat-form-field-outline-gap{transition:none}\n", ".mat-form-field-appearance-standard .mat-form-field-flex{padding-top:.75em}.mat-form-field-appearance-standard .mat-form-field-underline{height:1px}.cdk-high-contrast-active .mat-form-field-appearance-standard .mat-form-field-underline{height:0;border-top:solid 1px}.mat-form-field-appearance-standard .mat-form-field-ripple{bottom:0;height:2px}.cdk-high-contrast-active .mat-form-field-appearance-standard .mat-form-field-ripple{height:0;border-top:solid 2px}.mat-form-field-appearance-standard.mat-form-field-disabled .mat-form-field-underline{background-position:0;background-color:transparent}.cdk-high-contrast-active .mat-form-field-appearance-standard.mat-form-field-disabled .mat-form-field-underline{border-top-style:dotted;border-top-width:2px}.mat-form-field-appearance-standard:not(.mat-form-field-disabled) .mat-form-field-flex:hover~.mat-form-field-underline .mat-form-field-ripple{opacity:1;transform:none;transition:opacity 600ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-form-field-appearance-standard._mat-animation-noopable:not(.mat-form-field-disabled) .mat-form-field-flex:hover~.mat-form-field-underline .mat-form-field-ripple{transition:none}\n"]
|
---|
682 | },] }
|
---|
683 | ];
|
---|
684 | MatFormField.ctorParameters = () => [
|
---|
685 | { type: ElementRef },
|
---|
686 | { type: ChangeDetectorRef },
|
---|
687 | { type: undefined, decorators: [{ type: Inject, args: [ElementRef,] }] },
|
---|
688 | { type: Directionality, decorators: [{ type: Optional }] },
|
---|
689 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }] },
|
---|
690 | { type: Platform },
|
---|
691 | { type: NgZone },
|
---|
692 | { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
|
---|
693 | ];
|
---|
694 | MatFormField.propDecorators = {
|
---|
695 | appearance: [{ type: Input }],
|
---|
696 | hideRequiredMarker: [{ type: Input }],
|
---|
697 | hintLabel: [{ type: Input }],
|
---|
698 | floatLabel: [{ type: Input }],
|
---|
699 | underlineRef: [{ type: ViewChild, args: ['underline',] }],
|
---|
700 | _connectionContainerRef: [{ type: ViewChild, args: ['connectionContainer', { static: true },] }],
|
---|
701 | _inputContainerRef: [{ type: ViewChild, args: ['inputContainer',] }],
|
---|
702 | _label: [{ type: ViewChild, args: ['label',] }],
|
---|
703 | _controlNonStatic: [{ type: ContentChild, args: [MatFormFieldControl,] }],
|
---|
704 | _controlStatic: [{ type: ContentChild, args: [MatFormFieldControl, { static: true },] }],
|
---|
705 | _labelChildNonStatic: [{ type: ContentChild, args: [MatLabel,] }],
|
---|
706 | _labelChildStatic: [{ type: ContentChild, args: [MatLabel, { static: true },] }],
|
---|
707 | _placeholderChild: [{ type: ContentChild, args: [MatPlaceholder,] }],
|
---|
708 | _errorChildren: [{ type: ContentChildren, args: [MAT_ERROR, { descendants: true },] }],
|
---|
709 | _hintChildren: [{ type: ContentChildren, args: [_MAT_HINT, { descendants: true },] }],
|
---|
710 | _prefixChildren: [{ type: ContentChildren, args: [MAT_PREFIX, { descendants: true },] }],
|
---|
711 | _suffixChildren: [{ type: ContentChildren, args: [MAT_SUFFIX, { descendants: true },] }]
|
---|
712 | };
|
---|
713 |
|
---|
714 | /**
|
---|
715 | * @license
|
---|
716 | * Copyright Google LLC All Rights Reserved.
|
---|
717 | *
|
---|
718 | * Use of this source code is governed by an MIT-style license that can be
|
---|
719 | * found in the LICENSE file at https://angular.io/license
|
---|
720 | */
|
---|
721 | class MatFormFieldModule {
|
---|
722 | }
|
---|
723 | MatFormFieldModule.decorators = [
|
---|
724 | { type: NgModule, args: [{
|
---|
725 | declarations: [
|
---|
726 | MatError,
|
---|
727 | MatFormField,
|
---|
728 | MatHint,
|
---|
729 | MatLabel,
|
---|
730 | MatPlaceholder,
|
---|
731 | MatPrefix,
|
---|
732 | MatSuffix,
|
---|
733 | ],
|
---|
734 | imports: [
|
---|
735 | CommonModule,
|
---|
736 | MatCommonModule,
|
---|
737 | ObserversModule,
|
---|
738 | ],
|
---|
739 | exports: [
|
---|
740 | MatCommonModule,
|
---|
741 | MatError,
|
---|
742 | MatFormField,
|
---|
743 | MatHint,
|
---|
744 | MatLabel,
|
---|
745 | MatPlaceholder,
|
---|
746 | MatPrefix,
|
---|
747 | MatSuffix,
|
---|
748 | ],
|
---|
749 | },] }
|
---|
750 | ];
|
---|
751 |
|
---|
752 | /**
|
---|
753 | * @license
|
---|
754 | * Copyright Google LLC All Rights Reserved.
|
---|
755 | *
|
---|
756 | * Use of this source code is governed by an MIT-style license that can be
|
---|
757 | * found in the LICENSE file at https://angular.io/license
|
---|
758 | */
|
---|
759 |
|
---|
760 | /**
|
---|
761 | * Generated bundle index. Do not edit.
|
---|
762 | */
|
---|
763 |
|
---|
764 | export { MAT_ERROR, MAT_FORM_FIELD, MAT_FORM_FIELD_DEFAULT_OPTIONS, MAT_PREFIX, MAT_SUFFIX, MatError, MatFormField, MatFormFieldControl, MatFormFieldModule, MatHint, MatLabel, MatPlaceholder, MatPrefix, MatSuffix, _MAT_HINT, getMatFormFieldDuplicatedHintError, getMatFormFieldMissingControlError, getMatFormFieldPlaceholderConflictError, matFormFieldAnimations };
|
---|
765 | //# sourceMappingURL=form-field.js.map
|
---|