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
@@ -188,9 +188,9 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
188
188
 
189
189
  if (error) {
190
190
  return (
191
- <div className={cn("my-3 rounded-lg bg-brand/14 border border-destructive/30 p-4 text-xs text-destructive", className)}>
191
+ <div className={cn("my-3 rounded-lg bg-destructive-bg border border-destructive-border p-4 text-xs text-destructive", className)}>
192
192
  <p className="font-medium mb-1">Mermaid render error</p>
193
- <pre className="whitespace-pre-wrap text-[11px] opacity-70">{error}</pre>
193
+ <pre className="whitespace-pre-wrap text-xs text-muted-foreground">{error}</pre>
194
194
  </div>
195
195
  );
196
196
  }
@@ -210,7 +210,7 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
210
210
 
211
211
  <dialog
212
212
  ref={dialogRef}
213
- className="inset-2.5 m-0 h-auto w-auto max-h-none max-w-none overflow-hidden rounded-xl border border-foreground/25 bg-card p-0 shadow-xl backdrop:bg-black/40 open:flex open:flex-col"
213
+ className="inset-2.5 m-0 h-auto w-auto max-h-none max-w-none overflow-hidden rounded-xl border border-border bg-card p-0 shadow-(--nonla-shadow) backdrop:bg-black/40 open:flex open:flex-col"
214
214
  onClose={resetView}
