UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

2 lines (1 loc) 3.9 kB
"use strict";const a=require("react/jsx-runtime"),_=require("./index-DwV9MiDB.js"),L=require("react"),O=require("./index-DMAkK3b-.js"),F=require("./index-DO-atGp-.js"),B=require("./index-BhY3ui5c.js"),C=require("./index-CajSSBH7.js");require("react-dom");const G=require("./index-B4SDXrpf.js"),z=require("./index-C7R_tQdV.js");function H(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const s=H(L);var J=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],v=J.reduce((e,t)=>{const o=C.createSlot(`Primitive.${t}`),n=s.forwardRef((r,c)=>{const{asChild:l,...p}=r,d=l?o:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(d,{...p,ref:c})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),b="Collapsible",[K,Q]=F.createContextScope(b),[U,x]=K(b),T=s.forwardRef((e,t)=>{const{__scopeCollapsible:o,open:n,defaultOpen:r,disabled:c,onOpenChange:l,...p}=e,[d,u]=B.useControllableState({prop:n,defaultProp:r??!1,onChange:l,caller:b});return a.jsx(U,{scope:o,disabled:c,contentId:z.useId(),open:d,onOpenToggle:s.useCallback(()=>u(m=>!m),[u]),children:a.jsx(v.div,{"data-state":h(d),"data-disabled":c?"":void 0,...p,ref:t})})});T.displayName=b;var q="CollapsibleTrigger",$=s.forwardRef((e,t)=>{const{__scopeCollapsible:o,...n}=e,r=x(q,o);return a.jsx(v.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":h(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...n,ref:t,onClick:O.composeEventHandlers(e.onClick,r.onOpenToggle)})});$.displayName=q;var R="CollapsibleContent",E=s.forwardRef((e,t)=>{const{forceMount:o,...n}=e,r=x(R,e.__scopeCollapsible);return a.jsx(G.Presence,{present:o||r.open,children:({present:c})=>a.jsx(V,{...n,ref:t,present:c})})});E.displayName=R;var V=s.forwardRef((e,t)=>{const{__scopeCollapsible:o,present:n,children:r,...c}=e,l=x(R,o),[p,d]=s.useState(n),u=s.useRef(null),m=C.useComposedRefs(t,u),y=s.useRef(0),N=y.current,j=s.useRef(0),P=j.current,g=l.open||p,w=s.useRef(g),f=s.useRef(void 0);return s.useEffect(()=>{const i=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(i)},[]),O.useLayoutEffect2(()=>{const i=u.current;if(i){f.current=f.current||{transitionDuration:i.style.transitionDuration,animationName:i.style.animationName},i.style.transitionDuration="0s",i.style.animationName="none";const S=i.getBoundingClientRect();y.current=S.height,j.current=S.width,w.current||(i.style.transitionDuration=f.current.transitionDuration,i.style.animationName=f.current.animationName),d(n)}},[l.open,n]),a.jsx(v.div,{"data-state":h(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!g,...c,ref:m,style:{"--radix-collapsible-content-height":N?`${N}px`:void 0,"--radix-collapsible-content-width":P?`${P}px`:void 0,...e.style},children:g&&r})});function h(e){return e?"open":"closed"}var I=T,A=$,D=E;const W=e=>a.jsx(I,{"data-slot":"collapsible-root",...e}),X=A,M=({className:e,asChild:t=!1,...o})=>{const n=t?C.Slot:"div";return a.jsx(n,{"data-slot":"collapsible-content-root",className:_.cn("grid !transition-all data-[state=closed]:grid-rows-[0fr] data-[state=open]:grid-rows-[1fr]",e),...o})},k=({className:e,asChild:t=!1,...o})=>{const n=t?C.Slot:"div";return a.jsx(n,{"data-slot":"collapsible-content-inner",className:_.cn("overflow-hidden",e),...o})},Y=({children:e,...t})=>a.jsx(D,{asChild:!0,forceMount:!0,...t,children:a.jsx(M,{children:a.jsx(k,{children:e})})});exports.CollapsibleContent=Y;exports.CollapsibleContentInner=k;exports.CollapsibleContentRoot=M;exports.CollapsibleRoot=W;exports.CollapsibleTrigger=X;exports.Content=D;exports.Root=I;exports.Trigger=A;exports.createCollapsibleScope=Q;