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