PageSourceSearch

https://soshace.com/assets/accordion-B5n_TnuQ.js

js soshace.com collected 2026-09-24 22:12:42 UTC 6,594 bytes, 1 lines download raw bytes

1import{r as d,u as T,j as a,P as R,J as z,a as B,e as U,d as q,i as fe,m as f,c as me,s as ve,k,a7 as Ce}from"./index-Dv2z26Z4.js";import{P as xe}from"./index-CPKvcGNI.js";var _="Collapsible",[be,J]=U(_),[ge,M]=be(_),Y=d.forwardRef((e,r)=>{const{__scopeCollapsible:o,open:t,defaultOpen:s,disabled:n,onOpenChange:c,...l}=e,[p,u]=T({prop:t,defaultProp:s??!1,onChange:c,caller:_});return a.jsx(ge,{scope:o,disabled:n,contentId:z(),open:p,onOpenToggle:d.useCallback(()=>u(m=>!m),[u]),children:a.jsx(R.div,{"data-state":V(p),"data-disabled":n?"":void 0,...l,ref:r})})});Y.displayName=_;var Q="CollapsibleTrigger",W=d.forwardRef((e,r)=>{const{__scopeCollapsible:o,...t}=e,s=M(Q,o);return a.jsx(R.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":V(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...t,ref:r,onClick:B(e.onClick,s.onOpenToggle)})});W.displayName=Q;var $="CollapsibleContent",X=d.forwardRef((e,r)=>{const{forceMount:o,...t}=e,s=M($,e.__scopeCollapsible);return a.jsx(xe,{present:o||s.open,children:({present:n})=>a.jsx(Ae,{...t,ref:r,present:n})})});X.displayName=$;var Ae=d.forwardRef((e,r)=>{const{__scopeCollapsible:o,present:t,children:s,...n}=e,c=M($,o),[l,p]=d.useState(t),u=d.useRef(null),m=q(r,u),v=d.useRef(0),h=v.current,x=d.useRef(0),w=x.current,b=c.open||l,g=d.useRef(b),A=d.useRef(void 0);return d.useEffect(()=>{const i=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(i)},[]),fe(()=>{const i=u.current;if(i){A.current=A.current||{transitionDuration:i.style.transitionDuration,animationName:i.style.animationName},i.style.transitionDuration="0s",i.style.animationName="none";const I=i.getBoundingClientRect();v.current=I.height,x.current=I.width,g.current||(i.style.transitionDuration=A.current.transitionDuration,i.style.animationName=A.current.animationName),p(t)}},[c.open,t]),a.jsx(R.div,{"data-state":V(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!b,...n,ref:m,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:b&&s})});function V(e){return e?"open":"closed"}var he=Y,Ie=W,Re=X,C="Accordion",we=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[H,Ne,_e]=me(C),[y]=U(C,[_e,J]),L=J(),Z=f.forwardRef((e,r)=>{const{type:o,...t}=e,s=t,n=t;return a.jsx(H.Provider,{scope:e.__scopeAccordion,children:o==="multiple"?a.jsx(Ee,{...n,ref:r}):a.jsx(je,{...s,ref:r})})});Z.displayName=C;var[ee,ye]=y(C),[oe,Pe]=y(C,{collapsible:!1}),je=f.forwardRef((e,r)=>{const{value:o,defaultValue:t,onValueChange:s=()=>{},collapsible:n=!1,...c}=e,[l,p]=T({prop:o,defaultProp:t??"",onChange:s,caller:C});return a.jsx(ee,{scope:e.__scopeAccordion,value:f.useMemo(()=>l?[l]:[],[l]),onItemOpen:p,onItemClose:f.useCallback(()=>n&&p(""),[n,p]),children:a.jsx(oe,{scope:e.__scopeAccordion,collapsible:n,children:a.jsx(te,{...c,ref:r})})})}),Ee=f.forwardRef((e,r)=>{const{value:o,defaultValue:t,onValueChange:s=()=>{},...n}=e,[c,l]=T({prop:o,defaultProp:t??[],onChange:s,caller:C}),p=f.useCallback(m=>l((v=[])=>[...v,m]),[l]),u=f.useCallback(m=>l((v=[])=>v.filter(h=>h!==m)),[l]);return a.jsx(ee,{scope:e.__scopeAccordion,value:c,onItemOpen:p,onItemClose:u,children:a.jsx(oe,{scope:e.__scopeAccordion,collapsible:!0,children:a.jsx(te,{...n,ref:r})})})}),[Oe,P]=y(C),te=f.forwardRef((e,r)=>{const{__scopeAccordion:o,disabled:t,dir:s,orientation:n="vertical",...c}=e,l=f.useRef(null),p=q(l,r),u=Ne(o),v=ve(s)==="ltr",h=B(e.onKeyDown,x=>{var K;if(!we.includes(x.key))return;const w=x.target,b=u().filter(S=>{var F;return!((F=S.ref.current)!=null&&F.disabled)}),g=b.findIndex(S=>S.ref.current===w),A=b.length;if(g===-1)return;x.preventDefault();let i=g;const I=0,j=A-1,E=()=>{i=g+1,i>j&&(i=I)},O=()=>{i=g-1,i<I&&(i=j)};switch(x.key){case"Home":i=I;break;case"End":i=j;break;case"ArrowRight":n==="horizontal"&&(v?E():O());break;case"ArrowDown":n==="vertical"&&E();break;case"ArrowLeft":n==="horizontal"&&(v?O():E());break;case"ArrowUp":n==="vertical"&&O();break}const ue=i%A;(K=b[ue].ref.current)==null||K.focus()});return a.jsx(Oe,{scope:o,disabled:t,direction:s,orientation:n,children:a.jsx(H.Slot,{scope:o,children:a.jsx(R.div,{...c,"data-orientation":n,ref:p,onKeyDown:t?void 0:h})})})}),N="AccordionItem",[Se,G]=y(N),ne=f.forwardRef((e,r)=>{const{__scopeAccordion:o,value:t,...s}=e,n=P(N,o),c=ye(N,o),l=L(o),p=z(),u=t&&c.value.includes(t)||!1,m=n.disabled||e.disabled;return a.jsx(Se,{scope:o,open:u,disabled:m,triggerId:p,children:a.jsx(he,{"data-orientation":n.orientation,"data-state":le(u),...l,...s,ref:r,disabled:m,open:u,onOpenChange:v=>{v?c.onItemOpen(t):c.onItemClose(t)}})})});
1ne.displayName=N;var re="AccordionHeader",ae=f.forwardRef((e,r)=>{const{__scopeAccordion:o,...t}=e,s=P(C,o),n=G(re,o);return a.jsx(R.h3,{"data-orientation":s.orientation,"data-state":le(n.open),"data-disabled":n.disabled?"":void 0,...t,ref:r})});ae.displayName=re;var D="AccordionTrigger",se=f.forwardRef((e,r)=>{const{__scopeAccordion:o,...t}=e,s=P(C,o),n=G(D,o),c=Pe(D,o),l=L(o);return a.jsx(H.ItemSlot,{scope:o,children:a.jsx(Ie,{"aria-disabled":n.open&&!c.collapsible||void 0,"data-orientation":s.orientation,id:n.triggerId,...l,...t,ref:r})})});se.displayName=D;var ce="AccordionContent",ie=f.forwardRef((e,r)=>{const{__scopeAccordion:o,...t}=e,s=P(C,o),n=G(ce,o),c=L(o);return a.jsx(Re,{role:"region","aria-labelledby":n.triggerId,"data-orientation":s.orientation,...c,...t,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});ie.displayName=ce;function le(e){return e?"open":"closed"}var De=Z,Te=ne,ke=ae,de=se,pe=ie;const Ge=De,Me=d.forwardRef(({className:e,...r},o)=>a.jsx(Te,{ref:o,className:k("border-b",e),...r}));Me.displayName="AccordionItem";const $e=d.forwardRef(({className:e,children:r,...o},t)=>a.jsx(ke,{className:"flex",children:a.jsxs(de,{ref:t,className:k("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...o,children:[r,a.jsx(Ce,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));$e.displayName=de.displayName;const Ve=d.forwardRef(({className:e,children:r,...o},t)=>a.jsx(pe,{ref:t,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...o,children:a.jsx("div",{className:k("pb-4 pt-0",e),children:r})}));Ve.displayName=pe.displayName;export{Ge as A,Me as a,$e as b,Ve as c};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.