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