From 64f9e6fdf4f646ec0de704fde146d3ebda49cd75 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Tue, 19 Mar 2019 08:42:44 +0100 Subject: [PATCH] Review feedback: Create union types to support full component options. --- src/components/list_group/index.d.ts | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/components/list_group/index.d.ts b/src/components/list_group/index.d.ts index 710cd426fd1..79438ba828b 100644 --- a/src/components/list_group/index.d.ts +++ b/src/components/list_group/index.d.ts @@ -1,7 +1,15 @@ import { EuiButtonIconProps, EuiButtonPropsForButtonOrLink } from '@elastic/eui'; import { IconType } from '../icon'; import { CommonProps } from '../common'; -import { FunctionComponent, ReactNode, ReactPropTypes } from 'react'; +import { + AnchorHTMLAttributes, + ButtonHTMLAttributes, + FunctionComponent, + HTMLAttributes, + MouseEventHandler, + ReactElement, + ReactNode +} from 'react'; declare module '@elastic/eui' { /** @@ -10,7 +18,7 @@ declare module '@elastic/eui' { * @see './list_group.js' */ - type EuiListGroupProps = CommonProps & { + type EuiListGroupProps = CommonProps & HTMLAttributes & { bordered?: boolean; flush?: boolean; listItems?: FunctionComponent[]; @@ -27,14 +35,14 @@ declare module '@elastic/eui' { * @see './list_group_item.js' */ - type EuiListGroupItemProps = CommonProps & { + type EuiListGroupItemProps = { size?: 'xs' | 's' | 'm' | 'l'; label: ReactNode; isActive?: boolean; isDisabled?: boolean; href?: string; iconType?: IconType; - icon?: ReactPropTypes['element']; + icon?: ReactElement; showToolTip?: boolean; extraAction?: EuiButtonPropsForButtonOrLink< CommonProps & @@ -47,5 +55,16 @@ declare module '@elastic/eui' { wrapText?: boolean; }; - export const EuiListGroupItem: FunctionComponent; + type EuiListGroupItemExtendedProps = EuiListGroupItemProps & CommonProps & ( + ({ + onClick: MouseEventHandler; + } & ButtonHTMLAttributes) | + ({ + href: string; + onClick: MouseEventHandler; + } & AnchorHTMLAttributes) | + HTMLAttributes + ); + + export const EuiListGroupItem: FunctionComponent; }