UNPKG

@flexilla/collapsible

Version:

A utility for creating collapsible sections in web applications, conserving space and improving user experience.

1 lines 719 B
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@flexilla/utilities`);const t=(e,t)=>{e.setAttribute(`aria-hidden`,t===`open`?`false`:`true`),e.setAttribute(`data-state`,t)},n=(e,n=`close`,r=`0px`)=>{e.style.height=n===`open`?`auto`:r,t(e,n)},r=n=>{if(n.getAttribute(`data-state`)===`open`)return;t(n,`open`);let r=n.scrollHeight;n.style.height=`${r}px`,(0,e.afterTransition)({element:n,callback:()=>{n.getAttribute(`data-state`)===`open`&&(n.style.height=`auto`)}})},i=(e,n=`0px`)=>{e.getAttribute(`data-state`)!==`close`&&(e.style.height=`${e.scrollHeight}px`,e.offsetHeight,e.style.height=n,t(e,`close`))};exports.collapseElement=i,exports.expandElement=r,exports.initCollapsible=n;