1 |
- import{t as _,v as k,d as T,x as V,W as L,c as b,G as z,D as S,N as B,z as D,R as C,C as $,y as P,aZ as A,Z as I,aP as H,_ as Z,aE as j,al as R,E as G,ac as K,aQ as M}from"./index.ebf3a7fc.js";import{c as w,C as Q}from"./index.a5994f17.js";const[N,W]=_("collapse"),O=Symbol(N),Y={border:k,accordion:Boolean,modelValue:{type:[String,Number,Array],default:""}};var q=T({name:N,props:Y,emits:["change","update:modelValue"],setup(n,{emit:c,slots:l}){const{linkChildren:v,children:p}=V(O),r=e=>{c("change",e),c("update:modelValue",e)},m=(e,s)=>{const{accordion:o,modelValue:u}=n;r(o?e===u?"":e:s?u.concat(e):u.filter(h=>h!==e))},t=(e={})=>{if(n.accordion)return;typeof e=="boolean"&&(e={expanded:e});const{expanded:s,skipDisabled:o}=e,h=p.filter(d=>d.disabled&&o?d.expanded.value:s!=null?s:!d.expanded.value).map(d=>d.itemName.value);r(h)},i=e=>{const{accordion:s,modelValue:o}=n;return s?o===e:o.includes(e)};return L({toggleAll:t}),v({toggle:m,isExpanded:i}),()=>{var e;return b("div",{class:[W(),{[z]:n.border}]},[(e=l.default)==null?void 0:e.call(l)])}}});const ne=S(q),[F,x]=_("collapse-item"),J=["icon","title","value","label","right-icon"],U=B({},w,{name:D,isLink:k,disabled:Boolean,readonly:Boolean,lazyRender:k});var X=T({name:F,props:U,setup(n,{slots:c}){const l=C(),v=C(),{parent:p,index:r}=$(O);if(!p)return;const m=P(()=>{var a;return(a=n.name)!=null?a:r.value}),t=P(()=>p.isExpanded(m.value)),i=C(t.value),e=A(()=>i.value||!n.lazyRender),s=()=>{t.value?l.value&&(l.value.style.height=""):i.value=!1};I(t,(a,g)=>{if(g===null)return;a&&(i.value=!0),(a?Z:j)(()=>{if(!v.value||!l.value)return;const{offsetHeight:f}=v.value;if(f){const E=`${f}px`;l.value.style.height=a?"0":E,H(()=>{l.value&&(l.value.style.height=a?E:"0")})}else s()})});const o=(a=!t.value)=>{p.toggle(m.value,a)},u=()=>{!n.disabled&&!n.readonly&&o()},h=()=>{const{border:a,disabled:g,readonly:y}=n,f=R(n,Object.keys(w));return y&&(f.isLink=!1),(g||y)&&(f.clickable=!1),b(Q,G({role:"button",class:x("title",{disabled:g,expanded:t.value,borderless:!a}),"aria-expanded":String(t.value),onClick:u},f),R(c,J))},d=e(()=>{var a;return K(b("div",{ref:l,class:x("wrapper"),onTransitionend:s},[b("div",{ref:v,class:x("content")},[(a=c.default)==null?void 0:a.call(c)])]),[[M,i.value]])});return L({toggle:o,expanded:t,itemName:m}),()=>b("div",{class:[x({border:r.value&&n.border})]},[h(),d()])}});const le=S(X);export{ne as C,le as a};
|