| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import { memo } from 'react' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-08 21:56:09 +08:00
										 |  |  | type PromptMenuItemMenuItemProps = { | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |   icon: React.JSX.Element | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   title: string | 
					
						
							|  |  |  |   disabled?: boolean | 
					
						
							|  |  |  |   isSelected: boolean | 
					
						
							| 
									
										
										
										
											2024-07-08 21:56:09 +08:00
										 |  |  |   onClick: () => void | 
					
						
							|  |  |  |   onMouseEnter: () => void | 
					
						
							|  |  |  |   setRefElement?: (element: HTMLDivElement) => void | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | } | 
					
						
							|  |  |  | export const PromptMenuItem = memo(({ | 
					
						
							| 
									
										
										
										
											2024-07-08 21:56:09 +08:00
										 |  |  |   icon, | 
					
						
							|  |  |  |   title, | 
					
						
							|  |  |  |   disabled, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   isSelected, | 
					
						
							|  |  |  |   onClick, | 
					
						
							|  |  |  |   onMouseEnter, | 
					
						
							| 
									
										
										
										
											2024-07-08 21:56:09 +08:00
										 |  |  |   setRefElement, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | }: PromptMenuItemMenuItemProps) => { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div | 
					
						
							|  |  |  |       className={`
 | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         flex h-6 cursor-pointer items-center rounded-md px-3 hover:bg-state-base-hover | 
					
						
							| 
									
										
										
										
											2025-01-23 16:20:00 +08:00
										 |  |  |         ${isSelected && !disabled && '!bg-state-base-hover'} | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         ${disabled ? 'cursor-not-allowed opacity-30' : 'cursor-pointer hover:bg-state-base-hover'} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       `}
 | 
					
						
							|  |  |  |       tabIndex={-1} | 
					
						
							| 
									
										
										
										
											2024-07-08 21:56:09 +08:00
										 |  |  |       ref={setRefElement} | 
					
						
							|  |  |  |       onMouseEnter={() => { | 
					
						
							|  |  |  |         if (disabled) | 
					
						
							|  |  |  |           return | 
					
						
							|  |  |  |         onMouseEnter() | 
					
						
							|  |  |  |       }} | 
					
						
							|  |  |  |       onClick={() => { | 
					
						
							|  |  |  |         if (disabled) | 
					
						
							|  |  |  |           return | 
					
						
							|  |  |  |         onClick() | 
					
						
							|  |  |  |       }}> | 
					
						
							|  |  |  |       {icon} | 
					
						
							| 
									
										
										
										
											2025-01-23 16:20:00 +08:00
										 |  |  |       <div className='ml-1 text-[13px] text-text-secondary'>{title}</div> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | PromptMenuItem.displayName = 'PromptMenuItem' |