diff --git a/dist/vanilla-picker.js b/dist/vanilla-picker.js index 2234e3c..2432c1d 100644 --- a/dist/vanilla-picker.js +++ b/dist/vanilla-picker.js @@ -1,5 +1,5 @@ /*! - * vanilla-picker v2.0.0 + * vanilla-picker v2.0.1 * https://github.com/Sphinxxxx/vanilla-picker * * Copyright 2017-2018 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate) @@ -530,7 +530,7 @@ var BG_TRANSP = 'url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/s var HUES = 360; document.documentElement.firstElementChild -.appendChild(document.createElement('style')).textContent = '.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em;box-sizing:border-box;background:#f2f2f2;cursor:default;pointer-events:auto}.picker_wrapper>*{margin:.5em}.picker_wrapper::before{content:\'\';display:block;width:100%;order:1}.picker_slider,.picker_selector{padding:1em}.picker_hue{width:100%}.picker_sl{flex:1 1 auto}.picker_sl::before{content:\'\';display:block;padding-bottom:100%}.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_sample{order:1;flex:1 1 auto;min-height:3em}.picker_done{order:1;width:3rem;height:2rem}.picker_selector{position:absolute;z-index:1;display:block;transform:translate(-50%, -50%);border:2px solid white;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);outline:1px solid silver}.picker_sl{position:relative;outline:1px solid silver;background-image:linear-gradient(180deg, white, rgba(255,255,255,0) 50%),linear-gradient(0deg, black, transparent 50%),linear-gradient(90deg, gray, rgba(128,128,128,0))}.picker_alpha,.picker_sample{position:relative;background:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'2\' height=\'2\'%3E%3Cpath d=\'M1,0H0V1H2V2H1\' fill=\'lightgrey\'/%3E%3C/svg%3E") left top/contain white;outline:1px solid silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_sample::before{content:\'\';position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_done{font:inherit;font-family:sans-serif;box-sizing:border-box;text-align:center;cursor:pointer;position:relative;padding:0;text-indent:100%;white-space:nowrap;overflow:hidden}.picker_done::before{content:\'Ok\';position:absolute;top:0;left:0;display:flex;width:100%;height:100%;justify-content:center;align-items:center;font-size:1rem;text-indent:0}.picker_arrow{position:absolute}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,0.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;transform:skew(45deg);transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}'; +.appendChild(document.createElement('style')).textContent = '.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em;box-sizing:border-box;background:#f2f2f2;cursor:default;pointer-events:auto}.picker_wrapper>*{margin:.5em}.picker_wrapper::before{content:\'\';display:block;width:100%;height:0;order:1}.picker_slider,.picker_selector{padding:1em}.picker_hue{width:100%}.picker_sl{flex:1 1 auto}.picker_sl::before{content:\'\';display:block;padding-bottom:100%}.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_sample{order:1;flex:1 1 auto;min-height:3em}.picker_done{order:1;width:3rem;height:2rem}.picker_selector{position:absolute;z-index:1;display:block;transform:translate(-50%, -50%);border:2px solid white;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255,255,255,0) 50%),linear-gradient(0deg, black, transparent 50%),linear-gradient(90deg, gray, rgba(128,128,128,0))}.picker_alpha,.picker_sample{position:relative;background:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'2\' height=\'2\'%3E%3Cpath d=\'M1,0H0V1H2V2H1\' fill=\'lightgrey\'/%3E%3C/svg%3E") left top/contain white;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_sample::before{content:\'\';position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_done{font:inherit;font-family:sans-serif;box-sizing:border-box;text-align:center;cursor:pointer;position:relative;padding:0;text-indent:100%;white-space:nowrap;overflow:hidden}.picker_done::before{content:\'Ok\';position:absolute;top:0;left:0;display:flex;width:100%;height:100%;justify-content:center;align-items:center;font-size:1rem;text-indent:0}.picker_arrow{position:absolute}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,0.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;transform:skew(45deg);transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}'; var Picker = function () { diff --git a/dist/vanilla-picker.min.js b/dist/vanilla-picker.min.js index bd5dbd2..609cb06 100644 --- a/dist/vanilla-picker.min.js +++ b/dist/vanilla-picker.min.js @@ -1,8 +1,8 @@ /*! - * vanilla-picker v2.0.0 + * vanilla-picker v2.0.1 * https://github.com/Sphinxxxx/vanilla-picker * * Copyright 2017-2018 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate) * Released under the ISC license. */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Picker=t()}(this,function(){"use strict";var e=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t=function(){function e(e,t){for(var r=0;r.5?h/(2-s-p):h/(s+p),s){case i:l=(n-o)/h+(n1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e},u=o<.5?o*(1+n):o+n-o*n,h=2*o-u;s=c(h,u,i+1/3),p=c(h,u,i),l=c(h,u,i-1/3)}var d=[255*s,255*p,255*l].map(Math.round);return d[3]=a,d}}]),i}();function n(e){var t=Element.prototype;t.matches||(t.matches=t.msMatchesSelector||t.webkitMatchesSelector),t.closest||(t.closest=function(e){var t=this;do{if(t.matches(e))return t;t="svg"===t.tagName?t.parentNode:t.parentElement}while(t);return null});var r=(e=e||{}).container||document.documentElement,i=e.selector,n=e.callback||console.log,o=e.callbackDragStart,a=e.callbackDragEnd,s=e.callbackClick,p=!1!==e.roundCoords,l=!1!==e.dragOutside,c=e.handleOffset||!1!==e.handleOffset,u=null;switch(c){case"center":u=!0;break;case"topleft":case"top-left":u=!1}var h=void 0,d=void 0,f=void 0;function g(e,t,i,n){var o=e.clientX,a=e.clientY;function s(e,t,r){return Math.max(t,Math.min(e,r))}if(t){var l=t.getBoundingClientRect();if(o-=l.left,a-=l.top,i&&(o-=i[0],a-=i[1]),n&&(o=s(o,0,l.width),a=s(a,0,l.height)),t!==r)(null!==u?u:"circle"===t.nodeName||"ellipse"===t.nodeName)&&(o-=l.width/2,a-=l.height/2)}return p?[Math.round(o),Math.round(a)]:[o,a]}function m(e){(h=i?e.target.closest(i):{})&&(e.preventDefault(),e.stopPropagation(),d=i&&c?g(e,h):[0,0],f=g(e,r,d),p&&(f=f.map(Math.round)),o&&o(h,f))}function v(e){if(h){e.preventDefault(),e.stopPropagation();var t=g(e,r,d,!l);n(h,t,f)}}function _(e){if(h){if(a||s){var t=g(e,r,d,!l);s&&f[0]===t[0]&&f[1]===t[1]&&s(h,f),a&&a(h,t,f)}h=null}}function k(e){_(y(e))}function w(e){return void 0!==e.buttons?1===e.buttons:1===e.which}function b(e,t){1===e.touches.length?t(y(e)):_(e)}function y(e){var t=e.targetTouches[0];return t||(t=e.changedTouches[0]),t.preventDefault=e.preventDefault.bind(e),t.stopPropagation=e.stopPropagation.bind(e),t}r.addEventListener("mousedown",function(e){w(e)&&m(e)}),r.addEventListener("touchstart",function(e){b(e,m)}),window.addEventListener("mousemove",function(e){h&&(w(e)?v(e):_(e))}),window.addEventListener("touchmove",function(e){b(e,v)}),window.addEventListener("mouseup",function(e){h&&!w(e)&&_(e)}),r.addEventListener("touchend",k),r.addEventListener("touchcancel",k)}function o(e,t,r){e.addEventListener(t,r,!1)}return document.documentElement.firstElementChild.appendChild(document.createElement("style")).textContent=".picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em;box-sizing:border-box;background:#f2f2f2;cursor:default;pointer-events:auto}.picker_wrapper>*{margin:.5em}.picker_wrapper::before{content:'';display:block;width:100%;order:1}.picker_slider,.picker_selector{padding:1em}.picker_hue{width:100%}.picker_sl{flex:1 1 auto}.picker_sl::before{content:'';display:block;padding-bottom:100%}.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_sample{order:1;flex:1 1 auto;min-height:3em}.picker_done{order:1;width:3rem;height:2rem}.picker_selector{position:absolute;z-index:1;display:block;transform:translate(-50%, -50%);border:2px solid white;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);outline:1px solid silver}.picker_sl{position:relative;outline:1px solid silver;background-image:linear-gradient(180deg, white, rgba(255,255,255,0) 50%),linear-gradient(0deg, black, transparent 50%),linear-gradient(90deg, gray, rgba(128,128,128,0))}.picker_alpha,.picker_sample{position:relative;background:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Cpath d='M1,0H0V1H2V2H1' fill='lightgrey'/%3E%3C/svg%3E\") left top/contain white;outline:1px solid silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_sample::before{content:'';position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_done{font:inherit;font-family:sans-serif;box-sizing:border-box;text-align:center;cursor:pointer;position:relative;padding:0;text-indent:100%;white-space:nowrap;overflow:hidden}.picker_done::before{content:'Ok';position:absolute;top:0;left:0;display:flex;width:100%;height:100%;justify-content:center;align-items:center;font-size:1rem;text-indent:0}.picker_arrow{position:absolute}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,0.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:\"\";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;transform:skew(45deg);transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}",function(){function r(t){e(this,r),this.settings={popup:"right",alpha:!0},this.setOptions(t)}return t(r,[{key:"setOptions",value:function(e){var t=this;if(e){var r=this.settings;e instanceof HTMLElement?r.parent=e:function(e,t,r){for(var i in e)r&&r.indexOf(i)>=0||(t[i]=e[i])}(e,r),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone);var i=e.color||e.colour;i&&this.setColor(i),r.parent&&r.popup&&!this._popupInited?(o(r.parent,"click",function(e){return t.openHandler(e)}),this._popupInited=!0):e.parent&&!r.popup&&this.show()}}},{key:"openHandler",value:function(e){this.show(),this.settings.parent.style.pointerEvents="none"}},{key:"closeHandler",value:function(e){var t=!1;"mousedown"===e.type?this.domElement.contains(e.target)||(t=!0):(e.preventDefault(),e.stopPropagation(),t=!0),t&&(this.hide(),this.settings.parent.style.pointerEvents="")}},{key:"setColor",value:function(e){var t=new i(e);if(!this.settings.alpha){var r=t.hsla;r[3]=1,t.hsla=r}this.colour=this.color=t,this._setHSLA()}},{key:"setColour",value:function(e){this.setColor(e)}},{key:"show",value:function(){if(this.settings.parent){if(this.domElement)return this.domElement.style.display="",void this._setPosition();var e,t,r=this.settings.template||'
',i=(e=r,(t=document.createElement("div")).innerHTML=e,t.firstElementChild);this.domElement=i,this._domH=i.querySelector(".picker_hue"),this._domSL=i.querySelector(".picker_sl"),this._domA=i.querySelector(".picker_alpha"),this._domSample=i.querySelector(".picker_sample"),this._domOkay=i.querySelector(".picker_done"),this.settings.alpha||i.classList.add("no_alpha"),this._ifPopup(function(){return i.classList.add("popup")}),this._setPosition(),this.colour?this._updateUI():this.setColor("#0cf"),this._bindEvents()}}},{key:"hide",value:function(){this.domElement&&(this.domElement.style.display="none")}},{key:"_bindEvents",value:function(){var e=this,t=this;function r(e,t){function r(r,i){var n=i[0]/e.clientWidth,o=i[1]/e.clientHeight;t(n,o)}return{container:e,dragOutside:!1,callback:r,callbackClick:r,callbackDragStart:r}}n(r(this._domH,function(e,r){return t._setHSLA(e)})),n(r(this._domSL,function(e,r){return t._setHSLA(null,e,1-r)})),n(r(this._domA,function(e,r){return t._setHSLA(null,null,null,1-r)})),o(window,"mousedown",function(t){return e._ifPopup(function(){return e.closeHandler(t)})}),o(this._domOkay,"click",function(t){e._ifPopup(function(){return e.closeHandler(t)}),e.onDone&&e.onDone(e.colour)})}},{key:"_setPosition",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup(function(r){"static"===getComputedStyle(e).position&&(e.style.position="relative");var i=!0===r?"popup_right":"popup_"+r;["popup_top","popup_bottom","popup_left","popup_right"].forEach(function(e){e===i?t.classList.add(e):t.classList.remove(e)}),t.classList.add(i)})}},{key:"_setHSLA",value:function(e,t,r,i){var n=arguments,o=this.colour;if(n.length){for(var a=o.hsla,s=0;s.5?h/(2-s-p):h/(s+p),s){case i:l=(o-n)/h+(o1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e},u=n<.5?n*(1+o):n+o-n*o,h=2*n-u;s=c(h,u,i+1/3),p=c(h,u,i),l=c(h,u,i-1/3)}var d=[255*s,255*p,255*l].map(Math.round);return d[3]=a,d}}]),i}();function o(e){var t=Element.prototype;t.matches||(t.matches=t.msMatchesSelector||t.webkitMatchesSelector),t.closest||(t.closest=function(e){var t=this;do{if(t.matches(e))return t;t="svg"===t.tagName?t.parentNode:t.parentElement}while(t);return null});var r=(e=e||{}).container||document.documentElement,i=e.selector,o=e.callback||console.log,n=e.callbackDragStart,a=e.callbackDragEnd,s=e.callbackClick,p=!1!==e.roundCoords,l=!1!==e.dragOutside,c=e.handleOffset||!1!==e.handleOffset,u=null;switch(c){case"center":u=!0;break;case"topleft":case"top-left":u=!1}var h=void 0,d=void 0,f=void 0;function g(e,t,i,o){var n=e.clientX,a=e.clientY;function s(e,t,r){return Math.max(t,Math.min(e,r))}if(t){var l=t.getBoundingClientRect();if(n-=l.left,a-=l.top,i&&(n-=i[0],a-=i[1]),o&&(n=s(n,0,l.width),a=s(a,0,l.height)),t!==r)(null!==u?u:"circle"===t.nodeName||"ellipse"===t.nodeName)&&(n-=l.width/2,a-=l.height/2)}return p?[Math.round(n),Math.round(a)]:[n,a]}function m(e){(h=i?e.target.closest(i):{})&&(e.preventDefault(),e.stopPropagation(),d=i&&c?g(e,h):[0,0],f=g(e,r,d),p&&(f=f.map(Math.round)),n&&n(h,f))}function v(e){if(h){e.preventDefault(),e.stopPropagation();var t=g(e,r,d,!l);o(h,t,f)}}function _(e){if(h){if(a||s){var t=g(e,r,d,!l);s&&f[0]===t[0]&&f[1]===t[1]&&s(h,f),a&&a(h,t,f)}h=null}}function k(e){_(y(e))}function w(e){return void 0!==e.buttons?1===e.buttons:1===e.which}function b(e,t){1===e.touches.length?t(y(e)):_(e)}function y(e){var t=e.targetTouches[0];return t||(t=e.changedTouches[0]),t.preventDefault=e.preventDefault.bind(e),t.stopPropagation=e.stopPropagation.bind(e),t}r.addEventListener("mousedown",function(e){w(e)&&m(e)}),r.addEventListener("touchstart",function(e){b(e,m)}),window.addEventListener("mousemove",function(e){h&&(w(e)?v(e):_(e))}),window.addEventListener("touchmove",function(e){b(e,v)}),window.addEventListener("mouseup",function(e){h&&!w(e)&&_(e)}),r.addEventListener("touchend",k),r.addEventListener("touchcancel",k)}function n(e,t,r){e.addEventListener(t,r,!1)}return document.documentElement.firstElementChild.appendChild(document.createElement("style")).textContent=".picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em;box-sizing:border-box;background:#f2f2f2;cursor:default;pointer-events:auto}.picker_wrapper>*{margin:.5em}.picker_wrapper::before{content:'';display:block;width:100%;height:0;order:1}.picker_slider,.picker_selector{padding:1em}.picker_hue{width:100%}.picker_sl{flex:1 1 auto}.picker_sl::before{content:'';display:block;padding-bottom:100%}.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_sample{order:1;flex:1 1 auto;min-height:3em}.picker_done{order:1;width:3rem;height:2rem}.picker_selector{position:absolute;z-index:1;display:block;transform:translate(-50%, -50%);border:2px solid white;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255,255,255,0) 50%),linear-gradient(0deg, black, transparent 50%),linear-gradient(90deg, gray, rgba(128,128,128,0))}.picker_alpha,.picker_sample{position:relative;background:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Cpath d='M1,0H0V1H2V2H1' fill='lightgrey'/%3E%3C/svg%3E\") left top/contain white;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_sample::before{content:'';position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_done{font:inherit;font-family:sans-serif;box-sizing:border-box;text-align:center;cursor:pointer;position:relative;padding:0;text-indent:100%;white-space:nowrap;overflow:hidden}.picker_done::before{content:'Ok';position:absolute;top:0;left:0;display:flex;width:100%;height:100%;justify-content:center;align-items:center;font-size:1rem;text-indent:0}.picker_arrow{position:absolute}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,0.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:\"\";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;transform:skew(45deg);transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}",function(){function r(t){e(this,r),this.settings={popup:"right",alpha:!0},this.setOptions(t)}return t(r,[{key:"setOptions",value:function(e){var t=this;if(e){var r=this.settings;e instanceof HTMLElement?r.parent=e:function(e,t,r){for(var i in e)r&&r.indexOf(i)>=0||(t[i]=e[i])}(e,r),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone);var i=e.color||e.colour;i&&this.setColor(i),r.parent&&r.popup&&!this._popupInited?(n(r.parent,"click",function(e){return t.openHandler(e)}),this._popupInited=!0):e.parent&&!r.popup&&this.show()}}},{key:"openHandler",value:function(e){this.show(),this.settings.parent.style.pointerEvents="none"}},{key:"closeHandler",value:function(e){var t=!1;"mousedown"===e.type?this.domElement.contains(e.target)||(t=!0):(e.preventDefault(),e.stopPropagation(),t=!0),t&&(this.hide(),this.settings.parent.style.pointerEvents="")}},{key:"setColor",value:function(e){var t=new i(e);if(!this.settings.alpha){var r=t.hsla;r[3]=1,t.hsla=r}this.colour=this.color=t,this._setHSLA()}},{key:"setColour",value:function(e){this.setColor(e)}},{key:"show",value:function(){if(this.settings.parent){if(this.domElement)return this.domElement.style.display="",void this._setPosition();var e,t,r=this.settings.template||'
',i=(e=r,(t=document.createElement("div")).innerHTML=e,t.firstElementChild);this.domElement=i,this._domH=i.querySelector(".picker_hue"),this._domSL=i.querySelector(".picker_sl"),this._domA=i.querySelector(".picker_alpha"),this._domSample=i.querySelector(".picker_sample"),this._domOkay=i.querySelector(".picker_done"),this.settings.alpha||i.classList.add("no_alpha"),this._ifPopup(function(){return i.classList.add("popup")}),this._setPosition(),this.colour?this._updateUI():this.setColor("#0cf"),this._bindEvents()}}},{key:"hide",value:function(){this.domElement&&(this.domElement.style.display="none")}},{key:"_bindEvents",value:function(){var e=this,t=this;function r(e,t){function r(r,i){var o=i[0]/e.clientWidth,n=i[1]/e.clientHeight;t(o,n)}return{container:e,dragOutside:!1,callback:r,callbackClick:r,callbackDragStart:r}}o(r(this._domH,function(e,r){return t._setHSLA(e)})),o(r(this._domSL,function(e,r){return t._setHSLA(null,e,1-r)})),o(r(this._domA,function(e,r){return t._setHSLA(null,null,null,1-r)})),n(window,"mousedown",function(t){return e._ifPopup(function(){return e.closeHandler(t)})}),n(this._domOkay,"click",function(t){e._ifPopup(function(){return e.closeHandler(t)}),e.onDone&&e.onDone(e.colour)})}},{key:"_setPosition",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup(function(r){"static"===getComputedStyle(e).position&&(e.style.position="relative");var i=!0===r?"popup_right":"popup_"+r;["popup_top","popup_bottom","popup_left","popup_right"].forEach(function(e){e===i?t.classList.add(e):t.classList.remove(e)}),t.classList.add(i)})}},{key:"_setHSLA",value:function(e,t,r,i){var o=arguments,n=this.colour;if(o.length){for(var a=n.hsla,s=0;s