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.14.0 to 0.15.0

7

dist/coloris.d.ts

@@ -195,9 +195,2 @@ /**

/**
* Set to true to close the color picker when a color is selected.
*
* @default false
*/
autoClose?: boolean;
/**
* Set to true to hide all the color picker widgets (spectrum, hue, ...) except the swatches.

@@ -204,0 +197,0 @@ *

165

dist/esm/coloris.js

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

var currentColor = { r: 0, g: 0, b: 0, h: 0, s: 0, v: 0, a: 1 };
var picker, colorArea, colorAreaDims, colorMarker, colorPreview, colorValue, clearButton,
var container, picker, colorArea, colorAreaDims, colorMarker, colorPreview, colorValue, clearButton,
hueSlider, hueMarker, alphaSlider, alphaMarker, currentEl, currentFormat, oldColor;

@@ -18,3 +18,3 @@

el: '[data-coloris]',
parent: null,
parent: 'body',
theme: 'default',

@@ -32,9 +32,6 @@ themeMode: 'light',

selectInput: false,
autoClose: false,
inline: false,
defaultColor: '#000000',
clearButton: {
show: false,
label: 'Clear' },
clearButton: false,
clearLabel: 'Clear',
a11y: {

@@ -53,2 +50,8 @@ open: 'Open color picker',

// Virtual instances cache
var instances = {};
var currentInstanceId = '';
var defaultInstance = {};
var hasInstance = false;
/**

@@ -72,5 +75,11 @@ * Configure the color picker.

case 'parent':
settings.parent = document.querySelector(options.parent);
if (settings.parent) {
settings.parent.appendChild(picker);
container = document.querySelector(options.parent);
if (container) {
container.appendChild(picker);
settings.parent = options.parent;
// document.body is special
if (container === document.body) {
container = null;
}
}

@@ -107,4 +116,5 @@ break;

case 'formatToggle':
getEl('clr-format').style.display = options.formatToggle ? 'block' : 'none';
if (options.formatToggle) {
settings.formatToggle = !!options.formatToggle;
getEl('clr-format').style.display = settings.formatToggle ? 'block' : 'none';
if (settings.formatToggle) {
settings.format = 'auto';

@@ -121,3 +131,4 @@ }

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

@@ -128,6 +139,2 @@ break;

picker.setAttribute('data-minimal', settings.swatchesOnly);
if (settings.swatchesOnly) {
settings.autoClose = true;
}
break;

@@ -151,14 +158,19 @@ case 'alpha':

case 'clearButton':
var display = 'none';
// Backward compatibility
if (typeof options.clearButton === 'object') {
if (options.clearButton.label) {
settings.clearLabel = options.clearButton.label;
clearButton.innerHTML = settings.clearLabel;
}
if (options.clearButton.show) {
display = 'block';
options.clearButton = options.clearButton.show;
}
if (options.clearButton.label) {
clearButton.innerHTML = options.clearButton.label;
}
clearButton.style.display = display;
settings.clearButton = !!options.clearButton;
clearButton.style.display = settings.clearButton ? 'block' : 'none';
break;
case 'clearLabel':
settings.clearLabel = options.clearLabel;
clearButton.innerHTML = settings.clearLabel;
break;
case 'a11y':

@@ -196,2 +208,74 @@ var labels = options.a11y;

/**
* Add or update a virtual instance.
* @param {String} selector The CSS selector of the elements to which the instance is attached.
* @param {Object} options Per-instance options to apply.
*/
function setVirtualInstance(selector, options) {
if (typeof selector === 'string' && typeof options === 'object') {
instances[selector] = options;
hasInstance = true;
}
}
/**
* Remove a virtual instance.
* @param {String} selector The CSS selector of the elements to which the instance is attached.
*/
function removeVirtualInstance(selector) {
delete instances[selector];
if (Object.keys(instances).length === 0) {
hasInstance = false;
if (selector === currentInstanceId) {
resetVirtualInstance();
}
}
}
/**
* Attach a virtual instance to an element if it matches a selector.
* @param {Object} element Target element that will receive a virtual instance if applicable.
*/
function attachVirtualInstance(element) {
if (hasInstance) {
// These options can only be set globally, not per instance
var unsupportedOptions = ['el', 'wrap', 'inline', 'defaultColor', 'a11y'];var _loop = function _loop(
selector) {
var options = instances[selector];
// If the element matches an instance's CSS selector
if (element.matches(selector)) {
currentInstanceId = selector;
defaultInstance = {};
// Delete unsupported options
unsupportedOptions.forEach(function (option) {return delete options[option];});
// Back up the default options so we can restore them later
for (var option in options) {
defaultInstance[option] = Array.isArray(settings[option]) ? settings[option].slice() : settings[option];
}
// Set the instance's options
configure(options);
return "break";
}};for (var selector in instances) {var _ret = _loop(selector);if (_ret === "break") break;
}
}
}
/**
* Revert any per-instance options that were previously applied.
*/
function resetVirtualInstance() {
if (Object.keys(defaultInstance).length > 0) {
configure(defaultInstance);
currentInstanceId = '';
defaultInstance = {};
}
}
/**
* Bind the color picker to input fields that match the selector.

@@ -208,2 +292,5 @@ * @param {string} selector One or more selectors pointing to input fields.

// Apply any per-instance options first
attachVirtualInstance(event.target);
currentEl = event.target;

@@ -244,3 +331,3 @@ oldColor = currentEl.value;

function updatePickerPosition() {
var parent = settings.parent;
var parent = container;
var scrollY = window.scrollY;

@@ -353,2 +440,7 @@ var pickerWidth = picker.offsetWidth;

// Reset any previously set per-instance options
if (hasInstance) {
resetVirtualInstance();
}
// Trigger a "close" event

@@ -474,4 +566,4 @@ currentEl.dispatchEvent(new Event('close', { bubbles: true }));

if (settings.parent) {
y += settings.parent.scrollTop;
if (container) {
y += container.scrollTop;
}

@@ -776,2 +868,3 @@

// Render the UI
container = null;
picker = document.createElement('div');

@@ -807,3 +900,3 @@ picker.setAttribute('id', 'clr-picker');

'<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.clearLabel + "</button>") + ("<button type=\"button\" id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
settings.a11y.close + "\"></button>") + ("<span id=\"clr-open-label\" hidden>" +

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

if (settings.autoClose) {
if (settings.swatchesOnly) {
closePicker();

@@ -905,2 +998,8 @@ }

addListener(document, 'click', '.clr-field button', function (event) {
// Reset any previously set per-instance options
if (hasInstance) {
resetVirtualInstance();
}
// Open the color picker
event.target.nextElementSibling.dispatchEvent(new Event('click', { bubbles: true }));

@@ -992,2 +1091,4 @@ });

close: closePicker,
setInstance: setVirtualInstance,
removeInstance: removeVirtualInstance,
updatePosition: updatePickerPosition };

@@ -1006,3 +1107,3 @@

});
}var _loop = function _loop(
}var _loop2 = function _loop2(

@@ -1012,3 +1113,3 @@ key) {

DOMReady(methods[key], args);
};};for (var key in methods) {_loop(key);
};};for (var key in methods) {_loop2(key);
}

@@ -1015,0 +1116,0 @@

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

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

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

var currentColor = { r: 0, g: 0, b: 0, h: 0, s: 0, v: 0, a: 1 };
var picker, colorArea, colorAreaDims, colorMarker, colorPreview, colorValue, clearButton,
var container, picker, colorArea, colorAreaDims, colorMarker, colorPreview, colorValue, clearButton,
hueSlider, hueMarker, alphaSlider, alphaMarker, currentEl, currentFormat, oldColor;

@@ -59,3 +59,3 @@

el: '[data-coloris]',
parent: null,
parent: 'body',
theme: 'default',

@@ -73,9 +73,6 @@ themeMode: 'light',

selectInput: false,
autoClose: false,
inline: false,
defaultColor: '#000000',
clearButton: {
show: false,
label: 'Clear' },
clearButton: false,
clearLabel: 'Clear',
a11y: {

@@ -94,2 +91,8 @@ open: 'Open color picker',

// Virtual instances cache
var instances = {};
var currentInstanceId = '';
var defaultInstance = {};
var hasInstance = false;
/**

@@ -113,5 +116,11 @@ * Configure the color picker.

case 'parent':
settings.parent = document.querySelector(options.parent);
if (settings.parent) {
settings.parent.appendChild(picker);
container = document.querySelector(options.parent);
if (container) {
container.appendChild(picker);
settings.parent = options.parent;
// document.body is special
if (container === document.body) {
container = null;
}
}

@@ -148,4 +157,5 @@ break;

case 'formatToggle':
getEl('clr-format').style.display = options.formatToggle ? 'block' : 'none';
if (options.formatToggle) {
settings.formatToggle = !!options.formatToggle;
getEl('clr-format').style.display = settings.formatToggle ? 'block' : 'none';
if (settings.formatToggle) {
settings.format = 'auto';

@@ -162,3 +172,4 @@ }

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

@@ -169,6 +180,2 @@ break;

picker.setAttribute('data-minimal', settings.swatchesOnly);
if (settings.swatchesOnly) {
settings.autoClose = true;
}
break;

@@ -192,14 +199,19 @@ case 'alpha':

case 'clearButton':
var display = 'none';
// Backward compatibility
if (typeof options.clearButton === 'object') {
if (options.clearButton.label) {
settings.clearLabel = options.clearButton.label;
clearButton.innerHTML = settings.clearLabel;
}
if (options.clearButton.show) {
display = 'block';
options.clearButton = options.clearButton.show;
}
if (options.clearButton.label) {
clearButton.innerHTML = options.clearButton.label;
}
clearButton.style.display = display;
settings.clearButton = !!options.clearButton;
clearButton.style.display = settings.clearButton ? 'block' : 'none';
break;
case 'clearLabel':
settings.clearLabel = options.clearLabel;
clearButton.innerHTML = settings.clearLabel;
break;
case 'a11y':

@@ -237,2 +249,74 @@ var labels = options.a11y;

/**
* Add or update a virtual instance.
* @param {String} selector The CSS selector of the elements to which the instance is attached.
* @param {Object} options Per-instance options to apply.
*/
function setVirtualInstance(selector, options) {
if (typeof selector === 'string' && typeof options === 'object') {
instances[selector] = options;
hasInstance = true;
}
}
/**
* Remove a virtual instance.
* @param {String} selector The CSS selector of the elements to which the instance is attached.
*/
function removeVirtualInstance(selector) {
delete instances[selector];
if (Object.keys(instances).length === 0) {
hasInstance = false;
if (selector === currentInstanceId) {
resetVirtualInstance();
}
}
}
/**
* Attach a virtual instance to an element if it matches a selector.
* @param {Object} element Target element that will receive a virtual instance if applicable.
*/
function attachVirtualInstance(element) {
if (hasInstance) {
// These options can only be set globally, not per instance
var unsupportedOptions = ['el', 'wrap', 'inline', 'defaultColor', 'a11y'];var _loop = function _loop(
selector) {
var options = instances[selector];
// If the element matches an instance's CSS selector
if (element.matches(selector)) {
currentInstanceId = selector;
defaultInstance = {};
// Delete unsupported options
unsupportedOptions.forEach(function (option) {return delete options[option];});
// Back up the default options so we can restore them later
for (var option in options) {
defaultInstance[option] = Array.isArray(settings[option]) ? settings[option].slice() : settings[option];
}
// Set the instance's options
configure(options);
return "break";
}};for (var selector in instances) {var _ret = _loop(selector);if (_ret === "break") break;
}
}
}
/**
* Revert any per-instance options that were previously applied.
*/
function resetVirtualInstance() {
if (Object.keys(defaultInstance).length > 0) {
configure(defaultInstance);
currentInstanceId = '';
defaultInstance = {};
}
}
/**
* Bind the color picker to input fields that match the selector.

@@ -249,2 +333,5 @@ * @param {string} selector One or more selectors pointing to input fields.

// Apply any per-instance options first
attachVirtualInstance(event.target);
currentEl = event.target;

@@ -285,3 +372,3 @@ oldColor = currentEl.value;

function updatePickerPosition() {
var parent = settings.parent;
var parent = container;
var scrollY = window.scrollY;

@@ -394,2 +481,7 @@ var pickerWidth = picker.offsetWidth;

// Reset any previously set per-instance options
if (hasInstance) {
resetVirtualInstance();
}
// Trigger a "close" event

@@ -515,4 +607,4 @@ currentEl.dispatchEvent(new Event('close', { bubbles: true }));

if (settings.parent) {
y += settings.parent.scrollTop;
if (container) {
y += container.scrollTop;
}

@@ -817,2 +909,3 @@

// Render the UI
container = null;
picker = document.createElement('div');

@@ -848,3 +941,3 @@ picker.setAttribute('id', 'clr-picker');

'<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.clearLabel + "</button>") + ("<button type=\"button\" id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
settings.a11y.close + "\"></button>") + ("<span id=\"clr-open-label\" hidden>" +

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

if (settings.autoClose) {
if (settings.swatchesOnly) {
closePicker();

@@ -946,2 +1039,8 @@ }

addListener(document, 'click', '.clr-field button', function (event) {
// Reset any previously set per-instance options
if (hasInstance) {
resetVirtualInstance();
}
// Open the color picker
event.target.nextElementSibling.dispatchEvent(new Event('click', { bubbles: true }));

@@ -1033,2 +1132,4 @@ });

close: closePicker,
setInstance: setVirtualInstance,
removeInstance: removeVirtualInstance,
updatePosition: updatePickerPosition };

@@ -1047,3 +1148,3 @@

});
}var _loop = function _loop(
}var _loop2 = function _loop2(

@@ -1053,3 +1154,3 @@ key) {

DOMReady(methods[key], args);
};};for (var key in methods) {_loop(key);
};};for (var key in methods) {_loop2(key);
}

@@ -1056,0 +1157,0 @@

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

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

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