= ({
className,
id,
name,
@@ -54,24 +78,3 @@ export const EuiRadio = ({
);
};
-
-EuiRadio.propTypes = {
- className: PropTypes.string,
- id: PropTypes.string.isRequired,
- checked: PropTypes.bool.isRequired,
- label: PropTypes.node,
- value: PropTypes.string,
- onChange: PropTypes.func.isRequired,
- disabled: PropTypes.bool,
- /**
- * when `true` creates a shorter height radio row
- */
- compressed: PropTypes.bool,
- autoFocus: PropTypes.bool,
-};
-
-EuiRadio.defaultProps = {
- checked: false,
- disabled: false,
- compressed: false,
-};
diff --git a/src/components/form/radio/radio_group.js b/src/components/form/radio/radio_group.js
deleted file mode 100644
index 712b4932964..00000000000
--- a/src/components/form/radio/radio_group.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import { EuiRadio } from './radio';
-
-export const EuiRadioGroup = ({
- options,
- idSelected,
- onChange,
- name,
- className,
- disabled,
- compressed,
- ...rest
-}) => (
-
- {options.map((option, index) => {
- const { disabled: isOptionDisabled, ...optionRest } = option;
- return (
-
- );
- })}
-
-);
-
-EuiRadioGroup.propTypes = {
- disabled: PropTypes.bool,
- name: PropTypes.string,
- options: PropTypes.arrayOf(
- PropTypes.shape({
- id: PropTypes.string.isRequired,
- label: PropTypes.node,
- value: PropTypes.string,
- disabled: PropTypes.bool,
- })
- ).isRequired,
- idSelected: PropTypes.string,
- onChange: PropTypes.func.isRequired,
- /**
- * Tightens up the spacing between radio rows and sends down the
- * compressed prop to the radio itself
- */
- compressed: PropTypes.bool,
-};
-
-EuiRadioGroup.defaultProps = {
- options: [],
-};
diff --git a/src/components/form/radio/radio_group.test.js b/src/components/form/radio/radio_group.test.tsx
similarity index 97%
rename from src/components/form/radio/radio_group.test.js
rename to src/components/form/radio/radio_group.test.tsx
index 653d757872c..fa9271a8469 100644
--- a/src/components/form/radio/radio_group.test.js
+++ b/src/components/form/radio/radio_group.test.tsx
@@ -9,7 +9,7 @@ jest.mock('../radio', () => ({ EuiRadio: 'eui_radio' }));
describe('EuiRadioGroup', () => {
test('is rendered', () => {
const component = render(
- {}} />
+ {}} />
);
expect(component).toMatchSnapshot();
diff --git a/src/components/form/radio/radio_group.tsx b/src/components/form/radio/radio_group.tsx
new file mode 100644
index 00000000000..ec6dda906c0
--- /dev/null
+++ b/src/components/form/radio/radio_group.tsx
@@ -0,0 +1,54 @@
+import React, { FunctionComponent, HTMLAttributes } from 'react';
+import { CommonProps, Omit } from '../../common';
+
+import { EuiRadio, RadioProps } from './radio';
+
+export interface EuiRadioGroupOption
+ extends Omit {
+ id: string;
+}
+
+export type EuiRadioGroupChangeCallback = (id: string, value?: string) => void;
+
+export type EuiRadioGroupProps = CommonProps &
+ Omit, 'onChange'> & {
+ disabled?: boolean;
+ /**
+ * Tightens up the spacing between radio rows and sends down the
+ * compressed prop to the radio itself
+ */
+ compressed?: boolean;
+ name?: string;
+ options: EuiRadioGroupOption[];
+ idSelected?: string;
+ onChange: EuiRadioGroupChangeCallback;
+ };
+
+export const EuiRadioGroup: FunctionComponent = ({
+ options = [],
+ idSelected,
+ onChange,
+ name,
+ className,
+ disabled,
+ compressed,
+ ...rest
+}) => (
+
+ {options.map((option, index) => {
+ const { disabled: isOptionDisabled, ...optionRest } = option;
+ return (
+
+ );
+ })}
+
+);