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.
35 lines
1.1 KiB
35 lines
1.1 KiB
import { defineComponent, inject } from 'vue';
|
|
import Radio from './Radio';
|
|
import { getOptionProps, getSlot } from '../_util/props-util';
|
|
import { defaultConfigProvider } from '../config-provider';
|
|
|
|
export default defineComponent({
|
|
name: 'ARadioButton',
|
|
props: {
|
|
...Radio.props,
|
|
},
|
|
setup() {
|
|
return {
|
|
configProvider: inject('configProvider', defaultConfigProvider),
|
|
radioGroupContext: inject('radioGroupContext', {}),
|
|
};
|
|
},
|
|
render() {
|
|
const props = getOptionProps(this);
|
|
const { prefixCls: customizePrefixCls, ...otherProps } = props;
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
const prefixCls = getPrefixCls('radio-button', customizePrefixCls);
|
|
|
|
const radioProps = {
|
|
prefixCls,
|
|
...otherProps,
|
|
};
|
|
if (this.radioGroupContext) {
|
|
radioProps.onChange = this.radioGroupContext.onRadioChange;
|
|
radioProps.checked = props.value === this.radioGroupContext.stateValue;
|
|
radioProps.disabled = props.disabled || this.radioGroupContext.disabled;
|
|
}
|
|
return <Radio {...radioProps}>{getSlot(this)}</Radio>;
|
|
},
|
|
});
|