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