215
215
  onKeyDown={(e) => {
216
216
  if (e.key !== "Escape") return;
@@ -219,14 +219,14 @@ export function MermaidBlock({ children, className }: MermaidBlockProps) {
219
219
  closeFullscreen();
220
220
  }}
221
221
  >
222
- <div className="absolute top-5 right-5 z-50 flex items-center gap-1.5">
222
+ <div className="absolute top-5 right-5 z-10 flex items-center gap-1.5">
223
223
  <Button size="small" icon={<Icon name="download" size={12} />} title="Download SVG" aria-label="Download SVG" onClick={downloadSvg} disabled={!svgContent} />
224
224
  <Button size="small" icon={<Icon name="minimize" size={12} />} title="Exit fullscreen" onClick={closeFullscreen}>
225
225
  Exit
226
226
  </Button>
227
227
  </div>
228
228
 
229
- <div className="absolute bottom-5 left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-full border border-border bg-card px-3 py-1.5 text-xs text-muted-foreground shadow-md select-none">
229
+ <div className="absolute bottom-5 left-1/2 z-10 flex -translate-x-1/2 items-center gap-2 rounded-full border border-border bg-card px-3 py-1.5 text-xs text-muted-foreground shadow-(--nonla-shadow) select-none">
230
230
  <span>{Math.round(zoom * 100)}%</span>
231
231
  {!isDefaultView ? (
232
232
  <Button type="text" size="small" onClick={resetView}>
@@ -56,7 +56,7 @@ export function ReactCodeFrame({ title, icon, showHeader = true, code, className
56
56
  aria-expanded={open}
57
57
  aria-label={codeLabel}
58
58
  className={cn(
59
- "inline-flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/55",
59
+ "inline-flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors hover:bg-ink-hover active:bg-ink-active hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring",
60
60
  open ? "bg-muted text-foreground" : "text-muted-foreground",
61
61
  )}
62
62
  onClick={() => setOpen((value) => !value)}
package/src/menu/Menu.tsx CHANGED
@@ -42,13 +42,13 @@ export function MenuTrigger({ active, open, className, children, ...rest }: Menu
42
42
  aria-current={active ? "true" : undefined}
43
43
  className={cn(
44
44
  "inline-flex h-7 max-w-44 items-center gap-0.5 rounded-md border-0 bg-transparent px-2.5 text-sm font-medium leading-5 cursor-pointer",
45
- active || open ? "bg-ink-active text-foreground" : "text-foreground/85 hover:bg-ink-hover hover:text-foreground",
45
+ active || open ? "bg-ink-active text-foreground" : "text-foreground hover:bg-ink-hover",
46
46
  className,
47
47
  )}
48
48
  {...rest}
49
49
  >
50
50
  <span className="min-w-0 truncate leading-5">{children}</span>
51
- <Icon name="arrow-down" size={12} className={cn("shrink-0 transition-transform duration-150", open && "rotate-180")} />
51
+ <Icon name="arrow-down" size={12} className={cn("shrink-0 transition-transform duration-(--nonla-dur)", open && "rotate-180")} />
52
52
  </button>
53
53
  );
54
54
  }
@@ -45,8 +45,8 @@ const timers = new Map<string, number>();
45
45
  function IconSuccess() {
46
46
  return (
47
47
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
48
- <circle cx="8" cy="8" r="8" fill="var(--success)" />
49
- <path d="M4.6 8.15L6.85 10.3L11.4 5.7" stroke="var(--nonla-bg)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
48
+ <circle cx="8" cy="8" r="8" fill="var(--nonla-success-fill)" />
49
+ <path d="M4.6 8.15L6.85 10.3L11.4 5.7" stroke="var(--nonla-text-on-success)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
50
50
  </svg>
51
51
  );
52
52
  }
@@ -54,8 +54,8 @@ function IconSuccess() {
54
54
  function IconError() {
55
55
  return (
56
56
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
57
- <circle cx="8" cy="8" r="8" fill="var(--destructive)" />
58
- <path d="M5.4 5.4L10.6 10.6M10.6 5.4L5.4 10.6" stroke="var(--nonla-text-on-solid)" strokeWidth="1.6" strokeLinecap="round" />
57
+ <circle cx="8" cy="8" r="8" fill="var(--nonla-danger-fill)" />
58
+ <path d="M5.4 5.4L10.6 10.6M10.6 5.4L5.4 10.6" stroke="var(--nonla-text-on-danger)" strokeWidth="1.6" strokeLinecap="round" />
59
59
  </svg>
60
60
  );
61
61
  }
@@ -64,7 +64,7 @@ function IconInfo() {
64
64
  return (
65
65
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
66
66
  <circle cx="8" cy="8" r="8" fill="var(--link)" />
67
- <path d="M8 7.1V11.2M8 4.8V5.5" stroke="var(--nonla-text-on-solid)" strokeWidth="1.7" strokeLinecap="round" />
67
+ <path d="M8 7.1V11.2M8 4.8V5.5" stroke="var(--nonla-bg)" strokeWidth="1.7" strokeLinecap="round" />
68
68
  </svg>
69
69
  );
70
70
  }
@@ -72,8 +72,8 @@ function IconInfo() {
72
72
  function IconWarning() {
73
73
  return (
74
74
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
75
- <circle cx="8" cy="8" r="8" fill="var(--warn)" />
76
- <path d="M8 4.6V8.8M8 10.8V11.4" stroke="var(--nonla-bg)" strokeWidth="1.7" strokeLinecap="round" />
75
+ <circle cx="8" cy="8" r="8" fill="var(--nonla-warn-fill)" />
76
+ <path d="M8 4.6V8.8M8 10.8V11.4" stroke="var(--nonla-text-on-warn)" strokeWidth="1.7" strokeLinecap="round" />
77
77
  </svg>
78
78
  );
79
79
  }
@@ -111,7 +111,7 @@ function MessageList({ list }: { list: Active[] }) {
111
111
  className={cn(
112
112
  glassSurfaceClass,
113
113
  "nonla-message-item pointer-events-auto inline-flex items-center gap-2 rounded-(--radius) px-3 py-[9px] text-sm leading-[1.5714] will-change-[transform,opacity] animate-[nonla-message-in_var(--nonla-dur)_var(--nonla-ease-out)]",
114
- item.leaving && "animate-[nonla-message-out_150ms_var(--nonla-ease-in)_forwards]",
114
+ item.leaving && "animate-[nonla-message-out_var(--nonla-dur-fast)_var(--nonla-ease-in)_forwards]",
115
115
  item.className,
116
116
  )}
117
117
  data-type={item.type}
@@ -195,9 +195,9 @@ function ModalView({
195
195
  >
196
196
  {(title || closable) && (
197
197
  <div className="nonla-modal-header flex shrink-0 items-center justify-between gap-3 bg-transparent px-4 py-3" style={styles?.header}>
198
- <Dialog.Title className="nonla-modal-title m-0 text-[15px] leading-[1.4] font-semibold text-foreground">{title}</Dialog.Title>
198
+ <Dialog.Title className="nonla-modal-title m-0 text-lg leading-snug font-semibold text-foreground">{title}</Dialog.Title>
199
199
  {closable ? (
200
- <Dialog.Close className="nonla-modal-close -mt-1 -mr-1.5 -mb-1 ml-0 inline-flex size-7 cursor-pointer items-center justify-center rounded-(--radius) border-0 bg-transparent text-[18px] leading-none text-muted-foreground hover:bg-muted hover:text-foreground" aria-label="Close">
200
+ <Dialog.Close className="nonla-modal-close -mt-1 -mr-1.5 -mb-1 ml-0 inline-flex size-7 cursor-pointer items-center justify-center rounded-(--radius) border-0 bg-transparent text-[18px] leading-none text-muted-foreground hover:bg-ink-hover active:bg-ink-active hover:text-foreground" aria-label="Close">
201
201
  ×
202
202
  </Dialog.Close>
203
203
  ) : null}
@@ -0,0 +1,33 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ import { cn } from "../lib/cn";
3
+
4
+ export type PageHeaderProps = Omit<HTMLAttributes<HTMLElement>, "title"> & {
5
+ title: ReactNode;
6
+ /** Muted line under the title. */
7
+ description?: ReactNode;
8
+ /** Beside the title: a docs link, a status tag. */
9
+ meta?: ReactNode;
10
+ /** Right side: page actions (buttons, a date range). */
11
+ extra?: ReactNode;
12
+ /** Full-width hairline under the header. Default `true`. */
13
+ bordered?: boolean;
14
+ };
15
+
16
+ /** Page title row — title, meta, description, and actions on the right, over a hairline. */
17
+ export function PageHeader({ title, description, meta, extra, bordered = true, className, children, ...rest }: PageHeaderProps) {
18
+ return (
19
+ <header className={cn("flex flex-col gap-4 pb-5", bordered && "border-b border-solid border-border", className)} {...rest}>
20
+ <div className="flex flex-wrap items-start justify-between gap-x-6 gap-y-3">
21
+ <div className="flex min-w-0 flex-1 basis-64 flex-col gap-1">
22
+ <div className="flex min-w-0 flex-wrap items-center gap-2">
23
+ <h1 className="m-0 text-lg leading-7 font-semibold text-foreground">{title}</h1>
24
+ {meta}
25
+ </div>
26
+ {description != null && description !== "" ? <p className="m-0 text-sm text-muted-foreground">{description}</p> : null}
27
+ </div>
28
+ {extra != null ? <div className="flex shrink-0 items-center gap-2">{extra}</div> : null}
29
+ </div>
30
+ {children}
31
+ </header>
32
+ );
33
+ }
@@ -115,7 +115,7 @@ function ItemBtn({
115
115
  className={cn(
116
116
  "group inline-flex min-w-0 cursor-pointer items-center justify-center px-1.5 tabular-nums select-none",
117
117
  "transition-colors disabled:cursor-not-allowed disabled:opacity-40",
118
- active ? "bg-brand font-medium text-(--nonla-text-on-solid)" : "text-muted-foreground hover:bg-ink-hover hover:text-foreground",
118
+ active ? "bg-selected font-medium text-on-selected" : "text-muted-foreground hover:bg-ink-hover hover:text-foreground",
119
119
  className,
120
120
  )}
121
121
  style={{
@@ -185,7 +185,7 @@ function MiniField({
185
185
  }
186
186
  }}
187
187
  className={cn(
188
- "text-center tabular-nums text-foreground placeholder:text-quaternary-foreground",
188
+ "text-center tabular-nums text-foreground placeholder:text-tertiary-foreground",
189
189
  controlFieldSurface,
190
190
  controlFieldTransition,
191
191
  controlFieldFocusBorder,
@@ -562,7 +562,7 @@ function JumperField({
562
562
  }
563
563
  }}
564
564
  className={cn(
565
- "text-center tabular-nums text-foreground placeholder:text-quaternary-foreground",
565
+ "text-center tabular-nums text-foreground placeholder:text-tertiary-foreground",
566
566
  controlFieldSurface,
567
567
  controlFieldTransition,
568
568
  controlFieldFocusBorder,
@@ -12,7 +12,7 @@ export type PopconfirmProps = {
12
12
  onCancel?: () => void;
13
13
  okText?: ReactNode;
14
14
  cancelText?: ReactNode;
15
- okType?: "primary" | "default" | "dashed" | "link" | "text" | "danger";
15
+ okType?: "primary" | "default" | "link" | "text" | "danger";
16
16
  okButtonProps?: { danger?: boolean; type?: string; color?: string; variant?: string };
17
17
  cancelButtonProps?: Record<string, unknown>;
18
18
  /** Customize / hide the leading icon. Pass `null` to hide. */
@@ -90,7 +90,7 @@ export function Popconfirm({
90
90
  {showIcon ? <span className="nonla-popconfirm-icon">{resolvedIcon}</span> : null}
91
91
  <div className="min-w-0 flex-1">
92
92
  {title != null && title !== false ? <div className="text-sm font-medium leading-snug text-foreground">{title}</div> : null}
93
- {description != null && description !== false ? <div className={cn("text-[13px] leading-snug text-muted-foreground", title != null && title !== false && "mt-1")}>{description}</div> : null}
93
+ {description != null && description !== false ? <div className={cn("text-sm leading-snug text-muted-foreground", title != null && title !== false && "mt-1")}>{description}</div> : null}
94
94
  </div>
95
95
  </div>
96
96
  <div className="mt-3 flex justify-end gap-2">
@@ -109,7 +109,7 @@ export function Popconfirm({
109
109
  ) : null}
110
110
  <Button
111
111
  size="small"
112
- type={okBtnType as "primary" | "default" | "dashed" | "link" | "text"}
112
+ type={okBtnType as "primary" | "default" | "link" | "text"}
113
113
  danger={okDanger}
114
114
  loading={loading}
115
115
  onClick={async () => {
@@ -150,7 +150,7 @@ export function OverlayScroll({ visibility = "hover", scope = "scroll", autoHeig
150
150
 
151
151
  const thumbVisible = visibility === "always" || dragging || scrolling;
152
152
  const thumbClass = cn(
153
- "absolute z-20 rounded-full bg-(--nonla-scrollbar-thumb) transition-opacity duration-150",
153
+ "absolute z-20 rounded-full bg-(--nonla-scrollbar-thumb) transition-opacity",
154
154
  scope === "table" ? "group-hover/table:bg-(--nonla-scrollbar-thumb-hover)" : "group-hover/scroll:bg-(--nonla-scrollbar-thumb-hover)",
155
155
  visibility === "always" || dragging
156
156
  ? "pointer-events-auto opacity-100"
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, useLayoutEffect, useRef, useState } from "react";
2
- import { cn } from "../lib/cn";
2
+ import { cn, focusRing } from "../lib/cn";
3
3
  import { type ControlSize, controlHeightVar, controlRadiusVar, getSizeTokens, useControlSize } from "../lib/sizes";
4
4
 
5
5
  export type SegmentedOption<V extends string | number = string | number> = V | { label: ReactNode; value: V; disabled?: boolean; icon?: ReactNode };
@@ -24,7 +24,10 @@ type Thumb = { left: number; top: number; width: number; height: number };
24
24
 
25
25
  export function Segmented<V extends string | number = string | number>({ options, value, defaultValue, onChange, size, block, disabled, className }: SegmentedProps<V>) {
26
26
  const items = options.map((o) => norm(o));
27
- const current = value ?? defaultValue ?? items[0]?.value;
27
+ // Uncontrolled when `value` is unset: keep the pick locally so a click moves the selection.
28
+ const [inner, setInner] = useState<V | undefined>(defaultValue);
29
+ const controlled = value !== undefined;
30
+ const current = (controlled ? value : inner) ?? items[0]?.value;
28
31
  const resolvedSize = useControlSize(size);
29
32
  const tok = getSizeTokens(resolvedSize);
30
33
  const itemPadX = Math.max(tok.paddingInline - 4, 6);
@@ -60,7 +63,7 @@ export function Segmented<V extends string | number = string | number>({ options
60
63
  <div
61
64
  ref={rootRef}
62
65
  className={cn(
63
- "relative inline-flex w-fit max-w-full shrink-0 items-center gap-0.5 rounded-lg border border-solid border-border bg-muted p-0.5",
66
+ "relative inline-flex w-fit max-w-full shrink-0 items-center gap-0.5 rounded-lg bg-(--nonla-pill-track) p-0.5",
64
67
  block && "flex w-full",
65
68
  className,
66
69
  )}
@@ -71,7 +74,7 @@ export function Segmented<V extends string | number = string | number>({ options
71
74
  {thumb ? (
72
75
  <span
73
76
  aria-hidden
74
- className="nonla-segmented-thumb pointer-events-none absolute top-0 left-0 border border-solid border-border bg-card transition-[transform,width,height] duration-380 ease-[cubic-bezier(0.3,1.25,0.5,1)] motion-reduce:transition-none"
77
+ className="nonla-segmented-thumb pointer-events-none absolute top-0 left-0 bg-card shadow-(--nonla-pill-thumb-shadow) transition-[transform,width,height] duration-(--nonla-dur-slow) ease-(--nonla-ease-spring) motion-reduce:transition-none"
75
78
  style={{
76
79
  width: thumb.width,
77
80
  height: thumb.height,
@@ -94,9 +97,12 @@ export function Segmented<V extends string | number = string | number>({ options
94
97
  aria-selected={active}
95
98
  disabled={disabled || item.disabled}
96
99
  className={cn(
97
- "relative z-10 inline-flex cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border border-solid border-transparent transition-colors focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",
100
+ "relative z-10 inline-flex cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap border-0 bg-transparent font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-45",
101
+ focusRing,
102
+ "focus-visible:ring-offset-0",
98
103
  block ? "min-w-0 flex-1" : "shrink-0",
99
- active ? "text-foreground" : "bg-transparent text-foreground hover:bg-ink-hover",
104
+ // Cloudflare-style: idle labels are muted and only brighten on hover; the raised thumb marks the pick.
105
+ active ? "text-foreground" : "text-muted-foreground hover:text-foreground",
100
106
  )}
101
107
  style={{
102
108
  height: `max(22px, calc(${controlHeightVar(resolvedSize)} - 4px))`,
@@ -105,7 +111,10 @@ export function Segmented<V extends string | number = string | number>({ options
105
111
  fontSize: tok.fontSize,
106
112
  borderRadius: `max(4px, calc(${radius} - 2px))`,
107
113
  }}
108
- onClick={() => onChange?.(item.value)}
114
+ onClick={() => {
115
+ if (!controlled) setInner(item.value);
116
+ onChange?.(item.value);
117
+ }}
109
118
  >
110
119
  {item.icon}
111
120
  {item.label}
@@ -14,6 +14,7 @@ import {
14
14
  } from "react";
15
15
  import { usePopupContainer } from "../app/context";
16
16
  import { menuItemClass } from "../dropdown/menuClasses";
17
+ import { Icon } from "../icon/Icon";
17
18
  import { cn } from "../lib/cn";
18
19
  import { type ControlSize, controlFieldFocusBorder, controlFieldStyle, controlFieldSurface, controlFieldTransition, controlStatusClass, useControlSize } from "../lib/sizes";
19
20
  import { glassOverlayClass } from "../lib/surface";
@@ -21,9 +22,12 @@ import { glassOverlayClass } from "../lib/surface";
21
22
  export type SelectValue = string | number;
22
23
 
23
24
  export type SelectOptionConfig = {
25
+ /** Shown in the list and in the trigger. */
24
26
  label: ReactNode;
25
27
  value: SelectValue;
26
28
  disabled?: boolean;
29
+ /** Muted second line, in the list only (the trigger keeps one line). Search matches it too. */
30
+ description?: ReactNode;
27
31
  };
28
32
 
29
33
  export type SelectProps = {
@@ -44,9 +48,12 @@ export type SelectProps = {
44
48
  status?: "error" | "warning";
45
49
  className?: string;
46
50
  popupClassName?: string;
51
+ /** @deprecated Not parsed; pass `options`. Kept so antd-style markup type-checks. */
47
52
  children?: ReactNode;
48
53
  /** Alias of `onChange` for a single pick. */
49
54
  onSelect?: (value: SelectValue) => void;
55
+ /** Custom row content in the list (any height). The trigger still shows `label`. Extra fields you put on an option (email, role) come through. */
56
+ optionRender?: (option: SelectOptionConfig & Record<string, any>, info: { selected: boolean }) => ReactNode;
50
57
  };
51
58
 
52
59
  function Chevron() {
@@ -75,7 +82,7 @@ function textOf(node: ReactNode): string {
75
82
 
76
83
  function optionSearchText(opt: SelectOptionConfig, prop: string): string {
77
84
  if (prop === "value") return String(opt.value);
78
- return textOf(opt.label) || String(opt.value);
85
+ return [textOf(opt.label) || String(opt.value), textOf(opt.description)].join(" ");
79
86
  }
80
87
 
81
88
  export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select(
@@ -94,6 +101,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
94
101
  status,
95
102
  className,
96
103
  popupClassName,
104
+ optionRender,
97
105
  },
98
106
  ref,
99
107
  ) {
@@ -112,8 +120,9 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
112
120
  const portal = usePopupContainer()?.();
113
121
 
114
122
  const searchable = Boolean(showSearch);
123
+ // Search what the user sees: the label (falls back to value when the label is not text).
115
124
  const filterProp =
116
- typeof showSearch === "object" ? (showSearch.optionFilterProp ?? "value") : "value";
125
+ typeof showSearch === "object" ? (showSearch.optionFilterProp ?? "label") : "label";
117
126
 
118
127
  const selectedOpt = options.find((o) => o.value === selected);
119
128
 
@@ -243,6 +252,8 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
243
252
  const showClear = allowClear && selected != null && selected !== "" && !disabled;
244
253
  const display = selectedOpt ? selectedOpt.label : selected != null && selected !== "" ? String(selected) : placeholder;
245
254
  const displayEmpty = !selectedOpt && (selected == null || selected === "");
255
+ // A rich label (icon + text) is an element: lay it out as a centered flex row, not inline on the text baseline.
256
+ const richDisplay = isValidElement(display);
246
257
  const activeId = open && filtered[active] ? `${listId}-opt-${active}` : undefined;
247
258
 
248
259
  const fieldClass = cn(
@@ -283,8 +294,9 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
283
294
  }}
284
295
  >
285
296
  <div className="relative min-w-0 flex-1 overflow-hidden">
286
- <span aria-hidden className={cn("block truncate", (open && query) || displayEmpty ? "invisible" : "")}>
287
- {displayEmpty ? placeholder : display}
297
+ {/* While searching, the current pick fades to plain text (no icon), so the caret starts cleanly before it. */}
298
+ <span aria-hidden className={cn(richDisplay && !open ? "flex h-5 items-center overflow-hidden whitespace-nowrap" : "block truncate", (open && query) || displayEmpty ? "invisible" : open && "text-tertiary-foreground")}>
299
+ {displayEmpty ? placeholder : open ? textOf(display) || display : display}
288
300
  </span>
289
301
  <input
290
302
  ref={searchRef}
@@ -307,42 +319,45 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
307
319
  }}
308
320
  onKeyDown={onSearchKey}
309
321
  className={cn(
310
- "absolute inset-0 w-full border-0 bg-transparent p-0 font-[inherit] leading-[inherit] text-inherit outline-none placeholder:text-quaternary-foreground",
322
+ "absolute inset-0 w-full border-0 bg-transparent p-0 font-[inherit] leading-[inherit] text-inherit outline-none placeholder:text-tertiary-foreground",
311
323
  !open && "caret-transparent",
312
324
  )}
313
325
  />
314
326
  </div>
315
- {showClear ? (
327
+ {/* One slot: the chevron, swapped for the clear button while hovered (no two icons side by side). */}
328
+ <span className="grid size-4 shrink-0 place-items-center">
329
+ {showClear ? (
330
+ <span
331
+ data-select-affix=""
332
+ role="button"
333
+ tabIndex={-1}
334
+ aria-label="Clear"
335
+ className="pointer-events-none inline-flex size-4 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity [grid-area:1/1] hover:text-foreground group-hover/select:pointer-events-auto group-hover/select:opacity-100"
336
+ onPointerDown={(e) => {
337
+ e.preventDefault();
338
+ e.stopPropagation();
339
+ }}
340
+ onClick={(e) => {
341
+ e.preventDefault();
342
+ e.stopPropagation();
343
+ commit(null);
344
+ }}
345
+ >
346
+ <ClearIcon />
347
+ </span>
348
+ ) : null}
316
349
  <span
317
350
  data-select-affix=""
318
- role="button"
319
- tabIndex={-1}
320
- aria-label="Clear"
321
- className="inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity hover:bg-ink-hover hover:text-foreground group-hover/select:opacity-100"
351
+ className={cn("inline-flex cursor-pointer items-center justify-center transition-opacity [grid-area:1/1]", showClear && "group-hover/select:opacity-0")}
322
352
  onPointerDown={(e) => {
323
353
  e.preventDefault();
324
354
  e.stopPropagation();
325
- }}
326
- onClick={(e) => {
327
- e.preventDefault();
328
- e.stopPropagation();
329
- commit(null);
355
+ if (disabled) return;
356
+ setOpen((v) => !v);
330
357
  }}
331
358
  >
332
- <ClearIcon />
359
+ <Chevron />
333
360
  </span>
334
- ) : null}
335
- <span
336
- data-select-affix=""
337
- className="inline-flex shrink-0 cursor-pointer"
338
- onPointerDown={(e) => {
339
- e.preventDefault();
340
- e.stopPropagation();
341
- if (disabled) return;
342
- setOpen((v) => !v);
343
- }}
344
- >
345
- <Chevron />
346
361
  </span>
347
362
  </div>
348
363
  </PopoverPrimitive.Anchor>
@@ -358,24 +373,28 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
358
373
  style={controlFieldStyle(resolvedSize)}
359
374
  onKeyDown={onTriggerKey}
360
375
  >
361
- <span className={cn("min-w-0 flex-1 truncate", displayEmpty && "text-quaternary-foreground")}>{display}</span>
362
- {showClear ? (
363
- <span
364
- role="button"
365
- tabIndex={-1}
366
- aria-label="Clear"
367
- className="inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity hover:bg-ink-hover hover:text-foreground group-hover/select:opacity-100"
368
- onPointerDown={(e) => e.preventDefault()}
369
- onClick={(e) => {
370
- e.preventDefault();
371
- e.stopPropagation();
372
- commit(null);
373
- }}
374
- >
375
- <ClearIcon />
376
+ <span className={cn("min-w-0 flex-1", richDisplay ? "flex h-5 items-center overflow-hidden whitespace-nowrap" : "truncate", displayEmpty && "text-tertiary-foreground")}>{display}</span>
377
+ <span className="grid size-4 shrink-0 place-items-center">
378
+ {showClear ? (
379
+ <span
380
+ role="button"
381
+ tabIndex={-1}
382
+ aria-label="Clear"
383
+ className="pointer-events-none inline-flex size-4 cursor-pointer items-center justify-center rounded-full text-muted-foreground opacity-0 transition-opacity [grid-area:1/1] hover:text-foreground group-hover/select:pointer-events-auto group-hover/select:opacity-100"
384
+ onPointerDown={(e) => e.preventDefault()}
385
+ onClick={(e) => {
386
+ e.preventDefault();
387
+ e.stopPropagation();
388
+ commit(null);
389
+ }}
390
+ >
391
+ <ClearIcon />
392
+ </span>
393
+ ) : null}
394
+ <span className={cn("inline-flex items-center justify-center transition-opacity [grid-area:1/1]", showClear && "group-hover/select:opacity-0")}>
395
+ <Chevron />
376
396
  </span>
377
- ) : null}
378
- <Chevron />
397
+ </span>
379
398
  </button>
380
399
  </PopoverPrimitive.Trigger>
381
400
  )}
@@ -426,7 +445,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
426
445
  data-highlighted={!opt.disabled && i === active && opt.value !== selected ? "" : undefined}
427
446
  className={cn(
428
447
  menuItemClass,
429
- "cursor-pointer transition-[background-color] duration-20 ease-in motion-reduce:transition-none data-highlighted:border-transparent data-highlighted:bg-ink-hover",
448
+ "cursor-pointer transition-none data-highlighted:border-transparent data-highlighted:bg-ink-hover",
430
449
  opt.disabled && "pointer-events-none opacity-40",
431
450
  !opt.disabled && opt.value === selected && "border-transparent bg-ink-active text-foreground shadow-none",
432
451
  )}
@@ -436,7 +455,17 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
436
455
  if (!opt.disabled) commit(opt.value);
437
456
  }}
438
457
  >
439
- {opt.label}
458
+ {optionRender ? (
459
+ <div className="min-w-0 flex-1">{optionRender(opt, { selected: opt.value === selected })}</div>
460
+ ) : opt.description != null ? (
461
+ <span className="flex min-w-0 flex-1 flex-col">
462
+ <span className="truncate">{opt.label}</span>
463
+ <span className="truncate text-xs leading-4 text-muted-foreground">{opt.description}</span>
464
+ </span>
465
+ ) : (
466
+ <span className="min-w-0 flex-1 truncate">{opt.label}</span>
467
+ )}
468
+ {opt.value === selected ? <Icon name="check" size={14} className="shrink-0 text-foreground" aria-hidden /> : null}
440
469
  </div>
441
470
  ))
442
471
  )}
@@ -7,6 +7,8 @@ import { OverlayScroll } from "../scroll/OverlayScroll";
7
7
  export type SidebarItemType = {
8
8
  key?: string;
9
9
  label?: ReactNode;
10
+ /** Muted second line under the label (context, owner, path). The row grows to two lines. */
11
+ description?: ReactNode;
10
12
  /** An `Icon` name, or a node. */
11
13
  icon?: ReactNode;
12
14
  disabled?: boolean;
@@ -46,7 +48,7 @@ function labelText(label: ReactNode) {
46
48
  }
47
49
 
48
50
  function matchesQuery(item: SidebarItemType, q: string) {
49
- return labelText(item.label).toLowerCase().includes(q);
51
+ return `${labelText(item.label)} ${labelText(item.description)}`.toLowerCase().includes(q);
50
52
  }
51
53
 
52
54
  /** A group label stays when it matches, or when a later row matches before the next group. */
@@ -109,15 +111,17 @@ function SidebarList({
109
111
  if (item.type === "group") {
110
112
  if (item.label == null || item.label === "") return null;
111
113
  return (
112
- <div key={key} className={cn("px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wider text-tertiary-foreground not-first:mt-2", item.className)}>
114
+ <div key={key} className={cn("px-3 pb-1 pt-3 text-xs font-medium text-muted-foreground not-first:mt-2", item.className)}>
113
115
  {item.label}
114
116
  </div>
115
117
  );
116
118
  }
117
119
 
118
120
  const active = selected != null && key === selected;
121
+ const twoLine = item.description != null && item.description !== "";
119
122
  const className = cn(
120
- "nonla-sidebar-item box-border flex h-(--nonla-height) w-full items-center gap-3 rounded-(--nonla-radius) border-0 bg-transparent px-3 text-left text-[14px] font-normal text-foreground no-underline transition-[background-color,box-shadow] duration-(--nonla-dur-fast) ease-(--nonla-ease-out) hover:not-aria-current:not-disabled:not-aria-disabled:bg-ink-hover hover:not-disabled:not-aria-disabled:shadow-none aria-current:bg-ink-active aria-current:shadow-none aria-[current=page]:bg-ink-active aria-[current=page]:shadow-none",
123
+ twoLine ? "min-h-(--nonla-height) py-1.5" : "h-(--nonla-height)",
124
+ "nonla-sidebar-item box-border flex w-full items-center gap-3 rounded-(--nonla-radius) border-0 bg-transparent px-3 text-left text-(length:--nonla-nav-text-size) font-medium text-foreground no-underline transition-[background-color,box-shadow] duration-(--nonla-dur-fast) ease-(--nonla-ease-out) hover:not-aria-current:not-disabled:not-aria-disabled:bg-ink-hover hover:not-disabled:not-aria-disabled:shadow-none aria-current:bg-ink-active aria-current:shadow-none aria-[current=page]:bg-ink-active aria-[current=page]:shadow-none",
121
125
  item.disabled ? "pointer-events-none cursor-not-allowed opacity-40" : "cursor-pointer",
122
126
  item.className,
123
127
  );
@@ -125,7 +129,14 @@ function SidebarList({
125
129
  const body = (
126
130
  <>
127
131
  <ItemIcon icon={item.icon} />
128
- <span className="min-w-0 flex-1 truncate">{item.label}</span>
132
+ {twoLine ? (
133
+ <span className="flex min-w-0 flex-1 flex-col">
134
+ <span className="truncate">{item.label}</span>
135
+ <span className="truncate text-xs text-tertiary-foreground">{item.description}</span>
136
+ </span>
137
+ ) : (
138
+ <span className="min-w-0 flex-1 truncate">{item.label}</span>
139
+ )}
129
140
  {item.extra != null ? <span className="shrink-0 text-sm tabular-nums text-muted-foreground">{item.extra}</span> : null}
130
141
  </>
131
142
  );
@@ -433,7 +433,7 @@ function FloatingDropLine({ root, hint }: { root: HTMLElement | null; hint: Drop
433
433
  const rect = faceRect(root, hint.overId);
434
434
  if (!rect) return null;
435
435
  const top = hint.edge === "top" ? rect.top : rect.bottom;
436
- return <span aria-hidden className="pointer-events-none fixed z-1100 h-0.5 rounded-full bg-foreground" style={{ top: top - 1, left: rect.left + 6, width: Math.max(0, rect.width - 12) }} />;
436
+ return <span aria-hidden className="pointer-events-none fixed z-(--nonla-z-popup) h-0.5 rounded-full bg-foreground" style={{ top: top - 1, left: rect.left + 6, width: Math.max(0, rect.width - 12) }} />;
437
437
  }
438
438
 
439
439
  function SortableNode<T>({
@@ -290,7 +290,7 @@ function SplitterRoot({
290
290
  >
291
291
  <span
292
292
  className={cn(
293
- "pointer-events-none absolute rounded-full transition-all",
293
+ "pointer-events-none absolute rounded-full transition-[width,height,background-color]",
294
294
  isVertical
295
295
  ? "inset-x-0 top-1/2 h-px -translate-y-1/2 group-hover:h-[3px] group-focus-visible:h-[3px]"
296
296
  : "inset-y-0 left-1/2 w-px -translate-x-1/2 group-hover:w-[3px] group-focus-visible:w-[3px]",