@angular/material
Version:
Angular Material
10 lines (9 loc) • 17.7 kB
JavaScript
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/cdk/platform"),require("@angular/cdk/coercion"),require("@angular/material/core"),require("rxjs/observable/fromEvent"),require("rxjs/operators/startWith"),require("rxjs/operators/take"),require("@angular/animations")):"function"==typeof define&&define.amd?define(["exports","@angular/common","@angular/core","@angular/cdk/platform","@angular/cdk/coercion","@angular/material/core","rxjs/observable/fromEvent","rxjs/operators/startWith","rxjs/operators/take","@angular/animations"],t):t((e.ng=e.ng||{},e.ng.material=e.ng.material||{},e.ng.material.formField=e.ng.material.formField||{}),e.ng.common,e.ng.core,e.ng.cdk.platform,e.ng.cdk.coercion,e.ng.material.core,e.Rx.Observable,e.Rx.operators,e.Rx.operators,e.ng.animations)}(this,function(e,t,r,i,n,o,a,l,s,c){"use strict";function d(e,t){function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function f(){return Error("Placeholder attribute and child element were both specified.")}function m(e){return Error("A hint was already declared for 'align=\""+e+"\"'.")}function p(){return Error("mat-form-field must contain a MatFormFieldControl.")}var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},u=0,b=function(){function e(){this.id="mat-error-"+u++}return e.decorators=[{type:r.Directive,args:[{selector:"mat-error",host:{class:"mat-error",role:"alert","[attr.id]":"id"}}]}],e.ctorParameters=function(){return[]},e.propDecorators={id:[{type:r.Input}]},e}(),g={transitionMessages:c.trigger("transitionMessages",[c.state("enter",c.style({opacity:1,transform:"translateY(0%)"})),c.transition("void => enter",[c.style({opacity:0,transform:"translateY(-100%)"}),c.animate("300ms cubic-bezier(0.55, 0, 0.55, 0.2)")])])},_=function(){function e(){}return e}(),y=0,w=function(){function e(){this.align="start",this.id="mat-hint-"+y++}return e.decorators=[{type:r.Directive,args:[{selector:"mat-hint",host:{class:"mat-hint","[class.mat-right]":'align == "end"',"[attr.id]":"id","[attr.align]":"null"}}]}],e.ctorParameters=function(){return[]},e.propDecorators={align:[{type:r.Input}],id:[{type:r.Input}]},e}(),v=function(){function e(){}return e.decorators=[{type:r.Directive,args:[{selector:"mat-label"}]}],e.ctorParameters=function(){return[]},e}(),C=function(){function e(){}return e.decorators=[{type:r.Directive,args:[{selector:"mat-placeholder"}]}],e.ctorParameters=function(){return[]},e}(),x=function(){function e(){}return e.decorators=[{type:r.Directive,args:[{selector:"[matPrefix]"}]}],e.ctorParameters=function(){return[]},e}(),F=function(){function e(){}return e.decorators=[{type:r.Directive,args:[{selector:"[matSuffix]"}]}],e.ctorParameters=function(){return[]},e}(),k=function(){function e(e){this._elementRef=e}return e}(),L=o.mixinColor(k,"primary"),P=0,M=function(e){function t(t,r,i){var n=e.call(this,t)||this;return n._elementRef=t,n._changeDetectorRef=r,n._showAlwaysAnimate=!1,n._subscriptAnimationState="",n._hintLabel="",n._hintLabelId="mat-hint-"+P++,n._labelOptions=i||{},n.floatLabel=n._labelOptions.float||"auto",n}return d(t,e),Object.defineProperty(t.prototype,"dividerColor",{get:function(){return this.color},set:function(e){this.color=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hideRequiredMarker",{get:function(){return this._hideRequiredMarker},set:function(e){this._hideRequiredMarker=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_shouldAlwaysFloat",{get:function(){return"always"===this._floatLabel&&!this._showAlwaysAnimate},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_canLabelFloat",{get:function(){return"never"!==this._floatLabel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hintLabel",{get:function(){return this._hintLabel},set:function(e){this._hintLabel=e,this._processHints()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"floatPlaceholder",{get:function(){return this._floatLabel},set:function(e){this.floatLabel=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"floatLabel",{get:function(){return this._floatLabel},set:function(e){e!==this._floatLabel&&(this._floatLabel=e||this._labelOptions.float||"auto",this._changeDetectorRef.markForCheck())},enumerable:!0,configurable:!0}),t.prototype.ngAfterContentInit=function(){var e=this;this._validateControlChild(),this._control.controlType&&this._elementRef.nativeElement.classList.add("mat-form-field-type-"+this._control.controlType),this._control.stateChanges.pipe(l.startWith(null)).subscribe(function(){e._validatePlaceholders(),e._syncDescribedByIds(),e._changeDetectorRef.markForCheck()});var t=this._control.ngControl;t&&t.valueChanges&&t.valueChanges.subscribe(function(){e._changeDetectorRef.markForCheck()}),this._hintChildren.changes.pipe(l.startWith(null)).subscribe(function(){e._processHints(),e._changeDetectorRef.markForCheck()}),this._errorChildren.changes.pipe(l.startWith(null)).subscribe(function(){e._syncDescribedByIds(),e._changeDetectorRef.markForCheck()})},t.prototype.ngAfterContentChecked=function(){this._validateControlChild()},t.prototype.ngAfterViewInit=function(){this._subscriptAnimationState="enter",this._changeDetectorRef.detectChanges()},t.prototype._shouldForward=function(e){var t=this._control?this._control.ngControl:null;return t&&t[e]},t.prototype._hasPlaceholder=function(){return!(!this._control.placeholder&&!this._placeholderChild)},t.prototype._hasLabel=function(){return!!this._labelChild},t.prototype._shouldLabelFloat=function(){return this._canLabelFloat&&(this._control.shouldLabelFloat||this._control.shouldPlaceholderFloat||this._shouldAlwaysFloat)},t.prototype._hideControlPlaceholder=function(){return!this._hasLabel()||!this._shouldLabelFloat()},t.prototype._hasFloatingLabel=function(){return this._hasLabel()||this._hasPlaceholder()},t.prototype._getDisplayedMessages=function(){return this._errorChildren&&this._errorChildren.length>0&&this._control.errorState?"error":"hint"},t.prototype._animateAndLockLabel=function(){var e=this;this._hasFloatingLabel()&&this._canLabelFloat&&(this._showAlwaysAnimate=!0,this._floatLabel="always",a.fromEvent(this._label.nativeElement,"transitionend").pipe(s.take(1)).subscribe(function(){e._showAlwaysAnimate=!1}),this._changeDetectorRef.markForCheck())},t.prototype._validatePlaceholders=function(){if(this._control.placeholder&&this._placeholderChild)throw f()},t.prototype._processHints=function(){this._validateHints(),this._syncDescribedByIds()},t.prototype._validateHints=function(){var e=this;if(this._hintChildren){var t,r;this._hintChildren.forEach(function(i){if("start"===i.align){if(t||e.hintLabel)throw m("start");t=i}else if("end"===i.align){if(r)throw m("end");r=i}})}},t.prototype._syncDescribedByIds=function(){if(this._control){var e=[];if("hint"===this._getDisplayedMessages()){var t=this._hintChildren?this._hintChildren.find(function(e){return"start"===e.align}):null,r=this._hintChildren?this._hintChildren.find(function(e){return"end"===e.align}):null;t?e.push(t.id):this._hintLabel&&e.push(this._hintLabelId),r&&e.push(r.id)}else this._errorChildren&&(e=this._errorChildren.map(function(e){return e.id}));this._control.setDescribedByIds(e)}},t.prototype._validateControlChild=function(){if(!this._control)throw p()},t.decorators=[{type:r.Component,args:[{selector:"mat-input-container, mat-form-field",exportAs:"matFormField",template:'<div class="mat-input-wrapper mat-form-field-wrapper"><div class="mat-input-flex mat-form-field-flex" #connectionContainer (click)="_control.onContainerClick && _control.onContainerClick($event)"><div class="mat-input-prefix mat-form-field-prefix" *ngIf="_prefixChildren.length"><ng-content select="[matPrefix]"></ng-content></div><div class="mat-input-infix mat-form-field-infix" #inputContainer><ng-content></ng-content><span class="mat-form-field-label-wrapper mat-input-placeholder-wrapper mat-form-field-placeholder-wrapper"><label class="mat-form-field-label mat-input-placeholder mat-form-field-placeholder" [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>{{_control.placeholder}}</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"> *</span></label></span></div><div class="mat-input-suffix mat-form-field-suffix" *ngIf="_suffixChildren.length"><ng-content select="[matSuffix]"></ng-content></div></div><div class="mat-input-underline mat-form-field-underline" #underline><span class="mat-input-ripple mat-form-field-ripple" [class.mat-accent]="color == \'accent\'" [class.mat-warn]="color == \'warn\'"></span></div><div class="mat-input-subscript-wrapper mat-form-field-subscript-wrapper" [ngSwitch]="_getDisplayedMessages()"><div *ngSwitchCase="\'error\'" [@transitionMessages]="_subscriptAnimationState"><ng-content select="mat-error"></ng-content></div><div class="mat-input-hint-wrapper 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-input-hint-spacer mat-form-field-hint-spacer"></div><ng-content select="mat-hint[align=\'end\']"></ng-content></div></div></div>',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;width:100%}.mat-form-field-prefix,.mat-form-field-suffix{white-space:nowrap;flex:none}.mat-form-field-prefix .mat-icon,.mat-form-field-suffix .mat-icon{width:1em}.mat-form-field-prefix .mat-icon-button,.mat-form-field-suffix .mat-icon-button{font:inherit;vertical-align:baseline}.mat-form-field-prefix .mat-icon-button .mat-icon,.mat-form-field-suffix .mat-icon-button .mat-icon{font-size:inherit}.mat-form-field-infix{display:block;position:relative;flex:auto;min-width:0;width:180px}.mat-form-field-label-wrapper{position:absolute;left:0;box-sizing:content-box;width:100%;height:100%;overflow:hidden;pointer-events:none}.mat-form-field-label{position:absolute;left:0;font:inherit;pointer-events:none;width:100%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;transform:perspective(100px);-ms-transform:none;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-placeholder-wrapper .mat-form-field-placeholder,.mat-input-server[placeholder]:not(:placeholder-shown)+.mat-form-field-placeholder-wrapper .mat-form-field-placeholder{display:none}.mat-form-field-can-float .mat-input-server:focus+.mat-form-field-placeholder-wrapper .mat-form-field-placeholder,.mat-form-field-can-float .mat-input-server[placeholder]:not(:placeholder-shown)+.mat-form-field-placeholder-wrapper .mat-form-field-placeholder{display:block}.mat-form-field-label:not(.mat-form-field-empty){transition:none}.mat-form-field-underline{position:absolute;height:1px;width:100%}.mat-form-field-disabled .mat-form-field-underline{background-position:0;background-color:transparent}.mat-form-field-underline .mat-form-field-ripple{position:absolute;top:0;left:0;width:100%;height:2px;transform-origin:50%;transform:scaleX(.5);visibility:hidden;opacity:0;transition:background-color .3s cubic-bezier(.55,0,.55,.2)}.mat-form-field-invalid:not(.mat-focused) .mat-form-field-underline .mat-form-field-ripple{height:1px}.mat-focused .mat-form-field-underline .mat-form-field-ripple,.mat-form-field-invalid .mat-form-field-underline .mat-form-field-ripple{visibility:visible;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;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-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[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::placeholder{transition:color .4s .133s cubic-bezier(.25,.8,.25,1)}.mat-input-element::-moz-placeholder{transition:color .4s .133s cubic-bezier(.25,.8,.25,1)}.mat-input-element::-webkit-input-placeholder{transition:color .4s .133s cubic-bezier(.25,.8,.25,1)}.mat-input-element:-ms-input-placeholder{transition:color .4s .133s cubic-bezier(.25,.8,.25,1)}.mat-form-field-hide-placeholder .mat-input-element::placeholder{color:transparent!important;transition:none}.mat-form-field-hide-placeholder .mat-input-element::-moz-placeholder{color:transparent!important;transition:none}.mat-form-field-hide-placeholder .mat-input-element::-webkit-input-placeholder{color:transparent!important;transition:none}.mat-form-field-hide-placeholder .mat-input-element:-ms-input-placeholder{color:transparent!important;transition:none}textarea.mat-input-element{resize:vertical;overflow:auto}textarea.mat-autosize{resize:none}"],animations:[g.transitionMessages],host:{class:"mat-input-container mat-form-field","[class.mat-input-invalid]":"_control.errorState","[class.mat-form-field-invalid]":"_control.errorState","[class.mat-form-field-can-float]":"_canLabelFloat","[class.mat-form-field-should-float]":"_shouldLabelFloat()","[class.mat-form-field-hide-placeholder]":"_hideControlPlaceholder()","[class.mat-form-field-disabled]":"_control.disabled","[class.mat-focused]":"_control.focused","[class.ng-untouched]":'_shouldForward("untouched")',"[class.ng-touched]":'_shouldForward("touched")',"[class.ng-pristine]":'_shouldForward("pristine")',"[class.ng-dirty]":'_shouldForward("dirty")',"[class.ng-valid]":'_shouldForward("valid")',"[class.ng-invalid]":'_shouldForward("invalid")',"[class.ng-pending]":'_shouldForward("pending")'},inputs:["color"],encapsulation:r.ViewEncapsulation.None,preserveWhitespaces:!1,changeDetection:r.ChangeDetectionStrategy.OnPush}]}],t.ctorParameters=function(){return[{type:r.ElementRef},{type:r.ChangeDetectorRef},{type:void 0,decorators:[{type:r.Optional},{type:r.Inject,args:[o.MAT_LABEL_GLOBAL_OPTIONS]}]}]},t.propDecorators={dividerColor:[{type:r.Input}],hideRequiredMarker:[{type:r.Input}],hintLabel:[{type:r.Input}],floatPlaceholder:[{type:r.Input}],floatLabel:[{type:r.Input}],underlineRef:[{type:r.ViewChild,args:["underline"]}],_connectionContainerRef:[{type:r.ViewChild,args:["connectionContainer"]}],_inputContainerRef:[{type:r.ViewChild,args:["inputContainer"]}],_label:[{type:r.ViewChild,args:["label"]}],_control:[{type:r.ContentChild,args:[_]}],_placeholderChild:[{type:r.ContentChild,args:[C]}],_labelChild:[{type:r.ContentChild,args:[v]}],_errorChildren:[{type:r.ContentChildren,args:[b]}],_hintChildren:[{type:r.ContentChildren,args:[w]}],_prefixChildren:[{type:r.ContentChildren,args:[x]}],_suffixChildren:[{type:r.ContentChildren,args:[F]}]},t}(L),D=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{declarations:[b,w,M,C,x,F,v],imports:[t.CommonModule,i.PlatformModule],exports:[b,w,M,C,x,F,v]}]}],e.ctorParameters=function(){return[]},e}();e.MatFormFieldModule=D,e.MatError=b,e.MatFormFieldBase=k,e._MatFormFieldMixinBase=L,e.MatFormField=M,e.MatFormFieldControl=_,e.getMatFormFieldPlaceholderConflictError=f,e.getMatFormFieldDuplicatedHintError=m,e.getMatFormFieldMissingControlError=p,e.MatHint=w,e.MatPlaceholder=C,e.MatPrefix=x,e.MatSuffix=F,e.MatLabel=v,e.matFormFieldAnimations=g,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=material-form-field.umd.min.js.map