devnonla-ui 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/package.json +2 -2
  2. package/src/app/App.tsx +2 -2
  3. package/src/app/context.ts +1 -12
  4. package/src/avatar/avatar.css +107 -0
  5. package/src/blob-shape/BlobShape.tsx +337 -0
  6. package/src/button/Button.tsx +4 -4
  7. package/src/button/ButtonCopy.tsx +3 -3
  8. package/src/calendar/Calendar.tsx +1 -1
  9. package/src/card/Card.tsx +1 -1
  10. package/src/chat/AgentChatbox.tsx +1 -1
  11. package/src/chat/AgentPanel.tsx +1 -1
  12. package/src/chat/chatMessageList.tsx +5 -3
  13. package/src/chat/chatRhythm.ts +8 -0
  14. package/src/chat/common/createAgentSseSession.ts +9 -3
  15. package/src/chat/common/sse.ts +290 -122
  16. package/src/chat/common/useAgentStream.ts +1 -1
  17. package/src/chat/index.ts +2 -2
  18. package/src/chat/message-ui/ChatAgentMessage.tsx +4 -3
  19. package/src/chat/message-ui/ChatError.tsx +5 -4
  20. package/src/chat/message-ui/ChatInput.tsx +9 -8
  21. package/src/chat/message-ui/ChatMarkdown.tsx +36 -2
  22. package/src/chat/message-ui/ChatThinking.tsx +8 -7
  23. package/src/chat/message-ui/ChatUserMessage.tsx +5 -5
  24. package/src/chat/tool-ui/BackgroundTaskToolUI.tsx +7 -6
  25. package/src/chat/tool-ui/BackgroundTasksBar.tsx +9 -9
  26. package/src/chat/tool-ui/CallAgentToolUI.tsx +16 -15
  27. package/src/chat/tool-ui/ChatToolCall.tsx +13 -12
  28. package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +7 -6
  29. package/src/chat/tool-ui/ReadSkillToolUI.tsx +10 -9
  30. package/src/chat/tool-ui/RunJsToolUI.tsx +9 -8
  31. package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
  32. package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
  33. package/src/chat/tool-ui/WebFetchToolUI.tsx +10 -9
  34. package/src/checkbox/Checkbox.tsx +2 -2
  35. package/src/codeblock/CodeBlock.tsx +1 -1
  36. package/src/colorpicker/ColorPicker.tsx +10 -8
  37. package/src/datepicker/DatePicker.tsx +3 -3
  38. package/src/desktop/DesktopHeader.tsx +2 -2
  39. package/src/desktop/DesktopIcon.tsx +3 -4
  40. package/src/desktop/DesktopStage.tsx +1 -1
  41. package/src/desktop/DesktopWindow.tsx +3 -3
  42. package/src/desktop/MeadowDesktop.tsx +2 -2
  43. package/src/drawer/Drawer.tsx +6 -2
  44. package/src/dropdown/menuClasses.ts +1 -1
  45. package/src/empty/Empty.tsx +1 -1
  46. package/src/form/variants/FieldRadio.tsx +1 -1
  47. package/src/form/variants/FieldRepeaterItem.tsx +1 -1
  48. package/src/icon/Icon.tsx +21 -0
  49. package/src/icon/glyphs.ts +35 -0
  50. package/src/index.ts +9 -23
  51. package/src/input/EditableInput.tsx +5 -4
  52. package/src/input/Input.tsx +15 -7
  53. package/src/lib/sizes.ts +6 -6
  54. package/src/lib/surface.ts +14 -4
  55. package/src/markdown-editor/MarkdownDiff.tsx +4 -4
  56. package/src/markdown-editor/MarkdownEditor.tsx +4 -4
  57. package/src/markdown-editor/MarkdownPreview.tsx +6 -6
  58. package/src/markdown-editor/MarkdownSource.tsx +1 -1
  59. package/src/markdown-editor/MarkdownTable.tsx +48 -11
  60. package/src/markdown-editor/MarkdownViewer.tsx +28 -31
  61. package/src/markdown-editor/MermaidBlock.tsx +5 -5
  62. package/src/markdown-editor/ReactCodeFrame.tsx +10 -6
  63. package/src/markdown-editor/ReactCodeSandbox.tsx +2 -2
  64. package/src/markdown-editor/markdownScale.ts +66 -127
  65. package/src/menu/Menu.tsx +3 -3
  66. package/src/message/message.tsx +18 -8
  67. package/src/modal/Modal.tsx +13 -7
  68. package/src/pagination/Pagination.tsx +7 -7
  69. package/src/popover/Popover.tsx +1 -1
  70. package/src/scroll/OverlayScroll.tsx +13 -5
  71. package/src/segmented/Segmented.tsx +1 -1
  72. package/src/select/Select.tsx +4 -4
  73. package/src/sidebar/Sidebar.tsx +39 -36
  74. package/src/skeleton/Skeleton.tsx +4 -4
  75. package/src/spin/Spin.tsx +14 -2
  76. package/src/splitter/Splitter.tsx +1 -1
  77. package/src/styles.css +188 -844
  78. package/src/table/Table.tsx +12 -12
  79. package/src/tabs/Tabs.tsx +76 -14
  80. package/src/tag/Tag.tsx +3 -3
  81. package/src/theme-switcher/ThemeSwitcher.tsx +6 -6
  82. package/src/theme.ts +53 -147
  83. package/src/timepicker/TimePicker.tsx +2 -2
  84. package/src/typography/Typography.tsx +8 -8
  85. package/src/icon/SolarIcon.tsx +0 -39
  86. package/src/icon/solar.ts +0 -172
