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.10.2 to 0.10.3

4

dist/coloris.js

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

if (swatches.length) {
getEl('clr-swatches').innerHTML = "<div>" + swatches.join('') + "</div>";
}})();
getEl('clr-swatches').innerHTML = swatches.length ? "<div>" + swatches.join('') + "</div>" : '';})();
}

@@ -151,0 +149,0 @@ break;

@@ -1,7 +0,1 @@

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