Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankeairns committed Oct 16, 2019
1 parent 2eec6a4 commit 63f6bc6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

- Converted `EuiRadio` and `EuiRadioGroup` to TypeScript ([#2438](https://github.com/elastic/eui/pull/2438))

## [`14.6.0`](https://github.com/elastic/eui/tree/v14.6.0)

- Added new updated `infraApp` and `logsApp` icons. ([#2430](https://github.com/elastic/eui/pull/2430))

**Bug fixes**

- Fixed missing misc. button and link type definition exports ([#2434](https://github.com/elastic/eui/pull/2434))
- Strip custom semantics from `EuiSideNav` ([#2429](https://github.com/elastic/eui/pull/2429))

## [`14.5.0`](https://github.com/elastic/eui/tree/v14.5.0)

- Update Elastic-Charts to version 13.0.0 and updated the theme object accordingly ([#2381](https://github.com/elastic/eui/pull/2381))
Expand Down
9 changes: 7 additions & 2 deletions src/components/form/radio/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { EuiRadio } from './radio';
export { EuiRadio, EuiRadioProps } from './radio';

export { EuiRadioGroup } from './radio_group';
export {
EuiRadioGroup,
EuiRadioGroupProps,
EuiRadioGroupOption,
EuiRadioGroupChangeCallback,
} from './radio_group';
25 changes: 11 additions & 14 deletions src/components/form/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,32 @@ import React, {
ReactNode,
} from 'react';
import classNames from 'classnames';
import { CommonProps } from '../../common';
import { CommonProps, Omit } from '../../common';

export interface EuiRadioProps {
export interface RadioProps {
autoFocus?: boolean;
/**
* when `true` creates a shorter height radio row
* When `true` creates a shorter height radio row
*/
compressed?: boolean;
label?: ReactNode;
name?: string;
value?: string;
checked?: boolean;
disabled?: boolean;
onChange: ChangeEventHandler<HTMLInputElement>; // overriding to make it required
onChange: ChangeEventHandler<HTMLInputElement>;
}

export const EuiRadio: FunctionComponent<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiRadioProps
> = ({
export interface EuiRadioProps
extends CommonProps,
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>,
RadioProps {}

export const EuiRadio: FunctionComponent<EuiRadioProps> = ({
className,
id,
name,
checked,
checked = false,
label,
value,
onChange,
Expand Down Expand Up @@ -75,9 +78,3 @@ export const EuiRadio: FunctionComponent<
</div>
);
};

EuiRadio.defaultProps = {
checked: false,
disabled: false,
compressed: false,
};
2 changes: 1 addition & 1 deletion src/components/form/radio/radio_group.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jest.mock('../radio', () => ({ EuiRadio: 'eui_radio' }));
describe('EuiRadioGroup', () => {
test('is rendered', () => {
const component = render(
<EuiRadioGroup {...requiredProps} onChange={() => {}} />
<EuiRadioGroup {...requiredProps} options={[]} onChange={() => {}} />
);

expect(component).toMatchSnapshot();
Expand Down
20 changes: 6 additions & 14 deletions src/components/form/radio/radio_group.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React, { FunctionComponent, HTMLAttributes, ReactNode } from 'react';
import React, { FunctionComponent, HTMLAttributes } from 'react';
import { CommonProps, Omit } from '../../common';

import { EuiRadio } from './radio';
import { EuiRadio, RadioProps } from './radio';

export interface EuiRadioGroupOption {
export interface EuiRadioGroupOption
extends Omit<RadioProps, 'checked' | 'onChange'> {
id: string;
label?: ReactNode;
disabled?: boolean; // TODO: Added to fix TS error; disabled can be on group or item
value?: any; // TODO: Added to fix TS error; used in options map below
}

export type EuiRadioGroupChangeCallback = (id: string, value: string) => void;
export type EuiRadioGroupChangeCallback = (id: string, value?: string) => void;

export type EuiRadioGroupProps = CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
Expand All @@ -21,13 +19,11 @@ export type EuiRadioGroupProps = CommonProps &
*/
compressed?: boolean;
name?: string;
options?: EuiRadioGroupOption[];
options: EuiRadioGroupOption[];
idSelected?: string;
onChange: EuiRadioGroupChangeCallback;
};

export type x = EuiRadioGroupProps['onChange'];

export const EuiRadioGroup: FunctionComponent<EuiRadioGroupProps> = ({
options = [],
idSelected,
Expand Down Expand Up @@ -56,7 +52,3 @@ export const EuiRadioGroup: FunctionComponent<EuiRadioGroupProps> = ({
})}
</div>
);

EuiRadioGroup.defaultProps = {
options: [],
};

0 comments on commit 63f6bc6

Please sign in to comment.