prompt-menu.tsx 845 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { memo } from 'react'
  2. import { PromptMenuItem } from './prompt-option'
  3. type PromptMenuProps = {
  4. startIndex: number
  5. selectedIndex: number | null
  6. options: any[]
  7. onClick: (index: number, option: any) => void
  8. onMouseEnter: (index: number, option: any) => void
  9. }
  10. const PromptMenu = ({
  11. startIndex,
  12. selectedIndex,
  13. options,
  14. onClick,
  15. onMouseEnter,
  16. }: PromptMenuProps) => {
  17. return (
  18. <div className='p-1'>
  19. {
  20. options.map((option, index: number) => (
  21. <PromptMenuItem
  22. startIndex={startIndex}
  23. index={index}
  24. isSelected={selectedIndex === index + startIndex}
  25. onClick={onClick}
  26. onMouseEnter={onMouseEnter}
  27. key={option.key}
  28. option={option}
  29. />
  30. ))
  31. }
  32. </div>
  33. )
  34. }
  35. export default memo(PromptMenu)