gentelella
Version:
Gentelella v4 — free admin template. 60 pages, 20 chart variants, fully interactive inbox & kanban, live theme generator, component playground, PWA-ready. Vite 8, vanilla JS, no Bootstrap, no jQuery.
1 lines • 3.08 kB
JavaScript
import{t as e}from"./toast-DgCSlJPv.js";var t=null,n=null;function o(){t&&(t.remove(),n&&n.setAttribute("aria-expanded","false"),t=null,n=null)}function s(e,t){const n=t.getBoundingClientRect();e.style.visibility="hidden",document.body.appendChild(e);const o=e.offsetWidth,s=e.offsetHeight;let i=n.bottom+6,r=n.right-o;i+s>window.innerHeight-8&&(i=n.top-s-6),r=Math.max(8,Math.min(r,window.innerWidth-o-8)),e.style.top=`${Math.round(i)}px`,e.style.left=`${Math.round(r)}px`,e.style.visibility=""}function i(e,i){if(n===e)return void o();o();const r=function(e){const t=document.createElement("div");return t.className="menu-popover",t.setAttribute("role","menu"),e.forEach(e=>{if("-"===e){const e=document.createElement("div");return e.className="menu-separator",void t.appendChild(e)}const s=document.createElement("button");s.type="button",s.className="menu-item",s.setAttribute("role","menuitem"),s.textContent=e.label,s.addEventListener("click",()=>{const t=n;o(),"function"==typeof e.action&&e.action(t)}),t.appendChild(s)}),t}(i);s(r,e),t=r,n=e,e.setAttribute("aria-expanded","true");const a=r.querySelector(".menu-item");a&&a.focus()}function r(e,i,r={}){if(n===e)return void o();o();const a=document.createElement("div");a.className=`menu-popover menu-panel ${r.className||""}`.trim(),a.setAttribute("role","dialog"),r.width&&(a.style.width=`${r.width}px`),"string"==typeof i?a.innerHTML=i:a.appendChild(i),s(a,e),t=a,n=e,e.setAttribute("aria-expanded","true");const c=a.querySelector('button, [href], input, [tabindex]:not([tabindex="-1"])');c&&c.focus()}document.addEventListener("click",e=>{t&&(t.contains(e.target)||n&&n.contains(e.target)||o())},!0),document.addEventListener("keydown",e=>{if("Escape"===e.key&&t){const e=n;o(),e&&e.focus()}}),window.addEventListener("scroll",o,{passive:!0,capture:!0}),window.addEventListener("resize",o);var a=[{label:"Refresh",action:t=>{const n=t?.closest(".card");n&&(n.classList.add("is-refreshing"),setTimeout(()=>n.classList.remove("is-refreshing"),700),n.querySelector("[data-chart]")&&document.documentElement.dispatchEvent(new CustomEvent("themechange")),e("Refreshed",{variant:"success"}))}},{label:"Move up",action:e=>{const t=e?.closest(".card"),n=t?.previousElementSibling;t&&n&&n.classList.contains("card")&&t.parentNode.insertBefore(t,n)}},{label:"Move down",action:e=>{const t=e?.closest(".card"),n=t?.nextElementSibling;t&&n&&n.classList.contains("card")&&t.parentNode.insertBefore(n,t)}},"-",{label:"Hide card",action:t=>{const n=t?.closest(".card");if(!n)return;const o=document.createComment("hidden-card");n.style.transition="opacity 200ms, transform 200ms",n.style.opacity="0",n.style.transform="scale(0.97)",setTimeout(()=>{n.parentNode.insertBefore(o,n),n.remove()},220),e("Card hidden — click here to undo",{duration:5e3}),setTimeout(()=>{const e=document.querySelector(".toast-host .toast:last-child");e&&(e.style.cursor="pointer",e.addEventListener("click",()=>{o.parentNode&&(o.parentNode.insertBefore(n,o),o.remove(),n.style.opacity="1",n.style.transform="")},{once:!0}))},30)}}];export{i as n,r,a as t};