@erain20029/tooltips 2.0.36 → 2.0.37
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 +2 -66
- package/dist/tooltip.css +2 -3
- package/package.json +1 -1
|
@@ -1,68 +1,4 @@
|
|
|
1
|
-
(function(c){typeof define=="function"&&define.amd?define(c):c()})((function(){"use strict";(function(){const c=`
|
|
2
|
-
.tooltip-overlay {
|
|
3
|
-
position: fixed;
|
|
4
|
-
z-index: 9999;
|
|
5
|
-
pointer-events: none;
|
|
6
|
-
background: #53616E;
|
|
7
|
-
border-radius: 8px;
|
|
8
|
-
box-shadow: 0 4px 20px rgba(0,0,0,.25);
|
|
9
|
-
color: #DADADB;
|
|
10
|
-
max-width: 300px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.tooltip-overlay.with-image {
|
|
14
|
-
max-width: 500px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.tooltip-card {
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
gap: 16px;
|
|
21
|
-
padding: 16px 20px;
|
|
22
|
-
box-sizing: border-box;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.tooltip-image {
|
|
26
|
-
width: 120px;
|
|
27
|
-
height: 120px;
|
|
28
|
-
border-radius: 8px;
|
|
29
|
-
object-fit: cover;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.tooltip-text {
|
|
33
|
-
flex: 1;
|
|
34
|
-
min-width: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.tooltip-title {
|
|
38
|
-
font-weight: 300;
|
|
39
|
-
line-height: 1.3;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.tooltip-desc {
|
|
43
|
-
margin-top: 12px;
|
|
44
|
-
line-height: 1.5;
|
|
45
|
-
font-weight: 300;
|
|
46
|
-
letter-spacing: .2px;
|
|
47
|
-
overflow-wrap: break-word;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.tooltip-arrow {
|
|
51
|
-
position: absolute;
|
|
52
|
-
width: 0;
|
|
53
|
-
height: 0;
|
|
54
|
-
border-left: 14px solid transparent;
|
|
55
|
-
border-right: 14px solid transparent;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.tooltip-arrow.top {
|
|
59
|
-
border-bottom: 30px solid #53616E;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.tooltip-arrow.bottom {
|
|
63
|
-
border-top: 30px solid #53616E;
|
|
64
|
-
}
|
|
65
|
-
`,a={tooltips:[],ready:!1};let r=null,p=null,u=!1;const m=new Set;function w(){if(u)return;const t=document.createElement("style");t.textContent=c,document.head.appendChild(t),u=!0}function y(t){return m.has(t)?Promise.resolve():new Promise((e,o)=>{const i=document.createElement("script");i.src=t,i.async=!0,i.onload=()=>{m.add(t),e()},i.onerror=()=>o(new Error("Failed to load "+t)),document.head.appendChild(i)})}function g(){r&&(r.remove(),r=null,p=null)}async function b(){if(a.ready)return;const t=localStorage.getItem("product");if(!t)return;const e=JSON.parse(t).id;await y(`http://localhost:3000/documentation/${e}/tooltip.js`),typeof window.tooltipGetter=="function"&&(a.tooltips=await window.tooltipGetter(),a.ready=!0)}function v({title:t,description:e}){return{title:t==="large"?22:t==="small"?14:18,description:e==="large"?16:e==="small"?12:14}}function $({title:t,description:e,image:o}){return{title:t||"left",description:e||"left",image:o||"left"}}function E(t){const e=t.left+t.width/2,o=t.top+t.height/2,i=e<window.innerWidth/2,n=o<window.innerHeight/2;return i&&n?"left-bottom":!i&&n?"right-bottom":i&&!n?"left-top":"right-top"}function P(t,e,o,i){let s=0,l=0;switch(t){case"left-top":s=e.left,l=e.top-i-16;break;case"right-top":s=e.right-o,l=e.top-i-16;break;case"left-bottom":s=e.left,l=e.bottom+48;break;case"right-bottom":s=e.right-o,l=e.bottom+48;break}return{x:Math.max(8,Math.min(s,window.innerWidth-o-8)),y:Math.max(8,Math.min(l,window.innerHeight-i-8))}}function S({tooltip:t,target:e}){if(g(),w(),!(e instanceof Element))return;const o=document.createElement("div");o.className="tooltip-overlay",o.style.left="-9999px",o.style.top="-9999px";const i=v(t.size||{}),n=$(t.position||{});t.image&&o.classList.add("with-image");const l=window.TOOLTIP_UPLOAD_URL||"http://localhost:3000",h=t.image?`<img class="tooltip-image" src="${l}${t.image}" />`:"";o.innerHTML=`
|
|
1
|
+
(function(c){typeof define=="function"&&define.amd?define(c):c()})((function(){"use strict";const c=".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(){const a={tooltips:[],ready:!1};let r=null,p=null,u=!1;const m=new Set;function w(){if(u)return;const t=document.createElement("style");t.textContent=c,document.head.appendChild(t),u=!0}function y(t){return m.has(t)?Promise.resolve():new Promise((e,o)=>{const i=document.createElement("script");i.src=t,i.async=!0,i.onload=()=>{m.add(t),e()},i.onerror=()=>o(new Error("Failed to load "+t)),document.head.appendChild(i)})}function g(){r&&(r.remove(),r=null,p=null)}async function b(){if(a.ready)return;const t=localStorage.getItem("product");if(!t)return;const e=JSON.parse(t).id;await y(`http://localhost:3000/documentation/${e}/tooltip.js`),typeof window.tooltipGetter=="function"&&(a.tooltips=await window.tooltipGetter(),a.ready=!0)}function v({title:t,description:e}){return{title:t==="large"?22:t==="small"?14:18,description:e==="large"?16:e==="small"?12:14}}function $({title:t,description:e,image:o}){return{title:t||"left",description:e||"left",image:o||"left"}}function E(t){const e=t.left+t.width/2,o=t.top+t.height/2,i=e<window.innerWidth/2,n=o<window.innerHeight/2;return i&&n?"left-bottom":!i&&n?"right-bottom":i&&!n?"left-top":"right-top"}function P(t,e,o,i){let s=0,l=0;switch(t){case"left-top":s=e.left,l=e.top-i-16;break;case"right-top":s=e.right-o,l=e.top-i-16;break;case"left-bottom":s=e.left,l=e.bottom+48;break;case"right-bottom":s=e.right-o,l=e.bottom+48;break}return{x:Math.max(8,Math.min(s,window.innerWidth-o-8)),y:Math.max(8,Math.min(l,window.innerHeight-i-8))}}function S({tooltip:t,target:e}){if(g(),w(),!(e instanceof Element))return;const o=document.createElement("div");o.className="tooltip-overlay",o.style.left="-9999px",o.style.top="-9999px";const i=v(t.size||{}),n=$(t.position||{});t.image&&o.classList.add("with-image");const l=window.TOOLTIP_UPLOAD_URL||"http://localhost:3000",h=t.image?`<img class="tooltip-image" src="${l}${t.image}" />`:"";o.innerHTML=`
|
|
66
2
|
<div class="tooltip-arrow"></div>
|
|
67
3
|
<div class="tooltip-card">
|
|
68
4
|
${n.image==="left"?h:""}
|
|
@@ -76,4 +12,4 @@
|
|
|
76
12
|
</div>
|
|
77
13
|
${n.image==="right"?h:""}
|
|
78
14
|
</div>
|
|
79
|
-
`,document.body.appendChild(o);const x=e.getBoundingClientRect(),{width:T,height:
|
|
15
|
+
`,document.body.appendChild(o);const x=e.getBoundingClientRect(),{width:T,height:L}=o.getBoundingClientRect(),f=E(x),{x:z,y:A}=P(f,x,T,L);o.style.left=`${z}px`,o.style.top=`${A}px`;const d=o.querySelector(".tooltip-arrow");f.includes("top")?(d.classList.add("bottom"),d.style.top="100%"):(d.classList.add("top"),d.style.bottom="100%"),d.style.left=f.includes("right")?"94%":"20px",r=o,p=e}document.addEventListener("mouseenter",async t=>{if(t.target.closest(".tooltip-overlay")||(await b(),!a.ready))return;const e=t.target;if(!(e instanceof Element))return;const o=a.tooltips.find(i=>e.closest(i.selector));o&&S({tooltip:o,target:e.closest(o.selector)})},!0),document.addEventListener("mouseleave",t=>{if(!r||!p)return;const e=t.relatedTarget;e&&!r.contains(e)&&!p.contains(e)&&g()},!0)})()}));
|
package/dist/tooltip.css
CHANGED
|
@@ -36,14 +36,13 @@
|
|
|
36
36
|
.tooltip-title {
|
|
37
37
|
font-weight: 300;
|
|
38
38
|
line-height: 1.3;
|
|
39
|
-
margin: 0;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
.tooltip-desc {
|
|
43
42
|
margin-top: 12px;
|
|
44
43
|
line-height: 1.5;
|
|
45
44
|
font-weight: 300;
|
|
46
|
-
letter-spacing:
|
|
45
|
+
letter-spacing: .2px;
|
|
47
46
|
overflow-wrap: break-word;
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -61,4 +60,4 @@
|
|
|
61
60
|
|
|
62
61
|
.tooltip-arrow.bottom {
|
|
63
62
|
border-top: 30px solid #53616E;
|
|
64
|
-
}
|
|
63
|
+
}
|