@erain20029/tooltips 2.0.75 → 2.0.78

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,13 +1,19 @@
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:12px;line-height:1.5;font-weight:300;letter-spacing:.2px;overflow-wrap:break-word}.tooltip-arrow{position:absolute;width:0;height:0;pointer-events:none;color:#53616e}.tooltip-arrow img{width:24px;height:24px;display:block;position:absolute}.tooltip-arrow.left_top img{top:-24px;left:10px}.tooltip-arrow.left_bottom img{bottom:-24px;left:10px}.tooltip-arrow.right_bottom img{bottom:-24px;right:10px}.tooltip-arrow.right_top img{top:-24px;right:10px}",x="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 v(){if(document.getElementById("tooltip-overlay-styles"))return;const i=document.createElement("style");i.id="tooltip-overlay-styles",i.textContent=d,document.head.appendChild(i)}let s=null,p=null,u=[],m=!1;function y(i){const t=i.getBoundingClientRect(),e=window.innerWidth,r=window.innerHeight,l=t.left+t.width/2,o=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:l<e/2?"left":"right",vertical:o<r/2?"top":"bottom"}}}function b(i,t){if(!i)return{titleSize:16,descriptionSize:12};let e=16,r=12,l="left",o="left";switch(i.title){case"small":e=16,l="left";break;case"medium":e=18;break;case"large":e=22;break}switch(i.description){case"small":r=12;break;case"medium":r=14;break;case"large":r=16;break}switch(t.title){case"left":l="left";break;case"center":l="center";break;case"right":l="right";break}switch(t.description){case"left":o="left";break;case"center":o="center";break;case"right":o="right";break}return{titleSize:e,descriptionSize:r,titleAlign:l,descriptionAlign:o}}function w(){s&&(s.remove(),s=null,p=null)}async function k(){if(m)return;const i=localStorage.getItem("product");if(!i)return;const{id:t}=JSON.parse(i),e=document.createElement("script");e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((r,l)=>{e.onload=r,e.onerror=l,document.head.appendChild(e)}),typeof window.tooltipGetter=="function"&&(u=await window.tooltipGetter(),m=!0)}function z(i,t){w(),v();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=`http://localhost:3000${t.image}`,l=t.image?`<img class="tooltip-image" src="${r}" />`:"";e.innerHTML=`
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:12px;line-height:1.5;font-weight:300;letter-spacing:.2px;overflow-wrap:break-word}.tooltip-arrow{position:absolute;width:0;height:0;pointer-events:none}.tooltip-arrow .icon{width:24px;height:24px;display:block;position:absolute;color:#53616e}.tooltip-arrow.left_top .icon{top:-40px;left:10px}.tooltip-arrow.left_bottom .icon{bottom:-40px;left:10px}.tooltip-arrow.right_bottom .icon{bottom:-40px;right:10px}.tooltip-arrow.right_top .icon{top:-40px;right:10px}",x=`
2
+ <svg width="53" height="44" view-origin="60 25 60 40" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M100.524 56.5041 L84.3494 33.3916 L68.1748 56.5041 Z" fill="currentColor" />
4
+ </svg>
5
+ `(function(){function v(){if(document.getElementById("tooltip-overlay-styles"))return;const i=document.createElement("style");i.id="tooltip-overlay-styles",i.textContent=d,document.head.appendChild(i)}let s=null,p=null,m=[],u=!1;function y(i){const t=i.getBoundingClientRect(),e=window.innerWidth,n=window.innerHeight,r=t.left+t.width/2,o=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:r<e/2?"left":"right",vertical:o<n/2?"top":"bottom"}}}function b(i,t){if(!i)return{titleSize:16,descriptionSize:12};let e=16,n=12,r="left",o="left";switch(i.title){case"small":e=16,r="left";break;case"medium":e=18;break;case"large":e=22;break}switch(i.description){case"small":n=12;break;case"medium":n=14;break;case"large":n=16;break}switch(t.title){case"left":r="left";break;case"center":r="center";break;case"right":r="right";break}switch(t.description){case"left":o="left";break;case"center":o="center";break;case"right":o="right";break}return{titleSize:e,descriptionSize:n,titleAlign:r,descriptionAlign:o}}function w(){s&&(s.remove(),s=null,p=null)}async function k(){if(u)return;const i=localStorage.getItem("product");if(!i)return;const{id:t}=JSON.parse(i),e=document.createElement("script");e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((n,r)=>{e.onload=n,e.onerror=r,document.head.appendChild(e)}),typeof window.tooltipGetter=="function"&&(m=await window.tooltipGetter(),u=!0)}function z(i,t){w(),v();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 n=`http://localhost:3000${t.image}`,r=t.image?`<img class="tooltip-image" src="${n}" />`:"";e.innerHTML=`
2
6
  <div class="tooltip-arrow">
3
- <img src="${x}" alt="" />
7
+ <div class="icon">
8
+ ${x}
9
+ </div>
4
10
  </div>
5
11
  <div class="tooltip-card">
6
- ${t.position?.image==="left"?l:""}
12
+ ${t.position?.image==="left"?r:""}
7
13
  <div class="tooltip-text">
8
14
  <div class="tooltip-title">${t.title}</div>
9
15
  <div class="tooltip-desc">${t.description}</div>
10
16
  </div>
11
- ${t.position?.image==="right"?l:""}
17
+ ${t.position?.image==="right"?r:""}
12
18
  </div>
13
- `,document.body.appendChild(e);const{coordinates:o,position:n}=y(i),h=e.getBoundingClientRect(),g=16;let a=0,c=0;const f=e.querySelector(".tooltip-arrow"),{titleSize:S,descriptionSize:$,titleAlign:L,descriptionAlign:T}=b(t.size,t.position),_=`font-size: ${S}px; text-align: ${L};`,C=`font-size: ${$}px; text-align: ${T};`,E=e.querySelector(".tooltip-title"),A=e.querySelector(".tooltip-desc");E.style.cssText=_,A.style.cssText=C,n.horizontal==="left"&&n.vertical==="top"?(a=o.x,c=o.y+o.height+g,f.classList.add("left_top")):n.horizontal==="left"&&n.vertical==="bottom"?(a=o.x,c=o.y-h.height-g,f.classList.add("left_bottom")):n.horizontal==="right"&&n.vertical==="top"?(a=o.x+o.width-h.width,c=o.y+o.height+g,f.classList.add("right_top")):n.horizontal==="right"&&n.vertical==="bottom"&&(a=o.x+o.width-h.width,c=o.y-h.height-g,f.classList.add("right_bottom")),e.style.left=`${Math.max(8,a)}px`,e.style.top=`${Math.max(8,c)}px`,console.log(t),s=e,p=i}document.addEventListener("mouseenter",async i=>{if(!(i.target instanceof Element)||i.target.closest(".tooltip-overlay")||(await k(),!m))return;const t=u.find(r=>i.target.closest(r.selector));if(!t)return;const e=i.target.closest(t.selector);e&&z(e,t)},!0),document.addEventListener("mouseleave",i=>{if(!s||!p)return;const t=i.relatedTarget;t&&!s.contains(t)&&!p.contains(t)&&w()},!0)})()}));
19
+ `,document.body.appendChild(e);const{coordinates:o,position:l}=y(i),h=e.getBoundingClientRect(),g=16;let a=0,c=0;const f=e.querySelector(".tooltip-arrow"),{titleSize:S,descriptionSize:$,titleAlign:L,descriptionAlign:T}=b(t.size,t.position),_=`font-size: ${S}px; text-align: ${L};`,C=`font-size: ${$}px; text-align: ${T};`,E=e.querySelector(".tooltip-title"),A=e.querySelector(".tooltip-desc");E.style.cssText=_,A.style.cssText=C,l.horizontal==="left"&&l.vertical==="top"?(a=o.x,c=o.y+o.height+g,f.classList.add("left_top")):l.horizontal==="left"&&l.vertical==="bottom"?(a=o.x,c=o.y-h.height-g,f.classList.add("left_bottom")):l.horizontal==="right"&&l.vertical==="top"?(a=o.x+o.width-h.width,c=o.y+o.height+g,f.classList.add("right_top")):l.horizontal==="right"&&l.vertical==="bottom"&&(a=o.x+o.width-h.width,c=o.y-h.height-g,f.classList.add("right_bottom")),e.style.left=`${Math.max(8,a)}px`,e.style.top=`${Math.max(8,c)}px`,console.log(t),s=e,p=i}document.addEventListener("mouseenter",async i=>{if(!(i.target instanceof Element)||i.target.closest(".tooltip-overlay")||(await k(),!u))return;const t=m.find(n=>i.target.closest(n.selector));if(!t)return;const e=i.target.closest(t.selector);e&&z(e,t)},!0),document.addEventListener("mouseleave",i=>{if(!s||!p)return;const t=i.relatedTarget;t&&!s.contains(t)&&!p.contains(t)&&w()},!0)})()}));
package/dist/tooltip.css CHANGED
@@ -54,32 +54,32 @@
54
54
  width: 0;
