"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("@aplus-frontend/antdv"),g=require("lodash-unified");require("../../hooks/index.js");const q=require("../hooks/use-default-placeholder.js"),I=require("./use-request.js"),F=require("../../hooks/useControllableValue.js");function v(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!e.isVNode(o)}const L=e.defineComponent({name:"ApFieldTreeSelect",__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},suffixIcon:{},size:{},bordered:{type:Boolean,default:void 0},treeLine:{},replaceFields:{},placement:{},status:{},popupClassName:{},dropdownClassName:{},"onUpdate:value":{},"onUpdate:treeExpandedKeys":{},"onUpdate:searchValue":{},variant:{},switcherLoadingIcon:{},value:{},children:{},listHeight:{},onMouseenter:{},onMouseleave:{},tabindex:{},onClick:{},onFocus:{},onBlur:{},onChange:{},onKeydown:{},onKeyup:{},onMousedown:{},onSelect:{},open:{type:Boolean,default:void 0},animation:{},direction:{},multiple:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},prefixCls:{},id:{},autofocus:{type:Boolean,default:void 0},getPopupContainer:{},virtual:{type:Boolean,default:!0},dropdownMatchSelectWidth:{default:!0},placeholder:{},loading:{type:Boolean,default:void 0},defaultValue:{},prefix:{},clearIcon:{},allowClear:{type:Boolean,default:void 0},getRawInputElement:{},fieldNames:{},inputValue:{},searchValue:{},onSearch:{},autoClearSearchValue:{type:Boolean,default:void 0},onDeselect:{},listItemHeight:{},labelInValue:{type:Boolean,default:void 0},maxCount:{},showSearch:{type:Boolean,default:void 0},tagRender:{},optionLabelRender:{},notFoundContent:{},onClear:{},choiceTransitionName:{},defaultOpen:{type:Boolean,default:void 0},onDropdownVisibleChange:{},maxTagTextLength:{},maxTagCount:{},maxTagPlaceholder:{},tokenSeparators:{},removeIcon:{},transitionName:{},dropdownStyle:{},dropdownRender:{},dropdownAlign:{},showAction:{},onPopupScroll:{},onInputKeyDown:{},showArrow:{type:Boolean,default:void 0},showCheckedStrategy:{},filterTreeNode:{},treeNodeFilterProp:{},treeNodeLabelProp:{},treeCheckable:{type:Boolean,default:void 0},treeCheckStrictly:{type:Boolean,default:void 0},treeData:{},treeDataSimpleMode:{},treeLoadedKeys:{},onTreeLoad:{},treeDefaultExpandAll:{type:Boolean,default:void 0},treeExpandedKeys:{},treeDefaultExpandedKeys:{},onTreeExpand:{},treeIcon:{},switcherIcon:{},treeExpandAction:{},dropdownPopupAlign:{},request:{},lazy:{type:Boolean},params:{},loadData:{type:Boolean}},emits:["update:value"],setup(o,{expose:S,emit:B}){const n=o,w=e.computed(()=>g.omit(n,["onUpdate:value","value","treeData","loadData"])),C=e.useSlots(),x=B,s=e.shallowRef(),{value:f,updateValue:N}=F.useControllableValue(n,x),V=q.useDefaultPlaceholder("TreeSelect",n),{treeData:p,loading:m,request:h}=I.useRequest(n),b=e.computed(()=>{let a;const d=e.unref(f),u=g.isArray(d)?d:[d].filter(Boolean);if(!u.length)return e.createVNode(e.Fragment,null,[n.emptyText]);const t=[],c=n.fieldNames?.label||"label",P=n.fieldNames?.value||"value";function y(l){for(const r of l){if(u.find(R=>R===r[P])&&t.push(r[c]),t.length===u.length)return;r.children?.length&&y(r.children)}}return y(e.unref(p)),t.length?t.length===1?e.createVNode("span",null,[t[0]]):e.createVNode(i.Space,{size:4},v(a=t.map((l,r)=>e.createVNode(i.Tag,{style:{marginRight:0},key:`${l}-${r}`},v(l)?l:{default:()=>[l]})))?a:{default:()=>[a]}):e.createVNode(e.Fragment,null,[n.emptyText])});function T(){s.value?.focus?.()}function D(){s.value?.blur?.()}function k(a){return h(a)}return S({request:h,focus:T,blur:D}),(a,d)=>o.mode==="read"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(b.value),{key:0})):(e.openBlock(),e.createBlock(e.unref(i.TreeSelect),e.mergeProps({key:1},w.value,{ref_key:"treeSelectRef",ref:s,value:e.unref(f),"tree-data":e.unref(p),loading:e.unref(m),placeholder:e.unref(V),"load-data":o.loadData?k:void 0,"onUpdate:value":e.unref(N)}),e.createSlots({_:2},[e.renderList(C,(u,t)=>({name:t,fn:e.withCtx(c=>[e.renderSlot(a.$slots,t,e.normalizeProps(e.guardReactiveProps(c||{})))])})),e.unref(m)?{name:"notFoundContent",fn:e.withCtx(()=>[e.createVNode(e.unref(i.Spin),{size:"small"})]),key:"0"}:void 0]),1040,["value","tree-data","loading","placeholder","load-data","onUpdate:value"]))}});exports.default=L;
