chore: replace popoveer

This commit is contained in:
Richard Shiue
2025-09-05 15:46:01 +08:00
parent 535ca586d8
commit 09b39b7af9
10 changed files with 9 additions and 85 deletions

View File

@@ -2,7 +2,7 @@ import { useChatContext } from '@/components/chat/chat/context';
import { SpaceList } from '../add-messages-to-page-wrapper/space-list'; import { SpaceList } from '../add-messages-to-page-wrapper/space-list';
import { Label } from '@/components/ui/label'; import { Label } from '@/components/ui/label';
import { SearchInput } from '@/components/chat/components/ui/search-input'; import { SearchInput } from '@/components/chat/components/ui/search-input';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import { toast } from 'sonner'; import { toast } from 'sonner';
import { useViewContentInserter } from '@/components/chat/hooks/use-view-content-inserter'; import { useViewContentInserter } from '@/components/chat/hooks/use-view-content-inserter';

View File

@@ -6,7 +6,7 @@ import { AskAnything } from '@/components/chat/components/ai-writer/tools/ask-an
import { Explain } from '@/components/chat/components/ai-writer/tools/explain'; import { Explain } from '@/components/chat/components/ai-writer/tools/explain';
import { FixSpelling } from '@/components/chat/components/ai-writer/tools/fix-spelling'; import { FixSpelling } from '@/components/chat/components/ai-writer/tools/fix-spelling';
import { ImproveWriting } from '@/components/chat/components/ai-writer/tools/improve-writing'; import { ImproveWriting } from '@/components/chat/components/ai-writer/tools/improve-writing';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { useTranslation } from '@/components/chat/i18n'; import { useTranslation } from '@/components/chat/i18n';
import { AIAssistantType } from '@/components/chat/types'; import { AIAssistantType } from '@/components/chat/types';
import { useWriterContext } from '@/components/chat/writer/context'; import { useWriterContext } from '@/components/chat/writer/context';

View File

@@ -6,7 +6,7 @@ import { Spaces } from './spaces';
import { MESSAGE_VARIANTS } from '@/components/chat/lib/animations'; import { MESSAGE_VARIANTS } from '@/components/chat/lib/animations';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { SearchInput } from '@/components/chat/components/ui/search-input'; import { SearchInput } from '@/components/chat/components/ui/search-input';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import { useCheckboxTree } from '@/components/chat/hooks/use-checkbox-tree'; import { useCheckboxTree } from '@/components/chat/hooks/use-checkbox-tree';

View File

@@ -1,6 +1,6 @@
import { AiWriterMenuContent } from '../ai-writer/ai-writer-menu-content'; import { AiWriterMenuContent } from '../ai-writer/ai-writer-menu-content';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { useTranslation } from '@/components/chat/i18n'; import { useTranslation } from '@/components/chat/i18n';
import { AIAssistantType } from '@/components/chat/types'; import { AIAssistantType } from '@/components/chat/types';
import { useWriterContext } from '@/components/chat/writer/context'; import { useWriterContext } from '@/components/chat/writer/context';

View File

@@ -9,7 +9,7 @@ import {
Popover, Popover,
PopoverContent, PopoverContent,
PopoverTrigger, PopoverTrigger,
} from '@/components/chat/components/ui/popover'; } from '@/components/ui/popover';
import { useModelSelectorContext } from '@/components/chat/contexts/model-selector-context'; import { useModelSelectorContext } from '@/components/chat/contexts/model-selector-context';
import { MESSAGE_VARIANTS } from '@/components/chat/lib/animations'; import { MESSAGE_VARIANTS } from '@/components/chat/lib/animations';
import { ModelCache } from '@/components/chat/lib/model-cache'; import { ModelCache } from '@/components/chat/lib/model-cache';

View File

