1 |
- import{G as P,I as g,d as V,ak as w,j as u,az as O,P as A,K as z,H as B,V as y,au as I,X as x,bA as N,a4 as $,as as H,al as j,Y as D,av as G,aC as k,a9 as K,a7 as M,aG as Y}from"./index.c8a33855.js";import{c as E,C as X}from"./index.89b19a2f.js";const[R,q]=P("collapse"),T=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=V({name:R,props:F,emits:["change","update:modelValue"],setup(a,{emit:t,slots:n}){const{linkChildren:d}=w(T),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:[q(),{[O]:a.border}]},[(e=n.default)==null?void 0:e.call(n)])}}});const ne=A(Q),[U,p]=P("collapse-item"),W=["icon","title","value","label","right-icon"],Z=z({},E,{name:B,isLink:g,disabled:Boolean,readonly:Boolean,lazyRender:g});var ee=V({name:U,props:Z,setup(a,{slots:t}){const n=y(),d=y(),{parent:s,index:m}=I(T);if(!s){console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");return}const h=x(()=>{var l;return(l=a.name)!=null?l:m.value}),e=x(()=>s.isExpanded(h.value)),o=y(e.value),r=N(()=>o.value||!a.lazyRender),i=()=>{e.value?n.value&&(n.value.style.height=""):o.value=!1};$(e,(l,v)=>{if(v===null)return;l&&(o.value=!0),(l?D:G)(()=>{if(!d.value||!n.value)return;const{offsetHeight:c}=d.value;if(c){const C=`${c}px`;n.value.style.height=l?"0":C,H(()=>{n.value&&(n.value.style.height=l?C:"0")})}else i()})});const f=(l=!e.value)=>{s.toggle(h.value,l)},_=()=>{!a.disabled&&!a.readonly&&f()},L=()=>{const{border:l,disabled:v,readonly:b}=a,c=k(a,Object.keys(E));return b&&(c.isLink=!1),(v||b)&&(c.clickable=!1),u(X,K({role:"button",class:p("title",{disabled:v,expanded:e.value,borderless:!l}),"aria-expanded":String(e.value),onClick:_},c),k(t,W))},S=r(()=>{var l;return M(u("div",{ref:n,class:p("wrapper"),onTransitionend:i},[u("div",{ref:d,class:p("content")},[(l=t.default)==null?void 0:l.call(t)])]),[[Y,o.value]])});return j({toggle:f}),()=>u("div",{class:[p({border:m.value&&a.border})]},[L(),S()])}});const te=A(ee);export{ne as C,te as a};
|