mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
0046ef7707
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { memo } from 'react'
|
|
|
|
type PromptMenuItemMenuItemProps = {
|
|
icon: JSX.Element
|
|
title: string
|
|
disabled?: boolean
|
|
isSelected: boolean
|
|
onClick: () => void
|
|
onMouseEnter: () => void
|
|
setRefElement?: (element: HTMLDivElement) => void
|
|
}
|
|
export const PromptMenuItem = memo(({
|
|
icon,
|
|
title,
|
|
disabled,
|
|
isSelected,
|
|
onClick,
|
|
onMouseEnter,
|
|
setRefElement,
|
|
}: PromptMenuItemMenuItemProps) => {
|
|
return (
|
|
<div
|
|
className={`
|
|
flex items-center px-3 h-6 cursor-pointer hover:bg-gray-50 rounded-md
|
|
${isSelected && !disabled && '!bg-gray-50'}
|
|
${disabled ? 'cursor-not-allowed opacity-30' : 'hover:bg-gray-50 cursor-pointer'}
|
|
`}
|
|
tabIndex={-1}
|
|
ref={setRefElement}
|
|
onMouseEnter={() => {
|
|
if (disabled)
|
|
return
|
|
onMouseEnter()
|
|
}}
|
|
onClick={() => {
|
|
if (disabled)
|
|
return
|
|
onClick()
|
|
}}>
|
|
{icon}
|
|
<div className='ml-1 text-[13px] text-gray-900'>{title}</div>
|
|
</div>
|
|
)
|
|
})
|
|
PromptMenuItem.displayName = 'PromptMenuItem'
|