@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.37 to 0.0.38
@@ -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=()=>{if(t.classList.contains("visible")){t.classList.remove("visible");return}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=>{console.log("hide by outside"),!e.contains(o.target)&&!t.contains(o.target)&&t.classList.remove("visible")}}function u({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const o of t)o.onclick=()=>{console.log("hide by item"),e.classList.remove("visible")}}function d(){console.log("hide all");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:a,height:y}=e.getBoundingClientRect(),{width:m,height:p}=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",`${a}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${s}px`),t.style.setProperty("left",`${i-m}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${s-p}px`),t.style.setProperty("left",`${i}px`);return}t.style.setProperty("top",`${s+y}px`),t.style.setProperty("left",`${i}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")){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=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.37", | ||
"version": "0.0.38", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -64,6 +64,5 @@ console.log("Mindbe UI"); | ||
document.onclick = (event) => { | ||
console.log("hide by outside"); | ||
const isOutsideClick = | ||
!trigger.contains(event.target) && !dropdown.contains(event.target); | ||
!trigger.contains(event.target) && !dropdown.contains(event.target); | ||
@@ -77,3 +76,6 @@ if (isOutsideClick) { | ||
function addHideEventDropdownItems({ dropdown }) { | ||
if (dropdown.hasAttribute("static")) return; | ||
if (dropdown.hasAttribute("static")) { | ||
dropdown.classList.add("visible"); | ||
return | ||
}; | ||
@@ -84,3 +86,2 @@ const items = dropdown.querySelectorAll(".item"); | ||
item.onclick = () => { | ||
console.log("hide by item"); | ||
dropdown.classList.remove("visible"); | ||
@@ -92,3 +93,2 @@ }; | ||
function hideAllDropdowns() { | ||
console.log("hide all"); | ||
const dropdowns = document.querySelectorAll("*[dropdown]"); | ||
@@ -95,0 +95,0 @@ |
Sorry, the diff of this file is not supported yet
44198