devnonla-ui 0.7.1 → 0.9.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/README.md +31 -4
- package/package.json +3 -3
- package/src/app/App.tsx +5 -1
- package/src/app/context.ts +5 -3
- package/src/button/Button.tsx +2 -2
- package/src/button/ButtonCopy.tsx +2 -2
- package/src/card/Card.tsx +81 -0
- package/src/chat/AgentChatbox.tsx +1 -1
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/message-ui/ChatError.tsx +2 -2
- package/src/chat/message-ui/ChatInput.tsx +6 -6
- package/src/chat/message-ui/ChatMarkdown.tsx +8 -7
- package/src/chat/message-ui/ChatMarkdownTable.tsx +1 -1
- package/src/chat/message-ui/ChatThinking.tsx +3 -3
- package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
- package/src/chat/message-ui/MermaidBlock.tsx +76 -70
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +3 -3
- package/src/chat/tool-ui/CallAgentToolUI.tsx +3 -3
- package/src/chat/tool-ui/ChatToolCall.tsx +4 -4
- package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +2 -2
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +2 -2
- package/src/chat/tool-ui/RunJsToolUI.tsx +2 -2
- package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
- package/src/chat/tool-ui/WebFetchToolUI.tsx +2 -2
- package/src/checkbox/Checkbox.tsx +17 -4
- package/src/codeblock/CodeBlock.tsx +4 -10
- package/src/datepicker/DatePicker.tsx +3 -3
- package/src/desktop/DesktopHeader.tsx +1 -1
- package/src/desktop/DesktopIcon.tsx +2 -2
- package/src/desktop/DesktopWindow.tsx +51 -29
- package/src/empty/Empty.tsx +8 -5
- package/src/form/FormItem.tsx +1 -1
- package/src/form-layout/FormLayout.tsx +1 -1
- package/src/icon/SolarIcon.tsx +39 -0
- package/src/icon/solar.ts +172 -0
- package/src/index.ts +24 -12
- package/src/input/EditableInput.tsx +3 -3
- package/src/input/Input.tsx +3 -3
- package/src/lib/sizes.ts +9 -6
- package/src/lib/surface.ts +1 -1
- package/src/markdown-editor/MarkdownDiff.tsx +211 -0
- package/src/markdown-editor/MarkdownEditor.tsx +294 -0
- package/src/markdown-editor/MarkdownPreview.tsx +326 -0
- package/src/markdown-editor/MarkdownSource.tsx +72 -0
- package/src/markdown-editor/blocks.ts +329 -0
- package/src/markdown-editor/diff.ts +296 -0
- package/src/menu/Menu.tsx +3 -3
- package/src/pagination/Pagination.tsx +8 -7
- package/src/scroll/OverlayScroll.tsx +2 -2
- package/src/segmented/Segmented.tsx +2 -2
- package/src/select/Select.tsx +192 -63
- package/src/sidebar/Sidebar.tsx +9 -8
- package/src/spin/Spin.tsx +17 -11
- package/src/styles.css +273 -107
- package/src/switch/Switch.tsx +17 -3
- package/src/table/Table.tsx +63 -28
- package/src/theme-toggle/ThemeToggle.tsx +33 -0
- package/src/theme.ts +72 -0
- package/src/timepicker/TimePicker.tsx +1 -1
- package/src/icon/FluentIcon.tsx +0 -28
- package/src/icon/fluent.ts +0 -75
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ Aliases: `xs` → small, `middle` / `medium` → default.
|
|
|
55
55
|
|
|
56
56
|
All color lives in **`--nonla-*` knobs** (`src/styles.css`). Components never hardcode palette hex.
|
|
57
57
|
|
|
58
|
+
Dark is the default (`:root` and `.dark`). `.light` is the daylight palette. `<App>` calls `initColorMode()` once and restores `localStorage` key `nonla-color-mode`, falling back to dark. Switch with `setColorMode("light" | "dark")` or `<ThemeToggle>`. To start in daylight before paint, put `class="light"` on `<html>`.
|
|
59
|
+
|
|
58
60
|
**Other apps** — import the CSS, then override knobs. Do not fork Button/Tag/….
|
|
59
61
|
|
|
60
62
|
```css
|
|
@@ -67,7 +69,7 @@ All color lives in **`--nonla-*` knobs** (`src/styles.css`). Components never ha
|
|
|
67
69
|
}
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
`--brand-50` … `--brand-800` follow `--nonla-brand` (500 = the knob).
|
|
72
|
+
`--brand-50` … `--brand-800` follow `--nonla-brand` (500 = the knob). Tints mix into the surface; `brand-700` stays with the ink. Text **on** the brand fill (Button primary, Tag solid, Checkbox) is `--nonla-solid-fg` / `colors.solidFg` — default `#181818` on the neutral `#f0f0f0` fill.
|
|
71
73
|
|
|
72
74
|
Or at runtime:
|
|
73
75
|
|
|
@@ -99,12 +101,27 @@ Those map into shadcn-standard tokens (`--background`, `--destructive`, …) plu
|
|
|
99
101
|
</App>
|
|
100
102
|
```
|
|
101
103
|
|
|
104
|
+
# Card
|
|
105
|
+
|
|
106
|
+
Titled settings surface. `Card.Item` is a label row; `align="center"` for a short row, `split` so a field fills the trailing half. `Card.Footer` sits under the rows. `caption` is the note under the frame.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { Card, Switch } from "devnonla-ui";
|
|
110
|
+
|
|
111
|
+
<Card title="General" caption="Applies to this workspace.">
|
|
112
|
+
<Card.Item label="Notifications" align="center">
|
|
113
|
+
<Switch />
|
|
114
|
+
</Card.Item>
|
|
115
|
+
<Card.Footer>Saved</Card.Footer>
|
|
116
|
+
</Card>
|
|
117
|
+
```
|
|
118
|
+
|
|
102
119
|
# Desktop
|
|
103
120
|
|
|
104
121
|
Meadow wallpaper, window chrome, header bar, and desktop icons live in this package so other Nonla apps share the same shell.
|
|
105
122
|
|
|
106
123
|
```tsx
|
|
107
|
-
import { DesktopStage, DesktopHeader, MeadowDesktop, DesktopWindow, MeadowShell, Menu,
|
|
124
|
+
import { DesktopStage, DesktopHeader, MeadowDesktop, DesktopWindow, MeadowShell, Menu, SolarIcon } from "devnonla-ui";
|
|
108
125
|
|
|
109
126
|
<DesktopStage>
|
|
110
127
|
<MeadowDesktop>{icons}</MeadowDesktop>
|
|
@@ -175,10 +192,20 @@ Stream events:
|
|
|
175
192
|
|
|
176
193
|
Primitives (`ChatWelcome`, `ChatUserMessage`, `ChatAgentMessage`, `ChatThinking`, `ChatToolCall`, `ChatInput`, `ChatError`, `ChatMarkdown`) stay exported for custom layouts.
|
|
177
194
|
|
|
195
|
+
# Markdown
|
|
196
|
+
|
|
197
|
+
`MarkdownEditor` edits markdown in preview, source, or diff. Pass `original` to enable the diff view. `diffLayout` is side by side by default.
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import { MarkdownEditor } from "devnonla-ui";
|
|
201
|
+
|
|
202
|
+
<MarkdownEditor value={text} original={previous} onChange={setText} />
|
|
203
|
+
```
|
|
204
|
+
|
|
178
205
|
# Icons
|
|
179
206
|
|
|
180
|
-
`
|
|
207
|
+
`SolarIcon` renders vendored Solar icons (`@iconify-json/solar`) as inline SVG, so they follow `currentColor`. Default style is `linear`. A legacy Fluent Color id such as `settings-24` still resolves to the Solar equivalent.
|
|
181
208
|
|
|
182
209
|
```tsx
|
|
183
|
-
<
|
|
210
|
+
<SolarIcon name="settings-linear" size={16} />
|
|
184
211
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devnonla-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "NonlaUI — React controls for Nonla Agents",
|
|
6
6
|
"author": "devlangla <devlangla0x01@gmail.com>",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"react-hook-form": "^7.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@
|
|
40
|
+
"@fontsource-variable/inter": "^5.3.0",
|
|
41
|
+
"@iconify-json/solar": "^1.2.13",
|
|
41
42
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
42
43
|
"@radix-ui/react-context-menu": "^2.3.7",
|
|
43
44
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
"clsx": "^2.1.1",
|
|
50
51
|
"date-fns": "^4.4.0",
|
|
51
52
|
"highlight.js": "^11.12.0",
|
|
52
|
-
"lucide-react": "^1.45.0",
|
|
53
53
|
"mermaid": "^11.14.0",
|
|
54
54
|
"react-day-picker": "^10.0.1",
|
|
55
55
|
"react-markdown": "^10.1.0",
|
package/src/app/App.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { type ReactNode, useLayoutEffect, useMemo, useState } from "react";
|
|
|
3
3
|
import { type ControlSize, ControlSizeContext, normalizeSize } from "../lib/sizes";
|
|
4
4
|
import { MessageHolder, message } from "../message/message";
|
|
5
5
|
import { ConfirmHolder, Modal } from "../modal/Modal";
|
|
6
|
-
import { applyNonlaTheme, type NonlaThemeConfig } from "../theme";
|
|
6
|
+
import { applyNonlaTheme, initColorMode, type NonlaThemeConfig } from "../theme";
|
|
7
7
|
import { AppContext, type NonlaAppConfig, useAppConfig, usePopupContainer, useToken } from "./context";
|
|
8
8
|
|
|
9
9
|
export type { NonlaAppConfig };
|
|
@@ -27,6 +27,10 @@ export function App({ children, getPopupContainer, componentSize, theme }: AppPr
|
|
|
27
27
|
[getPopupContainer, size, themeRev],
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
initColorMode();
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
30
34
|
useLayoutEffect(() => {
|
|
31
35
|
if (!theme) return;
|
|
32
36
|
const restore = applyNonlaTheme(theme);
|
package/src/app/context.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createContext, useContext, useMemo } from "react";
|
|
1
|
+
import { createContext, useContext, useMemo, useSyncExternalStore } from "react";
|
|
2
2
|
import type { CanonicalSize } from "../lib/sizes";
|
|
3
|
-
import { getDesignToken, type NonlaTokenSnapshot } from "../theme";
|
|
3
|
+
import { getColorMode, getDesignToken, type NonlaTokenSnapshot, subscribeColorMode } from "../theme";
|
|
4
4
|
|
|
5
5
|
export type NonlaAppConfig = {
|
|
6
6
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -24,9 +24,11 @@ export function usePopupContainer(override?: () => HTMLElement) {
|
|
|
24
24
|
/** Computed seed knobs under the current App theme (`useToken`). */
|
|
25
25
|
export function useToken(): { token: NonlaTokenSnapshot } {
|
|
26
26
|
const { themeRev } = useAppConfig();
|
|
27
|
+
const mode = useSyncExternalStore(subscribeColorMode, getColorMode, () => "dark" as const);
|
|
27
28
|
const token = useMemo(() => {
|
|
28
29
|
void themeRev;
|
|
30
|
+
void mode;
|
|
29
31
|
return getDesignToken();
|
|
30
|
-
}, [themeRev]);
|
|
32
|
+
}, [themeRev, mode]);
|
|
31
33
|
return { token };
|
|
32
34
|
}
|
package/src/button/Button.tsx
CHANGED
|
@@ -73,7 +73,7 @@ const GroupSizeContext = createContext<ButtonSize | undefined>(undefined);
|
|
|
73
73
|
function tokenAppearance(color: "default" | "primary" | "danger" | "link", variant: ButtonVariant, ghost: boolean): string {
|
|
74
74
|
const g = ghost && variant !== "text" && variant !== "link";
|
|
75
75
|
if (color === "primary") {
|
|
76
|
-
if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-solid-fg)] hover:bg-[color-mix(in_oklab,var(--brand),
|
|
76
|
+
if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-solid-fg)] hover:bg-[color-mix(in_oklab,var(--brand),var(--background)_14%)] active:bg-[color-mix(in_oklab,var(--brand),black_18%)]";
|
|
77
77
|
if (variant === "filled") return "bg-brand/15 text-brand-700 border-transparent hover:bg-brand/25";
|
|
78
78
|
if (variant === "text") return "bg-transparent text-brand border-transparent hover:bg-brand/10";
|
|
79
79
|
if (variant === "link") return "text-brand border-transparent hover:text-brand-700";
|
|
@@ -89,7 +89,7 @@ function tokenAppearance(color: "default" | "primary" | "danger" | "link", varia
|
|
|
89
89
|
if (color === "link" || variant === "link") return "text-link border-transparent hover:text-link/80";
|
|
90
90
|
if (variant === "filled") return "bg-muted text-foreground border-transparent hover:bg-muted/80";
|
|
91
91
|
if (variant === "text") return "bg-transparent text-foreground border-transparent hover:bg-ink-hover hover:text-foreground";
|
|
92
|
-
if (variant === "dashed") return "bg-transparent text-foreground border-dashed border-
|
|
92
|
+
if (variant === "dashed") return "bg-transparent text-foreground border-dashed border-border hover:bg-ink-hover";
|
|
93
93
|
return "nonla-btn-glass text-foreground";
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Check, Copy } from "lucide-react";
|
|
2
1
|
import { type ComponentProps, useEffect, useState } from "react";
|
|
2
|
+
import { SolarIcon } from "../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../lib/cn";
|
|
4
4
|
import { type ControlSize, getSizeTokens, useControlSize } from "../lib/sizes";
|
|
5
5
|
|
|
@@ -44,7 +44,7 @@ export function ButtonCopy({ text, getText, label = "Copy", className, onClick,
|
|
|
44
44
|
}
|
|
45
45
|
}}
|
|
46
46
|
>
|
|
47
|
-
{copied ? <
|
|
47
|
+
{copied ? <SolarIcon name="check-linear" size={icon} /> : <SolarIcon name="copy-linear" size={icon} />}
|
|
48
48
|
</button>
|
|
49
49
|
);
|
|
50
50
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
|
|
4
|
+
/** Hairline used by the dashboard card ring and row rules (`--nonla-hairline`). */
|
|
5
|
+
const HAIRLINE = "var(--nonla-hairline)";
|
|
6
|
+
|
|
7
|
+
export type CardProps = HTMLAttributes<HTMLElement> & {
|
|
8
|
+
/** Section label above the surface. */
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
/** Note under the surface, such as a “Learn more” link. */
|
|
11
|
+
caption?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type CardItemProps = HTMLAttributes<HTMLDivElement> & {
|
|
15
|
+
label?: ReactNode;
|
|
16
|
+
description?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* `start` — label and control align to the top (rows with a description).
|
|
19
|
+
* `center` — short rows, control vertically centered with the label.
|
|
20
|
+
*/
|
|
21
|
+
align?: "start" | "center";
|
|
22
|
+
/** Split the row in half so a field can fill the trailing column. */
|
|
23
|
+
split?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type CardFooterProps = HTMLAttributes<HTMLDivElement>;
|
|
27
|
+
|
|
28
|
+
function CardRoot({ title, caption, className, children, ...rest }: CardProps) {
|
|
29
|
+
return (
|
|
30
|
+
<section className={cn("flex flex-col gap-[9px]", className)} {...rest}>
|
|
31
|
+
{title != null && title !== "" ? <div className="px-2 text-sm leading-4 text-foreground">{title}</div> : null}
|
|
32
|
+
<div className="flex flex-col self-stretch rounded-xl bg-card" style={{ boxShadow: `0 0 0 1px ${HAIRLINE}` }}>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
{caption != null && caption !== "" ? <div className="px-3 text-xs leading-4 text-tertiary-foreground">{caption}</div> : null}
|
|
36
|
+
</section>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function CardItem({ label, description, align = "start", split = false, className, children, ...rest }: CardItemProps) {
|
|
41
|
+
const hasCopy = (label != null && label !== "") || (description != null && description !== "");
|
|
42
|
+
const centered = align === "center";
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={cn(
|
|
47
|
+
"relative flex w-full gap-5 px-4 py-3",
|
|
48
|
+
centered ? "items-center" : "items-start",
|
|
49
|
+
"before:pointer-events-none before:absolute before:top-0 before:right-4 before:left-4 before:h-px before:bg-hairline before:content-[''] first:before:hidden",
|
|
50
|
+
className,
|
|
51
|
+
)}
|
|
52
|
+
{...rest}
|
|
53
|
+
>
|
|
54
|
+
{hasCopy ? (
|
|
55
|
+
<>
|
|
56
|
+
<div className={cn("flex min-w-0 flex-1 flex-col gap-0.5", centered && "justify-center")}>
|
|
57
|
+
{label != null && label !== "" ? <div className="flex items-center gap-1 text-sm leading-5 text-foreground">{label}</div> : null}
|
|
58
|
+
{description != null && description !== "" ? <div className="text-sm text-muted-foreground">{description}</div> : null}
|
|
59
|
+
</div>
|
|
60
|
+
{children != null ? (
|
|
61
|
+
<div className={cn("flex min-h-6 min-w-0 justify-end gap-2 text-sm text-foreground", split ? "flex-1" : "shrink-0", centered ? "items-center self-center" : "items-start self-stretch pt-[3px]")}>{children}</div>
|
|
62
|
+
) : null}
|
|
63
|
+
</>
|
|
64
|
+
) : (
|
|
65
|
+
children
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function CardFooter({ className, children, ...rest }: CardFooterProps) {
|
|
72
|
+
return (
|
|
73
|
+
<div className={cn("flex justify-end gap-2 py-4 pr-4", className)} {...rest}>
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Settings surface — title outside, rows inside, caption underneath. */
|
|
80
|
+
export const Card = Object.assign(CardRoot, { Item: CardItem, Footer: CardFooter });
|
|
81
|
+
export { CardFooter, CardItem };
|
|
@@ -88,7 +88,7 @@ export function AgentChatbox({
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
|
-
<div className={cn("nonla-agent-chatbox relative flex h-full min-h-0 flex-col overflow-hidden bg-
|
|
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
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 pb-16" : "pt-4 pb-20"}`}>
|
|
94
94
|
{messages.length === 0 ? (
|
package/src/chat/AgentPanel.tsx
CHANGED
|
@@ -95,7 +95,7 @@ export function AgentPanel({
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
return (
|
|
98
|
-
<div className={cn("nonla-agent-panel relative flex h-full min-h-0 flex-col overflow-hidden bg-
|
|
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
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 pb-24" : "pt-4 pb-28"}`}>
|
|
101
101
|
{messages.length === 0 ? (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CircleX } from "lucide-react";
|
|
2
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../../lib/cn";
|
|
4
4
|
|
|
5
5
|
export type ChatErrorProps = {
|
|
@@ -14,7 +14,7 @@ export function ChatError({ children, className }: ChatErrorProps) {
|
|
|
14
14
|
role="alert"
|
|
15
15
|
className="flex items-center gap-2 rounded-lg border border-destructive/40 bg-[color-mix(in_oklab,var(--destructive)_14%,var(--nonla-surface))] px-3 py-2 text-(length:--chat-body-size) leading-(--chat-body-leading) text-destructive"
|
|
16
16
|
>
|
|
17
|
-
<
|
|
17
|
+
<SolarIcon name="close-circle-linear" size={16} className="shrink-0" />
|
|
18
18
|
<div className="min-w-0">{children}</div>
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArrowUp, Eraser, Square } from "lucide-react";
|
|
2
1
|
import { type KeyboardEvent as ReactKeyboardEvent, type ReactNode, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../../lib/cn";
|
|
4
4
|
|
|
5
5
|
export type ChatInputProps = {
|
|
@@ -124,7 +124,7 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
return (
|
|
127
|
-
<div className={cn("nonla-glass relative isolate shrink-0 mx-4 mb-2.5 overflow-hidden pt-1 rounded-xl flex flex-col", disabled && "opacity-70", className)}>
|
|
127
|
+
<div className={cn("nonla-glass nonla-chat-input relative isolate shrink-0 mx-4 mb-2.5 overflow-hidden pt-1 rounded-xl flex flex-col", disabled && "opacity-70", className)}>
|
|
128
128
|
<textarea
|
|
129
129
|
ref={textareaRef}
|
|
130
130
|
data-chat-input
|
|
@@ -137,14 +137,14 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
|
|
|
137
137
|
className={cn(
|
|
138
138
|
"w-full resize-none appearance-none border-0 bg-transparent shadow-none outline-none focus:outline-none px-2.5 pt-1 pb-2.5",
|
|
139
139
|
"text-(length:--chat-composer-size) leading-(--chat-composer-leading) font-normal",
|
|
140
|
-
disabled ? "text-muted-foreground cursor-not-allowed placeholder:text-
|
|
140
|
+
disabled ? "text-muted-foreground cursor-not-allowed placeholder:text-placeholder" : "text-foreground placeholder:text-placeholder",
|
|
141
141
|
)}
|
|
142
142
|
/>
|
|
143
143
|
|
|
144
144
|
<div className="flex items-center gap-1.5 pb-2 px-2">
|
|
145
145
|
{onClear ? (
|
|
146
146
|
<button type="button" onClick={onClear} title="Clear chat" aria-label="Clear chat" className="inline-flex size-6 shrink-0 items-center justify-center rounded-lg border-0 bg-transparent cursor-pointer hover:bg-ink-hover">
|
|
147
|
-
<
|
|
147
|
+
<SolarIcon name="eraser-linear" size={14} />
|
|
148
148
|
</button>
|
|
149
149
|
) : null}
|
|
150
150
|
{toolbar}
|
|
@@ -152,7 +152,7 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
|
|
|
152
152
|
|
|
153
153
|
{generating ? (
|
|
154
154
|
<button type="button" onClick={onCancel} title="Stop" className="w-6 h-6 rounded-full bg-brand text-(--nonla-solid-fg) flex items-center justify-center shrink-0 cursor-pointer hover:bg-brand/90 active:scale-95 transition-all duration-100 border-0">
|
|
155
|
-
<
|
|
155
|
+
<SolarIcon name="stop-bold" size={12} />
|
|
156
156
|
<span className="sr-only">Stop</span>
|
|
157
157
|
</button>
|
|
158
158
|
) : (
|
|
@@ -163,7 +163,7 @@ export function ChatInput({ generating = false, placeholder = "Message…", disa
|
|
|
163
163
|
title="Send (Enter)"
|
|
164
164
|
className={cn("w-6 h-6 rounded-full flex items-center justify-center shrink-0 transition-all duration-100 border-0", canSend ? "bg-foreground text-background cursor-pointer" : "bg-border text-muted-foreground cursor-not-allowed opacity-50")}
|
|
165
165
|
>
|
|
166
|
-
<
|
|
166
|
+
<SolarIcon name="arrow-up-linear" size={14} />
|
|
167
167
|
<span className="sr-only">Send</span>
|
|
168
168
|
</button>
|
|
169
169
|
)}
|
|
@@ -16,11 +16,8 @@ export const chatMarkdownClass = cn(
|
|
|
16
16
|
chatBodyClass,
|
|
17
17
|
"min-w-0 wrap-anywhere",
|
|
18
18
|
"[&_p]:m-0 [&_p]:mb-(--chat-p-mb) [&_p:last-child]:mb-0",
|
|
19
|
-
"[&
|
|
20
|
-
"[&
|
|
21
|
-
"[&_h3]:mt-(--chat-h-mt) [&_h3]:mb-(--chat-h-mb) [&_h3]:text-(length:--chat-h3-size) [&_h3]:font-semibold [&_h3]:leading-snug",
|
|
22
|
-
"[&_h4]:mt-(--chat-h-mt) [&_h4]:mb-(--chat-h-mb) [&_h4]:text-(length:--chat-h4-size) [&_h4]:font-semibold [&_h4]:leading-snug",
|
|
23
|
-
"[&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0",
|
|
19
|
+
"[&_:is(h1,h2,h3,h4,h5,h6)]:mt-(--chat-h-mt) [&_:is(h1,h2,h3,h4,h5,h6)]:mb-(--chat-h-mb) [&_:is(h1,h2,h3,h4,h5,h6)]:text-(length:--chat-body-size) [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:leading-(--chat-body-leading)",
|
|
20
|
+
"[&_:is(h1,h2,h3,h4,h5,h6):first-child]:mt-0",
|
|
24
21
|
"[&_strong]:font-semibold [&_em]:italic",
|
|
25
22
|
"[&_blockquote]:m-0 [&_blockquote]:mb-(--chat-p-mb) [&_blockquote]:border-0 [&_blockquote]:p-0 [&_blockquote]:not-italic [&_blockquote]:text-inherit [&_blockquote:last-child]:mb-0",
|
|
26
23
|
"[&_ul]:mt-2 [&_ul]:mb-(--chat-p-mb)",
|
|
@@ -67,7 +64,7 @@ export function createChatMarkdownComponents(getState?: () => ChatMarkdownStream
|
|
|
67
64
|
return <CodeBlock code={codeText} language={lang || undefined} className="my-3 last:mb-0" />;
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
return <span className="rounded-sm bg-
|
|
67
|
+
return <span className="rounded-sm bg-foreground/12 font-mono px-px">{children}</span>;
|
|
71
68
|
},
|
|
72
69
|
hr() {
|
|
73
70
|
return null;
|
|
@@ -100,7 +97,11 @@ export function createChatMarkdownComponents(getState?: () => ChatMarkdownStream
|
|
|
100
97
|
if (type !== "checkbox") return <input type={type} checked={checked} readOnly />;
|
|
101
98
|
return (
|
|
102
99
|
<span className="nonla-md-task-check pointer-events-none inline-flex h-(--chat-body-leading) items-center">
|
|
103
|
-
<Checkbox
|
|
100
|
+
<Checkbox
|
|
101
|
+
checked={Boolean(checked)}
|
|
102
|
+
tabIndex={-1}
|
|
103
|
+
className="data-[state=checked]:border-white data-[state=checked]:bg-white data-[state=checked]:text-(--nonla-bg) data-[state=indeterminate]:border-white data-[state=indeterminate]:bg-white data-[state=indeterminate]:text-(--nonla-bg)"
|
|
104
|
+
/>
|
|
104
105
|
</span>
|
|
105
106
|
);
|
|
106
107
|
},
|
|
@@ -35,7 +35,7 @@ export function ChatMarkdownTable({ children }: { children: ReactNode }) {
|
|
|
35
35
|
<div className="overflow-x-auto">
|
|
36
36
|
<table
|
|
37
37
|
ref={tableRef}
|
|
38
|
-
className="w-max min-w-full wrap-normal border-separate border-spacing-0 text-[14px] [&_th]:bg-
|
|
38
|
+
className="w-max min-w-full wrap-normal border-separate border-spacing-0 text-[14px] [&_th]:bg-(--nonla-table-head) [&_th]:text-foreground [&_th]:font-semibold [&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:align-top [&_th]:border-r [&_th]:border-b [&_th]:border-border [&_th:last-child]:border-r-0 [&_td]:px-2.5 [&_td]:py-1.5 [&_td]:align-top [&_td]:text-foreground [&_td]:bg-card [&_td]:border-r [&_td]:border-b [&_td]:border-border [&_td:last-child]:border-r-0 [&_tbody_tr:last-child_td]:border-b-0"
|
|
39
39
|
>
|
|
40
40
|
{children}
|
|
41
41
|
</table>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChevronRight } from "lucide-react";
|
|
2
1
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../../lib/cn";
|
|
4
4
|
import { Shimmer } from "../../shimmer/Shimmer";
|
|
5
5
|
|
|
@@ -48,9 +48,9 @@ export function ChatThinking({ thinking, duration = 0, streaming = false, classN
|
|
|
48
48
|
if (el) el.scrollTop = el.scrollHeight;
|
|
49
49
|
}}
|
|
50
50
|
>
|
|
51
|
-
<summary className="cursor-pointer select-none text-
|
|
51
|
+
<summary className="cursor-pointer select-none text-base font-normal flex items-center gap-1 py-0.5 list-none [&::-webkit-details-marker]:hidden">
|
|
52
52
|
<Shimmer active={streaming} className="text-tertiary-foreground">{label}</Shimmer>
|
|
53
|
-
<
|
|
53
|
+
<SolarIcon name="alt-arrow-right-linear" size={12} className="shrink-0 opacity-0 text-tertiary-foreground transition-[opacity,transform] duration-150 group-hover/thinking:opacity-100 group-open/thinking:opacity-100 group-open/thinking:rotate-90" />
|
|
54
54
|
</summary>
|
|
55
55
|
|
|
56
56
|
<div ref={bodyRef} className="pt-2 max-h-40 min-w-0 overflow-y-auto overflow-x-hidden mb-2 text-[14px] leading-normal">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChevronDown } from "lucide-react";
|
|
2
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../../lib/cn";
|
|
4
4
|
|
|
5
5
|
const MAX_HEIGHT = 150;
|
|
@@ -30,7 +30,7 @@ export function ChatUserMessage({ content, className }: ChatUserMessageProps) {
|
|
|
30
30
|
<div
|
|
31
31
|
className={cn(
|
|
32
32
|
"nonla-chat-user relative isolate mt-6 mb-3 mx-4 overflow-hidden rounded-xl px-3 py-1.5",
|
|
33
|
-
"border border-solid border-
|
|
33
|
+
"border border-solid border-(--nonla-input) bg-well-strong",
|
|
34
34
|
className,
|
|
35
35
|
)}
|
|
36
36
|
>
|
|
@@ -55,7 +55,7 @@ export function ChatUserMessage({ content, className }: ChatUserMessageProps) {
|
|
|
55
55
|
}}
|
|
56
56
|
className="flex w-full cursor-pointer items-center justify-center border-0 bg-transparent pt-1 text-muted-foreground hover:text-foreground"
|
|
57
57
|
>
|
|
58
|
-
<
|
|
58
|
+
<SolarIcon name="alt-arrow-down-linear" size={12} className={cn("transition-transform duration-200", isExpanded && "rotate-180")} />
|
|
59
59
|
</button>
|
|
60
60
|
) : null}
|
|
61
61
|
</div>
|