"use strict";const t=require("vue"),c=require("./base-iCmnU-fv.js"),E=["onClick"],F=["innerHTML"],R={key:1},_=["onClick"],L=t.defineComponent({name:"ClTags",__name:"Index",props:{className:String,list:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},isRemove:{type:Boolean,default:!0},showTextFormat:String,isRemoveAll:{type:Boolean,default:!1},theme:{type:String,default:"default"},isFormatHtml:{type:Boolean,default:!1}},emits:["onRemove","onClickTag"],setup(r,{expose:k,emit:C}){const a=r,m=C,B=`tag-${c.CommonBase.getRandom(8)}`,g=t.ref(a.disabled),n=t.ref([]),l=t.reactive({status:0,startColor:"#FFFF80",endColor:"rgba(0, 0, 0, 0)",hID:""}),b=t.computed(()=>{const{className:e,theme:s}=a,o={"panel-tags":!0};return s!=="default"&&(o[`tags-${s}`]=!0),a.isRemoveAll&&n.value.length>0&&(o["tags-region"]=!0),c.CommonBase.isEmpty(e)||e.split(" ").forEach(i=>{c.CommonBase.isEmpty(i)||(o[i]=!0)}),o}),f=e=>{const{theme:s}=a;let o={};return s==="default"?(o={tag:!0,"tag-disabled":e.isShowDisabled,"tag-remove":a.isRemove&&!e.isShowDisabled},o["tag-hlight"]=e.id.toString()===l.hID&&l.status===2):s==="code"&&(o["tag-code"]=!0),o},y=e=>{const s={};if(e.id.toString()===l.hID)switch(l.status){case 1:s["background-color"]=l.startColor;break;case 2:s["background-color"]=l.endColor;break}return s},h=e=>c.CommonBase.isEmpty(a.showTextFormat)?e.name:c.CommonBase.convertStringFormat(a.showTextFormat,e),p=e=>{const s=g.value;let o=!1;s?o=!0:o=c.CommonBase.isBoolean(e.isDisabled)?e.isDisabled:!1,e.isShowDisabled=o},u=e=>{const s=[];return e.forEach(o=>{const i=c.CommonBase.getJsonClone(o);p(i),s.push(i)}),s},v=e=>{g.value=e;const s=u(n.value);n.value=s},D=e=>{l.hID=e.toString(),l.status=1,t.nextTick(()=>{setTimeout(()=>{l.status=2},10),setTimeout(()=>{l.status=0,l.hID=""},1500)})},w=()=>{const e=u(a.list);n.value=e};t.watch(()=>a.disabled,e=>{v(e)}),t.watch(()=>a.list,e=>{const s=u(e);n.value=s},{deep:!0}),t.onMounted(()=>{t.nextTick(()=>{w()})});const I=(e,s)=>{m("onClickTag",s)},S=(e,s,o)=>{e.preventDefault(),e.stopPropagation(),a.isRemove&&!s.isShowDisabled&&(n.value.splice(o,1),m("onRemove",s.id.toString()))},T=()=>{n.value=[],m("onRemove","")};return k({setDisabled:(e=!0)=>{v(e)},addInfo:e=>{const s=c.CommonBase.getListExistValue(n.value,e.name,"name");if(c.CommonBase.isEmpty(s)){const o=c.CommonBase.getJsonClone(e);p(o),n.value.push(o)}else D(s.info.id)},getData:()=>n.value}),(e,s)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(b.value)},[n.value.length>0?t.renderSlot(e.$slots,"head",{key:0}):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.value,(o,i)=>(t.openBlock(),t.createElementBlock("span",{key:`${B}-list-${i}-${o.id}`,class:t.normalizeClass(f(o)),style:t.normalizeStyle(y(o)),onClick:t.withModifiers(d=>I(d,o),["stop"])},[o.isHtml||r.isFormatHtml?(t.openBlock(),t.createElementBlock("span",{key:0,innerHTML:h(o)},null,8,F)):(t.openBlock(),t.createElementBlock("span",R,t.toDisplayString(h(o)),1)),r.isRemove&&!o.isShowDisabled?(t.openBlock(),t.createElementBlock("i",{key:2,class:"tag-close clIconFont clIcon-close",onClick:d=>S(d,o,i)},null,8,_)):t.createCommentVNode("",!0)],14,E))),128)),r.isRemoveAll&&n.value.length>0&&!r.disabled?(t.openBlock(),t.createElementBlock("i",{key:1,class:"tag-closeAll clIconFont clIcon-close",onClick:T})):t.createCommentVNode("",!0)],2))}});exports._sfc_main=L;
//# sourceMappingURL=Index.vue_vue_type_script_setup_true_lang-HDdyVujM.js.map
