@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.42 to 0.0.43
@@ -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 o=t.parentElement.querySelectorAll(".item:not([disabled])");for(const i of o)i!==t&&i.removeAttribute("open")}}function c(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const o=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);r({trigger:t,dropdown:o})}}function r({trigger:e,dropdown:t}){e.onclick=()=>{d(),t.classList.add("visible"),f({trigger:e,dropdown:t}),u({dropdown:t}),l({trigger:e,dropdown:t})}}function l({trigger:e,dropdown:t}){document.onclick=o=>{!e.contains(o.target)&&!t.contains(o.target)&&t.classList.remove("visible")}}function u({dropdown:e}){const t=e.querySelectorAll(".item");for(const o of t)o.onclick=()=>{e.hasAttribute("static")||e.classList.remove("visible")}}function d(){const e=document.querySelectorAll("*[dropdown]");for(const t of e)t.classList.remove("visible")}function f({trigger:e,dropdown:t}){const{top:o,left:i,right:p,height:a}=e.getBoundingClientRect(),{width:y,height:m}=t.getBoundingClientRect(),g=Math.abs(document.body.getBoundingClientRect().top),s=o+g;if(t.hasAttribute("dropend")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${p}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${i-y}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-m}px`),t.style.setProperty("left",`${i}px`);return}t.style.setProperty("top",`${s+a}px`),t.style.setProperty("left",`${i}px`)}const b=""}); | ||
(function(i){typeof define=="function"&&define.amd?define(i):i()})(function(){"use strict";console.log("Mindbe UI"),function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{i(),c()}),document.addEventListener("click",()=>{i(),c()}))}();async function i(){const e=document.querySelectorAll(".accordion .item");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 c(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const o=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);r({trigger:t,dropdown:o})}}function r({trigger:e,dropdown:t}){e.onclick=()=>{d(),l({dropdown:t}),console.log("trigger click"),f({trigger:e,dropdown:t}),u({trigger:e,dropdown:t})}}function l({dropdown:e}){if(e.classList.contains("visible")){e.classList.remove("visible");return}e.classList.add("visible")}function u({trigger:e,dropdown:t}){document.onclick=o=>{!e.contains(o.target)&&!t.contains(o.target)&&t.classList.remove("visible")}}function d(){const e=document.querySelectorAll("*[dropdown]");for(const t of e)t.classList.remove("visible")}function f({trigger:e,dropdown:t}){const{top:o,left:n,right:p,height:a}=e.getBoundingClientRect(),{width:g,height:y}=t.getBoundingClientRect(),m=Math.abs(document.body.getBoundingClientRect().top),s=o+m;if(t.hasAttribute("dropend")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${p}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${n-g}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-y}px`),t.style.setProperty("left",`${n}px`);return}t.style.setProperty("top",`${s+a}px`),t.style.setProperty("left",`${n}px`)}const b=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -48,12 +48,8 @@ console.log("Mindbe UI"); | ||
trigger.onclick = () => { | ||
// if (dropdown.classList.contains("visible")) { | ||
// dropdown.classList.remove("visible"); | ||
// return; | ||
// } | ||
hideAllDropdowns(); | ||
dropdown.classList.add("visible"); | ||
toggleDropdown({ dropdown }); | ||
console.log("trigger click"); | ||
setPositionDropdown({ trigger, dropdown }); | ||
addHideEventDropdownItems({ dropdown }); | ||
// addHideEventDropdownItems({ dropdown }); | ||
addHideEventDropdown({ trigger, dropdown }); | ||
@@ -63,2 +59,11 @@ }; | ||
function toggleDropdown({ dropdown }) { | ||
if (dropdown.classList.contains("visible")) { | ||
dropdown.classList.remove("visible"); | ||
return; | ||
} | ||
dropdown.classList.add("visible"); | ||
} | ||
function addHideEventDropdown({ trigger, dropdown }) { | ||
@@ -65,0 +70,0 @@ document.onclick = (event) => { |
44114
180