@erain20029/tooltips 2.0.55 → 2.0.57

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,13 +1,13 @@
1
- (function(f){typeof define=="function"&&define.amd?define(f):f()})((function(){"use strict";const f=".tooltip-overlay{position:fixed;z-index:9999;pointer-events:none;background:#53616e;border-radius:8px;box-shadow:0 4px 20px #00000040;color:#dadadb;max-width:300px}.tooltip-overlay.with-image{max-width:500px}.tooltip-card{display:flex;align-items:center;gap:16px;padding:16px 20px;box-sizing:border-box}.tooltip-image{width:120px;height:120px;border-radius:8px;object-fit:cover}.tooltip-text{flex:1;min-width:0}.tooltip-title{font-weight:300;line-height:1.3}.tooltip-desc{margin-top:12px;line-height:1.5;font-weight:300;letter-spacing:.2px;overflow-wrap:break-word}",T="data:image/svg+xml,%3csvg%20width='53'%20height='44'%20viewBox='60%2025%2060%2040'%20xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3cmask%20id='hide-bottom'%3e%3crect%20x='0'%20y='0'%20width='200'%20height='200'%20fill='white'%20/%3e%3crect%20x='0'%20y='55'%20width='200'%20height='20'%20fill='black'%20/%3e%3c/mask%3e%3c/defs%3e%3cpath%20d='M100.524%2056.5041%20L84.3494%2033.3916%20L68.1748%2056.5041%20Z'%20fill='currentColor'%20/%3e%3c/svg%3e";(function(){function $(){if(document.getElementById("tooltip-overlay-styles"))return;const o=document.createElement("style");o.id="tooltip-overlay-styles",o.textContent=f,document.head.appendChild(o)}let v={},c={};function L(o){const e=window.innerWidth,t=window.innerHeight,r=e/2,i=t/2,{left:n,top:s}=o.getBoundingClientRect();return n<r&&s<i&&(c={horizontal:"left",vertical:"top"}),n<r&&s>i&&(c={horizontal:"left",vertical:"bottom"}),n>r&&s<i&&(c={horizontal:"right",vertical:"top"}),n>r&&s>i&&(c={horizontal:"right",vertical:"bottom"}),v={x:n,y:s},{coordinates:v,overlayPosition:c}}let a=null,h=null,y=[],m=!1;async function z(){if(m)return;const o=localStorage.getItem("product");if(!o)return;const e=JSON.parse(o).id,t=document.createElement("script");t.src=`http://localhost:3000/documentation/${e}/tooltip.js`,await new Promise((r,i)=>{t.onload=r,t.onerror=i,document.head.appendChild(t)}),typeof window.tooltipGetter=="function"&&(y=await window.tooltipGetter(),m=!0)}function w(){a&&(a.remove(),a=null,h=null)}function E(o,e){w(),$();const t=document.createElement("div");t.className="tooltip-overlay",t.style.left="-9999px",t.style.top="-9999px",e.image&&t.classList.add("with-image");const r=e.image?`<img class="tooltip-image" src="${e.image}" />`:"";t.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;max-width:300px}.tooltip-overlay.with-image{max-width:500px}.tooltip-card{display:flex;align-items:center;gap:16px;padding:16px 20px;box-sizing:border-box}.tooltip-image{width:120px;height:120px;border-radius:8px;object-fit:cover}.tooltip-text{flex:1;min-width:0}.tooltip-title{font-weight:300;line-height:1.3}.tooltip-desc{margin-top:12px;line-height:1.5;font-weight:300;letter-spacing:.2px;overflow-wrap:break-word}.tooltip-arrow img{width:24px;height:24px;display:block}",b="data:image/svg+xml,%3csvg%20width='53'%20height='44'%20viewBox='60%2025%2060%2040'%20xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3cmask%20id='hide-bottom'%3e%3crect%20x='0'%20y='0'%20width='200'%20height='200'%20fill='white'%20/%3e%3crect%20x='0'%20y='55'%20width='200'%20height='20'%20fill='black'%20/%3e%3c/mask%3e%3c/defs%3e%3cpath%20d='M100.524%2056.5041%20L84.3494%2033.3916%20L68.1748%2056.5041%20Z'%20fill='currentColor'%20/%3e%3c/svg%3e";(function(){function T(){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 u={},x={};function $(o){const t=o.getBoundingClientRect(),e=window.innerWidth,r=window.innerHeight,i=t.left+t.width/2,l=t.top+t.height/2;return x={horizontal:i<e/2?"left":"right",vertical:l<r/2?"top":"bottom"},u={x:t.left,y:t.top},{coordinates:u,overlayPosition:x}}let s=null,p=null,v=[],h=!1;async function L(){if(h)return;const o=localStorage.getItem("product");if(!o)return;const t=JSON.parse(o).id,e=document.createElement("script");e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((r,i)=>{e.onload=r,e.onerror=i,document.head.appendChild(e)}),typeof window.tooltipGetter=="function"&&(v=await window.tooltipGetter(),h=!0)}function w(){s&&(s.remove(),s=null,p=null)}function E(o,t){w(),T();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=t.image?`<img class="tooltip-image" src="${t.image}" />`:"";e.innerHTML=`
2
2
  <div class="tooltip-arrow">
3
- ${T}
3
+ <img src="${b}" alt="svg" />
4
4
  </div>
5
5
  <div class="tooltip-card">
6
- ${e.position?.image==="left"?r:""}
6
+ ${t.position?.image==="left"?r:""}
7
7
  <div class="tooltip-text">
8
- <div class="tooltip-title">${e.title}</div>
9
- <div class="tooltip-desc">${e.description}</div>
8
+ <div class="tooltip-title">${t.title}</div>
9
+ <div class="tooltip-desc">${t.description}</div>
10
10
  </div>
11
- ${e.position?.image==="right"?r:""}
11
+ ${t.position?.image==="right"?r:""}
12
12
  </div>
13
- `,document.body.appendChild(t);const{coordinates:i,overlayPosition:n}=L(o),s=n.horizontal==="left"&&n.vertical==="top",O=n.horizontal==="left"&&n.vertical==="bottom",P=n.horizontal==="right"&&n.vertical==="top",R=n.horizontal==="right"&&n.vertical==="bottom",b=t.getBoundingClientRect(),u=b.width,g=b.height;let d=i.x,p=i.y;const x=22,l=t.querySelector(".tooltip-arrow");s&&(d=i.x,p=i.y+x,l.style.left="14px",l.style.top="-30px",l.classList.add("top")),O&&(d=i.x,p=i.y-g,l.style.left="14px",l.style.top=`${g}px`,l.classList.add("bottom")),P&&(d=i.x,p=i.y+x,l.style.left=`${u-ARROW_GAP}px`,l.style.top="-30px",l.classList.add("top")),R&&(d=i.x-u+50,p=i.y-g-x,l.style.left=`${u-ARROW_GAP}px`,l.style.top=`${g}px`,l.classList.add("bottom")),t.style.left=`${d}px`,t.style.top=`${p}px`,a=t,h=o}document.addEventListener("mouseenter",async o=>{if(!(o.target instanceof Element)||o.target.closest(".tooltip-overlay")||(await z(),!m))return;const e=y.find(r=>o.target.closest(r.selector));if(!e)return;const t=o.target.closest(e.selector);t instanceof Element&&E(t,e)},!0),document.addEventListener("mouseleave",o=>{if(!a||!h)return;const e=o.relatedTarget;e&&!a.contains(e)&&!h.contains(e)&&w()},!0)})()}));
13
+ `,document.body.appendChild(e);const{coordinates:i,overlayPosition:l}=$(o),C=l.horizontal==="left"&&l.vertical==="top",O=l.horizontal==="left"&&l.vertical==="bottom",z=l.horizontal==="right"&&l.vertical==="top",B=l.horizontal==="right"&&l.vertical==="bottom",y=e.getBoundingClientRect(),g=y.width,f=y.height;let a=i.x,c=i.y;const m=22,n=e.querySelector(".tooltip-arrow");C&&(a=i.x,c=i.y+m,n.style.left="14px",n.style.top="-30px",n.classList.add("top")),O&&(a=i.x,c=i.y-f,n.style.left="14px",n.style.top=`${f}px`,n.classList.add("bottom")),z&&(a=i.x,c=i.y+m,n.style.left=`${g-24}px`,n.style.top="-30px",n.classList.add("top")),B&&(a=i.x-g+50,c=i.y-f-m,n.style.left=`${g-24}px`,n.style.top=`${f}px`,n.classList.add("bottom")),e.style.left=`${a}px`,e.style.top=`${c}px`,s=e,p=o}document.addEventListener("mouseenter",async o=>{if(!(o.target instanceof Element)||o.target.closest(".tooltip-overlay")||(await L(),!h))return;const t=v.find(r=>o.target.closest(r.selector));if(!t)return;const e=o.target.closest(t.selector);e instanceof Element&&E(e,t)},!0),document.addEventListener("mouseleave",o=>{if(!s||!p)return;const t=o.relatedTarget;t&&!s.contains(t)&&!p.contains(t)&&w()},!0)})()}));
package/dist/tooltip.css CHANGED
@@ -4,7 +4,7 @@
4
4
  pointer-events: none;
5
5
  background: #53616E;
6
6
  border-radius: 8px;
7
- box-shadow: 0 4px 20px rgba(0,0,0,.25);
7
+ box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
8
8
  color: #DADADB;
9
9
  max-width: 300px;
10
10
  }
@@ -46,6 +46,12 @@
46
46
  overflow-wrap: break-word;
47
47
  }
48
48
 
49
+ .tooltip-arrow img {
50
+ width: 24px;
51
+ height: 24px;
52
+ display: block;
53
+ }
54
+
49
55
  /* .tooltip-arrow {
50
56
  position: absolute;
51
57
  width: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.55",
3
+ "version": "2.0.57",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",