@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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);const t
|
|
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{
|
|
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.
|
|
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.
|
|
37
|
+
"@data-slot/core": "0.2.124"
|
|
38
38
|
}
|
|
39
39
|
}
|