{"version":3,"sources":["../../src/app/components/colorpicker/colorpicker.ts"],"names":["COLORPICKER_VALUE_ACCESSOR","provide","NG_VALUE_ACCESSOR","useExisting","forwardRef","ColorPicker","multi","el","renderer","cd","this","format","autoZIndex","baseZIndex","showTransitionOptions","hideTransitionOptions","onChange","EventEmitter","onShow","onHide","value","h","s","b","defaultColor","onModelChange","onModelTouched","Object","defineProperty","prototype","element","colorSelectorViewChild","colorHandleViewChild","hueViewChild","hueHandleViewChild","onHueMousedown","event","disabled","bindDocumentMousemoveListener","bindDocumentMouseupListener","hueDragging","pickHue","top","nativeElement","getBoundingClientRect","window","pageYOffset","document","documentElement","scrollTop","body","validateHSB","Math","floor","max","min","pageY","updateColorSelector","updateUI","updateModel","emit","originalEvent","getValueToUpdate","onColorMousedown","colorDragging","pickColor","rect","left","scrollLeft","saturation","pageX","brightness","val","HSBtoHEX","HSBtoRGB","writeValue","HEXtoHSB","RGBtoHSB","markForCheck","hsb","style","backgroundColor","inputBgColor","onInputFocus","show","overlayVisible","onOverlayAnimationStart","toState","inline","overlay","appendOverlay","zIndex","String","DomHandler","zindex","alignOverlay","bindDocumentClickListener","bindDocumentResizeListener","bindScrollListener","onOverlayHide","onOverlayAnimationEnd","appendTo","appendChild","restoreOverlayAppend","absolutePosition","inputViewChild","relativePosition","hide","onInputClick","selfClick","togglePanel","onInputKeydown","which","preventDefault","onPanelClick","registerOnChange","fn","registerOnTouched","setDisabledState","_this","documentClickListener","documentTarget","ownerDocument","listen","unbindDocumentClickListener","documentMousemoveListener","unbindDocumentMousemoveListener","documentMouseupListener","unbindDocumentMouseupListener","documentResizeListener","onWindowResize","bind","addEventListener","unbindDocumentResizeListener","removeEventListener","scrollHandler","ConnectedOverlayScrollHandler","containerViewChild","unbindScrollListener","validateRGB","rgb","r","g","validateHEX","hex","len","length","o","i","push","join","HEXtoRGB","hexValue","parseInt","indexOf","substring","delta","v","t1","t2","t3","round","RGBtoHEX","toString","key","ngOnDestroy","destroy","Component","args","selector","template","animations","trigger","transition","opacity","transform","animate","providers","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ChangeDetectorRef","Input","Output","ViewChild","NgModule","imports","CommonModule","exports","declarations"],"mappings":"mlBAMaA,EAAkC,CAC3CC,QAASC,EAAAA,kBACTC,YAAaC,EAAAA,YAAW,WAAM,OAAAC,KAC9BC,OAAO,gBAyHP,SAAAD,EAAmBE,EAAuBC,EAA4BC,GAAnDC,KAAAH,GAAAA,EAAuBG,KAAAF,SAAAA,EAA4BE,KAAAD,GAAAA,EAvE7DC,KAAAC,OAAiB,MAUjBD,KAAAE,YAAsB,EAEtBF,KAAAG,WAAqB,EAErBH,KAAAI,sBAAgC,kCAEhCJ,KAAAK,sBAAgC,aAE/BL,KAAAM,SAA8B,IAAIC,EAAAA,aAElCP,KAAAQ,OAA4B,IAAID,EAAAA,aAEhCP,KAAAS,OAA4B,IAAIF,EAAAA,aAO1CP,KAAAU,MAAa,CAACC,EAAE,EAAGC,EAAG,IAAKC,EAAG,KAQ9Bb,KAAAc,aAAuB,SAEvBd,KAAAe,cAA0B,aAE1Bf,KAAAgB,eAA2B,oBAgC3BC,OAAAC,eAAgCvB,EAAAwB,UAAA,gBAAa,KAA7C,SAA8CC,GAC1CpB,KAAKqB,uBAAyBD,mCAGlCH,OAAAC,eAA8BvB,EAAAwB,UAAA,cAAW,KAAzC,SAA0CC,GACtCpB,KAAKsB,qBAAuBF,mCAGhCH,OAAAC,eAAsBvB,EAAAwB,UAAA,MAAG,KAAzB,SAA0BC,GACtBpB,KAAKuB,aAAeH,mCAGxBH,OAAAC,eAA4BvB,EAAAwB,UAAA,YAAS,KAArC,SAAsCC,GAClCpB,KAAKwB,mBAAqBJ,mCAG9BzB,EAAAwB,UAAAM,eAAA,SAAeC,GACP1B,KAAK2B,WAIT3B,KAAK4B,gCACL5B,KAAK6B,8BAEL7B,KAAK8B,aAAc,EACnB9B,KAAK+B,QAAQL,KAGjB/B,EAAAwB,UA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UAIjEG,UAAW,CAACjL,GACZkL,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,mkCAhDPC,EAAAA,kBAAgEC,EAAAA,iBAAsBC,EAAAA,oDAqD/GC,EAAAA,0BAEAA,EAAAA,sBAEAA,EAAAA,sBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,wBAEAA,EAAAA,uBAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,qCAEAA,EAAAA,qCAEAA,EAAAA,wBAEAC,EAAAA,uBAEAA,EAAAA,uBAEAA,EAAAA,mCAGAC,EAAAA,UAASrB,KAAA,CAAC,qCAEVqB,EAAAA,UAASrB,KAAA,CAAC,gCA8CVqB,EAAAA,UAASrB,KAAA,CAAC,sCAIVqB,EAAAA,UAASrB,KAAA,CAAC,4BAIVqB,EAAAA,UAASrB,KAAA,CAAC,0BAIVqB,EAAAA,UAASrB,KAAA,CAAC,sBA0ef,iCALCsB,EAAAA,SAAQtB,KAAA,CAAC,CACNuB,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAC5L,GACV6L,aAAc,CAAC7L","sourcesContent":["import { NgModule, Component, ElementRef, Input, Output, OnDestroy, EventEmitter, forwardRef, Renderer2, ViewChild, ChangeDetectorRef, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';\nimport { trigger, state, style, transition, animate, AnimationEvent } from '@angular/animations';\nimport { CommonModule } from '@angular/common';\nimport { DomHandler, ConnectedOverlayScrollHandler } from 'primeng/dom';\nimport { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';\n\nexport const COLORPICKER_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => ColorPicker),\n multi: true\n};\n\n@Component({\n selector: 'p-colorPicker',\n template: `\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n `,\n animations: [\n trigger('overlayAnimation', [\n transition(':enter', [\n style({opacity: 0, transform: 'scaleY(0.8)'}),\n animate('{{showTransitionParams}}')\n ]),\n transition(':leave', [\n animate('{{hideTransitionParams}}', style({ opacity: 0 }))\n ])\n ])\n ],\n providers: [COLORPICKER_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./colorpicker.css']\n})\nexport class ColorPicker implements ControlValueAccessor, OnDestroy {\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() inline: boolean;\n\n @Input() format: string = 'hex';\n\n @Input() appendTo: string;\n\n @Input() disabled: boolean;\n\n @Input() tabindex: string;\n\n @Input() inputId: string;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() showTransitionOptions: string = '.12s cubic-bezier(0, 0, 0.2, 1)';\n\n @Input() hideTransitionOptions: string = '.1s linear';\n\n @Output() onChange: EventEmitter = new EventEmitter();\n\n @Output() onShow: EventEmitter = new EventEmitter();\n\n @Output() onHide: EventEmitter = new EventEmitter();\n\n\n @ViewChild('container') containerViewChild: ElementRef;\n\n @ViewChild('input') inputViewChild: ElementRef;\n\n value: any = {h:0, s: 100, b: 100};\n\n inputBgColor: string;\n\n shown: boolean;\n\n overlayVisible: boolean;\n\n defaultColor: string = 'ff0000';\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n documentClickListener: Function;\n\n documentResizeListener: any;\n\n documentMousemoveListener: Function;\n\n documentMouseupListener: Function;\n\n documentHueMoveListener: Function;\n\n scrollHandler: any;\n\n selfClick: boolean;\n\n colorDragging: boolean;\n\n hueDragging: boolean;\n\n overlay: HTMLDivElement;\n\n colorSelectorViewChild: ElementRef;\n\n colorHandleViewChild: ElementRef;\n\n hueViewChild: ElementRef;\n\n hueHandleViewChild: ElementRef;\n\n constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef) {}\n\n @ViewChild('colorSelector') set colorSelector(element: ElementRef) {\n this.colorSelectorViewChild = element;\n }\n\n @ViewChild('colorHandle') set colorHandle(element: ElementRef) {\n this.colorHandleViewChild = element;\n }\n\n @ViewChild('hue') set hue(element: ElementRef) {\n this.hueViewChild = element;\n }\n\n @ViewChild('hueHandle') set hueHandle(element: ElementRef) {\n this.hueHandleViewChild = element;\n }\n\n onHueMousedown(event: MouseEvent) {\n if (this.disabled) {\n return;\n }\n\n this.bindDocumentMousemoveListener();\n this.bindDocumentMouseupListener();\n\n this.hueDragging = true;\n this.pickHue(event);\n }\n\n pickHue(event: MouseEvent) {\n let top: number = this.hueViewChild.nativeElement.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);\n this.value = this.validateHSB({\n h: Math.floor(360 * (150 - Math.max(0, Math.min(150, (event.pageY - top)))) / 150),\n s: this.value.s,\n b: this.value.b\n });\n\n this.updateColorSelector();\n this.updateUI();\n this.updateModel();\n this.onChange.emit({originalEvent: event, value: this.getValueToUpdate()});\n }\n\n onColorMousedown(event: MouseEvent) {\n if (this.disabled) {\n return;\n }\n\n this.bindDocumentMousemoveListener();\n this.bindDocumentMouseupListener();\n\n this.colorDragging = true;\n this.pickColor(event);\n }\n\n pickColor(event: MouseEvent) {\n let rect = this.colorSelectorViewChild.nativeElement.getBoundingClientRect();\n let top = rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);\n let left = rect.left + document.body.scrollLeft;\n let saturation = Math.floor(100 * (Math.max(0, Math.min(150, (event.pageX - left)))) / 150);\n let brightness = Math.floor(100 * (150 - Math.max(0, Math.min(150, (event.pageY - top)))) / 150);\n this.value = this.validateHSB({\n h: this.value.h,\n s: saturation,\n b: brightness\n });\n\n this.updateUI();\n this.updateModel();\n this.onChange.emit({originalEvent: event, value: this.getValueToUpdate()});\n }\n\n getValueToUpdate() {\n let val: any;\n switch(this.format) {\n case 'hex':\n val = '#' + this.HSBtoHEX(this.value);\n break;\n\n case 'rgb':\n val = this.HSBtoRGB(this.value);\n break;\n\n case 'hsb':\n val = this.value;\n break;\n }\n\n return val;\n }\n\n updateModel(): void {\n this.onModelChange(this.getValueToUpdate());\n }\n\n writeValue(value: any): void {\n if (value) {\n switch(this.format) {\n case 'hex':\n this.value = this.HEXtoHSB(value);\n break;\n\n case 'rgb':\n this.value = this.RGBtoHSB(value);\n break;\n\n case 'hsb':\n this.value = value;\n break;\n }\n }\n else {\n this.value = this.HEXtoHSB(this.defaultColor);\n }\n\n this.updateColorSelector();\n this.updateUI();\n this.cd.markForCheck();\n }\n\n updateColorSelector() {\n if (this.colorSelectorViewChild) {\n const hsb: any = {};\n hsb.s = 100;\n hsb.b = 100;\n hsb.h = this.value.h;\n\n this.colorSelectorViewChild.nativeElement.style.backgroundColor = '#' + this.HSBtoHEX(hsb);\n }\n }\n\n updateUI() {\n if (this.colorHandleViewChild && this.hueHandleViewChild.nativeElement) {\n this.colorHandleViewChild.nativeElement.style.left = Math.floor(150 * this.value.s / 100) + 'px';\n this.colorHandleViewChild.nativeElement.style.top = Math.floor(150 * (100 - this.value.b) / 100) + 'px';\n this.hueHandleViewChild.nativeElement.style.top = Math.floor(150 - (150 * this.value.h / 360)) + 'px';\n\n }\n\n this.inputBgColor = '#' + this.HSBtoHEX(this.value);\n }\n\n onInputFocus() {\n this.onModelTouched();\n }\n\n show() {\n this.overlayVisible = true;\n }\n\n onOverlayAnimationStart(event: AnimationEvent) {\n switch(event.toState) {\n case 'visible':\n if (!this.inline) {\n this.overlay = event.element;\n this.appendOverlay();\n if (this.autoZIndex) {\n this.overlay.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex));\n }\n this.alignOverlay();\n this.bindDocumentClickListener();\n this.bindDocumentResizeListener();\n this.bindScrollListener();\n\n this.updateColorSelector();\n this.updateUI();\n }\n break;\n\n case 'void':\n this.onOverlayHide();\n break;\n }\n }\n\n onOverlayAnimationEnd(event: AnimationEvent) {\n switch(event.toState) {\n case 'visible':\n if (!this.inline) {\n this.onShow.emit({})\n }\n break;\n\n case 'void':\n this.onHide.emit({})\n break;\n }\n }\n\n appendOverlay() {\n if (this.appendTo) {\n if (this.appendTo === 'body')\n document.body.appendChild(this.overlay);\n else\n DomHandler.appendChild(this.overlay, this.appendTo);\n }\n }\n\n restoreOverlayAppend() {\n if (this.overlay && this.appendTo) {\n this.el.nativeElement.appendChild(this.overlay);\n }\n }\n\n alignOverlay() {\n if (this.appendTo)\n DomHandler.absolutePosition(this.overlay, this.inputViewChild.nativeElement);\n else\n DomHandler.relativePosition(this.overlay, this.inputViewChild.nativeElement);\n }\n\n hide() {\n this.overlayVisible = false;\n this.cd.markForCheck();\n }\n\n onInputClick() {\n this.selfClick = true;\n this.togglePanel();\n }\n\n togglePanel() {\n if (!this.overlayVisible)\n this.show();\n else\n this.hide();\n }\n\n onInputKeydown(event: KeyboardEvent) {\n switch(event.which) {\n //space\n case 32:\n this.togglePanel();\n event.preventDefault();\n break;\n\n //escape and tab\n case 27:\n case 9:\n this.hide();\n break;\n }\n }\n\n onPanelClick() {\n this.selfClick = true;\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 bindDocumentClickListener() {\n if (!this.documentClickListener) {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentClickListener = this.renderer.listen(documentTarget, 'click', () => {\n if (!this.selfClick) {\n this.overlayVisible = false;\n this.unbindDocumentClickListener();\n }\n\n this.selfClick = false;\n this.cd.markForCheck();\n });\n }\n }\n\n unbindDocumentClickListener() {\n if (this.documentClickListener) {\n this.documentClickListener();\n this.documentClickListener = null;\n }\n }\n\n bindDocumentMousemoveListener() {\n if (!this.documentMousemoveListener) {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentMousemoveListener = this.renderer.listen(documentTarget, 'mousemove', (event: MouseEvent) => {\n if (this.colorDragging) {\n this.pickColor(event);\n }\n\n if (this.hueDragging) {\n this.pickHue(event);\n }\n });\n }\n }\n\n unbindDocumentMousemoveListener() {\n if (this.documentMousemoveListener) {\n this.documentMousemoveListener();\n this.documentMousemoveListener = null;\n }\n }\n\n bindDocumentMouseupListener() {\n if (!this.documentMouseupListener) {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentMouseupListener = this.renderer.listen(documentTarget, 'mouseup', () => {\n this.colorDragging = false;\n this.hueDragging = false;\n this.unbindDocumentMousemoveListener();\n this.unbindDocumentMouseupListener();\n });\n }\n }\n\n unbindDocumentMouseupListener() {\n if (this.documentMouseupListener) {\n this.documentMouseupListener();\n this.documentMouseupListener = null;\n }\n }\n\n bindDocumentResizeListener() {\n this.documentResizeListener = this.onWindowResize.bind(this);\n window.addEventListener('resize', this.documentResizeListener);\n }\n\n unbindDocumentResizeListener() {\n if (this.documentResizeListener) {\n window.removeEventListener('resize', this.documentResizeListener);\n this.documentResizeListener = null;\n }\n }\n\n onWindowResize() {\n this.hide();\n }\n\n bindScrollListener() {\n if (!this.scrollHandler) {\n this.scrollHandler = new ConnectedOverlayScrollHandler(this.containerViewChild.nativeElement, () => {\n if (this.overlayVisible) {\n this.hide();\n }\n });\n }\n\n this.scrollHandler.bindScrollListener();\n }\n\n unbindScrollListener() {\n if (this.scrollHandler) {\n this.scrollHandler.unbindScrollListener();\n }\n }\n\n validateHSB(hsb) {\n return {\n h: Math.min(360, Math.max(0, hsb.h)),\n s: Math.min(100, Math.max(0, hsb.s)),\n b: Math.min(100, Math.max(0, hsb.b))\n };\n }\n\n validateRGB(rgb) {\n return {\n r: Math.min(255, Math.max(0, rgb.r)),\n g: Math.min(255, Math.max(0, rgb.g)),\n b: Math.min(255, Math.max(0, rgb.b))\n };\n }\n\n validateHEX(hex) {\n var len = 6 - hex.length;\n if (len > 0) {\n var o = [];\n for (var i=0; i -1) ? hex.substring(1) : hex), 16);\n return {r: hexValue >> 16, g: (hexValue & 0x00FF00) >> 8, b: (hexValue & 0x0000FF)};\n }\n\n HEXtoHSB(hex) {\n return this.RGBtoHSB(this.HEXtoRGB(hex));\n }\n\n RGBtoHSB(rgb) {\n var hsb = {\n h: 0,\n s: 0,\n b: 0\n };\n var min = Math.min(rgb.r, rgb.g, rgb.b);\n var max = Math.max(rgb.r, rgb.g, rgb.b);\n var delta = max - min;\n hsb.b = max;\n hsb.s = max != 0 ? 255 * delta / max : 0;\n if (hsb.s != 0) {\n if (rgb.r == max) {\n hsb.h = (rgb.g - rgb.b) / delta;\n } else if (rgb.g == max) {\n hsb.h = 2 + (rgb.b - rgb.r) / delta;\n } else {\n hsb.h = 4 + (rgb.r - rgb.g) / delta;\n }\n } else {\n hsb.h = -1;\n }\n hsb.h *= 60;\n if (hsb.h < 0) {\n hsb.h += 360;\n }\n hsb.s *= 100/255;\n hsb.b *= 100/255;\n return hsb;\n }\n\n HSBtoRGB(hsb) {\n var rgb = {\n r: null, g: null, b: null\n };\n let h: number = hsb.h;\n let s: number = hsb.s*255/100;\n let v: number = hsb.b*255/100;\n if (s == 0) {\n rgb = {\n r: v,\n g: v,\n b: v\n }\n }\n else {\n let t1: number = v;\n let t2: number = (255-s)*v/255;\n let t3: number = (t1-t2)*(h%60)/60;\n if (h==360) h = 0;\n if (h<60) {rgb.r=t1;\trgb.b=t2; rgb.g=t2+t3}\n else if (h<120) {rgb.g=t1; rgb.b=t2;\trgb.r=t1-t3}\n else if (h<180) {rgb.g=t1; rgb.r=t2;\trgb.b=t2+t3}\n else if (h<240) {rgb.b=t1; rgb.r=t2;\trgb.g=t1-t3}\n else if (h<300) {rgb.b=t1; rgb.g=t2;\trgb.r=t2+t3}\n else if (h<360) {rgb.r=t1; rgb.g=t2;\trgb.b=t1-t3}\n else {rgb.r=0; rgb.g=0;\trgb.b=0}\n }\n return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};\n }\n\n RGBtoHEX(rgb) {\n var hex = [\n rgb.r.toString(16),\n rgb.g.toString(16),\n rgb.b.toString(16)\n ];\n\n for(var key in hex) {\n if (hex[key].length == 1) {\n hex[key] = '0' + hex[key];\n }\n }\n\n return hex.join('');\n }\n\n HSBtoHEX(hsb) {\n return this.RGBtoHEX(this.HSBtoRGB(hsb));\n }\n\n onOverlayHide() {\n this.unbindScrollListener();\n this.unbindDocumentResizeListener();\n this.unbindDocumentClickListener();\n this.overlay = null;\n }\n\n ngOnDestroy() {\n if (this.scrollHandler) {\n this.scrollHandler.destroy();\n this.scrollHandler = null;\n }\n\n this.restoreOverlayAppend();\n this.onOverlayHide();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [ColorPicker],\n declarations: [ColorPicker]\n})\nexport class ColorPickerModule { }\n"]}