index-e6470b2e.js 2.7 KB

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