1 |
- import{t as e,d as a,y as l,ag as s,a as n,al as o,v as t,C as r,D as d,w as i,Q as u,G as c,c as v,aR as p,S as m,as as b,V as g,a0 as f,ay as y,J as x,au as h,aA as k}from"./index-232a7449.js";import{c as V,C}from"./index-b3c0f2c5.js";const[S,j]=e("collapse"),A=Symbol(S),B=r(a({name:S,props:{border:t,accordion:Boolean,modelValue:{type:[String,Number,Array],"default":""}},emits:["change","update:modelValue"],setup(e,{emit:a,slots:t}){const{linkChildren:r,children:d}=l(A),i=e=>{a("change",e),a("update:modelValue",e)};return s({toggleAll:(a={})=>{if(e.accordion)return;"boolean"==typeof a&&(a={expanded:a});const{expanded:l,skipDisabled:s}=a,n=d.filter((e=>e.disabled&&s?e.expanded.value:null!=l?l:!e.expanded.value)).map((e=>e.itemName.value));i(n)}}),r({toggle:(a,l)=>{const{accordion:s,modelValue:n}=e;i(s?a===n?"":a:l?n.concat(a):n.filter((e=>e!==a)))},isExpanded:a=>{const{accordion:l,modelValue:s}=e;return l?s===a:s.includes(a)}}),()=>{var a;return n("div",{"class":[j(),{[o]:e.border}]},[null==(a=t["default"])?void 0:a.call(t)])}}})),[N,R]=e("collapse-item"),w=["icon","title","value","label","right-icon"],z=r(a({name:N,props:d({},V,{name:i,isLink:t,disabled:Boolean,readonly:Boolean,lazyRender:t}),setup(e,{slots:a}){const l=u(),o=u(),{parent:t,index:r}=c(A);if(!t)return;const d=v((()=>{var a;return null!=(a=e.name)?a:r.value})),i=v((()=>t.isExpanded(d.value))),S=u(i.value),j=p((()=>S.value||!e.lazyRender)),B=()=>{i.value?l.value&&(l.value.style.height=""):S.value=!1};m(i,((e,a)=>{null!==a&&(e&&(S.value=!0),(e?g:f)((()=>{if(!o.value||!l.value)return;const{offsetHeight:a}=o.value;if(a){const s="".concat(a,"px");l.value.style.height=e?"0":s,b((()=>{l.value&&(l.value.style.height=e?s:"0")}))}else B()})))}));const N=(e=!i.value)=>{t.toggle(d.value,e)},z=()=>{e.disabled||e.readonly||N()},D=()=>{const{border:l,disabled:s,readonly:o}=e,t=y(e,Object.keys(V));return o&&(t.isLink=!1),(s||o)&&(t.clickable=!1),n(C,x({role:"button","class":R("title",{disabled:s,expanded:i.value,borderless:!l}),"aria-expanded":String(i.value),onClick:z},t),y(a,w))},E=j((()=>{var e;return h(n("div",{ref:l,"class":R("wrapper"),onTransitionend:B},[n("div",{ref:o,"class":R("content")},[null==(e=a["default"])?void 0:e.call(a)])]),[[k,S.value]])}));return s({toggle:N,expanded:i,itemName:d}),()=>n("div",{"class":[R({border:r.value&&e.border})]},[D(),E()])}}));export{B as C,z as a};
|