From 2217976a38aff997ca64e77605a58a08b0c1968e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20St=C3=BCrmer?= Date: Fri, 19 Jan 2018 19:27:10 +0100 Subject: [PATCH] Add typescript definitions for more components --- src/components/form/form_row/index.d.ts | 21 +++++++++++++++++ src/components/form/index.d.ts | 3 +++ src/components/form/radio/index.d.ts | 26 +++++++++++++++++++++ src/components/form/switch/index.d.ts | 18 +++++++++++++++ src/components/index.d.ts | 2 ++ src/components/loading/index.d.ts | 30 +++++++++++++++++++++++++ src/components/progress/index.d.ts | 29 ++++++++++++++++++++++++ 7 files changed, 129 insertions(+) create mode 100644 src/components/form/form_row/index.d.ts create mode 100644 src/components/form/radio/index.d.ts create mode 100644 src/components/form/switch/index.d.ts create mode 100644 src/components/loading/index.d.ts create mode 100644 src/components/progress/index.d.ts diff --git a/src/components/form/form_row/index.d.ts b/src/components/form/form_row/index.d.ts new file mode 100644 index 000000000000..b2eb7becdf3a --- /dev/null +++ b/src/components/form/form_row/index.d.ts @@ -0,0 +1,21 @@ +/// + +import { SFC, ReactNode, HTMLAttributes } from 'react'; + +declare module '@elastic/eui' { + /** + * @see './form_row.js' + */ + + export type EuiFormRowProps = CommonProps & + HTMLAttributes & { + error?: string | string[]; + fullWidth?: boolean; + hasEmptyLabelSpace?: boolean; + helpText?: ReactNode; + isInvalid?: boolean; + label?: ReactNode; + }; + + export const EuiFormRow: SFC; +} diff --git a/src/components/form/index.d.ts b/src/components/form/index.d.ts index 9f634983baa9..1c2d5c4b02e1 100644 --- a/src/components/form/index.d.ts +++ b/src/components/form/index.d.ts @@ -1,2 +1,5 @@ /// /// +/// +/// +/// diff --git a/src/components/form/radio/index.d.ts b/src/components/form/radio/index.d.ts new file mode 100644 index 000000000000..056611d774be --- /dev/null +++ b/src/components/form/radio/index.d.ts @@ -0,0 +1,26 @@ +/// + +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, 'onChange'> & { + options?: EuiRadioGroupOption[]; + idSelected?: string; + onChange: (id: string) => void; + }; + + export type x = EuiRadioGroupProps['onChange']; + + export const EuiRadioGroup: SFC; +} diff --git a/src/components/form/switch/index.d.ts b/src/components/form/switch/index.d.ts new file mode 100644 index 000000000000..2e6aac981848 --- /dev/null +++ b/src/components/form/switch/index.d.ts @@ -0,0 +1,18 @@ +/// + +import { SFC, InputHTMLAttributes, ReactNode } from 'react'; + +declare module '@elastic/eui' { + /** + * @see './switch.js' + */ + export type EuiSwitchChangeCallback = (state: boolean) => void; + + export type EuiSwitchProps = CommonProps & + Omit, 'onChange'> & { + label?: ReactNode; + onChange?: EuiSwitchChangeCallback; + }; + + export const EuiSwitch: SFC; +} diff --git a/src/components/index.d.ts b/src/components/index.d.ts index 6a028a074999..709b3b456cf7 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -10,3 +10,5 @@ /// /// /// +/// +/// diff --git a/src/components/loading/index.d.ts b/src/components/loading/index.d.ts new file mode 100644 index 000000000000..5ae707dfee0d --- /dev/null +++ b/src/components/loading/index.d.ts @@ -0,0 +1,30 @@ +/// + +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 & { + size?: EuiLoadingSpinnerSize; + }; + + export const EuiLoadingSpinner: SFC; + + /** + * @see './loading_chart.js' + */ + export type EuiLoadingChartSize = 'm' | 'l' | 'xl'; + + export type EuiLoadingChartProps = CommonProps & + HTMLAttributes & { + mono?: boolean; + size?: EuiLoadingChartSize; + }; + + export const EuiLoadingChart: SFC; +} diff --git a/src/components/progress/index.d.ts b/src/components/progress/index.d.ts new file mode 100644 index 000000000000..82284388c42c --- /dev/null +++ b/src/components/progress/index.d.ts @@ -0,0 +1,29 @@ +/// + +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 & { + size?: EuiProgressSize; + color?: EuiProgressColor; + position?: EuiProgressPosition; + max?: number; + }; + + export const EuiProgress: SFC; +}