-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EuiSuggest: converted to Typescript (#2692)
* Converts EuiSuggest to Typescript * Adds PR number to CHANGELOG line * Changes Object.keys() to keysOf() * Changes icon type to IconType
- Loading branch information
1 parent
01a6c3f
commit 772d2a8
Showing
15 changed files
with
354 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { EuiSuggestInput, EuiSuggestInputProps } from './suggest_input'; | ||
|
||
export { EuiSuggestItem, EuiSuggestItemProps } from './suggest_item'; | ||
|
||
export { EuiSuggest, EuiSuggestProps } from './suggest'; |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { CommonProps } from '../common'; | ||
import { EuiSuggestItem, EuiSuggestItemProps } from './suggest_item'; | ||
import { EuiSuggestInput, EuiSuggestInputProps } from './suggest_input'; | ||
|
||
export type EuiSuggestProps = CommonProps & | ||
EuiSuggestInputProps & { | ||
/** | ||
* List of suggestions to display using 'suggestItem'. | ||
*/ | ||
suggestions: EuiSuggestItemProps[]; | ||
|
||
/** | ||
* Handler for click on a suggestItem. | ||
*/ | ||
onItemClick?: (item: EuiSuggestItemProps) => void; | ||
|
||
onInputChange?: (target: EventTarget) => void; | ||
}; | ||
|
||
export const EuiSuggest: FunctionComponent<EuiSuggestProps> = ( | ||
props: EuiSuggestProps | ||
) => { | ||
const { | ||
onItemClick, | ||
onInputChange, | ||
status, | ||
append, | ||
tooltipContent, | ||
suggestions, | ||
...rest | ||
} = props; | ||
|
||
const onChange = (e: React.FormEvent<HTMLDivElement>) => { | ||
onInputChange ? onInputChange(e.target) : null; | ||
}; | ||
|
||
const suggestionList = suggestions.map((item: EuiSuggestItemProps, index) => ( | ||
<EuiSuggestItem | ||
type={item.type} | ||
key={index} | ||
label={item.label} | ||
onClick={onItemClick ? () => onItemClick(item) : undefined} | ||
description={item.description} | ||
/> | ||
)); | ||
|
||
const suggestInput = ( | ||
<EuiSuggestInput | ||
status={status} | ||
tooltipContent={tooltipContent} | ||
append={append} | ||
suggestions={suggestionList} | ||
{...rest} | ||
/> | ||
); | ||
|
||
return <div onChange={onChange}>{suggestInput}</div>; | ||
}; | ||
|
||
EuiSuggestInput.defaultProps = { | ||
status: 'unchanged', | ||
}; |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.