From 805c1a428323bc9cf30ab9699dd22609c9a23c42 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Wed, 1 May 2019 14:10:52 -0400 Subject: [PATCH 1/3] Add type definitions to EuiSuperSelect #1752 --- CHANGELOG.md | 1 + src/components/form/index.d.ts | 1 + src/components/form/super_select/index.d.ts | 74 +++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 src/components/form/super_select/index.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index c1ab7ba4621..a75548a0948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Added `selectable` prop to `EuiCard` ([#1895](https://github.com/elastic/eui/pull/1895)) - Converted `EuiValidatableControl` to TS ([#1879](https://github.com/elastic/eui/pull/1879)) +- Add type definitions to `EuiSuperSelect` ([##1752](https://github.com/elastic/eui/issues/1752)) **Bug fixes** diff --git a/src/components/form/index.d.ts b/src/components/form/index.d.ts index 22100d015a1..86c86240560 100644 --- a/src/components/form/index.d.ts +++ b/src/components/form/index.d.ts @@ -9,6 +9,7 @@ import { CommonProps } from '../common'; /// /// /// +/// /// /// diff --git a/src/components/form/super_select/index.d.ts b/src/components/form/super_select/index.d.ts new file mode 100644 index 00000000000..5a7cab74178 --- /dev/null +++ b/src/components/form/super_select/index.d.ts @@ -0,0 +1,74 @@ +import { CommonProps } from '../../common'; + +import {FunctionComponent, ReactNode, ButtonHTMLAttributes} from 'react'; + +declare module '@elastic/eui' { + /** + * @see './super_select.js' + */ + + export type EuiSuperSelectProps = CommonProps & ButtonHTMLAttributes & { + /** + * Classes for the context menu item + */ + itemClassName: string; + + /** + * You must pass an `onChange` function to handle the update of the value + */ + onChange: (value: string) => void; + + /** + * Pass an array of options that must at least include: + * `value`: storing unique value of item, + * `inputDisplay`: what shows inside the form input when selected + * `dropdownDisplay` (optional): what shows for the item in the dropdown + */ + options?: Array<{ + value: string; + inputDisplay: ReactNode; + dropdownDisplay?: ReactNode; + }>; + + valueOfSelected: string; + + /** + * Change to `true` if you want horizontal lines between options. + * This is best used when options are multi-line. + */ + hasDividers?: boolean; + + /** + * Change `EuiContextMenuItem` layout position of icon + */ + itemLayoutAlign: string; + + /** + * Make it wide. Default: false + */ + fullWidth?: boolean; + + /** + * Provides invalid styling. Default: false + */ + isInvalid?: boolean; + + /** + * Make it short. Default: false + */ + compressed?: boolean; + + /** + * Applied to the outermost wrapper (popover) + */ + popoverClassName: string; + + /** + * Controls whether the options are shown. Default: false + */ + isOpen?: boolean; + + }; + + export const EuiSuperSelect: FunctionComponent; +} From ec4a09da0a06068ee6716bc84ea00892f190a902 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Tue, 7 May 2019 15:57:15 -0400 Subject: [PATCH 2/3] Correctly make EuiSuperSelect props optional, except options.value --- src/components/form/super_select/index.d.ts | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/form/super_select/index.d.ts b/src/components/form/super_select/index.d.ts index 5a7cab74178..cf7ecbfd93b 100644 --- a/src/components/form/super_select/index.d.ts +++ b/src/components/form/super_select/index.d.ts @@ -8,29 +8,29 @@ declare module '@elastic/eui' { */ export type EuiSuperSelectProps = CommonProps & ButtonHTMLAttributes & { - /** - * Classes for the context menu item - */ - itemClassName: string; - - /** - * You must pass an `onChange` function to handle the update of the value - */ - onChange: (value: string) => void; - /** * Pass an array of options that must at least include: * `value`: storing unique value of item, * `inputDisplay`: what shows inside the form input when selected * `dropdownDisplay` (optional): what shows for the item in the dropdown */ - options?: Array<{ + options: Array<{ value: string; - inputDisplay: ReactNode; + inputDisplay?: ReactNode; dropdownDisplay?: ReactNode; }>; - valueOfSelected: string; + valueOfSelected?: string; + + /** + * Classes for the context menu item + */ + itemClassName?: string; + + /** + * You must pass an `onChange` function to handle the update of the value + */ + onChange?: (value: string) => void; /** * Change to `true` if you want horizontal lines between options. @@ -41,7 +41,7 @@ declare module '@elastic/eui' { /** * Change `EuiContextMenuItem` layout position of icon */ - itemLayoutAlign: string; + itemLayoutAlign?: string; /** * Make it wide. Default: false @@ -61,7 +61,7 @@ declare module '@elastic/eui' { /** * Applied to the outermost wrapper (popover) */ - popoverClassName: string; + popoverClassName?: string; /** * Controls whether the options are shown. Default: false From abb643b8e101d30f5200375b92a229d609242097 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Tue, 21 May 2019 14:55:47 -0400 Subject: [PATCH 3/3] Move changelog to latest --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c2a010806b..46982f048f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Converted `EuiStepNumber` to TS ([#1893](https://github.com/elastic/eui/pull/1893)) - Converted `EuiFormControlLayoutClearButton` to TS ([#1922](https://github.com/elastic/eui/pull/1922)) - Added `data-test-subj` property to `EuiDraggable` and `EuiDroppable` ([#1943](https://github.com/elastic/eui/pull/1943)) +- Add type definitions to `EuiSuperSelect` ([##1752](https://github.com/elastic/eui/issues/1752)) ## [`11.1.0`](https://github.com/elastic/eui/tree/v11.1.0) @@ -58,7 +59,6 @@ - Added support for `href` on the last item in `EuiBreadcrumbs` ([#1905](https://github.com/elastic/eui/pull/1905)) - Added `selectable` prop to `EuiCard` ([#1895](https://github.com/elastic/eui/pull/1895)) - Converted `EuiValidatableControl` to TS ([#1879](https://github.com/elastic/eui/pull/1879)) -- Add type definitions to `EuiSuperSelect` ([##1752](https://github.com/elastic/eui/issues/1752)) **Bug fixes**