RadioButton.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
  2. import _extends from 'babel-runtime/helpers/extends';
  3. import Radio from './Radio';
  4. import { getOptionProps, getListeners } from '../_util/props-util';
  5. import { ConfigConsumerProps } from '../config-provider/configConsumerProps';
  6. export default {
  7. name: 'ARadioButton',
  8. props: _extends({}, Radio.props),
  9. inject: {
  10. radioGroupContext: { 'default': undefined },
  11. configProvider: { 'default': function _default() {
  12. return ConfigConsumerProps;
  13. } }
  14. },
  15. render: function render() {
  16. var h = arguments[0];
  17. var _getOptionProps = getOptionProps(this),
  18. customizePrefixCls = _getOptionProps.prefixCls,
  19. otherProps = _objectWithoutProperties(_getOptionProps, ['prefixCls']);
  20. var getPrefixCls = this.configProvider.getPrefixCls;
  21. var prefixCls = getPrefixCls('radio-button', customizePrefixCls);
  22. var radioProps = {
  23. props: _extends({}, otherProps, {
  24. prefixCls: prefixCls
  25. }),
  26. on: getListeners(this)
  27. };
  28. if (this.radioGroupContext) {
  29. radioProps.on.change = this.radioGroupContext.onRadioChange;
  30. radioProps.props.checked = this.$props.value === this.radioGroupContext.stateValue;
  31. radioProps.props.disabled = this.$props.disabled || this.radioGroupContext.disabled;
  32. }
  33. return h(
  34. Radio,
  35. radioProps,
  36. [this.$slots['default']]
  37. );
  38. }
  39. };