devnonla-ui 0.17.2 → 0.18.1

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.
@@ -51,7 +51,7 @@ function TaskRow({
51
51
  <div className="flex items-center gap-1 px-1.5 py-0.5">
52
52
  <button type="button" onClick={onLogs} title="Logs" aria-label={`Logs ${formatToolName(task.toolName)}`} className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-1 py-[3px] text-left transition-colors hover:bg-muted">
53
53
  <Spin variant="agent" size="small" className="shrink-0" />
54
- <span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">{formatToolName(task.toolName)}</span>
54
+ <span className="min-w-0 flex-1 truncate text-sm font-normal text-foreground">{formatToolName(task.toolName)}</span>
55
55
  <span className="shrink-0 text-sm tabular-nums text-tertiary-foreground">{formatBgElapsed(task.startedAt, now)}</span>
56
56
  </button>
57
57
  <Popconfirm title={`Stop ${formatToolName(task.toolName)}?`} okText="Stop" okType="danger" onConfirm={onCancel} getPopupContainer={() => document.body}>
@@ -100,50 +100,48 @@ export function BackgroundTasksBar({ children, tasks = [], cancellingIds, onCanc
100
100
  setListH(0);
101
101
  return;
102
102
  }
103
- const update = () => setListH(el.scrollHeight);
103
+ const update = () => {
104
+ const next = el.offsetHeight;
105
+ setListH((h) => (h === next ? h : next));
106
+ };
104
107
  update();
105
108
  const ro = new ResizeObserver(update);
106
109
  ro.observe(el);
107
110
  return () => ro.disconnect();
108
- }, [tasks.length, open]);
111
+ }, [tasks.length]);
109
112
 
110
113
  const label = tasks.length === 1 ? "1 background task" : `${tasks.length} background tasks`;
111
- const reserve = tasks.length > 0 ? 28 + (open ? listH : 0) : 0;
112
114
 
