-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypeScript definitions for EuiRange and EuiRadio #1253
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/// <reference path="../../common.d.ts" /> | ||
|
||
import { SFC, HTMLAttributes, ReactNode } from 'react'; | ||
import { SFC, ChangeEventHandler, InputHTMLAttributes, HTMLAttributes, ReactNode } from 'react'; | ||
|
||
declare module '@elastic/eui' { | ||
/** | ||
|
@@ -11,10 +11,12 @@ declare module '@elastic/eui' { | |
label?: ReactNode; | ||
} | ||
|
||
export type EuiRadioGroupChangeCallback = (id: string) => void; | ||
export type EuiRadioGroupChangeCallback = (id: string, value: string) => void; | ||
|
||
export type EuiRadioGroupProps = CommonProps & | ||
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & { | ||
disabled?: boolean; | ||
name?: string; | ||
options?: EuiRadioGroupOption[]; | ||
idSelected?: string; | ||
onChange: EuiRadioGroupChangeCallback; | ||
|
@@ -23,4 +25,15 @@ declare module '@elastic/eui' { | |
export type x = EuiRadioGroupProps['onChange']; | ||
|
||
export const EuiRadioGroup: SFC<EuiRadioGroupProps>; | ||
|
||
export interface EuiRadioProps { | ||
autoFocus?: boolean; | ||
compressed?: boolean; | ||
label?: ReactNode; | ||
onChange: ChangeEventHandler<HTMLInputElement>; // overriding to make it required | ||
} | ||
|
||
export const EuiRadio: SFC< | ||
CommonProps & InputHTMLAttributes<HTMLInputElement> & EuiRadioProps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference path="../../common.d.ts" /> | ||
|
||
import { SFC, ReactNode, HTMLAttributes, ChangeEventHandler, InputHTMLAttributes } from 'react'; | ||
|
||
declare module '@elastic/eui' { | ||
/** | ||
* @see './range.js' | ||
*/ | ||
|
||
export type EuiRangeLevelColor = 'primary' | 'success' | 'warning' | 'danger'; | ||
|
||
export interface EuiRangeProps { | ||
compressed?: boolean; | ||
fullWidth?: boolean; | ||
id?: string; | ||
levels?: Array<{ min?: number; max?: number; color?: EuiRangeLevelColor }>; | ||
showInput?: boolean; | ||
showLabels?: boolean; | ||
showRange?: boolean; | ||
showTicks?: boolean; | ||
showValue?: boolean; | ||
tickInterval?: number; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
export const EuiRange: SFC< | ||
CommonProps & InputHTMLAttributes<HTMLInputElement> & EuiRangeProps | ||
>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add
disabled
andname
to the radio group's proptypes as well, so they're included in the documentation & runtime checks.