mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-12 20:49:53 +08:00
- stores/versions-store.ts, hooks/use-session-manager.ts, lib/session-storage.ts: remove the diagramHistory conversion layer, the localStorage chat migration and the empty templates store - stores/canvas-store.ts, lib/drawio/editor-bridge.ts: remove the pages list nothing read - components/chat/chat-engine.tsx: use the context's chartXMLRef and latestSvgRef instead of local copies, subscribe to one settings field, stop prefetching quota limits (lib/use-quota-manager.tsx takes the values from the 429 body), readDiagramFile delegates to the MCP loader (which now strips XML prologs and accepts <svg:svg>) - contexts/diagram-context.tsx: one requestTaggedExport path for thumbnails, validation, fetch and save; fetchDiagramXml replaces handleExport plus the exported resolver map - hooks/use-validate-diagram.ts and app/api/validate-diagram: plain fetch returning JSON instead of a streamed object nobody consumed - hooks/use-diagram-tool-handlers.ts: drop the DEBUG blocks; canvas vars inheritance lives in placeOnPage (lib/diagram-pages.ts) - lobby-hero, icon-button, drawio-frame: remove unreachable branches and unused props
67 lines
2.1 KiB
TypeScript
67 lines
2.1 KiB
TypeScript
"use client"
|
|
|
|
import type React from "react"
|
|
import { forwardRef } from "react"
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from "@/components/ui/tooltip"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
interface IconButtonProps extends React.ComponentProps<"button"> {
|
|
label: string
|
|
/** Shown next to the label in the tooltip, e.g. "⌘B" */
|
|
shortcut?: string
|
|
tooltipSide?: "top" | "bottom" | "left" | "right"
|
|
}
|
|
|
|
/** Square icon button with a tooltip; the tooltip text is also its label */
|
|
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
function IconButton(
|
|
{
|
|
label,
|
|
shortcut,
|
|
tooltipSide = "bottom",
|
|
className,
|
|
children,
|
|
...props
|
|
},
|
|
ref,
|
|
) {
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<button
|
|
ref={ref}
|
|
type="button"
|
|
aria-label={label}
|
|
className={cn(
|
|
"inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors",
|
|
"hover:bg-accent hover:text-foreground",
|
|
"focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",
|
|
"disabled:pointer-events-none disabled:opacity-35",
|
|
"[&_svg]:size-4 [&_svg]:stroke-[1.75]",
|
|
className,
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</button>
|
|
</TooltipTrigger>
|
|
<TooltipContent
|
|
side={tooltipSide}
|
|
className="flex items-center gap-2"
|
|
>
|
|
{label}
|
|
{shortcut && (
|
|
<kbd className="font-sans text-[11px] opacity-60">
|
|
{shortcut}
|
|
</kbd>
|
|
)}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
},
|
|
)
|