{"version":3,"sources":["../../src/app/components/spinner/spinner.ts"],"names":["SPINNER_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","Spinner","multi","el","cd","this","onChange","EventEmitter","onFocus","onBlur","_step","onModelChange","onModelTouched","keyPattern","negativeSeparator","Object","defineProperty","prototype","val","tokens","step","toString","split","calculatedPrecision","length","undefined","ngOnInit","formatInput","localeDecimalSeparator","toLocaleString","substring","localeThousandSeparator","thousandRegExp","RegExp","thousandSeparator","decimalSeparator","console","warn","repeat","event","interval","dir","_this","i","clearTimer","timer","setTimeout","spin","currentValue","precision","getPrecision","value","parseValue","parseFloat","toFixed","maxlength","min","max","formatValue","emit","power","Math","pow","String","round","onUpButtonMousedown","disabled","inputfieldViewChild","nativeElement","focus","updateFilledState","preventDefault","onUpButtonMouseup","onUpButtonMouseleave","onDownButtonMousedown","onDownButtonMouseup","onDownButtonMouseleave","onInputKeydown","which","onInputChange","onInput","target","onInputBlur","onInputFocus","trim","replace","parseInt","isNaN","maximumFractionDigits","join","formattedValue","clearInterval","writeValue","markForCheck","registerOnChange","fn","registerOnTouched","setDisabledState","filled","Component","args","selector","template","host","[class.ui-inputwrapper-filled]","[class.ui-inputwrapper-focus]","providers","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","ChangeDetectorRef","Output","Input","ViewChild","NgModule","imports","CommonModule","InputTextModule","exports","declarations"],"mappings":"shBAKaA,EAA8B,CACvCC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBAoHP,SAAAD,EAAmBE,EAAuBC,GAAvBC,KAAAF,GAAAA,EAAuBE,KAAAD,GAAAA,EApFhCC,KAAAC,SAA8B,IAAIC,EAAAA,aAElCF,KAAAG,QAA6B,IAAID,EAAAA,aAEjCF,KAAAI,OAA4B,IAAIF,EAAAA,aAwC1CF,KAAAK,MAAgB,EAIhBL,KAAAM,cAA0B,aAE1BN,KAAAO,eA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BC,OACzCC,cAAeC,EAAAA,kBAAkBC,mxBAnCVC,EAAAA,kBAAiEC,EAAAA,uDAwCvFC,EAAAA,wBAEAA,EAAAA,uBAEAA,EAAAA,oBAEAC,EAAAA,mBAEAA,EAAAA,yBAEAA,EAAAA,oBAEAA,EAAAA,2BAEAA,EAAAA,uBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,oBAEAA,EAAAA,8BAEAA,EAAAA,0BAEAA,EAAAA,+BAEAA,EAAAA,2BAEAA,EAAAA,gCAEAA,EAAAA,iCAEAA,EAAAA,yBAEAA,EAAAA,mCA8BAC,EAAAA,UAASjB,KAAA,CAAC,4BAEVgB,EAAAA,eAqQL,iCALCE,EAAAA,SAAQlB,KAAA,CAAC,CACNmB,QAAS,CAACC,EAAAA,aAAaC,EAAAA,iBACvBC,QAAS,CAACzH,GACV0H,aAAc,CAAC1H","sourcesContent":["import {NgModule,Component,ElementRef,OnInit,Input,Output,EventEmitter,forwardRef,ViewChild,ChangeDetectorRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {InputTextModule} from 'primeng/inputtext';\nimport {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';\n\nexport const SPINNER_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => Spinner),\n multi: true\n};\n\n@Component({\n selector: 'p-spinner',\n template: `\n \n \n \n \n \n `,\n host: {\n '[class.ui-inputwrapper-filled]': 'filled',\n '[class.ui-inputwrapper-focus]': 'focus'\n },\n providers: [SPINNER_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./spinner.css']\n})\nexport class Spinner implements OnInit,ControlValueAccessor {\n \n @Output() onChange: EventEmitter = new EventEmitter();\n \n @Output() onFocus: EventEmitter = new EventEmitter();\n\n @Output() onBlur: EventEmitter = new EventEmitter();\n\n @Input() min: number;\n\n @Input() max: number;\n \n @Input() maxlength: number;\n \n @Input() size: number;\n\n @Input() placeholder: string;\n\n @Input() inputId: string;\n\n @Input() disabled: boolean;\n \n @Input() readonly: boolean;\n\n @Input() tabindex: number;\n \n @Input() required: boolean;\n\n @Input() name: string;\n\n @Input() ariaLabelledBy: string;\n\n @Input() inputStyle: any;\n\n @Input() inputStyleClass: string;\n\n @Input() formatInput: boolean;\n\n @Input() decimalSeparator: string;\n\n @Input() thousandSeparator: string;\n\n @Input() precision: number;\n \n value: any;\n\n _step: number = 1;\n\n formattedValue: string;\n \n onModelChange: Function = () => {};\n \n onModelTouched: Function = () => {};\n \n keyPattern: RegExp = /[0-9\\+\\-]/;\n \n public timer: any;\n \n public focus: boolean;\n \n public filled: boolean;\n \n public negativeSeparator = '-';\n\n localeDecimalSeparator: string;\n\n localeThousandSeparator: string;\n\n thousandRegExp: RegExp;\n\n calculatedPrecision: number;\n \n @ViewChild('inputfield') inputfieldViewChild: ElementRef;\n\n @Input() get step(): number {\n return this._step;\n }\n set step(val:number) {\n this._step = val;\n\n if (this._step != null) {\n let tokens = this.step.toString().split(/[,]|[.]/);\n this.calculatedPrecision = tokens[1] ? tokens[1].length : undefined;\n }\n }\n \n constructor(public el: ElementRef, public cd: ChangeDetectorRef) {}\n\n ngOnInit() {\n if (this.formatInput) {\n this.localeDecimalSeparator = (1.1).toLocaleString().substring(1, 2);\n this.localeThousandSeparator = (1000).toLocaleString().substring(1, 2);\n this.thousandRegExp = new RegExp(`[${this.thousandSeparator || this.localeThousandSeparator}]`, 'gim');\n\n if (this.decimalSeparator && this.thousandSeparator && this.decimalSeparator === this.thousandSeparator) {\n console.warn(\"thousandSeparator and decimalSeparator cannot have the same value.\");\n }\n }\n }\n\n repeat(event: Event, interval: number, dir: number) {\n let i = interval||500;\n\n this.clearTimer();\n this.timer = setTimeout(() => {\n this.repeat(event, 40, dir);\n }, i);\n\n this.spin(event, dir);\n }\n \n spin(event: Event, dir: number) {\n let step = this.step * dir;\n let currentValue: number;\n let precision = this.getPrecision();\n\n if (this.value)\n currentValue = (typeof this.value === 'string') ? this.parseValue(this.value) : this.value;\n else\n currentValue = 0;\n \n if (precision)\n this.value = parseFloat(this.toFixed(currentValue + step, precision));\n else\n this.value = currentValue + step;\n \n if (this.maxlength !== undefined && this.value.toString().length > this.maxlength) {\n this.value = currentValue;\n }\n \n if (this.min !== undefined && this.value < this.min) {\n this.value = this.min;\n }\n\n if (this.max !== undefined && this.value > this.max) {\n this.value = this.max;\n }\n \n this.formatValue();\n this.onModelChange(this.value);\n this.onChange.emit(event);\n }\n\n getPrecision() {\n return this.precision === undefined ? this.calculatedPrecision : this.precision;\n }\n \n toFixed(value: number, precision: number) {\n let power = Math.pow(10, precision||0);\n return String(Math.round(value * power) / power);\n }\n \n onUpButtonMousedown(event: Event) {\n if (!this.disabled) {\n this.inputfieldViewChild.nativeElement.focus();\n this.repeat(event, null, 1);\n this.updateFilledState();\n event.preventDefault();\n }\n }\n \n onUpButtonMouseup(event: Event) {\n if (!this.disabled) {\n this.clearTimer();\n }\n }\n \n onUpButtonMouseleave(event: Event) {\n if (!this.disabled) {\n this.clearTimer();\n }\n }\n \n onDownButtonMousedown(event: Event) {\n if (!this.disabled) {\n this.inputfieldViewChild.nativeElement.focus();\n this.repeat(event, null, -1);\n this.updateFilledState();\n event.preventDefault();\n }\n }\n \n onDownButtonMouseup(event: Event) {\n if (!this.disabled) {\n this.clearTimer();\n }\n }\n \n onDownButtonMouseleave(event: Event) {\n if (!this.disabled) {\n this.clearTimer();\n }\n }\n \n onInputKeydown(event: KeyboardEvent) {\n if (event.which == 38) {\n this.spin(event, 1);\n event.preventDefault();\n }\n else if (event.which == 40) {\n this.spin(event, -1);\n event.preventDefault();\n }\n }\n\n onInputChange(event: Event) {\n this.onChange.emit(event);\n }\n\n onInput(event: KeyboardEvent) {\n this.value = this.parseValue(( event.target).value);\n this.onModelChange(this.value);\n this.updateFilledState();\n }\n \n onInputBlur(event) {\n this.focus = false;\n this.formatValue();\n this.onModelTouched();\n this.onBlur.emit(event);\n }\n \n onInputFocus(event) {\n this.focus = true;\n this.onFocus.emit(event);\n }\n \n parseValue(val: string): number {\n let value: number;\n let precision = this.getPrecision();\n \n if (val.trim() === '') {\n value = null;\n }\n else {\n if (this.formatInput) {\n val = val.replace(this.thousandRegExp, '');\n }\n\n if (precision) {\n val = this.formatInput ? val.replace(this.decimalSeparator || this.localeDecimalSeparator, '.') : val.replace(',', '.');\n value = parseFloat(val);\n }\n else {\n value = parseInt(val, 10);\n }\n \n if (!isNaN(value)) {\n if (this.max !== null && value > this.max) {\n value = this.max;\n }\n\n if (this.min !== null && value < this.min) {\n value = this.min;\n }\n }\n else {\n value = null;\n }\n }\n \n return value;\n }\n\n formatValue() {\n let value = this.value;\n let precision = this.getPrecision();\n\n if (value != null) {\n if (this.formatInput) {\n value = value.toLocaleString(undefined, {maximumFractionDigits: 20});\n \n if (this.decimalSeparator && this.thousandSeparator) {\n value = value.split(this.localeDecimalSeparator);\n \n if (precision && value[1]) {\n value[1] = (this.decimalSeparator || this.localeDecimalSeparator) + value[1];\n }\n \n if (this.thousandSeparator && value[0].length > 3) {\n value[0] = value[0].replace(new RegExp(`[${this.localeThousandSeparator}]`, 'gim'), this.thousandSeparator);\n }\n \n value = value.join('');\n }\n }\n \n this.formattedValue = value.toString();\n }\n else {\n this.formattedValue = null;\n }\n\n if (this.inputfieldViewChild && this.inputfieldViewChild.nativeElement) {\n this.inputfieldViewChild.nativeElement.value = this.formattedValue;\n }\n }\n \n clearTimer() {\n if (this.timer) {\n clearInterval(this.timer);\n }\n }\n \n writeValue(value: any) : void {\n this.value = value;\n this.formatValue();\n this.updateFilledState();\n this.cd.markForCheck();\n }\n \n registerOnChange(fn: Function): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: Function): void {\n this.onModelTouched = fn;\n }\n \n setDisabledState(val: boolean): void {\n this.disabled = val;\n this.cd.markForCheck();\n }\n \n updateFilledState() {\n this.filled = (this.value !== undefined && this.value != null);\n }\n}\n\n\n@NgModule({\n imports: [CommonModule,InputTextModule],\n exports: [Spinner],\n declarations: [Spinner]\n})\nexport class SpinnerModule { }\n"]}