@erain20029/tooltips 2.0.133 → 2.0.134

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.rotated .icon{transform:rotate(180deg)}";(function(){function x(){if(document.getElementById("tooltip-overlay-styles"))return;const o=document.createElement("style");o.id="tooltip-overlay-styles",o.textContent=d,document.head.appendChild(o)}let c=null,p=null,m=[],g=!1;function w(o){const e=o.getBoundingClientRect(),t=window.innerWidth,i=window.innerHeight,n=e.left+e.width/2,l=e.top+e.height/2;return{coordinates:{x:e.left,y:e.top,left:e.left,top:e.top,right:t-e.right,bottom:i-e.bottom,width:e.width,height:e.height},position:{horizontal:n<t/2?"left":"right",vertical:l<i/2?"top":"bottom"}}}function y(o,e){if(!o)return{titleSize:16,descriptionSize:12};let t=16,i=12,n="left",l="left";switch(o.title){case"small":t=16,n="left";break;case"medium":t=18;break;case"large":t=22;break}switch(o.description){case"small":i=12;break;case"medium":i=14;break;case"large":i=16;break}switch(e.title){case"left":n="left";break;case"center":n="center";break;case"right":n="right";break}switch(e.description){case"left":l="left";break;case"center":l="center";break;case"right":l="right";break}return{titleSize:t,descriptionSize:i,titleAlign:n,descriptionAlign:l}}function u(){c&&(c.remove(),c=null,p=null)}async function v(){if(g)return;const o=localStorage.getItem("product");if(!o)return;const e=JSON.parse(o).id,t=document.createElement("script");if(t.type="module",t.src=`http://localhost:3000/documentation/${e}/tooltip.js`,await new Promise((n,l)=>{t.onload=n,t.onerror=l,document.head.appendChild(t)}),typeof window.tooltipGetter!="function")return;const i=await window.tooltipGetter();m=Array.isArray(i)?i:[],g=!0}const s=15,f=20;function b(o,e){u(),x();const t=document.createElement("div");t.className="tooltip-overlay",t.style.position="fixed",t.style.pointerEvents="none",t.style.zIndex="9999";const i=document.createElement("div");i.className="tooltip-arrow",i.style.position="absolute";const n=document.createElement("div");n.className="tooltip-card";const l=e.image?`<img class="tooltip-image" src="http://localhost:3000${e.image}" />`:"";n.innerHTML=`
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.rotated .icon{transform:rotate(180deg)}";(function(){function y(){if(document.getElementById("tooltip-overlay-styles"))return;const o=document.createElement("style");o.id="tooltip-overlay-styles",o.textContent=d,document.head.appendChild(o)}let c=null,p=null,g=[],h=!1;function v(o){const e=o.getBoundingClientRect(),t=window.innerWidth,i=window.innerHeight,n=e.left+e.width/2,l=e.top+e.height/2;return{coordinates:{x:e.left,y:e.top,left:e.left,top:e.top,right:t-e.right,bottom:i-e.bottom,width:e.width,height:e.height},position:{horizontal:n<t/2?"left":"right",vertical:l<i/2?"top":"bottom"}}}function b(o,e){if(!o)return{titleSize:16,descriptionSize:12};let t=16,i=12,n="left",l="left";switch(o.title){case"small":t=16,n="left";break;case"medium":t=18;break;case"large":t=22;break}switch(o.description){case"small":i=12;break;case"medium":i=14;break;case"large":i=16;break}switch(e.title){case"left":n="left";break;case"center":n="center";break;case"right":n="right";break}switch(e.description){case"left":l="left";break;case"center":l="center";break;case"right":l="right";break}return{titleSize:t,descriptionSize:i,titleAlign:n,descriptionAlign:l}}function f(){c&&(c.remove(),c=null,p=null)}async function $(){if(h)return;const o=localStorage.getItem("product");if(!o)return;const e=JSON.parse(o).id,t=document.createElement("script");if(t.type="module",t.src=`http://localhost:3000/documentation/${e}/tooltip.js`,await new Promise((n,l)=>{t.onload=n,t.onerror=l,document.head.appendChild(t)}),typeof window.tooltipGetter!="function")return;const i=await window.tooltipGetter();g=Array.isArray(i)?i:[],h=!0}function T(o,e){f(),y();const t=document.createElement("div");t.className="tooltip-overlay",t.style.position="fixed",t.style.pointerEvents="none",t.style.zIndex="9999";const i=document.createElement("div");i.className="tooltip-arrow",i.style.position="absolute";const n=document.createElement("div");n.className="tooltip-card";const l=e.image?`<img class="tooltip-image" src="http://localhost:3000${e.image}" />`:"";n.innerHTML=`
2
2
  ${e.position?.image==="left"?l:""}
