index.b9bf0df2.js 2.3 KB

12
  1. import{t as E,v as k,d as P,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 I,y as T,b2 as $,Z as A,aT as H,_ as j,aI as G,am as _,E as K,ac as M,ay as W}from"./index.1c621181.js";import{c as w,C as Y}from"./index.fd5ae97b.js";const[N,Z]=E("collapse"),O=Symbol(N),q={border:k,accordion:Boolean,modelValue:{type:[String,Number,Array],default:""}};var F=P({name:N,props:q,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:[Z(),{[z]:n.border}]},[(e=l.default)==null?void 0:e.call(l)])}}});const ne=S(F),[J,x]=E("collapse-item"),Q=["icon","title","value","label","right-icon"],U=B({},w,{name:D,isLink:k,disabled:Boolean,readonly:Boolean,lazyRender:k});var X=P({name:J,props:U,setup(n,{slots:c}){const l=C(),v=C(),{parent:p,index:r}=I(O);if(!p)return;const m=T(()=>{var a;return(a=n.name)!=null?a:r.value}),t=T(()=>p.isExpanded(m.value)),i=C(t.value),e=$(()=>i.value||!n.lazyRender),s=()=>{t.value?l.value&&(l.value.style.height=""):i.value=!1};A(t,(a,g)=>{if(g===null)return;a&&(i.value=!0),(a?j:G)(()=>{if(!v.value||!l.value)return;const{offsetHeight:f}=v.value;if(f){const R=`${f}px`;l.value.style.height=a?"0":R,H(()=>{l.value&&(l.value.style.height=a?R:"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=_(n,Object.keys(w));return y&&(f.isLink=!1),(g||y)&&(f.clickable=!1),b(Y,K({role:"button",class:x("title",{disabled:g,expanded:t.value,borderless:!a}),"aria-expanded":String(t.value),onClick:u},f),_(c,Q))},d=e(()=>{var a;return M(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)])]),[[W,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};