@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.48 to 0.0.49
@@ -1,1 +0,1 @@ | ||
(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")}"]`);l({trigger:t,dropdown:o})}}function l({trigger:e,dropdown:t}){e.onclick=()=>{a(),u({dropdown:t}),r({trigger:e,dropdown:t}),d({trigger:e,dropdown:t}),f({trigger:e,dropdown:t})}}function u({dropdown:e}){if(e.classList.contains("visible")){e.classList.remove("visible");return}e.classList.add("visible")}function f({trigger:e,dropdown:t}){document.onclick=o=>{const n=!e.contains(o.target)&&!t.contains(o.target);console.log("isOutsideClick",n),console.log(t),console.log(o.target)}}function d({trigger:e,dropdown:t}){const o=t.querySelectorAll(".item");for(const n of o)n.onclick=()=>{r({trigger:e,dropdown:t}),!t.hasAttribute("static")&&t.classList.remove("visible")}}function a(){const e=document.querySelectorAll("*[dropdown]");for(const t of e)t.classList.remove("visible")}function r({trigger:e,dropdown:t}){const{top:o,left:n,right:p,height:y}=e.getBoundingClientRect(),{width:m,height:g}=t.getBoundingClientRect(),b=Math.abs(document.body.getBoundingClientRect().top),s=o+b;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-m}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-g}px`),t.style.setProperty("left",`${n}px`);return}t.style.setProperty("top",`${s+y}px`),t.style.setProperty("left",`${n}px`)}const A=""}); | ||
(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")}"]`);l({trigger:t,dropdown:i})}}function l({trigger:e,dropdown:t}){e.onclick=()=>{u(),f({dropdown:t}),r({trigger:e,dropdown:t}),a({trigger:e,dropdown:t}),d({trigger:e,dropdown:t})}}function u(){const e=document.querySelectorAll("*[dropdown]");for(const t of e)t.classList.remove("visible")}function f({dropdown:e}){if(e.classList.contains("visible")){e.classList.remove("visible");return}e.classList.add("visible")}function d({trigger:e,dropdown:t}){document.onclick=i=>{!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("visible")}}function a({trigger:e,dropdown:t}){const i=t.querySelectorAll(".item");for(const o of i)o.onclick=()=>{r({trigger:e,dropdown:t}),!t.hasAttribute("static")&&t.classList.remove("visible")}}function r({trigger:e,dropdown:t}){const{top:i,left:o,right:p,height:m}=e.getBoundingClientRect(),{width:y,height:g}=t.getBoundingClientRect(),b=Math.abs(document.body.getBoundingClientRect().top),s=i+b;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",`${o-y}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-g}px`),t.style.setProperty("left",`${o}px`);return}t.style.setProperty("top",`${s+m}px`),t.style.setProperty("left",`${o}px`)}const v=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.48", | ||
"version": "0.0.49", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -48,5 +48,4 @@ console.log("Mindbe UI"); | ||
trigger.onclick = () => { | ||
hideAllDropdowns(); | ||
hideAllDropdown(); | ||
toggleDropdown({ dropdown }); | ||
setPositionDropdown({ trigger, dropdown }); | ||
@@ -58,2 +57,10 @@ addHideEventDropdownItems({ trigger, dropdown }); | ||
function hideAllDropdown() { | ||
const dropdowns = document.querySelectorAll("*[dropdown]"); | ||
for (const dropdown of dropdowns) { | ||
dropdown.classList.remove("visible"); | ||
} | ||
} | ||
function toggleDropdown({ dropdown }) { | ||
@@ -73,9 +80,5 @@ if (dropdown.classList.contains("visible")) { | ||
console.log("isOutsideClick", isOutsideClick); | ||
console.log(dropdown); | ||
console.log(event.target); | ||
// if (isOutsideClick) { | ||
// dropdown.classList.remove("visible"); | ||
// } | ||
if (isOutsideClick) { | ||
dropdown.classList.remove("visible"); | ||
} | ||
}; | ||
@@ -96,10 +99,2 @@ } | ||
function hideAllDropdowns() { | ||
const dropdowns = document.querySelectorAll("*[dropdown]"); | ||
for (const dropdown of dropdowns) { | ||
dropdown.classList.remove("visible"); | ||
} | ||
} | ||
function setPositionDropdown({ trigger, dropdown }) { | ||
@@ -106,0 +101,0 @@ const { top, left, right, height } = trigger.getBoundingClientRect(); |
44326
180