From 9856e945f3ce5de6b510e4d717006a9dc62cfe5c Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Wed, 7 Nov 2018 10:01:22 +0000 Subject: [PATCH 1/5] Badge and popover title TS defs --- src/components/badge/index.d.ts | 27 +++++++++++++++++++++++- src/components/error_boundary/index.d.ts | 9 ++++++++ src/components/index.d.ts | 1 + src/components/popover/index.d.ts | 4 ++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/components/error_boundary/index.d.ts diff --git a/src/components/badge/index.d.ts b/src/components/badge/index.d.ts index 783c8c7495c..ab98c45d56f 100644 --- a/src/components/badge/index.d.ts +++ b/src/components/badge/index.d.ts @@ -1,6 +1,7 @@ /// +/// -import { HTMLAttributes, MouseEventHandler, SFC } from 'react'; +import { HTMLAttributes, MouseEventHandler, SFC, ReactNode } from 'react'; declare module '@elastic/eui' { @@ -20,4 +21,28 @@ declare module '@elastic/eui' { export const EuiBadge: SFC< CommonProps & HTMLAttributes & HTMLAttributes & EuiBadgeProps >; + + export interface EuiBetaBadgeProps { + iconType?: IconType; + label: ReactNode; + tooltipContent?: ReactNode; + tooltipPosition?: ToolTipPositions; + title?: string; + } + + export const EuiBetaBadge: SFC< + CommonProps & HTMLAttributes & HTMLAttributes & EuiBetaBadgeProps + >; + + export interface EuiNotificationBadgeProps { + iconType?: IconType; + label: ReactNode; + tooltipContent?: ReactNode; + tooltipPosition?: ToolTipPositions; + title?: string; + } + + export const EuiNotificationBadge: SFC< + CommonProps & HTMLAttributes & HTMLAttributes + >; } diff --git a/src/components/error_boundary/index.d.ts b/src/components/error_boundary/index.d.ts new file mode 100644 index 00000000000..813200d82c7 --- /dev/null +++ b/src/components/error_boundary/index.d.ts @@ -0,0 +1,9 @@ +/// + +import { HTMLAttributes, Component } from 'react'; + +declare module '@elastic/eui' { + export class EuiErrorBoundary extends Component< + CommonProps & HTMLAttributes + > {} +} diff --git a/src/components/index.d.ts b/src/components/index.d.ts index d98c980af40..09511c669f3 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -10,6 +10,7 @@ /// /// /// +/// /// /// /// diff --git a/src/components/popover/index.d.ts b/src/components/popover/index.d.ts index 51622c122e0..2e58d8f837d 100644 --- a/src/components/popover/index.d.ts +++ b/src/components/popover/index.d.ts @@ -40,4 +40,8 @@ declare module '@elastic/eui' { export const EuiPopover: SFC< CommonProps & HTMLAttributes & EuiPopoverProps >; + + export const EuiPopoverTitle: SFC< + CommonProps & HTMLAttributes + >; } From 30552d487df2e8f81372b40f74c60188a0fce26e Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Thu, 8 Nov 2018 09:07:01 +0000 Subject: [PATCH 2/5] Include tab TS defs in index, plus build fix Ensure tab TS definitions are included in the main definition index. The definitions were added in a previous PR, but not included in the main index.d.ts file. Also fix an issue in the build where a required directly wasn't being created. --- CHANGELOG.md | 5 +---- scripts/compile-eui.js | 7 +++---- src/components/index.d.ts | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8da06cadf09..162fa836f95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ **Bug fixes** - Fixed size of `EuiSuperSelect`'s dropdown menu when there is no initial selection ([#1295](https://github.com/elastic/eui/pull/1295)) +- Added TypeScript definitions for `EuiPopoverTitle` and the beta and notification badges. Ensure tab TS definitions are included in the main definition index. ([#1299](https://github.com/elastic/eui/pull/1299)) ## [`5.0.0`](https://github.com/elastic/eui/tree/v5.0.0) @@ -27,10 +28,6 @@ **Bug fixes** -- Added TypeScript definitions for `EuiToolTip`'s `delay` prop. ([#1284](https://github.com/elastic/eui/pull/1284)) - -**Bug fixes** - - Added TypeScript definitions for `EuiToolTip`'s `delay` prop. ([#1284](https://github.com/elastic/eui/pull/1284)) - Added TypeScript definitions for step components, and some checkbox definition fixes ([#1263](https://github.com/elastic/eui/pull/1263)) diff --git a/scripts/compile-eui.js b/scripts/compile-eui.js index b10967959d2..215ca3c991d 100755 --- a/scripts/compile-eui.js +++ b/scripts/compile-eui.js @@ -4,7 +4,7 @@ const shell = require('shelljs'); const glob = require('glob'); function compileLib() { - shell.mkdir('-p', 'lib/components', 'lib/services', 'lib/test'); + shell.mkdir('-p', 'lib/components/icon/assets/tokens', 'lib/services', 'lib/test'); console.log('Compiling src/ to es/ and lib/'); @@ -16,15 +16,14 @@ function compileLib() { console.log(chalk.green('✔ Finished compiling src/')); - // Also copy over SVGs. Babel has a --copy-files option but that brings over - // all kinds of things we don't want into the lib folder. + // Also copy over SVGs. Babel has a --copy-files option but that brings over + // all kinds of things we don't want into the lib folder. shell.mkdir('-p', 'lib/components/icon/assets'); glob('./src/components/**/*.svg', undefined, (error, files) => { files.forEach(file => { const splitPath = file.split('/'); const basePath = splitPath.slice(2, splitPath.length).join('/'); - console.log(basePath) shell.cp('-f', `${file}`, `lib/${basePath}`); }); diff --git a/src/components/index.d.ts b/src/components/index.d.ts index 09511c669f3..1f52035a509 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -31,6 +31,7 @@ /// /// /// +/// /// /// /// From e1d9acb4f22729be8f7bd6ec9c750226c9ade799 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Thu, 8 Nov 2018 16:01:21 +0000 Subject: [PATCH 3/5] Fix typo in icon types --- CHANGELOG.md | 2 +- src/components/icon/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 162fa836f95..922ca47534c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ **Bug fixes** - Fixed size of `EuiSuperSelect`'s dropdown menu when there is no initial selection ([#1295](https://github.com/elastic/eui/pull/1295)) -- Added TypeScript definitions for `EuiPopoverTitle` and the beta and notification badges. Ensure tab TS definitions are included in the main definition index. ([#1299](https://github.com/elastic/eui/pull/1299)) +- Added TypeScript definitions for `EuiPopoverTitle` and the beta and notification badges. Ensure tab TS definitions are included in the main definition index. Fix typo in icon types ([#1299](https://github.com/elastic/eui/pull/1299)) ## [`5.0.0`](https://github.com/elastic/eui/tree/v5.0.0) diff --git a/src/components/icon/index.d.ts b/src/components/icon/index.d.ts index 20f0f830324..3639ea66cb1 100644 --- a/src/components/icon/index.d.ts +++ b/src/components/icon/index.d.ts @@ -77,7 +77,7 @@ declare module '@elastic/eui' { | 'filter' | 'fullScreen' | 'gear' - | 'glob' + | 'globe' | 'grab' | 'graphApp' | 'grid' From 80c55bee99d4e712034735f485cba55532055d11 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Thu, 8 Nov 2018 16:11:34 +0000 Subject: [PATCH 4/5] Fix from review --- src/components/badge/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/badge/index.d.ts b/src/components/badge/index.d.ts index ab98c45d56f..383f55955d3 100644 --- a/src/components/badge/index.d.ts +++ b/src/components/badge/index.d.ts @@ -31,7 +31,7 @@ declare module '@elastic/eui' { } export const EuiBetaBadge: SFC< - CommonProps & HTMLAttributes & HTMLAttributes & EuiBetaBadgeProps + CommonProps & HTMLAttributes & HTMLAttributes & EuiBetaBadgeProps >; export interface EuiNotificationBadgeProps { @@ -43,6 +43,6 @@ declare module '@elastic/eui' { } export const EuiNotificationBadge: SFC< - CommonProps & HTMLAttributes & HTMLAttributes + CommonProps & HTMLAttributes & HTMLAttributes >; } From b1df1b32ce9cbcda9b67c9beb76bad5a727d6bd1 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Thu, 8 Nov 2018 16:14:24 +0000 Subject: [PATCH 5/5] Fix it again argh --- src/components/badge/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/badge/index.d.ts b/src/components/badge/index.d.ts index 383f55955d3..5d401789d82 100644 --- a/src/components/badge/index.d.ts +++ b/src/components/badge/index.d.ts @@ -31,7 +31,7 @@ declare module '@elastic/eui' { } export const EuiBetaBadge: SFC< - CommonProps & HTMLAttributes & HTMLAttributes & EuiBetaBadgeProps + CommonProps & HTMLAttributes & EuiBetaBadgeProps >; export interface EuiNotificationBadgeProps { @@ -43,6 +43,6 @@ declare module '@elastic/eui' { } export const EuiNotificationBadge: SFC< - CommonProps & HTMLAttributes & HTMLAttributes + CommonProps & HTMLAttributes >; }