mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-04 21:18:14 +08:00
a2f7d6d062
closes vueComponent/ant-design-vue#5765 Add `compatConfig: { MODE: 3 }` to all component definitions to signal to `@vue/compat` not to use any Vue 2 compatibility features.
30 lines
995 B
Vue
30 lines
995 B
Vue
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({
|
|
compatConfig: { MODE: 3 },
|
|
name: 'ARadioButton',
|
|
props: radioProps(),
|
|
setup(props, { 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>;
|
|
};
|
|
},
|
|
});
|