@@ -394,7 +394,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
394
394
  setThumbInset((prev) => (prev === next ? prev : next));
395
395
  }, [headSticky, showHeader, size, flexLayout]);
396
396
  /** Opaque fill so a sticky header does not show body text, and every header matches. */
397
- const headBg: CSSProperties = { backgroundColor: "var(--nonla-table-head)" };
397
+ const headBg: CSSProperties = { backgroundColor: "var(--nonla-fill)" };
398
398
 
399
399
  const colStyle = (col: ColumnType<T>, key: string): CSSProperties => {
400
400
  const measured = flexLayout?.cols[key];
@@ -406,7 +406,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
406
406
  <div className={cn("relative w-full", className)}>
407
407
  {titleNode != null ? <div className="mb-3 text-sm font-medium text-foreground">{titleNode}</div> : null}
408
408
 
409
- <div className={cn(bordered && "overflow-hidden rounded-xl border border-hairline")}>
409
+ <div className={cn(bordered && "overflow-hidden rounded-xl border border-border-secondary")}>
410
410
  <Spin spinning={Boolean(loading)}>
411
411
  <div ref={containerRef} data-slot="table-container" className={cn("relative w-full", flexLayout ? "overflow-x-hidden" : "overflow-x-auto")} style={scroll?.x != null ? { overflowX: "auto" } : undefined}>
412
412
  <TableBodyScroll y={scroll?.y} x={scroll?.x} scrollRef={scrollBodyRef} insetTop={thumbInset}>
@@ -421,10 +421,10 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
421
421
  </colgroup>
422
422
  ) : null}
