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