devnonla-ui 0.19.1 → 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 (74) 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 +18 -7
  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/MarkdownViewer.tsx +8 -8
  47. package/src/markdown-editor/MermaidBlock.tsx +5 -5
  48. package/src/markdown-editor/ReactCodeFrame.tsx +1 -1
  49. package/src/menu/Menu.tsx +2 -2
  50. package/src/message/message.tsx +8 -8
  51. package/src/modal/Modal.tsx +2 -2
  52. package/src/page-header/PageHeader.tsx +33 -0
  53. package/src/pagination/Pagination.tsx +3 -3
  54. package/src/popconfirm/Popconfirm.tsx +3 -3
  55. package/src/scroll/OverlayScroll.tsx +1 -1
  56. package/src/segmented/Segmented.tsx +16 -7
  57. package/src/select/Select.tsx +76 -47
  58. package/src/sidebar/Sidebar.tsx +15 -4
  59. package/src/sortable-tree/SortableTree.tsx +1 -1
  60. package/src/splitter/Splitter.tsx +1 -1
  61. package/src/styles.css +262 -49
  62. package/src/switch/Switch.tsx +21 -20
  63. package/src/table/Table.tsx +32 -18
  64. package/src/tabs/Tabs.tsx +16 -13
  65. package/src/tag/Tag.tsx +16 -7
  66. package/src/theme-switcher/ThemeSwitcher.tsx +1 -1
  67. package/src/timepicker/TimePicker.tsx +2 -2
  68. package/src/tooltip/Tooltip.tsx +25 -3
  69. package/src/typography/Typography.tsx +3 -5
  70. package/src/blob-shape/BlobShape.tsx +0 -337
  71. package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +0 -51
  72. package/src/chat/tool-ui/ReadSkillToolUI.tsx +0 -82
  73. package/src/chat/tool-ui/RunJsToolUI.tsx +0 -108
  74. package/src/chat/tool-ui/WebFetchToolUI.tsx +0 -64
