@nuralyui/tooltips 0.0.4 → 0.0.6

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,173 +1 @@
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,s=Symbol(),o=new WeakMap;class e{constructor(t,i,o){if(this._$cssResult$=!0,o!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const s=this.t;if(i&&void 0===t){const i=void 0!==s&&1===s.length;i&&(t=o.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&o.set(s,t))}return t}toString(){return this.cssText}}const n=(t,...i)=>{const o=1===t.length?t[0]:i.reduce(((i,s,o)=>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.")})(s)+t[o+1]),t[0]);return new e(o,t,s)},h=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let i="";for(const s of t.cssRules)i+=s.cssText;return(t=>new e("string"==typeof t?t:t+"",void 0,s))(i)})(t):t
7
- /**
8
- * @license
9
- * Copyright 2017 Google LLC
10
- * SPDX-License-Identifier: BSD-3-Clause
11
- */;var r;const l=window,a=l.trustedTypes,c=a?a.emptyScript:"",d=l.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 s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},v=(t,i)=>i!==t&&(i==i||t==t),p={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:v},f="finalized";class g 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,s)=>{const o=this._$Ep(s,i);void 0!==o&&(this._$Ev.set(o,s),t.push(o))})),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 s="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,s,i);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,i,s){return{get(){return this[i]},set(o){const e=this[t];this[i]=o,this.requestUpdate(t,e,s)},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 s of i)this.createProperty(s,t[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)i.unshift(h(t))}else void 0!==t&&i.push(h(t));return i}static _$Ep(t,i){const s=i.attribute;return!1===s?void 0:"string"==typeof s?s:"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,s;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.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 s;const o=null!==(s=this.shadowRoot)&&void 0!==s?s:this.attachShadow(this.constructor.shadowRootOptions);return((s,o)=>{i?s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):o.forEach((i=>{const o=document.createElement("style"),e=t.litNonce;void 0!==e&&o.setAttribute("nonce",e),o.textContent=i.cssText,s.appendChild(o)}))})(o,this.constructor.elementStyles),o}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,s){this._$AK(t,s)}_$EO(t,i,s=p){var o;const e=this.constructor._$Ep(t,s);if(void 0!==e&&!0===s.reflect){const n=(void 0!==(null===(o=s.converter)||void 0===o?void 0:o.toAttribute)?s.converter:u).toAttribute(i,s.type);this._$El=t,null==n?this.removeAttribute(e):this.setAttribute(e,n),this._$El=null}}_$AK(t,i){var s;const o=this.constructor,e=o._$Ev.get(t);if(void 0!==e&&this._$El!==e){const t=o.getPropertyOptions(e),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(s=t.converter)||void 0===s?void 0:s.fromAttribute)?t.converter:u;this._$El=e,this[e]=n.fromAttribute(i,t.type),this._$El=null}}requestUpdate(t,i,s){let o=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||v)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):o=!1),!this.isUpdatePending&&o&&(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 s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),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(s)):this._$Ek()}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(s)}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 m;g[f]=!0,g.elementProperties=new Map,g.elementStyles=[],g.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:g}),(null!==(r=l.reactiveElementVersions)&&void 0!==r?r:l.reactiveElementVersions=[]).push("1.6.3");const y=window,b=y.trustedTypes,$=b?b.createPolicy("lit-html",{createHTML:t=>t}):void 0,w="$lit$",x=`lit$${(Math.random()+"").slice(9)}$`,S="?"+x,k=`<${S}>`,A=document,C=()=>A.createComment(""),_=t=>null===t||"object"!=typeof t&&"function"!=typeof t,E=Array.isArray,T="[ \t\n\f\r]",j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,U=/-->/g,M=/>/g,N=RegExp(`>|${T}(?:([^\\s"'>=/]+)(${T}*=${T}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),z=/'/g,O=/"/g,R=/^(?:script|style|textarea|title)$/i,I=Symbol.for("lit-noChange"),P=Symbol.for("lit-nothing"),L=new WeakMap,Z=A.createTreeWalker(A,129,null,!1);function B(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==$?$.createHTML(i):i}class D{constructor({strings:t,_$litType$:i},s){let o;this.parts=[];let e=0,n=0;const h=t.length-1,r=this.parts,[l,a]=((t,i)=>{const s=t.length-1,o=[];let e,n=2===i?"<svg>":"",h=j;for(let i=0;i<s;i++){const s=t[i];let r,l,a=-1,c=0;for(;c<s.length&&(h.lastIndex=c,l=h.exec(s),null!==l);)c=h.lastIndex,h===j?"!--"===l[1]?h=U:void 0!==l[1]?h=M:void 0!==l[2]?(R.test(l[2])&&(e=RegExp("</"+l[2],"g")),h=N):void 0!==l[3]&&(h=N):h===N?">"===l[0]?(h=null!=e?e:j,a=-1):void 0===l[1]?a=-2:(a=h.lastIndex-l[2].length,r=l[1],h=void 0===l[3]?N:'"'===l[3]?O:z):h===O||h===z?h=N:h===U||h===M?h=j:(h=N,e=void 0);const d=h===N&&t[i+1].startsWith("/>")?" ":"";n+=h===j?s+k:a>=0?(o.push(r),s.slice(0,a)+w+s.slice(a)+x+d):s+x+(-2===a?(o.push(void 0),i):d)}return[B(t,n+(t[s]||"<?>")+(2===i?"</svg>":"")),o]})(t,i);if(this.el=D.createElement(l,s),Z.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(o=Z.nextNode())&&r.length<h;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const i of o.getAttributeNames())if(i.endsWith(w)||i.startsWith(x)){const s=a[n++];if(t.push(i),void 0!==s){const t=o.getAttribute(s.toLowerCase()+w).split(x),i=/([.?@])?(.*)/.exec(s);r.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?q:"?"===i[1]?Y:"@"===i[1]?F:K})}else r.push({type:6,index:e})}for(const i of t)o.removeAttribute(i)}if(R.test(o.tagName)){const t=o.textContent.split(x),i=t.length-1;if(i>0){o.textContent=b?b.emptyScript:"";for(let s=0;s<i;s++)o.append(t[s],C()),Z.nextNode(),r.push({type:2,index:++e});o.append(t[i],C())}}}else if(8===o.nodeType)if(o.data===S)r.push({type:2,index:e});else{let t=-1;for(;-1!==(t=o.data.indexOf(x,t+1));)r.push({type:7,index:e}),t+=x.length-1}e++}}static createElement(t,i){const s=A.createElement("template");return s.innerHTML=t,s}}function H(t,i,s=t,o){var e,n,h,r;if(i===I)return i;let l=void 0!==o?null===(e=s._$Co)||void 0===e?void 0:e[o]:s._$Cl;const a=_(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==a&&(null===(n=null==l?void 0:l._$AO)||void 0===n||n.call(l,!1),void 0===a?l=void 0:(l=new a(t),l._$AT(t,s,o)),void 0!==o?(null!==(h=(r=s)._$Co)&&void 0!==h?h:r._$Co=[])[o]=l:s._$Cl=l),void 0!==l&&(i=H(t,l._$AS(t,i.values),l,o)),i}class W{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:s},parts:o}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:A).importNode(s,!0);Z.currentNode=e;let n=Z.nextNode(),h=0,r=0,l=o[0];for(;void 0!==l;){if(h===l.index){let i;2===l.type?i=new J(n,n.nextSibling,this,t):1===l.type?i=new l.ctor(n,l.name,l.strings,this,t):6===l.type&&(i=new G(n,this,t)),this._$AV.push(i),l=o[++r]}h!==(null==l?void 0:l.index)&&(n=Z.nextNode(),h++)}return Z.currentNode=A,e}v(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class J{constructor(t,i,s,o){var e;this.type=2,this._$AH=P,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=o,this._$Cp=null===(e=null==o?void 0:o.isConnected)||void 0===e||e}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=H(this,t,i),_(t)?t===P||null==t||""===t?(this._$AH!==P&&this._$AR(),this._$AH=P):t!==this._$AH&&t!==I&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>E(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!==P&&_(this._$AH)?this._$AA.nextSibling.data=t:this.$(A.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:o}=t,e="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=D.createElement(B(o.h,o.h[0]),this.options)),o);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.v(s);else{const t=new W(e,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=L.get(t.strings);return void 0===i&&L.set(t.strings,i=new D(t)),i}T(t){E(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,o=0;for(const e of t)o===i.length?i.push(s=new J(this.k(C()),this.k(C()),this,this.options)):s=i[o],s._$AI(e),o++;o<i.length&&(this._$AR(s&&s._$AB.nextSibling,o),i.length=o)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.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,s,o,e){this.type=1,this._$AH=P,this._$AN=void 0,this.element=t,this.name=i,this._$AM=o,this.options=e,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=P}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,o){const e=this.strings;let n=!1;if(void 0===e)t=H(this,t,i,0),n=!_(t)||t!==this._$AH&&t!==I,n&&(this._$AH=t);else{const o=t;let h,r;for(t=e[0],h=0;h<e.length-1;h++)r=H(this,o[s+h],i,h),r===I&&(r=this._$AH[h]),n||(n=!_(r)||r!==this._$AH[h]),r===P?t=P:t!==P&&(t+=(null!=r?r:"")+e[h+1]),this._$AH[h]=r}n&&!o&&this.j(t)}j(t){t===P?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class q extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===P?void 0:t}}const V=b?b.emptyScript:"";class Y extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==P?this.element.setAttribute(this.name,V):this.element.removeAttribute(this.name)}}class F extends K{constructor(t,i,s,o,e){super(t,i,s,o,e),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=H(this,t,i,0))&&void 0!==s?s:P)===I)return;const o=this._$AH,e=t===P&&o!==P||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,n=t!==P&&(o===P||e);e&&this.element.removeEventListener(this.name,this,o),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class G{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){H(this,t)}}const Q=y.litHtmlPolyfillSupport;
18
- /**
19
- * @license
20
- * Copyright 2017 Google LLC
21
- * SPDX-License-Identifier: BSD-3-Clause
22
- */
23
- var X;null==Q||Q(D,J),(null!==(m=y.litHtmlVersions)&&void 0!==m?m:y.litHtmlVersions=[]).push("2.8.0");const tt=window,it=tt.trustedTypes,st=it?it.createPolicy("lit-html",{createHTML:t=>t}):void 0,ot="$lit$",et=`lit$${(Math.random()+"").slice(9)}$`,nt="?"+et,ht=`<${nt}>`,rt=document,lt=()=>rt.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"),gt=/'/g,mt=/"/g,yt=/^(?:script|style|textarea|title)$/i,bt=(t=>(i,...s)=>({_$litType$:t,strings:i,values:s}))(1),$t=Symbol.for("lit-noChange"),wt=Symbol.for("lit-nothing"),xt=new WeakMap,St=rt.createTreeWalker(rt,129,null,!1);function kt(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==st?st.createHTML(i):i}const At=(t,i)=>{const s=t.length-1,o=[];let e,n=2===i?"<svg>":"",h=ut;for(let i=0;i<s;i++){const s=t[i];let r,l,a=-1,c=0;for(;c<s.length&&(h.lastIndex=c,l=h.exec(s),null!==l);)c=h.lastIndex,h===ut?"!--"===l[1]?h=vt:void 0!==l[1]?h=pt:void 0!==l[2]?(yt.test(l[2])&&(e=RegExp("</"+l[2],"g")),h=ft):void 0!==l[3]&&(h=ft):h===ft?">"===l[0]?(h=null!=e?e:ut,a=-1):void 0===l[1]?a=-2:(a=h.lastIndex-l[2].length,r=l[1],h=void 0===l[3]?ft:'"'===l[3]?mt:gt):h===mt||h===gt?h=ft:h===vt||h===pt?h=ut:(h=ft,e=void 0);const d=h===ft&&t[i+1].startsWith("/>")?" ":"";n+=h===ut?s+ht:a>=0?(o.push(r),s.slice(0,a)+ot+s.slice(a)+et+d):s+et+(-2===a?(o.push(void 0),i):d)}return[kt(t,n+(t[s]||"<?>")+(2===i?"</svg>":"")),o]};class Ct{constructor({strings:t,_$litType$:i},s){let o;this.parts=[];let e=0,n=0;const h=t.length-1,r=this.parts,[l,a]=At(t,i);if(this.el=Ct.createElement(l,s),St.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(o=St.nextNode())&&r.length<h;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const i of o.getAttributeNames())if(i.endsWith(ot)||i.startsWith(et)){const s=a[n++];if(t.push(i),void 0!==s){const t=o.getAttribute(s.toLowerCase()+ot).split(et),i=/([.?@])?(.*)/.exec(s);r.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?Ut:"?"===i[1]?Nt:"@"===i[1]?zt:jt})}else r.push({type:6,index:e})}for(const i of t)o.removeAttribute(i)}if(yt.test(o.tagName)){const t=o.textContent.split(et),i=t.length-1;if(i>0){o.textContent=it?it.emptyScript:"";for(let s=0;s<i;s++)o.append(t[s],lt()),St.nextNode(),r.push({type:2,index:++e});o.append(t[i],lt())}}}else if(8===o.nodeType)if(o.data===nt)r.push({type:2,index:e});else{let t=-1;for(;-1!==(t=o.data.indexOf(et,t+1));)r.push({type:7,index:e}),t+=et.length-1}e++}}static createElement(t,i){const s=rt.createElement("template");return s.innerHTML=t,s}}function _t(t,i,s=t,o){var e,n,h,r;if(i===$t)return i;let l=void 0!==o?null===(e=s._$Co)||void 0===e?void 0:e[o]:s._$Cl;const a=at(i)?void 0:i._$litDirective$;return(null==l?void 0:l.constructor)!==a&&(null===(n=null==l?void 0:l._$AO)||void 0===n||n.call(l,!1),void 0===a?l=void 0:(l=new a(t),l._$AT(t,s,o)),void 0!==o?(null!==(h=(r=s)._$Co)&&void 0!==h?h:r._$Co=[])[o]=l:s._$Cl=l),void 0!==l&&(i=_t(t,l._$AS(t,i.values),l,o)),i}class Et{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:s},parts:o}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:rt).importNode(s,!0);St.currentNode=e;let n=St.nextNode(),h=0,r=0,l=o[0];for(;void 0!==l;){if(h===l.index){let i;2===l.type?i=new Tt(n,n.nextSibling,this,t):1===l.type?i=new l.ctor(n,l.name,l.strings,this,t):6===l.type&&(i=new Ot(n,this,t)),this._$AV.push(i),l=o[++r]}h!==(null==l?void 0:l.index)&&(n=St.nextNode(),h++)}return St.currentNode=rt,e}v(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class Tt{constructor(t,i,s,o){var e;this.type=2,this._$AH=wt,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=o,this._$Cp=null===(e=null==o?void 0:o.isConnected)||void 0===e||e}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=_t(this,t,i),at(t)?t===wt||null==t||""===t?(this._$AH!==wt&&this._$AR(),this._$AH=wt):t!==this._$AH&&t!==$t&&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!==wt&&at(this._$AH)?this._$AA.nextSibling.data=t:this.$(rt.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:o}=t,e="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=Ct.createElement(kt(o.h,o.h[0]),this.options)),o);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.v(s);else{const t=new Et(e,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=xt.get(t.strings);return void 0===i&&xt.set(t.strings,i=new Ct(t)),i}T(t){ct(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,o=0;for(const e of t)o===i.length?i.push(s=new Tt(this.k(lt()),this.k(lt()),this,this.options)):s=i[o],s._$AI(e),o++;o<i.length&&(this._$AR(s&&s._$AB.nextSibling,o),i.length=o)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.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 jt{constructor(t,i,s,o,e){this.type=1,this._$AH=wt,this._$AN=void 0,this.element=t,this.name=i,this._$AM=o,this.options=e,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=wt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,o){const e=this.strings;let n=!1;if(void 0===e)t=_t(this,t,i,0),n=!at(t)||t!==this._$AH&&t!==$t,n&&(this._$AH=t);else{const o=t;let h,r;for(t=e[0],h=0;h<e.length-1;h++)r=_t(this,o[s+h],i,h),r===$t&&(r=this._$AH[h]),n||(n=!at(r)||r!==this._$AH[h]),r===wt?t=wt:t!==wt&&(t+=(null!=r?r:"")+e[h+1]),this._$AH[h]=r}n&&!o&&this.j(t)}j(t){t===wt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Ut extends jt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===wt?void 0:t}}const Mt=it?it.emptyScript:"";class Nt extends jt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==wt?this.element.setAttribute(this.name,Mt):this.element.removeAttribute(this.name)}}class zt extends jt{constructor(t,i,s,o,e){super(t,i,s,o,e),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=_t(this,t,i,0))&&void 0!==s?s:wt)===$t)return;const o=this._$AH,e=t===wt&&o!==wt||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,n=t!==wt&&(o===wt||e);e&&this.element.removeEventListener(this.name,this,o),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class Ot{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){_t(this,t)}}const Rt=tt.litHtmlPolyfillSupport;null==Rt||Rt(Ct,Tt),(null!==(X=tt.litHtmlVersions)&&void 0!==X?X:tt.litHtmlVersions=[]).push("2.8.0");
24
- /**
25
- * @license
26
- * Copyright 2017 Google LLC
27
- * SPDX-License-Identifier: BSD-3-Clause
28
- */
29
- var It,Pt;class Lt extends g{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,i;const s=super.createRenderRoot();return null!==(t=(i=this.renderOptions).renderBefore)&&void 0!==t||(i.renderBefore=s.firstChild),s}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,i,s)=>{var o,e;const n=null!==(o=null==s?void 0:s.renderBefore)&&void 0!==o?o:i;let h=n._$litPart$;if(void 0===h){const t=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:null;n._$litPart$=h=new Tt(i.insertBefore(lt(),t),t,void 0,null!=s?s:{})}return h._$AI(t),h})(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 $t}}Lt.finalized=!0,Lt._$litElement$=!0,null===(It=globalThis.litElementHydrateSupport)||void 0===It||It.call(globalThis,{LitElement:Lt});const Zt=globalThis.litElementPolyfillSupport;null==Zt||Zt({LitElement:Lt}),(null!==(Pt=globalThis.litElementVersions)&&void 0!==Pt?Pt:globalThis.litElementVersions=[]).push("3.3.3");
30
- /**
31
- * @license
32
- * Copyright 2017 Google LLC
33
- * SPDX-License-Identifier: BSD-3-Clause
34
- */
35
- const Bt=(t,i)=>"method"===i.kind&&i.descriptor&&!("value"in i.descriptor)?{...i,finisher(s){s.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(s){s.createProperty(i.key,t)}},Dt=(t,i,s)=>{i.constructor.createProperty(s,t)};
36
- /**
37
- * @license
38
- * Copyright 2017 Google LLC
39
- * SPDX-License-Identifier: BSD-3-Clause
40
- */function Ht(t){return(i,s)=>void 0!==s?Dt(t,i,s):Bt(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 Wt;null===(Wt=window.HTMLSlotElement)||void 0===Wt||Wt.prototype.assignedElements;const Jt=[n`
52
- :host([show]) {
53
- background-color: var(--nuraly-tooltip-background-color);
54
- color: var(--nuraly-tooltip-text-color);
55
- position: fixed;
56
- padding: 5px;
57
- text-align: center;
58
- opacity: 0;
59
- font-size: 14px;
60
- z-index: 9999;
61
- border-radius: 4px;
62
- animation-name: show-animation;
63
- animation-duration: 0.4s;
64
- animation-fill-mode: forwards;
65
- }
66
-
67
- .popconfirm-container {
68
- display: flex;
69
- flex-direction: column;
70
- }
71
- .btn-block {
72
- display: flex;
73
- justify-content: end;
74
- gap: 10px;
75
- margin: 10px;
76
- }
77
-
78
- .popconfirm-description,
79
- .popconfirm-title {
80
- margin: 5px;
81
- text-align: left;
82
- }
83
- .popconfirm-title {
84
- font-weight: bold;
85
- }
86
-
87
- @keyframes show-animation {
88
- from {
89
- opacity: 0;
90
- }
91
- to {
92
- opacity: 1;
93
- }
94
- }
95
-
96
- :host::after {
97
- content: '';
98
- height: 0;
99
- width: 0;
100
- position: absolute;
101
- border: 5px solid transparent;
102
- }
103
- :host(.top-position)::after {
104
- border-top-color: var(--nuraly-tooltip-background-color);
105
- top: 100%;
106
- }
107
- :host(.left-position)::after {
108
- border-left-color: var(--nuraly-tooltip-background-color);
109
- left: 100%;
110
- }
111
-
112
- :host(.right-position)::after {
113
- border-right-color: var(--nuraly-tooltip-background-color);
114
- right: 100%;
115
- }
116
- :host(.bottom-position)::after {
117
- border-bottom-color: var(--nuraly-tooltip-background-color);
118
- bottom: 100%;
119
- }
120
- :host(.alignement-center.top-position)::after,
121
- :host(.alignement-center.bottom-position)::after {
122
- right: 50%;
123
- transform: translate(50%);
124
- }
125
-
126
- :host(.alignement-start.top-position)::after,
127
- :host(.alignement-start.bottom-position)::after {
128
- left: 4%;
129
- }
130
- :host(.top-position.alignement-end)::after,
131
- :host(.alignement-end.bottom-position)::after {
132
- right: 4%;
133
- }
134
-
135
- :host(.alignement-center.left-position)::after,
136
- :host(.alignement-center.right-position)::after {
137
- top: 50%;
138
- transform: translate(0%, -50%);
139
- }
140
-
141
- :host(.alignement-start.left-position)::after,
142
- :host(.alignement-start.right-position)::after {
143
- top: 5px;
144
- }
145
- :host(.alignement-end.left-position)::after,
146
- :host(.alignement-end.right-position)::after {
147
- bottom: 5px;
148
- }
149
- `,n`
150
- :host {
151
- --nuraly-tooltip-background-color: #393939;
152
- --nuraly-tooltip-text-color: #ffffff;
153
- }
154
- @media (prefers-color-scheme: dark) {
155
- :host {
156
- --nuraly-tooltip-background-color: #f4f4f4;
157
- --nuraly-tooltip-text-color: #161616;
158
- }
159
- }
160
- `];var Kt,qt;!function(t){t.Top="top",t.Bottom="bottom",t.Right="right",t.Left="left"}(Kt||(Kt={})),function(t){t.Start="start",t.Center="center",t.End="end"}(qt||(qt={}));var Vt=function(t,i,s,o){for(var e,n=arguments.length,h=n<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,s):o,r=t.length-1;r>=0;r--)(e=t[r])&&(h=(n<3?e(h):n>3?e(i,s,h):e(i,s))||h);return n>3&&h&&Object.defineProperty(i,s,h),h};let Yt=class extends Lt{constructor(){super(...arguments),this.position=Kt.Bottom,this.alignement=qt.Center,this.show=!1,this.isPopConfirm=!1,this.popConfirmTitle="",this.popConfirmDescription="",this.okText="Yes",this.cancelText="No",this.horizontalOffset=10,this.verticalOffset=10,this.onMouseOver=()=>{this.show=!0},this.onMouseLeave=()=>{this.show=!1,this.initStyles()},this.onClick=()=>{this.show=!this.show},this.calculatePosition=()=>{this.initStyles(),this.style.width=`${this.clientWidth}px`,this.position==Kt.Bottom||this.position==Kt.Top?(this.calculateYposition(),this.calculateYalignement()):(this.calculateXposition(),this.calculateXalignement())},this.calculateYposition=()=>{const t=this.target.getBoundingClientRect(),i=t.bottom,s=t.top,o=window.visualViewport.height,e=this.clientHeight,n=e+this.verticalOffset<o-i,h=e+this.verticalOffset<s;this.position==Kt.Bottom?n||!h?(this.classList.add("bottom-position"),this.style.top=`${i+this.verticalOffset}px`):(this.classList.add("top-position"),this.style.top=s-e-this.verticalOffset+"px"):h||!n?(this.classList.add("top-position"),this.style.top=s-e-this.verticalOffset+"px"):(this.classList.add("bottom-position"),this.style.top=`${i+this.verticalOffset}px`)},this.calculateYalignement=()=>{const t=this.target.getBoundingClientRect(),i=t.right,s=t.width,o=t.left,e=this.clientWidth,n=o+s/2,h=window.visualViewport.width,r=h-i+s/2;if(this.alignement==qt.Start){e+o<h?(this.classList.add("alignement-start"),this.style.left=o-this.horizontalOffset+"px"):(this.classList.add("alignement-end"),this.style.left=`${o-e+this.horizontalOffset}px`)}else if(this.alignement==qt.End){e<o?(this.classList.add("alignement-end"),this.style.left=`${o-e+this.horizontalOffset}px`):(this.classList.add("alignement-start"),this.style.left=o-this.horizontalOffset+"px")}else{const t=e<n;e/2<n&&e/2<r||e>n&&e>r?(this.classList.add("alignement-center"),this.style.left=o-e/2+s/2+"px"):t?(this.classList.add("alignement-end"),this.style.left=`${o-e+this.horizontalOffset}px`):(this.classList.add("alignement-start"),this.style.left=o-this.horizontalOffset+"px")}},this.calculateXposition=()=>{const t=this.target.getBoundingClientRect(),i=t.left,s=t.right,o=window.visualViewport.width,e=this.clientWidth,n=e+this.horizontalOffset<o-s,h=e+this.horizontalOffset<i;this.position==Kt.Right?n||!h?(this.classList.add("right-position"),this.style.left=`${s+this.horizontalOffset}px`):(this.classList.add("left-position"),this.style.left=i-e-this.horizontalOffset+"px"):h||!n?(this.classList.add("left-position"),this.style.left=i-e-this.horizontalOffset+"px"):(this.classList.add("right-position"),this.style.left=`${s+this.horizontalOffset}px`)},this.calculateXalignement=()=>{const t=this.target.getBoundingClientRect(),i=t.top,s=t.height,o=t.bottom,e=this.clientHeight,n=window.visualViewport.height,h=n-o;if(this.alignement==qt.End){e<i?(this.classList.add("alignement-end"),this.style.top=o-e+"px"):(this.classList.add("alignement-start"),this.style.top=i-s/4+"px")}else if(this.alignement==qt.Start){e<n-o?(this.classList.add("alignement-start"),this.style.top=i-s/4+"px"):(this.classList.add("alignement-end"),this.style.top=o-e+"px")}else{const t=e<i;e/2<i&&e/2<h||e>i&&e>h?(this.classList.add("alignement-center"),this.style.top=i+s/2-e/2+"px"):t?(this.classList.add("alignement-end"),this.style.top=o-e+"px"):(this.classList.add("alignement-start"),this.style.top=i-s/4+"px")}},this.onClickOutside=t=>{const i=t.composedPath();!i.includes(this.target)&&!i.includes(this)&&(this.show=!1)}}connectedCallback(){super.connectedCallback(),this.target=this.target||this.previousElementSibling,this.target?this.isPopConfirm?(document.addEventListener("scroll",this.calculatePosition),this.target.addEventListener("click",this.onClick),document.addEventListener("click",this.onClickOutside)):(this.target.addEventListener("mouseover",this.onMouseOver),this.target.addEventListener("mouseleave",this.onMouseLeave)):console.error("Tooltip target is not defined or found. Ensure target is explicitly set or precedes the tooltip.")}initStyles(){this.style.top="",this.style.left="",this.style.width="",this.classList.remove(...this.classList.values())}updated(t){this.show&&this.calculatePosition()}onPopConfirmCancel(){this.dispatchEvent(new CustomEvent("onCancel")),this.show=!1,this.initStyles()}onPopConfirmConfirm(){this.dispatchEvent(new CustomEvent("onConfirm")),this.show=!1,this.initStyles()}disconnectedCallback(){super.disconnectedCallback(),this.isPopConfirm?(this.target.removeEventListener("click",this.onClick),document.removeEventListener("scroll",this.calculatePosition)):(this.target.removeEventListener("mouseover",this.onMouseOver),this.target.removeEventListener("mouseleave",this.onMouseLeave))}render(){return this.isPopConfirm?this.show?bt`
161
- <div class="popconfirm-container">
162
- <p class="popconfirm-title">${this.popConfirmTitle}</p>
163
- <p class="popconfirm-description">${this.popConfirmDescription}</p>
164
- <div class="btn-block">
165
- <nr-button .size=${"small"} type=${"primary"} @click=${this.onPopConfirmConfirm}
166
- >${this.okText}</nr-button
167
- >
168
- <nr-button .size=${"small"} type=${"danger"} @click=${this.onPopConfirmCancel}
169
- >${this.cancelText}</nr-button
170
- >
171
- </div>
172
- </div>
173
- `:wt:this.show?bt`<slot></slot>`:wt}};Yt.styles=Jt,Vt([Ht({reflect:!0})],Yt.prototype,"position",void 0),Vt([Ht({reflect:!0})],Yt.prototype,"alignement",void 0),Vt([function(t){return Ht({...t,state:!0})}()],Yt.prototype,"target",void 0),Vt([Ht({reflect:!0,type:Boolean})],Yt.prototype,"show",void 0),Vt([Ht()],Yt.prototype,"isPopConfirm",void 0),Vt([Ht()],Yt.prototype,"popConfirmTitle",void 0),Vt([Ht()],Yt.prototype,"popConfirmDescription",void 0),Vt([Ht()],Yt.prototype,"okText",void 0),Vt([Ht()],Yt.prototype,"cancelText",void 0),Yt=Vt([(t=>i=>"function"==typeof i?((t,i)=>(customElements.define(t,i),i))(t,i):((t,i)=>{const{kind:s,elements:o}=i;return{kind:s,elements:o,finisher(i){customElements.define(t,i)}}})(t,i))("hy-tooltip")],Yt);export{Yt as TooltipElement};
1
+ import{css as t,LitElement as i,html as o,nothing as s}from"lit";import{property as n,state as e,customElement as h}from"lit/decorators.js";const r=[t`:host([show]){background-color:var(--nuraly-tooltip-background-color);color:var(--nuraly-tooltip-text-color);position:fixed;padding:5px;text-align:center;opacity:0;font-size:14px;z-index:9999;border-radius:4px;animation-name:show-animation;animation-duration:.4s;animation-fill-mode:forwards}.popconfirm-container{display:flex;flex-direction:column}.btn-block{display:flex;justify-content:end;gap:10px;margin:10px}.popconfirm-description,.popconfirm-title{margin:5px;text-align:left}.popconfirm-title{font-weight:700}@keyframes show-animation{from{opacity:0}to{opacity:1}}:host::after{content:'';height:0;width:0;position:absolute;border:5px solid transparent}:host(.top-position)::after{border-top-color:var(--nuraly-tooltip-background-color);top:100%}:host(.left-position)::after{border-left-color:var(--nuraly-tooltip-background-color);left:100%}:host(.right-position)::after{border-right-color:var(--nuraly-tooltip-background-color);right:100%}:host(.bottom-position)::after{border-bottom-color:var(--nuraly-tooltip-background-color);bottom:100%}:host(.alignement-center.bottom-position)::after,:host(.alignement-center.top-position)::after{right:50%;transform:translate(50%)}:host(.alignement-start.bottom-position)::after,:host(.alignement-start.top-position)::after{left:4%}:host(.alignement-end.bottom-position)::after,:host(.top-position.alignement-end)::after{right:4%}:host(.alignement-center.left-position)::after,:host(.alignement-center.right-position)::after{top:50%;transform:translate(0,-50%)}:host(.alignement-start.left-position)::after,:host(.alignement-start.right-position)::after{top:5px}:host(.alignement-end.left-position)::after,:host(.alignement-end.right-position)::after{bottom:5px}`,t`:host{--nuraly-tooltip-background-color:#393939;--nuraly-tooltip-text-color:#ffffff}@media (prefers-color-scheme:dark){:host{--nuraly-tooltip-background-color:#f4f4f4;--nuraly-tooltip-text-color:#161616}}`];var a,l;!function(t){t.Top="top",t.Bottom="bottom",t.Right="right",t.Left="left"}(a||(a={})),function(t){t.Start="start",t.Center="center",t.End="end"}(l||(l={}));var p=function(t,i,o,s){for(var n,e=arguments.length,h=e<3?i:null===s?s=Object.getOwnPropertyDescriptor(i,o):s,r=t.length-1;r>=0;r--)(n=t[r])&&(h=(e<3?n(h):e>3?n(i,o,h):n(i,o))||h);return e>3&&h&&Object.defineProperty(i,o,h),h};let c=class extends i{constructor(){super(...arguments),this.position=a.Bottom,this.alignement=l.Center,this.show=!1,this.isPopConfirm=!1,this.popConfirmTitle="",this.popConfirmDescription="",this.okText="Yes",this.cancelText="No",this.horizontalOffset=10,this.verticalOffset=10,this.onMouseOver=()=>{this.show=!0},this.onMouseLeave=()=>{this.show=!1,this.initStyles()},this.onClick=()=>{this.show=!this.show},this.calculatePosition=()=>{this.initStyles(),this.style.width=`${this.clientWidth}px`,this.position==a.Bottom||this.position==a.Top?(this.calculateYposition(),this.calculateYalignement()):(this.calculateXposition(),this.calculateXalignement())},this.calculateYposition=()=>{const t=this.target.getBoundingClientRect(),i=t.bottom,o=t.top,s=window.visualViewport.height,n=this.clientHeight,e=n+this.verticalOffset<s-i,h=n+this.verticalOffset<o;this.position==a.Bottom?e||!h?(this.classList.add("bottom-position"),this.style.top=`${i+this.verticalOffset}px`):(this.classList.add("top-position"),this.style.top=o-n-this.verticalOffset+"px"):h||!e?(this.classList.add("top-position"),this.style.top=o-n-this.verticalOffset+"px"):(this.classList.add("bottom-position"),this.style.top=`${i+this.verticalOffset}px`)},this.calculateYalignement=()=>{const t=this.target.getBoundingClientRect(),i=t.right,o=t.width,s=t.left,n=this.clientWidth,e=s+o/2,h=window.visualViewport.width,r=h-i+o/2;if(this.alignement==l.Start){n+s<h?(this.classList.add("alignement-start"),this.style.left=s-this.horizontalOffset+"px"):(this.classList.add("alignement-end"),this.style.left=`${s-n+this.horizontalOffset}px`)}else if(this.alignement==l.End){n<s?(this.classList.add("alignement-end"),this.style.left=`${s-n+this.horizontalOffset}px`):(this.classList.add("alignement-start"),this.style.left=s-this.horizontalOffset+"px")}else{const t=n<e;n/2<e&&n/2<r||n>e&&n>r?(this.classList.add("alignement-center"),this.style.left=s-n/2+o/2+"px"):t?(this.classList.add("alignement-end"),this.style.left=`${s-n+this.horizontalOffset}px`):(this.classList.add("alignement-start"),this.style.left=s-this.horizontalOffset+"px")}},this.calculateXposition=()=>{const t=this.target.getBoundingClientRect(),i=t.left,o=t.right,s=window.visualViewport.width,n=this.clientWidth,e=n+this.horizontalOffset<s-o,h=n+this.horizontalOffset<i;this.position==a.Right?e||!h?(this.classList.add("right-position"),this.style.left=`${o+this.horizontalOffset}px`):(this.classList.add("left-position"),this.style.left=i-n-this.horizontalOffset+"px"):h||!e?(this.classList.add("left-position"),this.style.left=i-n-this.horizontalOffset+"px"):(this.classList.add("right-position"),this.style.left=`${o+this.horizontalOffset}px`)},this.calculateXalignement=()=>{const t=this.target.getBoundingClientRect(),i=t.top,o=t.height,s=t.bottom,n=this.clientHeight,e=window.visualViewport.height,h=e-s;if(this.alignement==l.End){n<i?(this.classList.add("alignement-end"),this.style.top=s-n+"px"):(this.classList.add("alignement-start"),this.style.top=i-o/4+"px")}else if(this.alignement==l.Start){n<e-s?(this.classList.add("alignement-start"),this.style.top=i-o/4+"px"):(this.classList.add("alignement-end"),this.style.top=s-n+"px")}else{const t=n<i;n/2<i&&n/2<h||n>i&&n>h?(this.classList.add("alignement-center"),this.style.top=i+o/2-n/2+"px"):t?(this.classList.add("alignement-end"),this.style.top=s-n+"px"):(this.classList.add("alignement-start"),this.style.top=i-o/4+"px")}},this.onClickOutside=t=>{const i=t.composedPath();!i.includes(this.target)&&!i.includes(this)&&(this.show=!1)}}connectedCallback(){super.connectedCallback(),this.target=this.target||this.previousElementSibling,this.target?this.isPopConfirm?(document.addEventListener("scroll",this.calculatePosition),this.target.addEventListener("click",this.onClick),document.addEventListener("click",this.onClickOutside)):(this.target.addEventListener("mouseover",this.onMouseOver),this.target.addEventListener("mouseleave",this.onMouseLeave)):console.error("Tooltip target is not defined or found. Ensure target is explicitly set or precedes the tooltip.")}initStyles(){this.style.top="",this.style.left="",this.style.width="",this.classList.remove(...this.classList.values())}updated(t){this.show&&this.calculatePosition()}onPopConfirmCancel(){this.dispatchEvent(new CustomEvent("onCancel")),this.show=!1,this.initStyles()}onPopConfirmConfirm(){this.dispatchEvent(new CustomEvent("onConfirm")),this.show=!1,this.initStyles()}disconnectedCallback(){super.disconnectedCallback(),this.isPopConfirm?(this.target.removeEventListener("click",this.onClick),document.removeEventListener("scroll",this.calculatePosition)):(this.target.removeEventListener("mouseover",this.onMouseOver),this.target.removeEventListener("mouseleave",this.onMouseLeave))}render(){return this.isPopConfirm?this.show?o`<div class="popconfirm-container"><p class="popconfirm-title">${this.popConfirmTitle}</p><p class="popconfirm-description">${this.popConfirmDescription}</p><div class="btn-block"><nr-button .size="${"small"}" type="${"primary"}" @click="${this.onPopConfirmConfirm}">${this.okText}</nr-button><nr-button .size="${"small"}" type="${"danger"}" @click="${this.onPopConfirmCancel}">${this.cancelText}</nr-button></div></div>`:s:this.show?o`<slot></slot>`:s}};c.styles=r,p([n({reflect:!0})],c.prototype,"position",void 0),p([n({reflect:!0})],c.prototype,"alignement",void 0),p([e()],c.prototype,"target",void 0),p([n({reflect:!0,type:Boolean})],c.prototype,"show",void 0),p([n()],c.prototype,"isPopConfirm",void 0),p([n()],c.prototype,"popConfirmTitle",void 0),p([n()],c.prototype,"popConfirmDescription",void 0),p([n()],c.prototype,"okText",void 0),p([n()],c.prototype,"cancelText",void 0),c=p([h("hy-tooltip")],c);export{c as TooltipElement};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuralyui/tooltips",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,6 +28,6 @@ export declare class TooltipElement extends LitElement {
28
28
  onPopConfirmConfirm(): void;
29
29
  onClickOutside: (onClickEvent: Event) => void;
30
30
  disconnectedCallback(): void;
31
- render(): import("lit").TemplateResult<1> | typeof nothing;
31
+ render(): typeof nothing | import("lit").TemplateResult<1>;
32
32
  }
33
33
  //# sourceMappingURL=tooltips.component.d.ts.map