devnonla-ui 0.19.2 → 0.20.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 (72) hide show
  1. package/README.md +11 -0
  2. package/package.json +1 -1
  3. package/src/alert/Alert.tsx +7 -7
  4. package/src/app/App.tsx +11 -7
  5. package/src/breadcrumb/Breadcrumb.tsx +80 -0
  6. package/src/button/Button.tsx +48 -33
  7. package/src/button/ButtonCopy.tsx +2 -2
  8. package/src/calendar/Calendar.tsx +12 -12
  9. package/src/card/Card.tsx +15 -10
  10. package/src/chat/AgentPanel.tsx +1 -1
  11. package/src/chat/index.ts +1 -5
  12. package/src/chat/message-ui/ChatError.tsx +1 -1
  13. package/src/chat/message-ui/ChatInput.tsx +4 -4
  14. package/src/chat/message-ui/ChatThinking.tsx +1 -1
  15. package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
  16. package/src/chat/message-ui/ChatWelcome.tsx +2 -2
  17. package/src/chat/tool-ui/BackgroundTasksBar.tsx +6 -6
  18. package/src/chat/tool-ui/ChatToolCall.tsx +4 -4
  19. package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
  20. package/src/chat/tool-ui/ToolUiTrailing.tsx +1 -1
  21. package/src/chat/tool-ui/registry.ts +5 -19
  22. package/src/checkbox/Checkbox.tsx +12 -10
  23. package/src/colorpicker/ColorPicker.tsx +2 -2
  24. package/src/command-palette/CommandPalette.tsx +223 -0
  25. package/src/drawer/Drawer.tsx +1 -1
  26. package/src/dropdown/Dropdown.tsx +4 -3
  27. package/src/dropdown/menuClasses.ts +2 -2
  28. package/src/empty/Empty.tsx +23 -9
  29. package/src/form/FormItem.tsx +1 -1
  30. package/src/form/variants/FieldRadio.tsx +2 -2
  31. package/src/form/variants/FieldRepeaterItem.tsx +1 -1
  32. package/src/icon/Icon.tsx +14 -4
  33. package/src/icon/glyphs.ts +47 -38
  34. package/src/index.ts +8 -2
  35. package/src/input/EditableInput.tsx +3 -3
  36. package/src/input/Input.tsx +30 -13
  37. package/src/kbd/Kbd.tsx +32 -0
  38. package/src/lib/cn.ts +7 -0
  39. package/src/lib/markdownScale.ts +7 -5
  40. package/src/lib/sizes.ts +1 -1
  41. package/src/lib/surface.ts +2 -2
  42. package/src/markdown-editor/MarkdownDiff.tsx +4 -4
  43. package/src/markdown-editor/MarkdownPreview.tsx +1 -1
  44. package/src/markdown-editor/MarkdownSource.tsx +2 -2
  45. package/src/markdown-editor/MarkdownTable.tsx +2 -2
  46. package/src/markdown-editor/MermaidBlock.tsx +5 -5
  47. package/src/markdown-editor/ReactCodeFrame.tsx +1 -1
  48. package/src/menu/Menu.tsx +2 -2
  49. package/src/message/message.tsx +8 -8
  50. package/src/modal/Modal.tsx +2 -2
  51. package/src/page-header/PageHeader.tsx +33 -0
  52. package/src/pagination/Pagination.tsx +3 -3
  53. package/src/popconfirm/Popconfirm.tsx +3 -3
  54. package/src/scroll/OverlayScroll.tsx +1 -1
  55. package/src/segmented/Segmented.tsx +16 -7
  56. package/src/select/Select.tsx +76 -47
  57. package/src/sidebar/Sidebar.tsx +15 -4
  58. package/src/sortable-tree/SortableTree.tsx +1 -1
  59. package/src/splitter/Splitter.tsx +1 -1
  60. package/src/styles.css +258 -45
  61. package/src/switch/Switch.tsx +21 -20
  62. package/src/table/Table.tsx +32 -18
  63. package/src/tabs/Tabs.tsx +16 -13
  64. package/src/tag/Tag.tsx +16 -7
  65. package/src/theme-switcher/ThemeSwitcher.tsx +1 -1
  66. package/src/timepicker/TimePicker.tsx +2 -2
  67. package/src/tooltip/Tooltip.tsx +25 -3
  68. package/src/blob-shape/BlobShape.tsx +0 -337
  69. package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +0 -51
  70. package/src/chat/tool-ui/ReadSkillToolUI.tsx +0 -82
  71. package/src/chat/tool-ui/RunJsToolUI.tsx +0 -108
  72. package/src/chat/tool-ui/WebFetchToolUI.tsx +0 -64