package/README.md CHANGED
@@ -31,3 +31,14 @@ import { MarkdownViewer } from "devnonla-ui/markdown";
31
31
  ```
32
32
 
33
33
  Install, theme, and each control are in the [docs](https://devnonla.github.io/devnonla-ui/).
34
+
35
+ ## Claude Code plugin
36
+
37
+ One `devnonla-ui` skill that teaches coding agents to build with NonlaUI: setup, which component to use, house style, theming, and the agent chat kit, plus an API table for every component that agents read on demand.
38
+
39
+ ```
40
+ /plugin marketplace add devnonla/devnonla-ui
41
+ /plugin install devnonla-ui@devnonla-ui
42
+ ```
43
+
44
+ Agents load it on their own when a task touches NonlaUI, or call it with `/devnonla-ui:devnonla-ui`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devnonla-ui",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "description": "NonlaUI — React controls for Nonla Agents",
6
6
  "author": "devlangla <devlangla0x01@gmail.com>",
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, useState } from "react";
2
- import { cn } from "../lib/cn";
2
+ import { cn, focusRing } from "../lib/cn";
3
3
 
4
4
  export type AlertType = "success" | "info" | "warning" | "error";
5
5
 
@@ -17,10 +17,10 @@ export type AlertProps = {
17
17
  };
18
18
 
19
19
  const TYPE_STYLES: Record<AlertType, string> = {
20
- success: "border-success/30 bg-success/10 text-foreground",
21
- info: "border-link/30 bg-link/10 text-foreground",
22
- warning: "border-warn/30 bg-warn/10 text-foreground",
23
- error: "border-destructive/30 bg-destructive/10 text-foreground",
20
+ success: "border-success-border bg-success-bg text-foreground",
21
+ info: "border-link-border bg-link-bg text-foreground",
22
+ warning: "border-warn-border bg-warn-bg text-foreground",
23
+ error: "border-destructive-border bg-destructive-bg text-foreground",
24
24
  };
25
25
 
26
26
  const ICON_COLOR: Record<AlertType, string> = {
@@ -91,14 +91,14 @@ export function Alert({
91
91
  {showIcon ? <AlertIcon type={type} /> : null}
92
92
  <div className="min-w-0 flex-1 flex flex-col gap-0.5">
93
93
  {heading != null && heading !== "" ? <div className="font-medium leading-5">{heading}</div> : null}
94
- {description != null && description !== "" ? <div className="leading-5 text-foreground/90">{description}</div> : null}
94
+ {description != null && description !== "" ? <div className="leading-5 text-foreground">{description}</div> : null}
95
95
  {children}
96
96
  </div>
97
97
  {canClose ? (
98
98
  <button
99
99
  type="button"
100
100
  aria-label="Close"
101
- className="shrink-0 -mr-1 -mt-0.5 inline-flex size-6 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground hover:text-foreground"
101
+ className={cn("shrink-0 -mr-1 -mt-0.5 inline-flex size-6 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground hover:text-foreground", focusRing, "focus-visible:ring-offset-0")}
102
102
  onClick={handleClose}
103
103
  >
104
104
  ×
package/src/app/App.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
2
- import { type ReactNode, useLayoutEffect, useMemo, useRef } from "react";
2
+ import { type ReactNode, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { cn } from "../lib/cn";
4
4
  import { type ControlSize, ControlSizeContext, normalizeSize } from "../lib/sizes";
5
5
  import { MessageHolder, message } from "../message/message";
@@ -22,20 +22,24 @@ export type AppProps = {
22
22
  /** Root host for NonlaUI — theme scope + message/modal holders. Mount once near app root. */
23
23
  export function App({ children, getPopupContainer, componentSize, className }: AppProps) {
24
24
  const hostRef = useRef<HTMLDivElement>(null);
25
+ // The host in state, not only a ref: the context changes once after mount, so components that read
26
+ // the popup container during their first render (Tooltip, ContextMenu) re-render and portal into the host.
27
+ const [host, setHost] = useState<HTMLDivElement | null>(null);
25
28
  const size = componentSize ? normalizeSize(componentSize) : undefined;
26
29
  const value = useMemo<NonlaAppConfig>(
27
30
  () => ({
28
- getPopupContainer: getPopupContainer ?? (() => hostRef.current ?? document.body),
31
+ getPopupContainer: getPopupContainer ?? (() => host ?? hostRef.current ?? document.body),
29
32
  componentSize: size,
30
33
  }),
31
- [getPopupContainer, size],
34
+ [getPopupContainer, size, host],
32
35
  );
33
36
 
34
37
  useLayoutEffect(() => {
35
- const host = hostRef.current;
36
- if (!host) return;
37
- bindColorModeTarget(host);
38
- initColorMode(host);
38
+ const el = hostRef.current;
39
+ if (!el) return;
40
+ setHost(el);
41
+ bindColorModeTarget(el);
42
+ initColorMode(el);
39
43
  return () => bindColorModeTarget(null);
40
44
  }, []);
41
45
 
@@ -0,0 +1,80 @@
1
+ import { Fragment, type ReactNode } from "react";
2
+ import { Icon } from "../icon/Icon";
3
+ import { cn } from "../lib/cn";
4
+
5
+ export type BreadcrumbItem = {
6
+ title: ReactNode;
7
+ /** Renders a link. */
8
+ href?: string;
9
+ /** Click handler, for client-side routing. */
10
+ onClick?: () => void;
11
+ /** Glyph before the title. */
12
+ icon?: ReactNode;
13
+ };
14
+
15
+ export type BreadcrumbProps = {
16
+ /** Path from the root to the current page. The last item is the current page. */
17
+ items: BreadcrumbItem[];
18
+ /** Between items. Defaults to a small chevron. */
19
+ separator?: ReactNode;
20
+ className?: string;
21
+ };
22
+
23
+ /** Page path for a top bar (measured on Cloudflare): muted 14px ancestors, the current page in 500 weight. */
24
+ export function Breadcrumb({ items, separator, className }: BreadcrumbProps) {
25
+ const sep = separator ?? <Icon name="arrow-right" size={14} className="text-quaternary-foreground" />;
26
+ return (
27
+ <nav aria-label="Breadcrumb" className={cn("min-w-0", className)}>
28
+ <ol className="m-0 flex min-w-0 list-none items-center gap-1.5 p-0 text-sm">
29
+ {items.map((item, i) => {
30
+ const last = i === items.length - 1;
31
+ const content = (
32
+ <>
33
+ {item.icon ? <span className="inline-flex shrink-0 items-center [&_svg]:size-4">{item.icon}</span> : null}
34
+ <span className="truncate">{item.title}</span>
35
+ </>
36
+ );
37
+ const base = "inline-flex min-w-0 items-center gap-1.5";
38
+ return (
39
+ // biome-ignore lint/suspicious/noArrayIndexKey: a path is ordered and short
40
+ <Fragment key={i}>
41
+ <li className={cn("min-w-0", last ? "shrink-0" : "shrink")}>
42
+ {last ? (
43
+ <span aria-current="page" className={cn(base, "font-medium text-foreground")}>
44
+ {content}
45
+ </span>
46
+ ) : item.href ? (
47
+ <a
48
+ href={item.href}
49
+ onClick={
50
+ item.onClick
51
+ ? (e) => {
52
+ e.preventDefault();
53
+ item.onClick?.();
54
+ }
55
+ : undefined
56
+ }
57
+ className={cn(base, "rounded-sm text-muted-foreground no-underline transition-colors hover:text-foreground")}
58
+ >
59
+ {content}
60
+ </a>
61
+ ) : item.onClick ? (
62
+ <button type="button" onClick={item.onClick} className={cn(base, "cursor-pointer rounded-sm border-0 bg-transparent p-0 font-[inherit] text-muted-foreground transition-colors hover:text-foreground")}>
63
+ {content}
64
+ </button>
65
+ ) : (
66
+ <span className={cn(base, "text-muted-foreground")}>{content}</span>
67
+ )}
68
+ </li>
69
+ {last ? null : (
70
+ <li aria-hidden className="inline-flex shrink-0 items-center">
71
+ {sep}
72
+ </li>
73
+ )}
74
+ </Fragment>
75
+ );
76
+ })}
77
+ </ol>
78
+ </nav>
79
+ );
80
+ }
@@ -1,10 +1,12 @@
1
- import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type CSSProperties, createContext, type ForwardRefExoticComponent, forwardRef, type MouseEvent, type ReactNode, type RefAttributes, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
- import { cn } from "../lib/cn";
1
+ import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type CSSProperties, cloneElement, createContext, type ForwardRefExoticComponent, forwardRef, isValidElement, type MouseEvent, type ReactNode, type RefAttributes, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
+ import { Icon } from "../icon/Icon";
3
+ import { cn, focusRing } from "../lib/cn";
3
4
  import type { ControlSize } from "../lib/sizes";
4
5
  import { controlHeightVar, controlRadiusVar, getSizeTokens, useControlSize } from "../lib/sizes";
5
6
 
6
- export type ButtonType = "default" | "primary" | "dashed" | "link" | "text";
7
- export type ButtonVariant = "outlined" | "dashed" | "solid" | "filled" | "text" | "link" | "nostyle";
7
+ /** `icon` is a square, icon-only button that looks like `text`: no fill or border until hover. Give it an `aria-label`. */
8
+ export type ButtonType = "default" | "primary" | "link" | "text" | "icon";
9
+ export type ButtonVariant = "outlined" | "solid" | "filled" | "text" | "icon" | "link" | "nostyle";
8
10
  export type ButtonShape = "default" | "circle" | "round" | "square";
9
11
  export type ButtonHtmlType = "submit" | "button" | "reset";
10
12
  export type ButtonSize = ControlSize;
@@ -44,9 +46,9 @@ export type ButtonGroupProps = {
44
46
  const TYPE_MAP: Record<ButtonType, [ButtonColor, ButtonVariant]> = {
45
47
  default: ["default", "outlined"],
46
48
  primary: ["primary", "solid"],
47
- dashed: ["default", "dashed"],
48
49
  link: ["link", "link"],
49
50
  text: ["default", "text"],
51
+ icon: ["default", "icon"],
50
52
  };
51
53
 
52
54
  const HTML_BUTTON_TYPES = new Set(["button", "submit", "reset"]);
@@ -66,6 +68,9 @@ function resolveTone(type: ButtonType | undefined, color: ButtonColor | undefine
66
68
  return ["default", variant ?? "outlined"];
67
69
  }
68
70
 
71
+ /** Glyph box for `type="icon"` per size: about 60% of the button. */
72
+ const ICON_BUTTON_GLYPH = { small: 16, default: 20, large: 24 } as const;
73
+
69
74
  const PRESET_COLORS = new Set<ButtonColor>(["blue", "purple", "cyan", "green", "magenta", "pink", "red", "orange", "yellow", "volcano", "geekblue", "lime", "gold"]);
70
75
 
71
76
  const TWO_CN = /^[\u4e00-\u9fa5]{2}$/;
@@ -75,35 +80,37 @@ function tokenAppearance(color: "default" | "primary" | "danger" | "link", varia
75
80
  if (variant === "nostyle") return "";
76
81
  const g = ghost && variant !== "text" && variant !== "link";
77
82
  if (color === "primary") {
78
- if (variant === "solid" && !g) return "border-transparent bg-brand text-[var(--nonla-text-on-solid)] hover:bg-[color-mix(in_oklab,var(--brand),var(--background)_14%)] active:bg-[color-mix(in_oklab,var(--brand),black_18%)]";
79
- if (variant === "filled") return "bg-brand/15 text-brand-700 border-transparent hover:bg-brand/25";
80
- if (variant === "text") return "bg-transparent text-brand border-transparent hover:bg-brand/10";
81
- if (variant === "link") return "text-brand border-transparent hover:text-brand-700";
82
- return "bg-transparent text-brand border-brand hover:bg-brand/10";
83
+ if (variant === "solid" && !g) return "border-(--nonla-brand-ring) bg-brand-fill text-on-brand shadow-(--nonla-solid-shadow) hover:bg-brand-fill-hover active:bg-brand-fill-active";
84
+ if (variant === "filled") return "bg-brand-bg text-brand border-transparent hover:bg-brand-bg-hover active:bg-brand-border";
85
+ if (variant === "text" || variant === "icon") return "bg-transparent text-brand border-transparent hover:bg-brand-bg active:bg-brand-bg-hover";
86
+ if (variant === "link") return "text-brand border-transparent underline-offset-4 hover:underline";
87
+ return "bg-transparent text-brand border-brand hover:bg-brand-bg active:bg-brand-bg-hover";
83
88
  }
84
89
  if (color === "danger") {
85
- if (variant === "solid" && !g) return "border-transparent bg-destructive text-(--nonla-text-on-solid) hover:bg-destructive/90";
86
- if (variant === "filled") return "bg-destructive/15 text-destructive border-transparent hover:bg-destructive/25";
87
- if (variant === "text") return "bg-transparent text-destructive border-transparent hover:bg-destructive/10";
88
- if (variant === "link") return "text-destructive border-transparent hover:text-destructive/80";
89
- return "bg-transparent text-destructive border-destructive hover:bg-destructive/10";
90
+ if (variant === "solid" && !g) return "border-(--nonla-danger-ring) bg-destructive-fill text-on-destructive shadow-(--nonla-solid-shadow) hover:bg-destructive-fill-hover active:bg-destructive-fill-active";
91
+ if (variant === "filled") return "bg-destructive-bg text-destructive border-transparent hover:bg-destructive-bg-hover active:bg-destructive-border";
92
+ if (variant === "text" || variant === "icon") return "bg-transparent text-destructive border-transparent hover:bg-destructive-bg active:bg-destructive-bg-hover";
93
+ if (variant === "link") return "text-destructive border-transparent underline-offset-4 hover:underline";
94
+ return "bg-transparent text-destructive border-destructive-border hover:bg-destructive-bg active:bg-destructive-bg-hover";
90
95
  }
91
- if (color === "link" || variant === "link") return "text-link border-transparent hover:text-link/80";
92
- if (variant === "filled") return "bg-muted text-foreground border-transparent hover:bg-muted/80";
93
- if (variant === "text") return "bg-transparent text-foreground border-transparent hover:bg-ink-hover hover:text-foreground";
94
- if (variant === "dashed") return "bg-transparent text-foreground border-dashed border-border hover:bg-ink-hover";
95
- return "nonla-btn-glass border-border bg-transparent text-foreground shadow-none transition-[box-shadow,transform] duration-(--nonla-dur-fast) ease-(--nonla-ease-out) hover:not-disabled:not-aria-disabled:shadow-[inset_0_0_0_999px_var(--nonla-ink-hover)] active:not-disabled:not-aria-disabled:scale-[0.98] active:not-disabled:not-aria-disabled:shadow-[inset_0_0_0_999px_var(--nonla-ink-active)] motion-reduce:transition-[box-shadow] motion-reduce:active:transform-none";
96
+ if (color === "link" || variant === "link") return "text-link border-transparent underline-offset-4 hover:underline";
97
+ if (variant === "filled") return "bg-muted text-foreground border-transparent hover:bg-(--nonla-fill-strong) active:bg-ink-active";
98
+ if (variant === "text") return "bg-transparent text-foreground border-transparent hover:bg-ink-hover active:bg-ink-active";
99
+ if (variant === "icon") return "bg-transparent text-foreground border-transparent hover:bg-ink-hover active:bg-ink-active";
100
+ // Raised default (measured on Cloudflare): surface fill, hairline, 1px contact shadow. Hover darkens the fill a step, press a bit more.
101
+ // No press scale on popup triggers (Radix sets `data-state`): the popup anchors to the trigger box and would jump with it.
102
+ return "nonla-btn-glass border-border bg-card text-foreground shadow-(--nonla-btn-shadow) transition-[background-color,transform] duration-(--nonla-dur-fast) ease-(--nonla-ease-out) hover:not-disabled:not-aria-disabled:bg-(--nonla-btn-bg-hover) active:not-disabled:not-aria-disabled:not-data-[state]:scale-[0.97] active:not-disabled:not-aria-disabled:bg-(--nonla-btn-bg-active) motion-reduce:transition-[background-color] motion-reduce:active:transform-none";
96
103
  }
97
104
 
98
105
  function presetAppearance(variant: ButtonVariant, ghost: boolean): string {
99
106
  if (variant === "nostyle") return "";
100
107
  const g = ghost && variant !== "text" && variant !== "link";
101
- if (variant === "solid" && !g) return "bg-(--nonla-btn) text-[var(--nonla-text-on-solid)] border-transparent hover:brightness-110";
102
- if (variant === "filled") return "bg-(--nonla-btn)/15 text-(--nonla-btn) border-transparent hover:bg-(--nonla-btn)/25";
103
- if (variant === "link") return "text-(--nonla-btn) border-transparent hover:opacity-80";
104
- if (variant === "dashed") return "bg-transparent text-(--nonla-btn) border-dashed border-(--nonla-btn) hover:bg-(--nonla-btn)/10";
105
- if (variant === "text") return "bg-transparent text-(--nonla-btn) border-transparent hover:bg-(--nonla-btn)/10";
106
- return "bg-transparent text-(--nonla-btn) border-(--nonla-btn) hover:bg-(--nonla-btn)/10";
108
+ if (variant === "solid" && !g)
109
+ return "bg-(--nonla-btn) text-(--nonla-text-on-solid) border-transparent hover:bg-[color-mix(in_oklab,var(--nonla-btn)_90%,var(--nonla-fill-shade))] active:bg-[color-mix(in_oklab,var(--nonla-btn)_82%,var(--nonla-fill-shade))]";
110
+ if (variant === "filled") return "bg-(--nonla-btn)/10 text-(--nonla-btn) border-transparent hover:bg-(--nonla-btn)/16 active:bg-(--nonla-btn)/24";
111
+ if (variant === "link") return "text-(--nonla-btn) border-transparent underline-offset-4 hover:underline";
112
+ if (variant === "text" || variant === "icon") return "bg-transparent text-(--nonla-btn) border-transparent hover:bg-(--nonla-btn)/10 active:bg-(--nonla-btn)/16";
113
+ return "bg-transparent text-(--nonla-btn) border-(--nonla-btn) hover:bg-(--nonla-btn)/10 active:bg-(--nonla-btn)/16";
107
114
  }
108
115
 
109
116
  function LoadingDot({ size }: { size: number }) {
@@ -162,7 +169,10 @@ const ButtonInner = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProp
162
169
  const [mergedColor, mergedVariant] = resolveTone(type, color, variant, danger);
163
170
  const preset = PRESET_COLORS.has(mergedColor);
164
171
  const placement = iconPlacement ?? iconPosition ?? "start";
165
- const iconOnly = children == null || children === false || children === "";
172
+ const iconVariant = mergedVariant === "icon";
173
+ // `type="icon"` takes the glyph from `icon` or, if unset, from `children`. It never renders a label.
174
+ const iconProp = iconVariant && icon == null ? children : icon;
175
+ const iconOnly = iconVariant || children == null || children === false || children === "";
166
176
 
167
177
  const loadingOn = typeof loading === "object" ? true : !!loading;
168
178
  const loadingDelay = typeof loading === "object" ? (loading.delay ?? 0) : 0;
@@ -197,12 +207,16 @@ const ButtonInner = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProp
197
207
  return children;
198
208
  }, [children, autoInsertSpace]);
199
209
 
200
- const iconNode = innerLoading ? typeof loading === "object" && loading.icon ? loading.icon : <LoadingDot size={tok.icon} /> : icon;
210
+ // Icon-only buttons use a toolbar-sized glyph box (20px in a 32px button, as on Claude desktop).
211
+ const iconSize = iconVariant ? ICON_BUTTON_GLYPH[size] : tok.icon;
212
+ // An `<Icon>` without its own `size` takes the icon button's glyph box, so the stroke weight matches the drawn size.
213
+ const sizedIcon = iconVariant && isValidElement<{ size?: number }>(iconProp) && iconProp.type === Icon && iconProp.props.size == null ? cloneElement(iconProp, { size: iconSize }) : iconProp;
214
+ const iconNode = innerLoading ? typeof loading === "object" && loading.icon ? loading.icon : <LoadingDot size={iconSize} /> : sizedIcon;
201
215
  const showIcon = Boolean(iconNode);
202
216
  const bare = mergedVariant === "nostyle";
203
217
  const radius = shape === "circle" || shape === "round" ? 9999 : shape === "square" ? 4 : controlRadiusVar(size);
204
218
  const appearance = bare ? "" : preset ? presetAppearance(mergedVariant, ghost) : tokenAppearance(mergedColor as "default" | "primary" | "danger" | "link", mergedVariant, ghost);
205
- const bordered = !bare && mergedVariant !== "text" && mergedVariant !== "link";
219
+ const bordered = !bare && mergedVariant !== "text" && mergedVariant !== "icon" && mergedVariant !== "link";
206
220
 
207
221
  const padText = tok.paddingInline;
208
222
  const paddingLeft = iconOnly ? 0 : showIcon && placement === "start" ? tok.paddingInlineIconStart : padText;
@@ -210,8 +224,9 @@ const ButtonInner = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProp
210
224
 
211
225
  const rootClass = cn(
212
226
  bare
213
- ? "inline-flex items-center justify-center gap-2 cursor-pointer border-0 bg-transparent px-0 py-0 text-inherit rounded-none disabled:cursor-not-allowed"
214
- : "inline-flex items-center justify-center gap-2 font-normal whitespace-nowrap select-none cursor-pointer border border-solid transition-colors duration-150 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",
227
+ ? "inline-flex items-center justify-center gap-2 cursor-pointer border-0 bg-transparent px-0 py-0 text-inherit rounded-none disabled:cursor-not-allowed focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
228
+ : "inline-flex items-center justify-center gap-1.5 font-medium whitespace-nowrap select-none cursor-pointer border border-solid transition-colors disabled:cursor-not-allowed disabled:opacity-45",
229
+ !bare && focusRing,
215
230
  !bare && (bordered ? "border" : "border-transparent"),
216
231
  appearance,
217
232
  block && "flex w-full",
@@ -251,11 +266,11 @@ const ButtonInner = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProp
251
266
  const inner = (
252
267
  <>
253
268
  {showIcon ? (
254
- <span className={cn("relative z-10 inline-flex shrink-0 items-center justify-center", !bare && "[&_svg]:size-full", classNames?.icon)} style={bare ? styles?.icon : { width: tok.icon, height: tok.icon, ...styles?.icon }}>
269
+ <span className={cn("relative z-10 inline-flex shrink-0 items-center justify-center", !bare && "[&_svg]:size-full", classNames?.icon)} style={bare ? styles?.icon : { width: iconSize, height: iconSize, ...styles?.icon }}>
255
270
  {iconNode}
256
271
  </span>
257
272
  ) : null}
258
- {content != null && content !== false && content !== "" ? (
273
+ {!iconVariant && content != null && content !== false && content !== "" ? (
259
274
  <span className={cn("relative z-10 inline-flex min-w-0 items-center", classNames?.content)} style={styles?.content}>
260
275
  {content}
261
276
  </span>
@@ -1,6 +1,6 @@
1
1
  import { type ComponentProps, useEffect, 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 { type ControlSize, getSizeTokens, useControlSize } from "../lib/sizes";
5
5
 
6
6
  export type ButtonCopyProps = Omit<ComponentProps<"button">, "children" | "size"> & {
@@ -29,7 +29,7 @@ export function ButtonCopy({ text, getText, label = "Copy", className, onClick,
29
29
  {...props}
30
30
  title={copied ? "Copied" : label}
31
31
  aria-label={copied ? "Copied" : label}
32
- className={cn("inline-flex cursor-pointer shrink-0 items-center justify-center text-muted-foreground transition-colors duration-200 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/55", className)}
32
+ className={cn("inline-flex cursor-pointer shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground", focusRing, className)}
33
33
  style={{ width: box, height: box }}
34
34
  onClick={async (e) => {
35
35
  onClick?.(e);
@@ -51,11 +51,11 @@ function CalendarDayButton({ className, day, modifiers, children, ...props }: Da
51
51
  data-range-middle={modifiers.range_middle ? "true" : undefined}
52
52
  className={cn(
53
53
  "relative flex aspect-square size-full min-w-8 items-center justify-center rounded-md bg-transparent text-sm font-normal leading-none",
54
- "transition-colors hover:bg-brand-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/55",
55
- "data-[selected-single=true]:bg-brand-200 data-[selected-single=true]:text-foreground data-[selected-single=true]:hover:bg-brand-200",
56
- "data-[range-start=true]:bg-brand-200 data-[range-start=true]:text-foreground data-[range-start=true]:hover:bg-brand-200 data-[range-start=true]:rounded-md",
57
- "data-[range-end=true]:bg-brand-200 data-[range-end=true]:text-foreground data-[range-end=true]:hover:bg-brand-200 data-[range-end=true]:rounded-md",
58
- "data-[range-middle=true]:bg-brand-50 data-[range-middle=true]:text-foreground data-[range-middle=true]:rounded-none",
54
+ "transition-colors hover:bg-ink-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring",
55
+ "data-[selected-single=true]:bg-selected data-[selected-single=true]:text-on-selected data-[selected-single=true]:hover:bg-selected",
56
+ "data-[range-start=true]:bg-selected data-[range-start=true]:text-on-selected data-[range-start=true]:hover:bg-selected data-[range-start=true]:rounded-md",
57
+ "data-[range-end=true]:bg-selected data-[range-end=true]:text-on-selected data-[range-end=true]:hover:bg-selected data-[range-end=true]:rounded-md",
58
+ "data-[range-middle=true]:bg-ink-active data-[range-middle=true]:text-foreground data-[range-middle=true]:rounded-none",
59
59
  defaultClassNames.day_button,
60
60
  className,
61
61
  )}
@@ -93,12 +93,12 @@ export function Calendar({
93
93
  nav: cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", defaultClassNames.nav),
94
94
  button_previous: cn(
95
95
  "inline-flex size-(--cell-size) items-center justify-center rounded-md p-0 text-foreground select-none",
96
- "hover:bg-brand-50 disabled:opacity-40",
96
+ "hover:bg-ink-hover disabled:opacity-40",
97
97
  defaultClassNames.button_previous,
98
98
  ),
99
99
  button_next: cn(
100
100
  "inline-flex size-(--cell-size) items-center justify-center rounded-md p-0 text-foreground select-none",
101
- "hover:bg-brand-50 disabled:opacity-40",
101
+ "hover:bg-ink-hover disabled:opacity-40",
102
102
  defaultClassNames.button_next,
103
103
  ),
104
104
  month_caption: cn("flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)", defaultClassNames.month_caption),
@@ -106,7 +106,7 @@ export function Calendar({
106
106
  dropdowns: cn("flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium", defaultClassNames.dropdowns),
107
107
  month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
108
108
  weekdays: cn("flex", defaultClassNames.weekdays),
109
- weekday: cn("flex-1 select-none rounded-md text-[0.8rem] font-normal text-muted-foreground", defaultClassNames.weekday),
109
+ weekday: cn("flex-1 select-none rounded-md text-xs font-normal text-muted-foreground", defaultClassNames.weekday),
110
110
  week: cn("mt-1.5 flex w-full", defaultClassNames.week),
111
111
  day: cn(
112
112
  "group/day relative aspect-square h-full w-full p-0 text-center select-none",
@@ -114,12 +114,12 @@ export function Calendar({
114
114
  defaultClassNames.day,
115
115
  ),
116
116
  today: cn(defaultClassNames.today),
117
- outside: cn("text-muted-foreground/60 aria-selected:text-muted-foreground", defaultClassNames.outside),
117
+ outside: cn("text-tertiary-foreground aria-selected:text-muted-foreground", defaultClassNames.outside),
118
118
  disabled: cn("text-muted-foreground opacity-40", defaultClassNames.disabled),
119
119
  hidden: cn("invisible", defaultClassNames.hidden),
120
- range_start: cn("rounded-l-md bg-brand-50", defaultClassNames.range_start),
121
- range_middle: cn("rounded-none bg-brand-50", defaultClassNames.range_middle),
122
- range_end: cn("rounded-r-md bg-brand-50", defaultClassNames.range_end),
120
+ range_start: cn("rounded-l-md bg-ink-active", defaultClassNames.range_start),
121
+ range_middle: cn("rounded-none bg-ink-active", defaultClassNames.range_middle),
122
+ range_end: cn("rounded-r-md bg-ink-active", defaultClassNames.range_end),
123
123
  ...classNames,
124
124
  }}
125
125
  components={{
package/src/card/Card.tsx CHANGED
@@ -12,8 +12,8 @@ export type CardItemProps = HTMLAttributes<HTMLDivElement> & {
12
12
  label?: ReactNode;
13
13
  description?: ReactNode;
14
14
  /**
15
- * `start` — label and control align to the top (rows with a description).
16
- * `center` — short rows, control vertically centered with the label.
15
+ * `center` (default) — control vertically centered on the row, like settings lists.
16
+ * `start` — control pinned to the first line (tall rows with long text or a multi-line field).
17
17
  */
18
18
  align?: "start" | "center";
19
19
  /** Split the row in half so a field can fill the trailing column. */
@@ -24,8 +24,8 @@ export type CardFooterProps = HTMLAttributes<HTMLDivElement>;
24
24
 
25
25
  function CardRoot({ title, caption, className, children, ...rest }: CardProps) {
26
26
  return (
27
- <section className={cn("flex flex-col gap-[9px]", className)} {...rest}>
28
- {title != null && title !== "" ? <div className="px-2 text-sm leading-4 text-foreground">{title}</div> : null}
27
+ <section className={cn("flex flex-col gap-2", className)} {...rest}>
28
+ {title != null && title !== "" ? <div className="px-1 text-sm leading-5 font-medium text-foreground">{title}</div> : null}
29
29
  <div className="flex flex-col self-stretch rounded-xl bg-card" style={{ boxShadow: "var(--nonla-card-shadow)" }}>
30
30
  {children}
31
31
  </div>
@@ -34,16 +34,17 @@ function CardRoot({ title, caption, className, children, ...rest }: CardProps) {
34
34
  );
35
35
  }
36
36
 
37
- function CardItem({ label, description, align = "start", split = false, className, children, ...rest }: CardItemProps) {
37
+ function CardItem({ label, description, align = "center", split = false, className, children, ...rest }: CardItemProps) {
38
38
  const hasCopy = (label != null && label !== "") || (description != null && description !== "");
39
39
  const centered = align === "center";
40
40
 
41
41
  return (
42
42
  <div
43
43
  className={cn(
44
- "relative flex w-full gap-5 px-4 py-3",
44
+ // Settings rhythm (measured on Cloudflare): 18px sides, 16px rows, full-width 6% dividers.
45
+ "relative flex w-full gap-4 px-4.5 py-4",
45
46
  centered ? "items-center" : "items-start",
46
- "before:pointer-events-none before:absolute before:top-0 before:right-4 before:left-4 before:h-px before:bg-border-secondary before:content-[''] first:before:hidden",
47
+ "before:pointer-events-none before:absolute before:top-0 before:right-0 before:left-0 before:h-px before:bg-border-secondary before:content-[''] first:before:hidden",
47
48
  className,
48
49
  )}
49
50
  {...rest}
@@ -51,8 +52,8 @@ function CardItem({ label, description, align = "start", split = false, classNam
51
52
  {hasCopy ? (
52
53
  <>
53
54
  <div className={cn("flex min-w-0 flex-1 flex-col gap-0.5", centered && "justify-center")}>
54
- {label != null && label !== "" ? <div className="flex items-center gap-1 text-sm leading-5 text-foreground">{label}</div> : null}
55
- {description != null && description !== "" ? <div className="text-sm text-muted-foreground">{description}</div> : null}
55
+ {label != null && label !== "" ? <div className="flex items-center gap-1.5 text-sm leading-5 font-medium text-foreground">{label}</div> : null}
56
+ {description != null && description !== "" ? <div className="text-sm leading-5 text-muted-foreground">{description}</div> : null}
56
57
  </div>
57
58
  {children != null ? (
58
59
  <div className={cn("flex min-h-6 min-w-0 justify-end gap-2 text-sm text-foreground", split ? "flex-1" : "shrink-0", centered ? "items-center self-center" : "items-start self-stretch pt-[3px]")}>{children}</div>
@@ -73,6 +74,10 @@ function CardFooter({ className, children, ...rest }: CardFooterProps) {
73
74
  );
74
75
  }
75
76
 
76
- /** Settings surface — title outside, rows inside, caption underneath. */
77
+ /**
78
+ * Settings surface — title outside, rows inside, caption underneath.
79
+ * Each `Card.Item` is a settings row: `label` + `description` on the left, the control (Switch, Button, Select) as children on the right.
80
+ * Stack several cards with `gap-10` between sections.
81
+ */
77
82
  export const Card = Object.assign(CardRoot, { Item: CardItem, Footer: CardFooter });
78
83
  export { CardFooter, CardItem };
@@ -31,7 +31,7 @@ export type AgentPanelProps = {
31
31
  triggers?: ChatTrigger[];
32
32
  /** Imperative composer handle, e.g. `insertChip` to add a text selection as context. */
33
33
  inputRef?: Ref<ChatInputHandle>;
34
- /** Extra tool cards keyed by stream `toolName`. Checked before builtins. */
34
+ /** Tool cards keyed by stream `toolName`. Unmatched tools render `ChatToolCall`. */
35
35
  toolUis?: AgentToolUI[];
36
36
  /** Fence language → component for assistant markdown (`step`, `subagent`, `mindmap`). */
37
37
  components?: MarkdownComponents;
package/src/chat/index.ts CHANGED
@@ -35,12 +35,8 @@ export { BackgroundTasksBar } from "./tool-ui/BackgroundTasksBar";
35
35
  export { BackgroundTaskToolUI } from "./tool-ui/BackgroundTaskToolUI";
36
36
  export type { ChatToolCallProps } from "./tool-ui/ChatToolCall";
37
37
  export { ChatToolCall } from "./tool-ui/ChatToolCall";
38
- export { GetCurrentTimeToolUI } from "./tool-ui/GetCurrentTimeToolUI";
39
- export { ReadSkillToolUI } from "./tool-ui/ReadSkillToolUI";
40
- export { RunJsToolUI } from "./tool-ui/RunJsToolUI";
41
38
  export type { AgentToolUI, AgentToolUIName } from "./tool-ui/registry";
42
- export { builtinToolUis, matchesToolUIName, resolveToolUI } from "./tool-ui/registry";
39
+ export { matchesToolUIName, resolveToolUI } from "./tool-ui/registry";
43
40
  export { ToolUiTrailing } from "./tool-ui/ToolUiTrailing";
44
41
  export type { ChatToolMessage, ToolUIProps } from "./tool-ui/types";
45
42
  export { isToolRunning } from "./tool-ui/types";
46
- export { WebFetchToolUI } from "./tool-ui/WebFetchToolUI";
@@ -13,7 +13,7 @@ export function ChatError({ children, className }: ChatErrorProps) {
13
13
  <div className={cn("nonla-chat-error px-4 py-1", chatRowClass, className)}>
14
14
  <div
15
15
  role="alert"
16
- className="flex items-center gap-2 rounded-lg border border-destructive/40 bg-[color-mix(in_oklab,var(--destructive)_14%,var(--nonla-surface))] px-3 py-2 text-sm text-destructive"
16
+ className="flex items-center gap-2 rounded-lg border border-destructive-border bg-destructive-bg px-3 py-2 text-sm text-destructive"
17
17
  >
18
18
  <Icon name="error" size={16} className="shrink-0" />
19
19
  <div className="min-w-0">{children}</div>
@@ -160,7 +160,7 @@ const DEFAULT_CHIP_COLOR = "#c9841a";
160
160
  const NEUTRAL_CHIP_COLOR = "#71717a";
161
161
  const HEX_COLOR = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
162
162
 
163
- const chipClass = "mx-px inline max-w-full truncate rounded-[4px] px-1 align-middle text-xs leading-4 text-white";
163
+ const chipClass = "mx-px inline max-w-full truncate rounded-xs px-1 align-middle text-xs leading-4 text-white";
164
164
 
165
165
  function paintComposer(root: HTMLElement, parts: readonly ComposerPart[]) {
166
166
  const frag = document.createDocumentFragment();
@@ -525,8 +525,8 @@ export function ChatInput({ inputRef, generating = false, placeholder = "Message
525
525
  <div className="flex-1" />
526
526
 
527
527
  {generating ? (
528
- <button type="button" onClick={onCancel} title="Stop" className="w-6 h-6 rounded-full bg-brand text-(--nonla-text-on-solid) flex items-center justify-center shrink-0 cursor-pointer hover:bg-brand/90 active:scale-95 transition-all duration-100 border-0">
529
- <Icon name="stop" size={12} />
528
+ <button type="button" onClick={onCancel} title="Stop" className="w-6 h-6 rounded-full bg-brand text-(--nonla-text-on-brand) flex items-center justify-center shrink-0 cursor-pointer hover:bg-brand/90 active:scale-[0.97] transition-[background-color,transform] duration-(--nonla-dur-instant) border-0">
529
+ <Icon name="stop" size={16} />
530
530
  <span className="sr-only">Stop</span>
531
531
  </button>
532
532
  ) : (
@@ -535,7 +535,7 @@ export function ChatInput({ inputRef, generating = false, placeholder = "Message
535
535
  disabled={!canSend}
536
536
  onClick={handleSend}
537
537
  title="Send (Enter)"
538
- className={cn("w-6 h-6 rounded-full flex items-center justify-center shrink-0 transition-all duration-100 border-0", canSend ? "bg-foreground text-background cursor-pointer" : "bg-border text-muted-foreground cursor-not-allowed opacity-50")}
538
+ className={cn("w-6 h-6 rounded-full flex items-center justify-center shrink-0 transition-[background-color,color,transform] duration-(--nonla-dur-instant) border-0", canSend ? "bg-foreground text-background cursor-pointer" : "bg-border text-muted-foreground cursor-not-allowed opacity-50")}
539
539
  >
540
540
  <Icon name="arrow-up" size={14} />
541
541
  <span className="sr-only">Send</span>
@@ -51,7 +51,7 @@ export function ChatThinking({ thinking, duration = 0, streaming = false, classN
51
51
  >
52
52
  <summary className={cn(chatToolLineClass, "cursor-pointer list-none font-medium select-none [&::-webkit-details-marker]:hidden")}>
53
53
  <Shimmer active={streaming} className="text-muted-foreground">{label}</Shimmer>
54
- <Icon name="arrow-right" size={12} className="shrink-0 opacity-0 text-muted-foreground transition-[opacity,transform] duration-150 group-hover/thinking:opacity-100 group-open/thinking:opacity-100 group-open/thinking:rotate-90" />
54
+ <Icon name="arrow-right" size={12} className="shrink-0 opacity-0 text-muted-foreground transition-[opacity,transform] group-hover/thinking:opacity-100 group-open/thinking:opacity-100 group-open/thinking:rotate-90" />
55
55
  </summary>
56
56
 
57
57
  <div ref={bodyRef} className="pt-2 max-h-40 min-w-0 overflow-y-auto overflow-x-hidden mb-2 text-sm">
@@ -29,8 +29,8 @@ export function ChatUserMessage({ content, className }: ChatUserMessageProps) {
29
29
  return (
30
30
  <div
31
31
  className={cn(
32
- "nonla-chat-user relative isolate mx-4 mt-8 mb-3 overflow-hidden rounded-xl border border-solid border-(--nonla-input) bg-muted-strong px-3 py-1.5",
33
- "[.light:not(.dark)_&]:bg-sidebar [.light_.nonla-ui:not(.dark)_&]:bg-sidebar",
32
+ // Borderless wash and roomy padding, like Claude desktop. `bg-bar` is #f2f2f2 in light and follows the mode.
33
+ "nonla-chat-user relative isolate mx-4 mt-8 mb-3 overflow-hidden rounded-xl bg-bar px-4 py-2.5",
34
34
  className,
35
35
  )}
36
36
  >
@@ -55,7 +55,7 @@ export function ChatUserMessage({ content, className }: ChatUserMessageProps) {
55
55
  }}
56
56
  className="flex w-full cursor-pointer items-center justify-center border-0 bg-transparent pt-1 text-muted-foreground hover:text-foreground"
57
57
  >
58
- <Icon name="arrow-down" size={12} className={cn("transition-transform duration-200", isExpanded && "rotate-180")} />
58
+ <Icon name="arrow-down" size={12} className={cn("transition-transform duration-(--nonla-dur)", isExpanded && "rotate-180")} />
59
59
  </button>
60
60
  ) : null}
61
61
  </div>
@@ -31,9 +31,9 @@ export function ChatWelcome({ name, description, avatar, starters = [...DEFAULT_
31
31
  <div className={cn("nonla-chat-welcome flex flex-col items-center justify-center min-h-full w-full px-6 py-10 text-center", className)}>
32
32
  <div className="mb-5">{avatar ?? <DefaultAvatar name={name} />}</div>
33
33
 
34
- <h2 className="m-0 text-[22px] font-semibold tracking-tight text-foreground leading-snug">Hi, I&apos;m {name}</h2>
34
+ <h2 className="m-0 text-xl font-semibold tracking-tight text-foreground leading-snug">Hi, I&apos;m {name}</h2>
35
35
 
36
- {desc ? <p className="mt-2 mb-0 max-w-90 text-[13px] leading-relaxed text-tertiary-foreground line-clamp-2">{desc}</p> : <p className="mt-2 mb-0 max-w-[320px] text-[13px] leading-relaxed text-tertiary-foreground">Send a message to start working together.</p>}
36
+ {desc ? <p className="mt-2 mb-0 max-w-90 text-sm leading-relaxed text-tertiary-foreground line-clamp-2">{desc}</p> : <p className="mt-2 mb-0 max-w-[320px] text-sm leading-relaxed text-tertiary-foreground">Send a message to start working together.</p>}
37
37
 
38
38
  {starters.length > 0 && onStarter ? (
39
39
  <div className="mt-8 flex flex-wrap items-center justify-center gap-2 max-w-130">