UNPKG

8.97 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("primeng/inputtext"),require("@angular/forms")):"function"==typeof define&&define.amd?define("primeng/spinner",["exports","@angular/core","@angular/common","primeng/inputtext","@angular/forms"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.spinner={}),t.ng.core,t.ng.common,t.primeng.inputtext,t.ng.forms)}(this,(function(t,e,n,i,o){"use strict";var a=this&&this.__decorate||function(t,e,n,i){var o,a=arguments.length,r=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var u=t.length-1;u>=0;u--)(o=t[u])&&(r=(a<3?o(r):a>3?o(e,n,r):o(e,n))||r);return a>3&&r&&Object.defineProperty(e,n,r),r},r={provide:o.NG_VALUE_ACCESSOR,useExisting:e.forwardRef((function(){return u})),multi:!0},u=function(){function t(t,n){this.el=t,this.cd=n,this.onChange=new e.EventEmitter,this.onFocus=new e.EventEmitter,this.onBlur=new e.EventEmitter,this._step=1,this.onModelChange=function(){},this.onModelTouched=function(){},this.keyPattern=/[0-9\+\-]/,this.negativeSeparator="-"}return Object.defineProperty(t.prototype,"step",{get:function(){return this._step},set:function(t){if(this._step=t,null!=this._step){var e=this.step.toString().split(/[,]|[.]/);this.calculatedPrecision=e[1]?e[1].length:void 0}},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){this.formatInput&&(this.localeDecimalSeparator=1.1.toLocaleString().substring(1,2),this.localeThousandSeparator=1e3.toLocaleString().substring(1,2),this.thousandRegExp=new RegExp("["+(this.thousandSeparator||this.localeThousandSeparator)+"]","gim"),this.decimalSeparator&&this.thousandSeparator&&this.decimalSeparator===this.thousandSeparator&&console.warn("thousandSeparator and decimalSeparator cannot have the same value."))},t.prototype.repeat=function(t,e,n){var i=this,o=e||500;this.clearTimer(),this.timer=setTimeout((function(){i.repeat(t,40,n)}),o),this.spin(t,n)},t.prototype.spin=function(t,e){var n,i=this.step*e,o=this.getPrecision();n=this.value?"string"==typeof this.value?this.parseValue(this.value):this.value:0,this.value=o?parseFloat(this.toFixed(n+i,o)):n+i,void 0!==this.maxlength&&this.value.toString().length>this.maxlength&&(this.value=n),void 0!==this.min&&this.value<this.min&&(this.value=this.min),void 0!==this.max&&this.value>this.max&&(this.value=this.max),this.formatValue(),this.onModelChange(this.value),this.onChange.emit(t)},t.prototype.getPrecision=function(){return void 0===this.precision?this.calculatedPrecision:this.precision},t.prototype.toFixed=function(t,e){var n=Math.pow(10,e||0);return String(Math.round(t*n)/n)},t.prototype.onUpButtonMousedown=function(t){this.disabled||(this.inputfieldViewChild.nativeElement.focus(),this.repeat(t,null,1),this.updateFilledState(),t.preventDefault())},t.prototype.onUpButtonMouseup=function(t){this.disabled||this.clearTimer()},t.prototype.onUpButtonMouseleave=function(t){this.disabled||this.clearTimer()},t.prototype.onDownButtonMousedown=function(t){this.disabled||(this.inputfieldViewChild.nativeElement.focus(),this.repeat(t,null,-1),this.updateFilledState(),t.preventDefault())},t.prototype.onDownButtonMouseup=function(t){this.disabled||this.clearTimer()},t.prototype.onDownButtonMouseleave=function(t){this.disabled||this.clearTimer()},t.prototype.onInputKeydown=function(t){38==t.which?(this.spin(t,1),t.preventDefault()):40==t.which&&(this.spin(t,-1),t.preventDefault())},t.prototype.onInputChange=function(t){this.onChange.emit(t)},t.prototype.onInput=function(t){this.value=this.parseValue(t.target.value),this.onModelChange(this.value),this.updateFilledState()},t.prototype.onInputBlur=function(t){this.focus=!1,this.formatValue(),this.onModelTouched(),this.onBlur.emit(t)},t.prototype.onInputFocus=function(t){this.focus=!0,this.onFocus.emit(t)},t.prototype.parseValue=function(t){var e,n=this.getPrecision();return""===t.trim()?e=null:(this.formatInput&&(t=t.replace(this.thousandRegExp,"")),n?(t=this.formatInput?t.replace(this.decimalSeparator||this.localeDecimalSeparator,"."):t.replace(",","."),e=parseFloat(t)):e=parseInt(t,10),isNaN(e)?e=null:(null!==this.max&&e>this.max&&(e=this.max),null!==this.min&&e<this.min&&(e=this.min))),e},t.prototype.formatValue=function(){var t=this.value,e=this.getPrecision();null!=t?(this.formatInput&&(t=t.toLocaleString(void 0,{maximumFractionDigits:20}),this.decimalSeparator&&this.thousandSeparator&&(t=t.split(this.localeDecimalSeparator),e&&t[1]&&(t[1]=(this.decimalSeparator||this.localeDecimalSeparator)+t[1]),this.thousandSeparator&&t[0].length>3&&(t[0]=t[0].replace(new RegExp("["+this.localeThousandSeparator+"]","gim"),this.thousandSeparator)),t=t.join(""))),this.formattedValue=t.toString()):this.formattedValue=null,this.inputfieldViewChild&&this.inputfieldViewChild.nativeElement&&(this.inputfieldViewChild.nativeElement.value=this.formattedValue)},t.prototype.clearTimer=function(){this.timer&&clearInterval(this.timer)},t.prototype.writeValue=function(t){this.value=t,this.formatValue(),this.updateFilledState(),this.cd.markForCheck()},t.prototype.registerOnChange=function(t){this.onModelChange=t},t.prototype.registerOnTouched=function(t){this.onModelTouched=t},t.prototype.setDisabledState=function(t){this.disabled=t},t.prototype.updateFilledState=function(){this.filled=void 0!==this.value&&null!=this.value},t.ctorParameters=function(){return[{type:e.ElementRef},{type:e.ChangeDetectorRef}]},a([e.Output()],t.prototype,"onChange",void 0),a([e.Output()],t.prototype,"onFocus",void 0),a([e.Output()],t.prototype,"onBlur",void 0),a([e.Input()],t.prototype,"min",void 0),a([e.Input()],t.prototype,"max",void 0),a([e.Input()],t.prototype,"maxlength",void 0),a([e.Input()],t.prototype,"size",void 0),a([e.Input()],t.prototype,"placeholder",void 0),a([e.Input()],t.prototype,"inputId",void 0),a([e.Input()],t.prototype,"disabled",void 0),a([e.Input()],t.prototype,"readonly",void 0),a([e.Input()],t.prototype,"tabindex",void 0),a([e.Input()],t.prototype,"required",void 0),a([e.Input()],t.prototype,"name",void 0),a([e.Input()],t.prototype,"ariaLabelledBy",void 0),a([e.Input()],t.prototype,"inputStyle",void 0),a([e.Input()],t.prototype,"inputStyleClass",void 0),a([e.Input()],t.prototype,"formatInput",void 0),a([e.Input()],t.prototype,"decimalSeparator",void 0),a([e.Input()],t.prototype,"thousandSeparator",void 0),a([e.Input()],t.prototype,"precision",void 0),a([e.ViewChild("inputfield")],t.prototype,"inputfieldViewChild",void 0),a([e.Input()],t.prototype,"step",null),t=a([e.Component({selector:"p-spinner",template:'\n <span class="ui-spinner ui-widget ui-corner-all">\n <input #inputfield type="text" [attr.id]="inputId" [value]="formattedValue||null" [attr.name]="name" [attr.aria-valumin]="min" [attr.aria-valuemax]="max" [attr.aria-valuenow]="value" [attr.aria-labelledby]="ariaLabelledBy"\n [attr.size]="size" [attr.maxlength]="maxlength" [attr.tabindex]="tabindex" [attr.placeholder]="placeholder" [disabled]="disabled" [readonly]="readonly" [attr.required]="required"\n (keydown)="onInputKeydown($event)" (blur)="onInputBlur($event)" (input)="onInput($event)" (change)="onInputChange($event)" (focus)="onInputFocus($event)"\n [ngStyle]="inputStyle" [class]="inputStyleClass" [ngClass]="\'ui-spinner-input ui-inputtext ui-widget ui-state-default ui-corner-all\'">\n <button type="button" [ngClass]="{\'ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default\':true,\'ui-state-disabled\':disabled}" [disabled]="disabled||readonly" tabindex="-1" [attr.readonly]="readonly"\n (mouseleave)="onUpButtonMouseleave($event)" (mousedown)="onUpButtonMousedown($event)" (mouseup)="onUpButtonMouseup($event)">\n <span class="ui-spinner-button-icon pi pi-caret-up ui-clickable"></span>\n </button>\n <button type="button" [ngClass]="{\'ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default\':true,\'ui-state-disabled\':disabled}" [disabled]="disabled||readonly" tabindex="-1" [attr.readonly]="readonly"\n (mouseleave)="onDownButtonMouseleave($event)" (mousedown)="onDownButtonMousedown($event)" (mouseup)="onDownButtonMouseup($event)">\n <span class="ui-spinner-button-icon pi pi-caret-down ui-clickable"></span>\n </button>\n </span>\n ',host:{"[class.ui-inputwrapper-filled]":"filled","[class.ui-inputwrapper-focus]":"focus"},providers:[r],changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),s=function(){function t(){}return t=a([e.NgModule({imports:[n.CommonModule,i.InputTextModule],exports:[u],declarations:[u]})],t)}();t.SPINNER_VALUE_ACCESSOR=r,t.Spinner=u,t.SpinnerModule=s,Object.defineProperty(t,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-spinner.umd.min.js.map
\No newline at end of file