UNPKG

@angular/material

Version:
10 lines (9 loc) 9.78 kB
/** * @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/cdk/platform"),require("@angular/common"),require("@angular/core"),require("@angular/material/form-field"),require("rxjs/observable/fromEvent"),require("rxjs/operators/auditTime"),require("rxjs/operators/takeUntil"),require("rxjs/Subject"),require("@angular/cdk/coercion"),require("@angular/forms"),require("@angular/material/core")):"function"==typeof define&&define.amd?define(["exports","@angular/cdk/platform","@angular/common","@angular/core","@angular/material/form-field","rxjs/observable/fromEvent","rxjs/operators/auditTime","rxjs/operators/takeUntil","rxjs/Subject","@angular/cdk/coercion","@angular/forms","@angular/material/core"],t):t((e.ng=e.ng||{},e.ng.material=e.ng.material||{},e.ng.material.input=e.ng.material.input||{}),e.ng.cdk.platform,e.ng.common,e.ng.core,e.ng.material.formField,e.Rx.Observable,e.Rx.operators,e.Rx.operators,e.Rx,e.ng.cdk.coercion,e.ng.forms,e.ng.material.core)}(this,function(e,t,r,n,o,i,a,s,u,p,l,c){"use strict";function d(e,t){function r(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function h(e){return Error('Input type "'+e+"\" isn't supported by matInput.")}var f=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])},y=function(){function e(e,t,r){this._elementRef=e,this._platform=t,this._ngZone=r,this._destroyed=new u.Subject}return Object.defineProperty(e.prototype,"minRows",{get:function(){return this._minRows},set:function(e){this._minRows=e,this._setMinHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxRows",{get:function(){return this._maxRows},set:function(e){this._maxRows=e,this._setMaxHeight()},enumerable:!0,configurable:!0}),e.prototype._setMinHeight=function(){var e=this.minRows&&this._cachedLineHeight?this.minRows*this._cachedLineHeight+"px":null;e&&this._setTextareaStyle("minHeight",e)},e.prototype._setMaxHeight=function(){var e=this.maxRows&&this._cachedLineHeight?this.maxRows*this._cachedLineHeight+"px":null;e&&this._setTextareaStyle("maxHeight",e)},e.prototype.ngAfterViewInit=function(){var e=this;this._platform.isBrowser&&(this.resizeToFitContent(),this._ngZone&&this._ngZone.runOutsideAngular(function(){i.fromEvent(window,"resize").pipe(a.auditTime(16),s.takeUntil(e._destroyed)).subscribe(function(){return e.resizeToFitContent(!0)})}))},e.prototype.ngOnDestroy=function(){this._destroyed.next(),this._destroyed.complete()},e.prototype._setTextareaStyle=function(e,t){this._elementRef.nativeElement.style[e]=t},e.prototype._cacheTextareaLineHeight=function(){if(!this._cachedLineHeight){var e=this._elementRef.nativeElement,t=e.cloneNode(!1);t.rows=1,t.style.position="absolute",t.style.visibility="hidden",t.style.border="none",t.style.padding="0",t.style.height="",t.style.minHeight="",t.style.maxHeight="",t.style.overflow="hidden",e.parentNode.appendChild(t),this._cachedLineHeight=t.clientHeight,e.parentNode.removeChild(t),this._setMinHeight(),this._setMaxHeight()}},e.prototype.ngDoCheck=function(){this._platform.isBrowser&&this.resizeToFitContent()},e.prototype.resizeToFitContent=function(e){if(void 0===e&&(e=!1),this._cacheTextareaLineHeight(),this._cachedLineHeight){var t=this._elementRef.nativeElement,r=t.value;if(r!==this._previousValue||e){var n=t.placeholder;t.style.height="auto",t.style.overflow="hidden",t.placeholder="",t.style.height=t.scrollHeight+"px",t.style.overflow="",t.placeholder=n,this._previousValue=r}}},e.decorators=[{type:n.Directive,args:[{selector:"textarea[mat-autosize], textarea[matTextareaAutosize]",exportAs:"matTextareaAutosize",host:{class:"mat-autosize",rows:"1"}}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:t.Platform},{type:n.NgZone}]},e.propDecorators={minRows:[{type:n.Input,args:["matAutosizeMinRows"]}],maxRows:[{type:n.Input,args:["matAutosizeMaxRows"]}]},e}(),m=new n.InjectionToken("MAT_INPUT_VALUE_ACCESSOR"),g=["button","checkbox","file","hidden","image","radio","range","reset","submit"],_=0,v=function(){function e(e,t,r,n){this._defaultErrorStateMatcher=e,this._parentForm=t,this._parentFormGroup=r,this.ngControl=n}return e}(),b=c.mixinErrorState(v),x=function(e){function r(r,n,o,i,a,s,p){var l=e.call(this,s,i,a,o)||this;return l._elementRef=r,l._platform=n,l.ngControl=o,l._uid="mat-input-"+_++,l._isServer=!1,l.focused=!1,l.stateChanges=new u.Subject,l.controlType="mat-input",l._disabled=!1,l.placeholder="",l._required=!1,l._type="text",l._readonly=!1,l._neverEmptyInputTypes=["date","datetime","datetime-local","month","time","week"].filter(function(e){return t.getSupportedInputTypes().has(e)}),l._inputValueAccessor=p||l._elementRef.nativeElement,l._previousNativeValue=l.value,l.id=l.id,n.IOS&&r.nativeElement.addEventListener("keyup",function(e){var t=e.target;t.value||t.selectionStart||t.selectionEnd||(t.setSelectionRange(1,1),t.setSelectionRange(0,0))}),l._isServer=!l._platform.isBrowser,l}return d(r,e),Object.defineProperty(r.prototype,"disabled",{get:function(){return this.ngControl&&null!==this.ngControl.disabled?this.ngControl.disabled:this._disabled},set:function(e){this._disabled=p.coerceBooleanProperty(e),this.focused&&(this.focused=!1,this.stateChanges.next())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"id",{get:function(){return this._id},set:function(e){this._id=e||this._uid},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"required",{get:function(){return this._required},set:function(e){this._required=p.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e||"text",this._validateType(),!this._isTextarea()&&t.getSupportedInputTypes().has(this._type)&&(this._elementRef.nativeElement.type=this._type)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this._inputValueAccessor.value},set:function(e){e!==this.value&&(this._inputValueAccessor.value=e,this.stateChanges.next())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"readonly",{get:function(){return this._readonly},set:function(e){this._readonly=p.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),r.prototype.ngOnChanges=function(){this.stateChanges.next()},r.prototype.ngOnDestroy=function(){this.stateChanges.complete()},r.prototype.ngDoCheck=function(){this.ngControl&&this.updateErrorState(),this._dirtyCheckNativeValue()},r.prototype.focus=function(){this._elementRef.nativeElement.focus()},r.prototype._focusChanged=function(e){e===this.focused||this.readonly||(this.focused=e,this.stateChanges.next())},r.prototype._onInput=function(){},r.prototype._dirtyCheckNativeValue=function(){var e=this.value;this._previousNativeValue!==e&&(this._previousNativeValue=e,this.stateChanges.next())},r.prototype._validateType=function(){if(g.indexOf(this._type)>-1)throw h(this._type)},r.prototype._isNeverEmpty=function(){return this._neverEmptyInputTypes.indexOf(this._type)>-1},r.prototype._isBadInput=function(){var e=this._elementRef.nativeElement.validity;return e&&e.badInput},r.prototype._isTextarea=function(){var e=this._elementRef.nativeElement,t=this._platform.isBrowser?e.nodeName:e.name;return!!t&&"textarea"===t.toLowerCase()},Object.defineProperty(r.prototype,"empty",{get:function(){return!this._isNeverEmpty()&&!this._elementRef.nativeElement.value&&!this._isBadInput()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shouldLabelFloat",{get:function(){return this.focused||!this.empty},enumerable:!0,configurable:!0}),r.prototype.setDescribedByIds=function(e){this._ariaDescribedby=e.join(" ")},r.prototype.onContainerClick=function(){this.focus()},r.decorators=[{type:n.Directive,args:[{selector:"input[matInput], textarea[matInput]",exportAs:"matInput",host:{class:"mat-input-element mat-form-field-autofill-control","[class.mat-input-server]":"_isServer","[attr.id]":"id","[placeholder]":"placeholder","[disabled]":"disabled","[required]":"required","[readonly]":"readonly","[attr.aria-describedby]":"_ariaDescribedby || null","[attr.aria-invalid]":"errorState","[attr.aria-required]":"required.toString()","(blur)":"_focusChanged(false)","(focus)":"_focusChanged(true)","(input)":"_onInput()"},providers:[{provide:o.MatFormFieldControl,useExisting:r}]}]}],r.ctorParameters=function(){return[{type:n.ElementRef},{type:t.Platform},{type:l.NgControl,decorators:[{type:n.Optional},{type:n.Self}]},{type:l.NgForm,decorators:[{type:n.Optional}]},{type:l.FormGroupDirective,decorators:[{type:n.Optional}]},{type:c.ErrorStateMatcher},{type:void 0,decorators:[{type:n.Optional},{type:n.Self},{type:n.Inject,args:[m]}]}]},r.propDecorators={disabled:[{type:n.Input}],id:[{type:n.Input}],placeholder:[{type:n.Input}],required:[{type:n.Input}],type:[{type:n.Input}],errorStateMatcher:[{type:n.Input}],value:[{type:n.Input}],readonly:[{type:n.Input}]},r}(b),C=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{declarations:[x,y],imports:[r.CommonModule,o.MatFormFieldModule,t.PlatformModule],exports:[o.MatFormFieldModule,x,y],providers:[c.ErrorStateMatcher]}]}],e.ctorParameters=function(){return[]},e}();e.MatInputModule=C,e.MatTextareaAutosize=y,e.MatInputBase=v,e._MatInputMixinBase=b,e.MatInput=x,e.getMatInputUnsupportedTypeError=h,e.MAT_INPUT_VALUE_ACCESSOR=m,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=material-input.umd.min.js.map