import{_ as e}from"./u-icon.DtKBPjPl.js";import{q as t,o as a,c as i,w as l,b as s,H as r,L as n,_ as o,i as h}from"./index-BdZf2PuA.js";import{r as d}from"./uni-app.es.ZCv6f5BQ.js";import{_ as u}from"./_plugin-vue_export-helper.BCo6x5W8.js";import{E as p}from"./emitter.DrjJCwnj.js";const c=u({name:"u-radio",emits:["change"],props:{name:{type:[String,Number],default:""},size:{type:[String,Number],default:34},shape:{type:String,default:""},disabled:{type:[String,Boolean],default:""},labelDisabled:{type:[String,Boolean],default:""},activeColor:{type:String,default:""},iconSize:{type:[String,Number],default:""},labelSize:{type:[String,Number],default:""}},data:()=>({parentData:{iconSize:null,labelDisabled:null,disabled:null,shape:null,activeColor:null,size:null,width:null,height:null,value:null,wrap:null,modelValue:null}}),created(){this.parent=!1,this.updateParentData(),this.parent.children.push(this)},computed:{elDisabled(){return""!==this.disabled?this.disabled:null!==this.parentData.disabled&&this.parentData.disabled},elLabelDisabled(){return""!==this.labelDisabled?this.labelDisabled:null!==this.parentData.labelDisabled&&this.parentData.labelDisabled},elSize(){return this.size?this.size:this.parentData.size?this.parentData.size:34},elIconSize(){return this.iconSize?this.iconSize:this.parentData.iconSize?this.parentData.iconSize:20},elActiveColor(){return this.activeColor?this.activeColor:this.parentData.activeColor?this.parentData.activeColor:"primary"},elShape(){return this.shape?this.shape:this.parentData.shape?this.parentData.shape:"circle"},iconStyle(){let e={};return this.elActiveColor&&this.parentData.value===this.name&&!this.elDisabled&&(e.borderColor=this.elActiveColor,e.backgroundColor=this.elActiveColor),e.width=this.$u.addUnit(this.elSize),e.height=this.$u.addUnit(this.elSize),e},iconColor(){return this.name===this.parentData.value?"#ffffff":"transparent"},iconClass(){let e=[];return e.push("u-radio__icon-wrap--"+this.elShape),this.name===this.parentData.value&&e.push("u-radio__icon-wrap--checked"),this.elDisabled&&e.push("u-radio__icon-wrap--disabled"),this.name===this.parentData.value&&this.elDisabled&&e.push("u-radio__icon-wrap--disabled--checked"),e.join(" ")},radioStyle(){let e={};return this.parentData.width&&(e.width=this.$u.addUnit(this.parentData.width),e.flex=`0 0 ${this.$u.addUnit(this.parentData.width)}`),this.parentData.wrap&&(e.width="100%",e.flex="0 0 100%"),e}},methods:{updateParentData(){this.getParentData("u-radio-group")},onClickLabel(){this.elLabelDisabled||this.elDisabled||this.setRadioCheckedStatus()},toggle(){this.elDisabled||this.setRadioCheckedStatus()},emitEvent(){this.parentData.value!=this.name&&this.$emit("change",this.name)},setRadioCheckedStatus(){this.emitEvent(),this.parent&&(this.parent.setValue(this.name),this.parentData.value=this.name)}}},[["render",function(u,p,c,m,b,D){const f=d(t("u-icon"),e),S=h;return a(),i(S,{class:"u-radio",style:n([D.radioStyle])},{default:l((()=>[s(S,{class:r(["u-radio__icon-wrap",[D.iconClass]]),onClick:D.toggle,style:n([D.iconStyle])},{default:l((()=>[s(f,{class:"u-radio__icon-wrap__icon",name:"checkbox-mark",size:D.elIconSize,color:D.iconColor},null,8,["size","color"])])),_:1},8,["onClick","class","style"]),s(S,{class:"u-radio__label",onClick:D.onClickLabel,style:n({fontSize:u.$u.addUnit(c.labelSize)})},{default:l((()=>[o(u.$slots,"default",{},void 0,!0)])),_:3},8,["onClick","style"])])),_:3},8,["style"])}],["__scopeId","data-v-1295fd34"]]);const m=u({name:"u-radio-group",emits:["update:modelValue","input","change"],mixins:[p],props:{value:{type:[String,Number],default:""},modelValue:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1},activeColor:{type:String,default:"#2979ff"},size:{type:[String,Number],default:34},labelDisabled:{type:Boolean,default:!1},shape:{type:String,default:"circle"},iconSize:{type:[String,Number],default:20},width:{type:[String,Number],default:"auto"},wrap:{type:Boolean,default:!1}},data:()=>({uFromData:{inputAlign:"left"}}),created(){this.children=[]},mounted(){let e=this.$u.$parent.call(this,"u-form");e&&Object.keys(this.uFromData).map((t=>{this.uFromData[t]=e[t]}))},watch:{parentData(){this.children.length&&this.children.map((e=>{"function"==typeof e.updateParentData&&e.updateParentData()}))}},computed:{valueCom(){return this.modelValue},parentData(){return[this.value,this.disabled,this.activeColor,this.size,this.labelDisabled,this.shape,this.iconSize,this.width,this.wrap,this.modelValue]}},methods:{setValue(e){this.children.map((t=>{t.parentData.value!=e&&(t.parentData.value="")})),this.$emit("input",e),this.$emit("update:modelValue",e),this.$emit("change",e),setTimeout((()=>{this.dispatch("u-form-item","onFieldChange",e)}),60)}}},[["render",function(e,t,s,n,d,u){const p=h;return a(),i(p,{class:r(["u-radio-group u-clearfix","right"==d.uFromData.inputAlign?"flex-end":""])},{default:l((()=>[o(e.$slots,"default",{},void 0,!0)])),_:3},8,["class"])}],["__scopeId","data-v-2aeb793f"]]);export{c as _,m as a};