// Libs import * as React from 'react'; import { BaseInputProps, BaseInputState, BaseInput, } from '../base/input/BaseInput'; import { withFormContext } from '../form/withFormContext'; import { withThemeContext } from '../themeProvider/withThemeContext'; // Misc export interface RadioProps extends BaseInputProps { onChange?: never; onChecked: (value: string) => void; result: string; value: string; name: string; } export interface RadioState extends BaseInputState {} export class RadioRaw extends BaseInput< RadioProps, RadioState, HTMLInputElement > { public static defaultProps = (Object.assign({}, BaseInput.defaultProps, { onChange: undefined, }) as unknown) as RadioProps; constructor(props: RadioProps) { super(props); this.onChecked = this.onChecked.bind(this); } public render() { return (
{!this.props.label && this.renderInput()} {this.props.label && ( )}
); } private renderInput() { return ( ); } private onChecked(e: React.ChangeEvent) { // e.preventDefault(); this.props.onChecked && this.props.onChecked(e.target.value); } } export const Radio = withThemeContext< RadioProps, InstanceType >(withFormContext(RadioRaw), 'radio'); export default Radio;