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.
ant-design-vue/components/radio/RadioButton.tsx

29 lines
976 B

import { defineComponent, inject } from 'vue';
import type { RadioProps } from './Radio';
import Radio, { radioProps } from './Radio';
import useConfigInject from '../_util/hooks/useConfigInject';
import type { RadioGroupContext } from './interface';
export default defineComponent({
name: 'ARadioButton',
props: radioProps,
setup(props: RadioProps, { slots }) {
const { prefixCls } = useConfigInject('radio-button', props);
const radioGroupContext = inject<RadioGroupContext>('radioGroupContext', undefined);
return () => {
const rProps: RadioProps = {
...props,
prefixCls: prefixCls.value,
};
if (radioGroupContext) {
rProps.onChange = radioGroupContext.onRadioChange;
rProps.checked = rProps.value === radioGroupContext.stateValue.value;
rProps.disabled = rProps.disabled || radioGroupContext.props.disabled;
}
return <Radio {...rProps}>{slots.default?.()}</Radio>;
};
},
});