import React from 'react'; import * as Ariakit from '@ariakit/react'; import { PinIcon } from '@librechat/client'; import { ChevronRight, WandSparkles } from 'lucide-react'; import { ArtifactModes } from 'librechat-data-provider'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; interface ArtifactsSubMenuProps { isArtifactsPinned: boolean; setIsArtifactsPinned: (value: boolean) => void; artifactsMode: string; handleArtifactsToggle: () => void; handleShadcnToggle: () => void; handleCustomToggle: () => void; } const ArtifactsSubMenu = React.forwardRef( ( { isArtifactsPinned, setIsArtifactsPinned, artifactsMode, handleArtifactsToggle, handleShadcnToggle, handleCustomToggle, ...props }, ref, ) => { const localize = useLocalize(); const menuStore = Ariakit.useMenuStore({ focusLoop: true, showTimeout: 100, placement: 'right', }); const isEnabled = artifactsMode !== '' && artifactsMode !== undefined; const isShadcnEnabled = artifactsMode === ArtifactModes.SHADCNUI; const isCustomEnabled = artifactsMode === ArtifactModes.CUSTOM; return (
) => { e.stopPropagation(); handleArtifactsToggle(); }} onMouseEnter={() => { if (isEnabled) { menuStore.show(); } }} className="flex w-full cursor-pointer items-center justify-between rounded-lg p-2 hover:bg-surface-hover" /> } >
{localize('com_ui_artifacts')} {isEnabled && }
{isEnabled && (
{localize('com_ui_artifacts_options')}
{/* Include shadcn/ui Option */} { event.preventDefault(); event.stopPropagation(); handleShadcnToggle(); }} disabled={isCustomEnabled} className={cn( 'mb-1 flex items-center justify-between rounded-lg px-2 py-2', 'cursor-pointer text-text-primary outline-none transition-colors', 'hover:bg-black/[0.075] dark:hover:bg-white/10', 'data-[active-item]:bg-black/[0.075] dark:data-[active-item]:bg-white/10', isCustomEnabled && 'cursor-not-allowed opacity-50', )} >
{localize('com_ui_include_shadcnui' as any)}
{/* Custom Prompt Mode Option */} { event.preventDefault(); event.stopPropagation(); handleCustomToggle(); }} className={cn( 'flex items-center justify-between rounded-lg px-2 py-2', 'cursor-pointer text-text-primary outline-none transition-colors', 'hover:bg-black/[0.075] dark:hover:bg-white/10', 'data-[active-item]:bg-black/[0.075] dark:data-[active-item]:bg-white/10', )} >
{localize('com_ui_custom_prompt_mode' as any)}
)}
); }, ); ArtifactsSubMenu.displayName = 'ArtifactsSubMenu'; export default React.memo(ArtifactsSubMenu);