diff --git a/index.css b/index.css index 9519bf1..0f8fa7b 100644 --- a/index.css +++ b/index.css @@ -1 +1 @@ -.k-colors-field{--dark:#16171a;--dark-background:#2d2f36;--muted-grey:#777;--border-grey:#ccc;--light-grey:#efefef;--white:#fff;--positive:#5d800d;--negative:#c82829;--focus:#4271ae;--notice:#f5871f}.k-colors-field.shows-contrast{display:grid;grid-gap:0 1.9rem;grid-template-columns:auto 2.25rem}.k-colors-field.shows-contrast .k-input{grid-row-start:2}.k-colors-field .k-input-element{display:grid;grid-template-columns:2.25rem auto 3.5rem 2.25rem}.k-colors-contrast{position:relative;width:calc(2.25rem + 1px)}.k-colors-contrast:before{content:"";position:absolute;left:-24px;width:16px;height:16px;border:2px solid var(--dark-background);border-radius:50%;background-image:linear-gradient(90deg,var(--light-grey) 0,var(--light-grey) 50%,var(--dark-background) 0)}.k-colors-contrast .k-colors-color:before{content:attr(data-rating);position:absolute;top:-1.725rem;right:0;color:var(--dark);font-size:.75rem;font-weight:600;white-space:nowrap}.k-colors-units{display:flex;grid-column-start:2;min-width:0;padding:0 .25rem 0 .5rem}.k-colors-label{display:flex;flex:1 1 4rem;flex-wrap:nowrap;align-items:center;min-width:0;height:2.25rem;color:var(--border-grey);font-size:.875rem}.k-colors-label:focus-within{color:var(--border-grey)}.k-colors-label span{flex:0 0 0.9rem}.k-colors-input{flex:0 0 3rem;min-width:0;height:1.75rem;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:1rem;border:none;outline:none}.k-colors-input:active,.k-colors-input:focus{color:var(--focus)}.k-colors-input.is-hex{flex-basis:5rem}.k-colors-opacity{display:flex;flex-wrap:nowrap;align-items:center;position:relative}.k-colors-opacity:before{content:"";position:absolute;top:.25rem;left:0;bottom:.25rem;border-left:1px solid var(--border-grey)}.k-colors-input.is-alpha{flex-basis:2.25rem;min-width:0;margin-left:.25rem;text-align:right}.k-colors-opacity span{width:1rem;margin-left:.1rem;color:var(--border-grey)}.k-colors-preview{flex:0 0 2.25rem;margin-right:.5rem;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjIiIGNsaXAtcnVsZT0iZXZlbm9kZCIgdmlld0JveD0iMCAwIDEyIDEyIj48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDEydjEySDB6Ii8+PHBhdGggZmlsbD0iI2ViZWJlYiIgZD0iTTAgMGg2djZIMHptNS45NTIgNmg2djZoLTZ6Ii8+PC9zdmc+);background-size:.75rem .75rem}.k-colors-color,.k-colors-preview{display:block;width:2.25rem;height:2.25rem}.k-colors-color{overflow:hidden;border-right:1px solid var(--border-grey)}.k-colors-picker{width:2.25rem;height:2.25rem;visibility:hidden}.k-colors-field .k-dropdown{grid-column-start:4}.k-colors-field .k-dropdown-item{justify-content:flex-end;padding-left:8px}.k-colors-field .k-dropdown-item.is-current:before{content:"✓";margin-right:.5rem}.k-colors-space-button{height:2.25rem;padding:0 12px} \ No newline at end of file +.k-colors-field{--dark:#16171a;--dark-background:#2d2f36;--muted-grey:#777;--border-grey:#ccc;--light-grey:#efefef;--white:#fff;--positive:#5d800d;--negative:#c82829;--focus:#4271ae;--notice:#f5871f}.k-colors-field.shows-contrast{display:grid;grid-gap:0 1.9rem;grid-template-columns:auto 2.25rem}.k-colors-field.shows-contrast .k-input{grid-row-start:2}.k-colors-field .k-input-element{display:grid;grid-template-columns:2.25rem auto 3.5rem 2.25rem}.k-colors-contrast{position:relative;width:calc(2.25rem + 1px)}.k-colors-contrast:before{content:"";position:absolute;left:-24px;width:16px;height:16px;border:2px solid var(--dark-background);border-radius:50%;background-image:linear-gradient(90deg,var(--light-grey) 0,var(--light-grey) 50%,var(--dark-background) 0)}.k-colors-contrast .k-colors-color:before{content:attr(data-rating);position:absolute;top:-1.725rem;right:0;color:var(--dark);font-size:.75rem;font-weight:600;white-space:nowrap}.k-colors-units{display:flex;grid-column-start:2;min-width:0;padding:0 .25rem 0 .5rem}.k-colors-label{display:flex;flex:1 1 4rem;flex-wrap:nowrap;align-items:center;min-width:0;height:2.25rem;color:var(--border-grey);font-size:.875rem}.k-colors-label:focus-within{color:var(--border-grey)}.k-colors-label span{flex:0 0 0.9rem}.k-colors-input{flex:0 0 3rem;min-width:0;height:1.75rem;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:1rem;border:none;outline:none;background:transparent}.k-colors-input:active,.k-colors-input:focus{color:var(--focus)}.k-colors-input.is-hex{flex-basis:5rem}.k-colors-opacity{display:flex;flex-wrap:nowrap;align-items:center;position:relative}.k-colors-opacity:before{content:"";position:absolute;top:.25rem;left:0;bottom:.25rem;border-left:1px solid var(--border-grey)}.k-colors-input.is-alpha{flex-basis:2.25rem;min-width:0;margin-left:.25rem;text-align:right}.k-colors-opacity span{width:1rem;margin-left:.1rem;color:var(--border-grey)}.k-colors-preview{flex:0 0 2.25rem;margin-right:.5rem;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjIiIGNsaXAtcnVsZT0iZXZlbm9kZCIgdmlld0JveD0iMCAwIDEyIDEyIj48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDEydjEySDB6Ii8+PHBhdGggZmlsbD0iI2ViZWJlYiIgZD0iTTAgMGg2djZIMHptNS45NTIgNmg2djZoLTZ6Ii8+PC9zdmc+);background-size:.75rem .75rem}.k-colors-color,.k-colors-preview{display:block;width:2.25rem;height:2.25rem}.k-colors-color{overflow:hidden;border-right:1px solid var(--border-grey)}.k-colors-picker{width:2.25rem;height:2.25rem;visibility:hidden}.k-colors-field .k-dropdown{grid-column-start:4}.k-colors-field .k-dropdown-item{justify-content:flex-end;padding-left:8px}.k-colors-field .k-dropdown-item.is-current:before{content:"✓";margin-right:.5rem}.k-colors-space-button{height:2.25rem;padding:0 12px} \ No newline at end of file diff --git a/index.js b/index.js index 708cbc5..8a46fac 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(function () {function L(r,$,o){return{r:255*b(r,255),g:255*b($,255),b:255*b(o,255)}}function u(r,$,o){r=b(r,255),$=b($,255),o=b(o,255);var t=Math.max(r,$,o),e=Math.min(r,$,o),g=0,a=0,n=(t+e)/2;if(t===e)a=0,g=0;else{var p=t-e;switch(a=n>.5?p/(2-t-e):p/(t+e),t){case r:g=($-o)/p+($1&&(o-=1),o<1/6?r+6*o*($-r):o<.5?$:o<2/3?r+($-r)*(2/3-o)*6:r}if(r=b(r,360),$=b($,100),o=b(o,100),0===$)e=o,g=o,t=o;else{var n=o<.5?o*(1+$):o+$-o*$,p=2*o-n;t=a(p,n,r+1/3),e=a(p,n,r),g=a(p,n,r-1/3)}return{r:255*t,g:255*e,b:255*g}}function s(r,$,o){r=b(r,255),$=b($,255),o=b(o,255);var t=Math.max(r,$,o),e=Math.min(r,$,o),g=0,a=t,n=t-e,p=0===t?0:n/t;if(t===e)g=0;else{switch(t){case r:g=($-o)/n+($1)&&(e=1),e}function j(e){return e<=1?100*Number(e)+"%":e}function h(e){return 1===e.length?"0"+e:String(e)}var k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function D($){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function($){return typeof $}:function($){return $&&"function"==typeof Symbol&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $})($)}function M($){var a={r:0,g:0,b:0},r=1,e=null,t=null,o=null,n=!1,i=!1;return"string"==typeof $&&($=A($)),"object"===D($)&&(f($.r)&&f($.g)&&f($.b)?(a=L($.r,$.g,$.b),n=!0,i="%"===String($.r).substr(-1)?"prgb":"rgb"):f($.h)&&f($.s)&&f($.v)?(e=j($.s),t=j($.v),a=B($.h,e,t),n=!0,i="hsv"):f($.h)&&f($.s)&&f($.l)&&(e=j($.s),o=j($.l),a=C($.h,e,o),n=!0,i="hsl"),Object.prototype.hasOwnProperty.call($,"a")&&(r=$.a)),r=x(r),{ok:n,format:$.format||i,r:Math.min(255,Math.max(a.r,0)),g:Math.min(255,Math.max(a.g,0)),b:Math.min(255,Math.max(a.b,0)),a:r}}var G="[-\\+]?\\d+%?",H="[-\\+]?\\d*\\.\\d+%?",a="(?:"+H+")|(?:"+G+")",r="[\\s|\\(]+("+a+")[,|\\s]+("+a+")[,|\\s]+("+a+")\\s*\\)?",q="[\\s|\\(]+("+a+")[,|\\s]+("+a+")[,|\\s]+("+a+")[,|\\s]+("+a+")\\s*\\)?",d={CSS_UNIT:new RegExp(a),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+q),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+q),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+q),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function A($){if(0===($=$.trim().toLowerCase()).length)return!1;var a=!1;if(k[$])$=k[$],a=!0;else if("transparent"===$)return{r:0,g:0,b:0,a:0,format:"name"};var r=d.rgb.exec($);return r?{r:r[1],g:r[2],b:r[3]}:(r=d.rgba.exec($))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=d.hsl.exec($))?{h:r[1],s:r[2],l:r[3]}:(r=d.hsla.exec($))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=d.hsv.exec($))?{h:r[1],s:r[2],v:r[3]}:(r=d.hsva.exec($))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=d.hex8.exec($))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),a:y(r[4]),format:a?"name":"hex8"}:(r=d.hex6.exec($))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),format:a?"name":"hex"}:(r=d.hex4.exec($))?{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),a:y(r[4]+r[4]),format:a?"name":"hex8"}:!!(r=d.hex3.exec($))&&{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),format:a?"name":"hex"}}function f($){return Boolean(d.CSS_UNIT.exec(String($)))}var g=function(){function t(r,o){if(void 0===r&&(r=""),void 0===o&&(o={}),r instanceof t)return r;this.originalInput=r;var i=M(r);this.originalInput=r,this.r=i.r,this.g=i.g,this.b=i.b,this.a=i.a,this.roundA=Math.round(100*this.a)/100,this.format=o.format||i.format,this.gradientType=o.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=i.ok}return t.prototype.isDark=function(){return this.getBrightness()<128},t.prototype.isLight=function(){return!this.isDark()},t.prototype.getBrightness=function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},t.prototype.getLuminance=function(){var t=this.toRgb(),r=t.r/255,o=t.g/255,i=t.b/255;return .2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},t.prototype.getAlpha=function(){return this.a},t.prototype.setAlpha=function(t){return this.a=x(t),this.roundA=Math.round(100*this.a)/100,this},t.prototype.toHsv=function(){var t=s(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}},t.prototype.toHsvString=function(){var t=s(this.r,this.g,this.b),r=Math.round(360*t.h),o=Math.round(100*t.s),i=Math.round(100*t.v);return 1===this.a?"hsv("+r+", "+o+"%, "+i+"%)":"hsva("+r+", "+o+"%, "+i+"%, "+this.roundA+")"},t.prototype.toHsl=function(){var t=u(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}},t.prototype.toHslString=function(){var t=u(this.r,this.g,this.b),r=Math.round(360*t.h),o=Math.round(100*t.s),i=Math.round(100*t.l);return 1===this.a?"hsl("+r+", "+o+"%, "+i+"%)":"hsla("+r+", "+o+"%, "+i+"%, "+this.roundA+")"},t.prototype.toHex=function(t){return void 0===t&&(t=!1),z(this.r,this.g,this.b,t)},t.prototype.toHexString=function(t){return void 0===t&&(t=!1),"#"+this.toHex(t)},t.prototype.toHex8=function(t){return void 0===t&&(t=!1),F(this.r,this.g,this.b,this.a,t)},t.prototype.toHex8String=function(t){return void 0===t&&(t=!1),"#"+this.toHex8(t)},t.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},t.prototype.toRgbString=function(){var t=Math.round(this.r),r=Math.round(this.g),o=Math.round(this.b);return 1===this.a?"rgb("+t+", "+r+", "+o+")":"rgba("+t+", "+r+", "+o+", "+this.roundA+")"},t.prototype.toPercentageRgb=function(){var t=function(t){return Math.round(100*b(t,255))+"%"};return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}},t.prototype.toPercentageRgbString=function(){var t=function(t){return Math.round(100*b(t,255))};return 1===this.a?"rgb("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%)":"rgba("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%, "+this.roundA+")"},t.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var t="#"+z(this.r,this.g,this.b,!1),r=0,o=Object.keys(k);r=0;return r||!i||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(o=this.toRgbString()),"prgb"===t&&(o=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(o=this.toHexString()),"hex3"===t&&(o=this.toHexString(!0)),"hex4"===t&&(o=this.toHex8String(!0)),"hex8"===t&&(o=this.toHex8String()),"name"===t&&(o=this.toName()),"hsl"===t&&(o=this.toHslString()),"hsv"===t&&(o=this.toHsvString()),o||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()},t.prototype.clone=function(){return new t(this.toString())},t.prototype.lighten=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.l+=r/100,o.l=p(o.l),new t(o)},t.prototype.brighten=function(r){void 0===r&&(r=10);var o=this.toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(-r/100*255))),o.g=Math.max(0,Math.min(255,o.g-Math.round(-r/100*255))),o.b=Math.max(0,Math.min(255,o.b-Math.round(-r/100*255))),new t(o)},t.prototype.darken=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.l-=r/100,o.l=p(o.l),new t(o)},t.prototype.tint=function(t){return void 0===t&&(t=10),this.mix("white",t)},t.prototype.shade=function(t){return void 0===t&&(t=10),this.mix("black",t)},t.prototype.desaturate=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.s-=r/100,o.s=p(o.s),new t(o)},t.prototype.saturate=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.s+=r/100,o.s=p(o.s),new t(o)},t.prototype.greyscale=function(){return this.desaturate(100)},t.prototype.spin=function(r){var o=this.toHsl(),i=(o.h+r)%360;return o.h=i<0?360+i:i,new t(o)},t.prototype.mix=function(r,o){void 0===o&&(o=50);var i=this.toRgb(),n=new t(r).toRgb(),s=o/100;return new t({r:(n.r-i.r)*s+i.r,g:(n.g-i.g)*s+i.g,b:(n.b-i.b)*s+i.b,a:(n.a-i.a)*s+i.a})},t.prototype.analogous=function(r,o){void 0===r&&(r=6),void 0===o&&(o=30);var i=this.toHsl(),n=360/o,s=[this];for(i.h=(i.h-(n*r>>1)+720)%360;--r;)i.h=(i.h+n)%360,s.push(new t(i));return s},t.prototype.complement=function(){var r=this.toHsl();return r.h=(r.h+180)%360,new t(r)},t.prototype.monochromatic=function(r){void 0===r&&(r=6);for(var o=this.toHsv(),i=o.h,n=o.s,s=o.v,e=[],h=1/r;r--;)e.push(new t({h:i,s:n,v:s})),s=(s+h)%1;return e},t.prototype.splitcomplement=function(){var r=this.toHsl(),o=r.h;return[this,new t({h:(o+72)%360,s:r.s,l:r.l}),new t({h:(o+216)%360,s:r.s,l:r.l})]},t.prototype.triad=function(){return this.polyad(3)},t.prototype.tetrad=function(){return this.polyad(4)},t.prototype.polyad=function(r){for(var o=this.toHsl(),i=o.h,n=[this],s=360/r,e=1;e=4.5;case"AAlarge":return o>=3;case"AAAsmall":return o>=7;default:return!1;}}function w(e,i,a){void 0===a&&(a={includeFallbackColors:!1,level:"AA",size:"small"});for(var o=null,l=0,r=a.includeFallbackColors,$=a.level,t=a.size,u=0,n=i;ul&&(l=d,o=new g(s))}return E(e,o,{level:$,size:t})||!r?o:(a.includeFallbackColors=!1,w(e,["#fff","#000"],a))}var l={inheritAttrs:!1,props:{name:[String,Number],label:String,default:String,value:Array,contrast:Object,readability:Boolean,alpha:Boolean,invalid:Boolean,disabled:Boolean,required:Boolean,help:String},computed:{color:function(){var t;return t=this.value.length?this.value[0]:this.default,new g(t)},space:function(){return this.color.format?this.color.format:"hex"}},methods:{onInput:function(t){this.store(t)},onChangeSpace:function(t){this.store(this.color[t]())},onChangeOpacity:function(t){this.store(t)},store:function(t){var o=this.getContrast(t);this.$emit("input",[t,o])},getContrast:function(t){var o=this.readable(t);if(o)return o.toString()},readable:function(){var t=this.contrast;return t&&!0!==t||(t=["#fff","#000"]),w(this.color,t)}}};if(typeof l==="function"){l=l.options}Object.assign(l,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-field",_vm._b({class:{"k-colors-field":true,"shows-contrast":_vm.contrast!==false}},"k-field",_vm.$props,false),[_c("k-input",_vm._b({ref:"input",attrs:{"id":_vm._uid,"theme":"field","type":"colors"},on:{"input":_vm.onInput}},"k-input",_vm.$props,false),[_c("k-colors-picker",{attrs:{"color":_vm.color},on:{"input":_vm.onInput}}),_vm._v(" "),_c("k-colors-input",{attrs:{"color":_vm.color,"space":_vm.space},on:{"input":_vm.onInput}}),_vm._v(" "),_vm.alpha!==false?_c("k-colors-opacity",{attrs:{"color":_vm.color},on:{"change-opacity":_vm.onChangeOpacity}}):_vm._e(),_vm._v(" "),_c("k-colors-spaces",{attrs:{"space":_vm.space},on:{"change-space":_vm.onChangeSpace}})],1),_vm._v(" "),_vm.contrast!==false?_c("k-colors-contrast",{attrs:{"color":_vm.color,"contrast":_vm.contrast}}):_vm._e()],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var o={props:{color:Object,contrast:[Boolean,Array]},computed:{readable:function(){var r=this.contrast;return!0===r&&(r=["#fff","#000"]),w(this.color,r)},rating:function(){var r=v(this.color,this.readable),t="AALarge";return r>=7?t="AAA":r>=4.5&&(t="AA / AAALarge"),t},value:function(){if(this.readable)return this.readable.toString()}}};if(typeof o==="function"){o=o.options}Object.assign(o,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-input",_vm._b({ref:"input",staticClass:"k-colors-contrast",attrs:{"id":_vm._uid,"theme":"field"}},"k-input",_vm.$props,false),[_c("div",{staticClass:"k-colors-color",style:{background:_vm.value},attrs:{"data-rating":_vm.rating}})])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var t={methods:{onInput:function(t){this.store(t.target.value)},onUp:function(t){var e=t.target,a=e.getAttribute("max");if(a){var r=parseInt(e.value,10),n=1;t.metaKey&&(n=10),r=Math.min(r+n,a),this.store(r,e)}},onDown:function(t){var e=t.target,a=e.getAttribute("min");if(a){var r=parseInt(e.value,10),n=1;t.metaKey&&(n=10),r=Math.max(a,r-n),this.store(r,e)}}}};var i={mixins:[t],props:{color:Object,space:String},computed:{hex:function(){if(""!==this.color.originalInput)return this.color.toHex()},rgb:function(){return this.color.toRgb()},hsl:function(){var t=this.color.toHsl();return t.h=Math.round(t.h),t.s=Math.round(100*t.s),t.l=Math.round(100*t.l),t}},methods:{store:function(t,r){var e=t;-1===e.indexOf("#")&&(e="#"+e),"rgb"===this.space?e={r:this.$refs.r.value,g:this.$refs.g.value,b:this.$refs.b.value}:"hsl"===this.space&&(e={h:this.$refs.h.value,s:this.$refs.s.value,l:this.$refs.l.value}),r&&(e[r.dataset.unit]=t),(e=new g(e)).setAlpha(this.color.getAlpha()),this.$emit("input",e.toString())}}};if(typeof i==="function"){i=i.options}Object.assign(i,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"k-colors-units"},[_vm.space==="rgb"?[_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("R")]),_vm._v(" "),_c("input",{ref:"r",staticClass:"k-colors-input",attrs:{"data-unit":"r","type":"text","min":"0","max":"255"},domProps:{"value":_vm.rgb.r},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("G")]),_vm._v(" "),_c("input",{ref:"g",staticClass:"k-colors-input",attrs:{"data-unit":"g","type":"text","min":"0","max":"255"},domProps:{"value":_vm.rgb.g},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("B")]),_vm._v(" "),_c("input",{ref:"b",staticClass:"k-colors-input",attrs:{"data-unit":"b","type":"text","min":"0","max":"255"},domProps:{"value":_vm.rgb.b},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})])]:_vm.space==="hsl"?[_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("H")]),_vm._v(" "),_c("input",{ref:"h",staticClass:"k-colors-input",attrs:{"data-unit":"h","type":"text","min":"0","max":"360"},domProps:{"value":_vm.hsl.h},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("S")]),_vm._v(" "),_c("input",{ref:"s",staticClass:"k-colors-input",attrs:{"data-unit":"s","type":"text","min":"0","max":"100"},domProps:{"value":_vm.hsl.s},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("L")]),_vm._v(" "),_c("input",{ref:"l",staticClass:"k-colors-input",attrs:{"data-unit":"l","type":"text","min":"0","max":"100"},domProps:{"value":_vm.hsl.l},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})])]:[_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("#")]),_vm._v(" "),_c("input",{ref:"hex",staticClass:"k-colors-input is-hex",attrs:{"type":"text"},domProps:{"value":_vm.hex},on:{"change":_vm.onInput}})])]],2)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var n={mixins:[t],props:{color:Object},computed:{opacity:function(){return Math.round(100*this.color.getAlpha())}},methods:{store:function(t){var e,o=parseInt(t,10)/100;this.color.format&&this.color.format.indexOf("hex")>-1&&(e="hex8"),this.color.setAlpha(o),this.$emit("change-opacity",this.color.toString(e))}}};if(typeof n==="function"){n=n.options}Object.assign(n,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("label",{staticClass:"k-colors-opacity"},[_c("input",{staticClass:"k-colors-input is-alpha",attrs:{"type":"text","min":"0","max":"100"},domProps:{"value":_vm.opacity},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}}),_vm._v(" "),_c("span",[_vm._v("%")])])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var m={props:{color:Object},data:{init:!1},computed:{value:function(){if(""!==this.color.originalInput)return"#"+this.color.toHex8()},hex:function(){if(""!==this.color.originalInput)return"#"+this.color.toHex()}},methods:{onInput:function(t){if(this.init){var i=new g(t.target.value),o=this.color.format;i.setAlpha(this.color.getAlpha()),this.$emit("invalid",!1),this.$emit("input",i.toString(o))}else this.init=!0}}};if(typeof m==="function"){m=m.options}Object.assign(m,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"k-colors-preview"},[_c("label",{staticClass:"k-colors-color",style:{background:_vm.value}},[_c("input",{staticClass:"k-colors-picker",attrs:{"type":"color"},domProps:{"value":_vm.hex},on:{"input":_vm.onInput}})])])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var e={props:{space:String},methods:{showHex:function(){this.$emit("change-space","toHex8")},showRgb:function(){this.$emit("change-space","toRgb")},showHsl:function(){this.$emit("change-space","toHsl")}}};if(typeof e==="function"){e=e.options}Object.assign(e,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-dropdown",[_c("k-button",{staticClass:"k-colors-space-button",attrs:{"icon":"angle-down","tabindex":"-1"},on:{"click":function($event){return _vm.$refs.dropdown.toggle()}}}),_vm._v(" "),_c("k-dropdown-content",{ref:"dropdown",attrs:{"align":"right"}},[_c("k-dropdown-item",{class:{"is-current":_vm.space.indexOf("hex")>-1},on:{"click":_vm.showHex}},[_vm._v("HEX")]),_vm._v(" "),_c("k-dropdown-item",{class:{"is-current":_vm.space.indexOf("rgb")>-1},on:{"click":_vm.showRgb}},[_vm._v("RGB")]),_vm._v(" "),_c("k-dropdown-item",{class:{"is-current":_vm.space.indexOf("hsl")>-1},on:{"click":_vm.showHsl}},[_vm._v("HSL")])],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("hananils/colors",{fields:{colors:l},components:{"k-colors-contrast":o,"k-colors-input":i,"k-colors-opacity":n,"k-colors-picker":m,"k-colors-spaces":e}});})(); \ No newline at end of file +(function () {function A(r,$,o){return{r:255*b(r,255),g:255*b($,255),b:255*b(o,255)}}function s(r,$,o){r=b(r,255),$=b($,255),o=b(o,255);var t=Math.max(r,$,o),e=Math.min(r,$,o),g=0,a=0,n=(t+e)/2;if(t===e)a=0,g=0;else{var p=t-e;switch(a=n>.5?p/(2-t-e):p/(t+e),t){case r:g=($-o)/p+($1&&(o-=1),o<1/6?r+6*o*($-r):o<.5?$:o<2/3?r+($-r)*(2/3-o)*6:r}if(r=b(r,360),$=b($,100),o=b(o,100),0===$)e=o,g=o,t=o;else{var n=o<.5?o*(1+$):o+$-o*$,p=2*o-n;t=a(p,n,r+1/3),e=a(p,n,r),g=a(p,n,r-1/3)}return{r:255*t,g:255*e,b:255*g}}function u(r,$,o){r=b(r,255),$=b($,255),o=b(o,255);var t=Math.max(r,$,o),e=Math.min(r,$,o),g=0,a=t,n=t-e,p=0===t?0:n/t;if(t===e)g=0;else{switch(t){case r:g=($-o)/n+($1)&&(e=1),e}function j(e){return e<=1?100*Number(e)+"%":e}function h(e){return 1===e.length?"0"+e:String(e)}var k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function H($){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function($){return typeof $}:function($){return $&&"function"==typeof Symbol&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $})($)}function I($){var a={r:0,g:0,b:0},r=1,e=null,t=null,o=null,n=!1,i=!1;return"string"==typeof $&&($=L($)),"object"===H($)&&(f($.r)&&f($.g)&&f($.b)?(a=A($.r,$.g,$.b),n=!0,i="%"===String($.r).substr(-1)?"prgb":"rgb"):f($.h)&&f($.s)&&f($.v)?(e=j($.s),t=j($.v),a=C($.h,e,t),n=!0,i="hsv"):f($.h)&&f($.s)&&f($.l)&&(e=j($.s),o=j($.l),a=B($.h,e,o),n=!0,i="hsl"),Object.prototype.hasOwnProperty.call($,"a")&&(r=$.a)),r=y(r),{ok:n,format:$.format||i,r:Math.min(255,Math.max(a.r,0)),g:Math.min(255,Math.max(a.g,0)),b:Math.min(255,Math.max(a.b,0)),a:r}}var J="[-\\+]?\\d+%?",K="[-\\+]?\\d*\\.\\d+%?",a="(?:"+K+")|(?:"+J+")",q="[\\s|\\(]+("+a+")[,|\\s]+("+a+")[,|\\s]+("+a+")\\s*\\)?",r="[\\s|\\(]+("+a+")[,|\\s]+("+a+")[,|\\s]+("+a+")[,|\\s]+("+a+")\\s*\\)?",d={CSS_UNIT:new RegExp(a),rgb:new RegExp("rgb"+q),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+q),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+q),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function L($){if(0===($=$.trim().toLowerCase()).length)return!1;var a=!1;if(k[$])$=k[$],a=!0;else if("transparent"===$)return{r:0,g:0,b:0,a:0,format:"name"};var r=d.rgb.exec($);return r?{r:r[1],g:r[2],b:r[3]}:(r=d.rgba.exec($))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=d.hsl.exec($))?{h:r[1],s:r[2],l:r[3]}:(r=d.hsla.exec($))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=d.hsv.exec($))?{h:r[1],s:r[2],v:r[3]}:(r=d.hsva.exec($))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=d.hex8.exec($))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),a:t(r[4]),format:a?"name":"hex8"}:(r=d.hex6.exec($))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),format:a?"name":"hex"}:(r=d.hex4.exec($))?{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),a:t(r[4]+r[4]),format:a?"name":"hex8"}:!!(r=d.hex3.exec($))&&{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),format:a?"name":"hex"}}function f($){return Boolean(d.CSS_UNIT.exec(String($)))}var g=function(){function t(r,o){if(void 0===r&&(r=""),void 0===o&&(o={}),r instanceof t)return r;this.originalInput=r;var i=I(r);this.originalInput=r,this.r=i.r,this.g=i.g,this.b=i.b,this.a=i.a,this.roundA=Math.round(100*this.a)/100,this.format=o.format||i.format,this.gradientType=o.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=i.ok}return t.prototype.isDark=function(){return this.getBrightness()<128},t.prototype.isLight=function(){return!this.isDark()},t.prototype.getBrightness=function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},t.prototype.getLuminance=function(){var t=this.toRgb(),r=t.r/255,o=t.g/255,i=t.b/255;return .2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},t.prototype.getAlpha=function(){return this.a},t.prototype.setAlpha=function(t){return this.a=y(t),this.roundA=Math.round(100*this.a)/100,this},t.prototype.toHsv=function(){var t=u(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}},t.prototype.toHsvString=function(){var t=u(this.r,this.g,this.b),r=Math.round(360*t.h),o=Math.round(100*t.s),i=Math.round(100*t.v);return 1===this.a?"hsv("+r+", "+o+"%, "+i+"%)":"hsva("+r+", "+o+"%, "+i+"%, "+this.roundA+")"},t.prototype.toHsl=function(){var t=s(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}},t.prototype.toHslString=function(){var t=s(this.r,this.g,this.b),r=Math.round(360*t.h),o=Math.round(100*t.s),i=Math.round(100*t.l);return 1===this.a?"hsl("+r+", "+o+"%, "+i+"%)":"hsla("+r+", "+o+"%, "+i+"%, "+this.roundA+")"},t.prototype.toHex=function(t){return void 0===t&&(t=!1),x(this.r,this.g,this.b,t)},t.prototype.toHexString=function(t){return void 0===t&&(t=!1),"#"+this.toHex(t)},t.prototype.toHex8=function(t){return void 0===t&&(t=!1),D(this.r,this.g,this.b,this.a,t)},t.prototype.toHex8String=function(t){return void 0===t&&(t=!1),"#"+this.toHex8(t)},t.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},t.prototype.toRgbString=function(){var t=Math.round(this.r),r=Math.round(this.g),o=Math.round(this.b);return 1===this.a?"rgb("+t+", "+r+", "+o+")":"rgba("+t+", "+r+", "+o+", "+this.roundA+")"},t.prototype.toPercentageRgb=function(){var t=function(t){return Math.round(100*b(t,255))+"%"};return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}},t.prototype.toPercentageRgbString=function(){var t=function(t){return Math.round(100*b(t,255))};return 1===this.a?"rgb("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%)":"rgba("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%, "+this.roundA+")"},t.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var t="#"+x(this.r,this.g,this.b,!1),r=0,o=Object.keys(k);r=0;return r||!i||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(o=this.toRgbString()),"prgb"===t&&(o=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(o=this.toHexString()),"hex3"===t&&(o=this.toHexString(!0)),"hex4"===t&&(o=this.toHex8String(!0)),"hex8"===t&&(o=this.toHex8String()),"name"===t&&(o=this.toName()),"hsl"===t&&(o=this.toHslString()),"hsv"===t&&(o=this.toHsvString()),o||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()},t.prototype.clone=function(){return new t(this.toString())},t.prototype.lighten=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.l+=r/100,o.l=e(o.l),new t(o)},t.prototype.brighten=function(r){void 0===r&&(r=10);var o=this.toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(-r/100*255))),o.g=Math.max(0,Math.min(255,o.g-Math.round(-r/100*255))),o.b=Math.max(0,Math.min(255,o.b-Math.round(-r/100*255))),new t(o)},t.prototype.darken=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.l-=r/100,o.l=e(o.l),new t(o)},t.prototype.tint=function(t){return void 0===t&&(t=10),this.mix("white",t)},t.prototype.shade=function(t){return void 0===t&&(t=10),this.mix("black",t)},t.prototype.desaturate=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.s-=r/100,o.s=e(o.s),new t(o)},t.prototype.saturate=function(r){void 0===r&&(r=10);var o=this.toHsl();return o.s+=r/100,o.s=e(o.s),new t(o)},t.prototype.greyscale=function(){return this.desaturate(100)},t.prototype.spin=function(r){var o=this.toHsl(),i=(o.h+r)%360;return o.h=i<0?360+i:i,new t(o)},t.prototype.mix=function(r,o){void 0===o&&(o=50);var i=this.toRgb(),n=new t(r).toRgb(),s=o/100;return new t({r:(n.r-i.r)*s+i.r,g:(n.g-i.g)*s+i.g,b:(n.b-i.b)*s+i.b,a:(n.a-i.a)*s+i.a})},t.prototype.analogous=function(r,o){void 0===r&&(r=6),void 0===o&&(o=30);var i=this.toHsl(),n=360/o,s=[this];for(i.h=(i.h-(n*r>>1)+720)%360;--r;)i.h=(i.h+n)%360,s.push(new t(i));return s},t.prototype.complement=function(){var r=this.toHsl();return r.h=(r.h+180)%360,new t(r)},t.prototype.monochromatic=function(r){void 0===r&&(r=6);for(var o=this.toHsv(),i=o.h,n=o.s,s=o.v,e=[],h=1/r;r--;)e.push(new t({h:i,s:n,v:s})),s=(s+h)%1;return e},t.prototype.splitcomplement=function(){var r=this.toHsl(),o=r.h;return[this,new t({h:(o+72)%360,s:r.s,l:r.l}),new t({h:(o+216)%360,s:r.s,l:r.l})]},t.prototype.triad=function(){return this.polyad(3)},t.prototype.tetrad=function(){return this.polyad(4)},t.prototype.polyad=function(r){for(var o=this.toHsl(),i=o.h,n=[this],s=360/r,e=1;e=4.5;case"AAlarge":return o>=3;case"AAAsmall":return o>=7;default:return!1;}}function w(e,i,a){void 0===a&&(a={includeFallbackColors:!1,level:"AA",size:"small"});for(var o=null,l=0,r=a.includeFallbackColors,$=a.level,t=a.size,u=0,n=i;ul&&(l=d,o=new g(s))}return M(e,o,{level:$,size:t})||!r?o:(a.includeFallbackColors=!1,w(e,["#fff","#000"],a))}var i={inheritAttrs:!1,props:{name:[String,Number],label:String,default:String,value:Array,contrast:Object,readability:Boolean,alpha:Boolean,invalid:Boolean,disabled:Boolean,required:Boolean,help:String},computed:{color:function(){var t;return t=this.value.length?this.value[0]:this.default,new g(t)},space:function(){return this.color.format?this.color.format:"hex"}},methods:{onInput:function(t){this.store(t)},onChangeSpace:function(t){this.store(this.color[t]())},onChangeOpacity:function(t){this.store(t)},store:function(t){var o=this.getContrast(t);this.$emit("input",[t,o])},getContrast:function(t){var o=this.readable(t);if(o)return o.toString()},readable:function(){var t=this.contrast;return t&&!0!==t||(t=["#fff","#000"]),w(this.color,t)}}};if(typeof i==="function"){i=i.options}Object.assign(i,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-field",_vm._b({class:{"k-colors-field":true,"shows-contrast":_vm.contrast!==false}},"k-field",_vm.$props,false),[_c("k-input",_vm._b({ref:"input",attrs:{"id":_vm._uid,"theme":"field","type":"colors"},on:{"input":_vm.onInput}},"k-input",_vm.$props,false),[_c("k-colors-picker",{attrs:{"color":_vm.color},on:{"input":_vm.onInput}}),_vm._v(" "),_c("k-colors-input",{attrs:{"color":_vm.color,"space":_vm.space},on:{"input":_vm.onInput}}),_vm._v(" "),_vm.alpha!==false?_c("k-colors-opacity",{attrs:{"color":_vm.color},on:{"change-opacity":_vm.onChangeOpacity}}):_vm._e(),_vm._v(" "),_c("k-colors-spaces",{attrs:{"space":_vm.space},on:{"change-space":_vm.onChangeSpace}})],1),_vm._v(" "),_vm.contrast!==false?_c("k-colors-contrast",{attrs:{"color":_vm.color,"contrast":_vm.contrast}}):_vm._e()],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var l={props:{color:Object,contrast:[Boolean,Array]},computed:{readable:function(){var r=this.contrast;return!0===r&&(r=["#fff","#000"]),w(this.color,r)},rating:function(){var r=v(this.color,this.readable),t="AALarge";return r>=7?t="AAA":r>=4.5&&(t="AA / AAALarge"),t},value:function(){if(this.readable)return this.readable.toString()}}};if(typeof l==="function"){l=l.options}Object.assign(l,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-input",_vm._b({ref:"input",staticClass:"k-colors-contrast",attrs:{"id":_vm._uid,"theme":"field"}},"k-input",_vm.$props,false),[_c("div",{staticClass:"k-colors-color",style:{background:_vm.value},attrs:{"data-rating":_vm.rating}})])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var z={methods:{onInput:function(t){this.store(t.target.value)},onUp:function(t){var e=t.target,a=e.getAttribute("max");if(a){var r=parseInt(e.value,10),n=1;t.metaKey&&(n=10),r=Math.min(r+n,a),this.store(r,e)}},onDown:function(t){var e=t.target,a=e.getAttribute("min");if(a){var r=parseInt(e.value,10),n=1;t.metaKey&&(n=10),r=Math.max(a,r-n),this.store(r,e)}}}};var m={mixins:[z],props:{color:Object,space:String},computed:{hex:function(){if(""!==this.color.originalInput)return this.color.toHex()},rgb:function(){return this.color.toRgb()},hsl:function(){var t=this.color.toHsl();return t.h=Math.round(t.h),t.s=Math.round(100*t.s),t.l=Math.round(100*t.l),t}},methods:{store:function(t,r){var e=t;-1===e.indexOf("#")&&(e="#"+e),"rgb"===this.space?e={r:this.$refs.r.value,g:this.$refs.g.value,b:this.$refs.b.value}:"hsl"===this.space&&(e={h:this.$refs.h.value,s:this.$refs.s.value,l:this.$refs.l.value}),r&&(e[r.dataset.unit]=t),(e=new g(e)).setAlpha(this.color.getAlpha()),this.$emit("input",e.toString())}}};if(typeof m==="function"){m=m.options}Object.assign(m,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"k-colors-units"},[_vm.space==="rgb"?[_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("R")]),_vm._v(" "),_c("input",{ref:"r",staticClass:"k-colors-input",attrs:{"data-unit":"r","type":"text","min":"0","max":"255"},domProps:{"value":_vm.rgb.r},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("G")]),_vm._v(" "),_c("input",{ref:"g",staticClass:"k-colors-input",attrs:{"data-unit":"g","type":"text","min":"0","max":"255"},domProps:{"value":_vm.rgb.g},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("B")]),_vm._v(" "),_c("input",{ref:"b",staticClass:"k-colors-input",attrs:{"data-unit":"b","type":"text","min":"0","max":"255"},domProps:{"value":_vm.rgb.b},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})])]:_vm.space==="hsl"?[_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("H")]),_vm._v(" "),_c("input",{ref:"h",staticClass:"k-colors-input",attrs:{"data-unit":"h","type":"text","min":"0","max":"360"},domProps:{"value":_vm.hsl.h},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("S")]),_vm._v(" "),_c("input",{ref:"s",staticClass:"k-colors-input",attrs:{"data-unit":"s","type":"text","min":"0","max":"100"},domProps:{"value":_vm.hsl.s},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})]),_vm._v(" "),_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("L")]),_vm._v(" "),_c("input",{ref:"l",staticClass:"k-colors-input",attrs:{"data-unit":"l","type":"text","min":"0","max":"100"},domProps:{"value":_vm.hsl.l},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}})])]:[_c("label",{staticClass:"k-colors-label"},[_c("span",[_vm._v("#")]),_vm._v(" "),_c("input",{ref:"hex",staticClass:"k-colors-input is-hex",attrs:{"type":"text"},domProps:{"value":_vm.hex},on:{"change":_vm.onInput}})])]],2)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var n={mixins:[z],props:{color:Object},computed:{opacity:function(){return Math.round(100*this.color.getAlpha())}},methods:{store:function(t){var e,o=parseInt(t,10)/100;this.color.format&&this.color.format.indexOf("hex")>-1&&(e="hex8"),this.color.setAlpha(o),this.$emit("change-opacity",this.color.toString(e))}}};if(typeof n==="function"){n=n.options}Object.assign(n,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("label",{staticClass:"k-colors-opacity"},[_c("input",{staticClass:"k-colors-input is-alpha",attrs:{"type":"text","min":"0","max":"100"},domProps:{"value":_vm.opacity},on:{"input":_vm.onInput,"keydown":[function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"up",38,$event.key,["Up","ArrowUp"])){return null}$event.preventDefault();return _vm.onUp($event)},function($event){if(!$event.type.indexOf("key")&&_vm._k($event.keyCode,"down",40,$event.key,["Down","ArrowDown"])){return null}$event.preventDefault();return _vm.onDown($event)}]}}),_vm._v(" "),_c("span",[_vm._v("%")])])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var o={props:{color:Object},data:{init:!1},computed:{value:function(){if(""!==this.color.originalInput)return"#"+this.color.toHex8()},hex:function(){if(""!==this.color.originalInput)return"#"+this.color.toHex()}},methods:{onInput:function(t){if(this.init){var i=new g(t.target.value),o=this.color.format;i.setAlpha(this.color.getAlpha()),this.$emit("invalid",!1),this.$emit("input",i.toString(o))}else this.init=!0}}};if(typeof o==="function"){o=o.options}Object.assign(o,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"k-colors-preview"},[_c("label",{staticClass:"k-colors-color",style:{background:_vm.value}},[_c("input",{staticClass:"k-colors-picker",attrs:{"type":"color"},domProps:{"value":_vm.hex},on:{"input":_vm.onInput}})])])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var p={props:{space:String},methods:{showHex:function(){this.$emit("change-space","toHex8")},showRgb:function(){this.$emit("change-space","toRgb")},showHsl:function(){this.$emit("change-space","toHsl")}}};if(typeof p==="function"){p=p.options}Object.assign(p,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("k-dropdown",[_c("k-button",{staticClass:"k-colors-space-button",attrs:{"icon":"angle-down","tabindex":"-1"},on:{"click":function($event){return _vm.$refs.dropdown.toggle()}}}),_vm._v(" "),_c("k-dropdown-content",{ref:"dropdown",attrs:{"align":"right"}},[_c("k-dropdown-item",{class:{"is-current":_vm.space.indexOf("hex")>-1},on:{"click":_vm.showHex}},[_vm._v("HEX")]),_vm._v(" "),_c("k-dropdown-item",{class:{"is-current":_vm.space.indexOf("rgb")>-1},on:{"click":_vm.showRgb}},[_vm._v("RGB")]),_vm._v(" "),_c("k-dropdown-item",{class:{"is-current":_vm.space.indexOf("hsl")>-1},on:{"click":_vm.showHsl}},[_vm._v("HSL")])],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("hananils/colors",{fields:{colors:i},components:{"k-colors-contrast":l,"k-colors-input":m,"k-colors-opacity":n,"k-colors-picker":o,"k-colors-spaces":p}});})(); \ No newline at end of file diff --git a/src/components/ColorsInput.vue b/src/components/ColorsInput.vue index 71d99cf..4aa3553 100644 --- a/src/components/ColorsInput.vue +++ b/src/components/ColorsInput.vue @@ -210,6 +210,7 @@ export default { font-size: 1rem; border: none; outline: none; + background: transparent; } .k-colors-input:focus,