From bf3295a6cff3b8ef5a7f03c2a31a64a4eeaf34dc Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Mon, 15 Oct 2018 17:22:30 +0100 Subject: [PATCH] Add missing TS defs and fixing existing def (#1240) * Add missing TS defs and fixing existing def Add TypeScript definitions for: - `EuiFieldNumber` - `EuiFormLabel` - `EuiSelect` Fix the `EuiTextColor` definition. --- CHANGELOG.md | 1 + src/components/form/field_number/index.d.ts | 26 +++++++++++++++++++++ src/components/form/form_label/index.d.ts | 17 ++++++++++++++ src/components/form/index.d.ts | 5 +++- src/components/form/select/index.d.ts | 26 +++++++++++++++++++++ src/components/text/index.d.ts | 15 ++++++++---- 6 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/components/form/field_number/index.d.ts create mode 100644 src/components/form/form_label/index.d.ts create mode 100644 src/components/form/select/index.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9690dbaf179..eff80607d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Add TypeScript definitions for `EuiFieldNumber, `EuiFormLabel` and `EuiSelect`, and fix the `EuiTextColor` definition. ([#1240](https://github.com/elastic/eui/pull/1240)) - Added support for nodes as column headers in `EuiBasicTable` for supporting things like tooltips and localized text. ([#1234](https://github.com/elastic/eui/pull/1234)) ## [`4.4.1`](https://github.com/elastic/eui/tree/v4.4.1) diff --git a/src/components/form/field_number/index.d.ts b/src/components/form/field_number/index.d.ts new file mode 100644 index 00000000000..3e767d1c3e1 --- /dev/null +++ b/src/components/form/field_number/index.d.ts @@ -0,0 +1,26 @@ +/// +/// + +import { ReactNode, SFC, InputHTMLAttributes } from 'react'; + +declare module '@elastic/eui' { + + /** + * text field type defs + * + * @see './field_number.js' + */ + export interface EuiFieldNumberProps { + icon?: IconType; + isInvalid?: boolean; + fullWidth?: boolean; + isLoading?: boolean; + compressed?: boolean; + prepend?: ReactNode | ReactNode[]; + append?: ReactNode | ReactNode[]; + } + + export const EuiFieldNumber: SFC< + CommonProps & InputHTMLAttributes & EuiFieldNumberProps + >; +} diff --git a/src/components/form/form_label/index.d.ts b/src/components/form/form_label/index.d.ts new file mode 100644 index 00000000000..90f95f3a5b8 --- /dev/null +++ b/src/components/form/form_label/index.d.ts @@ -0,0 +1,17 @@ +/// + +import { SFC, ReactNode, LabelHTMLAttributes } from 'react'; + +declare module '@elastic/eui' { + /** + * @see './form_label.js' + */ + + export type EuiFormLabelProps = CommonProps & + LabelHTMLAttributes & { + isFocused?: boolean; + isInvalid?: boolean; + }; + + export const EuiFormLabel: SFC; +} diff --git a/src/components/form/index.d.ts b/src/components/form/index.d.ts index 5e67b76d2ba..f5cf502b1c4 100644 --- a/src/components/form/index.d.ts +++ b/src/components/form/index.d.ts @@ -1,7 +1,10 @@ /// -/// +/// /// +/// +/// /// /// +/// /// /// diff --git a/src/components/form/select/index.d.ts b/src/components/form/select/index.d.ts new file mode 100644 index 00000000000..e7d7d83abc7 --- /dev/null +++ b/src/components/form/select/index.d.ts @@ -0,0 +1,26 @@ +/// + +import {SFC, ReactNode, Ref, OptionHTMLAttributes, SelectHTMLAttributes} from 'react'; + +declare module '@elastic/eui' { + /** + * @see './select.js' + */ + + export type EuiSelectProps = CommonProps & + SelectHTMLAttributes & { + name?: string; + id?: string; + options: Array<{ text: ReactNode } & OptionHTMLAttributes>; + isInvalid?: boolean; + fullWidth?: boolean; + isLoading?: boolean; + hasNoInitialSelection?: boolean; + inputRef?: Ref; + compressed?: boolean; + prepend?: ReactNode | ReactNode[]; + append?: ReactNode | ReactNode[]; + }; + + export const EuiSelect: SFC; +} diff --git a/src/components/text/index.d.ts b/src/components/text/index.d.ts index f9a01ba4e89..cb90f56fdf5 100644 --- a/src/components/text/index.d.ts +++ b/src/components/text/index.d.ts @@ -9,9 +9,9 @@ declare module '@elastic/eui' { * @see './text.js' * @see './text_color.js' */ - type EuiTextSize = 's' | 'xs'; + type SIZES = 's' | 'xs'; - type EuiTextColor = + type COLORS = | 'default' | 'subdued' | 'secondary' @@ -22,9 +22,16 @@ declare module '@elastic/eui' { type EuiTextProps = CommonProps & HTMLAttributes & { - size?: EuiTextSize; - color?: EuiTextColor; + size?: SIZES; + color?: COLORS; }; + type EuiTextColorProps = CommonProps & + HTMLAttributes & + HTMLAttributes & { + color?: COLORS; + }; + export const EuiText: SFC; + export const EuiTextColor: SFC; }