@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.
@@ -1,18 +1,18 @@
1
- (function(p){typeof define=="function"&&define.amd?define(p):p()})((function(){"use strict";const p=".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.left_top .icon{top:-25px;left:6px}.tooltip-arrow.left_bottom .icon{bottom:-25px;left:5px;transform:rotate(180deg)}.tooltip-arrow.right_bottom .icon{bottom:-50px;right:10px;transform:rotate(180deg)}.tooltip-arrow.right_top .icon{top:-50px;right:10px}";(function(){function x(){if(document.getElementById("tooltip-overlay-styles"))return;const i=document.createElement("style");i.id="tooltip-overlay-styles",i.textContent=p,document.head.appendChild(i)}let c=null,d=null,f=[],g=!1;function w(i){const e=i.getBoundingClientRect(),t=window.innerWidth,o=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:o-e.bottom,width:e.width,height:e.height},position:{horizontal:n<t/2?"left":"right",vertical:l<o/2?"top":"bottom"}}}function y(i,e){if(!i)return{titleSize:16,descriptionSize:12};let t=16,o=12,n="left",l="left";switch(i.title){case"small":t=16,n="left";break;case"medium":t=18;break;case"large":t=22;break}switch(i.description){case"small":o=12;break;case"medium":o=14;break;case"large":o=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:o,titleAlign:n,descriptionAlign:l}}function m(){c&&(c.remove(),c=null,d=null)}async function b(){if(g)return;const i=localStorage.getItem("product");if(!i)return;const e=JSON.parse(i).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 o=await window.tooltipGetter();f=Array.isArray(o)?o:[],g=!0}const s=15,u=15;function v(i,e){m(),x();const t=document.createElement("div");t.className="tooltip-overlay",t.style.position="fixed",t.style.pointerEvents="none",t.style.zIndex="9999";const o=document.createElement("div");o.className="tooltip-arrow",o.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=`
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
- `,o.innerHTML=`
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(o),t.appendChild(n),document.body.appendChild(t);const{titleSize:$,descriptionSize:T,titleAlign:z,descriptionAlign:k}=y(e.size,e.position);t.querySelector(".tooltip-title").style.cssText=`
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=i.getBoundingClientRect(),h=t.getBoundingClientRect(),a=w(i).position,E=a.horizontal==="left"&&a.vertical==="top",L=a.horizontal==="left"&&a.vertical==="bottom",_=a.horizontal==="right"&&a.vertical==="top",S=a.horizontal==="right"&&a.vertical==="bottom";E&&(t.style.left=`${r.left}px`,t.style.top=`${r.top+r.height+s}px`,o.style.left=`${s}px`,o.style.bottom=`${h.height}px`,o.classList.add("left_top")),L&&(t.style.left=`${r.left}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+s}px`,o.style.left=`${s}px`,o.style.top=`${h.height-u}px`,o.classList.add("left_bottom")),_&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.top=`${r.top+r.height+s}px`,o.style.right=`${s}px`,o.style.bottom=`${h.height}px`,o.classList.add("right_top")),S&&(t.style.right=`${window.innerWidth-r.right}px`,t.style.bottom=`${window.innerHeight-r.bottom+r.height+s}px`,o.style.right=`${s}px`,o.style.top=`${h.height-u}px`,o.classList.add("right_bottom"))}),c=t,d=i}document.addEventListener("mouseenter",async i=>{if(!(i.target instanceof Element)||i.target.closest(".tooltip-overlay")||(await b(),!g))return;const e=f.find(o=>i.target.closest(o.selector));if(!e)return;const t=i.target.closest(e.selector);t&&v(t,e)},!0),document.addEventListener("mouseleave",i=>{if(!c||!d)return;const e=i.relatedTarget;e&&!c.contains(e)&&!d.contains(e)&&m()},!0)})()}));
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.left_top .icon {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.127",
3
+ "version": "2.0.128",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",