mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-27 19:25:05 +08:00
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import React from 'react'
|
|
import useTheme from '../styles/use-theme'
|
|
import { useAutoCompleteContext } from './auto-complete-context'
|
|
import Dropdown from '../shared/dropdown'
|
|
|
|
interface Props {
|
|
visible: boolean
|
|
}
|
|
|
|
const AutoCompleteDropdown: React.FC<React.PropsWithChildren<Props>> = ({
|
|
children, visible
|
|
}) => {
|
|
const theme = useTheme()
|
|
const { ref } = useAutoCompleteContext()
|
|
const clickHandler = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
event.preventDefault()
|
|
event.stopPropagation()
|
|
event.nativeEvent.stopImmediatePropagation()
|
|
}
|
|
|
|
return (
|
|
<Dropdown parent={ref} visible={visible}>
|
|
<div className="auto-dropdown-dropdown" onClick={clickHandler}>
|
|
{children}
|
|
<style jsx>{`
|
|
.auto-dropdown-dropdown {
|
|
border-radius: ${theme.layout.radius};
|
|
box-shadow: ${theme.expressiveness.shadowLarge};
|
|
background-color: ${theme.palette.background};
|
|
}
|
|
`}</style>
|
|
</div>
|
|
</Dropdown>
|
|
)
|
|
}
|
|
|
|
export default AutoCompleteDropdown
|