You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
4.1 KiB

import{d as O,de as T,r as P,k as U,da as V,Q as j,dg as J,R as z,T as S,b as m,U as I,V as B,O as Q,p as q,dd as D,J as H}from"./index-f4658ae7.js";import{V as K}from"./Checkbox-abf1420e.js";var L=globalThis&&globalThis.__rest||function(n,e){var u={};for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&e.indexOf(a)<0&&(u[a]=n[a]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,a=Object.getOwnPropertySymbols(n);o<a.length;o++)e.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(n,a[o])&&(u[a[o]]=n[a[o]]);return u},A=function(){return{prefixCls:String,checked:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},isGroup:{type:Boolean,default:void 0},value:B.any,name:String,id:String,autofocus:{type:Boolean,default:void 0},onChange:Function,onFocus:Function,onBlur:Function,onClick:Function,"onUpdate:checked":Function,"onUpdate:value":Function}};const d=O({name:"ARadio",props:A(),setup:function(e,u){var a=u.emit,o=u.expose,b=u.slots,c=T(),s=P(),r=U("radioGroupContext",void 0),y=V("radio",e),l=y.prefixCls,x=y.direction,G=function(){s.value.focus()},v=function(){s.value.blur()};o({focus:G,blur:v});var g=function(i){var C=i.target.checked;a("update:checked",C),a("update:value",C),a("change",i),c.onFieldChange()},h=function(i){a("change",i),r&&r.onRadioChange&&r.onRadioChange(i)};return function(){var t,i=r;e.prefixCls;var C=e.id,R=C===void 0?c.id.value:C,k=L(e,["prefixCls","id"]),f=j({prefixCls:l.value,id:R},J(k,["onUpdate:checked","onUpdate:value"]));i?(f.name=i.props.name,f.onChange=h,f.checked=e.value===i.stateValue.value,f.disabled=e.disabled||i.props.disabled):f.onChange=g;var _=z((t={},S(t,"".concat(l.value,"-wrapper"),!0),S(t,"".concat(l.value,"-wrapper-checked"),f.checked),S(t,"".concat(l.value,"-wrapper-disabled"),f.disabled),S(t,"".concat(l.value,"-wrapper-rtl"),x.value==="rtl"),t));return m("label",{class:_},[m(K,I(I({},f),{},{type:"radio",ref:s}),null),b.default&&m("span",null,[b.default()])])}}});var M=D("large","default","small"),W=function(){return{prefixCls:String,value:B.any,size:B.oneOf(M).def("default"),options:{type:Array},disabled:{type:Boolean,default:void 0},name:String,buttonStyle:{type:String,default:"outline"},id:String,optionType:{type:String,default:"default"},onChange:Function,"onUpdate:value":Function}};const X=O({name:"ARadioGroup",props:W(),setup:function(e,u){var a=u.slots,o=u.emit,b=T(),c=V("radio",e),s=c.prefixCls,r=c.direction,y=c.size,l=P(e.value),x=P(!1);Q(function(){return e.value},function(v){l.value=v,x.value=!1});var G=function(g){var h=l.value,t=g.target.value;"value"in e||(l.value=t),!x.value&&t!==h&&(x.value=!0,o("update:value",t),o("change",g),b.onFieldChange()),H(function(){x.value=!1})};return q("radioGroupContext",{onRadioChange:G,stateValue:l,props:e}),function(){var v,g,h=e.options,t=e.optionType,i=e.buttonStyle,C=e.id,R=C===void 0?b.id.value:C,k="".concat(s.value,"-group"),f=z(k,"".concat(k,"-").concat(i),(v={},S(v,"".concat(k,"-").concat(y.value),y.value),S(v,"".concat(k,"-rtl"),r.value==="rtl"),v)),_=null;if(h&&h.length>0){var w=t==="button"?"".concat(s.value,"-button"):s.value;_=h.map(function(p){if(typeof p=="string"||typeof p=="number")return m(d,{key:p,prefixCls:w,disabled:e.disabled,value:p,checked:l.value===p},{default:function(){return[p]}});var F=p.value,N=p.disabled,$=p.label;return m(d,{key:"radio-group-value-options-".concat(F),prefixCls:w,disabled:N||e.disabled,value:F,checked:l.value===F},{default:function(){return[$]}})})}else _=(g=a.default)===null||g===void 0?void 0:g.call(a);return m("div",{class:f,id:R},[_])}}}),Y=O({name:"ARadioButton",props:A(),setup:function(e,u){var a=u.slots,o=V("radio-button",e),b=o.prefixCls,c=U("radioGroupContext",void 0);return function(){var s,r=j(j({},e),{prefixCls:b.value});return c&&(r.onChange=c.onRadioChange,r.checked=r.value===c.stateValue.value,r.disabled=r.disabled||c.props.disabled),m(d,r,{default:function(){return[(s=a.default)===null||s===void 0?void 0:s.call(a)]}})}}});d.Group=X;d.Button=Y;d.install=function(n){return n.component(d.name,d),n.component(d.Group.name,d.Group),n.component(d.Button.name,d.Button),n};export{d as R,X as a};