Socket
Socket
Sign inDemoInstall

@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.10.1 to 0.10.2

2

dist/coloris.js

@@ -668,2 +668,4 @@ // https://github.com/umdjs/umd/blob/master/templates/returnExports.js

// Workaround to mitigate a Chromium bug where the alpha value is rounded incorrectly
rgba.a = +rgba.a.toFixed(2);
} else {

@@ -670,0 +672,0 @@ match = ctx.fillStyle.replace('#', '').match(/.{2}/g).map(function (h) {return parseInt(h, 16);});

2

dist/coloris.min.js

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

*/
return y=window,b=document,m=Math,O=b.createElement("canvas").getContext("2d"),j={el:"[data-coloris]",parent:null,theme:"default",themeMode:"light",wrap:!0,margin:2,format:"hex",formatToggle:!(D={r:0,g:0,b:0,h:0,s:0,v:0,a:1}),swatches:[],swatchesOnly:!1,alpha:!0,focusInput:!0,autoClose:!1,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),function(){var r={init:p,set:a,wrap:c,close:l};function e(e){v(function(){e&&("string"==typeof e?i: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];v(r[l],t)}}(t);return e}();function a(e){if("object"==typeof e)for(var t in e)switch(t){case"el":i(e.el),!1!==e.wrap&&c(e.el);break;case"parent":j.parent=b.querySelector(e.parent),j.parent&&j.parent.appendChild(g);break;case"themeMode":j.themeMode=e.themeMode,"auto"===e.themeMode&&y.matchMedia&&y.matchMedia("(prefers-color-scheme: dark)").matches&&(j.themeMode="dark");case"theme":e.theme&&(j.theme=e.theme),g.className="clr-picker clr-"+j.theme+" clr-"+j.themeMode;break;case"margin":e.margin*=1,j.margin=(isNaN(e.margin)?j:e).margin;break;case"wrap":e.el&&e.wrap&&c(e.el);break;case"formatToggle":f("clr-format").style.display=e.formatToggle?"block":"none",e.formatToggle&&(j.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>")}),a.length&&(f("clr-swatches").innerHTML="<div>"+a.join("")+"</div>")}();break;case"swatchesOnly":j.swatchesOnly=!!e.swatchesOnly,g.setAttribute("data-minimal",j.swatchesOnly),j.swatchesOnly&&(j.autoClose=!0);break;case"alpha":j.alpha=!!e.alpha,g.setAttribute("data-alpha",j.alpha);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=e.a11y,o=!1;if("object"==typeof r)for(var n in r)r[n]&&j.a11y[n]&&(j.a11y[n]=r[n],o=!0);o&&(l=f("clr-open-label"),a=f("clr-swatch-label"),l.innerHTML=j.a11y.open,a.innerHTML=j.a11y.swatch,E.setAttribute("aria-label",j.a11y.close),C.setAttribute("aria-label",j.a11y.hueSlider),A.setAttribute("aria-label",j.a11y.alphaSlider),L.setAttribute("aria-label",j.a11y.input),w.setAttribute("aria-label",j.a11y.instruction));default:j[t]=e[t]}}function i(e){h(b,"click",e,function(e){var t=j.parent,a=e.target.getBoundingClientRect(),l=y.scrollY,r={left:!1,top:!1},o={x:0,y:0},n=a.x,i=l+a.y+a.height+j.margin;H=e.target,N=H.value,B=function(e){e=e.substring(0,3).toLowerCase();return"rgb"!==e&&"hsl"!==e?"hex":e}(N),g.classList.add("clr-open");var c,s=g.offsetWidth,u=g.offsetHeight;t?(c=y.getComputedStyle(t),e=parseFloat(c.marginTop),c=parseFloat(c.borderTopWidth),(o=t.getBoundingClientRect()).y+=c+l,n-=o.x,i-=o.y,n+s>t.clientWidth&&(n+=a.width-s,r.left=!0),i+u>t.clientHeight-e&&(i-=a.height+u+2*j.margin,r.top=!0),i+=t.scrollTop):(n+s>b.documentElement.clientWidth&&(n+=a.width-s,r.left=!0),i+u-l>b.documentElement.clientHeight&&(i=l+a.y-u-j.margin,r.top=!0)),g.classList.toggle("clr-left",r.left),g.classList.toggle("clr-top",r.top),g.style.left=n+"px",g.style.top=i+"px",k={width:w.offsetWidth,height:w.offsetHeight,x:g.offsetLeft+w.offsetLeft+o.x,y:g.offsetTop+w.offsetTop+o.y},d(N),j.focusInput&&L.focus({preventScroll:!0})}),h(b,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function c(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){H&&(e&&N!==H.value&&(H.value=N,H.dispatchEvent(new Event("input",{bubbles:!0}))),N!==H.value&&H.dispatchEvent(new Event("change",{bubbles:!0})),g.classList.remove("clr-open"),j.focusInput&&H.focus({preventScroll:!0}),H=null)}function d(e){var t=function(e){O.fillStyle="#000",O.fillStyle=e,e=(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(O.fillStyle))?{r:+e[3],g:+e[4],b:+e[5],a:+e[6]}:(e=O.fillStyle.replace("#","").match(/.{2}/g).map(function(e){return parseInt(e,16)}),{r:e[0],g:e[1],b:e[2],a:1});return e}(e),e=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),n=r-o,i=r,c=0,o=0;n&&(r===t&&(c=(a-l)/n),r===a&&(c=2+(l-t)/n),r===l&&(c=4+(t-a)/n),r&&(o=n/r));return{h:(c=m.floor(60*c))<0?c+360:c,s:m.round(100*o),v:m.round(100*i),a:e.a}}(t);n(e.s,e.v),s(t,e),C.value=e.h,g.style.color="hsl("+e.h+", 100%, 50%)",T.style.left=e.h/360*100+"%",x.style.left=k.width*e.s/100+"px",x.style.top=k.height-k.height*e.v/100+"px",A.value=100*e.a,M.style.left=100*e.a+"%"}function r(e){H&&(H.value=void 0!==e?e:L.value,H.dispatchEvent(new Event("input",{bubbles:!0})))}function o(e,t){e={h:+C.value,s:e/k.width*100,v:100-t/k.height*100,a:A.value/100},t=function(e){var t=e.s/100,a=e.v/100,l=t*a,r=e.h/60,o=l*(1-m.abs(r%2-1)),n=a-l;l+=n,o+=n;t=m.floor(r)%6,a=[l,o,n,n,o,l][t],r=[o,l,l,o,n,n][t],t=[n,n,o,l,l,o][t];return{r:m.round(255*a),g:m.round(255*r),b:m.round(255*t),a:e.a}}(e);n(e.s,e.v),s(t,e),r()}function n(e,t){var a=j.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:((a=e).changedTouches?a.changedTouches[0]:a).pageX,pageY:(a.changedTouches?a.changedTouches[0]:a).pageY},a=t.pageX-k.x,t=t.pageY-k.y;j.parent&&(t+=j.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",o(a,t),e.preventDefault(),e.stopPropagation()}function s(e,t){void 0===t&&(t={});var a,l,r=j.format;for(a in e=void 0===e?{}:e)D[a]=e[a];for(l in t)D[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);j.alpha&&e.a<1&&(e=255*e.a|0,r=e.toString(16),e<16&&(r="0"+r));return"#"+t+a+l+r}(D),i=n.substring(0,7);switch(x.style.color=i,M.parentNode.style.color=i,M.style.color=n,E.style.color=n,w.style.display="none",w.offsetHeight,w.style.display="",M.nextElementSibling.style.display="none",M.nextElementSibling.offsetHeight,M.nextElementSibling.style.display="","mixed"===r?r=1===D.a?"hex":"rgb":"auto"===r&&(r=B),r){case"hex":L.value=n;break;case"rgb":L.value=(o=D,j.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}}(D),j.alpha&&1!==o.a?"hsla("+o.h+", "+o.s+"%, "+o.l+"%, "+o.a+")":"hsl("+o.h+", "+o.s+"%, "+o.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%)",T.style.left=e/360*100+"%",o(t,a)}function u(){var e=A.value/100;M.style.left=100*e+"%",s({a:e}),r()}function p(){(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="'+j.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+j.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="'+j.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="'+j.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+j.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">'+j.clearButton.label+'</button><button id="clr-color-preview" class="clr-preview" aria-label="'+j.a11y.close+'"></button><span id="clr-open-label" hidden>'+j.a11y.open+'</span><span id="clr-swatch-label" hidden>'+j.a11y.swatch+"</span>",b.body.appendChild(g),w=f("clr-color-area"),x=f("clr-color-marker"),S=f("clr-clear"),E=f("clr-color-preview"),L=f("clr-color-value"),C=f("clr-hue-slider"),T=f("clr-hue-marker"),A=f("clr-alpha-slider"),M=f("clr-alpha-marker"),i(j.el),c(j.el),h(g,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),h(w,"mousedown",function(e){h(b,"mousemove",t)}),h(w,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),h(x,"mousedown",function(e){h(b,"mousemove",t)}),h(x,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),h(L,"change",function(e){d(L.value),r()}),h(S,"click",function(e){r(""),l()}),h(E,"click",function(e){r(),l()}),h(b,"click",".clr-format input",function(e){B=e.target.value,s(),r()}),h(g,"click",".clr-swatches button",function(e){d(e.target.textContent),r(),j.autoClose&&l()}),h(b,"mouseup",function(e){b.removeEventListener("mousemove",t)}),h(b,"touchend",function(e){b.removeEventListener("touchmove",t)}),h(b,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),l()}),h(b,"keydown",function(e){"Escape"===e.key?l(!0):"Tab"===e.key&&g.classList.add("clr-keyboard-nav")}),h(b,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),h(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",o(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),h(w,"click",t),h(C,"input",e),h(A,"input",u)}function f(e){return b.getElementById(e)}function h(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 v(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,T,A,M,H,B,N,O,D,j});
return y=window,b=document,m=Math,O=b.createElement("canvas").getContext("2d"),j={el:"[data-coloris]",parent:null,theme:"default",themeMode:"light",wrap:!0,margin:2,format:"hex",formatToggle:!(D={r:0,g:0,b:0,h:0,s:0,v:0,a:1}),swatches:[],swatchesOnly:!1,alpha:!0,focusInput:!0,autoClose:!1,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),function(){var r={init:p,set:a,wrap:c,close:l};function e(e){v(function(){e&&("string"==typeof e?i: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];v(r[l],t)}}(t);return e}();function a(e){if("object"==typeof e)for(var t in e)switch(t){case"el":i(e.el),!1!==e.wrap&&c(e.el);break;case"parent":j.parent=b.querySelector(e.parent),j.parent&&j.parent.appendChild(g);break;case"themeMode":j.themeMode=e.themeMode,"auto"===e.themeMode&&y.matchMedia&&y.matchMedia("(prefers-color-scheme: dark)").matches&&(j.themeMode="dark");case"theme":e.theme&&(j.theme=e.theme),g.className="clr-picker clr-"+j.theme+" clr-"+j.themeMode;break;case"margin":e.margin*=1,j.margin=(isNaN(e.margin)?j:e).margin;break;case"wrap":e.el&&e.wrap&&c(e.el);break;case"formatToggle":f("clr-format").style.display=e.formatToggle?"block":"none",e.formatToggle&&(j.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>")}),a.length&&(f("clr-swatches").innerHTML="<div>"+a.join("")+"</div>")}();break;case"swatchesOnly":j.swatchesOnly=!!e.swatchesOnly,g.setAttribute("data-minimal",j.swatchesOnly),j.swatchesOnly&&(j.autoClose=!0);break;case"alpha":j.alpha=!!e.alpha,g.setAttribute("data-alpha",j.alpha);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=e.a11y,o=!1;if("object"==typeof r)for(var n in r)r[n]&&j.a11y[n]&&(j.a11y[n]=r[n],o=!0);o&&(l=f("clr-open-label"),a=f("clr-swatch-label"),l.innerHTML=j.a11y.open,a.innerHTML=j.a11y.swatch,E.setAttribute("aria-label",j.a11y.close),C.setAttribute("aria-label",j.a11y.hueSlider),A.setAttribute("aria-label",j.a11y.alphaSlider),L.setAttribute("aria-label",j.a11y.input),w.setAttribute("aria-label",j.a11y.instruction));default:j[t]=e[t]}}function i(e){h(b,"click",e,function(e){var t=j.parent,a=e.target.getBoundingClientRect(),l=y.scrollY,r={left:!1,top:!1},o={x:0,y:0},n=a.x,i=l+a.y+a.height+j.margin;H=e.target,N=H.value,B=function(e){e=e.substring(0,3).toLowerCase();return"rgb"!==e&&"hsl"!==e?"hex":e}(N),g.classList.add("clr-open");var c,s=g.offsetWidth,u=g.offsetHeight;t?(c=y.getComputedStyle(t),e=parseFloat(c.marginTop),c=parseFloat(c.borderTopWidth),(o=t.getBoundingClientRect()).y+=c+l,n-=o.x,i-=o.y,n+s>t.clientWidth&&(n+=a.width-s,r.left=!0),i+u>t.clientHeight-e&&(i-=a.height+u+2*j.margin,r.top=!0),i+=t.scrollTop):(n+s>b.documentElement.clientWidth&&(n+=a.width-s,r.left=!0),i+u-l>b.documentElement.clientHeight&&(i=l+a.y-u-j.margin,r.top=!0)),g.classList.toggle("clr-left",r.left),g.classList.toggle("clr-top",r.top),g.style.left=n+"px",g.style.top=i+"px",k={width:w.offsetWidth,height:w.offsetHeight,x:g.offsetLeft+w.offsetLeft+o.x,y:g.offsetTop+w.offsetTop+o.y},d(N),j.focusInput&&L.focus({preventScroll:!0})}),h(b,"input",e,function(e){var t=e.target.parentNode;t.classList.contains("clr-field")&&(t.style.color=e.target.value)})}function c(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){H&&(e&&N!==H.value&&(H.value=N,H.dispatchEvent(new Event("input",{bubbles:!0}))),N!==H.value&&H.dispatchEvent(new Event("change",{bubbles:!0})),g.classList.remove("clr-open"),j.focusInput&&H.focus({preventScroll:!0}),H=null)}function d(e){var t=function(e){var t;O.fillStyle="#000",O.fillStyle=e,(e=/^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i.exec(O.fillStyle))?(t={r:+e[3],g:+e[4],b:+e[5],a:+e[6]}).a=+t.a.toFixed(2):(e=O.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),e=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),n=r-o,i=r,c=0,o=0;n&&(r===t&&(c=(a-l)/n),r===a&&(c=2+(l-t)/n),r===l&&(c=4+(t-a)/n),r&&(o=n/r));return{h:(c=m.floor(60*c))<0?c+360:c,s:m.round(100*o),v:m.round(100*i),a:e.a}}(t);n(e.s,e.v),s(t,e),C.value=e.h,g.style.color="hsl("+e.h+", 100%, 50%)",T.style.left=e.h/360*100+"%",x.style.left=k.width*e.s/100+"px",x.style.top=k.height-k.height*e.v/100+"px",A.value=100*e.a,M.style.left=100*e.a+"%"}function r(e){H&&(H.value=void 0!==e?e:L.value,H.dispatchEvent(new Event("input",{bubbles:!0})))}function o(e,t){e={h:+C.value,s:e/k.width*100,v:100-t/k.height*100,a:A.value/100},t=function(e){var t=e.s/100,a=e.v/100,l=t*a,r=e.h/60,o=l*(1-m.abs(r%2-1)),n=a-l;l+=n,o+=n;t=m.floor(r)%6,a=[l,o,n,n,o,l][t],r=[o,l,l,o,n,n][t],t=[n,n,o,l,l,o][t];return{r:m.round(255*a),g:m.round(255*r),b:m.round(255*t),a:e.a}}(e);n(e.s,e.v),s(t,e),r()}function n(e,t){var a=j.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:((a=e).changedTouches?a.changedTouches[0]:a).pageX,pageY:(a.changedTouches?a.changedTouches[0]:a).pageY},a=t.pageX-k.x,t=t.pageY-k.y;j.parent&&(t+=j.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",o(a,t),e.preventDefault(),e.stopPropagation()}function s(e,t){void 0===t&&(t={});var a,l,r=j.format;for(a in e=void 0===e?{}:e)D[a]=e[a];for(l in t)D[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);j.alpha&&e.a<1&&(e=255*e.a|0,r=e.toString(16),e<16&&(r="0"+r));return"#"+t+a+l+r}(D),i=n.substring(0,7);switch(x.style.color=i,M.parentNode.style.color=i,M.style.color=n,E.style.color=n,w.style.display="none",w.offsetHeight,w.style.display="",M.nextElementSibling.style.display="none",M.nextElementSibling.offsetHeight,M.nextElementSibling.style.display="","mixed"===r?r=1===D.a?"hex":"rgb":"auto"===r&&(r=B),r){case"hex":L.value=n;break;case"rgb":L.value=(o=D,j.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}}(D),j.alpha&&1!==o.a?"hsla("+o.h+", "+o.s+"%, "+o.l+"%, "+o.a+")":"hsl("+o.h+", "+o.s+"%, "+o.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%)",T.style.left=e/360*100+"%",o(t,a)}function u(){var e=A.value/100;M.style.left=100*e+"%",s({a:e}),r()}function p(){(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="'+j.a11y.input+'"><div id="clr-color-area" class="clr-gradient" role="application" aria-label="'+j.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="'+j.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="'+j.a11y.alphaSlider+'"><div id="clr-alpha-marker"></div><span></span></div><div id="clr-format" class="clr-format"><fieldset class="clr-segmented"><legend>'+j.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">'+j.clearButton.label+'</button><button id="clr-color-preview" class="clr-preview" aria-label="'+j.a11y.close+'"></button><span id="clr-open-label" hidden>'+j.a11y.open+'</span><span id="clr-swatch-label" hidden>'+j.a11y.swatch+"</span>",b.body.appendChild(g),w=f("clr-color-area"),x=f("clr-color-marker"),S=f("clr-clear"),E=f("clr-color-preview"),L=f("clr-color-value"),C=f("clr-hue-slider"),T=f("clr-hue-marker"),A=f("clr-alpha-slider"),M=f("clr-alpha-marker"),i(j.el),c(j.el),h(g,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),e.stopPropagation()}),h(w,"mousedown",function(e){h(b,"mousemove",t)}),h(w,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),h(x,"mousedown",function(e){h(b,"mousemove",t)}),h(x,"touchstart",function(e){b.addEventListener("touchmove",t,{passive:!1})}),h(L,"change",function(e){d(L.value),r()}),h(S,"click",function(e){r(""),l()}),h(E,"click",function(e){r(),l()}),h(b,"click",".clr-format input",function(e){B=e.target.value,s(),r()}),h(g,"click",".clr-swatches button",function(e){d(e.target.textContent),r(),j.autoClose&&l()}),h(b,"mouseup",function(e){b.removeEventListener("mousemove",t)}),h(b,"touchend",function(e){b.removeEventListener("touchmove",t)}),h(b,"mousedown",function(e){g.classList.remove("clr-keyboard-nav"),l()}),h(b,"keydown",function(e){"Escape"===e.key?l(!0):"Tab"===e.key&&g.classList.add("clr-keyboard-nav")}),h(b,"click",".clr-field button",function(e){e.target.nextElementSibling.dispatchEvent(new Event("click",{bubbles:!0}))}),h(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",o(e,t)}.apply(void 0,t[e.key]),e.preventDefault())}),h(w,"click",t),h(C,"input",e),h(A,"input",u)}function f(e){return b.getElementById(e)}function h(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 v(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,T,A,M,H,B,N,O,D,j});
{
"name": "@melloware/coloris",
"version": "0.10.1",
"version": "0.10.2",
"description": "A lightweight and elegant color picker.",

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

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

<artifactId>melloware__coloris</artifactId>
<version>0.10.1</version>
<version>0.10.2</version>
</dependency>

@@ -58,0 +58,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