form-field.js 47 KB

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