mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-12 12:39:52 +08:00
- components/model-selector.tsx uses Dialog, Command and Tooltip directly; delete components/ai-elements/model-selector.tsx and components/button-with-tooltip.tsx; one renderGroups for both lists; no "Server · " prefix round trip - components/ui: drop CommandDialog, CommandShortcut and six unused shadcn exports - model-config-dialog: no type-to-confirm on provider delete; provider-credentials-fields: drop footer and bedrockApiKey - hooks/use-model-config.ts and lib/types/model-config.ts: remove the 2025-12 single-provider migration, resetConfig, selectedModel and fields nothing reads - components/chat/TemplateFormDialog.tsx replaces the create and edit dialogs; TemplatePanel drops the setInput fallback, the templatesChanged listener, dictionary fallbacks and formatLastUsed; lib/template-storage.ts drops getTemplate, clickCount and indexes - reasoning.tsx becomes one component; shimmer uses a CSS keyframe (motion and @radix-ui/react-use-controllable-state removed) - error-toast.tsx deleted in favour of toast.error; ValidationCard drops the idle status; dev-xml-simulator uses English literals - admin: no enum setting type, shared types from lib/admin (AdminProviderInput stays exported for that), ENABLE_HISTORY_XML_REPLACE entry removed - app/globals.css: drop check-pop, --ease-spring, --duration-normal and the shadow aliases - dictionaries: 81 unused keys removed from all four languages
143 lines
3.8 KiB
TypeScript
143 lines
3.8 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { Command as CommandPrimitive } from "cmdk"
|
|
import { SearchIcon } from "lucide-react"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
function Command({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
return (
|
|
<CommandPrimitive
|
|
data-slot="command"
|
|
className={cn(
|
|
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function CommandInput({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
return (
|
|
<div
|
|
data-slot="command-input-wrapper"
|
|
className="flex h-9 items-center gap-2 border-b px-3"
|
|
>
|
|
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
<CommandPrimitive.Input
|
|
data-slot="command-input"
|
|
className={cn(
|
|
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const CommandList = React.forwardRef<
|
|
React.ElementRef<typeof CommandPrimitive.List>,
|
|
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
>(({ className, ...props }, ref) => {
|
|
return (
|
|
<CommandPrimitive.List
|
|
ref={ref}
|
|
data-slot="command-list"
|
|
className={cn(
|
|
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
})
|
|
CommandList.displayName = CommandPrimitive.List.displayName ?? "CommandList"
|
|
|
|
function CommandEmpty({
|
|
...props
|
|
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
return (
|
|
<CommandPrimitive.Empty
|
|
data-slot="command-empty"
|
|
className="py-6 text-center text-sm"
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function CommandGroup({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
return (
|
|
<CommandPrimitive.Group
|
|
data-slot="command-group"
|
|
className={cn(
|
|
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function CommandSeparator({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
return (
|
|
<CommandPrimitive.Separator
|
|
data-slot="command-separator"
|
|
className={cn("bg-border -mx-1 h-px", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function CommandItem({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
return (
|
|
<CommandPrimitive.Item
|
|
data-slot="command-item"
|
|
className={cn(
|
|
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
onMouseEnter={(e) => {
|
|
// Ensure hover updates selection for visual feedback
|
|
const item = e.currentTarget
|
|
item.setAttribute("data-selected", "true")
|
|
// Deselect siblings
|
|
const siblings = item.parentElement?.querySelectorAll("[cmdk-item]")
|
|
siblings?.forEach((sibling) => {
|
|
if (sibling !== item) {
|
|
sibling.setAttribute("data-selected", "false")
|
|
}
|
|
})
|
|
}}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export {
|
|
Command,
|
|
CommandInput,
|
|
CommandList,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandItem,
|
|
CommandSeparator,
|
|
}
|