import HelpIcon from 'wdk-client/Components/Icon/HelpIcon'; import React, { ReactNode } from 'react'; import { getValueOrDefault, wrappable } from 'wdk-client/Utils/ComponentUtils'; import 'wdk-client/Components/InputControls/RadioList.css'; const baseClassName = "wdk-RadioList"; type Props = { /** Value to use for "name" attribute of radio form input elements **/ name?: string; /** Array of items to display in the list **/ items: Array<{ display: ReactNode; value: string; description?: string; disabled?: boolean; }>; /** Value of the radio input element that should be checked **/ value?: string; /** Whether a value is required for submission */ required?: boolean; /** * Callback function that will be called when user changes selected value. * The new (string) value of the selected button will be passed to this * function. */ onChange: (value: string) => void; /** * CSS class name that will be applied to the parent
  • element of this * radio list. */ className?: string; } class RadioList extends React.Component { constructor(props: Props) { super(props); this.onChange = this.onChange.bind(this); } onChange(event: React.ChangeEvent) { // only call change function passed in if value is indeed changing if (event.target.value !== this.props.value) { this.props.onChange(event.target.value); } } render() { let className = baseClassName + " " + getValueOrDefault(this.props, "className", ""); const { required = false } = this.props; return (
      {this.props.items.map(item => (
    • ))}
    ); } } export default wrappable(RadioList)