From dc016bee43e7abc70f016840b1be7f33caae7d8d Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 10 Jul 2018 13:16:54 -0700 Subject: [PATCH 1/5] [types/EuiButtonEmpty] add missing isLoading and href props --- src/components/button/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/button/index.d.ts b/src/components/button/index.d.ts index 74785e7ca88..55e6af4debb 100644 --- a/src/components/button/index.d.ts +++ b/src/components/button/index.d.ts @@ -81,6 +81,8 @@ declare module '@elastic/eui' { size?: EmptyButtonSizes; flush?: EmptyButtonFlush; isDisabled?: boolean; + isLoading?: boolean; + href?: string; } export const EuiButtonEmpty: SFC< From a095a46da8826cbdac22a2a0c98c205eeb2ce1fc Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 10 Jul 2018 16:34:52 -0700 Subject: [PATCH 2/5] [types/EuiButton] expand element types to include HTMLAnchorElement --- src/components/button/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/button/index.d.ts b/src/components/button/index.d.ts index 55e6af4debb..c372527b75d 100644 --- a/src/components/button/index.d.ts +++ b/src/components/button/index.d.ts @@ -1,7 +1,7 @@ /// /// -import { SFC, ButtonHTMLAttributes, MouseEventHandler } from 'react'; +import { SFC, ButtonHTMLAttributes, AnchorHTMLAttributes } from 'react'; declare module '@elastic/eui' { /** @@ -20,17 +20,17 @@ declare module '@elastic/eui' { export type ButtonSize = 's' | 'l'; export interface EuiButtonProps { - onClick: MouseEventHandler; //overriding DOMAttributes to make this required iconType?: IconType; iconSide?: ButtonIconSide; fill?: boolean; color?: ButtonColor; size?: ButtonSize; + isLoading?: boolean; isDisabled?: boolean; + href?: string; } - export const EuiButton: SFC< - CommonProps & ButtonHTMLAttributes & EuiButtonProps + CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonProps >; /** @@ -47,15 +47,15 @@ declare module '@elastic/eui' { | 'text'; export interface EuiButtonIconProps { - onClick: MouseEventHandler; //overriding DOMAttributes to make this required iconType?: IconType; color?: ButtonIconColor; - isDisabled?: boolean; 'aria-label'?: string; 'aria-labelledby'?: string; + isDisabled?: boolean; + href?: string; } export const EuiButtonIcon: SFC< - CommonProps & ButtonHTMLAttributes & EuiButtonIconProps + CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonIconProps >; /** @@ -80,12 +80,12 @@ declare module '@elastic/eui' { color?: EmptyButtonColor; size?: EmptyButtonSizes; flush?: EmptyButtonFlush; - isDisabled?: boolean; isLoading?: boolean; + isDisabled?: boolean; href?: string; } export const EuiButtonEmpty: SFC< - CommonProps & ButtonHTMLAttributes & EuiButtonEmptyProps + CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonEmptyProps >; } From 9abae9503994518816f5305b7702d1c271330558 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 10 Jul 2018 17:47:29 -0700 Subject: [PATCH 3/5] [types/EuiButton*] rely on AnchorHTMLAttributes for href prop --- src/components/button/index.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/button/index.d.ts b/src/components/button/index.d.ts index c372527b75d..9fbfce85dbb 100644 --- a/src/components/button/index.d.ts +++ b/src/components/button/index.d.ts @@ -27,7 +27,6 @@ declare module '@elastic/eui' { size?: ButtonSize; isLoading?: boolean; isDisabled?: boolean; - href?: string; } export const EuiButton: SFC< CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonProps @@ -52,7 +51,6 @@ declare module '@elastic/eui' { 'aria-label'?: string; 'aria-labelledby'?: string; isDisabled?: boolean; - href?: string; } export const EuiButtonIcon: SFC< CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonIconProps @@ -82,7 +80,6 @@ declare module '@elastic/eui' { flush?: EmptyButtonFlush; isLoading?: boolean; isDisabled?: boolean; - href?: string; } export const EuiButtonEmpty: SFC< From 4c3c785add319a4a9b27ba6d17483b68d3c2e4ee Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 10 Jul 2018 17:50:03 -0700 Subject: [PATCH 4/5] mention changes in CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d83dc30eaaa..d3f78cb3269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Added beta version of `EuiXYChart` and associated components ([#309](https://github.com/elastic/eui/pull/309)) - Added `size` prop to `EuiIconTip` ([987](https://github.com/elastic/eui/pull/987)) - Added `database`, `filter`, `globe`, and `save` icons ([990](https://github.com/elastic/eui/pull/990)) +- Updated typings for `EuiButton`, `EuiButtonEmpty`, and `EuiButtonIcon` to include `` tag attributes like `href` ([#992](https://github.com/elastic/eui/pull/992)) **Bug fixes** From 53398b02c5ed5aac142458806f5c43047b640d37 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 10 Jul 2018 18:17:25 -0700 Subject: [PATCH 5/5] [types/EuiButton*] conditionally include HTMLAttributes based on href/onClick props --- src/components/button/index.d.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/button/index.d.ts b/src/components/button/index.d.ts index 9fbfce85dbb..a67acfe3b1b 100644 --- a/src/components/button/index.d.ts +++ b/src/components/button/index.d.ts @@ -1,9 +1,15 @@ /// /// -import { SFC, ButtonHTMLAttributes, AnchorHTMLAttributes } from 'react'; +import { SFC, ButtonHTMLAttributes, AnchorHTMLAttributes, MouseEventHandler } from 'react'; declare module '@elastic/eui' { + type EuiButtonPropsForButtonOrLink = ( + (Props & { onClick: MouseEventHandler } & ButtonHTMLAttributes) | + (Props & { href: string; onClick: MouseEventHandler } & AnchorHTMLAttributes) | + (Props & AnchorHTMLAttributes & ButtonHTMLAttributes) + ) + /** * Normal button type defs * @@ -29,7 +35,7 @@ declare module '@elastic/eui' { isDisabled?: boolean; } export const EuiButton: SFC< - CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonProps + EuiButtonPropsForButtonOrLink >; /** @@ -53,7 +59,7 @@ declare module '@elastic/eui' { isDisabled?: boolean; } export const EuiButtonIcon: SFC< - CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonIconProps + EuiButtonPropsForButtonOrLink >; /** @@ -83,6 +89,6 @@ declare module '@elastic/eui' { } export const EuiButtonEmpty: SFC< - CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes & EuiButtonEmptyProps + EuiButtonPropsForButtonOrLink >; }