devnonla-ui 0.12.0 → 0.14.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 +6 -245
- package/package.json +2 -2
- package/src/app/App.tsx +6 -22
- package/src/app/context.ts +2 -17
- package/src/avatar/AgentAvatar.tsx +17 -6
- package/src/avatar/avatar.css +107 -0
- package/src/button/Button.tsx +4 -4
- package/src/button/ButtonCopy.tsx +1 -1
- package/src/calendar/Calendar.tsx +1 -1
- package/src/card/Card.tsx +2 -5
- package/src/chat/AgentChatbox.tsx +1 -1
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/chatMessageList.tsx +1 -4
- package/src/chat/message-ui/ChatAgentMessage.tsx +6 -4
- package/src/chat/message-ui/ChatError.tsx +1 -1
- package/src/chat/message-ui/ChatInput.tsx +5 -4
- package/src/chat/message-ui/ChatMarkdown.tsx +2 -2
- package/src/chat/message-ui/ChatUserMessage.tsx +3 -3
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +3 -3
- package/src/chat/tool-ui/CallAgentToolUI.tsx +2 -2
- package/src/chat/tool-ui/ChatToolCall.tsx +3 -3
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +2 -2
- package/src/chat/tool-ui/RunJsToolUI.tsx +1 -1
- package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
- package/src/chat/tool-ui/WebFetchToolUI.tsx +1 -1
- package/src/checkbox/Checkbox.tsx +2 -2
- package/src/codeblock/CodeBlock.tsx +2 -2
- package/src/colorpicker/ColorPicker.tsx +10 -8
- package/src/datepicker/DatePicker.tsx +3 -3
- package/src/desktop/DesktopHeader.tsx +2 -2
- package/src/desktop/DesktopStage.tsx +1 -1
- package/src/desktop/DesktopWindow.tsx +3 -3
- package/src/desktop/MeadowDesktop.tsx +2 -2
- package/src/drawer/Drawer.tsx +6 -2
- package/src/dropdown/menuClasses.ts +1 -1
- package/src/empty/Empty.tsx +1 -1
- package/src/form/variants/FieldRadio.tsx +1 -1
- package/src/form/variants/FieldRepeaterItem.tsx +1 -1
- package/src/index.ts +7 -5
- package/src/input/EditableInput.tsx +3 -2
- package/src/input/Input.tsx +15 -7
- package/src/lib/sizes.ts +6 -6
- package/src/lib/surface.ts +14 -4
- package/src/markdown-editor/MarkdownDiff.tsx +4 -4
- package/src/markdown-editor/MarkdownPreview.tsx +6 -6
- package/src/markdown-editor/MarkdownSource.tsx +1 -1
- package/src/markdown-editor/MarkdownTable.tsx +2 -2
- package/src/markdown-editor/MarkdownViewer.tsx +54 -56
- package/src/markdown-editor/MermaidBlock.tsx +2 -2
- package/src/markdown-editor/ReactCode.tsx +6 -7
- package/src/markdown-editor/ReactCodeFrame.tsx +45 -15
- package/src/markdown-editor/ReactCodeSandbox.tsx +1 -1
- package/src/markdown-editor/markdownScale.ts +149 -0
- package/src/menu/Menu.tsx +1 -1
- package/src/message/message.tsx +18 -8
- package/src/modal/Modal.tsx +13 -7
- package/src/pagination/Pagination.tsx +3 -3
- package/src/popover/Popover.tsx +1 -1
- package/src/scroll/OverlayScroll.tsx +2 -2
- package/src/segmented/Segmented.tsx +1 -1
- package/src/select/Select.tsx +4 -4
- package/src/sidebar/Sidebar.tsx +35 -32
- package/src/skeleton/Skeleton.tsx +4 -4
- package/src/spin/Spin.tsx +14 -2
- package/src/splitter/Splitter.tsx +1 -1
- package/src/styles.css +171 -813
- package/src/table/Table.tsx +12 -12
- package/src/tabs/Tabs.tsx +261 -0
- package/src/tag/Tag.tsx +16 -16
- package/src/theme.ts +53 -232
- package/src/timepicker/TimePicker.tsx +2 -2
- package/src/typography/Typography.tsx +41 -35
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
|
|
3
|
+
/** `docs` is the article scale. `chat` is the tighter thread scale. */
|
|
4
|
+
export type MarkdownVariant = "docs" | "chat";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Size and spacing for each scale. Class fallbacks match `docs`, so the editor
|
|
8
|
+
* preview stays on the article scale when no preset is set.
|
|
9
|
+
* Docs body reads `--nonla-base-text-size` (16px, leading 1.5). Chat body, headings, table, and inline code are 14px.
|
|
10
|
+
* Fenced code is 14px.
|
|
11
|
+
*/
|
|
12
|
+
const MARKDOWN_PRESETS = {
|
|
13
|
+
docs: {
|
|
14
|
+
"--md-body-size": "var(--nonla-base-text-size, 16px)",
|
|
15
|
+
"--md-body-leading": "calc(var(--nonla-base-text-size, 16px) * 1.5)",
|
|
16
|
+
"--md-h1-size": "32px",
|
|
17
|
+
"--md-h1-leading": "1.25",
|
|
18
|
+
"--md-h1-weight": "800",
|
|
19
|
+
"--md-h1-mt": "0px",
|
|
20
|
+
"--md-h1-mb": "12px",
|
|
21
|
+
"--md-h1-py": "3px",
|
|
22
|
+
"--md-h2-size": "30px",
|
|
23
|
+
"--md-h2-leading": "40px",
|
|
24
|
+
"--md-h2-weight": "700",
|
|
25
|
+
"--md-h2-mt": "24px",
|
|
26
|
+
"--md-h2-mb": "1px",
|
|
27
|
+
"--md-h2-py": "3px",
|
|
28
|
+
"--md-h3-size": "24px",
|
|
29
|
+
"--md-h3-leading": "32px",
|
|
30
|
+
"--md-h3-weight": "700",
|
|
31
|
+
"--md-h3-mt": "22px",
|
|
32
|
+
"--md-h3-mb": "1px",
|
|
33
|
+
"--md-h4-size": "20px",
|
|
34
|
+
"--md-h4-leading": "26px",
|
|
35
|
+
"--md-h4-weight": "700",
|
|
36
|
+
"--md-h4-mt": "16px",
|
|
37
|
+
"--md-h4-mb": "1px",
|
|
38
|
+
"--md-h5-size": "16px",
|
|
39
|
+
"--md-h5-leading": "1.375",
|
|
40
|
+
"--md-h5-weight": "700",
|
|
41
|
+
"--md-h5-mt": "0px",
|
|
42
|
+
"--md-h5-mb": "0px",
|
|
43
|
+
"--md-h6-size": "14px",
|
|
44
|
+
"--md-h6-leading": "1.375",
|
|
45
|
+
"--md-h6-weight": "700",
|
|
46
|
+
"--md-h6-mt": "0px",
|
|
47
|
+
"--md-h6-mb": "0px",
|
|
48
|
+
"--md-strong-weight": "600",
|
|
49
|
+
"--md-p-my": "1px",
|
|
50
|
+
"--md-p-py": "4px",
|
|
51
|
+
"--md-p-leading": "1.5",
|
|
52
|
+
"--md-list-my": "8px",
|
|
53
|
+
"--md-ul-pl": "4px",
|
|
54
|
+
"--md-ol-pl": "4px",
|
|
55
|
+
"--md-li-mt": "4px",
|
|
56
|
+
"--md-quote-my": "4px",
|
|
57
|
+
"--md-rule-my": "8px",
|
|
58
|
+
"--md-img-my": "4px",
|
|
59
|
+
"--md-table-my": "16px",
|
|
60
|
+
"--md-table-size": "15px",
|
|
61
|
+
"--md-code-my": "8px",
|
|
62
|
+
"--md-code-size": "14px",
|
|
63
|
+
"--md-code-leading": "22px",
|
|
64
|
+
"--md-inline-size": "14px",
|
|
65
|
+
"--md-item-pl": "4px",
|
|
66
|
+
"--md-nest": "1.25rem",
|
|
67
|
+
},
|
|
68
|
+
chat: {
|
|
69
|
+
"--md-body-size": "14px",
|
|
70
|
+
"--md-body-leading": "22px",
|
|
71
|
+
"--md-h1-size": "14px",
|
|
72
|
+
"--md-h1-leading": "22px",
|
|
73
|
+
"--md-h1-weight": "600",
|
|
74
|
+
"--md-h1-mt": "0px",
|
|
75
|
+
"--md-h1-mb": "2px",
|
|
76
|
+
"--md-h1-py": "0px",
|
|
77
|
+
"--md-h2-size": "14px",
|
|
78
|
+
"--md-h2-leading": "22px",
|
|
79
|
+
"--md-h2-weight": "600",
|
|
80
|
+
"--md-h2-mt": "12px",
|
|
81
|
+
"--md-h2-mb": "2px",
|
|
82
|
+
"--md-h2-py": "0px",
|
|
83
|
+
"--md-h3-size": "14px",
|
|
84
|
+
"--md-h3-leading": "22px",
|
|
85
|
+
"--md-h3-weight": "600",
|
|
86
|
+
"--md-h3-mt": "10px",
|
|
87
|
+
"--md-h3-mb": "2px",
|
|
88
|
+
"--md-h4-size": "14px",
|
|
89
|
+
"--md-h4-leading": "22px",
|
|
90
|
+
"--md-h4-weight": "600",
|
|
91
|
+
"--md-h4-mt": "8px",
|
|
92
|
+
"--md-h4-mb": "2px",
|
|
93
|
+
"--md-h5-size": "14px",
|
|
94
|
+
"--md-h5-leading": "22px",
|
|
95
|
+
"--md-h5-weight": "600",
|
|
96
|
+
"--md-h5-mt": "6px",
|
|
97
|
+
"--md-h5-mb": "0px",
|
|
98
|
+
"--md-h6-size": "14px",
|
|
99
|
+
"--md-h6-leading": "22px",
|
|
100
|
+
"--md-h6-weight": "600",
|
|
101
|
+
"--md-h6-mt": "6px",
|
|
102
|
+
"--md-h6-mb": "0px",
|
|
103
|
+
"--md-strong-weight": "400",
|
|
104
|
+
"--md-p-my": "0px",
|
|
105
|
+
"--md-p-py": "1px",
|
|
106
|
+
"--md-p-leading": "1.5",
|
|
107
|
+
"--md-list-my": "4px",
|
|
108
|
+
"--md-ul-pl": "4px",
|
|
109
|
+
"--md-ol-pl": "4px",
|
|
110
|
+
"--md-li-mt": "2px",
|
|
111
|
+
"--md-quote-my": "2px",
|
|
112
|
+
"--md-rule-my": "6px",
|
|
113
|
+
"--md-img-my": "4px",
|
|
114
|
+
"--md-table-my": "8px",
|
|
115
|
+
"--md-table-size": "14px",
|
|
116
|
+
"--md-code-my": "6px",
|
|
117
|
+
"--md-code-size": "14px",
|
|
118
|
+
"--md-code-leading": "22px",
|
|
119
|
+
"--md-inline-size": "14px",
|
|
120
|
+
"--md-item-pl": "4px",
|
|
121
|
+
"--md-nest": "1rem",
|
|
122
|
+
},
|
|
123
|
+
} as const;
|
|
124
|
+
|
|
125
|
+
export function markdownVariantStyle(variant: MarkdownVariant = "docs"): CSSProperties {
|
|
126
|
+
return MARKDOWN_PRESETS[variant] as CSSProperties;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Article headings. A markdown `#` paints the same as `##`.
|
|
131
|
+
* The large page title is `pageTitleClass`, used by Typography only.
|
|
132
|
+
*/
|
|
133
|
+
export function headingClass(level: number): string {
|
|
134
|
+
if (level <= 1) return "text-foreground mt-(--md-h2-mt,24px) mb-(--md-h1-mb,12px) pt-(--md-h2-py,3px) pb-(--md-h2-py,3px) text-(length:--md-h2-size,30px) leading-(--md-h2-leading,40px) font-(--md-h2-weight,600)";
|
|
135
|
+
if (level === 2) return "text-foreground mt-(--md-h2-mt,24px) mb-(--md-h2-mb,1px) pt-(--md-h2-py,3px) pb-(--md-h2-py,3px) text-(length:--md-h2-size,30px) leading-(--md-h2-leading,40px) font-(--md-h2-weight,600)";
|
|
136
|
+
if (level === 3) return "text-foreground mt-(--md-h3-mt,22px) mb-(--md-h3-mb,1px) text-(length:--md-h3-size,24px) leading-(--md-h3-leading,32px) font-(--md-h3-weight,700)";
|
|
137
|
+
if (level === 4) return "text-foreground mt-(--md-h4-mt,16px) mb-(--md-h4-mb,1px) text-(length:--md-h4-size,20px) leading-(--md-h4-leading,26px) font-(--md-h4-weight,700)";
|
|
138
|
+
if (level === 5) return "text-foreground mt-(--md-h5-mt,0px) mb-(--md-h5-mb,0px) text-(length:--md-h5-size,16px) leading-(--md-h5-leading,1.375) font-(--md-h5-weight,700)";
|
|
139
|
+
return "text-foreground mt-(--md-h6-mt,0px) mb-(--md-h6-mb,0px) text-(length:--md-h6-size,14px) leading-(--md-h6-leading,1.375) font-(--md-h6-weight,700)";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Landing and page title. Not used inside markdown. */
|
|
143
|
+
export const pageTitleClass = "text-foreground mt-(--md-h1-mt,0px) mb-(--md-h1-mb,1px) pt-(--md-h1-py,3px) pb-(--md-h1-py,3px) text-(length:--md-h1-size,32px) leading-(--md-h1-leading,1.25) font-(--md-h1-weight,800) tracking-tight";
|
|
144
|
+
|
|
145
|
+
/** Body line. Same size and color as a markdown paragraph. */
|
|
146
|
+
export const markdownBodyClass = "text-(length:--md-body-size,16px) leading-(--md-body-leading,24px) text-foreground";
|
|
147
|
+
|
|
148
|
+
/** Paragraph box. Same rhythm as `MarkdownViewer` `p`. */
|
|
149
|
+
export const markdownParagraphClass = "nonla-typo m-0 my-(--md-p-my,1px) py-(--md-p-py,4px) text-(length:--md-body-size,16px) leading-(--md-p-leading,1.5) text-foreground";
|
package/src/menu/Menu.tsx
CHANGED
|
@@ -89,7 +89,7 @@ export function MenuAction({ className, ...rest }: ButtonHTMLAttributes<HTMLButt
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export function MenuDivider({ className }: { className?: string }) {
|
|
92
|
-
return <div className={cn("mx-2.5 my-1 h-px bg-
|
|
92
|
+
return <div className={cn("mx-2.5 my-1 h-px bg-border", className)} />;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
Menu.Trigger = MenuTrigger;
|
package/src/message/message.tsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode, useLayoutEffect, useState } from "react";
|
|
2
2
|
import { createRoot, type Root } from "react-dom/client";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
import { glassSurfaceClass } from "../lib/surface";
|
|
5
|
+
|
|
6
|
+
const messageHostClass =
|
|
7
|
+
"nonla-message-host pointer-events-none fixed top-4 left-1/2 z-(--nonla-z-message) flex max-w-[min(420px,calc(100vw-32px))] -translate-x-1/2 flex-col items-center gap-2";
|
|
3
8
|
|
|
4
9
|
export type MessageType = "success" | "error" | "info" | "warning" | "loading";
|
|
5
10
|
|
|
@@ -50,7 +55,7 @@ function IconError() {
|
|
|
50
55
|
return (
|
|
51
56
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
52
57
|
<circle cx="8" cy="8" r="8" fill="var(--destructive)" />
|
|
53
|
-
<path d="M5.4 5.4L10.6 10.6M10.6 5.4L5.4 10.6" stroke="var(--
|
|
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" />
|
|
54
59
|
</svg>
|
|
55
60
|
);
|
|
56
61
|
}
|
|
@@ -59,7 +64,7 @@ function IconInfo() {
|
|
|
59
64
|
return (
|
|
60
65
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
61
66
|
<circle cx="8" cy="8" r="8" fill="var(--link)" />
|
|
62
|
-
<path d="M8 7.1V11.2M8 4.8V5.5" stroke="var(--nonla-solid
|
|
67
|
+
<path d="M8 7.1V11.2M8 4.8V5.5" stroke="var(--nonla-text-on-solid)" strokeWidth="1.7" strokeLinecap="round" />
|
|
63
68
|
</svg>
|
|
64
69
|
);
|
|
65
70
|
}
|
|
@@ -75,7 +80,7 @@ function IconWarning() {
|
|
|
75
80
|
|
|
76
81
|
function IconLoading() {
|
|
77
82
|
return (
|
|
78
|
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden className="
|
|
83
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden className="animate-[spin_0.8s_linear_infinite]">
|
|
79
84
|
<circle cx="8" cy="8" r="6.25" stroke="color-mix(in oklab, var(--link) 30%, transparent)" strokeWidth="2" />
|
|
80
85
|
<path d="M14.25 8A6.25 6.25 0 0 0 8 1.75" stroke="var(--link)" strokeWidth="2" strokeLinecap="round" />
|
|
81
86
|
</svg>
|
|
@@ -103,14 +108,19 @@ function MessageList({ list }: { list: Active[] }) {
|
|
|
103
108
|
{list.map((item) => (
|
|
104
109
|
<div
|
|
105
110
|
key={item.id}
|
|
106
|
-
className={
|
|
111
|
+
className={cn(
|
|
112
|
+
glassSurfaceClass,
|
|
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]",
|
|
115
|
+
item.className,
|
|
116
|
+
)}
|
|
107
117
|
data-type={item.type}
|
|
108
118
|
role="status"
|
|
109
119
|
style={item.style}
|
|
110
120
|
onClick={item.onClick}
|
|
111
121
|
>
|
|
112
|
-
<span className="
|
|
113
|
-
<span className="
|
|
122
|
+
<span className="inline-flex size-4 shrink-0 items-center justify-center">{item.icon ?? defaultIcon(item.type)}</span>
|
|
123
|
+
<span className="min-w-0 wrap-break-word">{item.content}</span>
|
|
114
124
|
</div>
|
|
115
125
|
))}
|
|
116
126
|
</>
|
|
@@ -131,7 +141,7 @@ function dropFallbackHost() {
|
|
|
131
141
|
function ensureHost() {
|
|
132
142
|
if (renderer || (hostEl && root)) return;
|
|
133
143
|
hostEl = document.createElement("div");
|
|
134
|
-
hostEl.className =
|
|
144
|
+
hostEl.className = messageHostClass;
|
|
135
145
|
document.body.appendChild(hostEl);
|
|
136
146
|
root = createRoot(hostEl);
|
|
137
147
|
}
|
|
@@ -157,7 +167,7 @@ export function MessageHolder() {
|
|
|
157
167
|
};
|
|
158
168
|
}, []);
|
|
159
169
|
return (
|
|
160
|
-
<div className=
|
|
170
|
+
<div className={messageHostClass} aria-live="polite" aria-relevant="additions">
|
|
161
171
|
<MessageList list={list} />
|
|
162
172
|
</div>
|
|
163
173
|
);
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -17,6 +17,12 @@ import { glassSurfaceClass } from "../lib/surface";
|
|
|
17
17
|
/** Matches `--nonla-dur-fast` exit animation; fallback if animationend is skipped. */
|
|
18
18
|
const EXIT_MS = 200;
|
|
19
19
|
|
|
20
|
+
const modalOverlayClass =
|
|
21
|
+
"nonla-modal-overlay fixed inset-0 z-(--nonla-z-modal) bg-(--mask) data-[state=open]:animate-[nonla-overlay-in_var(--nonla-dur)_var(--nonla-ease-out)] data-[state=closed]:pointer-events-none data-[state=closed]:animate-[nonla-overlay-out_var(--nonla-dur-fast)_var(--nonla-ease-in)_forwards]";
|
|
22
|
+
|
|
23
|
+
const modalContentClass =
|
|
24
|
+
"nonla-modal-content fixed top-[60px] left-1/2 z-[calc(var(--nonla-z-modal)+1)] flex w-[min(480px,calc(100vw-32px))] max-h-[calc(100vh-88px)] flex-col overflow-hidden rounded-[calc(var(--radius)+4px)] p-0 outline-none will-change-[transform,opacity] [transform:translate(-50%,0)] data-[state=open]:animate-[nonla-modal-in_var(--nonla-dur)_var(--nonla-ease-out)] data-[state=closed]:pointer-events-none data-[state=closed]:animate-[nonla-modal-out_var(--nonla-dur-fast)_var(--nonla-ease-in)_forwards] data-[centered=true]:top-1/2 data-[centered=true]:max-h-[calc(100vh-64px)] data-[centered=true]:[transform:translate(-50%,-50%)] data-[centered=true]:data-[state=open]:animate-[nonla-modal-in-centered_var(--nonla-dur)_var(--nonla-ease-out)] data-[centered=true]:data-[state=closed]:animate-[nonla-modal-out-centered_var(--nonla-dur-fast)_var(--nonla-ease-in)_forwards]";
|
|
25
|
+
|
|
20
26
|
export type ModalProps = {
|
|
21
27
|
open?: boolean;
|
|
22
28
|
visible?: boolean;
|
|
@@ -171,9 +177,9 @@ function ModalView({
|
|
|
171
177
|
>
|
|
172
178
|
{isOpen || present ? (
|
|
173
179
|
<Dialog.Portal container={portal}>
|
|
174
|
-
<Dialog.Overlay className=
|
|
180
|
+
<Dialog.Overlay className={modalOverlayClass} />
|
|
175
181
|
<Dialog.Content
|
|
176
|
-
className={cn(
|
|
182
|
+
className={cn(modalContentClass, glassSurfaceClass, className)}
|
|
177
183
|
data-centered={centered ? "true" : undefined}
|
|
178
184
|
style={{ width, ...style, ...styles?.container, ...styles?.content }}
|
|
179
185
|
onAnimationEnd={onContentAnimationEnd}
|
|
@@ -188,20 +194,20 @@ function ModalView({
|
|
|
188
194
|
}}
|
|
189
195
|
>
|
|
190
196
|
{(title || closable) && (
|
|
191
|
-
<div className="nonla-modal-header" style={styles?.header}>
|
|
192
|
-
<Dialog.Title className="nonla-modal-title">{title}</Dialog.Title>
|
|
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>
|
|
193
199
|
{closable ? (
|
|
194
|
-
<Dialog.Close className="nonla-modal-close" 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-muted hover:text-foreground" aria-label="Close">
|
|
195
201
|
×
|
|
196
202
|
</Dialog.Close>
|
|
197
203
|
) : null}
|
|
198
204
|
</div>
|
|
199
205
|
)}
|
|
200
|
-
<div className="nonla-modal-body" style={styles?.body}>
|
|
206
|
+
<div className="nonla-modal-body flex-1 overflow-auto bg-transparent px-4 pt-4 pb-6 text-sm leading-normal text-foreground" style={styles?.body}>
|
|
201
207
|
{body}
|
|
202
208
|
</div>
|
|
203
209
|
{defaultFooter != null ? (
|
|
204
|
-
<div className="nonla-modal-footer" style={styles?.footer}>
|
|
210
|
+
<div className="nonla-modal-footer flex shrink-0 items-center justify-end gap-2 bg-transparent px-4 py-2.5" style={styles?.footer}>
|
|
205
211
|
{typeof defaultFooter === "function" ? null : defaultFooter}
|
|
206
212
|
</div>
|
|
207
213
|
) : null}
|
|
@@ -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-solid
|
|
118
|
+
active ? "bg-brand font-medium text-(--nonla-text-on-solid)" : "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-
|
|
188
|
+
"text-center tabular-nums text-foreground placeholder:text-quaternary-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-
|
|
565
|
+
"text-center tabular-nums text-foreground placeholder:text-quaternary-foreground",
|
|
566
566
|
controlFieldSurface,
|
|
567
567
|
controlFieldTransition,
|
|
568
568
|
controlFieldFocusBorder,
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -106,7 +106,7 @@ export function Popover({
|
|
|
106
106
|
>
|
|
107
107
|
{title ? <div className="mb-2 text-sm font-medium">{title}</div> : null}
|
|
108
108
|
{content}
|
|
109
|
-
{showArrow ? <PopoverPrimitive.Arrow width={12} height={6} className="fill-
|
|
109
|
+
{showArrow ? <PopoverPrimitive.Arrow width={12} height={6} className="fill-card drop-shadow-[0_1px_0_var(--border)]" /> : null}
|
|
110
110
|
</PopoverPrimitive.Content>
|
|
111
111
|
</PopoverPrimitive.Portal>
|
|
112
112
|
</PopoverPrimitive.Root>
|
|
@@ -146,7 +146,7 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
|
|
|
146
146
|
|
|
147
147
|
const thumbVisible = visibility === "always" || dragging || scrolling;
|
|
148
148
|
const thumbClass = cn(
|
|
149
|
-
"
|
|
149
|
+
"absolute z-20 rounded-full bg-(--nonla-scrollbar-thumb) transition-opacity duration-150 group-hover/scroll:bg-(--nonla-scrollbar-thumb-hover)",
|
|
150
150
|
visibility === "always" || dragging
|
|
151
151
|
? "pointer-events-auto opacity-100"
|
|
152
152
|
: "pointer-events-none opacity-0 group-hover/scroll:pointer-events-auto group-hover/scroll:opacity-100 group-data-scrolling/scroll:pointer-events-auto group-data-scrolling/scroll:opacity-100",
|
|
@@ -157,7 +157,7 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
|
|
|
157
157
|
<div
|
|
158
158
|
ref={setNode}
|
|
159
159
|
onScroll={handleScroll}
|
|
160
|
-
className={cn("
|
|
160
|
+
className={cn("overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden [&::-webkit-scrollbar]:h-0 [&::-webkit-scrollbar]:w-0", autoHeight ? "max-h-[inherit]" : "absolute inset-0", innerClassName)}
|
|
161
161
|
>
|
|
162
162
|
{children}
|
|
163
163
|
</div>
|
|
@@ -71,7 +71,7 @@ export function Segmented<V extends string | number = string | number>({ options
|
|
|
71
71
|
{thumb ? (
|
|
72
72
|
<span
|
|
73
73
|
aria-hidden
|
|
74
|
-
className="nonla-segmented-thumb pointer-events-none absolute border border-solid border-border bg-card"
|
|
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"
|
|
75
75
|
style={{
|
|
76
76
|
width: thumb.width,
|
|
77
77
|
height: thumb.height,
|
package/src/select/Select.tsx
CHANGED
|
@@ -307,7 +307,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
|
|
|
307
307
|
}}
|
|
308
308
|
onKeyDown={onSearchKey}
|
|
309
309
|
className={cn(
|
|
310
|
-
"absolute inset-0 w-full border-0 bg-transparent p-0 font-[inherit] leading-[inherit] text-inherit outline-none placeholder:text-
|
|
310
|
+
"absolute inset-0 w-full border-0 bg-transparent p-0 font-[inherit] leading-[inherit] text-inherit outline-none placeholder:text-quaternary-foreground",
|
|
311
311
|
!open && "caret-transparent",
|
|
312
312
|
)}
|
|
313
313
|
/>
|
|
@@ -358,7 +358,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
|
|
|
358
358
|
style={controlFieldStyle(resolvedSize)}
|
|
359
359
|
onKeyDown={onTriggerKey}
|
|
360
360
|
>
|
|
361
|
-
<span className={cn("min-w-0 flex-1 truncate", displayEmpty && "text-
|
|
361
|
+
<span className={cn("min-w-0 flex-1 truncate", displayEmpty && "text-quaternary-foreground")}>{display}</span>
|
|
362
362
|
{showClear ? (
|
|
363
363
|
<span
|
|
364
364
|
role="button"
|
|
@@ -426,9 +426,9 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(function Select
|
|
|
426
426
|
data-highlighted={!opt.disabled && i === active && opt.value !== selected ? "" : undefined}
|
|
427
427
|
className={cn(
|
|
428
428
|
menuItemClass,
|
|
429
|
-
"cursor-pointer",
|
|
429
|
+
"cursor-pointer transition-[background-color] duration-20 ease-in motion-reduce:transition-none data-highlighted:border-transparent data-highlighted:bg-ink-hover",
|
|
430
430
|
opt.disabled && "pointer-events-none opacity-40",
|
|
431
|
-
!opt.disabled && opt.value === selected && "
|
|
431
|
+
!opt.disabled && opt.value === selected && "border-transparent bg-ink-active text-foreground shadow-none",
|
|
432
432
|
)}
|
|
433
433
|
onMouseEnter={() => setActive(i)}
|
|
434
434
|
onMouseDown={(e) => e.preventDefault()}
|
package/src/sidebar/Sidebar.tsx
CHANGED
|
@@ -11,8 +11,8 @@ export type SidebarItemType = {
|
|
|
11
11
|
/** Solar icon name (`settings`), a legacy Fluent Color id (`settings-24`), or a node. String icons render as bold-duotone. */
|
|
12
12
|
icon?: ReactNode;
|
|
13
13
|
disabled?: boolean;
|
|
14
|
+
/** `"group"` is a section label. `"divider"` is a rule. Anything else is a row. */
|
|
14
15
|
type?: "item" | "group" | "divider";
|
|
15
|
-
children?: SidebarItemType[];
|
|
16
16
|
href?: string;
|
|
17
17
|
extra?: ReactNode;
|
|
18
18
|
className?: string;
|
|
@@ -38,11 +38,7 @@ export type SidebarProps = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
function itemKey(item: SidebarItemType, i: number) {
|
|
41
|
-
return item.key ?? (item.type === "divider" ? `divider-${i}` :
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isGroup(item: SidebarItemType) {
|
|
45
|
-
return item.type === "group" || (item.type !== "item" && item.type !== "divider" && Boolean(item.children?.length));
|
|
41
|
+
return item.key ?? (item.type === "divider" ? `divider-${i}` : item.type === "group" ? `group-${i}` : `item-${i}`);
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
function labelText(label: ReactNode) {
|
|
@@ -51,26 +47,40 @@ function labelText(label: ReactNode) {
|
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
function matchesQuery(item: SidebarItemType, q: string) {
|
|
54
|
-
if (!q) return true;
|
|
55
50
|
return labelText(item.label).toLowerCase().includes(q);
|
|
56
51
|
}
|
|
57
52
|
|
|
53
|
+
/** A group label stays when it matches, or when a later row matches before the next group. */
|
|
58
54
|
function filterItems(items: SidebarItemType[], q: string): SidebarItemType[] {
|
|
59
55
|
if (!q) return items;
|
|
60
|
-
|
|
56
|
+
|
|
57
|
+
type Section = { group?: SidebarItemType; rows: SidebarItemType[] };
|
|
58
|
+
const sections: Section[] = [];
|
|
59
|
+
let current: Section = { rows: [] };
|
|
61
60
|
for (const item of items) {
|
|
62
|
-
if (item.type === "
|
|
63
|
-
if (
|
|
61
|
+
if (item.type === "group") {
|
|
62
|
+
if (current.group || current.rows.length) sections.push(current);
|
|
63
|
+
current = { group: item, rows: [] };
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
current.rows.push(item);
|
|
67
|
+
}
|
|
68
|
+
if (current.group || current.rows.length) sections.push(current);
|
|
69
|
+
|
|
70
|
+
const out: SidebarItemType[] = [];
|
|
71
|
+
for (const section of sections) {
|
|
72
|
+
const kept: SidebarItemType[] = [];
|
|
73
|
+
for (const row of section.rows) {
|
|
74
|
+
if (row.type === "divider") {
|
|
75
|
+
if (kept.length && kept[kept.length - 1]?.type !== "divider") kept.push(row);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (matchesQuery(row, q)) kept.push(row);
|
|
70
79
|
}
|
|
71
|
-
|
|
80
|
+
while (kept[kept.length - 1]?.type === "divider") kept.pop();
|
|
81
|
+
if (section.group && (matchesQuery(section.group, q) || kept.length)) out.push(section.group);
|
|
82
|
+
out.push(...kept);
|
|
72
83
|
}
|
|
73
|
-
while (out[out.length - 1]?.type === "divider") out.pop();
|
|
74
84
|
return out;
|
|
75
85
|
}
|
|
76
86
|
|
|
@@ -90,32 +100,25 @@ function SidebarList({
|
|
|
90
100
|
onSelect?: SidebarProps["onSelect"];
|
|
91
101
|
}) {
|
|
92
102
|
return (
|
|
93
|
-
|
|
103
|
+
<div className="flex flex-col gap-1">
|
|
94
104
|
{items.map((item, i) => {
|
|
95
105
|
const key = itemKey(item, i);
|
|
96
106
|
if (item.type === "divider") {
|
|
97
|
-
return <div key={key} className="mx-2 my-1 h-px bg-
|
|
107
|
+
return <div key={key} className="mx-2 my-1 h-px bg-border" />;
|
|
98
108
|
}
|
|
99
|
-
if (
|
|
109
|
+
if (item.type === "group") {
|
|
110
|
+
if (item.label == null || item.label === "") return null;
|
|
100
111
|
return (
|
|
101
|
-
<div key={key} className="
|
|
102
|
-
{item.label
|
|
103
|
-
<div className={cn("px-3 pb-2 pt-3 text-[11px] font-bold uppercase tracking-wider text-quaternary-foreground", item.className)}>
|
|
104
|
-
{item.label}
|
|
105
|
-
</div>
|
|
106
|
-
) : null}
|
|
107
|
-
<div className="flex flex-col gap-1">
|
|
108
|
-
<SidebarList items={item.children ?? []} selected={selected} onSelect={onSelect} />
|
|
109
|
-
</div>
|
|
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-4", item.className)}>
|
|
113
|
+
{item.label}
|
|
110
114
|
</div>
|
|
111
115
|
);
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
const active = selected != null && key === selected;
|
|
115
119
|
const className = cn(
|
|
116
|
-
"nonla-sidebar-item flex w-full items-center gap-3 px-3 text-left text-[
|
|
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",
|
|
117
121
|
item.disabled ? "pointer-events-none cursor-not-allowed opacity-40" : "cursor-pointer",
|
|
118
|
-
active ? "text-foreground" : "text-foreground/80 hover:text-foreground",
|
|
119
122
|
item.className,
|
|
120
123
|
);
|
|
121
124
|
|
|
@@ -151,11 +154,11 @@ function SidebarList({
|
|
|
151
154
|
</button>
|
|
152
155
|
);
|
|
153
156
|
})}
|
|
154
|
-
|
|
157
|
+
</div>
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
/**
|
|
161
|
+
/** Side nav from a flat list. `type: "group"` is a section label. Router stays in the app (`onSelect` / `href`). */
|
|
159
162
|
export function Sidebar({
|
|
160
163
|
items = [],
|
|
161
164
|
selectedKey,
|
|
@@ -17,11 +17,11 @@ function SkeletonRoot({ active = true, loading = true, paragraph = true, title =
|
|
|
17
17
|
const pulse = active ? "animate-pulse" : "";
|
|
18
18
|
return (
|
|
19
19
|
<div className={cn("flex gap-3", className)}>
|
|
20
|
-
{avatar ? <div className={cn("size-10 shrink-0 rounded-full bg-
|
|
20
|
+
{avatar ? <div className={cn("size-10 shrink-0 rounded-full bg-muted", pulse)} /> : null}
|
|
21
21
|
<div className="flex-1 space-y-2">
|
|
22
|
-
{title ? <div className={cn("h-4 w-1/3 rounded bg-
|
|
22
|
+
{title ? <div className={cn("h-4 w-1/3 rounded bg-muted", pulse)} /> : null}
|
|
23
23
|
{Array.from({ length: rows }, (_, i) => `sk-${i}`).map((key, i) => (
|
|
24
|
-
<div key={key} className={cn("h-3 rounded bg-
|
|
24
|
+
<div key={key} className={cn("h-3 rounded bg-muted", pulse, i === rows - 1 ? "w-2/3" : "w-full")} />
|
|
25
25
|
))}
|
|
26
26
|
</div>
|
|
27
27
|
</div>
|
|
@@ -38,7 +38,7 @@ export type SkeletonInputProps = {
|
|
|
38
38
|
function SkeletonInput({ active = true, block, className, style }: SkeletonInputProps) {
|
|
39
39
|
return (
|
|
40
40
|
<div
|
|
41
|
-
className={cn("h-8 rounded-md bg-
|
|
41
|
+
className={cn("h-8 rounded-md bg-muted", active && "animate-pulse", block ? "w-full" : "w-40", className)}
|
|
42
42
|
style={style}
|
|
43
43
|
/>
|
|
44
44
|
);
|
package/src/spin/Spin.tsx
CHANGED
|
@@ -105,7 +105,7 @@ function MatrixSnake({ size, color, tickMs = 240 }: { size: ControlSize | undefi
|
|
|
105
105
|
|
|
106
106
|
return (
|
|
107
107
|
<span
|
|
108
|
-
className=
|
|
108
|
+
className="inline-grid place-content-center"
|
|
109
109
|
style={{
|
|
110
110
|
width: dim,
|
|
111
111
|
height: dim,
|
|
@@ -116,7 +116,19 @@ function MatrixSnake({ size, color, tickMs = 240 }: { size: ControlSize | undefi
|
|
|
116
116
|
aria-hidden
|
|
117
117
|
>
|
|
118
118
|
{MATRIX_CELLS.map((cell) => (
|
|
119
|
-
<span
|
|
119
|
+
<span
|
|
120
|
+
key={cell}
|
|
121
|
+
className={cn(
|
|
122
|
+
"block size-full rounded-full transition-colors duration-120 ease-linear motion-reduce:transition-none",
|
|
123
|
+
color === "neutral"
|
|
124
|
+
? lit.has(cell)
|
|
125
|
+
? "bg-muted-foreground"
|
|
126
|
+
: "bg-[color-mix(in_oklab,var(--foreground)_16%,transparent)]"
|
|
127
|
+
: lit.has(cell)
|
|
128
|
+
? "bg-brand"
|
|
129
|
+
: "bg-[color-mix(in_oklab,var(--brand)_10%,transparent)]",
|
|
130
|
+
)}
|
|
131
|
+
/>
|
|
120
132
|
))}
|
|
121
133
|
</span>
|
|
122
134
|
);
|
|
@@ -301,7 +301,7 @@ function SplitterRoot({
|
|
|
301
301
|
{draggerIcon ? (
|
|
302
302
|
<span
|
|
303
303
|
className={cn(
|
|
304
|
-
"pointer-events-none absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-sm bg-card text-muted-foreground
|
|
304
|
+
"pointer-events-none absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-sm bg-card text-muted-foreground ring-1 ring-border",
|
|
305
305
|
isVertical ? "h-1.5 w-5" : "h-5 w-1.5",
|
|
306
306
|
)}
|
|
307
307
|
>
|