devnonla-ui 0.14.0 → 0.16.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.
Files changed (51) hide show
  1. package/package.json +5 -2
  2. package/src/blob-shape/BlobShape.tsx +337 -0
  3. package/src/button/ButtonCopy.tsx +2 -2
  4. package/src/chat/AgentChatbox.tsx +1 -1
  5. package/src/chat/AgentPanel.tsx +1 -1
  6. package/src/chat/chatMessageList.tsx +5 -3
  7. package/src/chat/chatRhythm.ts +8 -0
  8. package/src/chat/common/createAgentSseSession.ts +9 -3
  9. package/src/chat/common/sse.ts +290 -122
  10. package/src/chat/common/useAgentStream.ts +1 -1
  11. package/src/chat/index.ts +2 -2
  12. package/src/chat/message-ui/ChatAgentMessage.tsx +4 -3
  13. package/src/chat/message-ui/ChatError.tsx +5 -4
  14. package/src/chat/message-ui/ChatInput.tsx +5 -5
  15. package/src/chat/message-ui/ChatMarkdown.tsx +36 -2
  16. package/src/chat/message-ui/ChatThinking.tsx +8 -7
  17. package/src/chat/message-ui/ChatUserMessage.tsx +4 -4
  18. package/src/chat/tool-ui/BackgroundTaskToolUI.tsx +7 -6
  19. package/src/chat/tool-ui/BackgroundTasksBar.tsx +7 -7
  20. package/src/chat/tool-ui/CallAgentToolUI.tsx +14 -13
  21. package/src/chat/tool-ui/ChatToolCall.tsx +13 -12
  22. package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +7 -6
  23. package/src/chat/tool-ui/ReadSkillToolUI.tsx +10 -9
  24. package/src/chat/tool-ui/RunJsToolUI.tsx +8 -7
  25. package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
  26. package/src/chat/tool-ui/WebFetchToolUI.tsx +10 -9
  27. package/src/codeblock/CodeBlock.tsx +1 -1
  28. package/src/desktop/DesktopIcon.tsx +3 -4
  29. package/src/icon/Icon.tsx +33 -0
  30. package/src/icon/glyphs.ts +42 -0
  31. package/src/index.ts +8 -20
  32. package/src/input/EditableInput.tsx +2 -2
  33. package/src/markdown-editor/MarkdownEditor.tsx +4 -4
  34. package/src/markdown-editor/MarkdownPreview.tsx +4 -4
  35. package/src/markdown-editor/MarkdownTable.tsx +67 -13
  36. package/src/markdown-editor/MarkdownViewer.tsx +25 -28
  37. package/src/markdown-editor/MermaidBlock.tsx +4 -4
  38. package/src/markdown-editor/ReactCodeFrame.tsx +2 -2
  39. package/src/markdown-editor/ReactCodeSandbox.tsx +2 -2
  40. package/src/markdown-editor/markdownScale.ts +65 -131
  41. package/src/menu/Menu.tsx +2 -2
  42. package/src/pagination/Pagination.tsx +4 -4
  43. package/src/scroll/OverlayScroll.tsx +13 -5
  44. package/src/sidebar/Sidebar.tsx +5 -5
  45. package/src/sortable-tree/SortableTree.tsx +599 -0
  46. package/src/styles.css +36 -16
  47. package/src/tabs/Tabs.tsx +75 -13
  48. package/src/theme-switcher/ThemeSwitcher.tsx +6 -6
  49. package/src/typography/Typography.tsx +4 -4
  50. package/src/icon/SolarIcon.tsx +0 -39
  51. package/src/icon/solar.ts +0 -172
package/src/index.ts CHANGED
@@ -17,6 +17,8 @@ export type { AlertProps, AlertType } from "./alert/Alert";
17
17
  export { Alert } from "./alert/Alert";
18
18
  export type { AgentAvatarConfig, AgentAvatarEyeColor, AgentAvatarLook, AgentAvatarMotion, AgentAvatarProps } from "./avatar/AgentAvatar";
19
19
  export { AGENT_AVATAR_PARTS, AgentAvatar } from "./avatar/AgentAvatar";
20
+ export type { BlobShapeAppearance, BlobShapeProps, BlobShapeVariant } from "./blob-shape/BlobShape";
21
+ export { BlobShape } from "./blob-shape/BlobShape";
20
22
  export type { CalendarProps } from "./calendar/Calendar";
21
23
  export { Calendar } from "./calendar/Calendar";
22
24
  export type { CardFooterProps, CardItemProps, CardProps } from "./card/Card";
