form-field.es5.js 55 KB

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