"use strict";const e=require("vue"),u=require("../Shared/base-iCmnU-fv.js"),F={key:0,className:"selectTree-inText-num"},E={class:"selectTree-inDropdown-container"},L={class:"selectTree-inDropdown-search"},N={class:"selectTree-inDropdown-body"},P=e.defineComponent({name:"ClSelectTree",__name:"Index",props:{value:[String,Number],list:{type:Array,default:()=>[]},className:String,placeholder:String,classDropDown:String,disabled:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},isClear:{type:Boolean,default:!1},arrowDirection:{type:String,default:"right"},searchPlaceholder:String,searchKey:{type:Array,default:()=>["name"]},searchKeyType:{type:String,default:"||"},showTextFormat:String,showDropDownTextFormat:String,onOpenBefore:Function,isSingleSelectParent:{type:Boolean,default:!1},isOutMerge:{type:Boolean,default:!0},parentKey:{type:String,default:"parentId"},topParentValue:{type:String,default:"0"}},emits:["update:value","onChange","onInit","onOpen"],setup(l,{expose:h,emit:g}){const o=l,s=g,r=e.ref(null),p=e.ref(null),n=e.reactive({isOpen:!1,isFirstDataFinish:!1,selectIds:"",selectLabel:[]}),d={prevSelectIds:[]},D=e.computed(()=>o.arrowDirection),C=e.computed(()=>{let a=["panel-selectTree","box-width"].join(" ");return u.CommonBase.isEmpty(o.className)||(a+=" "+o.className),a}),w=e.computed(()=>{const t=["selectTree-inDropdown"];return o.classDropDown&&!u.CommonBase.isEmpty(o.classDropDown)&&t.push(o.classDropDown),t.join(" ")}),y=t=>{s("update:value",t)},S=(t,a)=>{y(t),s("onChange",t,a)},v=()=>{e.nextTick(()=>{s("onInit")})},x=t=>{e.nextTick(()=>{s("onOpen",t)})},m=()=>{if(!n.isOpen){const t=n.selectIds,a=t.split(",");if(!u.CommonBase.isEqualArr(a,d.prevSelectIds)){d.prevSelectIds=a;const i=p.value.getValueData();S(t,i)}}},f=()=>{n.isFirstDataFinish||(n.isFirstDataFinish=!0,v())},V=()=>{o.list.length>0&&f()};e.watch([()=>o.value,()=>o.list],([t,a],[c,i])=>{t===c&&(n.isFirstDataFinish||f())}),e.onMounted(()=>{e.nextTick(()=>{V()})});const b=t=>{o.disabled||(n.isOpen=t,t?d.prevSelectIds=n.selectIds.split(","):m(),x(t))},B=()=>{o.disabled||(n.selectIds="",m())},I=()=>{r.value&&(r.value.checkCurrentIsOpen()||r.value.initCompleteOpen())},T=()=>{};return h({getValue:()=>n.selectIds,getValueData:()=>p.value.getValueData(),setValue:t=>{n.selectIds=t}}),(t,a)=>{const c=e.resolveComponent("cl-badge"),i=e.resolveComponent("cl-input-search"),O=e.resolveComponent("cl-tree"),k=e.resolveComponent("cl-dropdownlayer-list");return e.openBlock(),e.createBlock(k,{ref_key:"refElDropdownLayer",ref:r,classParent:C.value,classText:"selectTree-inText",classDropDown:w.value,placeholder:l.placeholder,isDisabled:l.disabled,isClear:l.isClear,textLabel:n.selectLabel.join(","),textArrowDirection:D.value,onOpenBeforeCallback:l.onOpenBefore,onOnChangeOpen:b,onOnClear:B},{textExtend:e.withCtx(()=>[l.multiple?(e.openBlock(),e.createElementBlock("span",F,[l.multiple&&n.selectLabel.length>1?(e.openBlock(),e.createBlock(c,{key:0,num:n.selectLabel.length},null,8,["num"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),dropdown:e.withCtx(()=>[e.createElementVNode("div",E,[e.createElementVNode("div",L,[e.createVNode(i,{ref:"refElSearch",onOnChange:T},null,512)]),e.createElementVNode("div",N,[e.createVNode(O,{ref_key:"refElList",ref:p,list:l.list,value:n.selectIds,"onUpdate:value":a[0]||(a[0]=_=>n.selectIds=_),multiple:l.multiple,textFormat:l.showDropDownTextFormat,isSingleSelectParent:l.isSingleSelectParent,parentKey:l.parentKey,topParentValue:l.topParentValue,shrinkColorBg:"transparent",onOnInit:I},null,8,["list","value","multiple","textFormat","isSingleSelectParent","parentKey","topParentValue"])])])]),_:1},8,["classParent","classDropDown","placeholder","isDisabled","isClear","textLabel","textArrowDirection","onOpenBeforeCallback"])}}});module.exports=P;
//# sourceMappingURL=ClSelectTree.cjs.map
