devnonla-ui 0.14.0 → 0.16.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 +5 -2
- package/src/blob-shape/BlobShape.tsx +337 -0
- package/src/button/ButtonCopy.tsx +2 -2
- 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 +5 -5
- 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 +4 -4
- package/src/chat/tool-ui/BackgroundTaskToolUI.tsx +7 -6
- package/src/chat/tool-ui/BackgroundTasksBar.tsx +7 -7
- package/src/chat/tool-ui/CallAgentToolUI.tsx +14 -13
- 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 +8 -7
- package/src/chat/tool-ui/ToolUiTrailing.tsx +3 -3
- package/src/chat/tool-ui/WebFetchToolUI.tsx +10 -9
- package/src/codeblock/CodeBlock.tsx +1 -1
- package/src/desktop/DesktopIcon.tsx +3 -4
- package/src/icon/Icon.tsx +33 -0
- package/src/icon/glyphs.ts +42 -0
- package/src/index.ts +8 -20
- package/src/input/EditableInput.tsx +2 -2
- package/src/markdown-editor/MarkdownEditor.tsx +4 -4
- package/src/markdown-editor/MarkdownPreview.tsx +4 -4
- package/src/markdown-editor/MarkdownTable.tsx +67 -13
- package/src/markdown-editor/MarkdownViewer.tsx +25 -28
- package/src/markdown-editor/MermaidBlock.tsx +4 -4
- package/src/markdown-editor/ReactCodeFrame.tsx +2 -2
- package/src/markdown-editor/ReactCodeSandbox.tsx +2 -2
- package/src/markdown-editor/markdownScale.ts +65 -131
- package/src/menu/Menu.tsx +2 -2
- package/src/pagination/Pagination.tsx +4 -4
- package/src/scroll/OverlayScroll.tsx +13 -5
- package/src/sidebar/Sidebar.tsx +5 -5
- package/src/sortable-tree/SortableTree.tsx +599 -0
- package/src/styles.css +36 -16
- package/src/tabs/Tabs.tsx +75 -13
- package/src/theme-switcher/ThemeSwitcher.tsx +6 -6
- package/src/typography/Typography.tsx +4 -4
- package/src/icon/SolarIcon.tsx +0 -39
- package/src/icon/solar.ts +0 -172
|
@@ -1,149 +1,83 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
2
|
|
|
3
|
-
/** `docs` is the article scale. `chat` is the tighter thread scale. */
|
|
4
|
-
export type MarkdownVariant = "docs" | "chat";
|
|
5
|
-
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* One markdown scale. Body reads `text-md` (`--nonla-md-text-size`). Leading is 1.6.
|
|
5
|
+
* Tables always use `text-base`.
|
|
6
|
+
* Inline code and fenced code read `--nonla-mono-text-size`.
|
|
7
|
+
* Class fallbacks match these values when the variables are not set.
|
|
11
8
|
*/
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
}
|
|
9
|
+
export const markdownScaleStyle = {
|
|
10
|
+
"--md-body-size": "var(--nonla-md-text-size)",
|
|
11
|
+
"--md-body-leading": "calc(var(--nonla-md-text-size) * 1.6)",
|
|
12
|
+
"--md-h1-size": "32px",
|
|
13
|
+
"--md-h1-leading": "1.25",
|
|
14
|
+
"--md-h1-weight": "800",
|
|
15
|
+
"--md-h1-mt": "0px",
|
|
16
|
+
"--md-h1-mb": "12px",
|
|
17
|
+
"--md-h1-py": "3px",
|
|
18
|
+
"--md-h2-size": "26px",
|
|
19
|
+
"--md-h2-leading": "32px",
|
|
20
|
+
"--md-h2-weight": "600",
|
|
21
|
+
"--md-h2-mt": "24px",
|
|
22
|
+
"--md-h2-mb": "8px",
|
|
23
|
+
"--md-h2-py": "3px",
|
|
24
|
+
"--md-h3-size": "24px",
|
|
25
|
+
"--md-h3-leading": "32px",
|
|
26
|
+
"--md-h3-weight": "600",
|
|
27
|
+
"--md-h3-mt": "22px",
|
|
28
|
+
"--md-h3-mb": "8px",
|
|
29
|
+
"--md-h4-size": "20px",
|
|
30
|
+
"--md-h4-leading": "26px",
|
|
31
|
+
"--md-h4-weight": "700",
|
|
32
|
+
"--md-h4-mt": "16px",
|
|
33
|
+
"--md-h4-mb": "1px",
|
|
34
|
+
"--md-h5-size": "20px",
|
|
35
|
+
"--md-h5-leading": "26px",
|
|
36
|
+
"--md-h5-weight": "700",
|
|
37
|
+
"--md-h5-mt": "16px",
|
|
38
|
+
"--md-h5-mb": "1px",
|
|
39
|
+
"--md-h6-size": "20px",
|
|
40
|
+
"--md-h6-leading": "26px",
|
|
41
|
+
"--md-h6-weight": "700",
|
|
42
|
+
"--md-h6-mt": "16px",
|
|
43
|
+
"--md-h6-mb": "1px",
|
|
44
|
+
"--md-strong-weight": "600",
|
|
45
|
+
"--md-p-my": "1px",
|
|
46
|
+
"--md-p-py": "4px",
|
|
47
|
+
"--md-p-leading": "1.6",
|
|
48
|
+
"--md-list-my": "8px",
|
|
49
|
+
"--md-ul-pl": "4px",
|
|
50
|
+
"--md-ol-pl": "4px",
|
|
51
|
+
"--md-li-mt": "4px",
|
|
52
|
+
"--md-quote-my": "0px",
|
|
53
|
+
"--md-rule-my": "8px",
|
|
54
|
+
"--md-img-my": "4px",
|
|
55
|
+
"--md-table-my": "16px",
|
|
56
|
+
"--md-code-my": "8px",
|
|
57
|
+
"--md-code-size": "var(--nonla-mono-text-size)",
|
|
58
|
+
"--md-code-leading": "calc(var(--nonla-mono-text-size) * 1.6)",
|
|
59
|
+
"--md-inline-size": "var(--nonla-mono-text-size)",
|
|
60
|
+
"--md-item-pl": "4px",
|
|
61
|
+
"--md-nest": "1.25rem",
|
|
62
|
+
} as CSSProperties;
|
|
128
63
|
|
|
129
64
|
/**
|
|
130
65
|
* Article headings. A markdown `#` paints the same as `##`.
|
|
66
|
+
* `#####` and `######` paint the same as `####`.
|
|
131
67
|
* The large page title is `pageTitleClass`, used by Typography only.
|
|
132
68
|
*/
|
|
133
69
|
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,
|
|
135
|
-
if (level === 2) return "text-foreground mt-(--md-h2-mt,24px) mb-(--md-h2-mb,
|
|
136
|
-
if (level === 3) return "text-foreground mt-(--md-h3-mt,22px) mb-(--md-h3-mb,
|
|
137
|
-
|
|
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)";
|
|
70
|
+
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,26px) leading-(--md-h2-leading,32px) font-(--md-h2-weight,600)";
|
|
71
|
+
if (level === 2) return "text-foreground mt-(--md-h2-mt,24px) mb-(--md-h2-mb,8px) pt-(--md-h2-py,3px) pb-(--md-h2-py,3px) text-(length:--md-h2-size,26px) leading-(--md-h2-leading,32px) font-(--md-h2-weight,600)";
|
|
72
|
+
if (level === 3) return "text-foreground mt-(--md-h3-mt,22px) mb-(--md-h3-mb,8px) text-(length:--md-h3-size,24px) leading-(--md-h3-leading,32px) font-(--md-h3-weight,600)";
|
|
73
|
+
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)";
|
|
140
74
|
}
|
|
141
75
|
|
|
142
76
|
/** Landing and page title. Not used inside markdown. */
|
|
143
77
|
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
78
|
|
|
145
79
|
/** Body line. Same size and color as a markdown paragraph. */
|
|
146
|
-
export const markdownBodyClass = "text-(length:--md-body-size,16px) leading-(--md-body-leading,
|
|
80
|
+
export const markdownBodyClass = "text-(length:--md-body-size,var(--nonla-md-text-size,16px)) leading-(--md-body-leading,calc(var(--nonla-md-text-size,16px)*1.6)) text-foreground";
|
|
147
81
|
|
|
148
82
|
/** 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.
|
|
83
|
+
export const markdownParagraphClass = "nonla-typo m-0 my-(--md-p-my,1px) py-(--md-p-py,4px) text-(length:--md-body-size,var(--nonla-md-text-size,16px)) leading-(--md-p-leading,1.6) text-foreground";
|
package/src/menu/Menu.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Icon } from "../icon/Icon";
|
|
3
3
|
import { cn } from "../lib/cn";
|
|
4
4
|
import type { PopperPlacement } from "../lib/placement";
|
|
5
5
|
import { Popover } from "../popover/Popover";
|
|
@@ -48,7 +48,7 @@ export function MenuTrigger({ active, open, className, children, ...rest }: Menu
|
|
|
48
48
|
{...rest}
|
|
49
49
|
>
|
|
50
50
|
<span className="min-w-0 truncate leading-5">{children}</span>
|
|
51
|
-
<
|
|
51
|
+
<Icon name="arrow-down" size={12} className={cn("shrink-0 transition-transform duration-150", open && "rotate-180")} />
|
|
52
52
|
</button>
|
|
53
53
|
);
|
|
54
54
|
}
|
|
@@ -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";
|
|
@@ -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
|
);
|
|
@@ -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
|
<>
|
|
@@ -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
|
-
"absolute z-20 rounded-full bg-(--nonla-scrollbar-thumb) transition-opacity duration-150
|
|
153
|
+
"absolute z-20 rounded-full bg-(--nonla-scrollbar-thumb) transition-opacity 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("overflow-y-auto overflow-x-hidden [overflow-anchor:none] [
|
|
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>
|
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,7 +7,7 @@ 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;
|
|
14
13
|
/** `"group"` is a section label. `"divider"` is a rule. Anything else is a row. */
|
|
@@ -86,7 +85,8 @@ function filterItems(items: SidebarItemType[], q: string): SidebarItemType[] {
|
|
|
86
85
|
|
|
87
86
|
function ItemIcon({ icon }: { icon?: ReactNode }) {
|
|
88
87
|
if (icon == null || icon === false) return null;
|
|
89
|
-
if (
|
|
88
|
+
if (isIconName(icon)) return <Icon name={icon} size={16} />;
|
|
89
|
+
if (typeof icon === "string") return null;
|
|
90
90
|
return <span className="inline-flex size-4 shrink-0 items-center justify-center [&_img]:size-4 [&_svg]:size-4">{icon}</span>;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -109,7 +109,7 @@ function SidebarList({
|
|
|
109
109
|
if (item.type === "group") {
|
|
110
110
|
if (item.label == null || item.label === "") return null;
|
|
111
111
|
return (
|
|
112
|
-
<div key={key} className={cn("px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wider text-tertiary-foreground not-first:mt-
|
|
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
113
|
{item.label}
|
|
114
114
|
</div>
|
|
115
115
|
);
|