From d8cf727255f634a7683ca3a4d4d906367843740c Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 2 Sep 2019 17:46:54 +0200 Subject: [PATCH 1/8] Setup basic translation system --- dist/pickr.es5.min.js | 2 +- dist/pickr.es5.min.js.map | 2 +- dist/pickr.min.js | 2 +- dist/pickr.min.js.map | 2 +- src/js/pickr.js | 12 ++++++++---- src/js/template.js | 18 +++++++++--------- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/dist/pickr.es5.min.js b/dist/pickr.es5.min.js index bab866f9..130e4c2e 100644 --- a/dist/pickr.es5.min.js +++ b/dist/pickr.es5.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r={};function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function i(t){for(var e=1;e4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(n)||(n=[n]);var a=!0,c=!1,l=void 0;try{for(var s,u=e[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){var p=s.value,h=!0,f=!1,d=void 0;try{for(var v,y=n[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var m=v.value;p[t](m,r,i({capture:!1},o))}}catch(t){f=!0,d=t}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}}}catch(t){c=!0,l=t}finally{try{a||null==u.return||u.return()}finally{if(c)throw l}}return Array.prototype.slice.call(arguments,1)}function u(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function p(t,e){var n=t.getAttribute(e);return t.removeAttribute(e),n}function h(t){return function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=p(e,":obj"),o=p(e,":ref"),i=r?n[r]={}:n;o&&(n[o]=e);for(var a=0,c=Array.from(e.children);a>/g).reduce(function(t,e,n,r){return t=t.querySelector(e),n1&&void 0!==arguments[1]?arguments[1]:function(t){return t};function n(n){var r=[.001,.01,.1][Number(n.shiftKey||2*n.ctrlKey)]*(n.deltaY<0?1:-1),o=0,i=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,function(t,n){return n<=i&&n+t.length>=i?(i=n,e(Number(t),r,o)):(o++,t)}),t.focus(),t.setSelectionRange(i,i),n.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",function(){return c(window,"wheel",n,{passive:!1})}),c(t,"blur",function(){return l(window,"wheel",n)})}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function m(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(r-=1)}return[360*r,100*o,100*a]}function C(t,e,n,r){return e/=100,n/=100,m(A(255*(1-b(1,(t/=100)*(1-(r/=100))+r)),255*(1-b(1,e*(1-r)+r)),255*(1-b(1,n*(1-r)+r))))}function S(t,e,n){return e/=100,[t,2*(e*=(n/=100)<.5?n:1-n)/(n+e)*100,100*(n+e)]}function O(t){return A.apply(void 0,m(t.match(/.{2}/g).map(function(t){return parseInt(t,16)})))}function j(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";var e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;var e,n={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},r=function(t){return t.map(function(t){return/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0})};t:for(var o in n)if(e=n[o].exec(t)){var i=!!e[2];switch(o){case"cmyk":var a=y(r(e),5),c=a[1],l=a[2],s=a[3],u=a[4];if(c>100||l>100||s>100||u>100)break t;return{values:C(c,l,s,u),type:o};case"rgba":var p=y(r(e),7),h=p[3],f=p[4],d=p[5],v=p[6];if(h>255||f>255||d>255||v<0||v>1||i===!v)break t;return{values:[].concat(m(A(h,f,d)),[v]),a:v,type:o};case"hexa":var b=y(e,2)[1];4!==b.length&&3!==b.length||(b=b.split("").map(function(t){return t+t}).join(""));var g=b.substring(0,6),_=b.substring(6);return _=_?parseInt(_,16)/255:void 0,{values:[].concat(m(O(g)),[_]),a:_,type:o};case"hsla":var w=y(r(e),7),k=w[3],j=w[4],x=w[5],E=w[6];if(k>360||j>100||x>100||E<0||E>1||i===!E)break t;return{values:[].concat(m(S(k,j,x)),[E]),a:E,type:o};case"hsva":var L=y(r(e),7),P=L[3],B=L[4],R=L[5],H=L[6];if(P>360||B>100||R>100||H<0||H>1||i===!H)break t;return{values:[P,B,R,H],a:H,type:o}}}return{values:null,type:null}}function x(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=function(t,e){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~n?t.map(function(t){return Number(t.toFixed(n))}):t)}},i={h:t,s:e,v:n,a:r,toHSVA:function(){var t=[i.h,i.s,i.v,i.a];return t.toString=o(t,function(t){return"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toHSLA:function(){var t=[].concat(x(function(t,e,n){var r=(2-(e/=100))*(n/=100)/2;return 0!==r&&(e=1===r?0:r<.5?e*n/(2*r):e*n/(2-2*r)),[t,100*e,100*r]}(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toRGBA:function(){var t=[].concat(x(k(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(i.a,")")}),t},toCMYK:function(){var t=function(t,e,n){var r,o=k(t,e,n),i=o[0]/255,a=o[1]/255,c=o[2]/255;return[100*(1===(r=b(1-i,1-a,1-c))?0:(1-i-r)/(1-r)),100*(1===r?0:(1-a-r)/(1-r)),100*(1===r?0:(1-c-r)/(1-r)),100*r]}(i.h,i.s,i.v);return t.toString=o(t,function(t){return"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")}),t},toHEXA:function(){var t=function(t,e,n){return k(t,e,n).map(function(t){return w(t).toString(16).padStart(2,"0")})}(i.h,i.s,i.v),e=i.a>=1?"":Number((255*i.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=function(){return"#".concat(t.join("").toUpperCase())},t},clone:function(){return E(i.h,i.s,i.v,i.a)}};return i}var L=function(t){return Math.max(Math.min(t,1),0)};function P(t){var e={options:Object.assign({lock:null,onchange:function(){return 0},onstop:function(){return 0}},t),_keyboard:function(t){var r=t.type,o=t.key;if(document.activeElement===n.wrapper)if("keydown"===r){var i=0,a=0;switch(o){case"ArrowLeft":i--;break;case"ArrowRight":i++;break;case"ArrowUp":a++;break;case"ArrowDown":a++}e.update(L(e.cache.x+.01*i),L(e.cache.y+.01*a))}else o.startsWith("Arrow")&&e.options.onstop()},_tapstart:function(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove:function(t){var r=e.options.lock,o=e.cache,i=n.element,a=n.wrapper,c=a.getBoundingClientRect(),l=0,s=0;if(t){var u=t&&t.touches&&t.touches[0];l=t?(u||t).clientX:0,s=t?(u||t).clientY:0,lc.left+c.width&&(l=c.left+c.width),sc.top+c.height&&(s=c.top+c.height),l-=c.left,s-=c.top}else o&&(l=o.x*c.width,s=o.y*c.height);"h"!==r&&(i.style.left="calc(".concat(l/c.width*100,"% - ").concat(i.offsetWidth/2,"px)")),"v"!==r&&(i.style.top="calc(".concat(s/c.height*100,"% - ").concat(i.offsetHeight/2,"px)")),e.cache={x:l/c.width,y:s/c.height};var p=L(l/a.offsetWidth),h=L(s/a.offsetHeight);switch(r){case"v":return n.onchange(p);case"h":return n.onchange(h);default:return n.onchange(p,h)}},_tapstop:function(){e.options.onstop(),l(document,["mouseup","touchend","touchcancel"],e._tapstop),l(document,["mousemove","touchmove"],e._tapmove)},trigger:function(){e._tapmove()},update:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.options.wrapper.getBoundingClientRect(),o=r.left,i=r.top,a=r.width,c=r.height;"h"===e.options.lock&&(n=t),e._tapmove({clientX:o+a*t,clientY:i+c*n})},destroy:function(){var t=e.options,n=e._tapstart;l([t.wrapper,t.element],"mousedown",n),l([t.wrapper,t.element],"touchstart",n,{passive:!1})}},n=e.options,r=e._tapstart,o=e._keyboard;return c([n.wrapper,n.element],"mousedown",r),c([n.wrapper,n.element],"touchstart",r,{passive:!1}),c(document,["keydown","keyup"],o),e}function B(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:function(){return 0},className:"",elements:[]},t);var e=c(t.elements,"click",function(e){t.elements.forEach(function(n){return n.classList[e.target===n?"add":"remove"](t.className)}),t.onchange(e)});return{destroy:function(){return l.apply(r,B(e))}}}function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function D(t){var e=t.el,n=t.reference,r=t.padding,o=void 0===r?8:r,i={start:"sme",middle:"mse",end:"ems"},a={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[e];if(n)return n;var r=e.split("-"),o=H(r,2),i=o[0],a=o[1],c=void 0===a?"middle":a,l="top"===i||"bottom"===i;return t[e]={position:i,variant:c,isVertical:l}}}();return{update:function(t){var r=c(t),l=r.position,s=r.variant,u=r.isVertical,p=n.getBoundingClientRect(),h=e.getBoundingClientRect(),f=function(t){return t?{s:p.left+p.width-h.width,m:-h.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-h.height,m:p.bottom-p.height/2-h.height/2,e:p.bottom-p.height}},d={};function v(t,n,r){var o="top"===r,i=o?h.height:h.width,a=window[o?"innerHeight":"innerWidth"],c=!0,l=!1,s=void 0;try{for(var u,p=t[Symbol.iterator]();!(c=(u=p.next()).done);c=!0){var f=n[u.value],v=d[r]="".concat(f,"px");if(f>0&&f+i\n\n '.concat(r?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o'));return o.swatches.appendChild(a),r.push({el:a,color:i}),this._eventBindings.push(c(a,"click",function(){e.setHSVA.apply(e,M(i.toHSVA()).concat([!0])),e._emit("swatchselect",i),e._emit("change",i)})),!0}return!1}},{key:"removeSwatch",value:function(t){var e=this._swatchColors[t];if(e){var n=e.el;return this._root.swatches.removeChild(n),this._swatchColors.splice(t,1),!0}return!1}},{key:"applyColor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=e.preview,r=e.button,o=this._color.toRGBA().toString();n.lastColor.style.color=o,this.options.useAsButton||(r.style.color=o),r.classList.remove("clear"),this._lastColor=this._color.clone(),this._initializingActive||t||this._emit("save",this._color)}},{key:"destroy",value:function(){var t=this;this._eventBindings.forEach(function(t){return l.apply(r,M(t))}),Object.keys(this._components).forEach(function(e){return t._components[e].destroy()})}},{key:"destroyAndRemove",value:function(){var t=this;this.destroy();var e=this._root,n=e.root,r=e.app;n.parentElement&&n.parentElement.removeChild(n),r.parentElement.removeChild(r),Object.keys(this).forEach(function(e){return t[e]=null})}},{key:"hide",value:function(){return this._root.app.classList.remove("visible"),this._emit("hide",this),this}},{key:"show",value:function(){return this.options.disabled||(this._root.app.classList.add("visible"),this._rePositioningPicker(),this._emit("show",this)),this}},{key:"isOpen",value:function(){return this._root.app.classList.contains("visible")}},{key:"setHSVA",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:360,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],i=this._recalc;if(this._recalc=!1,t<0||t>360||e<0||e>100||n<0||n>100||r<0||r>1)return!1;this._color=E(t,e,n,r);var a=this._components,c=a.hue,l=a.opacity,s=a.palette;return c.update(t/360),l.update(r),s.update(e/100,1-n/100),o||this.applyColor(),i&&this._updateOutput(),this._recalc=i,!0}},{key:"setColor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===t)return this._clearColor(e),!0;var n=this._parseLocalColor(t),r=n.values,o=n.type;if(r){var i=o.toUpperCase(),a=this._root.interaction.options,c=a.find(function(t){return t.getAttribute("data-type")===i});if(c&&!c.hidden){var l=!0,s=!1,u=void 0;try{for(var p,h=a[Symbol.iterator]();!(l=(p=h.next()).done);l=!0){var f=p.value;f.classList[f===c?"add":"remove"]("active")}}catch(t){s=!0,u=t}finally{try{l||null==h.return||h.return()}finally{if(s)throw u}}}return this.setColorRepresentation(i),this.setHSVA.apply(this,M(r).concat([e]))}return!1}},{key:"setColorRepresentation",value:function(t){return t=t.toUpperCase(),!!this._root.interaction.options.find(function(e){return e.getAttribute("data-type").startsWith(t)&&!e.click()})}},{key:"getColorRepresentation",value:function(){return this._representation}},{key:"getColor",value:function(){return this._color}},{key:"getSelectedColor",value:function(){return this._lastColor}},{key:"getRoot",value:function(){return this._root}},{key:"disable",value:function(){return this.hide(),this.options.disabled=!0,this._root.button.classList.add("disabled"),this}},{key:"enable",value:function(){return this.options.disabled=!1,this._root.button.classList.remove("disabled"),this}}])&&N(e.prototype,n),o&&N(e,o),t}();F.utils=r,F.libs={HSVaColor:E,Moveable:P,Nanopop:D,Selectable:R},F.create=function(t){return new F(t)},F.version="1.4.1";e.default=F}]).default}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r={};function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function i(t){for(var e=1;e4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(n)||(n=[n]);var a=!0,c=!1,l=void 0;try{for(var s,u=e[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){var p=s.value,h=!0,f=!1,d=void 0;try{for(var v,y=n[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var b=v.value;p[t](b,r,i({capture:!1},o))}}catch(t){f=!0,d=t}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}}}catch(t){c=!0,l=t}finally{try{a||null==u.return||u.return()}finally{if(c)throw l}}return Array.prototype.slice.call(arguments,1)}function u(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function p(t,e){var n=t.getAttribute(e);return t.removeAttribute(e),n}function h(t){return function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=p(e,":obj"),o=p(e,":ref"),i=r?n[r]={}:n;o&&(n[o]=e);for(var a=0,c=Array.from(e.children);a>/g).reduce(function(t,e,n,r){return t=t.querySelector(e),n1&&void 0!==arguments[1]?arguments[1]:function(t){return t};function n(n){var r=[.001,.01,.1][Number(n.shiftKey||2*n.ctrlKey)]*(n.deltaY<0?1:-1),o=0,i=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,function(t,n){return n<=i&&n+t.length>=i?(i=n,e(Number(t),r,o)):(o++,t)}),t.focus(),t.setSelectionRange(i,i),n.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",function(){return c(window,"wheel",n,{passive:!1})}),c(t,"blur",function(){return l(window,"wheel",n)})}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(r-=1)}return[360*r,100*o,100*a]}function C(t,e,n,r){return e/=100,n/=100,b(A(255*(1-m(1,(t/=100)*(1-(r/=100))+r)),255*(1-m(1,e*(1-r)+r)),255*(1-m(1,n*(1-r)+r))))}function O(t,e,n){return e/=100,[t,2*(e*=(n/=100)<.5?n:1-n)/(n+e)*100,100*(n+e)]}function S(t){return A.apply(void 0,b(t.match(/.{2}/g).map(function(t){return parseInt(t,16)})))}function j(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";var e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;var e,n={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},r=function(t){return t.map(function(t){return/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0})};t:for(var o in n)if(e=n[o].exec(t)){var i=!!e[2];switch(o){case"cmyk":var a=y(r(e),5),c=a[1],l=a[2],s=a[3],u=a[4];if(c>100||l>100||s>100||u>100)break t;return{values:C(c,l,s,u),type:o};case"rgba":var p=y(r(e),7),h=p[3],f=p[4],d=p[5],v=p[6];if(h>255||f>255||d>255||v<0||v>1||i===!v)break t;return{values:[].concat(b(A(h,f,d)),[v]),a:v,type:o};case"hexa":var m=y(e,2)[1];4!==m.length&&3!==m.length||(m=m.split("").map(function(t){return t+t}).join(""));var g=m.substring(0,6),w=m.substring(6);return w=w?parseInt(w,16)/255:void 0,{values:[].concat(b(S(g)),[w]),a:w,type:o};case"hsla":var _=y(r(e),7),k=_[3],j=_[4],x=_[5],E=_[6];if(k>360||j>100||x>100||E<0||E>1||i===!E)break t;return{values:[].concat(b(O(k,j,x)),[E]),a:E,type:o};case"hsva":var P=y(r(e),7),L=P[3],B=P[4],D=P[5],R=P[6];if(L>360||B>100||D>100||R<0||R>1||i===!R)break t;return{values:[L,B,D,R],a:R,type:o}}}return{values:null,type:null}}function x(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=function(t,e){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~n?t.map(function(t){return Number(t.toFixed(n))}):t)}},i={h:t,s:e,v:n,a:r,toHSVA:function(){var t=[i.h,i.s,i.v,i.a];return t.toString=o(t,function(t){return"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toHSLA:function(){var t=[].concat(x(function(t,e,n){var r=(2-(e/=100))*(n/=100)/2;return 0!==r&&(e=1===r?0:r<.5?e*n/(2*r):e*n/(2-2*r)),[t,100*e,100*r]}(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toRGBA:function(){var t=[].concat(x(k(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(i.a,")")}),t},toCMYK:function(){var t=function(t,e,n){var r,o=k(t,e,n),i=o[0]/255,a=o[1]/255,c=o[2]/255;return[100*(1===(r=m(1-i,1-a,1-c))?0:(1-i-r)/(1-r)),100*(1===r?0:(1-a-r)/(1-r)),100*(1===r?0:(1-c-r)/(1-r)),100*r]}(i.h,i.s,i.v);return t.toString=o(t,function(t){return"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")}),t},toHEXA:function(){var t=function(t,e,n){return k(t,e,n).map(function(t){return _(t).toString(16).padStart(2,"0")})}(i.h,i.s,i.v),e=i.a>=1?"":Number((255*i.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=function(){return"#".concat(t.join("").toUpperCase())},t},clone:function(){return E(i.h,i.s,i.v,i.a)}};return i}var P=function(t){return Math.max(Math.min(t,1),0)};function L(t){var e={options:Object.assign({lock:null,onchange:function(){return 0},onstop:function(){return 0}},t),_keyboard:function(t){var r=t.type,o=t.key;if(document.activeElement===n.wrapper)if("keydown"===r){var i=0,a=0;switch(o){case"ArrowLeft":i--;break;case"ArrowRight":i++;break;case"ArrowUp":a++;break;case"ArrowDown":a++}e.update(P(e.cache.x+.01*i),P(e.cache.y+.01*a))}else o.startsWith("Arrow")&&e.options.onstop()},_tapstart:function(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove:function(t){var r=e.options.lock,o=e.cache,i=n.element,a=n.wrapper,c=a.getBoundingClientRect(),l=0,s=0;if(t){var u=t&&t.touches&&t.touches[0];l=t?(u||t).clientX:0,s=t?(u||t).clientY:0,lc.left+c.width&&(l=c.left+c.width),sc.top+c.height&&(s=c.top+c.height),l-=c.left,s-=c.top}else o&&(l=o.x*c.width,s=o.y*c.height);"h"!==r&&(i.style.left="calc(".concat(l/c.width*100,"% - ").concat(i.offsetWidth/2,"px)")),"v"!==r&&(i.style.top="calc(".concat(s/c.height*100,"% - ").concat(i.offsetHeight/2,"px)")),e.cache={x:l/c.width,y:s/c.height};var p=P(l/a.offsetWidth),h=P(s/a.offsetHeight);switch(r){case"v":return n.onchange(p);case"h":return n.onchange(h);default:return n.onchange(p,h)}},_tapstop:function(){e.options.onstop(),l(document,["mouseup","touchend","touchcancel"],e._tapstop),l(document,["mousemove","touchmove"],e._tapmove)},trigger:function(){e._tapmove()},update:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.options.wrapper.getBoundingClientRect(),o=r.left,i=r.top,a=r.width,c=r.height;"h"===e.options.lock&&(n=t),e._tapmove({clientX:o+a*t,clientY:i+c*n})},destroy:function(){var t=e.options,n=e._tapstart;l([t.wrapper,t.element],"mousedown",n),l([t.wrapper,t.element],"touchstart",n,{passive:!1})}},n=e.options,r=e._tapstart,o=e._keyboard;return c([n.wrapper,n.element],"mousedown",r),c([n.wrapper,n.element],"touchstart",r,{passive:!1}),c(document,["keydown","keyup"],o),e}function B(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:function(){return 0},className:"",elements:[]},t);var e=c(t.elements,"click",function(e){t.elements.forEach(function(n){return n.classList[e.target===n?"add":"remove"](t.className)}),t.onchange(e)});return{destroy:function(){return l.apply(r,B(e))}}}function R(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function H(t){var e=t.el,n=t.reference,r=t.padding,o=void 0===r?8:r,i={start:"sme",middle:"mse",end:"ems"},a={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[e];if(n)return n;var r=e.split("-"),o=R(r,2),i=o[0],a=o[1],c=void 0===a?"middle":a,l="top"===i||"bottom"===i;return t[e]={position:i,variant:c,isVertical:l}}}();return{update:function(t){var r=c(t),l=r.position,s=r.variant,u=r.isVertical,p=n.getBoundingClientRect(),h=e.getBoundingClientRect(),f=function(t){return t?{s:p.left+p.width-h.width,m:-h.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-h.height,m:p.bottom-p.height/2-h.height/2,e:p.bottom-p.height}},d={};function v(t,n,r){var o="top"===r,i=o?h.height:h.width,a=window[o?"innerHeight":"innerWidth"],c=!0,l=!1,s=void 0;try{for(var u,p=t[Symbol.iterator]();!(c=(u=p.next()).done);c=!0){var f=n[u.value],v=d[r]="".concat(f,"px");if(f>0&&f+i\n\n '.concat(r?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:L({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,b=v.color;y.classList[s===b.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:L({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:L({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:D({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return this.options.i18n[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=E.apply(void 0,M(n)),a=u(''}\r\n\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n `);\r\n\r\n const int = root.interaction;\r\n\r\n // Select option which is not hidden\r\n int.options.find(o => !o.hidden && !o.classList.add('active'));\r\n\r\n // Create method to find currenlty active option\r\n int.type = () => int.options.find(e => e.classList.contains('active'));\r\n return root;\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/js/utils/utils.js","webpack:///./src/js/utils/color.js","webpack:///./src/js/utils/hsvacolor.js","webpack:///./src/js/libs/moveable.js","webpack:///./src/js/libs/selectable.js","webpack:///./src/js/libs/nanopop.js","webpack:///./src/js/pickr.js","webpack:///./src/js/template.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","on","eventListener","off","method","elements","events","fn","options","HTMLCollection","NodeList","Array","from","isArray","el","ev","capture","slice","arguments","createElementFromString","html","div","document","createElement","innerHTML","trim","firstElementChild","removeAttribute","getAttribute","createFromTemplate","str","resolve","element","base","con","subtree","children","child","arr","sub","push","keys","length","eventPath","evt","path","composedPath","target","parentElement","resolveElement","val","Element","split","reduce","pv","cv","ci","a","querySelector","shadowRoot","adjustableInputNumbers","mapper","v","handleScroll","e","inc","Number","shiftKey","ctrlKey","deltaY","index","selectionStart","replace","focus","setSelectionRange","preventDefault","dispatchEvent","Event","passive","min","Math","max","floor","round","hsvToRgb","h","f","q","mod","rgbToHsv","g","b","minVal","maxVal","delta","dr","dg","db","cmykToHsv","y","k","hslToHsv","hexToHsv","hex","match","map","parseInt","parseToHSVA","toLowerCase","ctx","getContext","fillStyle","standardizeColor","regex","cmyk","rgba","hsla","hsva","hexa","numarize","array","test","undefined","invalid","type","exec","alpha","values","join","raw","substring","HSVaColor","original","next","precision","toFixed","that","toHSVA","toString","toHSLA","hsvToHsl","toRGBA","toCMYK","rgb","hsvToCmyk","toHEXA","padStart","hsvToHex","toUpperCase","clone","clamp","Moveable","opt","assign","lock","onchange","onstop","_keyboard","activeElement","wrapper","xm","ym","update","cache","x","startsWith","_tapstart","_","_tapstop","_tapmove","getBoundingClientRect","touch","touches","clientX","clientY","left","width","top","height","style","offsetWidth","offsetHeight","cx","cy","trigger","destroy","Selectable","className","onTap","forEach","classList","Nanopop","reference","padding","vBehaviour","start","middle","end","hBehaviour","right","bottom","getInfo","pos","cached","position","variant","isVertical","rb","eb","variants","vertical","leastApplied","apply","bevs","vars","styleprop","adder","win","sv","rot","v2Ok","v1Ok","Pickr","init","save","hide","show","clear","change","changestop","cancel","swatchselect","this","appClass","theme","useAsButton","disabled","comparison","closeOnScroll","outputPrecision","lockOpacity","autoReposition","container","components","interaction","i18n","swatches","inline","sliders","default","defaultRepresentation","adjustableNumbers","showAlways","closeWithKey","includes","preview","opacity","hue","palette","_preBuild","_buildComponents","_bindEvents","_finalBuild","color","addSwatch","_root","button","app","_nanopop","setAttribute","_t","requestAnimationFrame","cb","setColor","_rePositioningPicker","_representation","setColorRepresentation","_initializingActive","_emit","lo","hidden","int","input","find","add","contains","appendChild","removeChild","parent","nextSibling","insertBefore","remove","parentNode","replaceChild","disable","transition","lastColor","inst","cs","repeat","so","sh","getColor","_color","_lastColor","picker","_recalc","_updateOutput","cssRGBaString","background","_swatchColors","currentColor","slider","backgroundColor","selectable","_components","eventBindings","_clearColor","setHSVA","applyColor","result","stopImmediatePropagation","ck","isOpen","code","some","ranges","step","range","getColorRepresentation","nv","toPrecision","timeout","setTimeout","rs","clearTimeout","_eventBindings","matchMedia","matches","margin","silent","alphaMakesAChange","event","args","_eventListener","def","callBacks","indexOf","splice","_parseLocalColor","swatchColor","recalc","string","utype","click","utils","libs","version"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,IARlB,CASGK,OAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDA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WA,EAAOyO,OAAQ,4BAC1B,YAAiBhR,EAAjB,+CAA0B,KAAfM,EAAe,QACtBA,EAAGgL,UAAUhL,IAAOiC,EAAS,MAAQ,UAAU,WAFzB,mFAO9B,OADAyL,KAAK4C,uBAAuB6E,GACrBzH,KAAKsF,QAAL,MAAAtF,KAAA,EAAgBzG,GAAhB,QAAwBqN,KAGnC,OAAO,I,6CASYxN,GAMnB,OAHAA,EAAOA,EAAKwB,gBAGHoF,KAAKiC,MAAMrB,YAAY5O,QAC3BmR,KAAK,SAAA7N,GAAC,OAAIA,EAAElC,aAAa,aAAayI,WAAWzC,KAAU9D,EAAEoS,Y,+CAQlE,OAAO1H,KAAK2C,kB,iCAOZ,OAAO3C,KAAKuE,S,yCAQZ,OAAOvE,KAAKwE,a,gCAOZ,OAAOxE,KAAKiC,Q,gCAUZ,OAHAjC,KAAKP,OACLO,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAU8F,IAAI,YACzBpD,O,+BASP,OAFAA,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAUqG,OAAO,YAC5B3D,U,gCAKfV,EAAMqI,MAAQ5L,EAGduD,EAAMsI,KAAO,CACTjO,YACAoB,WACAwC,UACAL,cAIJoC,EAAMvO,OAAS,SAAAiB,GAAO,OAAI,IAAIsN,EAAMtN,IAGpCsN,EAAMuI,QAAU,QACDvI,e","file":"pickr.es5.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pickr\"] = factory();\n\telse\n\t\troot[\"Pickr\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Add event(s) to element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const on = eventListener.bind(null, 'addEventListener');\r\n\r\n/**\r\n * Remove event(s) from element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const off = eventListener.bind(null, 'removeEventListener');\r\n\r\nfunction eventListener(method, elements, events, fn, options = {}) {\r\n\r\n // Normalize array\r\n if (elements instanceof HTMLCollection || elements instanceof NodeList) {\r\n elements = Array.from(elements);\r\n } else if (!Array.isArray(elements)) {\r\n elements = [elements];\r\n }\r\n\r\n if (!Array.isArray(events)) {\r\n events = [events];\r\n }\r\n\r\n for (const el of elements) {\r\n for (const ev of events) {\r\n el[method](ev, fn, {capture: false, ...options});\r\n }\r\n }\r\n\r\n return Array.prototype.slice.call(arguments, 1);\r\n}\r\n\r\n/**\r\n * Creates an DOM-Element out of a string (Single element).\r\n * @param html HTML representing a single element\r\n * @returns {Element | null} The element.\r\n */\r\nexport function createElementFromString(html) {\r\n const div = document.createElement('div');\r\n div.innerHTML = html.trim();\r\n return div.firstElementChild;\r\n}\r\n\r\n/**\r\n * Removes an attribute from a HTMLElement and returns the value.\r\n * @param el\r\n * @param name\r\n * @return {string}\r\n */\r\nexport function removeAttribute(el, name) {\r\n const value = el.getAttribute(name);\r\n el.removeAttribute(name);\r\n return value;\r\n}\r\n\r\n/**\r\n * Creates a new html element, every element which has\r\n * a ':ref' attribute will be saved in a object (which will be returned)\r\n * where the value of ':ref' is the object-key and the value the HTMLElement.\r\n *\r\n * It's possible to create a hierarchy if you add a ':obj' attribute. Every\r\n * sibling will be added to the object which will get the name from the 'data-con' attribute.\r\n *\r\n * If you want to create an Array out of multiple elements, you can use the ':arr' attribute,\r\n * the value defines the key and all elements, which has the same parent and the same 'data-arr' attribute,\r\n * would be added to it.\r\n *\r\n * @param str - The HTML String.\r\n */\r\nexport function createFromTemplate(str) {\r\n\r\n // Recursive function to resolve template\r\n function resolve(element, base = {}) {\r\n\r\n // Check key and container attribute\r\n const con = removeAttribute(element, ':obj');\r\n const key = removeAttribute(element, ':ref');\r\n const subtree = con ? (base[con] = {}) : base;\r\n\r\n // Check and save element\r\n key && (base[key] = element);\r\n for (const child of Array.from(element.children)) {\r\n const arr = removeAttribute(child, ':arr');\r\n const sub = resolve(child, arr ? {} : subtree);\r\n\r\n if (arr) {\r\n\r\n // Check if there is already an array and add element\r\n (subtree[arr] || (subtree[arr] = []))\r\n .push(Object.keys(sub).length ? sub : child);\r\n }\r\n }\r\n\r\n return base;\r\n }\r\n\r\n return resolve(createElementFromString(str));\r\n}\r\n\r\n/**\r\n * Polyfill for safari & firefox for the eventPath event property.\r\n * @param evt The event object.\r\n * @return [String] event path.\r\n */\r\nexport function eventPath(evt) {\r\n let path = evt.path || (evt.composedPath && evt.composedPath());\r\n if (path) return path;\r\n\r\n let el = evt.target.parentElement;\r\n path = [evt.target, el];\r\n while (el = el.parentElement) path.push(el);\r\n\r\n path.push(document, window);\r\n return path;\r\n}\r\n\r\n/**\r\n * Resolves a HTMLElement by query.\r\n * @param val\r\n * @returns {null|Document|Element}\r\n */\r\nexport function resolveElement(val) {\r\n if (val instanceof Element) {\r\n return val;\r\n } else if (typeof val === 'string') {\r\n return val.split(/>>/g).reduce((pv, cv, ci, a) => {\r\n pv = pv.querySelector(cv);\r\n return ci < a.length - 1 ? pv.shadowRoot : pv;\r\n }, document);\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Creates the ability to change numbers in an input field with the scroll-wheel.\r\n * @param el\r\n * @param mapper\r\n */\r\nexport function adjustableInputNumbers(el, mapper = v => v) {\r\n\r\n function handleScroll(e) {\r\n const inc = ([0.001, 0.01, 0.1])[Number(e.shiftKey || e.ctrlKey * 2)] * (e.deltaY < 0 ? 1 : -1);\r\n\r\n let index = 0;\r\n let off = el.selectionStart;\r\n el.value = el.value.replace(/[\\d.]+/g, (v, i) => {\r\n\r\n // Check if number is in cursor range and increase it\r\n if (i <= off && i + v.length >= off) {\r\n off = i;\r\n return mapper(Number(v), inc, index);\r\n }\r\n\r\n index++;\r\n return v;\r\n });\r\n\r\n el.focus();\r\n el.setSelectionRange(off, off);\r\n\r\n // Prevent default and trigger input event\r\n e.preventDefault();\r\n el.dispatchEvent(new Event('input'));\r\n }\r\n\r\n // Bind events\r\n on(el, 'focus', () => on(window, 'wheel', handleScroll, {passive: false}));\r\n on(el, 'blur', () => off(window, 'wheel', handleScroll));\r\n}\r\n","// Shorthands\r\nconst {min, max, floor, round} = Math;\r\n\r\n/**\r\n * Tries to convert a color name to rgb/a hex representation\r\n * @param name\r\n * @returns {string | CanvasGradient | CanvasPattern}\r\n */\r\nfunction standardizeColor(name) {\r\n\r\n // Since invalid color's will be parsed as black, filter them out\r\n if (name.toLowerCase() === 'black') {\r\n return '#000000';\r\n }\r\n\r\n const ctx = document.createElement('canvas').getContext('2d');\r\n ctx.fillStyle = name;\r\n return ctx.fillStyle === '#000000' ? null : ctx.fillStyle;\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to RGB.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} Array with rgb values.\r\n */\r\nexport function hsvToRgb(h, s, v) {\r\n h = (h / 360) * 6;\r\n s /= 100;\r\n v /= 100;\r\n\r\n const i = floor(h);\r\n\r\n const f = h - i;\r\n const p = v * (1 - s);\r\n const q = v * (1 - f * s);\r\n const t = v * (1 - (1 - f) * s);\r\n\r\n const mod = i % 6;\r\n const r = [v, q, p, p, t, v][mod];\r\n const g = [t, v, v, q, p, p][mod];\r\n const b = [p, p, t, v, v, q][mod];\r\n\r\n return [\r\n r * 255,\r\n g * 255,\r\n b * 255\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to Hex.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {string[]} Hex values\r\n */\r\nexport function hsvToHex(h, s, v) {\r\n return hsvToRgb(h, s, v).map(v =>\r\n round(v).toString(16).padStart(2, '0')\r\n );\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to CMYK.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} CMYK values\r\n */\r\nexport function hsvToCmyk(h, s, v) {\r\n const rgb = hsvToRgb(h, s, v);\r\n const r = rgb[0] / 255;\r\n const g = rgb[1] / 255;\r\n const b = rgb[2] / 255;\r\n\r\n let k, c, m, y;\r\n\r\n k = min(1 - r, 1 - g, 1 - b);\r\n\r\n c = k === 1 ? 0 : (1 - r - k) / (1 - k);\r\n m = k === 1 ? 0 : (1 - g - k) / (1 - k);\r\n y = k === 1 ? 0 : (1 - b - k) / (1 - k);\r\n\r\n return [\r\n c * 100,\r\n m * 100,\r\n y * 100,\r\n k * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to HSL.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} HSL values\r\n */\r\nexport function hsvToHsl(h, s, v) {\r\n s /= 100, v /= 100;\r\n\r\n const l = (2 - s) * v / 2;\r\n\r\n if (l !== 0) {\r\n if (l === 1) {\r\n s = 0;\r\n } else if (l < 0.5) {\r\n s = s * v / (l * 2);\r\n } else {\r\n s = s * v / (2 - l * 2);\r\n }\r\n }\r\n\r\n return [\r\n h,\r\n s * 100,\r\n l * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert RGB to HSV.\r\n * @param r Red\r\n * @param g Green\r\n * @param b Blue\r\n * @return {number[]} HSV values.\r\n */\r\nfunction rgbToHsv(r, g, b) {\r\n r /= 255, g /= 255, b /= 255;\r\n\r\n let h, s, v;\r\n const minVal = min(r, g, b);\r\n const maxVal = max(r, g, b);\r\n const delta = maxVal - minVal;\r\n\r\n v = maxVal;\r\n if (delta === 0) {\r\n h = s = 0;\r\n } else {\r\n s = delta / maxVal;\r\n const dr = (((maxVal - r) / 6) + (delta / 2)) / delta;\r\n const dg = (((maxVal - g) / 6) + (delta / 2)) / delta;\r\n const db = (((maxVal - b) / 6) + (delta / 2)) / delta;\r\n\r\n if (r === maxVal) {\r\n h = db - dg;\r\n } else if (g === maxVal) {\r\n h = (1 / 3) + dr - db;\r\n } else if (b === maxVal) {\r\n h = (2 / 3) + dg - dr;\r\n }\r\n\r\n if (h < 0) {\r\n h += 1;\r\n } else if (h > 1) {\r\n h -= 1;\r\n }\r\n }\r\n\r\n return [\r\n h * 360,\r\n s * 100,\r\n v * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert CMYK to HSV.\r\n * @param c Cyan\r\n * @param m Magenta\r\n * @param y Yellow\r\n * @param k Key (Black)\r\n * @return {number[]} HSV values.\r\n */\r\nfunction cmykToHsv(c, m, y, k) {\r\n c /= 100;\r\n m /= 100;\r\n y /= 100;\r\n k /= 100;\r\n\r\n const r = (1 - min(1, c * (1 - k) + k)) * 255;\r\n const g = (1 - min(1, m * (1 - k) + k)) * 255;\r\n const b = (1 - min(1, y * (1 - k) + k)) * 255;\r\n\r\n return [...rgbToHsv(r, g, b)];\r\n}\r\n\r\n/**\r\n * Convert HSL to HSV.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param l Lightness\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hslToHsv(h, s, l) {\r\n s /= 100;\r\n l /= 100;\r\n s *= l < 0.5 ? l : 1 - l;\r\n\r\n const ns = (2 * s / (l + s)) * 100;\r\n const v = (l + s) * 100;\r\n return [h, ns, v];\r\n}\r\n\r\n/**\r\n * Convert HEX to HSV.\r\n * @param hex Hexadecimal string of rgb colors, can have length 3 or 6.\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hexToHsv(hex) {\r\n return rgbToHsv(...hex.match(/.{2}/g).map(v => parseInt(v, 16)));\r\n}\r\n\r\n/**\r\n * Try's to parse a string which represents a color to a HSV array.\r\n * Current supported types are cmyk, rgba, hsla and hexadecimal.\r\n * @param str\r\n * @return {*}\r\n */\r\nexport function parseToHSVA(str) {\r\n\r\n // Check if string is a color-name\r\n str = str.match(/^[a-zA-Z]+$/) ? standardizeColor(str) : str;\r\n\r\n // Regular expressions to match different types of color represention\r\n const regex = {\r\n cmyk: /^cmyk[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)/i,\r\n rgba: /^((rgba)|rgb)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsla: /^((hsla)|hsl)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsva: /^((hsva)|hsv)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hexa: /^#?(([\\dA-Fa-f]{3,4})|([\\dA-Fa-f]{6})|([\\dA-Fa-f]{8}))$/i\r\n };\r\n\r\n /**\r\n * Takes an Array of any type, convert strings which represents\r\n * a number to a number an anything else to undefined.\r\n * @param array\r\n * @return {*}\r\n */\r\n const numarize = array => array.map(v => /^(|\\d+)\\.\\d+|\\d+$/.test(v) ? Number(v) : undefined);\r\n\r\n let match;\r\n invalid: for (const type in regex) {\r\n\r\n // Check if current scheme passed\r\n if (!(match = regex[type].exec(str)))\r\n continue;\r\n\r\n // match[2] does only contain a truly value if rgba, hsla, or hsla got matched\r\n const alpha = !!match[2];\r\n\r\n // Try to convert\r\n switch (type) {\r\n case 'cmyk': {\r\n const [, c, m, y, k] = numarize(match);\r\n\r\n if (c > 100 || m > 100 || y > 100 || k > 100)\r\n break invalid;\r\n\r\n return {values: cmykToHsv(c, m, y, k), type};\r\n }\r\n case 'rgba': {\r\n const [, , , r, g, b, a] = numarize(match);\r\n\r\n if (r > 255 || g > 255 || b > 255 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...rgbToHsv(r, g, b), a], a, type};\r\n }\r\n case 'hexa': {\r\n let [, hex] = match;\r\n\r\n if (hex.length === 4 || hex.length === 3) {\r\n hex = hex.split('').map(v => v + v).join('');\r\n }\r\n\r\n const raw = hex.substring(0, 6);\r\n let a = hex.substring(6);\r\n\r\n // Convert 0 - 255 to 0 - 1 for opacity\r\n a = a ? (parseInt(a, 16) / 255) : undefined;\r\n\r\n return {values: [...hexToHsv(raw), a], a, type};\r\n }\r\n case 'hsla': {\r\n const [, , , h, s, l, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || l > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...hslToHsv(h, s, l), a], a, type};\r\n }\r\n case 'hsva': {\r\n const [, , , h, s, v, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || v > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [h, s, v, a], a, type};\r\n }\r\n }\r\n }\r\n\r\n return {values: null, type: null};\r\n}\r\n","import {hsvToHsl, hsvToRgb, hsvToCmyk, hsvToHex} from './color';\r\n\r\n/**\r\n * Simple class which holds the properties\r\n * of the color represention model hsla (hue saturation lightness alpha)\r\n */\r\nexport function HSVaColor(h = 0, s = 0, v = 0, a = 1) {\r\n const mapper = (original, next) => (precision = -1) => {\r\n return next(~precision ? original.map(v => Number(v.toFixed(precision))) : original);\r\n };\r\n\r\n const that = {\r\n h, s, v, a,\r\n\r\n toHSVA() {\r\n const hsva = [that.h, that.s, that.v, that.a];\r\n hsva.toString = mapper(hsva, arr => `hsva(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsva;\r\n },\r\n\r\n toHSLA() {\r\n const hsla = [...hsvToHsl(that.h, that.s, that.v), that.a];\r\n hsla.toString = mapper(hsla, arr => `hsla(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsla;\r\n },\r\n\r\n toRGBA() {\r\n const rgba = [...hsvToRgb(that.h, that.s, that.v), that.a];\r\n rgba.toString = mapper(rgba, arr => `rgba(${arr[0]}, ${arr[1]}, ${arr[2]}, ${that.a})`);\r\n return rgba;\r\n },\r\n\r\n toCMYK() {\r\n const cmyk = hsvToCmyk(that.h, that.s, that.v);\r\n cmyk.toString = mapper(cmyk, arr => `cmyk(${arr[0]}%, ${arr[1]}%, ${arr[2]}%, ${arr[3]}%)`);\r\n return cmyk;\r\n },\r\n\r\n toHEXA() {\r\n const hex = hsvToHex(that.h, that.s, that.v);\r\n\r\n // Check if alpha channel make sense, convert it to 255 number space, convert\r\n // to hex and pad it with zeros if needet.\r\n const alpha = that.a >= 1 ? '' : Number((that.a * 255).toFixed(0))\r\n .toString(16)\r\n .toUpperCase().padStart(2, '0');\r\n\r\n alpha && hex.push(alpha);\r\n hex.toString = () => `#${hex.join('').toUpperCase()}`;\r\n return hex;\r\n },\r\n\r\n clone: () => HSVaColor(that.h, that.s, that.v, that.a)\r\n };\r\n\r\n return that;\r\n}\r\n","import * as _ from '../utils/utils';\n\nconst clamp = v => Math.max(Math.min(v, 1), 0);\nexport default function Moveable(opt) {\n\n const that = {\n\n // Assign default values\n options: Object.assign({\n lock: null,\n onchange: () => 0,\n onstop: () => 0\n }, opt),\n\n _keyboard({type, key}) {\n\n // Check to see if the Movable is focused and then move it based on arrow key inputs\n // for improved accessibility\n if (document.activeElement === options.wrapper) {\n if (type === 'keydown') {\n let xm = 0;\n let ym = 0;\n\n switch (key) {\n case 'ArrowLeft':\n xm--;\n break;\n case 'ArrowRight':\n xm++;\n break;\n case 'ArrowUp':\n ym++;\n break;\n case 'ArrowDown':\n ym++;\n }\n\n that.update(\n clamp(that.cache.x + (0.01 * xm)),\n clamp(that.cache.y + (0.01 * ym))\n );\n } else if (key.startsWith('Arrow')) {\n that.options.onstop();\n }\n }\n },\n\n _tapstart(evt) {\n _.on(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\n _.on(document, ['mousemove', 'touchmove'], that._tapmove);\n\n // Prevent default touch event\n evt.preventDefault();\n\n // Trigger\n that._tapmove(evt);\n },\n\n _tapmove(evt) {\n const {options: {lock}, cache} = that;\n const {element, wrapper} = options;\n const b = wrapper.getBoundingClientRect();\n\n let x = 0, y = 0;\n if (evt) {\n const touch = evt && evt.touches && evt.touches[0];\n x = evt ? (touch || evt).clientX : 0;\n y = evt ? (touch || evt).clientY : 0;\n\n // Reset to bounds\n if (x < b.left) x = b.left;\n else if (x > b.left + b.width) x = b.left + b.width;\n if (y < b.top) y = b.top;\n else if (y > b.top + b.height) y = b.top + b.height;\n\n // Normalize\n x -= b.left;\n y -= b.top;\n } else if (cache) {\n x = cache.x * b.width;\n y = cache.y * b.height;\n }\n\n if (lock !== 'h') {\n element.style.left = `calc(${x / b.width * 100}% - ${element.offsetWidth / 2}px)`;\n }\n\n if (lock !== 'v') {\n element.style.top = `calc(${y / b.height * 100}% - ${element.offsetHeight / 2}px)`;\n }\n\n that.cache = {x: x / b.width, y: y / b.height};\n const cx = clamp(x / wrapper.offsetWidth);\n const cy = clamp(y / wrapper.offsetHeight);\n\n switch (lock) {\n case 'v':\n return options.onchange(cx);\n case 'h':\n return options.onchange(cy);\n default:\n return options.onchange(cx, cy);\n }\n },\n\n _tapstop() {\n that.options.onstop();\n _.off(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\n _.off(document, ['mousemove', 'touchmove'], that._tapmove);\n },\n\n trigger() {\n that._tapmove();\n },\n\n update(x = 0, y = 0) {\n const {left, top, width, height} = that.options.wrapper.getBoundingClientRect();\n\n if (that.options.lock === 'h') {\n y = x;\n }\n\n that._tapmove({\n clientX: left + width * x,\n clientY: top + height * y\n });\n },\n\n destroy() {\n const {options, _tapstart} = that;\n _.off([options.wrapper, options.element], 'mousedown', _tapstart);\n _.off([options.wrapper, options.element], 'touchstart', _tapstart, {\n passive: false\n });\n }\n };\n\n // Initilize\n const {options, _tapstart, _keyboard} = that;\n _.on([options.wrapper, options.element], 'mousedown', _tapstart);\n _.on([options.wrapper, options.element], 'touchstart', _tapstart, {\n passive: false\n });\n\n _.on(document, ['keydown', 'keyup'], _keyboard);\n\n\n return that;\n}\n","import * as _ from '../utils/utils';\r\n\r\nexport default function Selectable(opt = {}) {\r\n opt = Object.assign({\r\n onchange: () => 0,\r\n className: '',\r\n elements: []\r\n }, opt);\r\n\r\n const onTap = _.on(opt.elements, 'click', evt => {\r\n opt.elements.forEach(e =>\r\n e.classList[evt.target === e ? 'add' : 'remove'](opt.className)\r\n );\r\n\r\n opt.onchange(evt);\r\n });\r\n\r\n return {\r\n destroy: () => _.off(...onTap)\r\n };\r\n}\r\n","/**\r\n * Micro positioning-engine\r\n * @param el\r\n * @param reference\r\n * @param pos\r\n * @param padding\r\n * @returns {{update(): void}}\r\n * @constructor\r\n */\r\nexport default function Nanopop({el, reference, padding = 8}) {\r\n const vBehaviour = {start: 'sme', middle: 'mse', end: 'ems'};\r\n const hBehaviour = {top: 'tbrl', right: 'rltb', bottom: 'btrl', left: 'lrbt'};\r\n\r\n const getInfo = ((cache = {}) => (pos, cached = cache[pos]) => {\r\n if (cached) return cached;\r\n const [position, variant = 'middle'] = pos.split('-');\r\n const isVertical = (position === 'top' || position === 'bottom');\r\n\r\n return cache[pos] = {\r\n position,\r\n variant,\r\n isVertical\r\n };\r\n })();\r\n\r\n return {\r\n update(pos) {\r\n const {position, variant, isVertical} = getInfo(pos);\r\n const rb = reference.getBoundingClientRect();\r\n const eb = el.getBoundingClientRect();\r\n\r\n const positions = vertical => vertical ? {\r\n t: rb.top - eb.height - padding,\r\n b: rb.bottom + padding\r\n } : {\r\n r: rb.right + padding,\r\n l: rb.left - eb.width - padding\r\n };\r\n\r\n const variants = vertical => vertical ? {\r\n s: rb.left + rb.width - eb.width,\r\n m: (-eb.width / 2) + (rb.left + rb.width / 2),\r\n e: rb.left\r\n } : {\r\n s: rb.bottom - eb.height,\r\n m: rb.bottom - rb.height / 2 - eb.height / 2,\r\n e: rb.bottom - rb.height\r\n };\r\n\r\n const leastApplied = {};\r\n\r\n function apply(bevs, vars, styleprop) {\r\n const vertical = styleprop === 'top';\r\n const adder = vertical ? eb.height : eb.width;\r\n const win = window[vertical ? 'innerHeight' : 'innerWidth'];\r\n\r\n for (const ch of bevs) {\r\n const v = vars[ch];\r\n const sv = leastApplied[styleprop] = `${v}px`;\r\n\r\n if (v > 0 && (v + adder) < win) {\r\n el.style[styleprop] = sv;\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n for (const rot of [isVertical, !isVertical]) {\r\n const v2Ok = apply(hBehaviour[position], positions(rot), rot ? 'top' : 'left');\r\n const v1Ok = apply(vBehaviour[variant], variants(rot), rot ? 'left' : 'top');\r\n\r\n if (v2Ok && v1Ok) {\r\n return;\r\n }\r\n }\r\n\r\n el.style.left = leastApplied.left;\r\n el.style.top = leastApplied.top;\r\n }\r\n };\r\n}\r\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr({...opt, t: this._t});\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return this.options.i18n[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pickr.min.js b/dist/pickr.min.js index 82686c11..c805c3f6 100644 --- a/dist/pickr.min.js +++ b/dist/pickr.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e);var n={};function i(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function r(t){for(var e=1;e>/g).reduce((t,e,o,n)=>(t=t.querySelector(e),ot)){function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,r=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,o)=>o<=r&&o+t.length>=r?(r=o,e(Number(t),n,i)):(i++,t)),t.focus(),t.setSelectionRange(r,r),o.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",()=>c(window,"wheel",o,{passive:!1})),c(t,"blur",()=>a(window,"wheel",o))}const{min:v,max:b,floor:g,round:y}=Math;function _(t,e,o){e/=100,o/=100;const n=g(t=t/360*6),i=t-n,r=o*(1-e),s=o*(1-i*e),c=o*(1-(1-i)*e),a=n%6;return[255*[o,s,r,r,c,o][a],255*[c,o,o,s,r,r][a],255*[r,r,c,o,o,s][a]]}function w(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function C(t,e,o){let n,i,r;const s=v(t/=255,e/=255,o/=255),c=b(t,e,o),a=c-s;if(0===a)n=i=0;else{i=a/c;const r=((c-t)/6+a/2)/a,s=((c-e)/6+a/2)/a,l=((c-o)/6+a/2)/a;t===c?n=l-s:e===c?n=1/3+r-l:o===c&&(n=2/3+s-r),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(r=c)]}function A(t,e,o,n){return e/=100,o/=100,[...C(255*(1-v(1,(t/=100)*(1-(n/=100))+n)),255*(1-v(1,e*(1-n)+n)),255*(1-v(1,o*(1-n)+n)))]}function k(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function S(t){return C(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function O(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const r=!!n[2];switch(i){case"cmyk":{const[,t,e,r,s]=o(n);if(t>100||e>100||r>100||s>100)break t;return{values:A(t,e,r,s),type:i}}case"rgba":{const[,,,t,e,s,c]=o(n);if(t>255||e>255||s>255||c<0||c>1||r===!c)break t;return{values:[...C(t,e,s),c],a:c,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map(t=>t+t).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...S(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[...k(t,e,s),c],a:c,type:i}}case"hsva":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[t,e,s,c],a:c,type:i}}}}return{values:null,type:null}}function j(t=0,e=0,o=0,n=1){const i=(t,e)=>(o=-1)=>e(~o?t.map(t=>Number(t.toFixed(o))):t),r={h:t,s:e,v:o,a:n,toHSVA(){const t=[r.h,r.s,r.v,r.a];return t.toString=i(t,t=>"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toHSLA(){const t=[...w(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toRGBA(){const t=[..._(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(r.a,")")),t},toCMYK(){const t=function(t,e,o){const n=_(t,e,o),i=n[0]/255,r=n[1]/255,s=n[2]/255;let c,a,l,p;return[100*(a=1===(c=v(1-i,1-r,1-s))?0:(1-i-c)/(1-c)),100*(l=1===c?0:(1-r-c)/(1-c)),100*(p=1===c?0:(1-s-c)/(1-c)),100*c]}(r.h,r.s,r.v);return t.toString=i(t,t=>"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")),t},toHEXA(){const t=function(t,e,o){return _(t,e,o).map(t=>y(t).toString(16).padStart(2,"0"))}(r.h,r.s,r.v),e=r.a>=1?"":Number((255*r.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>"#".concat(t.join("").toUpperCase()),t},clone:()=>j(r.h,r.s,r.v,r.a)};return r}const x=t=>Math.max(Math.min(t,1),0);function E(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard({type:t,key:n}){if(document.activeElement===o.wrapper)if("keydown"===t){let t=0,o=0;switch(n){case"ArrowLeft":t--;break;case"ArrowRight":t++;break;case"ArrowUp":o++;break;case"ArrowDown":o++}e.update(x(e.cache.x+.01*t),x(e.cache.y+.01*o))}else n.startsWith("Arrow")&&e.options.onstop()},_tapstart(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:{lock:n},cache:i}=e,{element:r,wrapper:s}=o,c=s.getBoundingClientRect();let a=0,l=0;if(t){const e=t&&t.touches&&t.touches[0];a=t?(e||t).clientX:0,l=t?(e||t).clientY:0,ac.left+c.width&&(a=c.left+c.width),lc.top+c.height&&(l=c.top+c.height),a-=c.left,l-=c.top}else i&&(a=i.x*c.width,l=i.y*c.height);"h"!==n&&(r.style.left="calc(".concat(a/c.width*100,"% - ").concat(r.offsetWidth/2,"px)")),"v"!==n&&(r.style.top="calc(".concat(l/c.height*100,"% - ").concat(r.offsetHeight/2,"px)")),e.cache={x:a/c.width,y:l/c.height};const p=x(a/s.offsetWidth),u=x(l/s.offsetHeight);switch(n){case"v":return o.onchange(p);case"h":return o.onchange(u);default:return o.onchange(p,u)}},_tapstop(){e.options.onstop(),a(document,["mouseup","touchend","touchcancel"],e._tapstop),a(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(t=0,o=0){const{left:n,top:i,width:r,height:s}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+r*t,clientY:i+s*o})},destroy(){const{options:t,_tapstart:o}=e;a([t.wrapper,t.element],"mousedown",o),a([t.wrapper,t.element],"touchstart",o,{passive:!1})}},{options:o,_tapstart:n,_keyboard:i}=e;return c([o.wrapper,o.element],"mousedown",n),c([o.wrapper,o.element],"touchstart",n,{passive:!1}),c(document,["keydown","keyup"],i),e}function L(t={}){t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=c(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)});return{destroy:()=>a(...e)}}function P({el:t,reference:e,padding:o=8}){const n={start:"sme",middle:"mse",end:"ems"},i={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},r=((t={})=>(e,o=t[e])=>{if(o)return o;const[n,i="middle"]=e.split("-"),r="top"===n||"bottom"===n;return t[e]={position:n,variant:i,isVertical:r}})();return{update(s){const{position:c,variant:a,isVertical:l}=r(s),p=e.getBoundingClientRect(),u=t.getBoundingClientRect(),h=t=>t?{t:p.top-u.height-o,b:p.bottom+o}:{r:p.right+o,l:p.left-u.width-o},d=t=>t?{s:p.left+p.width-u.width,m:-u.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-u.height,m:p.bottom-p.height/2-u.height/2,e:p.bottom-p.height},f={};function m(e,o,n){const i="top"===n,r=i?u.height:u.width,s=window[i?"innerHeight":"innerWidth"];for(const i of e){const e=o[i],c=f[n]="".concat(e,"px");if(e>0&&e+r{const c=t=>t?"":'style="display:none" hidden',a=h('\n
\n\n '.concat(o?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},strings:{},swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label","toggle color picker dialog");const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:E({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:E({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function D(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=L({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(function(t){for(var e=1;ethis._color||(this._color=this._lastColor.clone()),s={palette:x({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:x({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:x({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:E({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=S(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return this.options.i18n[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p(''}\r\n\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
\r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n `);\r\n\r\n const int = root.interaction;\r\n\r\n // Select option which is not hidden\r\n int.options.find(o => !o.hidden && !o.classList.add('active'));\r\n\r\n // Create method to find currenlty active option\r\n int.type = () => int.options.find(e => e.classList.contains('active'));\r\n return root;\r\n}\r\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n strings: {},\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', 'toggle color picker dialog');\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr({...opt, t: this._t});\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return this.options.i18n[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'} -
+
- +
-
+
-
+
-
+
@@ -42,9 +42,9 @@ export default ({components: c, strings: s, useAsButton, inline, appClass, theme - - - + + +
From 3d1d4405ea36d0cef47c4d9b631ed7783c92aa5e Mon Sep 17 00:00:00 2001 From: Simon Reinisch Date: Tue, 3 Sep 2019 21:30:57 +0200 Subject: [PATCH 2/8] Reduce usage of spread operator to create a smaller bundle --- dist/pickr.es5.min.js | 2 +- dist/pickr.es5.min.js.map | 2 +- dist/pickr.min.js | 2 +- dist/pickr.min.js.map | 2 +- src/js/pickr.js | 2 +- src/js/template.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/pickr.es5.min.js b/dist/pickr.es5.min.js index 130e4c2e..2b9fe735 100644 --- a/dist/pickr.es5.min.js +++ b/dist/pickr.es5.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r={};function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function i(t){for(var e=1;e4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(n)||(n=[n]);var a=!0,c=!1,l=void 0;try{for(var s,u=e[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){var p=s.value,h=!0,f=!1,d=void 0;try{for(var v,y=n[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var b=v.value;p[t](b,r,i({capture:!1},o))}}catch(t){f=!0,d=t}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}}}catch(t){c=!0,l=t}finally{try{a||null==u.return||u.return()}finally{if(c)throw l}}return Array.prototype.slice.call(arguments,1)}function u(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function p(t,e){var n=t.getAttribute(e);return t.removeAttribute(e),n}function h(t){return function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=p(e,":obj"),o=p(e,":ref"),i=r?n[r]={}:n;o&&(n[o]=e);for(var a=0,c=Array.from(e.children);a>/g).reduce(function(t,e,n,r){return t=t.querySelector(e),n1&&void 0!==arguments[1]?arguments[1]:function(t){return t};function n(n){var r=[.001,.01,.1][Number(n.shiftKey||2*n.ctrlKey)]*(n.deltaY<0?1:-1),o=0,i=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,function(t,n){return n<=i&&n+t.length>=i?(i=n,e(Number(t),r,o)):(o++,t)}),t.focus(),t.setSelectionRange(i,i),n.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",function(){return c(window,"wheel",n,{passive:!1})}),c(t,"blur",function(){return l(window,"wheel",n)})}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(r-=1)}return[360*r,100*o,100*a]}function C(t,e,n,r){return e/=100,n/=100,b(A(255*(1-m(1,(t/=100)*(1-(r/=100))+r)),255*(1-m(1,e*(1-r)+r)),255*(1-m(1,n*(1-r)+r))))}function O(t,e,n){return e/=100,[t,2*(e*=(n/=100)<.5?n:1-n)/(n+e)*100,100*(n+e)]}function S(t){return A.apply(void 0,b(t.match(/.{2}/g).map(function(t){return parseInt(t,16)})))}function j(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";var e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;var e,n={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},r=function(t){return t.map(function(t){return/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0})};t:for(var o in n)if(e=n[o].exec(t)){var i=!!e[2];switch(o){case"cmyk":var a=y(r(e),5),c=a[1],l=a[2],s=a[3],u=a[4];if(c>100||l>100||s>100||u>100)break t;return{values:C(c,l,s,u),type:o};case"rgba":var p=y(r(e),7),h=p[3],f=p[4],d=p[5],v=p[6];if(h>255||f>255||d>255||v<0||v>1||i===!v)break t;return{values:[].concat(b(A(h,f,d)),[v]),a:v,type:o};case"hexa":var m=y(e,2)[1];4!==m.length&&3!==m.length||(m=m.split("").map(function(t){return t+t}).join(""));var g=m.substring(0,6),w=m.substring(6);return w=w?parseInt(w,16)/255:void 0,{values:[].concat(b(S(g)),[w]),a:w,type:o};case"hsla":var _=y(r(e),7),k=_[3],j=_[4],x=_[5],E=_[6];if(k>360||j>100||x>100||E<0||E>1||i===!E)break t;return{values:[].concat(b(O(k,j,x)),[E]),a:E,type:o};case"hsva":var P=y(r(e),7),L=P[3],B=P[4],D=P[5],R=P[6];if(L>360||B>100||D>100||R<0||R>1||i===!R)break t;return{values:[L,B,D,R],a:R,type:o}}}return{values:null,type:null}}function x(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=function(t,e){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~n?t.map(function(t){return Number(t.toFixed(n))}):t)}},i={h:t,s:e,v:n,a:r,toHSVA:function(){var t=[i.h,i.s,i.v,i.a];return t.toString=o(t,function(t){return"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toHSLA:function(){var t=[].concat(x(function(t,e,n){var r=(2-(e/=100))*(n/=100)/2;return 0!==r&&(e=1===r?0:r<.5?e*n/(2*r):e*n/(2-2*r)),[t,100*e,100*r]}(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toRGBA:function(){var t=[].concat(x(k(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(i.a,")")}),t},toCMYK:function(){var t=function(t,e,n){var r,o=k(t,e,n),i=o[0]/255,a=o[1]/255,c=o[2]/255;return[100*(1===(r=m(1-i,1-a,1-c))?0:(1-i-r)/(1-r)),100*(1===r?0:(1-a-r)/(1-r)),100*(1===r?0:(1-c-r)/(1-r)),100*r]}(i.h,i.s,i.v);return t.toString=o(t,function(t){return"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")}),t},toHEXA:function(){var t=function(t,e,n){return k(t,e,n).map(function(t){return _(t).toString(16).padStart(2,"0")})}(i.h,i.s,i.v),e=i.a>=1?"":Number((255*i.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=function(){return"#".concat(t.join("").toUpperCase())},t},clone:function(){return E(i.h,i.s,i.v,i.a)}};return i}var P=function(t){return Math.max(Math.min(t,1),0)};function L(t){var e={options:Object.assign({lock:null,onchange:function(){return 0},onstop:function(){return 0}},t),_keyboard:function(t){var r=t.type,o=t.key;if(document.activeElement===n.wrapper)if("keydown"===r){var i=0,a=0;switch(o){case"ArrowLeft":i--;break;case"ArrowRight":i++;break;case"ArrowUp":a++;break;case"ArrowDown":a++}e.update(P(e.cache.x+.01*i),P(e.cache.y+.01*a))}else o.startsWith("Arrow")&&e.options.onstop()},_tapstart:function(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove:function(t){var r=e.options.lock,o=e.cache,i=n.element,a=n.wrapper,c=a.getBoundingClientRect(),l=0,s=0;if(t){var u=t&&t.touches&&t.touches[0];l=t?(u||t).clientX:0,s=t?(u||t).clientY:0,lc.left+c.width&&(l=c.left+c.width),sc.top+c.height&&(s=c.top+c.height),l-=c.left,s-=c.top}else o&&(l=o.x*c.width,s=o.y*c.height);"h"!==r&&(i.style.left="calc(".concat(l/c.width*100,"% - ").concat(i.offsetWidth/2,"px)")),"v"!==r&&(i.style.top="calc(".concat(s/c.height*100,"% - ").concat(i.offsetHeight/2,"px)")),e.cache={x:l/c.width,y:s/c.height};var p=P(l/a.offsetWidth),h=P(s/a.offsetHeight);switch(r){case"v":return n.onchange(p);case"h":return n.onchange(h);default:return n.onchange(p,h)}},_tapstop:function(){e.options.onstop(),l(document,["mouseup","touchend","touchcancel"],e._tapstop),l(document,["mousemove","touchmove"],e._tapmove)},trigger:function(){e._tapmove()},update:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.options.wrapper.getBoundingClientRect(),o=r.left,i=r.top,a=r.width,c=r.height;"h"===e.options.lock&&(n=t),e._tapmove({clientX:o+a*t,clientY:i+c*n})},destroy:function(){var t=e.options,n=e._tapstart;l([t.wrapper,t.element],"mousedown",n),l([t.wrapper,t.element],"touchstart",n,{passive:!1})}},n=e.options,r=e._tapstart,o=e._keyboard;return c([n.wrapper,n.element],"mousedown",r),c([n.wrapper,n.element],"touchstart",r,{passive:!1}),c(document,["keydown","keyup"],o),e}function B(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:function(){return 0},className:"",elements:[]},t);var e=c(t.elements,"click",function(e){t.elements.forEach(function(n){return n.classList[e.target===n?"add":"remove"](t.className)}),t.onchange(e)});return{destroy:function(){return l.apply(r,B(e))}}}function R(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function H(t){var e=t.el,n=t.reference,r=t.padding,o=void 0===r?8:r,i={start:"sme",middle:"mse",end:"ems"},a={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[e];if(n)return n;var r=e.split("-"),o=R(r,2),i=o[0],a=o[1],c=void 0===a?"middle":a,l="top"===i||"bottom"===i;return t[e]={position:i,variant:c,isVertical:l}}}();return{update:function(t){var r=c(t),l=r.position,s=r.variant,u=r.isVertical,p=n.getBoundingClientRect(),h=e.getBoundingClientRect(),f=function(t){return t?{s:p.left+p.width-h.width,m:-h.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-h.height,m:p.bottom-p.height/2-h.height/2,e:p.bottom-p.height}},d={};function v(t,n,r){var o="top"===r,i=o?h.height:h.width,a=window[o?"innerHeight":"innerWidth"],c=!0,l=!1,s=void 0;try{for(var u,p=t[Symbol.iterator]();!(c=(u=p.next()).done);c=!0){var f=n[u.value],v=d[r]="".concat(f,"px");if(f>0&&f+i\n\n '.concat(r?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:L({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,b=v.color;y.classList[s===b.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:L({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:L({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:D({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return this.options.i18n[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=E.apply(void 0,M(n)),a=u('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return this.options.i18n[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=E.apply(void 0,M(n)),a=u(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/js/utils/utils.js","webpack:///./src/js/utils/color.js","webpack:///./src/js/utils/hsvacolor.js","webpack:///./src/js/libs/moveable.js","webpack:///./src/js/libs/selectable.js","webpack:///./src/js/libs/nanopop.js","webpack:///./src/js/pickr.js","webpack:///./src/js/template.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","on","eventListener","off","method","elements","events","fn","options","HTMLCollection","NodeList","Array","from","isArray","el","ev","capture","slice","arguments","createElementFromString","html","div","document","createElement","innerHTML","trim","firstElementChild","removeAttribute","getAttribute","createFromTemplate","str","resolve","element","base","con","subtree","children","child","arr","sub","push","keys","length","eventPath","evt","path","composedPath","target","parentElement","resolveElement","val","Element","split","reduce","pv","cv","ci","a","querySelector","shadowRoot","adjustableInputNumbers","mapper","v","handleScroll","e","inc","Number","shiftKey","ctrlKey","deltaY","index","selectionStart","replace","focus","setSelectionRange","preventDefault","dispatchEvent","Event","passive","min","Math","max","floor","round","hsvToRgb","h","f","q","mod","rgbToHsv","g","b","minVal","maxVal","delta","dr","dg","db","cmykToHsv","y","k","hslToHsv","hexToHsv","hex","match","map","parseInt","parseToHSVA","toLowerCase","ctx","getContext","fillStyle","standardizeColor","regex","cmyk","rgba","hsla","hsva","hexa","numarize","array","test","undefined","invalid","type","exec","alpha","values","join","raw","substring","HSVaColor","original","next","precision","toFixed","that","toHSVA","toString","toHSLA","hsvToHsl","toRGBA","toCMYK","rgb","hsvToCmyk","toHEXA","padStart","hsvToHex","toUpperCase","clone","clamp","Moveable","opt","assign","lock","onchange","onstop","_keyboard","activeElement","wrapper","xm","ym","update","cache","x","startsWith","_tapstart","_","_tapstop","_tapmove","getBoundingClientRect","touch","touches","clientX","clientY","left","width","top","height","style","offsetWidth","offsetHeight","cx","cy","trigger","destroy","Selectable","className","onTap","forEach","classList","Nanopop","reference","padding","vBehaviour","start","middle","end","hBehaviour","right","bottom","getInfo","pos","cached","position","variant","isVertical","rb","eb","variants","vertical","leastApplied","apply","bevs","vars","styleprop","adder","win","sv","rot","v2Ok","v1Ok","Pickr","init","save","hide","show","clear","change","changestop","cancel","swatchselect","this","appClass","theme","useAsButton","disabled","comparison","closeOnScroll","outputPrecision","lockOpacity","autoReposition","container","components","interaction","i18n","swatches","inline","sliders","default","defaultRepresentation","adjustableNumbers","showAlways","closeWithKey","includes","preview","opacity","hue","palette","_preBuild","_buildComponents","_bindEvents","_finalBuild","color","addSwatch","_root","button","app","_nanopop","setAttribute","_t","requestAnimationFrame","cb","setColor","_rePositioningPicker","_representation","setColorRepresentation","_initializingActive","_emit","lo","hidden","int","input","find","add","contains","appendChild","removeChild","parent","nextSibling","insertBefore","remove","parentNode","replaceChild","disable","transition","lastColor","inst","cs","repeat","so","sh","getColor","_color","_lastColor","picker","_recalc","_updateOutput","cssRGBaString","background","_swatchColors","currentColor","slider","backgroundColor","selectable","_components","eventBindings","_clearColor","setHSVA","applyColor","result","stopImmediatePropagation","ck","isOpen","code","some","ranges","step","range","getColorRepresentation","nv","toPrecision","timeout","setTimeout","rs","clearTimeout","_eventBindings","matchMedia","matches","margin","silent","alphaMakesAChange","event","args","_eventListener","def","callBacks","indexOf","splice","_parseLocalColor","swatchColor","recalc","string","utype","click","utils","libs","version"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,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sN,EAAMtN,IAGpCsN,EAAMuI,QAAU,QACDvI,e","file":"pickr.es5.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pickr\"] = factory();\n\telse\n\t\troot[\"Pickr\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Add event(s) to element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const on = eventListener.bind(null, 'addEventListener');\r\n\r\n/**\r\n * Remove event(s) from element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const off = eventListener.bind(null, 'removeEventListener');\r\n\r\nfunction eventListener(method, elements, events, fn, options = {}) {\r\n\r\n // Normalize array\r\n if (elements instanceof HTMLCollection || elements instanceof NodeList) {\r\n elements = Array.from(elements);\r\n } else if (!Array.isArray(elements)) {\r\n elements = [elements];\r\n }\r\n\r\n if (!Array.isArray(events)) {\r\n events = [events];\r\n }\r\n\r\n for (const el of elements) {\r\n for (const ev of events) {\r\n el[method](ev, fn, {capture: false, ...options});\r\n }\r\n }\r\n\r\n return Array.prototype.slice.call(arguments, 1);\r\n}\r\n\r\n/**\r\n * Creates an DOM-Element out of a string (Single element).\r\n * @param html HTML representing a single element\r\n * @returns {Element | null} The element.\r\n */\r\nexport function createElementFromString(html) {\r\n const div = document.createElement('div');\r\n div.innerHTML = html.trim();\r\n return div.firstElementChild;\r\n}\r\n\r\n/**\r\n * Removes an attribute from a HTMLElement and returns the value.\r\n * @param el\r\n * @param name\r\n * @return {string}\r\n */\r\nexport function removeAttribute(el, name) {\r\n const value = el.getAttribute(name);\r\n el.removeAttribute(name);\r\n return value;\r\n}\r\n\r\n/**\r\n * Creates a new html element, every element which has\r\n * a ':ref' attribute will be saved in a object (which will be returned)\r\n * where the value of ':ref' is the object-key and the value the HTMLElement.\r\n *\r\n * It's possible to create a hierarchy if you add a ':obj' attribute. Every\r\n * sibling will be added to the object which will get the name from the 'data-con' attribute.\r\n *\r\n * If you want to create an Array out of multiple elements, you can use the ':arr' attribute,\r\n * the value defines the key and all elements, which has the same parent and the same 'data-arr' attribute,\r\n * would be added to it.\r\n *\r\n * @param str - The HTML String.\r\n */\r\nexport function createFromTemplate(str) {\r\n\r\n // Recursive function to resolve template\r\n function resolve(element, base = {}) {\r\n\r\n // Check key and container attribute\r\n const con = removeAttribute(element, ':obj');\r\n const key = removeAttribute(element, ':ref');\r\n const subtree = con ? (base[con] = {}) : base;\r\n\r\n // Check and save element\r\n key && (base[key] = element);\r\n for (const child of Array.from(element.children)) {\r\n const arr = removeAttribute(child, ':arr');\r\n const sub = resolve(child, arr ? {} : subtree);\r\n\r\n if (arr) {\r\n\r\n // Check if there is already an array and add element\r\n (subtree[arr] || (subtree[arr] = []))\r\n .push(Object.keys(sub).length ? sub : child);\r\n }\r\n }\r\n\r\n return base;\r\n }\r\n\r\n return resolve(createElementFromString(str));\r\n}\r\n\r\n/**\r\n * Polyfill for safari & firefox for the eventPath event property.\r\n * @param evt The event object.\r\n * @return [String] event path.\r\n */\r\nexport function eventPath(evt) {\r\n let path = evt.path || (evt.composedPath && evt.composedPath());\r\n if (path) return path;\r\n\r\n let el = evt.target.parentElement;\r\n path = [evt.target, el];\r\n while (el = el.parentElement) path.push(el);\r\n\r\n path.push(document, window);\r\n return path;\r\n}\r\n\r\n/**\r\n * Resolves a HTMLElement by query.\r\n * @param val\r\n * @returns {null|Document|Element}\r\n */\r\nexport function resolveElement(val) {\r\n if (val instanceof Element) {\r\n return val;\r\n } else if (typeof val === 'string') {\r\n return val.split(/>>/g).reduce((pv, cv, ci, a) => {\r\n pv = pv.querySelector(cv);\r\n return ci < a.length - 1 ? pv.shadowRoot : pv;\r\n }, document);\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Creates the ability to change numbers in an input field with the scroll-wheel.\r\n * @param el\r\n * @param mapper\r\n */\r\nexport function adjustableInputNumbers(el, mapper = v => v) {\r\n\r\n function handleScroll(e) {\r\n const inc = ([0.001, 0.01, 0.1])[Number(e.shiftKey || e.ctrlKey * 2)] * (e.deltaY < 0 ? 1 : -1);\r\n\r\n let index = 0;\r\n let off = el.selectionStart;\r\n el.value = el.value.replace(/[\\d.]+/g, (v, i) => {\r\n\r\n // Check if number is in cursor range and increase it\r\n if (i <= off && i + v.length >= off) {\r\n off = i;\r\n return mapper(Number(v), inc, index);\r\n }\r\n\r\n index++;\r\n return v;\r\n });\r\n\r\n el.focus();\r\n el.setSelectionRange(off, off);\r\n\r\n // Prevent default and trigger input event\r\n e.preventDefault();\r\n el.dispatchEvent(new Event('input'));\r\n }\r\n\r\n // Bind events\r\n on(el, 'focus', () => on(window, 'wheel', handleScroll, {passive: false}));\r\n on(el, 'blur', () => off(window, 'wheel', handleScroll));\r\n}\r\n","// Shorthands\r\nconst {min, max, floor, round} = Math;\r\n\r\n/**\r\n * Tries to convert a color name to rgb/a hex representation\r\n * @param name\r\n * @returns {string | CanvasGradient | CanvasPattern}\r\n */\r\nfunction standardizeColor(name) {\r\n\r\n // Since invalid color's will be parsed as black, filter them out\r\n if (name.toLowerCase() === 'black') {\r\n return '#000000';\r\n }\r\n\r\n const ctx = document.createElement('canvas').getContext('2d');\r\n ctx.fillStyle = name;\r\n return ctx.fillStyle === '#000000' ? null : ctx.fillStyle;\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to RGB.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} Array with rgb values.\r\n */\r\nexport function hsvToRgb(h, s, v) {\r\n h = (h / 360) * 6;\r\n s /= 100;\r\n v /= 100;\r\n\r\n const i = floor(h);\r\n\r\n const f = h - i;\r\n const p = v * (1 - s);\r\n const q = v * (1 - f * s);\r\n const t = v * (1 - (1 - f) * s);\r\n\r\n const mod = i % 6;\r\n const r = [v, q, p, p, t, v][mod];\r\n const g = [t, v, v, q, p, p][mod];\r\n const b = [p, p, t, v, v, q][mod];\r\n\r\n return [\r\n r * 255,\r\n g * 255,\r\n b * 255\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to Hex.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {string[]} Hex values\r\n */\r\nexport function hsvToHex(h, s, v) {\r\n return hsvToRgb(h, s, v).map(v =>\r\n round(v).toString(16).padStart(2, '0')\r\n );\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to CMYK.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} CMYK values\r\n */\r\nexport function hsvToCmyk(h, s, v) {\r\n const rgb = hsvToRgb(h, s, v);\r\n const r = rgb[0] / 255;\r\n const g = rgb[1] / 255;\r\n const b = rgb[2] / 255;\r\n\r\n let k, c, m, y;\r\n\r\n k = min(1 - r, 1 - g, 1 - b);\r\n\r\n c = k === 1 ? 0 : (1 - r - k) / (1 - k);\r\n m = k === 1 ? 0 : (1 - g - k) / (1 - k);\r\n y = k === 1 ? 0 : (1 - b - k) / (1 - k);\r\n\r\n return [\r\n c * 100,\r\n m * 100,\r\n y * 100,\r\n k * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to HSL.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} HSL values\r\n */\r\nexport function hsvToHsl(h, s, v) {\r\n s /= 100, v /= 100;\r\n\r\n const l = (2 - s) * v / 2;\r\n\r\n if (l !== 0) {\r\n if (l === 1) {\r\n s = 0;\r\n } else if (l < 0.5) {\r\n s = s * v / (l * 2);\r\n } else {\r\n s = s * v / (2 - l * 2);\r\n }\r\n }\r\n\r\n return [\r\n h,\r\n s * 100,\r\n l * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert RGB to HSV.\r\n * @param r Red\r\n * @param g Green\r\n * @param b Blue\r\n * @return {number[]} HSV values.\r\n */\r\nfunction rgbToHsv(r, g, b) {\r\n r /= 255, g /= 255, b /= 255;\r\n\r\n let h, s, v;\r\n const minVal = min(r, g, b);\r\n const maxVal = max(r, g, b);\r\n const delta = maxVal - minVal;\r\n\r\n v = maxVal;\r\n if (delta === 0) {\r\n h = s = 0;\r\n } else {\r\n s = delta / maxVal;\r\n const dr = (((maxVal - r) / 6) + (delta / 2)) / delta;\r\n const dg = (((maxVal - g) / 6) + (delta / 2)) / delta;\r\n const db = (((maxVal - b) / 6) + (delta / 2)) / delta;\r\n\r\n if (r === maxVal) {\r\n h = db - dg;\r\n } else if (g === maxVal) {\r\n h = (1 / 3) + dr - db;\r\n } else if (b === maxVal) {\r\n h = (2 / 3) + dg - dr;\r\n }\r\n\r\n if (h < 0) {\r\n h += 1;\r\n } else if (h > 1) {\r\n h -= 1;\r\n }\r\n }\r\n\r\n return [\r\n h * 360,\r\n s * 100,\r\n v * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert CMYK to HSV.\r\n * @param c Cyan\r\n * @param m Magenta\r\n * @param y Yellow\r\n * @param k Key (Black)\r\n * @return {number[]} HSV values.\r\n */\r\nfunction cmykToHsv(c, m, y, k) {\r\n c /= 100;\r\n m /= 100;\r\n y /= 100;\r\n k /= 100;\r\n\r\n const r = (1 - min(1, c * (1 - k) + k)) * 255;\r\n const g = (1 - min(1, m * (1 - k) + k)) * 255;\r\n const b = (1 - min(1, y * (1 - k) + k)) * 255;\r\n\r\n return [...rgbToHsv(r, g, b)];\r\n}\r\n\r\n/**\r\n * Convert HSL to HSV.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param l Lightness\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hslToHsv(h, s, l) {\r\n s /= 100;\r\n l /= 100;\r\n s *= l < 0.5 ? l : 1 - l;\r\n\r\n const ns = (2 * s / (l + s)) * 100;\r\n const v = (l + s) * 100;\r\n return [h, ns, v];\r\n}\r\n\r\n/**\r\n * Convert HEX to HSV.\r\n * @param hex Hexadecimal string of rgb colors, can have length 3 or 6.\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hexToHsv(hex) {\r\n return rgbToHsv(...hex.match(/.{2}/g).map(v => parseInt(v, 16)));\r\n}\r\n\r\n/**\r\n * Try's to parse a string which represents a color to a HSV array.\r\n * Current supported types are cmyk, rgba, hsla and hexadecimal.\r\n * @param str\r\n * @return {*}\r\n */\r\nexport function parseToHSVA(str) {\r\n\r\n // Check if string is a color-name\r\n str = str.match(/^[a-zA-Z]+$/) ? standardizeColor(str) : str;\r\n\r\n // Regular expressions to match different types of color represention\r\n const regex = {\r\n cmyk: /^cmyk[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)/i,\r\n rgba: /^((rgba)|rgb)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsla: /^((hsla)|hsl)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsva: /^((hsva)|hsv)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hexa: /^#?(([\\dA-Fa-f]{3,4})|([\\dA-Fa-f]{6})|([\\dA-Fa-f]{8}))$/i\r\n };\r\n\r\n /**\r\n * Takes an Array of any type, convert strings which represents\r\n * a number to a number an anything else to undefined.\r\n * @param array\r\n * @return {*}\r\n */\r\n const numarize = array => array.map(v => /^(|\\d+)\\.\\d+|\\d+$/.test(v) ? Number(v) : undefined);\r\n\r\n let match;\r\n invalid: for (const type in regex) {\r\n\r\n // Check if current scheme passed\r\n if (!(match = regex[type].exec(str)))\r\n continue;\r\n\r\n // match[2] does only contain a truly value if rgba, hsla, or hsla got matched\r\n const alpha = !!match[2];\r\n\r\n // Try to convert\r\n switch (type) {\r\n case 'cmyk': {\r\n const [, c, m, y, k] = numarize(match);\r\n\r\n if (c > 100 || m > 100 || y > 100 || k > 100)\r\n break invalid;\r\n\r\n return {values: cmykToHsv(c, m, y, k), type};\r\n }\r\n case 'rgba': {\r\n const [, , , r, g, b, a] = numarize(match);\r\n\r\n if (r > 255 || g > 255 || b > 255 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...rgbToHsv(r, g, b), a], a, type};\r\n }\r\n case 'hexa': {\r\n let [, hex] = match;\r\n\r\n if (hex.length === 4 || hex.length === 3) {\r\n hex = hex.split('').map(v => v + v).join('');\r\n }\r\n\r\n const raw = hex.substring(0, 6);\r\n let a = hex.substring(6);\r\n\r\n // Convert 0 - 255 to 0 - 1 for opacity\r\n a = a ? (parseInt(a, 16) / 255) : undefined;\r\n\r\n return {values: [...hexToHsv(raw), a], a, type};\r\n }\r\n case 'hsla': {\r\n const [, , , h, s, l, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || l > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...hslToHsv(h, s, l), a], a, type};\r\n }\r\n case 'hsva': {\r\n const [, , , h, s, v, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || v > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [h, s, v, a], a, type};\r\n }\r\n }\r\n }\r\n\r\n return {values: null, type: null};\r\n}\r\n","import {hsvToHsl, hsvToRgb, hsvToCmyk, hsvToHex} from './color';\r\n\r\n/**\r\n * Simple class which holds the properties\r\n * of the color represention model hsla (hue saturation lightness alpha)\r\n */\r\nexport function HSVaColor(h = 0, s = 0, v = 0, a = 1) {\r\n const mapper = (original, next) => (precision = -1) => {\r\n return next(~precision ? original.map(v => Number(v.toFixed(precision))) : original);\r\n };\r\n\r\n const that = {\r\n h, s, v, a,\r\n\r\n toHSVA() {\r\n const hsva = [that.h, that.s, that.v, that.a];\r\n hsva.toString = mapper(hsva, arr => `hsva(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsva;\r\n },\r\n\r\n toHSLA() {\r\n const hsla = [...hsvToHsl(that.h, that.s, that.v), that.a];\r\n hsla.toString = mapper(hsla, arr => `hsla(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsla;\r\n },\r\n\r\n toRGBA() {\r\n const rgba = [...hsvToRgb(that.h, that.s, that.v), that.a];\r\n rgba.toString = mapper(rgba, arr => `rgba(${arr[0]}, ${arr[1]}, ${arr[2]}, ${that.a})`);\r\n return rgba;\r\n },\r\n\r\n toCMYK() {\r\n const cmyk = hsvToCmyk(that.h, that.s, that.v);\r\n cmyk.toString = mapper(cmyk, arr => `cmyk(${arr[0]}%, ${arr[1]}%, ${arr[2]}%, ${arr[3]}%)`);\r\n return cmyk;\r\n },\r\n\r\n toHEXA() {\r\n const hex = hsvToHex(that.h, that.s, that.v);\r\n\r\n // Check if alpha channel make sense, convert it to 255 number space, convert\r\n // to hex and pad it with zeros if needet.\r\n const alpha = that.a >= 1 ? '' : Number((that.a * 255).toFixed(0))\r\n .toString(16)\r\n .toUpperCase().padStart(2, '0');\r\n\r\n alpha && hex.push(alpha);\r\n hex.toString = () => `#${hex.join('').toUpperCase()}`;\r\n return hex;\r\n },\r\n\r\n clone: () => HSVaColor(that.h, that.s, that.v, that.a)\r\n };\r\n\r\n return that;\r\n}\r\n","import * as _ from '../utils/utils';\n\nconst clamp = v => Math.max(Math.min(v, 1), 0);\nexport default function Moveable(opt) {\n\n const that = {\n\n // Assign default values\n options: Object.assign({\n lock: null,\n onchange: () => 0,\n onstop: () => 0\n }, opt),\n\n _keyboard({type, key}) {\n\n // Check to see if the Movable is focused and then move it based on arrow key inputs\n // for improved accessibility\n if (document.activeElement === options.wrapper) {\n if (type === 'keydown') {\n let xm = 0;\n let ym = 0;\n\n switch (key) {\n case 'ArrowLeft':\n xm--;\n break;\n case 'ArrowRight':\n xm++;\n break;\n case 'ArrowUp':\n ym++;\n break;\n case 'ArrowDown':\n ym++;\n }\n\n that.update(\n clamp(that.cache.x + (0.01 * xm)),\n clamp(that.cache.y + (0.01 * ym))\n );\n } else if (key.startsWith('Arrow')) {\n that.options.onstop();\n }\n }\n },\n\n _tapstart(evt) {\n _.on(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\n _.on(document, ['mousemove', 'touchmove'], that._tapmove);\n\n // Prevent default touch event\n evt.preventDefault();\n\n // Trigger\n that._tapmove(evt);\n },\n\n _tapmove(evt) {\n const {options: {lock}, cache} = that;\n const {element, wrapper} = options;\n const b = wrapper.getBoundingClientRect();\n\n let x = 0, y = 0;\n if (evt) {\n const touch = evt && evt.touches && evt.touches[0];\n x = evt ? (touch || evt).clientX : 0;\n y = evt ? (touch || evt).clientY : 0;\n\n // Reset to bounds\n if (x < b.left) x = b.left;\n else if (x > b.left + b.width) x = b.left + b.width;\n if (y < b.top) y = b.top;\n else if (y > b.top + b.height) y = b.top + b.height;\n\n // Normalize\n x -= b.left;\n y -= b.top;\n } else if (cache) {\n x = cache.x * b.width;\n y = cache.y * b.height;\n }\n\n if (lock !== 'h') {\n element.style.left = `calc(${x / b.width * 100}% - ${element.offsetWidth / 2}px)`;\n }\n\n if (lock !== 'v') {\n element.style.top = `calc(${y / b.height * 100}% - ${element.offsetHeight / 2}px)`;\n }\n\n that.cache = {x: x / b.width, y: y / b.height};\n const cx = clamp(x / wrapper.offsetWidth);\n const cy = clamp(y / wrapper.offsetHeight);\n\n switch (lock) {\n case 'v':\n return options.onchange(cx);\n case 'h':\n return options.onchange(cy);\n default:\n return options.onchange(cx, cy);\n }\n },\n\n _tapstop() {\n that.options.onstop();\n _.off(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\n _.off(document, ['mousemove', 'touchmove'], that._tapmove);\n },\n\n trigger() {\n that._tapmove();\n },\n\n update(x = 0, y = 0) {\n const {left, top, width, height} = that.options.wrapper.getBoundingClientRect();\n\n if (that.options.lock === 'h') {\n y = x;\n }\n\n that._tapmove({\n clientX: left + width * x,\n clientY: top + height * y\n });\n },\n\n destroy() {\n const {options, _tapstart} = that;\n _.off([options.wrapper, options.element], 'mousedown', _tapstart);\n _.off([options.wrapper, options.element], 'touchstart', _tapstart, {\n passive: false\n });\n }\n };\n\n // Initilize\n const {options, _tapstart, _keyboard} = that;\n _.on([options.wrapper, options.element], 'mousedown', _tapstart);\n _.on([options.wrapper, options.element], 'touchstart', _tapstart, {\n passive: false\n });\n\n _.on(document, ['keydown', 'keyup'], _keyboard);\n\n\n return that;\n}\n","import * as _ from '../utils/utils';\r\n\r\nexport default function Selectable(opt = {}) {\r\n opt = Object.assign({\r\n onchange: () => 0,\r\n className: '',\r\n elements: []\r\n }, opt);\r\n\r\n const onTap = _.on(opt.elements, 'click', evt => {\r\n opt.elements.forEach(e =>\r\n e.classList[evt.target === e ? 'add' : 'remove'](opt.className)\r\n );\r\n\r\n opt.onchange(evt);\r\n });\r\n\r\n return {\r\n destroy: () => _.off(...onTap)\r\n };\r\n}\r\n","/**\r\n * Micro positioning-engine\r\n * @param el\r\n * @param reference\r\n * @param pos\r\n * @param padding\r\n * @returns {{update(): void}}\r\n * @constructor\r\n */\r\nexport default function Nanopop({el, reference, padding = 8}) {\r\n const vBehaviour = {start: 'sme', middle: 'mse', end: 'ems'};\r\n const hBehaviour = {top: 'tbrl', right: 'rltb', bottom: 'btrl', left: 'lrbt'};\r\n\r\n const getInfo = ((cache = {}) => (pos, cached = cache[pos]) => {\r\n if (cached) return cached;\r\n const [position, variant = 'middle'] = pos.split('-');\r\n const isVertical = (position === 'top' || position === 'bottom');\r\n\r\n return cache[pos] = {\r\n position,\r\n variant,\r\n isVertical\r\n };\r\n })();\r\n\r\n return {\r\n update(pos) {\r\n const {position, variant, isVertical} = getInfo(pos);\r\n const rb = reference.getBoundingClientRect();\r\n const eb = el.getBoundingClientRect();\r\n\r\n const positions = vertical => vertical ? {\r\n t: rb.top - eb.height - padding,\r\n b: rb.bottom + padding\r\n } : {\r\n r: rb.right + padding,\r\n l: rb.left - eb.width - padding\r\n };\r\n\r\n const variants = vertical => vertical ? {\r\n s: rb.left + rb.width - eb.width,\r\n m: (-eb.width / 2) + (rb.left + rb.width / 2),\r\n e: rb.left\r\n } : {\r\n s: rb.bottom - eb.height,\r\n m: rb.bottom - rb.height / 2 - eb.height / 2,\r\n e: rb.bottom - rb.height\r\n };\r\n\r\n const leastApplied = {};\r\n\r\n function apply(bevs, vars, styleprop) {\r\n const vertical = styleprop === 'top';\r\n const adder = vertical ? eb.height : eb.width;\r\n const win = window[vertical ? 'innerHeight' : 'innerWidth'];\r\n\r\n for (const ch of bevs) {\r\n const v = vars[ch];\r\n const sv = leastApplied[styleprop] = `${v}px`;\r\n\r\n if (v > 0 && (v + adder) < win) {\r\n el.style[styleprop] = sv;\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n for (const rot of [isVertical, !isVertical]) {\r\n const v2Ok = apply(hBehaviour[position], positions(rot), rot ? 'top' : 'left');\r\n const v1Ok = apply(vBehaviour[variant], variants(rot), rot ? 'left' : 'top');\r\n\r\n if (v2Ok && v1Ok) {\r\n return;\r\n }\r\n }\r\n\r\n el.style.left = leastApplied.left;\r\n el.style.top = leastApplied.top;\r\n }\r\n };\r\n}\r\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this._t, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return this.options.i18n[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pickr.min.js b/dist/pickr.min.js index c805c3f6..bcb5d855 100644 --- a/dist/pickr.min.js +++ b/dist/pickr.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e);var n={};function i(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function r(t){for(var e=1;e>/g).reduce((t,e,o,n)=>(t=t.querySelector(e),ot)){function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,r=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,o)=>o<=r&&o+t.length>=r?(r=o,e(Number(t),n,i)):(i++,t)),t.focus(),t.setSelectionRange(r,r),o.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",()=>c(window,"wheel",o,{passive:!1})),c(t,"blur",()=>a(window,"wheel",o))}const{min:b,max:v,floor:g,round:y}=Math;function _(t,e,o){e/=100,o/=100;const n=g(t=t/360*6),i=t-n,r=o*(1-e),s=o*(1-i*e),c=o*(1-(1-i)*e),a=n%6;return[255*[o,s,r,r,c,o][a],255*[c,o,o,s,r,r][a],255*[r,r,c,o,o,s][a]]}function w(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function C(t,e,o){let n,i,r;const s=b(t/=255,e/=255,o/=255),c=v(t,e,o),a=c-s;if(0===a)n=i=0;else{i=a/c;const r=((c-t)/6+a/2)/a,s=((c-e)/6+a/2)/a,l=((c-o)/6+a/2)/a;t===c?n=l-s:e===c?n=1/3+r-l:o===c&&(n=2/3+s-r),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(r=c)]}function k(t,e,o,n){return e/=100,o/=100,[...C(255*(1-b(1,(t/=100)*(1-(n/=100))+n)),255*(1-b(1,e*(1-n)+n)),255*(1-b(1,o*(1-n)+n)))]}function A(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function O(t){return C(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function S(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const r=!!n[2];switch(i){case"cmyk":{const[,t,e,r,s]=o(n);if(t>100||e>100||r>100||s>100)break t;return{values:k(t,e,r,s),type:i}}case"rgba":{const[,,,t,e,s,c]=o(n);if(t>255||e>255||s>255||c<0||c>1||r===!c)break t;return{values:[...C(t,e,s),c],a:c,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map(t=>t+t).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...O(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[...A(t,e,s),c],a:c,type:i}}case"hsva":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[t,e,s,c],a:c,type:i}}}}return{values:null,type:null}}function j(t=0,e=0,o=0,n=1){const i=(t,e)=>(o=-1)=>e(~o?t.map(t=>Number(t.toFixed(o))):t),r={h:t,s:e,v:o,a:n,toHSVA(){const t=[r.h,r.s,r.v,r.a];return t.toString=i(t,t=>"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toHSLA(){const t=[...w(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toRGBA(){const t=[..._(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(r.a,")")),t},toCMYK(){const t=function(t,e,o){const n=_(t,e,o),i=n[0]/255,r=n[1]/255,s=n[2]/255;let c,a,l,p;return[100*(a=1===(c=b(1-i,1-r,1-s))?0:(1-i-c)/(1-c)),100*(l=1===c?0:(1-r-c)/(1-c)),100*(p=1===c?0:(1-s-c)/(1-c)),100*c]}(r.h,r.s,r.v);return t.toString=i(t,t=>"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")),t},toHEXA(){const t=function(t,e,o){return _(t,e,o).map(t=>y(t).toString(16).padStart(2,"0"))}(r.h,r.s,r.v),e=r.a>=1?"":Number((255*r.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>"#".concat(t.join("").toUpperCase()),t},clone:()=>j(r.h,r.s,r.v,r.a)};return r}const P=t=>Math.max(Math.min(t,1),0);function x(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard({type:t,key:n}){if(document.activeElement===o.wrapper)if("keydown"===t){let t=0,o=0;switch(n){case"ArrowLeft":t--;break;case"ArrowRight":t++;break;case"ArrowUp":o++;break;case"ArrowDown":o++}e.update(P(e.cache.x+.01*t),P(e.cache.y+.01*o))}else n.startsWith("Arrow")&&e.options.onstop()},_tapstart(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:{lock:n},cache:i}=e,{element:r,wrapper:s}=o,c=s.getBoundingClientRect();let a=0,l=0;if(t){const e=t&&t.touches&&t.touches[0];a=t?(e||t).clientX:0,l=t?(e||t).clientY:0,ac.left+c.width&&(a=c.left+c.width),lc.top+c.height&&(l=c.top+c.height),a-=c.left,l-=c.top}else i&&(a=i.x*c.width,l=i.y*c.height);"h"!==n&&(r.style.left="calc(".concat(a/c.width*100,"% - ").concat(r.offsetWidth/2,"px)")),"v"!==n&&(r.style.top="calc(".concat(l/c.height*100,"% - ").concat(r.offsetHeight/2,"px)")),e.cache={x:a/c.width,y:l/c.height};const p=P(a/s.offsetWidth),u=P(l/s.offsetHeight);switch(n){case"v":return o.onchange(p);case"h":return o.onchange(u);default:return o.onchange(p,u)}},_tapstop(){e.options.onstop(),a(document,["mouseup","touchend","touchcancel"],e._tapstop),a(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(t=0,o=0){const{left:n,top:i,width:r,height:s}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+r*t,clientY:i+s*o})},destroy(){const{options:t,_tapstart:o}=e;a([t.wrapper,t.element],"mousedown",o),a([t.wrapper,t.element],"touchstart",o,{passive:!1})}},{options:o,_tapstart:n,_keyboard:i}=e;return c([o.wrapper,o.element],"mousedown",n),c([o.wrapper,o.element],"touchstart",n,{passive:!1}),c(document,["keydown","keyup"],i),e}function E(t={}){t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=c(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)});return{destroy:()=>a(...e)}}function L({el:t,reference:e,padding:o=8}){const n={start:"sme",middle:"mse",end:"ems"},i={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},r=((t={})=>(e,o=t[e])=>{if(o)return o;const[n,i="middle"]=e.split("-"),r="top"===n||"bottom"===n;return t[e]={position:n,variant:i,isVertical:r}})();return{update(s){const{position:c,variant:a,isVertical:l}=r(s),p=e.getBoundingClientRect(),u=t.getBoundingClientRect(),h=t=>t?{t:p.top-u.height-o,b:p.bottom+o}:{r:p.right+o,l:p.left-u.width-o},d=t=>t?{s:p.left+p.width-u.width,m:-u.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-u.height,m:p.bottom-p.height/2-u.height/2,e:p.bottom-p.height},f={};function m(e,o,n){const i="top"===n,r=i?u.height:u.width,s=window[i?"innerHeight":"innerWidth"];for(const i of e){const e=o[i],c=f[n]="".concat(e,"px");if(e>0&&e+r{const c=t=>t?"":'style="display:none" hidden',a=h('\n
\n\n '.concat(o?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function D(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=L({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(function(t){for(var e=1;ethis._color||(this._color=this._lastColor.clone()),s={palette:x({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:x({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:x({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:E({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=S(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return this.options.i18n[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(this._t,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:E({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:E({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return this.options.i18n[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr({...opt, t: this._t});\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return this.options.i18n[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this._t, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return this.options.i18n[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return this.options.i18n[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=E.apply(void 0,M(n)),a=u('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return this.options.i18n[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=E.apply(void 0,M(n)),a=u(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/js/utils/utils.js","webpack:///./src/js/utils/color.js","webpack:///./src/js/utils/hsvacolor.js","webpack:///./src/js/libs/moveable.js","webpack:///./src/js/libs/selectable.js","webpack:///./src/js/libs/nanopop.js","webpack:///./src/js/pickr.js","webpack:///./src/js/template.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","on","eventListener","off","method","elements","events","fn","options","HTMLCollection","NodeList","Array","from","isArray","el","ev","capture","slice","arguments","createElementFromString","html","div","document","createElement","innerHTML","trim","firstElementChild","removeAttribute","getAttribute","createFromTemplate","str","resolve","element","base","con","subtree","children","child","arr","sub","push","keys","length","eventPath","evt","path","composedPath","target","parentElement","resolveElement","val","Element","split","reduce","pv","cv","ci","a","querySelector","shadowRoot","adjustableInputNumbers","mapper","v","handleScroll","e","inc","Number","shiftKey","ctrlKey","deltaY","index","selectionStart","replace","focus","setSelectionRange","preventDefault","dispatchEvent","Event","passive","min","Math","max","floor","round","hsvToRgb","h","f","q","mod","rgbToHsv","g","b","minVal","maxVal","delta","dr","dg","db","cmykToHsv","y","k","hslToHsv","hexToHsv","hex","match","map","parseInt","parseToHSVA","toLowerCase","ctx","getContext","fillStyle","standardizeColor","regex","cmyk","rgba","hsla","hsva","hexa","numarize","array","test","undefined","invalid","type","exec","alpha","values","join","raw","substring","HSVaColor","original","next","precision","toFixed","that","toHSVA","toString","toHSLA","hsvToHsl","toRGBA","toCMYK","rgb","hsvToCmyk","toHEXA","padStart","hsvToHex","toUpperCase","clone","clamp","Moveable","opt","assign","lock","onchange","onstop","_keyboard","activeElement","wrapper","xm","ym","update","cache","x","startsWith","_tapstart","_","_tapstop","_tapmove","getBoundingClientRect","touch","touches","clientX","clientY","left","width","top","height","style","offsetWidth","offsetHeight","cx","cy","trigger","destroy","Selectable","className","onTap","forEach","classList","Nanopop","reference","padding","vBehaviour","start","middle","end","hBehaviour","right","bottom","getInfo","pos","cached","position","variant","isVertical","rb","eb","variants","vertical","leastApplied","apply","bevs","vars","styleprop","adder","win","sv","rot","v2Ok","v1Ok","Pickr","init","save","hide","show","clear","change","changestop","cancel","swatchselect","this","appClass","theme","useAsButton","disabled","comparison","closeOnScroll","outputPrecision","lockOpacity","autoReposition","container","components","interaction","i18n","swatches","inline","sliders","default","defaultRepresentation","adjustableNumbers","showAlways","closeWithKey","includes","preview","opacity","hue","palette","_preBuild","_buildComponents","_bindEvents","_finalBuild","color","addSwatch","_root","button","app","_nanopop","setAttribute","_t","requestAnimationFrame","cb","setColor","_rePositioningPicker","_representation","setColorRepresentation","_initializingActive","_emit","lo","hidden","int","input","find","add","contains","appendChild","removeChild","parent","nextSibling","insertBefore","remove","parentNode","replaceChild","disable","transition","lastColor","inst","cs","repeat","so","sh","getColor","_color","_lastColor","picker","_recalc","_updateOutput","cssRGBaString","background","_swatchColors","currentColor","slider","backgroundColor","selectable","_components","eventBindings","_clearColor","setHSVA","applyColor","result","stopImmediatePropagation","ck","isOpen","code","some","ranges","step","range","getColorRepresentation","nv","toPrecision","timeout","setTimeout","rs","clearTimeout","_eventBindings","matchMedia","matches","margin","silent","alphaMakesAChange","event","args","_eventListener","def","callBacks","indexOf","splice","_parseLocalColor","swatchColor","recalc","string","utype","click","utils","libs","version"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,IARlB,CASGK,OAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAAS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Aa,eAAiBqU,IAGnE,GAAIlT,IAAWA,EAAOyO,OAAQ,4BAC1B,YAAiBhR,EAAjB,+CAA0B,KAAfM,EAAe,QACtBA,EAAGgL,UAAUhL,IAAOiC,EAAS,MAAQ,UAAU,WAFzB,mFAO9B,OADAyL,KAAK4C,uBAAuB6E,GACrBzH,KAAKsF,QAAL,MAAAtF,KAAA,EAAgBzG,GAAhB,QAAwBqN,KAGnC,OAAO,I,6CASYxN,GAMnB,OAHAA,EAAOA,EAAKwB,gBAGHoF,KAAKiC,MAAMrB,YAAY5O,QAC3BmR,KAAK,SAAA7N,GAAC,OAAIA,EAAElC,aAAa,aAAayI,WAAWzC,KAAU9D,EAAEoS,Y,+CAQlE,OAAO1H,KAAK2C,kB,iCAOZ,OAAO3C,KAAKuE,S,yCAQZ,OAAOvE,KAAKwE,a,gCAOZ,OAAOxE,KAAKiC,Q,gCAUZ,OAHAjC,KAAKP,OACLO,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAU8F,IAAI,YACzBpD,O,+BASP,OAFAA,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAUqG,OAAO,YAC5B3D,U,gCAKfV,EAAMqI,MAAQ5L,EAGduD,EAAMsI,KAAO,CACTjO,YACAoB,WACAwC,UACAL,cAIJoC,EAAMvO,OAAS,SAAAiB,GAAO,OAAI,IAAIsN,EAAMtN,IAGpCsN,EAAMuI,QAAU,QACDvI,e","file":"pickr.es5.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pickr\"] = factory();\n\telse\n\t\troot[\"Pickr\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Add event(s) to element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const on = eventListener.bind(null, 'addEventListener');\r\n\r\n/**\r\n * Remove event(s) from element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const off = eventListener.bind(null, 'removeEventListener');\r\n\r\nfunction eventListener(method, elements, events, fn, options = {}) {\r\n\r\n // Normalize array\r\n if (elements instanceof HTMLCollection || elements instanceof NodeList) {\r\n elements = Array.from(elements);\r\n } else if (!Array.isArray(elements)) {\r\n elements = [elements];\r\n }\r\n\r\n if (!Array.isArray(events)) {\r\n events = [events];\r\n }\r\n\r\n for (const el of elements) {\r\n for (const ev of events) {\r\n el[method](ev, fn, {capture: false, ...options});\r\n }\r\n }\r\n\r\n return Array.prototype.slice.call(arguments, 1);\r\n}\r\n\r\n/**\r\n * Creates an DOM-Element out of a string (Single element).\r\n * @param html HTML representing a single element\r\n * @returns {Element | null} The element.\r\n */\r\nexport function createElementFromString(html) {\r\n const div = document.createElement('div');\r\n div.innerHTML = html.trim();\r\n return div.firstElementChild;\r\n}\r\n\r\n/**\r\n * Removes an attribute from a HTMLElement and returns the value.\r\n * @param el\r\n * @param name\r\n * @return {string}\r\n */\r\nexport function removeAttribute(el, name) {\r\n const value = el.getAttribute(name);\r\n el.removeAttribute(name);\r\n return value;\r\n}\r\n\r\n/**\r\n * Creates a new html element, every element which has\r\n * a ':ref' attribute will be saved in a object (which will be returned)\r\n * where the value of ':ref' is the object-key and the value the HTMLElement.\r\n *\r\n * It's possible to create a hierarchy if you add a ':obj' attribute. Every\r\n * sibling will be added to the object which will get the name from the 'data-con' attribute.\r\n *\r\n * If you want to create an Array out of multiple elements, you can use the ':arr' attribute,\r\n * the value defines the key and all elements, which has the same parent and the same 'data-arr' attribute,\r\n * would be added to it.\r\n *\r\n * @param str - The HTML String.\r\n */\r\nexport function createFromTemplate(str) {\r\n\r\n // Recursive function to resolve template\r\n function resolve(element, base = {}) {\r\n\r\n // Check key and container attribute\r\n const con = removeAttribute(element, ':obj');\r\n const key = removeAttribute(element, ':ref');\r\n const subtree = con ? (base[con] = {}) : base;\r\n\r\n // Check and save element\r\n key && (base[key] = element);\r\n for (const child of Array.from(element.children)) {\r\n const arr = removeAttribute(child, ':arr');\r\n const sub = resolve(child, arr ? {} : subtree);\r\n\r\n if (arr) {\r\n\r\n // Check if there is already an array and add element\r\n (subtree[arr] || (subtree[arr] = []))\r\n .push(Object.keys(sub).length ? sub : child);\r\n }\r\n }\r\n\r\n return base;\r\n }\r\n\r\n return resolve(createElementFromString(str));\r\n}\r\n\r\n/**\r\n * Polyfill for safari & firefox for the eventPath event property.\r\n * @param evt The event object.\r\n * @return [String] event path.\r\n */\r\nexport function eventPath(evt) {\r\n let path = evt.path || (evt.composedPath && evt.composedPath());\r\n if (path) return path;\r\n\r\n let el = evt.target.parentElement;\r\n path = [evt.target, el];\r\n while (el = el.parentElement) path.push(el);\r\n\r\n path.push(document, window);\r\n return path;\r\n}\r\n\r\n/**\r\n * Resolves a HTMLElement by query.\r\n * @param val\r\n * @returns {null|Document|Element}\r\n */\r\nexport function resolveElement(val) {\r\n if (val instanceof Element) {\r\n return val;\r\n } else if (typeof val === 'string') {\r\n return val.split(/>>/g).reduce((pv, cv, ci, a) => {\r\n pv = pv.querySelector(cv);\r\n return ci < a.length - 1 ? pv.shadowRoot : pv;\r\n }, document);\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Creates the ability to change numbers in an input field with the scroll-wheel.\r\n * @param el\r\n * @param mapper\r\n */\r\nexport function adjustableInputNumbers(el, mapper = v => v) {\r\n\r\n function handleScroll(e) {\r\n const inc = ([0.001, 0.01, 0.1])[Number(e.shiftKey || e.ctrlKey * 2)] * (e.deltaY < 0 ? 1 : -1);\r\n\r\n let index = 0;\r\n let off = el.selectionStart;\r\n el.value = el.value.replace(/[\\d.]+/g, (v, i) => {\r\n\r\n // Check if number is in cursor range and increase it\r\n if (i <= off && i + v.length >= off) {\r\n off = i;\r\n return mapper(Number(v), inc, index);\r\n }\r\n\r\n index++;\r\n return v;\r\n });\r\n\r\n el.focus();\r\n el.setSelectionRange(off, off);\r\n\r\n // Prevent default and trigger input event\r\n e.preventDefault();\r\n el.dispatchEvent(new Event('input'));\r\n }\r\n\r\n // Bind events\r\n on(el, 'focus', () => on(window, 'wheel', handleScroll, {passive: false}));\r\n on(el, 'blur', () => off(window, 'wheel', handleScroll));\r\n}\r\n","// Shorthands\r\nconst {min, max, floor, round} = Math;\r\n\r\n/**\r\n * Tries to convert a color name to rgb/a hex representation\r\n * @param name\r\n * @returns {string | CanvasGradient | CanvasPattern}\r\n */\r\nfunction standardizeColor(name) {\r\n\r\n // Since invalid color's will be parsed as black, filter them out\r\n if (name.toLowerCase() === 'black') {\r\n return '#000000';\r\n }\r\n\r\n const ctx = document.createElement('canvas').getContext('2d');\r\n ctx.fillStyle = name;\r\n return ctx.fillStyle === '#000000' ? null : ctx.fillStyle;\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to RGB.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} Array with rgb values.\r\n */\r\nexport function hsvToRgb(h, s, v) {\r\n h = (h / 360) * 6;\r\n s /= 100;\r\n v /= 100;\r\n\r\n const i = floor(h);\r\n\r\n const f = h - i;\r\n const p = v * (1 - s);\r\n const q = v * (1 - f * s);\r\n const t = v * (1 - (1 - f) * s);\r\n\r\n const mod = i % 6;\r\n const r = [v, q, p, p, t, v][mod];\r\n const g = [t, v, v, q, p, p][mod];\r\n const b = [p, p, t, v, v, q][mod];\r\n\r\n return [\r\n r * 255,\r\n g * 255,\r\n b * 255\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to Hex.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {string[]} Hex values\r\n */\r\nexport function hsvToHex(h, s, v) {\r\n return hsvToRgb(h, s, v).map(v =>\r\n round(v).toString(16).padStart(2, '0')\r\n );\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to CMYK.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} CMYK values\r\n */\r\nexport function hsvToCmyk(h, s, v) {\r\n const rgb = hsvToRgb(h, s, v);\r\n const r = rgb[0] / 255;\r\n const g = rgb[1] / 255;\r\n const b = rgb[2] / 255;\r\n\r\n let k, c, m, y;\r\n\r\n k = min(1 - r, 1 - g, 1 - b);\r\n\r\n c = k === 1 ? 0 : (1 - r - k) / (1 - k);\r\n m = k === 1 ? 0 : (1 - g - k) / (1 - k);\r\n y = k === 1 ? 0 : (1 - b - k) / (1 - k);\r\n\r\n return [\r\n c * 100,\r\n m * 100,\r\n y * 100,\r\n k * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to HSL.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} HSL values\r\n */\r\nexport function hsvToHsl(h, s, v) {\r\n s /= 100, v /= 100;\r\n\r\n const l = (2 - s) * v / 2;\r\n\r\n if (l !== 0) {\r\n if (l === 1) {\r\n s = 0;\r\n } else if (l < 0.5) {\r\n s = s * v / (l * 2);\r\n } else {\r\n s = s * v / (2 - l * 2);\r\n }\r\n }\r\n\r\n return [\r\n h,\r\n s * 100,\r\n l * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert RGB to HSV.\r\n * @param r Red\r\n * @param g Green\r\n * @param b Blue\r\n * @return {number[]} HSV values.\r\n */\r\nfunction rgbToHsv(r, g, b) {\r\n r /= 255, g /= 255, b /= 255;\r\n\r\n let h, s, v;\r\n const minVal = min(r, g, b);\r\n const maxVal = max(r, g, b);\r\n const delta = maxVal - minVal;\r\n\r\n v = maxVal;\r\n if (delta === 0) {\r\n h = s = 0;\r\n } else {\r\n s = delta / maxVal;\r\n const dr = (((maxVal - r) / 6) + (delta / 2)) / delta;\r\n const dg = (((maxVal - g) / 6) + (delta / 2)) / delta;\r\n const db = (((maxVal - b) / 6) + (delta / 2)) / delta;\r\n\r\n if (r === maxVal) {\r\n h = db - dg;\r\n } else if (g === maxVal) {\r\n h = (1 / 3) + dr - db;\r\n } else if (b === maxVal) {\r\n h = (2 / 3) + dg - dr;\r\n }\r\n\r\n if (h < 0) {\r\n h += 1;\r\n } else if (h > 1) {\r\n h -= 1;\r\n }\r\n }\r\n\r\n return [\r\n h * 360,\r\n s * 100,\r\n v * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert CMYK to HSV.\r\n * @param c Cyan\r\n * @param m Magenta\r\n * @param y Yellow\r\n * @param k Key (Black)\r\n * @return {number[]} HSV values.\r\n */\r\nfunction cmykToHsv(c, m, y, k) {\r\n c /= 100;\r\n m /= 100;\r\n y /= 100;\r\n k /= 100;\r\n\r\n const r = (1 - min(1, c * (1 - k) + k)) * 255;\r\n const g = (1 - min(1, m * (1 - k) + k)) * 255;\r\n const b = (1 - min(1, y * (1 - k) + k)) * 255;\r\n\r\n return [...rgbToHsv(r, g, b)];\r\n}\r\n\r\n/**\r\n * Convert HSL to HSV.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param l Lightness\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hslToHsv(h, s, l) {\r\n s /= 100;\r\n l /= 100;\r\n s *= l < 0.5 ? l : 1 - l;\r\n\r\n const ns = (2 * s / (l + s)) * 100;\r\n const v = (l + s) * 100;\r\n return [h, ns, v];\r\n}\r\n\r\n/**\r\n * Convert HEX to HSV.\r\n * @param hex Hexadecimal string of rgb colors, can have length 3 or 6.\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hexToHsv(hex) {\r\n return rgbToHsv(...hex.match(/.{2}/g).map(v => parseInt(v, 16)));\r\n}\r\n\r\n/**\r\n * Try's to parse a string which represents a color to a HSV array.\r\n * Current supported types are cmyk, rgba, hsla and hexadecimal.\r\n * @param str\r\n * @return {*}\r\n */\r\nexport function parseToHSVA(str) {\r\n\r\n // Check if string is a color-name\r\n str = str.match(/^[a-zA-Z]+$/) ? standardizeColor(str) : str;\r\n\r\n // Regular expressions to match different types of color represention\r\n const regex = {\r\n cmyk: /^cmyk[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)/i,\r\n rgba: /^((rgba)|rgb)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsla: /^((hsla)|hsl)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsva: /^((hsva)|hsv)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hexa: /^#?(([\\dA-Fa-f]{3,4})|([\\dA-Fa-f]{6})|([\\dA-Fa-f]{8}))$/i\r\n };\r\n\r\n /**\r\n * Takes an Array of any type, convert strings which represents\r\n * a number to a number an anything else to undefined.\r\n * @param array\r\n * @return {*}\r\n */\r\n const numarize = array => array.map(v => /^(|\\d+)\\.\\d+|\\d+$/.test(v) ? Number(v) : undefined);\r\n\r\n let match;\r\n invalid: for (const type in regex) {\r\n\r\n // Check if current scheme passed\r\n if (!(match = regex[type].exec(str)))\r\n continue;\r\n\r\n // match[2] does only contain a truly value if rgba, hsla, or hsla got matched\r\n const alpha = !!match[2];\r\n\r\n // Try to convert\r\n switch (type) {\r\n case 'cmyk': {\r\n const [, c, m, y, k] = numarize(match);\r\n\r\n if (c > 100 || m > 100 || y > 100 || k > 100)\r\n break invalid;\r\n\r\n return {values: cmykToHsv(c, m, y, k), type};\r\n }\r\n case 'rgba': {\r\n const [, , , r, g, b, a] = numarize(match);\r\n\r\n if (r > 255 || g > 255 || b > 255 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...rgbToHsv(r, g, b), a], a, type};\r\n }\r\n case 'hexa': {\r\n let [, hex] = match;\r\n\r\n if (hex.length === 4 || hex.length === 3) {\r\n hex = hex.split('').map(v => v + v).join('');\r\n }\r\n\r\n const raw = hex.substring(0, 6);\r\n let a = hex.substring(6);\r\n\r\n // Convert 0 - 255 to 0 - 1 for opacity\r\n a = a ? (parseInt(a, 16) / 255) : undefined;\r\n\r\n return {values: [...hexToHsv(raw), a], a, type};\r\n }\r\n case 'hsla': {\r\n const [, , , h, s, l, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || l > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...hslToHsv(h, s, l), a], a, type};\r\n }\r\n case 'hsva': {\r\n const [, , , h, s, v, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || v > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [h, s, v, a], a, type};\r\n }\r\n }\r\n }\r\n\r\n return {values: null, type: null};\r\n}\r\n","import {hsvToHsl, hsvToRgb, hsvToCmyk, hsvToHex} from './color';\r\n\r\n/**\r\n * Simple class which holds the properties\r\n * of the color represention model hsla (hue saturation lightness alpha)\r\n */\r\nexport function HSVaColor(h = 0, s = 0, v = 0, a = 1) {\r\n const mapper = (original, next) => (precision = -1) => {\r\n return next(~precision ? original.map(v => Number(v.toFixed(precision))) : original);\r\n };\r\n\r\n const that = {\r\n h, s, v, a,\r\n\r\n toHSVA() {\r\n const hsva = [that.h, that.s, that.v, that.a];\r\n hsva.toString = mapper(hsva, arr => `hsva(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsva;\r\n },\r\n\r\n toHSLA() {\r\n const hsla = [...hsvToHsl(that.h, that.s, that.v), that.a];\r\n hsla.toString = mapper(hsla, arr => `hsla(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsla;\r\n },\r\n\r\n toRGBA() {\r\n const rgba = [...hsvToRgb(that.h, that.s, that.v), that.a];\r\n rgba.toString = mapper(rgba, arr => `rgba(${arr[0]}, ${arr[1]}, ${arr[2]}, ${that.a})`);\r\n return rgba;\r\n },\r\n\r\n toCMYK() {\r\n const cmyk = hsvToCmyk(that.h, that.s, that.v);\r\n cmyk.toString = mapper(cmyk, arr => `cmyk(${arr[0]}%, ${arr[1]}%, ${arr[2]}%, ${arr[3]}%)`);\r\n return cmyk;\r\n },\r\n\r\n toHEXA() {\r\n const hex = hsvToHex(that.h, that.s, that.v);\r\n\r\n // Check if alpha channel make sense, convert it to 255 number space, convert\r\n // to hex and pad it with zeros if needet.\r\n const alpha = that.a >= 1 ? '' : Number((that.a * 255).toFixed(0))\r\n .toString(16)\r\n .toUpperCase().padStart(2, '0');\r\n\r\n alpha && hex.push(alpha);\r\n hex.toString = () => `#${hex.join('').toUpperCase()}`;\r\n return hex;\r\n },\r\n\r\n clone: () => HSVaColor(that.h, that.s, that.v, that.a)\r\n };\r\n\r\n return that;\r\n}\r\n","import * as _ from '../utils/utils';\r\n\r\nconst clamp = v => Math.max(Math.min(v, 1), 0);\r\nexport default function Moveable(opt) {\r\n\r\n const that = {\r\n\r\n // Assign default values\r\n options: Object.assign({\r\n lock: null,\r\n onchange: () => 0,\r\n onstop: () => 0\r\n }, opt),\r\n\r\n _keyboard({type, key}) {\r\n\r\n // Check to see if the Movable is focused and then move it based on arrow key inputs\r\n // for improved accessibility\r\n if (document.activeElement === options.wrapper) {\r\n if (type === 'keydown') {\r\n let xm = 0;\r\n let ym = 0;\r\n\r\n switch (key) {\r\n case 'ArrowLeft':\r\n xm--;\r\n break;\r\n case 'ArrowRight':\r\n xm++;\r\n break;\r\n case 'ArrowUp':\r\n ym++;\r\n break;\r\n case 'ArrowDown':\r\n ym++;\r\n }\r\n\r\n that.update(\r\n clamp(that.cache.x + (0.01 * xm)),\r\n clamp(that.cache.y + (0.01 * ym))\r\n );\r\n } else if (key.startsWith('Arrow')) {\r\n that.options.onstop();\r\n }\r\n }\r\n },\r\n\r\n _tapstart(evt) {\r\n _.on(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\r\n _.on(document, ['mousemove', 'touchmove'], that._tapmove);\r\n\r\n // Prevent default touch event\r\n evt.preventDefault();\r\n\r\n // Trigger\r\n that._tapmove(evt);\r\n },\r\n\r\n _tapmove(evt) {\r\n const {options: {lock}, cache} = that;\r\n const {element, wrapper} = options;\r\n const b = wrapper.getBoundingClientRect();\r\n\r\n let x = 0, y = 0;\r\n if (evt) {\r\n const touch = evt && evt.touches && evt.touches[0];\r\n x = evt ? (touch || evt).clientX : 0;\r\n y = evt ? (touch || evt).clientY : 0;\r\n\r\n // Reset to bounds\r\n if (x < b.left) x = b.left;\r\n else if (x > b.left + b.width) x = b.left + b.width;\r\n if (y < b.top) y = b.top;\r\n else if (y > b.top + b.height) y = b.top + b.height;\r\n\r\n // Normalize\r\n x -= b.left;\r\n y -= b.top;\r\n } else if (cache) {\r\n x = cache.x * b.width;\r\n y = cache.y * b.height;\r\n }\r\n\r\n if (lock !== 'h') {\r\n element.style.left = `calc(${x / b.width * 100}% - ${element.offsetWidth / 2}px)`;\r\n }\r\n\r\n if (lock !== 'v') {\r\n element.style.top = `calc(${y / b.height * 100}% - ${element.offsetHeight / 2}px)`;\r\n }\r\n\r\n that.cache = {x: x / b.width, y: y / b.height};\r\n const cx = clamp(x / wrapper.offsetWidth);\r\n const cy = clamp(y / wrapper.offsetHeight);\r\n\r\n switch (lock) {\r\n case 'v':\r\n return options.onchange(cx);\r\n case 'h':\r\n return options.onchange(cy);\r\n default:\r\n return options.onchange(cx, cy);\r\n }\r\n },\r\n\r\n _tapstop() {\r\n that.options.onstop();\r\n _.off(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\r\n _.off(document, ['mousemove', 'touchmove'], that._tapmove);\r\n },\r\n\r\n trigger() {\r\n that._tapmove();\r\n },\r\n\r\n update(x = 0, y = 0) {\r\n const {left, top, width, height} = that.options.wrapper.getBoundingClientRect();\r\n\r\n if (that.options.lock === 'h') {\r\n y = x;\r\n }\r\n\r\n that._tapmove({\r\n clientX: left + width * x,\r\n clientY: top + height * y\r\n });\r\n },\r\n\r\n destroy() {\r\n const {options, _tapstart} = that;\r\n _.off([options.wrapper, options.element], 'mousedown', _tapstart);\r\n _.off([options.wrapper, options.element], 'touchstart', _tapstart, {\r\n passive: false\r\n });\r\n }\r\n };\r\n\r\n // Initilize\r\n const {options, _tapstart, _keyboard} = that;\r\n _.on([options.wrapper, options.element], 'mousedown', _tapstart);\r\n _.on([options.wrapper, options.element], 'touchstart', _tapstart, {\r\n passive: false\r\n });\r\n\r\n _.on(document, ['keydown', 'keyup'], _keyboard);\r\n\r\n\r\n return that;\r\n}\r\n","import * as _ from '../utils/utils';\r\n\r\nexport default function Selectable(opt = {}) {\r\n opt = Object.assign({\r\n onchange: () => 0,\r\n className: '',\r\n elements: []\r\n }, opt);\r\n\r\n const onTap = _.on(opt.elements, 'click', evt => {\r\n opt.elements.forEach(e =>\r\n e.classList[evt.target === e ? 'add' : 'remove'](opt.className)\r\n );\r\n\r\n opt.onchange(evt);\r\n });\r\n\r\n return {\r\n destroy: () => _.off(...onTap)\r\n };\r\n}\r\n","/**\r\n * Micro positioning-engine\r\n * @param el\r\n * @param reference\r\n * @param pos\r\n * @param padding\r\n * @returns {{update(): void}}\r\n * @constructor\r\n */\r\nexport default function Nanopop({el, reference, padding = 8}) {\r\n const vBehaviour = {start: 'sme', middle: 'mse', end: 'ems'};\r\n const hBehaviour = {top: 'tbrl', right: 'rltb', bottom: 'btrl', left: 'lrbt'};\r\n\r\n const getInfo = ((cache = {}) => (pos, cached = cache[pos]) => {\r\n if (cached) return cached;\r\n const [position, variant = 'middle'] = pos.split('-');\r\n const isVertical = (position === 'top' || position === 'bottom');\r\n\r\n return cache[pos] = {\r\n position,\r\n variant,\r\n isVertical\r\n };\r\n })();\r\n\r\n return {\r\n update(pos) {\r\n const {position, variant, isVertical} = getInfo(pos);\r\n const rb = reference.getBoundingClientRect();\r\n const eb = el.getBoundingClientRect();\r\n\r\n const positions = vertical => vertical ? {\r\n t: rb.top - eb.height - padding,\r\n b: rb.bottom + padding\r\n } : {\r\n r: rb.right + padding,\r\n l: rb.left - eb.width - padding\r\n };\r\n\r\n const variants = vertical => vertical ? {\r\n s: rb.left + rb.width - eb.width,\r\n m: (-eb.width / 2) + (rb.left + rb.width / 2),\r\n e: rb.left\r\n } : {\r\n s: rb.bottom - eb.height,\r\n m: rb.bottom - rb.height / 2 - eb.height / 2,\r\n e: rb.bottom - rb.height\r\n };\r\n\r\n const leastApplied = {};\r\n\r\n function apply(bevs, vars, styleprop) {\r\n const vertical = styleprop === 'top';\r\n const adder = vertical ? eb.height : eb.width;\r\n const win = window[vertical ? 'innerHeight' : 'innerWidth'];\r\n\r\n for (const ch of bevs) {\r\n const v = vars[ch];\r\n const sv = leastApplied[styleprop] = `${v}px`;\r\n\r\n if (v > 0 && (v + adder) < win) {\r\n el.style[styleprop] = sv;\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n for (const rot of [isVertical, !isVertical]) {\r\n const v2Ok = apply(hBehaviour[position], positions(rot), rot ? 'top' : 'left');\r\n const v1Ok = apply(vBehaviour[variant], variants(rot), rot ? 'left' : 'top');\r\n\r\n if (v2Ok && v1Ok) {\r\n return;\r\n }\r\n }\r\n\r\n el.style.left = leastApplied.left;\r\n el.style.top = leastApplied.top;\r\n }\r\n };\r\n}\r\n","// Import utils\r\nimport * as _ from './utils/utils';\r\nimport {parseToHSVA} from './utils/color';\r\n\r\n// Import classes\r\nimport {HSVaColor} from './utils/hsvacolor';\r\nimport Moveable from './libs/moveable';\r\nimport Selectable from './libs/selectable';\r\nimport Nanopop from './libs/nanopop';\r\nimport buildPickr from './template';\r\n\r\nclass Pickr {\r\n\r\n // Will be used to prevent specific actions during initilization\r\n _initializingActive = true;\r\n\r\n // If the current color value should be recalculated\r\n _recalc = true;\r\n\r\n // Current and last color for comparison\r\n _color = HSVaColor();\r\n _lastColor = HSVaColor();\r\n _swatchColors = [];\r\n\r\n // Evenlistener name: [callbacks]\r\n _eventListener = {\r\n init: [],\r\n save: [],\r\n hide: [],\r\n show: [],\r\n clear: [],\r\n change: [],\r\n changestop: [],\r\n cancel: [],\r\n swatchselect: []\r\n };\r\n\r\n constructor(opt) {\r\n\r\n // Assign default values\r\n this.options = opt = Object.assign({\r\n appClass: null,\r\n theme: 'classic',\r\n useAsButton: false,\r\n padding: 8,\r\n disabled: false,\r\n comparison: true,\r\n closeOnScroll: false,\r\n outputPrecision: 0,\r\n lockOpacity: false,\r\n autoReposition: true,\r\n container: 'body',\r\n components: {\r\n interaction: {}\r\n },\r\n\r\n i18n: null,\r\n swatches: null,\r\n inline: false,\r\n sliders: null,\r\n\r\n default: '#42445a',\r\n defaultRepresentation: null,\r\n position: 'bottom-middle',\r\n adjustableNumbers: true,\r\n showAlways: false,\r\n\r\n closeWithKey: 'Escape'\r\n }, opt);\r\n\r\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\r\n\r\n if (['nano', 'monolith'].includes(theme) && !sliders) {\r\n opt.sliders = 'h';\r\n }\r\n\r\n // Check interaction section\r\n if (!components.interaction) {\r\n components.interaction = {};\r\n }\r\n\r\n // Overwrite palette if preview, opacity or hue are true\r\n const {preview, opacity, hue, palette} = components;\r\n components.opacity = (!lockOpacity && opacity);\r\n components.palette = palette || preview || opacity || hue;\r\n\r\n // Initialize picker\r\n this._preBuild();\r\n this._buildComponents();\r\n this._bindEvents();\r\n this._finalBuild();\r\n\r\n // Append pre-defined swatch colors\r\n if (swatches && swatches.length) {\r\n swatches.forEach(color => this.addSwatch(color));\r\n }\r\n\r\n // Initialize positioning engine\r\n const {button, app} = this._root;\r\n this._nanopop = Nanopop({\r\n reference: button,\r\n padding,\r\n el: app\r\n });\r\n\r\n // Initialize accessibility\r\n button.setAttribute('role', 'button');\r\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\r\n\r\n // Initilization is finish, pickr is visible and ready for usage\r\n const that = this;\r\n requestAnimationFrame((function cb() {\r\n\r\n if (!app.offsetWidth && app.parentElement !== opt.container) {\r\n return requestAnimationFrame(cb);\r\n }\r\n\r\n // Apply default color\r\n that.setColor(opt.default);\r\n that._rePositioningPicker();\r\n\r\n // Initialize color representation\r\n if (opt.defaultRepresentation) {\r\n that._representation = opt.defaultRepresentation;\r\n that.setColorRepresentation(that._representation);\r\n }\r\n\r\n // Show pickr if locked\r\n if (opt.showAlways) {\r\n that.show();\r\n }\r\n\r\n // Initialization is done - pickr is usable, fire init event\r\n that._initializingActive = false;\r\n that._emit('init');\r\n }));\r\n }\r\n\r\n // Does only the absolutly basic thing to initialize the components\r\n _preBuild() {\r\n const opt = this.options;\r\n\r\n // Resolve elements\r\n for (const type of ['el', 'container']) {\r\n opt[type] = _.resolveElement(opt[type]);\r\n }\r\n\r\n // Create element and append it to body to\r\n // prevent initialization errors\r\n this._root = buildPickr(this._t, opt);\r\n\r\n // Check if a custom button is used\r\n if (opt.useAsButton) {\r\n this._root.button = opt.el; // Replace button with customized button\r\n }\r\n\r\n opt.container.appendChild(this._root.root);\r\n }\r\n\r\n _finalBuild() {\r\n const opt = this.options;\r\n const root = this._root;\r\n\r\n // Remove from body\r\n opt.container.removeChild(root.root);\r\n\r\n if (opt.inline) {\r\n const parent = opt.el.parentElement;\r\n\r\n if (opt.el.nextSibling) {\r\n parent.insertBefore(root.app, opt.el.nextSibling);\r\n } else {\r\n parent.appendChild(root.app);\r\n }\r\n } else {\r\n opt.container.appendChild(root.app);\r\n }\r\n\r\n // Don't replace the the element if a custom button is used\r\n if (!opt.useAsButton) {\r\n\r\n // Replace element with actual color-picker\r\n opt.el.parentNode.replaceChild(root.root, opt.el);\r\n } else if (opt.inline) {\r\n opt.el.remove();\r\n }\r\n\r\n // Check if it should be immediatly disabled\r\n if (opt.disabled) {\r\n this.disable();\r\n }\r\n\r\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\r\n if (!opt.comparison) {\r\n root.button.style.transition = 'none';\r\n if (!opt.useAsButton) {\r\n root.preview.lastColor.style.transition = 'none';\r\n }\r\n }\r\n\r\n this.hide();\r\n }\r\n\r\n _buildComponents() {\r\n\r\n // Instance reference\r\n const inst = this;\r\n const cs = this.options.components;\r\n const sliders = (inst.options.sliders || 'v').repeat(2);\r\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\r\n\r\n // Re-assign if null\r\n const getColor = () =>\r\n this._color || (this._color = this._lastColor.clone());\r\n\r\n const components = {\r\n\r\n palette: Moveable({\r\n element: inst._root.palette.picker,\r\n wrapper: inst._root.palette.palette,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(x, y) {\r\n if (!cs.palette) return;\r\n\r\n const color = getColor();\r\n const {_root, options} = inst;\r\n\r\n // Update the input field only if the user is currently not typing\r\n if (inst._recalc) {\r\n\r\n // Calculate saturation based on the position\r\n color.s = x * 100;\r\n\r\n // Calculate the value\r\n color.v = 100 - y * 100;\r\n\r\n // Prevent falling under zero\r\n color.v < 0 ? color.v = 0 : 0;\r\n inst._updateOutput();\r\n }\r\n\r\n // Set picker and gradient color\r\n const cssRGBaString = color.toRGBA().toString(0);\r\n this.element.style.background = cssRGBaString;\r\n this.wrapper.style.background = `\r\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\r\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\r\n `;\r\n\r\n // Check if color is locked\r\n if (!options.comparison) {\r\n _root.button.style.color = cssRGBaString;\r\n } else {\r\n if (!options.useAsButton && !inst._lastColor) {\r\n _root.preview.lastColor.style.color = cssRGBaString;\r\n }\r\n }\r\n\r\n // Check if there's a swatch which color matches the current one\r\n const hexa = color.toHEXA().toString();\r\n for (const {el, color} of inst._swatchColors) {\r\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\r\n }\r\n\r\n // Change current color\r\n _root.preview.currentColor.style.color = cssRGBaString;\r\n\r\n if (!inst.options.comparison) {\r\n\r\n // If the user changes the color, remove the cleared icon\r\n _root.button.classList.remove('clear');\r\n }\r\n }\r\n }),\r\n\r\n hue: Moveable({\r\n lock: sh === 'v' ? 'h' : 'v',\r\n element: inst._root.hue.picker,\r\n wrapper: inst._root.hue.slider,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(v) {\r\n if (!cs.hue || !cs.palette) return;\r\n const color = getColor();\r\n\r\n // Calculate hue\r\n if (inst._recalc) {\r\n color.h = v * 360;\r\n }\r\n\r\n // Update color\r\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\r\n components.palette.trigger();\r\n }\r\n }),\r\n\r\n opacity: Moveable({\r\n lock: so === 'v' ? 'h' : 'v',\r\n element: inst._root.opacity.picker,\r\n wrapper: inst._root.opacity.slider,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(v) {\r\n if (!cs.opacity || !cs.palette) return;\r\n const color = getColor();\r\n\r\n // Calculate opacity\r\n if (inst._recalc) {\r\n color.a = Math.round(v * 1e2) / 100;\r\n }\r\n\r\n // Update color\r\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\r\n components.palette.trigger();\r\n }\r\n }),\r\n\r\n selectable: Selectable({\r\n elements: inst._root.interaction.options,\r\n className: 'active',\r\n\r\n onchange(e) {\r\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\r\n inst._recalc && inst._updateOutput();\r\n }\r\n })\r\n };\r\n\r\n this._components = components;\r\n }\r\n\r\n _bindEvents() {\r\n const {_root, options} = this;\r\n\r\n const eventBindings = [\r\n\r\n // Clear color\r\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\r\n\r\n // Select last color on click\r\n _.on([\r\n _root.interaction.cancel,\r\n _root.preview.lastColor\r\n ], 'click', () => {\r\n this._emit('cancel', this);\r\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\r\n }),\r\n\r\n // Save color\r\n _.on(_root.interaction.save, 'click', () => {\r\n !this.applyColor() && !options.showAlways && this.hide();\r\n }),\r\n\r\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\r\n\r\n // Fire listener if initialization is finish and changed color was valid\r\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\r\n this._emit('change', this._color);\r\n }\r\n\r\n e.stopImmediatePropagation();\r\n }),\r\n\r\n // Detect user input and disable auto-recalculation\r\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\r\n this._recalc = e.type === 'blur';\r\n this._recalc && this._updateOutput();\r\n }),\r\n\r\n // Cancel input detection on color change\r\n _.on([\r\n _root.palette.palette,\r\n _root.palette.picker,\r\n _root.hue.slider,\r\n _root.hue.picker,\r\n _root.opacity.slider,\r\n _root.opacity.picker\r\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\r\n ];\r\n\r\n // Provide hiding / showing abilities only if showAlways is false\r\n if (!options.showAlways) {\r\n const ck = options.closeWithKey;\r\n\r\n eventBindings.push(\r\n // Save and hide / show picker\r\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\r\n\r\n // Close with escape key\r\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\r\n\r\n // Cancel selecting if the user taps behind the color picker\r\n _.on(document, ['touchstart', 'mousedown'], e => {\r\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\r\n this.hide();\r\n }\r\n }, {capture: true})\r\n );\r\n }\r\n\r\n // Make input adjustable if enabled\r\n if (options.adjustableNumbers) {\r\n const ranges = {\r\n rgba: [255, 255, 255, 1],\r\n hsva: [360, 100, 100, 1],\r\n hsla: [360, 100, 100, 1],\r\n cmyk: [100, 100, 100, 100]\r\n };\r\n\r\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\r\n const range = ranges[this.getColorRepresentation().toLowerCase()];\r\n\r\n if (range) {\r\n const max = range[index];\r\n\r\n // Calculate next reasonable number\r\n const nv = o + (max >= 100 ? step * 1000 : step);\r\n\r\n // Apply range of zero up to max, fix floating-point issues\r\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\r\n }\r\n\r\n return o;\r\n });\r\n }\r\n\r\n if (options.autoReposition && !options.inline) {\r\n let timeout = null;\r\n const that = this;\r\n\r\n // Re-calc position on window resize, scroll and wheel\r\n eventBindings.push(\r\n _.on(window, ['scroll', 'resize'], () => {\r\n if (that.isOpen()) {\r\n\r\n if (options.closeOnScroll) {\r\n that.hide();\r\n }\r\n\r\n if (timeout === null) {\r\n timeout = setTimeout(() => timeout = null, 100);\r\n\r\n // Update position on every frame\r\n requestAnimationFrame(function rs() {\r\n that._rePositioningPicker();\r\n (timeout !== null) && requestAnimationFrame(rs);\r\n });\r\n } else {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(() => timeout = null, 100);\r\n }\r\n }\r\n }, {capture: true})\r\n );\r\n }\r\n\r\n // Save bindings\r\n this._eventBindings = eventBindings;\r\n }\r\n\r\n _rePositioningPicker() {\r\n const {options} = this;\r\n\r\n // No repositioning needed if inline\r\n if (!options.inline) {\r\n const {app} = this._root;\r\n\r\n if (matchMedia('(max-width: 576px)').matches) {\r\n Object.assign(app.style, {\r\n margin: 'auto',\r\n height: `${app.getBoundingClientRect().height}px`,\r\n top: 0,\r\n bottom: 0,\r\n left: 0,\r\n right: 0\r\n });\r\n } else {\r\n Object.assign(app.style, {\r\n margin: null,\r\n right: null,\r\n top: null,\r\n bottom: null,\r\n left: null,\r\n height: null\r\n });\r\n\r\n this._nanopop.update(options.position);\r\n }\r\n }\r\n }\r\n\r\n _updateOutput() {\r\n const {_root, _color, options} = this;\r\n\r\n // Check if component is present\r\n if (_root.interaction.type()) {\r\n\r\n // Construct function name and call if present\r\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\r\n _root.interaction.result.value = typeof _color[method] === 'function' ?\r\n _color[method]().toString(options.outputPrecision) : '';\r\n }\r\n\r\n // Fire listener if initialization is finish\r\n if (!this._initializingActive && this._recalc) {\r\n this._emit('change', _color);\r\n }\r\n }\r\n\r\n _clearColor(silent = false) {\r\n const {_root, options} = this;\r\n\r\n // Change only the button color if it isn't customized\r\n if (!options.useAsButton) {\r\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\r\n }\r\n\r\n _root.button.classList.add('clear');\r\n\r\n if (!options.showAlways) {\r\n this.hide();\r\n }\r\n\r\n this._lastColor = null;\r\n if (!this._initializingActive && !silent) {\r\n\r\n // Fire listener\r\n this._emit('save', null);\r\n this._emit('clear', this);\r\n }\r\n }\r\n\r\n _parseLocalColor(str) {\r\n const {values, type, a} = parseToHSVA(str);\r\n const {lockOpacity} = this.options;\r\n const alphaMakesAChange = a !== undefined && a !== 1;\r\n\r\n // If no opacity is applied, add undefined at the very end which gets\r\n // set to 1 in setHSVA\r\n if (values && values.length === 3) {\r\n values[3] = undefined;\r\n }\r\n\r\n return {\r\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\r\n type\r\n };\r\n }\r\n\r\n _emit(event, ...args) {\r\n this._eventListener[event].forEach(cb => cb(...args, this));\r\n }\r\n\r\n _t(key, def = 'unknown') {\r\n return this.options.i18n[key] || def;\r\n }\r\n\r\n on(event, cb) {\r\n\r\n // Validate\r\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\r\n this._eventListener[event].push(cb);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n off(event, cb) {\r\n const callBacks = this._eventListener[event];\r\n\r\n if (callBacks) {\r\n const index = callBacks.indexOf(cb);\r\n\r\n if (~index) {\r\n callBacks.splice(index, 1);\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Appends a color to the swatch palette\r\n * @param color\r\n * @returns {boolean}\r\n */\r\n addSwatch(color) {\r\n const {values} = this._parseLocalColor(color);\r\n\r\n if (values) {\r\n const {_swatchColors, _root} = this;\r\n const color = HSVaColor(...values);\r\n\r\n // Create new swatch HTMLElement\r\n const el = _.createElementFromString(\r\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pickr.min.js b/dist/pickr.min.js index bcb5d855..e5eaa55d 100644 --- a/dist/pickr.min.js +++ b/dist/pickr.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e);var n={};function i(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function r(t){for(var e=1;e>/g).reduce((t,e,o,n)=>(t=t.querySelector(e),ot)){function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,r=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,o)=>o<=r&&o+t.length>=r?(r=o,e(Number(t),n,i)):(i++,t)),t.focus(),t.setSelectionRange(r,r),o.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",()=>c(window,"wheel",o,{passive:!1})),c(t,"blur",()=>a(window,"wheel",o))}const{min:v,max:b,floor:g,round:y}=Math;function _(t,e,o){e/=100,o/=100;const n=g(t=t/360*6),i=t-n,r=o*(1-e),s=o*(1-i*e),c=o*(1-(1-i)*e),a=n%6;return[255*[o,s,r,r,c,o][a],255*[c,o,o,s,r,r][a],255*[r,r,c,o,o,s][a]]}function w(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function C(t,e,o){let n,i,r;const s=v(t/=255,e/=255,o/=255),c=b(t,e,o),a=c-s;if(0===a)n=i=0;else{i=a/c;const r=((c-t)/6+a/2)/a,s=((c-e)/6+a/2)/a,l=((c-o)/6+a/2)/a;t===c?n=l-s:e===c?n=1/3+r-l:o===c&&(n=2/3+s-r),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(r=c)]}function A(t,e,o,n){return e/=100,o/=100,[...C(255*(1-v(1,(t/=100)*(1-(n/=100))+n)),255*(1-v(1,e*(1-n)+n)),255*(1-v(1,o*(1-n)+n)))]}function k(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function S(t){return C(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function O(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const r=!!n[2];switch(i){case"cmyk":{const[,t,e,r,s]=o(n);if(t>100||e>100||r>100||s>100)break t;return{values:A(t,e,r,s),type:i}}case"rgba":{const[,,,t,e,s,c]=o(n);if(t>255||e>255||s>255||c<0||c>1||r===!c)break t;return{values:[...C(t,e,s),c],a:c,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map(t=>t+t).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...S(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[...k(t,e,s),c],a:c,type:i}}case"hsva":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[t,e,s,c],a:c,type:i}}}}return{values:null,type:null}}function j(t=0,e=0,o=0,n=1){const i=(t,e)=>(o=-1)=>e(~o?t.map(t=>Number(t.toFixed(o))):t),r={h:t,s:e,v:o,a:n,toHSVA(){const t=[r.h,r.s,r.v,r.a];return t.toString=i(t,t=>"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toHSLA(){const t=[...w(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toRGBA(){const t=[..._(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(r.a,")")),t},toCMYK(){const t=function(t,e,o){const n=_(t,e,o),i=n[0]/255,r=n[1]/255,s=n[2]/255;let c,a,l,p;return[100*(a=1===(c=v(1-i,1-r,1-s))?0:(1-i-c)/(1-c)),100*(l=1===c?0:(1-r-c)/(1-c)),100*(p=1===c?0:(1-s-c)/(1-c)),100*c]}(r.h,r.s,r.v);return t.toString=i(t,t=>"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")),t},toHEXA(){const t=function(t,e,o){return _(t,e,o).map(t=>y(t).toString(16).padStart(2,"0"))}(r.h,r.s,r.v),e=r.a>=1?"":Number((255*r.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>"#".concat(t.join("").toUpperCase()),t},clone:()=>j(r.h,r.s,r.v,r.a)};return r}const x=t=>Math.max(Math.min(t,1),0);function E(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard({type:t,key:n}){if(document.activeElement===o.wrapper)if("keydown"===t){let t=0,o=0;switch(n){case"ArrowLeft":t--;break;case"ArrowRight":t++;break;case"ArrowUp":o++;break;case"ArrowDown":o++}e.update(x(e.cache.x+.01*t),x(e.cache.y+.01*o))}else n.startsWith("Arrow")&&e.options.onstop()},_tapstart(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:{lock:n},cache:i}=e,{element:r,wrapper:s}=o,c=s.getBoundingClientRect();let a=0,l=0;if(t){const e=t&&t.touches&&t.touches[0];a=t?(e||t).clientX:0,l=t?(e||t).clientY:0,ac.left+c.width&&(a=c.left+c.width),lc.top+c.height&&(l=c.top+c.height),a-=c.left,l-=c.top}else i&&(a=i.x*c.width,l=i.y*c.height);"h"!==n&&(r.style.left="calc(".concat(a/c.width*100,"% - ").concat(r.offsetWidth/2,"px)")),"v"!==n&&(r.style.top="calc(".concat(l/c.height*100,"% - ").concat(r.offsetHeight/2,"px)")),e.cache={x:a/c.width,y:l/c.height};const p=x(a/s.offsetWidth),u=x(l/s.offsetHeight);switch(n){case"v":return o.onchange(p);case"h":return o.onchange(u);default:return o.onchange(p,u)}},_tapstop(){e.options.onstop(),a(document,["mouseup","touchend","touchcancel"],e._tapstop),a(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(t=0,o=0){const{left:n,top:i,width:r,height:s}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+r*t,clientY:i+s*o})},destroy(){const{options:t,_tapstart:o}=e;a([t.wrapper,t.element],"mousedown",o),a([t.wrapper,t.element],"touchstart",o,{passive:!1})}},{options:o,_tapstart:n,_keyboard:i}=e;return c([o.wrapper,o.element],"mousedown",n),c([o.wrapper,o.element],"touchstart",n,{passive:!1}),c(document,["keydown","keyup"],i),e}function L(t={}){t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=c(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)});return{destroy:()=>a(...e)}}function P({el:t,reference:e,padding:o=8}){const n={start:"sme",middle:"mse",end:"ems"},i={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},r=((t={})=>(e,o=t[e])=>{if(o)return o;const[n,i="middle"]=e.split("-"),r="top"===n||"bottom"===n;return t[e]={position:n,variant:i,isVertical:r}})();return{update(s){const{position:c,variant:a,isVertical:l}=r(s),p=e.getBoundingClientRect(),u=t.getBoundingClientRect(),h=t=>t?{t:p.top-u.height-o,b:p.bottom+o}:{r:p.right+o,l:p.left-u.width-o},d=t=>t?{s:p.left+p.width-u.width,m:-u.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-u.height,m:p.bottom-p.height/2-u.height/2,e:p.bottom-p.height},f={};function m(e,o,n){const i="top"===n,r=i?u.height:u.width,s=window[i?"innerHeight":"innerWidth"];for(const i of e){const e=o[i],c=f[n]="".concat(e,"px");if(e>0&&e+r{const c=t=>t?"":'style="display:none" hidden',a=h('\n
\n\n '.concat(o?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(this._t,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:E({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:E({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return this.options.i18n[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(this._t,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:E({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:E({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return this.options.i18n[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this._t, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return this.options.i18n[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\r\nimport * as _ from './utils/utils';\r\nimport {parseToHSVA} from './utils/color';\r\n\r\n// Import classes\r\nimport {HSVaColor} from './utils/hsvacolor';\r\nimport Moveable from './libs/moveable';\r\nimport Selectable from './libs/selectable';\r\nimport Nanopop from './libs/nanopop';\r\nimport buildPickr from './template';\r\n\r\nclass Pickr {\r\n\r\n // Will be used to prevent specific actions during initilization\r\n _initializingActive = true;\r\n\r\n // If the current color value should be recalculated\r\n _recalc = true;\r\n\r\n // Current and last color for comparison\r\n _color = HSVaColor();\r\n _lastColor = HSVaColor();\r\n _swatchColors = [];\r\n\r\n // Evenlistener name: [callbacks]\r\n _eventListener = {\r\n init: [],\r\n save: [],\r\n hide: [],\r\n show: [],\r\n clear: [],\r\n change: [],\r\n changestop: [],\r\n cancel: [],\r\n swatchselect: []\r\n };\r\n\r\n constructor(opt) {\r\n\r\n // Assign default values\r\n this.options = opt = Object.assign({\r\n appClass: null,\r\n theme: 'classic',\r\n useAsButton: false,\r\n padding: 8,\r\n disabled: false,\r\n comparison: true,\r\n closeOnScroll: false,\r\n outputPrecision: 0,\r\n lockOpacity: false,\r\n autoReposition: true,\r\n container: 'body',\r\n components: {\r\n interaction: {}\r\n },\r\n\r\n i18n: null,\r\n swatches: null,\r\n inline: false,\r\n sliders: null,\r\n\r\n default: '#42445a',\r\n defaultRepresentation: null,\r\n position: 'bottom-middle',\r\n adjustableNumbers: true,\r\n showAlways: false,\r\n\r\n closeWithKey: 'Escape'\r\n }, opt);\r\n\r\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\r\n\r\n if (['nano', 'monolith'].includes(theme) && !sliders) {\r\n opt.sliders = 'h';\r\n }\r\n\r\n // Check interaction section\r\n if (!components.interaction) {\r\n components.interaction = {};\r\n }\r\n\r\n // Overwrite palette if preview, opacity or hue are true\r\n const {preview, opacity, hue, palette} = components;\r\n components.opacity = (!lockOpacity && opacity);\r\n components.palette = palette || preview || opacity || hue;\r\n\r\n // Initialize picker\r\n this._preBuild();\r\n this._buildComponents();\r\n this._bindEvents();\r\n this._finalBuild();\r\n\r\n // Append pre-defined swatch colors\r\n if (swatches && swatches.length) {\r\n swatches.forEach(color => this.addSwatch(color));\r\n }\r\n\r\n // Initialize positioning engine\r\n const {button, app} = this._root;\r\n this._nanopop = Nanopop({\r\n reference: button,\r\n padding,\r\n el: app\r\n });\r\n\r\n // Initialize accessibility\r\n button.setAttribute('role', 'button');\r\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\r\n\r\n // Initilization is finish, pickr is visible and ready for usage\r\n const that = this;\r\n requestAnimationFrame((function cb() {\r\n\r\n if (!app.offsetWidth && app.parentElement !== opt.container) {\r\n return requestAnimationFrame(cb);\r\n }\r\n\r\n // Apply default color\r\n that.setColor(opt.default);\r\n that._rePositioningPicker();\r\n\r\n // Initialize color representation\r\n if (opt.defaultRepresentation) {\r\n that._representation = opt.defaultRepresentation;\r\n that.setColorRepresentation(that._representation);\r\n }\r\n\r\n // Show pickr if locked\r\n if (opt.showAlways) {\r\n that.show();\r\n }\r\n\r\n // Initialization is done - pickr is usable, fire init event\r\n that._initializingActive = false;\r\n that._emit('init');\r\n }));\r\n }\r\n\r\n // Does only the absolutly basic thing to initialize the components\r\n _preBuild() {\r\n const opt = this.options;\r\n\r\n // Resolve elements\r\n for (const type of ['el', 'container']) {\r\n opt[type] = _.resolveElement(opt[type]);\r\n }\r\n\r\n // Create element and append it to body to\r\n // prevent initialization errors\r\n this._root = buildPickr(this._t, opt);\r\n\r\n // Check if a custom button is used\r\n if (opt.useAsButton) {\r\n this._root.button = opt.el; // Replace button with customized button\r\n }\r\n\r\n opt.container.appendChild(this._root.root);\r\n }\r\n\r\n _finalBuild() {\r\n const opt = this.options;\r\n const root = this._root;\r\n\r\n // Remove from body\r\n opt.container.removeChild(root.root);\r\n\r\n if (opt.inline) {\r\n const parent = opt.el.parentElement;\r\n\r\n if (opt.el.nextSibling) {\r\n parent.insertBefore(root.app, opt.el.nextSibling);\r\n } else {\r\n parent.appendChild(root.app);\r\n }\r\n } else {\r\n opt.container.appendChild(root.app);\r\n }\r\n\r\n // Don't replace the the element if a custom button is used\r\n if (!opt.useAsButton) {\r\n\r\n // Replace element with actual color-picker\r\n opt.el.parentNode.replaceChild(root.root, opt.el);\r\n } else if (opt.inline) {\r\n opt.el.remove();\r\n }\r\n\r\n // Check if it should be immediatly disabled\r\n if (opt.disabled) {\r\n this.disable();\r\n }\r\n\r\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\r\n if (!opt.comparison) {\r\n root.button.style.transition = 'none';\r\n if (!opt.useAsButton) {\r\n root.preview.lastColor.style.transition = 'none';\r\n }\r\n }\r\n\r\n this.hide();\r\n }\r\n\r\n _buildComponents() {\r\n\r\n // Instance reference\r\n const inst = this;\r\n const cs = this.options.components;\r\n const sliders = (inst.options.sliders || 'v').repeat(2);\r\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\r\n\r\n // Re-assign if null\r\n const getColor = () =>\r\n this._color || (this._color = this._lastColor.clone());\r\n\r\n const components = {\r\n\r\n palette: Moveable({\r\n element: inst._root.palette.picker,\r\n wrapper: inst._root.palette.palette,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(x, y) {\r\n if (!cs.palette) return;\r\n\r\n const color = getColor();\r\n const {_root, options} = inst;\r\n\r\n // Update the input field only if the user is currently not typing\r\n if (inst._recalc) {\r\n\r\n // Calculate saturation based on the position\r\n color.s = x * 100;\r\n\r\n // Calculate the value\r\n color.v = 100 - y * 100;\r\n\r\n // Prevent falling under zero\r\n color.v < 0 ? color.v = 0 : 0;\r\n inst._updateOutput();\r\n }\r\n\r\n // Set picker and gradient color\r\n const cssRGBaString = color.toRGBA().toString(0);\r\n this.element.style.background = cssRGBaString;\r\n this.wrapper.style.background = `\r\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\r\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\r\n `;\r\n\r\n // Check if color is locked\r\n if (!options.comparison) {\r\n _root.button.style.color = cssRGBaString;\r\n } else {\r\n if (!options.useAsButton && !inst._lastColor) {\r\n _root.preview.lastColor.style.color = cssRGBaString;\r\n }\r\n }\r\n\r\n // Check if there's a swatch which color matches the current one\r\n const hexa = color.toHEXA().toString();\r\n for (const {el, color} of inst._swatchColors) {\r\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\r\n }\r\n\r\n // Change current color\r\n _root.preview.currentColor.style.color = cssRGBaString;\r\n\r\n if (!inst.options.comparison) {\r\n\r\n // If the user changes the color, remove the cleared icon\r\n _root.button.classList.remove('clear');\r\n }\r\n }\r\n }),\r\n\r\n hue: Moveable({\r\n lock: sh === 'v' ? 'h' : 'v',\r\n element: inst._root.hue.picker,\r\n wrapper: inst._root.hue.slider,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(v) {\r\n if (!cs.hue || !cs.palette) return;\r\n const color = getColor();\r\n\r\n // Calculate hue\r\n if (inst._recalc) {\r\n color.h = v * 360;\r\n }\r\n\r\n // Update color\r\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\r\n components.palette.trigger();\r\n }\r\n }),\r\n\r\n opacity: Moveable({\r\n lock: so === 'v' ? 'h' : 'v',\r\n element: inst._root.opacity.picker,\r\n wrapper: inst._root.opacity.slider,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(v) {\r\n if (!cs.opacity || !cs.palette) return;\r\n const color = getColor();\r\n\r\n // Calculate opacity\r\n if (inst._recalc) {\r\n color.a = Math.round(v * 1e2) / 100;\r\n }\r\n\r\n // Update color\r\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\r\n components.palette.trigger();\r\n }\r\n }),\r\n\r\n selectable: Selectable({\r\n elements: inst._root.interaction.options,\r\n className: 'active',\r\n\r\n onchange(e) {\r\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\r\n inst._recalc && inst._updateOutput();\r\n }\r\n })\r\n };\r\n\r\n this._components = components;\r\n }\r\n\r\n _bindEvents() {\r\n const {_root, options} = this;\r\n\r\n const eventBindings = [\r\n\r\n // Clear color\r\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\r\n\r\n // Select last color on click\r\n _.on([\r\n _root.interaction.cancel,\r\n _root.preview.lastColor\r\n ], 'click', () => {\r\n this._emit('cancel', this);\r\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\r\n }),\r\n\r\n // Save color\r\n _.on(_root.interaction.save, 'click', () => {\r\n !this.applyColor() && !options.showAlways && this.hide();\r\n }),\r\n\r\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\r\n\r\n // Fire listener if initialization is finish and changed color was valid\r\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\r\n this._emit('change', this._color);\r\n }\r\n\r\n e.stopImmediatePropagation();\r\n }),\r\n\r\n // Detect user input and disable auto-recalculation\r\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\r\n this._recalc = e.type === 'blur';\r\n this._recalc && this._updateOutput();\r\n }),\r\n\r\n // Cancel input detection on color change\r\n _.on([\r\n _root.palette.palette,\r\n _root.palette.picker,\r\n _root.hue.slider,\r\n _root.hue.picker,\r\n _root.opacity.slider,\r\n _root.opacity.picker\r\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\r\n ];\r\n\r\n // Provide hiding / showing abilities only if showAlways is false\r\n if (!options.showAlways) {\r\n const ck = options.closeWithKey;\r\n\r\n eventBindings.push(\r\n // Save and hide / show picker\r\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\r\n\r\n // Close with escape key\r\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\r\n\r\n // Cancel selecting if the user taps behind the color picker\r\n _.on(document, ['touchstart', 'mousedown'], e => {\r\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\r\n this.hide();\r\n }\r\n }, {capture: true})\r\n );\r\n }\r\n\r\n // Make input adjustable if enabled\r\n if (options.adjustableNumbers) {\r\n const ranges = {\r\n rgba: [255, 255, 255, 1],\r\n hsva: [360, 100, 100, 1],\r\n hsla: [360, 100, 100, 1],\r\n cmyk: [100, 100, 100, 100]\r\n };\r\n\r\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\r\n const range = ranges[this.getColorRepresentation().toLowerCase()];\r\n\r\n if (range) {\r\n const max = range[index];\r\n\r\n // Calculate next reasonable number\r\n const nv = o + (max >= 100 ? step * 1000 : step);\r\n\r\n // Apply range of zero up to max, fix floating-point issues\r\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\r\n }\r\n\r\n return o;\r\n });\r\n }\r\n\r\n if (options.autoReposition && !options.inline) {\r\n let timeout = null;\r\n const that = this;\r\n\r\n // Re-calc position on window resize, scroll and wheel\r\n eventBindings.push(\r\n _.on(window, ['scroll', 'resize'], () => {\r\n if (that.isOpen()) {\r\n\r\n if (options.closeOnScroll) {\r\n that.hide();\r\n }\r\n\r\n if (timeout === null) {\r\n timeout = setTimeout(() => timeout = null, 100);\r\n\r\n // Update position on every frame\r\n requestAnimationFrame(function rs() {\r\n that._rePositioningPicker();\r\n (timeout !== null) && requestAnimationFrame(rs);\r\n });\r\n } else {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(() => timeout = null, 100);\r\n }\r\n }\r\n }, {capture: true})\r\n );\r\n }\r\n\r\n // Save bindings\r\n this._eventBindings = eventBindings;\r\n }\r\n\r\n _rePositioningPicker() {\r\n const {options} = this;\r\n\r\n // No repositioning needed if inline\r\n if (!options.inline) {\r\n const {app} = this._root;\r\n\r\n if (matchMedia('(max-width: 576px)').matches) {\r\n Object.assign(app.style, {\r\n margin: 'auto',\r\n height: `${app.getBoundingClientRect().height}px`,\r\n top: 0,\r\n bottom: 0,\r\n left: 0,\r\n right: 0\r\n });\r\n } else {\r\n Object.assign(app.style, {\r\n margin: null,\r\n right: null,\r\n top: null,\r\n bottom: null,\r\n left: null,\r\n height: null\r\n });\r\n\r\n this._nanopop.update(options.position);\r\n }\r\n }\r\n }\r\n\r\n _updateOutput() {\r\n const {_root, _color, options} = this;\r\n\r\n // Check if component is present\r\n if (_root.interaction.type()) {\r\n\r\n // Construct function name and call if present\r\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\r\n _root.interaction.result.value = typeof _color[method] === 'function' ?\r\n _color[method]().toString(options.outputPrecision) : '';\r\n }\r\n\r\n // Fire listener if initialization is finish\r\n if (!this._initializingActive && this._recalc) {\r\n this._emit('change', _color);\r\n }\r\n }\r\n\r\n _clearColor(silent = false) {\r\n const {_root, options} = this;\r\n\r\n // Change only the button color if it isn't customized\r\n if (!options.useAsButton) {\r\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\r\n }\r\n\r\n _root.button.classList.add('clear');\r\n\r\n if (!options.showAlways) {\r\n this.hide();\r\n }\r\n\r\n this._lastColor = null;\r\n if (!this._initializingActive && !silent) {\r\n\r\n // Fire listener\r\n this._emit('save', null);\r\n this._emit('clear', this);\r\n }\r\n }\r\n\r\n _parseLocalColor(str) {\r\n const {values, type, a} = parseToHSVA(str);\r\n const {lockOpacity} = this.options;\r\n const alphaMakesAChange = a !== undefined && a !== 1;\r\n\r\n // If no opacity is applied, add undefined at the very end which gets\r\n // set to 1 in setHSVA\r\n if (values && values.length === 3) {\r\n values[3] = undefined;\r\n }\r\n\r\n return {\r\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\r\n type\r\n };\r\n }\r\n\r\n _emit(event, ...args) {\r\n this._eventListener[event].forEach(cb => cb(...args, this));\r\n }\r\n\r\n _t(key, def = 'unknown') {\r\n return this.options.i18n[key] || def;\r\n }\r\n\r\n on(event, cb) {\r\n\r\n // Validate\r\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\r\n this._eventListener[event].push(cb);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n off(event, cb) {\r\n const callBacks = this._eventListener[event];\r\n\r\n if (callBacks) {\r\n const index = callBacks.indexOf(cb);\r\n\r\n if (~index) {\r\n callBacks.splice(index, 1);\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Appends a color to the swatch palette\r\n * @param color\r\n * @returns {boolean}\r\n */\r\n addSwatch(color) {\r\n const {values} = this._parseLocalColor(color);\r\n\r\n if (values) {\r\n const {_swatchColors, _root} = this;\r\n const color = HSVaColor(...values);\r\n\r\n // Create new swatch HTMLElement\r\n const el = _.createElementFromString(\r\n `','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ')),(u=s.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),u.type=function(){return u.options.find(function(t){return t.classList.contains("active")})},s),p.useAsButton&&(this._root.button=p.el),p.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return this.options.i18n[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=E.apply(void 0,M(n)),a=u('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ")),(p=u.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),p.type=function(){return p.options.find(function(t){return t.classList.contains("active")})},u),f.useAsButton&&(this._root.button=f.el),f.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return(this.options.i18n||{})[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=x.apply(void 0,M(n)),a=u(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/js/utils/utils.js","webpack:///./src/js/utils/color.js","webpack:///./src/js/utils/hsvacolor.js","webpack:///./src/js/libs/moveable.js","webpack:///./src/js/libs/selectable.js","webpack:///./src/js/libs/nanopop.js","webpack:///./src/js/pickr.js","webpack:///./src/js/template.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","on","eventListener","off","method","elements","events","fn","options","HTMLCollection","NodeList","Array","from","isArray","el","ev","capture","slice","arguments","createElementFromString","html","div","document","createElement","innerHTML","trim","firstElementChild","removeAttribute","getAttribute","createFromTemplate","str","resolve","element","base","con","subtree","children","child","arr","sub","push","keys","length","eventPath","evt","path","composedPath","target","parentElement","resolveElement","val","Element","split","reduce","pv","cv","ci","a","querySelector","shadowRoot","adjustableInputNumbers","mapper","v","handleScroll","e","inc","Number","shiftKey","ctrlKey","deltaY","index","selectionStart","replace","focus","setSelectionRange","preventDefault","dispatchEvent","Event","passive","min","Math","max","floor","round","hsvToRgb","h","f","q","mod","rgbToHsv","g","b","minVal","maxVal","delta","dr","dg","db","cmykToHsv","y","k","hslToHsv","hexToHsv","hex","match","map","parseInt","parseToHSVA","toLowerCase","ctx","getContext","fillStyle","standardizeColor","regex","cmyk","rgba","hsla","hsva","hexa","numarize","array","test","undefined","invalid","type","exec","alpha","values","join","raw","substring","HSVaColor","original","next","precision","toFixed","that","toHSVA","toString","toHSLA","hsvToHsl","toRGBA","toCMYK","rgb","hsvToCmyk","toHEXA","padStart","hsvToHex","toUpperCase","clone","clamp","Moveable","opt","assign","lock","onchange","onstop","_keyboard","activeElement","wrapper","xm","ym","update","cache","x","startsWith","_tapstart","_","_tapstop","_tapmove","getBoundingClientRect","touch","touches","clientX","clientY","left","width","top","height","style","offsetWidth","offsetHeight","cx","cy","trigger","destroy","Selectable","className","onTap","forEach","classList","Nanopop","reference","padding","vBehaviour","start","middle","end","hBehaviour","right","bottom","getInfo","pos","cached","position","variant","isVertical","rb","eb","variants","vertical","leastApplied","apply","bevs","vars","styleprop","adder","win","sv","rot","v2Ok","v1Ok","Pickr","init","save","hide","show","clear","change","changestop","cancel","swatchselect","this","appClass","theme","useAsButton","disabled","comparison","closeOnScroll","outputPrecision","lockOpacity","autoReposition","container","components","interaction","i18n","swatches","inline","sliders","default","defaultRepresentation","adjustableNumbers","showAlways","closeWithKey","includes","preview","opacity","hue","palette","_preBuild","_buildComponents","_bindEvents","_finalBuild","color","addSwatch","_root","button","app","_nanopop","setAttribute","_t","requestAnimationFrame","cb","setColor","_rePositioningPicker","_representation","setColorRepresentation","_initializingActive","_emit","inst","lo","hidden","int","input","find","add","contains","appendChild","removeChild","parent","nextSibling","insertBefore","remove","parentNode","replaceChild","disable","transition","lastColor","cs","repeat","so","sh","getColor","_color","_lastColor","picker","_recalc","_updateOutput","cssRGBaString","background","_swatchColors","currentColor","slider","backgroundColor","selectable","_components","eventBindings","_clearColor","setHSVA","applyColor","result","stopImmediatePropagation","ck","isOpen","code","some","ranges","step","range","getColorRepresentation","nv","toPrecision","timeout","setTimeout","rs","clearTimeout","_eventBindings","matchMedia","matches","margin","silent","alphaMakesAChange","event","args","_eventListener","def","callBacks","indexOf","splice","_parseLocalColor","swatchColor","recalc","string","utype","click","utils","libs","version"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,IARlB,CASGK,OAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,EAAoBmB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GA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OACLO,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAU+F,IAAI,YACzBrD,O,+BASP,OAFAA,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAUsG,OAAO,YAC5B5D,U,gCAKfV,EAAMqI,MAAQ5L,EAGduD,EAAMsI,KAAO,CACTjO,YACAoB,WACAwC,UACAL,cAIJoC,EAAMvO,OAAS,SAAAiB,GAAO,OAAI,IAAIsN,EAAMtN,IAGpCsN,EAAMuI,QAAU,QACDvI,e","file":"pickr.es5.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pickr\"] = factory();\n\telse\n\t\troot[\"Pickr\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\r\n * Add event(s) to element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const on = eventListener.bind(null, 'addEventListener');\r\n\r\n/**\r\n * Remove event(s) from element(s).\r\n * @param elements DOM-Elements\r\n * @param events Event names\r\n * @param fn Callback\r\n * @param options Optional options\r\n * @return Array passed arguments\r\n */\r\nexport const off = eventListener.bind(null, 'removeEventListener');\r\n\r\nfunction eventListener(method, elements, events, fn, options = {}) {\r\n\r\n // Normalize array\r\n if (elements instanceof HTMLCollection || elements instanceof NodeList) {\r\n elements = Array.from(elements);\r\n } else if (!Array.isArray(elements)) {\r\n elements = [elements];\r\n }\r\n\r\n if (!Array.isArray(events)) {\r\n events = [events];\r\n }\r\n\r\n for (const el of elements) {\r\n for (const ev of events) {\r\n el[method](ev, fn, {capture: false, ...options});\r\n }\r\n }\r\n\r\n return Array.prototype.slice.call(arguments, 1);\r\n}\r\n\r\n/**\r\n * Creates an DOM-Element out of a string (Single element).\r\n * @param html HTML representing a single element\r\n * @returns {Element | null} The element.\r\n */\r\nexport function createElementFromString(html) {\r\n const div = document.createElement('div');\r\n div.innerHTML = html.trim();\r\n return div.firstElementChild;\r\n}\r\n\r\n/**\r\n * Removes an attribute from a HTMLElement and returns the value.\r\n * @param el\r\n * @param name\r\n * @return {string}\r\n */\r\nexport function removeAttribute(el, name) {\r\n const value = el.getAttribute(name);\r\n el.removeAttribute(name);\r\n return value;\r\n}\r\n\r\n/**\r\n * Creates a new html element, every element which has\r\n * a ':ref' attribute will be saved in a object (which will be returned)\r\n * where the value of ':ref' is the object-key and the value the HTMLElement.\r\n *\r\n * It's possible to create a hierarchy if you add a ':obj' attribute. Every\r\n * sibling will be added to the object which will get the name from the 'data-con' attribute.\r\n *\r\n * If you want to create an Array out of multiple elements, you can use the ':arr' attribute,\r\n * the value defines the key and all elements, which has the same parent and the same 'data-arr' attribute,\r\n * would be added to it.\r\n *\r\n * @param str - The HTML String.\r\n */\r\nexport function createFromTemplate(str) {\r\n\r\n // Recursive function to resolve template\r\n function resolve(element, base = {}) {\r\n\r\n // Check key and container attribute\r\n const con = removeAttribute(element, ':obj');\r\n const key = removeAttribute(element, ':ref');\r\n const subtree = con ? (base[con] = {}) : base;\r\n\r\n // Check and save element\r\n key && (base[key] = element);\r\n for (const child of Array.from(element.children)) {\r\n const arr = removeAttribute(child, ':arr');\r\n const sub = resolve(child, arr ? {} : subtree);\r\n\r\n if (arr) {\r\n\r\n // Check if there is already an array and add element\r\n (subtree[arr] || (subtree[arr] = []))\r\n .push(Object.keys(sub).length ? sub : child);\r\n }\r\n }\r\n\r\n return base;\r\n }\r\n\r\n return resolve(createElementFromString(str));\r\n}\r\n\r\n/**\r\n * Polyfill for safari & firefox for the eventPath event property.\r\n * @param evt The event object.\r\n * @return [String] event path.\r\n */\r\nexport function eventPath(evt) {\r\n let path = evt.path || (evt.composedPath && evt.composedPath());\r\n if (path) return path;\r\n\r\n let el = evt.target.parentElement;\r\n path = [evt.target, el];\r\n while (el = el.parentElement) path.push(el);\r\n\r\n path.push(document, window);\r\n return path;\r\n}\r\n\r\n/**\r\n * Resolves a HTMLElement by query.\r\n * @param val\r\n * @returns {null|Document|Element}\r\n */\r\nexport function resolveElement(val) {\r\n if (val instanceof Element) {\r\n return val;\r\n } else if (typeof val === 'string') {\r\n return val.split(/>>/g).reduce((pv, cv, ci, a) => {\r\n pv = pv.querySelector(cv);\r\n return ci < a.length - 1 ? pv.shadowRoot : pv;\r\n }, document);\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Creates the ability to change numbers in an input field with the scroll-wheel.\r\n * @param el\r\n * @param mapper\r\n */\r\nexport function adjustableInputNumbers(el, mapper = v => v) {\r\n\r\n function handleScroll(e) {\r\n const inc = ([0.001, 0.01, 0.1])[Number(e.shiftKey || e.ctrlKey * 2)] * (e.deltaY < 0 ? 1 : -1);\r\n\r\n let index = 0;\r\n let off = el.selectionStart;\r\n el.value = el.value.replace(/[\\d.]+/g, (v, i) => {\r\n\r\n // Check if number is in cursor range and increase it\r\n if (i <= off && i + v.length >= off) {\r\n off = i;\r\n return mapper(Number(v), inc, index);\r\n }\r\n\r\n index++;\r\n return v;\r\n });\r\n\r\n el.focus();\r\n el.setSelectionRange(off, off);\r\n\r\n // Prevent default and trigger input event\r\n e.preventDefault();\r\n el.dispatchEvent(new Event('input'));\r\n }\r\n\r\n // Bind events\r\n on(el, 'focus', () => on(window, 'wheel', handleScroll, {passive: false}));\r\n on(el, 'blur', () => off(window, 'wheel', handleScroll));\r\n}\r\n","// Shorthands\r\nconst {min, max, floor, round} = Math;\r\n\r\n/**\r\n * Tries to convert a color name to rgb/a hex representation\r\n * @param name\r\n * @returns {string | CanvasGradient | CanvasPattern}\r\n */\r\nfunction standardizeColor(name) {\r\n\r\n // Since invalid color's will be parsed as black, filter them out\r\n if (name.toLowerCase() === 'black') {\r\n return '#000000';\r\n }\r\n\r\n const ctx = document.createElement('canvas').getContext('2d');\r\n ctx.fillStyle = name;\r\n return ctx.fillStyle === '#000000' ? null : ctx.fillStyle;\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to RGB.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} Array with rgb values.\r\n */\r\nexport function hsvToRgb(h, s, v) {\r\n h = (h / 360) * 6;\r\n s /= 100;\r\n v /= 100;\r\n\r\n const i = floor(h);\r\n\r\n const f = h - i;\r\n const p = v * (1 - s);\r\n const q = v * (1 - f * s);\r\n const t = v * (1 - (1 - f) * s);\r\n\r\n const mod = i % 6;\r\n const r = [v, q, p, p, t, v][mod];\r\n const g = [t, v, v, q, p, p][mod];\r\n const b = [p, p, t, v, v, q][mod];\r\n\r\n return [\r\n r * 255,\r\n g * 255,\r\n b * 255\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to Hex.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {string[]} Hex values\r\n */\r\nexport function hsvToHex(h, s, v) {\r\n return hsvToRgb(h, s, v).map(v =>\r\n round(v).toString(16).padStart(2, '0')\r\n );\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to CMYK.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} CMYK values\r\n */\r\nexport function hsvToCmyk(h, s, v) {\r\n const rgb = hsvToRgb(h, s, v);\r\n const r = rgb[0] / 255;\r\n const g = rgb[1] / 255;\r\n const b = rgb[2] / 255;\r\n\r\n let k, c, m, y;\r\n\r\n k = min(1 - r, 1 - g, 1 - b);\r\n\r\n c = k === 1 ? 0 : (1 - r - k) / (1 - k);\r\n m = k === 1 ? 0 : (1 - g - k) / (1 - k);\r\n y = k === 1 ? 0 : (1 - b - k) / (1 - k);\r\n\r\n return [\r\n c * 100,\r\n m * 100,\r\n y * 100,\r\n k * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert HSV spectrum to HSL.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param v Value\r\n * @returns {number[]} HSL values\r\n */\r\nexport function hsvToHsl(h, s, v) {\r\n s /= 100, v /= 100;\r\n\r\n const l = (2 - s) * v / 2;\r\n\r\n if (l !== 0) {\r\n if (l === 1) {\r\n s = 0;\r\n } else if (l < 0.5) {\r\n s = s * v / (l * 2);\r\n } else {\r\n s = s * v / (2 - l * 2);\r\n }\r\n }\r\n\r\n return [\r\n h,\r\n s * 100,\r\n l * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert RGB to HSV.\r\n * @param r Red\r\n * @param g Green\r\n * @param b Blue\r\n * @return {number[]} HSV values.\r\n */\r\nfunction rgbToHsv(r, g, b) {\r\n r /= 255, g /= 255, b /= 255;\r\n\r\n let h, s, v;\r\n const minVal = min(r, g, b);\r\n const maxVal = max(r, g, b);\r\n const delta = maxVal - minVal;\r\n\r\n v = maxVal;\r\n if (delta === 0) {\r\n h = s = 0;\r\n } else {\r\n s = delta / maxVal;\r\n const dr = (((maxVal - r) / 6) + (delta / 2)) / delta;\r\n const dg = (((maxVal - g) / 6) + (delta / 2)) / delta;\r\n const db = (((maxVal - b) / 6) + (delta / 2)) / delta;\r\n\r\n if (r === maxVal) {\r\n h = db - dg;\r\n } else if (g === maxVal) {\r\n h = (1 / 3) + dr - db;\r\n } else if (b === maxVal) {\r\n h = (2 / 3) + dg - dr;\r\n }\r\n\r\n if (h < 0) {\r\n h += 1;\r\n } else if (h > 1) {\r\n h -= 1;\r\n }\r\n }\r\n\r\n return [\r\n h * 360,\r\n s * 100,\r\n v * 100\r\n ];\r\n}\r\n\r\n/**\r\n * Convert CMYK to HSV.\r\n * @param c Cyan\r\n * @param m Magenta\r\n * @param y Yellow\r\n * @param k Key (Black)\r\n * @return {number[]} HSV values.\r\n */\r\nfunction cmykToHsv(c, m, y, k) {\r\n c /= 100;\r\n m /= 100;\r\n y /= 100;\r\n k /= 100;\r\n\r\n const r = (1 - min(1, c * (1 - k) + k)) * 255;\r\n const g = (1 - min(1, m * (1 - k) + k)) * 255;\r\n const b = (1 - min(1, y * (1 - k) + k)) * 255;\r\n\r\n return [...rgbToHsv(r, g, b)];\r\n}\r\n\r\n/**\r\n * Convert HSL to HSV.\r\n * @param h Hue\r\n * @param s Saturation\r\n * @param l Lightness\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hslToHsv(h, s, l) {\r\n s /= 100;\r\n l /= 100;\r\n s *= l < 0.5 ? l : 1 - l;\r\n\r\n const ns = (2 * s / (l + s)) * 100;\r\n const v = (l + s) * 100;\r\n return [h, ns, v];\r\n}\r\n\r\n/**\r\n * Convert HEX to HSV.\r\n * @param hex Hexadecimal string of rgb colors, can have length 3 or 6.\r\n * @return {number[]} HSV values.\r\n */\r\nfunction hexToHsv(hex) {\r\n return rgbToHsv(...hex.match(/.{2}/g).map(v => parseInt(v, 16)));\r\n}\r\n\r\n/**\r\n * Try's to parse a string which represents a color to a HSV array.\r\n * Current supported types are cmyk, rgba, hsla and hexadecimal.\r\n * @param str\r\n * @return {*}\r\n */\r\nexport function parseToHSVA(str) {\r\n\r\n // Check if string is a color-name\r\n str = str.match(/^[a-zA-Z]+$/) ? standardizeColor(str) : str;\r\n\r\n // Regular expressions to match different types of color represention\r\n const regex = {\r\n cmyk: /^cmyk[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)/i,\r\n rgba: /^((rgba)|rgb)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsla: /^((hsla)|hsl)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hsva: /^((hsva)|hsv)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\r\n hexa: /^#?(([\\dA-Fa-f]{3,4})|([\\dA-Fa-f]{6})|([\\dA-Fa-f]{8}))$/i\r\n };\r\n\r\n /**\r\n * Takes an Array of any type, convert strings which represents\r\n * a number to a number an anything else to undefined.\r\n * @param array\r\n * @return {*}\r\n */\r\n const numarize = array => array.map(v => /^(|\\d+)\\.\\d+|\\d+$/.test(v) ? Number(v) : undefined);\r\n\r\n let match;\r\n invalid: for (const type in regex) {\r\n\r\n // Check if current scheme passed\r\n if (!(match = regex[type].exec(str)))\r\n continue;\r\n\r\n // match[2] does only contain a truly value if rgba, hsla, or hsla got matched\r\n const alpha = !!match[2];\r\n\r\n // Try to convert\r\n switch (type) {\r\n case 'cmyk': {\r\n const [, c, m, y, k] = numarize(match);\r\n\r\n if (c > 100 || m > 100 || y > 100 || k > 100)\r\n break invalid;\r\n\r\n return {values: cmykToHsv(c, m, y, k), type};\r\n }\r\n case 'rgba': {\r\n const [, , , r, g, b, a] = numarize(match);\r\n\r\n if (r > 255 || g > 255 || b > 255 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...rgbToHsv(r, g, b), a], a, type};\r\n }\r\n case 'hexa': {\r\n let [, hex] = match;\r\n\r\n if (hex.length === 4 || hex.length === 3) {\r\n hex = hex.split('').map(v => v + v).join('');\r\n }\r\n\r\n const raw = hex.substring(0, 6);\r\n let a = hex.substring(6);\r\n\r\n // Convert 0 - 255 to 0 - 1 for opacity\r\n a = a ? (parseInt(a, 16) / 255) : undefined;\r\n\r\n return {values: [...hexToHsv(raw), a], a, type};\r\n }\r\n case 'hsla': {\r\n const [, , , h, s, l, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || l > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [...hslToHsv(h, s, l), a], a, type};\r\n }\r\n case 'hsva': {\r\n const [, , , h, s, v, a] = numarize(match);\r\n\r\n if (h > 360 || s > 100 || v > 100 || a < 0 || a > 1 || (alpha === !a))\r\n break invalid;\r\n\r\n return {values: [h, s, v, a], a, type};\r\n }\r\n }\r\n }\r\n\r\n return {values: null, type: null};\r\n}\r\n","import {hsvToHsl, hsvToRgb, hsvToCmyk, hsvToHex} from './color';\r\n\r\n/**\r\n * Simple class which holds the properties\r\n * of the color represention model hsla (hue saturation lightness alpha)\r\n */\r\nexport function HSVaColor(h = 0, s = 0, v = 0, a = 1) {\r\n const mapper = (original, next) => (precision = -1) => {\r\n return next(~precision ? original.map(v => Number(v.toFixed(precision))) : original);\r\n };\r\n\r\n const that = {\r\n h, s, v, a,\r\n\r\n toHSVA() {\r\n const hsva = [that.h, that.s, that.v, that.a];\r\n hsva.toString = mapper(hsva, arr => `hsva(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsva;\r\n },\r\n\r\n toHSLA() {\r\n const hsla = [...hsvToHsl(that.h, that.s, that.v), that.a];\r\n hsla.toString = mapper(hsla, arr => `hsla(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\r\n return hsla;\r\n },\r\n\r\n toRGBA() {\r\n const rgba = [...hsvToRgb(that.h, that.s, that.v), that.a];\r\n rgba.toString = mapper(rgba, arr => `rgba(${arr[0]}, ${arr[1]}, ${arr[2]}, ${that.a})`);\r\n return rgba;\r\n },\r\n\r\n toCMYK() {\r\n const cmyk = hsvToCmyk(that.h, that.s, that.v);\r\n cmyk.toString = mapper(cmyk, arr => `cmyk(${arr[0]}%, ${arr[1]}%, ${arr[2]}%, ${arr[3]}%)`);\r\n return cmyk;\r\n },\r\n\r\n toHEXA() {\r\n const hex = hsvToHex(that.h, that.s, that.v);\r\n\r\n // Check if alpha channel make sense, convert it to 255 number space, convert\r\n // to hex and pad it with zeros if needet.\r\n const alpha = that.a >= 1 ? '' : Number((that.a * 255).toFixed(0))\r\n .toString(16)\r\n .toUpperCase().padStart(2, '0');\r\n\r\n alpha && hex.push(alpha);\r\n hex.toString = () => `#${hex.join('').toUpperCase()}`;\r\n return hex;\r\n },\r\n\r\n clone: () => HSVaColor(that.h, that.s, that.v, that.a)\r\n };\r\n\r\n return that;\r\n}\r\n","import * as _ from '../utils/utils';\r\n\r\nconst clamp = v => Math.max(Math.min(v, 1), 0);\r\nexport default function Moveable(opt) {\r\n\r\n const that = {\r\n\r\n // Assign default values\r\n options: Object.assign({\r\n lock: null,\r\n onchange: () => 0,\r\n onstop: () => 0\r\n }, opt),\r\n\r\n _keyboard({type, key}) {\r\n\r\n // Check to see if the Movable is focused and then move it based on arrow key inputs\r\n // for improved accessibility\r\n if (document.activeElement === options.wrapper) {\r\n if (type === 'keydown') {\r\n let xm = 0;\r\n let ym = 0;\r\n\r\n switch (key) {\r\n case 'ArrowLeft':\r\n xm--;\r\n break;\r\n case 'ArrowRight':\r\n xm++;\r\n break;\r\n case 'ArrowUp':\r\n ym++;\r\n break;\r\n case 'ArrowDown':\r\n ym++;\r\n }\r\n\r\n that.update(\r\n clamp(that.cache.x + (0.01 * xm)),\r\n clamp(that.cache.y + (0.01 * ym))\r\n );\r\n } else if (key.startsWith('Arrow')) {\r\n that.options.onstop();\r\n }\r\n }\r\n },\r\n\r\n _tapstart(evt) {\r\n _.on(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\r\n _.on(document, ['mousemove', 'touchmove'], that._tapmove);\r\n\r\n // Prevent default touch event\r\n evt.preventDefault();\r\n\r\n // Trigger\r\n that._tapmove(evt);\r\n },\r\n\r\n _tapmove(evt) {\r\n const {options: {lock}, cache} = that;\r\n const {element, wrapper} = options;\r\n const b = wrapper.getBoundingClientRect();\r\n\r\n let x = 0, y = 0;\r\n if (evt) {\r\n const touch = evt && evt.touches && evt.touches[0];\r\n x = evt ? (touch || evt).clientX : 0;\r\n y = evt ? (touch || evt).clientY : 0;\r\n\r\n // Reset to bounds\r\n if (x < b.left) x = b.left;\r\n else if (x > b.left + b.width) x = b.left + b.width;\r\n if (y < b.top) y = b.top;\r\n else if (y > b.top + b.height) y = b.top + b.height;\r\n\r\n // Normalize\r\n x -= b.left;\r\n y -= b.top;\r\n } else if (cache) {\r\n x = cache.x * b.width;\r\n y = cache.y * b.height;\r\n }\r\n\r\n if (lock !== 'h') {\r\n element.style.left = `calc(${x / b.width * 100}% - ${element.offsetWidth / 2}px)`;\r\n }\r\n\r\n if (lock !== 'v') {\r\n element.style.top = `calc(${y / b.height * 100}% - ${element.offsetHeight / 2}px)`;\r\n }\r\n\r\n that.cache = {x: x / b.width, y: y / b.height};\r\n const cx = clamp(x / wrapper.offsetWidth);\r\n const cy = clamp(y / wrapper.offsetHeight);\r\n\r\n switch (lock) {\r\n case 'v':\r\n return options.onchange(cx);\r\n case 'h':\r\n return options.onchange(cy);\r\n default:\r\n return options.onchange(cx, cy);\r\n }\r\n },\r\n\r\n _tapstop() {\r\n that.options.onstop();\r\n _.off(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\r\n _.off(document, ['mousemove', 'touchmove'], that._tapmove);\r\n },\r\n\r\n trigger() {\r\n that._tapmove();\r\n },\r\n\r\n update(x = 0, y = 0) {\r\n const {left, top, width, height} = that.options.wrapper.getBoundingClientRect();\r\n\r\n if (that.options.lock === 'h') {\r\n y = x;\r\n }\r\n\r\n that._tapmove({\r\n clientX: left + width * x,\r\n clientY: top + height * y\r\n });\r\n },\r\n\r\n destroy() {\r\n const {options, _tapstart} = that;\r\n _.off([options.wrapper, options.element], 'mousedown', _tapstart);\r\n _.off([options.wrapper, options.element], 'touchstart', _tapstart, {\r\n passive: false\r\n });\r\n }\r\n };\r\n\r\n // Initilize\r\n const {options, _tapstart, _keyboard} = that;\r\n _.on([options.wrapper, options.element], 'mousedown', _tapstart);\r\n _.on([options.wrapper, options.element], 'touchstart', _tapstart, {\r\n passive: false\r\n });\r\n\r\n _.on(document, ['keydown', 'keyup'], _keyboard);\r\n\r\n\r\n return that;\r\n}\r\n","import * as _ from '../utils/utils';\r\n\r\nexport default function Selectable(opt = {}) {\r\n opt = Object.assign({\r\n onchange: () => 0,\r\n className: '',\r\n elements: []\r\n }, opt);\r\n\r\n const onTap = _.on(opt.elements, 'click', evt => {\r\n opt.elements.forEach(e =>\r\n e.classList[evt.target === e ? 'add' : 'remove'](opt.className)\r\n );\r\n\r\n opt.onchange(evt);\r\n });\r\n\r\n return {\r\n destroy: () => _.off(...onTap)\r\n };\r\n}\r\n","/**\r\n * Micro positioning-engine\r\n * @param el\r\n * @param reference\r\n * @param pos\r\n * @param padding\r\n * @returns {{update(): void}}\r\n * @constructor\r\n */\r\nexport default function Nanopop({el, reference, padding = 8}) {\r\n const vBehaviour = {start: 'sme', middle: 'mse', end: 'ems'};\r\n const hBehaviour = {top: 'tbrl', right: 'rltb', bottom: 'btrl', left: 'lrbt'};\r\n\r\n const getInfo = ((cache = {}) => (pos, cached = cache[pos]) => {\r\n if (cached) return cached;\r\n const [position, variant = 'middle'] = pos.split('-');\r\n const isVertical = (position === 'top' || position === 'bottom');\r\n\r\n return cache[pos] = {\r\n position,\r\n variant,\r\n isVertical\r\n };\r\n })();\r\n\r\n return {\r\n update(pos) {\r\n const {position, variant, isVertical} = getInfo(pos);\r\n const rb = reference.getBoundingClientRect();\r\n const eb = el.getBoundingClientRect();\r\n\r\n const positions = vertical => vertical ? {\r\n t: rb.top - eb.height - padding,\r\n b: rb.bottom + padding\r\n } : {\r\n r: rb.right + padding,\r\n l: rb.left - eb.width - padding\r\n };\r\n\r\n const variants = vertical => vertical ? {\r\n s: rb.left + rb.width - eb.width,\r\n m: (-eb.width / 2) + (rb.left + rb.width / 2),\r\n e: rb.left\r\n } : {\r\n s: rb.bottom - eb.height,\r\n m: rb.bottom - rb.height / 2 - eb.height / 2,\r\n e: rb.bottom - rb.height\r\n };\r\n\r\n const leastApplied = {};\r\n\r\n function apply(bevs, vars, styleprop) {\r\n const vertical = styleprop === 'top';\r\n const adder = vertical ? eb.height : eb.width;\r\n const win = window[vertical ? 'innerHeight' : 'innerWidth'];\r\n\r\n for (const ch of bevs) {\r\n const v = vars[ch];\r\n const sv = leastApplied[styleprop] = `${v}px`;\r\n\r\n if (v > 0 && (v + adder) < win) {\r\n el.style[styleprop] = sv;\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n for (const rot of [isVertical, !isVertical]) {\r\n const v2Ok = apply(hBehaviour[position], positions(rot), rot ? 'top' : 'left');\r\n const v1Ok = apply(vBehaviour[variant], variants(rot), rot ? 'left' : 'top');\r\n\r\n if (v2Ok && v1Ok) {\r\n return;\r\n }\r\n }\r\n\r\n el.style.left = leastApplied.left;\r\n el.style.top = leastApplied.top;\r\n }\r\n };\r\n}\r\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('btn:toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return (this.options.i18n || {})[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pickr.min.js b/dist/pickr.min.js index e5eaa55d..d9a1c3ea 100644 --- a/dist/pickr.min.js +++ b/dist/pickr.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e);var n={};function i(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function r(t){for(var e=1;e>/g).reduce((t,e,o,n)=>(t=t.querySelector(e),ot)){function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,r=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,o)=>o<=r&&o+t.length>=r?(r=o,e(Number(t),n,i)):(i++,t)),t.focus(),t.setSelectionRange(r,r),o.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",()=>c(window,"wheel",o,{passive:!1})),c(t,"blur",()=>a(window,"wheel",o))}const{min:v,max:b,floor:g,round:y}=Math;function _(t,e,o){e/=100,o/=100;const n=g(t=t/360*6),i=t-n,r=o*(1-e),s=o*(1-i*e),c=o*(1-(1-i)*e),a=n%6;return[255*[o,s,r,r,c,o][a],255*[c,o,o,s,r,r][a],255*[r,r,c,o,o,s][a]]}function w(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function C(t,e,o){let n,i,r;const s=v(t/=255,e/=255,o/=255),c=b(t,e,o),a=c-s;if(0===a)n=i=0;else{i=a/c;const r=((c-t)/6+a/2)/a,s=((c-e)/6+a/2)/a,l=((c-o)/6+a/2)/a;t===c?n=l-s:e===c?n=1/3+r-l:o===c&&(n=2/3+s-r),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(r=c)]}function A(t,e,o,n){return e/=100,o/=100,[...C(255*(1-v(1,(t/=100)*(1-(n/=100))+n)),255*(1-v(1,e*(1-n)+n)),255*(1-v(1,o*(1-n)+n)))]}function k(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function S(t){return C(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function O(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const r=!!n[2];switch(i){case"cmyk":{const[,t,e,r,s]=o(n);if(t>100||e>100||r>100||s>100)break t;return{values:A(t,e,r,s),type:i}}case"rgba":{const[,,,t,e,s,c]=o(n);if(t>255||e>255||s>255||c<0||c>1||r===!c)break t;return{values:[...C(t,e,s),c],a:c,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map(t=>t+t).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...S(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[...k(t,e,s),c],a:c,type:i}}case"hsva":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[t,e,s,c],a:c,type:i}}}}return{values:null,type:null}}function j(t=0,e=0,o=0,n=1){const i=(t,e)=>(o=-1)=>e(~o?t.map(t=>Number(t.toFixed(o))):t),r={h:t,s:e,v:o,a:n,toHSVA(){const t=[r.h,r.s,r.v,r.a];return t.toString=i(t,t=>"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toHSLA(){const t=[...w(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toRGBA(){const t=[..._(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(r.a,")")),t},toCMYK(){const t=function(t,e,o){const n=_(t,e,o),i=n[0]/255,r=n[1]/255,s=n[2]/255;let c,a,l,p;return[100*(a=1===(c=v(1-i,1-r,1-s))?0:(1-i-c)/(1-c)),100*(l=1===c?0:(1-r-c)/(1-c)),100*(p=1===c?0:(1-s-c)/(1-c)),100*c]}(r.h,r.s,r.v);return t.toString=i(t,t=>"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")),t},toHEXA(){const t=function(t,e,o){return _(t,e,o).map(t=>y(t).toString(16).padStart(2,"0"))}(r.h,r.s,r.v),e=r.a>=1?"":Number((255*r.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>"#".concat(t.join("").toUpperCase()),t},clone:()=>j(r.h,r.s,r.v,r.a)};return r}const x=t=>Math.max(Math.min(t,1),0);function E(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard({type:t,key:n}){if(document.activeElement===o.wrapper)if("keydown"===t){let t=0,o=0;switch(n){case"ArrowLeft":t--;break;case"ArrowRight":t++;break;case"ArrowUp":o++;break;case"ArrowDown":o++}e.update(x(e.cache.x+.01*t),x(e.cache.y+.01*o))}else n.startsWith("Arrow")&&e.options.onstop()},_tapstart(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:{lock:n},cache:i}=e,{element:r,wrapper:s}=o,c=s.getBoundingClientRect();let a=0,l=0;if(t){const e=t&&t.touches&&t.touches[0];a=t?(e||t).clientX:0,l=t?(e||t).clientY:0,ac.left+c.width&&(a=c.left+c.width),lc.top+c.height&&(l=c.top+c.height),a-=c.left,l-=c.top}else i&&(a=i.x*c.width,l=i.y*c.height);"h"!==n&&(r.style.left="calc(".concat(a/c.width*100,"% - ").concat(r.offsetWidth/2,"px)")),"v"!==n&&(r.style.top="calc(".concat(l/c.height*100,"% - ").concat(r.offsetHeight/2,"px)")),e.cache={x:a/c.width,y:l/c.height};const p=x(a/s.offsetWidth),u=x(l/s.offsetHeight);switch(n){case"v":return o.onchange(p);case"h":return o.onchange(u);default:return o.onchange(p,u)}},_tapstop(){e.options.onstop(),a(document,["mouseup","touchend","touchcancel"],e._tapstop),a(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(t=0,o=0){const{left:n,top:i,width:r,height:s}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+r*t,clientY:i+s*o})},destroy(){const{options:t,_tapstart:o}=e;a([t.wrapper,t.element],"mousedown",o),a([t.wrapper,t.element],"touchstart",o,{passive:!1})}},{options:o,_tapstart:n,_keyboard:i}=e;return c([o.wrapper,o.element],"mousedown",n),c([o.wrapper,o.element],"touchstart",n,{passive:!1}),c(document,["keydown","keyup"],i),e}function L(t={}){t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=c(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)});return{destroy:()=>a(...e)}}function P({el:t,reference:e,padding:o=8}){const n={start:"sme",middle:"mse",end:"ems"},i={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},r=((t={})=>(e,o=t[e])=>{if(o)return o;const[n,i="middle"]=e.split("-"),r="top"===n||"bottom"===n;return t[e]={position:n,variant:i,isVertical:r}})();return{update(s){const{position:c,variant:a,isVertical:l}=r(s),p=e.getBoundingClientRect(),u=t.getBoundingClientRect(),h=t=>t?{t:p.top-u.height-o,b:p.bottom+o}:{r:p.right+o,l:p.left-u.width-o},d=t=>t?{s:p.left+p.width-u.width,m:-u.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-u.height,m:p.bottom-p.height/2-u.height/2,e:p.bottom-p.height},f={};function m(e,o,n){const i="top"===n,r=i?u.height:u.width,s=window[i?"innerHeight":"innerWidth"];for(const i of e){const e=o[i],c=f[n]="".concat(e,"px");if(e>0&&e+r{const c=t=>t?"":'style="display:none" hidden',a=h('\n
\n\n '.concat(o?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n ')),l=a.interaction;return l.options.find(t=>!t.hidden&&!t.classList.add("active")),l.type=()=>l.options.find(t=>t.classList.contains("active")),a};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(this._t,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:E({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:E({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:E({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return this.options.i18n[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ")),p=l.interaction;return p.options.find(t=>!t.hidden&&!t.classList.add("active")),p.type=()=>p.options.find(t=>t.classList.contains("active")),l};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("btn:toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(this,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:x({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:x({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:x({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return(this.options.i18n||{})[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\r\nimport * as _ from './utils/utils';\r\nimport {parseToHSVA} from './utils/color';\r\n\r\n// Import classes\r\nimport {HSVaColor} from './utils/hsvacolor';\r\nimport Moveable from './libs/moveable';\r\nimport Selectable from './libs/selectable';\r\nimport Nanopop from './libs/nanopop';\r\nimport buildPickr from './template';\r\n\r\nclass Pickr {\r\n\r\n // Will be used to prevent specific actions during initilization\r\n _initializingActive = true;\r\n\r\n // If the current color value should be recalculated\r\n _recalc = true;\r\n\r\n // Current and last color for comparison\r\n _color = HSVaColor();\r\n _lastColor = HSVaColor();\r\n _swatchColors = [];\r\n\r\n // Evenlistener name: [callbacks]\r\n _eventListener = {\r\n init: [],\r\n save: [],\r\n hide: [],\r\n show: [],\r\n clear: [],\r\n change: [],\r\n changestop: [],\r\n cancel: [],\r\n swatchselect: []\r\n };\r\n\r\n constructor(opt) {\r\n\r\n // Assign default values\r\n this.options = opt = Object.assign({\r\n appClass: null,\r\n theme: 'classic',\r\n useAsButton: false,\r\n padding: 8,\r\n disabled: false,\r\n comparison: true,\r\n closeOnScroll: false,\r\n outputPrecision: 0,\r\n lockOpacity: false,\r\n autoReposition: true,\r\n container: 'body',\r\n components: {\r\n interaction: {}\r\n },\r\n\r\n i18n: null,\r\n swatches: null,\r\n inline: false,\r\n sliders: null,\r\n\r\n default: '#42445a',\r\n defaultRepresentation: null,\r\n position: 'bottom-middle',\r\n adjustableNumbers: true,\r\n showAlways: false,\r\n\r\n closeWithKey: 'Escape'\r\n }, opt);\r\n\r\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\r\n\r\n if (['nano', 'monolith'].includes(theme) && !sliders) {\r\n opt.sliders = 'h';\r\n }\r\n\r\n // Check interaction section\r\n if (!components.interaction) {\r\n components.interaction = {};\r\n }\r\n\r\n // Overwrite palette if preview, opacity or hue are true\r\n const {preview, opacity, hue, palette} = components;\r\n components.opacity = (!lockOpacity && opacity);\r\n components.palette = palette || preview || opacity || hue;\r\n\r\n // Initialize picker\r\n this._preBuild();\r\n this._buildComponents();\r\n this._bindEvents();\r\n this._finalBuild();\r\n\r\n // Append pre-defined swatch colors\r\n if (swatches && swatches.length) {\r\n swatches.forEach(color => this.addSwatch(color));\r\n }\r\n\r\n // Initialize positioning engine\r\n const {button, app} = this._root;\r\n this._nanopop = Nanopop({\r\n reference: button,\r\n padding,\r\n el: app\r\n });\r\n\r\n // Initialize accessibility\r\n button.setAttribute('role', 'button');\r\n button.setAttribute('aria-label', this._t('toggle', 'toggle color picker dialog'));\r\n\r\n // Initilization is finish, pickr is visible and ready for usage\r\n const that = this;\r\n requestAnimationFrame((function cb() {\r\n\r\n if (!app.offsetWidth && app.parentElement !== opt.container) {\r\n return requestAnimationFrame(cb);\r\n }\r\n\r\n // Apply default color\r\n that.setColor(opt.default);\r\n that._rePositioningPicker();\r\n\r\n // Initialize color representation\r\n if (opt.defaultRepresentation) {\r\n that._representation = opt.defaultRepresentation;\r\n that.setColorRepresentation(that._representation);\r\n }\r\n\r\n // Show pickr if locked\r\n if (opt.showAlways) {\r\n that.show();\r\n }\r\n\r\n // Initialization is done - pickr is usable, fire init event\r\n that._initializingActive = false;\r\n that._emit('init');\r\n }));\r\n }\r\n\r\n // Does only the absolutly basic thing to initialize the components\r\n _preBuild() {\r\n const opt = this.options;\r\n\r\n // Resolve elements\r\n for (const type of ['el', 'container']) {\r\n opt[type] = _.resolveElement(opt[type]);\r\n }\r\n\r\n // Create element and append it to body to\r\n // prevent initialization errors\r\n this._root = buildPickr(this._t, opt);\r\n\r\n // Check if a custom button is used\r\n if (opt.useAsButton) {\r\n this._root.button = opt.el; // Replace button with customized button\r\n }\r\n\r\n opt.container.appendChild(this._root.root);\r\n }\r\n\r\n _finalBuild() {\r\n const opt = this.options;\r\n const root = this._root;\r\n\r\n // Remove from body\r\n opt.container.removeChild(root.root);\r\n\r\n if (opt.inline) {\r\n const parent = opt.el.parentElement;\r\n\r\n if (opt.el.nextSibling) {\r\n parent.insertBefore(root.app, opt.el.nextSibling);\r\n } else {\r\n parent.appendChild(root.app);\r\n }\r\n } else {\r\n opt.container.appendChild(root.app);\r\n }\r\n\r\n // Don't replace the the element if a custom button is used\r\n if (!opt.useAsButton) {\r\n\r\n // Replace element with actual color-picker\r\n opt.el.parentNode.replaceChild(root.root, opt.el);\r\n } else if (opt.inline) {\r\n opt.el.remove();\r\n }\r\n\r\n // Check if it should be immediatly disabled\r\n if (opt.disabled) {\r\n this.disable();\r\n }\r\n\r\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\r\n if (!opt.comparison) {\r\n root.button.style.transition = 'none';\r\n if (!opt.useAsButton) {\r\n root.preview.lastColor.style.transition = 'none';\r\n }\r\n }\r\n\r\n this.hide();\r\n }\r\n\r\n _buildComponents() {\r\n\r\n // Instance reference\r\n const inst = this;\r\n const cs = this.options.components;\r\n const sliders = (inst.options.sliders || 'v').repeat(2);\r\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\r\n\r\n // Re-assign if null\r\n const getColor = () =>\r\n this._color || (this._color = this._lastColor.clone());\r\n\r\n const components = {\r\n\r\n palette: Moveable({\r\n element: inst._root.palette.picker,\r\n wrapper: inst._root.palette.palette,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(x, y) {\r\n if (!cs.palette) return;\r\n\r\n const color = getColor();\r\n const {_root, options} = inst;\r\n\r\n // Update the input field only if the user is currently not typing\r\n if (inst._recalc) {\r\n\r\n // Calculate saturation based on the position\r\n color.s = x * 100;\r\n\r\n // Calculate the value\r\n color.v = 100 - y * 100;\r\n\r\n // Prevent falling under zero\r\n color.v < 0 ? color.v = 0 : 0;\r\n inst._updateOutput();\r\n }\r\n\r\n // Set picker and gradient color\r\n const cssRGBaString = color.toRGBA().toString(0);\r\n this.element.style.background = cssRGBaString;\r\n this.wrapper.style.background = `\r\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\r\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\r\n `;\r\n\r\n // Check if color is locked\r\n if (!options.comparison) {\r\n _root.button.style.color = cssRGBaString;\r\n } else {\r\n if (!options.useAsButton && !inst._lastColor) {\r\n _root.preview.lastColor.style.color = cssRGBaString;\r\n }\r\n }\r\n\r\n // Check if there's a swatch which color matches the current one\r\n const hexa = color.toHEXA().toString();\r\n for (const {el, color} of inst._swatchColors) {\r\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\r\n }\r\n\r\n // Change current color\r\n _root.preview.currentColor.style.color = cssRGBaString;\r\n\r\n if (!inst.options.comparison) {\r\n\r\n // If the user changes the color, remove the cleared icon\r\n _root.button.classList.remove('clear');\r\n }\r\n }\r\n }),\r\n\r\n hue: Moveable({\r\n lock: sh === 'v' ? 'h' : 'v',\r\n element: inst._root.hue.picker,\r\n wrapper: inst._root.hue.slider,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(v) {\r\n if (!cs.hue || !cs.palette) return;\r\n const color = getColor();\r\n\r\n // Calculate hue\r\n if (inst._recalc) {\r\n color.h = v * 360;\r\n }\r\n\r\n // Update color\r\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\r\n components.palette.trigger();\r\n }\r\n }),\r\n\r\n opacity: Moveable({\r\n lock: so === 'v' ? 'h' : 'v',\r\n element: inst._root.opacity.picker,\r\n wrapper: inst._root.opacity.slider,\r\n\r\n onstop: () => inst._emit('changestop', inst),\r\n onchange(v) {\r\n if (!cs.opacity || !cs.palette) return;\r\n const color = getColor();\r\n\r\n // Calculate opacity\r\n if (inst._recalc) {\r\n color.a = Math.round(v * 1e2) / 100;\r\n }\r\n\r\n // Update color\r\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\r\n components.palette.trigger();\r\n }\r\n }),\r\n\r\n selectable: Selectable({\r\n elements: inst._root.interaction.options,\r\n className: 'active',\r\n\r\n onchange(e) {\r\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\r\n inst._recalc && inst._updateOutput();\r\n }\r\n })\r\n };\r\n\r\n this._components = components;\r\n }\r\n\r\n _bindEvents() {\r\n const {_root, options} = this;\r\n\r\n const eventBindings = [\r\n\r\n // Clear color\r\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\r\n\r\n // Select last color on click\r\n _.on([\r\n _root.interaction.cancel,\r\n _root.preview.lastColor\r\n ], 'click', () => {\r\n this._emit('cancel', this);\r\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\r\n }),\r\n\r\n // Save color\r\n _.on(_root.interaction.save, 'click', () => {\r\n !this.applyColor() && !options.showAlways && this.hide();\r\n }),\r\n\r\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\r\n\r\n // Fire listener if initialization is finish and changed color was valid\r\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\r\n this._emit('change', this._color);\r\n }\r\n\r\n e.stopImmediatePropagation();\r\n }),\r\n\r\n // Detect user input and disable auto-recalculation\r\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\r\n this._recalc = e.type === 'blur';\r\n this._recalc && this._updateOutput();\r\n }),\r\n\r\n // Cancel input detection on color change\r\n _.on([\r\n _root.palette.palette,\r\n _root.palette.picker,\r\n _root.hue.slider,\r\n _root.hue.picker,\r\n _root.opacity.slider,\r\n _root.opacity.picker\r\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\r\n ];\r\n\r\n // Provide hiding / showing abilities only if showAlways is false\r\n if (!options.showAlways) {\r\n const ck = options.closeWithKey;\r\n\r\n eventBindings.push(\r\n // Save and hide / show picker\r\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\r\n\r\n // Close with escape key\r\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\r\n\r\n // Cancel selecting if the user taps behind the color picker\r\n _.on(document, ['touchstart', 'mousedown'], e => {\r\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\r\n this.hide();\r\n }\r\n }, {capture: true})\r\n );\r\n }\r\n\r\n // Make input adjustable if enabled\r\n if (options.adjustableNumbers) {\r\n const ranges = {\r\n rgba: [255, 255, 255, 1],\r\n hsva: [360, 100, 100, 1],\r\n hsla: [360, 100, 100, 1],\r\n cmyk: [100, 100, 100, 100]\r\n };\r\n\r\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\r\n const range = ranges[this.getColorRepresentation().toLowerCase()];\r\n\r\n if (range) {\r\n const max = range[index];\r\n\r\n // Calculate next reasonable number\r\n const nv = o + (max >= 100 ? step * 1000 : step);\r\n\r\n // Apply range of zero up to max, fix floating-point issues\r\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\r\n }\r\n\r\n return o;\r\n });\r\n }\r\n\r\n if (options.autoReposition && !options.inline) {\r\n let timeout = null;\r\n const that = this;\r\n\r\n // Re-calc position on window resize, scroll and wheel\r\n eventBindings.push(\r\n _.on(window, ['scroll', 'resize'], () => {\r\n if (that.isOpen()) {\r\n\r\n if (options.closeOnScroll) {\r\n that.hide();\r\n }\r\n\r\n if (timeout === null) {\r\n timeout = setTimeout(() => timeout = null, 100);\r\n\r\n // Update position on every frame\r\n requestAnimationFrame(function rs() {\r\n that._rePositioningPicker();\r\n (timeout !== null) && requestAnimationFrame(rs);\r\n });\r\n } else {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(() => timeout = null, 100);\r\n }\r\n }\r\n }, {capture: true})\r\n );\r\n }\r\n\r\n // Save bindings\r\n this._eventBindings = eventBindings;\r\n }\r\n\r\n _rePositioningPicker() {\r\n const {options} = this;\r\n\r\n // No repositioning needed if inline\r\n if (!options.inline) {\r\n const {app} = this._root;\r\n\r\n if (matchMedia('(max-width: 576px)').matches) {\r\n Object.assign(app.style, {\r\n margin: 'auto',\r\n height: `${app.getBoundingClientRect().height}px`,\r\n top: 0,\r\n bottom: 0,\r\n left: 0,\r\n right: 0\r\n });\r\n } else {\r\n Object.assign(app.style, {\r\n margin: null,\r\n right: null,\r\n top: null,\r\n bottom: null,\r\n left: null,\r\n height: null\r\n });\r\n\r\n this._nanopop.update(options.position);\r\n }\r\n }\r\n }\r\n\r\n _updateOutput() {\r\n const {_root, _color, options} = this;\r\n\r\n // Check if component is present\r\n if (_root.interaction.type()) {\r\n\r\n // Construct function name and call if present\r\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\r\n _root.interaction.result.value = typeof _color[method] === 'function' ?\r\n _color[method]().toString(options.outputPrecision) : '';\r\n }\r\n\r\n // Fire listener if initialization is finish\r\n if (!this._initializingActive && this._recalc) {\r\n this._emit('change', _color);\r\n }\r\n }\r\n\r\n _clearColor(silent = false) {\r\n const {_root, options} = this;\r\n\r\n // Change only the button color if it isn't customized\r\n if (!options.useAsButton) {\r\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\r\n }\r\n\r\n _root.button.classList.add('clear');\r\n\r\n if (!options.showAlways) {\r\n this.hide();\r\n }\r\n\r\n this._lastColor = null;\r\n if (!this._initializingActive && !silent) {\r\n\r\n // Fire listener\r\n this._emit('save', null);\r\n this._emit('clear', this);\r\n }\r\n }\r\n\r\n _parseLocalColor(str) {\r\n const {values, type, a} = parseToHSVA(str);\r\n const {lockOpacity} = this.options;\r\n const alphaMakesAChange = a !== undefined && a !== 1;\r\n\r\n // If no opacity is applied, add undefined at the very end which gets\r\n // set to 1 in setHSVA\r\n if (values && values.length === 3) {\r\n values[3] = undefined;\r\n }\r\n\r\n return {\r\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\r\n type\r\n };\r\n }\r\n\r\n _emit(event, ...args) {\r\n this._eventListener[event].forEach(cb => cb(...args, this));\r\n }\r\n\r\n _t(key, def = 'unknown') {\r\n return this.options.i18n[key] || def;\r\n }\r\n\r\n on(event, cb) {\r\n\r\n // Validate\r\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\r\n this._eventListener[event].push(cb);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n off(event, cb) {\r\n const callBacks = this._eventListener[event];\r\n\r\n if (callBacks) {\r\n const index = callBacks.indexOf(cb);\r\n\r\n if (~index) {\r\n callBacks.splice(index, 1);\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Appends a color to the swatch palette\r\n * @param color\r\n * @returns {boolean}\r\n */\r\n addSwatch(color) {\r\n const {values} = this._parseLocalColor(color);\r\n\r\n if (values) {\r\n const {_swatchColors, _root} = this;\r\n const color = HSVaColor(...values);\r\n\r\n // Create new swatch HTMLElement\r\n const el = _.createElementFromString(\r\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('btn:toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return (this.options.i18n || {})[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n ` +
-
+
-
+
-
+
@@ -42,9 +43,9 @@ export default (t, {components: c, useAsButton, inline, appClass, theme, lockOpa - - - + + + From 1a64ecde4ac4b98ef8ac0f3463957ce7d9f1ab56 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Mon, 6 Apr 2020 16:01:03 +0530 Subject: [PATCH 5/8] Add aria-label to color input field. --- README.md | 1 + dist/pickr.es5.min.js | 2 +- dist/pickr.es5.min.js.map | 2 +- dist/pickr.min.js | 2 +- dist/pickr.min.js.map | 2 +- src/js/template.js | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 014cf7ff..06a6a41e 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,7 @@ const pickr = new Pickr({ 'btn:save': 'Save', 'btn:cancel': 'Cancel', 'btn:clear': 'Clear', + 'input:color': 'color input field', 'ui:palette': 'color selection area', 'ui:hue': 'hue selection slider', 'ui:opacity': 'selection slider' diff --git a/dist/pickr.es5.min.js b/dist/pickr.es5.min.js index 21bae6e7..b89b926f 100644 --- a/dist/pickr.es5.min.js +++ b/dist/pickr.es5.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r={};function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function i(t){for(var e=1;e4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(n)||(n=[n]);var a=!0,c=!1,l=void 0;try{for(var s,u=e[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){var p=s.value,h=!0,f=!1,d=void 0;try{for(var v,y=n[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var m=v.value;p[t](m,r,i({capture:!1},o))}}catch(t){f=!0,d=t}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}}}catch(t){c=!0,l=t}finally{try{a||null==u.return||u.return()}finally{if(c)throw l}}return Array.prototype.slice.call(arguments,1)}function u(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function p(t,e){var n=t.getAttribute(e);return t.removeAttribute(e),n}function h(t){return function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=p(e,":obj"),o=p(e,":ref"),i=r?n[r]={}:n;o&&(n[o]=e);for(var a=0,c=Array.from(e.children);a>/g).reduce(function(t,e,n,r){return t=t.querySelector(e),n1&&void 0!==arguments[1]?arguments[1]:function(t){return t};function n(n){var r=[.001,.01,.1][Number(n.shiftKey||2*n.ctrlKey)]*(n.deltaY<0?1:-1),o=0,i=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,function(t,n){return n<=i&&n+t.length>=i?(i=n,e(Number(t),r,o)):(o++,t)}),t.focus(),t.setSelectionRange(i,i),n.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",function(){return c(window,"wheel",n,{passive:!1})}),c(t,"blur",function(){return l(window,"wheel",n)})}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function m(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(r-=1)}return[360*r,100*o,100*a]}function C(t,e,n,r){return e/=100,n/=100,m(A(255*(1-b(1,(t/=100)*(1-(r/=100))+r)),255*(1-b(1,e*(1-r)+r)),255*(1-b(1,n*(1-r)+r))))}function S(t,e,n){return e/=100,[t,2*(e*=(n/=100)<.5?n:1-n)/(n+e)*100,100*(n+e)]}function O(t){return A.apply(void 0,m(t.match(/.{2}/g).map(function(t){return parseInt(t,16)})))}function j(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";var e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;var e,n={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},r=function(t){return t.map(function(t){return/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0})};t:for(var o in n)if(e=n[o].exec(t)){var i=!!e[2];switch(o){case"cmyk":var a=y(r(e),5),c=a[1],l=a[2],s=a[3],u=a[4];if(c>100||l>100||s>100||u>100)break t;return{values:C(c,l,s,u),type:o};case"rgba":var p=y(r(e),7),h=p[3],f=p[4],d=p[5],v=p[6];if(h>255||f>255||d>255||v<0||v>1||i===!v)break t;return{values:[].concat(m(A(h,f,d)),[v]),a:v,type:o};case"hexa":var b=y(e,2)[1];4!==b.length&&3!==b.length||(b=b.split("").map(function(t){return t+t}).join(""));var g=b.substring(0,6),_=b.substring(6);return _=_?parseInt(_,16)/255:void 0,{values:[].concat(m(O(g)),[_]),a:_,type:o};case"hsla":var w=y(r(e),7),k=w[3],j=w[4],E=w[5],x=w[6];if(k>360||j>100||E>100||x<0||x>1||i===!x)break t;return{values:[].concat(m(S(k,j,E)),[x]),a:x,type:o};case"hsva":var L=y(r(e),7),P=L[3],B=L[4],R=L[5],H=L[6];if(P>360||B>100||R>100||H<0||H>1||i===!H)break t;return{values:[P,B,R,H],a:H,type:o}}}return{values:null,type:null}}function E(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=function(t,e){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~n?t.map(function(t){return Number(t.toFixed(n))}):t)}},i={h:t,s:e,v:n,a:r,toHSVA:function(){var t=[i.h,i.s,i.v,i.a];return t.toString=o(t,function(t){return"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toHSLA:function(){var t=[].concat(E(function(t,e,n){var r=(2-(e/=100))*(n/=100)/2;return 0!==r&&(e=1===r?0:r<.5?e*n/(2*r):e*n/(2-2*r)),[t,100*e,100*r]}(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")}),t},toRGBA:function(){var t=[].concat(E(k(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,function(t){return"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(i.a,")")}),t},toCMYK:function(){var t=function(t,e,n){var r,o=k(t,e,n),i=o[0]/255,a=o[1]/255,c=o[2]/255;return[100*(1===(r=b(1-i,1-a,1-c))?0:(1-i-r)/(1-r)),100*(1===r?0:(1-a-r)/(1-r)),100*(1===r?0:(1-c-r)/(1-r)),100*r]}(i.h,i.s,i.v);return t.toString=o(t,function(t){return"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")}),t},toHEXA:function(){var t=function(t,e,n){return k(t,e,n).map(function(t){return w(t).toString(16).padStart(2,"0")})}(i.h,i.s,i.v),e=i.a>=1?"":Number((255*i.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=function(){return"#".concat(t.join("").toUpperCase())},t},clone:function(){return x(i.h,i.s,i.v,i.a)}};return i}var L=function(t){return Math.max(Math.min(t,1),0)};function P(t){var e={options:Object.assign({lock:null,onchange:function(){return 0},onstop:function(){return 0}},t),_keyboard:function(t){var r=t.type,o=t.key;if(document.activeElement===n.wrapper)if("keydown"===r){var i=0,a=0;switch(o){case"ArrowLeft":i--;break;case"ArrowRight":i++;break;case"ArrowUp":a++;break;case"ArrowDown":a++}e.update(L(e.cache.x+.01*i),L(e.cache.y+.01*a))}else o.startsWith("Arrow")&&e.options.onstop()},_tapstart:function(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove:function(t){var r=e.options.lock,o=e.cache,i=n.element,a=n.wrapper,c=a.getBoundingClientRect(),l=0,s=0;if(t){var u=t&&t.touches&&t.touches[0];l=t?(u||t).clientX:0,s=t?(u||t).clientY:0,lc.left+c.width&&(l=c.left+c.width),sc.top+c.height&&(s=c.top+c.height),l-=c.left,s-=c.top}else o&&(l=o.x*c.width,s=o.y*c.height);"h"!==r&&(i.style.left="calc(".concat(l/c.width*100,"% - ").concat(i.offsetWidth/2,"px)")),"v"!==r&&(i.style.top="calc(".concat(s/c.height*100,"% - ").concat(i.offsetHeight/2,"px)")),e.cache={x:l/c.width,y:s/c.height};var p=L(l/a.offsetWidth),h=L(s/a.offsetHeight);switch(r){case"v":return n.onchange(p);case"h":return n.onchange(h);default:return n.onchange(p,h)}},_tapstop:function(){e.options.onstop(),l(document,["mouseup","touchend","touchcancel"],e._tapstop),l(document,["mousemove","touchmove"],e._tapmove)},trigger:function(){e._tapmove()},update:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.options.wrapper.getBoundingClientRect(),o=r.left,i=r.top,a=r.width,c=r.height;"h"===e.options.lock&&(n=t),e._tapmove({clientX:o+a*t,clientY:i+c*n})},destroy:function(){var t=e.options,n=e._tapstart;l([t.wrapper,t.element],"mousedown",n),l([t.wrapper,t.element],"touchstart",n,{passive:!1})}},n=e.options,r=e._tapstart,o=e._keyboard;return c([n.wrapper,n.element],"mousedown",r),c([n.wrapper,n.element],"touchstart",r,{passive:!1}),c(document,["keydown","keyup"],o),e}function B(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:function(){return 0},className:"",elements:[]},t);var e=c(t.elements,"click",function(e){t.elements.forEach(function(n){return n.classList[e.target===n?"add":"remove"](t.className)}),t.onchange(e)});return{destroy:function(){return l.apply(r,B(e))}}}function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function D(t){var e=t.el,n=t.reference,r=t.padding,o=void 0===r?8:r,i={start:"sme",middle:"mse",end:"ems"},a={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[e];if(n)return n;var r=e.split("-"),o=H(r,2),i=o[0],a=o[1],c=void 0===a?"middle":a,l="top"===i||"bottom"===i;return t[e]={position:i,variant:c,isVertical:l}}}();return{update:function(t){var r=c(t),l=r.position,s=r.variant,u=r.isVertical,p=n.getBoundingClientRect(),h=e.getBoundingClientRect(),f=function(t){return t?{s:p.left+p.width-h.width,m:-h.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-h.height,m:p.bottom-p.height/2-h.height/2,e:p.bottom-p.height}},d={};function v(t,n,r){var o="top"===r,i=o?h.height:h.width,a=window[o?"innerHeight":"innerWidth"],c=!0,l=!1,s=void 0;try{for(var u,p=t[Symbol.iterator]();!(c=(u=p.next()).done);c=!0){var f=n[u.value],v=d[r]="".concat(f,"px");if(f>0&&f+i\n\n '.concat(r?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ")),(p=u.interaction).options.find(function(t){return!t.hidden&&!t.classList.add("active")}),p.type=function(){return p.options.find(function(t){return t.classList.contains("active")})},u),f.useAsButton&&(this._root.button=f.el),f.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=T(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:P({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,m=v.color;y.classList[s===m.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:P({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:P({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:R({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",function(){return t._clearColor()}),c([e.interaction.cancel,e.preview.lastColor],"click",function(){t._emit("cancel",t),t.setHSVA.apply(t,M((t._lastColor||t._color).toHSVA()).concat([!0]))}),c(e.interaction.save,"click",function(){!t.applyColor()&&!n.showAlways&&t.hide()}),c(e.interaction.result,["keyup","input"],function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()}),c(e.interaction.result,["focus","blur"],function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()}),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],function(){return t._recalc=!0})];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",function(){return t.isOpen()?t.hide():t.show()}),c(document,"keyup",function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()}),c(document,["touchstart","mousedown"],function(n){t.isOpen()&&!f(n).some(function(t){return t===e.app||t===e.button})&&t.hide()},{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=j(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return(this.options.i18n||{})[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=x.apply(void 0,M(n)),a=u('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ")),(p=u.interaction).options.find((function(t){return!t.hidden&&!t.classList.add("active")})),p.type=function(){return p.options.find((function(t){return t.classList.contains("active")}))},u),f.useAsButton&&(this._root.button=f.el),f.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=F(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:H({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,b=v.color;y.classList[s===b.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:H({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:H({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:M({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",(function(){return t._clearColor()})),c([e.interaction.cancel,e.preview.lastColor],"click",(function(){t._emit("cancel",t),t.setHSVA.apply(t,V((t._lastColor||t._color).toHSVA()).concat([!0]))})),c(e.interaction.save,"click",(function(){!t.applyColor()&&!n.showAlways&&t.hide()})),c(e.interaction.result,["keyup","input"],(function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()})),c(e.interaction.result,["focus","blur"],(function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()})),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],(function(){return t._recalc=!0}))];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",(function(){return t.isOpen()?t.hide():t.show()})),c(document,"keyup",(function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()})),c(document,["touchstart","mousedown"],(function(n){t.isOpen()&&!f(n).some((function(t){return t===e.app||t===e.button}))&&t.hide()}),{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,(function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=L(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return(this.options.i18n||{})[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=B.apply(void 0,V(n)),a=u(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/js/utils/utils.js","webpack:///./src/js/utils/color.js","webpack:///./src/js/utils/hsvacolor.js","webpack:///./src/js/libs/moveable.js","webpack:///./src/js/libs/selectable.js","webpack:///./src/js/libs/nanopop.js","webpack:///./src/js/pickr.js","webpack:///./src/js/template.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","on","eventListener","off","method","elements","events","fn","options","HTMLCollection","NodeList","Array","from","isArray","el","ev","capture","slice","arguments","createElementFromString","html","div","document","createElement","innerHTML","trim","firstElementChild","removeAttribute","getAttribute","createFromTemplate","str","resolve","element","base","con","subtree","children","child","arr","sub","push","keys","length","eventPath","evt","path","composedPath","target","parentElement","resolveElement","val","Element","split","reduce","pv","cv","ci","a","querySelector","shadowRoot","adjustableInputNumbers","mapper","v","handleScroll","e","inc","Number","shiftKey","ctrlKey","deltaY","index","selectionStart","replace","focus","setSelectionRange","preventDefault","dispatchEvent","Event","passive","min","Math","max","floor","round","hsvToRgb","h","f","q","mod","hsvToHex","map","toString","padStart","hsvToCmyk","k","rgb","g","b","hsvToHsl","rgbToHsv","minVal","maxVal","delta","dr","dg","db","cmykToHsv","y","hslToHsv","hexToHsv","hex","match","parseInt","parseToHSVA","toLowerCase","ctx","getContext","fillStyle","standardizeColor","regex","cmyk","rgba","hsla","hsva","hexa","numarize","array","test","undefined","invalid","type","exec","alpha","values","join","raw","substring","HSVaColor","original","next","precision","toFixed","that","toHSVA","toHSLA","toRGBA","toCMYK","toHEXA","toUpperCase","clone","clamp","Moveable","opt","assign","lock","onchange","onstop","_keyboard","activeElement","wrapper","xm","ym","update","cache","x","startsWith","_tapstart","_","_tapstop","_tapmove","getBoundingClientRect","touch","touches","clientX","clientY","left","width","top","height","style","offsetWidth","offsetHeight","cx","cy","trigger","destroy","Selectable","className","onTap","forEach","classList","Nanopop","reference","padding","vBehaviour","start","middle","end","hBehaviour","right","bottom","getInfo","pos","cached","position","variant","isVertical","rb","eb","variants","vertical","leastApplied","apply","bevs","vars","styleprop","adder","win","sv","rot","v2Ok","v1Ok","Pickr","init","save","hide","show","clear","change","changestop","cancel","swatchselect","this","appClass","theme","useAsButton","disabled","comparison","closeOnScroll","outputPrecision","lockOpacity","autoReposition","container","components","interaction","i18n","swatches","inline","sliders","default","defaultRepresentation","adjustableNumbers","showAlways","closeWithKey","includes","preview","opacity","hue","palette","_preBuild","_buildComponents","_bindEvents","_finalBuild","color","addSwatch","_root","button","app","_nanopop","setAttribute","_t","requestAnimationFrame","cb","setColor","_rePositioningPicker","_representation","setColorRepresentation","_initializingActive","_emit","inst","lo","hidden","int","input","find","add","contains","appendChild","removeChild","parent","nextSibling","insertBefore","remove","parentNode","replaceChild","disable","transition","lastColor","cs","repeat","so","sh","getColor","_color","_lastColor","picker","_recalc","_updateOutput","cssRGBaString","background","_swatchColors","currentColor","slider","backgroundColor","selectable","_components","eventBindings","_clearColor","setHSVA","applyColor","result","stopImmediatePropagation","ck","isOpen","code","some","ranges","step","range","getColorRepresentation","nv","toPrecision","timeout","setTimeout","rs","clearTimeout","_eventBindings","matchMedia","matches","margin","silent","alphaMakesAChange","event","args","_eventListener","def","callBacks","indexOf","splice","_parseLocalColor","swatchColor","recalc","string","utype","click","utils","libs","version"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAe,MAAID,IAEnBD,EAAY,MAAIC,IARlB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAA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C3BoR,MAAK,SAAA9N,GAAC,OAAIA,EAAElC,aAAa,aAAayI,WAAWnC,KAAUpE,EAAEoS,a,+CAQlE,OAAO1H,KAAK2C,kB,iCAOZ,OAAO3C,KAAKuE,S,yCAQZ,OAAOvE,KAAKwE,a,gCAOZ,OAAOxE,KAAKiC,Q,gCAUZ,OAHAjC,KAAKP,OACLO,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAU+F,IAAI,YACzBrD,O,+BASP,OAFAA,KAAKhO,QAAQoO,UAAW,EACxBJ,KAAKiC,MAAMC,OAAO5E,UAAUsG,OAAO,YAC5B5D,U,gCAKfV,EAAMqI,MAAQ5L,EAGduD,EAAMsI,KAAO,CACT3N,YACAc,WACAwC,UACAL,cAIJoC,EAAMvO,OAAS,SAAAiB,GAAO,OAAI,IAAIsN,EAAMtN,IAGpCsN,EAAMuI,QAAU,QACDvI,e","file":"pickr.es5.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pickr\"] = factory();\n\telse\n\t\troot[\"Pickr\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\n * Add event(s) to element(s).\n * @param elements DOM-Elements\n * @param events Event names\n * @param fn Callback\n * @param options Optional options\n * @return Array passed arguments\n */\nexport const on = eventListener.bind(null, 'addEventListener');\n\n/**\n * Remove event(s) from element(s).\n * @param elements DOM-Elements\n * @param events Event names\n * @param fn Callback\n * @param options Optional options\n * @return Array passed arguments\n */\nexport const off = eventListener.bind(null, 'removeEventListener');\n\nfunction eventListener(method, elements, events, fn, options = {}) {\n\n // Normalize array\n if (elements instanceof HTMLCollection || elements instanceof NodeList) {\n elements = Array.from(elements);\n } else if (!Array.isArray(elements)) {\n elements = [elements];\n }\n\n if (!Array.isArray(events)) {\n events = [events];\n }\n\n for (const el of elements) {\n for (const ev of events) {\n el[method](ev, fn, {capture: false, ...options});\n }\n }\n\n return Array.prototype.slice.call(arguments, 1);\n}\n\n/**\n * Creates an DOM-Element out of a string (Single element).\n * @param html HTML representing a single element\n * @returns {Element | null} The element.\n */\nexport function createElementFromString(html) {\n const div = document.createElement('div');\n div.innerHTML = html.trim();\n return div.firstElementChild;\n}\n\n/**\n * Removes an attribute from a HTMLElement and returns the value.\n * @param el\n * @param name\n * @return {string}\n */\nexport function removeAttribute(el, name) {\n const value = el.getAttribute(name);\n el.removeAttribute(name);\n return value;\n}\n\n/**\n * Creates a new html element, every element which has\n * a ':ref' attribute will be saved in a object (which will be returned)\n * where the value of ':ref' is the object-key and the value the HTMLElement.\n *\n * It's possible to create a hierarchy if you add a ':obj' attribute. Every\n * sibling will be added to the object which will get the name from the 'data-con' attribute.\n *\n * If you want to create an Array out of multiple elements, you can use the ':arr' attribute,\n * the value defines the key and all elements, which has the same parent and the same 'data-arr' attribute,\n * would be added to it.\n *\n * @param str - The HTML String.\n */\nexport function createFromTemplate(str) {\n\n // Recursive function to resolve template\n function resolve(element, base = {}) {\n\n // Check key and container attribute\n const con = removeAttribute(element, ':obj');\n const key = removeAttribute(element, ':ref');\n const subtree = con ? (base[con] = {}) : base;\n\n // Check and save element\n key && (base[key] = element);\n for (const child of Array.from(element.children)) {\n const arr = removeAttribute(child, ':arr');\n const sub = resolve(child, arr ? {} : subtree);\n\n if (arr) {\n\n // Check if there is already an array and add element\n (subtree[arr] || (subtree[arr] = []))\n .push(Object.keys(sub).length ? sub : child);\n }\n }\n\n return base;\n }\n\n return resolve(createElementFromString(str));\n}\n\n/**\n * Polyfill for safari & firefox for the eventPath event property.\n * @param evt The event object.\n * @return [String] event path.\n */\nexport function eventPath(evt) {\n let path = evt.path || (evt.composedPath && evt.composedPath());\n if (path) return path;\n\n let el = evt.target.parentElement;\n path = [evt.target, el];\n while (el = el.parentElement) path.push(el);\n\n path.push(document, window);\n return path;\n}\n\n/**\n * Resolves a HTMLElement by query.\n * @param val\n * @returns {null|Document|Element}\n */\nexport function resolveElement(val) {\n if (val instanceof Element) {\n return val;\n } else if (typeof val === 'string') {\n return val.split(/>>/g).reduce((pv, cv, ci, a) => {\n pv = pv.querySelector(cv);\n return ci < a.length - 1 ? pv.shadowRoot : pv;\n }, document);\n }\n\n return null;\n}\n\n/**\n * Creates the ability to change numbers in an input field with the scroll-wheel.\n * @param el\n * @param mapper\n */\nexport function adjustableInputNumbers(el, mapper = v => v) {\n\n function handleScroll(e) {\n const inc = ([0.001, 0.01, 0.1])[Number(e.shiftKey || e.ctrlKey * 2)] * (e.deltaY < 0 ? 1 : -1);\n\n let index = 0;\n let off = el.selectionStart;\n el.value = el.value.replace(/[\\d.]+/g, (v, i) => {\n\n // Check if number is in cursor range and increase it\n if (i <= off && i + v.length >= off) {\n off = i;\n return mapper(Number(v), inc, index);\n }\n\n index++;\n return v;\n });\n\n el.focus();\n el.setSelectionRange(off, off);\n\n // Prevent default and trigger input event\n e.preventDefault();\n el.dispatchEvent(new Event('input'));\n }\n\n // Bind events\n on(el, 'focus', () => on(window, 'wheel', handleScroll, {passive: false}));\n on(el, 'blur', () => off(window, 'wheel', handleScroll));\n}\n","// Shorthands\nconst {min, max, floor, round} = Math;\n\n/**\n * Tries to convert a color name to rgb/a hex representation\n * @param name\n * @returns {string | CanvasGradient | CanvasPattern}\n */\nfunction standardizeColor(name) {\n\n // Since invalid color's will be parsed as black, filter them out\n if (name.toLowerCase() === 'black') {\n return '#000000';\n }\n\n const ctx = document.createElement('canvas').getContext('2d');\n ctx.fillStyle = name;\n return ctx.fillStyle === '#000000' ? null : ctx.fillStyle;\n}\n\n/**\n * Convert HSV spectrum to RGB.\n * @param h Hue\n * @param s Saturation\n * @param v Value\n * @returns {number[]} Array with rgb values.\n */\nexport function hsvToRgb(h, s, v) {\n h = (h / 360) * 6;\n s /= 100;\n v /= 100;\n\n const i = floor(h);\n\n const f = h - i;\n const p = v * (1 - s);\n const q = v * (1 - f * s);\n const t = v * (1 - (1 - f) * s);\n\n const mod = i % 6;\n const r = [v, q, p, p, t, v][mod];\n const g = [t, v, v, q, p, p][mod];\n const b = [p, p, t, v, v, q][mod];\n\n return [\n r * 255,\n g * 255,\n b * 255\n ];\n}\n\n/**\n * Convert HSV spectrum to Hex.\n * @param h Hue\n * @param s Saturation\n * @param v Value\n * @returns {string[]} Hex values\n */\nexport function hsvToHex(h, s, v) {\n return hsvToRgb(h, s, v).map(v =>\n round(v).toString(16).padStart(2, '0')\n );\n}\n\n/**\n * Convert HSV spectrum to CMYK.\n * @param h Hue\n * @param s Saturation\n * @param v Value\n * @returns {number[]} CMYK values\n */\nexport function hsvToCmyk(h, s, v) {\n const rgb = hsvToRgb(h, s, v);\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n\n let k, c, m, y;\n\n k = min(1 - r, 1 - g, 1 - b);\n\n c = k === 1 ? 0 : (1 - r - k) / (1 - k);\n m = k === 1 ? 0 : (1 - g - k) / (1 - k);\n y = k === 1 ? 0 : (1 - b - k) / (1 - k);\n\n return [\n c * 100,\n m * 100,\n y * 100,\n k * 100\n ];\n}\n\n/**\n * Convert HSV spectrum to HSL.\n * @param h Hue\n * @param s Saturation\n * @param v Value\n * @returns {number[]} HSL values\n */\nexport function hsvToHsl(h, s, v) {\n s /= 100, v /= 100;\n\n const l = (2 - s) * v / 2;\n\n if (l !== 0) {\n if (l === 1) {\n s = 0;\n } else if (l < 0.5) {\n s = s * v / (l * 2);\n } else {\n s = s * v / (2 - l * 2);\n }\n }\n\n return [\n h,\n s * 100,\n l * 100\n ];\n}\n\n/**\n * Convert RGB to HSV.\n * @param r Red\n * @param g Green\n * @param b Blue\n * @return {number[]} HSV values.\n */\nfunction rgbToHsv(r, g, b) {\n r /= 255, g /= 255, b /= 255;\n\n let h, s, v;\n const minVal = min(r, g, b);\n const maxVal = max(r, g, b);\n const delta = maxVal - minVal;\n\n v = maxVal;\n if (delta === 0) {\n h = s = 0;\n } else {\n s = delta / maxVal;\n const dr = (((maxVal - r) / 6) + (delta / 2)) / delta;\n const dg = (((maxVal - g) / 6) + (delta / 2)) / delta;\n const db = (((maxVal - b) / 6) + (delta / 2)) / delta;\n\n if (r === maxVal) {\n h = db - dg;\n } else if (g === maxVal) {\n h = (1 / 3) + dr - db;\n } else if (b === maxVal) {\n h = (2 / 3) + dg - dr;\n }\n\n if (h < 0) {\n h += 1;\n } else if (h > 1) {\n h -= 1;\n }\n }\n\n return [\n h * 360,\n s * 100,\n v * 100\n ];\n}\n\n/**\n * Convert CMYK to HSV.\n * @param c Cyan\n * @param m Magenta\n * @param y Yellow\n * @param k Key (Black)\n * @return {number[]} HSV values.\n */\nfunction cmykToHsv(c, m, y, k) {\n c /= 100;\n m /= 100;\n y /= 100;\n k /= 100;\n\n const r = (1 - min(1, c * (1 - k) + k)) * 255;\n const g = (1 - min(1, m * (1 - k) + k)) * 255;\n const b = (1 - min(1, y * (1 - k) + k)) * 255;\n\n return [...rgbToHsv(r, g, b)];\n}\n\n/**\n * Convert HSL to HSV.\n * @param h Hue\n * @param s Saturation\n * @param l Lightness\n * @return {number[]} HSV values.\n */\nfunction hslToHsv(h, s, l) {\n s /= 100;\n l /= 100;\n s *= l < 0.5 ? l : 1 - l;\n\n const ns = (2 * s / (l + s)) * 100;\n const v = (l + s) * 100;\n return [h, ns, v];\n}\n\n/**\n * Convert HEX to HSV.\n * @param hex Hexadecimal string of rgb colors, can have length 3 or 6.\n * @return {number[]} HSV values.\n */\nfunction hexToHsv(hex) {\n return rgbToHsv(...hex.match(/.{2}/g).map(v => parseInt(v, 16)));\n}\n\n/**\n * Try's to parse a string which represents a color to a HSV array.\n * Current supported types are cmyk, rgba, hsla and hexadecimal.\n * @param str\n * @return {*}\n */\nexport function parseToHSVA(str) {\n\n // Check if string is a color-name\n str = str.match(/^[a-zA-Z]+$/) ? standardizeColor(str) : str;\n\n // Regular expressions to match different types of color represention\n const regex = {\n cmyk: /^cmyk[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)/i,\n rgba: /^((rgba)|rgb)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\n hsla: /^((hsla)|hsl)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\n hsva: /^((hsva)|hsv)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]+([\\d.]+)[\\D]*?([\\d.]+|$)/i,\n hexa: /^#?(([\\dA-Fa-f]{3,4})|([\\dA-Fa-f]{6})|([\\dA-Fa-f]{8}))$/i\n };\n\n /**\n * Takes an Array of any type, convert strings which represents\n * a number to a number an anything else to undefined.\n * @param array\n * @return {*}\n */\n const numarize = array => array.map(v => /^(|\\d+)\\.\\d+|\\d+$/.test(v) ? Number(v) : undefined);\n\n let match;\n invalid: for (const type in regex) {\n\n // Check if current scheme passed\n if (!(match = regex[type].exec(str)))\n continue;\n\n // match[2] does only contain a truly value if rgba, hsla, or hsla got matched\n const alpha = !!match[2];\n\n // Try to convert\n switch (type) {\n case 'cmyk': {\n const [, c, m, y, k] = numarize(match);\n\n if (c > 100 || m > 100 || y > 100 || k > 100)\n break invalid;\n\n return {values: cmykToHsv(c, m, y, k), type};\n }\n case 'rgba': {\n const [, , , r, g, b, a] = numarize(match);\n\n if (r > 255 || g > 255 || b > 255 || a < 0 || a > 1 || (alpha === !a))\n break invalid;\n\n return {values: [...rgbToHsv(r, g, b), a], a, type};\n }\n case 'hexa': {\n let [, hex] = match;\n\n if (hex.length === 4 || hex.length === 3) {\n hex = hex.split('').map(v => v + v).join('');\n }\n\n const raw = hex.substring(0, 6);\n let a = hex.substring(6);\n\n // Convert 0 - 255 to 0 - 1 for opacity\n a = a ? (parseInt(a, 16) / 255) : undefined;\n\n return {values: [...hexToHsv(raw), a], a, type};\n }\n case 'hsla': {\n const [, , , h, s, l, a] = numarize(match);\n\n if (h > 360 || s > 100 || l > 100 || a < 0 || a > 1 || (alpha === !a))\n break invalid;\n\n return {values: [...hslToHsv(h, s, l), a], a, type};\n }\n case 'hsva': {\n const [, , , h, s, v, a] = numarize(match);\n\n if (h > 360 || s > 100 || v > 100 || a < 0 || a > 1 || (alpha === !a))\n break invalid;\n\n return {values: [h, s, v, a], a, type};\n }\n }\n }\n\n return {values: null, type: null};\n}\n","import {hsvToHsl, hsvToRgb, hsvToCmyk, hsvToHex} from './color';\n\n/**\n * Simple class which holds the properties\n * of the color represention model hsla (hue saturation lightness alpha)\n */\nexport function HSVaColor(h = 0, s = 0, v = 0, a = 1) {\n const mapper = (original, next) => (precision = -1) => {\n return next(~precision ? original.map(v => Number(v.toFixed(precision))) : original);\n };\n\n const that = {\n h, s, v, a,\n\n toHSVA() {\n const hsva = [that.h, that.s, that.v, that.a];\n hsva.toString = mapper(hsva, arr => `hsva(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\n return hsva;\n },\n\n toHSLA() {\n const hsla = [...hsvToHsl(that.h, that.s, that.v), that.a];\n hsla.toString = mapper(hsla, arr => `hsla(${arr[0]}, ${arr[1]}%, ${arr[2]}%, ${that.a})`);\n return hsla;\n },\n\n toRGBA() {\n const rgba = [...hsvToRgb(that.h, that.s, that.v), that.a];\n rgba.toString = mapper(rgba, arr => `rgba(${arr[0]}, ${arr[1]}, ${arr[2]}, ${that.a})`);\n return rgba;\n },\n\n toCMYK() {\n const cmyk = hsvToCmyk(that.h, that.s, that.v);\n cmyk.toString = mapper(cmyk, arr => `cmyk(${arr[0]}%, ${arr[1]}%, ${arr[2]}%, ${arr[3]}%)`);\n return cmyk;\n },\n\n toHEXA() {\n const hex = hsvToHex(that.h, that.s, that.v);\n\n // Check if alpha channel make sense, convert it to 255 number space, convert\n // to hex and pad it with zeros if needet.\n const alpha = that.a >= 1 ? '' : Number((that.a * 255).toFixed(0))\n .toString(16)\n .toUpperCase().padStart(2, '0');\n\n alpha && hex.push(alpha);\n hex.toString = () => `#${hex.join('').toUpperCase()}`;\n return hex;\n },\n\n clone: () => HSVaColor(that.h, that.s, that.v, that.a)\n };\n\n return that;\n}\n","import * as _ from '../utils/utils';\n\nconst clamp = v => Math.max(Math.min(v, 1), 0);\nexport default function Moveable(opt) {\n\n const that = {\n\n // Assign default values\n options: Object.assign({\n lock: null,\n onchange: () => 0,\n onstop: () => 0\n }, opt),\n\n _keyboard({type, key}) {\n\n // Check to see if the Movable is focused and then move it based on arrow key inputs\n // for improved accessibility\n if (document.activeElement === options.wrapper) {\n if (type === 'keydown') {\n let xm = 0;\n let ym = 0;\n\n switch (key) {\n case 'ArrowLeft':\n xm--;\n break;\n case 'ArrowRight':\n xm++;\n break;\n case 'ArrowUp':\n ym++;\n break;\n case 'ArrowDown':\n ym++;\n }\n\n that.update(\n clamp(that.cache.x + (0.01 * xm)),\n clamp(that.cache.y + (0.01 * ym))\n );\n } else if (key.startsWith('Arrow')) {\n that.options.onstop();\n }\n }\n },\n\n _tapstart(evt) {\n _.on(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\n _.on(document, ['mousemove', 'touchmove'], that._tapmove);\n\n // Prevent default touch event\n evt.preventDefault();\n\n // Trigger\n that._tapmove(evt);\n },\n\n _tapmove(evt) {\n const {options: {lock}, cache} = that;\n const {element, wrapper} = options;\n const b = wrapper.getBoundingClientRect();\n\n let x = 0, y = 0;\n if (evt) {\n const touch = evt && evt.touches && evt.touches[0];\n x = evt ? (touch || evt).clientX : 0;\n y = evt ? (touch || evt).clientY : 0;\n\n // Reset to bounds\n if (x < b.left) x = b.left;\n else if (x > b.left + b.width) x = b.left + b.width;\n if (y < b.top) y = b.top;\n else if (y > b.top + b.height) y = b.top + b.height;\n\n // Normalize\n x -= b.left;\n y -= b.top;\n } else if (cache) {\n x = cache.x * b.width;\n y = cache.y * b.height;\n }\n\n if (lock !== 'h') {\n element.style.left = `calc(${x / b.width * 100}% - ${element.offsetWidth / 2}px)`;\n }\n\n if (lock !== 'v') {\n element.style.top = `calc(${y / b.height * 100}% - ${element.offsetHeight / 2}px)`;\n }\n\n that.cache = {x: x / b.width, y: y / b.height};\n const cx = clamp(x / wrapper.offsetWidth);\n const cy = clamp(y / wrapper.offsetHeight);\n\n switch (lock) {\n case 'v':\n return options.onchange(cx);\n case 'h':\n return options.onchange(cy);\n default:\n return options.onchange(cx, cy);\n }\n },\n\n _tapstop() {\n that.options.onstop();\n _.off(document, ['mouseup', 'touchend', 'touchcancel'], that._tapstop);\n _.off(document, ['mousemove', 'touchmove'], that._tapmove);\n },\n\n trigger() {\n that._tapmove();\n },\n\n update(x = 0, y = 0) {\n const {left, top, width, height} = that.options.wrapper.getBoundingClientRect();\n\n if (that.options.lock === 'h') {\n y = x;\n }\n\n that._tapmove({\n clientX: left + width * x,\n clientY: top + height * y\n });\n },\n\n destroy() {\n const {options, _tapstart} = that;\n _.off([options.wrapper, options.element], 'mousedown', _tapstart);\n _.off([options.wrapper, options.element], 'touchstart', _tapstart, {\n passive: false\n });\n }\n };\n\n // Initilize\n const {options, _tapstart, _keyboard} = that;\n _.on([options.wrapper, options.element], 'mousedown', _tapstart);\n _.on([options.wrapper, options.element], 'touchstart', _tapstart, {\n passive: false\n });\n\n _.on(document, ['keydown', 'keyup'], _keyboard);\n\n\n return that;\n}\n","import * as _ from '../utils/utils';\n\nexport default function Selectable(opt = {}) {\n opt = Object.assign({\n onchange: () => 0,\n className: '',\n elements: []\n }, opt);\n\n const onTap = _.on(opt.elements, 'click', evt => {\n opt.elements.forEach(e =>\n e.classList[evt.target === e ? 'add' : 'remove'](opt.className)\n );\n\n opt.onchange(evt);\n });\n\n return {\n destroy: () => _.off(...onTap)\n };\n}\n","/**\n * Micro positioning-engine\n * @param el\n * @param reference\n * @param pos\n * @param padding\n * @returns {{update(): void}}\n * @constructor\n */\nexport default function Nanopop({el, reference, padding = 8}) {\n const vBehaviour = {start: 'sme', middle: 'mse', end: 'ems'};\n const hBehaviour = {top: 'tbrl', right: 'rltb', bottom: 'btrl', left: 'lrbt'};\n\n const getInfo = ((cache = {}) => (pos, cached = cache[pos]) => {\n if (cached) return cached;\n const [position, variant = 'middle'] = pos.split('-');\n const isVertical = (position === 'top' || position === 'bottom');\n\n return cache[pos] = {\n position,\n variant,\n isVertical\n };\n })();\n\n return {\n update(pos) {\n const {position, variant, isVertical} = getInfo(pos);\n const rb = reference.getBoundingClientRect();\n const eb = el.getBoundingClientRect();\n\n const positions = vertical => vertical ? {\n t: rb.top - eb.height - padding,\n b: rb.bottom + padding\n } : {\n r: rb.right + padding,\n l: rb.left - eb.width - padding\n };\n\n const variants = vertical => vertical ? {\n s: rb.left + rb.width - eb.width,\n m: (-eb.width / 2) + (rb.left + rb.width / 2),\n e: rb.left\n } : {\n s: rb.bottom - eb.height,\n m: rb.bottom - rb.height / 2 - eb.height / 2,\n e: rb.bottom - rb.height\n };\n\n const leastApplied = {};\n\n function apply(bevs, vars, styleprop) {\n const vertical = styleprop === 'top';\n const adder = vertical ? eb.height : eb.width;\n const win = window[vertical ? 'innerHeight' : 'innerWidth'];\n\n for (const ch of bevs) {\n const v = vars[ch];\n const sv = leastApplied[styleprop] = `${v}px`;\n\n if (v > 0 && (v + adder) < win) {\n el.style[styleprop] = sv;\n return true;\n }\n }\n\n return false;\n }\n\n for (const rot of [isVertical, !isVertical]) {\n const v2Ok = apply(hBehaviour[position], positions(rot), rot ? 'top' : 'left');\n const v1Ok = apply(vBehaviour[variant], variants(rot), rot ? 'left' : 'top');\n\n if (v2Ok && v1Ok) {\n return;\n }\n }\n\n el.style.left = leastApplied.left;\n el.style.top = leastApplied.top;\n }\n };\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('btn:toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return (this.options.i18n || {})[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pickr.min.js b/dist/pickr.min.js index d9a1c3ea..dc1ce26f 100644 --- a/dist/pickr.min.js +++ b/dist/pickr.min.js @@ -1,3 +1,3 @@ /*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){"use strict";o.r(e);var n={};function i(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,n)}return o}function r(t){for(var e=1;e>/g).reduce((t,e,o,n)=>(t=t.querySelector(e),ot)){function o(o){const n=[.001,.01,.1][Number(o.shiftKey||2*o.ctrlKey)]*(o.deltaY<0?1:-1);let i=0,r=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(t,o)=>o<=r&&o+t.length>=r?(r=o,e(Number(t),n,i)):(i++,t)),t.focus(),t.setSelectionRange(r,r),o.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",()=>c(window,"wheel",o,{passive:!1})),c(t,"blur",()=>a(window,"wheel",o))}const{min:b,max:v,floor:g,round:y}=Math;function _(t,e,o){e/=100,o/=100;const n=g(t=t/360*6),i=t-n,r=o*(1-e),s=o*(1-i*e),c=o*(1-(1-i)*e),a=n%6;return[255*[o,s,r,r,c,o][a],255*[c,o,o,s,r,r][a],255*[r,r,c,o,o,s][a]]}function w(t,e,o){const n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}function A(t,e,o){let n,i,r;const s=b(t/=255,e/=255,o/=255),c=v(t,e,o),a=c-s;if(0===a)n=i=0;else{i=a/c;const r=((c-t)/6+a/2)/a,s=((c-e)/6+a/2)/a,l=((c-o)/6+a/2)/a;t===c?n=l-s:e===c?n=1/3+r-l:o===c&&(n=2/3+s-r),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(r=c)]}function C(t,e,o,n){return e/=100,o/=100,[...A(255*(1-b(1,(t/=100)*(1-(n/=100))+n)),255*(1-b(1,e*(1-n)+n)),255*(1-b(1,o*(1-n)+n)))]}function k(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function S(t){return A(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function O(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;const e={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;t:for(const i in e){if(!(n=e[i].exec(t)))continue;const r=!!n[2];switch(i){case"cmyk":{const[,t,e,r,s]=o(n);if(t>100||e>100||r>100||s>100)break t;return{values:C(t,e,r,s),type:i}}case"rgba":{const[,,,t,e,s,c]=o(n);if(t>255||e>255||s>255||c<0||c>1||r===!c)break t;return{values:[...A(t,e,s),c],a:c,type:i}}case"hexa":{let[,t]=n;4!==t.length&&3!==t.length||(t=t.split("").map(t=>t+t).join(""));const e=t.substring(0,6);let o=t.substring(6);return o=o?parseInt(o,16)/255:void 0,{values:[...S(e),o],a:o,type:i}}case"hsla":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[...k(t,e,s),c],a:c,type:i}}case"hsva":{const[,,,t,e,s,c]=o(n);if(t>360||e>100||s>100||c<0||c>1||r===!c)break t;return{values:[t,e,s,c],a:c,type:i}}}}return{values:null,type:null}}function j(t=0,e=0,o=0,n=1){const i=(t,e)=>(o=-1)=>e(~o?t.map(t=>Number(t.toFixed(o))):t),r={h:t,s:e,v:o,a:n,toHSVA(){const t=[r.h,r.s,r.v,r.a];return t.toString=i(t,t=>"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toHSLA(){const t=[...w(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(r.a,")")),t},toRGBA(){const t=[..._(r.h,r.s,r.v),r.a];return t.toString=i(t,t=>"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(r.a,")")),t},toCMYK(){const t=function(t,e,o){const n=_(t,e,o),i=n[0]/255,r=n[1]/255,s=n[2]/255;let c,a,l,p;return[100*(a=1===(c=b(1-i,1-r,1-s))?0:(1-i-c)/(1-c)),100*(l=1===c?0:(1-r-c)/(1-c)),100*(p=1===c?0:(1-s-c)/(1-c)),100*c]}(r.h,r.s,r.v);return t.toString=i(t,t=>"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")),t},toHEXA(){const t=function(t,e,o){return _(t,e,o).map(t=>y(t).toString(16).padStart(2,"0"))}(r.h,r.s,r.v),e=r.a>=1?"":Number((255*r.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=()=>"#".concat(t.join("").toUpperCase()),t},clone:()=>j(r.h,r.s,r.v,r.a)};return r}const E=t=>Math.max(Math.min(t,1),0);function x(t){const e={options:Object.assign({lock:null,onchange:()=>0,onstop:()=>0},t),_keyboard({type:t,key:n}){if(document.activeElement===o.wrapper)if("keydown"===t){let t=0,o=0;switch(n){case"ArrowLeft":t--;break;case"ArrowRight":t++;break;case"ArrowUp":o++;break;case"ArrowDown":o++}e.update(E(e.cache.x+.01*t),E(e.cache.y+.01*o))}else n.startsWith("Arrow")&&e.options.onstop()},_tapstart(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const{options:{lock:n},cache:i}=e,{element:r,wrapper:s}=o,c=s.getBoundingClientRect();let a=0,l=0;if(t){const e=t&&t.touches&&t.touches[0];a=t?(e||t).clientX:0,l=t?(e||t).clientY:0,ac.left+c.width&&(a=c.left+c.width),lc.top+c.height&&(l=c.top+c.height),a-=c.left,l-=c.top}else i&&(a=i.x*c.width,l=i.y*c.height);"h"!==n&&(r.style.left="calc(".concat(a/c.width*100,"% - ").concat(r.offsetWidth/2,"px)")),"v"!==n&&(r.style.top="calc(".concat(l/c.height*100,"% - ").concat(r.offsetHeight/2,"px)")),e.cache={x:a/c.width,y:l/c.height};const p=E(a/s.offsetWidth),u=E(l/s.offsetHeight);switch(n){case"v":return o.onchange(p);case"h":return o.onchange(u);default:return o.onchange(p,u)}},_tapstop(){e.options.onstop(),a(document,["mouseup","touchend","touchcancel"],e._tapstop),a(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(t=0,o=0){const{left:n,top:i,width:r,height:s}=e.options.wrapper.getBoundingClientRect();"h"===e.options.lock&&(o=t),e._tapmove({clientX:n+r*t,clientY:i+s*o})},destroy(){const{options:t,_tapstart:o}=e;a([t.wrapper,t.element],"mousedown",o),a([t.wrapper,t.element],"touchstart",o,{passive:!1})}},{options:o,_tapstart:n,_keyboard:i}=e;return c([o.wrapper,o.element],"mousedown",n),c([o.wrapper,o.element],"touchstart",n,{passive:!1}),c(document,["keydown","keyup"],i),e}function L(t={}){t=Object.assign({onchange:()=>0,className:"",elements:[]},t);const e=c(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)});return{destroy:()=>a(...e)}}function P({el:t,reference:e,padding:o=8}){const n={start:"sme",middle:"mse",end:"ems"},i={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},r=((t={})=>(e,o=t[e])=>{if(o)return o;const[n,i="middle"]=e.split("-"),r="top"===n||"bottom"===n;return t[e]={position:n,variant:i,isVertical:r}})();return{update(s){const{position:c,variant:a,isVertical:l}=r(s),p=e.getBoundingClientRect(),u=t.getBoundingClientRect(),h=t=>t?{t:p.top-u.height-o,b:p.bottom+o}:{r:p.right+o,l:p.left-u.width-o},d=t=>t?{s:p.left+p.width-u.width,m:-u.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-u.height,m:p.bottom-p.height/2-u.height/2,e:p.bottom-p.height},f={};function m(e,o,n){const i="top"===n,r=i?u.height:u.width,s=window[i?"innerHeight":"innerWidth"];for(const i of e){const e=o[i],c=f[n]="".concat(e,"px");if(e>0&&e+r{const c=t=>t?"":'style="display:none" hidden',a=e=>t._t(e),l=h('\n
\n\n '.concat(o?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n ")),p=l.interaction;return p.options.find(t=>!t.hidden&&!t.classList.add("active")),p.type=()=>p.options.find(t=>t.classList.contains("active")),l};function R(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class H{constructor(t){R(this,"_initializingActive",!0),R(this,"_recalc",!0),R(this,"_color",j()),R(this,"_lastColor",j()),R(this,"_swatchColors",[]),R(this,"_eventListener",{init:[],save:[],hide:[],show:[],clear:[],change:[],changestop:[],cancel:[],swatchselect:[]}),this.options=t=Object.assign({appClass:null,theme:"classic",useAsButton:!1,padding:8,disabled:!1,comparison:!0,closeOnScroll:!1,outputPrecision:0,lockOpacity:!1,autoReposition:!0,container:"body",components:{interaction:{}},i18n:null,swatches:null,inline:!1,sliders:null,default:"#42445a",defaultRepresentation:null,position:"bottom-middle",adjustableNumbers:!0,showAlways:!1,closeWithKey:"Escape"},t);const{swatches:e,components:o,theme:n,sliders:i,lockOpacity:r,padding:s}=t;["nano","monolith"].includes(n)&&!i&&(t.sliders="h"),o.interaction||(o.interaction={});const{preview:c,opacity:a,hue:l,palette:p}=o;o.opacity=!r&&a,o.palette=p||c||a||l,this._preBuild(),this._buildComponents(),this._bindEvents(),this._finalBuild(),e&&e.length&&e.forEach(t=>this.addSwatch(t));const{button:u,app:h}=this._root;this._nanopop=P({reference:u,padding:s,el:h}),u.setAttribute("role","button"),u.setAttribute("aria-label",this._t("btn:toggle","toggle color picker dialog"));const d=this;requestAnimationFrame(function e(){if(!h.offsetWidth&&h.parentElement!==t.container)return requestAnimationFrame(e);d.setColor(t.default),d._rePositioningPicker(),t.defaultRepresentation&&(d._representation=t.defaultRepresentation,d.setColorRepresentation(d._representation)),t.showAlways&&d.show(),d._initializingActive=!1,d._emit("init")})}_preBuild(){const t=this.options;for(const e of["el","container"])t[e]=f(t[e]);this._root=B(this,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:x({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const e of t._swatchColors){const{el:t,color:o}=e;t.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active")}s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:x({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:x({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame(function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)})):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return(this.options.i18n||{})[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p('','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n ")),p=l.interaction;return p.options.find(t=>!t.hidden&&!t.classList.add("active")),p.type=()=>p.options.find(t=>t.classList.contains("active")),l})(this,t),t.useAsButton&&(this._root.button=t.el),t.container.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){const o=t.el.parentElement;t.el.nextSibling?o.insertBefore(e.app,t.el.nextSibling):o.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}_buildComponents(){const t=this,e=this.options.components,o=(t.options.sliders||"v").repeat(2),[n,i]=o.match(/^[vh]+$/g)?o:[],r=()=>this._color||(this._color=this._lastColor.clone()),s={palette:x({element:t._root.palette.picker,wrapper:t._root.palette.palette,onstop:()=>t._emit("changestop",t),onchange(o,n){if(!e.palette)return;const i=r(),{_root:s,options:c}=t;t._recalc&&(i.s=100*o,i.v=100-100*n,i.v<0&&(i.v=0),t._updateOutput());const a=i.toRGBA().toString(0);this.element.style.background=a,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(i.a,"), transparent),\n linear-gradient(to left, hsla(").concat(i.h,", 100%, 50%, ").concat(i.a,"), rgba(255, 255, 255, ").concat(i.a,"))\n "),c.comparison?c.useAsButton||t._lastColor||(s.preview.lastColor.style.color=a):s.button.style.color=a;const l=i.toHEXA().toString();for(const{el:e,color:o}of t._swatchColors)e.classList[l===o.toHEXA().toString()?"add":"remove"]("pcr-active");s.preview.currentColor.style.color=a,t.options.comparison||s.button.classList.remove("clear")}}),hue:x({lock:"v"===i?"h":"v",element:t._root.hue.picker,wrapper:t._root.hue.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.hue||!e.palette)return;const n=r();t._recalc&&(n.h=360*o),this.element.style.backgroundColor="hsl(".concat(n.h,", 100%, 50%)"),s.palette.trigger()}}),opacity:x({lock:"v"===n?"h":"v",element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onstop:()=>t._emit("changestop",t),onchange(o){if(!e.opacity||!e.palette)return;const n=r();t._recalc&&(n.a=Math.round(100*o)/100),this.element.style.background="rgba(0, 0, 0, ".concat(n.a,")"),s.palette.trigger()}}),selectable:L({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._recalc&&t._updateOutput()}})};this._components=s}_bindEvents(){const{_root:t,options:e}=this,o=[c(t.interaction.clear,"click",()=>this._clearColor()),c([t.interaction.cancel,t.preview.lastColor],"click",()=>{this._emit("cancel",this),this.setHSVA(...(this._lastColor||this._color).toHSVA(),!0)}),c(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),c(t.interaction.result,["keyup","input"],t=>{this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),c(t.interaction.result,["focus","blur"],t=>{this._recalc="blur"===t.type,this._recalc&&this._updateOutput()}),c([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0)];if(!e.showAlways){const n=e.closeWithKey;o.push(c(t.button,"click",()=>this.isOpen()?this.hide():this.show()),c(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),c(document,["touchstart","mousedown"],e=>{this.isOpen()&&!d(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}if(e.adjustableNumbers){const e={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};m(t.interaction.result,(t,o,n)=>{const i=e[this.getColorRepresentation().toLowerCase()];if(i){const e=i[n],r=t+(e>=100?1e3*o:o);return r<=0?0:Number((r{n.isOpen()&&(e.closeOnScroll&&n.hide(),null===t?(t=setTimeout(()=>t=null,100),requestAnimationFrame((function e(){n._rePositioningPicker(),null!==t&&requestAnimationFrame(e)}))):(clearTimeout(t),t=setTimeout(()=>t=null,100)))},{capture:!0}))}this._eventBindings=o}_rePositioningPicker(){const{options:t}=this;if(!t.inline){const{app:e}=this._root;matchMedia("(max-width: 576px)").matches?Object.assign(e.style,{margin:"auto",height:"".concat(e.getBoundingClientRect().height,"px"),top:0,bottom:0,left:0,right:0}):(Object.assign(e.style,{margin:null,right:null,top:null,bottom:null,left:null,height:null}),this._nanopop.update(t.position))}}_updateOutput(){const{_root:t,_color:e,options:o}=this;if(t.interaction.type()){const n="to".concat(t.interaction.type().getAttribute("data-type"));t.interaction.result.value="function"==typeof e[n]?e[n]().toString(o.outputPrecision):""}!this._initializingActive&&this._recalc&&this._emit("change",e)}_clearColor(t=!1){const{_root:e,options:o}=this;o.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),o.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}_parseLocalColor(t){const{values:e,type:o,a:n}=O(t),{lockOpacity:i}=this.options,r=void 0!==n&&1!==n;return e&&3===e.length&&(e[3]=void 0),{values:!e||i&&r?null:e,type:o}}_emit(t,...e){this._eventListener[t].forEach(t=>t(...e,this))}_t(t,e="unknown"){return(this.options.i18n||{})[t]||e}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const{values:e}=this._parseLocalColor(t);if(e){const{_swatchColors:t,_root:o}=this,n=j(...e),i=p(''}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n","// Import utils\nimport * as _ from './utils/utils';\nimport {parseToHSVA} from './utils/color';\n\n// Import classes\nimport {HSVaColor} from './utils/hsvacolor';\nimport Moveable from './libs/moveable';\nimport Selectable from './libs/selectable';\nimport Nanopop from './libs/nanopop';\nimport buildPickr from './template';\n\nclass Pickr {\n\n // Will be used to prevent specific actions during initilization\n _initializingActive = true;\n\n // If the current color value should be recalculated\n _recalc = true;\n\n // Current and last color for comparison\n _color = HSVaColor();\n _lastColor = HSVaColor();\n _swatchColors = [];\n\n // Evenlistener name: [callbacks]\n _eventListener = {\n init: [],\n save: [],\n hide: [],\n show: [],\n clear: [],\n change: [],\n changestop: [],\n cancel: [],\n swatchselect: []\n };\n\n constructor(opt) {\n\n // Assign default values\n this.options = opt = Object.assign({\n appClass: null,\n theme: 'classic',\n useAsButton: false,\n padding: 8,\n disabled: false,\n comparison: true,\n closeOnScroll: false,\n outputPrecision: 0,\n lockOpacity: false,\n autoReposition: true,\n container: 'body',\n components: {\n interaction: {}\n },\n\n i18n: null,\n swatches: null,\n inline: false,\n sliders: null,\n\n default: '#42445a',\n defaultRepresentation: null,\n position: 'bottom-middle',\n adjustableNumbers: true,\n showAlways: false,\n\n closeWithKey: 'Escape'\n }, opt);\n\n const {swatches, components, theme, sliders, lockOpacity, padding} = opt;\n\n if (['nano', 'monolith'].includes(theme) && !sliders) {\n opt.sliders = 'h';\n }\n\n // Check interaction section\n if (!components.interaction) {\n components.interaction = {};\n }\n\n // Overwrite palette if preview, opacity or hue are true\n const {preview, opacity, hue, palette} = components;\n components.opacity = (!lockOpacity && opacity);\n components.palette = palette || preview || opacity || hue;\n\n // Initialize picker\n this._preBuild();\n this._buildComponents();\n this._bindEvents();\n this._finalBuild();\n\n // Append pre-defined swatch colors\n if (swatches && swatches.length) {\n swatches.forEach(color => this.addSwatch(color));\n }\n\n // Initialize positioning engine\n const {button, app} = this._root;\n this._nanopop = Nanopop({\n reference: button,\n padding,\n el: app\n });\n\n // Initialize accessibility\n button.setAttribute('role', 'button');\n button.setAttribute('aria-label', this._t('btn:toggle', 'toggle color picker dialog'));\n\n // Initilization is finish, pickr is visible and ready for usage\n const that = this;\n requestAnimationFrame((function cb() {\n\n if (!app.offsetWidth && app.parentElement !== opt.container) {\n return requestAnimationFrame(cb);\n }\n\n // Apply default color\n that.setColor(opt.default);\n that._rePositioningPicker();\n\n // Initialize color representation\n if (opt.defaultRepresentation) {\n that._representation = opt.defaultRepresentation;\n that.setColorRepresentation(that._representation);\n }\n\n // Show pickr if locked\n if (opt.showAlways) {\n that.show();\n }\n\n // Initialization is done - pickr is usable, fire init event\n that._initializingActive = false;\n that._emit('init');\n }));\n }\n\n // Does only the absolutly basic thing to initialize the components\n _preBuild() {\n const opt = this.options;\n\n // Resolve elements\n for (const type of ['el', 'container']) {\n opt[type] = _.resolveElement(opt[type]);\n }\n\n // Create element and append it to body to\n // prevent initialization errors\n this._root = buildPickr(this, opt);\n\n // Check if a custom button is used\n if (opt.useAsButton) {\n this._root.button = opt.el; // Replace button with customized button\n }\n\n opt.container.appendChild(this._root.root);\n }\n\n _finalBuild() {\n const opt = this.options;\n const root = this._root;\n\n // Remove from body\n opt.container.removeChild(root.root);\n\n if (opt.inline) {\n const parent = opt.el.parentElement;\n\n if (opt.el.nextSibling) {\n parent.insertBefore(root.app, opt.el.nextSibling);\n } else {\n parent.appendChild(root.app);\n }\n } else {\n opt.container.appendChild(root.app);\n }\n\n // Don't replace the the element if a custom button is used\n if (!opt.useAsButton) {\n\n // Replace element with actual color-picker\n opt.el.parentNode.replaceChild(root.root, opt.el);\n } else if (opt.inline) {\n opt.el.remove();\n }\n\n // Check if it should be immediatly disabled\n if (opt.disabled) {\n this.disable();\n }\n\n // Check if color comparison is disabled, if yes - remove transitions so everything keeps smoothly\n if (!opt.comparison) {\n root.button.style.transition = 'none';\n if (!opt.useAsButton) {\n root.preview.lastColor.style.transition = 'none';\n }\n }\n\n this.hide();\n }\n\n _buildComponents() {\n\n // Instance reference\n const inst = this;\n const cs = this.options.components;\n const sliders = (inst.options.sliders || 'v').repeat(2);\n const [so, sh] = sliders.match(/^[vh]+$/g) ? sliders : [];\n\n // Re-assign if null\n const getColor = () =>\n this._color || (this._color = this._lastColor.clone());\n\n const components = {\n\n palette: Moveable({\n element: inst._root.palette.picker,\n wrapper: inst._root.palette.palette,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(x, y) {\n if (!cs.palette) return;\n\n const color = getColor();\n const {_root, options} = inst;\n\n // Update the input field only if the user is currently not typing\n if (inst._recalc) {\n\n // Calculate saturation based on the position\n color.s = x * 100;\n\n // Calculate the value\n color.v = 100 - y * 100;\n\n // Prevent falling under zero\n color.v < 0 ? color.v = 0 : 0;\n inst._updateOutput();\n }\n\n // Set picker and gradient color\n const cssRGBaString = color.toRGBA().toString(0);\n this.element.style.background = cssRGBaString;\n this.wrapper.style.background = `\n linear-gradient(to top, rgba(0, 0, 0, ${color.a}), transparent),\n linear-gradient(to left, hsla(${color.h}, 100%, 50%, ${color.a}), rgba(255, 255, 255, ${color.a}))\n `;\n\n // Check if color is locked\n if (!options.comparison) {\n _root.button.style.color = cssRGBaString;\n } else {\n if (!options.useAsButton && !inst._lastColor) {\n _root.preview.lastColor.style.color = cssRGBaString;\n }\n }\n\n // Check if there's a swatch which color matches the current one\n const hexa = color.toHEXA().toString();\n for (const {el, color} of inst._swatchColors) {\n el.classList[hexa === color.toHEXA().toString() ? 'add' : 'remove']('pcr-active');\n }\n\n // Change current color\n _root.preview.currentColor.style.color = cssRGBaString;\n\n if (!inst.options.comparison) {\n\n // If the user changes the color, remove the cleared icon\n _root.button.classList.remove('clear');\n }\n }\n }),\n\n hue: Moveable({\n lock: sh === 'v' ? 'h' : 'v',\n element: inst._root.hue.picker,\n wrapper: inst._root.hue.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.hue || !cs.palette) return;\n const color = getColor();\n\n // Calculate hue\n if (inst._recalc) {\n color.h = v * 360;\n }\n\n // Update color\n this.element.style.backgroundColor = `hsl(${color.h}, 100%, 50%)`;\n components.palette.trigger();\n }\n }),\n\n opacity: Moveable({\n lock: so === 'v' ? 'h' : 'v',\n element: inst._root.opacity.picker,\n wrapper: inst._root.opacity.slider,\n\n onstop: () => inst._emit('changestop', inst),\n onchange(v) {\n if (!cs.opacity || !cs.palette) return;\n const color = getColor();\n\n // Calculate opacity\n if (inst._recalc) {\n color.a = Math.round(v * 1e2) / 100;\n }\n\n // Update color\n this.element.style.background = `rgba(0, 0, 0, ${color.a})`;\n components.palette.trigger();\n }\n }),\n\n selectable: Selectable({\n elements: inst._root.interaction.options,\n className: 'active',\n\n onchange(e) {\n inst._representation = e.target.getAttribute('data-type').toUpperCase();\n inst._recalc && inst._updateOutput();\n }\n })\n };\n\n this._components = components;\n }\n\n _bindEvents() {\n const {_root, options} = this;\n\n const eventBindings = [\n\n // Clear color\n _.on(_root.interaction.clear, 'click', () => this._clearColor()),\n\n // Select last color on click\n _.on([\n _root.interaction.cancel,\n _root.preview.lastColor\n ], 'click', () => {\n this._emit('cancel', this);\n this.setHSVA(...(this._lastColor || this._color).toHSVA(), true);\n }),\n\n // Save color\n _.on(_root.interaction.save, 'click', () => {\n !this.applyColor() && !options.showAlways && this.hide();\n }),\n\n _.on(_root.interaction.result, ['keyup', 'input'], e => {\n\n // Fire listener if initialization is finish and changed color was valid\n if (this.setColor(e.target.value, true) && !this._initializingActive) {\n this._emit('change', this._color);\n }\n\n e.stopImmediatePropagation();\n }),\n\n // Detect user input and disable auto-recalculation\n _.on(_root.interaction.result, ['focus', 'blur'], e => {\n this._recalc = e.type === 'blur';\n this._recalc && this._updateOutput();\n }),\n\n // Cancel input detection on color change\n _.on([\n _root.palette.palette,\n _root.palette.picker,\n _root.hue.slider,\n _root.hue.picker,\n _root.opacity.slider,\n _root.opacity.picker\n ], ['mousedown', 'touchstart'], () => this._recalc = true)\n ];\n\n // Provide hiding / showing abilities only if showAlways is false\n if (!options.showAlways) {\n const ck = options.closeWithKey;\n\n eventBindings.push(\n // Save and hide / show picker\n _.on(_root.button, 'click', () => this.isOpen() ? this.hide() : this.show()),\n\n // Close with escape key\n _.on(document, 'keyup', e => this.isOpen() && (e.key === ck || e.code === ck) && this.hide()),\n\n // Cancel selecting if the user taps behind the color picker\n _.on(document, ['touchstart', 'mousedown'], e => {\n if (this.isOpen() && !_.eventPath(e).some(el => el === _root.app || el === _root.button)) {\n this.hide();\n }\n }, {capture: true})\n );\n }\n\n // Make input adjustable if enabled\n if (options.adjustableNumbers) {\n const ranges = {\n rgba: [255, 255, 255, 1],\n hsva: [360, 100, 100, 1],\n hsla: [360, 100, 100, 1],\n cmyk: [100, 100, 100, 100]\n };\n\n _.adjustableInputNumbers(_root.interaction.result, (o, step, index) => {\n const range = ranges[this.getColorRepresentation().toLowerCase()];\n\n if (range) {\n const max = range[index];\n\n // Calculate next reasonable number\n const nv = o + (max >= 100 ? step * 1000 : step);\n\n // Apply range of zero up to max, fix floating-point issues\n return nv <= 0 ? 0 : Number((nv < max ? nv : max).toPrecision(3));\n }\n\n return o;\n });\n }\n\n if (options.autoReposition && !options.inline) {\n let timeout = null;\n const that = this;\n\n // Re-calc position on window resize, scroll and wheel\n eventBindings.push(\n _.on(window, ['scroll', 'resize'], () => {\n if (that.isOpen()) {\n\n if (options.closeOnScroll) {\n that.hide();\n }\n\n if (timeout === null) {\n timeout = setTimeout(() => timeout = null, 100);\n\n // Update position on every frame\n requestAnimationFrame(function rs() {\n that._rePositioningPicker();\n (timeout !== null) && requestAnimationFrame(rs);\n });\n } else {\n clearTimeout(timeout);\n timeout = setTimeout(() => timeout = null, 100);\n }\n }\n }, {capture: true})\n );\n }\n\n // Save bindings\n this._eventBindings = eventBindings;\n }\n\n _rePositioningPicker() {\n const {options} = this;\n\n // No repositioning needed if inline\n if (!options.inline) {\n const {app} = this._root;\n\n if (matchMedia('(max-width: 576px)').matches) {\n Object.assign(app.style, {\n margin: 'auto',\n height: `${app.getBoundingClientRect().height}px`,\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n });\n } else {\n Object.assign(app.style, {\n margin: null,\n right: null,\n top: null,\n bottom: null,\n left: null,\n height: null\n });\n\n this._nanopop.update(options.position);\n }\n }\n }\n\n _updateOutput() {\n const {_root, _color, options} = this;\n\n // Check if component is present\n if (_root.interaction.type()) {\n\n // Construct function name and call if present\n const method = `to${_root.interaction.type().getAttribute('data-type')}`;\n _root.interaction.result.value = typeof _color[method] === 'function' ?\n _color[method]().toString(options.outputPrecision) : '';\n }\n\n // Fire listener if initialization is finish\n if (!this._initializingActive && this._recalc) {\n this._emit('change', _color);\n }\n }\n\n _clearColor(silent = false) {\n const {_root, options} = this;\n\n // Change only the button color if it isn't customized\n if (!options.useAsButton) {\n _root.button.style.color = 'rgba(0, 0, 0, 0.15)';\n }\n\n _root.button.classList.add('clear');\n\n if (!options.showAlways) {\n this.hide();\n }\n\n this._lastColor = null;\n if (!this._initializingActive && !silent) {\n\n // Fire listener\n this._emit('save', null);\n this._emit('clear', this);\n }\n }\n\n _parseLocalColor(str) {\n const {values, type, a} = parseToHSVA(str);\n const {lockOpacity} = this.options;\n const alphaMakesAChange = a !== undefined && a !== 1;\n\n // If no opacity is applied, add undefined at the very end which gets\n // set to 1 in setHSVA\n if (values && values.length === 3) {\n values[3] = undefined;\n }\n\n return {\n values: (!values || (lockOpacity && alphaMakesAChange)) ? null : values,\n type\n };\n }\n\n _emit(event, ...args) {\n this._eventListener[event].forEach(cb => cb(...args, this));\n }\n\n _t(key, def = 'unknown') {\n return (this.options.i18n || {})[key] || def;\n }\n\n on(event, cb) {\n\n // Validate\n if (typeof cb === 'function' && typeof event === 'string' && event in this._eventListener) {\n this._eventListener[event].push(cb);\n }\n\n return this;\n }\n\n off(event, cb) {\n const callBacks = this._eventListener[event];\n\n if (callBacks) {\n const index = callBacks.indexOf(cb);\n\n if (~index) {\n callBacks.splice(index, 1);\n }\n }\n\n return this;\n }\n\n /**\n * Appends a color to the swatch palette\n * @param color\n * @returns {boolean}\n */\n addSwatch(color) {\n const {values} = this._parseLocalColor(color);\n\n if (values) {\n const {_swatchColors, _root} = this;\n const color = HSVaColor(...values);\n\n // Create new swatch HTMLElement\n const el = _.createElementFromString(\n `'}\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n \n `);\n\n const int = root.interaction;\n\n // Select option which is not hidden\n int.options.find(o => !o.hidden && !o.classList.add('active'));\n\n // Create method to find currenlty active option\n int.type = () => int.options.find(e => e.classList.contains('active'));\n return root;\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/js/template.js b/src/js/template.js index 680aa21d..fde8ceef 100644 --- a/src/js/template.js +++ b/src/js/template.js @@ -35,7 +35,7 @@ export default (inst, {components: c, useAsButton, inline, appClass, theme, lock
- + From 91f1d4aba644e1891a96feda6b4c80b7443d7c36 Mon Sep 17 00:00:00 2001 From: Simon Reinisch Date: Mon, 6 Apr 2020 16:54:08 +0200 Subject: [PATCH 6/8] More i18n options; Cleanup --- README.md | 19 ++++++++++----- src/js/pickr.js | 15 ++++++------ src/js/template.js | 58 +++++++++++++++++++++++++++------------------- 3 files changed, 55 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 96e26865..0dc4d7ae 100644 --- a/README.md +++ b/README.md @@ -333,17 +333,24 @@ const pickr = new Pickr({ // Translations i18n: { - 'dialog': 'color picker dialog', + + // Strings visible in the UI + 'ui:dialog': 'color picker dialog', 'btn:toggle': 'toggle color picker dialog', - 'btn:swatch': 'color-swatch', + 'btn:swatch': 'color swatch', 'btn:last-color': 'use previous color', 'btn:save': 'Save', 'btn:cancel': 'Cancel', 'btn:clear': 'Clear', - 'input:color': 'color input field', - 'ui:palette': 'color selection area', - 'ui:hue': 'hue selection slider', - 'ui:opacity': 'selection slider' + + // Strings used for aria-labels + 'aria:btn:save': 'save and close', + 'aria:btn:cancel': 'cancel and close', + 'aria:btn:clear': 'clear and close', + 'aria:input': 'color input field', + 'aria:palette': 'color selection area', + 'aria:hue': 'hue selection slider', + 'aria:opacity': 'selection slider' } }); ``` diff --git a/src/js/pickr.js b/src/js/pickr.js index 7bb7baca..2402159b 100644 --- a/src/js/pickr.js +++ b/src/js/pickr.js @@ -140,23 +140,23 @@ class Pickr { // Does only the absolutly basic thing to initialize the components _preBuild() { - const opt = this.options; + const {options} = this; // Resolve elements for (const type of ['el', 'container']) { - opt[type] = _.resolveElement(opt[type]); + options[type] = _.resolveElement(options[type]); } // Create element and append it to body to // Prevent initialization errors - this._root = buildPickr(this, opt); + this._root = buildPickr(this); // Check if a custom button is used - if (opt.useAsButton) { - this._root.button = opt.el; // Replace button with customized button + if (options.useAsButton) { + this._root.button = options.el; // Replace button with customized button } - opt.container.appendChild(this._root.root); + options.container.appendChild(this._root.root); } _finalBuild() { @@ -230,6 +230,7 @@ class Pickr { const color = getColor(); const {_root, options} = inst; + const {lastColor, currentColor} = _root.preview; // Update the input field only if the user is currently not typing if (inst._recalc) { @@ -581,7 +582,7 @@ class Pickr { // Create new swatch HTMLElement const el = _.createElementFromString( - `'} -
-
-
-
- +
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
- +
+ - - - - - + + + + + - - - + + +
@@ -57,7 +67,7 @@ export default (inst, {components: c, useAsButton, inline, appClass, theme, lock // Select option which is not hidden int.options.find(o => !o.hidden && !o.classList.add('active')); - // Create method to find currenlty active option + // Append method to find currently active option int.type = () => int.options.find(e => e.classList.contains('active')); return root; } From 032088539a0911d2e15d88f4fdcc4b31ec55f0ca Mon Sep 17 00:00:00 2001 From: Simon Reinisch Date: Mon, 6 Apr 2020 16:55:43 +0200 Subject: [PATCH 7/8] Inline removeAttribute --- README.md | 1 - src/js/utils/utils.js | 20 ++++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0dc4d7ae..45c8bef4 100644 --- a/README.md +++ b/README.md @@ -429,7 +429,6 @@ If `silent` is true (Default is false), the button won't change the current colo * off(elements`:HTMLElement(s)`, event`:String(s)`, fn`:Function`[, options `:Object`]) _- Remove an event handler._ * createElementFromString(html`:String`)`:HTMLElement` _- Creates an new HTML Element out of this string._ * eventPath(evt`:Event`)`:[HTMLElement]` _- A polyfill for the event-path event propery._ -* removeAttribute(el`:HTMLElement`, name`:String`) _- Removes an attribute from a HTMLElement and returns the value._ * createFromTemplate(str`:String`) _- See [inline doumentation](https://github.com/Simonwep/pickr/blob/master/src/js/lib/utils.js#L88)._ * resolveElement(val`:String|HTMLElement`) _- Resolves a `HTMLElement`, supports `>>>` as shadow dom selector._ * adjustableInputNumbers(el`:InputElement`, mapper`:Function`) _- Creates the possibility to change the numbers in an inputfield via mouse scrolling. diff --git a/src/js/utils/utils.js b/src/js/utils/utils.js index 985d65c9..28b4ffa9 100644 --- a/src/js/utils/utils.js +++ b/src/js/utils/utils.js @@ -52,18 +52,6 @@ export function createElementFromString(html) { return div.firstElementChild; } -/** - * Removes an attribute from a HTMLElement and returns the value. - * @param el - * @param name - * @return {string} - */ -export function removeAttribute(el, name) { - const value = el.getAttribute(name); - el.removeAttribute(name); - return value; -} - /** * Creates a new html element, every element which has * a ':ref' attribute will be saved in a object (which will be returned) @@ -78,8 +66,16 @@ export function removeAttribute(el, name) { * * @param str - The HTML String. */ + export function createFromTemplate(str) { + // Removes an attribute from a HTMLElement and returns the value. + const removeAttribute = (el, name) => { + const value = el.getAttribute(name); + el.removeAttribute(name); + return value; + }; + // Recursive function to resolve template function resolve(element, base = {}) { From 0a506745d506488ee81a2f331524776d045251f4 Mon Sep 17 00:00:00 2001 From: Simon Reinisch Date: Mon, 6 Apr 2020 17:07:25 +0200 Subject: [PATCH 8/8] Store default strings and friends as static attributes of Pickr --- README.md | 2 +- dist/pickr.es5.min.js | 4 +-- dist/pickr.es5.min.js.map | 2 +- dist/pickr.min.js | 4 +-- dist/pickr.min.js.map | 2 +- src/js/pickr.js | 67 ++++++++++++++++++++++++--------------- src/js/utils/utils.js | 4 +-- 7 files changed, 51 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 45c8bef4..5dda2a5a 100644 --- a/README.md +++ b/README.md @@ -331,7 +331,7 @@ const pickr = new Pickr({ }, }, - // Translations + // Translations, these are the default values. i18n: { // Strings visible in the UI diff --git a/dist/pickr.es5.min.js b/dist/pickr.es5.min.js index b89b926f..b3346f66 100644 --- a/dist/pickr.es5.min.js +++ b/dist/pickr.es5.min.js @@ -1,3 +1,3 @@ -/*! Pickr 1.4.1 MIT | https://github.com/Simonwep/pickr */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var r={};function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t){for(var e=1;e4&&void 0!==arguments[4]?arguments[4]:{};e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(n)||(n=[n]);var a=!0,c=!1,l=void 0;try{for(var s,u=e[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){var p=s.value,h=!0,f=!1,d=void 0;try{for(var v,y=n[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var b=v.value;p[t](b,r,i({capture:!1},o))}}catch(t){f=!0,d=t}finally{try{h||null==y.return||y.return()}finally{if(f)throw d}}}}catch(t){c=!0,l=t}finally{try{a||null==u.return||u.return()}finally{if(c)throw l}}return Array.prototype.slice.call(arguments,1)}function u(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function p(t,e){var n=t.getAttribute(e);return t.removeAttribute(e),n}function h(t){return function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=p(e,":obj"),o=p(e,":ref"),i=r?n[r]={}:n;o&&(n[o]=e);for(var a=0,c=Array.from(e.children);a>/g).reduce((function(t,e,n,r){return t=t.querySelector(e),n1&&void 0!==arguments[1]?arguments[1]:function(t){return t};function n(n){var r=[.001,.01,.1][Number(n.shiftKey||2*n.ctrlKey)]*(n.deltaY<0?1:-1),o=0,i=t.selectionStart;t.value=t.value.replace(/[\d.]+/g,(function(t,n){return n<=i&&n+t.length>=i?(i=n,e(Number(t),r,o)):(o++,t)})),t.focus(),t.setSelectionRange(i,i),n.preventDefault(),t.dispatchEvent(new Event("input"))}c(t,"focus",(function(){return c(window,"wheel",n,{passive:!1})})),c(t,"blur",(function(){return l(window,"wheel",n)}))}function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(!(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1&&(r-=1)}return[360*r,100*o,100*a]}function j(t,e,n,r){return e/=100,n/=100,b(O(255*(1-m(1,(t/=100)*(1-(r/=100))+r)),255*(1-m(1,e*(1-r)+r)),255*(1-m(1,n*(1-r)+r))))}function E(t,e,n){return e/=100,[t,2*(e*=(n/=100)<.5?n:1-n)/(n+e)*100,100*(n+e)]}function x(t){return O.apply(void 0,b(t.match(/.{2}/g).map((function(t){return parseInt(t,16)}))))}function L(t){t=t.match(/^[a-zA-Z]+$/)?function(t){if("black"===t.toLowerCase())return"#000000";var e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,"#000000"===e.fillStyle?null:e.fillStyle}(t):t;var e,n={cmyk:/^cmyk[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)/i,rgba:/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsla:/^((hsla)|hsl)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hsva:/^((hsva)|hsv)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i,hexa:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},r=function(t){return t.map((function(t){return/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0}))};t:for(var o in n)if(e=n[o].exec(t)){var i=!!e[2];switch(o){case"cmyk":var a=y(r(e),5),c=a[1],l=a[2],s=a[3],u=a[4];if(c>100||l>100||s>100||u>100)break t;return{values:j(c,l,s,u),type:o};case"rgba":var p=y(r(e),7),h=p[3],f=p[4],d=p[5],v=p[6];if(h>255||f>255||d>255||v<0||v>1||i===!v)break t;return{values:[].concat(b(O(h,f,d)),[v]),a:v,type:o};case"hexa":var m=y(e,2)[1];4!==m.length&&3!==m.length||(m=m.split("").map((function(t){return t+t})).join(""));var g=m.substring(0,6),_=m.substring(6);return _=_?parseInt(_,16)/255:void 0,{values:[].concat(b(x(g)),[_]),a:_,type:o};case"hsla":var w=y(r(e),7),A=w[3],k=w[4],S=w[5],C=w[6];if(A>360||k>100||S>100||C<0||C>1||i===!C)break t;return{values:[].concat(b(E(A,k,S)),[C]),a:C,type:o};case"hsva":var L=y(r(e),7),P=L[3],B=L[4],R=L[5],H=L[6];if(P>360||B>100||R>100||H<0||H>1||i===!H)break t;return{values:[P,B,R,H],a:H,type:o}}}return{values:null,type:null}}function P(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=function(t,e){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;return e(~n?t.map((function(t){return Number(t.toFixed(n))})):t)}},i={h:t,s:e,v:n,a:r,toHSVA:function(){var t=[i.h,i.s,i.v,i.a];return t.toString=o(t,(function(t){return"hsva(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")})),t},toHSLA:function(){var t=[].concat(P(C(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,(function(t){return"hsla(".concat(t[0],", ").concat(t[1],"%, ").concat(t[2],"%, ").concat(i.a,")")})),t},toRGBA:function(){var t=[].concat(P(A(i.h,i.s,i.v)),[i.a]);return t.toString=o(t,(function(t){return"rgba(".concat(t[0],", ").concat(t[1],", ").concat(t[2],", ").concat(i.a,")")})),t},toCMYK:function(){var t=S(i.h,i.s,i.v);return t.toString=o(t,(function(t){return"cmyk(".concat(t[0],"%, ").concat(t[1],"%, ").concat(t[2],"%, ").concat(t[3],"%)")})),t},toHEXA:function(){var t=k(i.h,i.s,i.v),e=i.a>=1?"":Number((255*i.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return e&&t.push(e),t.toString=function(){return"#".concat(t.join("").toUpperCase())},t},clone:function(){return B(i.h,i.s,i.v,i.a)}};return i}var R=function(t){return Math.max(Math.min(t,1),0)};function H(t){var e={options:Object.assign({lock:null,onchange:function(){return 0},onstop:function(){return 0}},t),_keyboard:function(t){var r=t.type,o=t.key;if(document.activeElement===n.wrapper)if("keydown"===r){var i=0,a=0;switch(o){case"ArrowLeft":i--;break;case"ArrowRight":i++;break;case"ArrowUp":a++;break;case"ArrowDown":a++}e.update(R(e.cache.x+.01*i),R(e.cache.y+.01*a))}else o.startsWith("Arrow")&&e.options.onstop()},_tapstart:function(t){c(document,["mouseup","touchend","touchcancel"],e._tapstop),c(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove:function(t){var r=e.options.lock,o=e.cache,i=n.element,a=n.wrapper,c=a.getBoundingClientRect(),l=0,s=0;if(t){var u=t&&t.touches&&t.touches[0];l=t?(u||t).clientX:0,s=t?(u||t).clientY:0,lc.left+c.width&&(l=c.left+c.width),sc.top+c.height&&(s=c.top+c.height),l-=c.left,s-=c.top}else o&&(l=o.x*c.width,s=o.y*c.height);"h"!==r&&(i.style.left="calc(".concat(l/c.width*100,"% - ").concat(i.offsetWidth/2,"px)")),"v"!==r&&(i.style.top="calc(".concat(s/c.height*100,"% - ").concat(i.offsetHeight/2,"px)")),e.cache={x:l/c.width,y:s/c.height};var p=R(l/a.offsetWidth),h=R(s/a.offsetHeight);switch(r){case"v":return n.onchange(p);case"h":return n.onchange(h);default:return n.onchange(p,h)}},_tapstop:function(){e.options.onstop(),l(document,["mouseup","touchend","touchcancel"],e._tapstop),l(document,["mousemove","touchmove"],e._tapmove)},trigger:function(){e._tapmove()},update:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.options.wrapper.getBoundingClientRect(),o=r.left,i=r.top,a=r.width,c=r.height;"h"===e.options.lock&&(n=t),e._tapmove({clientX:o+a*t,clientY:i+c*n})},destroy:function(){var t=e.options,n=e._tapstart;l([t.wrapper,t.element],"mousedown",n),l([t.wrapper,t.element],"touchstart",n,{passive:!1})}},n=e.options,r=e._tapstart,o=e._keyboard;return c([n.wrapper,n.element],"mousedown",r),c([n.wrapper,n.element],"touchstart",r,{passive:!1}),c(document,["keydown","keyup"],o),e}function D(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{};t=Object.assign({onchange:function(){return 0},className:"",elements:[]},t);var e=c(t.elements,"click",(function(e){t.elements.forEach((function(n){return n.classList[e.target===n?"add":"remove"](t.className)})),t.onchange(e)}));return{destroy:function(){return l.apply(r,D(e))}}}function T(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(!(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function N(t){var e=t.el,n=t.reference,r=t.padding,o=void 0===r?8:r,i={start:"sme",middle:"mse",end:"ems"},a={top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t[e];if(n)return n;var r=e.split("-"),o=T(r,2),i=o[0],a=o[1],c=void 0===a?"middle":a,l="top"===i||"bottom"===i;return t[e]={position:i,variant:c,isVertical:l}}}();return{update:function(t){var r=c(t),l=r.position,s=r.variant,u=r.isVertical,p=n.getBoundingClientRect(),h=e.getBoundingClientRect(),f=function(t){return t?{s:p.left+p.width-h.width,m:-h.width/2+(p.left+p.width/2),e:p.left}:{s:p.bottom-h.height,m:p.bottom-p.height/2-h.height/2,e:p.bottom-p.height}},d={};function v(t,n,r){var o="top"===r,i=o?h.height:h.width,a=window[o?"innerHeight":"innerWidth"],c=!0,l=!1,s=void 0;try{for(var u,p=t[Symbol.iterator]();!(c=(u=p.next()).done);c=!0){var f=n[u.value],v=d[r]="".concat(f,"px");if(f>0&&f+i\n\n '.concat(r?"":'','\n\n
\n
\n
\n \n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n \n\n \n \n \n \n \n\n \n \n \n
\n
\n
\n ")),(p=u.interaction).options.find((function(t){return!t.hidden&&!t.classList.add("active")})),p.type=function(){return p.options.find((function(t){return t.classList.contains("active")}))},u),f.useAsButton&&(this._root.button=f.el),f.container.appendChild(this._root.root)}},{key:"_finalBuild",value:function(){var t=this.options,e=this._root;if(t.container.removeChild(e.root),t.inline){var n=t.el.parentElement;t.el.nextSibling?n.insertBefore(e.app,t.el.nextSibling):n.appendChild(e.app)}else t.container.appendChild(e.app);t.useAsButton?t.inline&&t.el.remove():t.el.parentNode.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),this.hide()}},{key:"_buildComponents",value:function(){var t=this,e=this,n=this.options.components,r=(e.options.sliders||"v").repeat(2),o=F(r.match(/^[vh]+$/g)?r:[],2),i=o[0],a=o[1],c=function(){return t._color||(t._color=t._lastColor.clone())},l={palette:H({element:e._root.palette.picker,wrapper:e._root.palette.palette,onstop:function(){return e._emit("changestop",e)},onchange:function(t,r){if(n.palette){var o=c(),i=e._root,a=e.options;e._recalc&&(o.s=100*t,o.v=100-100*r,o.v<0&&(o.v=0),e._updateOutput());var l=o.toRGBA().toString(0);this.element.style.background=l,this.wrapper.style.background="\n linear-gradient(to top, rgba(0, 0, 0, ".concat(o.a,"), transparent),\n linear-gradient(to left, hsla(").concat(o.h,", 100%, 50%, ").concat(o.a,"), rgba(255, 255, 255, ").concat(o.a,"))\n "),a.comparison?a.useAsButton||e._lastColor||(i.preview.lastColor.style.color=l):i.button.style.color=l;var s=o.toHEXA().toString(),u=!0,p=!1,h=void 0;try{for(var f,d=e._swatchColors[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var v=f.value,y=v.el,b=v.color;y.classList[s===b.toHEXA().toString()?"add":"remove"]("pcr-active")}}catch(t){p=!0,h=t}finally{try{u||null==d.return||d.return()}finally{if(p)throw h}}i.preview.currentColor.style.color=l,e.options.comparison||i.button.classList.remove("clear")}}}),hue:H({lock:"v"===a?"h":"v",element:e._root.hue.picker,wrapper:e._root.hue.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.hue&&n.palette){var r=c();e._recalc&&(r.h=360*t),this.element.style.backgroundColor="hsl(".concat(r.h,", 100%, 50%)"),l.palette.trigger()}}}),opacity:H({lock:"v"===i?"h":"v",element:e._root.opacity.picker,wrapper:e._root.opacity.slider,onstop:function(){return e._emit("changestop",e)},onchange:function(t){if(n.opacity&&n.palette){var r=c();e._recalc&&(r.a=Math.round(100*t)/100),this.element.style.background="rgba(0, 0, 0, ".concat(r.a,")"),l.palette.trigger()}}}),selectable:M({elements:e._root.interaction.options,className:"active",onchange:function(t){e._representation=t.target.getAttribute("data-type").toUpperCase(),e._recalc&&e._updateOutput()}})};this._components=l}},{key:"_bindEvents",value:function(){var t=this,e=this._root,n=this.options,r=[c(e.interaction.clear,"click",(function(){return t._clearColor()})),c([e.interaction.cancel,e.preview.lastColor],"click",(function(){t._emit("cancel",t),t.setHSVA.apply(t,V((t._lastColor||t._color).toHSVA()).concat([!0]))})),c(e.interaction.save,"click",(function(){!t.applyColor()&&!n.showAlways&&t.hide()})),c(e.interaction.result,["keyup","input"],(function(e){t.setColor(e.target.value,!0)&&!t._initializingActive&&t._emit("change",t._color),e.stopImmediatePropagation()})),c(e.interaction.result,["focus","blur"],(function(e){t._recalc="blur"===e.type,t._recalc&&t._updateOutput()})),c([e.palette.palette,e.palette.picker,e.hue.slider,e.hue.picker,e.opacity.slider,e.opacity.picker],["mousedown","touchstart"],(function(){return t._recalc=!0}))];if(!n.showAlways){var o=n.closeWithKey;r.push(c(e.button,"click",(function(){return t.isOpen()?t.hide():t.show()})),c(document,"keyup",(function(e){return t.isOpen()&&(e.key===o||e.code===o)&&t.hide()})),c(document,["touchstart","mousedown"],(function(n){t.isOpen()&&!f(n).some((function(t){return t===e.app||t===e.button}))&&t.hide()}),{capture:!0}))}if(n.adjustableNumbers){var i={rgba:[255,255,255,1],hsva:[360,100,100,1],hsla:[360,100,100,1],cmyk:[100,100,100,100]};v(e.interaction.result,(function(e,n,r){var o=i[t.getColorRepresentation().toLowerCase()];if(o){var a=o[r],c=e+(a>=100?1e3*n:n);return c<=0?0:Number((c0&&void 0!==arguments[0]&&arguments[0],e=this._root,n=this.options;n.useAsButton||(e.button.style.color="rgba(0, 0, 0, 0.15)"),e.button.classList.add("clear"),n.showAlways||this.hide(),this._lastColor=null,this._initializingActive||t||(this._emit("save",null),this._emit("clear",this))}},{key:"_parseLocalColor",value:function(t){var e=L(t),n=e.values,r=e.type,o=e.a,i=this.options.lockOpacity,a=void 0!==o&&1!==o;return n&&3===n.length&&(n[3]=void 0),{values:!n||i&&a?null:n,type:r}}},{key:"_emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:"unknown";return(this.options.i18n||{})[t]||e}},{key:"on",value:function(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}},{key:"off",value:function(t,e){var n=this._eventListener[t];if(n){var r=n.indexOf(e);~r&&n.splice(r,1)}return this}},{key:"addSwatch",value:function(t){var e=this,n=this._parseLocalColor(t).values;if(n){var r=this._swatchColors,o=this._root,i=B.apply(void 0,V(n)),a=u('