devnonla-ui 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -4
- package/package.json +3 -3
- package/src/app/App.tsx +5 -1
- package/src/app/context.ts +5 -3
- package/src/button/Button.tsx +2 -2
- package/src/button/ButtonCopy.tsx +2 -2
- package/src/card/Card.tsx +81 -0
- package/src/chat/AgentChatbox.tsx +1 -1
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/message-ui/ChatError.tsx +2 -2
- package/src/chat/message-ui/ChatInput.tsx +6 -6
- package/src/chat/message-ui/ChatMarkdown.tsx +8 -7
- package/src/chat/message-ui/ChatMarkdownTable.tsx +1 -1
- package/src/chat/message-ui/ChatThinking.tsx +3 -3
- package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
- package/src/chat/message-ui/MermaidBlock.tsx +76 -70
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +3 -3
- package/src/chat/tool-ui/CallAgentToolUI.tsx +3 -3
- package/src/chat/tool-ui/ChatToolCall.tsx +4 -4
- package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +2 -2
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +2 -2
- package/src/chat/tool-ui/RunJsToolUI.tsx +2 -2
- package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
- package/src/chat/tool-ui/WebFetchToolUI.tsx +2 -2
- package/src/checkbox/Checkbox.tsx +17 -4
- package/src/codeblock/CodeBlock.tsx +4 -10
- package/src/datepicker/DatePicker.tsx +3 -3
- package/src/desktop/DesktopHeader.tsx +1 -1
- package/src/desktop/DesktopIcon.tsx +2 -2
- package/src/desktop/DesktopWindow.tsx +51 -29
- package/src/empty/Empty.tsx +8 -5
- package/src/form/FormItem.tsx +1 -1
- package/src/form-layout/FormLayout.tsx +1 -1
- package/src/icon/SolarIcon.tsx +39 -0
- package/src/icon/solar.ts +172 -0
- package/src/index.ts +24 -12
- package/src/input/EditableInput.tsx +3 -3
- package/src/input/Input.tsx +3 -3
- package/src/lib/sizes.ts +9 -6
- package/src/lib/surface.ts +1 -1
- package/src/markdown-editor/MarkdownDiff.tsx +211 -0
- package/src/markdown-editor/MarkdownEditor.tsx +294 -0
- package/src/markdown-editor/MarkdownPreview.tsx +326 -0
- package/src/markdown-editor/MarkdownSource.tsx +72 -0
- package/src/markdown-editor/blocks.ts +329 -0
- package/src/markdown-editor/diff.ts +296 -0
- package/src/menu/Menu.tsx +3 -3
- package/src/pagination/Pagination.tsx +8 -7
- package/src/scroll/OverlayScroll.tsx +2 -2
- package/src/segmented/Segmented.tsx +2 -2
- package/src/select/Select.tsx +192 -63
- package/src/sidebar/Sidebar.tsx +9 -8
- package/src/spin/Spin.tsx +17 -11
- package/src/styles.css +273 -107
- package/src/switch/Switch.tsx +17 -3
- package/src/table/Table.tsx +63 -28
- package/src/theme-toggle/ThemeToggle.tsx +33 -0
- package/src/theme.ts +72 -0
- package/src/timepicker/TimePicker.tsx +1 -1
- package/src/icon/FluentIcon.tsx +0 -28
- package/src/icon/fluent.ts +0 -75
|
@@ -38,7 +38,7 @@ function isEditableTarget(target: EventTarget | null) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function hasOpenDialog() {
|
|
41
|
-
return Boolean(document.querySelector('[role="dialog"][data-state="open"], .nonla-modal-content'));
|
|
41
|
+
return Boolean(document.querySelector('dialog[open], [role="dialog"][data-state="open"], .nonla-modal-content'));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function originFromActiveIcon(overlay: HTMLElement, frame: HTMLElement) {
|
|
@@ -55,7 +55,7 @@ function originFromActiveIcon(overlay: HTMLElement, frame: HTMLElement) {
|
|
|
55
55
|
function compactSize(view: Size): Size {
|
|
56
56
|
return {
|
|
57
57
|
w: Math.min(window.innerWidth * 0.8, view.w),
|
|
58
|
-
h: Math.max(0, view.h -
|
|
58
|
+
h: Math.max(0, view.h - 40),
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -256,6 +256,29 @@ function TrafficLight({
|
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
function WindowTraffic({
|
|
260
|
+
expanded,
|
|
261
|
+
floating,
|
|
262
|
+
onClose,
|
|
263
|
+
onToggleExpand,
|
|
264
|
+
}: {
|
|
265
|
+
expanded: boolean;
|
|
266
|
+
floating?: boolean;
|
|
267
|
+
onClose: () => void;
|
|
268
|
+
onToggleExpand: () => void;
|
|
269
|
+
}) {
|
|
270
|
+
return (
|
|
271
|
+
<div className={cn("group/traffic flex shrink-0 items-center gap-2", floating && "absolute top-3 left-3 z-20")}>
|
|
272
|
+
<TrafficLight label="Close window" tone="close" onClick={onClose} shortcut="Esc">
|
|
273
|
+
<GlyphClose />
|
|
274
|
+
</TrafficLight>
|
|
275
|
+
<TrafficLight label={expanded ? "Restore window" : "Expand window"} tone="expand" onClick={onToggleExpand} shortcut="Shift + ↑">
|
|
276
|
+
<GlyphExpand restore={expanded} />
|
|
277
|
+
</TrafficLight>
|
|
278
|
+
</div>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
259
282
|
type WindowHeaderSlot = {
|
|
260
283
|
left: HTMLElement | null;
|
|
261
284
|
right: HTMLElement | null;
|
|
@@ -284,6 +307,8 @@ export type DesktopWindowProps = {
|
|
|
284
307
|
title?: ReactNode;
|
|
285
308
|
left?: ReactNode;
|
|
286
309
|
right?: ReactNode;
|
|
310
|
+
/** Title bar. `false` hides it so children fill the frame; close and expand stay pinned over the top-left. */
|
|
311
|
+
header?: boolean;
|
|
287
312
|
expanded: boolean;
|
|
288
313
|
onClose: () => void;
|
|
289
314
|
onToggleExpand: () => void;
|
|
@@ -299,6 +324,7 @@ export function DesktopWindow({
|
|
|
299
324
|
title,
|
|
300
325
|
left,
|
|
301
326
|
right,
|
|
327
|
+
header = true,
|
|
302
328
|
expanded,
|
|
303
329
|
onClose,
|
|
304
330
|
onToggleExpand,
|
|
@@ -579,34 +605,29 @@ export function DesktopWindow({
|
|
|
579
605
|
data-expanded={expanded || undefined}
|
|
580
606
|
className={cn("absolute flex flex-col rounded-xl pointer-events-auto transform-gpu", glassSurfaceClass, "nonla-window-glass", leaving && "pointer-events-none")}
|
|
581
607
|
>
|
|
582
|
-
<div className="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl">
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
<
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
<div
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
{typeof title === "string" ? <span className="min-w-0 truncate text-xs font-semibold leading-none text-foreground/90">{title}</span> : title}
|
|
603
|
-
</div>
|
|
604
|
-
<div className="flex shrink-0 items-center">
|
|
605
|
-
{right}
|
|
606
|
-
<div ref={setRightSlot} className="contents" />
|
|
608
|
+
<div className="relative flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl">
|
|
609
|
+
{header ? (
|
|
610
|
+
<header
|
|
611
|
+
onPointerDown={startDrag}
|
|
612
|
+
className="nonla-window-header flex h-9 shrink-0 cursor-default items-center gap-4 border-0 px-3 select-none touch-none"
|
|
613
|
+
>
|
|
614
|
+
<WindowTraffic expanded={expanded} onClose={requestClose} onToggleExpand={onToggleExpand} />
|
|
615
|
+
<div className="flex min-w-0 flex-1 items-center">
|
|
616
|
+
<div className="flex min-w-0 items-center">
|
|
617
|
+
{left}
|
|
618
|
+
<div ref={setLeftSlot} className="contents" />
|
|
619
|
+
</div>
|
|
620
|
+
{/* biome-ignore lint/a11y/noStaticElementInteractions: middle strip double-clicks to expand */}
|
|
621
|
+
<div onDoubleClick={onTitleBarDoubleClick} className="flex min-w-8 flex-1 items-center self-stretch px-2">
|
|
622
|
+
{typeof title === "string" ? <span className="min-w-0 truncate text-xs font-semibold leading-none text-foreground/90">{title}</span> : title}
|
|
623
|
+
</div>
|
|
624
|
+
<div className="flex shrink-0 items-center">
|
|
625
|
+
{right}
|
|
626
|
+
<div ref={setRightSlot} className="contents" />
|
|
627
|
+
</div>
|
|
607
628
|
</div>
|
|
608
|
-
</
|
|
609
|
-
|
|
629
|
+
</header>
|
|
630
|
+
) : null}
|
|
610
631
|
|
|
611
632
|
<div className="min-h-0 flex-1 overflow-hidden">
|
|
612
633
|
{scroll ? (
|
|
@@ -617,6 +638,7 @@ export function DesktopWindow({
|
|
|
617
638
|
children
|
|
618
639
|
)}
|
|
619
640
|
</div>
|
|
641
|
+
{header ? null : <WindowTraffic floating expanded={expanded} onClose={requestClose} onToggleExpand={onToggleExpand} />}
|
|
620
642
|
</div>
|
|
621
643
|
|
|
622
644
|
{!leaving
|
package/src/empty/Empty.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import { Card } from "../card/Card";
|
|
2
3
|
import { cn } from "../lib/cn";
|
|
3
4
|
|
|
4
5
|
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";
|
|
@@ -38,10 +39,12 @@ export type EmptyProps = {
|
|
|
38
39
|
|
|
39
40
|
export function Empty({ description = "No data", children, className }: EmptyProps) {
|
|
40
41
|
return (
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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>
|
|
46
49
|
);
|
|
47
50
|
}
|
package/src/form/FormItem.tsx
CHANGED
|
@@ -111,7 +111,7 @@ export function FormItem(props: FormItemProps) {
|
|
|
111
111
|
</svg>
|
|
112
112
|
</button>
|
|
113
113
|
) : null}
|
|
114
|
-
<div className="text-sm text-foreground">
|
|
114
|
+
<div className="text-sm font-medium text-foreground">
|
|
115
115
|
{label}
|
|
116
116
|
{required ? <span className="ml-1 text-destructive">*</span> : null}
|
|
117
117
|
</div>
|
|
@@ -53,7 +53,7 @@ function FormItem({
|
|
|
53
53
|
)}
|
|
54
54
|
>
|
|
55
55
|
{label != null && label !== false ? (
|
|
56
|
-
<div className={cn("text-sm text-foreground", layout === "horizontal" && "pt-1.5 shrink-0")}>
|
|
56
|
+
<div className={cn("text-sm font-medium text-foreground", layout === "horizontal" && "pt-1.5 shrink-0")}>
|
|
57
57
|
{label}
|
|
58
58
|
{required ? <span className="ml-1 text-destructive">*</span> : null}
|
|
59
59
|
</div>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
import { ensureSolarIcons, getSolarSvg } from "./solar";
|
|
4
|
+
|
|
5
|
+
export function SolarIcon({ name, size = 16, className }: { name: string; size?: number; className?: string }) {
|
|
6
|
+
const [svg, setSvg] = useState<string | null>(() => getSolarSvg(name));
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const cached = getSolarSvg(name);
|
|
10
|
+
if (cached) {
|
|
11
|
+
setSvg(cached);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let cancelled = false;
|
|
15
|
+
void ensureSolarIcons().then(() => {
|
|
16
|
+
if (!cancelled) setSvg(getSolarSvg(name));
|
|
17
|
+
});
|
|
18
|
+
return () => {
|
|
19
|
+
cancelled = true;
|
|
20
|
+
};
|
|
21
|
+
}, [name]);
|
|
22
|
+
|
|
23
|
+
if (!svg) {
|
|
24
|
+
return <span aria-hidden className={cn("inline-block shrink-0", className)} style={{ width: size, height: size }} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<span
|
|
29
|
+
aria-hidden
|
|
30
|
+
className={cn("inline-flex shrink-0 select-none text-current pointer-events-none [&_svg]:size-full", className)}
|
|
31
|
+
style={{ width: size, height: size }}
|
|
32
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: Solar SVG comes from the vendored icon pack, keyed by name
|
|
33
|
+
dangerouslySetInnerHTML={{ __html: svg }}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @deprecated Use SolarIcon. Same component — Solar icons, not Fluent Color. */
|
|
39
|
+
export const FluentIcon = SolarIcon;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
export const ICON_PREFIX = "solar";
|
|
2
|
+
export const DEFAULT_ICON_STYLE = "linear";
|
|
3
|
+
export const DEFAULT_ICON_NAME = "bot-linear";
|
|
4
|
+
export const DEFAULT_TOOL_ICON = `${ICON_PREFIX}:${DEFAULT_ICON_NAME}`;
|
|
5
|
+
|
|
6
|
+
const STYLE_SUFFIXES = ["bold-duotone", "line-duotone", "linear", "outline", "broken", "bold"] as const;
|
|
7
|
+
|
|
8
|
+
export type SolarIconStyle = (typeof STYLE_SUFFIXES)[number];
|
|
9
|
+
|
|
10
|
+
/** Fluent Color ids that do not share a Solar stem. Values are full Solar icon ids. */
|
|
11
|
+
const LEGACY_NAMES: Record<string, string> = {
|
|
12
|
+
alert: "bell-linear",
|
|
13
|
+
apps: "widget-4-linear",
|
|
14
|
+
"apps-list": "list-linear",
|
|
15
|
+
"apps-list-detail": "sidebar-minimalistic-linear",
|
|
16
|
+
"arrow-square-down": "alt-arrow-down-linear",
|
|
17
|
+
"arrow-sync": "refresh-linear",
|
|
18
|
+
board: "kanban-linear",
|
|
19
|
+
"book-open": "book-2-linear",
|
|
20
|
+
"bot-sparkle": "magic-stick-3-linear",
|
|
21
|
+
"calendar-clock": "calendar-mark-linear",
|
|
22
|
+
chat: "chat-round-linear",
|
|
23
|
+
"chat-bubbles-question": "chat-round-question-mark-linear",
|
|
24
|
+
"chat-more": "chat-round-dots-linear",
|
|
25
|
+
"chat-multiple": "dialog-2-linear",
|
|
26
|
+
checkbox: "check-square-linear",
|
|
27
|
+
clock: "clock-circle-linear",
|
|
28
|
+
"code-block": "code-square-linear",
|
|
29
|
+
comment: "dialog-linear",
|
|
30
|
+
"content-view": "window-frame-linear",
|
|
31
|
+
"data-bar-vertical-ascending": "chart-linear",
|
|
32
|
+
"dismiss-circle": "close-circle-linear",
|
|
33
|
+
drafts: "notes-linear",
|
|
34
|
+
edit: "pen-linear",
|
|
35
|
+
"fast-forward-circle": "round-double-alt-arrow-right-linear",
|
|
36
|
+
form: "clipboard-text-linear",
|
|
37
|
+
"image-off": "gallery-remove-linear",
|
|
38
|
+
"lightbulb-filament": "lightbulb-linear",
|
|
39
|
+
"list-bar": "hamburger-menu-linear",
|
|
40
|
+
"number-symbol-square": "hashtag-square-linear",
|
|
41
|
+
options: "tuning-2-linear",
|
|
42
|
+
"people-community": "users-group-rounded-linear",
|
|
43
|
+
person: "user-rounded-linear",
|
|
44
|
+
"search-sparkle": "magnifer-linear",
|
|
45
|
+
"share-android": "share-linear",
|
|
46
|
+
"share-ios": "square-share-line-linear",
|
|
47
|
+
sparkle: "stars-linear",
|
|
48
|
+
"text-edit-style": "text-field-linear",
|
|
49
|
+
vault: "safe-square-linear",
|
|
50
|
+
"wrench-screwdriver": "toolbox-linear",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type IconifyIcon = { body: string; width?: number; height?: number; left?: number; top?: number };
|
|
54
|
+
type IconifyAlias = { parent: string };
|
|
55
|
+
type IconifyPack = {
|
|
56
|
+
icons?: Record<string, IconifyIcon>;
|
|
57
|
+
aliases?: Record<string, IconifyAlias>;
|
|
58
|
+
width?: number;
|
|
59
|
+
height?: number;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
let pack: IconifyPack | null = null;
|
|
63
|
+
let memoryNames: string[] | null = null;
|
|
64
|
+
const svgByName = new Map<string, string>();
|
|
65
|
+
const imgSrcByName = new Map<string, string>();
|
|
66
|
+
let inflight: Promise<string[]> | null = null;
|
|
67
|
+
|
|
68
|
+
function hasStyle(name: string) {
|
|
69
|
+
return STYLE_SUFFIXES.some((style) => name.endsWith(`-${style}`));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function stripStyle(name: string) {
|
|
73
|
+
for (const style of STYLE_SUFFIXES) {
|
|
74
|
+
const suffix = `-${style}`;
|
|
75
|
+
if (name.endsWith(suffix)) return name.slice(0, -suffix.length);
|
|
76
|
+
}
|
|
77
|
+
return name;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function bareName(value: string) {
|
|
81
|
+
let name = value.trim();
|
|
82
|
+
if (name.startsWith(`${ICON_PREFIX}:`)) name = name.slice(ICON_PREFIX.length + 1);
|
|
83
|
+
if (name.startsWith("fluent-color:")) name = name.slice("fluent-color:".length);
|
|
84
|
+
return name;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Solar icon id. Accepts `solar:…`, a styled id, or a legacy Fluent Color id such as `settings-24`. Pass `style` to force a weight such as `bold-duotone`. */
|
|
88
|
+
export function solarIconName(value: string, style?: SolarIconStyle): string {
|
|
89
|
+
const name = bareName(value);
|
|
90
|
+
const stem = name.replace(/-24$/, "");
|
|
91
|
+
const resolved = hasStyle(name) ? name : (LEGACY_NAMES[stem] ?? LEGACY_NAMES[name] ?? `${stem}-${DEFAULT_ICON_STYLE}`);
|
|
92
|
+
if (!style || resolved.endsWith(`-${style}`)) return resolved;
|
|
93
|
+
return `${stripStyle(resolved)}-${style}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function solarIconRef(name: string): string {
|
|
97
|
+
return `${ICON_PREFIX}:${solarIconName(name)}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function lookup(name: string): IconifyIcon | null {
|
|
101
|
+
if (!pack) return null;
|
|
102
|
+
const seen = new Set<string>();
|
|
103
|
+
let current = name;
|
|
104
|
+
while (current && !seen.has(current)) {
|
|
105
|
+
seen.add(current);
|
|
106
|
+
const icon = pack.icons?.[current];
|
|
107
|
+
if (icon?.body) return icon;
|
|
108
|
+
const parent = pack.aliases?.[current]?.parent;
|
|
109
|
+
if (!parent) return null;
|
|
110
|
+
current = parent;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function toSvg(icon: IconifyIcon): string {
|
|
116
|
+
const left = icon.left ?? 0;
|
|
117
|
+
const top = icon.top ?? 0;
|
|
118
|
+
const width = icon.width ?? pack?.width ?? 24;
|
|
119
|
+
const height = icon.height ?? pack?.height ?? 24;
|
|
120
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="${left} ${top} ${width} ${height}">${icon.body}</svg>`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Loads the vendored Solar pack (code-split). No network. */
|
|
124
|
+
export function ensureSolarIcons(): Promise<string[]> {
|
|
125
|
+
if (memoryNames) return Promise.resolve(memoryNames);
|
|
126
|
+
if (inflight) return inflight;
|
|
127
|
+
inflight = import("@iconify-json/solar/icons.json")
|
|
128
|
+
.then((mod) => {
|
|
129
|
+
pack = (mod.default ?? mod) as IconifyPack;
|
|
130
|
+
memoryNames = [...Object.keys(pack.icons ?? {}), ...Object.keys(pack.aliases ?? {})];
|
|
131
|
+
return memoryNames;
|
|
132
|
+
})
|
|
133
|
+
.finally(() => {
|
|
134
|
+
inflight = null;
|
|
135
|
+
});
|
|
136
|
+
return inflight;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function getIconNames(): string[] {
|
|
140
|
+
return memoryNames ?? [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function getSolarSvg(name: string): string | null {
|
|
144
|
+
if (!pack) return null;
|
|
145
|
+
const resolved = solarIconName(name);
|
|
146
|
+
const cached = svgByName.get(resolved);
|
|
147
|
+
if (cached) return cached;
|
|
148
|
+
const icon = lookup(resolved);
|
|
149
|
+
if (!icon) return null;
|
|
150
|
+
const svg = toSvg(icon);
|
|
151
|
+
svgByName.set(resolved, svg);
|
|
152
|
+
return svg;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function getSolarImgSrc(name: string): string | null {
|
|
156
|
+
const resolved = solarIconName(name);
|
|
157
|
+
const hit = imgSrcByName.get(resolved);
|
|
158
|
+
if (hit) return hit;
|
|
159
|
+
const svg = getSolarSvg(name);
|
|
160
|
+
if (!svg) return null;
|
|
161
|
+
const src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
162
|
+
imgSrcByName.set(resolved, src);
|
|
163
|
+
return src;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function isSvgIcon(value?: string | null): boolean {
|
|
167
|
+
return !!value && value.trimStart().startsWith("<svg");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function isSolarIcon(value?: string | null): boolean {
|
|
171
|
+
return !!value && (value.startsWith(`${ICON_PREFIX}:`) || value.startsWith("fluent-color:"));
|
|
172
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ export type { AlertProps, AlertType } from "./alert/Alert";
|
|
|
17
17
|
export { Alert } from "./alert/Alert";
|
|
18
18
|
export type { CalendarProps } from "./calendar/Calendar";
|
|
19
19
|
export { Calendar } from "./calendar/Calendar";
|
|
20
|
+
export type { CardFooterProps, CardItemProps, CardProps } from "./card/Card";
|
|
21
|
+
export { Card } from "./card/Card";
|
|
20
22
|
export type {
|
|
21
23
|
AgentChatboxProps,
|
|
22
24
|
AgentHistoryMessage,
|
|
@@ -88,7 +90,7 @@ export {
|
|
|
88
90
|
useAgentStream,
|
|
89
91
|
WebFetchToolUI,
|
|
90
92
|
} from "./chat";
|
|
91
|
-
export type { CheckboxProps } from "./checkbox/Checkbox";
|
|
93
|
+
export type { CheckboxColor, CheckboxProps } from "./checkbox/Checkbox";
|
|
92
94
|
export { Checkbox } from "./checkbox/Checkbox";
|
|
93
95
|
export type { CodeBlockCopyButtonProps, CodeBlockProps } from "./codeblock/CodeBlock";
|
|
94
96
|
export { CodeBlock, CodeBlockCopyButton } from "./codeblock/CodeBlock";
|
|
@@ -137,25 +139,33 @@ export {
|
|
|
137
139
|
export type { FormLayoutItemProps, FormLayoutProps } from "./form-layout/FormLayout";
|
|
138
140
|
/** Layout-only Form + Form.Item for labeled fields. */
|
|
139
141
|
export { Form } from "./form-layout/FormLayout";
|
|
140
|
-
export { FluentIcon } from "./icon/
|
|
142
|
+
export { FluentIcon, SolarIcon } from "./icon/SolarIcon";
|
|
141
143
|
export {
|
|
142
144
|
DEFAULT_ICON_NAME,
|
|
143
145
|
DEFAULT_TOOL_ICON,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
fluentIconRef,
|
|
147
|
-
getFluentImgSrc,
|
|
146
|
+
ensureSolarIcons,
|
|
147
|
+
ensureSolarIcons as ensureFluentIcons,
|
|
148
148
|
getIconNames,
|
|
149
|
+
getSolarImgSrc,
|
|
150
|
+
getSolarImgSrc as getFluentImgSrc,
|
|
151
|
+
getSolarSvg,
|
|
149
152
|
ICON_PREFIX,
|
|
150
|
-
|
|
153
|
+
isSolarIcon,
|
|
154
|
+
isSolarIcon as isFluentIcon,
|
|
151
155
|
isSvgIcon,
|
|
152
|
-
|
|
156
|
+
solarIconName,
|
|
157
|
+
solarIconName as fluentIconName,
|
|
158
|
+
solarIconRef,
|
|
159
|
+
solarIconRef as fluentIconRef,
|
|
160
|
+
} from "./icon/solar";
|
|
153
161
|
export { cn } from "./lib/cn";
|
|
154
162
|
export type { PopperPlacement } from "./lib/placement";
|
|
155
163
|
export { placementToRadix } from "./lib/placement";
|
|
156
164
|
export type { CanonicalSize, ControlSize, ControlSizeTokens } from "./lib/sizes";
|
|
157
165
|
export { CONTROL_SIZES, controlHeightVar, controlRadiusVar, controlStatusClass, getSizeTokens, normalizeSize, useControlSize } from "./lib/sizes";
|
|
158
166
|
export { glassOverlayClass, glassSurfaceClass, meadowSurfaceClass } from "./lib/surface";
|
|
167
|
+
export type { MarkdownDiffLayout, MarkdownEditorMode, MarkdownEditorProps } from "./markdown-editor/MarkdownEditor";
|
|
168
|
+
export { MarkdownEditor } from "./markdown-editor/MarkdownEditor";
|
|
159
169
|
export type { MenuItemProps, MenuRootProps, MenuTriggerProps } from "./menu/Menu";
|
|
160
170
|
export { Menu, MenuAction, MenuDivider, MenuItem, MenuTrigger } from "./menu/Menu";
|
|
161
171
|
export type { MessageConfig, MessageType } from "./message/message";
|
|
@@ -180,11 +190,11 @@ export type { SidebarItemType, SidebarProps, SidebarSelectInfo } from "./sidebar
|
|
|
180
190
|
export { Sidebar } from "./sidebar/Sidebar";
|
|
181
191
|
export type { SkeletonProps } from "./skeleton/Skeleton";
|
|
182
192
|
export { Skeleton } from "./skeleton/Skeleton";
|
|
183
|
-
export type { SpinProps, SpinVariant } from "./spin/Spin";
|
|
193
|
+
export type { SpinColor, SpinProps, SpinVariant } from "./spin/Spin";
|
|
184
194
|
export { Spin } from "./spin/Spin";
|
|
185
195
|
export type { SplitterOrientation, SplitterPanelProps, SplitterProps, SplitterSemanticSlot, SplitterSize } from "./splitter/Splitter";
|
|
186
196
|
export { Splitter, SplitterPanel } from "./splitter/Splitter";
|
|
187
|
-
export type { SwitchProps, SwitchVariant } from "./switch/Switch";
|
|
197
|
+
export type { SwitchColor, SwitchProps, SwitchVariant } from "./switch/Switch";
|
|
188
198
|
export { Switch } from "./switch/Switch";
|
|
189
199
|
export type {
|
|
190
200
|
ColumnsType,
|
|
@@ -197,8 +207,10 @@ export type {
|
|
|
197
207
|
export { Table } from "./table/Table";
|
|
198
208
|
export type { TagProps, TagVariant } from "./tag/Tag";
|
|
199
209
|
export { Tag } from "./tag/Tag";
|
|
200
|
-
export type { NonlaThemeColorName, NonlaThemeColors, NonlaThemeConfig, NonlaThemeKnob, NonlaThemeKnobName, NonlaTokenSnapshot } from "./theme";
|
|
201
|
-
export { applyNonlaTheme, getDesignToken, NONLA_THEME_KEYS, NONLA_THEME_KNOBS } from "./theme";
|
|
210
|
+
export type { NonlaColorMode, NonlaThemeColorName, NonlaThemeColors, NonlaThemeConfig, NonlaThemeKnob, NonlaThemeKnobName, NonlaTokenSnapshot } from "./theme";
|
|
211
|
+
export { applyNonlaTheme, getColorMode, getDesignToken, initColorMode, NONLA_COLOR_MODE_KEY, NONLA_THEME_KEYS, NONLA_THEME_KNOBS, setColorMode } from "./theme";
|
|
212
|
+
export type { ThemeToggleProps } from "./theme-toggle/ThemeToggle";
|
|
213
|
+
export { ThemeToggle, useColorMode } from "./theme-toggle/ThemeToggle";
|
|
202
214
|
export type { TimePickerProps, TimeValue } from "./timepicker/TimePicker";
|
|
203
215
|
export { TimePicker } from "./timepicker/TimePicker";
|
|
204
216
|
export type { TooltipPlacement, TooltipProps } from "./tooltip/Tooltip";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Pencil } from "lucide-react";
|
|
2
1
|
import { type CSSProperties, cloneElement, isValidElement, type KeyboardEvent, type ReactElement, type ReactNode, type Ref, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
2
|
import { createPortal } from "react-dom";
|
|
4
3
|
import { usePopupContainer } from "../app/context";
|
|
5
4
|
import { Button } from "../button/Button";
|
|
5
|
+
import { SolarIcon } from "../icon/SolarIcon";
|
|
6
6
|
import { cn } from "../lib/cn";
|
|
7
7
|
import { type CanonicalSize, type ControlSize, controlHeightVar, controlRadiusVar, getSizeTokens, useControlSize } from "../lib/sizes";
|
|
8
8
|
import { message } from "../message/message";
|
|
@@ -12,7 +12,7 @@ const FIELD_INSET: Record<CanonicalSize, string> = { small: "-4px", default: "-6
|
|
|
12
12
|
const MULTILINE_MIN: Record<CanonicalSize, number> = { small: 56, default: 72, large: 96 };
|
|
13
13
|
const GLASS_BORDER = 1;
|
|
14
14
|
|
|
15
|
-
const fieldClass = (saving: boolean) => cn("relative z-1 m-0 w-full border-0 bg-transparent text-foreground placeholder:text-
|
|
15
|
+
const fieldClass = (saving: boolean) => cn("relative z-1 m-0 w-full border-0 bg-transparent text-foreground placeholder:text-placeholder focus:outline-none", saving && "opacity-60");
|
|
16
16
|
|
|
17
17
|
type Lock = {
|
|
18
18
|
top: number;
|
|
@@ -227,7 +227,7 @@ function EditButton({ label, size, onClick }: { label: string; size: CanonicalSi
|
|
|
227
227
|
className="inline-flex shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover/edit:opacity-100 focus-visible:opacity-100"
|
|
228
228
|
style={{ width: box, height: box }}
|
|
229
229
|
>
|
|
230
|
-
<
|
|
230
|
+
<SolarIcon name="pen-linear" size={tok.icon} />
|
|
231
231
|
</button>
|
|
232
232
|
);
|
|
233
233
|
}
|
package/src/input/Input.tsx
CHANGED
|
@@ -15,10 +15,10 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "p
|
|
|
15
15
|
onPressEnter?: (e: KeyboardEvent<HTMLInputElement>) => void;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const fieldBase = cn("w-full", controlFieldSurface, "placeholder:text-
|
|
18
|
+
const fieldBase = cn("w-full", controlFieldSurface, "placeholder:text-placeholder focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45", controlFieldFocusBorder);
|
|
19
19
|
|
|
20
20
|
function variantClass(variant: InputProps["variant"]) {
|
|
21
|
-
if (variant === "borderless") return "border-transparent bg-transparent hover:bg-transparent shadow-none focus:border-transparent";
|
|
21
|
+
if (variant === "borderless") return "border-transparent bg-transparent hover:bg-transparent shadow-none focus:border-transparent focus:bg-transparent focus-within:bg-transparent";
|
|
22
22
|
if (variant === "filled") return "border-transparent bg-muted focus:border-transparent focus:bg-[var(--control-bg-hover)]";
|
|
23
23
|
return "";
|
|
24
24
|
}
|
|
@@ -275,7 +275,7 @@ const InputNumber = forwardRef<HTMLInputElement, InputNumberProps>(function Inpu
|
|
|
275
275
|
}}
|
|
276
276
|
onKeyDown={handleKeyDown}
|
|
277
277
|
className={cn(
|
|
278
|
-
"min-w-0 flex-1 border-0 bg-transparent text-foreground placeholder:text-
|
|
278
|
+
"min-w-0 flex-1 border-0 bg-transparent text-foreground placeholder:text-placeholder outline-none",
|
|
279
279
|
"disabled:cursor-not-allowed",
|
|
280
280
|
// Kill native number chrome if type ever switches
|
|
281
281
|
"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
package/src/lib/sizes.ts
CHANGED
|
@@ -94,14 +94,17 @@ export function controlStatusClass(status?: "error" | "warning"): string {
|
|
|
94
94
|
export const controlFieldTransition = "transition-[background-color,border-color] duration-[var(--nonla-dur-fast,150ms)] ease-[var(--nonla-ease-out,cubic-bezier(0.16,1,0.3,1))] motion-reduce:transition-none";
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* Outlined field.
|
|
98
|
-
*
|
|
97
|
+
* Outlined field. Resting stroke is `--input` (Cursor `--border-secondary`, ink at 12%).
|
|
98
|
+
* Fill stays transparent so the stroke sits on the card, same as the settings inputs.
|
|
99
99
|
*/
|
|
100
|
-
export const controlFieldSurface =
|
|
101
|
-
"border border-solid border-input bg-glass-bar text-foreground shadow-[inset_0_1px_0_var(--glass-highlight)] backdrop-blur-xl";
|
|
100
|
+
export const controlFieldSurface = "border border-solid border-input bg-transparent text-foreground";
|
|
102
101
|
|
|
103
|
-
/**
|
|
104
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Focus fill is Cursor `--bg-tertiary` (ink at 8%).
|
|
104
|
+
* Keyboard focus / open menu also strengthens the stroke to `--border-primary` (ink at 20%).
|
|
105
|
+
*/
|
|
106
|
+
export const controlFieldFocusBorder =
|
|
107
|
+
"focus:bg-input-fill focus-within:bg-input-fill data-[state=open]:bg-input-fill aria-expanded:bg-input-fill focus-visible:border-input-focus has-[:focus-visible]:border-input-focus data-[state=open]:border-input-focus aria-expanded:border-input-focus";
|
|
105
108
|
|
|
106
109
|
/** Shared field chrome (Input / Select / DatePicker). */
|
|
107
110
|
export function controlFieldStyle(size: ControlSize | undefined): CSSProperties {
|
package/src/lib/surface.ts
CHANGED