Skip to content
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

[TypeScript] Updated existing and added additional TypeScript definitions #666

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Close `EuiComboBox` `singleSelection` options list when option is choosen ([#645](https://github.com/elastic/eui/pull/645))
- Wrap `EuiHorizontalStep` text instead of truncating it ([#653](https://github.com/elastic/eui/pull/653))
- Fixed a bug where `EuiSideNavItem` wouldn't pass an `onClick` handler down to `<a>` tags if they also had an `href`. ([#664](https://github.com/elastic/eui/pull/664))
- Updated existing and added additional TypeScript definitions ([#666](https://github.com/elastic/eui/pull/666))

**Breaking changes**

Expand Down
28 changes: 28 additions & 0 deletions src/components/form/field_text/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// <reference path="../../common.d.ts" />

import { SFC, InputHTMLAttributes } from 'react';

declare module '@elastic/eui' {

/**
* text field type defs
*
* @see './field_text.js'
*/
export interface EuiFieldTextProps {
name?: string;
id?: string;
placeholder?: string;
value?: string;
defaultValue?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The props name, id, placeholder, value and defaultValue are already part of React.InputHTMLAttributes<HTMLInputElement>.

icon?: string;
isInvalid?: boolean;
inputRef?: (ref: HTMLInputElement) => void;
fullWidth?: boolean;
isLoading?: boolean;
}

export const EuiFieldText: SFC<
CommonProps & InputHTMLAttributes<HTMLInputElement> & EuiFieldTextProps
>;
}
2 changes: 2 additions & 0 deletions src/components/form/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference path="./checkbox/index.d.ts" />
/// <reference path="./field_text/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" />
/// <reference path="./text_area/index.d.ts" />
26 changes: 26 additions & 0 deletions src/components/form/text_area/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference path="../../common.d.ts" />

import { SFC, TextareaHTMLAttributes } from 'react';

declare module '@elastic/eui' {

/**
* @see './text_area.js'
*/
export interface EuiTextAreaProps {
id?: string;
name?: string;
placeholder?: string;
rows?: number;
isInvalid?: boolean;
fullWidth?: boolean;
onChange?: (event: any) => void;
value?: string;
defaultValue?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties id, name, placeholder, rows, onChange, value and defaultValue are already defined in TextareaHTMLAttributes<HTMLTextAreaElement>.

inputRef?: (input: any) => void;
}

export const EuiTextArea: SFC<
CommonProps & TextareaHTMLAttributes & EuiTextAreaProps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that TextareaHTMLAttributes requires an argument (HTMLTextAreaElement in this case).

>;
}
27 changes: 27 additions & 0 deletions src/components/horizontal_rule/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference path="../common.d.ts" />

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

declare module '@elastic/eui' {

/**
* EuiHorizontalRule type defs
*
* @see './horizontal_rule.js'
*/

export type EuiHorizontalRuleSize = 'full' | 'half' | 'quarter';

export type EuiHorizontalRuleMargin = 'none' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';

export interface EuiHorizontalRuleProps {
children?: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children is already defined in DOMAttributes<T>, which is extended by HTMLAttributes<T>.

size?: EuiHorizontalRuleSize;
margin?: EuiHorizontalRuleMargin;
}

export const EuiHorizontalRule: SFC<
CommonProps & HTMLAttributes<HTMLHRElement> & EuiHorizontalRuleProps
>;

}
37 changes: 31 additions & 6 deletions src/components/icon/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import { SFC, SVGAttributes } from 'react';

declare module '@elastic/eui' {

/**
* icon type defs
*
* @see './icon.js'
*/

export type IconType =
| 'addDataApp'
| 'advancedSettingsApp'
Expand Down Expand Up @@ -37,34 +37,50 @@ declare module '@elastic/eui' {
| 'controlsVertical'
| 'copy'
| 'copyClipboard'
| 'createAdvancedJob'
| 'createMultiMetricJob'
| 'createPopulationJob'
| 'createSingleMetricJob'
| 'cross'
| 'dashboardApp'
| 'dataVisualizer'
| 'devToolsApp'
| 'discoverApp'
| 'document'
| 'dot'
| 'empty'
| 'exit'
| 'expand'
| 'exportAction'
| 'eyeClosed'
| 'eye'
| 'faceHappy'
| 'faceNeutral'
| 'faceSad'
| 'fullScreen'
| 'gear'
| 'grab'
| 'graphApp'
| 'grid'
| 'grokApp'
| 'heatmap'
| 'help'
| 'iInCircle'
| 'importAction'
| 'indexClose'
| 'indexEdit'
| 'indexFlush'
| 'indexMapping'
| 'indexOpen'
| 'indexSettings'
| 'indexPatternApp'
| 'inputOutput'
| 'indexSettings'
| 'invert'
| 'inputOutput'
| 'kqlField'
| 'kqlOperand'
| 'kqlValue'
| 'kqlFunction'
| 'kqlSelector'
| 'link'
| 'list'
| 'listAdd'
Expand All @@ -73,17 +89,27 @@ declare module '@elastic/eui' {
| 'logoApache'
| 'logoBeats'
| 'logoCloud'
| 'logoDocker'
| 'logoElastic'
| 'logoElasticSearch'
| 'logoElasticStack'
| 'logoGmail'
| 'logoGithub'
| 'logoKibana'
| 'logoKubernetes'
| 'logoLogstash'
| 'logoMySQL'
| 'logoNginx'
| 'logoRedis'
| 'logoSketch'
| 'logoSlack'
| 'logoWebhook'
| 'logoXpack'
| 'logstashFilter'
| 'logstashIf'
| 'logstashInput'
| 'logstashOutput'
| 'logstashQueue'
| 'machineLearningApp'
| 'managementApp'
| 'mapMarker'
Expand Down Expand Up @@ -129,6 +155,7 @@ declare module '@elastic/eui' {
| 'upgradeAssistantApp'
| 'user'
| 'usersRolesApp'
| 'vector'
| 'visualizeApp'
| 'watchesApp'
| 'wrench';
Expand All @@ -153,7 +180,5 @@ declare module '@elastic/eui' {
size?: IconSize;
}

export const EuiIcon: SFC<
CommonProps & SVGAttributes<SVGAElement> & EuiIconProps
>;
export const EuiIcon: SFC<CommonProps & SVGAttributes<SVGAElement> & EuiIconProps>;
}
4 changes: 4 additions & 0 deletions src/components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
/// <reference path="./portal/index.d.ts" />
/// <reference path="./title/index.d.ts" />
/// <reference path="./text/index.d.ts" />
/// <reference path="./modal/index.d.ts" />
/// <reference path="./overlay_mask/index.d.ts" />
/// <reference path="./horizontal_rule/index.d.ts" />
/// <reference path="./page/index.d.ts" />
12 changes: 12 additions & 0 deletions src/components/loading/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ declare module '@elastic/eui' {
};

export const EuiLoadingChart: SFC<EuiLoadingChartProps>;


/**
* @see './loading_kibana.js'
*/
export interface EuiLoadingKibanaProps {
size: 'm' | 'l' | 'xl';
}

export const EuiLoadingKibana: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiLoadingKibanaProps
>;
}
77 changes: 77 additions & 0 deletions src/components/modal/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/// <reference path="../common.d.ts" />

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

declare module '@elastic/eui' {

import { HTMLAttributes } from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports in module augmentations are not allowed. `HTMLAttributes' is already being imported in line 3.


/**
* Modal type defs
*
* @see './modal.js'
*/
export interface EuiModalProps {
className?: string;
children?: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties className and children are already part of CommonProps and DOMAttributes<T> respectively.

onClose: () => void;
}

export const EuiModal: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiModalProps
>;


/**
* @see './modal_body.js'
*/
export interface EuiModalBodyProps {
className?: string;
children?: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties are already defined in CommonAttributes and DOMAttributes respectively.

Copy link
Contributor Author

@uboness uboness Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall I still keep the empty EuiModalBodyProps just for consistency and documentation?

}

export const EuiModalBody: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiModalBodyProps
>;


/**
* @see './modal_footer.js'
*/
export interface EuiModalFooterProps {
className?: string;
children?: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties are already defined in CommonAttributes and DOMAttributes respectively.

}

export const EuiModalFooter: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiModalFooterProps
>;


/**
* @see './modal_header.js'
*/
export interface EuiModalHeaderProps {
className?: string;
children?: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties are already defined in CommonAttributes and DOMAttributes respectively.

}

export const EuiModalHeader: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiModalHeaderProps
>;


/**
* @see './modal_header_title.js'
*/
export interface EuiModalHeaderTitleProps {
className?: string;
children?: ReactNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties are already defined in CommonAttributes and DOMAttributes respectively.

}

export const EuiModalHeaderTitle: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiModalHeaderTitleProps
>;


}
22 changes: 22 additions & 0 deletions src/components/overlay_mask/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference path="../common.d.ts" />

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

declare module '@elastic/eui' {

/**
* EuiOverlayMask type defs
*
* @see './overlay_mask.js'
*/
export interface EuiOverlayMaskProps {
className?: string,
children?: ReactNode,
onClick?: () => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These properties are already defined in CommonAttributes and DOMAttributes respectively.

}

export const EuiOverlayMask: SFC<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiOverlayMaskProps
>;

}
Loading