@erain20029/tooltips 2.0.107 → 2.0.109

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.
@@ -1,4 +1,4 @@
1
- (function(d){typeof define=="function"&&define.amd?define(d):d()})((function(){"use strict";const d=".tooltip-overlay{position:fixed;z-index:9999;pointer-events:none;background:#53616e;border-radius:8px;box-shadow:0 4px 20px #00000040;color:#dadadb;min-width:45px;max-width:300px;overflow:visible}.tooltip-overlay.with-image{max-width:384px}.tooltip-card{display:flex;align-items:center;gap:16px;padding:10px;box-sizing:border-box}.tooltip-image{width:80px;height:80px;border-radius:8px;object-fit:cover}.tooltip-text{flex:1;color:#fff}.tooltip-title{font-weight:300;line-height:1.3}.tooltip-desc{margin-top:8px;line-height:1.5;font-weight:300;letter-spacing:.2px;overflow-wrap:break-word}.tooltip-arrow .icon{width:40px;height:40px;position:absolute}.tooltip-arrow.left_top .icon{top:-25px;left:10px}.tooltip-arrow.left_bottom .icon{bottom:-25px;left:10px;transform:rotate(180deg)}.tooltip-arrow.right_bottom .icon{bottom:-25px;right:10px;transform:rotate(180deg)}.tooltip-arrow.right_top .icon{top:-25px;right:10px}";(function(){function v(){if(document.getElementById("tooltip-overlay-styles"))return;const i=document.createElement("style");i.id="tooltip-overlay-styles",i.textContent=d,document.head.appendChild(i)}let s=null,p=null,u=[],f=!1;function y(i){const t=i.getBoundingClientRect(),e=window.innerWidth,r=window.innerHeight,n=t.left+t.width/2,o=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:n<e/2?"left":"right",vertical:o<r/2?"top":"bottom"}}}function b(i,t){if(!i)return{titleSize:16,descriptionSize:12};let e=16,r=12,n="left",o="left";switch(i.title){case"small":e=16,n="left";break;case"medium":e=18;break;case"large":e=22;break}switch(i.description){case"small":r=12;break;case"medium":r=14;break;case"large":r=16;break}switch(t.title){case"left":n="left";break;case"center":n="center";break;case"right":n="right";break}switch(t.description){case"left":o="left";break;case"center":o="center";break;case"right":o="right";break}return{titleSize:e,descriptionSize:r,titleAlign:n,descriptionAlign:o}}function m(){s&&(s.remove(),s=null,p=null)}async function k(){if(f)return;const i=localStorage.getItem("product");if(!i)return;const t=JSON.parse(i).id,e=document.createElement("script");if(e.type="module",e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((n,o)=>{e.onload=n,e.onerror=o,document.head.appendChild(e)}),typeof window.tooltipGetter!="function")return;const r=await window.tooltipGetter();u=Array.isArray(r)?r:[],f=!0}function z(i,t){m(),v();const e=document.createElement("div");e.className="tooltip-overlay",e.style.left="-9999px",e.style.top="-9999px",t.image&&e.classList.add("with-image");const r=`http://localhost:3000${t.image}`,n=t.image?`<img class="tooltip-image" src="${r}" />`:"";e.innerHTML=`
1
+ (function(p){typeof define=="function"&&define.amd?define(p):p()})((function(){"use strict";const p=".tooltip-overlay{position:fixed;z-index:9999;pointer-events:none;background:#53616e;border-radius:8px;box-shadow:0 4px 20px #00000040;color:#dadadb;min-width:45px;max-width:300px;overflow:visible}.tooltip-overlay.with-image{max-width:384px}.tooltip-card{display:flex;align-items:center;gap:16px;padding:10px;box-sizing:border-box}.tooltip-image{width:80px;height:80px;border-radius:8px;object-fit:cover}.tooltip-text{flex:1;color:#fff}.tooltip-title{font-weight:300;line-height:1.3}.tooltip-desc{margin-top:8px;line-height:1.5;font-weight:300;letter-spacing:.2px;overflow-wrap:break-word}.tooltip-arrow .icon{width:40px;height:40px;position:absolute}.tooltip-arrow.left_top .icon{top:-25px;left:10px}.tooltip-arrow.left_bottom .icon{bottom:-25px;left:10px;transform:rotate(180deg)}.tooltip-arrow.right_bottom .icon{bottom:-25px;right:10px;transform:rotate(180deg)}.tooltip-arrow.right_top .icon{top:-25px;right:10px}";(function(){function v(){if(document.getElementById("tooltip-overlay-styles"))return;const i=document.createElement("style");i.id="tooltip-overlay-styles",i.textContent=p,document.head.appendChild(i)}let s=null,h=null,m=[],u=!1;function y(i){const t=i.getBoundingClientRect(),e=window.innerWidth,r=window.innerHeight,n=t.left+t.width/2,o=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:n<e/2?"left":"right",vertical:o<r/2?"top":"bottom"}}}function b(i,t){if(!i)return{titleSize:16,descriptionSize:12};let e=16,r=12,n="left",o="left";switch(i.title){case"small":e=16,n="left";break;case"medium":e=18;break;case"large":e=22;break}switch(i.description){case"small":r=12;break;case"medium":r=14;break;case"large":r=16;break}switch(t.title){case"left":n="left";break;case"center":n="center";break;case"right":n="right";break}switch(t.description){case"left":o="left";break;case"center":o="center";break;case"right":o="right";break}return{titleSize:e,descriptionSize:r,titleAlign:n,descriptionAlign:o}}function x(){s&&(s.remove(),s=null,h=null)}async function k(){if(u)return;const i=localStorage.getItem("product");if(!i)return;const t=JSON.parse(i).id,e=document.createElement("script");if(e.type="module",e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((n,o)=>{e.onload=n,e.onerror=o,document.head.appendChild(e)}),typeof window.tooltipGetter!="function")return;const r=await window.tooltipGetter();m=Array.isArray(r)?r:[],u=!0}function z(i,t){x(),v();const e=document.createElement("div");e.className="tooltip-overlay",e.style.left="-9999px",e.style.top="-9999px",t.image&&e.classList.add("with-image");const r=`http://localhost:3000${t.image}`,n=t.image?`<img class="tooltip-image" src="${r}" />`:"";e.innerHTML=`
2
2
  <div class="tooltip-arrow">
3
3
  <div class="icon">
4
4
  <svg
@@ -22,4 +22,4 @@
22
22
  </div>
23
23
  ${t.position?.image==="right"?n:""}
24
24
  </div>
25
- `,document.body.appendChild(e);const{coordinates:o,position:l}=y(i),x=e.getBoundingClientRect(),g=30;let a=0,c=0;const h=e.querySelector(".tooltip-arrow"),{titleSize:S,descriptionSize:$,titleAlign:T,descriptionAlign:L}=b(t.size,t.position),E=`font-size: ${S}px; text-align: ${T};`,_=`font-size: ${$}px; text-align: ${L};`,A=e.querySelector(".tooltip-title"),C=e.querySelector(".tooltip-desc");A.style.cssText=E,C.style.cssText=_;const w=i.getBoundingClientRect().height;l.horizontal==="left"&&l.vertical==="top"?(a=o.x,c=o.y+o.height+g,h.classList.add("left_top")):l.horizontal==="left"&&l.vertical==="bottom"?(a=o.x,c=o.y-w-g,h.classList.add("left_bottom")):l.horizontal==="right"&&l.vertical==="top"?(a=o.x-x.width+50,c=o.y+o.height+g,h.classList.add("right_top")):l.horizontal==="right"&&l.vertical==="bottom"&&(a=o.x-x.width+50,c=o.y-w-g,h.classList.add("right_bottom")),e.style.left=`${Math.max(8,a)}px`,e.style.top=`${Math.max(8,c)}px`,console.log(t),s=e,p=i}document.addEventListener("mouseenter",async i=>{if(!(i.target instanceof Element)||i.target.closest(".tooltip-overlay")||(await k(),!f))return;const t=u.find(r=>i.target.closest(r.selector));if(!t)return;const e=i.target.closest(t.selector);e&&z(e,t)},!0),document.addEventListener("mouseleave",i=>{if(!s||!p)return;const t=i.relatedTarget;t&&!s.contains(t)&&!p.contains(t)&&m()},!0)})()}));
25
+ `,document.body.appendChild(e);const{coordinates:o,position:l}=y(i),w=e.getBoundingClientRect(),g=30;let c=0,d=0;const f=e.querySelector(".tooltip-arrow"),{titleSize:S,descriptionSize:$,titleAlign:T,descriptionAlign:L}=b(t.size,t.position),E=`font-size: ${S}px; text-align: ${T};`,_=`font-size: ${$}px; text-align: ${L};`,A=e.querySelector(".tooltip-title"),C=e.querySelector(".tooltip-desc");A.style.cssText=E,C.style.cssText=_;const a=i.getBoundingClientRect().height;l.horizontal==="left"&&l.vertical==="top"?(c=o.x,d=o.y+o.height+g,f.classList.add("left_top")):l.horizontal==="left"&&l.vertical==="bottom"?(c=o.x,d=o.y-a-a-a-g,f.classList.add("left_bottom")):l.horizontal==="right"&&l.vertical==="top"?(c=o.x-w.width+50,d=o.y+o.height+g,f.classList.add("right_top")):l.horizontal==="right"&&l.vertical==="bottom"&&(c=o.x-w.width+50,d=o.y-a-a-a-g,f.classList.add("right_bottom")),e.style.left=`${Math.max(8,c)}px`,e.style.top=`${Math.max(8,d)}px`,s=e,h=i}document.addEventListener("mouseenter",async i=>{if(!(i.target instanceof Element)||i.target.closest(".tooltip-overlay")||(await k(),!u))return;const t=m.find(r=>i.target.closest(r.selector));if(!t)return;const e=i.target.closest(t.selector);e&&z(e,t)},!0),document.addEventListener("mouseleave",i=>{if(!s||!h)return;const t=i.relatedTarget;t&&!s.contains(t)&&!h.contains(t)&&x()},!0)})()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.107",
3
+ "version": "2.0.109",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",