devnonla-ui 0.7.0 → 0.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devnonla-ui",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "NonlaUI — React controls for Nonla Agents",
6
6
  "author": "devlangla <devlangla0x01@gmail.com>",
@@ -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
@@ -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-foreground/4 [&_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"
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>
@@ -48,7 +48,7 @@ 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-sm font-medium flex items-center gap-1 py-0.5 list-none [&::-webkit-details-marker]:hidden">
51
+ <summary className="cursor-pointer select-none text-base font-medium 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
  <ChevronRight className="size-3 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" aria-hidden />
54
54
  </summary>
@@ -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-border bg-[color-mix(in_oklab,var(--nonla-ink)_7%,transparent)] backdrop-blur-xl",
33
+ "border border-solid border-brand-200 bg-brand-100",
34
34
  className,
35
35
  )}
36
36
  >
@@ -1,5 +1,6 @@
1
- import { Download, Maximize2, Minimize2, Moon, Sun } from "lucide-react";
1
+ import { Download, Maximize2, Minimize2 } from "lucide-react";
2
2
  import { useCallback, useEffect, useId, useRef, useState } from "react";
3
+ import { Button } from "../../button/Button";
3
4
  import { CodeBlock } from "../../codeblock/CodeBlock";
4
5
  import { cn } from "../../lib/cn";
5
6
  import { sanitizeMermaid } from "./sanitizeMermaid";
@@ -9,10 +10,6 @@ export type MermaidBlockProps = {
9
10
  className?: string;
10
11
  };
11
12
 
12
- type MermaidTheme = "light" | "dark";
13
-
14
- const btnClass = "flex items-center gap-1 px-2 py-1 rounded-lg border border-border text-muted-foreground text-xs cursor-pointer transition-colors hover:text-primary hover:border-primary/30 bg-transparent";
15
-
16
13
  export function MermaidBlock({ children, className }: MermaidBlockProps) {
17
14
  const id = useId().replace(/:/g, "_");
18
15
  const containerRef = useRef<HTMLDivElement>(null);
@@ -20,15 +17,11 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
20
17
  const fullscreenRef = useRef<HTMLDivElement>(null);
21
18
  const [error, setError] = useState<string | null>(null);
22
19
  const [svgContent, setSvgContent] = useState("");
23
- const [theme, setTheme] = useState<MermaidTheme>("light");
24
20
  const [zoom, setZoom] = useState(1);
25
21
  const [pan, setPan] = useState({ x: 0, y: 0 });
26
22
  const dragRef = useRef({ active: false, startX: 0, startY: 0, panX: 0, panY: 0 });
27
23
  const [isDragging, setIsDragging] = useState(false);
28
24
 
29
- const isDark = theme === "dark";
30
- const surfaceClass = isDark ? "bg-[#1e1e1e]" : "bg-card";
31
-
32
25
  useEffect(() => {
33
26
  let cancelled = false;
34
27
 
@@ -36,11 +29,11 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
36
29
  const { default: mermaid } = await import("mermaid");
37
30
  mermaid.initialize({
38
31
  startOnLoad: false,
39
- theme: isDark ? "dark" : "default",
32
+ theme: "default",
40
33
  });
41
34
 
42
35
  const raw = children.trim();
43
- const renderId = `mermaid-${id}-${theme}`;
36
+ const renderId = `mermaid-${id}`;
44
37
 
45
38
  try {
46
39
  document.getElementById(`d${renderId}`)?.remove();
@@ -73,7 +66,7 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
73
66
  return () => {
74
67
  cancelled = true;
75
68
  };
76
- }, [children, id, theme, isDark]);
69
+ }, [children, id]);
77
70
 
78
71
  useEffect(() => {
79
72
  if (containerRef.current && svgContent) containerRef.current.innerHTML = svgContent;
@@ -90,8 +83,6 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
90
83
  setPan({ x: 0, y: 0 });
91
84
  }, []);
92
85
 
