@nuralyui/colorpicker 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle.js CHANGED
@@ -1,65 +1,4 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- const t=window,i=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e=Symbol(),s=new WeakMap;class o{constructor(t,i,s){if(this._$cssResult$=!0,s!==e)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=s.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&s.set(e,t))}return t}toString(){return this.cssText}}const r=(t,...i)=>{const s=1===t.length?t[0]:i.reduce(((i,e,s)=>i+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(e)+t[s+1]),t[0]);return new o(s,t,e)},n=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const e of t.cssRules)i+=e.cssText;return(t=>new o("string"==typeof t?t:t+"",void 0,e))(i)})(t):t
7
- /**
8
- * @license
9
- * Copyright 2017 Google LLC
10
- * SPDX-License-Identifier: BSD-3-Clause
11
- */;var l;const h=window,a=h.trustedTypes,c=a?a.emptyScript:"",d=h.reactiveElementPolyfillSupport,u={toAttribute(t,i){switch(i){case Boolean:t=t?c:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let e=t;switch(i){case Boolean:e=null!==t;break;case Number:e=null===t?null:Number(t);break;case Object:case Array:try{e=JSON.parse(t)}catch(t){e=null}}return e}},v=(t,i)=>i!==t&&(i==i||t==t),p={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:v},f="finalized";class b extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var i;this.finalize(),(null!==(i=this.h)&&void 0!==i?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,e)=>{const s=this._$Ep(e,i);void 0!==s&&(this._$Ev.set(s,e),t.push(s))})),t}static createProperty(t,i=p){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const e="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,e,i);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,e){return{get(){return this[i]},set(s){const o=this[t];this[i]=s,this.requestUpdate(t,o,e)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty(f))return!1;this[f]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const e of i)this.createProperty(e,t[e])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const e=new Set(t.flat(1/0).reverse());for(const t of e)i.unshift(n(t))}else void 0!==t&&i.push(n(t));return i}static _$Ep(t,i){const e=i.attribute;return!1===e?void 0:"string"==typeof e?e:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var i,e;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(e=t.hostConnected)||void 0===e||e.call(t))}removeController(t){var i;null===(i=this._$ES)||void 0===i||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])}))}createRenderRoot(){var e;const s=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,s)=>{i?e.adoptedStyleSheets=s.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):s.forEach((i=>{const s=document.createElement("style"),o=t.litNonce;void 0!==o&&s.setAttribute("nonce",o),s.textContent=i.cssText,e.appendChild(s)}))})(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}))}attributeChangedCallback(t,i,e){this._$AK(t,e)}_$EO(t,i,e=p){var s;const o=this.constructor._$Ep(t,e);if(void 0!==o&&!0===e.reflect){const r=(void 0!==(null===(s=e.converter)||void 0===s?void 0:s.toAttribute)?e.converter:u).toAttribute(i,e.type);this._$El=t,null==r?this.removeAttribute(o):this.setAttribute(o,r),this._$El=null}}_$AK(t,i){var e;const s=this.constructor,o=s._$Ev.get(t);if(void 0!==o&&this._$El!==o){const t=s.getPropertyOptions(o),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(e=t.converter)||void 0===e?void 0:e.fromAttribute)?t.converter:u;this._$El=o,this[o]=r.fromAttribute(i,t.type),this._$El=null}}requestUpdate(t,i,e){let s=!0;void 0!==t&&(((e=e||this.constructor.getPropertyOptions(t)).hasChanged||v)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===e.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,e))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,i)=>this[i]=t)),this._$Ei=void 0);let i=!1;const e=this._$AL;try{i=this.shouldUpdate(e),i?(this.willUpdate(e),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(e)):this._$Ek()}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(e)}willUpdate(t){}_$AE(t){var i;null===(i=this._$ES)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$EO(i,this[i],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
12
- /**
13
- * @license
14
- * Copyright 2017 Google LLC
15
- * SPDX-License-Identifier: BSD-3-Clause
16
- */
17
- var y;b[f]=!0,b.elementProperties=new Map,b.elementStyles=[],b.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:b}),(null!==(l=h.reactiveElementVersions)&&void 0!==l?l:h.reactiveElementVersions=[]).push("1.6.3");const g=window,m=g.trustedTypes,w=m?m.createPolicy("lit-html",{createHTML:t=>t}):void 0,$="$lit$",x=`lit$${(Math.random()+"").slice(9)}$`,k="?"+x,C=`<${k}>`,S=document,E=()=>S.createComment(""),A=t=>null===t||"object"!=typeof t&&"function"!=typeof t,_=Array.isArray,O="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,j=/>/g,T=RegExp(`>|${O}(?:([^\\s"'>=/]+)(${O}*=${O}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),P=/'/g,U=/"/g,I=/^(?:script|style|textarea|title)$/i,R=Symbol.for("lit-noChange"),N=Symbol.for("lit-nothing"),D=new WeakMap,B=S.createTreeWalker(S,129,null,!1);function L(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(i):i}class H{constructor({strings:t,_$litType$:i},e){let s;this.parts=[];let o=0,r=0;const n=t.length-1,l=this.parts,[h,a]=((t,i)=>{const e=t.length-1,s=[];let o,r=2===i?"<svg>":"",n=z;for(let i=0;i<e;i++){const e=t[i];let l,h,a=-1,c=0;for(;c<e.length&&(n.lastIndex=c,h=n.exec(e),null!==h);)c=n.lastIndex,n===z?"!--"===h[1]?n=M:void 0!==h[1]?n=j:void 0!==h[2]?(I.test(h[2])&&(o=RegExp("</"+h[2],"g")),n=T):void 0!==h[3]&&(n=T):n===T?">"===h[0]?(n=null!=o?o:z,a=-1):void 0===h[1]?a=-2:(a=n.lastIndex-h[2].length,l=h[1],n=void 0===h[3]?T:'"'===h[3]?U:P):n===U||n===P?n=T:n===M||n===j?n=z:(n=T,o=void 0);const d=n===T&&t[i+1].startsWith("/>")?" ":"";r+=n===z?e+C:a>=0?(s.push(l),e.slice(0,a)+$+e.slice(a)+x+d):e+x+(-2===a?(s.push(void 0),i):d)}return[L(t,r+(t[e]||"<?>")+(2===i?"</svg>":"")),s]})(t,i);if(this.el=H.createElement(h,e),B.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(s=B.nextNode())&&l.length<n;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const i of s.getAttributeNames())if(i.endsWith($)||i.startsWith(x)){const e=a[r++];if(t.push(i),void 0!==e){const t=s.getAttribute(e.toLowerCase()+$).split(x),i=/([.?@])?(.*)/.exec(e);l.push({type:1,index:o,name:i[2],strings:t,ctor:"."===i[1]?W:"?"===i[1]?J:"@"===i[1]?G:K})}else l.push({type:6,index:o})}for(const i of t)s.removeAttribute(i)}if(I.test(s.tagName)){const t=s.textContent.split(x),i=t.length-1;if(i>0){s.textContent=m?m.emptyScript:"";for(let e=0;e<i;e++)s.append(t[e],E()),B.nextNode(),l.push({type:2,index:++o});s.append(t[i],E())}}}else if(8===s.nodeType)if(s.data===k)l.push({type:2,index:o});else{let t=-1;for(;-1!==(t=s.data.indexOf(x,t+1));)l.push({type:7,index:o}),t+=x.length-1}o++}}static createElement(t,i){const e=S.createElement("template");return e.innerHTML=t,e}}function V(t,i,e=t,s){var o,r,n,l;if(i===R)return i;let h=void 0!==s?null===(o=e._$Co)||void 0===o?void 0:o[s]:e._$Cl;const a=A(i)?void 0:i._$litDirective$;return(null==h?void 0:h.constructor)!==a&&(null===(r=null==h?void 0:h._$AO)||void 0===r||r.call(h,!1),void 0===a?h=void 0:(h=new a(t),h._$AT(t,e,s)),void 0!==s?(null!==(n=(l=e)._$Co)&&void 0!==n?n:l._$Co=[])[s]=h:e._$Cl=h),void 0!==h&&(i=V(t,h._$AS(t,i.values),h,s)),i}class q{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;const{el:{content:e},parts:s}=this._$AD,o=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:S).importNode(e,!0);B.currentNode=o;let r=B.nextNode(),n=0,l=0,h=s[0];for(;void 0!==h;){if(n===h.index){let i;2===h.type?i=new F(r,r.nextSibling,this,t):1===h.type?i=new h.ctor(r,h.name,h.strings,this,t):6===h.type&&(i=new Q(r,this,t)),this._$AV.push(i),h=s[++l]}n!==(null==h?void 0:h.index)&&(r=B.nextNode(),n++)}return B.currentNode=S,o}v(t){let i=0;for(const e of this._$AV)void 0!==e&&(void 0!==e.strings?(e._$AI(t,e,i),i+=e.strings.length-2):e._$AI(t[i])),i++}}class F{constructor(t,i,e,s){var o;this.type=2,this._$AH=N,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=e,this.options=s,this._$Cp=null===(o=null==s?void 0:s.isConnected)||void 0===o||o}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=V(this,t,i),A(t)?t===N||null==t||""===t?(this._$AH!==N&&this._$AR(),this._$AH=N):t!==this._$AH&&t!==R&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>_(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==N&&A(this._$AH)?this._$AA.nextSibling.data=t:this.$(S.createTextNode(t)),this._$AH=t}g(t){var i;const{values:e,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=H.createElement(L(s.h,s.h[0]),this.options)),s);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===o)this._$AH.v(e);else{const t=new q(o,this),i=t.u(this.options);t.v(e),this.$(i),this._$AH=t}}_$AC(t){let i=D.get(t.strings);return void 0===i&&D.set(t.strings,i=new H(t)),i}T(t){_(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let e,s=0;for(const o of t)s===i.length?i.push(e=new F(this.k(E()),this.k(E()),this,this.options)):e=i[s],e._$AI(o),s++;s<i.length&&(this._$AR(e&&e._$AB.nextSibling,s),i.length=s)}_$AR(t=this._$AA.nextSibling,i){var e;for(null===(e=this._$AP)||void 0===e||e.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class K{constructor(t,i,e,s,o){this.type=1,this._$AH=N,this._$AN=void 0,this.element=t,this.name=i,this._$AM=s,this.options=o,e.length>2||""!==e[0]||""!==e[1]?(this._$AH=Array(e.length-1).fill(new String),this.strings=e):this._$AH=N}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,e,s){const o=this.strings;let r=!1;if(void 0===o)t=V(this,t,i,0),r=!A(t)||t!==this._$AH&&t!==R,r&&(this._$AH=t);else{const s=t;let n,l;for(t=o[0],n=0;n<o.length-1;n++)l=V(this,s[e+n],i,n),l===R&&(l=this._$AH[n]),r||(r=!A(l)||l!==this._$AH[n]),l===N?t=N:t!==N&&(t+=(null!=l?l:"")+o[n+1]),this._$AH[n]=l}r&&!s&&this.j(t)}j(t){t===N?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class W extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===N?void 0:t}}const Z=m?m.emptyScript:"";class J extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==N?this.element.setAttribute(this.name,Z):this.element.removeAttribute(this.name)}}class G extends K{constructor(t,i,e,s,o){super(t,i,e,s,o),this.type=5}_$AI(t,i=this){var e;if((t=null!==(e=V(this,t,i,0))&&void 0!==e?e:N)===R)return;const s=this._$AH,o=t===N&&s!==N||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==N&&(s===N||o);o&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,e;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}class Q{constructor(t,i,e){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=e}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const X=g.litHtmlPolyfillSupport;
18
- /**
19
- * @license
20
- * Copyright 2017 Google LLC
21
- * SPDX-License-Identifier: BSD-3-Clause
22
- */
23
- var Y;null==X||X(H,F),(null!==(y=g.litHtmlVersions)&&void 0!==y?y:g.litHtmlVersions=[]).push("2.8.0");const tt=window,it=tt.trustedTypes,et=it?it.createPolicy("lit-html",{createHTML:t=>t}):void 0,st="$lit$",ot=`lit$${(Math.random()+"").slice(9)}$`,rt="?"+ot,nt=`<${rt}>`,lt=document,ht=()=>lt.createComment(""),at=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ct=Array.isArray,dt="[ \t\n\f\r]",ut=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,vt=/-->/g,pt=/>/g,ft=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),bt=/'/g,yt=/"/g,gt=/^(?:script|style|textarea|title)$/i,mt=(t=>(i,...e)=>({_$litType$:t,strings:i,values:e}))(1),wt=Symbol.for("lit-noChange"),$t=Symbol.for("lit-nothing"),xt=new WeakMap,kt=lt.createTreeWalker(lt,129,null,!1);function Ct(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==et?et.createHTML(i):i}const St=(t,i)=>{const e=t.length-1,s=[];let o,r=2===i?"<svg>":"",n=ut;for(let i=0;i<e;i++){const e=t[i];let l,h,a=-1,c=0;for(;c<e.length&&(n.lastIndex=c,h=n.exec(e),null!==h);)c=n.lastIndex,n===ut?"!--"===h[1]?n=vt:void 0!==h[1]?n=pt:void 0!==h[2]?(gt.test(h[2])&&(o=RegExp("</"+h[2],"g")),n=ft):void 0!==h[3]&&(n=ft):n===ft?">"===h[0]?(n=null!=o?o:ut,a=-1):void 0===h[1]?a=-2:(a=n.lastIndex-h[2].length,l=h[1],n=void 0===h[3]?ft:'"'===h[3]?yt:bt):n===yt||n===bt?n=ft:n===vt||n===pt?n=ut:(n=ft,o=void 0);const d=n===ft&&t[i+1].startsWith("/>")?" ":"";r+=n===ut?e+nt:a>=0?(s.push(l),e.slice(0,a)+st+e.slice(a)+ot+d):e+ot+(-2===a?(s.push(void 0),i):d)}return[Ct(t,r+(t[e]||"<?>")+(2===i?"</svg>":"")),s]};class Et{constructor({strings:t,_$litType$:i},e){let s;this.parts=[];let o=0,r=0;const n=t.length-1,l=this.parts,[h,a]=St(t,i);if(this.el=Et.createElement(h,e),kt.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(s=kt.nextNode())&&l.length<n;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const i of s.getAttributeNames())if(i.endsWith(st)||i.startsWith(ot)){const e=a[r++];if(t.push(i),void 0!==e){const t=s.getAttribute(e.toLowerCase()+st).split(ot),i=/([.?@])?(.*)/.exec(e);l.push({type:1,index:o,name:i[2],strings:t,ctor:"."===i[1]?Mt:"?"===i[1]?Tt:"@"===i[1]?Pt:zt})}else l.push({type:6,index:o})}for(const i of t)s.removeAttribute(i)}if(gt.test(s.tagName)){const t=s.textContent.split(ot),i=t.length-1;if(i>0){s.textContent=it?it.emptyScript:"";for(let e=0;e<i;e++)s.append(t[e],ht()),kt.nextNode(),l.push({type:2,index:++o});s.append(t[i],ht())}}}else if(8===s.nodeType)if(s.data===rt)l.push({type:2,index:o});else{let t=-1;for(;-1!==(t=s.data.indexOf(ot,t+1));)l.push({type:7,index:o}),t+=ot.length-1}o++}}static createElement(t,i){const e=lt.createElement("template");return e.innerHTML=t,e}}function At(t,i,e=t,s){var o,r,n,l;if(i===wt)return i;let h=void 0!==s?null===(o=e._$Co)||void 0===o?void 0:o[s]:e._$Cl;const a=at(i)?void 0:i._$litDirective$;return(null==h?void 0:h.constructor)!==a&&(null===(r=null==h?void 0:h._$AO)||void 0===r||r.call(h,!1),void 0===a?h=void 0:(h=new a(t),h._$AT(t,e,s)),void 0!==s?(null!==(n=(l=e)._$Co)&&void 0!==n?n:l._$Co=[])[s]=h:e._$Cl=h),void 0!==h&&(i=At(t,h._$AS(t,i.values),h,s)),i}class _t{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;const{el:{content:e},parts:s}=this._$AD,o=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:lt).importNode(e,!0);kt.currentNode=o;let r=kt.nextNode(),n=0,l=0,h=s[0];for(;void 0!==h;){if(n===h.index){let i;2===h.type?i=new Ot(r,r.nextSibling,this,t):1===h.type?i=new h.ctor(r,h.name,h.strings,this,t):6===h.type&&(i=new Ut(r,this,t)),this._$AV.push(i),h=s[++l]}n!==(null==h?void 0:h.index)&&(r=kt.nextNode(),n++)}return kt.currentNode=lt,o}v(t){let i=0;for(const e of this._$AV)void 0!==e&&(void 0!==e.strings?(e._$AI(t,e,i),i+=e.strings.length-2):e._$AI(t[i])),i++}}class Ot{constructor(t,i,e,s){var o;this.type=2,this._$AH=$t,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=e,this.options=s,this._$Cp=null===(o=null==s?void 0:s.isConnected)||void 0===o||o}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=At(this,t,i),at(t)?t===$t||null==t||""===t?(this._$AH!==$t&&this._$AR(),this._$AH=$t):t!==this._$AH&&t!==wt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>ct(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==$t&&at(this._$AH)?this._$AA.nextSibling.data=t:this.$(lt.createTextNode(t)),this._$AH=t}g(t){var i;const{values:e,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Et.createElement(Ct(s.h,s.h[0]),this.options)),s);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===o)this._$AH.v(e);else{const t=new _t(o,this),i=t.u(this.options);t.v(e),this.$(i),this._$AH=t}}_$AC(t){let i=xt.get(t.strings);return void 0===i&&xt.set(t.strings,i=new Et(t)),i}T(t){ct(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let e,s=0;for(const o of t)s===i.length?i.push(e=new Ot(this.k(ht()),this.k(ht()),this,this.options)):e=i[s],e._$AI(o),s++;s<i.length&&(this._$AR(e&&e._$AB.nextSibling,s),i.length=s)}_$AR(t=this._$AA.nextSibling,i){var e;for(null===(e=this._$AP)||void 0===e||e.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class zt{constructor(t,i,e,s,o){this.type=1,this._$AH=$t,this._$AN=void 0,this.element=t,this.name=i,this._$AM=s,this.options=o,e.length>2||""!==e[0]||""!==e[1]?(this._$AH=Array(e.length-1).fill(new String),this.strings=e):this._$AH=$t}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,e,s){const o=this.strings;let r=!1;if(void 0===o)t=At(this,t,i,0),r=!at(t)||t!==this._$AH&&t!==wt,r&&(this._$AH=t);else{const s=t;let n,l;for(t=o[0],n=0;n<o.length-1;n++)l=At(this,s[e+n],i,n),l===wt&&(l=this._$AH[n]),r||(r=!at(l)||l!==this._$AH[n]),l===$t?t=$t:t!==$t&&(t+=(null!=l?l:"")+o[n+1]),this._$AH[n]=l}r&&!s&&this.j(t)}j(t){t===$t?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Mt extends zt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$t?void 0:t}}const jt=it?it.emptyScript:"";class Tt extends zt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==$t?this.element.setAttribute(this.name,jt):this.element.removeAttribute(this.name)}}class Pt extends zt{constructor(t,i,e,s,o){super(t,i,e,s,o),this.type=5}_$AI(t,i=this){var e;if((t=null!==(e=At(this,t,i,0))&&void 0!==e?e:$t)===wt)return;const s=this._$AH,o=t===$t&&s!==$t||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==$t&&(s===$t||o);o&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,e;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}class Ut{constructor(t,i,e){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=e}get _$AU(){return this._$AM._$AU}_$AI(t){At(this,t)}}const It=tt.litHtmlPolyfillSupport;null==It||It(Et,Ot),(null!==(Y=tt.litHtmlVersions)&&void 0!==Y?Y:tt.litHtmlVersions=[]).push("2.8.0");
24
- /**
25
- * @license
26
- * Copyright 2017 Google LLC
27
- * SPDX-License-Identifier: BSD-3-Clause
28
- */
29
- var Rt,Nt;class Dt extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;const e=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=e.firstChild),e}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,i,e)=>{var s,o;const r=null!==(s=null==e?void 0:e.renderBefore)&&void 0!==s?s:i;let n=r._$litPart$;if(void 0===n){const t=null!==(o=null==e?void 0:e.renderBefore)&&void 0!==o?o:null;r._$litPart$=n=new Ot(i.insertBefore(ht(),t),t,void 0,null!=e?e:{})}return n._$AI(t),n})(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return wt}}Dt.finalized=!0,Dt._$litElement$=!0,null===(Rt=globalThis.litElementHydrateSupport)||void 0===Rt||Rt.call(globalThis,{LitElement:Dt});const Bt=globalThis.litElementPolyfillSupport;null==Bt||Bt({LitElement:Dt}),(null!==(Nt=globalThis.litElementVersions)&&void 0!==Nt?Nt:globalThis.litElementVersions=[]).push("3.3.3");
30
- /**
31
- * @license
32
- * Copyright 2017 Google LLC
33
- * SPDX-License-Identifier: BSD-3-Clause
34
- */
35
- const Lt=t=>i=>"function"==typeof i?((t,i)=>(customElements.define(t,i),i))(t,i):((t,i)=>{const{kind:e,elements:s}=i;return{kind:e,elements:s,finisher(i){customElements.define(t,i)}}})(t,i)
36
- /**
37
- * @license
38
- * Copyright 2017 Google LLC
39
- * SPDX-License-Identifier: BSD-3-Clause
40
- */,Ht=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(e){e.createProperty(i.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:i.key,initializer(){"function"==typeof i.initializer&&(this[i.key]=i.initializer.call(this))},finisher(e){e.createProperty(i.key,t)}},Vt=(t,i,e)=>{i.constructor.createProperty(e,t)};function qt(t){return(i,e)=>void 0!==e?Vt(t,i,e):Ht(t,i)
41
- /**
42
- * @license
43
- * Copyright 2017 Google LLC
44
- * SPDX-License-Identifier: BSD-3-Clause
45
- */}
46
- /**
47
- * @license
48
- * Copyright 2021 Google LLC
49
- * SPDX-License-Identifier: BSD-3-Clause
50
- */
51
- var Ft;null===(Ft=window.HTMLSlotElement)||void 0===Ft||Ft.prototype.assignedElements;
52
- /**
53
- * @license
54
- * Copyright 2017 Google LLC
55
- * SPDX-License-Identifier: BSD-3-Clause
56
- */
57
- const Kt=1,Wt=t=>(...i)=>({_$litDirective$:t,values:i});class Zt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,e){this._$Ct=t,this._$AM=i,this._$Ci=e}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}
58
- /**
59
- * @license
60
- * Copyright 2018 Google LLC
61
- * SPDX-License-Identifier: BSD-3-Clause
62
- */const Jt=Wt(class extends Zt{constructor(t){var i;if(super(t),t.type!==Kt||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((i=>t[i])).join(" ")+" "}update(t,[i]){var e,s;if(void 0===this.it){this.it=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!(null===(e=this.nt)||void 0===e?void 0:e.has(t))&&this.it.add(t);return this.render(i)}const o=t.element.classList;this.it.forEach((t=>{t in i||(o.remove(t),this.it.delete(t))}));for(const t in i){const e=!!i[t];e===this.it.has(t)||(null===(s=this.nt)||void 0===s?void 0:s.has(t))||(e?(o.add(t),this.it.add(t)):(o.remove(t),this.it.delete(t)))}return R}}),Gt=t=>class extends t{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var t,i,e;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(i=this.designSystemObserver)||void 0===i||i.disconnect(),null===(e=this.mediaQuery)||void 0===e||e.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,i;const e=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return e||((null===(i=window.matchMedia)||void 0===i?void 0:i.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var t;const i=(null===(t=this.closest("[design-system]"))||void 0===t?void 0:t.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===i?i:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver((()=>{this.requestUpdate()})),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver((()=>{this.requestUpdate()})),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},Qt=()=>{var t;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(t=process.env)||void 0===t?void 0:t.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},Xt=t=>class extends t{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(Qt())for(const t of this.requiredComponents)if(!this.isComponentAvailable(t))throw new Error(`Required component "${t}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${t}';`)}validateDependenciesWithHandler(t){if(!Qt())return!0;let i=!0;for(const e of this.requiredComponents)if(!this.isComponentAvailable(e)){i=!1;const s=new Error(`Required component "${e}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(e,s):console.error(s.message)}return i}isComponentAvailable(t){return!!customElements.get(t)}getMissingDependencies(){return this.requiredComponents.filter((t=>!this.isComponentAvailable(t)))}areDependenciesAvailable(){return this.requiredComponents.every((t=>this.isComponentAvailable(t)))}addRequiredComponent(t){this.requiredComponents.includes(t)||this.requiredComponents.push(t)}removeRequiredComponent(t){const i=this.requiredComponents.indexOf(t);i>-1&&this.requiredComponents.splice(i,1)}},Yt=t=>class extends t{dispatchCustomEvent(t,i){this.dispatchEvent(new CustomEvent(t,{detail:i,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,i){var e;const s=Object.assign(Object.assign({},i),{timestamp:Date.now(),componentName:(null===(e=this.tagName)||void 0===e?void 0:e.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,s)}dispatchInputEvent(t,i){const e=Object.assign({target:i.target||this,value:i.value,originalEvent:i.originalEvent},i);this.dispatchCustomEvent(t,e)}dispatchFocusEvent(t,i){const e=Object.assign({target:i.target||this,value:i.value,focused:i.focused,cursorPosition:i.cursorPosition,selectedText:i.selectedText},i);this.dispatchCustomEvent(t,e)}dispatchValidationEvent(t,i){var e;const s=Object.assign({target:i.target||this,value:i.value,isValid:null!==(e=i.isValid)&&void 0!==e&&e,error:i.error},i);this.dispatchCustomEvent(t,s)}dispatchActionEvent(t,i){const e=Object.assign({target:i.target||this,action:i.action,previousValue:i.previousValue,newValue:i.newValue},i);this.dispatchCustomEvent(t,e)}isReadonlyKeyAllowed(t){if(t.ctrlKey||t.metaKey){return["KeyA","KeyC"].includes(t.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return"Enter"===t.key||" "===t.key}},ti="important",ii=" !"+ti,ei=Wt(class extends Zt{constructor(t){var i;if(super(t),t.type!==Kt||"style"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((i,e)=>{const s=t[e];return null==s?i:i+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(t,[i]){const{style:e}=t.element;if(void 0===this.ht){this.ht=new Set;for(const t in i)this.ht.add(t);return this.render(i)}this.ht.forEach((t=>{null==i[t]&&(this.ht.delete(t),t.includes("-")?e.removeProperty(t):e[t]="")}));for(const t in i){const s=i[t];if(null!=s){this.ht.add(t);const i="string"==typeof s&&s.endsWith(ii);t.includes("-")||i?e.setProperty(t,i?s.slice(0,-11):s,i?ti:""):e[t]=s}}return R}}),si=r`
1
+ import{css as t,LitElement as e,html as o,nothing as r}from"lit";import{property as i,customElement as s,state as n}from"lit/decorators.js";import{classMap as l}from"lit/directives/class-map.js";import{NuralyUIBaseMixin as a}from"@nuralyui/common/mixins";import{styleMap as h}from"lit/directives/style-map.js";import{map as c}from"lit/directives/map.js";const d=t`
63
2
  :host {
64
3
  display: inline-block;
65
4
  cursor: pointer;
@@ -102,20 +41,15 @@ const Kt=1,Wt=t=>(...i)=>({_$litDirective$:t,values:i});class Zt{constructor(t){
102
41
  * Copyright 2023 Nuraly, Laabidi Aymen
103
42
  * SPDX-License-Identifier: MIT
104
43
  */
105
- /**
106
- * @license
107
- * Copyright 2023 Nuraly, Laabidi Aymen
108
- * SPDX-License-Identifier: MIT
109
- */
110
- var oi=function(t,i,e,s){for(var o,r=arguments.length,n=r<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(o=t[l])&&(n=(r<3?o(n):r>3?o(i,e,n):o(i,e))||n);return r>3&&n&&Object.defineProperty(i,e,n),n};let ri=class extends Dt{constructor(){super(...arguments),this.color="#3498db",this.size="default",this.disabled=!1,this.showTransparencyGrid=!0,this.borderWidth=2,this.showBorder=!0}isValidColor(){try{return CSS.supports("color",this.color)}catch(t){return!1}}isTransparent(){return"transparent"===this.color||this.color.toLowerCase().includes("rgba")||this.color.toLowerCase().includes("hsla")}render(){const t={"color-holder-container":!0,"color-holder-container--disabled":this.disabled,"color-holder-container--invalid":!this.isValidColor(),"color-holder-container--transparent":this.isTransparent()&&this.showTransparencyGrid,[`color-holder-container--${this.size}`]:!0},i={backgroundColor:this.isValidColor()?this.color:"#ffffff",borderWidth:this.showBorder?`${this.borderWidth}px`:"0"};return mt`
44
+ var u=function(t,e,o,r){for(var i,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,l=t.length-1;l>=0;l--)(i=t[l])&&(n=(s<3?i(n):s>3?i(e,o,n):i(e,o))||n);return s>3&&n&&Object.defineProperty(e,o,n),n};let p=class extends e{constructor(){super(...arguments),this.color="#3498db",this.size="default",this.disabled=!1,this.showTransparencyGrid=!0,this.borderWidth=2,this.showBorder=!0}isValidColor(){try{return CSS.supports("color",this.color)}catch(t){return!1}}isTransparent(){return"transparent"===this.color||this.color.toLowerCase().includes("rgba")||this.color.toLowerCase().includes("hsla")}render(){const t={"color-holder-container":!0,"color-holder-container--disabled":this.disabled,"color-holder-container--invalid":!this.isValidColor(),"color-holder-container--transparent":this.isTransparent()&&this.showTransparencyGrid,[`color-holder-container--${this.size}`]:!0},e={backgroundColor:this.isValidColor()?this.color:"#ffffff",borderWidth:this.showBorder?`${this.borderWidth}px`:"0"};return o`
111
45
  <div
112
- class="${Jt(t)}"
113
- style="${ei(i)}"
46
+ class="${l(t)}"
47
+ style="${h(e)}"
114
48
  role="img"
115
49
  aria-label="Color swatch: ${this.color}"
116
50
  title="${this.color}"
117
51
  ></div>
118
- `}};ri.styles=si,oi([qt({type:String})],ri.prototype,"color",void 0),oi([qt({type:String,reflect:!0})],ri.prototype,"size",void 0),oi([qt({type:Boolean,reflect:!0})],ri.prototype,"disabled",void 0),oi([qt({type:Boolean,attribute:"show-transparency-grid"})],ri.prototype,"showTransparencyGrid",void 0),oi([qt({type:Number,attribute:"border-width"})],ri.prototype,"borderWidth",void 0),oi([qt({type:Boolean,attribute:"show-border"})],ri.prototype,"showBorder",void 0),ri=oi([Lt("nr-colorholder-box")],ri);const ni=r`
52
+ `}};p.styles=d,u([i({type:String})],p.prototype,"color",void 0),u([i({type:String,reflect:!0})],p.prototype,"size",void 0),u([i({type:Boolean,reflect:!0})],p.prototype,"disabled",void 0),u([i({type:Boolean,attribute:"show-transparency-grid"})],p.prototype,"showTransparencyGrid",void 0),u([i({type:Number,attribute:"border-width"})],p.prototype,"borderWidth",void 0),u([i({type:Boolean,attribute:"show-border"})],p.prototype,"showBorder",void 0),p=u([s("nr-colorholder-box")],p);const b=t`
119
53
  .default-color-sets-container {
120
54
  display: flex;
121
55
  flex-wrap: wrap;
@@ -147,20 +81,14 @@ var oi=function(t,i,e,s){for(var o,r=arguments.length,n=r<3?i:null===s?s=Object.
147
81
  * Copyright 2023 Nuraly, Laabidi Aymen
148
82
  * SPDX-License-Identifier: MIT
149
83
  */
150
- var li=function(t,i,e,s){for(var o,r=arguments.length,n=r<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(o=t[l])&&(n=(r<3?o(n):r>3?o(i,e,n):o(i,e))||n);return r>3&&n&&Object.defineProperty(i,e,n),n};let hi=class extends Dt{constructor(){super(...arguments),this.defaultColorSets=[],this.size="default",this.columns=8}handleColorClick(t,i){if(i.stopPropagation(),!this.isValidColor(t))return void console.warn(`Invalid color: ${t}`);const e={value:t};this.dispatchEvent(new CustomEvent("color-click",{bubbles:!0,composed:!0,detail:e}))}isValidColor(t){try{return CSS.supports("color",t)}catch(t){return!1}}render(){return this.defaultColorSets&&0!==this.defaultColorSets.length?mt`
84
+ var v=function(t,e,o,r){for(var i,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,l=t.length-1;l>=0;l--)(i=t[l])&&(n=(s<3?i(n):s>3?i(e,o,n):i(e,o))||n);return s>3&&n&&Object.defineProperty(e,o,n),n};let f=class extends e{constructor(){super(...arguments),this.defaultColorSets=[],this.size="default",this.columns=8}handleColorClick(t,e){if(e.stopPropagation(),!this.isValidColor(t))return void console.warn(`Invalid color: ${t}`);const o={value:t};this.dispatchEvent(new CustomEvent("color-click",{bubbles:!0,composed:!0,detail:o}))}isValidColor(t){try{return CSS.supports("color",t)}catch(t){return!1}}render(){return this.defaultColorSets&&0!==this.defaultColorSets.length?o`
151
85
  <div
152
86
  class="default-color-sets-container"
153
87
  role="list"
154
88
  aria-label="Preset color swatches"
155
89
  style="--columns: ${this.columns}"
156
90
  >
157
- ${
158
- /**
159
- * @license
160
- * Copyright 2021 Google LLC
161
- * SPDX-License-Identifier: BSD-3-Clause
162
- */
163
- function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.defaultColorSets,(t=>mt`
91
+ ${c(this.defaultColorSets,(t=>o`
164
92
  <nr-colorholder-box
165
93
  color="${t}"
166
94
  .size=${this.size}
@@ -168,12 +96,12 @@ function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.def
168
96
  role="listitem"
169
97
  tabindex="0"
170
98
  aria-label="Color ${t}"
171
- @click=${i=>this.handleColorClick(t,i)}
172
- @keydown=${i=>{"Enter"!==i.key&&" "!==i.key||(i.preventDefault(),this.handleColorClick(t,i))}}
99
+ @click=${e=>this.handleColorClick(t,e)}
100
+ @keydown=${e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleColorClick(t,e))}}
173
101
  ></nr-colorholder-box>
174
102
  `))}
175
103
  </div>
176
- `:$t}};hi.styles=ni,li([qt({type:Array,attribute:"default-color-sets"})],hi.prototype,"defaultColorSets",void 0),li([qt({type:String,reflect:!0})],hi.prototype,"size",void 0),li([qt({type:Number,attribute:"columns"})],hi.prototype,"columns",void 0),hi=li([Lt("nr-default-color-sets")],hi);var ai=r`
104
+ `:r}};f.styles=b,v([i({type:Array,attribute:"default-color-sets"})],f.prototype,"defaultColorSets",void 0),v([i({type:String,reflect:!0})],f.prototype,"size",void 0),v([i({type:Number,attribute:"columns"})],f.prototype,"columns",void 0),f=v([s("nr-default-color-sets")],f);var m=t`
177
105
  :host {
178
106
  display: inline-block;
179
107
  vertical-align: middle;
@@ -249,13 +177,13 @@ function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.def
249
177
  opacity: 1;
250
178
  visibility: visible;
251
179
  }
252
- `;class ci{constructor(t){this.host=t,t.addController(this)}hostConnected(){}hostDisconnected(){}hostUpdated(){}dispatchEvent(t){this.host.dispatchEvent(t)}requestUpdate(){this.host.requestUpdate()}handleError(t,i){console.error(`[ColorPicker ${i}]:`,t)}findElement(t){var i;return(null===(i=this.host.shadowRoot)||void 0===i?void 0:i.querySelector(t))||null}}class di extends ci{constructor(){super(...arguments),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._dropdownElement=null,this._triggerElement=null,this._scrollHandler=null,this._resizeHandler=null}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}hostConnected(){this.setupScrollAndResizeListeners()}hostDisconnected(){this.cleanup()}open(){try{this._isOpen||this.host.disabled||(this._isOpen=!0,this.host.show=!0,this.requestUpdate(),requestAnimationFrame((()=>{this.findElements(),this._dropdownElement&&this._dropdownElement.classList.remove("positioned"),requestAnimationFrame((()=>{this.calculatePosition(),this._dropdownElement&&this._dropdownElement.classList.add("positioned")}))})),this.host&&"function"==typeof this.host.setupEventListeners&&setTimeout((()=>{var t,i;null===(i=(t=this.host).setupEventListeners)||void 0===i||i.call(t)}),50),this.dispatchEvent(new CustomEvent("nr-colorpicker-open",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"open")}}close(){var t,i;try{this._isOpen&&(this._isOpen=!1,this.host.show=!1,this.resetPosition(),this.requestUpdate(),this.host&&"function"==typeof this.host.removeEventListeners&&(null===(i=(t=this.host).removeEventListeners)||void 0===i||i.call(t)),this.dispatchEvent(new CustomEvent("nr-colorpicker-close",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"close")}}toggle(){this._isOpen?this.close():this.open()}findElements(){this._dropdownElement=this.findElement(".dropdown-container"),this._triggerElement=this.findElement(".color-holder")}calculatePosition(){var t,i;try{if(this._dropdownElement&&this._triggerElement||this.findElements(),!this._dropdownElement||!this._triggerElement)return;const e=this._triggerElement.getBoundingClientRect(),s=this._dropdownElement.getBoundingClientRect(),o=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight,r=(null===(i=window.visualViewport)||void 0===i?void 0:i.width)||window.innerWidth,n=o-e.bottom,l=e.top,h=r-e.left;let a,c,d="bottom";n>=s.height||n>l?(a=e.bottom,d="bottom"):(a=e.top-s.height,d="top"),c=h>=s.width?e.left:Math.max(0,r-s.width),this._position={top:a,left:c,width:Math.max(e.width,s.width),placement:d},this.applyPosition()}catch(t){this.handleError(t,"calculatePosition")}}applyPosition(){try{if(!this._dropdownElement)return;this._dropdownElement.style.position="fixed",this._dropdownElement.style.top=`${this._position.top}px`,this._dropdownElement.style.left=`${this._position.left}px`,this._dropdownElement.style.zIndex="9999",this._dropdownElement.classList.remove("placement-top","placement-bottom"),this._dropdownElement.classList.add(`placement-${this._position.placement}`),this._dropdownElement.classList.add("positioned")}catch(t){this.handleError(t,"applyPosition")}}resetPosition(){try{this._dropdownElement&&(this._dropdownElement.style.removeProperty("position"),this._dropdownElement.style.removeProperty("top"),this._dropdownElement.style.removeProperty("left"),this._dropdownElement.style.removeProperty("z-index"),this._dropdownElement.classList.remove("placement-top","placement-bottom","positioned"))}catch(t){this.handleError(t,"resetPosition")}}setupScrollAndResizeListeners(){this._scrollHandler=()=>{this._isOpen&&this.calculatePosition()},this._resizeHandler=()=>{this._isOpen&&this.calculatePosition()},document.addEventListener("scroll",this._scrollHandler,{passive:!0}),window.addEventListener("resize",this._resizeHandler)}cleanup(){this._scrollHandler&&(document.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}}class ui extends ci{constructor(){super(...arguments),this._outsideClickHandler=null,this._escapeHandler=null}setupEventListeners(){this._outsideClickHandler=this.handleOutsideClick.bind(this),document.addEventListener("click",this._outsideClickHandler,!0),this._escapeHandler=this.handleEscapeKey.bind(this),document.addEventListener("keydown",this._escapeHandler)}removeEventListeners(){this._outsideClickHandler&&(document.removeEventListener("click",this._outsideClickHandler,!0),this._outsideClickHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler),this._escapeHandler=null)}handleTriggerClick(t){if(t.stopPropagation(),!this.host.disabled){const t=this.host.dropdownController;t&&t.toggle()}}handleOutsideClick(t){if(!t.composedPath().includes(this.host)){const t=this.host.dropdownController;t&&t.close()}}handleEscapeKey(t){if("Escape"===t.key&&this.host.show){t.preventDefault();const i=this.host.dropdownController;i&&i.close()}}handleColorChange(t){if(this.isValidColor(t)&&this.host.color!==t){const i=this.host.color;this.host.color=t,this.dispatchColorChangeEvent(t,i),this.requestUpdate()}}handleInputChange(t){const i=t.detail.value;i&&i!==this.host.color&&this.handleColorChange(i)}dispatchColorChangeEvent(t,i){const e={value:t,previousValue:i,isValid:this.isValidColor(t)};this.dispatchEvent(new CustomEvent("hy-color-change",{bubbles:!0,composed:!0,detail:e})),this.dispatchEvent(new CustomEvent("color-changed",{bubbles:!0,composed:!0,detail:{value:t}}))}isValidColor(t){try{return CSS.supports("color",t)}catch(t){return!1}}}
180
+ `;class y{constructor(t){this.host=t,t.addController(this)}hostConnected(){}hostDisconnected(){}hostUpdated(){}dispatchEvent(t){this.host.dispatchEvent(t)}requestUpdate(){this.host.requestUpdate()}handleError(t,e){console.error(`[ColorPicker ${e}]:`,t)}findElement(t){var e;return(null===(e=this.host.shadowRoot)||void 0===e?void 0:e.querySelector(t))||null}}class x extends y{constructor(){super(...arguments),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._dropdownElement=null,this._triggerElement=null,this._scrollHandler=null,this._resizeHandler=null}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}hostConnected(){this.setupScrollAndResizeListeners()}hostDisconnected(){this.cleanup()}open(){try{this._isOpen||this.host.disabled||(this._isOpen=!0,this.host.show=!0,this.requestUpdate(),requestAnimationFrame((()=>{this.findElements(),this._dropdownElement&&this._dropdownElement.classList.remove("positioned"),requestAnimationFrame((()=>{this.calculatePosition(),this._dropdownElement&&this._dropdownElement.classList.add("positioned")}))})),this.host&&"function"==typeof this.host.setupEventListeners&&setTimeout((()=>{var t,e;null===(e=(t=this.host).setupEventListeners)||void 0===e||e.call(t)}),50),this.dispatchEvent(new CustomEvent("nr-colorpicker-open",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"open")}}close(){var t,e;try{this._isOpen&&(this._isOpen=!1,this.host.show=!1,this.resetPosition(),this.requestUpdate(),this.host&&"function"==typeof this.host.removeEventListeners&&(null===(e=(t=this.host).removeEventListeners)||void 0===e||e.call(t)),this.dispatchEvent(new CustomEvent("nr-colorpicker-close",{bubbles:!0,composed:!0})))}catch(t){this.handleError(t,"close")}}toggle(){this._isOpen?this.close():this.open()}findElements(){this._dropdownElement=this.findElement(".dropdown-container"),this._triggerElement=this.findElement(".color-holder")}calculatePosition(){var t,e;try{if(this._dropdownElement&&this._triggerElement||this.findElements(),!this._dropdownElement||!this._triggerElement)return;const o=this._triggerElement.getBoundingClientRect(),r=this._dropdownElement.getBoundingClientRect(),i=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight,s=(null===(e=window.visualViewport)||void 0===e?void 0:e.width)||window.innerWidth,n=i-o.bottom,l=o.top,a=s-o.left;let h,c,d="bottom";n>=r.height||n>l?(h=o.bottom,d="bottom"):(h=o.top-r.height,d="top"),c=a>=r.width?o.left:Math.max(0,s-r.width),this._position={top:h,left:c,width:Math.max(o.width,r.width),placement:d},this.applyPosition()}catch(t){this.handleError(t,"calculatePosition")}}applyPosition(){try{if(!this._dropdownElement)return;this._dropdownElement.style.position="fixed",this._dropdownElement.style.top=`${this._position.top}px`,this._dropdownElement.style.left=`${this._position.left}px`,this._dropdownElement.style.zIndex="9999",this._dropdownElement.classList.remove("placement-top","placement-bottom"),this._dropdownElement.classList.add(`placement-${this._position.placement}`),this._dropdownElement.classList.add("positioned")}catch(t){this.handleError(t,"applyPosition")}}resetPosition(){try{this._dropdownElement&&(this._dropdownElement.style.removeProperty("position"),this._dropdownElement.style.removeProperty("top"),this._dropdownElement.style.removeProperty("left"),this._dropdownElement.style.removeProperty("z-index"),this._dropdownElement.classList.remove("placement-top","placement-bottom","positioned"))}catch(t){this.handleError(t,"resetPosition")}}setupScrollAndResizeListeners(){this._scrollHandler=()=>{this._isOpen&&this.calculatePosition()},this._resizeHandler=()=>{this._isOpen&&this.calculatePosition()},document.addEventListener("scroll",this._scrollHandler,{passive:!0}),window.addEventListener("resize",this._resizeHandler)}cleanup(){this._scrollHandler&&(document.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}}class g extends y{constructor(){super(...arguments),this._outsideClickHandler=null,this._escapeHandler=null}setupEventListeners(){this._outsideClickHandler=this.handleOutsideClick.bind(this),document.addEventListener("click",this._outsideClickHandler,!0),this._escapeHandler=this.handleEscapeKey.bind(this),document.addEventListener("keydown",this._escapeHandler)}removeEventListeners(){this._outsideClickHandler&&(document.removeEventListener("click",this._outsideClickHandler,!0),this._outsideClickHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler),this._escapeHandler=null)}handleTriggerClick(t){if(t.stopPropagation(),!this.host.disabled){const t=this.host.dropdownController;t&&t.toggle()}}handleOutsideClick(t){if(!t.composedPath().includes(this.host)){const t=this.host.dropdownController;t&&t.close()}}handleEscapeKey(t){if("Escape"===t.key&&this.host.show){t.preventDefault();const e=this.host.dropdownController;e&&e.close()}}handleColorChange(t){if(this.isValidColor(t)&&this.host.color!==t){const e=this.host.color;this.host.color=t,this.dispatchColorChangeEvent(t,e),this.requestUpdate()}}handleInputChange(t){const e=t.detail.value;e&&e!==this.host.color&&this.handleColorChange(e)}dispatchColorChangeEvent(t,e){const o={value:t,previousValue:e,isValid:this.isValidColor(t)};this.dispatchEvent(new CustomEvent("hy-color-change",{bubbles:!0,composed:!0,detail:o})),this.dispatchEvent(new CustomEvent("color-changed",{bubbles:!0,composed:!0,detail:{value:t}}))}isValidColor(t){try{return CSS.supports("color",t)}catch(t){return!1}}}
253
181
  /**
254
182
  * @license
255
183
  * Copyright 2023 Nuraly, Laabidi Aymen
256
184
  * SPDX-License-Identifier: MIT
257
- */var vi=function(t,i,e,s){for(var o,r=arguments.length,n=r<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,e):s,l=t.length-1;l>=0;l--)(o=t[l])&&(n=(r<3?o(n):r>3?o(i,e,n):o(i,e))||n);return r>3&&n&&Object.defineProperty(i,e,n),n};let pi=class extends((t=>Xt(Gt(Yt(t))))(Dt)){constructor(){super(),this.requiredComponents=["nr-input","nr-icon"],this.color="#3498db",this.show=!1,this.defaultColorSets=[],this.disabled=!1,this.size="default",this.trigger="click",this.placement="auto",this.animation="fade",this.closeOnSelect=!1,this.closeOnOutsideClick=!0,this.closeOnEscape=!0,this.showInput=!0,this.showCopyButton=!0,this.format="hex",this.inputPlaceholder="Enter color",this.label="",this.helperText="",this.isValidColor=!0,this.dropdownController=new di(this),this.eventController=new ui(this),this.handleTriggerClick=t=>{this.eventController.handleTriggerClick(t)},this.handleColorChanged=t=>{const i=t.detail.value;this.eventController.handleColorChange(i),this.closeOnSelect&&this.dropdownController.close()},this.handleInputChange=t=>{this.eventController.handleInputChange(t)},"undefined"!=typeof window&&Promise.resolve().then((function(){return qi}))}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}updated(t){super.updated(t),t.has("color")&&this.validateColor()}open(){this.dropdownController.open()}close(){this.dropdownController.close()}toggle(){this.dropdownController.toggle()}validateColor(){return this.isValidColor=this.eventController.isValidColor(this.color),this.isValidColor}setupEventListeners(){(this.closeOnOutsideClick||this.closeOnEscape)&&this.eventController.setupEventListeners()}removeEventListeners(){this.eventController.removeEventListeners()}render(){const t={"color-picker-container":!0,"color-picker-container--disabled":this.disabled,"color-picker-container--open":this.show,[`color-picker-container--${this.size}`]:!0};return mt`
258
- <div class="${Jt(t)}" data-theme="${this.currentTheme}">
185
+ */var w=function(t,e,o,r){for(var i,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r,l=t.length-1;l>=0;l--)(i=t[l])&&(n=(s<3?i(n):s>3?i(e,o,n):i(e,o))||n);return s>3&&n&&Object.defineProperty(e,o,n),n};let k=class extends(a(e)){constructor(){super(),this.requiredComponents=["nr-input","nr-icon"],this.color="#3498db",this.show=!1,this.defaultColorSets=[],this.disabled=!1,this.size="default",this.trigger="click",this.placement="auto",this.animation="fade",this.closeOnSelect=!1,this.closeOnOutsideClick=!0,this.closeOnEscape=!0,this.showInput=!0,this.showCopyButton=!0,this.format="hex",this.inputPlaceholder="Enter color",this.label="",this.helperText="",this.isValidColor=!0,this.dropdownController=new x(this),this.eventController=new g(this),this.handleTriggerClick=t=>{this.eventController.handleTriggerClick(t)},this.handleColorChanged=t=>{const e=t.detail.value;this.eventController.handleColorChange(e),this.closeOnSelect&&this.dropdownController.close()},this.handleInputChange=t=>{this.eventController.handleInputChange(t)},"undefined"!=typeof window&&Promise.resolve().then((function(){return Y}))}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}updated(t){super.updated(t),t.has("color")&&this.validateColor()}open(){this.dropdownController.open()}close(){this.dropdownController.close()}toggle(){this.dropdownController.toggle()}validateColor(){return this.isValidColor=this.eventController.isValidColor(this.color),this.isValidColor}setupEventListeners(){(this.closeOnOutsideClick||this.closeOnEscape)&&this.eventController.setupEventListeners()}removeEventListeners(){this.eventController.removeEventListeners()}render(){const t={"color-picker-container":!0,"color-picker-container--disabled":this.disabled,"color-picker-container--open":this.show,[`color-picker-container--${this.size}`]:!0};return o`
186
+ <div class="${l(t)}" data-theme="${this.currentTheme}">
259
187
  ${this.renderLabel()}
260
188
 
261
189
  <nr-colorholder-box
@@ -263,7 +191,7 @@ function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.def
263
191
  color="${this.color}"
264
192
  .size=${this.size}
265
193
  ?disabled="${this.disabled}"
266
- @click=${this.disabled?$t:this.handleTriggerClick}
194
+ @click=${this.disabled?r:this.handleTriggerClick}
267
195
  role="button"
268
196
  aria-label="Select color"
269
197
  aria-expanded="${this.show}"
@@ -274,11 +202,11 @@ function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.def
274
202
  ${this.renderDropdown()}
275
203
  ${this.renderHelperText()}
276
204
  </div>
277
- `}renderLabel(){return this.label?mt`
205
+ `}renderLabel(){return this.label?o`
278
206
  <label class="color-picker-label">
279
207
  ${this.label}
280
208
  </label>
281
- `:$t}renderDropdown(){return this.show?mt`
209
+ `:r}renderDropdown(){return this.show?o`
282
210
  <div
283
211
  class="dropdown-container"
284
212
  role="dialog"
@@ -288,19 +216,19 @@ function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.def
288
216
  ${this.renderColorPicker()}
289
217
  ${this.renderColorInput()}
290
218
  </div>
291
- `:$t}renderDefaultColorSets(){return this.defaultColorSets&&0!==this.defaultColorSets.length?mt`
219
+ `:r}renderDefaultColorSets(){return this.defaultColorSets&&0!==this.defaultColorSets.length?o`
292
220
  <nr-default-color-sets
293
221
  .defaultColorSets=${this.defaultColorSets}
294
222
  @color-click="${this.handleColorChanged}"
295
223
  aria-label="Preset colors">
296
224
  </nr-default-color-sets>
297
- `:$t}renderColorPicker(){return mt`
225
+ `:r}renderColorPicker(){return o`
298
226
  <hex-color-picker
299
227
  color="${this.color}"
300
228
  @color-changed="${this.handleColorChanged}"
301
229
  aria-label="Color gradient picker">
302
230
  </hex-color-picker>
303
- `}renderColorInput(){return this.showInput?mt`
231
+ `}renderColorInput(){return this.showInput?o`
304
232
  <nr-input
305
233
  type="text"
306
234
  .value="${this.color}"
@@ -311,8 +239,8 @@ function*(t,i){if(void 0!==t){let e=0;for(const s of t)yield i(s,e++)}}(this.def
311
239
  aria-label="Color value input"
312
240
  aria-invalid="${!this.isValidColor}">
313
241
  </nr-input>
314
- `:$t}renderHelperText(){return this.helperText?mt`
242
+ `:r}renderHelperText(){return this.helperText?o`
315
243
  <div class="color-picker-helper-text">
316
244
  ${this.helperText}
317
245
  </div>
318
- `:$t}};pi.styles=ai,vi([qt({type:String})],pi.prototype,"color",void 0),vi([qt({type:Boolean,reflect:!0})],pi.prototype,"show",void 0),vi([qt({type:Array,attribute:"default-color-sets"})],pi.prototype,"defaultColorSets",void 0),vi([qt({type:Boolean,reflect:!0})],pi.prototype,"disabled",void 0),vi([qt({type:String,reflect:!0})],pi.prototype,"size",void 0),vi([qt({type:String,reflect:!0})],pi.prototype,"trigger",void 0),vi([qt({type:String,reflect:!0})],pi.prototype,"placement",void 0),vi([qt({type:String,reflect:!0})],pi.prototype,"animation",void 0),vi([qt({type:Boolean,attribute:"close-on-select"})],pi.prototype,"closeOnSelect",void 0),vi([qt({type:Boolean,attribute:"close-on-outside-click"})],pi.prototype,"closeOnOutsideClick",void 0),vi([qt({type:Boolean,attribute:"close-on-escape"})],pi.prototype,"closeOnEscape",void 0),vi([qt({type:Boolean,attribute:"show-input"})],pi.prototype,"showInput",void 0),vi([qt({type:Boolean,attribute:"show-copy-button"})],pi.prototype,"showCopyButton",void 0),vi([qt({type:String,reflect:!0})],pi.prototype,"format",void 0),vi([qt({type:String,attribute:"input-placeholder"})],pi.prototype,"inputPlaceholder",void 0),vi([qt({type:String})],pi.prototype,"label",void 0),vi([qt({type:String,attribute:"helper-text"})],pi.prototype,"helperText",void 0),vi([function(t){return qt({...t,state:!0})}()],pi.prototype,"isValidColor",void 0),pi=vi([Lt("nr-color-picker")],pi);const fi=(t,i=0,e=1)=>t>e?e:t<i?i:t,bi=(t,i=0,e=Math.pow(10,i))=>Math.round(e*t)/e,yi=t=>("#"===t[0]&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?bi(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:8===t.length?bi(parseInt(t.substring(6,8),16)/255,2):1}),gi=t=>{const{h:i,s:e,l:s}=(({h:t,s:i,v:e,a:s})=>{const o=(200-i)*e/100;return{h:bi(t),s:bi(o>0&&o<200?i*e/100/(o<=100?o:200-o)*100:0),l:bi(o/2),a:bi(s,2)}})(t);return`hsl(${i}, ${e}%, ${s}%)`},mi=({h:t,s:i,v:e,a:s})=>{t=t/360*6,i/=100,e/=100;const o=Math.floor(t),r=e*(1-i),n=e*(1-(t-o)*i),l=e*(1-(1-t+o)*i),h=o%6;return{r:bi(255*[e,n,r,r,l,e][h]),g:bi(255*[l,e,e,n,r,r][h]),b:bi(255*[r,r,l,e,e,n][h]),a:bi(s,2)}},wi=t=>{const i=t.toString(16);return i.length<2?"0"+i:i},$i=({r:t,g:i,b:e,a:s})=>{const o=s<1?wi(bi(255*s)):"";return"#"+wi(t)+wi(i)+wi(e)+o},xi=({r:t,g:i,b:e,a:s})=>{const o=Math.max(t,i,e),r=o-Math.min(t,i,e),n=r?o===t?(i-e)/r:o===i?2+(e-t)/r:4+(t-i)/r:0;return{h:bi(60*(n<0?n+6:n)),s:bi(o?r/o*100:0),v:bi(o/255*100),a:s}},ki=(t,i)=>{if(t===i)return!0;for(const e in t)if(t[e]!==i[e])return!1;return!0},Ci={},Si=t=>{let i=Ci[t];return i||(i=document.createElement("template"),i.innerHTML=t,Ci[t]=i),i},Ei=(t,i,e)=>{t.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:e}))};let Ai=!1;const _i=t=>"touches"in t,Oi=(t,i)=>{const e=_i(i)?i.touches[0]:i,s=t.el.getBoundingClientRect();Ei(t.el,"move",t.getMove({x:fi((e.pageX-(s.left+window.pageXOffset))/s.width),y:fi((e.pageY-(s.top+window.pageYOffset))/s.height)}))};class zi{constructor(t,i,e,s){const o=Si(`<div role="slider" tabindex="0" part="${i}" ${e}><div part="${i}-pointer"></div></div>`);t.appendChild(o.content.cloneNode(!0));const r=t.querySelector(`[part=${i}]`);r.addEventListener("mousedown",this),r.addEventListener("touchstart",this),r.addEventListener("keydown",this),this.el=r,this.xy=s,this.nodes=[r.firstChild,r]}set dragging(t){const i=t?document.addEventListener:document.removeEventListener;i(Ai?"touchmove":"mousemove",this),i(Ai?"touchend":"mouseup",this)}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":if(t.preventDefault(),!(t=>!(Ai&&!_i(t)||(Ai||(Ai=_i(t)),0)))(t)||!Ai&&0!=t.button)return;this.el.focus(),Oi(this,t),this.dragging=!0;break;case"mousemove":case"touchmove":t.preventDefault(),Oi(this,t);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((t,i)=>{const e=i.keyCode;e>40||t.xy&&e<37||e<33||(i.preventDefault(),Ei(t.el,"move",t.getMove({x:39===e?.01:37===e?-.01:34===e?.05:33===e?-.05:35===e?1:36===e?-1:0,y:40===e?.01:38===e?-.01:0},!0)))})(this,t)}}style(t){t.forEach(((t,i)=>{for(const e in t)this.nodes[i].style.setProperty(e,t[e])}))}}class Mi extends zi{constructor(t){super(t,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:t}){this.h=t,this.style([{left:t/360*100+"%",color:gi({h:t,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${bi(t)}`)}getMove(t,i){return{h:i?fi(this.h+360*t.x,0,360):360*t.x}}}class ji extends zi{constructor(t){super(t,"saturation",'aria-label="Color"',!0)}update(t){this.hsva=t,this.style([{top:100-t.v+"%",left:`${t.s}%`,color:gi(t)},{"background-color":gi({h:t.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${bi(t.s)}%, Brightness ${bi(t.v)}%`)}getMove(t,i){return{s:i?fi(this.hsva.s+100*t.x,0,100):100*t.x,v:i?fi(this.hsva.v-100*t.y,0,100):Math.round(100-100*t.y)}}}const Ti=Symbol("same"),Pi=Symbol("color"),Ui=Symbol("hsva"),Ii=Symbol("update"),Ri=Symbol("parts"),Ni=Symbol("css"),Di=Symbol("sliders");class Bi extends HTMLElement{static get observedAttributes(){return["color"]}get[Ni](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[Di](){return[ji,Mi]}get color(){return this[Pi]}set color(t){if(!this[Ti](t)){const i=this.colorModel.toHsva(t);this[Ii](i),this[Pi]=t}}constructor(){super();const t=Si(`<style>${this[Ni].join("")}</style>`),i=this.attachShadow({mode:"open"});i.appendChild(t.content.cloneNode(!0)),i.addEventListener("move",this),this[Ri]=this[Di].map((t=>new t(i)))}connectedCallback(){if(this.hasOwnProperty("color")){const t=this.color;delete this.color,this.color=t}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(t,i,e){const s=this.colorModel.fromAttr(e);this[Ti](s)||(this.color=s)}handleEvent(t){const i=this[Ui],e={...i,...t.detail};let s;this[Ii](e),ki(e,i)||this[Ti](s=this.colorModel.fromHsva(e))||(this[Pi]=s,Ei(this,"color-changed",{value:s}))}[Ti](t){return this.color&&this.colorModel.equal(t,this.color)}[Ii](t){this[Ui]=t,this[Ri].forEach((i=>i.update(t)))}}const Li={defaultColor:"#000",toHsva:t=>xi(yi(t)),fromHsva:({h:t,s:i,v:e})=>$i(mi({h:t,s:i,v:e,a:1})),equal:(t,i)=>t.toLowerCase()===i.toLowerCase()||ki(yi(t),yi(i)),fromAttr:t=>t};class Hi extends Bi{get colorModel(){return Li}}class Vi extends Hi{}customElements.define("hex-color-picker",Vi);var qi=Object.freeze({__proto__:null,HexColorPicker:Vi});export{ri as ColorHolderBox,pi as ColorPicker};
246
+ `:r}};k.styles=m,w([i({type:String})],k.prototype,"color",void 0),w([i({type:Boolean,reflect:!0})],k.prototype,"show",void 0),w([i({type:Array,attribute:"default-color-sets"})],k.prototype,"defaultColorSets",void 0),w([i({type:Boolean,reflect:!0})],k.prototype,"disabled",void 0),w([i({type:String,reflect:!0})],k.prototype,"size",void 0),w([i({type:String,reflect:!0})],k.prototype,"trigger",void 0),w([i({type:String,reflect:!0})],k.prototype,"placement",void 0),w([i({type:String,reflect:!0})],k.prototype,"animation",void 0),w([i({type:Boolean,attribute:"close-on-select"})],k.prototype,"closeOnSelect",void 0),w([i({type:Boolean,attribute:"close-on-outside-click"})],k.prototype,"closeOnOutsideClick",void 0),w([i({type:Boolean,attribute:"close-on-escape"})],k.prototype,"closeOnEscape",void 0),w([i({type:Boolean,attribute:"show-input"})],k.prototype,"showInput",void 0),w([i({type:Boolean,attribute:"show-copy-button"})],k.prototype,"showCopyButton",void 0),w([i({type:String,reflect:!0})],k.prototype,"format",void 0),w([i({type:String,attribute:"input-placeholder"})],k.prototype,"inputPlaceholder",void 0),w([i({type:String})],k.prototype,"label",void 0),w([i({type:String,attribute:"helper-text"})],k.prototype,"helperText",void 0),w([n()],k.prototype,"isValidColor",void 0),k=w([s("nr-color-picker")],k);const $=(t,e=0,o=1)=>t>o?o:t<e?e:t,C=(t,e=0,o=Math.pow(10,e))=>Math.round(o*t)/o,S=t=>("#"===t[0]&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?C(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:8===t.length?C(parseInt(t.substring(6,8),16)/255,2):1}),E=t=>{const{h:e,s:o,l:r}=(({h:t,s:e,v:o,a:r})=>{const i=(200-e)*o/100;return{h:C(t),s:C(i>0&&i<200?e*o/100/(i<=100?i:200-i)*100:0),l:C(i/2),a:C(r,2)}})(t);return`hsl(${e}, ${o}%, ${r}%)`},z=({h:t,s:e,v:o,a:r})=>{t=t/360*6,e/=100,o/=100;const i=Math.floor(t),s=o*(1-e),n=o*(1-(t-i)*e),l=o*(1-(1-t+i)*e),a=i%6;return{r:C(255*[o,n,s,s,l,o][a]),g:C(255*[l,o,o,n,s,s][a]),b:C(255*[s,s,l,o,o,n][a]),a:C(r,2)}},O=t=>{const e=t.toString(16);return e.length<2?"0"+e:e},P=({r:t,g:e,b:o,a:r})=>{const i=r<1?O(C(255*r)):"";return"#"+O(t)+O(e)+O(o)+i},j=({r:t,g:e,b:o,a:r})=>{const i=Math.max(t,e,o),s=i-Math.min(t,e,o),n=s?i===t?(e-o)/s:i===e?2+(o-t)/s:4+(t-e)/s:0;return{h:C(60*(n<0?n+6:n)),s:C(i?s/i*100:0),v:C(i/255*100),a:r}},B=(t,e)=>{if(t===e)return!0;for(const o in t)if(t[o]!==e[o])return!1;return!0},I={},M=t=>{let e=I[t];return e||(e=document.createElement("template"),e.innerHTML=t,I[t]=e),e},A=(t,e,o)=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:o}))};let L=!1;const T=t=>"touches"in t,H=(t,e)=>{const o=T(e)?e.touches[0]:e,r=t.el.getBoundingClientRect();A(t.el,"move",t.getMove({x:$((o.pageX-(r.left+window.pageXOffset))/r.width),y:$((o.pageY-(r.top+window.pageYOffset))/r.height)}))};class V{constructor(t,e,o,r){const i=M(`<div role="slider" tabindex="0" part="${e}" ${o}><div part="${e}-pointer"></div></div>`);t.appendChild(i.content.cloneNode(!0));const s=t.querySelector(`[part=${e}]`);s.addEventListener("mousedown",this),s.addEventListener("touchstart",this),s.addEventListener("keydown",this),this.el=s,this.xy=r,this.nodes=[s.firstChild,s]}set dragging(t){const e=t?document.addEventListener:document.removeEventListener;e(L?"touchmove":"mousemove",this),e(L?"touchend":"mouseup",this)}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":if(t.preventDefault(),!(t=>!(L&&!T(t)||(L||(L=T(t)),0)))(t)||!L&&0!=t.button)return;this.el.focus(),H(this,t),this.dragging=!0;break;case"mousemove":case"touchmove":t.preventDefault(),H(this,t);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((t,e)=>{const o=e.keyCode;o>40||t.xy&&o<37||o<33||(e.preventDefault(),A(t.el,"move",t.getMove({x:39===o?.01:37===o?-.01:34===o?.05:33===o?-.05:35===o?1:36===o?-1:0,y:40===o?.01:38===o?-.01:0},!0)))})(this,t)}}style(t){t.forEach(((t,e)=>{for(const o in t)this.nodes[e].style.setProperty(o,t[o])}))}}class q extends V{constructor(t){super(t,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:t}){this.h=t,this.style([{left:t/360*100+"%",color:E({h:t,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${C(t)}`)}getMove(t,e){return{h:e?$(this.h+360*t.x,0,360):360*t.x}}}class D extends V{constructor(t){super(t,"saturation",'aria-label="Color"',!0)}update(t){this.hsva=t,this.style([{top:100-t.v+"%",left:`${t.s}%`,color:E(t)},{"background-color":E({h:t.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${C(t.s)}%, Brightness ${C(t.v)}%`)}getMove(t,e){return{s:e?$(this.hsva.s+100*t.x,0,100):100*t.x,v:e?$(this.hsva.v-100*t.y,0,100):Math.round(100-100*t.y)}}}const F=Symbol("same"),_=Symbol("color"),N=Symbol("hsva"),U=Symbol("update"),W=Symbol("parts"),G=Symbol("css"),K=Symbol("sliders");class R extends HTMLElement{static get observedAttributes(){return["color"]}get[G](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[K](){return[D,q]}get color(){return this[_]}set color(t){if(!this[F](t)){const e=this.colorModel.toHsva(t);this[U](e),this[_]=t}}constructor(){super();const t=M(`<style>${this[G].join("")}</style>`),e=this.attachShadow({mode:"open"});e.appendChild(t.content.cloneNode(!0)),e.addEventListener("move",this),this[W]=this[K].map((t=>new t(e)))}connectedCallback(){if(this.hasOwnProperty("color")){const t=this.color;delete this.color,this.color=t}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(t,e,o){const r=this.colorModel.fromAttr(o);this[F](r)||(this.color=r)}handleEvent(t){const e=this[N],o={...e,...t.detail};let r;this[U](o),B(o,e)||this[F](r=this.colorModel.fromHsva(o))||(this[_]=r,A(this,"color-changed",{value:r}))}[F](t){return this.color&&this.colorModel.equal(t,this.color)}[U](t){this[N]=t,this[W].forEach((e=>e.update(t)))}}const J={defaultColor:"#000",toHsva:t=>j(S(t)),fromHsva:({h:t,s:e,v:o})=>P(z({h:t,s:e,v:o,a:1})),equal:(t,e)=>t.toLowerCase()===e.toLowerCase()||B(S(t),S(e)),fromAttr:t=>t};class Q extends R{get colorModel(){return J}}class X extends Q{}customElements.define("hex-color-picker",X);var Y=Object.freeze({__proto__:null,HexColorPicker:X});export{p as ColorHolderBox,k as ColorPicker};
@@ -40,6 +40,6 @@ export declare class DefaultColorSets extends LitElement {
40
40
  * Validates if a color string is valid CSS color
41
41
  */
42
42
  private isValidColor;
43
- render(): import("lit").TemplateResult<1> | typeof nothing;
43
+ render(): typeof nothing | import("lit").TemplateResult<1>;
44
44
  }
45
45
  //# sourceMappingURL=default-color-sets.component.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuralyui/colorpicker",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",