@@ -49,14 +49,14 @@ function TaskRow({
49
49
  }) {
50
50
  return (
51
51
  <div className="flex items-center gap-1 px-1.5 py-0.5">
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">
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-ink-hover active:bg-ink-active">
53
53
  <Spin variant="agent" size="small" className="shrink-0" />
54
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}>
58
- <button type="button" disabled={cancelling} title="Stop" aria-label={`Stop ${formatToolName(task.toolName)}`} className="inline-flex size-5 shrink-0 items-center justify-center rounded cursor-pointer text-destructive transition-colors hover:bg-destructive/10 disabled:opacity-40">
59
- <Icon name="stop" size={10} />
58
+ <button type="button" disabled={cancelling} title="Stop" aria-label={`Stop ${formatToolName(task.toolName)}`} className="inline-flex size-5 shrink-0 items-center justify-center rounded cursor-pointer text-destructive transition-colors hover:bg-destructive-bg disabled:opacity-40">
59
+ <Icon name="stop" size={13} />
60
60
  </button>
61
61
  </Popconfirm>
62
62
  </div>
@@ -117,13 +117,13 @@ export function BackgroundTasksBar({ children, tasks = [], cancellingIds, onCanc
117
117
  {tasks.length > 0 ? (
118
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
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")} />
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 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-(--nonla-dur)", !open && "-rotate-90")} />
122
122
  <span className="truncate">{label}</span>
123
123
  </button>
124
124
  </div>
125
125
 
126
- <div className="overflow-hidden transition-[height] duration-200 ease-out" style={{ height: open ? listH : 0 }}>
126
+ <div className="overflow-hidden transition-[height] duration-(--nonla-dur)" style={{ height: open ? listH : 0 }}>
127
127
  <div ref={listInnerRef} className="max-h-55 overflow-y-auto py-0.5">
128
128
  {tasks.map((task) => (
129
129
  <TaskRow
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode, useState } from "react";
2
2
  import { Icon } from "../../icon/Icon";
3
- import { cn } from "../../lib/cn";
3
+ import { cn, focusRing } from "../../lib/cn";
4
4
  import { Shimmer } from "../../shimmer/Shimmer";
5
5
  import { chatRowClass, chatToolLineClass } from "../chatRhythm";
6
6
  import { formatToolName, hasMeaningfulInput, prettyJson } from "../common/utils";
@@ -45,7 +45,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
45
45
  <div className={cn("nonla-chat-tool", chatRowClass, className)}>
46
46
  <div className="px-4">
47
47
  {expandable ? (
48
- <button type="button" onClick={() => setOpen((v) => !v)} className={cn(chatToolLineClass, "group w-full cursor-pointer border-0 bg-transparent outline-none")}>
48
+ <button type="button" onClick={() => setOpen((v) => !v)} className={cn(chatToolLineClass, "group w-full cursor-pointer rounded-md border-0 bg-transparent", focusRing)}>
49
49
  {header}
50
50
  </button>
51
51
  ) : (
@@ -53,7 +53,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
53
53
  )}
54
54
 
55
55
  {open && expandable ? (
56
- <div className={cn("mt-1.5 mb-1 overflow-hidden rounded-lg border font-mono text-sm", hasError ? "border-destructive/35 bg-destructive/6" : "border-border bg-card")}>
56
+ <div className={cn("mt-1.5 mb-1 overflow-hidden rounded-lg border font-mono text-sm", hasError ? "border-destructive-border bg-destructive-bg" : "border-border bg-card")}>
57
57
  {hasInput ? <pre className="m-0 max-h-27.5 overflow-y-auto px-3 py-1.5 break-all whitespace-pre-wrap font-normal leading-[1.65] text-muted-foreground">{prettyJson(toolInput)}</pre> : null}
58
58
  {running ? (
59
59
  <div className={cn("px-3 py-1.5 text-muted-foreground", hasInput && "border-t border-border")}>
@@ -61,7 +61,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
61
61
  </div>
62
62
  ) : null}
63
63
  {!isPending ? (
64
- <pre className={cn("m-0 max-h-75 overflow-y-auto px-3 py-1.5 break-all whitespace-pre-wrap font-normal leading-[1.65]", hasInput && "border-t", hasError ? "border-destructive/35 text-destructive" : "border-border text-muted-foreground")}>
64
+ <pre className={cn("m-0 max-h-75 overflow-y-auto px-3 py-1.5 break-all whitespace-pre-wrap font-normal leading-[1.65]", hasInput && "border-t", hasError ? "border-destructive-border text-destructive" : "border-border text-muted-foreground")}>
65
65
  {hasOutput ? prettyJson(toolOutput) : typeof toolError === "string" ? toolError : "Tool execution failed"}
66
66
  </pre>
67
67
  ) : null}
@@ -2,7 +2,7 @@ export function ToolUiBadge({ show = false, label, color }: { show?: boolean; la
2
2
  if (!show) return null;
3
3
  return (
4
4
  <div className="flex items-center gap-2.5 px-4 pt-3 pb-1">
5
- <span className="inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-bold tracking-wider uppercase select-none" style={{ background: color ?? "var(--nonla-text-main)", color: "var(--nonla-bg)", letterSpacing: "0.08em" }}>
5
+ <span className="inline-flex items-center rounded px-1.5 py-0.5 text-2xs font-medium select-none" style={{ background: color ?? "var(--nonla-text-main)", color: "var(--nonla-bg)", letterSpacing: "0.08em" }}>
6
6
  {label}
7
7
  </span>
8
8
  </div>
@@ -16,5 +16,5 @@ export function ToolUiTrailing({
16
16
  if (running) return <ChatSpinner />;
17
17
  if (failed) return <Icon name="error" size={13} className="shrink-0 text-destructive" />;
18
18
  if (!chevron) return null;
19
- return <Icon name="arrow-right" size={12} className={cn("shrink-0 opacity-0 transition-[opacity,transform] duration-150", chevronClassName)} />;
19
+ return <Icon name="arrow-right" size={12} className={cn("shrink-0 opacity-0 transition-[opacity,transform]", chevronClassName)} />;
20
20
  }
@@ -1,11 +1,7 @@
1
1
  import type { ComponentType } from "react";
2
2
  import type { AgentToolNameMatch } from "../common/types";
3
3
  import { matchesToolName } from "../common/utils";
4
- import { GetCurrentTimeToolUI } from "./GetCurrentTimeToolUI";
5
- import { ReadSkillToolUI } from "./ReadSkillToolUI";
6
- import { RunJsToolUI } from "./RunJsToolUI";
7
4
  import type { ToolUIProps } from "./types";
8
- import { WebFetchToolUI } from "./WebFetchToolUI";
9
5
 
10
6
  /** Exact name, aliases, or a predicate. */
11
7
  export type AgentToolUIName = AgentToolNameMatch;
@@ -19,21 +15,11 @@ export function matchesToolUIName(name: AgentToolUIName, toolName: string): bool
19
15
  return matchesToolName(name, toolName);
20
16
  }
21
17
 
22
- export const builtinToolUis: AgentToolUI[] = [
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 },
27
- ];
28
-
29
- /** App `toolUis` win on the same name; builtins are the fallback. */
30
- export function resolveToolUI(toolName: string | null | undefined, extras?: readonly AgentToolUI[] | null): ComponentType<ToolUIProps> | null {
31
- if (!toolName) return null;
32
- const lists = extras?.length ? [extras, builtinToolUis] : [builtinToolUis];
33
- for (const list of lists) {
34
- for (const entry of list) {
35
- if (matchesToolUIName(entry.name, toolName)) return entry.component;
36
- }
18
+ /** First app `toolUis` entry whose name matches. No match falls back to `ChatToolCall`. */
19
+ export function resolveToolUI(toolName: string | null | undefined, toolUis?: readonly AgentToolUI[] | null): ComponentType<ToolUIProps> | null {
20
+ if (!toolName || !toolUis?.length) return null;
21
+ for (const entry of toolUis) {
22
+ if (matchesToolUIName(entry.name, toolName)) return entry.component;
37
23
  }
38
24
  return null;
39
25
  }
@@ -1,9 +1,9 @@
1
1
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
2
2
  import { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from "react";
3
- import { cn } from "../lib/cn";
3
+ import { cn, focusRing } from "../lib/cn";
4
4
 
5
- /** Checked fill. `white` is the on-state for dark surfaces — the mark stays ink. */
6
- export type CheckboxColor = "brand" | "success" | "white";
5
+ /** Checked fill. `default` is ink (`--nonla-selected`). `white` is the on-state for dark surfaces — the mark stays ink. */
6
+ export type CheckboxColor = "default" | "brand" | "success" | "white";
7
7
 
8
8
  export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, "onCheckedChange" | "checked" | "onChange"> & {
9
9
  checked?: boolean | "indeterminate";
@@ -16,12 +16,14 @@ export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof CheckboxPrimiti
16
16
  };
17
17
 
18
18
  const CHECKED_FILL: Record<CheckboxColor, string> = {
19
+ default:
20
+ "data-[state=checked]:bg-selected data-[state=checked]:border-selected data-[state=checked]:text-on-selected data-[state=indeterminate]:bg-selected data-[state=indeterminate]:border-selected data-[state=indeterminate]:text-on-selected",
19
21
  brand:
20
- "data-[state=checked]:bg-brand data-[state=checked]:border-brand data-[state=checked]:text-(--nonla-text-on-solid) data-[state=indeterminate]:bg-brand data-[state=indeterminate]:border-brand data-[state=indeterminate]:text-(--nonla-text-on-solid)",
22
+ "data-[state=checked]:bg-brand data-[state=checked]:border-brand data-[state=checked]:text-(--nonla-text-on-brand) data-[state=indeterminate]:bg-brand data-[state=indeterminate]:border-brand data-[state=indeterminate]:text-(--nonla-text-on-brand)",
21
23
  success:
22
- "data-[state=checked]:bg-success data-[state=checked]:border-success data-[state=checked]:text-(--nonla-text-on-solid) data-[state=indeterminate]:bg-success data-[state=indeterminate]:border-success data-[state=indeterminate]:text-(--nonla-text-on-solid)",
24
+ "data-[state=checked]:bg-success-fill data-[state=checked]:border-success-fill data-[state=checked]:text-on-success data-[state=indeterminate]:bg-success-fill data-[state=indeterminate]:border-success-fill data-[state=indeterminate]:text-on-success",
23
25
  white:
24
- "data-[state=checked]:bg-white data-[state=checked]:border-white data-[state=checked]:text-[#141414] data-[state=indeterminate]:bg-white data-[state=indeterminate]:border-white data-[state=indeterminate]:text-[#141414]",
26
+ "data-[state=checked]:bg-white data-[state=checked]:border-white data-[state=checked]:text-(--nonla-bg) data-[state=indeterminate]:bg-white data-[state=indeterminate]:border-white data-[state=indeterminate]:text-(--nonla-bg)",
25
27
  };
26
28
 
27
29
  function CheckIcon() {
@@ -33,7 +35,7 @@ function CheckIcon() {
33
35
  }
34
36
 
35
37
  export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(function Checkbox(
36
- { className, checked, defaultChecked, onChange, children, indeterminate, disabled, color = "brand", ...rest },
38
+ { className, checked, defaultChecked, onChange, children, indeterminate, disabled, color = "default", ...rest },
37
39
  ref,
38
40
  ) {
39
41
  const resolved = indeterminate ? "indeterminate" : checked;
@@ -47,14 +49,14 @@ export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(function Ch
47
49
  disabled={disabled}
48
50
  onCheckedChange={(v) => onChange?.(v === true)}
49
51
  className={cn(
50
- "size-4 shrink-0 rounded-sm border border-input bg-(--nonla-surface) transition-colors duration-150 ease-[cubic-bezier(0.16,1,0.3,1)]",
51
- "focus-visible:outline-none",
52
+ "size-4 shrink-0 rounded-sm border border-input bg-(--nonla-surface) transition-colors",
53
+ focusRing,
52
54
  CHECKED_FILL[color],
53
55
  className,
54
56
  )}
55
57
  {...rest}
56
58
  >
57
- <CheckboxPrimitive.Indicator className="flex items-center justify-center text-current animate-[nonla-check-in_150ms_cubic-bezier(0.16,1,0.3,1)]">
59
+ <CheckboxPrimitive.Indicator className="flex items-center justify-center text-current animate-[nonla-check-in_var(--nonla-dur-fast)_var(--nonla-ease-out)]">
58
60
  <CheckIcon />
59
61
  </CheckboxPrimitive.Indicator>
60
62
  </CheckboxPrimitive.Root>
@@ -388,7 +388,7 @@ function PresetGroup({
388
388
  type="button"
389
389
  title={color.toHexString()}
390
390
  aria-label={color.toHexString()}
391
- className={cn(CHECKERED, "size-5 cursor-pointer overflow-hidden rounded-sm border border-border", active && "ring-2 ring-brand ring-offset-1 ring-offset-background")}
391
+ className={cn(CHECKERED, "size-5 cursor-pointer overflow-hidden rounded-sm border border-border", active && "ring-2 ring-selected ring-offset-1 ring-offset-background")}
392
392
  onClick={() => onPick(color)}
393
393
  >
394
394
  <span className="block size-full" style={{ backgroundColor: color.toRgbString() }} />
@@ -594,7 +594,7 @@ export function ColorPicker({
594
594
  ) : (
595
595
  <button
596
596
  type="button"
597
- className="inline-flex h-6 w-11 shrink-0 cursor-pointer items-center justify-between rounded-md border-0 bg-transparent px-0.5 text-[11px] font-medium text-muted-foreground hover:text-foreground"
597
+ className="inline-flex h-6 w-11 shrink-0 cursor-pointer items-center justify-between rounded-md border-0 bg-transparent px-0.5 text-xs font-medium text-muted-foreground hover:text-foreground"
598
598
  onClick={cycleFormat}
599
599
  >
600
600
  {format.toUpperCase()}
@@ -0,0 +1,223 @@
1
+ import * as Dialog from "@radix-ui/react-dialog";
2
+ import { type KeyboardEvent, type ReactNode, useEffect, useMemo, useRef, useState } from "react";
3
+ import { usePopupContainer } from "../app/context";
4
+ import { Icon, isIconName } from "../icon/Icon";
5
+ import { Kbd } from "../kbd/Kbd";
6
+ import { cn } from "../lib/cn";
7
+
8
+ export type CommandItem = {
9
+ key: string;
10
+ /** Main text. A string is also what the query matches. */
11
+ label: ReactNode;
12
+ /** Muted context after an em dash, e.g. the section a page lives in. */
13
+ description?: ReactNode;
14
+ /** An `Icon` name, or a node. */
15
+ icon?: ReactNode;
16
+ /** Extra words the query should match (aliases, ids). */
17
+ keywords?: string[];
18
+ /** Keys shown on the right, e.g. `["⌘", "N"]`. Display only. */
19
+ shortcut?: string[];
20
+ disabled?: boolean;
21
+ /** Runs on Enter or click. The palette closes afterwards unless you return `false`. */
22
+ onSelect?: () => unknown;
23
+ };
24
+
25
+ export type CommandGroup = {
26
+ /** Small muted heading, e.g. "Recents". */
27
+ label?: ReactNode;
28
+ items: CommandItem[];
29
+ };
30
+
31
+ export type CommandPaletteProps = {
32
+ open?: boolean;
33
+ defaultOpen?: boolean;
34
+ onOpenChange?: (open: boolean) => void;
35
+ groups: CommandGroup[];
36
+ placeholder?: string;
37
+ /** Shown when nothing matches the query. */
38
+ emptyText?: ReactNode;
39
+ /** Open on ⌘K / Ctrl+K anywhere on the page. Default `true`. */
40
+ hotkey?: boolean;
41
+ /** Called on every keystroke, for remote search. Local filtering still runs on `label`, `description`, and `keywords`. */
42
+ onQueryChange?: (query: string) => void;
43
+ /** Turn off local filtering, e.g. when `groups` already hold remote results. Default `true`. */
44
+ filter?: boolean;
45
+ className?: string;
46
+ };
47
+
48
+ function textOf(node: ReactNode): string {
49
+ if (node == null || typeof node === "boolean") return "";
50
+ if (typeof node === "string" || typeof node === "number") return String(node);
51
+ if (Array.isArray(node)) return node.map(textOf).join(" ");
52
+ return "";
53
+ }
54
+
55
+ function matches(item: CommandItem, q: string) {
56
+ if (!q) return true;
57
+ const hay = [textOf(item.label), textOf(item.description), ...(item.keywords ?? [])].join(" ").toLowerCase();
58
+ return q
59
+ .toLowerCase()
60
+ .split(/\s+/)
61
+ .every((word) => hay.includes(word));
62
+ }
63
+
64
+ /**
65
+ * ⌘K palette (measured on Cloudflare): a top-anchored panel, grouped rows of icon + label — context,
66
+ * a pale page wash behind it, and key hints in the footer.
67
+ */
68
+ export function CommandPalette({ open: openProp, defaultOpen = false, onOpenChange, groups, placeholder = "Search…", emptyText = "No results", hotkey = true, onQueryChange, filter = true, className }: CommandPaletteProps) {
69
+ const [innerOpen, setInnerOpen] = useState(defaultOpen);
70
+ const open = openProp ?? innerOpen;
71
+ const setOpen = (next: boolean) => {
72
+ if (openProp === undefined) setInnerOpen(next);
73
+ onOpenChange?.(next);
74
+ };
75
+ const [query, setQuery] = useState("");
76
+ const [active, setActive] = useState(0);
77
+ const listRef = useRef<HTMLDivElement>(null);
78
+ const portal = usePopupContainer()?.();
79
+
80
+ // ⌘K / Ctrl+K toggles from anywhere.
81
+ useEffect(() => {
82
+ if (!hotkey) return;
83
+ const onKey = (e: globalThis.KeyboardEvent) => {
84
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
85
+ e.preventDefault();
86
+ setOpen(!open);
87
+ }
88
+ };
89
+ window.addEventListener("keydown", onKey);
90
+ return () => window.removeEventListener("keydown", onKey);
91
+ }, [hotkey, open]);
92
+
93
+ useEffect(() => {
94
+ if (!open) {
95
+ setQuery("");
96
+ setActive(0);
97
+ }
98
+ }, [open]);
99
+
100
+ const visible = useMemo(
101
+ () => groups.map((g) => ({ ...g, items: filter ? g.items.filter((it) => matches(it, query.trim())) : g.items })).filter((g) => g.items.length > 0),
102
+ [groups, query, filter],
103
+ );
104
+ const flat = useMemo(() => visible.flatMap((g) => g.items), [visible]);
105
+ const enabled = flat.filter((it) => !it.disabled);
106
+
107
+ useEffect(() => {
108
+ listRef.current?.querySelector('[data-active="true"]')?.scrollIntoView({ block: "nearest" });
109
+ }, [active]);
110
+
111
+ const run = (item: CommandItem | undefined) => {
112
+ if (!item || item.disabled) return;
113
+ const keep = item.onSelect?.() === false;
114
+ if (!keep) setOpen(false);
115
+ };
116
+
117
+ const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
118
+ if (e.nativeEvent.isComposing) return;
119
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
120
+ e.preventDefault();
121
+ if (!enabled.length) return;
122
+ const dir = e.key === "ArrowDown" ? 1 : -1;
123
+ setActive((i) => (i + dir + enabled.length) % enabled.length);
124
+ } else if (e.key === "Enter") {
125
+ e.preventDefault();
126
+ run(enabled[active]);
127
+ }
128
+ };
129
+
130
+ const activeItem = enabled[active];
131
+
132
+ return (
133
+ <Dialog.Root open={open} onOpenChange={setOpen}>
134
+ <Dialog.Portal container={portal}>
135
+ <Dialog.Overlay className="fixed inset-0 z-(--nonla-z-modal) bg-(--mask) data-[state=open]:animate-[nonla-overlay-in_var(--nonla-dur)_var(--nonla-ease-out)] data-[state=closed]:animate-[nonla-overlay-out_var(--nonla-dur-fast)_var(--nonla-ease-in)_forwards]" />
136
+ <Dialog.Content
137
+ aria-describedby={undefined}
138
+ className={cn(
139
+ "fixed top-[12vh] left-1/2 [transform:translate(-50%,0)] z-[calc(var(--nonla-z-modal)+1)] flex max-h-[min(560px,76vh)] w-[min(672px,calc(100vw-32px))] flex-col overflow-hidden rounded-lg bg-card text-foreground shadow-(--nonla-card-shadow) outline-none",
140
+ "data-[state=open]:animate-[nonla-modal-in_var(--nonla-dur)_var(--nonla-ease-out)] data-[state=closed]:animate-[nonla-modal-out_var(--nonla-dur-fast)_var(--nonla-ease-in)_forwards]",
141
+ className,
142
+ )}
143
+ >
144
+ <Dialog.Title className="sr-only">Command palette</Dialog.Title>
145
+ <div className="flex items-center gap-2.5 border-b border-solid border-border-secondary px-3.5">
146
+ <Icon name="search" size={16} className="text-tertiary-foreground" />
147
+ <input
148
+ // biome-ignore lint/a11y/noAutofocus: a palette exists to be typed into
149
+ autoFocus
150
+ value={query}
151
+ onChange={(e) => {
152
+ setQuery(e.target.value);
153
+ setActive(0);
154
+ onQueryChange?.(e.target.value);
155
+ }}
156
+ onKeyDown={onKeyDown}
157
+ placeholder={placeholder}
158
+ role="combobox"
159
+ aria-expanded
160
+ aria-controls="nonla-command-list"
161
+ aria-activedescendant={activeItem ? `nonla-command-${activeItem.key}` : undefined}
162
+ className="h-12 min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-foreground outline-none placeholder:text-tertiary-foreground"
163
+ />
164
+ <Kbd>Esc</Kbd>
165
+ </div>
166
+
167
+ <div ref={listRef} id="nonla-command-list" role="listbox" className="min-h-0 flex-1 overflow-y-auto p-1.5">
168
+ {visible.length === 0 ? (
169
+ <div className="px-3 py-8 text-center text-sm text-muted-foreground">{emptyText}</div>
170
+ ) : (
171
+ visible.map((group, gi) => (
172
+ // biome-ignore lint/suspicious/noArrayIndexKey: groups are positional
173
+ <div key={gi} role="group" className="not-first:mt-1.5">
174
+ {group.label != null ? <div className="px-2.5 pt-2 pb-1 text-xs font-medium text-tertiary-foreground">{group.label}</div> : null}
175
+ {group.items.map((item) => {
176
+ const index = enabled.indexOf(item);
177
+ const isActive = index === active && index !== -1;
178
+ return (
179
+ <div
180
+ key={item.key}
181
+ id={`nonla-command-${item.key}`}
182
+ role="option"
183
+ tabIndex={-1}
184
+ aria-selected={isActive}
185
+ aria-disabled={item.disabled || undefined}
186
+ data-active={isActive || undefined}
187
+ onMouseMove={() => index !== -1 && index !== active && setActive(index)}
188
+ onClick={() => run(item)}
189
+ className={cn(
190
+ "flex h-9 cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-sm",
191
+ isActive && "bg-ink-hover",
192
+ item.disabled && "cursor-not-allowed opacity-45",
193
+ )}
194
+ >
195
+ {item.icon != null ? (
196
+ <span className="inline-flex size-4 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4">{isIconName(item.icon) ? <Icon name={item.icon} size={16} /> : item.icon}</span>
197
+ ) : null}
198
+ <span className="min-w-0 flex-1 truncate">
199
+ <span className="text-foreground">{item.label}</span>
200
+ {item.description != null ? <span className="text-tertiary-foreground"> — {item.description}</span> : null}
201
+ </span>
202
+ {item.shortcut ? <Kbd keys={item.shortcut} /> : isActive ? <Icon name="arrow-forward" size={14} className="text-tertiary-foreground" /> : null}
203
+ </div>
204
+ );
205
+ })}
206
+ </div>
207
+ ))
208
+ )}
209
+ </div>
210
+
211
+ <div className="flex items-center gap-4 border-t border-solid border-border-secondary px-3.5 py-2 text-xs text-tertiary-foreground">
212
+ <span className="inline-flex items-center gap-1.5">
213
+ <Kbd keys={["↑", "↓"]} /> to navigate
214
+ </span>
215
+ <span className="inline-flex items-center gap-1.5">
216
+ <Kbd>↵</Kbd> to select
217
+ </span>
218
+ </div>
219
+ </Dialog.Content>
220
+ </Dialog.Portal>
221
+ </Dialog.Root>
222
+ );
223
+ }
@@ -107,7 +107,7 @@ export function Drawer({
107
107
  >
108
108
  {(title || closable || extra) && (
109
109
  <div className="flex items-center justify-between gap-3 border-b border-border px-5 py-4" style={styles?.header}>
110
- <Dialog.Title className="m-0 min-w-0 flex-1 text-base font-semibold">{title}</Dialog.Title>
110
+ <Dialog.Title className="m-0 min-w-0 flex-1 text-lg font-semibold">{title}</Dialog.Title>
111
111
  {extra ? <div className="flex shrink-0 items-center gap-2">{extra}</div> : null}
112
112
  {closable ? (
113
113
  <Dialog.Close className="text-muted-foreground hover:text-foreground text-lg leading-none" aria-label="Close">
@@ -37,6 +37,7 @@ export type DropdownProps = {
37
37
  disabled?: boolean;
38
38
  /** Alias — accepted, no-op (Radix unmounts when closed). */
39
39
  destroyOnHidden?: boolean;
40
+ /** `overlay` goes on the menu panel (like `overlayClassName`); `root` on the trigger. */
40
41
  classNames?: { root?: string; overlay?: string };
41
42
  };
42
43
 
@@ -109,7 +110,7 @@ function MenuItems({ items, onClick, portal }: { items: (MenuItemType | null | u
109
110
  );
110
111
  }
111
112
 
112
- export function Dropdown({ menu, children, trigger = ["click"], open, onOpenChange, placement = "bottomLeft", className, overlayClassName, disabled }: DropdownProps) {
113
+ export function Dropdown({ menu, children, trigger = ["click"], open, onOpenChange, placement = "bottomLeft", className, overlayClassName, disabled, classNames }: DropdownProps) {
113
114
  const { side, align } = placementToRadix(placement);
114
115
  const portal = usePopupContainer()?.();
115
116
  const hover = trigger.includes("hover");
@@ -130,7 +131,7 @@ export function Dropdown({ menu, children, trigger = ["click"], open, onOpenChan
130
131
 
131
132
  return (
132
133
  <DropdownMenu.Root open={isOpen} onOpenChange={setIsOpen} modal={!hover}>
133
- <DropdownMenu.Trigger asChild disabled={disabled} onClick={click || contextMenu ? undefined : (e) => e.preventDefault()} onMouseEnter={hover && !disabled ? () => setIsOpen(true) : undefined} onMouseLeave={hover ? () => setIsOpen(false) : undefined} onContextMenu={handleContext}>
134
+ <DropdownMenu.Trigger asChild className={classNames?.root} disabled={disabled} onClick={click || contextMenu ? undefined : (e) => e.preventDefault()} onMouseEnter={hover && !disabled ? () => setIsOpen(true) : undefined} onMouseLeave={hover ? () => setIsOpen(false) : undefined} onContextMenu={handleContext}>
134
135
  {children}
135
136
  </DropdownMenu.Trigger>
136
137
  <DropdownMenu.Portal container={portal}>
@@ -138,7 +139,7 @@ export function Dropdown({ menu, children, trigger = ["click"], open, onOpenChan
138
139
  side={side}
139
140
  align={align === "center" ? "start" : align}
140
141
  sideOffset={4}
141
- className={cn(menuContentClass, "nonla-popper", className, overlayClassName, menu?.className)}
142
+ className={cn(menuContentClass, "nonla-popper", className, overlayClassName, classNames?.overlay, menu?.className)}
142
143
  style={menu?.style}
143
144
  onMouseEnter={hover ? () => setIsOpen(true) : undefined}
144
145
  onMouseLeave={hover ? () => setIsOpen(false) : undefined}
@@ -2,9 +2,9 @@ import { cn } from "../lib/cn";
2
2
  import { glassOverlayClass } from "../lib/surface";
3
3
 
4
4
  export const menuItemClass =
5
- "nonla-menu-item relative flex cursor-default select-none items-center gap-2 rounded-lg border border-solid border-transparent px-2.5 py-1 text-sm leading-5 outline-none data-[disabled]:opacity-40 data-highlighted:border-border data-highlighted:bg-ink-hover";
5
+ "nonla-menu-item relative flex cursor-default select-none items-center gap-2 rounded-md border border-solid border-transparent px-2 py-1 text-sm leading-5 outline-none data-[disabled]:opacity-40 data-highlighted:bg-ink-hover";
6
6
 
7
- export const menuContentClass = cn(glassOverlayClass, "min-w-40 overflow-hidden p-1");
7
+ export const menuContentClass = cn(glassOverlayClass, "min-w-40 overflow-hidden p-1.5");
8
8
 
9
9
  export const menuIconClass = "inline-flex size-4 shrink-0 items-center justify-center [&_img]:size-4 [&_svg]:size-4";
10
10
 
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  import { Card } from "../card/Card";
3
+ import { Icon, isIconName } from "../icon/Icon";
3
4
  import { cn } from "../lib/cn";
4
5
 
5
6
  const LOGO_CONE = "M768 68 C752 68 640 145 439 300 C338 377 250 449 194 500 C172 519 150 540 134 560 C122 576 109 591 103 600 C99 613 100 628 101 640 A666 108 0 0 1 1433 640 C1434 628 1435 613 1431 600 C1425 591 1412 576 1400 560 C1384 540 1362 519 1340 500 C1284 449 1196 377 1095 300 C894 145 782 68 768 68Z";
@@ -32,19 +33,32 @@ function LogoMark() {
32
33
  }
33
34
 
34
35
  export type EmptyProps = {
36
+ /** Glyph above the title: an `Icon` name or any node. Defaults to the Nonla mark. `null` hides it. */
37
+ icon?: ReactNode;
38
+ /** Bold line, e.g. "No projects yet". */
39
+ title?: ReactNode;
40
+ /** Muted line under the title. */
35
41
  description?: ReactNode | null;
42
+ /** Call to action under the text, usually a primary `Button`. */
43
+ action?: ReactNode;
44
+ /** Extra content under the action. */
36
45
  children?: ReactNode;
46
+ /** Wrap in a `Card`. Turn off inside tables, panels, or cards. Default `true`. */
47
+ bordered?: boolean;
37
48
  className?: string;
38
49
  };
39
50
 
40
- export function Empty({ description = "No data", children, className }: EmptyProps) {
41
- return (
42
- <Card className="w-full">
43
- <div role="status" className={cn("flex min-w-0 flex-col items-center justify-center gap-3 px-6 py-10 text-center", className)}>
44
- <LogoMark />
45
- {description != null ? <p className="m-0 max-w-sm text-sm text-muted-foreground">{description}</p> : null}
46
- {children ? <div className="mt-2 flex flex-col items-center gap-2">{children}</div> : null}
47
- </div>
48
- </Card>
51
+ /** Empty state (measured on Cloudflare): 36px ink icon, 20px title, muted line, then the action. */
52
+ export function Empty({ icon, title, description = title == null ? "No data" : undefined, action, children, bordered = true, className }: EmptyProps) {
53
+ const glyph = icon === undefined ? <LogoMark /> : icon === null ? null : isIconName(icon) ? <Icon name={icon} size={36} className="text-foreground" /> : icon;
54
+ const body = (
55
+ <div role="status" className={cn("flex min-w-0 flex-col items-center justify-center px-6 py-10 text-center", className)}>
56
+ {glyph ? <div className="mb-4 flex items-center justify-center">{glyph}</div> : null}
57
+ {title != null && title !== "" ? <p className="m-0 text-xl leading-7 font-semibold text-foreground">{title}</p> : null}
58
+ {description != null && description !== "" ? <p className={cn("m-0 max-w-sm text-sm text-muted-foreground", title != null && "mt-1")}>{description}</p> : null}
59
+ {action ? <div className="mt-5 flex flex-wrap items-center justify-center gap-2">{action}</div> : null}
60
+ {children ? <div className="mt-3 flex flex-col items-center gap-2">{children}</div> : null}
61
+ </div>
49
62
  );
63
+ return bordered ? <Card className="w-full">{body}</Card> : body;
50
64
  }
@@ -96,7 +96,7 @@ export function FormItem(props: FormItemProps) {
96
96
  <button
97
97
  type="button"
98
98
  aria-label={collapsed ? "Expand" : "Collapse"}
99
- className="inline-flex size-4 cursor-pointer items-center justify-center rounded-[3px] border-0 bg-muted p-0 text-muted-foreground"
99
+ className="inline-flex size-4 cursor-pointer items-center justify-center rounded-xs border-0 bg-muted p-0 text-muted-foreground"
100
100
  onClick={() => setCollapsed((v) => !v)}
101
101
  >
102
102
  <svg
@@ -27,9 +27,9 @@ export function FieldRadio({ field, choices }: Props) {
27
27
  />
28
28
  <span
29
29
  aria-hidden
30
- className="pointer-events-none size-4 rounded-full border border-solid border-input bg-muted peer-checked:border-brand"
30
+ className="pointer-events-none size-4 rounded-full border border-solid border-input bg-muted peer-checked:border-selected"
31
31
  />
32
- <span aria-hidden className="pointer-events-none absolute inset-[3.5px] rounded-full bg-brand opacity-0 peer-checked:opacity-100" />
32
+ <span aria-hidden className="pointer-events-none absolute inset-[3.5px] rounded-full bg-selected opacity-0 peer-checked:opacity-100" />
33
33
  </span>
34
34
  <span>{option.label}</span>
35
35
  </label>
@@ -25,7 +25,7 @@ export function FieldRepeaterItem({ index, remove, namePrefix, childItems, contr
25
25
  <button
26
26
  type="button"
27
27
  aria-label={collapsed ? "Expand item" : "Collapse item"}
28
- className="inline-flex size-4 items-center justify-center rounded-[3px] border-0 bg-muted text-muted-foreground cursor-pointer p-0"
28
+ className="inline-flex size-4 items-center justify-center rounded-xs border-0 bg-muted text-muted-foreground cursor-pointer p-0"
29
29
  onClick={() => setCollapsed((v) => !v)}
30
30
  >
31
31
  <svg width="10" height="10" viewBox="0 0 12 12" fill="none" aria-hidden className={collapsed ? "-rotate-90" : undefined}>
package/src/icon/Icon.tsx CHANGED
@@ -7,20 +7,30 @@ export function isIconName(value: unknown): value is IconName {
7
7
  return typeof value === "string" && value in ICON_GLYPHS;
8
8
  }
9
9
 
10
+ /** Rendered line weight in CSS px. Measured against Claude desktop: about 1.25px at every size. */
11
+ const OPTICAL_STROKE_PX = 1.25;
12
+
13
+ /** Line weight in the 24 viewBox that renders `OPTICAL_STROKE_PX`, clamped so tiny icons stay open and large ones stay light. */
14
+ function opticalStroke(size: number): number {
15
+ const raw = (OPTICAL_STROKE_PX * 24) / size;
16
+ return Math.round(Math.min(2.25, Math.max(1.25, raw)) * 100) / 100;
17
+ }
18
+
10
19
  export function Icon({
11
20
  name,
12
21
  size = 16,
13
- stroke = 1.5,
22
+ stroke,
14
23
  className,
15
24
  }: {
16
25
  name: IconName;
17
26
  size?: number;
18
- /** Line weight in the 24 viewBox. `1.5` is the regular weight. Higher draws a bolder line. */
27
+ /** Line weight in the 24 viewBox. Default keeps about 1.25px on screen at any `size` (1.88 at 16px, 1.25 at 24px). */
19
28
  stroke?: number;
20
29
  className?: string;
21
30
  }) {
22
- const glyph = ICON_GLYPHS[name].replaceAll('stroke-width="1.5"', `stroke-width="${stroke}"`);
23
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke-width="${stroke}" shape-rendering="geometricPrecision">${glyph}</svg>`;
31
+ const weight = stroke ?? opticalStroke(size);
32
+ const glyph = ICON_GLYPHS[name].replaceAll('stroke-width="1.5"', `stroke-width="${weight}"`);
33
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke-width="${weight}" stroke-linecap="round" stroke-linejoin="round" shape-rendering="geometricPrecision">${glyph}</svg>`;
24
34
  return (
25
35
  <span
26
36
  aria-hidden