Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@melloware/coloris

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@melloware/coloris - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

8

dist/esm/coloris.js

@@ -110,3 +110,3 @@ var Coloris = function () {

options.swatches.forEach(function (swatch, i) {
swatches.push("<button id=\"clr-swatch-" + i + "\" aria-labelledby=\"clr-swatch-label clr-swatch-" + i + "\" style=\"color: " + swatch + ";\">" + swatch + "</button>");
swatches.push("<button type=\"button\" id=\"clr-swatch-" + i + "\" aria-labelledby=\"clr-swatch-label clr-swatch-" + i + "\" style=\"color: " + swatch + ";\">" + swatch + "</button>");
});

@@ -304,3 +304,3 @@

wrapper.innerHTML = "<button aria-labelledby=\"clr-open-label\"></button>";
wrapper.innerHTML = "<button type=\"button\" aria-labelledby=\"clr-open-label\"></button>";
parentNode.insertBefore(wrapper, field);

@@ -785,4 +785,4 @@ wrapper.setAttribute('class', 'clr-field');

'</div>' +
'<div id="clr-swatches" class="clr-swatches"></div>' + ("<button id=\"clr-clear\" class=\"clr-clear\">" +
settings.clearButton.label + "</button>") + ("<button id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
'<div id="clr-swatches" class="clr-swatches"></div>' + ("<button type=\"button\" id=\"clr-clear\" class=\"clr-clear\">" +
settings.clearButton.label + "</button>") + ("<button type=\"button\" id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
settings.a11y.close + "\"></button>") + ("<span id=\"clr-open-label\" hidden>" +

@@ -789,0 +789,0 @@ settings.a11y.open + "</span>") + ("<span id=\"clr-swatch-label\" hidden>" +

@@ -7,2 +7,2 @@ var Coloris=function(){

*/
return b=window,y=document,m=Math,N=y.createElement("canvas").getContext("2d"),_={el:"[data-coloris]",parent:null,theme:"default",themeMode:"light",wrap:!0,margin:2,format:"hex",formatToggle:!(O={r:0,g:0,b:0,h:0,s:0,v:0,a:1}),swatches:[],swatchesOnly:!1,alpha:!0,focusInput:!0,autoClose:!1,inline:!1,defaultColor:"#000000",clearButton:{show:!1,label:"Clear"},a11y:{open:"Open color picker",close:"Close color picker",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),(D=function(){var r={init:I,set:a,wrap:u,close:l,updatePosition:s};function e(e){n(function(){e&&("string"==typeof e?c:a)(e)})}for(var t in r)!function(l){e[l]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];n(r[l],t)}}(t);return e}()).coloris=D;function a(e){if("object"==typeof e)for(var t in e)switch(t){case"el":c(e.el),!1!==e.wrap&&u(e.el);break;case"parent":_.parent=y.querySelector(e.parent),_.parent&&_.parent.appendChild(g);break;case"themeMode":_.themeMode=e.themeMode,"auto"===e.themeMode&&b.matchMedia&&b.matchMedia("(prefers-color-scheme: dark)").matches&&(_.themeMode="dark");case"theme":e.theme&&(_.theme=e.theme),g.className="clr-picker clr-"+_.theme+" clr-"+_.themeMode,_.inline&&s();break;case"margin":e.margin*=1,_.margin=(isNaN(e.margin)?_:e).margin;break;case"wrap":e.el&&e.wrap&&u(e.el);break;case"formatToggle":v("clr-format").style.display=e.formatToggle?"block":"none",e.formatToggle&&(_.format="auto");break;case"swatches":Array.isArray(e.swatches)&&!function(){var a=[];e.swatches.forEach(function(e,t){a.push('<button id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+"</button>")}),v("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":""}();break;case"swatchesOnly":_.swatchesOnly=!!e.swatchesOnly,g.setAttribute("data-minimal",_.swatchesOnly),_.swatchesOnly&&(_.autoClose=!0);break;case"alpha":_.alpha=!!e.alpha,g.setAttribute("data-alpha",_.alpha);break;case"inline":_.inline=!!e.inline,g.setAttribute("data-inline",_.inline),_.inline&&(a=e.defaultColor||_.defaultColor,s(),d(a));break;case"clearButton":var a="none";e.clearButton.show&&(a="block"),e.clearButton.label&&(C.innerHTML=e.clearButton.label),C.style.display=a;break;case"a11y":var l,r,o=e.a11y,n=!1;if("object"==typeof o)for(var i in o)o[i]&&_.a11y[i]&&(_.a11y[i]=o[i],n=!0);n&&(l=v("clr-open-label"),r=v("clr-swatch-label"),l.innerHTML=_.a11y.open,r.innerHTML=_.a11y.swatch,E.setAttribute("aria-label",_.a11y.close),S.setAttribute("aria-label",_.a11y.hueSlider),T.setAttribute("aria-label",_.a11y.alphaSlider),L.setAttribute("aria-label",_.a11y.input),w.setAttribute("aria-label",_.a11y.instruction));default:_[t]=e[t]}}function c(e){o(y,"click",e,function(e){_.inline||(M=e.target,B=M.value,H=function(e){e=e.substring(0,3).toLowerCase();return"rgb"!==e&&"hsl"!==e?"hex":e}(B),g.classList.add("clr-open"),s(),d(B),_.focusInput&&L.focus({preventScroll:!0}),M.dispatchEvent(new Event("open",{bubbles:!0})))}),o(y,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function s(){var e,t,a,l,r=_.parent,o=b.scrollY,n=g.offsetWidth,i=g.offsetHeight,c={left:!1,top:!1},s={x:0,y:0};r&&(t=b.getComputedStyle(r),e=parseFloat(t.marginTop),t=parseFloat(t.borderTopWidth),(s=r.getBoundingClientRect()).y+=t+o),_.inline||(a=(t=M.getBoundingClientRect()).x,l=o+t.y+t.height+_.margin,r?(a-=s.x,l-=s.y,a+n>r.clientWidth&&(a+=t.width-n,c.left=!0),l+i>r.clientHeight-e&&(l-=t.height+i+2*_.margin,c.top=!0),l+=r.scrollTop):(a+n>y.documentElement.clientWidth&&(a+=t.width-n,c.left=!0),l+i-o>y.documentElement.clientHeight&&(l=o+t.y-i-_.margin,c.top=!0)),g.classList.toggle("clr-left",c.left),g.classList.toggle("clr-top",c.top),g.style.left=a+"px",g.style.top=l+"px"),k={width:w.offsetWidth,height:w.offsetHeight,x:g.offsetLeft+w.offsetLeft+s.x,y:g.offsetTop+w.offsetTop+s.y}}function u(e){y.querySelectorAll(e).forEach(function(e){var t,a=e.parentNode;a.classList.contains("clr-field")||((t=y.createElement("div")).innerHTML='<button aria-labelledby="clr-open-label"></button>',a.insertBefore(t,e),t.setAttribute("class","clr-field"),t.style.color=e.value,t.appendChild(e))})}function l(e){M&&!_.inline&&(e&&B!==M.value&&(M.value=B,M.dispatchEvent(new Event("input",{bubbles:!0}))),B!==M.value&&M.dispatchEvent(new Event("change",{bubbles:!0})),g.classList.remove("clr-open"),M.dispatchEvent(new Event("close",{bubbles:!0})),_.focusInput&&M.focus({preventScroll:!0}),M=null)}function d(e){var e=function(e){var t;N.fillStyle="#000",N.fillStyle=e,(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(N.fillStyle))?(t={r:+e[3],g:+e[4],b:+e[5],a:+e[6]}).a=+t.a.toFixed(2):(e=N.fillStyle.replace("#","").match(/.{2}/g).map(function(e){return parseInt(e,16)}),t={r:e[0],g:e[1],b:e[2],a:1});return t}(e),t=function(e){var t=e.r/255,a=e.g/255,l=e.b/255,r=m.max(t,a,l),o=m.min(t,a,l),o=r-o,n=r,i=0,c=0;o&&(r===t&&(i=(a-l)/o),r===a&&(i=2+(l-t)/o),r===l&&(i=4+(t-a)/o),r&&(c=o/r));return{h:(i=m.floor(60*i))<0?i+360:i,s:m.round(100*c),v:m.round(100*n),a:e.a}}(e);h(t.s,t.v),f(e,t),S.value=t.h,g.style.color="hsl("+t.h+", 100%, 50%)",i.style.left=t.h/360*100+"%",x.style.left=k.width*t.s/100+"px",x.style.top=k.height-k.height*t.v/100+"px",T.value=100*t.a,A.style.left=100*t.a+"%"}function p(e){e=void 0!==e?e:L.value,M&&(M.value=e,M.dispatchEvent(new Event("input",{bubbles:!0}))),y.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e}}))}function r(e,t){var a,l,r,o,n,e={h:+S.value,s:e/k.width*100,v:100-t/k.height*100,a:T.value/100},i=(i=(t=e).s/100,a=t.v/100,i*=a,l=t.h/60,r=i*(1-m.abs(l%2-1)),i+=a-=i,r+=a,l=m.floor(l)%6,o=[i,r,a,a,r,i][l],n=[r,i,i,r,a,a][l],a=[a,a,r,i,i,r][l],{r:m.round(255*o),g:m.round(255*n),b:m.round(255*a),a:t.a});h(e.s,e.v),f(i,e),p()}function h(e,t){var a=_.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),x.setAttribute("aria-label",a)}function t(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},a=t.pageX-k.x,t=t.pageY-k.y;_.parent&&(t+=_.parent.scrollTop),a=a<0?0:a>k.width?k.width:a,t=t<0?0:t>k.height?k.height:t,x.style.left=a+"px",x.style.top=t+"px",r(a,t),e.preventDefault(),e.stopPropagation()}function f(e,t){void 0===t&&(t={});var a,l,r=_.format;for(a in e=void 0===e?{}:e)O[a]=e[a];for(l in t)O[l]=t[l];var o,n=function(e){var t=e.r.toString(16),a=e.g.toString(16),l=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(l="0"+l);_.alpha&&e.a<1&&(e=255*e.a|0,r=e.toString(16),e<16&&(r="0"+r));return"#"+t+a+l+r}(O),i=n.substring(0,7);switch(x.style.color=i,A.parentNode.style.color=i,A.style.color=n,E.style.color=n,w.style.display="none",w.offsetHeight,w.style.display="",A.nextElementSibling.style.display="none",A.nextElementSibling.offsetHeight,A.nextElementSibling.style.display="","mixed"===r?r=1===O.a?"hex":"rgb":"auto"===r&&(r=H),r){case"hex":L.value=n;break;case"rgb":L.value=(o=O,_.alpha&&1!==o.a?"rgba("+o.r+", "+o.g+", "+o.b+", "+o.a+")":"rgb("+o.r+", "+o.g+", "+o.b+")");break;case"hsl":L.value=(o=function(e){var t,a=e.v/100,l=a*(1-e.s/100/2);0<l&&l<1&&(t=m.round((a-l)/m.min(l,1-l)*100));return{h:e.h,s:t||0,l:m.round(100*l),a:e.a}}(O),_.alpha&&1!==o.a?"hsla("+o.h+", "+o.s+"%, "+o.l+"%, "+o.a+")":"hsl("+o.h+", "+o.s+"%, "+o.l+"%)")}y.querySelector('.clr-format [value="'+r+'"]').checked=!0}function e(){var e=+S.value,t=+x.style.left.replace("px",""),a=+x.style.top.replace("px","");g.style.color="hsl("+e+", 100%, 50%)",i.style.left=e/360*100+"%",r(t,a)}function F(){var e=T.value/100;A.style.left=100*e+"%",f({a:e}),p()}function I(){(g=y.createElement("div")).setAttribute("id","clr-picker"),g.className="clr-picker",g.innerHTML='<input id="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+_.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+_.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+_.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+_.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+_.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button id="clr-clear" class="clr-clear">'+_.clearButton.label+'</button><button id="clr-color-preview" class="clr-preview" aria-label="'+_.a11y.close+'"></button><span id="clr-open-label" hidden>'+_.a11y.open+'</span><span id="clr-swatch-label" hidden>'+_.a11y.swatch+"</span>",y.body.appendChild(g),w=v("clr-color-area"),x=v("clr-color-marker"),C=v("clr-clear"),E=v("clr-color-preview"),L=v("clr-color-value"),S=v("clr-hue-slider"),i=v("clr-hue-marker"),T=v("clr-alpha-slider"),A=v("clr-alpha-marker"),c(_.el),u(_.el),o(g,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),o(w,"mousedown",function(e){o(y,"mousemove",t)}),o(w,"touchstart",function(e){y.addEventListener("touchmove",t,{passive:!1})}),o(x,"mousedown",function(e){o(y,"mousemove",t)}),o(x,"touchstart",function(e){y.addEventListener("touchmove",t,{passive:!1})}),o(L,"change",function(e){d(L.value),p()}),o(C,"click",function(e){p(""),l()}),o(E,"click",function(e){p(),l()}),o(y,"click",".clr-format input",function(e){H=e.target.value,f(),p()}),o(g,"click",".clr-swatches button",function(e){d(e.target.textContent),p(),_.autoClose&&l()}),o(y,"mouseup",function(e){y.removeEventListener("mousemove",t)}),o(y,"touchend",function(e){y.removeEventListener("touchmove",t)}),o(y,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),l()}),o(y,"keydown",function(e){"Escape"===e.key?l(!0):"Tab"===e.key&&g.classList.add("clr-keyboard-nav")}),o(y,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),o(x,"keydown",function(e){var t={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};-1!==Object.keys(t).indexOf(e.key)&&(!function(e,t){e=+x.style.left.replace("px","")+e,t=+x.style.top.replace("px","")+t,x.style.left=e+"px",x.style.top=t+"px",r(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),o(w,"click",t),o(S,"input",e),o(T,"input",F)}function v(e){return y.getElementById(e)}function o(e,t,a,l){var r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,function(e){r.call(e.target,a)&&l.call(e.target,e)}):(l=a,e.addEventListener(t,l))}function n(e,t){t=void 0!==t?t:[],"loading"!==y.readyState?e.apply(void 0,t):y.addEventListener("DOMContentLoaded",function(){e.apply(void 0,t)})}var b,y,m,g,w,k,x,E,L,C,S,i,T,A,M,H,B,N,O,_,D}(),_coloris=Coloris.coloris,_init=Coloris.init,_set=Coloris.set,_wrap=Coloris.wrap,_close=Coloris.close;export default Coloris;export{_coloris as coloris,_close as close,_init as init,_set as set,_wrap as wrap};
return b=window,y=document,m=Math,N=y.createElement("canvas").getContext("2d"),_={el:"[data-coloris]",parent:null,theme:"default",themeMode:"light",wrap:!0,margin:2,format:"hex",formatToggle:!(O={r:0,g:0,b:0,h:0,s:0,v:0,a:1}),swatches:[],swatchesOnly:!1,alpha:!0,focusInput:!0,autoClose:!1,inline:!1,defaultColor:"#000000",clearButton:{show:!1,label:"Clear"},a11y:{open:"Open color picker",close:"Close color picker",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),(D=function(){var r={init:I,set:a,wrap:u,close:l,updatePosition:s};function e(e){n(function(){e&&("string"==typeof e?c:a)(e)})}for(var t in r)!function(l){e[l]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];n(r[l],t)}}(t);return e}()).coloris=D;function a(e){if("object"==typeof e)for(var t in e)switch(t){case"el":c(e.el),!1!==e.wrap&&u(e.el);break;case"parent":_.parent=y.querySelector(e.parent),_.parent&&_.parent.appendChild(g);break;case"themeMode":_.themeMode=e.themeMode,"auto"===e.themeMode&&b.matchMedia&&b.matchMedia("(prefers-color-scheme: dark)").matches&&(_.themeMode="dark");case"theme":e.theme&&(_.theme=e.theme),g.className="clr-picker clr-"+_.theme+" clr-"+_.themeMode,_.inline&&s();break;case"margin":e.margin*=1,_.margin=(isNaN(e.margin)?_:e).margin;break;case"wrap":e.el&&e.wrap&&u(e.el);break;case"formatToggle":v("clr-format").style.display=e.formatToggle?"block":"none",e.formatToggle&&(_.format="auto");break;case"swatches":Array.isArray(e.swatches)&&!function(){var a=[];e.swatches.forEach(function(e,t){a.push('<button type="button" id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+"</button>")}),v("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":""}();break;case"swatchesOnly":_.swatchesOnly=!!e.swatchesOnly,g.setAttribute("data-minimal",_.swatchesOnly),_.swatchesOnly&&(_.autoClose=!0);break;case"alpha":_.alpha=!!e.alpha,g.setAttribute("data-alpha",_.alpha);break;case"inline":_.inline=!!e.inline,g.setAttribute("data-inline",_.inline),_.inline&&(a=e.defaultColor||_.defaultColor,s(),p(a));break;case"clearButton":var a="none";e.clearButton.show&&(a="block"),e.clearButton.label&&(C.innerHTML=e.clearButton.label),C.style.display=a;break;case"a11y":var l,r,o=e.a11y,n=!1;if("object"==typeof o)for(var i in o)o[i]&&_.a11y[i]&&(_.a11y[i]=o[i],n=!0);n&&(l=v("clr-open-label"),r=v("clr-swatch-label"),l.innerHTML=_.a11y.open,r.innerHTML=_.a11y.swatch,E.setAttribute("aria-label",_.a11y.close),S.setAttribute("aria-label",_.a11y.hueSlider),T.setAttribute("aria-label",_.a11y.alphaSlider),L.setAttribute("aria-label",_.a11y.input),w.setAttribute("aria-label",_.a11y.instruction));default:_[t]=e[t]}}function c(e){o(y,"click",e,function(e){_.inline||(M=e.target,B=M.value,H=function(e){e=e.substring(0,3).toLowerCase();return"rgb"!==e&&"hsl"!==e?"hex":e}(B),g.classList.add("clr-open"),s(),p(B),_.focusInput&&L.focus({preventScroll:!0}),M.dispatchEvent(new Event("open",{bubbles:!0})))}),o(y,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function s(){var e,t,a,l,r=_.parent,o=b.scrollY,n=g.offsetWidth,i=g.offsetHeight,c={left:!1,top:!1},s={x:0,y:0};r&&(t=b.getComputedStyle(r),e=parseFloat(t.marginTop),t=parseFloat(t.borderTopWidth),(s=r.getBoundingClientRect()).y+=t+o),_.inline||(a=(t=M.getBoundingClientRect()).x,l=o+t.y+t.height+_.margin,r?(a-=s.x,l-=s.y,a+n>r.clientWidth&&(a+=t.width-n,c.left=!0),l+i>r.clientHeight-e&&(l-=t.height+i+2*_.margin,c.top=!0),l+=r.scrollTop):(a+n>y.documentElement.clientWidth&&(a+=t.width-n,c.left=!0),l+i-o>y.documentElement.clientHeight&&(l=o+t.y-i-_.margin,c.top=!0)),g.classList.toggle("clr-left",c.left),g.classList.toggle("clr-top",c.top),g.style.left=a+"px",g.style.top=l+"px"),k={width:w.offsetWidth,height:w.offsetHeight,x:g.offsetLeft+w.offsetLeft+s.x,y:g.offsetTop+w.offsetTop+s.y}}function u(e){y.querySelectorAll(e).forEach(function(e){var t,a=e.parentNode;a.classList.contains("clr-field")||((t=y.createElement("div")).innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',a.insertBefore(t,e),t.setAttribute("class","clr-field"),t.style.color=e.value,t.appendChild(e))})}function l(e){M&&!_.inline&&(e&&B!==M.value&&(M.value=B,M.dispatchEvent(new Event("input",{bubbles:!0}))),B!==M.value&&M.dispatchEvent(new Event("change",{bubbles:!0})),g.classList.remove("clr-open"),M.dispatchEvent(new Event("close",{bubbles:!0})),_.focusInput&&M.focus({preventScroll:!0}),M=null)}function p(e){var e=function(e){var t;N.fillStyle="#000",N.fillStyle=e,(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(N.fillStyle))?(t={r:+e[3],g:+e[4],b:+e[5],a:+e[6]}).a=+t.a.toFixed(2):(e=N.fillStyle.replace("#","").match(/.{2}/g).map(function(e){return parseInt(e,16)}),t={r:e[0],g:e[1],b:e[2],a:1});return t}(e),t=function(e){var t=e.r/255,a=e.g/255,l=e.b/255,r=m.max(t,a,l),o=m.min(t,a,l),o=r-o,n=r,i=0,c=0;o&&(r===t&&(i=(a-l)/o),r===a&&(i=2+(l-t)/o),r===l&&(i=4+(t-a)/o),r&&(c=o/r));return{h:(i=m.floor(60*i))<0?i+360:i,s:m.round(100*c),v:m.round(100*n),a:e.a}}(e);h(t.s,t.v),f(e,t),S.value=t.h,g.style.color="hsl("+t.h+", 100%, 50%)",i.style.left=t.h/360*100+"%",x.style.left=k.width*t.s/100+"px",x.style.top=k.height-k.height*t.v/100+"px",T.value=100*t.a,A.style.left=100*t.a+"%"}function d(e){e=void 0!==e?e:L.value,M&&(M.value=e,M.dispatchEvent(new Event("input",{bubbles:!0}))),y.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e}}))}function r(e,t){var a,l,r,o,n,e={h:+S.value,s:e/k.width*100,v:100-t/k.height*100,a:T.value/100},i=(i=(t=e).s/100,a=t.v/100,i*=a,l=t.h/60,r=i*(1-m.abs(l%2-1)),i+=a-=i,r+=a,l=m.floor(l)%6,o=[i,r,a,a,r,i][l],n=[r,i,i,r,a,a][l],a=[a,a,r,i,i,r][l],{r:m.round(255*o),g:m.round(255*n),b:m.round(255*a),a:t.a});h(e.s,e.v),f(i,e),d()}function h(e,t){var a=_.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),x.setAttribute("aria-label",a)}function t(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},a=t.pageX-k.x,t=t.pageY-k.y;_.parent&&(t+=_.parent.scrollTop),a=a<0?0:a>k.width?k.width:a,t=t<0?0:t>k.height?k.height:t,x.style.left=a+"px",x.style.top=t+"px",r(a,t),e.preventDefault(),e.stopPropagation()}function f(e,t){void 0===t&&(t={});var a,l,r=_.format;for(a in e=void 0===e?{}:e)O[a]=e[a];for(l in t)O[l]=t[l];var o,n=function(e){var t=e.r.toString(16),a=e.g.toString(16),l=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(l="0"+l);_.alpha&&e.a<1&&(e=255*e.a|0,r=e.toString(16),e<16&&(r="0"+r));return"#"+t+a+l+r}(O),i=n.substring(0,7);switch(x.style.color=i,A.parentNode.style.color=i,A.style.color=n,E.style.color=n,w.style.display="none",w.offsetHeight,w.style.display="",A.nextElementSibling.style.display="none",A.nextElementSibling.offsetHeight,A.nextElementSibling.style.display="","mixed"===r?r=1===O.a?"hex":"rgb":"auto"===r&&(r=H),r){case"hex":L.value=n;break;case"rgb":L.value=(o=O,_.alpha&&1!==o.a?"rgba("+o.r+", "+o.g+", "+o.b+", "+o.a+")":"rgb("+o.r+", "+o.g+", "+o.b+")");break;case"hsl":L.value=(o=function(e){var t,a=e.v/100,l=a*(1-e.s/100/2);0<l&&l<1&&(t=m.round((a-l)/m.min(l,1-l)*100));return{h:e.h,s:t||0,l:m.round(100*l),a:e.a}}(O),_.alpha&&1!==o.a?"hsla("+o.h+", "+o.s+"%, "+o.l+"%, "+o.a+")":"hsl("+o.h+", "+o.s+"%, "+o.l+"%)")}y.querySelector('.clr-format [value="'+r+'"]').checked=!0}function e(){var e=+S.value,t=+x.style.left.replace("px",""),a=+x.style.top.replace("px","");g.style.color="hsl("+e+", 100%, 50%)",i.style.left=e/360*100+"%",r(t,a)}function F(){var e=T.value/100;A.style.left=100*e+"%",f({a:e}),d()}function I(){(g=y.createElement("div")).setAttribute("id","clr-picker"),g.className="clr-picker",g.innerHTML='<input id="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+_.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+_.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+_.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+_.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+_.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear">'+_.clearButton.label+'</button><button type="button" id="clr-color-preview" class="clr-preview" aria-label="'+_.a11y.close+'"></button><span id="clr-open-label" hidden>'+_.a11y.open+'</span><span id="clr-swatch-label" hidden>'+_.a11y.swatch+"</span>",y.body.appendChild(g),w=v("clr-color-area"),x=v("clr-color-marker"),C=v("clr-clear"),E=v("clr-color-preview"),L=v("clr-color-value"),S=v("clr-hue-slider"),i=v("clr-hue-marker"),T=v("clr-alpha-slider"),A=v("clr-alpha-marker"),c(_.el),u(_.el),o(g,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),o(w,"mousedown",function(e){o(y,"mousemove",t)}),o(w,"touchstart",function(e){y.addEventListener("touchmove",t,{passive:!1})}),o(x,"mousedown",function(e){o(y,"mousemove",t)}),o(x,"touchstart",function(e){y.addEventListener("touchmove",t,{passive:!1})}),o(L,"change",function(e){p(L.value),d()}),o(C,"click",function(e){d(""),l()}),o(E,"click",function(e){d(),l()}),o(y,"click",".clr-format input",function(e){H=e.target.value,f(),d()}),o(g,"click",".clr-swatches button",function(e){p(e.target.textContent),d(),_.autoClose&&l()}),o(y,"mouseup",function(e){y.removeEventListener("mousemove",t)}),o(y,"touchend",function(e){y.removeEventListener("touchmove",t)}),o(y,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),l()}),o(y,"keydown",function(e){"Escape"===e.key?l(!0):"Tab"===e.key&&g.classList.add("clr-keyboard-nav")}),o(y,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),o(x,"keydown",function(e){var t={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};-1!==Object.keys(t).indexOf(e.key)&&(!function(e,t){e=+x.style.left.replace("px","")+e,t=+x.style.top.replace("px","")+t,x.style.left=e+"px",x.style.top=t+"px",r(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),o(w,"click",t),o(S,"input",e),o(T,"input",F)}function v(e){return y.getElementById(e)}function o(e,t,a,l){var r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,function(e){r.call(e.target,a)&&l.call(e.target,e)}):(l=a,e.addEventListener(t,l))}function n(e,t){t=void 0!==t?t:[],"loading"!==y.readyState?e.apply(void 0,t):y.addEventListener("DOMContentLoaded",function(){e.apply(void 0,t)})}var b,y,m,g,w,k,x,E,L,C,S,i,T,A,M,H,B,N,O,_,D}(),_coloris=Coloris.coloris,_init=Coloris.init,_set=Coloris.set,_wrap=Coloris.wrap,_close=Coloris.close;export default Coloris;export{_coloris as coloris,_close as close,_init as init,_set as set,_wrap as wrap};

@@ -151,3 +151,3 @@ // https://github.com/umdjs/umd/blob/master/templates/returnExports.js

options.swatches.forEach(function (swatch, i) {
swatches.push("<button id=\"clr-swatch-" + i + "\" aria-labelledby=\"clr-swatch-label clr-swatch-" + i + "\" style=\"color: " + swatch + ";\">" + swatch + "</button>");
swatches.push("<button type=\"button\" id=\"clr-swatch-" + i + "\" aria-labelledby=\"clr-swatch-label clr-swatch-" + i + "\" style=\"color: " + swatch + ";\">" + swatch + "</button>");
});

@@ -345,3 +345,3 @@

wrapper.innerHTML = "<button aria-labelledby=\"clr-open-label\"></button>";
wrapper.innerHTML = "<button type=\"button\" aria-labelledby=\"clr-open-label\"></button>";
parentNode.insertBefore(wrapper, field);

@@ -826,4 +826,4 @@ wrapper.setAttribute('class', 'clr-field');

'</div>' +
'<div id="clr-swatches" class="clr-swatches"></div>' + ("<button id=\"clr-clear\" class=\"clr-clear\">" +
settings.clearButton.label + "</button>") + ("<button id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
'<div id="clr-swatches" class="clr-swatches"></div>' + ("<button type=\"button\" id=\"clr-clear\" class=\"clr-clear\">" +
settings.clearButton.label + "</button>") + ("<button type=\"button\" id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
settings.a11y.close + "\"></button>") + ("<span id=\"clr-open-label\" hidden>" +

@@ -830,0 +830,0 @@ settings.a11y.open + "</span>") + ("<span id=\"clr-swatch-label\" hidden>" +

@@ -7,2 +7,2 @@ !function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof module&&module.exports?module.exports=t():(e.Coloris=t(),"object"==typeof window&&e.Coloris.init())}("undefined"!=typeof self?self:void 0,function(){

*/
return y=window,b=document,m=Math,N=b.createElement("canvas").getContext("2d"),D={el:"[data-coloris]",parent:null,theme:"default",themeMode:"light",wrap:!0,margin:2,format:"hex",formatToggle:!(O={r:0,g:0,b:0,h:0,s:0,v:0,a:1}),swatches:[],swatchesOnly:!1,alpha:!0,focusInput:!0,autoClose:!1,inline:!1,defaultColor:"#000000",clearButton:{show:!1,label:"Clear"},a11y:{open:"Open color picker",close:"Close color picker",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),(j=function(){var r={init:I,set:a,wrap:u,close:l,updatePosition:s};function e(e){o(function(){e&&("string"==typeof e?c:a)(e)})}for(var t in r)!function(l){e[l]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];o(r[l],t)}}(t);return e}()).coloris=j;function a(e){if("object"==typeof e)for(var t in e)switch(t){case"el":c(e.el),!1!==e.wrap&&u(e.el);break;case"parent":D.parent=b.querySelector(e.parent),D.parent&&D.parent.appendChild(g);break;case"themeMode":D.themeMode=e.themeMode,"auto"===e.themeMode&&y.matchMedia&&y.matchMedia("(prefers-color-scheme: dark)").matches&&(D.themeMode="dark");case"theme":e.theme&&(D.theme=e.theme),g.className="clr-picker clr-"+D.theme+" clr-"+D.themeMode,D.inline&&s();break;case"margin":e.margin*=1,D.margin=(isNaN(e.margin)?D:e).margin;break;case"wrap":e.el&&e.wrap&&u(e.el);break;case"formatToggle":v("clr-format").style.display=e.formatToggle?"block":"none",e.formatToggle&&(D.format="auto");break;case"swatches":Array.isArray(e.swatches)&&!function(){var a=[];e.swatches.forEach(function(e,t){a.push('<button id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+"</button>")}),v("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":""}();break;case"swatchesOnly":D.swatchesOnly=!!e.swatchesOnly,g.setAttribute("data-minimal",D.swatchesOnly),D.swatchesOnly&&(D.autoClose=!0);break;case"alpha":D.alpha=!!e.alpha,g.setAttribute("data-alpha",D.alpha);break;case"inline":D.inline=!!e.inline,g.setAttribute("data-inline",D.inline),D.inline&&(a=e.defaultColor||D.defaultColor,s(),d(a));break;case"clearButton":var a="none";e.clearButton.show&&(a="block"),e.clearButton.label&&(S.innerHTML=e.clearButton.label),S.style.display=a;break;case"a11y":var l,r,n=e.a11y,o=!1;if("object"==typeof n)for(var i in n)n[i]&&D.a11y[i]&&(D.a11y[i]=n[i],o=!0);o&&(l=v("clr-open-label"),r=v("clr-swatch-label"),l.innerHTML=D.a11y.open,r.innerHTML=D.a11y.swatch,E.setAttribute("aria-label",D.a11y.close),C.setAttribute("aria-label",D.a11y.hueSlider),T.setAttribute("aria-label",D.a11y.alphaSlider),L.setAttribute("aria-label",D.a11y.input),w.setAttribute("aria-label",D.a11y.instruction));default:D[t]=e[t]}}function c(e){n(b,"click",e,function(e){D.inline||(M=e.target,B=M.value,H=function(e){e=e.substring(0,3).toLowerCase();return"rgb"!==e&&"hsl"!==e?"hex":e}(B),g.classList.add("clr-open"),s(),d(B),D.focusInput&&L.focus({preventScroll:!0}),M.dispatchEvent(new Event("open",{bubbles:!0})))}),n(b,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function s(){var e,t,a,l,r=D.parent,n=y.scrollY,o=g.offsetWidth,i=g.offsetHeight,c={left:!1,top:!1},s={x:0,y:0};r&&(t=y.getComputedStyle(r),e=parseFloat(t.marginTop),t=parseFloat(t.borderTopWidth),(s=r.getBoundingClientRect()).y+=t+n),D.inline||(a=(t=M.getBoundingClientRect()).x,l=n+t.y+t.height+D.margin,r?(a-=s.x,l-=s.y,a+o>r.clientWidth&&(a+=t.width-o,c.left=!0),l+i>r.clientHeight-e&&(l-=t.height+i+2*D.margin,c.top=!0),l+=r.scrollTop):(a+o>b.documentElement.clientWidth&&(a+=t.width-o,c.left=!0),l+i-n>b.documentElement.clientHeight&&(l=n+t.y-i-D.margin,c.top=!0)),g.classList.toggle("clr-left",c.left),g.classList.toggle("clr-top",c.top),g.style.left=a+"px",g.style.top=l+"px"),k={width:w.offsetWidth,height:w.offsetHeight,x:g.offsetLeft+w.offsetLeft+s.x,y:g.offsetTop+w.offsetTop+s.y}}function u(e){b.querySelectorAll(e).forEach(function(e){var t,a=e.parentNode;a.classList.contains("clr-field")||((t=b.createElement("div")).innerHTML='<button aria-labelledby="clr-open-label"></button>',a.insertBefore(t,e),t.setAttribute("class","clr-field"),t.style.color=e.value,t.appendChild(e))})}function l(e){M&&!D.inline&&(e&&B!==M.value&&(M.value=B,M.dispatchEvent(new Event("input",{bubbles:!0}))),B!==M.value&&M.dispatchEvent(new Event("change",{bubbles:!0})),g.classList.remove("clr-open"),M.dispatchEvent(new Event("close",{bubbles:!0})),D.focusInput&&M.focus({preventScroll:!0}),M=null)}function d(e){var e=function(e){var t;N.fillStyle="#000",N.fillStyle=e,(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(N.fillStyle))?(t={r:+e[3],g:+e[4],b:+e[5],a:+e[6]}).a=+t.a.toFixed(2):(e=N.fillStyle.replace("#","").match(/.{2}/g).map(function(e){return parseInt(e,16)}),t={r:e[0],g:e[1],b:e[2],a:1});return t}(e),t=function(e){var t=e.r/255,a=e.g/255,l=e.b/255,r=m.max(t,a,l),n=m.min(t,a,l),n=r-n,o=r,i=0,c=0;n&&(r===t&&(i=(a-l)/n),r===a&&(i=2+(l-t)/n),r===l&&(i=4+(t-a)/n),r&&(c=n/r));return{h:(i=m.floor(60*i))<0?i+360:i,s:m.round(100*c),v:m.round(100*o),a:e.a}}(e);f(t.s,t.v),h(e,t),C.value=t.h,g.style.color="hsl("+t.h+", 100%, 50%)",i.style.left=t.h/360*100+"%",x.style.left=k.width*t.s/100+"px",x.style.top=k.height-k.height*t.v/100+"px",T.value=100*t.a,A.style.left=100*t.a+"%"}function p(e){e=void 0!==e?e:L.value,M&&(M.value=e,M.dispatchEvent(new Event("input",{bubbles:!0}))),b.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e}}))}function r(e,t){var a,l,r,n,o,e={h:+C.value,s:e/k.width*100,v:100-t/k.height*100,a:T.value/100},i=(i=(t=e).s/100,a=t.v/100,i*=a,l=t.h/60,r=i*(1-m.abs(l%2-1)),i+=a-=i,r+=a,l=m.floor(l)%6,n=[i,r,a,a,r,i][l],o=[r,i,i,r,a,a][l],a=[a,a,r,i,i,r][l],{r:m.round(255*n),g:m.round(255*o),b:m.round(255*a),a:t.a});f(e.s,e.v),h(i,e),p()}function f(e,t){var a=D.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),x.setAttribute("aria-label",a)}function t(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},a=t.pageX-k.x,t=t.pageY-k.y;D.parent&&(t+=D.parent.scrollTop),a=a<0?0:a>k.width?k.width:a,t=t<0?0:t>k.height?k.height:t,x.style.left=a+"px",x.style.top=t+"px",r(a,t),e.preventDefault(),e.stopPropagation()}function h(e,t){void 0===t&&(t={});var a,l,r=D.format;for(a in e=void 0===e?{}:e)O[a]=e[a];for(l in t)O[l]=t[l];var n,o=function(e){var t=e.r.toString(16),a=e.g.toString(16),l=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(l="0"+l);D.alpha&&e.a<1&&(e=255*e.a|0,r=e.toString(16),e<16&&(r="0"+r));return"#"+t+a+l+r}(O),i=o.substring(0,7);switch(x.style.color=i,A.parentNode.style.color=i,A.style.color=o,E.style.color=o,w.style.display="none",w.offsetHeight,w.style.display="",A.nextElementSibling.style.display="none",A.nextElementSibling.offsetHeight,A.nextElementSibling.style.display="","mixed"===r?r=1===O.a?"hex":"rgb":"auto"===r&&(r=H),r){case"hex":L.value=o;break;case"rgb":L.value=(n=O,D.alpha&&1!==n.a?"rgba("+n.r+", "+n.g+", "+n.b+", "+n.a+")":"rgb("+n.r+", "+n.g+", "+n.b+")");break;case"hsl":L.value=(n=function(e){var t,a=e.v/100,l=a*(1-e.s/100/2);0<l&&l<1&&(t=m.round((a-l)/m.min(l,1-l)*100));return{h:e.h,s:t||0,l:m.round(100*l),a:e.a}}(O),D.alpha&&1!==n.a?"hsla("+n.h+", "+n.s+"%, "+n.l+"%, "+n.a+")":"hsl("+n.h+", "+n.s+"%, "+n.l+"%)")}b.querySelector('.clr-format [value="'+r+'"]').checked=!0}function e(){var e=+C.value,t=+x.style.left.replace("px",""),a=+x.style.top.replace("px","");g.style.color="hsl("+e+", 100%, 50%)",i.style.left=e/360*100+"%",r(t,a)}function F(){var e=T.value/100;A.style.left=100*e+"%",h({a:e}),p()}function I(){(g=b.createElement("div")).setAttribute("id","clr-picker"),g.className="clr-picker",g.innerHTML='<input id="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+D.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+D.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+D.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+D.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+D.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button id="clr-clear" class="clr-clear">'+D.clearButton.label+'</button><button id="clr-color-preview" class="clr-preview" aria-label="'+D.a11y.close+'"></button><span id="clr-open-label" hidden>'+D.a11y.open+'</span><span id="clr-swatch-label" hidden>'+D.a11y.swatch+"</span>",b.body.appendChild(g),w=v("clr-color-area"),x=v("clr-color-marker"),S=v("clr-clear"),E=v("clr-color-preview"),L=v("clr-color-value"),C=v("clr-hue-slider"),i=v("clr-hue-marker"),T=v("clr-alpha-slider"),A=v("clr-alpha-marker"),c(D.el),u(D.el),n(g,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),n(w,"mousedown",function(e){n(b,"mousemove",t)}),n(w,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),n(x,"mousedown",function(e){n(b,"mousemove",t)}),n(x,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),n(L,"change",function(e){d(L.value),p()}),n(S,"click",function(e){p(""),l()}),n(E,"click",function(e){p(),l()}),n(b,"click",".clr-format input",function(e){H=e.target.value,h(),p()}),n(g,"click",".clr-swatches button",function(e){d(e.target.textContent),p(),D.autoClose&&l()}),n(b,"mouseup",function(e){b.removeEventListener("mousemove",t)}),n(b,"touchend",function(e){b.removeEventListener("touchmove",t)}),n(b,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),l()}),n(b,"keydown",function(e){"Escape"===e.key?l(!0):"Tab"===e.key&&g.classList.add("clr-keyboard-nav")}),n(b,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),n(x,"keydown",function(e){var t={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};-1!==Object.keys(t).indexOf(e.key)&&(!function(e,t){e=+x.style.left.replace("px","")+e,t=+x.style.top.replace("px","")+t,x.style.left=e+"px",x.style.top=t+"px",r(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),n(w,"click",t),n(C,"input",e),n(T,"input",F)}function v(e){return b.getElementById(e)}function n(e,t,a,l){var r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,function(e){r.call(e.target,a)&&l.call(e.target,e)}):(l=a,e.addEventListener(t,l))}function o(e,t){t=void 0!==t?t:[],"loading"!==b.readyState?e.apply(void 0,t):b.addEventListener("DOMContentLoaded",function(){e.apply(void 0,t)})}var y,b,m,g,w,k,x,E,L,S,C,i,T,A,M,H,B,N,O,D,j});
return y=window,b=document,m=Math,N=b.createElement("canvas").getContext("2d"),D={el:"[data-coloris]",parent:null,theme:"default",themeMode:"light",wrap:!0,margin:2,format:"hex",formatToggle:!(O={r:0,g:0,b:0,h:0,s:0,v:0,a:1}),swatches:[],swatchesOnly:!1,alpha:!0,focusInput:!0,autoClose:!1,inline:!1,defaultColor:"#000000",clearButton:{show:!1,label:"Clear"},a11y:{open:"Open color picker",close:"Close color picker",marker:"Saturation: {s}. Brightness: {v}.",hueSlider:"Hue slider",alphaSlider:"Opacity slider",input:"Color value field",format:"Color format",swatch:"Color swatch",instruction:"Saturation and brightness selector. Use up, down, left and right arrow keys to select."}},void 0!==NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),(j=function(){var r={init:I,set:a,wrap:u,close:l,updatePosition:s};function e(e){o(function(){e&&("string"==typeof e?c:a)(e)})}for(var t in r)!function(l){e[l]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];o(r[l],t)}}(t);return e}()).coloris=j;function a(e){if("object"==typeof e)for(var t in e)switch(t){case"el":c(e.el),!1!==e.wrap&&u(e.el);break;case"parent":D.parent=b.querySelector(e.parent),D.parent&&D.parent.appendChild(g);break;case"themeMode":D.themeMode=e.themeMode,"auto"===e.themeMode&&y.matchMedia&&y.matchMedia("(prefers-color-scheme: dark)").matches&&(D.themeMode="dark");case"theme":e.theme&&(D.theme=e.theme),g.className="clr-picker clr-"+D.theme+" clr-"+D.themeMode,D.inline&&s();break;case"margin":e.margin*=1,D.margin=(isNaN(e.margin)?D:e).margin;break;case"wrap":e.el&&e.wrap&&u(e.el);break;case"formatToggle":v("clr-format").style.display=e.formatToggle?"block":"none",e.formatToggle&&(D.format="auto");break;case"swatches":Array.isArray(e.swatches)&&!function(){var a=[];e.swatches.forEach(function(e,t){a.push('<button type="button" id="clr-swatch-'+t+'" aria-labelledby="clr-swatch-label clr-swatch-'+t+'" style="color: '+e+';">'+e+"</button>")}),v("clr-swatches").innerHTML=a.length?"<div>"+a.join("")+"</div>":""}();break;case"swatchesOnly":D.swatchesOnly=!!e.swatchesOnly,g.setAttribute("data-minimal",D.swatchesOnly),D.swatchesOnly&&(D.autoClose=!0);break;case"alpha":D.alpha=!!e.alpha,g.setAttribute("data-alpha",D.alpha);break;case"inline":D.inline=!!e.inline,g.setAttribute("data-inline",D.inline),D.inline&&(a=e.defaultColor||D.defaultColor,s(),d(a));break;case"clearButton":var a="none";e.clearButton.show&&(a="block"),e.clearButton.label&&(S.innerHTML=e.clearButton.label),S.style.display=a;break;case"a11y":var l,r,n=e.a11y,o=!1;if("object"==typeof n)for(var i in n)n[i]&&D.a11y[i]&&(D.a11y[i]=n[i],o=!0);o&&(l=v("clr-open-label"),r=v("clr-swatch-label"),l.innerHTML=D.a11y.open,r.innerHTML=D.a11y.swatch,E.setAttribute("aria-label",D.a11y.close),C.setAttribute("aria-label",D.a11y.hueSlider),T.setAttribute("aria-label",D.a11y.alphaSlider),L.setAttribute("aria-label",D.a11y.input),w.setAttribute("aria-label",D.a11y.instruction));default:D[t]=e[t]}}function c(e){n(b,"click",e,function(e){D.inline||(M=e.target,B=M.value,H=function(e){e=e.substring(0,3).toLowerCase();return"rgb"!==e&&"hsl"!==e?"hex":e}(B),g.classList.add("clr-open"),s(),d(B),D.focusInput&&L.focus({preventScroll:!0}),M.dispatchEvent(new Event("open",{bubbles:!0})))}),n(b,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function s(){var e,t,a,l,r=D.parent,n=y.scrollY,o=g.offsetWidth,i=g.offsetHeight,c={left:!1,top:!1},s={x:0,y:0};r&&(t=y.getComputedStyle(r),e=parseFloat(t.marginTop),t=parseFloat(t.borderTopWidth),(s=r.getBoundingClientRect()).y+=t+n),D.inline||(a=(t=M.getBoundingClientRect()).x,l=n+t.y+t.height+D.margin,r?(a-=s.x,l-=s.y,a+o>r.clientWidth&&(a+=t.width-o,c.left=!0),l+i>r.clientHeight-e&&(l-=t.height+i+2*D.margin,c.top=!0),l+=r.scrollTop):(a+o>b.documentElement.clientWidth&&(a+=t.width-o,c.left=!0),l+i-n>b.documentElement.clientHeight&&(l=n+t.y-i-D.margin,c.top=!0)),g.classList.toggle("clr-left",c.left),g.classList.toggle("clr-top",c.top),g.style.left=a+"px",g.style.top=l+"px"),k={width:w.offsetWidth,height:w.offsetHeight,x:g.offsetLeft+w.offsetLeft+s.x,y:g.offsetTop+w.offsetTop+s.y}}function u(e){b.querySelectorAll(e).forEach(function(e){var t,a=e.parentNode;a.classList.contains("clr-field")||((t=b.createElement("div")).innerHTML='<button type="button" aria-labelledby="clr-open-label"></button>',a.insertBefore(t,e),t.setAttribute("class","clr-field"),t.style.color=e.value,t.appendChild(e))})}function l(e){M&&!D.inline&&(e&&B!==M.value&&(M.value=B,M.dispatchEvent(new Event("input",{bubbles:!0}))),B!==M.value&&M.dispatchEvent(new Event("change",{bubbles:!0})),g.classList.remove("clr-open"),M.dispatchEvent(new Event("close",{bubbles:!0})),D.focusInput&&M.focus({preventScroll:!0}),M=null)}function d(e){var e=function(e){var t;N.fillStyle="#000",N.fillStyle=e,(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(N.fillStyle))?(t={r:+e[3],g:+e[4],b:+e[5],a:+e[6]}).a=+t.a.toFixed(2):(e=N.fillStyle.replace("#","").match(/.{2}/g).map(function(e){return parseInt(e,16)}),t={r:e[0],g:e[1],b:e[2],a:1});return t}(e),t=function(e){var t=e.r/255,a=e.g/255,l=e.b/255,r=m.max(t,a,l),n=m.min(t,a,l),n=r-n,o=r,i=0,c=0;n&&(r===t&&(i=(a-l)/n),r===a&&(i=2+(l-t)/n),r===l&&(i=4+(t-a)/n),r&&(c=n/r));return{h:(i=m.floor(60*i))<0?i+360:i,s:m.round(100*c),v:m.round(100*o),a:e.a}}(e);f(t.s,t.v),h(e,t),C.value=t.h,g.style.color="hsl("+t.h+", 100%, 50%)",i.style.left=t.h/360*100+"%",x.style.left=k.width*t.s/100+"px",x.style.top=k.height-k.height*t.v/100+"px",T.value=100*t.a,A.style.left=100*t.a+"%"}function p(e){e=void 0!==e?e:L.value,M&&(M.value=e,M.dispatchEvent(new Event("input",{bubbles:!0}))),b.dispatchEvent(new CustomEvent("coloris:pick",{detail:{color:e}}))}function r(e,t){var a,l,r,n,o,e={h:+C.value,s:e/k.width*100,v:100-t/k.height*100,a:T.value/100},i=(i=(t=e).s/100,a=t.v/100,i*=a,l=t.h/60,r=i*(1-m.abs(l%2-1)),i+=a-=i,r+=a,l=m.floor(l)%6,n=[i,r,a,a,r,i][l],o=[r,i,i,r,a,a][l],a=[a,a,r,i,i,r][l],{r:m.round(255*n),g:m.round(255*o),b:m.round(255*a),a:t.a});f(e.s,e.v),h(i,e),p()}function f(e,t){var a=D.a11y.marker;e=+e.toFixed(1),t=+t.toFixed(1),a=(a=a.replace("{s}",e)).replace("{v}",t),x.setAttribute("aria-label",a)}function t(e){var t={pageX:((t=e).changedTouches?t.changedTouches[0]:t).pageX,pageY:(t.changedTouches?t.changedTouches[0]:t).pageY},a=t.pageX-k.x,t=t.pageY-k.y;D.parent&&(t+=D.parent.scrollTop),a=a<0?0:a>k.width?k.width:a,t=t<0?0:t>k.height?k.height:t,x.style.left=a+"px",x.style.top=t+"px",r(a,t),e.preventDefault(),e.stopPropagation()}function h(e,t){void 0===t&&(t={});var a,l,r=D.format;for(a in e=void 0===e?{}:e)O[a]=e[a];for(l in t)O[l]=t[l];var n,o=function(e){var t=e.r.toString(16),a=e.g.toString(16),l=e.b.toString(16),r="";e.r<16&&(t="0"+t);e.g<16&&(a="0"+a);e.b<16&&(l="0"+l);D.alpha&&e.a<1&&(e=255*e.a|0,r=e.toString(16),e<16&&(r="0"+r));return"#"+t+a+l+r}(O),i=o.substring(0,7);switch(x.style.color=i,A.parentNode.style.color=i,A.style.color=o,E.style.color=o,w.style.display="none",w.offsetHeight,w.style.display="",A.nextElementSibling.style.display="none",A.nextElementSibling.offsetHeight,A.nextElementSibling.style.display="","mixed"===r?r=1===O.a?"hex":"rgb":"auto"===r&&(r=H),r){case"hex":L.value=o;break;case"rgb":L.value=(n=O,D.alpha&&1!==n.a?"rgba("+n.r+", "+n.g+", "+n.b+", "+n.a+")":"rgb("+n.r+", "+n.g+", "+n.b+")");break;case"hsl":L.value=(n=function(e){var t,a=e.v/100,l=a*(1-e.s/100/2);0<l&&l<1&&(t=m.round((a-l)/m.min(l,1-l)*100));return{h:e.h,s:t||0,l:m.round(100*l),a:e.a}}(O),D.alpha&&1!==n.a?"hsla("+n.h+", "+n.s+"%, "+n.l+"%, "+n.a+")":"hsl("+n.h+", "+n.s+"%, "+n.l+"%)")}b.querySelector('.clr-format [value="'+r+'"]').checked=!0}function e(){var e=+C.value,t=+x.style.left.replace("px",""),a=+x.style.top.replace("px","");g.style.color="hsl("+e+", 100%, 50%)",i.style.left=e/360*100+"%",r(t,a)}function F(){var e=T.value/100;A.style.left=100*e+"%",h({a:e}),p()}function I(){(g=b.createElement("div")).setAttribute("id","clr-picker"),g.className="clr-picker",g.innerHTML='<input id="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="'+D.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+D.a11y.instruction+'"><div id="clr-color-marker" class="clr-marker" tabindex="0"></div></div><div class="clr-hue"><input id="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="'+D.a11y.hueSlider+'"><div id="clr-hue-marker"></div></div><div class="clr-alpha"><input id="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="'+D.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+D.a11y.format+'</legend><input id="clr-f1" type="radio" name="clr-format" value="hex"><label for="clr-f1">Hex</label><input id="clr-f2" type="radio" name="clr-format" value="rgb"><label for="clr-f2">RGB</label><input id="clr-f3" type="radio" name="clr-format" value="hsl"><label for="clr-f3">HSL</label><span></span></fieldset></div><div id="clr-swatches" class="clr-swatches"></div><button type="button" id="clr-clear" class="clr-clear">'+D.clearButton.label+'</button><button type="button" id="clr-color-preview" class="clr-preview" aria-label="'+D.a11y.close+'"></button><span id="clr-open-label" hidden>'+D.a11y.open+'</span><span id="clr-swatch-label" hidden>'+D.a11y.swatch+"</span>",b.body.appendChild(g),w=v("clr-color-area"),x=v("clr-color-marker"),S=v("clr-clear"),E=v("clr-color-preview"),L=v("clr-color-value"),C=v("clr-hue-slider"),i=v("clr-hue-marker"),T=v("clr-alpha-slider"),A=v("clr-alpha-marker"),c(D.el),u(D.el),n(g,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),n(w,"mousedown",function(e){n(b,"mousemove",t)}),n(w,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),n(x,"mousedown",function(e){n(b,"mousemove",t)}),n(x,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),n(L,"change",function(e){d(L.value),p()}),n(S,"click",function(e){p(""),l()}),n(E,"click",function(e){p(),l()}),n(b,"click",".clr-format input",function(e){H=e.target.value,h(),p()}),n(g,"click",".clr-swatches button",function(e){d(e.target.textContent),p(),D.autoClose&&l()}),n(b,"mouseup",function(e){b.removeEventListener("mousemove",t)}),n(b,"touchend",function(e){b.removeEventListener("touchmove",t)}),n(b,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),l()}),n(b,"keydown",function(e){"Escape"===e.key?l(!0):"Tab"===e.key&&g.classList.add("clr-keyboard-nav")}),n(b,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),n(x,"keydown",function(e){var t={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]};-1!==Object.keys(t).indexOf(e.key)&&(!function(e,t){e=+x.style.left.replace("px","")+e,t=+x.style.top.replace("px","")+t,x.style.left=e+"px",x.style.top=t+"px",r(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),n(w,"click",t),n(C,"input",e),n(T,"input",F)}function v(e){return b.getElementById(e)}function n(e,t,a,l){var r=Element.prototype.matches||Element.prototype.msMatchesSelector;"string"==typeof a?e.addEventListener(t,function(e){r.call(e.target,a)&&l.call(e.target,e)}):(l=a,e.addEventListener(t,l))}function o(e,t){t=void 0!==t?t:[],"loading"!==b.readyState?e.apply(void 0,t):b.addEventListener("DOMContentLoaded",function(){e.apply(void 0,t)})}var y,b,m,g,w,k,x,E,L,S,C,i,T,A,M,H,B,N,O,D,j});
{
"name": "@melloware/coloris",
"version": "0.12.1",
"version": "0.12.2",
"description": "A lightweight and elegant color picker.",

@@ -5,0 +5,0 @@ "author": "Momo Bassit",

@@ -68,3 +68,3 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<artifactId>melloware__coloris</artifactId>
<version>0.12.0</version>
<version>0.12.2</version>
</dependency>

@@ -71,0 +71,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc