2 lines
20 KiB
JavaScript
2 lines
20 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pickr=e():t.Pickr=e()}(window,function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="dist/",o(o.s=1)}([function(t,e,o){},function(t,e,o){"use strict";o.r(e);o(0);function n(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}const i=r.bind(null,"addEventListener"),s=r.bind(null,"removeEventListener");function r(t,e,o,i){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return e instanceof HTMLCollection||e instanceof NodeList?e=Array.from(e):Array.isArray(e)||(e=[e]),Array.isArray(o)||(o=[o]),e.forEach(e=>o.forEach(o=>e[t](o,i,function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},i=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(o).filter(function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable}))),i.forEach(function(e){n(t,e,o[e])})}return t}({capture:!1},s)))),Array.prototype.slice.call(arguments,1)}function a(t){const e=document.createElement("div");return e.innerHTML=t.trim(),e.firstElementChild}function c(t,e){const o=t.getAttribute(e);return t.removeAttribute(e),o}function l(t){return function t(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=c(e,"data-con"),i=c(e,"data-key");i&&(o[i]=e);const s=Array.from(e.children),r=n?o[n]={}:o;for(let e of s){const o=c(e,"data-arr");o?(r[o]||(r[o]=[])).push(e):t(e,r)}return o}(a(t))}function p(t){let e=t.path||t.composedPath&&t.composedPath();if(e)return e;let o=t.target.parentElement;for(e=[t.target,o];o=o.parentElement;)e.push(o);return e.push(document,window),e}function h(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const o=t=>t>="0"&&t<="9"||"-"===t||"."===t;function n(n){const i=t.value,s=t.selectionStart;let r=s,a="";for(let t=s-1;t>0&&o(i[t]);t--)a=i[t]+a,r--;for(let t=s,e=i.length;t<e&&o(i[t]);t++)a+=i[t];if(a.length>0&&!isNaN(a)&&isFinite(a)){const o=n.deltaY<0?1:-1,s=n.ctrlKey?5*o:o;let c=Number(a)+s;!e&&c<0&&(c=0);const l=i.substr(0,r)+c+i.substring(r+a.length,i.length),p=r+String(c).length;t.value=l,t.focus(),t.setSelectionRange(p,p)}n.preventDefault(),t.dispatchEvent(new Event("input"))}i(t,"focus",()=>i(window,"wheel",n)),i(t,"blur",()=>s(window,"wheel",n))}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var o=[],n=!0,i=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(n=(r=a.next()).done)&&(o.push(r.value),!e||o.length!==e);n=!0);}catch(t){i=!0,s=t}finally{try{n||null==a.return||a.return()}finally{if(i)throw s}}return o}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}const d=Math.min,f=Math.max;function v(t,e,o){t=t/360*6,e/=100,o/=100;let n=Math.floor(t),i=t-n,s=o*(1-e),r=o*(1-i*e),a=o*(1-(1-i)*e),c=n%6;return[255*[o,r,s,s,a,o][c],255*[a,o,o,r,s,s][c],255*[s,s,a,o,o,r][c]]}function y(t,e,o){let n,i,s;const r=d(t/=255,e/=255,o/=255),a=f(t,e,o),c=a-r;if(0===c)n=i=0;else{i=c/a;let s=((a-t)/6+c/2)/c,r=((a-e)/6+c/2)/c,l=((a-o)/6+c/2)/c;t===a?n=l-r:e===a?n=1/3+s-l:o===a&&(n=2/3+r-s),n<0?n+=1:n>1&&(n-=1)}return[360*n,100*i,100*(s=a)]}function g(t,e,o,n){return e/=100,o/=100,[...y(255*(1-d(1,(t/=100)*(1-(n/=100))+n)),255*(1-d(1,e*(1-n)+n)),255*(1-d(1,o*(1-n)+n)))]}function m(t,e,o){return e/=100,[t,2*(e*=(o/=100)<.5?o:1-o)/(o+e)*100,100*(o+e)]}function b(t){return y(...t.match(/.{2}/g).map(t=>parseInt(t,16)))}function _(t){const e={cmyk:/^cmyk[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)/i,rgba:/^(rgb|rgba)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]*?([\d.]+|$)/i,hsla:/^(hsl|hsla)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]*?([\d.]+|$)/i,hsva:/^(hsv|hsva)[\D]+(\d+)[\D]+(\d+)[\D]+(\d+)[\D]*?([\d.]+|$)/i,hex:/^#?(([\dA-Fa-f]{3,4})|([\dA-Fa-f]{6})|([\dA-Fa-f]{8}))$/i},o=t=>t.map(t=>/^(|\d+)\.\d+|\d+$/.test(t)?Number(t):void 0);let n;for(let r in e)if(n=e[r].exec(t))switch(r){case"cmyk":{let t=u(o(n),5),e=t[1],i=t[2],s=t[3],a=t[4];if(e>100||i>100||s>100||a>100)break;return{values:[...g(e,i,s,a),1],type:r}}case"rgba":{let t=u(o(n),6),e=t[2],i=t[3],s=t[4],a=t[5],c=void 0===a?1:a;if(e>255||i>255||s>255||c<0||c>1)break;return{values:[...y(e,i,s),c],type:r}}case"hex":{const t=(t,e)=>[t.substring(0,e),t.substring(e,t.length)];let e,o=u(n,2)[1];if(3===o.length?o+="F":6===o.length&&(o+="FF"),4===o.length){var i=u(t(o,3).map(t=>t+t),2);o=i[0],e=i[1]}else if(8===o.length){var s=u(t(o,6),2);o=s[0],e=s[1]}return e=parseInt(e,16)/255,{values:[...b(o),e],type:r}}case"hsla":{let t=u(o(n),6),e=t[2],i=t[3],s=t[4],a=t[5],c=void 0===a?1:a;if(e>360||i>100||s>100||c<0||c>1)break;return{values:[...m(e,i,s),c],type:r}}case"hsva":{let t=u(o(n),6),e=t[2],i=t[3],s=t[4],a=t[5],c=void 0===a?1:a;if(e>360||i>100||s>100||c<0||c>1)break;return{values:[e,i,s,c],type:r}}}return{values:null,type:null}}function w(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;const i=Math.ceil,s={h:t,s:e,v:o,a:n,toHSVA(){const t=[s.h,s.s,s.v],e=t.map(i);return t.push(s.a),t.toString=(()=>`hsva(${e[0]}, ${e[1]}%, ${e[2]}%, ${s.a.toFixed(1)})`),t},toHSLA(){const t=function(t,e,o){let n=(2-(e/=100))*(o/=100)/2;return 0!==n&&(e=1===n?0:n<.5?e*o/(2*n):e*o/(2-2*n)),[t,100*e,100*n]}(s.h,s.s,s.v),e=t.map(i);return t.push(s.a),t.toString=(()=>`hsla(${e[0]}, ${e[1]}%, ${e[2]}%, ${s.a.toFixed(1)})`),t},toRGBA(){const t=v(s.h,s.s,s.v),e=t.map(i);return t.push(s.a),t.toString=(()=>`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${s.a.toFixed(1)})`),t},toCMYK(){const t=function(t,e,o){const n=v(t,e,o),i=n[0]/255,s=n[1]/255,r=n[2]/255;let a,c,l,p;return[100*(c=1===(a=d(1-i,1-s,1-r))?0:(1-i-a)/(1-a)),100*(l=1===a?0:(1-s-a)/(1-a)),100*(p=1===a?0:(1-r-a)/(1-a)),100*a]}(s.h,s.s,s.v),e=t.map(i);return t.toString=(()=>`cmyk(${e[0]}%, ${e[1]}%, ${e[2]}%, ${e[3]}%)`),t},toHEX(){const t=function(t,e,o){return v(t,e,o).map(t=>Math.round(t).toString(16).padStart(2,"0"))}(...[s.h,s.s,s.v]);return t.toString=(()=>{const e=s.a>=1?"":Number((255*s.a).toFixed(0)).toString(16).toUpperCase().padStart(2,"0");return`#${t.join("").toUpperCase()+e}`}),t},clone:()=>w(s.h,s.s,s.v,s.a)};return s}function k(t){const e={options:Object.assign({lockX:!1,lockY:!1,onchange:()=>0},t),_tapstart(t){i(document,["mouseup","touchend","touchcancel"],e._tapstop),i(document,["mousemove","touchmove"],e._tapmove),t.preventDefault(),e._tapmove(t)},_tapmove(t){const o=e.options,n=e.cache,i=o.element,s=e.options.wrapper.getBoundingClientRect();let r=0,a=0;if(t){const e=t&&t.touches&&t.touches[0];r=t?(e||t).clientX:0,a=t?(e||t).clientY:0,r<s.left?r=s.left:r>s.left+s.width&&(r=s.left+s.width),a<s.top?a=s.top:a>s.top+s.height&&(a=s.top+s.height),r-=s.left,a-=s.top}else n&&(r=n.x*s.width,a=n.y*s.height);o.lockX||(i.style.left=`calc(${r/s.width*100}% - ${i.offsetWidth/2}px)`),o.lockY||(i.style.top=`calc(${a/s.height*100}% - ${i.offsetWidth/2}px)`),e.cache={x:r/s.width,y:a/s.height},o.onchange(r,a)},_tapstop(){s(document,["mouseup","touchend","touchcancel"],e._tapstop),s(document,["mousemove","touchmove"],e._tapmove)},trigger(){e._tapmove()},update(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=e.options.wrapper.getBoundingClientRect();e._tapmove({clientX:n.left+t,clientY:n.top+o})},destroy(){const t=e.options,o=e._tapstart;s([t.wrapper,t.element],"mousedown",o),s([t.wrapper,t.element],"touchstart",o,{passive:!1})}},o=e.options,n=e._tapstart;return i([o.wrapper,o.element],"mousedown",n),i([o.wrapper,o.element],"touchstart",n,{passive:!1}),e}function A(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=Object.assign({onchange:()=>0,className:"",elements:[]},t),i(t.elements,"click",e=>{t.elements.forEach(o=>o.classList[e.target===o?"add":"remove"](t.className)),t.onchange(e)}),{destory:()=>s(t.elements,"click",this._ontap)}}class C{constructor(t){this.options=Object.assign({useAsButton:!1,disabled:!1,comparison:!0,components:{interaction:{}},strings:{},swatches:null,default:"fff",defaultRepresentation:"HEX",position:"middle",adjustableNumbers:!0,showAlways:!1,parent:void 0,closeWithKey:"Escape"},t),this.options.components.interaction||(this.options.components.interaction={}),this._initializingActive=!0,this._recalc=!0,this._color=w(),this._lastColor=w(),this._swatchColors=[],this._eventListener={swatchselect:[],change:[],save:[],init:[]},this._preBuild(),this._buildComponents(),this._bindEvents(),this._representation=this.options.defaultRepresentation,this.setColorRepresentation(this._representation),this._finalBuild(),this._rePositioningPicker();const e=this.options.swatches;e&&e.length&&e.forEach(t=>this.addSwatch(t)),requestAnimationFrame(function t(){if(!this._root.app.offsetParent)return requestAnimationFrame(t.bind(this));this.setColor(this.options.default),this._initializingActive=!1,this._emit("init")}.bind(this))}_preBuild(){const t=this.options;"string"==typeof t.el&&(t.el=document.querySelector(t.el)),this._root=function(t){const e=t.components,o=t.strings,n=t.useAsButton,i=t=>t?"":'style="display:none" hidden',s=l(`\n <div data-key="root" class="pickr">\n \n ${n?"":'<button data-key="button" class="pcr-button"></button>'}\n\n <div data-key="app" class="pcr-app">\n <div class="pcr-selection">\n <div data-con="preview" class="pcr-color-preview" ${i(e.preview)}>\n <button data-key="lastColor" class="pcr-last-color"></button>\n <div data-key="currentColor" class="pcr-current-color"></div>\n </div>\n\n <div data-con="palette" class="pcr-color-palette">\n <div data-key="picker" class="pcr-picker"></div>\n <div data-key="palette" class="pcr-palette"></div>\n </div>\n\n <div data-con="hue" class="pcr-color-chooser" ${i(e.hue)}>\n <div data-key="picker" class="pcr-picker"></div>\n <div data-key="slider" class="pcr-hue pcr-slider"></div>\n </div>\n\n <div data-con="opacity" class="pcr-color-opacity" ${i(e.opacity)}>\n <div data-key="picker" class="pcr-picker"></div>\n <div data-key="slider" class="pcr-opacity pcr-slider"></div>\n </div>\n </div>\n\n <div class="swatches" data-key="swatches"></div> \n\n <div data-con="interaction" class="pcr-interaction" ${i(Object.keys(e.interaction).length)}>\n <input data-key="result" class="pcr-result" type="text" spellcheck="false" ${i(e.interaction.input)}>\n\n <input data-arr="options" class="pcr-type" data-type="HEX" value="HEX" type="button" ${i(e.interaction.hex)}>\n <input data-arr="options" class="pcr-type" data-type="RGBA" value="RGBa" type="button" ${i(e.interaction.rgba)}>\n <input data-arr="options" class="pcr-type" data-type="HSLA" value="HSLa" type="button" ${i(e.interaction.hsla)}>\n <input data-arr="options" class="pcr-type" data-type="HSVA" value="HSVa" type="button" ${i(e.interaction.hsva)}>\n <input data-arr="options" class="pcr-type" data-type="CMYK" value="CMYK" type="button" ${i(e.interaction.cmyk)}>\n\n <input data-key="save" class="pcr-save" value="${o.save||"Save"}" type="button" ${i(e.interaction.save)}>\n <input data-key="clear" class="pcr-clear" value="${o.clear||"Clear"}" type="button" ${i(e.interaction.clear)}>\n </div>\n </div>\n </div>\n `),r=s.interaction;return r.options.find(t=>!t.hidden&&!t.classList.add("active")),r.type=(()=>r.options.find(t=>t.classList.contains("active"))),s}(t),t.useAsButton&&(t.parent||(t.parent="body"),this._root.button=t.el),document.body.appendChild(this._root.root)}_finalBuild(){const t=this.options,e=this._root;document.body.removeChild(e.root),t.parent&&("string"==typeof t.parent&&(t.parent=document.querySelector(t.parent)),t.parent.appendChild(e.app)),t.useAsButton||t.el.parentElement.replaceChild(e.root,t.el),t.disabled&&this.disable(),t.comparison||(e.button.style.transition="none",t.useAsButton||(e.preview.lastColor.style.transition="none")),t.showAlways?e.app.classList.add("visible"):this.hide()}_buildComponents(){const t=this,e=this.options.components,o={palette:k({element:t._root.palette.picker,wrapper:t._root.palette.palette,onchange(e,o){const n=t._color,i=t._root,s=t.options;n.s=e/this.wrapper.offsetWidth*100,n.v=100-o/this.wrapper.offsetHeight*100,n.v<0&&(n.v=0);const r=n.toRGBA().toString();this.element.style.background=r,this.wrapper.style.background=`\n linear-gradient(to top, rgba(0, 0, 0, ${n.a}), transparent), \n linear-gradient(to left, hsla(${n.h}, 100%, 50%, ${n.a}), rgba(255, 255, 255, ${n.a}))\n `,s.comparison||(i.button.style.color=r,s.useAsButton||(i.preview.lastColor.style.color=r)),i.preview.currentColor.style.color=r,t._recalc&&t._updateOutput(),i.button.classList.remove("clear")}}),hue:k({lockX:!0,element:t._root.hue.picker,wrapper:t._root.hue.slider,onchange(n,i){e.hue&&(t._color.h=i/this.wrapper.offsetHeight*360,this.element.style.backgroundColor=`hsl(${t._color.h}, 100%, 50%)`,o.palette.trigger())}}),opacity:k({lockX:!0,element:t._root.opacity.picker,wrapper:t._root.opacity.slider,onchange(o,n){e.opacity&&(t._color.a=Math.round(n/this.wrapper.offsetHeight*100)/100,this.element.style.background=`rgba(0, 0, 0, ${t._color.a})`,t.components.palette.trigger())}}),selectable:A({elements:t._root.interaction.options,className:"active",onchange(e){t._representation=e.target.getAttribute("data-type").toUpperCase(),t._updateOutput()}})};this.components=o}_bindEvents(){const t=this._root,e=this.options,o=[i(t.interaction.clear,"click",()=>this._clearColor()),i(t.preview.lastColor,"click",()=>this.setHSVA(...this._lastColor.toHSVA())),i(t.interaction.save,"click",()=>{!this.applyColor()&&!e.showAlways&&this.hide()}),i(t.interaction.result,["keyup","input"],t=>{this._recalc=!1,this.setColor(t.target.value,!0)&&!this._initializingActive&&this._emit("change",this._color),t.stopImmediatePropagation()}),i([t.palette.palette,t.palette.picker,t.hue.slider,t.hue.picker,t.opacity.slider,t.opacity.picker],["mousedown","touchstart"],()=>this._recalc=!0),i(window,"resize",()=>this._rePositioningPicker)];if(!e.showAlways){const n=e.closeWithKey;o.push(i(t.button,"click",()=>this.isOpen()?this.hide():this.show()),i(document,"keyup",t=>this.isOpen()&&(t.key===n||t.code===n)&&this.hide()),i(document,["touchstart","mousedown"],e=>{this.isOpen()&&!p(e).some(e=>e===t.app||e===t.button)&&this.hide()},{capture:!0}))}e.adjustableNumbers&&h(t.interaction.result,!1),this._eventBindings=o}_rePositioningPicker(){const t=this._root,e=this._root.app;if(this.options.parent){const o=t.button.getBoundingClientRect();e.style.position="fixed",e.style.marginLeft=`${o.left}px`,e.style.marginTop=`${o.top}px`}const o=t.button.getBoundingClientRect(),n=e.getBoundingClientRect(),i=e.style;n.bottom>window.innerHeight?i.top=`${-n.height-5}px`:o.bottom+n.height<window.innerHeight&&(i.top=`${o.height+5}px`);const s={left:-n.width+o.width,middle:-n.width/2+o.width/2,right:0},r=parseInt(getComputedStyle(e).left,10);let a=s[this.options.position];const c=n.left-r+a,l=n.left-r+a+n.width;"middle"!==this.options.position&&(c<0&&-c<n.width/2||l>window.innerWidth&&l-window.innerWidth<n.width/2)?a=s.middle:c<0?a=s.right:l>window.innerWidth&&(a=s.left),i.left=`${a}px`}_updateOutput(){if(this._root.interaction.type()){const t=`to${this._root.interaction.type().getAttribute("data-type")}`;this._root.interaction.result.value="function"==typeof this._color[t]?this._color[t]().toString():""}this._initializingActive||this._emit("change",this._color)}_clearColor(){const t=this._root,e=this.options;e.useAsButton||(t.button.style.color="rgba(0, 0, 0, 0.4)"),t.button.classList.add("clear"),e.showAlways||this.hide(),this._emit("save",null)}_emit(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;n<e;n++)o[n-1]=arguments[n];this._eventListener[t].forEach(t=>t(...o,this))}on(t,e){return"function"==typeof e&&"string"==typeof t&&t in this._eventListener&&this._eventListener[t].push(e),this}off(t,e){const o=this._eventListener[t];if(o){const t=o.indexOf(e);~t&&o.splice(t,1)}return this}addSwatch(t){const e=_(t).values;if(e){const t=this._swatchColors,o=this._root,n=w(...e),s=a(`<button style="color: ${n.toRGBA()}"></button>`);return o.swatches.appendChild(s),t.push({element:s,hsvaColorObject:n}),this._eventBindings.push(i(s,"click",()=>{this.setHSVA(...n.toHSVA(),!0),this._emit("swatchselect",n)})),!0}return!1}removeSwatch(t){if("number"==typeof t){const e=this._swatchColors[t];if(e){const o=e.element;return this._root.swatches.removeChild(o),this._swatchColors.splice(t,1),!0}}return!1}applyColor(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this._root,o=e.preview,n=e.button,i=this._color.toRGBA().toString();o.lastColor.style.color=i,this.options.useAsButton||(n.style.color=i),n.classList.remove("clear"),this._lastColor=this._color.clone(),this._initializingActive||t||this._emit("save",this._color)}destroy(){this._eventBindings.forEach(t=>s(...t)),Object.keys(this.components).forEach(t=>this.components[t].destroy())}destroyAndRemove(){this.destroy();const t=this._root.root;t.parentElement.removeChild(t)}hide(){return this._root.app.classList.remove("visible"),this}show(){if(!this.options.disabled)return this._root.app.classList.add("visible"),this._rePositioningPicker(),this}isOpen(){return this._root.app.classList.contains("visible")}setHSVA(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:360,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const s=this._recalc;if(this._recalc=!1,t<0||t>360||e<0||e>100||o<0||o>100||n<0||n>1)return!1;const r=this.components,a=r.hue,c=r.opacity,l=r.palette,p=a.options.wrapper.offsetHeight*(t/360);a.update(0,p);const h=c.options.wrapper.offsetHeight*n;c.update(0,h);const u=l.options.wrapper,d=u.offsetWidth*(e/100),f=u.offsetHeight*(1-o/100);return l.update(d,f),this._color=w(t,e,o,n),this._recalc=s,this._recalc&&this._updateOutput(),i||this.applyColor(),!0}setColor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null===t)return this._clearColor(),!0;const o=_(t),n=o.values,i=o.type;if(n){const t=i.toUpperCase(),o=this._root.interaction.options,s=o.find(e=>e.getAttribute("data-type")===t);if(!s.hidden)for(const t of o)t.classList[t===s?"add":"remove"]("active");return this.setHSVA(...n,e)}}setColorRepresentation(t){return t=t.toUpperCase(),!!this._root.interaction.options.find(e=>e.getAttribute("data-type")===t&&!e.click())}getColorRepresentation(){return this._representation}getColor(){return this._color}getRoot(){return this._root}disable(){return this.hide(),this.options.disabled=!0,this._root.button.classList.add("disabled"),this}enable(){return this.options.disabled=!1,this._root.button.classList.remove("disabled"),this}}C.utils={once:(t,e,o,n)=>i(t,e,function t(){o.apply(this,arguments),this.removeEventListener(e,t)},n),on:i,off:s,eventPath:p,createElementFromString:a,adjustableInputNumbers:h,removeAttribute:c,createFromTemplate:l},C.create=(t=>new C(t)),C.version="0.4.2";e.default=C}]).default});
|
|
//# sourceMappingURL=pickr.min.js.map
|