@townco/ui 0.1.68 → 0.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/core/hooks/use-chat-messages.d.ts +6 -1
  2. package/dist/core/hooks/use-chat-session.d.ts +1 -1
  3. package/dist/core/hooks/use-tool-calls.d.ts +6 -1
  4. package/dist/core/schemas/chat.d.ts +10 -0
  5. package/dist/core/schemas/tool-call.d.ts +5 -0
  6. package/dist/core/schemas/tool-call.js +8 -0
  7. package/dist/core/utils/tool-call-state.d.ts +30 -0
  8. package/dist/core/utils/tool-call-state.js +73 -0
  9. package/dist/core/utils/tool-summary.d.ts +13 -0
  10. package/dist/core/utils/tool-summary.js +172 -0
  11. package/dist/core/utils/tool-verbiage.d.ts +28 -0
  12. package/dist/core/utils/tool-verbiage.js +185 -0
  13. package/dist/gui/components/AppSidebar.d.ts +22 -0
  14. package/dist/gui/components/AppSidebar.js +22 -0
  15. package/dist/gui/components/Button.d.ts +1 -1
  16. package/dist/gui/components/ChatLayout.d.ts +5 -0
  17. package/dist/gui/components/ChatLayout.js +239 -132
  18. package/dist/gui/components/ChatView.js +42 -118
  19. package/dist/gui/components/MessageContent.js +151 -39
  20. package/dist/gui/components/SessionHistory.d.ts +10 -0
  21. package/dist/gui/components/SessionHistory.js +101 -0
  22. package/dist/gui/components/SessionHistoryItem.d.ts +11 -0
  23. package/dist/gui/components/SessionHistoryItem.js +24 -0
  24. package/dist/gui/components/Sheet.d.ts +25 -0
  25. package/dist/gui/components/Sheet.js +36 -0
  26. package/dist/gui/components/Sidebar.d.ts +65 -0
  27. package/dist/gui/components/Sidebar.js +231 -0
  28. package/dist/gui/components/SidebarToggle.d.ts +3 -0
  29. package/dist/gui/components/SidebarToggle.js +9 -0
  30. package/dist/gui/components/ToolCallList.js +3 -3
  31. package/dist/gui/components/ToolOperation.d.ts +11 -0
  32. package/dist/gui/components/ToolOperation.js +289 -0
  33. package/dist/gui/components/WorkProgress.d.ts +20 -0
  34. package/dist/gui/components/WorkProgress.js +79 -0
  35. package/dist/gui/components/index.d.ts +8 -1
  36. package/dist/gui/components/index.js +9 -1
  37. package/dist/gui/hooks/index.d.ts +1 -0
  38. package/dist/gui/hooks/index.js +1 -0
  39. package/dist/gui/hooks/use-mobile.d.ts +1 -0
  40. package/dist/gui/hooks/use-mobile.js +15 -0
  41. package/dist/gui/index.d.ts +1 -0
  42. package/dist/gui/index.js +2 -0
  43. package/dist/gui/lib/motion.d.ts +55 -0
  44. package/dist/gui/lib/motion.js +217 -0
  45. package/dist/sdk/schemas/session.d.ts +11 -6
  46. package/dist/sdk/transports/types.d.ts +5 -0
  47. package/package.json +8 -7
  48. package/src/styles/global.css +128 -1
  49. package/dist/gui/components/InvokingGroup.d.ts +0 -9
  50. package/dist/gui/components/InvokingGroup.js +0 -16
  51. package/dist/gui/components/SubagentStream.d.ts +0 -23
  52. package/dist/gui/components/SubagentStream.js +0 -98
  53. package/dist/gui/components/ToolCall.d.ts +0 -8
  54. package/dist/gui/components/ToolCall.js +0 -234
  55. package/dist/gui/components/ToolCallGroup.d.ts +0 -8
  56. package/dist/gui/components/ToolCallGroup.js +0 -29
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createLogger } from "@townco/core";
3
+ import { Loader2 } from "lucide-react";
4
+ import { useCallback, useEffect, useState } from "react";
5
+ import { SessionHistoryItem } from "./SessionHistoryItem.js";
6
+ import { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, useSidebar, } from "./Sidebar.js";
7
+ const logger = createLogger("session-history");
8
+ const isToday = (date) => {
9
+ const today = new Date();
10
+ return (date.getDate() === today.getDate() &&
11
+ date.getMonth() === today.getMonth() &&
12
+ date.getFullYear() === today.getFullYear());
13
+ };
14
+ const isYesterday = (date) => {
15
+ const yesterday = new Date();
16
+ yesterday.setDate(yesterday.getDate() - 1);
17
+ return (date.getDate() === yesterday.getDate() &&
18
+ date.getMonth() === yesterday.getMonth() &&
19
+ date.getFullYear() === yesterday.getFullYear());
20
+ };
21
+ const groupSessionsByDate = (sessions) => {
22
+ const now = new Date();
23
+ const oneWeekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
24
+ const oneMonthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
25
+ return sessions.reduce((groups, session) => {
26
+ const sessionDate = new Date(session.updatedAt);
27
+ if (isToday(sessionDate)) {
28
+ groups.today.push(session);
29
+ }
30
+ else if (isYesterday(sessionDate)) {
31
+ groups.yesterday.push(session);
32
+ }
33
+ else if (sessionDate > oneWeekAgo) {
34
+ groups.lastWeek.push(session);
35
+ }
36
+ else if (sessionDate > oneMonthAgo) {
37
+ groups.lastMonth.push(session);
38
+ }
39
+ else {
40
+ groups.older.push(session);
41
+ }
42
+ return groups;
43
+ }, {
44
+ today: [],
45
+ yesterday: [],
46
+ lastWeek: [],
47
+ lastMonth: [],
48
+ older: [],
49
+ });
50
+ };
51
+ export function SessionHistory({ client, currentSessionId, onSessionSelect, onRenameSession, onArchiveSession, onDeleteSession, }) {
52
+ const { setOpenMobile } = useSidebar();
53
+ const [sessions, setSessions] = useState([]);
54
+ const [isLoading, setIsLoading] = useState(false);
55
+ const fetchSessions = useCallback(async () => {
56
+ if (!client)
57
+ return;
58
+ setIsLoading(true);
59
+ try {
60
+ const sessionList = await client.listSessions();
61
+ setSessions(sessionList);
62
+ }
63
+ catch (error) {
64
+ logger.error("Failed to fetch sessions", { error });
65
+ }
66
+ finally {
67
+ setIsLoading(false);
68
+ }
69
+ }, [client]);
70
+ // Fetch sessions on mount and when client changes
71
+ useEffect(() => {
72
+ fetchSessions();
73
+ }, [fetchSessions]);
74
+ const handleSessionSelect = (sessionId) => {
75
+ if (sessionId === currentSessionId) {
76
+ return;
77
+ }
78
+ if (onSessionSelect) {
79
+ onSessionSelect(sessionId);
80
+ }
81
+ else {
82
+ // Default behavior: update URL with session ID
83
+ const url = new URL(window.location.href);
84
+ url.searchParams.set("session", sessionId);
85
+ window.location.href = url.toString();
86
+ }
87
+ };
88
+ if (!client) {
89
+ return (_jsx(SidebarGroup, { children: _jsx(SidebarGroupContent, { children: _jsx("div", { className: "flex w-full flex-row items-center justify-center gap-2 px-2 text-sm text-muted-foreground", children: "Connect to an agent to see session history" }) }) }));
90
+ }
91
+ if (isLoading) {
92
+ return (_jsxs(SidebarGroup, { children: [_jsx(SidebarGroupLabel, { children: "Today" }), _jsx(SidebarGroupContent, { children: _jsx("div", { className: "flex flex-col", children: [44, 32, 28, 64, 52].map((item) => (_jsx("div", { className: "flex h-8 items-center gap-2 rounded-md px-2", children: _jsx("div", { className: "h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse", style: {
93
+ maxWidth: `${item}%`,
94
+ } }) }, item))) }) })] }));
95
+ }
96
+ if (sessions.length === 0) {
97
+ return (_jsx(SidebarGroup, { children: _jsx(SidebarGroupContent, { children: _jsx("div", { className: "flex w-full flex-row items-center justify-center gap-2 px-2 py-4 text-sm text-muted-foreground", children: "Your sessions will appear here once you start chatting!" }) }) }));
98
+ }
99
+ const groupedSessions = groupSessionsByDate(sessions);
100
+ return (_jsx(SidebarGroup, { children: _jsx(SidebarGroupContent, { children: _jsx(SidebarMenu, { children: _jsxs("div", { className: "flex flex-col gap-6", children: [groupedSessions.today.length > 0 && (_jsxs("div", { children: [_jsx("div", { className: "px-2 py-1 text-sidebar-foreground/50 text-xs", children: "Today" }), groupedSessions.today.map((session) => (_jsx(SessionHistoryItem, { session: session, isActive: session.sessionId === currentSessionId, onSelect: handleSessionSelect, onRename: onRenameSession, onArchive: onArchiveSession, onDelete: onDeleteSession, setOpenMobile: setOpenMobile }, session.sessionId)))] })), groupedSessions.yesterday.length > 0 && (_jsxs("div", { children: [_jsx("div", { className: "px-2 py-1 text-sidebar-foreground/50 text-xs", children: "Yesterday" }), groupedSessions.yesterday.map((session) => (_jsx(SessionHistoryItem, { session: session, isActive: session.sessionId === currentSessionId, onSelect: handleSessionSelect, onRename: onRenameSession, onArchive: onArchiveSession, onDelete: onDeleteSession, setOpenMobile: setOpenMobile }, session.sessionId)))] })), groupedSessions.lastWeek.length > 0 && (_jsxs("div", { children: [_jsx("div", { className: "px-2 py-1 text-sidebar-foreground/50 text-xs", children: "Last 7 days" }), groupedSessions.lastWeek.map((session) => (_jsx(SessionHistoryItem, { session: session, isActive: session.sessionId === currentSessionId, onSelect: handleSessionSelect, onRename: onRenameSession, onArchive: onArchiveSession, onDelete: onDeleteSession, setOpenMobile: setOpenMobile }, session.sessionId)))] })), groupedSessions.lastMonth.length > 0 && (_jsxs("div", { children: [_jsx("div", { className: "px-2 py-1 text-sidebar-foreground/50 text-xs", children: "Last 30 days" }), groupedSessions.lastMonth.map((session) => (_jsx(SessionHistoryItem, { session: session, isActive: session.sessionId === currentSessionId, onSelect: handleSessionSelect, onRename: onRenameSession, onArchive: onArchiveSession, onDelete: onDeleteSession, setOpenMobile: setOpenMobile }, session.sessionId)))] })), groupedSessions.older.length > 0 && (_jsxs("div", { children: [_jsx("div", { className: "px-2 py-1 text-sidebar-foreground/50 text-xs", children: "Older" }), groupedSessions.older.map((session) => (_jsx(SessionHistoryItem, { session: session, isActive: session.sessionId === currentSessionId, onSelect: handleSessionSelect, onRename: onRenameSession, onArchive: onArchiveSession, onDelete: onDeleteSession, setOpenMobile: setOpenMobile }, session.sessionId)))] }))] }) }) }) }));
101
+ }
@@ -0,0 +1,11 @@
1
+ import type { SessionSummary } from "../../sdk/transports/index.js";
2
+ export interface SessionHistoryItemProps {
3
+ session: SessionSummary;
4
+ isActive: boolean;
5
+ onSelect: (sessionId: string) => void;
6
+ onRename?: ((sessionId: string) => void) | undefined;
7
+ onArchive?: ((sessionId: string) => void) | undefined;
8
+ onDelete?: ((sessionId: string) => void) | undefined;
9
+ setOpenMobile: (open: boolean) => void;
10
+ }
11
+ export declare const SessionHistoryItem: import("react").MemoExoticComponent<({ session, isActive, onSelect, onRename, onArchive, onDelete, setOpenMobile, }: SessionHistoryItemProps) => import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { MoreHorizontal } from "lucide-react";
3
+ import { memo } from "react";
4
+ import { cn } from "../lib/utils.js";
5
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "./DropdownMenu.js";
6
+ import { SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, } from "./Sidebar.js";
7
+ const PureSessionHistoryItem = ({ session, isActive, onSelect, onRename, onArchive, onDelete, setOpenMobile, }) => {
8
+ return (_jsxs(SidebarMenuItem, { children: [_jsx(SidebarMenuButton, { asChild: true, isActive: isActive, onClick: () => {
9
+ onSelect(session.sessionId);
10
+ setOpenMobile(false);
11
+ }, children: _jsx("button", { type: "button", className: "w-full", children: _jsx("span", { className: "truncate", children: session.firstUserMessage || "Empty session" }) }) }), _jsxs(DropdownMenu, { modal: true, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(SidebarMenuAction, { className: "mr-0.5 data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground", showOnHover: !isActive, children: [_jsx(MoreHorizontal, {}), _jsx("span", { className: "sr-only", children: "More" })] }) }), _jsxs(DropdownMenuContent, { align: "end", side: "bottom", children: [_jsx(DropdownMenuItem, { className: "cursor-pointer", disabled: !onRename, onSelect: () => onRename?.(session.sessionId), children: "Rename" }), _jsx(DropdownMenuItem, { className: "cursor-pointer", disabled: !onArchive, onSelect: () => onArchive?.(session.sessionId), children: "Archive" }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { className: cn("cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive"), disabled: !onDelete, onSelect: () => onDelete?.(session.sessionId), children: "Delete" })] })] })] }));
12
+ };
13
+ export const SessionHistoryItem = memo(PureSessionHistoryItem, (prevProps, nextProps) => {
14
+ if (prevProps.isActive !== nextProps.isActive) {
15
+ return false;
16
+ }
17
+ if (prevProps.session.sessionId !== nextProps.session.sessionId) {
18
+ return false;
19
+ }
20
+ if (prevProps.session.firstUserMessage !== nextProps.session.firstUserMessage) {
21
+ return false;
22
+ }
23
+ return true;
24
+ });
@@ -0,0 +1,25 @@
1
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ import * as React from "react";
4
+ declare const Sheet: React.FC<DialogPrimitive.DialogProps>;
5
+ declare const SheetTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
6
+ declare const SheetClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const SheetPortal: React.FC<DialogPrimitive.DialogPortalProps>;
8
+ declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ declare const sheetVariants: (props?: ({
10
+ side?: "top" | "right" | "bottom" | "left" | null | undefined;
11
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
12
+ interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, VariantProps<typeof sheetVariants> {
13
+ }
14
+ declare const SheetContent: React.ForwardRefExoticComponent<SheetContentProps & React.RefAttributes<HTMLDivElement>>;
15
+ declare const SheetHeader: {
16
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
17
+ displayName: string;
18
+ };
19
+ declare const SheetFooter: {
20
+ ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
21
+ displayName: string;
22
+ };
23
+ declare const SheetTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
24
+ declare const SheetDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
25
+ export { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ import { cva } from "class-variance-authority";
4
+ import { X } from "lucide-react";
5
+ import * as React from "react";
6
+ import { cn } from "../lib/utils.js";
7
+ const Sheet = DialogPrimitive.Root;
8
+ const SheetTrigger = DialogPrimitive.Trigger;
9
+ const SheetClose = DialogPrimitive.Close;
10
+ const SheetPortal = DialogPrimitive.Portal;
11
+ const SheetOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Overlay, { className: cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className), ...props, ref: ref })));
12
+ SheetOverlay.displayName = DialogPrimitive.Overlay.displayName;
13
+ const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", {
14
+ variants: {
15
+ side: {
16
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
17
+ bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
18
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
19
+ right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ side: "right",
24
+ },
25
+ });
26
+ const SheetContent = React.forwardRef(({ side = "right", className, children, ...props }, ref) => (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(DialogPrimitive.Content, { ref: ref, className: cn(sheetVariants({ side }), className), ...props, children: [children, _jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary", children: [_jsx(X, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] })));
27
+ SheetContent.displayName = DialogPrimitive.Content.displayName;
28
+ const SheetHeader = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col space-y-2 text-center sm:text-left", className), ...props }));
29
+ SheetHeader.displayName = "SheetHeader";
30
+ const SheetFooter = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className), ...props }));
31
+ SheetFooter.displayName = "SheetFooter";
32
+ const SheetTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ref: ref, className: cn("text-lg font-semibold text-foreground", className), ...props })));
33
+ SheetTitle.displayName = DialogPrimitive.Title.displayName;
34
+ const SheetDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn("text-sm text-muted-foreground", className), ...props })));
35
+ SheetDescription.displayName = DialogPrimitive.Description.displayName;
36
+ export { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
@@ -0,0 +1,65 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import * as React from "react";
3
+ import { TooltipContent } from "./Tooltip.js";
4
+ type SidebarContextProps = {
5
+ state: "expanded" | "collapsed";
6
+ open: boolean;
7
+ setOpen: (open: boolean) => void;
8
+ openMobile: boolean;
9
+ setOpenMobile: (open: boolean) => void;
10
+ isMobile: boolean;
11
+ toggleSidebar: () => void;
12
+ };
13
+ declare function useSidebar(): SidebarContextProps;
14
+ declare const SidebarProvider: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
15
+ defaultOpen?: boolean;
16
+ open?: boolean;
17
+ onOpenChange?: (open: boolean) => void;
18
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
+ declare const Sidebar: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
20
+ side?: "left" | "right";
21
+ variant?: "sidebar" | "floating" | "inset";
22
+ collapsible?: "offcanvas" | "icon" | "none";
23
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
24
+ declare const SidebarTrigger: React.ForwardRefExoticComponent<Omit<import("./Button.js").ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
25
+ declare const SidebarRail: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
26
+ declare const SidebarInset: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
27
+ declare const SidebarInput: React.ForwardRefExoticComponent<Omit<import("./Input.js").InputProps & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
28
+ declare const SidebarHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
29
+ declare const SidebarFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
30
+ declare const SidebarSeparator: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
31
+ declare const SidebarContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
32
+ declare const SidebarGroup: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
33
+ declare const SidebarGroupLabel: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
34
+ asChild?: boolean;
35
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
36
+ declare const SidebarGroupAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
37
+ asChild?: boolean;
38
+ }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
39
+ declare const SidebarGroupContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
40
+ declare const SidebarMenu: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
41
+ declare const SidebarMenuItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
42
+ declare const SidebarMenuButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
43
+ asChild?: boolean;
44
+ isActive?: boolean;
45
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
46
+ } & VariantProps<(props?: ({
47
+ variant?: "default" | "outline" | null | undefined;
48
+ size?: "default" | "sm" | "lg" | null | undefined;
49
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
50
+ declare const SidebarMenuAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
51
+ asChild?: boolean;
52
+ showOnHover?: boolean;
53
+ }, "ref"> & React.RefAttributes<HTMLButtonElement>>;
54
+ declare const SidebarMenuBadge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
55
+ declare const SidebarMenuSkeleton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
56
+ showIcon?: boolean;
57
+ }, "ref"> & React.RefAttributes<HTMLDivElement>>;
58
+ declare const SidebarMenuSub: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
59
+ declare const SidebarMenuSubItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
60
+ declare const SidebarMenuSubButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
61
+ asChild?: boolean;
62
+ size?: "sm" | "md";
63
+ isActive?: boolean;
64
+ }, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
65
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
@@ -0,0 +1,231 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Slot as SlotPrimitive } from "@radix-ui/react-slot";
3
+ import { cva } from "class-variance-authority";
4
+ import { PanelLeft } from "lucide-react";
5
+ import * as React from "react";
6
+ import { useIsMobile } from "../hooks/use-mobile.js";
7
+ import { cn } from "../lib/utils.js";
8
+ import { Button } from "./Button.js";
9
+ import { Input } from "./Input.js";
10
+ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./Sheet.js";
11
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./Tooltip.js";
12
+ const SIDEBAR_COOKIE_NAME = "sidebar_state";
13
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
14
+ const SIDEBAR_WIDTH = "16rem";
15
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
16
+ const SIDEBAR_WIDTH_ICON = "3rem";
17
+ const SIDEBAR_KEYBOARD_SHORTCUT = "s";
18
+ const SidebarContext = React.createContext(null);
19
+ function useSidebar() {
20
+ const context = React.useContext(SidebarContext);
21
+ if (!context) {
22
+ throw new Error("useSidebar must be used within a SidebarProvider.");
23
+ }
24
+ return context;
25
+ }
26
+ const SidebarProvider = React.forwardRef(({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }, ref) => {
27
+ const isMobile = useIsMobile();
28
+ const [openMobile, setOpenMobile] = React.useState(false);
29
+ // This is the internal state of the sidebar.
30
+ // We use openProp and setOpenProp for control from outside the component.
31
+ const [_open, _setOpen] = React.useState(defaultOpen);
32
+ const open = openProp ?? _open;
33
+ const setOpen = React.useCallback((value) => {
34
+ const openState = typeof value === "function" ? value(open) : value;
35
+ if (setOpenProp) {
36
+ setOpenProp(openState);
37
+ }
38
+ else {
39
+ _setOpen(openState);
40
+ }
41
+ // This sets the cookie to keep the sidebar state.
42
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
43
+ }, [setOpenProp, open]);
44
+ // Helper to toggle the sidebar.
45
+ const toggleSidebar = React.useCallback(() => {
46
+ return isMobile
47
+ ? setOpenMobile((open) => !open)
48
+ : setOpen((open) => !open);
49
+ }, [isMobile, setOpen, setOpenMobile]);
50
+ // Adds a keyboard shortcut to toggle the sidebar (Cmd/Ctrl+Shift+S).
51
+ React.useEffect(() => {
52
+ const handleKeyDown = (event) => {
53
+ if (event.key.toLowerCase() === SIDEBAR_KEYBOARD_SHORTCUT &&
54
+ event.shiftKey &&
55
+ (event.metaKey || event.ctrlKey)) {
56
+ event.preventDefault();
57
+ toggleSidebar();
58
+ }
59
+ };
60
+ window.addEventListener("keydown", handleKeyDown);
61
+ return () => window.removeEventListener("keydown", handleKeyDown);
62
+ }, [toggleSidebar]);
63
+ // We add a state so that we can do data-state="expanded" or "collapsed".
64
+ // This makes it easier to style the sidebar with Tailwind classes.
65
+ const state = open ? "expanded" : "collapsed";
66
+ const contextValue = React.useMemo(() => ({
67
+ state,
68
+ open,
69
+ setOpen,
70
+ isMobile,
71
+ openMobile,
72
+ setOpenMobile,
73
+ toggleSidebar,
74
+ }), [
75
+ state,
76
+ open,
77
+ setOpen,
78
+ isMobile,
79
+ openMobile,
80
+ setOpenMobile,
81
+ toggleSidebar,
82
+ ]);
83
+ return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx(TooltipProvider, { delayDuration: 0, children: _jsx("div", { className: cn("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar", className), ref: ref, style: {
84
+ "--sidebar-width": SIDEBAR_WIDTH,
85
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
86
+ ...style,
87
+ }, ...props, children: children }) }) }));
88
+ });
89
+ SidebarProvider.displayName = "SidebarProvider";
90
+ const Sidebar = React.forwardRef(({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, ...props }, ref) => {
91
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
92
+ if (collapsible === "none") {
93
+ return (_jsx("div", { className: cn("flex h-full w-[var(--sidebar-width)] flex-col bg-sidebar text-sidebar-foreground", className), ref: ref, ...props, children: children }));
94
+ }
95
+ if (isMobile) {
96
+ return (_jsx(Sheet, { onOpenChange: setOpenMobile, open: openMobile, ...props, children: _jsxs(SheetContent, { className: "w-[var(--sidebar-width)] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", "data-mobile": "true", "data-sidebar": "sidebar", side: side, style: {
97
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
98
+ }, children: [_jsxs(SheetHeader, { className: "sr-only", children: [_jsx(SheetTitle, { children: "Sidebar" }), _jsx(SheetDescription, { children: "Displays the mobile sidebar." })] }), _jsx("div", { className: "flex h-full w-full flex-col", children: children })] }) }));
99
+ }
100
+ return (_jsxs("div", { className: "group peer hidden text-sidebar-foreground md:block", "data-collapsible": state === "collapsed" ? collapsible : "", "data-side": side, "data-state": state, "data-variant": variant, ref: ref, children: [_jsx("div", { className: cn("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-150 ease-linear", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset"
101
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
102
+ : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]") }), _jsx("div", { className: cn("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-150 ease-linear md:flex", side === "left"
103
+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
104
+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
105
+ // Adjust the padding for floating and inset variants.
106
+ variant === "floating" || variant === "inset"
107
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
108
+ : "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l", className), ...props, children: _jsx("div", { className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow", "data-sidebar": "sidebar", children: children }) })] }));
109
+ });
110
+ Sidebar.displayName = "Sidebar";
111
+ const SidebarTrigger = React.forwardRef(({ className, onClick, ...props }, ref) => {
112
+ const { toggleSidebar } = useSidebar();
113
+ return (_jsxs(Button, { className: cn("h-7 w-7", className), "data-sidebar": "trigger", onClick: (event) => {
114
+ onClick?.(event);
115
+ toggleSidebar();
116
+ }, ref: ref, size: "icon", variant: "ghost", ...props, children: [_jsx(PanelLeft, {}), _jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
117
+ });
118
+ SidebarTrigger.displayName = "SidebarTrigger";
119
+ const SidebarRail = React.forwardRef(({ className, ...props }, ref) => {
120
+ const { toggleSidebar } = useSidebar();
121
+ return (_jsx("button", { type: "button", "aria-label": "Toggle Sidebar", className: cn("-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex", "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className), "data-sidebar": "rail", onClick: toggleSidebar, ref: ref, tabIndex: -1, title: "Toggle Sidebar", ...props }));
122
+ });
123
+ SidebarRail.displayName = "SidebarRail";
124
+ const SidebarInset = React.forwardRef(({ className, ...props }, ref) => {
125
+ return (_jsx("main", { className: cn("relative flex w-full flex-1 flex-col bg-background", "md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow", className), ref: ref, ...props }));
126
+ });
127
+ SidebarInset.displayName = "SidebarInset";
128
+ const SidebarInput = React.forwardRef(({ className, ...props }, ref) => {
129
+ return (_jsx(Input, { className: cn("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring", className), "data-sidebar": "input", ref: ref, ...props }));
130
+ });
131
+ SidebarInput.displayName = "SidebarInput";
132
+ const SidebarHeader = React.forwardRef(({ className, ...props }, ref) => {
133
+ return (_jsx("div", { className: cn("flex flex-col gap-2 p-2", className), "data-sidebar": "header", ref: ref, ...props }));
134
+ });
135
+ SidebarHeader.displayName = "SidebarHeader";
136
+ const SidebarFooter = React.forwardRef(({ className, ...props }, ref) => {
137
+ return (_jsx("div", { className: cn("flex flex-col gap-2 p-2", className), "data-sidebar": "footer", ref: ref, ...props }));
138
+ });
139
+ SidebarFooter.displayName = "SidebarFooter";
140
+ const SidebarSeparator = React.forwardRef(({ className, ...props }, ref) => {
141
+ return (_jsx("div", { className: cn("mx-2 h-px w-auto bg-sidebar-border", className), "data-sidebar": "separator", ref: ref, ...props }));
142
+ });
143
+ SidebarSeparator.displayName = "SidebarSeparator";
144
+ const SidebarContent = React.forwardRef(({ className, ...props }, ref) => {
145
+ return (_jsx("div", { className: cn("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className), "data-sidebar": "content", ref: ref, ...props }));
146
+ });
147
+ SidebarContent.displayName = "SidebarContent";
148
+ const SidebarGroup = React.forwardRef(({ className, ...props }, ref) => {
149
+ return (_jsx("div", { className: cn("relative flex w-full min-w-0 flex-col p-2", className), "data-sidebar": "group", ref: ref, ...props }));
150
+ });
151
+ SidebarGroup.displayName = "SidebarGroup";
152
+ const SidebarGroupLabel = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
153
+ const Comp = asChild ? SlotPrimitive : "div";
154
+ return (_jsx(Comp, { className: cn("flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0", className), "data-sidebar": "group-label", ref: ref, ...props }));
155
+ });
156
+ SidebarGroupLabel.displayName = "SidebarGroupLabel";
157
+ const SidebarGroupAction = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
158
+ const Comp = asChild ? SlotPrimitive : "button";
159
+ return (_jsx(Comp, { className: cn("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
160
+ // Increases the hit area of the button on mobile.
161
+ "after:-inset-2 after:absolute after:md:hidden", "group-data-[collapsible=icon]:hidden", className), "data-sidebar": "group-action", ref: ref, type: "button", ...props }));
162
+ });
163
+ SidebarGroupAction.displayName = "SidebarGroupAction";
164
+ const SidebarGroupContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { className: cn("w-full text-sm", className), "data-sidebar": "group-content", ref: ref, ...props })));
165
+ SidebarGroupContent.displayName = "SidebarGroupContent";
166
+ const SidebarMenu = React.forwardRef(({ className, ...props }, ref) => (_jsx("ul", { className: cn("flex w-full min-w-0 flex-col gap-1", className), "data-sidebar": "menu", ref: ref, ...props })));
167
+ SidebarMenu.displayName = "SidebarMenu";
168
+ const SidebarMenuItem = React.forwardRef(({ className, ...props }, ref) => (_jsx("li", { className: cn("group/menu-item relative", className), "data-sidebar": "menu-item", ref: ref, ...props })));
169
+ SidebarMenuItem.displayName = "SidebarMenuItem";
170
+ const sidebarMenuButtonVariants = cva("peer/menu-button group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
171
+ variants: {
172
+ variant: {
173
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
174
+ outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
175
+ },
176
+ size: {
177
+ default: "h-8 text-sm",
178
+ sm: "h-7 text-xs",
179
+ lg: "group-data-[collapsible=icon]:!p-0 h-12 text-sm",
180
+ },
181
+ },
182
+ defaultVariants: {
183
+ variant: "default",
184
+ size: "default",
185
+ },
186
+ });
187
+ const SidebarMenuButton = React.forwardRef(({ asChild = false, isActive = false, variant = "default", size = "default", tooltip, className, ...props }, ref) => {
188
+ const Comp = asChild ? SlotPrimitive : "button";
189
+ const { isMobile, state } = useSidebar();
190
+ const button = (_jsx(Comp, { className: cn(sidebarMenuButtonVariants({ variant, size }), className), "data-active": isActive, "data-sidebar": "menu-button", "data-size": size, ref: ref, type: asChild ? undefined : "button", ...props }));
191
+ if (!tooltip) {
192
+ return button;
193
+ }
194
+ if (typeof tooltip === "string") {
195
+ tooltip = {
196
+ children: tooltip,
197
+ };
198
+ }
199
+ return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { align: "center", hidden: state !== "collapsed" || isMobile, side: "right", ...tooltip })] }));
200
+ });
201
+ SidebarMenuButton.displayName = "SidebarMenuButton";
202
+ const SidebarMenuAction = React.forwardRef(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
203
+ const Comp = asChild ? SlotPrimitive : "button";
204
+ return (_jsx(Comp, { className: cn("absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
205
+ // Increases the hit area of the button on mobile.
206
+ "after:-inset-2 after:absolute after:md:hidden", "peer-data-[size=sm]/menu-button:top-1", "peer-data-[size=default]/menu-button:top-1.5", "peer-data-[size=lg]/menu-button:top-2.5", "group-data-[collapsible=icon]:hidden", showOnHover &&
207
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0", className), "data-sidebar": "menu-action", ref: ref, type: asChild ? undefined : "button", ...props }));
208
+ });
209
+ SidebarMenuAction.displayName = "SidebarMenuAction";
210
+ const SidebarMenuBadge = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { className: cn("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 font-medium text-sidebar-foreground text-xs tabular-nums", "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground", "peer-data-[size=sm]/menu-button:top-1", "peer-data-[size=default]/menu-button:top-1.5", "peer-data-[size=lg]/menu-button:top-2.5", "group-data-[collapsible=icon]:hidden", className), "data-sidebar": "menu-badge", ref: ref, ...props })));
211
+ SidebarMenuBadge.displayName = "SidebarMenuBadge";
212
+ const SidebarMenuSkeleton = React.forwardRef(({ className, showIcon = false, ...props }, ref) => {
213
+ // Random width between 50 to 90%.
214
+ const width = React.useMemo(() => {
215
+ return `${Math.floor(Math.random() * 40) + 50}%`;
216
+ }, []);
217
+ return (_jsxs("div", { className: cn("flex h-8 items-center gap-2 rounded-md px-2", className), "data-sidebar": "menu-skeleton", ref: ref, ...props, children: [showIcon && (_jsx("div", { className: "size-4 rounded-md bg-sidebar-accent-foreground/10 animate-pulse", "data-sidebar": "menu-skeleton-icon" })), _jsx("div", { className: "h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse", "data-sidebar": "menu-skeleton-text", style: {
218
+ maxWidth: width,
219
+ } })] }));
220
+ });
221
+ SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
222
+ const SidebarMenuSub = React.forwardRef(({ className, ...props }, ref) => (_jsx("ul", { className: cn("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5", "group-data-[collapsible=icon]:hidden", className), "data-sidebar": "menu-sub", ref: ref, ...props })));
223
+ SidebarMenuSub.displayName = "SidebarMenuSub";
224
+ const SidebarMenuSubItem = React.forwardRef(({ ...props }, ref) => _jsx("li", { ref: ref, ...props }));
225
+ SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
226
+ const SidebarMenuSubButton = React.forwardRef(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
227
+ const Comp = asChild ? SlotPrimitive : "a";
228
+ return (_jsx(Comp, { className: cn("-translate-x-px flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground", size === "sm" && "text-xs", size === "md" && "text-sm", "group-data-[collapsible=icon]:hidden", className), "data-active": isActive, "data-sidebar": "menu-sub-button", "data-size": size, ref: ref, ...props }));
229
+ });
230
+ SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
231
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
@@ -0,0 +1,3 @@
1
+ import type { ComponentProps } from "react";
2
+ import { type SidebarTrigger } from "./Sidebar.js";
3
+ export declare function SidebarToggle({ className, }: ComponentProps<typeof SidebarTrigger>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Menu } from "lucide-react";
3
+ import { cn } from "../lib/utils.js";
4
+ import { IconButton } from "./IconButton.js";
5
+ import { useSidebar } from "./Sidebar.js";
6
+ export function SidebarToggle({ className, }) {
7
+ const { toggleSidebar, open } = useSidebar();
8
+ return (_jsx(IconButton, { className: cn(className), "data-testid": "sidebar-toggle-button", "data-state": open ? "open" : "closed", onClick: toggleSidebar, "aria-label": "Toggle sidebar", children: _jsx(Menu, { className: "size-4 text-muted-foreground" }) }));
9
+ }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ToolCall } from "./ToolCall.js";
2
+ import { ToolOperation } from "./ToolOperation.js";
3
3
  /**
4
4
  * ToolCallList component - renders a list of tool calls, optionally grouped
5
5
  */
@@ -15,8 +15,8 @@ export function ToolCallList({ toolCalls, groupBy = "chronological", }) {
15
15
  completed: toolCalls.filter((tc) => tc.status === "completed"),
16
16
  failed: toolCalls.filter((tc) => tc.status === "failed"),
17
17
  };
18
- return (_jsxs("div", { className: "space-y-4", children: [grouped.in_progress.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "In Progress" }), grouped.in_progress.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] })), grouped.pending.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Pending" }), grouped.pending.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] })), grouped.completed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Completed" }), grouped.completed.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] })), grouped.failed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-2 pl-1", children: "Failed" }), grouped.failed.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id)))] }))] }));
18
+ return (_jsxs("div", { className: "space-y-4", children: [grouped.in_progress.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "In Progress" }), grouped.in_progress.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] })), grouped.pending.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Pending" }), grouped.pending.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] })), grouped.completed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-2 pl-1", children: "Completed" }), grouped.completed.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] })), grouped.failed.length > 0 && (_jsxs("div", { children: [_jsx("h4", { className: "text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-2 pl-1", children: "Failed" }), grouped.failed.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id)))] }))] }));
19
19
  }
20
20
  // Default: chronological order
21
- return (_jsx("div", { className: "space-y-2", children: toolCalls.map((tc) => (_jsx(ToolCall, { toolCall: tc }, tc.id))) }));
21
+ return (_jsx("div", { className: "space-y-2", children: toolCalls.map((tc) => (_jsx(ToolOperation, { toolCalls: [tc], isGrouped: false }, tc.id))) }));
22
22
  }
@@ -0,0 +1,11 @@
1
+ import type { ToolCall as ToolCallType } from "../../core/schemas/tool-call.js";
2
+ export interface ToolOperationProps {
3
+ toolCalls: ToolCallType[];
4
+ isGrouped?: boolean;
5
+ autoMinimize?: boolean;
6
+ }
7
+ /**
8
+ * ToolOperation component - unified display for tool calls
9
+ * Handles both individual and grouped tool calls with smooth transitions
10
+ */
11
+ export declare function ToolOperation({ toolCalls, isGrouped, autoMinimize, }: ToolOperationProps): import("react/jsx-runtime").JSX.Element;