93
- const toggleTheme = () => setTheme((prev) => (prev === "light" ? "dark" : "light"));
94
-
95
86
  const downloadSvg = () => {
96
87
  if (!svgContent) return;
97
88
  const blob = new Blob([svgContent], { type: "image/svg+xml;charset=utf-8" });
@@ -173,47 +164,33 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
173
164
 
174
165
  return (
175
166
  <>
176
- <div className={cn("my-3 last:mb-0 group relative rounded-xl border border-border overflow-hidden", surfaceClass, className)}>
167
+ <div className={cn("my-3 last:mb-0 group relative rounded-xl border border-border overflow-hidden bg-card", className)}>
177
168
  <div className="absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
178
- <button type="button" onClick={toggleTheme} className={cn(btnClass, surfaceClass)} title={isDark ? "Light theme" : "Dark theme"}>
179
- {isDark ? <Sun size={14} aria-hidden /> : <Moon size={14} aria-hidden />}
180
- </button>
181
- <button type="button" onClick={downloadSvg} className={cn(btnClass, surfaceClass)} title="Download SVG" disabled={!svgContent}>
182
- <Download size={14} aria-hidden />
183
- </button>
184
- <button type="button" onClick={openFullscreen} className={cn(btnClass, surfaceClass)} title="Fullscreen">
185
- <Maximize2 size={14} aria-hidden />
186
- </button>
169
+ <Button size="small" icon={<Maximize2 aria-hidden />} title="Fullscreen" aria-label="Fullscreen" onClick={openFullscreen} />
187
170
  </div>
188
171
  <div ref={containerRef} className="flex justify-center p-6 overflow-x-auto [&_svg]:max-w-full" />
189
172
  </div>
190
173
 
191
174
  <dialog
192
175
  ref={dialogRef}
193
- className={cn("m-0 p-0 w-screen h-screen max-w-none max-h-none backdrop:bg-black/40 open:flex open:flex-col", surfaceClass)}
176
+ className="m-0 p-0 w-screen h-screen max-w-none max-h-none backdrop:bg-black/40 open:flex open:flex-col bg-card"
194
177
  onKeyDown={(e) => {
195
178
  if (e.key === "Escape") closeFullscreen();
196
179
  }}
197
180
  >
198
181
  <div className="fixed top-5 right-5 z-50 flex items-center gap-1.5">
199
- <button type="button" onClick={toggleTheme} className={cn(btnClass, surfaceClass, "px-3 py-2 text-sm shadow-md")} title={isDark ? "Light theme" : "Dark theme"}>
200
- {isDark ? <Sun size={16} aria-hidden /> : <Moon size={16} aria-hidden />}
201
- </button>
202
- <button type="button" onClick={downloadSvg} className={cn(btnClass, surfaceClass, "px-3 py-2 text-sm shadow-md")} title="Download SVG" disabled={!svgContent}>
203
- <Download size={16} aria-hidden />
204
- </button>
205
- <button type="button" onClick={closeFullscreen} className={cn(btnClass, surfaceClass, "px-3 py-2 text-sm shadow-md")} title="Exit fullscreen">
206
- <Minimize2 size={16} aria-hidden />
207
- <span>Exit</span>
208
- </button>
182
+ <Button size="small" icon={<Download aria-hidden />} title="Download SVG" aria-label="Download SVG" onClick={downloadSvg} disabled={!svgContent} />
183
+ <Button size="small" icon={<Minimize2 aria-hidden />} title="Exit fullscreen" onClick={closeFullscreen}>
184
+ Exit
185
+ </Button>
209
186
  </div>
210
187
 
211
- <div className={cn("fixed bottom-5 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 px-3 py-1.5 rounded-full border border-border text-xs text-muted-foreground shadow-md select-none", surfaceClass)}>
188
+ <div className="fixed bottom-5 left-1/2 -translate-x-1/2 z-50 flex items-center gap-2 px-3 py-1.5 rounded-full border border-border text-xs text-muted-foreground shadow-md select-none bg-card">
212
189
  <span>{Math.round(zoom * 100)}%</span>
213
190
  {!isDefaultView ? (
214
- <button type="button" onClick={resetView} className="text-muted-foreground hover:text-primary cursor-pointer transition-colors border-0 bg-transparent p-0 font-[inherit]">
191
+ <Button type="text" size="small" onClick={resetView}>
215
192
  Reset
216
- </button>
193
+ </Button>
217
194
  ) : null}
218
195
  </div>
219
196
 
@@ -1,4 +1,3 @@
1
- import { FileText } from "lucide-react";
2
1
  import { type ComponentProps, createContext, type ReactNode, useContext, useMemo } from "react";
3
2
  import { ButtonCopy } from "../button/ButtonCopy";
4
3
  import { cn } from "../lib/cn";
@@ -46,21 +45,16 @@ export function CodeBlock({ code, language, title, lineNumbers = false, wordWrap
46
45
  return (
47
46
  <CodeBlockContext.Provider value={{ code }}>
48
47
  <div className={cn("nonla-codeblock relative flex min-w-0 w-full flex-col overflow-clip rounded-lg border border-border bg-glass-bar text-sm text-foreground backdrop-blur-lg", className)} data-language={language} {...props}>
49
- <div className="flex h-9 items-center justify-between gap-2 pl-2 pr-1 text-sm text-muted-foreground">
48
+ <div className="flex h-8 items-center justify-between gap-2 pl-3 pr-1 text-xs text-muted-foreground">
50
49
  <div className="flex min-w-0 items-center gap-2">
51
- {label ? (
52
- <>
53
- <FileText size={14} className="shrink-0" aria-hidden />
54
- <span className="truncate font-medium">{label}</span>
55
- </>
56
- ) : null}
50
+ {label ? <span className="truncate font-medium">{label}</span> : null}
57
51
  </div>
58
52
  <CodeBlockCopyButton />
59
53
  </div>
60
54
 
61
55
  <OverlayScroll
62
56
  autoHeight
63
- className={cn("nonla-codeblock-body nonla-codeblock-well min-w-0 bg-card font-mono text-[13px] leading-5 max-h-96", !children && "mx-0.5 mb-0.5 rounded-lg")}
57
+ className={cn("nonla-codeblock-body nonla-codeblock-well min-w-0 bg-card font-mono text-[13px] leading-5 max-h-96", !children && "mx-0.5 mb-0.5 w-[calc(100%-4px)] rounded-lg")}
64
58
  innerClassName={wordWrap ? undefined : "overflow-x-auto"}
65
59
  >
66
60
  <pre className={cn("nonla-codeblock-pre m-0 whitespace-pre break-normal", lineNumbers && "nonla-codeblock-lines", wordWrap && "whitespace-pre-wrap wrap-break-word")}>
@@ -203,10 +203,10 @@ function EditorPopover({
203
203
  {field}
204
204
  </div>
205
205
  <div className="mt-3 flex items-center gap-2">
206
- <Button type="primary" size={size} loading={saving} disabled={saveDisabled} onClick={onSave}>
206
+ <Button type="primary" size="small" loading={saving} disabled={saveDisabled} onClick={onSave}>
207
207
  Save
208
208
  </Button>
209
- <Button type="text" size={size} disabled={saving} onClick={onCancel}>
209
+ <Button type="text" size="small" disabled={saving} onClick={onCancel}>
210
210
  Cancel
211
211
  </Button>
212
212
  </div>
@@ -1,4 +1,4 @@
1
- import { type ReactNode, type PointerEvent as ReactPointerEvent, type Ref, type UIEventHandler, useCallback, useLayoutEffect, useRef, useState } from "react";
1
+ import { type CSSProperties, type ReactNode, type PointerEvent as ReactPointerEvent, type Ref, type UIEventHandler, useCallback, useLayoutEffect, useRef, useState } from "react";
2
2
  import { cn } from "../lib/cn";
3
3
 
4
4
  export type OverlayScrollVisibility = "hover" | "always";
@@ -12,10 +12,13 @@ export type OverlayScrollProps = {
12
12
  /** Size to content (honors max-height on `className`) instead of filling the parent. */
13
13
  autoHeight?: boolean;
14
14
  className?: string;
15
+ style?: CSSProperties;
15
16
  innerClassName?: string;
16
17
  children?: ReactNode;
17
18
  onScroll?: UIEventHandler<HTMLDivElement>;
18
19
  scrollRef?: Ref<HTMLDivElement>;
20
+ /** Keep the vertical thumb below this many pixels (sticky table header). */
21
+ insetTop?: number;
19
22
  };
20
23
 
21
24
  type Thumb = { offset: number; size: number; shown: boolean };
@@ -29,11 +32,12 @@ function assignRef(ref: Ref<HTMLDivElement> | undefined, node: HTMLDivElement |
29
32
  else ref.current = node;
30
33
  }
31
34
 
32
- function measure(scroll: number, scrollSize: number, client: number): Thumb {
35
+ function measure(scroll: number, scrollSize: number, client: number, inset = 0): Thumb {
36
+ const track = Math.max(0, client - inset);
33
37
  const overflow = scrollSize - client;
34
- if (overflow <= 1) return HIDDEN;
35
- const size = Math.max(MIN_THUMB, (client / scrollSize) * client);
36
- const offset = (scroll / overflow) * (client - size);
38
+ if (overflow <= 1 || track <= 1) return HIDDEN;
39
+ const size = Math.min(track, Math.max(MIN_THUMB, (track / scrollSize) * track));
40
+ const offset = (scroll / overflow) * Math.max(0, track - size);
37
41
  return { offset, size, shown: true };
38
42
  }
39
43
 
@@ -42,7 +46,7 @@ function canScrollX(el: HTMLDivElement) {
42
46
  return overflow === "auto" || overflow === "scroll";
43
47
  }
44
48
 
45
- export function OverlayScroll({ visibility = "hover", autoHeight = false, className, innerClassName, children, onScroll, scrollRef }: OverlayScrollProps) {
49
+ export function OverlayScroll({ visibility = "hover", autoHeight = false, className, style, innerClassName, children, onScroll, scrollRef, insetTop = 0 }: OverlayScrollProps) {
46
50
  const elRef = useRef<HTMLDivElement | null>(null);
47
51
  const hideTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
48
52
  const vThumbRef = useRef<Thumb>(HIDDEN);
@@ -54,10 +58,13 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
54
58
  vThumbRef.current = vThumb;
55
59
  hThumbRef.current = hThumb;
56
60
 
61
+ const insetTopRef = useRef(insetTop);
62
+ insetTopRef.current = insetTop;
63
+
57
64
  const updateThumb = useCallback(() => {
58
65
  const el = elRef.current;
59
66
  if (!el) return;
60
- setVThumb(measure(el.scrollTop, el.scrollHeight, el.clientHeight));
67
+ setVThumb(measure(el.scrollTop, el.scrollHeight, el.clientHeight, insetTopRef.current));
61
68
  setHThumb(canScrollX(el) ? measure(el.scrollLeft, el.scrollWidth, el.clientWidth) : HIDDEN);
62
69
  }, []);
63
70
 
@@ -79,7 +86,7 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
79
86
  const child = el.firstElementChild;
80
87
  if (child) ro.observe(child);
81
88
  return () => ro.disconnect();
82
- }, [updateThumb, innerClassName, autoHeight]);
89
+ }, [updateThumb, innerClassName, autoHeight, insetTop]);
83
90
 
84
91
  useLayoutEffect(() => {
85
92
  return () => {
@@ -104,8 +111,9 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
104
111
  e.preventDefault();
105
112
  e.stopPropagation();
106
113
 
114
+ const inset = axis === "y" ? insetTopRef.current : 0;
107
115
  const overflow = axis === "y" ? el.scrollHeight - el.clientHeight : el.scrollWidth - el.clientWidth;
108
- const track = (axis === "y" ? el.clientHeight : el.clientWidth) - current.size;
116
+ const track = (axis === "y" ? el.clientHeight - inset : el.clientWidth) - current.size;
109
117
  if (overflow <= 0 || track <= 0) return;
110
118
 
111
119
  const start = axis === "y" ? e.clientY : e.clientX;
@@ -145,7 +153,7 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
145
153
  );
146
154
 
147
155
  return (
148
- <div className={cn("group/scroll relative min-h-0 min-w-0 w-full overflow-hidden", className)} data-scrolling={thumbVisible ? "true" : undefined}>
156
+ <div className={cn("group/scroll relative min-h-0 min-w-0 w-full overflow-hidden", className)} style={style} data-scrolling={thumbVisible ? "true" : undefined}>
149
157
  <div
150
158
  ref={setNode}
151
159
  onScroll={handleScroll}
@@ -154,10 +162,10 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
154
162
  {children}
155
163
  </div>
156
164
  {vThumb.shown ? (
157
- <div aria-hidden onPointerDown={onThumbPointerDown("y")} className={thumbClass} style={{ right: 2, width: "var(--nonla-scrollbar-size)", height: vThumb.size, transform: `translateY(${vThumb.offset}px)` }} />
165
+ <div aria-hidden onPointerDown={onThumbPointerDown("y")} className={thumbClass} style={{ top: insetTop, right: 1, width: "var(--nonla-scrollbar-size)", height: vThumb.size, transform: `translateY(${vThumb.offset}px)` }} />
158
166
  ) : null}
159
167
  {hThumb.shown ? (
160
- <div aria-hidden onPointerDown={onThumbPointerDown("x")} className={thumbClass} style={{ bottom: 2, height: "var(--nonla-scrollbar-size)", width: hThumb.size, transform: `translateX(${hThumb.offset}px)` }} />
168
+ <div aria-hidden onPointerDown={onThumbPointerDown("x")} className={thumbClass} style={{ left: 0, bottom: 1, height: "var(--nonla-scrollbar-size)", width: hThumb.size, transform: `translateX(${hThumb.offset}px)` }} />
161
169
  ) : null}
162
170
  </div>
163
171
  );
package/src/styles.css CHANGED
@@ -18,18 +18,19 @@
18
18
  color-scheme: light;
19
19
 
20
20
  /* ── Knobs / Seed (override these) ──────────────────────────────────── */
21
- --nonla-bg: #fffcf1;
22
- --nonla-fg: #1f1f1e;
23
- /* Text rank on cream — same ink, contrast steps ~13.6 / 7 / 4.5 / 3 (WCAG AAA body → AA body → AA UI). */
24
- --nonla-fg-muted: color-mix(in oklab, var(--nonla-fg) 78%, var(--nonla-bg));
25
- --nonla-fg-tertiary: color-mix(in oklab, var(--nonla-fg) 64%, var(--nonla-bg));
26
- --nonla-fg-quaternary: color-mix(in oklab, var(--nonla-fg) 50%, var(--nonla-bg));
21
+ /* Neutrals measured from Discord light (Vietnix DEV #website). */
22
+ --nonla-bg: #f3f3f4;
23
+ --nonla-fg: #2e2e34;
24
+ /* Text rank: default / subtle / muted / placeholder. */
25
+ --nonla-fg-muted: #595a63;
26
+ --nonla-fg-tertiary: #6c6d76;
27
+ --nonla-fg-quaternary: #84858d;
27
28
  --nonla-brand: #f18d00;
28
29
  /* Label on brand fills (Button primary, Tag solid, Checkbox). Override via `colors.solidFg`. */
29
30
  --nonla-solid-fg: #ffffff;
30
- --nonla-danger: #c0392b;
31
+ --nonla-danger: #ef4444;
31
32
  --nonla-success: #1f9d55;
32
- --nonla-warn: #c47d12;
33
+ --nonla-warn: #f59e0b;
33
34
  --nonla-link: var(--nonla-brand);
34
35
  --nonla-radius: 8px;
35
36
  --nonla-height: 32px;
@@ -39,12 +40,14 @@
39
40
  --nonla-ink: var(--nonla-fg);
40
41
  --nonla-surface: #ffffff;
41
42
  --nonla-elevated: var(--nonla-surface);
42
- --nonla-chip: color-mix(in oklab, var(--nonla-fg) 5%, var(--nonla-bg));
43
- --nonla-chip-hover: color-mix(in oklab, var(--nonla-fg) 9%, var(--nonla-bg));
44
- --nonla-border: color-mix(in oklab, var(--nonla-fg) 7%, var(--nonla-bg));
45
- --nonla-input: color-mix(in oklab, var(--nonla-fg) 12%, var(--nonla-bg));
43
+ --nonla-chip: #e6e6e8;
44
+ --nonla-chip-hover: #ebeced;
45
+ --nonla-border: #e2e2e4;
46
+ --nonla-input: #d5d5d9;
46
47
  --nonla-composer: var(--nonla-surface);
47
- --nonla-chat-bg: #fcfcfc;
48
+ --nonla-chat-bg: #fbfbfb;
49
+ /* Opaque header fill. Alpha `fg/4` picks up whatever sits behind the glass. */
50
+ --nonla-table-head: color-mix(in srgb, var(--nonla-fg) 4%, var(--nonla-bg));
48
51
 
49
52
  /* Neutral frost — blur shows whatever sits behind, no page-tint */
50
53
  --nonla-meadow: #4f7a32;
@@ -53,9 +56,10 @@
53
56
  --nonla-glass-menu: color-mix(in srgb, white 48%, transparent);
54
57
  --nonla-glass-border: color-mix(in srgb, white 62%, transparent);
55
58
  --nonla-glass-highlight: color-mix(in srgb, white 70%, transparent);
56
- --nonla-ink-hover: color-mix(in srgb, var(--nonla-ink) 6%, transparent);
57
- --nonla-ink-active: color-mix(in srgb, var(--nonla-ink) 8%, transparent);
58
- --nonla-ink-line: color-mix(in srgb, var(--nonla-ink) 14%, transparent);
59
+ /* Discord interactive wash: hsl(240 4% 60.784%) at hover / active alpha. */
60
+ --nonla-ink-hover: hsl(240 4% 60.784% / 0.122);
61
+ --nonla-ink-active: hsl(240 4% 60.784% / 0.161);
62
+ --nonla-ink-line: #e2e2e4;
59
63
  --nonla-desktop-bar-height: 42px;
60
64
  --nonla-z-base: 0;
61
65
  --nonla-z-desktop: 20;
@@ -150,8 +154,8 @@
150
154
  --nonla-dur-slow: 300ms;
151
155
 
152
156
  /* Chat type — one scale for full-page chat and side panels */
153
- --chat-body-size: 15px;
154
- --chat-body-leading: 24px;
157
+ --chat-body-size: 14px;
158
+ --chat-body-leading: 20px;
155
159
  --chat-h1-size: 16px;
156
160
  --chat-h2-size: 16px;
157
161
  --chat-h3-size: 14px;
@@ -626,8 +630,15 @@
626
630
  backdrop-filter: blur(24px) saturate(160%);
627
631
  }
628
632
 
633
+ /* Composer sits on light glass; the white hairline disappears. Use the input stroke. */
634
+ .nonla-chat-input {
635
+ border-color: var(--nonla-input);
636
+ }
637
+
629
638
  /* Desktop window — cream wash + less saturate so meadow doesn't tint the panel. */
630
639
  .nonla-window-glass {
640
+ border: 0;
641
+ box-shadow: inset 0 0 0 1px var(--glass-border), 0 10px 28px color-mix(in srgb, black 12%, transparent);
631
642
  background: color-mix(in srgb, var(--nonla-bg) 81%, transparent);
632
643
  -webkit-backdrop-filter: blur(40px) saturate(108%);
633
644
  backdrop-filter: blur(40px) saturate(108%);
@@ -1,9 +1,10 @@
1
- import { type CSSProperties, type Key, type ReactNode, useLayoutEffect, useMemo, useRef, useState } from "react";
1
+ import { type CSSProperties, type Key, type ReactNode, type Ref, useLayoutEffect, useMemo, useRef, useState } from "react";
2
2
  import { Checkbox } from "../checkbox/Checkbox";
3
3
  import { Empty } from "../empty/Empty";
4
4
  import { cn } from "../lib/cn";
5
5
  import { type CanonicalSize, type ControlSize, useControlSize } from "../lib/sizes";
6
6
  import { Pagination, type PaginationProps } from "../pagination/Pagination";
7
+ import { OverlayScroll } from "../scroll/OverlayScroll";
7
8
  import { Spin } from "../spin/Spin";
8
9
 
9
10
  export type SortOrder = "ascend" | "descend" | null;
@@ -164,6 +165,15 @@ function layoutsClose(prev: FlexLayout | null, next: FlexLayout): boolean {
164
165
  return keys.every((key) => Math.abs((prev.cols[key] ?? -1) - next.cols[key]) <= 0.5);
165
166
  }
166
167
 
168
+ function TableBodyScroll({ x, y, scrollRef, insetTop = 0, children }: { x?: number | string; y?: number | string; scrollRef: Ref<HTMLDivElement>; insetTop?: number; children: ReactNode }) {
169
+ if (y == null) return <div ref={scrollRef}>{children}</div>;
170
+ return (
171
+ <OverlayScroll autoHeight visibility="hover" scrollRef={scrollRef} insetTop={insetTop} style={{ maxHeight: y }} innerClassName={x != null ? "overflow-x-auto" : undefined}>
172
+ {children}
173
+ </OverlayScroll>
174
+ );
175
+ }
176
+
167
177
  function sizeClasses(s: CanonicalSize) {
168
178
  if (s === "small") {
169
179
  return {
@@ -287,10 +297,11 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
287
297
  const alignClass = (align?: "left" | "center" | "right") => (align === "center" ? "text-center" : align === "right" ? "text-right" : "text-left");
288
298
 
289
299
  const containerRef = useRef<HTMLDivElement>(null);
300
+ const scrollBodyRef = useRef<HTMLDivElement>(null);
290
301
  const columnsRef = useRef(columns);
291
302
  columnsRef.current = columns;
292
303
  const [flexLayout, setFlexLayout] = useState<FlexLayout | null>(null);
293
- const flexSig = `${scroll?.x ?? ""}|${rowSelection ? 1 : 0}|${showHeader ? 1 : 0}|${dataSource.length}|${columns.map((col, i) => `${getColumnKey(col, i)}:${col.flex ?? ""}:${col.width ?? ""}`).join(",")}`;
304
+ const flexSig = `${scroll?.x ?? ""}|${scroll?.y ?? ""}|${rowSelection ? 1 : 0}|${showHeader ? 1 : 0}|${dataSource.length}|${columns.map((col, i) => `${getColumnKey(col, i)}:${col.flex ?? ""}:${col.width ?? ""}`).join(",")}`;
294
305
  const flexSigRef = useRef(flexSig);
295
306
  if (flexSigRef.current !== flexSig) {
296
307
  flexSigRef.current = flexSig;
@@ -309,7 +320,9 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
309
320
  let locked: { selection?: number; fixed: Record<string, number>; weights: { key: string; weight: number }[] } | null = null;
310
321
 
311
322
  const apply = () => {
312
- const client = container.clientWidth;
323
+ const scroller = scrollBodyRef.current;
324
+ const scrollbar = scroller && scroller.scrollHeight > scroller.clientHeight + 1 ? scroller.offsetWidth - scroller.clientWidth : 0;
325
+ const client = container.clientWidth - Math.max(0, scrollbar);
313
326
  if (client <= 0) return;
314
327
  if (!locked) {
315
328
  const table = container.querySelector("table");
@@ -348,11 +361,26 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
348
361
  apply();
349
362
  const observer = new ResizeObserver(apply);
350
363
  observer.observe(container);
364
+ if (scrollBodyRef.current) observer.observe(scrollBodyRef.current);
351
365
  return () => observer.disconnect();
352
- }, [flexSig, rowSelection, scroll?.x, showHeader]);
366
+ }, [flexSig, rowSelection, scroll?.x, scroll?.y, showHeader]);
353
367
 
354
368
  const wantsFlex = scroll?.x == null && columns.some((col) => flexWeight(col) > 0);
355
369
 
370
+ const headSticky = scroll?.y != null;
371
+ const [thumbInset, setThumbInset] = useState(0);
372
+ useLayoutEffect(() => {
373
+ if (!headSticky || !showHeader) {
374
+ setThumbInset(0);
375
+ return;
376
+ }
377
+ const head = scrollBodyRef.current?.querySelector("thead");
378
+ const next = head ? Math.ceil(head.getBoundingClientRect().height) + 4 : 0;
379
+ setThumbInset((prev) => (prev === next ? prev : next));
380
+ }, [headSticky, showHeader, size, flexLayout]);
381
+ /** Opaque fill so a sticky header does not show body text, and every header matches. */
382
+ const headBg: CSSProperties = { backgroundColor: "var(--nonla-table-head)" };
383
+
356
384
  const colStyle = (col: ColumnType<T>, key: string): CSSProperties => {
357
385
  const measured = flexLayout?.cols[key];
358
386
  if (measured != null) return { width: measured, maxWidth: measured, minWidth: 0 };
@@ -365,8 +393,8 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
365
393
 
366
394
  <Spin spinning={Boolean(loading)}>
367
395
  <div ref={containerRef} data-slot="table-container" className={cn("relative w-full", flexLayout ? "overflow-x-hidden" : "overflow-x-auto", bordered && "rounded-md border border-border")} style={scroll?.x != null ? { overflowX: "auto" } : undefined}>
368
- <div style={scroll?.y != null ? { maxHeight: scroll.y, overflow: "auto" } : undefined}>
369
- <table data-slot="table" className={cn("caption-bottom border-collapse text-base", flexLayout ? "w-full table-fixed" : wantsFlex ? "w-max" : "w-full")}>
396
+ <TableBodyScroll y={scroll?.y} x={scroll?.x} scrollRef={scrollBodyRef} insetTop={thumbInset}>
397
+ <table data-slot="table" className={cn("caption-bottom text-base", headSticky ? "border-separate border-spacing-0" : "border-collapse", flexLayout ? "w-full table-fixed" : wantsFlex ? "w-max" : "w-full")}>
370
398
  {flexLayout ? (
371
399
  <colgroup>
372
400
  {rowSelection ? <col style={{ width: flexLayout.selection }} /> : null}
@@ -377,10 +405,10 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
377
405
  </colgroup>
378
406
  ) : null}
379
407
  {showHeader ? (
380
- <thead data-slot="table-header" className="[&_tr]:border-b [&_tr]:border-border">
408
+ <thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-border", headSticky && "relative z-20")}>
381
409
  <tr data-slot="table-row" className="border-b border-border transition-colors hover:bg-transparent">
382
410
  {rowSelection ? (
383
- <th data-slot="table-head" className={cn(sz.head, sz.check, "align-middle font-medium text-foreground bg-foreground/4", scroll?.y && "sticky top-0 z-10", bordered && "border-b border-border")} style={selectionColWidth != null ? { width: selectionColWidth } : undefined}>
411
+ <th data-slot="table-head" className={cn(sz.head, sz.check, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border", bordered && "border-b border-border")} style={{ ...(selectionColWidth != null ? { width: selectionColWidth } : undefined), ...headBg }}>
384
412
  <div className="flex items-center justify-center">
385
413
  {rowSelection.type === "radio" ? null : (
386
414
  <Checkbox
@@ -405,9 +433,10 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
405
433
  <th
406
434
  key={key}
407
435
  data-slot="table-head"
408
- className={cn(sz.head, "align-middle font-medium text-foreground bg-foreground/4", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), scroll?.y && "sticky top-0 z-10", bordered && "border-b border-border", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
436
+ className={cn(sz.head, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), bordered && "border-b border-border", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
409
437
  style={{
410
438
  ...colStyle(col, key),
439
+ ...headBg,
411
440
  ...headerExtra?.style,
412
441
  }}
413
442
  onClick={sortable ? () => toggleSort(col, i) : undefined}
@@ -423,7 +452,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
423
452
  </thead>
424
453
  ) : null}
425
454
 
426
- <tbody data-slot="table-body" className="[&_tr:last-child]:border-0">
455
+ <tbody data-slot="table-body" className={cn("[&_tr:last-child]:border-0", headSticky && "relative z-0")}>
427
456
  {pageData.length === 0 ? (
428
457
  <tr data-slot="table-row" className="border-b border-border">
429
458
  <td data-slot="table-cell" colSpan={colCount} className={cn(sz.cell, "text-center align-middle")}>
@@ -461,7 +490,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
461
490
  }
462
491
  >
463
492
  {rowSelection ? (
464
- <td data-row-select data-slot="table-cell" className={cn(sz.cell, sz.check, "align-middle")} style={selectionColWidth != null ? { width: selectionColWidth } : undefined} onClick={(e) => e.stopPropagation()}>
493
+ <td data-row-select data-slot="table-cell" className={cn(sz.cell, sz.check, "align-middle", headSticky && "border-b border-border")} style={selectionColWidth != null ? { width: selectionColWidth } : undefined} onClick={(e) => e.stopPropagation()}>
465
494
  <div className="flex items-center justify-center">
466
495
  {rowSelection.type === "radio" ? (
467
496
  <input type="radio" name="nonla-table-row-select" checked={selected} disabled={rowSelection.getCheckboxProps?.(record)?.disabled} aria-label="Select row" className="size-3.5 accent-foreground" onChange={() => emitSelection([key])} />
@@ -486,7 +515,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
486
515
  <td
487
516
  key={getColumnKey(col, i)}
488
517
  data-slot="table-cell"
489
- className={cn(sz.cell, "align-middle", alignClass(col.align), flexLayout && flexWeight(col) > 0 ? (col.ellipsis ? "max-w-0 truncate" : "min-w-0 whitespace-normal wrap-break-word") : col.ellipsis ? "max-w-0 truncate" : "whitespace-nowrap", col.className)}
518
+ className={cn(sz.cell, "align-middle", headSticky && "border-b border-border", alignClass(col.align), flexLayout && flexWeight(col) > 0 ? (col.ellipsis ? "max-w-0 truncate" : "min-w-0 whitespace-normal wrap-break-word") : col.ellipsis ? "max-w-0 truncate" : "whitespace-nowrap", col.className)}
490
519
  style={colStyle(col, getColumnKey(col, i))}
491
520
  title={col.ellipsis && (typeof content === "string" || typeof content === "number") ? String(content) : undefined}
492
521
  >
@@ -510,7 +539,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
510
539
  </tfoot>
511
540
  ) : null}
512
541
  </table>
513
- </div>
542
+ </TableBodyScroll>
514
543
  </div>
515
544
  </Spin>
516
545