@townco/ui 0.1.0 → 0.1.3
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,9 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
3
2
|
import { Check, ChevronRight, Circle } from "lucide-react";
|
|
4
3
|
import * as React from "react";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
|
+
|
|
6
7
|
/* -------------------------------------------------------------------------------------------------
|
|
7
8
|
* DropdownMenu Root
|
|
8
9
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -15,54 +16,200 @@ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
|
15
16
|
/* -------------------------------------------------------------------------------------------------
|
|
16
17
|
* DropdownMenuSubTrigger
|
|
17
18
|
* -----------------------------------------------------------------------------------------------*/
|
|
18
|
-
const DropdownMenuSubTrigger = React.forwardRef(
|
|
19
|
+
const DropdownMenuSubTrigger = React.forwardRef(
|
|
20
|
+
({ className, inset, children, ...props }, ref) =>
|
|
21
|
+
_jsxs(DropdownMenuPrimitive.SubTrigger, {
|
|
22
|
+
ref: ref,
|
|
23
|
+
className: cn(
|
|
24
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
25
|
+
"focus:bg-muted data-[state=open]:bg-muted",
|
|
26
|
+
inset && "pl-8",
|
|
27
|
+
className,
|
|
28
|
+
),
|
|
29
|
+
...props,
|
|
30
|
+
children: [
|
|
31
|
+
children,
|
|
32
|
+
_jsx(ChevronRight, { className: "ml-auto h-4 w-4" }),
|
|
33
|
+
],
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
19
36
|
DropdownMenuSubTrigger.displayName =
|
|
20
|
-
|
|
37
|
+
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
21
38
|
/* -------------------------------------------------------------------------------------------------
|
|
22
39
|
* DropdownMenuSubContent
|
|
23
40
|
* -----------------------------------------------------------------------------------------------*/
|
|
24
|
-
const DropdownMenuSubContent = React.forwardRef(
|
|
41
|
+
const DropdownMenuSubContent = React.forwardRef(
|
|
42
|
+
({ className, ...props }, ref) =>
|
|
43
|
+
_jsx(DropdownMenuPrimitive.SubContent, {
|
|
44
|
+
ref: ref,
|
|
45
|
+
className: cn(
|
|
46
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 shadow-lg",
|
|
47
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
48
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
49
|
+
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
50
|
+
"data-[side=bottom]:slide-in-from-top-2",
|
|
51
|
+
"data-[side=left]:slide-in-from-right-2",
|
|
52
|
+
"data-[side=right]:slide-in-from-left-2",
|
|
53
|
+
"data-[side=top]:slide-in-from-bottom-2",
|
|
54
|
+
className,
|
|
55
|
+
),
|
|
56
|
+
...props,
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
25
59
|
DropdownMenuSubContent.displayName =
|
|
26
|
-
|
|
60
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
27
61
|
/* -------------------------------------------------------------------------------------------------
|
|
28
62
|
* DropdownMenuContent
|
|
29
63
|
* -----------------------------------------------------------------------------------------------*/
|
|
30
|
-
const DropdownMenuContent = React.forwardRef(
|
|
64
|
+
const DropdownMenuContent = React.forwardRef(
|
|
65
|
+
({ className, sideOffset = 4, ...props }, ref) =>
|
|
66
|
+
_jsx(DropdownMenuPrimitive.Portal, {
|
|
67
|
+
children: _jsx(DropdownMenuPrimitive.Content, {
|
|
68
|
+
ref: ref,
|
|
69
|
+
sideOffset: sideOffset,
|
|
70
|
+
className: cn(
|
|
71
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 shadow-md",
|
|
72
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
73
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
74
|
+
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
75
|
+
"data-[side=bottom]:slide-in-from-top-2",
|
|
76
|
+
"data-[side=left]:slide-in-from-right-2",
|
|
77
|
+
"data-[side=right]:slide-in-from-left-2",
|
|
78
|
+
"data-[side=top]:slide-in-from-bottom-2",
|
|
79
|
+
className,
|
|
80
|
+
),
|
|
81
|
+
...props,
|
|
82
|
+
}),
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
31
85
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
32
86
|
/* -------------------------------------------------------------------------------------------------
|
|
33
87
|
* DropdownMenuItem
|
|
34
88
|
* -----------------------------------------------------------------------------------------------*/
|
|
35
|
-
const DropdownMenuItem = React.forwardRef(
|
|
89
|
+
const DropdownMenuItem = React.forwardRef(
|
|
90
|
+
({ className, inset, ...props }, ref) =>
|
|
91
|
+
_jsx(DropdownMenuPrimitive.Item, {
|
|
92
|
+
ref: ref,
|
|
93
|
+
className: cn(
|
|
94
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
|
|
95
|
+
"focus:bg-muted focus:text-foreground",
|
|
96
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
97
|
+
inset && "pl-8",
|
|
98
|
+
className,
|
|
99
|
+
),
|
|
100
|
+
...props,
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
36
103
|
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
37
104
|
/* -------------------------------------------------------------------------------------------------
|
|
38
105
|
* DropdownMenuCheckboxItem
|
|
39
106
|
* -----------------------------------------------------------------------------------------------*/
|
|
40
|
-
const DropdownMenuCheckboxItem = React.forwardRef(
|
|
107
|
+
const DropdownMenuCheckboxItem = React.forwardRef(
|
|
108
|
+
({ className, children, ...props }, ref) =>
|
|
109
|
+
_jsxs(DropdownMenuPrimitive.CheckboxItem, {
|
|
110
|
+
ref: ref,
|
|
111
|
+
className: cn(
|
|
112
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors",
|
|
113
|
+
"focus:bg-muted focus:text-foreground",
|
|
114
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
115
|
+
className,
|
|
116
|
+
),
|
|
117
|
+
...props,
|
|
118
|
+
children: [
|
|
119
|
+
_jsx("span", {
|
|
120
|
+
className:
|
|
121
|
+
"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
122
|
+
children: _jsx(DropdownMenuPrimitive.ItemIndicator, {
|
|
123
|
+
children: _jsx(Check, { className: "h-4 w-4" }),
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
126
|
+
children,
|
|
127
|
+
],
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
41
130
|
DropdownMenuCheckboxItem.displayName =
|
|
42
|
-
|
|
131
|
+
DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
43
132
|
/* -------------------------------------------------------------------------------------------------
|
|
44
133
|
* DropdownMenuRadioItem
|
|
45
134
|
* -----------------------------------------------------------------------------------------------*/
|
|
46
|
-
const DropdownMenuRadioItem = React.forwardRef(
|
|
135
|
+
const DropdownMenuRadioItem = React.forwardRef(
|
|
136
|
+
({ className, children, ...props }, ref) =>
|
|
137
|
+
_jsxs(DropdownMenuPrimitive.RadioItem, {
|
|
138
|
+
ref: ref,
|
|
139
|
+
className: cn(
|
|
140
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors",
|
|
141
|
+
"focus:bg-muted focus:text-foreground",
|
|
142
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
143
|
+
className,
|
|
144
|
+
),
|
|
145
|
+
...props,
|
|
146
|
+
children: [
|
|
147
|
+
_jsx("span", {
|
|
148
|
+
className:
|
|
149
|
+
"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
150
|
+
children: _jsx(DropdownMenuPrimitive.ItemIndicator, {
|
|
151
|
+
children: _jsx(Circle, { className: "h-2 w-2 fill-current" }),
|
|
152
|
+
}),
|
|
153
|
+
}),
|
|
154
|
+
children,
|
|
155
|
+
],
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
47
158
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
48
159
|
/* -------------------------------------------------------------------------------------------------
|
|
49
160
|
* DropdownMenuLabel
|
|
50
161
|
* -----------------------------------------------------------------------------------------------*/
|
|
51
|
-
const DropdownMenuLabel = React.forwardRef(
|
|
162
|
+
const DropdownMenuLabel = React.forwardRef(
|
|
163
|
+
({ className, inset, ...props }, ref) =>
|
|
164
|
+
_jsx(DropdownMenuPrimitive.Label, {
|
|
165
|
+
ref: ref,
|
|
166
|
+
className: cn(
|
|
167
|
+
"px-2 py-1.5 text-sm font-semibold",
|
|
168
|
+
inset && "pl-8",
|
|
169
|
+
className,
|
|
170
|
+
),
|
|
171
|
+
...props,
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
52
174
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
53
175
|
/* -------------------------------------------------------------------------------------------------
|
|
54
176
|
* DropdownMenuSeparator
|
|
55
177
|
* -----------------------------------------------------------------------------------------------*/
|
|
56
|
-
const DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) =>
|
|
178
|
+
const DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) =>
|
|
179
|
+
_jsx(DropdownMenuPrimitive.Separator, {
|
|
180
|
+
ref: ref,
|
|
181
|
+
className: cn("-mx-1 my-1 h-px bg-border", className),
|
|
182
|
+
...props,
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
57
185
|
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
58
186
|
/* -------------------------------------------------------------------------------------------------
|
|
59
187
|
* DropdownMenuShortcut
|
|
60
188
|
* -----------------------------------------------------------------------------------------------*/
|
|
61
189
|
const DropdownMenuShortcut = ({ className, ...props }) => {
|
|
62
|
-
|
|
190
|
+
return _jsx("span", {
|
|
191
|
+
className: cn("ml-auto text-xs tracking-widest opacity-60", className),
|
|
192
|
+
...props,
|
|
193
|
+
});
|
|
63
194
|
};
|
|
64
195
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
65
196
|
/* -------------------------------------------------------------------------------------------------
|
|
66
197
|
* Exports
|
|
67
198
|
* -----------------------------------------------------------------------------------------------*/
|
|
68
|
-
export {
|
|
199
|
+
export {
|
|
200
|
+
DropdownMenu,
|
|
201
|
+
DropdownMenuTrigger,
|
|
202
|
+
DropdownMenuContent,
|
|
203
|
+
DropdownMenuItem,
|
|
204
|
+
DropdownMenuCheckboxItem,
|
|
205
|
+
DropdownMenuRadioItem,
|
|
206
|
+
DropdownMenuLabel,
|
|
207
|
+
DropdownMenuSeparator,
|
|
208
|
+
DropdownMenuShortcut,
|
|
209
|
+
DropdownMenuGroup,
|
|
210
|
+
DropdownMenuPortal,
|
|
211
|
+
DropdownMenuSub,
|
|
212
|
+
DropdownMenuSubContent,
|
|
213
|
+
DropdownMenuSubTrigger,
|
|
214
|
+
DropdownMenuRadioGroup,
|
|
215
|
+
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
interface HeightTransitionProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
durationMs?: number;
|
|
5
|
+
easing?: string;
|
|
6
|
+
pinContentTo?: "top" | "bottom";
|
|
7
|
+
className?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function HeightTransition({
|
|
10
|
-
|
|
9
|
+
export declare function HeightTransition({
|
|
10
|
+
children,
|
|
11
|
+
durationMs,
|
|
12
|
+
easing,
|
|
13
|
+
pinContentTo,
|
|
14
|
+
className,
|
|
15
|
+
}: HeightTransitionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,80 +1,91 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
|
-
export function HeightTransition({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
4
|
+
export function HeightTransition({
|
|
5
|
+
children,
|
|
6
|
+
durationMs = 320,
|
|
7
|
+
easing = "ease",
|
|
8
|
+
pinContentTo = "top",
|
|
9
|
+
className,
|
|
10
|
+
}) {
|
|
11
|
+
const containerRef = useRef(null);
|
|
12
|
+
const contentRef = useRef(null);
|
|
13
|
+
const prevHeightRef = useRef(null);
|
|
14
|
+
const isAnimatingRef = useRef(false);
|
|
15
|
+
const durationRef = useRef(durationMs);
|
|
16
|
+
const easingRef = useRef(easing);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
durationRef.current = durationMs;
|
|
19
|
+
easingRef.current = easing;
|
|
20
|
+
}, [durationMs, easing]);
|
|
21
|
+
const transitionTo = useCallback(
|
|
22
|
+
(next) => {
|
|
23
|
+
const el = containerRef.current;
|
|
24
|
+
const contentEl = contentRef.current;
|
|
25
|
+
if (!el || !contentEl) return;
|
|
26
|
+
const prev = prevHeightRef.current ?? el.getBoundingClientRect().height;
|
|
27
|
+
if (Math.abs(prev - next) < 0.5) {
|
|
28
|
+
prevHeightRef.current = next;
|
|
29
|
+
el.style.height = `${next}px`;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (isAnimatingRef.current) return;
|
|
33
|
+
isAnimatingRef.current = true;
|
|
34
|
+
el.style.transition = "none";
|
|
35
|
+
el.style.height = `${prev}px`;
|
|
36
|
+
void el.getBoundingClientRect();
|
|
37
|
+
el.style.transition = `height ${durationRef.current}ms ${easingRef.current}`;
|
|
38
|
+
el.style.height = `${next}px`;
|
|
39
|
+
contentEl.style.position = "absolute";
|
|
40
|
+
if (pinContentTo === "top") {
|
|
41
|
+
contentEl.style.top = "0";
|
|
42
|
+
} else {
|
|
43
|
+
contentEl.style.bottom = "0";
|
|
44
|
+
}
|
|
45
|
+
prevHeightRef.current = next;
|
|
46
|
+
},
|
|
47
|
+
[pinContentTo],
|
|
48
|
+
);
|
|
49
|
+
const onEndTransition = useCallback((e) => {
|
|
50
|
+
const el = containerRef.current;
|
|
51
|
+
const contentEl = contentRef.current;
|
|
52
|
+
if (!el || !contentEl) return;
|
|
53
|
+
if (e.propertyName !== "height") return;
|
|
54
|
+
if (e.target !== el) return;
|
|
55
|
+
el.style.transition = "";
|
|
56
|
+
el.style.height = `auto`;
|
|
57
|
+
contentEl.style.removeProperty("position");
|
|
58
|
+
contentEl.style.removeProperty("top");
|
|
59
|
+
contentEl.style.removeProperty("bottom");
|
|
60
|
+
isAnimatingRef.current = false;
|
|
61
|
+
}, []);
|
|
62
|
+
// Observe intrinsic content height changes and animate container height accordingly
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const el = containerRef.current;
|
|
65
|
+
const contentEl = contentRef.current;
|
|
66
|
+
if (!el || !contentEl) return;
|
|
67
|
+
const initial = contentEl.scrollHeight;
|
|
68
|
+
prevHeightRef.current = initial;
|
|
69
|
+
const ro = new ResizeObserver(() => {
|
|
70
|
+
const next = contentEl.scrollHeight;
|
|
71
|
+
transitionTo(next);
|
|
72
|
+
});
|
|
73
|
+
ro.observe(contentEl);
|
|
74
|
+
el.addEventListener("transitionend", onEndTransition);
|
|
75
|
+
return () => {
|
|
76
|
+
ro.disconnect();
|
|
77
|
+
el.removeEventListener("transitionend", onEndTransition);
|
|
78
|
+
};
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, [onEndTransition, transitionTo]);
|
|
81
|
+
return _jsx("div", {
|
|
82
|
+
ref: containerRef,
|
|
83
|
+
className: cn("overflow-hidden relative", className),
|
|
84
|
+
style: { willChange: "height" },
|
|
85
|
+
children: _jsx("div", {
|
|
86
|
+
ref: contentRef,
|
|
87
|
+
className: "w-full",
|
|
88
|
+
children: children,
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
80
91
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
declare const inputVariants: (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
3
|
+
declare const inputVariants: (
|
|
4
|
+
props?:
|
|
5
|
+
| ({
|
|
6
|
+
variant?: "default" | "error" | "success" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp)
|
|
8
|
+
| undefined,
|
|
9
|
+
) => string;
|
|
10
|
+
export interface InputProps
|
|
11
|
+
extends React.InputHTMLAttributes<HTMLInputElement>,
|
|
12
|
+
VariantProps<typeof inputVariants> {}
|
|
13
|
+
declare const Input: React.ForwardRefExoticComponent<
|
|
14
|
+
InputProps & React.RefAttributes<HTMLInputElement>
|
|
15
|
+
>;
|
|
9
16
|
export { Input, inputVariants };
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cva } from "class-variance-authority";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
5
|
+
|
|
6
|
+
const inputVariants = cva(
|
|
7
|
+
"flex h-10 w-full rounded-md border bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "border-input focus-visible:ring-ring",
|
|
12
|
+
error: "border-destructive focus-visible:ring-destructive",
|
|
13
|
+
success: "border-green-500 focus-visible:ring-green-500",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: "default",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
const Input = React.forwardRef(
|
|
22
|
+
({ className, type, variant, ...props }, ref) => {
|
|
23
|
+
return _jsx("input", {
|
|
24
|
+
type: type,
|
|
25
|
+
className: cn(inputVariants({ variant, className })),
|
|
26
|
+
ref: ref,
|
|
27
|
+
...props,
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
);
|
|
20
31
|
Input.displayName = "Input";
|
|
21
32
|
export { Input, inputVariants };
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
export interface InputBoxProps {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
value: string;
|
|
3
|
+
isSubmitting: boolean;
|
|
4
|
+
attachedFiles: Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
size: number;
|
|
8
|
+
}>;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
onSubmit: () => void;
|
|
11
|
+
onRemoveFile?: (index: number) => void;
|
|
12
12
|
}
|
|
13
|
-
export declare function InputBox({
|
|
14
|
-
|
|
13
|
+
export declare function InputBox({
|
|
14
|
+
value,
|
|
15
|
+
isSubmitting,
|
|
16
|
+
attachedFiles,
|
|
17
|
+
onChange,
|
|
18
|
+
onSubmit,
|
|
19
|
+
onRemoveFile,
|
|
20
|
+
}: InputBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=InputBox.d.ts.map
|
|
@@ -1,18 +1,90 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export function InputBox({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export function InputBox({
|
|
3
|
+
value,
|
|
4
|
+
isSubmitting,
|
|
5
|
+
attachedFiles,
|
|
6
|
+
onChange,
|
|
7
|
+
onSubmit,
|
|
8
|
+
onRemoveFile,
|
|
9
|
+
}) {
|
|
10
|
+
const handleKeyDown = (e) => {
|
|
11
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
onSubmit();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return _jsxs("div", {
|
|
17
|
+
className: "border-t border-gray-200 bg-white p-4",
|
|
18
|
+
children: [
|
|
19
|
+
attachedFiles.length > 0 &&
|
|
20
|
+
_jsxs("div", {
|
|
21
|
+
className: "mb-3 space-y-1",
|
|
22
|
+
children: [
|
|
23
|
+
_jsx("p", {
|
|
24
|
+
className: "text-xs text-gray-500",
|
|
25
|
+
children: "Attached files:",
|
|
26
|
+
}),
|
|
27
|
+
_jsx("div", {
|
|
28
|
+
className: "flex flex-wrap gap-2",
|
|
29
|
+
children: attachedFiles.map((file, index) =>
|
|
30
|
+
_jsxs(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
className:
|
|
34
|
+
"flex items-center gap-2 px-3 py-1 bg-cyan-50 text-cyan-700 rounded-full text-xs",
|
|
35
|
+
children: [
|
|
36
|
+
_jsx("span", { children: file.name }),
|
|
37
|
+
_jsxs("span", {
|
|
38
|
+
className: "text-gray-400",
|
|
39
|
+
children: ["(", formatFileSize(file.size), ")"],
|
|
40
|
+
}),
|
|
41
|
+
onRemoveFile &&
|
|
42
|
+
_jsx("button", {
|
|
43
|
+
onClick: () => onRemoveFile(index),
|
|
44
|
+
className: "hover:text-cyan-900",
|
|
45
|
+
children: "\u00D7",
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
index,
|
|
50
|
+
),
|
|
51
|
+
),
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
}),
|
|
55
|
+
_jsxs("div", {
|
|
56
|
+
className: "flex items-end gap-2",
|
|
57
|
+
children: [
|
|
58
|
+
_jsx("textarea", {
|
|
59
|
+
value: value,
|
|
60
|
+
onChange: (e) => onChange(e.target.value),
|
|
61
|
+
onKeyDown: handleKeyDown,
|
|
62
|
+
disabled: isSubmitting,
|
|
63
|
+
placeholder:
|
|
64
|
+
"Type your message... (Press Enter to send, Shift+Enter for new line)",
|
|
65
|
+
className:
|
|
66
|
+
"flex-1 resize-none rounded-lg border border-gray-300 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed",
|
|
67
|
+
rows: 3,
|
|
68
|
+
}),
|
|
69
|
+
_jsx("button", {
|
|
70
|
+
onClick: onSubmit,
|
|
71
|
+
disabled: isSubmitting || !value.trim(),
|
|
72
|
+
className:
|
|
73
|
+
"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors",
|
|
74
|
+
children: isSubmitting ? "Sending..." : "Send",
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
}),
|
|
78
|
+
_jsx("p", {
|
|
79
|
+
className: "mt-2 text-xs text-gray-500",
|
|
80
|
+
children: "Press Enter to send \u2022 Shift+Enter for new line",
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
});
|
|
10
84
|
}
|
|
11
85
|
function formatFileSize(bytes) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
16
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
86
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
87
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
88
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
17
89
|
}
|
|
18
|
-
//# sourceMappingURL=InputBox.js.map
|
|
90
|
+
//# sourceMappingURL=InputBox.js.map
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
declare const Label: React.ForwardRefExoticComponent<
|
|
3
|
+
declare const Label: React.ForwardRefExoticComponent<
|
|
4
|
+
Omit<
|
|
5
|
+
LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>,
|
|
6
|
+
"ref"
|
|
7
|
+
> &
|
|
8
|
+
React.RefAttributes<HTMLLabelElement>
|
|
9
|
+
>;
|
|
4
10
|
export { Label };
|