1 |
- import{x as e,d as a,af as l,ad as s,a as n,aj as o,E as t,w as r,a6 as d,z as i,H as u,ar as c,c as v,aR as p,j as m,at as b,K as f,Y as g,az as x,G as y,av as h,aB as k}from"./index-d31722d5.js";import{c as j,C as V}from"./index-40db5953.js";const[z,B]=e("collapse"),C=Symbol(z),E=r(a({name:z,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(C),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":[B(),{[o]:e.border}]},[null==(a=t["default"])?void 0:a.call(t)])}}})),[N,R]=e("collapse-item"),S=["icon","title","value","label","right-icon"],w=r(a({name:N,props:d({},j,{name:i,isLink:t,disabled:Boolean,readonly:Boolean,lazyRender:t}),setup(e,{slots:a}){const l=u(),o=u(),{parent:t,index:r}=c(C);if(!t)return;const d=v((()=>{var a;return null!=(a=e.name)?a:r.value})),i=v((()=>t.isExpanded(d.value))),z=u(i.value),B=p((()=>z.value||!e.lazyRender)),E=()=>{i.value?l.value&&(l.value.style.height=""):z.value=!1};m(i,((e,a)=>{null!==a&&(e&&(z.value=!0),(e?f:g)((()=>{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 E()})))}));const N=(e=!i.value)=>{t.toggle(d.value,e)},w=()=>{e.disabled||e.readonly||N()},A=()=>{const{border:l,disabled:s,readonly:o}=e,t=x(e,Object.keys(j));return o&&(t.isLink=!1),(s||o)&&(t.clickable=!1),n(V,y({role:"button","class":R("title",{disabled:s,expanded:i.value,borderless:!l}),"aria-expanded":String(i.value),onClick:w},t),x(a,S))},H=B((()=>{var e;return h(n("div",{ref:l,"class":R("wrapper"),onTransitionend:E},[n("div",{ref:o,"class":R("content")},[null==(e=a["default"])?void 0:e.call(a)])]),[[k,z.value]])}));return s({toggle:N,expanded:i,itemName:d}),()=>n("div",{"class":[R({border:r.value&&e.border})]},[A(),H()])}}));export{w as C,E as a};
|