@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -1,1 +0,1 @@ | ||
(function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict";console.log("Mindbe UI"),function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{n(),c()}),document.addEventListener("click",()=>{n(),c()}))}();async function n(){const e=document.querySelectorAll(".accordion .item");for(const t of e)t.onclick=()=>{const i=t.parentElement.querySelectorAll(".item:not([disabled])");for(const o of i)o!==t&&o.removeAttribute("open")}}function c(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const i=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);r({trigger:t,dropdown:i})}}function r({trigger:e,dropdown:t}){e.onclick=()=>{if(t.classList.contains("visible")){t.classList.remove("visible");return}f(),t.classList.add("visible"),d({trigger:e,dropdown:t}),u({dropdown:t}),l({trigger:e,dropdown:t})}}function l({trigger:e,dropdown:t}){document.onclick=i=>{!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("visible")}}function u({dropdown:e}){if(e.hasAttribute("static")){e.classList.add("visible");return}const t=e.querySelectorAll(".item");for(const i of t)i.onclick=()=>{e.classList.remove("visible")}}function f(){const e=document.querySelectorAll("*[dropdown]");for(const t of e)t.classList.remove("visible")}function d({trigger:e,dropdown:t}){const{top:i,left:o,right:a,height:m}=e.getBoundingClientRect(),{width:p,height:y}=t.getBoundingClientRect(),g=Math.abs(document.body.getBoundingClientRect().top),s=i+g;if(t.hasAttribute("dropend")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${a}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${o-p}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-y}px`),t.style.setProperty("left",`${o}px`);return}t.style.setProperty("top",`${s+m}px`),t.style.setProperty("left",`${o}px`)}const b=""}); | ||
(function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict";console.log("Mindbe UI"),function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{n(),c()}),document.addEventListener("click",()=>{n(),c()}))}();async function n(){const e=document.querySelectorAll(".accordion .item");for(const t of e)t.onclick=()=>{const i=t.parentElement.querySelectorAll(".item:not([disabled])");for(const o of i)o!==t&&o.removeAttribute("open")}}function c(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const i=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);r({trigger:t,dropdown:i})}}function r({trigger:e,dropdown:t}){e.onclick=()=>{if(t.classList.contains("visible")){t.classList.remove("visible");return}f(),t.classList.add("visible"),d({trigger:e,dropdown:t}),u({dropdown:t}),l({trigger:e,dropdown:t})}}function l({trigger:e,dropdown:t}){document.onclick=i=>{!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("visible")}}function u({dropdown:e}){if(e.hasAttribute("static")){setTimeout(()=>{e.classList.add("visible")},100);return}const t=e.querySelectorAll(".item");for(const i of t)i.onclick=()=>{e.classList.remove("visible")}}function f(){const e=document.querySelectorAll("*[dropdown]");for(const t of e)t.classList.remove("visible")}function d({trigger:e,dropdown:t}){const{top:i,left:o,right:a,height:m}=e.getBoundingClientRect(),{width:p,height:y}=t.getBoundingClientRect(),g=Math.abs(document.body.getBoundingClientRect().top),s=i+g;if(t.hasAttribute("dropend")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${a}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${o-p}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-y}px`),t.style.setProperty("left",`${o}px`);return}t.style.setProperty("top",`${s+m}px`),t.style.setProperty("left",`${o}px`)}const b=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -64,5 +64,4 @@ console.log("Mindbe UI"); | ||
document.onclick = (event) => { | ||
const isOutsideClick = | ||
!trigger.contains(event.target) && !dropdown.contains(event.target); | ||
!trigger.contains(event.target) && !dropdown.contains(event.target); | ||
@@ -77,5 +76,7 @@ if (isOutsideClick) { | ||
if (dropdown.hasAttribute("static")) { | ||
dropdown.classList.add("visible"); | ||
return | ||
}; | ||
setTimeout(() => { | ||
dropdown.classList.add("visible"); | ||
}, 100); | ||
return; | ||
} | ||
@@ -82,0 +83,0 @@ const items = dropdown.querySelectorAll(".item"); |
44255
181