devnonla-ui 0.8.0 → 0.9.1
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 +5 -5
- package/src/chat/message-ui/ChatMarkdown.tsx +8 -7
- 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 +68 -39
- 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 +2 -2
- 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 +301 -0
- package/src/markdown-editor/MarkdownPreview.tsx +346 -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/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 +265 -110
- package/src/switch/Switch.tsx +17 -3
- package/src/table/Table.tsx +61 -26
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../../lib/cn";
|
|
4
4
|
import { Shimmer } from "../../shimmer/Shimmer";
|
|
5
5
|
import { formatToolName, hasMeaningfulInput, prettyJson } from "../common/utils";
|
|
@@ -28,7 +28,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
|
|
|
28
28
|
const [open, setOpen] = useState(defaultOpen);
|
|
29
29
|
const displayLabel = label ?? formatToolName(toolName);
|
|
30
30
|
|
|
31
|
-
const identityIcon = icon ?? <
|
|
31
|
+
const identityIcon = icon ?? <SolarIcon name="code-square-linear" size={13} className="shrink-0" />;
|
|
32
32
|
|
|
33
33
|
const header = (
|
|
34
34
|
<>
|
|
@@ -52,7 +52,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
|
|
|
52
52
|
)}
|
|
53
53
|
|
|
54
54
|
{open && expandable ? (
|
|
55
|
-
<div className="mt-1.5 mb-1 overflow-hidden rounded-lg font-mono text-[13px]">
|
|
55
|
+
<div className="mt-1.5 mb-1 overflow-hidden rounded-lg border border-border bg-card font-mono text-[13px]">
|
|
56
56
|
{hasInput ? <pre className="m-0 max-h-27.5 overflow-y-auto bg-well px-3 py-1.5 break-all whitespace-pre-wrap font-normal leading-[1.65] text-muted-foreground">{prettyJson(toolInput)}</pre> : null}
|
|
57
57
|
{running ? (
|
|
58
58
|
<div className="bg-well-strong px-3 py-1.5 text-muted-foreground">
|
|
@@ -60,7 +60,7 @@ export function ChatToolCall({ toolName = "Tool", label, toolInput, toolOutput,
|
|
|
60
60
|
</div>
|
|
61
61
|
) : null}
|
|
62
62
|
{!isPending ? (
|
|
63
|
-
<pre className={cn("m-0 max-h-75 overflow-y-auto px-3 py-1.5 break-all whitespace-pre-wrap font-normal leading-[1.65] text-muted-foreground", hasError
|
|
63
|
+
<pre className={cn("m-0 max-h-75 overflow-y-auto bg-well-strong px-3 py-1.5 break-all whitespace-pre-wrap font-normal leading-[1.65] text-muted-foreground", hasError && "bg-destructive/6")}>
|
|
64
64
|
{hasOutput ? prettyJson(toolOutput) : typeof toolError === "string" ? toolError : "Tool execution failed"}
|
|
65
65
|
</pre>
|
|
66
66
|
) : null}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
2
2
|
import { Shimmer } from "../../shimmer/Shimmer";
|
|
3
3
|
import { parseJsonObject } from "../common/utils";
|
|
4
4
|
import { ToolUiBadge } from "./ToolUiBadge";
|
|
@@ -40,7 +40,7 @@ export function GetCurrentTimeToolUI({ msg, assistantLabel = "Assistant", assist
|
|
|
40
40
|
<ToolUiBadge show={showAvatar} label={assistantLabel} color={assistantColor} />
|
|
41
41
|
<div className="px-4 pb-1">
|
|
42
42
|
<div className="flex items-center gap-2 py-1">
|
|
43
|
-
<
|
|
43
|
+
<SolarIcon name="clock-circle-linear" size={13} className="shrink-0 text-muted-foreground" />
|
|
44
44
|
<Shimmer active={running} className="truncate text-[14px] font-medium tabular-nums text-muted-foreground">{hasError ? "Failed to get time" : running ? "Getting time…" : label}</Shimmer>
|
|
45
45
|
<ToolUiTrailing failed={hasError} />
|
|
46
46
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
2
2
|
import { cn } from "../../lib/cn";
|
|
3
3
|
import { Shimmer } from "../../shimmer/Shimmer";
|
|
4
4
|
import { parseJsonObject } from "../common/utils";
|
|
@@ -55,7 +55,7 @@ export function ReadSkillToolUI({ msg, assistantLabel = "Assistant", assistantCo
|
|
|
55
55
|
<ToolUiBadge show={showAvatar} label={assistantLabel} color={assistantColor} />
|
|
56
56
|
<details className="group/readskill px-4 pb-2" style={{ overflowAnchor: "none" }}>
|
|
57
57
|
<summary className="flex cursor-pointer list-none items-center gap-2 py-0.5 text-[14px] leading-5.5 select-none [&::-webkit-details-marker]:hidden">
|
|
58
|
-
<
|
|
58
|
+
<SolarIcon name={reference ? "document-text-linear" : "book-linear"} size={13} className="shrink-0 text-muted-foreground" />
|
|
59
59
|
<Shimmer active={running} className="min-w-0 truncate font-medium text-muted-foreground">
|
|
60
60
|
{verb}
|
|
61
61
|
{targetLabel ? <span className="font-normal text-tertiary-foreground"> {targetLabel}</span> : null}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CodeBlock } from "../../codeblock/CodeBlock";
|
|
2
|
-
import {
|
|
2
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
3
3
|
import { cn } from "../../lib/cn";
|
|
4
4
|
import { Shimmer } from "../../shimmer/Shimmer";
|
|
5
5
|
import { parseBgTaskRef } from "../common/bgTasks";
|
|
@@ -87,7 +87,7 @@ export function RunJsToolUI({ msg, assistantLabel = "Assistant", assistantColor,
|
|
|
87
87
|
<ToolUiBadge show={showAvatar} label={assistantLabel} color={assistantColor} />
|
|
88
88
|
<details className="group/runjs px-4 pb-2" style={{ overflowAnchor: "none" }}>
|
|
89
89
|
<summary className="flex cursor-pointer list-none items-center gap-2 py-0.5 text-[14px] leading-5.5 select-none [&::-webkit-details-marker]:hidden">
|
|
90
|
-
<
|
|
90
|
+
<SolarIcon name="code-square-linear" size={13} className="shrink-0 text-muted-foreground" />
|
|
91
91
|
<Shimmer active={running} className="min-w-0 truncate font-medium text-muted-foreground">{verb}</Shimmer>
|
|
92
92
|
<ToolUiTrailing running={running} failed={failed} chevron chevronClassName="group-hover/runjs:opacity-100 group-open/runjs:opacity-100 group-open/runjs:rotate-90" />
|
|
93
93
|
</summary>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
2
2
|
import { cn } from "../../lib/cn";
|
|
3
3
|
import { ChatSpinner } from "../message-ui/ChatSpinner";
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@ export function ToolUiTrailing({
|
|
|
14
14
|
chevronClassName?: string;
|
|
15
15
|
}) {
|
|
16
16
|
if (running) return <ChatSpinner />;
|
|
17
|
-
if (failed) return <
|
|
17
|
+
if (failed) return <SolarIcon name="close-circle-linear" size={13} className="text-destructive" />;
|
|
18
18
|
if (!chevron) return null;
|
|
19
|
-
return <
|
|
19
|
+
return <SolarIcon name="alt-arrow-right-linear" size={12} className={cn("shrink-0 opacity-0 transition-[opacity,transform] duration-150", chevronClassName)} />;
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SolarIcon } from "../../icon/SolarIcon";
|
|
2
2
|
import { cn } from "../../lib/cn";
|
|
3
3
|
import { Shimmer } from "../../shimmer/Shimmer";
|
|
4
4
|
import { parseJsonObject } from "../common/utils";
|
|
@@ -37,7 +37,7 @@ export function WebFetchToolUI({ msg, assistantLabel = "Assistant", assistantCol
|
|
|
37
37
|
|
|
38
38
|
const header = (
|
|
39
39
|
<>
|
|
40
|
-
<
|
|
40
|
+
<SolarIcon name="globe-linear" size={13} className="shrink-0 text-muted-foreground" />
|
|
41
41
|
<Shimmer active={running} className="min-w-0 truncate font-medium text-muted-foreground">
|
|
42
42
|
{verb} <span className="font-normal text-tertiary-foreground">{url}</span>
|
|
43
43
|
</Shimmer>
|
|
@@ -2,6 +2,9 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
|
2
2
|
import { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from "react";
|
|
3
3
|
import { cn } from "../lib/cn";
|
|
4
4
|
|
|
5
|
+
/** Checked fill. `white` is the on-state for dark surfaces — the mark stays ink. */
|
|
6
|
+
export type CheckboxColor = "brand" | "success" | "white";
|
|
7
|
+
|
|
5
8
|
export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, "onCheckedChange" | "checked" | "onChange"> & {
|
|
6
9
|
checked?: boolean | "indeterminate";
|
|
7
10
|
defaultChecked?: boolean;
|
|
@@ -9,6 +12,16 @@ export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof CheckboxPrimiti
|
|
|
9
12
|
onChange?: (checked: boolean) => void;
|
|
10
13
|
children?: ReactNode;
|
|
11
14
|
indeterminate?: boolean;
|
|
15
|
+
color?: CheckboxColor;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const CHECKED_FILL: Record<CheckboxColor, string> = {
|
|
19
|
+
brand:
|
|
20
|
+
"data-[state=checked]:bg-brand data-[state=checked]:border-brand data-[state=checked]:text-(--nonla-solid-fg) data-[state=indeterminate]:bg-brand data-[state=indeterminate]:border-brand data-[state=indeterminate]:text-(--nonla-solid-fg)",
|
|
21
|
+
success:
|
|
22
|
+
"data-[state=checked]:bg-success data-[state=checked]:border-success data-[state=checked]:text-(--nonla-solid-fg) data-[state=indeterminate]:bg-success data-[state=indeterminate]:border-success data-[state=indeterminate]:text-(--nonla-solid-fg)",
|
|
23
|
+
white:
|
|
24
|
+
"data-[state=checked]:bg-white data-[state=checked]:border-white data-[state=checked]:text-[#141414] data-[state=indeterminate]:bg-white data-[state=indeterminate]:border-white data-[state=indeterminate]:text-[#141414]",
|
|
12
25
|
};
|
|
13
26
|
|
|
14
27
|
function CheckIcon() {
|
|
@@ -20,7 +33,7 @@ function CheckIcon() {
|
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(function Checkbox(
|
|
23
|
-
{ className, checked, defaultChecked, onChange, children, indeterminate, disabled, ...rest },
|
|
36
|
+
{ className, checked, defaultChecked, onChange, children, indeterminate, disabled, color = "brand", ...rest },
|
|
24
37
|
ref,
|
|
25
38
|
) {
|
|
26
39
|
const resolved = indeterminate ? "indeterminate" : checked;
|
|
@@ -34,9 +47,9 @@ export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(function Ch
|
|
|
34
47
|
disabled={disabled}
|
|
35
48
|
onCheckedChange={(v) => onChange?.(v === true)}
|
|
36
49
|
className={cn(
|
|
37
|
-
"size-4 shrink-0 rounded-sm border border-input bg-(--
|
|
38
|
-
"focus-visible:outline-none
|
|
39
|
-
|
|
50
|
+
"size-4 shrink-0 rounded-sm border border-input bg-(--nonla-surface) transition-colors duration-150 ease-[cubic-bezier(0.16,1,0.3,1)]",
|
|
51
|
+
"focus-visible:outline-none",
|
|
52
|
+
CHECKED_FILL[color],
|
|
40
53
|
className,
|
|
41
54
|
)}
|
|
42
55
|
{...rest}
|
|
@@ -44,7 +44,7 @@ export function CodeBlock({ code, language, title, lineNumbers = false, wordWrap
|
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
46
|
<CodeBlockContext.Provider value={{ code }}>
|
|
47
|
-
<div className={cn("nonla-codeblock relative flex min-w-0 w-full flex-col overflow-clip rounded-
|
|
47
|
+
<div className={cn("nonla-codeblock relative flex min-w-0 w-full flex-col overflow-clip rounded-xl border border-border bg-card text-sm text-foreground", className)} data-language={language} {...props}>
|
|
48
48
|
<div className="flex h-8 items-center justify-between gap-2 pl-3 pr-1 text-xs text-muted-foreground">
|
|
49
49
|
<div className="flex min-w-0 items-center gap-2">
|
|
50
50
|
{label ? <span className="truncate font-medium">{label}</span> : null}
|
|
@@ -54,7 +54,7 @@ export function CodeBlock({ code, language, title, lineNumbers = false, wordWrap
|
|
|
54
54
|
|
|
55
55
|
<OverlayScroll
|
|
56
56
|
autoHeight
|
|
57
|
-
className=
|
|
57
|
+
className="nonla-codeblock-body nonla-codeblock-well min-w-0 bg-card font-mono text-[13px] leading-5 max-h-96"
|
|
58
58
|
innerClassName={wordWrap ? undefined : "overflow-x-auto"}
|
|
59
59
|
>
|
|
60
60
|
<pre className={cn("nonla-codeblock-pre m-0 whitespace-pre break-normal", lineNumbers && "nonla-codeblock-lines", wordWrap && "whitespace-pre-wrap wrap-break-word")}>
|
|
@@ -278,7 +278,7 @@ const DatePickerRoot = forwardRef<HTMLButtonElement, DatePickerProps>(function D
|
|
|
278
278
|
) : null
|
|
279
279
|
}
|
|
280
280
|
>
|
|
281
|
-
<span className={cn(!selected && "text-
|
|
281
|
+
<span className={cn(!selected && "text-placeholder")}>{selected ? label : placeholder}</span>
|
|
282
282
|
</TriggerChrome>
|
|
283
283
|
</PopoverPrimitive.Trigger>
|
|
284
284
|
<PopoverPrimitive.Portal container={portal}>
|
|
@@ -418,9 +418,9 @@ const RangePicker = forwardRef<HTMLButtonElement, RangePickerProps>(function Ran
|
|
|
418
418
|
}
|
|
419
419
|
>
|
|
420
420
|
<span className="inline-flex min-w-0 items-center gap-1.5">
|
|
421
|
-
<span className={cn("truncate", !selected?.from && "text-
|
|
421
|
+
<span className={cn("truncate", !selected?.from && "text-placeholder")}>{selected?.from ? startLabel : placeholders[0]}</span>
|
|
422
422
|
<span className="shrink-0 text-muted-foreground">{separator}</span>
|
|
423
|
-
<span className={cn("truncate", !rangeComplete && "text-
|
|
423
|
+
<span className={cn("truncate", !rangeComplete && "text-placeholder")}>{rangeComplete ? endLabel : placeholders[1]}</span>
|
|
424
424
|
</span>
|
|
425
425
|
</TriggerChrome>
|
|
426
426
|
</PopoverPrimitive.Trigger>
|
|
@@ -76,7 +76,7 @@ export function DesktopHeader({ left, right, className }: DesktopHeaderProps) {
|
|
|
76
76
|
return (
|
|
77
77
|
<header
|
|
78
78
|
className={cn(
|
|
79
|
-
"nonla-header-layer fixed inset-x-0 top-0 flex h-desktop-bar items-center justify-between gap-3 border-0 bg-
|
|
79
|
+
"nonla-header-layer fixed inset-x-0 top-0 flex h-desktop-bar items-center justify-between gap-3 border-0 bg-background px-3",
|
|
80
80
|
className,
|
|
81
81
|
)}
|
|
82
82
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { forwardRef, type ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { SolarIcon } from "../icon/SolarIcon";
|
|
3
3
|
|
|
4
4
|
const iconButtonClass =
|
|
5
5
|
"group w-[96px] flex flex-col items-center gap-0.5 py-2 px-0 rounded-md border-none cursor-pointer select-none outline-none bg-transparent focus-visible:outline-2 focus-visible:outline-brand motion-safe:transition-transform motion-safe:hover:-translate-y-0.5 motion-safe:active:scale-[0.98]";
|
|
@@ -19,7 +19,7 @@ export const DesktopIcon = forwardRef<
|
|
|
19
19
|
>(function DesktopIcon({ label, icon, media, active = false, onCard = false, onClick }, ref) {
|
|
20
20
|
return (
|
|
21
21
|
<button ref={ref} type="button" title={label} aria-label={label} aria-current={active ? "true" : undefined} dir="ltr" onClick={onClick} className={iconButtonClass}>
|
|
22
|
-
{media ?? <
|
|
22
|
+
{media ?? <SolarIcon name={icon ?? "stars-linear"} size={32} />}
|
|
23
23
|
<span className={`${labelClass} ${onCard ? "text-foreground" : "text-white [text-shadow:0_1px_2px_rgba(0,0,0,0.85)]"}`}>{label}</span>
|
|
24
24
|
</button>
|
|
25
25
|
);
|
|
@@ -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
|
+
}
|