import{TreeSelect as e}from"antd";import{useMemo as l,useEffect as t}from"react";import{processTreeDataByLevel as a,processTreeDataForOnlyLastLevel as n,getDataType as r,getTreeNodePaths as o,arrayObjectDeduplication as s}from"../../../utils/index.js";import{jsx as c}from"react/jsx-runtime";function d(d){const{onGetData:i,onChange:h,onGetLabel:u,onGetNodePaths:y,onGetNodePathsIsIncludeOneself:f,getNodePathsIsIncludeOneself:m=!0,placeholder:I="",treeData:p=[],nameKey:v="name",idKey:g="id",childrenKey:K="children",level:S,onlyLastLevel:C=!1,...L}=d;void 0!==f&&console.warn("【BasicSelectTree】 onGetNodePathsIsIncludeOneself 参数已弃用，请使用 getNodePathsIsIncludeOneself 参数");const N=void 0!==f?f:m,b=l(()=>{let e=S?a({data:p,level:S,childrenKey:K,currentLevel:1}):p;return e=n({data:e,childrenKey:K,onlyLastLevel:C}),e},[p,S,K,C]);return t(()=>{i?.(p,b)},[p,b]),c(e,{showSearch:!0,style:{width:"100%"},styles:{popup:{root:{maxHeight:400,overflow:"auto"}}},placeholder:`请选择${I}`,onChange:(e,l,t)=>{if(e){if("Array"===r(e)){if(y){const l=[];for(let t=0;t<e.length;t++){const a=L.labelInValue||L.treeCheckStrictly?e[t].value:e[t],n=o({data:p,targetId:a,idKey:g,childrenKey:K,isIncludeOneself:N});l.push(...n)}const t=s(l,g);y?.(t)}u?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.label):l)}else if(y||u){const l=L.labelInValue||L.treeCheckStrictly?e.value:e,t=o({data:p,targetId:l,idKey:g,childrenKey:K,isIncludeOneself:N});y?.(t),u?.(t[t.length-1][v])}}else y?.([]),u?.("");h?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.value):e,l,t)},allowClear:!0,treeData:b,fieldNames:{label:v,value:g,children:K},treeNodeFilterProp:v,showCheckedStrategy:e.SHOW_ALL,...L})}d.displayName="BasicSelectTree";export{d as default};
