@townco/ui 0.1.0 → 0.1.6
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.
- package/dist/core/hooks/use-chat-input.d.ts +17 -17
- package/dist/core/hooks/use-chat-input.js +64 -55
- package/dist/core/hooks/use-chat-messages.d.ts +11 -11
- package/dist/core/hooks/use-chat-messages.js +121 -114
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-chat-session.js +78 -80
- package/dist/core/hooks/use-media-query.d.ts +5 -5
- package/dist/core/hooks/use-media-query.js +38 -38
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/schemas/chat.d.ts +83 -56
- package/dist/core/schemas/chat.js +27 -25
- package/dist/core/store/chat-store.d.ts +28 -22
- package/dist/core/store/chat-store.js +59 -50
- package/dist/gui/components/Button.d.ts +23 -7
- package/dist/gui/components/Button.js +40 -27
- package/dist/gui/components/Card.d.ts +26 -7
- package/dist/gui/components/Card.js +54 -8
- package/dist/gui/components/ChatHeader.d.ts +58 -31
- package/dist/gui/components/ChatHeader.js +171 -66
- package/dist/gui/components/ChatInput.d.ts +58 -36
- package/dist/gui/components/ChatInput.js +191 -121
- package/dist/gui/components/ChatInterface.d.ts +9 -6
- package/dist/gui/components/ChatInterface.js +162 -90
- package/dist/gui/components/ChatLayout.d.ts +71 -41
- package/dist/gui/components/ChatLayout.js +214 -87
- package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
- package/dist/gui/components/ChatPanelTabContent.js +88 -10
- package/dist/gui/components/ChatPreview.d.ts +9 -6
- package/dist/gui/components/ChatPreview.js +212 -162
- package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
- package/dist/gui/components/ChatSecondaryPanel.js +115 -38
- package/dist/gui/components/ChatSidebar.d.ts +26 -13
- package/dist/gui/components/ChatSidebar.js +48 -14
- package/dist/gui/components/ChatStatus.d.ts +4 -2
- package/dist/gui/components/ChatStatus.js +45 -34
- package/dist/gui/components/ChatView.d.ts +5 -3
- package/dist/gui/components/ChatView.js +38 -9
- package/dist/gui/components/ConfigPanel.d.ts +16 -12
- package/dist/gui/components/ConfigPanel.js +218 -41
- package/dist/gui/components/Conversation.d.ts +17 -14
- package/dist/gui/components/Conversation.js +143 -83
- package/dist/gui/components/Dialog.d.ts +57 -11
- package/dist/gui/components/Dialog.js +84 -8
- package/dist/gui/components/DropdownMenu.d.ts +101 -20
- package/dist/gui/components/DropdownMenu.js +161 -14
- package/dist/gui/components/HeightTransition.d.ts +12 -7
- package/dist/gui/components/HeightTransition.js +88 -77
- package/dist/gui/components/Input.d.ts +13 -6
- package/dist/gui/components/Input.js +27 -16
- package/dist/gui/components/InputBox.d.ts +19 -12
- package/dist/gui/components/InputBox.js +86 -14
- package/dist/gui/components/Label.d.ts +7 -1
- package/dist/gui/components/Label.js +12 -2
- package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
- package/dist/gui/components/MarkdownRenderer.js +178 -81
- package/dist/gui/components/Message.d.ts +25 -18
- package/dist/gui/components/Message.js +44 -23
- package/dist/gui/components/MessageContent.d.ts +29 -22
- package/dist/gui/components/MessageContent.js +157 -85
- package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
- package/dist/gui/components/PlaygroundLayout.js +43 -12
- package/dist/gui/components/Reasoning.d.ts +30 -24
- package/dist/gui/components/Reasoning.js +187 -60
- package/dist/gui/components/Response.d.ts +11 -9
- package/dist/gui/components/Response.js +229 -90
- package/dist/gui/components/Select.d.ts +69 -10
- package/dist/gui/components/Select.js +118 -12
- package/dist/gui/components/Sonner.d.ts +3 -1
- package/dist/gui/components/Sonner.js +29 -18
- package/dist/gui/components/StatusBar.d.ts +9 -5
- package/dist/gui/components/StatusBar.js +56 -9
- package/dist/gui/components/Tabs.d.ts +24 -4
- package/dist/gui/components/Tabs.js +32 -4
- package/dist/gui/components/Task.d.ts +28 -24
- package/dist/gui/components/Task.js +164 -31
- package/dist/gui/components/Textarea.d.ts +15 -7
- package/dist/gui/components/Textarea.js +63 -46
- package/dist/gui/components/ThinkingBlock.d.ts +20 -10
- package/dist/gui/components/ThinkingBlock.js +134 -35
- package/dist/gui/components/TodoList.d.ts +12 -10
- package/dist/gui/components/TodoList.js +22 -7
- package/dist/gui/components/TodoListItem.d.ts +9 -6
- package/dist/gui/components/TodoListItem.js +18 -4
- package/dist/gui/components/index.d.ts +59 -8
- package/dist/gui/components/index.js +42 -8
- package/dist/gui/lib/utils.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.test.js +0 -1
- package/dist/sdk/client/acp-client.d.ts +88 -76
- package/dist/sdk/client/acp-client.js +215 -217
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/schemas/agent.d.ts +111 -64
- package/dist/sdk/schemas/agent.js +24 -24
- package/dist/sdk/schemas/message.d.ts +245 -147
- package/dist/sdk/schemas/message.js +40 -40
- package/dist/sdk/schemas/session.d.ts +219 -135
- package/dist/sdk/schemas/session.js +27 -27
- package/dist/sdk/transports/http.d.ts +55 -55
- package/dist/sdk/transports/http.js +472 -469
- package/dist/sdk/transports/stdio.d.ts +20 -20
- package/dist/sdk/transports/stdio.js +289 -286
- package/dist/sdk/transports/types.d.ts +42 -42
- package/dist/sdk/transports/websocket.d.ts +12 -12
- package/dist/sdk/transports/websocket.js +52 -46
- package/dist/tui/components/ChatView.d.ts +4 -2
- package/dist/tui/components/ChatView.js +51 -18
- package/dist/tui/components/GameOfLife.js +64 -35
- package/dist/tui/components/InputBox.d.ts +18 -11
- package/dist/tui/components/InputBox.js +70 -10
- package/dist/tui/components/MessageList.d.ts +4 -2
- package/dist/tui/components/MessageList.js +37 -10
- package/dist/tui/components/MultiSelect.d.ts +15 -9
- package/dist/tui/components/MultiSelect.js +116 -69
- package/dist/tui/components/ReadlineInput.d.ts +12 -6
- package/dist/tui/components/ReadlineInput.js +252 -237
- package/dist/tui/components/SingleSelect.d.ts +15 -9
- package/dist/tui/components/SingleSelect.js +84 -43
- package/dist/tui/components/StatusBar.d.ts +11 -6
- package/dist/tui/components/StatusBar.js +102 -67
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +2 -3
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const Card: React.ForwardRefExoticComponent<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
declare const Card: React.ForwardRefExoticComponent<
|
|
3
|
+
React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>
|
|
4
|
+
>;
|
|
5
|
+
declare const CardHeader: React.ForwardRefExoticComponent<
|
|
6
|
+
React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>
|
|
7
|
+
>;
|
|
8
|
+
declare const CardTitle: React.ForwardRefExoticComponent<
|
|
9
|
+
React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>
|
|
10
|
+
>;
|
|
11
|
+
declare const CardDescription: React.ForwardRefExoticComponent<
|
|
12
|
+
React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>
|
|
13
|
+
>;
|
|
14
|
+
declare const CardContent: React.ForwardRefExoticComponent<
|
|
15
|
+
React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>
|
|
16
|
+
>;
|
|
17
|
+
declare const CardFooter: React.ForwardRefExoticComponent<
|
|
18
|
+
React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>
|
|
19
|
+
>;
|
|
20
|
+
export {
|
|
21
|
+
Card,
|
|
22
|
+
CardHeader,
|
|
23
|
+
CardFooter,
|
|
24
|
+
CardTitle,
|
|
25
|
+
CardDescription,
|
|
26
|
+
CardContent,
|
|
27
|
+
};
|
|
@@ -1,16 +1,62 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import * as React from "react";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef(({ className, ...props }, ref) =>
|
|
6
|
+
_jsx("div", {
|
|
7
|
+
ref: ref,
|
|
8
|
+
className: cn(
|
|
9
|
+
"rounded-lg border bg-card text-card-foreground shadow-sm",
|
|
10
|
+
className,
|
|
11
|
+
),
|
|
12
|
+
...props,
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
5
15
|
Card.displayName = "Card";
|
|
6
|
-
const CardHeader = React.forwardRef(({ className, ...props }, ref) =>
|
|
16
|
+
const CardHeader = React.forwardRef(({ className, ...props }, ref) =>
|
|
17
|
+
_jsx("div", {
|
|
18
|
+
ref: ref,
|
|
19
|
+
className: cn("flex flex-col space-y-1.5 p-6", className),
|
|
20
|
+
...props,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
7
23
|
CardHeader.displayName = "CardHeader";
|
|
8
|
-
const CardTitle = React.forwardRef(({ className, ...props }, ref) =>
|
|
24
|
+
const CardTitle = React.forwardRef(({ className, ...props }, ref) =>
|
|
25
|
+
_jsx("div", {
|
|
26
|
+
ref: ref,
|
|
27
|
+
className: cn(
|
|
28
|
+
"text-2xl font-semibold leading-none tracking-tight",
|
|
29
|
+
className,
|
|
30
|
+
),
|
|
31
|
+
...props,
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
9
34
|
CardTitle.displayName = "CardTitle";
|
|
10
|
-
const CardDescription = React.forwardRef(({ className, ...props }, ref) =>
|
|
35
|
+
const CardDescription = React.forwardRef(({ className, ...props }, ref) =>
|
|
36
|
+
_jsx("div", {
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
39
|
+
...props,
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
11
42
|
CardDescription.displayName = "CardDescription";
|
|
12
|
-
const CardContent = React.forwardRef(({ className, ...props }, ref) =>
|
|
43
|
+
const CardContent = React.forwardRef(({ className, ...props }, ref) =>
|
|
44
|
+
_jsx("div", { ref: ref, className: cn("p-6 pt-0", className), ...props }),
|
|
45
|
+
);
|
|
13
46
|
CardContent.displayName = "CardContent";
|
|
14
|
-
const CardFooter = React.forwardRef(({ className, ...props }, ref) =>
|
|
47
|
+
const CardFooter = React.forwardRef(({ className, ...props }, ref) =>
|
|
48
|
+
_jsx("div", {
|
|
49
|
+
ref: ref,
|
|
50
|
+
className: cn("flex items-center p-6 pt-0", className),
|
|
51
|
+
...props,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
15
54
|
CardFooter.displayName = "CardFooter";
|
|
16
|
-
export {
|
|
55
|
+
export {
|
|
56
|
+
Card,
|
|
57
|
+
CardHeader,
|
|
58
|
+
CardFooter,
|
|
59
|
+
CardTitle,
|
|
60
|
+
CardDescription,
|
|
61
|
+
CardContent,
|
|
62
|
+
};
|
|
@@ -1,38 +1,65 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
interface ChatHeaderContextValue {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
isExpanded: boolean;
|
|
4
|
+
setIsExpanded: (expanded: boolean) => void;
|
|
5
5
|
}
|
|
6
6
|
declare const useChatHeaderContext: () => ChatHeaderContextValue;
|
|
7
|
-
export interface ChatHeaderRootProps
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export interface ChatHeaderRootProps
|
|
8
|
+
extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
/** Initial expanded state */
|
|
10
|
+
defaultExpanded?: boolean;
|
|
11
|
+
/** Controlled expanded state */
|
|
12
|
+
expanded?: boolean;
|
|
13
|
+
/** Callback when expanded state changes */
|
|
14
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
14
15
|
}
|
|
15
|
-
declare const ChatHeaderRoot: React.ForwardRefExoticComponent<
|
|
16
|
-
|
|
16
|
+
declare const ChatHeaderRoot: React.ForwardRefExoticComponent<
|
|
17
|
+
ChatHeaderRootProps & React.RefAttributes<HTMLDivElement>
|
|
18
|
+
>;
|
|
19
|
+
export interface ChatHeaderTitleProps
|
|
20
|
+
extends React.HTMLAttributes<HTMLHeadingElement> {}
|
|
21
|
+
declare const ChatHeaderTitle: React.ForwardRefExoticComponent<
|
|
22
|
+
ChatHeaderTitleProps & React.RefAttributes<HTMLHeadingElement>
|
|
23
|
+
>;
|
|
24
|
+
export interface ChatHeaderActionsProps
|
|
25
|
+
extends React.HTMLAttributes<HTMLDivElement> {}
|
|
26
|
+
declare const ChatHeaderActions: React.ForwardRefExoticComponent<
|
|
27
|
+
ChatHeaderActionsProps & React.RefAttributes<HTMLDivElement>
|
|
28
|
+
>;
|
|
29
|
+
export type ConnectionStatus =
|
|
30
|
+
| "connected"
|
|
31
|
+
| "connecting"
|
|
32
|
+
| "error"
|
|
33
|
+
| "disconnected";
|
|
34
|
+
export interface ChatHeaderStatusIndicatorProps
|
|
35
|
+
extends React.HTMLAttributes<HTMLDivElement> {
|
|
36
|
+
/** Connection status */
|
|
37
|
+
status: ConnectionStatus;
|
|
38
|
+
/** Optional status text override */
|
|
39
|
+
statusText?: string;
|
|
17
40
|
}
|
|
18
|
-
declare const
|
|
19
|
-
|
|
41
|
+
declare const ChatHeaderStatusIndicator: React.ForwardRefExoticComponent<
|
|
42
|
+
ChatHeaderStatusIndicatorProps & React.RefAttributes<HTMLDivElement>
|
|
43
|
+
>;
|
|
44
|
+
export interface ChatHeaderToggleProps
|
|
45
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
46
|
+
/** Icon to display (should rotate based on expanded state) */
|
|
47
|
+
icon?: React.ReactNode;
|
|
20
48
|
}
|
|
21
|
-
declare const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export { ChatHeaderRoot as Root, ChatHeaderTitle as Title, ChatHeaderActions as Actions, ChatHeaderStatusIndicator as StatusIndicator, ChatHeaderToggle as Toggle, ChatHeaderExpandablePanel as ExpandablePanel, useChatHeaderContext, };
|
|
49
|
+
declare const ChatHeaderToggle: React.ForwardRefExoticComponent<
|
|
50
|
+
ChatHeaderToggleProps & React.RefAttributes<HTMLButtonElement>
|
|
51
|
+
>;
|
|
52
|
+
export interface ChatHeaderExpandablePanelProps
|
|
53
|
+
extends React.HTMLAttributes<HTMLDivElement> {}
|
|
54
|
+
declare const ChatHeaderExpandablePanel: React.ForwardRefExoticComponent<
|
|
55
|
+
ChatHeaderExpandablePanelProps & React.RefAttributes<HTMLDivElement>
|
|
56
|
+
>;
|
|
57
|
+
export {
|
|
58
|
+
ChatHeaderRoot as Root,
|
|
59
|
+
ChatHeaderTitle as Title,
|
|
60
|
+
ChatHeaderActions as Actions,
|
|
61
|
+
ChatHeaderStatusIndicator as StatusIndicator,
|
|
62
|
+
ChatHeaderToggle as Toggle,
|
|
63
|
+
ChatHeaderExpandablePanel as ExpandablePanel,
|
|
64
|
+
useChatHeaderContext,
|
|
65
|
+
};
|
|
@@ -1,84 +1,189 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import * as React from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
4
5
|
const ChatHeaderContext = React.createContext(undefined);
|
|
5
6
|
const useChatHeaderContext = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const context = React.useContext(ChatHeaderContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"ChatHeader components must be used within ChatHeader.Root",
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
11
14
|
};
|
|
12
|
-
const ChatHeaderRoot = React.forwardRef(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
const ChatHeaderRoot = React.forwardRef(
|
|
16
|
+
(
|
|
17
|
+
{
|
|
18
|
+
defaultExpanded = false,
|
|
19
|
+
expanded: expandedProp,
|
|
20
|
+
onExpandedChange,
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
25
|
+
ref,
|
|
26
|
+
) => {
|
|
27
|
+
const [isExpandedInternal, setIsExpandedInternal] =
|
|
28
|
+
React.useState(defaultExpanded);
|
|
29
|
+
const isExpanded = expandedProp ?? isExpandedInternal;
|
|
30
|
+
const setIsExpanded = React.useCallback(
|
|
31
|
+
(expanded) => {
|
|
32
|
+
setIsExpandedInternal(expanded);
|
|
33
|
+
onExpandedChange?.(expanded);
|
|
34
|
+
},
|
|
35
|
+
[onExpandedChange],
|
|
36
|
+
);
|
|
37
|
+
// Separate children into main content and expandable panel
|
|
38
|
+
const childrenArray = React.Children.toArray(children);
|
|
39
|
+
const expandablePanel = childrenArray.find(
|
|
40
|
+
(child) =>
|
|
41
|
+
React.isValidElement(child) &&
|
|
42
|
+
child.type?.displayName === "ChatHeader.ExpandablePanel",
|
|
43
|
+
);
|
|
44
|
+
const mainContent = childrenArray.filter(
|
|
45
|
+
(child) => child !== expandablePanel,
|
|
46
|
+
);
|
|
47
|
+
return _jsxs(ChatHeaderContext.Provider, {
|
|
48
|
+
value: { isExpanded, setIsExpanded },
|
|
49
|
+
children: [
|
|
50
|
+
_jsx("div", {
|
|
51
|
+
ref: ref,
|
|
52
|
+
className: cn(
|
|
53
|
+
"flex items-center justify-between px-6 py-4",
|
|
54
|
+
className,
|
|
55
|
+
),
|
|
56
|
+
...props,
|
|
57
|
+
children: mainContent,
|
|
58
|
+
}),
|
|
59
|
+
expandablePanel,
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
);
|
|
26
64
|
ChatHeaderRoot.displayName = "ChatHeader.Root";
|
|
27
|
-
const ChatHeaderTitle = React.forwardRef(
|
|
28
|
-
|
|
29
|
-
|
|
65
|
+
const ChatHeaderTitle = React.forwardRef(
|
|
66
|
+
({ className, children, ...props }, ref) => {
|
|
67
|
+
return _jsx("h1", {
|
|
68
|
+
ref: ref,
|
|
69
|
+
className: cn("m-0 text-xl font-semibold", className),
|
|
70
|
+
...props,
|
|
71
|
+
children: children,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
);
|
|
30
75
|
ChatHeaderTitle.displayName = "ChatHeader.Title";
|
|
31
|
-
const ChatHeaderActions = React.forwardRef(
|
|
32
|
-
|
|
33
|
-
|
|
76
|
+
const ChatHeaderActions = React.forwardRef(
|
|
77
|
+
({ className, children, ...props }, ref) => {
|
|
78
|
+
return _jsx("div", {
|
|
79
|
+
ref: ref,
|
|
80
|
+
className: cn("flex items-center gap-3", className),
|
|
81
|
+
...props,
|
|
82
|
+
children: children,
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
);
|
|
34
86
|
ChatHeaderActions.displayName = "ChatHeader.Actions";
|
|
35
87
|
const getStatusColor = (status) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
88
|
+
switch (status) {
|
|
89
|
+
case "connected":
|
|
90
|
+
return "bg-green-500";
|
|
91
|
+
case "connecting":
|
|
92
|
+
return "bg-yellow-500";
|
|
93
|
+
case "error":
|
|
94
|
+
return "bg-red-500";
|
|
95
|
+
default:
|
|
96
|
+
return "bg-gray-500";
|
|
97
|
+
}
|
|
46
98
|
};
|
|
47
99
|
const getDefaultStatusText = (status) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
100
|
+
switch (status) {
|
|
101
|
+
case "connected":
|
|
102
|
+
return "Connected";
|
|
103
|
+
case "connecting":
|
|
104
|
+
return "Connecting...";
|
|
105
|
+
case "error":
|
|
106
|
+
return "Connection Error";
|
|
107
|
+
default:
|
|
108
|
+
return "No Server";
|
|
109
|
+
}
|
|
58
110
|
};
|
|
59
|
-
const ChatHeaderStatusIndicator = React.forwardRef(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
111
|
+
const ChatHeaderStatusIndicator = React.forwardRef(
|
|
112
|
+
({ status, statusText, className, ...props }, ref) => {
|
|
113
|
+
const text = statusText ?? getDefaultStatusText(status);
|
|
114
|
+
const colorClass = getStatusColor(status);
|
|
115
|
+
return _jsxs("div", {
|
|
116
|
+
ref: ref,
|
|
117
|
+
className: cn("flex items-center gap-2", className),
|
|
118
|
+
...props,
|
|
119
|
+
children: [
|
|
120
|
+
_jsx("div", { className: cn("h-2 w-2 rounded-full", colorClass) }),
|
|
121
|
+
_jsx("span", {
|
|
122
|
+
className: "text-sm text-muted-foreground",
|
|
123
|
+
children: text,
|
|
124
|
+
}),
|
|
125
|
+
],
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
);
|
|
64
129
|
ChatHeaderStatusIndicator.displayName = "ChatHeader.StatusIndicator";
|
|
65
|
-
const ChatHeaderToggle = React.forwardRef(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
130
|
+
const ChatHeaderToggle = React.forwardRef(
|
|
131
|
+
({ icon, className, children, onClick, ...props }, ref) => {
|
|
132
|
+
const { isExpanded, setIsExpanded } = useChatHeaderContext();
|
|
133
|
+
const handleClick = (e) => {
|
|
134
|
+
setIsExpanded(!isExpanded);
|
|
135
|
+
onClick?.(e);
|
|
136
|
+
};
|
|
137
|
+
return _jsxs("button", {
|
|
138
|
+
ref: ref,
|
|
139
|
+
type: "button",
|
|
140
|
+
onClick: handleClick,
|
|
141
|
+
className: cn(
|
|
142
|
+
"rounded p-1 transition-colors hover:bg-background lg:hidden",
|
|
143
|
+
className,
|
|
144
|
+
),
|
|
145
|
+
"aria-label": isExpanded ? "Collapse header" : "Expand header",
|
|
146
|
+
...props,
|
|
147
|
+
children: [
|
|
148
|
+
icon &&
|
|
149
|
+
_jsx("div", {
|
|
150
|
+
className: cn(
|
|
151
|
+
"transition-transform duration-200",
|
|
152
|
+
isExpanded && "rotate-180",
|
|
153
|
+
),
|
|
154
|
+
children: icon,
|
|
155
|
+
}),
|
|
156
|
+
children,
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
);
|
|
73
161
|
ChatHeaderToggle.displayName = "ChatHeader.Toggle";
|
|
74
|
-
const ChatHeaderExpandablePanel = React.forwardRef(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
162
|
+
const ChatHeaderExpandablePanel = React.forwardRef(
|
|
163
|
+
({ className, children, ...props }, ref) => {
|
|
164
|
+
const { isExpanded } = useChatHeaderContext();
|
|
165
|
+
if (!isExpanded) return null;
|
|
166
|
+
return _jsx("div", {
|
|
167
|
+
ref: ref,
|
|
168
|
+
className: cn(
|
|
169
|
+
"absolute top-full left-0 right-0 z-50 border-b border-border bg-card px-6 py-4 shadow-lg lg:hidden",
|
|
170
|
+
className,
|
|
171
|
+
),
|
|
172
|
+
...props,
|
|
173
|
+
children: children,
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
);
|
|
80
177
|
ChatHeaderExpandablePanel.displayName = "ChatHeader.ExpandablePanel";
|
|
81
178
|
/* -------------------------------------------------------------------------------------------------
|
|
82
179
|
* Exports
|
|
83
180
|
* -----------------------------------------------------------------------------------------------*/
|
|
84
|
-
export {
|
|
181
|
+
export {
|
|
182
|
+
ChatHeaderRoot as Root,
|
|
183
|
+
ChatHeaderTitle as Title,
|
|
184
|
+
ChatHeaderActions as Actions,
|
|
185
|
+
ChatHeaderStatusIndicator as StatusIndicator,
|
|
186
|
+
ChatHeaderToggle as Toggle,
|
|
187
|
+
ChatHeaderExpandablePanel as ExpandablePanel,
|
|
188
|
+
useChatHeaderContext,
|
|
189
|
+
};
|
|
@@ -1,42 +1,64 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { AcpClient } from "../../sdk/client/index.js";
|
|
3
3
|
import type { Textarea } from "./Textarea.js";
|
|
4
|
-
export interface ChatInputRootProps
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
export interface ChatInputRootProps
|
|
5
|
+
extends Omit<
|
|
6
|
+
React.FormHTMLAttributes<HTMLFormElement>,
|
|
7
|
+
"onChange" | "onSubmit"
|
|
8
|
+
> {
|
|
9
|
+
/**
|
|
10
|
+
* ACP Client for hook-based input management (recommended pattern)
|
|
11
|
+
* Either client or value/onChange/onSubmit must be provided
|
|
12
|
+
*/
|
|
13
|
+
client?: AcpClient | null;
|
|
14
|
+
/**
|
|
15
|
+
* Input value (legacy prop-based pattern)
|
|
16
|
+
* Either client or value/onChange/onSubmit must be provided
|
|
17
|
+
*/
|
|
18
|
+
value?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Input change handler (legacy prop-based pattern)
|
|
21
|
+
*/
|
|
22
|
+
onChange?: (value: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Submit handler (legacy prop-based pattern)
|
|
25
|
+
*/
|
|
26
|
+
onSubmit?: () => void | Promise<void>;
|
|
27
|
+
/** Whether input is disabled */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Whether input is currently submitting */
|
|
30
|
+
isSubmitting?: boolean;
|
|
31
|
+
/** Whether to submit on Enter key (default: true) */
|
|
32
|
+
submitOnEnter?: boolean;
|
|
29
33
|
}
|
|
30
|
-
declare const ChatInputRoot: React.ForwardRefExoticComponent<
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
declare const ChatInputRoot: React.ForwardRefExoticComponent<
|
|
35
|
+
ChatInputRootProps & React.RefAttributes<HTMLFormElement>
|
|
36
|
+
>;
|
|
37
|
+
export interface ChatInputFieldProps
|
|
38
|
+
extends Omit<
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof Textarea>,
|
|
40
|
+
"value" | "onChange"
|
|
41
|
+
> {
|
|
42
|
+
asChild?: boolean;
|
|
33
43
|
}
|
|
34
|
-
declare const ChatInputField: React.ForwardRefExoticComponent<
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
declare const ChatInputField: React.ForwardRefExoticComponent<
|
|
45
|
+
ChatInputFieldProps & React.RefAttributes<HTMLTextAreaElement>
|
|
46
|
+
>;
|
|
47
|
+
export interface ChatInputSubmitProps
|
|
48
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
49
|
+
asChild?: boolean;
|
|
37
50
|
}
|
|
38
|
-
declare const ChatInputSubmit: React.ForwardRefExoticComponent<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
declare const ChatInputSubmit: React.ForwardRefExoticComponent<
|
|
52
|
+
ChatInputSubmitProps & React.RefAttributes<HTMLButtonElement>
|
|
53
|
+
>;
|
|
54
|
+
export interface ChatInputToolbarProps
|
|
55
|
+
extends React.HTMLAttributes<HTMLDivElement> {}
|
|
56
|
+
declare const ChatInputToolbar: React.ForwardRefExoticComponent<
|
|
57
|
+
ChatInputToolbarProps & React.RefAttributes<HTMLDivElement>
|
|
58
|
+
>;
|
|
59
|
+
export {
|
|
60
|
+
ChatInputRoot as Root,
|
|
61
|
+
ChatInputField as Field,
|
|
62
|
+
ChatInputSubmit as Submit,
|
|
63
|
+
ChatInputToolbar as Toolbar,
|
|
64
|
+
};
|