devnonla-ui 0.13.0 → 0.15.0
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/package.json +2 -2
- package/src/app/App.tsx +2 -2
- package/src/app/context.ts +1 -12
- package/src/avatar/avatar.css +107 -0
- package/src/blob-shape/BlobShape.tsx +337 -0
- package/src/button/Button.tsx +4 -4
- package/src/button/ButtonCopy.tsx +3 -3
- package/src/calendar/Calendar.tsx +1 -1
- package/src/card/Card.tsx +1 -1
- package/src/chat/AgentChatbox.tsx +1 -1
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/chatMessageList.tsx +5 -3
- package/src/chat/chatRhythm.ts +8 -0
- package/src/chat/common/createAgentSseSession.ts +9 -3
- package/src/chat/common/sse.ts +290 -122
- package/src/chat/common/useAgentStream.ts +1 -1
- package/src/chat/index.ts +2 -2
- package/src/chat/message-ui/ChatAgentMessage.tsx +4 -3
- package/src/chat/message-ui/ChatError.tsx +5 -4
- package/src/chat/message-ui/ChatInput.tsx +9 -8
- package/src/chat/message-ui/ChatMarkdown.tsx +36 -2
- package/src/chat/message-ui/ChatThinking.tsx +8 -7
- package/src/chat/message-ui/ChatUserMessage.tsx +5 -5
- package/src/chat/tool-ui/BackgroundTaskToolUI.tsx +7 -6
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +9 -9
- package/src/chat/tool-ui/CallAgentToolUI.tsx +16 -15
- package/src/chat/tool-ui/ChatToolCall.tsx +13 -12
- package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +7 -6
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +10 -9
- package/src/chat/tool-ui/RunJsToolUI.tsx +9 -8
- package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
- package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
- package/src/chat/tool-ui/WebFetchToolUI.tsx +10 -9
- package/src/checkbox/Checkbox.tsx +2 -2
- package/src/codeblock/CodeBlock.tsx +1 -1
- package/src/colorpicker/ColorPicker.tsx +10 -8
- package/src/datepicker/DatePicker.tsx +3 -3
- package/src/desktop/DesktopHeader.tsx +2 -2
- package/src/desktop/DesktopIcon.tsx +3 -4
- package/src/desktop/DesktopStage.tsx +1 -1
- package/src/desktop/DesktopWindow.tsx +3 -3
- package/src/desktop/MeadowDesktop.tsx +2 -2
- package/src/drawer/Drawer.tsx +6 -2
- package/src/dropdown/menuClasses.ts +1 -1
- package/src/empty/Empty.tsx +1 -1
- package/src/form/variants/FieldRadio.tsx +1 -1
- package/src/form/variants/FieldRepeaterItem.tsx +1 -1
- package/src/icon/Icon.tsx +21 -0
- package/src/icon/glyphs.ts +35 -0
- package/src/index.ts +9 -23
- package/src/input/EditableInput.tsx +5 -4
- package/src/input/Input.tsx +15 -7
- package/src/lib/sizes.ts +6 -6
- package/src/lib/surface.ts +14 -4
- package/src/markdown-editor/MarkdownDiff.tsx +4 -4
- package/src/markdown-editor/MarkdownEditor.tsx +4 -4
- package/src/markdown-editor/MarkdownPreview.tsx +6 -6
- package/src/markdown-editor/MarkdownSource.tsx +1 -1
- package/src/markdown-editor/MarkdownTable.tsx +48 -11
- package/src/markdown-editor/MarkdownViewer.tsx +28 -31
- package/src/markdown-editor/MermaidBlock.tsx +5 -5
- package/src/markdown-editor/ReactCodeFrame.tsx +10 -6
- package/src/markdown-editor/ReactCodeSandbox.tsx +2 -2
- package/src/markdown-editor/markdownScale.ts +66 -127
- package/src/menu/Menu.tsx +3 -3
- package/src/message/message.tsx +18 -8
- package/src/modal/Modal.tsx +13 -7
- package/src/pagination/Pagination.tsx +7 -7
- package/src/popover/Popover.tsx +1 -1
- package/src/scroll/OverlayScroll.tsx +13 -5
- package/src/segmented/Segmented.tsx +1 -1
- package/src/select/Select.tsx +4 -4
- package/src/sidebar/Sidebar.tsx +39 -36
- package/src/skeleton/Skeleton.tsx +4 -4
- package/src/spin/Spin.tsx +14 -2
- package/src/splitter/Splitter.tsx +1 -1
- package/src/styles.css +188 -844
- package/src/table/Table.tsx +12 -12
- package/src/tabs/Tabs.tsx +76 -14
- package/src/tag/Tag.tsx +3 -3
- package/src/theme-switcher/ThemeSwitcher.tsx +6 -6
- package/src/theme.ts +53 -147
- package/src/timepicker/TimePicker.tsx +2 -2
- package/src/typography/Typography.tsx +8 -8
- package/src/icon/SolarIcon.tsx +0 -39
- package/src/icon/solar.ts +0 -172
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devnonla-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "NonlaUI — React controls for Nonla Agents",
|
|
6
6
|
"author": "devlangla <devlangla0x01@gmail.com>",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"react-hook-form": "^7.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@ag-ui/client": "1.0.2",
|
|
41
42
|
"@fontsource-variable/inter": "^5.3.0",
|
|
42
43
|
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
|
43
|
-
"@iconify-json/solar": "^1.2.13",
|
|
44
44
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
45
45
|
"@radix-ui/react-context-menu": "^2.3.7",
|
|
46
46
|
"@radix-ui/react-dialog": "^1.1.15",
|
package/src/app/App.tsx
CHANGED
|
@@ -4,10 +4,10 @@ import { type ControlSize, ControlSizeContext, normalizeSize } from "../lib/size
|
|
|
4
4
|
import { MessageHolder, message } from "../message/message";
|
|
5
5
|
import { ConfirmHolder, Modal } from "../modal/Modal";
|
|
6
6
|
import { initColorMode } from "../theme";
|
|
7
|
-
import { AppContext, type NonlaAppConfig, useAppConfig, usePopupContainer
|
|
7
|
+
import { AppContext, type NonlaAppConfig, useAppConfig, usePopupContainer } from "./context";
|
|
8
8
|
|
|
9
9
|
export type { NonlaAppConfig };
|
|
10
|
-
export { useAppConfig, usePopupContainer
|
|
10
|
+
export { useAppConfig, usePopupContainer };
|
|
11
11
|
|
|
12
12
|
export type AppProps = {
|
|
13
13
|
children: ReactNode;
|
package/src/app/context.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createContext, useContext
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
2
|
import type { CanonicalSize } from "../lib/sizes";
|
|
3
|
-
import { getColorMode, getDesignToken, type NonlaTokenSnapshot, subscribeColorMode } from "../theme";
|
|
4
3
|
|
|
5
4
|
export type NonlaAppConfig = {
|
|
6
5
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -18,13 +17,3 @@ export function usePopupContainer(override?: () => HTMLElement) {
|
|
|
18
17
|
const { getPopupContainer } = useAppConfig();
|
|
19
18
|
return () => (override ?? getPopupContainer)?.() ?? document.body;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
/** Computed `--nonla-*` knobs (`useToken`). Re-reads when the color mode changes. */
|
|
23
|
-
export function useToken(): { token: NonlaTokenSnapshot } {
|
|
24
|
-
const mode = useSyncExternalStore(subscribeColorMode, getColorMode, () => "dark" as const);
|
|
25
|
-
const token = useMemo(() => {
|
|
26
|
-
void mode;
|
|
27
|
-
return getDesignToken();
|
|
28
|
-
}, [mode]);
|
|
29
|
-
return { token };
|
|
30
|
-
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
@keyframes nonla-avatar-wander {
|
|
2
|
+
0%,
|
|
3
|
+
14%,
|
|
4
|
+
100% {
|
|
5
|
+
transform: translate(var(--nonla-avatar-hx, 0), var(--nonla-avatar-hy, 0));
|
|
6
|
+
}
|
|
7
|
+
22%,
|
|
8
|
+
34% {
|
|
9
|
+
transform: translate(-5%, 1%);
|
|
10
|
+
}
|
|
11
|
+
42%,
|
|
12
|
+
54% {
|
|
13
|
+
transform: translate(0, -4%);
|
|
14
|
+
}
|
|
15
|
+
62%,
|
|
16
|
+
74% {
|
|
17
|
+
transform: translate(5%, 1%);
|
|
18
|
+
}
|
|
19
|
+
82%,
|
|
20
|
+
94% {
|
|
21
|
+
transform: translate(0, 4.4%);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@keyframes nonla-avatar-glance {
|
|
26
|
+
0%,
|
|
27
|
+
14%,
|
|
28
|
+
100% {
|
|
29
|
+
transform: translate(var(--nonla-avatar-ex, 0), var(--nonla-avatar-ey, 0));
|
|
30
|
+
}
|
|
31
|
+
22%,
|
|
32
|
+
34% {
|
|
33
|
+
transform: translate(-10%, 0.6%);
|
|
34
|
+
}
|
|
35
|
+
42%,
|
|
36
|
+
54% {
|
|
37
|
+
transform: translate(0, -6.9%);
|
|
38
|
+
}
|
|
39
|
+
62%,
|
|
40
|
+
74% {
|
|
41
|
+
transform: translate(10%, 0.6%);
|
|
42
|
+
}
|
|
43
|
+
82%,
|
|
44
|
+
94% {
|
|
45
|
+
transform: translate(0, 7.2%);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@keyframes nonla-avatar-blink {
|
|
50
|
+
0%,
|
|
51
|
+
46%,
|
|
52
|
+
52%,
|
|
53
|
+
100% {
|
|
54
|
+
transform: scaleY(1);
|
|
55
|
+
}
|
|
56
|
+
49% {
|
|
57
|
+
transform: scaleY(0.15);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* A quiet shift, not a bounce. */
|
|
62
|
+
.nonla-avatar {
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
flex-shrink: 0;
|
|
65
|
+
line-height: 0;
|
|
66
|
+
vertical-align: middle;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.nonla-avatar-bob {
|
|
70
|
+
display: block;
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
transform: translate(var(--nonla-avatar-hx, 0), var(--nonla-avatar-hy, 0));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.nonla-avatar-gaze {
|
|
77
|
+
transform-box: view-box;
|
|
78
|
+
transform: translate(var(--nonla-avatar-ex, 0), var(--nonla-avatar-ey, 0));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.nonla-avatar-eyes {
|
|
82
|
+
transform-box: fill-box;
|
|
83
|
+
transform-origin: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.nonla-avatar[data-motion="idle"] .nonla-avatar-bob {
|
|
87
|
+
animation: nonla-avatar-wander 8.4s ease-in-out infinite;
|
|
88
|
+
animation-delay: var(--nonla-avatar-delay, 0s);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.nonla-avatar[data-motion="idle"] .nonla-avatar-gaze {
|
|
92
|
+
animation: nonla-avatar-glance 8.4s ease-in-out infinite;
|
|
93
|
+
animation-delay: var(--nonla-avatar-delay, 0s);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.nonla-avatar[data-motion="idle"] .nonla-avatar-eyes {
|
|
97
|
+
animation: nonla-avatar-blink 6.4s ease-in-out infinite;
|
|
98
|
+
animation-delay: var(--nonla-avatar-delay, 0s);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@media (prefers-reduced-motion: reduce) {
|
|
102
|
+
.nonla-avatar[data-motion] .nonla-avatar-bob,
|
|
103
|
+
.nonla-avatar[data-motion] .nonla-avatar-gaze,
|
|
104
|
+
.nonla-avatar[data-motion] .nonla-avatar-eyes {
|
|
105
|
+
animation: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode, useId } from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `blob`, `blob-alt`, `ring`, `orb`, `square`, `star`, `circle`, `cursor` are background decorations.
|
|
6
|
+
* `horizontal`, `fade`, `dashed`, `double`, `ornament`, `zigzag`, `wave`, `waves`, `mountain`, `vertical` are thin line dividers.
|
|
7
|
+
*/
|
|
8
|
+
export type BlobShapeVariant =
|
|
9
|
+
| "blob"
|
|
10
|
+
| "blob-alt"
|
|
11
|
+
| "ring"
|
|
12
|
+
| "orb"
|
|
13
|
+
| "square"
|
|
14
|
+
| "star"
|
|
15
|
+
| "circle"
|
|
16
|
+
| "cursor"
|
|
17
|
+
| "horizontal"
|
|
18
|
+
| "fade"
|
|
19
|
+
| "dashed"
|
|
20
|
+
| "double"
|
|
21
|
+
| "ornament"
|
|
22
|
+
| "zigzag"
|
|
23
|
+
| "wave"
|
|
24
|
+
| "waves"
|
|
25
|
+
| "mountain"
|
|
26
|
+
| "vertical";
|
|
27
|
+
|
|
28
|
+
type DividerVariant = Extract<BlobShapeVariant, "horizontal" | "fade" | "dashed" | "double" | "ornament" | "zigzag" | "wave" | "waves" | "mountain" | "vertical">;
|
|
29
|
+
|
|
30
|
+
/** How a closed shape is painted. Dividers are lines, so they ignore it. */
|
|
31
|
+
export type BlobShapeAppearance = "solid" | "outline" | "sticker";
|
|
32
|
+
|
|
33
|
+
export type BlobShapeProps = {
|
|
34
|
+
variant?: BlobShapeVariant;
|
|
35
|
+
/** Fill color, or stroke for `outline` and dividers. Any CSS color works, including `var(--nonla-*)`. Defaults to brand. */
|
|
36
|
+
color?: string;
|
|
37
|
+
/** Width in px or any CSS length. Decorations default to 320. Dividers default to `100%`, and `vertical` defaults to `1`. */
|
|
38
|
+
width?: number | string;
|
|
39
|
+
/** Explicit height. Usually omit it so the aspect ratio holds. */
|
|
40
|
+
height?: number | string;
|
|
41
|
+
/** Opacity from 0 to 1. */
|
|
42
|
+
opacity?: number;
|
|
43
|
+
/** Gaussian blur in px. Softens edges for glow-style backgrounds. */
|
|
44
|
+
blur?: number;
|
|
45
|
+
/** Mirror horizontally. */
|
|
46
|
+
flipX?: boolean;
|
|
47
|
+
/** Mirror vertically. Use it to put a divider on the top edge of a section. */
|
|
48
|
+
flipY?: boolean;
|
|
49
|
+
/** `solid` fills the shape. `outline` strokes its edge. `sticker` adds a white border and a drop shadow. Dividers ignore it. */
|
|
50
|
+
appearance?: BlobShapeAppearance;
|
|
51
|
+
className?: string;
|
|
52
|
+
style?: CSSProperties;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const DIVIDER_VARIANTS: ReadonlySet<BlobShapeVariant> = new Set<BlobShapeVariant>([
|
|
56
|
+
"horizontal",
|
|
57
|
+
"fade",
|
|
58
|
+
"dashed",
|
|
59
|
+
"double",
|
|
60
|
+
"ornament",
|
|
61
|
+
"zigzag",
|
|
62
|
+
"wave",
|
|
63
|
+
"waves",
|
|
64
|
+
"mountain",
|
|
65
|
+
"vertical",
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
/** Box and default size for each divider. Lines keep their stroke in screen pixels, so they stay thin when stretched. */
|
|
69
|
+
const DIVIDER_BOX: Record<DividerVariant, { viewBox: string; width: number | string; height?: number | string }> = {
|
|
70
|
+
horizontal: { viewBox: "0 0 1440 1", width: "100%", height: 1 },
|
|
71
|
+
fade: { viewBox: "0 0 1440 1", width: "100%", height: 1 },
|
|
72
|
+
dashed: { viewBox: "0 0 1440 1", width: "100%", height: 1 },
|
|
73
|
+
double: { viewBox: "0 0 1440 5", width: "100%", height: 5 },
|
|
74
|
+
ornament: { viewBox: "0 0 1440 12", width: "100%", height: 12 },
|
|
75
|
+
zigzag: { viewBox: "0 0 1440 8", width: "100%", height: 8 },
|
|
76
|
+
wave: { viewBox: "0 0 1440 40", width: "100%" },
|
|
77
|
+
waves: { viewBox: "0 0 1440 40", width: "100%" },
|
|
78
|
+
mountain: { viewBox: "0 0 1440 40", width: "100%" },
|
|
79
|
+
vertical: { viewBox: "0 0 1 1440", width: 1, height: "100%" },
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Stroke width in screen pixels. */
|
|
83
|
+
const LINE_STROKE = 1;
|
|
84
|
+
const WAVE_STROKE = 2;
|
|
85
|
+
|
|
86
|
+
/** One smooth wave: four bumps across the 1440 box, centered on y = 20. */
|
|
87
|
+
const WAVE_PATH = "M0,20 C120,0 240,0 360,20 C480,40 600,40 720,20 C840,0 960,0 1080,20 C1200,40 1320,40 1440,20";
|
|
88
|
+
|
|
89
|
+
/** Front and back ridges of a mountain range, drawn as open lines in the 40-unit box. */
|
|
90
|
+
const MOUNTAIN_FRONT = "M0,36 L240,10 L400,26 L600,2 L820,28 L980,8 L1200,30 L1440,18";
|
|
91
|
+
const MOUNTAIN_BACK = "M0,26 L160,12 L300,24 L470,6 L640,22 L820,10 L1000,24 L1200,8 L1440,20";
|
|
92
|
+
|
|
93
|
+
/** Diamond ornament at the center of the `ornament` divider. */
|
|
94
|
+
const ORNAMENT_DIAMOND = "M720,1 L726,6 L720,11 L714,6 Z";
|
|
95
|
+
|
|
96
|
+
const BLOB_PATH =
|
|
97
|
+
"M44.7,-76.4C58.8,-69.2,71.8,-59.1,79.6,-45.8C87.4,-32.6,90,-16.3,88.5,-0.9C87,14.5,81.4,29,73.1,41.1C64.8,53.2,53.8,62.9,41.2,70.3C28.6,77.7,14.3,82.8,-0.5,83.7C-15.3,84.6,-30.6,81.3,-43.4,74.2C-56.2,67.1,-66.5,56,-74.8,43.2C-83.1,30.4,-89.4,15.2,-89.4,0C-89.4,-15.2,-83.1,-30.4,-74.3,-42.9C-65.5,-55.4,-54.2,-65.2,-41.4,-72.6C-28.6,-80,-14.3,-85,0.9,-86.3C16.1,-87.6,30.6,-83.6,44.7,-76.4Z";
|
|
98
|
+
|
|
99
|
+
const BLOB_ALT_PATH = "M-6,-88C48,-92,90,-40,84,8C78,54,36,90,-12,84C-58,78,-90,40,-84,-6C-78,-52,-52,-86,-6,-88Z";
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Windows-style arrow pointer: vertical left edge, 45-degree right edge, horizontal wing, slanted tail.
|
|
103
|
+
* Sharp corners, drawn on an 11 x 18 grid, scaled 8x and centered in the -100..100 box.
|
|
104
|
+
*/
|
|
105
|
+
const CURSOR_PATH = "M0,0 L0,16 L4.2,12.2 L6.9,18 L8.6,17.2 L5.9,11.2 L11,11.2 Z";
|
|
106
|
+
const CURSOR_SCALE = 8;
|
|
107
|
+
const CURSOR_TRANSFORM = "translate(-44 -72) scale(8)";
|
|
108
|
+
/** Sticker stroke width in viewBox units. */
|
|
109
|
+
const STICKER_STROKE = 8;
|
|
110
|
+
|
|
111
|
+
const STAR_PATH = "M0.0,-90.0 L23.5,-32.4 L85.6,-27.8 L38.0,12.4 L52.9,72.8 L0.0,40.0 L-52.9,72.8 L-38.0,12.4 L-85.6,-27.8 L-23.5,-32.4 Z";
|
|
112
|
+
|
|
113
|
+
const f2 = (n: number) => n.toFixed(2);
|
|
114
|
+
|
|
115
|
+
/** Open smooth line through sampled points, using Catmull-Rom curves converted to cubic Béziers. */
|
|
116
|
+
function smoothLine(points: [number, number][]): string {
|
|
117
|
+
let d = `M${f2(points[0][0])},${f2(points[0][1])}`;
|
|
118
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
119
|
+
const p0 = points[Math.max(i - 1, 0)];
|
|
120
|
+
const p1 = points[i];
|
|
121
|
+
const p2 = points[i + 1];
|
|
122
|
+
const p3 = points[Math.min(i + 2, points.length - 1)];
|
|
123
|
+
const c1x = p1[0] + (p2[0] - p0[0]) / 6;
|
|
124
|
+
const c1y = p1[1] + (p2[1] - p0[1]) / 6;
|
|
125
|
+
const c2x = p2[0] - (p3[0] - p1[0]) / 6;
|
|
126
|
+
const c2y = p2[1] - (p3[1] - p1[1]) / 6;
|
|
127
|
+
d += ` C${f2(c1x)},${f2(c1y)} ${f2(c2x)},${f2(c2y)} ${f2(p2[0])},${f2(p2[1])}`;
|
|
128
|
+
}
|
|
129
|
+
return d;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Sine wave across the 1440 box, centered on `base`: one crest every 360 units. */
|
|
133
|
+
function sineWave(base: number, amp: number, phase: number): string {
|
|
134
|
+
const points: [number, number][] = [];
|
|
135
|
+
for (let x = 0; x <= 1440; x += 90) {
|
|
136
|
+
points.push([x, base + amp * Math.sin((2 * Math.PI * x) / 360 + phase)]);
|
|
137
|
+
}
|
|
138
|
+
return smoothLine(points);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Zigzag across the 8-unit box: alternating top and bottom points every 24 units. */
|
|
142
|
+
function zigzagPath(): string {
|
|
143
|
+
let d = "M0,7";
|
|
144
|
+
for (let x = 24, i = 0; x <= 1440; x += 24, i++) {
|
|
145
|
+
d += ` L${x},${i % 2 === 0 ? 1 : 7}`;
|
|
146
|
+
}
|
|
147
|
+
return d;
|
|
148
|
+
}
|
|
149
|
+
const ZIGZAG_PATH = zigzagPath();
|
|
150
|
+
|
|
151
|
+
/** Three sine waves, out of phase, at decreasing opacity. */
|
|
152
|
+
const WAVES_LAYERS: { d: string; opacity: number }[] = [
|
|
153
|
+
{ d: sineWave(20, 10, 0), opacity: 1 },
|
|
154
|
+
{ d: sineWave(20, 10, 0.9), opacity: 0.55 },
|
|
155
|
+
{ d: sineWave(20, 10, 1.8), opacity: 0.25 },
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
/** Edge width of an `outline` shape, in viewBox units. Same as the `ring` stroke. */
|
|
159
|
+
const OUTLINE_STROKE = 3;
|
|
160
|
+
|
|
161
|
+
/** Radius of the disc used for `circle` and `orb` outline and sticker forms. */
|
|
162
|
+
const DISC_RADIUS = 88;
|
|
163
|
+
|
|
164
|
+
type ClosedVariant = Extract<BlobShapeVariant, "blob" | "blob-alt" | "ring" | "orb" | "square" | "star" | "circle" | "cursor">;
|
|
165
|
+
|
|
166
|
+
const CLOSED_VARIANTS: ReadonlySet<BlobShapeVariant> = new Set<BlobShapeVariant>(["blob", "blob-alt", "ring", "orb", "square", "star", "circle", "cursor"]);
|
|
167
|
+
|
|
168
|
+
function isClosedVariant(variant: BlobShapeVariant): variant is ClosedVariant {
|
|
169
|
+
return CLOSED_VARIANTS.has(variant);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Fill and stroke for a closed shape. `strokeWidth` is in viewBox units. */
|
|
173
|
+
type Paint = { fill: string; stroke: string; strokeWidth: number };
|
|
174
|
+
|
|
175
|
+
const solidPaint = (color: string): Paint => ({ fill: color, stroke: "none", strokeWidth: 0 });
|
|
176
|
+
const outlinePaint = (color: string): Paint => ({ fill: "none", stroke: color, strokeWidth: OUTLINE_STROKE });
|
|
177
|
+
|
|
178
|
+
/** Draws one closed shape with the given paint. Used for the shape itself and for its sticker border. */
|
|
179
|
+
function closedShape(variant: ClosedVariant, paint: Paint): ReactNode {
|
|
180
|
+
const paintStyle: CSSProperties = { fill: paint.fill, stroke: paint.stroke };
|
|
181
|
+
switch (variant) {
|
|
182
|
+
case "blob":
|
|
183
|
+
return <path d={BLOB_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
184
|
+
case "blob-alt":
|
|
185
|
+
return <path d={BLOB_ALT_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
186
|
+
case "ring":
|
|
187
|
+
return <path d={BLOB_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
188
|
+
case "square":
|
|
189
|
+
return <rect x={-80} y={-80} width={160} height={160} rx={24} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
190
|
+
case "star":
|
|
191
|
+
return <path d={STAR_PATH} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
192
|
+
case "circle":
|
|
193
|
+
case "orb":
|
|
194
|
+
return <circle cx={0} cy={0} r={DISC_RADIUS} style={paintStyle} strokeWidth={paint.strokeWidth} />;
|
|
195
|
+
case "cursor":
|
|
196
|
+
// The transform scales the stroke too, so the stroke width is divided by the scale here.
|
|
197
|
+
return <path d={CURSOR_PATH} transform={CURSOR_TRANSFORM} style={paintStyle} strokeWidth={paint.strokeWidth / CURSOR_SCALE} />;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Decorative SVG shapes for landing pages.
|
|
203
|
+
* Decorations sit in a `-100 -100 200 200` box. Dividers are thin lines that span the full width or height.
|
|
204
|
+
* Position it with `className` (e.g. `absolute -z-10`). The shape ignores pointer events.
|
|
205
|
+
*/
|
|
206
|
+
export function BlobShape({ variant = "blob", color = "var(--nonla-brand)", width, height, opacity, blur, flipX, flipY, appearance = "solid", className, style }: BlobShapeProps) {
|
|
207
|
+
const rawId = useId();
|
|
208
|
+
const idKey = rawId.replace(/:/g, "");
|
|
209
|
+
const gradientId = `nonla-blob-${idKey}`;
|
|
210
|
+
const fadeId = `nonla-fade-${idKey}`;
|
|
211
|
+
const divider = DIVIDER_VARIANTS.has(variant);
|
|
212
|
+
const box = divider ? DIVIDER_BOX[variant as DividerVariant] : undefined;
|
|
213
|
+
const fill: CSSProperties = { fill: color };
|
|
214
|
+
const stroke: CSSProperties = { stroke: color };
|
|
215
|
+
const line: CSSProperties = { ...stroke, fill: "none" };
|
|
216
|
+
|
|
217
|
+
const transform = [flipX && "scaleX(-1)", flipY && "scaleY(-1)"].filter(Boolean).join(" ");
|
|
218
|
+
|
|
219
|
+
// Ring is an outline by nature. The orb glow is a gradient, so only its solid form uses it.
|
|
220
|
+
const paint = appearance === "outline" || variant === "ring" ? outlinePaint(color) : solidPaint(color);
|
|
221
|
+
let shape: ReactNode = null;
|
|
222
|
+
if (variant === "orb" && appearance === "solid") {
|
|
223
|
+
shape = (
|
|
224
|
+
<>
|
|
225
|
+
<defs>
|
|
226
|
+
<radialGradient id={gradientId}>
|
|
227
|
+
<stop offset="0%" stopOpacity={1} style={{ stopColor: color }} />
|
|
228
|
+
<stop offset="100%" stopOpacity={0} style={{ stopColor: color }} />
|
|
229
|
+
</radialGradient>
|
|
230
|
+
</defs>
|
|
231
|
+
<circle cx={0} cy={0} r={100} fill={`url(#${gradientId})`} />
|
|
232
|
+
</>
|
|
233
|
+
);
|
|
234
|
+
} else if (isClosedVariant(variant)) {
|
|
235
|
+
shape = closedShape(variant, paint);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
switch (variant) {
|
|
239
|
+
case "horizontal":
|
|
240
|
+
shape = <line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />;
|
|
241
|
+
break;
|
|
242
|
+
case "fade":
|
|
243
|
+
shape = (
|
|
244
|
+
<>
|
|
245
|
+
<defs>
|
|
246
|
+
<linearGradient id={fadeId} gradientUnits="userSpaceOnUse" x1={0} y1={0} x2={1440} y2={0}>
|
|
247
|
+
<stop offset="0" stopOpacity={0} style={{ stopColor: color }} />
|
|
248
|
+
<stop offset="0.5" stopOpacity={1} style={{ stopColor: color }} />
|
|
249
|
+
<stop offset="1" stopOpacity={0} style={{ stopColor: color }} />
|
|
250
|
+
</linearGradient>
|
|
251
|
+
</defs>
|
|
252
|
+
<line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" stroke={`url(#${fadeId})`} fill="none" />
|
|
253
|
+
</>
|
|
254
|
+
);
|
|
255
|
+
break;
|
|
256
|
+
case "dashed":
|
|
257
|
+
shape = <line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} strokeDasharray="6 4" vectorEffect="non-scaling-stroke" style={line} />;
|
|
258
|
+
break;
|
|
259
|
+
case "double":
|
|
260
|
+
shape = (
|
|
261
|
+
<>
|
|
262
|
+
<line x1={0} y1={0.5} x2={1440} y2={0.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />
|
|
263
|
+
<line x1={0} y1={4.5} x2={1440} y2={4.5} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />
|
|
264
|
+
</>
|
|
265
|
+
);
|
|
266
|
+
break;
|
|
267
|
+
case "ornament":
|
|
268
|
+
shape = (
|
|
269
|
+
<>
|
|
270
|
+
<line x1={0} y1={6} x2={1440} y2={6} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />
|
|
271
|
+
<path d={ORNAMENT_DIAMOND} style={fill} />
|
|
272
|
+
</>
|
|
273
|
+
);
|
|
274
|
+
break;
|
|
275
|
+
case "zigzag":
|
|
276
|
+
shape = <path d={ZIGZAG_PATH} strokeWidth={LINE_STROKE} strokeLinejoin="round" vectorEffect="non-scaling-stroke" style={line} />;
|
|
277
|
+
break;
|
|
278
|
+
case "wave":
|
|
279
|
+
shape = <path d={WAVE_PATH} strokeWidth={WAVE_STROKE} strokeLinecap="round" vectorEffect="non-scaling-stroke" style={line} />;
|
|
280
|
+
break;
|
|
281
|
+
case "waves":
|
|
282
|
+
shape = WAVES_LAYERS.map((layer) => (
|
|
283
|
+
<path key={layer.d} d={layer.d} strokeWidth={LINE_STROKE} strokeLinecap="round" vectorEffect="non-scaling-stroke" style={{ ...line, opacity: layer.opacity }} />
|
|
284
|
+
));
|
|
285
|
+
break;
|
|
286
|
+
case "mountain":
|
|
287
|
+
shape = (
|
|
288
|
+
<>
|
|
289
|
+
<path d={MOUNTAIN_BACK} strokeWidth={LINE_STROKE} strokeLinejoin="round" vectorEffect="non-scaling-stroke" style={{ ...line, opacity: 0.4 }} />
|
|
290
|
+
<path d={MOUNTAIN_FRONT} strokeWidth={WAVE_STROKE} strokeLinejoin="round" vectorEffect="non-scaling-stroke" style={line} />
|
|
291
|
+
</>
|
|
292
|
+
);
|
|
293
|
+
break;
|
|
294
|
+
case "vertical":
|
|
295
|
+
shape = <line x1={0.5} y1={0} x2={0.5} y2={1440} strokeWidth={LINE_STROKE} vectorEffect="non-scaling-stroke" style={line} />;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Sticker: a white border under the shape, so only the outer edge shows, plus a soft drop shadow.
|
|
300
|
+
// Dividers have no sticker form.
|
|
301
|
+
if (appearance === "sticker" && isClosedVariant(variant)) {
|
|
302
|
+
const stickerId = `nonla-sticker-${idKey}`;
|
|
303
|
+
const border: Paint = { fill: "#ffffff", stroke: "#ffffff", strokeWidth: paint.strokeWidth + STICKER_STROKE };
|
|
304
|
+
shape = (
|
|
305
|
+
<>
|
|
306
|
+
<defs>
|
|
307
|
+
<filter id={stickerId} x="-30%" y="-30%" width="160%" height="160%">
|
|
308
|
+
<feDropShadow dx={0} dy={2} stdDeviation={2} floodColor="#000000" floodOpacity={0.2} />
|
|
309
|
+
</filter>
|
|
310
|
+
</defs>
|
|
311
|
+
<g filter={`url(#${stickerId})`}>{closedShape(variant, border)}</g>
|
|
312
|
+
{shape}
|
|
313
|
+
</>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
<svg
|
|
319
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
320
|
+
viewBox={box?.viewBox ?? "-100 -100 200 200"}
|
|
321
|
+
preserveAspectRatio={divider ? "none" : undefined}
|
|
322
|
+
width={width ?? box?.width ?? 320}
|
|
323
|
+
height={height ?? box?.height}
|
|
324
|
+
aria-hidden
|
|
325
|
+
focusable="false"
|
|
326
|
+
className={cn("pointer-events-none block shrink-0", className)}
|
|
327
|
+
style={{
|
|
328
|
+
opacity,
|
|
329
|
+
filter: blur ? `blur(${blur}px)` : undefined,
|
|
330
|
+
transform: transform || undefined,
|
|
331
|
+
...style,
|
|
332
|
+
}}
|
|
333
|
+
>
|
|
334
|
+
{shape}
|
|
335
|
+
</svg>
|
|
336
|
+
);
|
|
337
|
+
}
|
package/src/button/Button.tsx
CHANGED
|
@@ -75,14 +75,14 @@ function tokenAppearance(color: "default" | "primary" | "danger" | "link", varia
|
|
|
75
75
|
if (variant === "nostyle") return "";
|
|
76
76
|
const g = ghost && variant !== "text" && variant !== "link";
|
|
77
77
|
if (color === "primary") {
|
|
78
|
-
if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-solid
|
|
78
|
+
if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-text-on-solid)] hover:bg-[color-mix(in_oklab,var(--brand),var(--background)_14%)] active:bg-[color-mix(in_oklab,var(--brand),black_18%)]";
|
|
79
79
|
if (variant === "filled") return "bg-brand/15 text-brand-700 border-transparent hover:bg-brand/25";
|
|
80
80
|
if (variant === "text") return "bg-transparent text-brand border-transparent hover:bg-brand/10";
|
|
81
81
|
if (variant === "link") return "text-brand border-transparent hover:text-brand-700";
|
|
82
82
|
return "bg-transparent text-brand border-brand hover:bg-brand/10";
|
|
83
83
|
}
|
|
84
84
|
if (color === "danger") {
|
|
85
|
-
if (variant === "solid" && !g) return "border-transparent bg-destructive text-
|
|
85
|
+
if (variant === "solid" && !g) return "border-transparent bg-destructive text-(--nonla-text-on-solid) hover:bg-destructive/90";
|
|
86
86
|
if (variant === "filled") return "bg-destructive/15 text-destructive border-transparent hover:bg-destructive/25";
|
|
87
87
|
if (variant === "text") return "bg-transparent text-destructive border-transparent hover:bg-destructive/10";
|
|
88
88
|
if (variant === "link") return "text-destructive border-transparent hover:text-destructive/80";
|
|
@@ -92,13 +92,13 @@ function tokenAppearance(color: "default" | "primary" | "danger" | "link", varia
|
|
|
92
92
|
if (variant === "filled") return "bg-muted text-foreground border-transparent hover:bg-muted/80";
|
|
93
93
|
if (variant === "text") return "bg-transparent text-foreground border-transparent hover:bg-ink-hover hover:text-foreground";
|
|
94
94
|
if (variant === "dashed") return "bg-transparent text-foreground border-dashed border-border hover:bg-ink-hover";
|
|
95
|
-
return "nonla-btn-glass text-foreground";
|
|
95
|
+
return "nonla-btn-glass border-border bg-transparent text-foreground shadow-none transition-[box-shadow,transform] duration-(--nonla-dur-fast) ease-(--nonla-ease-out) hover:not-disabled:not-aria-disabled:shadow-[inset_0_0_0_999px_var(--nonla-ink-hover)] active:not-disabled:not-aria-disabled:scale-[0.98] active:not-disabled:not-aria-disabled:shadow-[inset_0_0_0_999px_var(--nonla-ink-active)] motion-reduce:transition-[box-shadow] motion-reduce:active:transform-none";
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
function presetAppearance(variant: ButtonVariant, ghost: boolean): string {
|
|
99
99
|
if (variant === "nostyle") return "";
|
|
100
100
|
const g = ghost && variant !== "text" && variant !== "link";
|
|
101
|
-
if (variant === "solid" && !g) return "bg-(--nonla-btn) text-[var(--nonla-solid
|
|
101
|
+
if (variant === "solid" && !g) return "bg-(--nonla-btn) text-[var(--nonla-text-on-solid)] border-transparent hover:brightness-110";
|
|
102
102
|
if (variant === "filled") return "bg-(--nonla-btn)/15 text-(--nonla-btn) border-transparent hover:bg-(--nonla-btn)/25";
|
|
103
103
|
if (variant === "link") return "text-(--nonla-btn) border-transparent hover:opacity-80";
|
|
104
104
|
if (variant === "dashed") return "bg-transparent text-(--nonla-btn) border-dashed border-(--nonla-btn) hover:bg-(--nonla-btn)/10";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComponentProps, useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Icon } from "../icon/Icon";
|
|
3
3
|
import { cn } from "../lib/cn";
|
|
4
4
|
import { type ControlSize, getSizeTokens, useControlSize } from "../lib/sizes";
|
|
5
5
|
|
|
@@ -29,7 +29,7 @@ export function ButtonCopy({ text, getText, label = "Copy", className, onClick,
|
|
|
29
29
|
{...props}
|
|
30
30
|
title={copied ? "Copied" : label}
|
|
31
31
|
aria-label={copied ? "Copied" : label}
|
|
32
|
-
className={cn("inline-flex cursor-pointer shrink-0 items-center justify-center text-muted-foreground transition-colors duration-200 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-
|
|
32
|
+
className={cn("inline-flex cursor-pointer shrink-0 items-center justify-center text-muted-foreground transition-colors duration-200 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/55", className)}
|
|
33
33
|
style={{ width: box, height: box }}
|
|
34
34
|
onClick={async (e) => {
|
|
35
35
|
onClick?.(e);
|
|
@@ -44,7 +44,7 @@ export function ButtonCopy({ text, getText, label = "Copy", className, onClick,
|
|
|
44
44
|
}
|
|
45
45
|
}}
|
|
46
46
|
>
|
|
47
|
-
{copied ? <
|
|
47
|
+
{copied ? <Icon name="check" size={icon} /> : <Icon name="copy" size={icon} />}
|
|
48
48
|
</button>
|
|
49
49
|
);
|
|
50
50
|
}
|
|
@@ -51,7 +51,7 @@ function CalendarDayButton({ className, day, modifiers, children, ...props }: Da
|
|
|
51
51
|
data-range-middle={modifiers.range_middle ? "true" : undefined}
|
|
52
52
|
className={cn(
|
|
53
53
|
"relative flex aspect-square size-full min-w-8 items-center justify-center rounded-md bg-transparent text-sm font-normal leading-none",
|
|
54
|
-
"transition-colors hover:bg-brand-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-
|
|
54
|
+
"transition-colors hover:bg-brand-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/55",
|
|
55
55
|
"data-[selected-single=true]:bg-brand-200 data-[selected-single=true]:text-foreground data-[selected-single=true]:hover:bg-brand-200",
|
|
56
56
|
"data-[range-start=true]:bg-brand-200 data-[range-start=true]:text-foreground data-[range-start=true]:hover:bg-brand-200 data-[range-start=true]:rounded-md",
|
|
57
57
|
"data-[range-end=true]:bg-brand-200 data-[range-end=true]:text-foreground data-[range-end=true]:hover:bg-brand-200 data-[range-end=true]:rounded-md",
|
package/src/card/Card.tsx
CHANGED
|
@@ -43,7 +43,7 @@ function CardItem({ label, description, align = "start", split = false, classNam
|
|
|
43
43
|
className={cn(
|
|
44
44
|
"relative flex w-full gap-5 px-4 py-3",
|
|
45
45
|
centered ? "items-center" : "items-start",
|
|
46
|
-
"before:pointer-events-none before:absolute before:top-0 before:right-4 before:left-4 before:h-px before:bg-
|
|
46
|
+
"before:pointer-events-none before:absolute before:top-0 before:right-4 before:left-4 before:h-px before:bg-border-secondary before:content-[''] first:before:hidden",
|
|
47
47
|
className,
|
|
48
48
|
)}
|
|
49
49
|
{...rest}
|
|
@@ -90,7 +90,7 @@ export function AgentChatbox({
|
|
|
90
90
|
return (
|
|
91
91
|
<div className={cn("nonla-agent-chatbox relative flex h-full min-h-0 flex-col overflow-hidden bg-transparent", className)}>
|
|
92
92
|
<OverlayScroll visibility={scrollbar} scrollRef={scrollRef} onScroll={onScroll} className="flex-1 min-h-0 min-w-0" innerClassName={messages.length === 0 ? "flex flex-col" : undefined}>
|
|
93
|
-
<div data-chat-scroll-content className={`max-w-200 mx-auto min-w-0 w-full ${messages.length === 0 ? "flex flex-1 flex-col" : "pt-4 pb-20"}`}>
|
|
93
|
+
<div data-chat-scroll-content className={`max-w-200 mx-auto min-w-0 w-full ${messages.length === 0 ? "flex flex-1 flex-col" : "px-2.5 pt-4 pb-20"}`}>
|
|
94
94
|
{messages.length === 0 ? (
|
|
95
95
|
(emptyState ?? (
|
|
96
96
|
<ChatWelcome name={welcomeName} description={description} avatar={avatar} starters={starters} onStarter={sendMessage} disabled={generating} />
|
package/src/chat/AgentPanel.tsx
CHANGED
|
@@ -97,7 +97,7 @@ export function AgentPanel({
|
|
|
97
97
|
return (
|
|
98
98
|
<div className={cn("nonla-agent-panel relative flex h-full min-h-0 flex-col overflow-hidden bg-transparent", className)}>
|
|
99
99
|
<OverlayScroll visibility={scrollbar} scrollRef={scrollRef} onScroll={onScroll} className="flex-1 min-h-0 min-w-0" innerClassName={messages.length === 0 ? "flex flex-col" : undefined}>
|
|
100
|
-
<div data-chat-scroll-content className={`max-w-200 mx-auto min-w-0 w-full ${messages.length === 0 ? "flex flex-1 flex-col" : "pt-4 pb-28"}`}>
|
|
100
|
+
<div data-chat-scroll-content className={`max-w-200 mx-auto min-w-0 w-full ${messages.length === 0 ? "flex flex-1 flex-col" : "px-2.5 pt-4 pb-28"}`}>
|
|
101
101
|
{messages.length === 0 ? (
|
|
102
102
|
(emptyState ?? (
|
|
103
103
|
<ChatWelcome name={welcomeName} description={description} avatar={avatar} starters={starters} onStarter={sendMessage} disabled={generating} />
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useCallback, useRef } from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
2
3
|
import { Shimmer } from "../shimmer/Shimmer";
|
|
4
|
+
import { chatRowBoxClass, chatRowClass } from "./chatRhythm";
|
|
3
5
|
import { parseBgTaskRef } from "./common/bgTasks";
|
|
4
6
|
import type { AgentMessage } from "./common/types";
|
|
5
7
|
import { formatToolName } from "./common/utils";
|
|
@@ -51,7 +53,7 @@ export function MessageRow({ msg, generating, toolUis }: { msg: AgentMessage; ge
|
|
|
51
53
|
if (msg.role === "user") return <ChatUserMessage content={msg.content} />;
|
|
52
54
|
if (msg.role === "error") return <ChatError>{msg.content}</ChatError>;
|
|
53
55
|
if (msg.role === "thinking") {
|
|
54
|
-
return <ChatThinking thinking={msg.content} duration={(msg.meta?.thinkingDuration as number) ?? 0} />;
|
|
56
|
+
return <ChatThinking className={chatRowClass} thinking={msg.content} duration={(msg.meta?.thinkingDuration as number) ?? 0} />;
|
|
55
57
|
}
|
|
56
58
|
if (msg.role === "tool-call") {
|
|
57
59
|
const CustomUI = resolveToolUI(msg.toolName, toolUis);
|
|
@@ -101,8 +103,8 @@ export function AgentMessageList({
|
|
|
101
103
|
<MessageRow key={msg.id} msg={msg} generating={generating} toolUis={toolUis} />
|
|
102
104
|
))}
|
|
103
105
|
{showFooter ? (
|
|
104
|
-
<div className=
|
|
105
|
-
<Shimmer className="text-sm font-medium text-tertiary-foreground">{status}</Shimmer>
|
|
106
|
+
<div className={cn(chatRowClass, chatRowBoxClass)}>
|
|
107
|
+
<Shimmer className="text-sm font-medium leading-5.5 text-tertiary-foreground">{status}</Shimmer>
|
|
106
108
|
</div>
|
|
107
109
|
) : null}
|
|
108
110
|
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Space before each chat row. Text, tools, errors, and the status line share it. */
|
|
2
|
+
export const chatRowClass = "mt-1";
|
|
3
|
+
|
|
4
|
+
/** Inset and vertical padding for a one-line row such as agent text or the status line. */
|
|
5
|
+
export const chatRowBoxClass = "px-4 py-1";
|
|
6
|
+
|
|
7
|
+
/** Tool header. `py-1` and `leading-5.5` match `chatRowBoxClass`, so every line has the same gap. */
|
|
8
|
+
export const chatToolLineClass = "flex items-center gap-2 py-1 text-sm leading-5.5";
|