@erain20029/tooltips 2.0.127 → 2.0.128
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 +4 -4
- package/dist/tooltip.css +1 -19
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
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;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,f=[],g=!1;function y(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 w(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();f=Array.isArray(i)?i:[],g=!0}const s=15,m=15;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=`
|
|
2
2
|
${e.position?.image==="left"?l:""}
|
|
3
3
|
<div class="tooltip-text">
|
|
4
4
|
<div class="tooltip-title">${e.title}</div>
|
|
5
5
|
<div class="tooltip-desc">${e.description}</div>
|
|
6
6
|
</div>
|
|
7
7
|
${e.position?.image==="right"?l:""}
|
|
8
|
-
`,
|
|
8
|
+
`,i.innerHTML=`
|
|
9
9
|
<svg class="icon" width="28" height="28" viewBox="0 0 60 40">
|
|
10
10
|
<path d="M30 0 L60 40 L0 40 Z" fill="#53616E" />
|
|
11
11
|
</svg>
|
|
12
|
-
`,t.appendChild(
|
|
12
|
+
`,t.appendChild(i),t.appendChild(n),document.body.appendChild(t);const{titleSize:$,descriptionSize:T,titleAlign:z,descriptionAlign:k}=w(e.size,e.position);t.querySelector(".tooltip-title").style.cssText=`
|
|
13
13
|
font-size: ${$}px;
|
|
14
14
|
text-align: ${z};
|
|
15
15
|
`,t.querySelector(".tooltip-desc").style.cssText=`
|
|
16
16
|
font-size: ${T}px;
|
|
17
17
|
text-align: ${k};
|
|
18
|
-
`,requestAnimationFrame(()=>{const r=
|
|
18
|
+
`,requestAnimationFrame(()=>{const r=o.getBoundingClientRect(),h=t.getBoundingClientRect(),a=y(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}px`),L&&(t.style.left=`${r.left}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+s}px`,i.style.left=`${s}px`,i.style.top=`${h.height-m}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}px`,i.classList.add("rotated")),A&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+s}px`,i.style.right=`${s}px`,i.style.top=`${h.height-m}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=f.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)})()}));
|
package/dist/tooltip.css
CHANGED
|
@@ -55,24 +55,6 @@
|
|
|
55
55
|
position: absolute;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.tooltip-arrow.
|
|
59
|
-
top: -25px;
|
|
60
|
-
left: 6px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.tooltip-arrow.left_bottom .icon {
|
|
64
|
-
bottom: -25px;
|
|
65
|
-
left: 5px;
|
|
58
|
+
.tooltip-arrow.rotated .icon {
|
|
66
59
|
transform: rotate(180deg);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.tooltip-arrow.right_bottom .icon {
|
|
70
|
-
bottom: -50px;
|
|
71
|
-
right: 10px;
|
|
72
|
-
transform: rotate(180deg);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.tooltip-arrow.right_top .icon {
|
|
76
|
-
top: -50px;
|
|
77
|
-
right: 10px;
|
|
78
60
|
}
|