devnonla-ui 0.13.0 → 0.15.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/package.json +2 -2
- package/src/app/App.tsx +2 -2
- package/src/app/context.ts +1 -12
- package/src/avatar/avatar.css +107 -0
- package/src/blob-shape/BlobShape.tsx +337 -0
- package/src/button/Button.tsx +4 -4
- package/src/button/ButtonCopy.tsx +3 -3
- package/src/calendar/Calendar.tsx +1 -1
- package/src/card/Card.tsx +1 -1
- package/src/chat/AgentChatbox.tsx +1 -1
- package/src/chat/AgentPanel.tsx +1 -1
- package/src/chat/chatMessageList.tsx +5 -3
- package/src/chat/chatRhythm.ts +8 -0
- package/src/chat/common/createAgentSseSession.ts +9 -3
- package/src/chat/common/sse.ts +290 -122
- package/src/chat/common/useAgentStream.ts +1 -1
- package/src/chat/index.ts +2 -2
- package/src/chat/message-ui/ChatAgentMessage.tsx +4 -3
- package/src/chat/message-ui/ChatError.tsx +5 -4
- package/src/chat/message-ui/ChatInput.tsx +9 -8
- package/src/chat/message-ui/ChatMarkdown.tsx +36 -2
- package/src/chat/message-ui/ChatThinking.tsx +8 -7
- package/src/chat/message-ui/ChatUserMessage.tsx +5 -5
- package/src/chat/tool-ui/BackgroundTaskToolUI.tsx +7 -6
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +9 -9
- package/src/chat/tool-ui/CallAgentToolUI.tsx +16 -15
- package/src/chat/tool-ui/ChatToolCall.tsx +13 -12
- package/src/chat/tool-ui/GetCurrentTimeToolUI.tsx +7 -6
- package/src/chat/tool-ui/ReadSkillToolUI.tsx +10 -9
- package/src/chat/tool-ui/RunJsToolUI.tsx +9 -8
- package/src/chat/tool-ui/ToolUiBadge.tsx +1 -1
- package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
- package/src/chat/tool-ui/WebFetchToolUI.tsx +10 -9
- package/src/checkbox/Checkbox.tsx +2 -2
- package/src/codeblock/CodeBlock.tsx +1 -1
- package/src/colorpicker/ColorPicker.tsx +10 -8
- package/src/datepicker/DatePicker.tsx +3 -3
- package/src/desktop/DesktopHeader.tsx +2 -2
- package/src/desktop/DesktopIcon.tsx +3 -4
- 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/icon/Icon.tsx +21 -0
- package/src/icon/glyphs.ts +35 -0
- package/src/index.ts +9 -23
- package/src/input/EditableInput.tsx +5 -4
- 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/MarkdownEditor.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 +48 -11
- package/src/markdown-editor/MarkdownViewer.tsx +28 -31
- package/src/markdown-editor/MermaidBlock.tsx +5 -5
- package/src/markdown-editor/ReactCodeFrame.tsx +10 -6
- package/src/markdown-editor/ReactCodeSandbox.tsx +2 -2
- package/src/markdown-editor/markdownScale.ts +66 -127
- package/src/menu/Menu.tsx +3 -3
- package/src/message/message.tsx +18 -8
- package/src/modal/Modal.tsx +13 -7
- package/src/pagination/Pagination.tsx +7 -7
- package/src/popover/Popover.tsx +1 -1
- package/src/scroll/OverlayScroll.tsx +13 -5
- package/src/segmented/Segmented.tsx +1 -1
- package/src/select/Select.tsx +4 -4
- package/src/sidebar/Sidebar.tsx +39 -36
- 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 +188 -844
- package/src/table/Table.tsx +12 -12
- package/src/tabs/Tabs.tsx +76 -14
- package/src/tag/Tag.tsx +3 -3
- package/src/theme-switcher/ThemeSwitcher.tsx +6 -6
- package/src/theme.ts +53 -147
- package/src/timepicker/TimePicker.tsx +2 -2
- package/src/typography/Typography.tsx +8 -8
- package/src/icon/SolarIcon.tsx +0 -39
- package/src/icon/solar.ts +0 -172
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}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComponentType, type CSSProperties, cloneElement, isValidElement, type KeyboardEvent, type ReactElement, type ReactNode, useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Icon } from "../icon/Icon";
|
|
3
3
|
import { cn } from "../lib/cn";
|
|
4
4
|
import { type CanonicalSize, type ControlSize, controlFieldFocusBorder, controlFieldSurface, controlFieldTransition, controlHeightVar, controlRadiusVar, getSizeTokens, useControlSize } from "../lib/sizes";
|
|
5
5
|
import { Select, type SelectProps } from "../select/Select";
|
|
@@ -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={{
|
|
@@ -137,7 +137,7 @@ function JumpInner({ dir, icon }: { dir: "prev" | "next"; icon: number }) {
|
|
|
137
137
|
<span className="relative inline-flex size-full items-center justify-center">
|
|
138
138
|
<span className="leading-none group-hover:opacity-0 group-focus-visible:opacity-0">…</span>
|
|
139
139
|
<span className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100">
|
|
140
|
-
{dir === "prev" ? <
|
|
140
|
+
{dir === "prev" ? <Icon name="chevrons-left" size={icon} /> : <Icon name="chevrons-right" size={icon} />}
|
|
141
141
|
</span>
|
|
142
142
|
</span>
|
|
143
143
|
);
|
|
@@ -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,
|
|
@@ -369,8 +369,8 @@ export function Pagination(props: PaginationProps) {
|
|
|
369
369
|
|
|
370
370
|
const sizeOptions = toSizes(pageSizeOptions);
|
|
371
371
|
|
|
372
|
-
const prevInner = wrap(page - 1, "prev", <
|
|
373
|
-
const nextInner = wrap(page + 1, "next", <
|
|
372
|
+
const prevInner = wrap(page - 1, "prev", <Icon name="arrow-left" size={icon} />);
|
|
373
|
+
const nextInner = wrap(page + 1, "next", <Icon name="arrow-right" size={icon} />);
|
|
374
374
|
|
|
375
375
|
const pager = isSimple ? (
|
|
376
376
|
<>
|
|
@@ -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>
|
|
@@ -6,9 +6,13 @@ export type OverlayScrollVisibility = "hover" | "always";
|
|
|
6
6
|
const HIDE_MS = 1000;
|
|
7
7
|
const MIN_THUMB = 32;
|
|
8
8
|
|
|
9
|
+
export type OverlayScrollScope = "scroll" | "table";
|
|
10
|
+
|
|
9
11
|
export type OverlayScrollProps = {
|
|
10
12
|
/** `hover` shows the thumb on hover / while scrolling. `always` keeps it visible. */
|
|
11
13
|
visibility?: OverlayScrollVisibility;
|
|
14
|
+
/** Named hover group. `table` does not light up when a parent chat scroller is hovered. */
|
|
15
|
+
scope?: OverlayScrollScope;
|
|
12
16
|
/** Size to content (honors max-height on `className`) instead of filling the parent. */
|
|
13
17
|
autoHeight?: boolean;
|
|
14
18
|
className?: string;
|
|
@@ -46,7 +50,7 @@ function canScrollX(el: HTMLDivElement) {
|
|
|
46
50
|
return overflow === "auto" || overflow === "scroll";
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
export function OverlayScroll({ visibility = "hover", autoHeight = false, className, style, innerClassName, children, onScroll, scrollRef, insetTop = 0 }: OverlayScrollProps) {
|
|
53
|
+
export function OverlayScroll({ visibility = "hover", scope = "scroll", autoHeight = false, className, style, innerClassName, children, onScroll, scrollRef, insetTop = 0 }: OverlayScrollProps) {
|
|
50
54
|
const elRef = useRef<HTMLDivElement | null>(null);
|
|
51
55
|
const hideTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
52
56
|
const vThumbRef = useRef<Thumb>(HIDDEN);
|
|
@@ -146,18 +150,22 @@ export function OverlayScroll({ visibility = "hover", autoHeight = false, classN
|
|
|
146
150
|
|
|
147
151
|
const thumbVisible = visibility === "always" || dragging || scrolling;
|
|
148
152
|
const thumbClass = cn(
|
|
149
|
-
"
|
|
153
|
+
"absolute z-20 rounded-full bg-(--nonla-scrollbar-thumb) transition-opacity duration-150",
|
|
154
|
+
scope === "table" ? "group-hover/table:bg-(--nonla-scrollbar-thumb-hover)" : "group-hover/scroll:bg-(--nonla-scrollbar-thumb-hover)",
|
|
150
155
|
visibility === "always" || dragging
|
|
151
156
|
? "pointer-events-auto opacity-100"
|
|
152
|
-
:
|
|
157
|
+
: scope === "table"
|
|
158
|
+
? "pointer-events-none opacity-0 group-hover/table:pointer-events-auto group-hover/table:opacity-100 group-data-scrolling/table:pointer-events-auto group-data-scrolling/table:opacity-100"
|
|
159
|
+
: "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",
|
|
153
160
|
);
|
|
154
161
|
|
|
155
162
|
return (
|
|
156
|
-
<div className={cn("group/scroll relative min-h-0 min-w-0 w-full overflow-hidden", className)} style={style} data-scrolling={thumbVisible ? "true" : undefined}>
|
|
163
|
+
<div className={cn(scope === "table" ? "group/table" : "group/scroll", "relative min-h-0 min-w-0 w-full overflow-hidden", className)} style={style} data-scrolling={thumbVisible ? "true" : undefined}>
|
|
157
164
|
<div
|
|
158
165
|
ref={setNode}
|
|
159
166
|
onScroll={handleScroll}
|
|
160
|
-
className={cn("
|
|
167
|
+
className={cn("overflow-y-auto overflow-x-hidden [overflow-anchor:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden [&::-webkit-scrollbar]:h-0 [&::-webkit-scrollbar]:w-0", autoHeight ? "max-h-[inherit]" : "absolute inset-0", innerClassName)}
|
|
168
|
+
style={{ scrollbarWidth: "none" }}
|
|
161
169
|
>
|
|
162
170
|
{children}
|
|
163
171
|
</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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type MouseEvent, type ReactNode, useMemo, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { solarIconName } from "../icon/solar";
|
|
2
|
+
import { Icon, isIconName } from "../icon/Icon";
|
|
4
3
|
import { SearchInput } from "../input/SearchInput";
|
|
5
4
|
import { cn } from "../lib/cn";
|
|
6
5
|
import { OverlayScroll } from "../scroll/OverlayScroll";
|
|
@@ -8,11 +7,11 @@ import { OverlayScroll } from "../scroll/OverlayScroll";
|
|
|
8
7
|
export type SidebarItemType = {
|
|
9
8
|
key?: string;
|
|
10
9
|
label?: ReactNode;
|
|
11
|
-
/**
|
|
10
|
+
/** An `Icon` name, or a node. */
|
|
12
11
|
icon?: ReactNode;
|
|
13
12
|
disabled?: boolean;
|
|
13
|
+
/** `"group"` is a section label. `"divider"` is a rule. Anything else is a row. */
|
|
14
14
|
type?: "item" | "group" | "divider";
|
|
15
|
-
children?: SidebarItemType[];
|
|
16
15
|
href?: string;
|
|
17
16
|
extra?: ReactNode;
|
|
18
17
|
className?: string;
|
|
@@ -38,11 +37,7 @@ export type SidebarProps = {
|
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
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));
|
|
40
|
+
return item.key ?? (item.type === "divider" ? `divider-${i}` : item.type === "group" ? `group-${i}` : `item-${i}`);
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
function labelText(label: ReactNode) {
|
|
@@ -51,32 +46,47 @@ function labelText(label: ReactNode) {
|
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
function matchesQuery(item: SidebarItemType, q: string) {
|
|
54
|
-
if (!q) return true;
|
|
55
49
|
return labelText(item.label).toLowerCase().includes(q);
|
|
56
50
|
}
|
|
57
51
|
|
|
52
|
+
/** A group label stays when it matches, or when a later row matches before the next group. */
|
|
58
53
|
function filterItems(items: SidebarItemType[], q: string): SidebarItemType[] {
|
|
59
54
|
if (!q) return items;
|
|
60
|
-
|
|
55
|
+
|
|
56
|
+
type Section = { group?: SidebarItemType; rows: SidebarItemType[] };
|
|
57
|
+
const sections: Section[] = [];
|
|
58
|
+
let current: Section = { rows: [] };
|
|
61
59
|
for (const item of items) {
|
|
62
|
-
if (item.type === "
|
|
63
|
-
if (
|
|
60
|
+
if (item.type === "group") {
|
|
61
|
+
if (current.group || current.rows.length) sections.push(current);
|
|
62
|
+
current = { group: item, rows: [] };
|
|
64
63
|
continue;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
current.rows.push(item);
|
|
66
|
+
}
|
|
67
|
+
if (current.group || current.rows.length) sections.push(current);
|
|
68
|
+
|
|
69
|
+
const out: SidebarItemType[] = [];
|
|
70
|
+
for (const section of sections) {
|
|
71
|
+
const kept: SidebarItemType[] = [];
|
|
72
|
+
for (const row of section.rows) {
|
|
73
|
+
if (row.type === "divider") {
|
|
74
|
+
if (kept.length && kept[kept.length - 1]?.type !== "divider") kept.push(row);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (matchesQuery(row, q)) kept.push(row);
|
|
70
78
|
}
|
|
71
|
-
|
|
79
|
+
while (kept[kept.length - 1]?.type === "divider") kept.pop();
|
|
80
|
+
if (section.group && (matchesQuery(section.group, q) || kept.length)) out.push(section.group);
|
|
81
|
+
out.push(...kept);
|
|
72
82
|
}
|
|
73
|
-
while (out[out.length - 1]?.type === "divider") out.pop();
|
|
74
83
|
return out;
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
function ItemIcon({ icon }: { icon?: ReactNode }) {
|
|
78
87
|
if (icon == null || icon === false) return null;
|
|
79
|
-
if (
|
|
88
|
+
if (isIconName(icon)) return <Icon name={icon} size={16} />;
|
|
89
|
+
if (typeof icon === "string") return null;
|
|
80
90
|
return <span className="inline-flex size-4 shrink-0 items-center justify-center [&_img]:size-4 [&_svg]:size-4">{icon}</span>;
|
|
81
91
|
}
|
|
82
92
|
|
|
@@ -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-semibold 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-2", 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-[14px] font-normal no-underline",
|
|
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
|
>
|