@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -1,1 +0,1 @@ | ||
(function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict";console.log("Mindbe UI");async function n(){const e=document.querySelectorAll(".accordion .item:not([disabled])");for(const t of e)t.addEventListener("click",()=>{const o=t.parentElement.querySelectorAll(".item:not([disabled])");for(const i of o)i!==t&&i.removeAttribute("open")})}function s(){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}),c({trigger:t,dropdown:o}),l({trigger:t,dropdown:o})}}function r({trigger:e,dropdown:t}){e.addEventListener("click",()=>{if(t.classList.contains("show")){t.classList.remove("show");return}t.classList.add("show"),u({trigger:e,dropdown:t})})}function c({trigger:e,dropdown:t}){document.addEventListener("click",o=>{!e.contains(o.target)&&!t.contains(o.target)&&t.classList.remove("show")})}function l({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const o of t)o.addEventListener("click",()=>{e.classList.remove("show")})}function u({trigger:e,dropdown:t}){const{top:o,left:i,right:d,height:a}=e.getBoundingClientRect(),{width:f,height:g}=t.getBoundingClientRect();if(t.hasAttribute("dropend")){t.style.setProperty("top",`${o}px`),t.style.setProperty("left",`${d}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${o}px`),t.style.setProperty("left",`${i-f}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${o-g}px`),t.style.setProperty("left",`${i}px`);return}t.style.setProperty("top",`${o+a}px`),t.style.setProperty("left",`${i}px`)}(function e(){if(document){document.addEventListener("DOMContentLoaded",()=>{n(),s()}),document.addEventListener("click",function(t){n(),console.log("click"),!t.target.hasAttribute("dropdown-trigger")&&(console.log("passow"),console.log(t.target.hasAttribute("dropdown-trigger")),console.log(t.target),s())});return}setTimeout(()=>{e()},1e3)})();const p=""}); | ||
(function(s){typeof define=="function"&&define.amd?define(s):s()})(function(){"use strict";console.log("Mindbe UI");async function s(){const e=document.querySelectorAll(".accordion .item:not([disabled])");for(const t of e){if(t.getAttribute("listener"))return;t.setAttribute("listener",!0),t.addEventListener("click",()=>{const i=t.parentElement.querySelectorAll(".item:not([disabled])");for(const n of i)n!==t&&n.removeAttribute("open")})}}function r(e){const t=document.querySelectorAll("*[dropdown-trigger]");for(const i of t){const n=document.querySelector(`.dropdown[dropdown="${i.getAttribute("dropdown-trigger")}"]`);if(o({trigger:i,dropdown:n}),u({trigger:i,dropdown:n}),e)return;c({trigger:i,dropdown:n})}}function o({trigger:e,dropdown:t}){e.getAttribute("listener")||e.addEventListener("click",()=>{if(e.setAttribute("listener",!0),t.classList.contains("show")){t.classList.remove("show");return}t.classList.add("show"),l({trigger:e,dropdown:t})})}function c({trigger:e,dropdown:t}){document.addEventListener("click",i=>{!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("show")})}function u({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const i of t){if(i.getAttribute("listener"))return;i.setAttribute("listener",!0),i.addEventListener("click",()=>{e.classList.remove("show")})}}function l({trigger:e,dropdown:t}){const{top:i,left:n,right:f,height:d}=e.getBoundingClientRect(),{width:a,height:m}=t.getBoundingClientRect();if(t.hasAttribute("dropend")){t.style.setProperty("top",`${i}px`),t.style.setProperty("left",`${f}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${i}px`),t.style.setProperty("left",`${n-a}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${i-m}px`),t.style.setProperty("left",`${n}px`);return}t.style.setProperty("top",`${i+d}px`),t.style.setProperty("left",`${n}px`)}(function e(){if(document){document.addEventListener("DOMContentLoaded",t=>{s(),r()}),document.addEventListener("click",t=>{s(),r(!0)});return}setTimeout(()=>{e()},1e3)})();const y=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -7,2 +7,5 @@ console.log("Mindbe UI"); | ||
for (const item of items) { | ||
if (item.getAttribute("listener")) return; | ||
item.setAttribute("listener", true); | ||
item.addEventListener("click", () => { | ||
@@ -22,3 +25,3 @@ const itemsByAccordion = item.parentElement.querySelectorAll( | ||
function Dropdown() { | ||
function Dropdown(reload) { | ||
const triggers = document.querySelectorAll("*[dropdown-trigger]"); | ||
@@ -32,4 +35,6 @@ | ||
addShowEventDropdown({ trigger, dropdown }); | ||
addHideEventDropdownItems({ trigger, dropdown }); | ||
if (reload) return; | ||
addHideEventDropdown({ trigger, dropdown }); | ||
addHideEventDropdownItems({ trigger, dropdown }); | ||
} | ||
@@ -39,3 +44,7 @@ } | ||
function addShowEventDropdown({ trigger, dropdown }) { | ||
if (trigger.getAttribute("listener")) return; | ||
trigger.addEventListener("click", () => { | ||
trigger.setAttribute("listener", true); | ||
if (dropdown.classList.contains("show")) { | ||
@@ -45,3 +54,2 @@ dropdown.classList.remove("show"); | ||
} | ||
dropdown.classList.add("show"); | ||
@@ -69,2 +77,5 @@ setPositionDropdown({ trigger, dropdown }); | ||
for (const item of items) { | ||
if (item.getAttribute("listener")) return; | ||
item.setAttribute("listener", true); | ||
item.addEventListener("click", () => { | ||
@@ -102,15 +113,9 @@ dropdown.classList.remove("show"); | ||
if (document) { | ||
document.addEventListener("DOMContentLoaded", () => { | ||
document.addEventListener("DOMContentLoaded", (e) => { | ||
Accordion(); | ||
Dropdown(); | ||
}); | ||
document.addEventListener("click", function (e) { | ||
document.addEventListener("click", (e) => { | ||
Accordion(); | ||
console.log("click"); | ||
if (e.target.hasAttribute("dropdown-trigger")) return; | ||
console.log("passow"); | ||
console.log(e.target.hasAttribute("dropdown-trigger")); | ||
console.log(e.target); | ||
Dropdown(); | ||
Dropdown(true); | ||
}); | ||
@@ -117,0 +122,0 @@ return; |
44255
179