Skip to content

Commit

Permalink
Add missing TS defs and fixing existing def (#1240)
Browse files Browse the repository at this point in the history
* Add missing TS defs and fixing existing def

Add TypeScript definitions for:
- `EuiFieldNumber`
- `EuiFormLabel`
- `EuiSelect`

Fix the `EuiTextColor` definition.
  • Loading branch information
pugnascotia authored Oct 15, 2018
1 parent aa50e32 commit bf3295a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 26 additions & 0 deletions src/components/form/field_number/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference path="../../common.d.ts" />
/// <reference path="../../icon/index.d.ts" />

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<HTMLInputElement> & EuiFieldNumberProps
>;
}
17 changes: 17 additions & 0 deletions src/components/form/form_label/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path="../../common.d.ts" />

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

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

export type EuiFormLabelProps = CommonProps &
LabelHTMLAttributes<HTMLLabelElement> & {
isFocused?: boolean;
isInvalid?: boolean;
};

export const EuiFormLabel: SFC<EuiFormLabelProps>;
}
5 changes: 4 additions & 1 deletion src/components/form/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/// <reference path="./checkbox/index.d.ts" />
/// <reference path="./field_text/index.d.ts" />
/// <reference path="./field_number/index.d.ts" />
/// <reference path="./field_search/index.d.ts" />
/// <reference path="./field_text/index.d.ts" />
/// <reference path="./form_label/index.d.ts" />
/// <reference path="./form_row/index.d.ts" />
/// <reference path="./radio/index.d.ts" />
/// <reference path="./select/index.d.ts" />
/// <reference path="./switch/index.d.ts" />
/// <reference path="./text_area/index.d.ts" />
26 changes: 26 additions & 0 deletions src/components/form/select/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference path="../../common.d.ts" />

import {SFC, ReactNode, Ref, OptionHTMLAttributes, SelectHTMLAttributes} from 'react';

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

export type EuiSelectProps = CommonProps &
SelectHTMLAttributes<HTMLSelectElement> & {
name?: string;
id?: string;
options: Array<{ text: ReactNode } & OptionHTMLAttributes<HTMLOptionElement>>;
isInvalid?: boolean;
fullWidth?: boolean;
isLoading?: boolean;
hasNoInitialSelection?: boolean;
inputRef?: Ref<HTMLSelectElement>;
compressed?: boolean;
prepend?: ReactNode | ReactNode[];
append?: ReactNode | ReactNode[];
};

export const EuiSelect: SFC<EuiSelectProps>;
}
15 changes: 11 additions & 4 deletions src/components/text/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -22,9 +22,16 @@ declare module '@elastic/eui' {

type EuiTextProps = CommonProps &
HTMLAttributes<HTMLDivElement> & {
size?: EuiTextSize;
color?: EuiTextColor;
size?: SIZES;
color?: COLORS;
};

type EuiTextColorProps = CommonProps &
HTMLAttributes<HTMLDivElement> &
HTMLAttributes<HTMLSpanElement> & {
color?: COLORS;
};

export const EuiText: SFC<EuiTextProps>;
export const EuiTextColor: SFC<EuiTextColorProps>;
}

0 comments on commit bf3295a

Please sign in to comment.