423
423
  {showHeader ? (
424
- <thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-hairline", headSticky && "relative z-20")}>
425
- <tr data-slot="table-row" className="border-b border-hairline transition-colors hover:bg-transparent">
424
+ <thead data-slot="table-header" className={cn("[&_tr]:border-b [&_tr]:border-border-secondary", headSticky && "relative z-20")}>
425
+ <tr data-slot="table-row" className="border-b border-border-secondary transition-colors hover:bg-transparent">
426
426
  {rowSelection ? (
427
- <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-hairline", bordered && "border-b border-hairline")} style={{ ...(selectionColWidth != null ? { width: selectionColWidth } : undefined), ...headBg }}>
427
+ <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-secondary", bordered && "border-b border-border-secondary")} style={{ ...(selectionColWidth != null ? { width: selectionColWidth } : undefined), ...headBg }}>
428
428
  <div className="flex items-center justify-center">
429
429
  {rowSelection.type === "radio" ? null : (
430
430
  <Checkbox
@@ -449,7 +449,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
449
449
  <th
450
450
  key={key}
451
451
  data-slot="table-head"
452
- className={cn(sz.head, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-hairline", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), bordered && "border-b border-hairline", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
452
+ className={cn(sz.head, "align-middle font-medium text-foreground", headSticky && "sticky top-0 z-10 border-b border-border-secondary", flexLayout && flexWeight(col) > 0 ? "min-w-0" : "whitespace-nowrap", alignClass(col.align), bordered && "border-b border-border-secondary", sortable && "cursor-pointer select-none", col.className, headerExtra?.className)}
453
453
  style={{
454
454
  ...colStyle(col, key),
455
455
  ...headBg,
@@ -470,7 +470,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
470
470
 
471
471
  <tbody data-slot="table-body" className={cn("[&_tr:last-child]:border-0", headSticky && "relative z-0")}>
472
472
  {pageData.length === 0 ? (
473
- <tr data-slot="table-row" className="border-b border-hairline">
473
+ <tr data-slot="table-row" className="border-b border-border-secondary">
474
474
  <td data-slot="table-cell" colSpan={colCount} className={cn(sz.cell, "text-center align-middle")}>
475
475
  {locale?.emptyText ?? <Empty description="No data" className="py-10" />}
476
476
  </td>
@@ -489,7 +489,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
489
489
  key={key}
490
490
  data-slot="table-row"
491
491
  data-state={selected ? "selected" : undefined}
492
- className={cn("border-b border-hairline transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", inSelectionMode && !rowDisabled && "cursor-pointer", rowProps?.className, extraClass)}
492
+ className={cn("border-b border-border-secondary transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", inSelectionMode && !rowDisabled && "cursor-pointer", rowProps?.className, extraClass)}
493
493
  style={rowProps?.style}
494
494
  onClick={inSelectionMode ? undefined : rowProps?.onClick}
495
495
  onClickCapture={
@@ -506,7 +506,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
506
506
  }
507
507
  >
508
508
  {rowSelection ? (
509
- <td data-row-select data-slot="table-cell" className={cn(sz.cell, sz.check, "align-middle", headSticky && "border-b border-hairline")} style={selectionColWidth != null ? { width: selectionColWidth } : undefined} onClick={(e) => e.stopPropagation()}>
509
+ <td data-row-select data-slot="table-cell" className={cn(sz.cell, sz.check, "align-middle", headSticky && "border-b border-border-secondary")} style={selectionColWidth != null ? { width: selectionColWidth } : undefined} onClick={(e) => e.stopPropagation()}>
510
510
  <div className="flex items-center justify-center">
511
511
  {rowSelection.type === "radio" ? (
512
512
  <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])} />
@@ -531,7 +531,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
531
531
  <td
532
532
  key={getColumnKey(col, i)}
533
533
  data-slot="table-cell"
534
- className={cn(sz.cell, "align-middle", headSticky && "border-b border-hairline", 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)}
534
+ className={cn(sz.cell, "align-middle", headSticky && "border-b border-border-secondary", 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)}
535
535
  style={colStyle(col, getColumnKey(col, i))}
536
536
  title={col.ellipsis && (typeof content === "string" || typeof content === "number") ? String(content) : undefined}
537
537
  >
@@ -546,7 +546,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
546
546
  </tbody>
547
547
 
548
548
  {footerNode != null ? (
549
- <tfoot data-slot="table-footer" className="border-t border-hairline bg-muted/50 font-medium [&>tr]:last:border-b-0">
549
+ <tfoot data-slot="table-footer" className="border-t border-border-secondary bg-muted/50 font-medium [&>tr]:last:border-b-0">
550
550
  <tr>
551
551
  <td colSpan={colCount} className={cn(sz.cell, "align-middle text-muted-foreground")}>
552
552
  {footerNode}
@@ -560,7 +560,7 @@ export function Table<T extends object = Record<string, unknown>>({ columns = []
560
560
  </Spin>
561
561
 
562
562
  {showPagination ? (
563
- <div className={cn("flex flex-wrap items-center justify-between gap-3 px-3 py-2", bordered && "border-t border-hairline", pageConfig.className)}>
563
+ <div className={cn("flex flex-wrap items-center justify-between gap-3 px-3 py-2", bordered && "border-t border-border-secondary", pageConfig.className)}>
564
564
  <div className="flex items-center gap-3">
565
565
  {pageConfig.showSizeChanger !== false ? (
566
566
  <Select
package/src/tabs/Tabs.tsx CHANGED
@@ -1,6 +1,5 @@
1
- import { type CSSProperties, type KeyboardEvent, type ReactNode, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
2
- import { SolarIcon } from "../icon/SolarIcon";
3
- import { solarIconName } from "../icon/solar";
1
+ import { type CSSProperties, type KeyboardEvent, type MouseEvent as ReactMouseEvent, type ReactNode, type PointerEvent as ReactPointerEvent, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
2
+ import { Icon, isIconName } from "../icon/Icon";
4
3
  import { cn } from "../lib/cn";
5
4
 
6
5
  export type TabsItem = {
@@ -8,7 +7,7 @@ export type TabsItem = {
8
7
  label: ReactNode;
9
8
  children?: ReactNode;
10
9
  disabled?: boolean;
11
- /** Solar icon name (`settings`), a legacy Fluent Color id (`settings-24`), or a node. */
10
+ /** An `Icon` name, or a node. */
12
11
  icon?: ReactNode;
13
12
  };
14
13
 
@@ -26,6 +25,12 @@ export type TabsProps = {
26
25
  const FADE = 32;
27
26
  const EDGE = 64;
28
27
  const TAB_HEIGHT = 40;
28
+ /** Mouse wheel multiplier. Raise for faster wheel scrolling. */
29
+ const WHEEL_SPEED = 2;
30
+ /** Pointer travel (px) before a press becomes a drag instead of a click. */
31
+ const DRAG_THRESHOLD = 4;
32
+
33
+ type DragState = { id: number; startX: number; startLeft: number; moved: boolean };
29
34
 
30
35
  type Ink = { left: number; width: number };
31
36
  type Overflow = { left: boolean; right: boolean };
@@ -56,7 +61,8 @@ function scrollToX(el: HTMLElement, target: number) {
56
61
 
57
62
  function TabIcon({ icon, size }: { icon?: ReactNode; size: number }) {
58
63
  if (icon == null || icon === false) return null;
59
- if (typeof icon === "string") return <SolarIcon name={solarIconName(icon)} size={size} />;
64
+ if (isIconName(icon)) return <Icon name={icon} size={size} />;
65
+ if (typeof icon === "string") return null;
60
66
  return <span className="inline-flex shrink-0 items-center justify-center">{icon}</span>;
61
67
  }
62
68
 
@@ -71,7 +77,7 @@ function ScrollButton({ dir, onClick }: { dir: "left" | "right"; onClick: () =>
71
77
  )}
72
78
  onClick={onClick}
73
79
  >
74
- <SolarIcon name={dir === "left" ? "alt-arrow-left-linear" : "alt-arrow-right-linear"} size={16} />
80
+ <Icon name={dir === "left" ? "arrow-left" : "arrow-right"} size={16} />
75
81
  </button>
76
82
  );
77
83
  }
@@ -87,6 +93,8 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
87
93
  const rowRef = useRef<HTMLDivElement>(null);
88
94
  const tabRefs = useRef(new Map<string, HTMLButtonElement>());
89
95
  const focusKey = useRef<string | null>(null);
96
+ const drag = useRef<DragState | null>(null);
97
+ const suppressClick = useRef(false);
90
98
 
91
99
  const [ink, setInk] = useState<Ink | null>(null);
92
100
  const [overflow, setOverflow] = useState<Overflow>({ left: false, right: false });
@@ -151,9 +159,10 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
151
159
  const onWheel = (event: WheelEvent) => {
152
160
  if (el.scrollWidth <= el.clientWidth + 1) return;
153
161
  if (Math.abs(event.deltaX) >= Math.abs(event.deltaY)) return;
154
- if (event.deltaY === 0) return;
162
+ const raw = event.deltaY * (event.deltaMode === 1 ? 16 : 1) * WHEEL_SPEED;
163
+ if (raw === 0) return;
155
164
  const max = el.scrollWidth - el.clientWidth;
156
- const next = Math.min(max, Math.max(0, el.scrollLeft + event.deltaY));
165
+ const next = Math.min(max, Math.max(0, el.scrollLeft + raw));
157
166
  if (next === el.scrollLeft) return;
158
167
  el.scrollLeft = next;
159
168
  updateOverflow();
@@ -163,6 +172,49 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
163
172
  return () => el.removeEventListener("wheel", onWheel);
164
173
  }, [itemsKey, updateOverflow]);
165
174
 
175
+ function onPointerDown(event: ReactPointerEvent<HTMLDivElement>) {
176
+ const el = scrollerRef.current;
177
+ if (!el || el.scrollWidth <= el.clientWidth + 1) return;
178
+ if (event.pointerType === "mouse" && event.button !== 0) return;
179
+ suppressClick.current = false;
180
+ drag.current = { id: event.pointerId, startX: event.clientX, startLeft: el.scrollLeft, moved: false };
181
+ }
182
+
183
+ function onPointerMove(event: ReactPointerEvent<HTMLDivElement>) {
184
+ const state = drag.current;
185
+ const el = scrollerRef.current;
186
+ if (!state || !el || event.pointerId !== state.id) return;
187
+ if (event.pointerType === "mouse" && event.buttons === 0) {
188
+ drag.current = null;
189
+ return;
190
+ }
191
+ const dx = event.clientX - state.startX;
192
+ if (!state.moved) {
193
+ if (Math.abs(dx) < DRAG_THRESHOLD) return;
194
+ state.moved = true;
195
+ el.setPointerCapture(event.pointerId);
196
+ }
197
+ scrollToX(el, state.startLeft - dx);
198
+ }
199
+
200
+ function endDrag(event: ReactPointerEvent<HTMLDivElement>) {
201
+ const state = drag.current;
202
+ if (!state || event.pointerId !== state.id) return;
203
+ drag.current = null;
204
+ if (!state.moved) return;
205
+ suppressClick.current = true;
206
+ const el = scrollerRef.current;
207
+ if (el?.hasPointerCapture(event.pointerId)) el.releasePointerCapture(event.pointerId);
208
+ }
209
+
210
+ /** A drag that moved should not also activate the tab under the pointer. */
211
+ function onClickCapture(event: ReactMouseEvent<HTMLDivElement>) {
212
+ if (!suppressClick.current) return;
213
+ suppressClick.current = false;
214
+ event.stopPropagation();
215
+ event.preventDefault();
216
+ }
217
+
166
218
  function select(key: string, fromKeyboard = false) {
167
219
  if (fromKeyboard) focusKey.current = key;
168
220
  if (activeKey === undefined) setInner(key);
@@ -203,12 +255,22 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
203
255
  <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 h-px bg-border" />
204
256
  <div
205
257
  ref={scrollerRef}
206
- className="nonla-scroll-hidden relative overflow-x-auto overflow-y-hidden overscroll-x-contain"
207
- style={mask ? { maskImage: mask, WebkitMaskImage: mask } : undefined}
258
+ className="relative overflow-x-auto overflow-y-hidden overscroll-x-contain touch-pan-y select-none [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden [&::-webkit-scrollbar]:h-0 [&::-webkit-scrollbar]:w-0"
259
+ style={{
260
+ // Inline on purpose: the unlayered `* { scrollbar-width: thin }` in styles.css beats the layered utility class.
261
+ scrollbarWidth: "none",
262
+ msOverflowStyle: "none",
263
+ ...(mask ? { maskImage: mask, WebkitMaskImage: mask } : null),
264
+ }}
208
265
  onScroll={updateOverflow}
266
+ onPointerDown={onPointerDown}
267
+ onPointerMove={onPointerMove}
268
+ onPointerUp={endDrag}
269
+ onPointerCancel={endDrag}
270
+ onClickCapture={onClickCapture}
209
271
  >
210
272
  <div ref={rowRef} role="tablist" aria-label={ariaLabel} aria-orientation="horizontal" className="relative flex w-max gap-3" onKeyDown={onKeyDown}>
211
- {ink ? <span aria-hidden className="nonla-tabs-ink" style={{ width: ink.width, transform: `translateX(${ink.left}px)` }} /> : null}
273
+ {ink ? <span aria-hidden className="pointer-events-none absolute bottom-0 left-0 z-1 h-0.5 rounded-t-xs bg-brand transition-[transform,width] duration-380 ease-[cubic-bezier(0.3,1.25,0.5,1)] motion-reduce:transition-none" style={{ width: ink.width, transform: `translateX(${ink.left}px)` }} /> : null}
212
274
  {items.map((item) => {
213
275
  const selected = item.key === active;
214
276
  return (
@@ -226,10 +288,10 @@ export function Tabs({ items, activeKey, defaultActiveKey, onChange, className,
226
288
  tabIndex={selected ? 0 : -1}
227
289
  disabled={item.disabled}
228
290
  className={cn(
229
- "relative z-10 inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-normal text-tertiary-foreground transition-colors select-none",
230
- "hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset",
291
+ "relative z-10 inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-normal transition-colors select-none",
292
+ "focus-visible:ring-brand/55 focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset",
231
293
  "disabled:cursor-not-allowed disabled:opacity-40",
232
- selected && "text-foreground",
294
+ selected ? "text-brand" : "text-(--nonla-text-main) hover:text-foreground",
233
295
  )}
234
296
  style={{
235
297
  height: TAB_HEIGHT,
package/src/tag/Tag.tsx CHANGED
@@ -43,7 +43,7 @@ const NAMED_VAR: Record<string, string> = {
43
43
  };
44
44
 
45
45
  const SOFT = "bg-[color-mix(in_oklab,var(--nonla-tag)_12%,transparent)] text-[color-mix(in_oklab,var(--nonla-tag)_72%,black)]";
46
- const SOLID = "bg-(--nonla-tag) text-[var(--nonla-solid-fg)]";
46
+ const SOLID = "bg-(--nonla-tag) text-[var(--nonla-text-on-solid)]";
47
47
 
48
48
  function resolveVariant(variant: TagProps["variant"]): TagVariant {
49
49
  if (variant === "solid") return "solid";
@@ -79,7 +79,7 @@ export function Tag({
79
79
  <span
80
80
  className={cn(
81
81
  "inline-flex h-5.5 max-w-full items-center gap-1.5 rounded-full px-2.5 text-[11px] font-medium tracking-[0.01em]",
82
- isDefault && (solid ? "bg-foreground/10 text-(--nonla-ink)" : "bg-muted text-muted-foreground"),
82
+ isDefault && (solid ? "bg-foreground/10 text-foreground" : "bg-muted text-muted-foreground"),
83
83
  !isDefault && (solid ? SOLID : SOFT),
84
84
  className,
85
85
  )}
@@ -87,7 +87,7 @@ export function Tag({
87
87
  >
88
88
  {showDot ? (
89
89
  <span
90
- className={cn("size-1.5 shrink-0 rounded-full", isDefault ? "bg-(--nonla-fg-muted)" : "bg-(--nonla-tag)")}
90
+ className={cn("size-1.5 shrink-0 rounded-full", isDefault ? "bg-(--nonla-text-secondary)" : "bg-(--nonla-tag)")}
91
91
  aria-hidden
92
92
  />
93
93
  ) : null}
@@ -1,12 +1,12 @@
1
1
  import { useLayoutEffect, useSyncExternalStore } from "react";
2
- import { SolarIcon } from "../icon/SolarIcon";
2
+ import { Icon, type IconName } from "../icon/Icon";
3
3
  import { cn } from "../lib/cn";
4
4
  import { getColorPreference, initColorMode, type NonlaColorPreference, setColorPreference, subscribeColorPreference } from "../theme";
5
5
 
6
- const OPTIONS: { value: NonlaColorPreference; label: string; icon: string }[] = [
7
- { value: "system", label: "System", icon: "monitor-linear" },
8
- { value: "light", label: "Light", icon: "sun-linear" },
9
- { value: "dark", label: "Dark", icon: "moon-linear" },
6
+ const OPTIONS: { value: NonlaColorPreference; label: string; icon: IconName }[] = [
7
+ { value: "system", label: "System", icon: "monitor" },
8
+ { value: "light", label: "Light", icon: "sun" },
9
+ { value: "dark", label: "Dark", icon: "moon" },
10
10
  ];
11
11
 
12
12
  export function useColorPreference(): NonlaColorPreference {
@@ -46,7 +46,7 @@ export function ThemeSwitcher({ className }: ThemeSwitcherProps) {
46
46
  selected ? "bg-ink-active text-foreground" : "hover:bg-ink-hover hover:text-foreground",
47
47
  )}
48
48
  >
49
- <SolarIcon name={option.icon} size={12} />
49
+ <Icon name={option.icon} size={12} />
50
50
  </button>
51
51
  );
52
52
  })}
package/src/theme.ts CHANGED
@@ -1,74 +1,8 @@
1
1
  /**
2
- * Theme knobs for NonlaUI.
3
- *
4
- * Defaults live in `styles.css` on `:root` / `.nonla-ui`.
5
- * Consumers retheme by overriding `--nonla-*` in CSS. Aliases follow those knobs.
6
- * `--brand-50`…`--brand-800` follow `--nonla-brand` (500 = the knob).
7
- * Color mode is `light` | `dark` on `<html>` (`setColorMode`, `<ThemeToggle>`). Dark is the default.
8
- * `<ThemeSwitcher>` also stores `system`, which follows the OS and still paints `light` or `dark`.
2
+ * Paint `light` or `dark` on `<html>`. Dark is the default.
3
+ * The stored choice may be `system`, which follows the OS and still paints one of those two.
9
4
  */
10
5
 
11
- export const NONLA_THEME_KEYS = {
12
- bg: "--nonla-bg",
13
- fg: "--nonla-fg",
14
- fgMuted: "--nonla-fg-muted",
15
- fgTertiary: "--nonla-fg-tertiary",
16
- fgQuaternary: "--nonla-fg-quaternary",
17
- brand: "--nonla-brand",
18
- solidFg: "--nonla-solid-fg",
19
- danger: "--nonla-danger",
20
- success: "--nonla-success",
21
- warn: "--nonla-warn",
22
- link: "--nonla-link",
23
- radius: "--nonla-radius",
24
- height: "--nonla-height",
25
- heightSm: "--nonla-height-sm",
26
- heightLg: "--nonla-height-lg",
27
- ink: "--nonla-ink",
28
- sidebar: "--nonla-sidebar",
29
- surface: "--nonla-surface",
30
- elevated: "--nonla-elevated",
31
- chip: "--nonla-chip",
32
- chipHover: "--nonla-chip-hover",
33
- border: "--nonla-border",
34
- borderInput: "--nonla-input",
35
- composer: "--nonla-composer",
36
- chatBg: "--nonla-chat-bg",
37
- meadow: "--nonla-meadow",
38
- glass: "--nonla-glass",
39
- glassBar: "--nonla-glass-bar",
40
- glassMenu: "--nonla-glass-menu",
41
- glassBorder: "--nonla-glass-border",
42
- glassHighlight: "--nonla-glass-highlight",
43
- inkHover: "--nonla-ink-hover",
44
- inkActive: "--nonla-ink-active",
45
- inkLine: "--nonla-ink-line",
46
- desktopBarHeight: "--nonla-desktop-bar-height",
47
- windowHeader: "--nonla-window-header",
48
- zBase: "--nonla-z-base",
49
- zDesktop: "--nonla-z-desktop",
50
- zWindow: "--nonla-z-window",
51
- zHeader: "--nonla-z-header",
52
- zPopupBase: "--nonla-z-popup-base",
53
- } as const;
54
-
55
- export type NonlaThemeKnobName = keyof typeof NONLA_THEME_KEYS;
56
- export type NonlaThemeKnob = (typeof NONLA_THEME_KEYS)[NonlaThemeKnobName];
57
-
58
- export const NONLA_THEME_KNOBS = Object.values(NONLA_THEME_KEYS);
59
-
60
- export type NonlaTokenSnapshot = { [K in NonlaThemeKnobName]: string };
61
-
62
- /** Read computed `--nonla-*` knobs (`getDesignToken`). */
63
- export function getDesignToken(target?: HTMLElement): NonlaTokenSnapshot {
64
- const el = target ?? (typeof document === "undefined" ? null : document.documentElement);
65
- const token = {} as NonlaTokenSnapshot;
66
- for (const name of Object.keys(NONLA_THEME_KEYS) as NonlaThemeKnobName[]) {
67
- token[name] = el ? getComputedStyle(el).getPropertyValue(NONLA_THEME_KEYS[name]).trim() : "";
68
- }
69
- return token;
70
- }
71
-
72
6
  export type NonlaColorMode = "light" | "dark";
73
7
 
74
8
  /** Stored choice. `system` follows the OS and still applies `light` or `dark` on `<html>`. */
@@ -77,117 +11,90 @@ export type NonlaColorPreference = NonlaColorMode | "system";
77
11
  /** `localStorage` key written by `setColorMode` / `setColorPreference`. */
78
12
  export const NONLA_COLOR_MODE_KEY = "nonla-color-mode";
79
13
 
80
- const COLOR_SCHEME_QUERY = "(prefers-color-scheme: dark)";
81
-
82
- const modeListeners = new Set<() => void>();
83
- const preferenceListeners = new Set<() => void>();
84
- let colorMode: NonlaColorMode = "dark";
85
- let colorPreference: NonlaColorPreference = "dark";
86
- let colorModeReady = false;
14
+ const listeners = new Set<() => void>();
15
+ let mode: NonlaColorMode = "dark";
16
+ let preference: NonlaColorPreference = "dark";
17
+ let ready = false;
87
18
  let schemeQuery: MediaQueryList | null = null;
88
19
 
89
- export function getColorMode(): NonlaColorMode {
90
- return colorMode;
91
- }
92
-
93
- export function getColorPreference(): NonlaColorPreference {
94
- return colorPreference;
20
+ function notify() {
21
+ for (const listener of listeners) listener();
95
22
  }
96
23
 
97
- export function subscribeColorMode(listener: () => void) {
98
- modeListeners.add(listener);
24
+ function subscribe(listener: () => void) {
25
+ listeners.add(listener);
99
26
  return () => {
100
- modeListeners.delete(listener);
27
+ listeners.delete(listener);
101
28
  };
102
29
  }
103
30
 
104
- export function subscribeColorPreference(listener: () => void) {
105
- preferenceListeners.add(listener);
106
- return () => {
107
- preferenceListeners.delete(listener);
108
- };
109
- }
31
+ export const subscribeColorMode = subscribe;
32
+ export const subscribeColorPreference = subscribe;
110
33
 
111
- function notifyColorMode() {
112
- for (const listener of modeListeners) listener();
113
- }
114
-
115
- function notifyColorPreference() {
116
- for (const listener of preferenceListeners) listener();
34
+ export function getColorMode(): NonlaColorMode {
35
+ return mode;
117
36
  }
118
37
 
119
- function isColorPreference(value: string | null): value is NonlaColorPreference {
120
- return value === "light" || value === "dark" || value === "system";
38
+ export function getColorPreference(): NonlaColorPreference {
39
+ return preference;
121
40
  }
122
41
 
123
- function readStoredPreference(): NonlaColorPreference | null {
42
+ function readStored(): NonlaColorPreference | null {
124
43
  try {
125
44
  // Sandboxed iframes throw on the property access itself, before getItem.
126
45
  const value = localStorage.getItem(NONLA_COLOR_MODE_KEY);
127
- return isColorPreference(value) ? value : null;
46
+ return value === "light" || value === "dark" || value === "system" ? value : null;
128
47
  } catch {
129
48
  return null;
130
49
  }
131
50
  }
132
51
 
133
- function systemColorMode(): NonlaColorMode {
134
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "dark";
135
- return window.matchMedia(COLOR_SCHEME_QUERY).matches ? "dark" : "light";
52
+ function writeStored(next: NonlaColorPreference) {
53
+ try {
54
+ localStorage.setItem(NONLA_COLOR_MODE_KEY, next);
55
+ } catch {
56
+ /* private mode or sandboxed iframe */
57
+ }
136
58
  }
137
59
 
138
- function resolvedMode(next: NonlaColorPreference): NonlaColorMode {
139
- return next === "system" ? systemColorMode() : next;
60
+ function systemMode(): NonlaColorMode {
61
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "dark";
62
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
140
63
  }
141
64
 
142
- function onSchemeChange() {
143
- if (colorPreference !== "system") return;
144
- const next = systemColorMode();
145
- if (typeof document === "undefined") {
146
- colorMode = next;
147
- notifyColorMode();
148
- return;
149
- }
150
- applyColorMode(next);
65
+ function resolved(next: NonlaColorPreference): NonlaColorMode {
66
+ return next === "system" ? systemMode() : next;
151
67
  }
152
68
 
153
- function watchSystemScheme() {
69
+ function watchSystem() {
154
70
  if (typeof window === "undefined" || typeof window.matchMedia !== "function" || schemeQuery) return;
155
- schemeQuery = window.matchMedia(COLOR_SCHEME_QUERY);
156
- schemeQuery.addEventListener("change", onSchemeChange);
157
- }
158
-
159
- function rememberPreference(next: NonlaColorPreference) {
160
- try {
161
- localStorage.setItem(NONLA_COLOR_MODE_KEY, next);
162
- } catch {
163
- /* private mode */
164
- }
71
+ schemeQuery = window.matchMedia("(prefers-color-scheme: dark)");
72
+ schemeQuery.addEventListener("change", () => {
73
+ if (preference === "system") applyColorMode(systemMode());
74
+ });
165
75
  }
166
76
 
167
77
  /** Set `light` or `dark` on `target` (default `<html>`) so portals inherit the palette. */
168
78
  export function applyColorMode(next: NonlaColorMode, target: HTMLElement = document.documentElement) {
169
- colorMode = next;
79
+ mode = next;
170
80
  target.classList.toggle("light", next === "light");
171
81
  target.classList.toggle("dark", next === "dark");
172
82
  target.style.colorScheme = next;
173
- notifyColorMode();
83
+ notify();
174
84
  }
175
85
 
176
86
  /** Switch the stored choice. `system` follows the OS and still paints `light` or `dark`. */
177
87
  export function setColorPreference(next: NonlaColorPreference, target?: HTMLElement) {
178
- colorPreference = next;
179
- if (next === "system") watchSystemScheme();
180
- const resolved = resolvedMode(next);
88
+ preference = next;
89
+ if (next === "system") watchSystem();
181
90
  if (typeof document === "undefined") {
182
- colorMode = resolved;
183
- notifyColorMode();
184
- notifyColorPreference();
91
+ mode = resolved(next);
92
+ notify();
185
93
  return;
186
94
  }
187
- applyColorMode(resolved, target);
188
- colorModeReady = true;
189
- rememberPreference(next);
190
- notifyColorPreference();
95
+ ready = true;
96
+ writeStored(next);
97
+ applyColorMode(resolved(next), target);
191
98
  }
192
99
 
193
100
  /** Switch mode and remember it. */
@@ -197,14 +104,13 @@ export function setColorMode(next: NonlaColorMode, target?: HTMLElement) {
197
104
 
198
105
  /** Apply the saved mode once. Falls back to dark. A stored `system` choice follows the OS. */
199
106
  export function initColorMode(target?: HTMLElement): NonlaColorMode {
200
- if (typeof document === "undefined") return colorMode;
201
- if (colorModeReady) return colorMode;
202
- colorModeReady = true;
203
- const fromClass = document.documentElement.classList.contains("light") ? "light" : document.documentElement.classList.contains("dark") ? "dark" : null;
204
- const next = readStoredPreference() ?? fromClass ?? "dark";
205
- colorPreference = next;
206
- if (next === "system") watchSystemScheme();
207
- applyColorMode(resolvedMode(next), target);
208
- notifyColorPreference();
209
- return colorMode;
107
+ if (typeof document === "undefined" || ready) return mode;
108
+ ready = true;
109
+ const root = document.documentElement;
110
+ const fromClass = root.classList.contains("light") ? "light" : root.classList.contains("dark") ? "dark" : null;
111
+ const next = readStored() ?? fromClass ?? "dark";
112
+ preference = next;
113
+ if (next === "system") watchSystem();
114
+ applyColorMode(resolved(next), target);
115
+ return mode;
210
116
  }
@@ -632,7 +632,7 @@ export const TimePicker = forwardRef<HTMLInputElement, TimePickerProps>(function
632
632
  onKeyDown={handleKeyDown}
633
633
  onKeyUp={(e) => syncPartFromCaret(e.currentTarget)}
634
634
  onClick={(e) => syncPartFromCaret(e.currentTarget)}
635
- className="min-w-0 flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-placeholder outline-none disabled:cursor-not-allowed"
635
+ className="min-w-0 flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-quaternary-foreground outline-none disabled:cursor-not-allowed"
636
636
  style={{ fontSize: fieldStyle.fontSize, lineHeight: fieldStyle.lineHeight }}
637
637
  />
638
638
  {allowClear && selected && !disabled ? (
@@ -745,7 +745,7 @@ export const TimePicker = forwardRef<HTMLInputElement, TimePickerProps>(function
745
745
  </div>
746
746
  )}
747
747
  </div>
748
- <PopoverPrimitive.Arrow width={12} height={7} className="fill-glass drop-shadow-[0_1px_0_var(--glass-border)]" />
748
+ <PopoverPrimitive.Arrow width={12} height={7} className="fill-card drop-shadow-[0_1px_0_var(--border)]" />
749
749
  </PopoverPrimitive.Content>
750
750
  </PopoverPrimitive.Portal>
751
751
  </PopoverPrimitive.Root>
@@ -1,6 +1,6 @@
1
1
  import { type AnchorHTMLAttributes, type CSSProperties, createElement, type HTMLAttributes, type ReactNode } from "react";
2
2
  import { cn } from "../lib/cn";
3
- import { headingClass, markdownBodyClass, markdownParagraphClass, markdownVariantStyle, pageTitleClass } from "../markdown-editor/markdownScale";
3
+ import { headingClass, markdownBodyClass, markdownParagraphClass, markdownScaleStyle, pageTitleClass } from "../markdown-editor/markdownScale";
4
4
 
5
5
  export type TypographyType = "secondary" | "success" | "warning" | "danger";
6
6
 
@@ -20,10 +20,10 @@ type Decorations = {
20
20
 
21
21
  /** Same ink as MarkdownViewer. Status tones sit on top of that. */
22
22
  const INK = {
23
- title: "var(--md-heading)",
24
- body: "var(--md-ink)",
25
- secondary: "var(--nonla-fg-tertiary)",
26
- quiet: "var(--nonla-fg-quaternary)",
23
+ title: "var(--nonla-text-main)",
24
+ body: "var(--nonla-text-main)",
25
+ secondary: "var(--nonla-text-tertiary)",
26
+ quiet: "var(--nonla-text-quaternary)",
27
27
  success: "var(--nonla-success)",
28
28
  warning: "var(--nonla-warn)",
29
29
  danger: "var(--nonla-danger)",
@@ -40,10 +40,10 @@ const TITLE_TAG = {
40
40
  6: "h6",
41
41
  } as const;
42
42
 
43
- /** Same scale as MarkdownViewer `docs`. Body 16/24. Inline code reads `--md-inline-size` (14px). */
43
+ /** Same scale as MarkdownViewer. Body size is `text-md`. Inline code reads `--nonla-mono-text-size`. */
44
44
  const BODY = markdownBodyClass;
45
45
 
46
- const INLINE_CODE = "nonla-inline-code";
46
+ const INLINE_CODE = "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]";
47
47
 
48
48
  const TITLE_SPACE = "nonla-typo";
49
49
 
@@ -82,7 +82,7 @@ function rankColor(role: InkRole, props: Decorations): string | undefined {
82
82
  function decorated(props: Decorations, children: ReactNode, base: string, className?: string, style?: HTMLAttributes<HTMLElement>["style"], role: InkRole = "body") {
83
83
  const line = decorationLine(props.underline, props.delete);
84
84
  const color = rankColor(role, props);
85
- const scale: CSSProperties = { ...markdownVariantStyle("docs"), ...(color ? { color } : null), ...(line ? { textDecorationLine: line } : null), ...style };
85
+ const scale: CSSProperties = { ...markdownScaleStyle, ...(color ? { color } : null), ...(line ? { textDecorationLine: line } : null), ...style };
86
86
  return {
87
87
  className: cn(base, props.disabled && "cursor-not-allowed", props.strong && "font-(--md-strong-weight,600)", props.italic && "italic", props.underline && "underline-offset-[3px]", className),
88
88
  style: scale,