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.0 KiB
35 lines
1.0 KiB
import { inject } from 'vue';
|
|
import Radio from './Radio';
|
|
import { getOptionProps, getSlot } from '../_util/props-util';
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
export default {
|
|
name: 'ARadioButton',
|
|
props: {
|
|
...Radio.props,
|
|
},
|
|
setup() {
|
|
return {
|
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
|
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>;
|
|
},
|
|
};
|