accordionary 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,7 +27,7 @@ Download `dist/accordionary.js` and include it in your HTML:
27
27
  Or link directly from GitHub (replace `v1.0.0` with the desired version):
28
28
 
29
29
  ```html
30
- <script src="https://cdn.jsdelivr.net/gh/briantucker/accordionary@v1.0.0/dist/accordionary.js"></script>
30
+ <script src="https://cdn.jsdelivr.net/npm/accordionary@1.0.0/dist/accordionary.js"></script>
31
31
  ```
32
32
 
33
33
  This version auto-initializes all accordions on page load.
@@ -1 +1 @@
1
- var{defineProperty:F,getOwnPropertyNames:I,getOwnPropertyDescriptor:O}=Object,f=Object.prototype.hasOwnProperty;var S=new WeakMap,u=(j)=>{var k=S.get(j),J;if(k)return k;if(k=F({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function")I(j).map((K)=>!f.call(k,K)&&F(k,K,{get:()=>j[K],enumerable:!(J=O(j,K))||J.enumerable}));return S.set(j,k),k};var A=(j,k)=>{for(var J in k)F(j,J,{get:k[J],enumerable:!0,configurable:!0,set:(K)=>k[J]=()=>K})};var d={};A(d,{initAll:()=>C,init:()=>v,default:()=>g});module.exports=u(d);var h=0;function w(j,k,J,K){let{headingElement:P,contentElement:G,iconElement:W,config:H}=j,_=`accordionary-${h++}`,z=`${_}-header`,q=`${_}-content`,U=!1;if(H.openOverride!==null)U=H.openOverride;else if(k.openDefault==="all")U=!0;else if(k.openDefault==="first"&&J)U=!0;let Q=U,{speed:$,easing:V,reduceMotion:B}=k,R=B?"none":`height ${$}ms ${V}`,x=B?"none":`transform ${$}ms ${V}`;if(G.style.overflow="hidden",G.style.transition=R,G.style.height=Q?"auto":"0px",W.style.transition=x,H.disabled)W.style.visibility="hidden";else if(Q)W.style.transform="rotate(180deg)";if(P.id=z,P.setAttribute("tabindex",H.disabled?"-1":"0"),P.setAttribute("role","button"),P.setAttribute("aria-expanded",Q?"true":"false"),P.setAttribute("aria-controls",q),P.style.cursor=H.disabled?"default":"pointer",H.disabled)P.setAttribute("aria-disabled","true");G.id=q,G.setAttribute("role","region"),G.setAttribute("aria-labelledby",z);function T(){if(Q)return;Q=!0,G.style.height=`${G.scrollHeight}px`,W.style.transform="rotate(180deg)",P.setAttribute("aria-expanded","true")}function y(){if(!Q)return;Q=!1,G.style.height=`${G.scrollHeight}px`,G.offsetHeight,G.style.height="0px",W.style.transform="rotate(0deg)",P.setAttribute("aria-expanded","false")}function b(){if(H.disabled)return;if(Q)y();else{if(!k.allowMultiple){for(let X of K)if(X!==j&&X.close)X.close()}T()}}j.open=T,j.close=y,j.toggle=b,P.addEventListener("click",b),P.addEventListener("keydown",(X)=>{if(X.key==="Enter"||X.key===" ")X.preventDefault(),b()}),G.addEventListener("transitionend",()=>{if(Q)G.style.height="auto"})}function Z(j,k){console.warn(`[Accordionary] ${j}`,k||"")}function L(j,k){console.error(`[Accordionary] ${j}`,k||"")}function Y(j,k){return j.getAttribute(`accordionary-${k}`)}function N(j,k=document){return k.querySelector(`[accordionary="${j}"]`)}function D(j,k=document){return k.querySelectorAll(`[accordionary="${j}"]`)}var E=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function M(j){if(j.hasAttribute("data-accordionary-initialized"))return null;j.setAttribute("data-accordionary-initialized","true");let k=Y(j,"open"),J=Y(j,"multiple"),K=Y(j,"speed"),P=Y(j,"easing");if(k&&!["all","first","none"].includes(k))Z(`Invalid accordionary-open="${k}". Expected "all", "first", or "none". Defaulting to "none".`,j);if(J&&!["true","false"].includes(J))Z(`Invalid accordionary-multiple="${J}". Expected "true" or "false". Defaulting to "true".`,j);let G=K?parseInt(K,10):300;if(K&&(isNaN(G)||G<0))Z(`Invalid accordionary-speed="${K}". Expected a positive number in milliseconds. Defaulting to 300.`,j);let W={openDefault:k==="all"||k==="first"?k:"none",allowMultiple:J!=="false",speed:isNaN(G)||G<0?300:G,easing:P||"ease",reduceMotion:E},H=[],_=D("item",j);if(_.length===0)return Z('No items found. Add elements with accordionary="item" inside your component.',j),null;for(let q of _){let U=N("header",q),Q=N("content",q),$=N("icon",q);if(!U){L('Missing header element. Add accordionary="header" inside this item.',q);continue}if(!Q){L('Missing content element. Add accordionary="content" inside this item.',q);continue}if(!$){L('Missing icon element. Add accordionary="icon" inside your header.',q);continue}let V=Y(q,"open"),B=Y(q,"disable");if(V&&!["true","false"].includes(V))Z(`Invalid accordionary-open="${V}" on item. Expected "true" or "false".`,q);let R={openOverride:V==="true"?!0:V==="false"?!1:null,disabled:B==="true"};H.push({element:q,headingElement:U,contentElement:Q,iconElement:$,config:R})}H.forEach((q,U)=>{w(q,W,U===0,H)});let z=H.map((q)=>({element:q.element,open:()=>q.open?.(),close:()=>q.close?.(),toggle:()=>q.toggle?.()}));return{element:j,openAll:()=>{for(let q of H)q.open?.()},closeAll:()=>{for(let q of H)q.close?.()},open:(q)=>{H[q]?.open?.()},close:(q)=>{H[q]?.close?.()},toggle:(q)=>{H[q]?.toggle?.()},items:z}}function v(j){let k=typeof j==="string"?document.querySelector(j):j;if(!k)return console.error(`[Accordionary] Element not found: ${j}`),null;return M(k)}function C(){let j=D("component"),k=[];for(let J of j){let K=M(J);if(K)k.push(K)}return k}var g={init:v,initAll:C};
1
+ var{defineProperty:F,getOwnPropertyNames:I,getOwnPropertyDescriptor:O}=Object,f=Object.prototype.hasOwnProperty;var S=new WeakMap,u=(j)=>{var k=S.get(j),J;if(k)return k;if(k=F({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function")I(j).map((K)=>!f.call(k,K)&&F(k,K,{get:()=>j[K],enumerable:!(J=O(j,K))||J.enumerable}));return S.set(j,k),k};var A=(j,k)=>{for(var J in k)F(j,J,{get:k[J],enumerable:!0,configurable:!0,set:(K)=>k[J]=()=>K})};var d={};A(d,{initAll:()=>C,init:()=>v,default:()=>E});module.exports=u(d);var h=0;function w(j,k,J,K){let{headingElement:P,contentElement:G,iconElement:W,config:H}=j,_=`accordionary-${h++}`,z=`${_}-header`,q=`${_}-content`,U=!1;if(H.openOverride!==null)U=H.openOverride;else if(k.openDefault==="all")U=!0;else if(k.openDefault==="first"&&J)U=!0;let Q=U,{speed:$,easing:V,reduceMotion:B}=k,R=B?"none":`height ${$}ms ${V}`,x=B?"none":`transform ${$}ms ${V}`;if(G.style.overflow="hidden",G.style.transition=R,G.style.height=Q?"auto":"0px",!Q)G.inert=!0;if(W.style.transition=x,H.disabled)W.style.visibility="hidden";else if(Q)W.style.transform="rotate(180deg)";if(P.id=z,P.setAttribute("tabindex",H.disabled?"-1":"0"),P.setAttribute("role","button"),P.setAttribute("aria-expanded",Q?"true":"false"),P.setAttribute("aria-controls",q),P.style.cursor=H.disabled?"default":"pointer",H.disabled)P.setAttribute("aria-disabled","true");G.id=q,G.setAttribute("role","region"),G.setAttribute("aria-labelledby",z);function T(){if(Q)return;Q=!0,G.inert=!1,G.style.height=`${G.scrollHeight}px`,W.style.transform="rotate(180deg)",P.setAttribute("aria-expanded","true")}function y(){if(!Q)return;Q=!1,G.inert=!0,G.style.height=`${G.scrollHeight}px`,G.offsetHeight,G.style.height="0px",W.style.transform="rotate(0deg)",P.setAttribute("aria-expanded","false")}function b(){if(H.disabled)return;if(Q)y();else{if(!k.allowMultiple){for(let X of K)if(X!==j&&X.close)X.close()}T()}}j.open=T,j.close=y,j.toggle=b,P.addEventListener("click",b),P.addEventListener("keydown",(X)=>{if(X.key==="Enter"||X.key===" ")X.preventDefault(),b()}),G.addEventListener("transitionend",()=>{if(Q)G.style.height="auto"})}function Z(j,k){console.warn(`[Accordionary] ${j}`,k||"")}function L(j,k){console.error(`[Accordionary] ${j}`,k||"")}function Y(j,k){return j.getAttribute(`accordionary-${k}`)}function N(j,k=document){return k.querySelector(`[accordionary="${j}"]`)}function D(j,k=document){return k.querySelectorAll(`[accordionary="${j}"]`)}var g=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function M(j){if(j.hasAttribute("data-accordionary-initialized"))return null;j.setAttribute("data-accordionary-initialized","true");let k=Y(j,"open"),J=Y(j,"multiple"),K=Y(j,"speed"),P=Y(j,"easing");if(k&&!["all","first","none"].includes(k))Z(`Invalid accordionary-open="${k}". Expected "all", "first", or "none". Defaulting to "none".`,j);if(J&&!["true","false"].includes(J))Z(`Invalid accordionary-multiple="${J}". Expected "true" or "false". Defaulting to "true".`,j);let G=K?parseInt(K,10):300;if(K&&(isNaN(G)||G<0))Z(`Invalid accordionary-speed="${K}". Expected a positive number in milliseconds. Defaulting to 300.`,j);let W={openDefault:k==="all"||k==="first"?k:"none",allowMultiple:J!=="false",speed:isNaN(G)||G<0?300:G,easing:P||"ease",reduceMotion:g},H=[],_=D("item",j);if(_.length===0)return Z('No items found. Add elements with accordionary="item" inside your component.',j),null;for(let q of _){let U=N("header",q),Q=N("content",q),$=N("icon",q);if(!U){L('Missing header element. Add accordionary="header" inside this item.',q);continue}if(!Q){L('Missing content element. Add accordionary="content" inside this item.',q);continue}if(!$){L('Missing icon element. Add accordionary="icon" inside your header.',q);continue}let V=Y(q,"open"),B=Y(q,"disable");if(V&&!["true","false"].includes(V))Z(`Invalid accordionary-open="${V}" on item. Expected "true" or "false".`,q);let R={openOverride:V==="true"?!0:V==="false"?!1:null,disabled:B==="true"};H.push({element:q,headingElement:U,contentElement:Q,iconElement:$,config:R})}H.forEach((q,U)=>{w(q,W,U===0,H)});let z=H.map((q)=>({element:q.element,open:()=>q.open?.(),close:()=>q.close?.(),toggle:()=>q.toggle?.()}));return{element:j,openAll:()=>{for(let q of H)q.open?.()},closeAll:()=>{for(let q of H)q.close?.()},open:(q)=>{H[q]?.open?.()},close:(q)=>{H[q]?.close?.()},toggle:(q)=>{H[q]?.toggle?.()},items:z}}function v(j){let k=typeof j==="string"?document.querySelector(j):j;if(!k)return console.error(`[Accordionary] Element not found: ${j}`),null;return M(k)}function C(){let j=D("component"),k=[];for(let J of j){let K=M(J);if(K)k.push(K)}return k}var E={init:v,initAll:C};
@@ -1 +1 @@
1
- var w=0;function y(j,q,P,Q){let{headingElement:J,contentElement:G,iconElement:W,config:H}=j,_=`accordionary-${w++}`,z=`${_}-header`,k=`${_}-content`,U=!1;if(H.openOverride!==null)U=H.openOverride;else if(q.openDefault==="all")U=!0;else if(q.openDefault==="first"&&P)U=!0;let K=U,{speed:$,easing:V,reduceMotion:B}=q,R=B?"none":`height ${$}ms ${V}`,S=B?"none":`transform ${$}ms ${V}`;if(G.style.overflow="hidden",G.style.transition=R,G.style.height=K?"auto":"0px",W.style.transition=S,H.disabled)W.style.visibility="hidden";else if(K)W.style.transform="rotate(180deg)";if(J.id=z,J.setAttribute("tabindex",H.disabled?"-1":"0"),J.setAttribute("role","button"),J.setAttribute("aria-expanded",K?"true":"false"),J.setAttribute("aria-controls",k),J.style.cursor=H.disabled?"default":"pointer",H.disabled)J.setAttribute("aria-disabled","true");G.id=k,G.setAttribute("role","region"),G.setAttribute("aria-labelledby",z);function M(){if(K)return;K=!0,G.style.height=`${G.scrollHeight}px`,W.style.transform="rotate(180deg)",J.setAttribute("aria-expanded","true")}function T(){if(!K)return;K=!1,G.style.height=`${G.scrollHeight}px`,G.offsetHeight,G.style.height="0px",W.style.transform="rotate(0deg)",J.setAttribute("aria-expanded","false")}function b(){if(H.disabled)return;if(K)T();else{if(!q.allowMultiple){for(let X of Q)if(X!==j&&X.close)X.close()}M()}}j.open=M,j.close=T,j.toggle=b,J.addEventListener("click",b),J.addEventListener("keydown",(X)=>{if(X.key==="Enter"||X.key===" ")X.preventDefault(),b()}),G.addEventListener("transitionend",()=>{if(K)G.style.height="auto"})}function Z(j,q){console.warn(`[Accordionary] ${j}`,q||"")}function L(j,q){console.error(`[Accordionary] ${j}`,q||"")}function Y(j,q){return j.getAttribute(`accordionary-${q}`)}function N(j,q=document){return q.querySelector(`[accordionary="${j}"]`)}function D(j,q=document){return q.querySelectorAll(`[accordionary="${j}"]`)}var v=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function F(j){if(j.hasAttribute("data-accordionary-initialized"))return null;j.setAttribute("data-accordionary-initialized","true");let q=Y(j,"open"),P=Y(j,"multiple"),Q=Y(j,"speed"),J=Y(j,"easing");if(q&&!["all","first","none"].includes(q))Z(`Invalid accordionary-open="${q}". Expected "all", "first", or "none". Defaulting to "none".`,j);if(P&&!["true","false"].includes(P))Z(`Invalid accordionary-multiple="${P}". Expected "true" or "false". Defaulting to "true".`,j);let G=Q?parseInt(Q,10):300;if(Q&&(isNaN(G)||G<0))Z(`Invalid accordionary-speed="${Q}". Expected a positive number in milliseconds. Defaulting to 300.`,j);let W={openDefault:q==="all"||q==="first"?q:"none",allowMultiple:P!=="false",speed:isNaN(G)||G<0?300:G,easing:J||"ease",reduceMotion:v},H=[],_=D("item",j);if(_.length===0)return Z('No items found. Add elements with accordionary="item" inside your component.',j),null;for(let k of _){let U=N("header",k),K=N("content",k),$=N("icon",k);if(!U){L('Missing header element. Add accordionary="header" inside this item.',k);continue}if(!K){L('Missing content element. Add accordionary="content" inside this item.',k);continue}if(!$){L('Missing icon element. Add accordionary="icon" inside your header.',k);continue}let V=Y(k,"open"),B=Y(k,"disable");if(V&&!["true","false"].includes(V))Z(`Invalid accordionary-open="${V}" on item. Expected "true" or "false".`,k);let R={openOverride:V==="true"?!0:V==="false"?!1:null,disabled:B==="true"};H.push({element:k,headingElement:U,contentElement:K,iconElement:$,config:R})}H.forEach((k,U)=>{y(k,W,U===0,H)});let z=H.map((k)=>({element:k.element,open:()=>k.open?.(),close:()=>k.close?.(),toggle:()=>k.toggle?.()}));return{element:j,openAll:()=>{for(let k of H)k.open?.()},closeAll:()=>{for(let k of H)k.close?.()},open:(k)=>{H[k]?.open?.()},close:(k)=>{H[k]?.close?.()},toggle:(k)=>{H[k]?.toggle?.()},items:z}}function C(j){let q=typeof j==="string"?document.querySelector(j):j;if(!q)return console.error(`[Accordionary] Element not found: ${j}`),null;return F(q)}function x(){let j=D("component"),q=[];for(let P of j){let Q=F(P);if(Q)q.push(Q)}return q}var g={init:C,initAll:x};export{x as initAll,C as init,g as default};
1
+ var w=0;function y(j,q,P,Q){let{headingElement:J,contentElement:G,iconElement:W,config:H}=j,_=`accordionary-${w++}`,z=`${_}-header`,k=`${_}-content`,U=!1;if(H.openOverride!==null)U=H.openOverride;else if(q.openDefault==="all")U=!0;else if(q.openDefault==="first"&&P)U=!0;let K=U,{speed:$,easing:V,reduceMotion:B}=q,R=B?"none":`height ${$}ms ${V}`,S=B?"none":`transform ${$}ms ${V}`;if(G.style.overflow="hidden",G.style.transition=R,G.style.height=K?"auto":"0px",!K)G.inert=!0;if(W.style.transition=S,H.disabled)W.style.visibility="hidden";else if(K)W.style.transform="rotate(180deg)";if(J.id=z,J.setAttribute("tabindex",H.disabled?"-1":"0"),J.setAttribute("role","button"),J.setAttribute("aria-expanded",K?"true":"false"),J.setAttribute("aria-controls",k),J.style.cursor=H.disabled?"default":"pointer",H.disabled)J.setAttribute("aria-disabled","true");G.id=k,G.setAttribute("role","region"),G.setAttribute("aria-labelledby",z);function M(){if(K)return;K=!0,G.inert=!1,G.style.height=`${G.scrollHeight}px`,W.style.transform="rotate(180deg)",J.setAttribute("aria-expanded","true")}function T(){if(!K)return;K=!1,G.inert=!0,G.style.height=`${G.scrollHeight}px`,G.offsetHeight,G.style.height="0px",W.style.transform="rotate(0deg)",J.setAttribute("aria-expanded","false")}function b(){if(H.disabled)return;if(K)T();else{if(!q.allowMultiple){for(let X of Q)if(X!==j&&X.close)X.close()}M()}}j.open=M,j.close=T,j.toggle=b,J.addEventListener("click",b),J.addEventListener("keydown",(X)=>{if(X.key==="Enter"||X.key===" ")X.preventDefault(),b()}),G.addEventListener("transitionend",()=>{if(K)G.style.height="auto"})}function Z(j,q){console.warn(`[Accordionary] ${j}`,q||"")}function L(j,q){console.error(`[Accordionary] ${j}`,q||"")}function Y(j,q){return j.getAttribute(`accordionary-${q}`)}function N(j,q=document){return q.querySelector(`[accordionary="${j}"]`)}function D(j,q=document){return q.querySelectorAll(`[accordionary="${j}"]`)}var v=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function F(j){if(j.hasAttribute("data-accordionary-initialized"))return null;j.setAttribute("data-accordionary-initialized","true");let q=Y(j,"open"),P=Y(j,"multiple"),Q=Y(j,"speed"),J=Y(j,"easing");if(q&&!["all","first","none"].includes(q))Z(`Invalid accordionary-open="${q}". Expected "all", "first", or "none". Defaulting to "none".`,j);if(P&&!["true","false"].includes(P))Z(`Invalid accordionary-multiple="${P}". Expected "true" or "false". Defaulting to "true".`,j);let G=Q?parseInt(Q,10):300;if(Q&&(isNaN(G)||G<0))Z(`Invalid accordionary-speed="${Q}". Expected a positive number in milliseconds. Defaulting to 300.`,j);let W={openDefault:q==="all"||q==="first"?q:"none",allowMultiple:P!=="false",speed:isNaN(G)||G<0?300:G,easing:J||"ease",reduceMotion:v},H=[],_=D("item",j);if(_.length===0)return Z('No items found. Add elements with accordionary="item" inside your component.',j),null;for(let k of _){let U=N("header",k),K=N("content",k),$=N("icon",k);if(!U){L('Missing header element. Add accordionary="header" inside this item.',k);continue}if(!K){L('Missing content element. Add accordionary="content" inside this item.',k);continue}if(!$){L('Missing icon element. Add accordionary="icon" inside your header.',k);continue}let V=Y(k,"open"),B=Y(k,"disable");if(V&&!["true","false"].includes(V))Z(`Invalid accordionary-open="${V}" on item. Expected "true" or "false".`,k);let R={openOverride:V==="true"?!0:V==="false"?!1:null,disabled:B==="true"};H.push({element:k,headingElement:U,contentElement:K,iconElement:$,config:R})}H.forEach((k,U)=>{y(k,W,U===0,H)});let z=H.map((k)=>({element:k.element,open:()=>k.open?.(),close:()=>k.close?.(),toggle:()=>k.toggle?.()}));return{element:j,openAll:()=>{for(let k of H)k.open?.()},closeAll:()=>{for(let k of H)k.close?.()},open:(k)=>{H[k]?.open?.()},close:(k)=>{H[k]?.close?.()},toggle:(k)=>{H[k]?.toggle?.()},items:z}}function C(j){let q=typeof j==="string"?document.querySelector(j):j;if(!q)return console.error(`[Accordionary] Element not found: ${j}`),null;return F(q)}function x(){let j=D("component"),q=[];for(let P of j){let Q=F(P);if(Q)q.push(Q)}return q}var E={init:C,initAll:x};export{x as initAll,C as init,E as default};
@@ -1 +1 @@
1
- (()=>{var y=0;function M(j,q,U,Y){let{headingElement:J,contentElement:G,iconElement:V,config:H}=j,_=`accordionary-${y++}`,B=`${_}-header`,k=`${_}-content`,P=!1;if(H.openOverride!==null)P=H.openOverride;else if(q.openDefault==="all")P=!0;else if(q.openDefault==="first"&&U)P=!0;let K=P,{speed:$,easing:Q,reduceMotion:L}=q,R=L?"none":`height ${$}ms ${Q}`,v=L?"none":`transform ${$}ms ${Q}`;if(G.style.overflow="hidden",G.style.transition=R,G.style.height=K?"auto":"0px",V.style.transition=v,H.disabled)V.style.visibility="hidden";else if(K)V.style.transform="rotate(180deg)";if(J.id=B,J.setAttribute("tabindex",H.disabled?"-1":"0"),J.setAttribute("role","button"),J.setAttribute("aria-expanded",K?"true":"false"),J.setAttribute("aria-controls",k),J.style.cursor=H.disabled?"default":"pointer",H.disabled)J.setAttribute("aria-disabled","true");G.id=k,G.setAttribute("role","region"),G.setAttribute("aria-labelledby",B);function F(){if(K)return;K=!0,G.style.height=`${G.scrollHeight}px`,V.style.transform="rotate(180deg)",J.setAttribute("aria-expanded","true")}function T(){if(!K)return;K=!1,G.style.height=`${G.scrollHeight}px`,G.offsetHeight,G.style.height="0px",V.style.transform="rotate(0deg)",J.setAttribute("aria-expanded","false")}function b(){if(H.disabled)return;if(K)T();else{if(!q.allowMultiple){for(let W of Y)if(W!==j&&W.close)W.close()}F()}}j.open=F,j.close=T,j.toggle=b,J.addEventListener("click",b),J.addEventListener("keydown",(W)=>{if(W.key==="Enter"||W.key===" ")W.preventDefault(),b()}),G.addEventListener("transitionend",()=>{if(K)G.style.height="auto"})}function Z(j,q){console.warn(`[Accordionary] ${j}`,q||"")}function N(j,q){console.error(`[Accordionary] ${j}`,q||"")}function X(j,q){return j.getAttribute(`accordionary-${q}`)}function z(j,q=document){return q.querySelector(`[accordionary="${j}"]`)}function D(j,q=document){return q.querySelectorAll(`[accordionary="${j}"]`)}var x=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function S(j){if(j.hasAttribute("data-accordionary-initialized"))return null;j.setAttribute("data-accordionary-initialized","true");let q=X(j,"open"),U=X(j,"multiple"),Y=X(j,"speed"),J=X(j,"easing");if(q&&!["all","first","none"].includes(q))Z(`Invalid accordionary-open="${q}". Expected "all", "first", or "none". Defaulting to "none".`,j);if(U&&!["true","false"].includes(U))Z(`Invalid accordionary-multiple="${U}". Expected "true" or "false". Defaulting to "true".`,j);let G=Y?parseInt(Y,10):300;if(Y&&(isNaN(G)||G<0))Z(`Invalid accordionary-speed="${Y}". Expected a positive number in milliseconds. Defaulting to 300.`,j);let V={openDefault:q==="all"||q==="first"?q:"none",allowMultiple:U!=="false",speed:isNaN(G)||G<0?300:G,easing:J||"ease",reduceMotion:x},H=[],_=D("item",j);if(_.length===0)return Z('No items found. Add elements with accordionary="item" inside your component.',j),null;for(let k of _){let P=z("header",k),K=z("content",k),$=z("icon",k);if(!P){N('Missing header element. Add accordionary="header" inside this item.',k);continue}if(!K){N('Missing content element. Add accordionary="content" inside this item.',k);continue}if(!$){N('Missing icon element. Add accordionary="icon" inside your header.',k);continue}let Q=X(k,"open"),L=X(k,"disable");if(Q&&!["true","false"].includes(Q))Z(`Invalid accordionary-open="${Q}" on item. Expected "true" or "false".`,k);let R={openOverride:Q==="true"?!0:Q==="false"?!1:null,disabled:L==="true"};H.push({element:k,headingElement:P,contentElement:K,iconElement:$,config:R})}H.forEach((k,P)=>{M(k,V,P===0,H)});let B=H.map((k)=>({element:k.element,open:()=>k.open?.(),close:()=>k.close?.(),toggle:()=>k.toggle?.()}));return{element:j,openAll:()=>{for(let k of H)k.open?.()},closeAll:()=>{for(let k of H)k.close?.()},open:(k)=>{H[k]?.open?.()},close:(k)=>{H[k]?.close?.()},toggle:(k)=>{H[k]?.toggle?.()},items:B}}function w(){let j=D("component");for(let q of j)S(q)}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",w);else w();})();
1
+ (()=>{var y=0;function M(j,q,U,Y){let{headingElement:J,contentElement:G,iconElement:V,config:H}=j,_=`accordionary-${y++}`,B=`${_}-header`,k=`${_}-content`,P=!1;if(H.openOverride!==null)P=H.openOverride;else if(q.openDefault==="all")P=!0;else if(q.openDefault==="first"&&U)P=!0;let K=P,{speed:$,easing:Q,reduceMotion:L}=q,R=L?"none":`height ${$}ms ${Q}`,v=L?"none":`transform ${$}ms ${Q}`;if(G.style.overflow="hidden",G.style.transition=R,G.style.height=K?"auto":"0px",!K)G.inert=!0;if(V.style.transition=v,H.disabled)V.style.visibility="hidden";else if(K)V.style.transform="rotate(180deg)";if(J.id=B,J.setAttribute("tabindex",H.disabled?"-1":"0"),J.setAttribute("role","button"),J.setAttribute("aria-expanded",K?"true":"false"),J.setAttribute("aria-controls",k),J.style.cursor=H.disabled?"default":"pointer",H.disabled)J.setAttribute("aria-disabled","true");G.id=k,G.setAttribute("role","region"),G.setAttribute("aria-labelledby",B);function F(){if(K)return;K=!0,G.inert=!1,G.style.height=`${G.scrollHeight}px`,V.style.transform="rotate(180deg)",J.setAttribute("aria-expanded","true")}function T(){if(!K)return;K=!1,G.inert=!0,G.style.height=`${G.scrollHeight}px`,G.offsetHeight,G.style.height="0px",V.style.transform="rotate(0deg)",J.setAttribute("aria-expanded","false")}function b(){if(H.disabled)return;if(K)T();else{if(!q.allowMultiple){for(let W of Y)if(W!==j&&W.close)W.close()}F()}}j.open=F,j.close=T,j.toggle=b,J.addEventListener("click",b),J.addEventListener("keydown",(W)=>{if(W.key==="Enter"||W.key===" ")W.preventDefault(),b()}),G.addEventListener("transitionend",()=>{if(K)G.style.height="auto"})}function Z(j,q){console.warn(`[Accordionary] ${j}`,q||"")}function N(j,q){console.error(`[Accordionary] ${j}`,q||"")}function X(j,q){return j.getAttribute(`accordionary-${q}`)}function z(j,q=document){return q.querySelector(`[accordionary="${j}"]`)}function D(j,q=document){return q.querySelectorAll(`[accordionary="${j}"]`)}var x=window.matchMedia("(prefers-reduced-motion: reduce)").matches;function S(j){if(j.hasAttribute("data-accordionary-initialized"))return null;j.setAttribute("data-accordionary-initialized","true");let q=X(j,"open"),U=X(j,"multiple"),Y=X(j,"speed"),J=X(j,"easing");if(q&&!["all","first","none"].includes(q))Z(`Invalid accordionary-open="${q}". Expected "all", "first", or "none". Defaulting to "none".`,j);if(U&&!["true","false"].includes(U))Z(`Invalid accordionary-multiple="${U}". Expected "true" or "false". Defaulting to "true".`,j);let G=Y?parseInt(Y,10):300;if(Y&&(isNaN(G)||G<0))Z(`Invalid accordionary-speed="${Y}". Expected a positive number in milliseconds. Defaulting to 300.`,j);let V={openDefault:q==="all"||q==="first"?q:"none",allowMultiple:U!=="false",speed:isNaN(G)||G<0?300:G,easing:J||"ease",reduceMotion:x},H=[],_=D("item",j);if(_.length===0)return Z('No items found. Add elements with accordionary="item" inside your component.',j),null;for(let k of _){let P=z("header",k),K=z("content",k),$=z("icon",k);if(!P){N('Missing header element. Add accordionary="header" inside this item.',k);continue}if(!K){N('Missing content element. Add accordionary="content" inside this item.',k);continue}if(!$){N('Missing icon element. Add accordionary="icon" inside your header.',k);continue}let Q=X(k,"open"),L=X(k,"disable");if(Q&&!["true","false"].includes(Q))Z(`Invalid accordionary-open="${Q}" on item. Expected "true" or "false".`,k);let R={openOverride:Q==="true"?!0:Q==="false"?!1:null,disabled:L==="true"};H.push({element:k,headingElement:P,contentElement:K,iconElement:$,config:R})}H.forEach((k,P)=>{M(k,V,P===0,H)});let B=H.map((k)=>({element:k.element,open:()=>k.open?.(),close:()=>k.close?.(),toggle:()=>k.toggle?.()}));return{element:j,openAll:()=>{for(let k of H)k.open?.()},closeAll:()=>{for(let k of H)k.close?.()},open:(k)=>{H[k]?.open?.()},close:(k)=>{H[k]?.close?.()},toggle:(k)=>{H[k]?.toggle?.()},items:B}}function w(){let j=D("component");for(let q of j)S(q)}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",w);else w();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accordionary",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A lightweight, accessible, vanilla JavaScript accordion with zero dependencies",
5
5
  "author": "Brian Tucker",
6
6
  "license": "GPL-3.0-or-later",