el-tree-select-4ae7c290.js 5.1 KB

1
  1. import{aB as W,ck as O,cl as H,y as M,cm as V,J as C,am as A,d as S,x as B,al as $,K as P,cc as F,cn as w,aL as G,aO as Q,co as R,r as q,e as L,k as X,aP as j,aD as Y,__tla as Z}from"./index-2eab2d23.js";let z,ee=Promise.all([(()=>{try{return Z}catch{}})()]).then(async()=>{const I=S({extends:B,setup(e,n){const c=B.setup(e,n);delete c.selectOptionClick;const i=$().proxy;return A(()=>{c.select.cachedOptions.get(i.value)||c.select.onOptionCreate(i)}),c},methods:{selectOptionClick(){this.$el.parentElement.click()}}});function E(e){return e||e===0}function _(e){return Array.isArray(e)&&e.length}function b(e){return Array.isArray(e)?e:E(e)?[e]:[]}function K(e,n,c,i,r){for(let s=0;s<e.length;s++){const h=e[s];if(n(h,s,e,r))return i?i(h,s,e,r):h;{const m=c(h);if(_(m)){const a=K(m,n,c,i,h);if(a)return a}}}}function D(e,n,c,i){for(let r=0;r<e.length;r++){const s=e[r];n(s,r,e,i);const h=c(s);_(h)&&D(h,n,c,s)}}const J=(e,{attrs:n,slots:c,emit:i},{select:r,tree:s,key:h})=>{P(()=>e.modelValue,()=>{e.showCheckbox&&A(()=>{const l=s.value;l&&!F(l.getCheckedKeys(),b(e.modelValue))&&l.setCheckedKeys(b(e.modelValue))})},{immediate:!0,deep:!0});const m=C(()=>({value:h.value,label:"label",children:"children",disabled:"disabled",isLeaf:"isLeaf",...e.props})),a=(l,t)=>{var d;const u=m.value[l];return G(u)?u(t,(d=s.value)==null?void 0:d.getNode(a("value",t))):t[u]},x=b(e.modelValue).map(l=>K(e.data||[],t=>a("value",t)===l,t=>a("children",t),(t,d,u,v)=>v&&a("value",v))).filter(l=>E(l)),g=C(()=>{if(!e.renderAfterExpand&&!e.lazy)return[];const l=[];return D(e.data.concat(e.cacheData),t=>{const d=a("value",t);l.push({value:d,currentLabel:a("label",t),isDisabled:a("disabled",t)})},t=>a("children",t)),l}),p=C(()=>g.value.reduce((l,t)=>({...l,[t.value]:t}),{}));return{...O(H(e),Object.keys(w.props)),...n,nodeKey:h,expandOnClickNode:C(()=>!e.checkStrictly&&e.expandOnClickNode),defaultExpandedKeys:C(()=>e.defaultExpandedKeys?e.defaultExpandedKeys.concat(x):x),renderContent:(l,{node:t,data:d,store:u})=>l(I,{value:a("value",d),label:a("label",d),disabled:a("disabled",d)},e.renderContent?()=>e.renderContent(l,{node:t,data:d,store:u}):c.default?()=>c.default({node:t,data:d,store:u}):void 0),filterNodeMethod:(l,t,d)=>{var u;return e.filterNodeMethod?e.filterNodeMethod(l,t,d):!l||((u=a("label",t))==null?void 0:u.includes(l))},onNodeClick:(l,t,d)=>{var u,v,k;if((u=n.onNodeClick)==null||u.call(n,l,t,d),!e.showCheckbox||!e.checkOnClickNode){if(e.showCheckbox||!e.checkStrictly&&!t.isLeaf)e.expandOnClickNode&&d.proxy.handleExpandIconClick();else if(!a("disabled",l)){const o=(v=r.value)==null?void 0:v.options.get(a("value",l));(k=r.value)==null||k.handleOptionSelect(o)}}},onCheck:(l,t)=>{if(!e.showCheckbox)return;const d=a("value",l),u=t.checkedKeys,v=e.multiple?b(e.modelValue).filter(o=>o in p.value&&!s.value.getNode(o)&&!u.includes(o)):[],k=u.concat(v);if(e.checkStrictly)i(V,e.multiple?k:k.includes(d)?d:void 0);else if(e.multiple)i(V,s.value.getCheckedKeys(!0));else{const o=K([l],y=>!_(a("children",y))&&!a("disabled",y),y=>a("children",y)),f=o?a("value",o):void 0,U=E(e.modelValue)&&!!K([l],y=>a("value",y)===e.modelValue,y=>a("children",y));i(V,f===e.modelValue||U?void 0:f)}A(()=>{var o;const f=b(e.modelValue);s.value.setCheckedKeys(f),(o=n.onCheck)==null||o.call(n,l,{checkedKeys:s.value.getCheckedKeys(),checkedNodes:s.value.getCheckedNodes(),halfCheckedKeys:s.value.getHalfCheckedKeys(),halfCheckedNodes:s.value.getHalfCheckedNodes()})})},cacheOptions:g}};var T=S({props:{data:{type:Array,default:()=>[]}},setup(e){const n=Q(R);return P(()=>e.data,()=>{var c;e.data.forEach(r=>{n.cachedOptions.has(r.value)||n.cachedOptions.set(r.value,r)});const i=((c=n.selectWrapper)==null?void 0:c.querySelectorAll("input"))||[];Array.from(i).includes(document.activeElement)||n.setSelected()},{flush:"post",immediate:!0}),()=>{}}}),N=Y(S({name:"ElTreeSelect",inheritAttrs:!1,props:{...M.props,...w.props,cacheData:{type:Array,default:()=>[]}},setup(e,n){const{slots:c,expose:i}=n,r=q(),s=q(),h=C(()=>e.nodeKey||e.valueKey||"value"),m=((p,{attrs:l,emit:t},{tree:d,key:u})=>{const v=W("tree-select"),k={...O(H(p),Object.keys(M.props)),...l,"onUpdate:modelValue":o=>t(V,o),valueKey:u,popperClass:C(()=>{const o=[v.e("popper")];return p.popperClass&&o.push(p.popperClass),o.join(" ")}),filterMethod:(o="")=>{p.filterMethod&&p.filterMethod(o),A(()=>{var f;(f=d.value)==null||f.filter(o)})},onVisibleChange:o=>{var f;(f=l.onVisibleChange)==null||f.call(l,o),p.filterable&&o&&k.filterMethod()}};return k})(e,n,{select:r,tree:s,key:h}),{cacheOptions:a,...x}=J(e,n,{select:r,tree:s,key:h}),g=L({});return i(g),X(()=>{Object.assign(g,{...O(s.value,["filter","updateKeyChildren","getCheckedNodes","setCheckedNodes","getCheckedKeys","setCheckedKeys","setChecked","getHalfCheckedNodes","getHalfCheckedKeys","getCurrentKey","getCurrentNode","setCurrentKey","setCurrentNode","getNode","remove","append","insertBefore","insertAfter"]),...O(r.value,["focus","blur"])})}),()=>j(M,L({...m,ref:p=>r.value=p}),{...c,default:()=>[j(T,{data:a.value}),j(w,L({...x,ref:p=>s.value=p}))]})}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/tree-select/src/tree-select.vue"]]);N.install=e=>{e.component(N.name,N)},z=N});export{z as E,ee as __tla};