@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.
- package/dist/tooltip-overlay.umd.js +7 -7
- package/dist/tooltip.css +7 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(
|
|
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
|
-
${
|
|
3
|
+
<img src="${b}" alt="svg" />
|
|
4
4
|
</div>
|
|
5
5
|
<div class="tooltip-card">
|
|
6
|
-
${
|
|
6
|
+
${t.position?.image==="left"?r:""}
|
|
7
7
|
<div class="tooltip-text">
|
|
8
|
-
<div class="tooltip-title">${
|
|
9
|
-
<div class="tooltip-desc">${
|
|
8
|
+
<div class="tooltip-title">${t.title}</div>
|
|
9
|
+
<div class="tooltip-desc">${t.description}</div>
|
|
10
10
|
</div>
|
|
11
|
-
${
|
|
11
|
+
${t.position?.image==="right"?r:""}
|
|
12
12
|
</div>
|
|
13
|
-
`,document.body.appendChild(
|
|
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
|
|
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;
|