113
115
  return (
114
116
  <>
115
- <div className="pointer-events-none shrink-0 overflow-hidden transition-[height] duration-200 ease-out" style={{ height: reserve }} aria-hidden />
116
- <div className="relative">
117
- {children}
118
-
119
- {tasks.length > 0 ? (
120
- <div className="absolute inset-x-6 bottom-[calc(100%)] z-20 overflow-hidden rounded-t-lg border-x border-t border-border">
121
- <div className={cn("flex h-7.5 items-center gap-1 px-1", open && "border-b border-border-secondary")}>
122
- <button type="button" onClick={() => setOpen((v) => !v)} className="flex min-w-0 flex-1 cursor-pointer font-medium items-center gap-1 rounded-md px-1.5 py-1 text-sm text-muted-foreground/90 transition-colors hover:text-foreground" aria-expanded={open} aria-label={label}>
123
- <Icon name="arrow-down" size={13} className={cn("shrink-0 transition-transform duration-150", !open && "-rotate-90")} />
124
- <span className="truncate">{label}</span>
125
- </button>
126
- </div>
117
+ {tasks.length > 0 ? (
118
+ <div className="mx-8 rounded-t-lg bg-muted-strong shadow-[inset_0_1px_0_0_var(--nonla-border),inset_1px_0_0_0_var(--nonla-border),inset_-1px_0_0_0_var(--nonla-border)] [.light:not(.dark)_&]:bg-background [.light_.nonla-ui:not(.dark)_&]:bg-background">
119
+ <div className={cn("flex h-7.5 items-center gap-1 border-b px-1", open ? "border-border-secondary" : "border-transparent")}>
120
+ <button type="button" onClick={() => setOpen((v) => !v)} className="flex min-w-0 flex-1 cursor-pointer font-normal items-center gap-1 rounded-md px-1.5 py-1 text-sm text-muted-foreground/90 transition-colors hover:text-foreground" aria-expanded={open} aria-label={label}>
121
+ <Icon name="arrow-down" size={13} className={cn("shrink-0 transition-transform duration-200 ease-out", !open && "-rotate-90")} />
122
+ <span className="truncate">{label}</span>
123
+ </button>
124
+ </div>
127
125
 
128
- <div className={cn("overflow-hidden transition-[max-height] duration-200 ease-out", open ? "max-h-55" : "max-h-0")}>
129
- <div ref={listInnerRef} className="max-h-55 overflow-y-auto py-0.5">
130
- {tasks.map((task) => (
131
- <TaskRow
132
- key={task.taskId}
133
- task={task}
134
- now={now}
135
- cancelling={cancellingIds?.has(task.taskId) ?? false}
136
- onCancel={() => {
137
- void onCancel?.(task.taskId);
138
- }}
139
- onLogs={() => setLogsTaskId(task.taskId)}
140
- />
141
- ))}
142
- </div>
126
+ <div className="overflow-hidden transition-[height] duration-200 ease-out" style={{ height: open ? listH : 0 }}>
127
+ <div ref={listInnerRef} className="max-h-55 overflow-y-auto py-0.5">
128
+ {tasks.map((task) => (
129
+ <TaskRow
130
+ key={task.taskId}
131
+ task={task}
132
+ now={now}
133
+ cancelling={cancellingIds?.has(task.taskId) ?? false}
134
+ onCancel={() => {
135
+ void onCancel?.(task.taskId);
136
+ }}
137
+ onLogs={() => setLogsTaskId(task.taskId)}
138
+ />
139
+ ))}
143
140
  </div>
144
141
  </div>
145
- ) : null}
146
- </div>
142
+ </div>
143
+ ) : null}
144
+ {children}
147
145
 
148
146
  <TaskLogsModal task={logsTask} open={Boolean(logsTask)} onClose={() => setLogsTaskId(null)} />
149
147
  </>
@@ -35,7 +35,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
35
35
  <>
36
36
  {identityIcon}
37
37
  <span className="flex min-w-0 items-center gap-1">
38
- <Shimmer active={running} className={cn("min-w-0 truncate text-left font-medium", !running && "text-muted-foreground")}>{displayLabel}</Shimmer>
38
+ <Shimmer active={running} className={cn("min-w-0 truncate text-left font-normal", !running && "text-muted-foreground")}>{displayLabel}</Shimmer>
39
39
  <ToolUiTrailing failed={hasError} chevron={expandable} chevronClassName={cn("text-muted-foreground group-hover:opacity-100", open && "opacity-100 rotate-90")} />
40
40
  </span>
41
41
  </>
@@ -42,7 +42,7 @@ export function GetCurrentTimeToolUI({ msg, assistantLabel = "Assistant", assist
42
42
  <div className="px-4">
43
43
  <div className={chatToolLineClass}>
44
44
  <Icon name="clock" size={13} className="shrink-0 text-muted-foreground" />
45
- <Shimmer active={running} className="truncate font-medium tabular-nums text-muted-foreground">{hasError ? "Failed to get time" : running ? "Getting time…" : label}</Shimmer>
45
+ <Shimmer active={running} className="truncate font-normal tabular-nums text-muted-foreground">{hasError ? "Failed to get time" : running ? "Getting time…" : label}</Shimmer>
46
46
  <ToolUiTrailing failed={hasError} />
47
47
  </div>
48
48
  </div>
@@ -57,7 +57,7 @@ export function ReadSkillToolUI({ msg, assistantLabel = "Assistant", assistantCo
57
57
  <details className="group/readskill px-4" style={{ overflowAnchor: "none" }}>
58
58
  <summary className={cn(chatToolLineClass, "cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden")}>
59
59
  <Icon name={reference ? "document" : "book"} size={13} className="shrink-0 text-muted-foreground" />
60
- <Shimmer active={running} className="min-w-0 truncate font-medium text-muted-foreground">
60
+ <Shimmer active={running} className="min-w-0 truncate font-normal text-muted-foreground">
61
61
  {verb}
62
62
  {targetLabel ? <span className="text-tertiary-foreground"> {targetLabel}</span> : null}
63
63
  </Shimmer>
@@ -89,7 +89,7 @@ export function RunJsToolUI({ msg, assistantLabel = "Assistant", assistantColor,
89
89
  <details className="group/runjs px-4" style={{ overflowAnchor: "none" }}>
90
90
  <summary className={cn(chatToolLineClass, "cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden")}>
91
91
  <Icon name="code" size={13} className="shrink-0 text-muted-foreground" />
92
- <Shimmer active={running} className="min-w-0 truncate font-medium text-muted-foreground">{verb}</Shimmer>
92
+ <Shimmer active={running} className="min-w-0 truncate font-normal text-muted-foreground">{verb}</Shimmer>
93
93
  <ToolUiTrailing running={running} failed={failed} chevron chevronClassName="group-hover/runjs:opacity-100 group-open/runjs:opacity-100 group-open/runjs:rotate-90" />
94
94
  </summary>
95
95
 
@@ -39,7 +39,7 @@ export function WebFetchToolUI({ msg, assistantLabel = "Assistant", assistantCol
39
39
  const header = (
40
40
  <>
41
41
  <Icon name="globe" size={13} className="shrink-0 text-muted-foreground" />
42
- <Shimmer active={running} className="min-w-0 truncate font-medium text-muted-foreground">
42
+ <Shimmer active={running} className="min-w-0 truncate font-normal text-muted-foreground">
43
43
  {verb} <span className="text-tertiary-foreground">{url}</span>
44
44
  </Shimmer>
45
45
  <ToolUiTrailing failed={failed} chevron={expandable} chevronClassName="group-hover/webfetch:opacity-100 group-open/webfetch:opacity-100 group-open/webfetch:rotate-90" />
@@ -1,14 +1,13 @@
1
1
  import type { ComponentType } from "react";
2
2
  import type { AgentToolNameMatch } from "../common/types";
3
- import { isCallAgentToolName, matchesToolName } from "../common/utils";
4
- import { CallAgentToolUI } from "./CallAgentToolUI";
3
+ import { matchesToolName } from "../common/utils";
5
4
  import { GetCurrentTimeToolUI } from "./GetCurrentTimeToolUI";
6
5
  import { ReadSkillToolUI } from "./ReadSkillToolUI";
7
6
  import { RunJsToolUI } from "./RunJsToolUI";
8
7
  import type { ToolUIProps } from "./types";
9
8
  import { WebFetchToolUI } from "./WebFetchToolUI";
10
9
 
11
- /** Exact name, aliases, or a predicate (e.g. `call_agent__*`). */
10
+ /** Exact name, aliases, or a predicate. */
12
11
  export type AgentToolUIName = AgentToolNameMatch;
13
12
 
14
13
  export type AgentToolUI = {
@@ -21,11 +20,10 @@ export function matchesToolUIName(name: AgentToolUIName, toolName: string): bool
21
20
  }
22
21
 
23
22
  export const builtinToolUis: AgentToolUI[] = [
24
- { name: isCallAgentToolName, component: CallAgentToolUI },
25
- { name: ["web_fetch", "fetch_url", "browser"], component: WebFetchToolUI },
26
- { name: "get_current_time", component: GetCurrentTimeToolUI },
27
- { name: "read_skill", component: ReadSkillToolUI },
28
- { name: "run_js", component: RunJsToolUI },
23
+ { name: "nonla_web_fetch", component: WebFetchToolUI },
24
+ { name: "nonla_get_current_time", component: GetCurrentTimeToolUI },
25
+ { name: "nonla_read_skill", component: ReadSkillToolUI },
26
+ { name: "nonla_run_js", component: RunJsToolUI },
29
27
  ];
30
28
 
31
29
  /** App `toolUis` win on the same name; builtins are the fallback. */
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 { AgentBodyConfig, AgentBodyLook, AgentBodyMotion, AgentBodyProps } from "./avatar/AgentBody";
21
+ export { AGENT_BODY_PARTS, AgentBody } from "./avatar/AgentBody";
20
22
  export type { BlobShapeAppearance, BlobShapeProps, BlobShapeVariant } from "./blob-shape/BlobShape";
21
23
  export { BlobShape } from "./blob-shape/BlobShape";
22
24
  export type { CalendarProps } from "./calendar/Calendar";
@@ -23,7 +23,7 @@ function tableToMarkdown(table: HTMLTableElement): string {
23
23
  }
24
24
 
25
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";
26
+ "w-max min-w-full border-separate border-spacing-0 text-sm [&_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
27
 
28
28
  export function MarkdownTable({ children }: { children: ReactNode }) {
29
29
  const tableRef = useRef<HTMLTableElement>(null);
@@ -137,7 +137,7 @@ export function ListItem({ view, children }: { view: Extract<InlineEdit, { kind:
137
137
  const ordinal = Number(/^(\d+)/.exec(view.marker)?.[1] ?? "1");
138
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)";
139
139
  return (
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}>
140
+ <div data-md-list="" className="flex items-start gap-1.5 pl-(--md-item-pl,4px)" style={level > 0 ? { marginLeft: `calc(${level} * var(--md-nest, 1.25rem))` } : undefined}>
141
141
  {view.task ? (
142
142
  <span className={cn(marker, "pointer-events-none inline-flex justify-center")}>
143
143
  <span className="mt-[calc((1lh-1rem)/2)] inline-flex">
@@ -12,6 +12,15 @@ function useMermaidTheme(): "default" | "dark" {
12
12
  return mode === "light" ? "default" : "dark";
13
13
  }
14
14
 
15
+ /** Same stack as `--nonla-font` on `.nonla-ui` (Inter Variable). Mermaid bakes this into the SVG. */
16
+ function mermaidFontFamily(): string {
17
+ const fallback = '"Inter Variable", ui-sans-serif, system-ui, sans-serif';
18
+ if (typeof document === "undefined") return fallback;
19
+ const host = document.querySelector(".nonla-ui");
20
+ const value = host ? getComputedStyle(host).getPropertyValue("--nonla-font").trim() : "";
21
+ return value || fallback;
22
+ }
23
+
15
24
  /** Mermaid keeps one global theme. Render one diagram at a time so a cancelled pass cannot overwrite it. */
16
25
  let mermaidQueue: Promise<unknown> = Promise.resolve();
17
26
 
@@ -51,9 +60,12 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
51
60
 
52
61
  await enqueueMermaid(async () => {
53
62
  if (cancelled) return;
63
+ const fontFamily = mermaidFontFamily();
54
64
  mermaid.initialize({
55
65
  startOnLoad: false,
56
66
  theme,
67
+ fontFamily,
68
+ themeVariables: { fontFamily },
57
69
  });
58
70
 
59
71
  const raw = children.trim();
@@ -47,18 +47,34 @@ export type SortableTreeProps<T = unknown> = {
47
47
 
48
48
  const DROP_ANIMATION = { duration: 180, easing: "cubic-bezier(0.16, 1, 0.3, 1)" };
49
49
 
50
- /** Keep the floating preview inside the window. Uses the source rect so the overlay is not clamped twice. */
51
- const clampOverlayToWindow: Modifier = ({ transform, activeNodeRect, windowRect }) => {
50
+ type OverlayOrigin = { key: string; left: number; top: number; width: number; height: number };
51
+
52
+ /**
53
+ * The overlay is `position: fixed` at the rect from drag start, then translated.
54
+ * `activeNodeRect` keeps moving as the list scrolls, so clamping against it
55
+ * walks the preview off the pointer. Lock the origin for the whole drag.
56
+ */
57
+ let overlayOrigin: OverlayOrigin | null = null;
58
+
59
+ const clampOverlayToWindow: Modifier = ({ transform, active, activeNodeRect, windowRect }) => {
60
+ if (!active) {
61
+ overlayOrigin = null;
62
+ return transform;
63
+ }
52
64
  if (!activeNodeRect || !windowRect) return transform;
65
+ const key = String(active.id);
66
+ if (!overlayOrigin || overlayOrigin.key !== key) {
67
+ overlayOrigin = { key, left: activeNodeRect.left, top: activeNodeRect.top, width: activeNodeRect.width, height: activeNodeRect.height };
68
+ }
53
69
  const next = { ...transform };
54
- const left = activeNodeRect.left + transform.x;
55
- const top = activeNodeRect.top + transform.y;
56
- const maxLeft = windowRect.left + windowRect.width - activeNodeRect.width;
57
- const maxTop = windowRect.top + windowRect.height - activeNodeRect.height;
58
- if (left < windowRect.left) next.x = windowRect.left - activeNodeRect.left;
59
- else if (left > maxLeft) next.x = maxLeft - activeNodeRect.left;
60
- if (top < windowRect.top) next.y = windowRect.top - activeNodeRect.top;
61
- else if (top > maxTop) next.y = maxTop - activeNodeRect.top;
70
+ const left = overlayOrigin.left + transform.x;
71
+ const top = overlayOrigin.top + transform.y;
72
+ const maxLeft = windowRect.left + windowRect.width - overlayOrigin.width;
73
+ const maxTop = windowRect.top + windowRect.height - overlayOrigin.height;
74
+ if (left < windowRect.left) next.x = windowRect.left - overlayOrigin.left;
75
+ else if (left > maxLeft) next.x = maxLeft - overlayOrigin.left;
76
+ if (top < windowRect.top) next.y = windowRect.top - overlayOrigin.top;
77
+ else if (top > maxTop) next.y = maxTop - overlayOrigin.top;
62
78
  return next;
63
79
  };
64
80
 
@@ -87,10 +103,9 @@ function faceRect(root: HTMLElement | null, id: string): DOMRect | null {
87
103
  return node instanceof HTMLElement ? node.getBoundingClientRect() : null;
88
104
  }
89
105
 
90
- /**
91
- * The seam between two parents is only a couple of pixels, and it falls on the last child.
92
- * A pointer in the lower half of that child — or in the seam just under it — is aiming at the next parent.
93
- */
106
+ /** Only the last few pixels of a trailing child belong to the next parent. The rest of the row stays with that child. */
107
+ const PARENT_SEAM = 6;
108
+
94
109
  function gapTarget<T>(items: SortableTreeItem<T>[], hitId: string, pointerY: number | null, root: HTMLElement | null, blocked: Set<string>): string {
95
110
  if (pointerY == null) return hitId;
96
111
  const flat = flatten(items);
@@ -106,10 +121,28 @@ function gapTarget<T>(items: SortableTreeItem<T>[], hitId: string, pointerY: num
106
121
  const following = flat[scan];
107
122
  if (!following || following.depth >= hit.depth || blocked.has(following.id)) return hitId;
108
123
  const rect = faceRect(root, hitId);
109
- if (!rect || pointerY < rect.top + rect.height / 2) return hitId;
124
+ if (!rect || pointerY < rect.bottom - PARENT_SEAM) return hitId;
110
125
  return following.id;
111
126
  }
112
127
 
128
+ /** Distance from the pointer. `closestCenter` measures the overlay rect, which already includes the drag delta, so it drifts off the cursor. */
129
+ function closestToPointer(containers: Parameters<CollisionDetection>[0]["droppableContainers"], rects: Parameters<CollisionDetection>[0]["droppableRects"], pointer: { x: number; y: number }): Collision | undefined {
130
+ let best: Collision | undefined;
131
+ let bestDistance = Number.POSITIVE_INFINITY;
132
+ for (const container of containers) {
133
+ const rect = rects.get(container.id);
134
+ if (!rect) continue;
135
+ const dx = rect.left + rect.width / 2 - pointer.x;
136
+ const dy = rect.top + rect.height / 2 - pointer.y;
137
+ const distance = dx * dx + dy * dy;
138
+ if (distance < bestDistance) {
139
+ bestDistance = distance;
140
+ best = { id: container.id };
141
+ }
142
+ }
143
+ return best;
144
+ }
145
+
113
146
  function smallestHit(hits: Collision[], rects: Parameters<CollisionDetection>[0]["droppableRects"]): Collision {
114
147
  let best = hits[0];
115
148
  let bestArea = Number.POSITIVE_INFINITY;
@@ -147,14 +180,14 @@ function collideTree<T>(args: Parameters<CollisionDetection>[0], items: Sortable
147
180
  const containers = args.droppableContainers.filter((container) => !blocked.has(String(container.id)));
148
181
  const scoped = { ...args, droppableContainers: containers };
149
182
  const inside = pointerWithin(scoped);
150
- let hit = inside.length > 0 ? smallestHit(inside, args.droppableRects) : closestCenter(scoped)[0];
183
+ let hit = inside.length > 0 ? smallestHit(inside, args.droppableRects) : pointer ? closestToPointer(containers, args.droppableRects, pointer) : closestCenter(scoped)[0];
151
184
  if (!hit) return [];
152
185
 
153
186
  const activeId = String(args.active.id);
154
187
  if (isAncestor(items, activeId, String(hit.id)) && !pointerInside(faceRect(root, String(hit.id)), pointer)) {
155
188
  const parentId = parentIdOf(args.active.data.current);
156
189
  const siblings = containers.filter((container) => parentIdOf(container.data.current) === parentId);
157
- const siblingHit = closestCenter({ ...scoped, droppableContainers: siblings })[0];
190
+ const siblingHit = pointer ? closestToPointer(siblings, args.droppableRects, pointer) : closestCenter({ ...scoped, droppableContainers: siblings })[0];
158
191
  if (siblingHit) hit = siblingHit;
159
192
  }
160
193
 
@@ -395,8 +428,12 @@ function OverlayBranch<T>({ item, renderItem }: { item: SortableTreeItem<T>; ren
395
428
  );
396
429
  }
397
430
 
398
- function DropLine({ edge }: { edge: "top" | "bottom" }) {
399
- return <span aria-hidden className={cn("pointer-events-none absolute inset-x-1 z-10 h-0.5 rounded-full bg-foreground", edge === "top" ? "top-0" : "bottom-0")} />;
431
+ /** Insertion edge, painted above the drag preview so the ghost cannot hide it. */
432
+ function FloatingDropLine({ root, hint }: { root: HTMLElement | null; hint: DropHint }) {
433
+ const rect = faceRect(root, hint.overId);
434
+ if (!rect) return null;
435
+ const top = hint.edge === "top" ? rect.top : rect.bottom;
436
+ return <span aria-hidden className="pointer-events-none fixed z-1100 h-0.5 rounded-full bg-foreground" style={{ top: top - 1, left: rect.left + 6, width: Math.max(0, rect.width - 12) }} />;
400
437
  }
401
438
 
402
439
  function SortableNode<T>({
@@ -404,20 +441,19 @@ function SortableNode<T>({
404
441
  parentId,
405
442
  depth,
406
443
  renderItem,
407
- hint,
444
+ sorting,
408
445
  }: {
409
446
  item: SortableTreeItem<T>;
410
447
  parentId: string | null;
411
448
  depth: number;
412
449
  renderItem?: SortableTreeProps<T>["renderItem"];
413
- hint: DropHint | null;
450
+ sorting: boolean;
414
451
  }) {
415
452
  const { attributes, listeners, setActivatorNodeRef, setNodeRef, transform, transition, isDragging } = useSortable({
416
453
  id: item.id,
417
454
  data: { parentId },
418
455
  disabled: item.disabled ? { draggable: true } : false,
419
456
  });
420
- const edge = hint?.overId === item.id ? hint.edge : null;
421
457
 
422
458
  return (
423
459
  <div
@@ -426,11 +462,10 @@ function SortableNode<T>({
426
462
  className={cn("relative min-w-0 max-w-full", isDragging && "rounded-md bg-muted shadow-[inset_0_0_0_1px_var(--nonla-border)]")}
427
463
  style={{
428
464
  transform: verticalShift(transform),
429
- transition,
465
+ transition: sorting ? undefined : transition,
430
466
  zIndex: isDragging ? 1 : undefined,
431
467
  }}
432
468
  >
433
- {edge ? <DropLine edge={edge} /> : null}
434
469
  <div className={cn("min-w-0", isDragging && "invisible")}>
435
470
  <RowFace
436
471
  item={item}
@@ -447,7 +482,7 @@ function SortableNode<T>({
447
482
  />
448
483
  {item.children?.length ? (
449
484
  <div className="min-w-0 ps-4">
450
- <SortableLevel items={item.children} parentId={item.id} depth={depth + 1} renderItem={renderItem} hint={hint} />
485
+ <SortableLevel items={item.children} parentId={item.id} depth={depth + 1} renderItem={renderItem} sorting={sorting} />
451
486
  </div>
452
487
  ) : null}
453
488
  </div>
@@ -460,19 +495,19 @@ function SortableLevel<T>({
460
495
  parentId,
461
496
  depth,
462
497
  renderItem,
463
- hint,
498
+ sorting,
464
499
  }: {
465
500
  items: SortableTreeItem<T>[];
466
501
  parentId: string | null;
467
502
  depth: number;
468
503
  renderItem?: SortableTreeProps<T>["renderItem"];
469
- hint: DropHint | null;
504
+ sorting: boolean;
470
505
  }) {
471
506
  return (
472
507
  <SortableContext items={items.map((item) => item.id)} strategy={verticalListSortingStrategy}>
473
508
  <div className="flex min-w-0 flex-col gap-0.5">
474
509
  {items.map((item) => (
475
- <SortableNode key={item.id} item={item} parentId={parentId} depth={depth} renderItem={renderItem} hint={hint} />
510
+ <SortableNode key={item.id} item={item} parentId={parentId} depth={depth} renderItem={renderItem} sorting={sorting} />
476
511
  ))}
477
512
  </div>
478
513
  </SortableContext>
@@ -486,6 +521,7 @@ export function SortableTree<T = unknown>({ items, onChange, onDragEnd, renderIt
486
521
  const overRef = useRef<string | null>(null);
487
522
  const blockedRef = useRef<Set<string>>(new Set());
488
523
  const rootRef = useRef<HTMLDivElement>(null);
524
+ const pointerRef = useRef<{ x: number; y: number } | null>(null);
489
525
  const onChangeRef = useRef(onChange);
490
526
  const onDragEndRef = useRef(onDragEnd);
491
527
  const itemsRef = useRef(items);
@@ -499,7 +535,12 @@ export function SortableTree<T = unknown>({ items, onChange, onDragEnd, renderIt
499
535
  useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
500
536
  );
501
537
 
502
- const collisionDetection: CollisionDetection = (args) => collideTree(args, itemsRef.current, blockedRef.current, rootRef.current);
538
+ const collisionDetection: CollisionDetection = (args) => {
539
+ if (args.pointerCoordinates) pointerRef.current = args.pointerCoordinates;
540
+ return collideTree(args, itemsRef.current, blockedRef.current, rootRef.current);
541
+ };
542
+
543
+ const cursorY = (event: DragMoveEvent | DragEndEvent) => pointerRef.current?.y ?? pointerY(event);
503
544
 
504
545
  const assignHint = (next: DropHint | null) => {
505
546
  const prev = hintRef.current;
@@ -524,6 +565,8 @@ export function SortableTree<T = unknown>({ items, onChange, onDragEnd, renderIt
524
565
 
525
566
  const onDragStart = (event: DragStartEvent) => {
526
567
  const id = String(event.active.id);
568
+ overlayOrigin = null;
569
+ pointerRef.current = null;
527
570
  setActiveId(id);
528
571
  overRef.current = null;
529
572
  const node = findItem(itemsRef.current, id);
@@ -533,27 +576,28 @@ export function SortableTree<T = unknown>({ items, onChange, onDragEnd, renderIt
533
576
  const onDragOver = (event: DragMoveEvent) => {
534
577
  const id = event.over ? String(event.over.id) : null;
535
578
  overRef.current = id;
536
- showPlace(String(event.active.id), id, pointerY(event));
579
+ showPlace(String(event.active.id), id, cursorY(event));
537
580
  };
538
581
 
539
582
  const onDragMove = (event: DragMoveEvent) => {
540
583
  const id = event.over ? String(event.over.id) : overRef.current;
541
584
  if (!id) return;
542
585
  if (event.over) overRef.current = id;
543
- showPlace(String(event.active.id), id, pointerY(event));
586
+ showPlace(String(event.active.id), id, cursorY(event));
544
587
  };
545
588
 
546
589
  const stopDrag = () => {
547
590
  setActiveId(null);
548
591
  overRef.current = null;
549
592
  blockedRef.current = new Set();
593
+ pointerRef.current = null;
550
594
  assignHint(null);
551
595
  };
552
596
 
553
597
  const handleDragEnd = (event: DragEndEvent) => {
554
598
  const activeDragId = String(event.active.id);
555
599
  const overId = event.over ? String(event.over.id) : overRef.current;
556
- const place = placeFor(activeDragId, overId, pointerY(event));
600
+ const place = placeFor(activeDragId, overId, cursorY(event));
557
601
  stopDrag();
558
602
  if (!place || !overId) return;
559
603
  const current = itemsRef.current;
@@ -575,21 +619,24 @@ export function SortableTree<T = unknown>({ items, onChange, onDragEnd, renderIt
575
619
  return (
576
620
  <div ref={rootRef} className={cn("w-full min-w-0 max-w-full overscroll-x-none", className)} style={{ overflowX: "clip" }}>
577
621
  <DndContext sensors={sensors} collisionDetection={collisionDetection} onDragStart={onDragStart} onDragOver={onDragOver} onDragMove={onDragMove} onDragEnd={handleDragEnd} onDragCancel={onDragCancel}>
578
- <SortableLevel items={items} parentId={null} depth={0} renderItem={renderItem} hint={hint} />
622
+ <SortableLevel items={items} parentId={null} depth={0} renderItem={renderItem} sorting={activeId != null} />
579
623
  {portalNode
580
624
  ? createPortal(
581
- <DragOverlay
582
- zIndex={1050}
583
- dropAnimation={DROP_ANIMATION}
584
- modifiers={[clampOverlayToWindow]}
585
- className="pointer-events-none overflow-hidden rounded-md bg-card shadow-(--nonla-card-shadow)"
586
- >
587
- {activeItem ? (
588
- <div data-sortable-overlay="">
589
- <OverlayBranch item={activeItem} renderItem={renderItem} />
590
- </div>
591
- ) : null}
592
- </DragOverlay>,
625
+ <>
626
+ <DragOverlay
627
+ zIndex={1050}
628
+ dropAnimation={DROP_ANIMATION}
629
+ modifiers={[clampOverlayToWindow]}
630
+ className="pointer-events-none overflow-hidden rounded-md bg-card shadow-(--nonla-card-shadow)"
631
+ >
632
+ {activeItem ? (
633
+ <div data-sortable-overlay="">
634
+ <OverlayBranch item={activeItem} renderItem={renderItem} />
635
+ </div>
636
+ ) : null}
637
+ </DragOverlay>
638
+ {hint ? <FloatingDropLine root={rootRef.current} hint={hint} /> : null}
639
+ </>,
593
640
  portalNode,
594
641
  )
595
642
  : null}
package/src/styles.css CHANGED
@@ -1,4 +1,8 @@
1
1
  @import "highlight.js/styles/github-dark-dimmed.css";
2
+ @import "@fontsource-variable/inter/opsz.css";
3
+ @import "@fontsource-variable/inter/opsz-italic.css";
4
+ @import "@fontsource-variable/geist-mono/wght.css";
5
+ @import "@fontsource-variable/geist-mono/wght-italic.css";
2
6
  @import "./avatar/avatar.css";
3
7
 
4
8
  /**
@@ -19,7 +23,6 @@
19
23
  color-scheme: dark;
20
24
 
21
25
  /* ── Config. Set these. `.nonla-ui.light` repeats the same keys. ───── */
22
- /* Claude dark (claude.com). Warm gray, hue ~60. Page 950, sidebar 900, cards 850, bar 800. */
23
26
  --nonla-bg: #141413;
24
27
  --nonla-text-main: #faf9f5;
25
28
  --nonla-text-secondary: #b0aea5;
@@ -39,15 +42,16 @@
39
42
  --nonla-border-secondary: #242322;
40
43
  --nonla-input: rgb(250 249 245 / 14%);
41
44
 
42
- --nonla-font: ui-sans-serif, -apple-system, system-ui, "Segoe UI Variable Display", "Segoe UI", Helvetica, "Apple Color Emoji", "Noto Sans Arabic", "Noto Sans Hebrew", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
45
+ --nonla-font: "Inter Variable", ui-sans-serif, -apple-system, system-ui, "Segoe UI Variable Display", "Segoe UI", Helvetica, "Apple Color Emoji", "Noto Sans Arabic", "Noto Sans Hebrew", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
46
+ --nonla-mono-font: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
43
47
  /* Default body size. Tailwind `text-base` follows this. Leading is 1.6. */
44
48
  --nonla-base-text-size: 15px;
45
- /* `text-md`. MarkdownViewer body and agent reply text use this. */
49
+ /* `text-md`. MarkdownViewer body uses this. Agent replies use `text-base`. */
46
50
  --nonla-md-text-size: 16px;
47
51
  /* `text-sm`. Composer, tool lines, and errors use this. User bubbles use `text-base`. */
48
52
  --nonla-sm-text-size: 14px;
49
- /* Code. A step under the body, so mono does not look larger than the text around it. */
50
- --nonla-mono-text-size: calc(var(--nonla-base-text-size) * 0.9);
53
+ /* Code. One pixel under the body, so mono does not look larger than the text around it. */
54
+ --nonla-mono-text-size: calc(var(--nonla-base-text-size));
51
55
  --nonla-radius: 8px;
52
56
  --nonla-height: 32px;
53
57
  --nonla-height-sm: 24px;
@@ -226,7 +230,7 @@
226
230
 
227
231
  --font-sans: var(--nonla-font);
228
232
  --font-family-sans: var(--font-sans);
229
- --font-mono: Menlo, Monaco, "Courier New", monospace;
233
+ --font-mono: var(--nonla-mono-font);
230
234
  --font-family-mono: var(--font-mono);
231
235
 
232
236
  --animate-fadeIn: fadeIn 0.28s ease-out both;
@@ -525,6 +529,10 @@
525
529
  }
526
530
  }
527
531
 
532
+ .nonla-ui :is(pre, code, kbd, samp) {
533
+ font-family: var(--nonla-mono-font);
534
+ }
535
+
528
536
  .nonla-codeblock-pre code,
529
537
  .nonla-codeblock-pre .hljs {
530
538
  color: var(--foreground);