@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.81 to 0.0.82
@@ -1,1 +0,1 @@ | ||
(function(i){typeof define=="function"&&define.amd?define(i):i()})(function(){"use strict";console.log("Mindbe UI");async function i(){const e=document.querySelectorAll(".accordion .item:not([disabled]");for(const t of e)t.onclick=()=>{const o=t.parentElement.querySelectorAll(".item:not([disabled])");for(const n of o)n!==t&&n.removeAttribute("open")}}function r(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const o=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);y({trigger:t,dropdown:o})}}function y({trigger:e,dropdown:t}){e.onclick=()=>{b({dropdown:t}),w({dropdown:t}),c({trigger:e,dropdown:t}),window.onresize=()=>{c({trigger:e,dropdown:t})},document.onscroll=()=>{c({trigger:e,dropdown:t})},v({trigger:e,dropdown:t}),A({trigger:e,dropdown:t})}}function b({dropdown:e}){const t=document.querySelectorAll("*[dropdown]");for(const o of t)e!==o&&s({dropdown:o})}function w({dropdown:e}){e.classList.toggle("visible"),e.classList.contains("visible")||l()}function A({trigger:e,dropdown:t}){document.onclick=o=>{!e.contains(o.target)&&!t.contains(o.target)&&s({dropdown:t})}}function v({trigger:e,dropdown:t}){const o=t.querySelectorAll(".item");for(const n of o)n.onclick=()=>{if(t.hasAttribute("static")){setTimeout(()=>{console.log("entrei"),c({trigger:e,dropdown:t})},100);return}s({dropdown:t})}}function c({trigger:e,dropdown:t}){const{top:o,bottom:n,left:D,right:T}=e.getBoundingClientRect(),{width:d,height:u}=t.getBoundingClientRect(),{width:E,height:L,top:f,left:g}=document.body.getBoundingClientRect(),m=T-g,k=D-g,a=n-f,x=o-f,p=m+d>E,h=a+u>L;h||t.style.setProperty("top",`${a}px`),h&&t.style.setProperty("top",`${x-u}px`),p||t.style.setProperty("left",`${k}px`),p&&t.style.setProperty("left",`${m-d}px`)}function s({dropdown:e}){e.classList.remove("visible"),l()}function l(){window.onresize=()=>{},document.onscroll=()=>{}}(function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{i(),r()}),document.addEventListener("click",()=>{i(),r()}))})();const q=""}); | ||
(function(c){typeof define=="function"&&define.amd?define(c):c()})(function(){"use strict";console.log("Mindbe UI");function c(){const e=document.querySelectorAll("[tooltip]");for(const t of e)t.onmouseenter=({target:o})=>{const{top:n,left:d}=document.body.getBoundingClientRect(),{top:u,left:r}=t.getBoundingClientRect(),i=document.createElement("div");i.innerHTML=o.getAttribute("tooltip"),i.classList.add("tooltip");const f=r-d,g=u-n-35;i.style.setProperty("top",`${g}px`),i.style.setProperty("left",`${f}px`),document.body.append(i)},t.onmouseleave=()=>{document.querySelector("div.tooltip").remove()}}function m(){const e=document.querySelectorAll(".accordion .item");for(const t of e)t.onclick=()=>{if(!t)return;const o=t.parentElement.querySelectorAll(".item");for(const n of o)n!==t&&n.removeAttribute("open")}}function p(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const o=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);w({trigger:t,dropdown:o})}}function w({trigger:e,dropdown:t}){e.onclick=()=>{D({dropdown:t}),E({dropdown:t}),s({trigger:e,dropdown:t}),window.onresize=()=>{s({trigger:e,dropdown:t})},document.onscroll=()=>{s({trigger:e,dropdown:t})},x({trigger:e,dropdown:t}),L({trigger:e,dropdown:t})}}function D({dropdown:e}){const t=document.querySelectorAll("*[dropdown]");for(const o of t)e!==o&&l({dropdown:o})}function E({dropdown:e}){e.classList.toggle("visible"),e.classList.contains("visible")||a()}function L({trigger:e,dropdown:t}){document.onclick=o=>{!e.contains(o.target)&&!t.contains(o.target)&&l({dropdown:t})}}function x({trigger:e,dropdown:t}){const o=t.querySelectorAll(".item");for(const n of o)n.onclick=()=>{if(t.hasAttribute("static")){s({trigger:e,dropdown:t});return}l({dropdown:t})}}function s({trigger:e,dropdown:t}){const{top:o,bottom:n,left:d,right:u}=e.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),{width:f,height:g,top:y,left:b}=document.body.getBoundingClientRect(),h=u-b,q=d-b,v=n-y,C=o-y,A=h+r>f,T=v+i>g;T||t.style.setProperty("top",`${v}px`),T&&t.style.setProperty("top",`${C-i}px`),A||t.style.setProperty("left",`${q}px`),A&&t.style.setProperty("left",`${h-r}px`)}function l({dropdown:e}){e.classList.remove("visible"),a()}function a(){window.onresize=()=>{},document.onscroll=()=>{}}(function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{c(),m(),p()}),document.addEventListener("click",()=>{c(),m(),p()}))})();const S=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.81", | ||
"version": "0.0.82", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
console.log("Mindbe UI"); | ||
async function Accordion() { | ||
const items = document.querySelectorAll(".accordion .item:not([disabled]"); | ||
function Tooltip() { | ||
const items = document.querySelectorAll("[tooltip]"); | ||
for (const item of items) { | ||
item.onmouseenter = ({ target }) => { | ||
const { top: scrollTop, left: scrollLeft } = | ||
document.body.getBoundingClientRect(); | ||
const { top: topTarget, left: leftTarget } = item.getBoundingClientRect(); | ||
const div = document.createElement("div"); | ||
div.innerHTML = target.getAttribute("tooltip"); | ||
div.classList.add("tooltip"); | ||
const left = leftTarget - scrollLeft; | ||
const top = topTarget - scrollTop - 35; | ||
div.style.setProperty("top", `${top}px`); | ||
div.style.setProperty("left", `${left}px`); | ||
document.body.append(div); | ||
}; | ||
item.onmouseleave = () => { | ||
document.querySelector("div.tooltip").remove(); | ||
}; | ||
} | ||
} | ||
function Accordion() { | ||
const items = document.querySelectorAll(".accordion .item"); | ||
for (const item of items) { | ||
item.onclick = () => { | ||
const itemsByAccordion = item.parentElement.querySelectorAll( | ||
".item:not([disabled])" | ||
); | ||
if (!item) return; | ||
const itemsByAccordion = item.parentElement.querySelectorAll(".item"); | ||
@@ -82,6 +108,3 @@ for (const itemAccordion of itemsByAccordion) { | ||
if (dropdown.hasAttribute("static")) { | ||
setTimeout(() => { | ||
console.log("entrei"); | ||
setPositionDropdown({ trigger, dropdown }); | ||
}, 100); | ||
setPositionDropdown({ trigger, dropdown }); | ||
return; | ||
@@ -147,2 +170,3 @@ } | ||
document.addEventListener("DOMContentLoaded", () => { | ||
Tooltip(); | ||
Accordion(); | ||
@@ -152,2 +176,3 @@ Dropdown(); | ||
document.addEventListener("click", () => { | ||
Tooltip(); | ||
Accordion(); | ||
@@ -154,0 +179,0 @@ Dropdown(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53967
24
242