@erain20029/tooltips 2.0.54 → 2.0.56

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,11 +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}.tooltip-arrow{position:absolute;width:0;height:0;border-left:14px solid transparent;border-right:14px solid transparent}.tooltip-arrow.top{border-bottom:30px solid #53616E}.tooltip-arrow.bottom{border-top:30px solid #53616E}";(function(){function b(){if(document.getElementById("tooltip-overlay-styles"))return;const e=document.createElement("style");e.id="tooltip-overlay-styles",e.textContent=f,document.head.appendChild(e)}let g={},c={};function T(e){const o=window.innerWidth,t=window.innerHeight,r=o/2,i=t/2,{left:n,top:s}=e.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"}),g={x:n,y:s},{coordinates:g,overlayPosition:c}}let a=null,u=null,v=[],x=!1;async function E(){if(x)return;const e=localStorage.getItem("product");if(!e)return;const o=JSON.parse(e).id,t=document.createElement("script");t.src=`http://localhost:3000/documentation/${o}/tooltip.js`,await new Promise((r,i)=>{t.onload=r,t.onerror=i,document.head.appendChild(t)}),typeof window.tooltipGetter=="function"&&(v=await window.tooltipGetter(),x=!0)}function y(){a&&(a.remove(),a=null,u=null)}function P(e,o){y(),b();const t=document.createElement("div");t.className="tooltip-overlay",t.style.left="-9999px",t.style.top="-9999px",o.image&&t.classList.add("with-image");const r=o.image?`<img class="tooltip-image" src="${o.image}" />`:"";t.innerHTML=`
2
- <div class="tooltip-arrow"></div>
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=`
2
+ <div class="tooltip-arrow">
3
+ ${T}
4
+ </div>
3
5
  <div class="tooltip-card">
4
- ${o.position?.image==="left"?r:""}
6
+ ${e.position?.image==="left"?r:""}
5
7
  <div class="tooltip-text">
6
- <div class="tooltip-title">${o.title}</div>
7
- <div class="tooltip-desc">${o.description}</div>
8
+ <div class="tooltip-title">${e.title}</div>
9
+ <div class="tooltip-desc">${e.description}</div>
8
10
  </div>
9
- ${o.position?.image==="right"?r:""}
11
+ ${e.position?.image==="right"?r:""}
10
12
  </div>
11
- `,document.body.appendChild(t);const{coordinates:i,overlayPosition:n}=T(e),s=n.horizontal==="left"&&n.vertical==="top",$=n.horizontal==="left"&&n.vertical==="bottom",z=n.horizontal==="right"&&n.vertical==="top",G=n.horizontal==="right"&&n.vertical==="bottom",w=t.getBoundingClientRect(),h=w.width,m=w.height;let d=i.x,p=i.y;const l=t.querySelector(".tooltip-arrow");s&&(d=i.x,p=i.y+10,l.style.left="14px",l.style.top="-30px",l.classList.add("top")),$&&(d=i.x,p=i.y-m,l.style.left="14px",l.style.top=`${m}px`,l.classList.add("bottom")),z&&(d=i.x-h+50,p=i.y+10,l.style.left=`${h-ARROW_GAP}px`,l.style.top="-30px",l.classList.add("top")),G&&(d=i.x-h+50,p=i.y-m-10,l.style.left=`${h-ARROW_GAP}px`,l.style.top=`${m}px`,l.classList.add("bottom")),t.style.left=`${d}px`,t.style.top=`${p}px`,a=t,u=e}document.addEventListener("mouseenter",async e=>{if(!(e.target instanceof Element)||e.target.closest(".tooltip-overlay")||(await E(),!x))return;const o=v.find(r=>e.target.closest(r.selector));if(!o)return;const t=e.target.closest(o.selector);t instanceof Element&&P(t,o)},!0),document.addEventListener("mouseleave",e=>{if(!a||!u)return;const o=e.relatedTarget;o&&!a.contains(o)&&!u.contains(o)&&y()},!0)})()}));
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)})()}));
package/dist/tooltip.css CHANGED
@@ -46,7 +46,7 @@
46
46
  overflow-wrap: break-word;
47
47
  }
48
48
 
49
- .tooltip-arrow {
49
+ /* .tooltip-arrow {
50
50
  position: absolute;
51
51
  width: 0;
52
52
  height: 0;
@@ -60,4 +60,4 @@
60
60
 
61
61
  .tooltip-arrow.bottom {
62
62
  border-top: 30px solid #53616E;
63
- }
63
+ } */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.54",
3
+ "version": "2.0.56",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",