"use strict";const e=require("vue");;/* empty css                        */const o=require("../Shared/base-iCmnU-fv.js"),b=require("../Web/__directive__/Tooltip.cjs"),D=["id","name","value","disabled","checked","onClick"],F=["for"],J=e.defineComponent({name:"ClRadio",directives:{cltooltip:b.tooltipDirectives},__name:"Index",props:{value:{type:[String,Number],required:!0},className:{type:String,default:""},name:{type:String,required:!0},list:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},width:{type:String,default:"auto"},isInline:{type:Boolean,default:!0}},emits:["update:value","onChange","onInit"],setup(r,{expose:h,emit:y}){const s=r,d=y,B=`rd-${o.CommonBase.getRandom(8)}`,a=e.ref(s.value?.toString()||"");let u={};const c=e.ref(!1),k=e.computed(()=>{const t=s.className,n={"panel-radio":!0};return t&&!o.CommonBase.isEmpty(t)&&t.split(" ").forEach(i=>{o.CommonBase.isEmpty(i)||(n[i]=!0)}),n}),E=e.computed(()=>{const t={radio:!0,"radio-default":!0};return t["radio-inline"]=s.isInline??!0,t}),_=t=>{const n={"radio-icon-tip":!0};return o.CommonBase.isEmpty(t.tipIcon)?n["clIconFont clIcon-question-circle"]=!0:n[t.tipIcon]=!0,n},V=t=>{const n={},{width:i}=s;return t&&!o.CommonBase.isEmpty(t.width)?n.width=t.width:o.CommonBase.isEmpty(i)||(n.width=s.width),n},C=t=>{d("update:value",t)},I=t=>{const n=t.id.toString();C(n),d("onChange",n,o.CommonBase.getJsonClone(t))},x=()=>{e.nextTick(()=>{d("onInit")})},f=()=>o.CommonBase.isExistJsonKey(u,a.value)?a.value:"",p=t=>{u=o.CommonBase.isEmpty(t)?{}:o.CommonBase.getJsonByList(t)},m=()=>{if(c.value){const t=o.CommonBase.isEmpty(a.value)?"":a.value;o.CommonBase.isExistJsonKey(u,t)||(a.value="",C(""))}},v=t=>{t!==a.value&&(a.value=t?.toString()||"")},w=()=>{c.value=s.list.length!==0,p(s.list),m()};e.watch(c,t=>{t&&x()}),e.watch(()=>s.list,t=>{c.value||(c.value=!0,t.length===0&&m())}),e.watch([()=>s.value,()=>s.list],([t,n])=>{const i=n;!c.value&&i.length>0&&(c.value=!0),p(i),t!==a.value&&v(t),m()}),e.onMounted(()=>{e.nextTick(()=>{w()})});const N=t=>{if(!t.isDisabled&&!s.disabled){const n=t.id.toString();n!==a.value&&(a.value=n,I(t))}},g=()=>f();return h({getValue:g,getValueData:()=>{const t=g();return o.CommonBase.isExistJsonKey(u,t)?o.CommonBase.getJsonClone(u[t]):{}},setValue:t=>{v(t),m()},runInitComplete:()=>{c.value||(c.value=!0,p(s.list),v(s.value),m())}}),(t,n)=>{const i=e.resolveDirective("cltooltip");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(k.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.list,(l,S)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${B}-${S}`},[l.isShow||l.isShow===void 0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(E.value),style:e.normalizeStyle(V(l))},[e.createElementVNode("span",null,[e.createElementVNode("span",null,[e.createElementVNode("input",{type:"radio",id:`rd_${r.name}_${l.id}`,name:r.name,value:l.id,disabled:l.isDisabled||r.disabled,checked:l.id.toString()===a.value,onClick:M=>N(l)},null,8,D),e.createElementVNode("label",{for:`rd_${r.name}_${l.id}`},[l.icon&&l.icon.length>0?e.withDirectives((e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(l.icon)},null,2)),[[i,{html:l.name,className:"tooltip-modal"}]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(l.name),1)],64))],8,F)]),l.tipMsg&&l.tipMsg.length>0?e.withDirectives((e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(_(l))},null,2)),[[i,{html:l.tipMsg,className:"tooltip-modal"}]]):e.createCommentVNode("",!0)])],6)):e.createCommentVNode("",!0)],64))),128))],2)}}});module.exports=J;
//# sourceMappingURL=ClRadio.cjs.map
