@erain20029/tooltips 2.0.66 → 2.0.67

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:120px;height:120px;border-radius:8px;object-fit:cover}.tooltip-text{flex:1}.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}",u="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 o=document.createElement("style");o.id="tooltip-overlay-styles",o.textContent=c,document.head.appendChild(o)}let l=null,d=null,f=[],m=!1;function v(o){const t=o.getBoundingClientRect(),e=window.innerWidth,r=window.innerHeight,i=t.left+t.width/2,n=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:i<e/2?"left":"right",vertical:n<r/2?"top":"bottom"}}}function w(){l&&(l.remove(),l=null,d=null)}async function y(){if(m)return;const o=localStorage.getItem("product");if(!o)return;const{id:t}=JSON.parse(o),e=document.createElement("script");e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((r,i)=>{e.onload=r,e.onerror=i,document.head.appendChild(e)}),typeof window.tooltipGetter=="function"&&(f=await window.tooltipGetter(),m=!0)}function b(o,t){w(),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 r=t.image?`<img class="tooltip-image" src="${t.image}" />`:"";e.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;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:120px;height:120px;border-radius:8px;object-fit:cover}.tooltip-text{flex:1}.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 o=document.createElement("style");o.id="tooltip-overlay-styles",o.textContent=c,document.head.appendChild(o)}let l=null,d=null,g=[],f=!1;function v(o){const t=o.getBoundingClientRect(),e=window.innerWidth,r=window.innerHeight,i=t.left+t.width/2,n=t.top+t.height/2;return{coordinates:{x:t.left,y:t.top,width:t.width,height:t.height},position:{horizontal:i<e/2?"left":"right",vertical:n<r/2?"top":"bottom"}}}function u(){l&&(l.remove(),l=null,d=null)}async function y(){if(f)return;const o=localStorage.getItem("product");if(!o)return;const{id:t}=JSON.parse(o),e=document.createElement("script");e.src=`http://localhost:3000/documentation/${t}/tooltip.js`,await new Promise((r,i)=>{e.onload=r,e.onerror=i,document.head.appendChild(e)}),typeof window.tooltipGetter=="function"&&(g=await window.tooltipGetter(),f=!0)}function b(o,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 r=t.image?`<img class="tooltip-image" src="${t.image}" />`:"";e.innerHTML=`
2
2
  <div class="tooltip-arrow">
3
- <img src="${u}" alt="" />
3
+ <img src="${w}" alt="" />
4
4
  </div>
5
5
  <div class="tooltip-card">
6
6
  ${t.position?.image==="left"?r:""}
@@ -10,4 +10,4 @@
10
10
  </div>
11
11
  ${t.position?.image==="right"?r:""}
12
12
  </div>
13
- `,document.body.appendChild(e);const{coordinates:i,position:n}=v(o),p=e.getBoundingClientRect(),h=16;let a=0,s=0;const g=e.querySelector(".tooltip-arrow");n.horizontal==="left"&&n.vertical==="top"&&(a=i.x,s=i.y+i.height+h,g.classList.add("left_top")),n.horizontal==="left"&&n.vertical==="bottom"&&(a=i.x,s=i.y-p.height-h,g.classList.add("left_bottom")),n.horizontal==="right"&&n.vertical==="top"&&(a=i.x+i.width-p.width,s=i.y+i.height+h,g.classList.add("right_top")),n.horizontal==="right"&&n.vertical==="bottom"&&(a=i.x+i.width-p.width,s=i.y-p.height-h,g.classList.add("right_bottom")),e.style.left=`${Math.max(8,a)}px`,e.style.top=`${Math.max(8,s)}px`,console.log(f),l=e,d=o}document.addEventListener("mouseenter",async o=>{if(!(o.target instanceof Element)||o.target.closest(".tooltip-overlay")||(await y(),!m))return;const t=f.find(r=>o.target.closest(r.selector));if(!t)return;const e=o.target.closest(t.selector);e&&b(e,t)},!0),document.addEventListener("mouseleave",o=>{if(!l||!d)return;const t=o.relatedTarget;t&&!l.contains(t)&&!d.contains(t)&&w()},!0)})()}));
13
+ `,document.body.appendChild(e);const{coordinates:i,position:n}=v(o),m=e.getBoundingClientRect(),p=16;let a=0,s=0;const h=e.querySelector(".tooltip-arrow");n.horizontal==="left"&&n.vertical==="top"&&(a=i.x,s=i.y+i.height+p,h.classList.add("left_top")),n.horizontal==="left"&&n.vertical==="bottom"&&(a=i.x,s=i.y-m.height-p,h.classList.add("left_bottom")),n.horizontal==="right"&&n.vertical==="top"&&(a=i.x+i.width-m.width,s=i.y+i.height+p,h.classList.add("right_top")),n.horizontal==="right"&&n.vertical==="bottom"&&(a=i.x,s=i.y-m.height-p,h.classList.add("right_bottom")),e.style.left=`${Math.max(8,a)}px`,e.style.top=`${Math.max(8,s)}px`,console.log(g),l=e,d=o}document.addEventListener("mouseenter",async o=>{if(!(o.target instanceof Element)||o.target.closest(".tooltip-overlay")||(await y(),!f))return;const t=g.find(r=>o.target.closest(r.selector));if(!t)return;const e=o.target.closest(t.selector);e&&b(e,t)},!0),document.addEventListener("mouseleave",o=>{if(!l||!d)return;const t=o.relatedTarget;t&&!l.contains(t)&&!d.contains(t)&&u()},!0)})()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erain20029/tooltips",
3
- "version": "2.0.66",
3
+ "version": "2.0.67",
4
4
  "description": "Universal tooltip overlay for any HTML project",
5
5
  "license": "MIT",
6
6
  "author": "Erik",