index-bf88cb5e.js 2.3 KB

1
  1. import{w as e,d as a,A as l,aj as s,a as n,ao as o,x as t,E as r,G as d,y as i,S as u,I as c,c as v,aU as p,V as m,av as b,X as g,a3 as f,aB as x,L as y,ax as h,aD as k}from"./index-ed417473.js";import{c as V,C as j}from"./index-075ea1c3.js";const[B,C]=e("collapse"),S=Symbol(B),A=r(a({name:B,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(S),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":[C(),{[o]:e.border}]},[null==(a=t["default"])?void 0:a.call(t)])}}})),[E,L]=e("collapse-item"),N=["icon","title","value","label","right-icon"],w=r(a({name:E,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(S);if(!t)return;const d=v((()=>{var a;return null!=(a=e.name)?a:r.value})),i=v((()=>t.isExpanded(d.value))),B=u(i.value),C=p((()=>B.value||!e.lazyRender)),A=()=>{i.value?l.value&&(l.value.style.height=""):B.value=!1};m(i,((e,a)=>{null!==a&&(e&&(B.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 A()})))}));const E=(e=!i.value)=>{t.toggle(d.value,e)},w=()=>{e.disabled||e.readonly||E()},z=()=>{const{border:l,disabled:s,readonly:o}=e,t=x(e,Object.keys(V));return o&&(t.isLink=!1),(s||o)&&(t.clickable=!1),n(j,y({role:"button","class":L("title",{disabled:s,expanded:i.value,borderless:!l}),"aria-expanded":String(i.value),onClick:w},t),x(a,N))},D=C((()=>{var e;return h(n("div",{ref:l,"class":L("wrapper"),onTransitionend:A},[n("div",{ref:o,"class":L("content")},[null==(e=a["default"])?void 0:e.call(a)])]),[[k,B.value]])}));return s({toggle:E,expanded:i,itemName:d}),()=>n("div",{"class":[L({border:r.value&&e.border})]},[z(),D()])}}));export{A as C,w as a};