@@ -2,7 +2,7 @@ import {
Popover, Popover,
PopoverContent, PopoverContent,
PopoverTrigger, PopoverTrigger,
} from '@/components/chat/components/ui/popover'; } from '@/components/ui/popover';
import { SearchInput } from '@/components/chat/components/ui/search-input'; import { SearchInput } from '@/components/chat/components/ui/search-input';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import { ReactNode, useState } from 'react'; import { ReactNode, useState } from 'react';

View File

@@ -2,7 +2,7 @@ import LoadingDots from '@/components/chat/components/ui/loading-dots';
import { SearchInput } from '@/components/chat/components/ui/search-input'; import { SearchInput } from '@/components/chat/components/ui/search-input';
import { Spaces } from './spaces'; import { Spaces } from './spaces';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { ReactComponent as DocIcon } from '@/components/chat/assets/icons/doc.svg'; import { ReactComponent as DocIcon } from '@/components/chat/assets/icons/doc.svg';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';

View File

@@ -4,7 +4,7 @@ import { ReactComponent as RegenerateCircleIcon } from '@/components/chat/assets
import { ReactComponent as TryAgainIcon } from '@/components/chat/assets/icons/undo.svg'; import { ReactComponent as TryAgainIcon } from '@/components/chat/assets/icons/undo.svg';
import { FormatGroup } from '@/components/chat/components/ui/format-group'; import { FormatGroup } from '@/components/chat/components/ui/format-group';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { useTranslation } from '@/components/chat/i18n'; import { useTranslation } from '@/components/chat/i18n';
import { useMessagesHandlerContext } from '@/components/chat/provider/messages-handler-provider'; import { useMessagesHandlerContext } from '@/components/chat/provider/messages-handler-provider';

View File

@@ -1,76 +0,0 @@
import * as PopoverPrimitive from '@radix-ui/react-popover';
import { forwardRef } from 'react';
import { cn } from '@/components/chat/lib/utils';
function Popover({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
return <PopoverPrimitive.Root data-slot='popover' {...props} />;
}
const PopoverTrigger = forwardRef<
HTMLButtonElement,
React.ComponentProps<typeof PopoverPrimitive.Trigger>
>(({ ...props }, ref) => {
return (
<PopoverPrimitive.Trigger
data-slot='popover-trigger'
{...props}
ref={ref}
/>
);
});
function PopoverContent({
className,
align = 'center',
sideOffset = 4,
container,
...props
}: React.ComponentProps<typeof PopoverPrimitive.Content> & {
container?: React.ComponentProps<typeof PopoverPrimitive.Portal>['container'];
disableOutsidePointerEvents?: boolean;
}) {
return (
<PopoverPrimitive.Portal container={container}>
<PopoverPrimitive.Content
data-slot='popover-content'
align={align}
sideOffset={sideOffset}
className={cn(
'z-50 min-w-[240px] rounded-400 bg-background-primary p-0 shadow-popover',
'origin-(--radix-popover-content-transform-origin)',
'data-[state=open]:animate-in',
'data-[state=closed]:animate-out',
'data-[state=open]:fade-in-0',
'data-[state=closed]:fade-out-0',
'data-[state=open]:zoom-in-95',
'data-[state=closed]:zoom-out-95',
'data-[side=bottom]:slide-in-from-top-2',
'data-[side=left]:slide-in-from-right-2',
'data-[side=right]:slide-in-from-left-2',
'data-[side=top]:slide-in-from-bottom-2',
'focus:outline-none focus-visible:outline-none',
className,
)}
{...props}
/>
</PopoverPrimitive.Portal>
);
}
function PopoverAnchor({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
return <PopoverPrimitive.Anchor data-slot='popover-anchor' {...props} />;
}
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };

View File

@@ -1,5 +1,5 @@
import { AiWriterMenuContent } from '@/components/chat/components/ai-writer/ai-writer-menu-content'; import { AiWriterMenuContent } from '@/components/chat/components/ai-writer/ai-writer-menu-content';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/chat/components/ui/popover'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { AIAssistantType } from '@/components/chat/types'; import { AIAssistantType } from '@/components/chat/types';
interface AIWriterMenuProps { interface AIWriterMenuProps {