@erain20029/tooltips 2.0.74 → 2.0.75

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,6 +1,6 @@
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;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}",w="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 x(){if(document.getElementById("tooltip-overlay-styles"))return;const i=document.createElement("style");i.id="tooltip-overlay-styles",i.textContent=c,document.head.appendChild(i)}let n=null,d=null,m=[],f=!1;function v(i){const t=i.getBoundingClientRect(),e=window.innerWidth,l=window.innerHeight,o=t.left+t.width/2,r=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:o<e/2?"left":"right",vertical:r<l/2?"top":"bottom"}}}function y(i,t){if(!i)return{titleSize:16,descriptionSize:12};let e=16,l=12,o="left",r="left";switch(i.title){case"small":e=16,o="left";break;case"medium":e=18;break;case"large":e=22;break}switch(i.description){case"small":l=12;break;case"medium":l=14;break;case"large":l=16;break}switch(t.title){case"left":o="left";break;case"center":o="center";break;case"right":o="right";break}switch(t.description){case"left":r="left";break;case"center":r="center";break;case"right":r="right";break}return{titleSize:e,descriptionSize:l,titleAlign:o,descriptionAlign:r}}function u(){n&&(n.remove(),n=null,d=null)}async function b(){if(f)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((l,o)=>{e.onload=l,e.onerror=o,document.head.appendChild(e)}),typeof window.tooltipGetter=="function"&&(m=await window.tooltipGetter(),f=!0)}function k(i,t){u(),x();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 l=t.image?`<img class="tooltip-image" src="${t.image}" />`:"";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;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=`
2
2
  <div class="tooltip-arrow">
3
- <img src="${w}" alt="" />
3
+ <img src="${x}" alt="" />
4
4
  </div>
5
5
  <div class="tooltip-card">
6
6
  ${t.position?.image==="left"?l:""}
@@ -10,4 +10,4 @@
10
10
  </div>
11
11
  ${t.position?.image==="right"?l:""}
12
12
  </div>
13
- `,document.body.appendChild(e);const{coordinates:o,position:r}=v(i),p=e.getBoundingClientRect(),h=16;let s=0,a=0;const g=e.querySelector(".tooltip-arrow"),{titleSize:z,descriptionSize:S,titleAlign:$,descriptionAlign:L}=y(t.size,t.position),T=`font-size: ${z}px; text-align: ${$};`,_=`font-size: ${S}px; text-align: ${L};`,C=e.querySelector(".tooltip-title"),E=e.querySelector(".tooltip-desc");C.style.cssText=T,E.style.cssText=_,r.horizontal==="left"&&r.vertical==="top"?(s=o.x,a=o.y+o.height+h,g.classList.add("left_top")):r.horizontal==="left"&&r.vertical==="bottom"?(s=o.x,a=o.y-p.height-h,g.classList.add("left_bottom")):r.horizontal==="right"&&r.vertical==="top"?(s=o.x+o.width-p.width,a=o.y+o.height+h,g.classList.add("right_top")):r.horizontal==="right"&&r.vertical==="bottom"&&(s=o.x+o.width-p.width,a=o.y-p.height-h,g.classList.add("right_bottom")),e.style.left=`${Math.max(8,s)}px`,e.style.top=`${Math.max(8,a)}px`,console.log(t),n=e,d=i}document.addEventListener("mouseenter",async i=>{if(!(i.target instanceof Element)||i.target.closest(".tooltip-overlay")||(await b(),!f))return;const t=m.find(l=>i.target.closest(l.selector));if(!t)return;const e=i.target.closest(t.selector);e&&k(e,t)},!0),document.addEventListener("mouseleave",i=>{if(!n||!d)return;const t=i.relatedTarget;t&&!n.contains(t)&&!d.contains(t)&&u()},!0)})()}));
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)})()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.74",
3
+ "version": "2.0.75",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",