|
|
@ -58,16 +58,8 @@ class Dropdown extends React.PureComponent {
|
|
|
|
userInputtedValue = ''
|
|
|
|
userInputtedValue = ''
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
const { innerRef, color, selected, onChange, itemWrapper, icon, disableInput, title } =
|
|
|
|
innerRef,
|
|
|
|
this.props
|
|
|
|
color,
|
|
|
|
|
|
|
|
selected,
|
|
|
|
|
|
|
|
onChange,
|
|
|
|
|
|
|
|
itemWrapper,
|
|
|
|
|
|
|
|
icon,
|
|
|
|
|
|
|
|
disableInput,
|
|
|
|
|
|
|
|
title,
|
|
|
|
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
const { itemsToShow, inputValue } = this.state
|
|
|
|
const { itemsToShow, inputValue } = this.state
|
|
|
|
|
|
|
|
|
|
|
|
const labelId = title ? `${title.toLowerCase()}-dropdown` : undefined
|
|
|
|
const labelId = title ? `${title.toLowerCase()}-dropdown` : undefined
|
|
|
@ -98,51 +90,53 @@ class Dropdown extends React.PureComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const renderDropdown = ({ color, list, itemWrapper, icon, disableInput, title, labelId }) => ({
|
|
|
|
const renderDropdown =
|
|
|
|
isOpen,
|
|
|
|
({ color, list, itemWrapper, icon, disableInput, title, labelId }) =>
|
|
|
|
highlightedIndex,
|
|
|
|
({
|
|
|
|
selectedItem,
|
|
|
|
isOpen,
|
|
|
|
getRootProps,
|
|
|
|
highlightedIndex,
|
|
|
|
getToggleButtonProps,
|
|
|
|
selectedItem,
|
|
|
|
getInputProps,
|
|
|
|
getRootProps,
|
|
|
|
getItemProps,
|
|
|
|
getToggleButtonProps,
|
|
|
|
}) => {
|
|
|
|
getInputProps,
|
|
|
|
return (
|
|
|
|
getItemProps,
|
|
|
|
<DropdownContainer {...getRootProps({ refKey: 'innerRef' })}>
|
|
|
|
}) => {
|
|
|
|
{title && <VisuallyHidden id={labelId}>{title}</VisuallyHidden>}
|
|
|
|
return (
|
|
|
|
<DropdownIcon isOpen={isOpen}>{icon}</DropdownIcon>
|
|
|
|
<DropdownContainer {...getRootProps({ refKey: 'innerRef' })}>
|
|
|
|
<SelectedItem
|
|
|
|
{title && <VisuallyHidden id={labelId}>{title}</VisuallyHidden>}
|
|
|
|
getToggleButtonProps={getToggleButtonProps}
|
|
|
|
<DropdownIcon isOpen={isOpen}>{icon}</DropdownIcon>
|
|
|
|
getInputProps={getInputProps}
|
|
|
|
<SelectedItem
|
|
|
|
isOpen={isOpen}
|
|
|
|
getToggleButtonProps={getToggleButtonProps}
|
|
|
|
color={color}
|
|
|
|
getInputProps={getInputProps}
|
|
|
|
hasIcon={!!icon}
|
|
|
|
isOpen={isOpen}
|
|
|
|
disabled={disableInput}
|
|
|
|
color={color}
|
|
|
|
>
|
|
|
|
hasIcon={!!icon}
|
|
|
|
{selectedItem.name}
|
|
|
|
disabled={disableInput}
|
|
|
|
</SelectedItem>
|
|
|
|
>
|
|
|
|
{isOpen ? (
|
|
|
|
{selectedItem.name}
|
|
|
|
<ListItems color={color}>
|
|
|
|
</SelectedItem>
|
|
|
|
{list.map((item, index) => (
|
|
|
|
{isOpen ? (
|
|
|
|
<ListItem
|
|
|
|
<ListItems color={color}>
|
|
|
|
key={index}
|
|
|
|
{list.map((item, index) => (
|
|
|
|
color={color}
|
|
|
|
<ListItem
|
|
|
|
item={item}
|
|
|
|
key={index}
|
|
|
|
itemWrapper={itemWrapper}
|
|
|
|
color={color}
|
|
|
|
{...getItemProps({
|
|
|
|
item={item}
|
|
|
|
item,
|
|
|
|
itemWrapper={itemWrapper}
|
|
|
|
isSelected: selectedItem.name === item.name,
|
|
|
|
{...getItemProps({
|
|
|
|
isHighlighted: highlightedIndex === index,
|
|
|
|
item,
|
|
|
|
})}
|
|
|
|
isSelected: selectedItem.name === item.name,
|
|
|
|
>
|
|
|
|
isHighlighted: highlightedIndex === index,
|
|
|
|
{item.name}
|
|
|
|
})}
|
|
|
|
</ListItem>
|
|
|
|
>
|
|
|
|
))}
|
|
|
|
{item.name}
|
|
|
|
</ListItems>
|
|
|
|
</ListItem>
|
|
|
|
) : null}
|
|
|
|
))}
|
|
|
|
</DropdownContainer>
|
|
|
|
</ListItems>
|
|
|
|
)
|
|
|
|
) : null}
|
|
|
|
}
|
|
|
|
</DropdownContainer>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const DropdownContainer = ({ children, innerRef, ...rest }) => {
|
|
|
|
const DropdownContainer = ({ children, innerRef, ...rest }) => {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|