@data-slot/collapsible 0.2.123 → 0.2.124

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=new WeakSet,n=e=>{let t=e.trim();return t?t.endsWith(`ms`)?Number.parseFloat(t.slice(0,-2))||0:t.endsWith(`s`)?(Number.parseFloat(t.slice(0,-1))||0)*1e3:Number.parseFloat(t)||0:0},r=(e,t)=>{let r=e.split(`,`),i=t.split(`,`),a=Math.max(r.length,i.length),o=0;for(let e=0;e<a;e+=1){let t=n(r[e]??r[r.length-1]??`0`),a=n(i[e]??i[i.length-1]??`0`);o=Math.max(o,t+a)}return o},i=e=>{let t=getComputedStyle(e),n=r(t.transitionDuration,t.transitionDelay),i=r(t.animationDuration,t.animationDelay);return Math.max(n,i)};function a(n,r={}){let a=r.defaultOpen??(0,e.getDataBool)(n,`defaultOpen`)??!1,o=r.hiddenUntilFound??(0,e.getDataBool)(n,`hiddenUntilFound`)??!1,s=r.onOpenChange,c=(0,e.getPart)(n,`collapsible-trigger`),l=(0,e.getPart)(n,`collapsible-content`);if(!c||!l)throw Error(`Collapsible requires trigger and content slots`);let u=n.ownerDocument?.defaultView??window,d=a,f=[],p=null,m=null,h=null,g=null,_=[],v=(0,e.ensureId)(l,`collapsible-content`),y=(0,e.ensureId)(c,`collapsible-trigger`);c.setAttribute(`aria-controls`,v),l.setAttribute(`role`,`region`),l.setAttribute(`aria-labelledby`,y);let b=e=>{n.setAttribute(`data-state`,e),l.setAttribute(`data-state`,e)},x=(e,t)=>{l.style.setProperty(`--collapsible-panel-height`,e),l.style.setProperty(`--collapsible-panel-width`,t)},S=(e,t)=>{x(`${e}px`,`${t}px`)},C=()=>{x(`auto`,`auto`)},w=()=>{S(0,0)},T=()=>{S(l.scrollHeight,l.scrollWidth)},E=()=>{let e=l.style.getPropertyValue(`--collapsible-panel-height`).trim(),t=l.style.getPropertyValue(`--collapsible-panel-width`).trim();return e===`auto`&&t===`auto`},D=()=>{m!==null&&(u.cancelAnimationFrame(m),m=null),h!==null&&(u.clearTimeout(h),h=null),_.forEach(e=>e()),_=[]},O=()=>{g!==null&&(u.cancelAnimationFrame(g),g=null)},k=()=>{D(),O()},A=()=>{l.removeAttribute(`hidden`)},j=()=>{o?l.setAttribute(`hidden`,`until-found`):l.hidden=!0,w()},M=()=>{D(),!(!d||F.isExiting)&&C()},N=()=>{D();let e=i(l);if(e>0){let t=e=>{e.target===l&&M()};l.addEventListener(`transitionend`,t),l.addEventListener(`animationend`,t),_.push(()=>l.removeEventListener(`transitionend`,t)),_.push(()=>l.removeEventListener(`animationend`,t)),h=u.setTimeout(()=>{h=null,M()},Math.ceil(e)+50);return}m=u.requestAnimationFrame(()=>{m=null,M()})},P=()=>{O(),g=u.requestAnimationFrame(()=>{g=null,!d&&F.isExiting&&w()})},F=(0,e.createPresenceLifecycle)({element:l,onExitComplete:()=>{O(),j()}}),I=t=>{d!==t&&(d=t,(0,e.setAria)(c,`expanded`,d),b(d?`open`:`closed`),d?(O(),A(),T(),F.enter(),N()):(D(),T(),F.exit(),P()),(0,e.emit)(n,`collapsible:change`,{open:d}),s?.(d))};return(0,e.setAria)(c,`expanded`,d),d?(A(),T(),N()):j(),b(d?`open`:`closed`),typeof ResizeObserver<`u`&&(p=new ResizeObserver(()=>{!d||F.isExiting||E()||T()}),p.observe(l)),f.push((0,e.on)(c,`click`,()=>{c.hasAttribute(`disabled`)||c.getAttribute(`aria-disabled`)===`true`||I(!d)})),o&&f.push((0,e.on)(l,`beforematch`,()=>{d||I(!0)})),f.push((0,e.on)(n,`collapsible:set`,e=>{if(c.hasAttribute(`disabled`)||c.getAttribute(`aria-disabled`)===`true`)return;let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&I(n)})),{open:()=>I(!0),close:()=>I(!1),toggle:()=>I(!d),get isOpen(){return d},destroy:()=>{F.cleanup(),k(),p?.disconnect(),p=null,f.forEach(e=>e()),f.length=0,t.delete(n)}}}function o(n=document){let r=[];for(let i of(0,e.getRoots)(n,`collapsible`))t.has(i)||(t.add(i),r.push(a(i)));return r}exports.create=o,exports.createCollapsible=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t=`@data-slot/collapsible`,n=e=>{let t=e.trim();return t?t.endsWith(`ms`)?Number.parseFloat(t.slice(0,-2))||0:t.endsWith(`s`)?(Number.parseFloat(t.slice(0,-1))||0)*1e3:Number.parseFloat(t)||0:0},r=(e,t)=>{let r=e.split(`,`),i=t.split(`,`),a=Math.max(r.length,i.length),o=0;for(let e=0;e<a;e+=1){let t=n(r[e]??r[r.length-1]??`0`),a=n(i[e]??i[i.length-1]??`0`);o=Math.max(o,t+a)}return o},i=e=>{let t=getComputedStyle(e),n=r(t.transitionDuration,t.transitionDelay),i=r(t.animationDuration,t.animationDelay);return Math.max(n,i)};function a(n,r={}){let a=(0,e.reuseRootBinding)(n,t,`[@data-slot/collapsible] createCollapsible() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(a)return a;let o=r.defaultOpen??(0,e.getDataBool)(n,`defaultOpen`)??!1,s=r.hiddenUntilFound??(0,e.getDataBool)(n,`hiddenUntilFound`)??!1,c=r.onOpenChange,l=(0,e.getPart)(n,`collapsible-trigger`),u=(0,e.getPart)(n,`collapsible-content`);if(!l||!u)throw Error(`Collapsible requires trigger and content slots`);let d=n.ownerDocument?.defaultView??window,f=o,p=[],m=null,h=null,g=null,_=null,v=[],y=(0,e.ensureId)(u,`collapsible-content`),b=(0,e.ensureId)(l,`collapsible-trigger`);l.setAttribute(`aria-controls`,y),u.setAttribute(`role`,`region`),u.setAttribute(`aria-labelledby`,b);let x=e=>{n.setAttribute(`data-state`,e),u.setAttribute(`data-state`,e)},S=(e,t)=>{u.style.setProperty(`--collapsible-panel-height`,e),u.style.setProperty(`--collapsible-panel-width`,t)},C=(e,t)=>{S(`${e}px`,`${t}px`)},w=()=>{S(`auto`,`auto`)},T=()=>{C(0,0)},E=()=>{C(u.scrollHeight,u.scrollWidth)},D=()=>{let e=u.style.getPropertyValue(`--collapsible-panel-height`).trim(),t=u.style.getPropertyValue(`--collapsible-panel-width`).trim();return e===`auto`&&t===`auto`},O=()=>{h!==null&&(d.cancelAnimationFrame(h),h=null),g!==null&&(d.clearTimeout(g),g=null),v.forEach(e=>e()),v=[]},k=()=>{_!==null&&(d.cancelAnimationFrame(_),_=null)},A=()=>{O(),k()},j=()=>{u.removeAttribute(`hidden`)},M=()=>{s?u.setAttribute(`hidden`,`until-found`):u.hidden=!0,T()},N=()=>{O(),!(!f||I.isExiting)&&w()},P=()=>{O();let e=i(u);if(e>0){let t=e=>{e.target===u&&N()};u.addEventListener(`transitionend`,t),u.addEventListener(`animationend`,t),v.push(()=>u.removeEventListener(`transitionend`,t)),v.push(()=>u.removeEventListener(`animationend`,t)),g=d.setTimeout(()=>{g=null,N()},Math.ceil(e)+50);return}h=d.requestAnimationFrame(()=>{h=null,N()})},F=()=>{k(),_=d.requestAnimationFrame(()=>{_=null,!f&&I.isExiting&&T()})},I=(0,e.createPresenceLifecycle)({element:u,onExitComplete:()=>{k(),M()}}),L=t=>{f!==t&&(f=t,(0,e.setAria)(l,`expanded`,f),x(f?`open`:`closed`),f?(k(),j(),E(),I.enter(),P()):(O(),E(),I.exit(),F()),(0,e.emit)(n,`collapsible:change`,{open:f}),c?.(f))};(0,e.setAria)(l,`expanded`,f),f?(j(),E(),P()):M(),x(f?`open`:`closed`),typeof ResizeObserver<`u`&&(m=new ResizeObserver(()=>{!f||I.isExiting||D()||E()}),m.observe(u)),p.push((0,e.on)(l,`click`,()=>{l.hasAttribute(`disabled`)||l.getAttribute(`aria-disabled`)===`true`||L(!f)})),s&&p.push((0,e.on)(u,`beforematch`,()=>{f||L(!0)})),p.push((0,e.on)(n,`collapsible:set`,e=>{if(l.hasAttribute(`disabled`)||l.getAttribute(`aria-disabled`)===`true`)return;let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&L(n)}));let R={open:()=>L(!0),close:()=>L(!1),toggle:()=>L(!f),get isOpen(){return f},destroy:()=>{I.cleanup(),A(),m?.disconnect(),m=null,p.forEach(e=>e()),p.length=0,(0,e.clearRootBinding)(n,t,R)}};return(0,e.setRootBinding)(n,t,R),R}function o(n=document){let r=[];for(let i of(0,e.getRoots)(n,`collapsible`))(0,e.hasRootBinding)(i,t)||r.push(a(i));return r}exports.create=o,exports.createCollapsible=a;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createPresenceLifecycle as e,emit as t,ensureId as n,getDataBool as r,getPart as i,getRoots as a,on as o,setAria as s}from"@data-slot/core";const c=new WeakSet,l=e=>{let t=e.trim();return t?t.endsWith(`ms`)?Number.parseFloat(t.slice(0,-2))||0:t.endsWith(`s`)?(Number.parseFloat(t.slice(0,-1))||0)*1e3:Number.parseFloat(t)||0:0},u=(e,t)=>{let n=e.split(`,`),r=t.split(`,`),i=Math.max(n.length,r.length),a=0;for(let e=0;e<i;e+=1){let t=l(n[e]??n[n.length-1]??`0`),i=l(r[e]??r[r.length-1]??`0`);a=Math.max(a,t+i)}return a},d=e=>{let t=getComputedStyle(e),n=u(t.transitionDuration,t.transitionDelay),r=u(t.animationDuration,t.animationDelay);return Math.max(n,r)};function f(a,l={}){let u=l.defaultOpen??r(a,`defaultOpen`)??!1,f=l.hiddenUntilFound??r(a,`hiddenUntilFound`)??!1,p=l.onOpenChange,m=i(a,`collapsible-trigger`),h=i(a,`collapsible-content`);if(!m||!h)throw Error(`Collapsible requires trigger and content slots`);let g=a.ownerDocument?.defaultView??window,_=u,v=[],y=null,b=null,x=null,S=null,C=[],w=n(h,`collapsible-content`),T=n(m,`collapsible-trigger`);m.setAttribute(`aria-controls`,w),h.setAttribute(`role`,`region`),h.setAttribute(`aria-labelledby`,T);let E=e=>{a.setAttribute(`data-state`,e),h.setAttribute(`data-state`,e)},D=(e,t)=>{h.style.setProperty(`--collapsible-panel-height`,e),h.style.setProperty(`--collapsible-panel-width`,t)},O=(e,t)=>{D(`${e}px`,`${t}px`)},k=()=>{D(`auto`,`auto`)},A=()=>{O(0,0)},j=()=>{O(h.scrollHeight,h.scrollWidth)},M=()=>{let e=h.style.getPropertyValue(`--collapsible-panel-height`).trim(),t=h.style.getPropertyValue(`--collapsible-panel-width`).trim();return e===`auto`&&t===`auto`},N=()=>{b!==null&&(g.cancelAnimationFrame(b),b=null),x!==null&&(g.clearTimeout(x),x=null),C.forEach(e=>e()),C=[]},P=()=>{S!==null&&(g.cancelAnimationFrame(S),S=null)},F=()=>{N(),P()},I=()=>{h.removeAttribute(`hidden`)},L=()=>{f?h.setAttribute(`hidden`,`until-found`):h.hidden=!0,A()},R=()=>{N(),!(!_||V.isExiting)&&k()},z=()=>{N();let e=d(h);if(e>0){let t=e=>{e.target===h&&R()};h.addEventListener(`transitionend`,t),h.addEventListener(`animationend`,t),C.push(()=>h.removeEventListener(`transitionend`,t)),C.push(()=>h.removeEventListener(`animationend`,t)),x=g.setTimeout(()=>{x=null,R()},Math.ceil(e)+50);return}b=g.requestAnimationFrame(()=>{b=null,R()})},B=()=>{P(),S=g.requestAnimationFrame(()=>{S=null,!_&&V.isExiting&&A()})},V=e({element:h,onExitComplete:()=>{P(),L()}}),H=e=>{_!==e&&(_=e,s(m,`expanded`,_),E(_?`open`:`closed`),_?(P(),I(),j(),V.enter(),z()):(N(),j(),V.exit(),B()),t(a,`collapsible:change`,{open:_}),p?.(_))};return s(m,`expanded`,_),_?(I(),j(),z()):L(),E(_?`open`:`closed`),typeof ResizeObserver<`u`&&(y=new ResizeObserver(()=>{!_||V.isExiting||M()||j()}),y.observe(h)),v.push(o(m,`click`,()=>{m.hasAttribute(`disabled`)||m.getAttribute(`aria-disabled`)===`true`||H(!_)})),f&&v.push(o(h,`beforematch`,()=>{_||H(!0)})),v.push(o(a,`collapsible:set`,e=>{if(m.hasAttribute(`disabled`)||m.getAttribute(`aria-disabled`)===`true`)return;let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&H(n)})),{open:()=>H(!0),close:()=>H(!1),toggle:()=>H(!_),get isOpen(){return _},destroy:()=>{V.cleanup(),F(),y?.disconnect(),y=null,v.forEach(e=>e()),v.length=0,c.delete(a)}}}function p(e=document){let t=[];for(let n of a(e,`collapsible`))c.has(n)||(c.add(n),t.push(f(n)));return t}export{p as create,f as createCollapsible};
1
+ import{clearRootBinding as e,createPresenceLifecycle as t,emit as n,ensureId as r,getDataBool as i,getPart as a,getRoots as o,hasRootBinding as s,on as c,reuseRootBinding as l,setAria as u,setRootBinding as d}from"@data-slot/core";const f=`@data-slot/collapsible`,p=e=>{let t=e.trim();return t?t.endsWith(`ms`)?Number.parseFloat(t.slice(0,-2))||0:t.endsWith(`s`)?(Number.parseFloat(t.slice(0,-1))||0)*1e3:Number.parseFloat(t)||0:0},m=(e,t)=>{let n=e.split(`,`),r=t.split(`,`),i=Math.max(n.length,r.length),a=0;for(let e=0;e<i;e+=1){let t=p(n[e]??n[n.length-1]??`0`),i=p(r[e]??r[r.length-1]??`0`);a=Math.max(a,t+i)}return a},h=e=>{let t=getComputedStyle(e),n=m(t.transitionDuration,t.transitionDelay),r=m(t.animationDuration,t.animationDelay);return Math.max(n,r)};function g(o,s={}){let p=l(o,f,`[@data-slot/collapsible] createCollapsible() called more than once for the same root. Returning the existing controller. Destroy it before rebinding with new options.`);if(p)return p;let m=s.defaultOpen??i(o,`defaultOpen`)??!1,g=s.hiddenUntilFound??i(o,`hiddenUntilFound`)??!1,_=s.onOpenChange,v=a(o,`collapsible-trigger`),y=a(o,`collapsible-content`);if(!v||!y)throw Error(`Collapsible requires trigger and content slots`);let b=o.ownerDocument?.defaultView??window,x=m,S=[],C=null,w=null,T=null,E=null,D=[],O=r(y,`collapsible-content`),k=r(v,`collapsible-trigger`);v.setAttribute(`aria-controls`,O),y.setAttribute(`role`,`region`),y.setAttribute(`aria-labelledby`,k);let A=e=>{o.setAttribute(`data-state`,e),y.setAttribute(`data-state`,e)},j=(e,t)=>{y.style.setProperty(`--collapsible-panel-height`,e),y.style.setProperty(`--collapsible-panel-width`,t)},M=(e,t)=>{j(`${e}px`,`${t}px`)},N=()=>{j(`auto`,`auto`)},P=()=>{M(0,0)},F=()=>{M(y.scrollHeight,y.scrollWidth)},I=()=>{let e=y.style.getPropertyValue(`--collapsible-panel-height`).trim(),t=y.style.getPropertyValue(`--collapsible-panel-width`).trim();return e===`auto`&&t===`auto`},L=()=>{w!==null&&(b.cancelAnimationFrame(w),w=null),T!==null&&(b.clearTimeout(T),T=null),D.forEach(e=>e()),D=[]},R=()=>{E!==null&&(b.cancelAnimationFrame(E),E=null)},z=()=>{L(),R()},B=()=>{y.removeAttribute(`hidden`)},V=()=>{g?y.setAttribute(`hidden`,`until-found`):y.hidden=!0,P()},H=()=>{L(),!(!x||G.isExiting)&&N()},U=()=>{L();let e=h(y);if(e>0){let t=e=>{e.target===y&&H()};y.addEventListener(`transitionend`,t),y.addEventListener(`animationend`,t),D.push(()=>y.removeEventListener(`transitionend`,t)),D.push(()=>y.removeEventListener(`animationend`,t)),T=b.setTimeout(()=>{T=null,H()},Math.ceil(e)+50);return}w=b.requestAnimationFrame(()=>{w=null,H()})},W=()=>{R(),E=b.requestAnimationFrame(()=>{E=null,!x&&G.isExiting&&P()})},G=t({element:y,onExitComplete:()=>{R(),V()}}),K=e=>{x!==e&&(x=e,u(v,`expanded`,x),A(x?`open`:`closed`),x?(R(),B(),F(),G.enter(),U()):(L(),F(),G.exit(),W()),n(o,`collapsible:change`,{open:x}),_?.(x))};u(v,`expanded`,x),x?(B(),F(),U()):V(),A(x?`open`:`closed`),typeof ResizeObserver<`u`&&(C=new ResizeObserver(()=>{!x||G.isExiting||I()||F()}),C.observe(y)),S.push(c(v,`click`,()=>{v.hasAttribute(`disabled`)||v.getAttribute(`aria-disabled`)===`true`||K(!x)})),g&&S.push(c(y,`beforematch`,()=>{x||K(!0)})),S.push(c(o,`collapsible:set`,e=>{if(v.hasAttribute(`disabled`)||v.getAttribute(`aria-disabled`)===`true`)return;let t=e.detail,n;t?.open===void 0?t?.value!==void 0&&(n=t.value):n=t.open,typeof n==`boolean`&&K(n)}));let q={open:()=>K(!0),close:()=>K(!1),toggle:()=>K(!x),get isOpen(){return x},destroy:()=>{G.cleanup(),z(),C?.disconnect(),C=null,S.forEach(e=>e()),S.length=0,e(o,f,q)}};return d(o,f,q),q}function _(e=document){let t=[];for(let n of o(e,`collapsible`))s(n,f)||t.push(g(n));return t}export{_ as create,g as createCollapsible};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-slot/collapsible",
3
- "version": "0.2.123",
3
+ "version": "0.2.124",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.cjs",
@@ -34,6 +34,6 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@data-slot/core": "0.2.123"
37
+ "@data-slot/core": "0.2.124"
38
38
  }
39
39
  }