55
55
  height: 0;
56
56
  pointer-events: none;
57
- color: #53616E;
58
57
  }
59
58
 
60
- .tooltip-arrow img {
59
+ .tooltip-arrow .icon {
61
60
  width: 24px;
62
61
  height: 24px;
63
62
  display: block;
64
63
  position: absolute;
64
+ color: #53616E;
65
65
  }
66
66
 
67
- .tooltip-arrow.left_top img {
68
- top: -24px;
67
+ .tooltip-arrow.left_top .icon {
68
+ top: -40px;
69
69
  left: 10px;
70
70
  }
71
71
 
72
- .tooltip-arrow.left_bottom img {
73
- bottom: -24px;
72
+ .tooltip-arrow.left_bottom .icon {
73
+ bottom: -40px;
74
74
  left: 10px;
75
75
  }
76
76
 
77
- .tooltip-arrow.right_bottom img {
78
- bottom: -24px;
77
+ .tooltip-arrow.right_bottom .icon {
78
+ bottom: -40px;
79
79
  right: 10px;
80
80
  }
81
81
 
82
- .tooltip-arrow.right_top img {
83
- top: -24px;
82
+ .tooltip-arrow.right_top .icon {
83
+ top: -40px;
84
84
  right: 10px;
85
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.75",
3
+ "version": "2.0.78",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",