@@ -28,6 +30,7 @@ export type {
28
30
  AgentMessageRole,
29
31
  AgentPanelEndpoint,
30
32
  AgentPanelProps,
33
+ AgentSseCallbacks,
31
34
  AgentStreamRequest,
32
35
  AgentToolCallEvent,
33
36
  AgentToolHook,
@@ -134,25 +137,8 @@ export {
134
137
  export type { FormLayoutItemProps, FormLayoutProps } from "./form-layout/FormLayout";
135
138
  /** Layout-only Form + Form.Item for labeled fields. */
136
139
  export { Form } from "./form-layout/FormLayout";
137
- export { FluentIcon, SolarIcon } from "./icon/SolarIcon";
138
- export {
139
- DEFAULT_ICON_NAME,
140
- DEFAULT_TOOL_ICON,
141
- ensureSolarIcons,
142
- ensureSolarIcons as ensureFluentIcons,
143
- getIconNames,
144
- getSolarImgSrc,
145
- getSolarImgSrc as getFluentImgSrc,
146
- getSolarSvg,
147
- ICON_PREFIX,
148
- isSolarIcon,
149
- isSolarIcon as isFluentIcon,
150
- isSvgIcon,
151
- solarIconName,
152
- solarIconName as fluentIconName,
153
- solarIconRef,
154
- solarIconRef as fluentIconRef,
155
- } from "./icon/solar";
140
+ export type { IconName } from "./icon/Icon";
141
+ export { Icon } from "./icon/Icon";
156
142
  export { cn } from "./lib/cn";
157
143
  export type { PopperPlacement } from "./lib/placement";
158
144
  export { placementToRadix } from "./lib/placement";
@@ -163,7 +149,7 @@ export type { LogoProps, LogoVariant } from "./logo/Logo";
163
149
  export { Logo } from "./logo/Logo";
164
150
  export type { MarkdownDiffLayout, MarkdownEditorMode, MarkdownEditorProps } from "./markdown-editor/MarkdownEditor";
165
151
  export { MarkdownEditor } from "./markdown-editor/MarkdownEditor";
166
- export type { MarkdownVariant, MarkdownViewerProps } from "./markdown-editor/MarkdownViewer";
152
+ export type { MarkdownViewerProps } from "./markdown-editor/MarkdownViewer";
167
153
  export { MarkdownViewer } from "./markdown-editor/MarkdownViewer";
168
154
  export type { MermaidBlockProps } from "./markdown-editor/MermaidBlock";
169
155
  export { MermaidBlock } from "./markdown-editor/MermaidBlock";
@@ -198,6 +184,8 @@ export type { SidebarItemType, SidebarProps, SidebarSelectInfo } from "./sidebar
198
184
  export { Sidebar } from "./sidebar/Sidebar";
199
185
  export type { SkeletonProps } from "./skeleton/Skeleton";
200
186
  export { Skeleton } from "./skeleton/Skeleton";
187
+ export type { SortableTreeChange, SortableTreeItem, SortableTreeProps } from "./sortable-tree/SortableTree";
188
+ export { SortableTree } from "./sortable-tree/SortableTree";
201
189
  export type { SpinColor, SpinProps, SpinVariant } from "./spin/Spin";
202
190
  export { Spin } from "./spin/Spin";
203
191
  export type { SplitterOrientation, SplitterPanelProps, SplitterProps, SplitterSemanticSlot, SplitterSize } from "./splitter/Splitter";
@@ -2,7 +2,7 @@ import { type CSSProperties, cloneElement, isValidElement, type KeyboardEvent, t
2
2
  import { createPortal } from "react-dom";
3
3
  import { usePopupContainer } from "../app/context";
4
4
  import { Button } from "../button/Button";
5
- import { SolarIcon } from "../icon/SolarIcon";
5
+ import { Icon } from "../icon/Icon";
6
6
  import { cn } from "../lib/cn";
7
7
  import { type CanonicalSize, type ControlSize, controlHeightVar, controlRadiusVar, getSizeTokens, useControlSize } from "../lib/sizes";
8
8
  import { glassSurfaceClass } from "../lib/surface";
@@ -228,7 +228,7 @@ function EditButton({ label, size, onClick }: { label: string; size: CanonicalSi
228
228
  className="inline-flex shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover/edit:opacity-100 focus-visible:opacity-100"
229
229
  style={{ width: box, height: box }}
230
230
  >
231
- <SolarIcon name="pen-linear" size={tok.icon} />
231
+ <Icon name="pen" size={tok.icon} />
232
232
  </button>
233
233
  );
234
234
  }
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties, type MouseEvent, type ReactNode, useCallback, useMemo, useRef, useState } from "react";
2
- import { SolarIcon } from "../icon/SolarIcon";
2
+ import { Icon } from "../icon/Icon";
3
3
  import { cn } from "../lib/cn";
4
4
  import { Segmented } from "../segmented/Segmented";
5
5
  import { appendTextBlock, cleanupDoc, joinMarkdownDoc, type MarkdownDoc, parseMarkdownDoc, readInlineEdit, splitListItem } from "./blocks";
@@ -268,9 +268,9 @@ export function MarkdownEditor({
268
268
  value={mode}
269
269
  onChange={changeMode}
270
270
  options={[
271
- { label: "Preview", value: "preview", icon: <SolarIcon name="eye-linear" size={14} /> },
272
- { label: "Edit", value: "edit", icon: <SolarIcon name="pen-linear" size={14} /> },
273
- { label: "Diff", value: "diff", icon: <SolarIcon name="transfer-horizontal-linear" size={14} />, disabled: original === undefined },
271
+ { label: "Preview", value: "preview", icon: <Icon name="eye" size={14} /> },
272
+ { label: "Edit", value: "edit", icon: <Icon name="pen" size={14} /> },
273
+ { label: "Diff", value: "diff", icon: <Icon name="transfer" size={14} />, disabled: original === undefined },
274
274
  ]}
275
275
  />
276
276
  ) : null}
@@ -2,7 +2,7 @@ import { type MouseEvent, useLayoutEffect, useRef } from "react";
2
2
  import { cn } from "../lib/cn";
3
3
  import { OverlayScroll } from "../scroll/OverlayScroll";
4
4
  import { type MarkdownDoc, readInlineEdit, writeInlineEdit } from "./blocks";
5
- import { BlockBody, headingClass, ListItem, markdownVariantStyle, spaceBefore } from "./MarkdownViewer";
5
+ import { BlockBody, headingClass, ListItem, markdownScaleStyle, spaceBefore } from "./MarkdownViewer";
6
6
 
7
7
  function BlockEditor({ value, mono, className, caret = "end", onChange, onBlur, onEnter }: { value: string; mono?: boolean; className?: string; caret?: "start" | "end"; onChange: (value: string) => void; onBlur: () => void; onEnter?: (before: string, after: string) => void }) {
8
8
  const ref = useRef<HTMLTextAreaElement>(null);
@@ -57,8 +57,8 @@ function BlockEditor({ value, mono, className, caret = "end", onChange, onBlur,
57
57
  });
58
58
  }}
59
59
  className={cn(
60
- "block w-full resize-none overflow-hidden border-0 bg-transparent p-0 text-(length:--md-body-size,16px) leading-(--md-body-leading,24px) text-foreground shadow-none outline-none ring-0 placeholder:text-quaternary-foreground focus:outline-none focus:ring-0",
61
- mono && "font-mono text-(length:--md-code-size,14px) leading-(--md-code-leading,22px)",
60
+ "block w-full resize-none overflow-hidden border-0 bg-transparent p-0 text-(length:--md-body-size,var(--nonla-md-text-size,16px)) leading-(--md-body-leading,calc(var(--nonla-md-text-size,16px)*1.6)) text-foreground shadow-none outline-none ring-0 placeholder:text-quaternary-foreground focus:outline-none focus:ring-0",
61
+ mono && "font-mono text-(length:--md-code-size,var(--nonla-mono-text-size)) leading-(--md-code-leading,calc(var(--nonla-mono-text-size)*1.6))",
62
62
  className,
63
63
  )}
64
64
  aria-label="Edit markdown"
@@ -88,7 +88,7 @@ export type MarkdownPreviewProps = {
88
88
  export function MarkdownPreview({ doc, editingIndex, readOnly, placeholder = "Write markdown…", onStartEdit, onEditMouseDown, onChangeBody, onBlurBlock, onEnterList, caret = "end", onAppend }: MarkdownPreviewProps) {
89
89
  return (
90
90
  <OverlayScroll className="h-full bg-card">
91
- <div className="mx-auto flex w-full max-w-3xl flex-col px-8 py-6" style={markdownVariantStyle("docs")}>
91
+ <div className="mx-auto flex w-full max-w-3xl flex-col px-8 py-6" style={markdownScaleStyle}>
92
92
  {doc.blocks.map((block, index) => {
93
93
  const editing = editingIndex === index;
94
94
  const locked = block.kind === "mermaid" || readOnly;
@@ -1,5 +1,7 @@
1
- import { type ReactNode, useCallback, useRef } from "react";
2
- import { ButtonCopy } from "../button/ButtonCopy";
1
+ import { type ReactNode, useCallback, useEffect, useRef, useState } from "react";
2
+ import { Button } from "../button/Button";
3
+ import { Icon } from "../icon/Icon";
4
+ import { OverlayScroll } from "../scroll/OverlayScroll";
3
5
 
4
6
  function escapeCell(text: string): string {
5
7
  return text.replace(/\|/g, "\\|").replace(/\n+/g, "").trim();
@@ -20,26 +22,78 @@ function tableToMarkdown(table: HTMLTableElement): string {
20
22
  return [`| ${header.join(" | ")} |`, `| ${separator.join(" | ")} |`, ...body.map((row) => `| ${row.join(" | ")} |`)].join("\n");
21
23
  }
22
24
 
25
+ const tableClass =
26
+ "w-max min-w-full border-separate border-spacing-0 text-base [&_th]:whitespace-normal [&_td]:whitespace-normal [&_th]:wrap-normal [&_td]:wrap-normal [&_th]:border-b [&_th]:border-border-secondary [&_th]:px-4 [&_th]:py-1.5 [&_th]:text-left [&_th]:align-top [&_th]:font-medium [&_td]:border-b [&_td]:border-border-secondary [&_td]:px-4 [&_td]:py-1.5 [&_td]:align-top";
27
+
23
28
  export function MarkdownTable({ children }: { children: ReactNode }) {
24
29
  const tableRef = useRef<HTMLTableElement>(null);
30
+ const dialogRef = useRef<HTMLDialogElement>(null);
31
+ const [copied, setCopied] = useState(false);
25
32
 
26
33
  const getText = useCallback(() => {
27
34
  const table = tableRef.current;
28
35
  return table ? tableToMarkdown(table) : "";
29
36
  }, []);
30
37
 
38
+ useEffect(() => {
39
+ if (!copied) return;
40
+ const t = window.setTimeout(() => setCopied(false), 1600);
41
+ return () => window.clearTimeout(t);
42
+ }, [copied]);
43
+
44
+ const copyMarkdown = async () => {
45
+ const value = getText();
46
+ if (!value) return;
47
+ try {
48
+ await navigator.clipboard.writeText(value);
49
+ setCopied(true);
50
+ } catch {
51
+ /* ignore */
52
+ }
53
+ };
54
+
55
+ const openFullscreen = () => {
56
+ dialogRef.current?.showModal();
57
+ };
58
+
59
+ const closeFullscreen = () => {
60
+ dialogRef.current?.close();
61
+ };
62
+
31
63
  return (
32
- <div className="relative my-(--md-table-my,16px) max-w-full overflow-hidden rounded-xl border border-border bg-card group">
33
- <ButtonCopy getText={getText} label="Copy as Markdown" className="absolute top-1 right-1 z-10 opacity-0 group-hover:opacity-100" />
34
-
35
- <div className="overflow-x-auto">
36
- <table
37
- ref={tableRef}
38
- className="w-max min-w-full border-separate border-spacing-0 text-(length:--md-table-size,15px) [&_th]:max-w-[360px] [&_td]:max-w-[360px] [&_th]:whitespace-normal [&_td]:whitespace-normal [&_th]:wrap-normal [&_td]:wrap-normal [&_th]:bg-muted [&_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]: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
- >
40
- {children}
41
- </table>
64
+ <>
65
+ <div className="group relative my-(--md-table-my,16px) max-w-full overflow-hidden rounded-xl border border-border bg-card">
66
+ <div className="absolute top-1.5 right-1.5 z-10 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100">
67
+ <Button size="small" className="bg-background" icon={<Icon name={copied ? "check" : "copy"} size={12} />} title={copied ? "Copied" : "Copy as Markdown"} aria-label={copied ? "Copied" : "Copy as Markdown"} onClick={copyMarkdown} />
68
+ <Button size="small" className="bg-background" icon={<Icon name="maximize" size={12} />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
69
+ </div>
70
+
71
+ <OverlayScroll autoHeight visibility="hover" scope="table" innerClassName="overflow-x-auto">
72
+ <table ref={tableRef} className={`${tableClass} [&_tr:last-child_td]:border-b-0 [&_th]:max-w-[360px] [&_td]:max-w-[360px]`}>
73
+ {children}
74
+ </table>
75
+ </OverlayScroll>
42
76
  </div>
43
- </div>
77
+
78
+ <dialog
79
+ ref={dialogRef}
80
+ className="inset-2.5 m-0 h-auto w-auto max-h-none max-w-none overflow-hidden rounded-xl border border-foreground/25 bg-card p-0 shadow-xl backdrop:bg-black/40 open:flex open:flex-col"
81
+ onKeyDown={(e) => {
82
+ if (e.key !== "Escape") return;
83
+ e.preventDefault();
84
+ e.stopPropagation();
85
+ closeFullscreen();
86
+ }}
87
+ >
88
+ <div className="absolute top-5 right-5 z-50 flex items-center gap-1">
89
+ <Button size="small" className="bg-background" icon={<Icon name={copied ? "check" : "copy"} size={12} />} title={copied ? "Copied" : "Copy as Markdown"} aria-label={copied ? "Copied" : "Copy as Markdown"} onClick={copyMarkdown} />
90
+ <Button size="small" className="bg-background" icon={<Icon name="minimize" size={12} />} title="Exit fullscreen" aria-label="Exit fullscreen" onClick={closeFullscreen} />
91
+ </div>
92
+
93
+ <div className="min-h-0 flex-1 overflow-auto p-8">
94
+ <table className={tableClass}>{children}</table>
95
+ </div>
96
+ </dialog>
97
+ </>
44
98
  );
45
99
  }
@@ -1,4 +1,4 @@
1
- import { type ReactNode, useMemo } from "react";
1
+ import { type CSSProperties, type ReactNode, useMemo } from "react";
2
2
  import ReactMarkdown, { type Components } from "react-markdown";
3
3
  import remarkGfm from "remark-gfm";
4
4
  import { Checkbox } from "../checkbox/Checkbox";
@@ -7,37 +7,35 @@ import { cn } from "../lib/cn";
7
7
  import { type InlineEdit, type MarkdownBlock, parseMarkdownDoc, readFence, readInlineEdit } from "./blocks";
8
8
  import { MarkdownTable } from "./MarkdownTable";
9
9
  import { MermaidBlock } from "./MermaidBlock";
10
- import { headingClass, type MarkdownVariant, markdownVariantStyle } from "./markdownScale";
10
+ import { headingClass, markdownScaleStyle } from "./markdownScale";
11
11
  import { ReactCode } from "./ReactCode";
12
12
  import { ReactCodeSandbox } from "./ReactCodeSandbox";
13
13
 
14
- export type { MarkdownVariant };
15
- export { headingClass, markdownVariantStyle };
14
+ export { headingClass, markdownScaleStyle };
16
15
 
17
16
  /** Task checks use the body ink, so a checked box sits with the text instead of the brand fill. */
18
17
  const taskCheckClass =
19
18
  "data-[state=checked]:border-foreground! data-[state=checked]:bg-foreground! data-[state=checked]:text-background! data-[state=indeterminate]:border-foreground! data-[state=indeterminate]:bg-foreground! data-[state=indeterminate]:text-background!";
20
19
 
21
20
  const documentClass = cn(
22
- "min-w-0 wrap-anywhere text-(length:--md-body-size,16px) leading-(--md-body-leading,24px) text-foreground",
21
+ "min-w-0 wrap-anywhere text-(length:--md-body-size,var(--nonla-md-text-size,16px)) leading-(--md-body-leading,calc(var(--nonla-md-text-size,16px)*1.6)) text-foreground",
23
22
  "[&_:is(h1,h2,h3,h4,h5,h6)]:text-foreground",
24
- "[&_:is(h1,h2)]:mt-(--md-h2-mt,24px) [&_h1]:mb-(--md-h1-mb,12px) [&_h2]:mb-(--md-h2-mb,1px) [&_:is(h1,h2)]:pt-(--md-h2-py,3px) [&_:is(h1,h2)]:pb-(--md-h2-py,3px) [&_:is(h1,h2)]:text-(length:--md-h2-size,30px) [&_:is(h1,h2)]:leading-(--md-h2-leading,40px) [&_:is(h1,h2)]:font-(--md-h2-weight,700) [&_:is(h1,h2)]:tracking-normal",
25
- "[&_h3]:mt-(--md-h3-mt,22px) [&_h3]:mb-(--md-h3-mb,1px) [&_h3]:text-(length:--md-h3-size,24px) [&_h3]:leading-(--md-h3-leading,32px) [&_h3]:font-(--md-h3-weight,700)",
26
- "[&_h4]:mt-(--md-h4-mt,16px) [&_h4]:mb-(--md-h4-mb,1px) [&_h4]:text-(length:--md-h4-size,20px) [&_h4]:leading-(--md-h4-leading,26px) [&_h4]:font-(--md-h4-weight,700)",
27
- "[&_h5]:mt-(--md-h5-mt,0px) [&_h5]:mb-(--md-h5-mb,0px) [&_h5]:text-(length:--md-h5-size,16px) [&_h5]:leading-(--md-h5-leading,1.375) [&_h5]:font-(--md-h5-weight,700)",
28
- "[&_h6]:mt-(--md-h6-mt,0px) [&_h6]:mb-(--md-h6-mb,0px) [&_h6]:text-(length:--md-h6-size,14px) [&_h6]:leading-(--md-h6-leading,1.375) [&_h6]:font-(--md-h6-weight,700)",
29
- "[&_p]:my-(--md-p-my,1px) [&_p]:py-(--md-p-py,4px) [&_p]:leading-(--md-p-leading,1.5)",
23
+ "[&_:is(h1,h2)]:mt-(--md-h2-mt,24px) [&_h1]:mb-(--md-h1-mb,12px) [&_h2]:mb-(--md-h2-mb,8px) [&_:is(h1,h2)]:pt-(--md-h2-py,3px) [&_:is(h1,h2)]:pb-(--md-h2-py,3px) [&_:is(h1,h2)]:text-(length:--md-h2-size,26px) [&_:is(h1,h2)]:leading-(--md-h2-leading,32px) [&_:is(h1,h2)]:font-(--md-h2-weight,600) [&_:is(h1,h2)]:tracking-normal",
24
+ "[&_h3]:mt-(--md-h3-mt,22px) [&_h3]:mb-(--md-h3-mb,8px) [&_h3]:text-(length:--md-h3-size,24px) [&_h3]:leading-(--md-h3-leading,32px) [&_h3]:font-(--md-h3-weight,600)",
25
+ "[&_:is(h4,h5,h6)]:mt-(--md-h4-mt,16px) [&_:is(h4,h5,h6)]:mb-(--md-h4-mb,1px) [&_:is(h4,h5,h6)]:text-(length:--md-h4-size,20px) [&_:is(h4,h5,h6)]:leading-(--md-h4-leading,26px) [&_:is(h4,h5,h6)]:font-(--md-h4-weight,700)",
26
+ "[&_p]:my-(--md-p-my,1px) [&_p]:py-(--md-p-py,4px) [&_p]:leading-(--md-p-leading,1.6)",
30
27
  "[&_ul]:my-(--md-list-my,8px) [&_ul]:list-disc [&_ul]:pl-(--md-ul-pl,4px)",
31
28
  "[&_ol]:my-(--md-list-my,8px) [&_ol]:list-decimal [&_ol]:pl-(--md-ol-pl,4px)",
32
29
  "[&_li>ul]:mt-1 [&_li>ol]:mt-1 [&_li>ol]:pl-(--md-nest,1.25rem)",
33
30
  "[&_th_ul]:my-0 [&_td_ul]:my-0 [&_th_ol]:my-0 [&_td_ol]:my-0 [&_th_li]:mt-0 [&_td_li]:mt-0 [&_th_li>ul]:mt-0.5 [&_td_li>ul]:mt-0.5 [&_th_li>ol]:mt-0.5 [&_td_li>ol]:mt-0.5 [&_th_li>p]:my-0 [&_td_li>p]:my-0",
34
31
  "[&_ul.contains-task-list]:list-none",
35
- "[&_li]:mt-(--md-li-mt,4px) [&_li]:leading-[1.5]",
32
+ "[&_li]:mt-(--md-li-mt,4px) [&_li]:leading-[1.6]",
36
33
  "[&_li.task-list-item]:relative",
37
34
  "[&_li.task-list-item>.nonla-md-task-check]:absolute [&_li.task-list-item>.nonla-md-task-check]:top-1 [&_li.task-list-item>.nonla-md-task-check]:-left-5",
38
- "[&_blockquote]:my-(--md-quote-my,4px) [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground",
35
+ /* Body paragraphs sit in separate blocks, so their margins do not collapse. Quote paragraphs share one block, so the next paragraph's top margin is doubled to land on that same gap. */
36
+ "[&_blockquote]:my-(--md-quote-my,0px) [&_blockquote>p:not(:first-child)]:mt-[calc(var(--md-p-my,1px)*2)] [&_blockquote>p:not(:last-child)]:mb-0 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-foreground",
39
37
  "[&_a]:text-link [&_a]:underline-offset-[3px] hover:[&_a]:underline",
40
- "[&_hr]:my-(--md-rule-my,8px) [&_hr]:border-border",
38
+ "[&_hr]:hidden",
41
39
  "[&_strong]:font-(--md-strong-weight,600)",
42
40
  "[&_img]:my-(--md-img-my,4px) [&_img]:max-w-full [&_img]:rounded-lg",
43
41
  );
@@ -49,7 +47,7 @@ const previewComponents: Components = {
49
47
  const codeText = String(children).replace(/\n$/, "");
50
48
  const isBlock = codeText.includes("\n") || !!match;
51
49
  if (!isBlock) {
52
- return <code className="nonla-inline-code rounded-sm bg-muted px-[0.35em] py-[0.12em] align-baseline font-mono text-(length:--md-inline-size,14px) leading-none whitespace-nowrap [box-decoration-break:clone] [-webkit-box-decoration-break:clone]">{children}</code>;
50
+ return <code className="nonla-inline-code rounded-[4px] bg-muted px-[2px] py-px align-baseline font-mono text-(length:--md-inline-size,var(--nonla-mono-text-size)) leading-none whitespace-nowrap [box-decoration-break:clone] [-webkit-box-decoration-break:clone]">{children}</code>;
53
51
  }
54
52
  if (lang.toLowerCase() === "mermaid") return <MermaidView code={codeText} />;
55
53
  return <CodeBlock code={codeText} language={lang || undefined} className="my-(--md-code-my,8px)" />;
@@ -67,7 +65,7 @@ const previewComponents: Components = {
67
65
  input({ type, checked }) {
68
66
  if (type !== "checkbox") return <input type={type} checked={checked} readOnly />;
69
67
  return (
70
- <span className="nonla-md-task-check pointer-events-none inline-flex h-(--md-body-leading,24px) items-center">
68
+ <span className="nonla-md-task-check pointer-events-none inline-flex h-(--md-body-leading,calc(var(--nonla-md-text-size,16px)*1.6)) items-center">
71
69
  <Checkbox checked={Boolean(checked)} tabIndex={-1} className={taskCheckClass} />
72
70
  </span>
73
71
  );
@@ -137,7 +135,7 @@ function RichText({ source }: { source: string }) {
137
135
  export function ListItem({ view, children }: { view: Extract<InlineEdit, { kind: "list" }>; children: ReactNode }) {
138
136
  const level = Math.floor(view.indent.length / 2);
139
137
  const ordinal = Number(/^(\d+)/.exec(view.marker)?.[1] ?? "1");
140
- const marker = "w-6 shrink-0 pt-0.5 text-(length:--md-body-size,16px) leading-(--md-p-leading,1.5)";
138
+ const marker = "w-6 shrink-0 pt-0.5 text-(length:--md-body-size,var(--nonla-md-text-size,16px)) leading-(--md-p-leading,1.6)";
141
139
  return (
142
140
  <div className="flex items-start gap-1.5 pl-(--md-item-pl,4px)" style={level > 0 ? { marginLeft: `calc(${level} * var(--md-nest, 1.25rem))` } : undefined}>
143
141
  {view.task ? (
@@ -162,14 +160,13 @@ function isListBlock(block: MarkdownBlock): boolean {
162
160
  return block.kind === "text" && readInlineEdit(block.body).kind === "list";
163
161
  }
164
162
 
165
- export function spaceBefore(block: MarkdownBlock, prev?: MarkdownBlock, variant: MarkdownVariant = "docs"): string {
166
- const chat = variant === "chat";
163
+ export function spaceBefore(block: MarkdownBlock, prev?: MarkdownBlock): string {
167
164
  if (!prev) return "";
168
- if (isListBlock(block) && isListBlock(prev)) return chat ? "mt-px" : "mt-0.5";
169
- if (prev.kind === "text" && readInlineEdit(prev.body).kind === "heading") return "[&_p]:mt-0! [&_p]:pt-0.5!";
170
- if (isListBlock(block) && prev.kind === "text") return chat ? "mt-0.5" : "mt-1";
165
+ if (isListBlock(block) && isListBlock(prev)) return "mt-0.5";
166
+ if (prev.kind === "text" && readInlineEdit(prev.body).kind === "heading") return "[&_p:first-child]:mt-0! [&_p:first-child]:pt-0.5!";
167
+ if (isListBlock(block) && prev.kind === "text") return "mt-1";
171
168
  if (block.kind === "text" && prev.kind === "text") return "";
172
- return chat ? "mt-2" : "mt-3";
169
+ return "mt-3";
173
170
  }
174
171
 
175
172
  function fenceClosed(body: string): boolean {
@@ -235,24 +232,24 @@ export type MarkdownViewerProps = {
235
232
  showHeader?: boolean;
236
233
  /** Switch that opens the source of a `live-react` preview. Needs `showHeader`. Default `true`. */
237
234
  showCode?: boolean;
238
- /** `docs` is the article scale. `chat` tightens size and spacing for a thread. Default `docs`. */
239
- variant?: MarkdownVariant;
235
+ /** Overrides scale variables from `markdownScaleStyle`, such as heading size. */
236
+ style?: CSSProperties;
240
237
  };
241
238
 
242
239
  /** Read-only markdown. Same blocks as the editor preview, without editing. */
243
- export function MarkdownViewer({ value = "", streaming = false, sandboxSrc, trustedModules, showHeader = true, showCode = true, placeholder, className, variant = "docs" }: MarkdownViewerProps) {
240
+ export function MarkdownViewer({ value = "", streaming = false, sandboxSrc, trustedModules, showHeader = true, showCode = true, placeholder, className, style }: MarkdownViewerProps) {
244
241
  const doc = useMemo(() => parseMarkdownDoc(value), [value]);
245
242
  if (doc.blocks.length === 0) {
246
243
  return placeholder ? <p className={cn("m-0 text-sm text-quaternary-foreground", className)}>{placeholder}</p> : null;
247
244
  }
248
245
  return (
249
- <div data-variant={variant} className={cn("nonla-markdown-viewer flex min-w-0 flex-col text-foreground", variant === "chat" && "[&>[data-md-block]:first-child_:is(h1,h2,h3,h4,h5,h6)]:mt-0", className)} style={markdownVariantStyle(variant)}>
246
+ <div className={cn("nonla-markdown-viewer flex min-w-0 flex-col text-foreground", className)} style={{ ...markdownScaleStyle, ...style }}>
250
247
  {doc.blocks.map((block, index) => (
251
248
  <div
252
249
  // biome-ignore lint/suspicious/noArrayIndexKey: block position is the document identity
253
250
  key={`${index}:${block.kind}`}
254
251
  data-md-block={block.kind}
255
- className={cn("outline-none", spaceBefore(block, doc.blocks[index - 1], variant))}
252
+ className={cn("outline-none", spaceBefore(block, doc.blocks[index - 1]))}
256
253
  >
257
254
  <BlockBody block={block} streaming={streaming} trustedModules={trustedModules} sandboxSrc={sandboxSrc} showHeader={showHeader} showCode={showCode} />
258
255
  </div>
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
2
2
  import { Button } from "../button/Button";
3
3
  import { CodeBlock } from "../codeblock/CodeBlock";
4
- import { SolarIcon } from "../icon/SolarIcon";
4
+ import { Icon } from "../icon/Icon";
5
5
  import { cn } from "../lib/cn";
6
6
  import { getColorMode, subscribeColorMode } from "../theme";
7
7
  import { sanitizeMermaid } from "./sanitizeMermaid";
@@ -191,7 +191,7 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
191
191
  <>
192
192
  <div className={cn("my-3 last:mb-0 group relative overflow-hidden rounded-xl bg-card", className)}>
193
193
  <div className="absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
194
- <Button size="small" icon={<SolarIcon name="maximize-linear" size={12} />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
194
+ <Button size="small" icon={<Icon name="maximize" size={12} />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
195
195
  </div>
196
196
  <div ref={containerRef} className="flex justify-center p-6 overflow-x-auto [&_svg]:max-w-full" />
197
197
  </div>
@@ -208,8 +208,8 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
208
208
  }}
209
209
  >
210
210
  <div className="absolute top-5 right-5 z-50 flex items-center gap-1.5">
211
- <Button size="small" icon={<SolarIcon name="download-linear" size={12} />} title="Download SVG" aria-label="Download SVG" onClick={downloadSvg} disabled={!svgContent} />
212
- <Button size="small" icon={<SolarIcon name="minimize-linear" size={12} />} title="Exit fullscreen" onClick={closeFullscreen}>
211
+ <Button size="small" icon={<Icon name="download" size={12} />} title="Download SVG" aria-label="Download SVG" onClick={downloadSvg} disabled={!svgContent} />
212
+ <Button size="small" icon={<Icon name="minimize" size={12} />} title="Exit fullscreen" onClick={closeFullscreen}>
213
213
  Exit
214
214
  </Button>
215
215
  </div>
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode, useState } from "react";
2
2
  import { CodeBlock } from "../codeblock/CodeBlock";
3
- import { SolarIcon } from "../icon/SolarIcon";
3
+ import { Icon } from "../icon/Icon";
4
4
  import { cn } from "../lib/cn";
5
5
  import { Segmented } from "../segmented/Segmented";
6
6
  import { Tooltip } from "../tooltip/Tooltip";
@@ -61,7 +61,7 @@ export function ReactCodeFrame({ title, icon, showHeader = true, code, className
61
61
  )}
62
62
  onClick={() => setOpen((value) => !value)}
63
63
  >
64
- <SolarIcon name="code-square-linear" size={16} />
64
+ <Icon name="code" size={16} />
65
65
  </button>
66
66
  </Tooltip>
67
67
  </div>
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
2
- import { SolarIcon } from "../icon/SolarIcon";
2
+ import { Icon } from "../icon/Icon";
3
3
  import { cn } from "../lib/cn";
4
4
  import { getColorMode, type NonlaColorMode, subscribeColorMode } from "../theme";
5
5
  import { ReactCodeFrame } from "./ReactCodeFrame";
@@ -136,7 +136,7 @@ export function ReactCodeSandbox({ code, src, showHeader = true, showCode = true
136
136
  return (
137
137
  <ReactCodeFrame
138
138
  title={title}
139
- icon={icon === undefined ? <SolarIcon name="shield-check-linear" size={16} className="text-success" /> : icon}
139
+ icon={icon === undefined ? <Icon name="shield-check" size={16} className="text-success" /> : icon}
140
140
  showHeader={showHeader}
141
141
  code={showCode ? code : undefined}
142
142
  className={className}