Skip to content

Commit

Permalink
Add typescript definitions for more components
Browse files Browse the repository at this point in the history
  • Loading branch information
weltenwort committed Jan 19, 2018
1 parent fd61c69 commit 2217976
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/form/form_row/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference path="../../common.d.ts" />

import { SFC, ReactNode, HTMLAttributes } from 'react';

declare module '@elastic/eui' {
/**
* @see './form_row.js'
*/

export type EuiFormRowProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
error?: string | string[];
fullWidth?: boolean;
hasEmptyLabelSpace?: boolean;
helpText?: ReactNode;
isInvalid?: boolean;
label?: ReactNode;
};

export const EuiFormRow: SFC<EuiFormRowProps>;
}
3 changes: 3 additions & 0 deletions src/components/form/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/// <reference path="./checkbox/index.d.ts" />
/// <reference path="./field_search/index.d.ts" />
/// <reference path="./form_row/index.d.ts" />
/// <reference path="./radio/index.d.ts" />
/// <reference path="./switch/index.d.ts" />
26 changes: 26 additions & 0 deletions src/components/form/radio/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference path="../../common.d.ts" />

import { SFC, HTMLAttributes, ReactNode } from 'react';

declare module '@elastic/eui' {
/**
* @see './radio_group.js'
*/
export interface EuiRadioGroupOption {
id: string;
label?: ReactNode;
}

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

export type EuiRadioGroupProps = CommonProps &
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> & {
options?: EuiRadioGroupOption[];
idSelected?: string;
onChange: (id: string) => void;
};

export type x = EuiRadioGroupProps['onChange'];

export const EuiRadioGroup: SFC<EuiRadioGroupProps>;
}
18 changes: 18 additions & 0 deletions src/components/form/switch/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="../../common.d.ts" />

import { SFC, InputHTMLAttributes, ReactNode } from 'react';

declare module '@elastic/eui' {
/**
* @see './switch.js'
*/
export type EuiSwitchChangeCallback = (state: boolean) => void;

export type EuiSwitchProps = CommonProps &
Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
label?: ReactNode;
onChange?: EuiSwitchChangeCallback;
};

export const EuiSwitch: SFC<EuiSwitchProps>;
}
2 changes: 2 additions & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
/// <reference path="./spacer/index.d.ts" />
/// <reference path="./pagination/index.d.ts" />
/// <reference path="./link/index.d.ts" />
/// <reference path="./loading/index.d.ts" />
/// <reference path="./progress/index.d.ts" />
30 changes: 30 additions & 0 deletions src/components/loading/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference path="../common.d.ts" />

import { SFC, HTMLAttributes } from 'react';

declare module '@elastic/eui' {
/**
* @see './loading_spinner.js'
*/
export type EuiLoadingSpinnerSize = 's' | 'm' | 'l' | 'xl';

export type EuiLoadingSpinnerProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
size?: EuiLoadingSpinnerSize;
};

export const EuiLoadingSpinner: SFC<EuiLoadingSpinnerProps>;

/**
* @see './loading_chart.js'
*/
export type EuiLoadingChartSize = 'm' | 'l' | 'xl';

export type EuiLoadingChartProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
mono?: boolean;
size?: EuiLoadingChartSize;
};

export const EuiLoadingChart: SFC<EuiLoadingChartProps>;
}
29 changes: 29 additions & 0 deletions src/components/progress/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// <reference path="../common.d.ts" />

import { SFC, HTMLAttributes } from 'react';

declare module '@elastic/eui' {
/**
* @see './progress.js'
*/
export type EuiProgressColor =
| 'accent'
| 'danger'
| 'primary'
| 'secondar'
| 'subdued';

export type EuiProgressSize = 'xs' | 's' | 'm' | 'l';

export type EuiProgressPosition = 'fixed' | 'absolute' | 'static';

export type EuiProgressProps = CommonProps &
HTMLAttributes<HTMLProgressElement> & {
size?: EuiProgressSize;
color?: EuiProgressColor;
position?: EuiProgressPosition;
max?: number;
};

export const EuiProgress: SFC<EuiProgressProps>;
}

0 comments on commit 2217976

Please sign in to comment.