@erain20029/tooltips 2.0.32 → 2.0.35
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 +77 -12
- package/dist/tooltip.css +36 -27
- package/package.json +1 -1
|
@@ -1,14 +1,79 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,f=!1;const m=new Set;function y(){if(f)return;const t=document.createElement("style");t.textContent=c,document.head.appendChild(t),f=!0}function b(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 v(){if(a.ready)return;const t=localStorage.getItem("product");if(!t)return;const e=JSON.parse(t).id;await b(`http://localhost:3000/documentation/${e}/tooltip.js`),typeof window.tooltipGetter=="function"&&(a.tooltips=await window.tooltipGetter(),a.ready=!0)}function E({title:t,description:e}){return{title:t==="large"?22:t==="small"?14:18,description:e==="large"?16:e==="small"?12:14}}function P({title:t,description:e,image:o}){return{title:t||"left",description:e||"left",image:o||"left"}}function $(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 S(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 T({tooltip:t,target:e}){g(),y();const o=document.createElement("div");o.className="tooltip-overlay",o.style.left="-9999px",o.style.top="-9999px";const i=E(t.size||{}),n=P(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
|
+
<div class="tooltip-arrow"></div>
|
|
67
|
+
<div class="tooltip-card">
|
|
68
|
+
${n.image==="left"?h:""}
|
|
69
|
+
<div class="tooltip-text">
|
|
70
|
+
<div class="tooltip-title" style="font-size:${i.title}px;text-align:${n.title}">
|
|
71
|
+
${t.title}
|
|
72
|
+
</div>
|
|
73
|
+
<div class="tooltip-desc" style="font-size:${i.description}px;text-align:${n.description}">
|
|
74
|
+
${t.description}
|
|
75
|
+
</div>
|
|
10
76
|
</div>
|
|
77
|
+
${n.image==="right"?h:""}
|
|
11
78
|
</div>
|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
`,document.body.appendChild(i),l=i,d=o}}));
|
|
79
|
+
`,document.body.appendChild(o);const x=e.getBoundingClientRect(),{width:A,height:L}=o.getBoundingClientRect(),u=$(x),w=S(u,x,A,L);o.style.left=w.x+"px",o.style.top=w.y+"px";const d=o.querySelector(".tooltip-arrow");u.includes("top")?(d.classList.add("bottom"),d.style.top="100%"):(d.classList.add("top"),d.style.bottom="100%"),d.style.left=u.includes("right")?"94%":"20px",r=o,p=e}document.addEventListener("mouseenter",async t=>{if(t.target.closest(".tooltip-overlay")||(await v(),!a.ready))return;const e=t.target;if(!(e instanceof Element))return;const o=a.tooltips.find(i=>e.closest(i.selector));o&&T({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
|
@@ -1,55 +1,64 @@
|
|
|
1
|
-
.overlay {
|
|
2
|
-
background: white;
|
|
3
|
-
color: #111;
|
|
1
|
+
.tooltip-overlay {
|
|
4
2
|
position: fixed;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
z-index: 9999;
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
background: #53616E;
|
|
6
|
+
border-radius: 8px;
|
|
7
|
+
box-shadow: 0 4px 20px rgba(0,0,0,.25);
|
|
8
|
+
color: #DADADB;
|
|
9
|
+
max-width: 300px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.tooltip-overlay.with-image {
|
|
13
|
+
max-width: 500px;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
.tooltip-card {
|
|
12
17
|
display: flex;
|
|
13
|
-
height: 100%;
|
|
14
18
|
align-items: center;
|
|
15
19
|
gap: 16px;
|
|
16
20
|
padding: 16px 20px;
|
|
17
|
-
max-width: 500px;
|
|
18
21
|
box-sizing: border-box;
|
|
19
|
-
background: #53616E;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.tooltip-media {
|
|
23
|
-
display: flex;
|
|
24
|
-
justify-content: center;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
.tooltip-image {
|
|
28
25
|
width: 120px;
|
|
29
26
|
height: 120px;
|
|
30
|
-
object-fit: cover;
|
|
31
27
|
border-radius: 8px;
|
|
28
|
+
object-fit: cover;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
.tooltip-text {
|
|
35
32
|
flex: 1;
|
|
36
33
|
min-width: 0;
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
gap: 8px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.tooltip-text div {
|
|
43
|
-
width: 100%;
|
|
44
|
-
display: block;
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
.tooltip-title {
|
|
48
|
-
font-weight:
|
|
37
|
+
font-weight: 300;
|
|
49
38
|
line-height: 1.3;
|
|
39
|
+
margin: 0;
|
|
50
40
|
}
|
|
51
41
|
|
|
52
42
|
.tooltip-desc {
|
|
43
|
+
margin-top: 12px;
|
|
53
44
|
line-height: 1.5;
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
font-weight: 300;
|
|
46
|
+
letter-spacing: 0.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
|
+
}
|