From f44527673af2713cf7754a57e03b28f1d1651eca Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 16:34:54 -0700 Subject: [PATCH 1/7] [types] add types for EuiEmptyPrompt --- src/components/empty_prompt/index.d.ts | 26 ++++++++++++++++++++++++++ src/components/index.d.ts | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/components/empty_prompt/index.d.ts diff --git a/src/components/empty_prompt/index.d.ts b/src/components/empty_prompt/index.d.ts new file mode 100644 index 00000000000..912e2dcb240 --- /dev/null +++ b/src/components/empty_prompt/index.d.ts @@ -0,0 +1,26 @@ +/// +/// +/// + +import { SFC, ReactNode, HTMLAttributes } from 'react'; + +declare module '@elastic/eui' { + /** + * EuiEmptyPrompt type defs + * + * @see './empty_prompt.js' + */ + + export interface EuiEmptyPromptProps { + iconType?: IconType; + iconColor?: IconColor; + title?: ReactNode; + titleSize?: EuiTitleSize; + body?: ReactNode; + actions?: ReactNode; + } + + export const EuiEmptyPrompt: SFC< + CommonProps & EuiEmptyPromptProps & HTMLAttributes + >; +} diff --git a/src/components/index.d.ts b/src/components/index.d.ts index 082845d03d0..17c0cf7d823 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -21,3 +21,4 @@ /// /// /// +/// From 9397296186d2bf43741e0827e3f083012f571017 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 16:42:44 -0700 Subject: [PATCH 2/7] [types] add types for EuiCode and EuiCodeBlock --- src/components/code/index.d.ts | 57 ++++++++++++++++++++++++++++++++++ src/components/index.d.ts | 1 + 2 files changed, 58 insertions(+) create mode 100644 src/components/code/index.d.ts diff --git a/src/components/code/index.d.ts b/src/components/code/index.d.ts new file mode 100644 index 00000000000..a1e3d134747 --- /dev/null +++ b/src/components/code/index.d.ts @@ -0,0 +1,57 @@ +/// + +import { SFC, HTMLAttributes } from 'react'; + +declare module '@elastic/eui' { + type FontSize = 's' | 'm' | 'l'; + type PaddingSize = 'none' | 's' | 'm' | 'l'; + + // there isn't a specific type for the element, and MDN + // says that it only supports the HTMLElement interface + // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code + type HTMLCodeElement = HTMLElement + + interface EuiCodeSharedProps { + paddingSize?: PaddingSize; + + /** + * Sets the syntax highlighting for a specific language + * See http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases + * for options + */ + language?: string; + + overflowHeight?: number; + fontSize?: FontSize; + transparentBackground?: boolean; + } + + + /** + * EuiCode type defs + * + * @see './code.js' + */ + + export interface EuiCodeProps extends EuiCodeSharedProps { + inline?: true + } + + export const EuiCode: SFC< + CommonProps & EuiCodeProps & HTMLAttributes + >; + + /** + * EuiCodeBlock type defs + * + * @see './code_block.js' + */ + + export interface EuiCodeBlockProps extends EuiCodeSharedProps { + inline?: false + } + + export const EuiCodeBlock: SFC< + CommonProps & EuiCodeBlockProps & HTMLAttributes + >; +} diff --git a/src/components/index.d.ts b/src/components/index.d.ts index 17c0cf7d823..a7592349c6c 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -22,3 +22,4 @@ /// /// /// +/// From 042560fa0a5d1439aa888403fe32dc2c4247b020 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 16:47:38 -0700 Subject: [PATCH 3/7] [types] add types for EuiCallOut --- src/components/call_out/index.d.ts | 26 ++++++++++++++++++++++++++ src/components/index.d.ts | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/components/call_out/index.d.ts diff --git a/src/components/call_out/index.d.ts b/src/components/call_out/index.d.ts new file mode 100644 index 00000000000..4746156bf52 --- /dev/null +++ b/src/components/call_out/index.d.ts @@ -0,0 +1,26 @@ +/// +/// + +import { SFC, ReactNode, HTMLAttributes } from 'react'; + +declare module '@elastic/eui' { + /** + * EuiCallOut type defs + * + * @see './code.js' + */ + + type Color = 'primary' | 'success' | 'warning' | 'danger'; + type Size = 's' | 'm'; + + export interface EuiCallOutProps { + title?: ReactNode, + iconType?: IconType, + color?: Color, + size?: Size, + } + + export const EuiCallOut: SFC< + CommonProps & EuiCallOutProps & HTMLAttributes + >; +} diff --git a/src/components/index.d.ts b/src/components/index.d.ts index a7592349c6c..b34302413fa 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -23,3 +23,4 @@ /// /// /// +/// From 93886bfff1874572a92dc652ab99998b5b97cea5 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 17:07:24 -0700 Subject: [PATCH 4/7] add note to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6de4c1dedcb..1119b0f2309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Make some proprties of `EuiFlyout` optional ([#1003](https://github.com/elastic/eui/pull/1003)) - Add typings for `EuiFlyout`, `EuiFlyoutBody`, `EuiFlyoutHeader`, and `EuiFlyoutFooter` ([#1001](https://github.com/elastic/eui/pull/1001)) - Gave `EuiFlyout` close button a data-test-subj ([#1000](https://github.com/elastic/eui/pull/1000)) +- Add typings for `EuiEmptyPrompt`, `EuiCode`, `EuiCodeBlock`, and `EuiCallOut` ([#1010](https://github.com/elastic/eui/pull/1010)) **Breaking changes** From ecf2de396ba68b7e6961cbdd757e930dd38d09c7 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 17:22:46 -0700 Subject: [PATCH 5/7] [types/EuiEmptyPrompt] remove HTMLAttributes<> to avoid collision at "title" prop --- src/components/empty_prompt/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/empty_prompt/index.d.ts b/src/components/empty_prompt/index.d.ts index 912e2dcb240..9c4a028e212 100644 --- a/src/components/empty_prompt/index.d.ts +++ b/src/components/empty_prompt/index.d.ts @@ -2,7 +2,7 @@ /// /// -import { SFC, ReactNode, HTMLAttributes } from 'react'; +import { SFC, ReactNode } from 'react'; declare module '@elastic/eui' { /** @@ -21,6 +21,8 @@ declare module '@elastic/eui' { } export const EuiEmptyPrompt: SFC< - CommonProps & EuiEmptyPromptProps & HTMLAttributes + CommonProps & EuiEmptyPromptProps >; + + } From b22189b9e924086dec8cfa577c75e1024d057f1f Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 18:03:36 -0700 Subject: [PATCH 6/7] [types/EuiEmptyPrompt] re-enable HTMLAttributes, but omit "title" attribute --- src/components/empty_prompt/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/empty_prompt/index.d.ts b/src/components/empty_prompt/index.d.ts index 9c4a028e212..920ae94c94d 100644 --- a/src/components/empty_prompt/index.d.ts +++ b/src/components/empty_prompt/index.d.ts @@ -2,7 +2,7 @@ /// /// -import { SFC, ReactNode } from 'react'; +import { SFC, ReactNode, HTMLAttributes } from 'react'; declare module '@elastic/eui' { /** @@ -21,7 +21,7 @@ declare module '@elastic/eui' { } export const EuiEmptyPrompt: SFC< - CommonProps & EuiEmptyPromptProps + CommonProps & EuiEmptyPromptProps & Omit, 'title'> >; From c56ed8628ac11ea5bbc1b6a0b1e47548e9eebd6c Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 18:05:39 -0700 Subject: [PATCH 7/7] [types/EuiCallOut] omit "title" attribute from HTMLAttributes --- src/components/call_out/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/call_out/index.d.ts b/src/components/call_out/index.d.ts index 4746156bf52..74b343ac68e 100644 --- a/src/components/call_out/index.d.ts +++ b/src/components/call_out/index.d.ts @@ -21,6 +21,6 @@ declare module '@elastic/eui' { } export const EuiCallOut: SFC< - CommonProps & EuiCallOutProps & HTMLAttributes + CommonProps & EuiCallOutProps & Omit, 'title'> >; }