3
3
  <div class="tooltip-text">
4
4
  <div class="tooltip-title">${e.title}</div>
@@ -18,10 +18,10 @@
18
18
  fill="#53616E"
19
19
  />
20
20
  </svg>
21
- `,t.appendChild(i),t.appendChild(n),document.body.appendChild(t);const{titleSize:$,descriptionSize:T,titleAlign:z,descriptionAlign:k}=y(e.size,e.position);t.querySelector(".tooltip-title").style.cssText=`
22
- font-size: ${$}px;
23
- text-align: ${z};
21
+ `,t.appendChild(i),t.appendChild(n),document.body.appendChild(t);const{titleSize:z,descriptionSize:k,titleAlign:A,descriptionAlign:O}=b(e.size,e.position);t.querySelector(".tooltip-title").style.cssText=`
22
+ font-size: ${z}px;
23
+ text-align: ${A};
24
24
  `,t.querySelector(".tooltip-desc").style.cssText=`
25
- font-size: ${T}px;
26
- text-align: ${k};
27
- `,requestAnimationFrame(()=>{const r=o.getBoundingClientRect(),h=t.getBoundingClientRect(),a=w(o).position,E=a.horizontal==="left"&&a.vertical==="top",L=a.horizontal==="left"&&a.vertical==="bottom",S=a.horizontal==="right"&&a.vertical==="top",A=a.horizontal==="right"&&a.vertical==="bottom";E&&(t.style.left=`${r.left}px`,t.style.top=`${r.top+r.height+s}px`,i.style.left=`${s}px`,i.style.bottom=`${h.height+s}px`),L&&(t.style.left=`${r.left}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+f}px`,i.style.left=`${s}px`,i.style.top=`${h.height-f}px`,i.classList.add("rotated")),S&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.top=`${r.top+r.height+s}px`,i.style.right=`${s}px`,i.style.bottom=`${h.height+s}px`),A&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+s}px`,i.style.right="30px",i.style.top=`${h.height-f}px`,i.classList.add("rotated"))}),c=t,p=o}document.addEventListener("mouseenter",async o=>{if(!(o.target instanceof Element)||o.target.closest(".tooltip-overlay")||(await v(),!g))return;const e=m.find(i=>o.target.closest(i.selector));if(!e)return;const t=o.target.closest(e.selector);t&&b(t,e)},!0),document.addEventListener("mouseleave",o=>{if(!c||!p)return;const e=o.relatedTarget;e&&!c.contains(e)&&!p.contains(e)&&u()},!0)})()}));
25
+ font-size: ${k}px;
26
+ text-align: ${O};
27
+ `,requestAnimationFrame(()=>{const r=o.getBoundingClientRect(),m=t.getBoundingClientRect(),s=v(o).position,E=s.horizontal==="left"&&s.vertical==="top",R=s.horizontal==="left"&&s.vertical==="bottom",L=s.horizontal==="right"&&s.vertical==="top",P=s.horizontal==="right"&&s.vertical==="bottom",a=15,u=30,x=m.height-u,w=m.height+a;E&&(t.style.left=`${r.left}px`,t.style.top=`${r.top+r.height+a}px`,i.style.left=`${a}px`,i.style.bottom=`${w}px`),R&&(t.style.left=`${r.left}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+u}px`,i.style.left=`${a}px`,i.style.top=`${x}px`,i.classList.add("rotated")),L&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.top=`${r.top+r.height+a}px`,i.style.right=`${a}px`,i.style.bottom=`${w}px`),P&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+a}px`,i.style.right=`${a}px`,i.style.top=`${x}px`,i.classList.add("rotated"))}),c=t,p=o}document.addEventListener("mouseenter",async o=>{if(!(o.target instanceof Element)||o.target.closest(".tooltip-overlay")||(await $(),!h))return;const e=g.find(i=>o.target.closest(i.selector));if(!e)return;const t=o.target.closest(e.selector);t&&T(t,e)},!0),document.addEventListener("mouseleave",o=>{if(!c||!p)return;const e=o.relatedTarget;e&&!c.contains(e)&&!p.contains(e)&&f()},!0)})()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.133",
3
+ "version": "2.0.134",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",