@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -1,1 +0,1 @@ | ||
(function(i){typeof define=="function"&&define.amd?define(i):i()})(function(){"use strict";console.log("Mindbe UI");async function i(){const e=document.querySelectorAll(".accordion .item:not([disabled])");for(const t of e)t.addEventListener("click",()=>{const n=t.parentElement.querySelectorAll(".item:not([disabled])");for(const o of n)o!==t&&o.removeAttribute("open")})}function c(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const n=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);s({trigger:t,dropdown:n}),r({trigger:t,dropdown:n}),d({trigger:t,dropdown:n})}}function s({trigger:e,dropdown:t}){e.addEventListener("click",()=>{if(t.classList.contains("show")){t.classList.remove("show");return}l({trigger:e,dropdown:t}),t.classList.add("show")})}function r({trigger:e,dropdown:t}){document.addEventListener("click",n=>{!e.contains(n.target)&&!t.contains(n.target)&&t.classList.remove("show")})}function d({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const n of t)n.addEventListener("click",()=>{e.classList.remove("show")})}function l({trigger:e,dropdown:t}){const{top:n,left:o,height:u}=e.getBoundingClientRect();t.style.setProperty("top",`${n+window.scrollY+u}px`),t.style.setProperty("left",`${o+window.scrollX}px`)}(function e(){if(document){document.addEventListener("DOMContentLoaded",function(){i(),c()});return}setTimeout(()=>{e()},1e3)})();const f=""}); | ||
(function(o){typeof define=="function"&&define.amd?define(o):o()})(function(){"use strict";console.log("Mindbe UI");async function o(){const e=document.querySelectorAll(".accordion .item:not([disabled])");for(const t of e)t.addEventListener("click",()=>{const i=t.parentElement.querySelectorAll(".item:not([disabled])");for(const n of i)n!==t&&n.removeAttribute("open")})}function s(){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}),c({trigger:t,dropdown:i}),l({trigger:t,dropdown:i})}}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",i=>{!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("show")})}function l({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const i of t)i.addEventListener("click",()=>{e.classList.remove("show")})}function u({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",function(){o(),s()});return}setTimeout(()=>{e()},1e3)})();const y=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -42,4 +42,4 @@ console.log("Mindbe UI"); | ||
dropdown.classList.add("show"); | ||
setPositionDropdown({ trigger, dropdown }); | ||
dropdown.classList.add("show"); | ||
}); | ||
@@ -72,5 +72,23 @@ } | ||
function setPositionDropdown({ trigger, dropdown }) { | ||
const { top, left, height } = trigger.getBoundingClientRect(); | ||
dropdown.style.setProperty("top", `${top + window.scrollY + height}px`); | ||
dropdown.style.setProperty("left", `${left + window.scrollX}px`); | ||
const { top, left, right, height } = trigger.getBoundingClientRect(); | ||
const { width, height: heightDrop } = dropdown.getBoundingClientRect(); | ||
if (dropdown.hasAttribute("dropend")) { | ||
dropdown.style.setProperty("top", `${top}px`); | ||
dropdown.style.setProperty("left", `${right}px`); | ||
return; | ||
} | ||
if (dropdown.hasAttribute("dropstart")) { | ||
dropdown.style.setProperty("top", `${top}px`); | ||
dropdown.style.setProperty("left", `${left - width}px`); | ||
return; | ||
} | ||
if (dropdown.hasAttribute("dropup")) { | ||
dropdown.style.setProperty("top", `${top - heightDrop}px`); | ||
dropdown.style.setProperty("left", `${left}px`); | ||
return; | ||
} | ||
dropdown.style.setProperty("top", `${top + height}px`); | ||
dropdown.style.setProperty("left", `${left}px`); | ||
} | ||
@@ -77,0 +95,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36815
156