vue-pick-colors
Version:
A Color picker for Vue.js 3
2 lines (1 loc) • 47 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@popperjs/core")):"function"==typeof define&&define.amd?define(["exports","vue","@popperjs/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).index={},e.Vue,e.Popperjs)}(this,(function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function a(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function c(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function l(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){c(a,r,o,i,l,"next",e)}function l(e){c(a,r,o,i,l,"throw",e)}i(void 0)}))}}var u={exports:{}},s={exports:{}};!function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(s),function(e){var t=s.exports.default;function n(){e.exports=n=function(){return o},e.exports.__esModule=!0,e.exports.default=e.exports;var r,o={},a=Object.prototype,i=a.hasOwnProperty,c=Object.defineProperty||function(e,t,n){e[t]=n.value},l="function"==typeof Symbol?Symbol:{},u=l.iterator||"@@iterator",s=l.asyncIterator||"@@asyncIterator",f=l.toStringTag||"@@toStringTag";function d(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(r){d=function(e,t,n){return e[t]=n}}function p(e,t,n,r){var o=t&&t.prototype instanceof w?t:w,a=Object.create(o.prototype),i=new I(r||[]);return c(a,"_invoke",{value:B(e,n,i)}),a}function h(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}o.wrap=p;var v="suspendedStart",m="suspendedYield",y="executing",g="completed",b={};function w(){}function x(){}function k(){}var S={};d(S,u,(function(){return this}));var C=Object.getPrototypeOf,E=C&&C(C(L([])));E&&E!==a&&i.call(E,u)&&(S=E);var N=k.prototype=w.prototype=Object.create(S);function O(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,n){function r(o,a,c,l){var u=h(e[o],e,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==t(f)&&i.call(f,"__await")?n.resolve(f.__await).then((function(e){r("next",e,c,l)}),(function(e){r("throw",e,c,l)})):n.resolve(f).then((function(e){s.value=e,c(s)}),(function(e){return r("throw",e,c,l)}))}l(u.arg)}var o;c(this,"_invoke",{value:function(e,t){function a(){return new n((function(n,o){r(e,t,n,o)}))}return o=o?o.then(a,a):a()}})}function B(e,t,n){var o=v;return function(a,i){if(o===y)throw Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:r,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var l=F(c,n);if(l){if(l===b)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var u=h(e,t,n);if("normal"===u.type){if(o=n.done?g:m,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=g,n.method="throw",n.arg=u.arg)}}}function F(e,t){var n=t.method,o=e.iterator[n];if(o===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=r,F(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var a=h(o,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,b;var i=a.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=r),t.delegate=null,b):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,b)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function L(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function t(){for(;++o<e.length;)if(i.call(e,o))return t.value=e[o],t.done=!1,t;return t.value=r,t.done=!0,t};return a.next=a}}throw new TypeError(t(e)+" is not iterable")}return x.prototype=k,c(N,"constructor",{value:k,configurable:!0}),c(k,"constructor",{value:x,configurable:!0}),x.displayName=d(k,f,"GeneratorFunction"),o.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===x||"GeneratorFunction"===(t.displayName||t.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,d(e,f,"GeneratorFunction")),e.prototype=Object.create(N),e},o.awrap=function(e){return{__await:e}},O(A.prototype),d(A.prototype,s,(function(){return this})),o.AsyncIterator=A,o.async=function(e,t,n,r,a){void 0===a&&(a=Promise);var i=new A(p(e,t,n,r),a);return o.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(N),d(N,f,"Generator"),d(N,u,(function(){return this})),d(N,"toString",(function(){return"[object Generator]"})),o.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},o.values=L,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=r)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,o){return c.type="throw",c.arg=e,t.next=n,o&&(t.method="next",t.arg=r),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),u=i.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;P(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=r),b}},o}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(u);var f=u.exports(),d=f;try{regeneratorRuntime=f}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=f:Function("r","regeneratorRuntime = r")(f)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a,i,c=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,o=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return c}}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==i(t)?t:t+""}function v(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=t.defineComponent({name:"Saturation",props:{size:{type:Number,default:160},hue:{type:Number,default:0},saturation:{type:Number,default:0},value:{type:Number,default:0}},emits:["change"],setup:function(e,n){var r=n.emit,o=t.computed((function(){return{width:"".concat(e.size,"px"),height:"".concat(e.size,"px"),background:"hsl(".concat(e.hue,", 100%, 50%)")}}));return{saturationStyle:o,sliderStyle:t.computed((function(){return{top:"".concat((100-e.value)/100*e.size-5,"px"),left:"".concat(e.saturation*e.size/100-5,"px"),width:"".concat(10,"px"),height:"".concat(10,"px")}})),onSelect:function(t){var n=t.target.getBoundingClientRect(),o=n.left,a=n.top,i=function(t){var n,i;t instanceof MouseEvent?(n=t.clientX,i=t.clientY):t instanceof TouchEvent&&(n=t.touches[0].clientX,i=t.touches[0].clientY);var c=n-o,l=i-a;c<0&&(c=0),l<0&&(l=0),c>e.size&&(c=e.size),l>e.size&&(l=e.size);var u=c/e.size*100,s=100-l/e.size*100;r("change",u,s)};i(t);var c=function(){document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",c),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",c)};i(t),t instanceof MouseEvent&&(document.addEventListener("mousemove",i),document.addEventListener("mouseup",c)),t instanceof TouchEvent&&(t.preventDefault(),document.addEventListener("touchmove",i,{passive:!1}),document.addEventListener("touchend",c))}}}});function y(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}y(".saturation[data-v-24517fec]{position:relative}.saturation-black[data-v-24517fec],.saturation-white[data-v-24517fec]{cursor:pointer;height:100%;left:0;position:absolute;top:0;width:100%}.saturation-white[data-v-24517fec]{background:linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.saturation-black[data-v-24517fec]{background:linear-gradient(0deg,#000,transparent)}.slider[data-v-24517fec]{border:1px solid #fff;border-radius:50%;box-shadow:0 0 1px 1px rgba(0,0,0,.3);left:0;pointer-events:none;position:absolute;top:0;z-index:1}"),m.render=function(e,n,r,o,a,i){return t.openBlock(),t.createElementBlock("div",{class:"saturation",style:t.normalizeStyle(e.saturationStyle),onMousedown:n[0]||(n[0]=t.withModifiers((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"])),onTouchstart:n[1]||(n[1]=t.withModifiers((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"]))},[n[2]||(n[2]=t.createElementVNode("div",{class:"saturation-white"},null,-1)),n[3]||(n[3]=t.createElementVNode("div",{class:"saturation-black"},null,-1)),t.createElementVNode("div",{class:"slider",style:t.normalizeStyle(e.sliderStyle)},null,4)],36)},m.__scopeId="data-v-24517fec",m.__file="src/picker/Saturation.vue";var g=t.defineComponent({name:"Hue",props:{width:{type:Number,default:15},height:{type:Number,default:160},hue:{type:Number,default:0}},emits:["change"],setup:function(e,n){var r=n.emit,o=t.computed((function(){return{top:"".concat((1-e.hue/360)*e.height-2,"px"),height:"".concat(4,"px")}})),a=t.ref();t.onMounted((function(){!function(){if(a.value){a.value.width=e.width,a.value.height=e.height;var t=a.value.getContext("2d");if(t){var n=t.createLinearGradient(0,0,0,e.height);n.addColorStop(0,"#FF0000"),n.addColorStop(.17,"#FF00FF"),n.addColorStop(.34,"#0000FF"),n.addColorStop(.51,"#00FFFF"),n.addColorStop(.68,"#00FF00"),n.addColorStop(.17*5,"#FFFF00"),n.addColorStop(1,"#FF0000"),t.fillStyle=n,t.fillRect(0,0,e.width,e.height)}}}()}));return{canvas:a,sliderStyle:o,onSelect:function(t){var n=t.target.getBoundingClientRect().top,o=function(t){var o;t instanceof MouseEvent?o=t.clientY:t instanceof TouchEvent&&(o=t.touches[0].clientY);var a=o-n;a<0&&(a=0),a>e.height&&(a=e.height);var i=-100*a/e.height+100;r("change",360*i/100)},a=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",a)};o(t),t instanceof MouseEvent&&(document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)),t instanceof TouchEvent&&(t.preventDefault(),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",a))}}}}),b={ref:"canvas"};y(".hue[data-v-78b9f4f0]{position:relative;touch-action:none}.slider[data-v-78b9f4f0]{background:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,.3);left:0;pointer-events:none;position:absolute;width:100%;z-index:1}"),g.render=function(e,n,r,o,a,i){return t.openBlock(),t.createElementBlock("div",{class:"hue",onMousedown:n[0]||(n[0]=t.withModifiers((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"])),onTouchstart:n[1]||(n[1]=t.withModifiers((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"]))},[t.createElementVNode("canvas",b,null,512),t.createElementVNode("div",{class:"slider",style:t.normalizeStyle(e.sliderStyle)},null,4)],32)},g.__scopeId="data-v-78b9f4f0",g.__file="src/picker/Hue.vue";var w=t.defineComponent({name:"Alpha",props:{width:{type:Number,default:15},height:{type:Number,default:160},color:{type:String,default:"#000000"},alpha:{type:Number,default:1}},setup:function(e,n){var r=n.emit,o=t.computed((function(){return{top:"".concat(e.alpha*e.height-2,"px"),height:"".concat(4,"px")}})),a=t.ref(),i=function(){var t=a.value.getContext("2d");a.value.width=e.width,a.value.height=e.height;var n=function(e){var t=document.createElement("canvas"),n=t.getContext("2d"),r=2*e;return t.width=r,t.height=r,n.fillStyle="#ffffff",n.fillRect(0,0,r,r),n.fillStyle="#ccd5db",n.fillRect(0,0,e,e),n.fillRect(e,e,e,e),t}(5);t.fillStyle=t.createPattern(n,"repeat"),t.fillRect(0,0,e.width,e.height);var r=t.createLinearGradient(0,0,0,e.height);r.addColorStop(.01,"rgba(255,255,255,0)"),r.addColorStop(.99,e.color),t.fillStyle=r,t.fillRect(0,0,e.width,e.height)};t.watch((function(){return e.color}),(function(){i()})),t.onMounted((function(){i()}));return{canvas:a,sliderStyle:o,onSelect:function(t){var n=t.target.getBoundingClientRect().top,o=function(t){var o;t instanceof MouseEvent?o=t.clientY:t instanceof TouchEvent&&(o=t.touches[0].clientY);var a=o-n;a<0&&(a=0),a>e.height&&(a=e.height);var i=parseFloat((a/e.height).toFixed(2));r("change",i)},a=function(){document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",a)};o(t),t instanceof MouseEvent&&(document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)),t instanceof TouchEvent&&(t.preventDefault(),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",a))}}}}),x={ref:"canvas"};y(".alpha[data-v-24dc9656]{position:relative;touch-action:none}.slider[data-v-24dc9656]{background:#fff;box-shadow:0 0 1px 0 rgba(0,0,0,.3);left:0;pointer-events:none;position:absolute;width:100%;z-index:1}"),w.render=function(e,n,r,o,a,i){return t.openBlock(),t.createElementBlock("div",{class:"alpha",onMousedown:n[0]||(n[0]=t.withModifiers((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"])),onTouchstart:n[1]||(n[1]=t.withModifiers((function(){return e.onSelect&&e.onSelect.apply(e,arguments)}),["prevent","stop"]))},[t.createElementVNode("canvas",x,null,512),t.createElementVNode("div",{class:"slider",style:t.normalizeStyle(e.sliderStyle)},null,4)],32)},w.__scopeId="data-v-24dc9656",w.__file="src/picker/Alpha.vue";var k={rgb:"RGBA",hex:"HEX",hsl:"HSLA",hsv:"HSVA"},S={rgb:"RGB",hex:"HEX",hsl:"HSL",hsv:"HSV"},C={RGB:"rgb",RGBA:"rgb",HEX:"hex",HSL:"hsl",HSLA:"hsl",HSV:"hsv",HSVA:"hsv"};function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var O=null,A=function(e,r,o){var a=t.ref({}),i=o||{},c=i.placement,l=i.defaultStyle,u={strategy:i.strategy||"absolute",placement:c||"auto",onFirstUpdate:function(){O.update()},modifiers:[{name:"offset",options:{offset:[0,5]}},{name:"computeStyles",options:{gpuAcceleration:!1,adaptive:!0}},{name:"flip",options:{allowedAutoPlacements:["top","bottom"]}},{name:"applyStyles",enabled:!1},{name:"updateState",enabled:!0,phase:"write",requires:["computeStyles"],fn:function(e){var t=e.state,n=t.styles,r=t.placement,o=n.popper;a.value=N(N(N({},o),l),{},{transformOrigin:"top"===r?"center bottom":"center top"})}}]};return t.watch((function(){return[t.unref(e),t.unref(r)]}),(function(e,r){var o,a=p(e,2),i=a[0],c=a[1],l=p(r,2),s=l[0],f=l[1];if(i&&c&&(s!==i||f!==s)){null===(o=O)||void 0===o||o.destroy();var d=i.$el||i,h=c.$el||c;t.nextTick((function(){O=n.createPopper(d,h,u)}))}})),t.onBeforeUnmount((function(){var e;O&&(null===(e=O)||void 0===e||e.destroy(),O=null)})),{instance:O,style:a}},B=t.defineComponent({props:{value:{type:String,default:"RGBA"},showAlpha:{type:Boolean},options:{type:[Boolean,Array]}},emits:["change"],setup:function(e,n){var r=n.emit,o=t.ref(null),a=t.ref(null),i=t.ref(!1),c=A(o,a,{strategy:"fixed",defaultStyle:{zIndex:2}}).style,l=t.computed((function(){return Array.isArray(e.options)&&e.options.length>1})),u=t.computed((function(){var t=e.options,n=e.showAlpha,r=e.value;return Array.isArray(t)?n?t.map((function(e){return k[e]})).filter((function(e){return!e.includes(r)})):t.map((function(e){return S[e]})).filter((function(e){return!e.includes(r)})):[]})),s=function(e){var n,r,a=e.target;!(null!==(n=t.unref(o))&&void 0!==n&&n.isEqualNode(a))&&(null===(r=t.unref(o))||void 0===r?void 0:r.contains(a))||(i.value=!1)};return t.onMounted((function(){document.addEventListener("mouseup",s,!1)})),t.onUnmounted((function(){document.removeEventListener("mouseup",s,!1)})),{targetRef:o,selectorRef:a,selectorStyle:c,isShowSelector:i,isNeedSelect:l,formatOptions:u,onShow:function(){l.value&&(i.value=!0)},onFormatChange:function(e){r("change",C[e])}}}}),F={class:"format"},_={key:0,class:"arrow"},P=["onClick"];y(".format[data-v-5f6e8f5e]{position:relative}.label[data-v-5f6e8f5e]{align-items:center;background:#e7e8e9;color:#999;display:flex;float:left;font-weight:500;height:30px;justify-content:center;position:relative;width:60px}[pick-colors-theme=dark] .label[data-v-5f6e8f5e]{background:#252930;color:#999}.arrow[data-v-5f6e8f5e]{height:6px;margin-bottom:4px;margin-left:5px;transform:rotate(135deg);width:6px}.arrow[data-v-5f6e8f5e],[pick-colors-theme=dark] .arrow[data-v-5f6e8f5e]{border-right:1px solid #999;border-top:1px solid #999}.selector[data-v-5f6e8f5e]{align-items:center;background:#f7f8f9;border-radius:5px;box-shadow:0 0 16px 0 rgba(0,0,0,.16);cursor:pointer;display:flex;flex-direction:column;font-weight:400;justify-content:center;padding:4px}[pick-colors-theme=dark] .selector[data-v-5f6e8f5e]{background:#252930;color:#999}.selector-item[data-v-5f6e8f5e]{align-items:center;display:flex;height:30px;justify-content:center;width:60px}.selector-item[data-v-5f6e8f5e]:hover{background:#e1f2fe}[pick-colors-theme=dark] .selector-item[data-v-5f6e8f5e]{color:#fff}[pick-colors-theme=dark] .selector-item[data-v-5f6e8f5e]:hover{background:#0087fa}.active-selector-item[data-v-5f6e8f5e]{background:#e1f2fe}[pick-colors-theme=dark] .active-selector-item[data-v-5f6e8f5e]{background:#0087fa}.v-enter-active[data-v-5f6e8f5e],.v-leave-active[data-v-5f6e8f5e]{opacity:1;transform:scaleY(1);transform-origin:center top;transition:opacity .2s ease-in-out,transform .2s ease-in-out}.v-enter-from[data-v-5f6e8f5e],.v-leave-to[data-v-5f6e8f5e]{opacity:0;transform:scaleY(0)}"),B.render=function(e,n,r,o,a,i){return t.openBlock(),t.createElementBlock("div",F,[t.createElementVNode("div",{class:"label",ref:"targetRef",onClick:n[0]||(n[0]=function(){return e.onShow&&e.onShow.apply(e,arguments)})},[t.createElementVNode("span",null,t.toDisplayString(e.value),1),e.isNeedSelect?(t.openBlock(),t.createElementBlock("div",_)):t.createCommentVNode("v-if",!0)],512),t.createVNode(t.Transition,null,{default:t.withCtx((function(){return[e.isShowSelector?(t.openBlock(),t.createElementBlock("div",{key:0,class:"selector",ref:"selectorRef",style:t.normalizeStyle(e.selectorStyle)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.formatOptions,(function(n){return t.openBlock(),t.createElementBlock("div",{class:"selector-item",key:n,onClick:function(t){return e.onFormatChange(n)}},t.toDisplayString(n),9,P)})),128))],4)):t.createCommentVNode("v-if",!0)]})),_:1})])},B.__scopeId="data-v-5f6e8f5e",B.__file="src/picker/input-value/FormatValue.vue";var I=t.defineComponent({name:"Input",components:{FormatValue:B},props:{format:{type:String,default:"RGBA"},value:{type:String,default:""},width:{type:Number},showAlpha:{type:Boolean},formatOptions:{type:[Boolean,Array]}},emits:["change","focus","blur","enter","formatChange"],setup:function(e,n){var r=n.emit;return{onInput:function(e){var t;r("change",null===(t=e.target)||void 0===t?void 0:t.value)},valueStyle:t.computed((function(){return{minWidth:"".concat(e.width,"px"),maxWidth:"".concat(e.width,"px"),width:"".concat(e.width,"px")}})),onFocus:function(){r("focus")},onBlur:function(){r("blur")},onEnter:function(){r("enter")},onFormatChange:function(e){r("formatChange",e)}}}}),L={class:"input"},j=[".value"];function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}y(".input[data-v-2c454c00]{display:flex;font-size:12px}.value[data-v-2c454c00]{background:#eceef0;border:1px solid #eceef0;box-sizing:border-box;color:#666;flex:1;height:30px;text-align:center}[pick-colors-theme=dark] .value[data-v-2c454c00]{background:#2e333a;border:1px solid #2e333a;color:#fff}.value[data-v-2c454c00]:focus{border:1px solid #1890ff;outline:none}"),I.render=function(e,n,r,o,a,i){var c=t.resolveComponent("FormatValue");return t.openBlock(),t.createElementBlock("div",L,[t.createVNode(c,{value:e.format,showAlpha:e.showAlpha,options:e.formatOptions,onChange:e.onFormatChange},null,8,["value","showAlpha","options","onChange"]),t.createElementVNode("input",{class:"value",style:t.normalizeStyle(e.valueStyle),".value":e.value,onFocus:n[0]||(n[0]=function(){return e.onFocus&&e.onFocus.apply(e,arguments)}),onInput:n[1]||(n[1]=function(){return e.onInput&&e.onInput.apply(e,arguments)}),onBlur:n[2]||(n[2]=function(){return e.onBlur&&e.onBlur.apply(e,arguments)}),onKeydown:n[3]||(n[3]=t.withKeys((function(){return e.onEnter&&e.onEnter.apply(e,arguments)}),["enter"]))},null,44,j)])},I.__scopeId="data-v-2c454c00",I.__file="src/picker/input-value/InputValue.vue";var z=function(e,t,n){return[e,t*n/((e=(2-t)*n)<1?e:2-e)||0,e/2]},T={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"},R=function(e){e=Math.min(Math.round(e),255);var t=Math.floor(e/16),n=e%16;return"".concat(T[t]||t).concat(T[n]||n)},D=function(e){var t=e.r,n=e.g,r=e.b;return isNaN(t)||isNaN(n)||isNaN(r)?"":"#".concat(R(t)).concat(R(n)).concat(R(r))},H=function(e,t){var n;"string"==typeof(n=e)&&-1!==n.indexOf(".")&&1===parseFloat(n)&&(e="100%");var r=function(e){return"string"==typeof e&&-1!==e.indexOf("%")}(e);return e=Math.min(t,Math.max(0,parseFloat("".concat(e)))),r&&(e=parseInt("".concat(e*t),10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)},G=function(e,t,n){e=6*H(e,360),t=H(t,100),n=H(n,100);var r=Math.floor(e),o=e-r,a=n*(1-t),i=n*(1-o*t),c=n*(1-(1-o)*t),l=r%6,u=[n,i,a,a,c,n][l],s=[c,n,n,i,a,a][l],f=[a,a,c,n,n,i][l];return{r:Math.round(255*u),g:Math.round(255*s),b:Math.round(255*f)}},Y=function(e,t,n){var r,o,a=e.h,i=e.s,c=e.v,l=e.a;if(n)switch(["hsl","hsv","rga"].includes(t)&&(l=(o=(r=l).toString().match(/\.(\d{1,2})(\d*)/))&&o[2].length>0?parseFloat(r.toFixed(2)):r),t){case"hsl":var u=z(a,i/100,c/100);return"hsla(".concat(a.toFixed(0),", ").concat(Math.round(100*u[1]),"%, ").concat(Math.round(100*u[2]),"%, ").concat(l,")");case"hsv":return"hsva(".concat(a.toFixed(0),", ").concat(Math.round(i),"%, ").concat(Math.round(c),"%, ").concat(l,")");case"rgb":var s=G(a,i,c),f=s.r,d=s.g,p=s.b;return"rgba(".concat(f,", ").concat(d,", ").concat(p,", ").concat(l,")");default:return"".concat(D(G(a,i,c))).concat(R(255*l))}else switch(t){case"hsl":var h=z(a,i/100,c/100);return"hsl(".concat(a.toFixed(0),", ").concat(Math.round(100*h[1]),"%, ").concat(Math.round(100*h[2]),"%)");case"hsv":return"hsv(".concat(a.toFixed(0),", ").concat(Math.round(i),"%, ").concat(Math.round(c),"%)");case"rgb":var v=G(a,i,c),m=v.r,y=v.g,g=v.b;return"rgb(".concat(m,", ").concat(y,", ").concat(g,")");default:return D(G(a,i,c))}},$=function(e){var t=e.r,n=e.g,r=e.b;t=H(t,255),n=H(n,255),r=H(r,255);var o,a=Math.max(t,n,r),i=Math.min(t,n,r),c=a,l=a-i,u=0===a?0:l/a;if(a===i)o=0;else{switch(a){case t:o=(n-r)/l+(n<r?6:0);break;case n:o=(r-t)/l+2;break;case r:o=(t-n)/l+4}o/=6}return{h:360*o,s:100*u,v:100*c}},U=function(e){var t=e.h,n=e.s,r=e.l;r/=100;var o=n/=100,a=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,o*=a<=1?a:2-a,{h:+t,s:100*(0===r?2*o/(a+o):2*n/(r+n)),v:100*((r+n)/2)}},q=function(e){var t=[];if(e.match(/^#([0-9a-fA-f]{3,4})$/g))for(var n=1;n<e.length;n++)t.push(parseInt("0x"+e[n].repeat(2)));else if(e.match(/^#([0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/g))for(var r=1;r<e.length;r+=2)t.push(parseInt("0x"+e.slice(r,r+2)));return{r:t[0],g:t[1],b:t[2],a:t[3]}},X=function(e,t,n){if("string"==typeof e&&""!==e){var r=Q(e,Z(e),n),o=ee(r);return null==o?"":Y(o,t,n)}return""},J=function(e){var t=p(e.match(/(\d(\.\d+)?)+/g),4);return{r:t[0],g:t[1],b:t[2],a:t[3]}},K=function(e){var t=p(e.match(/(\d(\.\d+)?)+/g),4),n=t[0],r=t[1],o=t[2],a=t[3];return{h:n,s:parseFloat(r),l:parseFloat(o),a:a}},W=function(e){var t=p(e.match(/(\d(\.\d+)?)+/g),4),n=t[0],r=t[1],o=t[2],a=t[3];return{h:parseFloat(n),s:parseFloat(r),v:parseFloat(o),a:parseFloat(a)}},Q=function(e,t){if(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])switch(t){case"rgb":var n=J(e),r=n.r,o=n.g,a=n.b,i=n.a;return V(V({},$({r:r,g:o,b:a})),{},{a:+i});case"hsv":var c=W(e);return{h:c.h,s:c.s,v:c.v,a:c.a};case"hsl":var l=K(e),u=l.h,s=l.s,f=l.l,d=l.a;return V(V({},U({h:u,s:s,l:f})),{},{a:+d});default:var p=q(e),h=p.r,v=p.g,m=p.b,y=p.a;return V(V({},$({r:h,g:v,b:m})),{},{a:y/255})}else{switch(t){case"rgb":return V(V({},$(J(e))),{},{a:1});case"hsv":var g=W(e);return{h:g.h,s:g.s,v:g.v,a:1};case"hsl":return V(V({},U(K(e))),{},{a:1});default:return V(V({},$(q(e))),{},{a:1})}}},Z=function(e){return e.match(/^#/)?"hex":e.match(/^rgb/)?"rgb":e.match(/^hsl/)?"hsl":e.match(/^hsv/)?"hsv":"hex"},ee=function(e){var t=e.h,n=e.s,r=e.v,o=e.a;return isNaN(t)&&isNaN(n)&&isNaN(r)?null:(isNaN(t)&&(t=0),isNaN(n)&&(n=0),isNaN(r)&&(r=0),isNaN(o)&&(o=1),{h:t,s:n,v:r,a:o})},te=t.defineComponent({name:"ColorItem",props:{size:{type:[Number,String],default:20},width:{type:[Number,String]},height:{type:[Number,String]},value:{type:String,default:""},border:{type:Boolean,default:!0},borderRadius:{type:Number,default:5},selected:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1}},emits:["select"],setup:function(e){var n=t.ref(),r=t.inject("theme",{theme:"light"}).theme,o=t.computed((function(){return parseFloat((e.width||e.size)+"")})),a=t.computed((function(){return parseFloat((e.height||e.size)+"")})),i=t.computed((function(){return{width:"".concat(t.unref(o),"px"),height:"".concat(t.unref(a),"px"),border:e.border?"1px solid ".concat("dark"===t.unref(r)?"#434345":"#d9d9d9"):"",borderRadius:"".concat(e.borderRadius,"px"),boxShadow:e.selected?"0 0 3px 2px ".concat("dark"===t.unref(r)?"#2681ff":"#1890ff"):""}})),c=function(){var r=n.value.getContext("2d");n.value.width=t.unref(o),n.value.height=t.unref(a);var i=function(e){var t=document.createElement("canvas"),n=t.getContext("2d"),r=2*e;return t.width=r,t.height=r,n.fillStyle="#ffffff",n.fillRect(0,0,r,r),n.fillStyle="#ccd5db",n.fillRect(0,0,e,e),n.fillRect(e,e,e,e),t}(5);r.fillStyle=r.createPattern(i,"repeat"),r.fillRect(0,0,t.unref(o),t.unref(a)),r.fillStyle=e.value,r.fillRect(0,0,t.unref(o),t.unref(a))};return t.watch((function(){return e.value}),(function(){c()})),t.onMounted((function(){c()})),{canvas:n,colorItemStyle:i}}}),ne=["draggable"];y(".color-item[data-v-02da71fd]{display:inline-block;vertical-align:top}"),te.render=function(e,n,r,o,a,i){return t.openBlock(),t.createElementBlock("canvas",{class:"color-item",style:t.normalizeStyle(e.colorItemStyle),ref:"canvas",draggable:e.draggable},null,12,ne)},te.__scopeId="data-v-02da71fd",te.__file="src/color-item/ColorItem.vue";var re=t.defineComponent({name:"Colors",components:{ColorItem:te},props:{colors:{type:Array,default:function(){return[]}},selectedIndex:{type:Number,default:-1}},emits:["change"],setup:function(e,n){var r=n.emit;return{onSelectColor:function(e,t){r("change",e,t)},useColors:t.computed((function(){return e.colors.map((function(e){return X(e,"hex",!0)}))}))}}}),oe={class:"colors"};function ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ie(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ae(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}y(".colors[data-v-0f8b52a8]{align-items:center;display:flex;flex-wrap:wrap;margin-top:5px}.color-item[data-v-0f8b52a8]{margin:5px}"),re.render=function(e,n,r,o,a,i){var c=t.resolveComponent("color-item");return t.openBlock(),t.createElementBlock("div",oe,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.useColors,(function(n,r){return t.openBlock(),t.createBlock(c,{key:r,class:"color-item",size:16,value:n,border:!1,"border-radius":3,selected:e.selectedIndex===r,onClick:t.withModifiers((function(t){return e.onSelectColor(n,+r)}),["stop","prevent"])},null,8,["value","selected","onClick"])})),128))])},re.__scopeId="data-v-0f8b52a8",re.__file="src/picker/Colors.vue";var ce=t.defineComponent({name:"Picker",components:{Colors:re,Saturation:m,Hue:g,Alpha:w,InputValue:I},props:{format:{type:String,default:"hex"},showAlpha:{type:Boolean,default:!1},value:{type:String,default:""},colors:{type:Array,default:function(){return[]}},style:{type:Object,default:function(){return{}}},formatOptions:{type:[Boolean,Array]}},emits:["change","formatChange"],setup:function(e,n){var r=n.emit,o=t.computed((function(){return ie(ie({},e.style),{},{width:e.showAlpha?"230px":"205px"})})),a=t.ref(),i=t.ref(),c=t.ref(),l=function(){var t,n=null===(t=e.value)||void 0===t?void 0:t.trim();if(null!=n&&""!==n){var r=Z(n);return ee(Q(n,r,e.showAlpha))}return null};t.watch((function(){return e.value}),(function(){e.value!==t.unref(c)&&(a.value=l())}),{immediate:!0}),t.watch((function(){return[t.unref(a),e.format]}),(function(t){var n=p(t,2),o=n[0],a=n[1],u="";null!=o?(u=Y(ie({},o),e.format,e.showAlpha),i.value=ie({},o)):i.value=null,c.value=u;var s=l();JSON.stringify(o)!==JSON.stringify(s)&&JSON.stringify(o)!==JSON.stringify(a)&&r("change",u)}),{immediate:!0});var u=t.computed((function(){var e;return(null===(e=t.unref(a))||void 0===e?void 0:e.h)||0})),s=t.computed((function(){var e;return(null===(e=t.unref(a))||void 0===e?void 0:e.s)||0})),f=t.computed((function(){var e;return(null===(e=t.unref(a))||void 0===e?void 0:e.v)||0})),d=t.computed((function(){var e,n;return null!=(null===(e=t.unref(a))||void 0===e?void 0:e.a)?null===(n=t.unref(a))||void 0===n?void 0:n.a:1})),h=t.computed((function(){return G(t.unref(u),t.unref(s),t.unref(f))})),v=t.computed((function(){return"rgb(".concat(t.unref(h).r,", ").concat(t.unref(h).g,", ").concat(t.unref(h).b,")")})),m=t.ref(-1);return{h:u,s:s,v:f,a:d,rgbStr:v,onSelectSaturation:function(e,n){m.value=-1,null==t.unref(a)?a.value={h:t.unref(u),s:e,v:n,a:t.unref(d)}:a.value=ie(ie({},t.unref(a)),{},{s:e,v:n})},onSelectHue:function(e){m.value=-1,null==t.unref(a)&&(a.value={h:e,s:t.unref(s),v:t.unref(f),a:t.unref(d)}),a.value=ie(ie({},t.unref(a)),{},{h:e})},onSelectAlpha:function(e){m.value=-1,null==t.unref(a)?a.value={h:t.unref(u),s:t.unref(s),v:t.unref(f),a:e}:a.value=ie(ie({},t.unref(a)),{},{a:e})},handleInputFormat:function(t){return e.showAlpha?k[t]:S[t]},colorValue:c,pickerStyle:o,onInputChange:function(e){m.value=-1,c.value=e},handleChange:function(){var n,r=null===(n=t.unref(c))||void 0===n?void 0:n.trim();if(""!==r){var o=e.showAlpha,l=Z(r),u=ee(Q(r,l,o)),s=function(e){if(!e)return!1;var t=e.h,n=e.s,r=e.v,o=e.a;return!(isNaN(t)||isNaN(n)||isNaN(r)||isNaN(o))}(u);s?a.value=u:null!=t.unref(i)?a.value=t.unref(i):c.value=""}else a.value=null},selectColorIndex:m,onSelectColor:function(e,t){if(m.value=t,""===(e=e.trim()))a.value=null;else{var n=Z(e);n?function(e,t,n){if(0!==e.length){var r=Q(e,t,n),o=r.h,i=r.s,c=r.v;if(!(isNaN(o)||isNaN(i)||isNaN(c))){var l=1,u=r.a;isNaN(u)||(l=u),a.value={h:o,s:i,v:c,a:l}}}}(e,n,!0):a.value=null}},onFormatChange:function(e){r("formatChange",e)}}}}),le={class:"picker-inner"},ue={class:"picker-header"};y(".picker[data-v-6ceadec6]{background:#f7f8f9;border-radius:4px;box-shadow:0 0 16px 0 rgba(0,0,0,.16)}.picker-inner[data-v-6ceadec6]{padding:10px}[pick-colors-theme=dark] .picker-inner[data-v-6ceadec6]{background:#1d2024;box-shadow:0 0 16px 0 rgba(0,0,0,.16)}.picker-header[data-v-6ceadec6]{display:flex;margin-bottom:5px}.alpha[data-v-6ceadec6],.hue[data-v-6ceadec6]{margin-left:10px}.colors[data-v-6ceadec6]{margin-top:5px}"),ce.render=function(e,n,r,o,a,i){var c=t.resolveComponent("saturation"),l=t.resolveComponent("hue"),u=t.resolveComponent("alpha"),s=t.resolveComponent("input-value"),f=t.resolveComponent("Colors");return t.openBlock(),t.createElementBlock("div",{class:"picker",style:t.normalizeStyle(e.pickerStyle)},[t.createElementVNode("div",le,[t.createElementVNode("div",ue,[t.createVNode(c,{class:"saturation",hue:e.h,saturation:e.s,value:e.v,onChange:e.onSelectSaturation},null,8,["hue","saturation","value","onChange"]),t.createVNode(l,{class:"hue",hue:e.h,onChange:e.onSelectHue},null,8,["hue","onChange"]),e.showAlpha?(t.openBlock(),t.createBlock(u,{key:0,class:"alpha",alpha:e.a,color:e.rgbStr,onChange:e.onSelectAlpha},null,8,["alpha","color","onChange"])):t.createCommentVNode("v-if",!0)]),t.createVNode(s,{format:e.handleInputFormat(e.format),value:e.colorValue,showAlpha:e.showAlpha,width:e.showAlpha?150:125,formatOptions:e.formatOptions,onChange:e.onInputChange,onBlur:e.handleChange,onEnter:e.handleChange,onFormatChange:e.onFormatChange},null,8,["format","value","showAlpha","width","formatOptions","onChange","onBlur","onEnter","onFormatChange"]),e.colors.length>0?(t.openBlock(),t.createBlock(f,{key:0,class:"colors",colors:e.colors,"selected-index":e.selectColorIndex,onChange:e.onSelectColor},null,8,["colors","selected-index","onChange"])):t.createCommentVNode("v-if",!0)])],4)},ce.__scopeId="data-v-6ceadec6",ce.__file="src/picker/Picker.vue";var se=t.defineComponent({name:"AddColorItem",props:{size:{type:Number,default:20},selected:{type:Boolean,default:!1}},setup:function(e){var n=t.inject("theme",{theme:"light"}).theme;return{addColorItemStyle:t.computed((function(){return{width:"".concat(e.size,"px"),height:"".concat(e.size,"px"),lineHeight:"".concat(e.size,"px"),boxShadow:e.selected?"0 0 3px 2px ".concat("dark"===t.unref(n)?"#2681ff":"#1890ff"):""}}))}}});y(".add-color-item[data-v-ceb1719c]{background:#fff;border:1px solid #d9d9d9;border-radius:5px;vertical-align:top}.container[data-v-ceb1719c]{pointer-events:none;transform:scale(.9);transform-origin:center}[pick-colors-theme=dark] .add-color-item[data-v-ceb1719c]{background:#141414;border:1px solid #434343}path[data-v-ceb1719c]{fill:#000}[pick-colors-theme=dark] path[data-v-ceb1719c]{fill:#fff}"),se.render=function(e,n,r,o,a,i){return t.openBlock(),t.createElementBlock("svg",{class:"add-color-item",style:t.normalizeStyle(e.addColorItemStyle),viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg"},n[0]||(n[0]=[t.createElementVNode("g",{class:"container"},[t.createElementVNode("path",{d:"M544 464V160h-80v304H160v80h304v304h80V544h304v-80z"})],-1)]),4)},se.__scopeId="data-v-ceb1719c",se.__file="src/add-color-item/AddColorItem.vue";var fe=t.defineComponent({name:"ColorPicker",components:{ColorItem:te,Picker:ce,AddColorItem:se},props:{value:{type:[String,Array]},theme:{type:String,default:"light"},size:{type:[Number,String],default:20},width:{type:[Number,String]},height:{type:[Number,String]},format:{type:String},showPicker:{type:Boolean,default:void 0},showAlpha:{type:Boolean,default:!1},addColor:{type:Boolean,default:!1},deleteColor:{type:Boolean,default:!0},max:{type:Number,default:13},popupContainer:{type:[String,Object,Boolean],default:"body"},zIndex:{type:Number,default:1e3},colors:{type:Array,default:function(){return["#ff4500","#ff8c00","#ffd700","#90ee90","#00ced1","#1e90ff","#c71585","#ff4500","#ff7d4d","#00babd","#1f93ff","#fa64c3"]}},position:{type:String},placement:{type:String},formatOptions:{type:[Boolean,Array],default:!1}},emits:["change","update:value","update:showPicker","overflowMax","closePicker","formatChange"],setup:function(e,n){var r=n.emit,o=t.ref([]),c=t.computed((function(){return t.unref(o).map((function(t){return X(t,"hex",e.showAlpha)}))})),u=t.ref("hex");t.watch((function(){return e.format}),(function(){u.value=e.format}),{immediate:!0});t.watch((function(){return e.value}),(function(){var n=e.value||"",r=Array.isArray(n)?n:[n];o.value=r.map((function(n){return X(n,t.unref(u),e.showAlpha)}))}),{immediate:!0});var s=t.ref(void 0),f=t.computed((function(){return t.unref(o)[t.unref(s)]})),p=t.ref(!1);t.watch((function(){return e.showPicker}),(function(){p.value=e.showPicker}),{immediate:!0});var h,v,m=t.ref(null),y=t.ref(null),g=A(m,y,{defaultStyle:{zIndex:e.zIndex},strategy:e.position,placement:e.placement}).style,b=function(){null==t.unref(m)&&(m.value=t.unref(F)[0]),null==t.unref(s)&&(s.value=0),void 0===e.showPicker?p.value=!0:r("update:showPicker",!0)},w=function(){s.value=void 0,void 0===e.showPicker?p.value=!1:r("update:showPicker",!1),r("closePicker",t.toRaw(Array.isArray(e.value)||e.addColor?t.unref(o):t.unref(o)[0]))},x=t.ref(),k=function(){var e=l(d.mark((function e(n){var r,o,a,i;return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.target,null!=(a=null===(r=o.dataset)||void 0===r?void 0:r.index)&&""!==a){e.next=4;break}return e.abrupt("return");case 4:if(i=+a,t.unref(s)!==i){e.next=7;break}return e.abrupt("return");case 7:null!=t.unref(s)&&t.unref(s)!==i?(w(),h&&clearTimeout(h),h=setTimeout((function(){b(),clearTimeout(h)}),100)):b(),s.value=i,m.value=o;case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),S=function(){var e=l(d.mark((function e(n){var r,o,a,i,c;return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.target,!(!(null!==(r=t.unref(x))&&void 0!==r&&r.isEqualNode(i))&&(null===(o=t.unref(x))||void 0===o?void 0:o.contains(i)))){e.next=4;break}return e.abrupt("return");case 4:if(c=null===(a=t.unref(y))||void 0===a?void 0:a.$el,!((null==c?void 0:c.contains(i))||!1)){e.next=8;break}return e.abrupt("return");case 8:v&&clearTimeout(v),v=setTimeout((function(){t.unref(p)&&w()}),0);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();t.watch(p,(function(){t.unref(p)&&(b(),clearTimeout(v))}));var C,E=t.ref(e.max>t.unref(o).length),N=t.computed((function(){return"string"==typeof e.popupContainer||"object"===i(e.popupContainer)&&null!=e.popupContainer?e.popupContainer:"body"})),O=t.computed((function(){return"boolean"==typeof e.popupContainer&&!1===e.popupContainer})),B=t.computed((function(){return e.theme}));t.watch((function(){return[e.theme,t.unref(y)]}),(function(){t.nextTick((function(){var e,n;null===(e=t.unref(x))||void 0===e||e.setAttribute("pick-colors-theme",t.unref(B)),null===(n=t.unref(y))||void 0===n||null===(n=n.$el)||void 0===n||n.setAttribute("pick-colors-theme",t.unref(B))}))}),{immediate:!0}),t.provide("theme",{theme:B});var F=t.ref([]);return t.onMounted((function(){document.addEventListener("mouseup",S,!1),e.showPicker&&b()})),t.onUnmounted((function(){document.removeEventListener("mouseup",S,!1),h&&(clearTimeout(h),h=null),v&&(clearTimeout(v),v=null)})),{valueList:o,colorItemSelected:function(n){return(e.addColor?t.unref(o).length>0:t.unref(o).length>1)&&t.unref(s)===n},selectedColor:f,selectedIndex:s,isShowPicker:p,addColorItemShow:E,onPickerChange:function(n){var a=t.unref(s),i=t.unref(o).slice(),c=t.unref(o).length;if(null!=a){a>=0?i[a]=n:(s.value=c,i.push(n));var l="";l=Array.isArray(e.value)||e.addColor?i:n,o.value=Array.isArray(l)?l:[l],r("update:value",l),r("change",l,n,a),e.addColor&&c>=e.max&&(E.value=!1,r("overflowMax"))}},colorPicker:x,onColorClick:k,pickerRef:y,onColorItemDragStart:function(e){e.dataTransfer.effectAllowed="move";var t=e.target;C=+t.dataset.index},onColorItemDragOver:function(e){},onColorItemDrop:function(e){var n=+e.target.dataset.index,i=a(t.unref(o)),c=i[C];i.splice(C,1);var l=i.slice(0,n),u=i.splice(n),s=l.concat([c]).concat(u);r("update:value",s),r("change",s,s[C],C)},colorItemsRef:F,pickerStyle:g,values:c,teleportDisabled:O,toPopupContainer:N,formatValue:u,onFormatChange:function(e){u.value=e,r("formatChange",e)}}}});y(".color-picker[data-v-3c43ade8]{display:inline-block}.color-item[data-v-3c43ade8]{margin:5px}.add-color-item[data-v-3c43ade8]{display:inline-block;margin:5px}.picker[data-v-3c43ade8]{overflow:hidden}.v-enter-active[data-v-3c43ade8],.v-leave-active[data-v-3c43ade8]{opacity:1;transform:scaleY(1);transform-origin:center top;transition:opacity .2s ease-in-out,transform .2s ease-in-out}.v-enter-from[data-v-3c43ade8],.v-leave-to[data-v-3c43ade8]{opacity:0;transform:scaleY(0)}"),fe.render=function(e,n,r,o,a,i){var c=t.resolveComponent("color-item"),l=t.resolveComponent("add-color-item"),u=t.resolveComponent("picker");return t.openBlock(),t.createElementBlock("div",{class:"color-picker",ref:"colorPicker",onDragstart:n[0]||(n[0]=t.withModifiers((function(){return e.onColorItemDragStart&&e.onColorItemDragStart.apply(e,arguments)}),["stop"])),onDragover:n[1]||(n[1]=t.withModifiers((function(){return e.onColorItemDragOver&&e.onColorItemDragOver.apply(e,arguments)}),["prevent","stop"])),onDrop:n[2]||(n[2]=t.withModifiers((function(){return e.onColorItemDrop&&e.onColorItemDrop.apply(e,arguments)}),["prevent","stop"])),onClick:n[3]||(n[3]=t.withModifiers((function(){return e.onColorClick&&e.onColorClick.apply(e,arguments)}),["stop"]))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.values,(function(n,r){return t.openBlock(),t.createBlock(c,{class:"color-item",key:r,ref_for:!0,ref:function(t){return e.colorItemsRef[r]=t},size:e.size,width:e.width,height:e.height,value:n,selected:e.colorItemSelected(r),"data-index":r,draggable:e.valueList.length>1,format:e.formatValue},null,8,["size","width","height","value","selected","data-index","draggable","format"])})),128)),e.addColor&&e.addColorItemShow?(t.openBlock(),t.createBlock(l,{key:0,class:"add-color-item",ref:"addColorItem",selected:e.colorItemSelected(-1),"data-index":-1},null,8,["selected"])):t.createCommentVNode("v-if",!0),(t.openBlock(),t.createBlock(t.Teleport,{to:e.toPopupContainer,disabled:e.teleportDisabled},[t.createVNode(t.Transition,null,{default:t.withCtx((function(){return[e.isShowPicker?(t.openBlock(),t.createBlock(u,{key:0,class:"picker",style:t.normalizeStyle(e.pickerStyle),ref:"pickerRef",value:e.selectedColor,format:e.formatValue,"show-alpha":e.showAlpha,colors:e.colors,formatOptions:e.formatOptions,onChange:e.onPickerChange,onFormatChange:e.onFormatChange},null,8,["style","value","format","show-alpha","colors","formatOptions","onChange","onFormatChange"])):t.createCommentVNode("v-if",!0)]})),_:1})],8,["to","disabled"]))],544)},fe.__scopeId="data-v-3c43ade8",fe.__file="src/ColorPicker.vue",e.ALPHA_FORMAT_MAP=k,e.FORMAT_MAP=S,e.FORMAT_VALUE_MAP=C,e.default=fe,Object.defineProperty(e,"__esModule",{value:!0})}));