@vetta-org/theme-ui 0.1.2 → 0.2.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/package.json +8 -16
- package/src/action-approval/StorageCleanListView.test.tsx +36 -0
- package/src/action-approval/StorageCleanListView.tsx +52 -0
- package/src/action-approval/index.ts +2 -0
- package/src/activity/ActivityPanel.tsx +7 -1
- package/src/activity/ActivityPanelFrame.tsx +1 -1
- package/src/activity/BackgroundTasksTabPanelView.tsx +18 -2
- package/src/activity/BrowserPanelView.tsx +15 -1
- package/src/activity/BrowserSelectionView.tsx +199 -0
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +86 -10
- package/src/activity/index.ts +1 -0
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/EditDiffView.tsx +4 -4
- package/src/chat/HeaderActionBarView.tsx +135 -48
- package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
- package/src/chat/MessageFeedLayoutView.tsx +6 -5
- package/src/chat/MessageInputView.tsx +5 -1
- package/src/chat/index.ts +2 -1
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/chat/streaming-reveal.test.ts +1 -74
- package/src/chat/streaming-reveal.ts +0 -3
- package/src/file-preview/FilePreviewDialogView.tsx +2 -1
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/layout/ResizeHandle.tsx +4 -1
- package/src/layout/resize-handle-reset.test.tsx +50 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/MarkdownContent.tsx +61 -31
- package/src/markdown/MarkdownImage.tsx +6 -16
- package/src/markdown/MermaidBlock.tsx +50 -11
- package/src/markdown/UrlLinkBadge.tsx +84 -0
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +2 -0
- package/src/markdown/nodes.ts +6 -1
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +33 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +9 -0
- package/src/markdown/streaming-fade.test.ts +83 -0
- package/src/markdown/streaming-fade.tsx +141 -0
- package/src/markdown/streaming-reveal.ts +0 -67
- package/src/markdown/streaming.ts +64 -131
- package/src/overlays/CommandMenuRow.tsx +47 -26
- package/src/overlays/CommandMenuView.tsx +107 -15
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteImage.test.tsx +105 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +49 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +120 -7
- package/src/overlays/SplashPanel.tsx +4 -4
- package/src/overlays/SplashParts.tsx +6 -2
- package/src/overlays/UpdateCheckerView.tsx +17 -15
- package/src/overlays/UpdateRestartDialogView.tsx +76 -2
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/index.ts +13 -0
- package/src/plugin-ui/index.ts +4 -0
- package/src/project/DefaultConversationSectionView.tsx +17 -22
- package/src/project/DefaultSessionRowView.tsx +8 -0
- package/src/project/ManageSessionsSplashView.tsx +0 -2
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/GeneralSettingsView.tsx +21 -5
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +272 -0
- package/src/settings/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderRowView.tsx +37 -98
- package/src/settings/ShortcutsSettingsView.tsx +0 -4
- package/src/settings/SpaceEditorDialogView.tsx +94 -56
- package/src/settings/SpacesSettingsView.tsx +53 -8
- package/src/settings/StorageBar.tsx +70 -0
- package/src/settings/StorageExplorer.tsx +488 -0
- package/src/settings/StorageReadout.tsx +64 -0
- package/src/settings/StorageSettingsView.test.tsx +181 -0
- package/src/settings/StorageSettingsView.tsx +458 -0
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +28 -39
- package/src/settings/storage-treemap-layout.test.ts +32 -0
- package/src/settings/storage-treemap-layout.ts +55 -0
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +18 -11
- package/src/shared/StageDialogContent.test.tsx +61 -0
- package/src/shared/StageDialogContent.tsx +80 -0
- package/src/shared/TabBar.tsx +2 -2
- package/src/shared/VettaKbd.tsx +20 -1
- package/src/shared/index.ts +4 -1
- package/src/shared/platform.ts +9 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +13 -12
- package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/styles.css +7 -0
- package/src/markdown/streaming.test.ts +0 -57
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -43
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
- package/src/settings/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
2
|
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Switch, cn } from "@vetta-org/ui";
|
|
3
3
|
import { InputField } from "./SettingsFormFields";
|
|
4
4
|
|
|
@@ -9,13 +9,14 @@ export interface PresetProviderRowModelView {
|
|
|
9
9
|
readonly isOpen: boolean;
|
|
10
10
|
readonly adopted: boolean;
|
|
11
11
|
readonly enabled: boolean;
|
|
12
|
-
readonly autoKey: boolean;
|
|
13
12
|
readonly baseUrl?: string;
|
|
14
13
|
readonly offline: boolean;
|
|
15
14
|
readonly models: readonly unknown[];
|
|
16
15
|
readonly refreshing: boolean;
|
|
17
16
|
readonly hasApiKey: boolean;
|
|
18
17
|
readonly modelsError: string | null;
|
|
18
|
+
/** 由外部程序接入并管理(如 Magpie):只展示是否已接入,没有任何操作按钮。 */
|
|
19
|
+
readonly managedBy?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export interface PresetProviderRowViewLabels {
|
|
@@ -38,9 +39,13 @@ export interface PresetProviderRowViewLabels {
|
|
|
38
39
|
readonly refreshModels: string;
|
|
39
40
|
readonly refreshingModels: string;
|
|
40
41
|
readonly copyApiKey: string;
|
|
41
|
-
readonly editBaseUrl: string;
|
|
42
|
-
readonly baseUrlPlaceholder: string;
|
|
43
42
|
readonly toggleProvider: (name: string) => string;
|
|
43
|
+
/** 外部管理且已接入时,副标题里模型数后面的说明,如「由 Magpie 管理」。 */
|
|
44
|
+
readonly managedConnected: string;
|
|
45
|
+
/** 外部管理但还没接入时的副标题,告诉用户去哪里接入。 */
|
|
46
|
+
readonly managedNotConnected: string;
|
|
47
|
+
/** 外部管理的行右侧按钮,打开接入说明。 */
|
|
48
|
+
readonly managedGuide: string;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export interface PresetProviderRowViewProps {
|
|
@@ -53,11 +58,11 @@ export interface PresetProviderRowViewProps {
|
|
|
53
58
|
readonly onDraftKeyChange: (key: string) => void;
|
|
54
59
|
readonly onAdopt: () => void;
|
|
55
60
|
readonly onToggleEnabled: (next: boolean) => void;
|
|
56
|
-
/** 返回是否已保存;保存成功后关闭地址弹窗。 */
|
|
57
|
-
readonly onChangeBaseUrl: (url: string) => Promise<boolean>;
|
|
58
61
|
readonly onRemove: () => void;
|
|
59
62
|
readonly onRefreshModels: () => void;
|
|
60
63
|
readonly onCopyApiKey: () => void;
|
|
64
|
+
/** 外部管理的行(如 Magpie)打开接入说明;不传则不显示按钮。 */
|
|
65
|
+
readonly onOpenManagedGuide?: () => void;
|
|
61
66
|
readonly icon: ReactNode;
|
|
62
67
|
readonly modelsList?: ReactNode;
|
|
63
68
|
}
|
|
@@ -72,30 +77,22 @@ export function PresetProviderRowView({
|
|
|
72
77
|
onDraftKeyChange,
|
|
73
78
|
onAdopt,
|
|
74
79
|
onToggleEnabled,
|
|
75
|
-
onChangeBaseUrl,
|
|
76
80
|
onRemove,
|
|
77
81
|
onRefreshModels,
|
|
78
82
|
onCopyApiKey,
|
|
83
|
+
onOpenManagedGuide,
|
|
79
84
|
icon,
|
|
80
85
|
modelsList,
|
|
81
86
|
}: PresetProviderRowViewProps): JSX.Element {
|
|
87
|
+
// 外部管理的(如 Magpie)只在对方那边开关,这里不给任何操作。
|
|
88
|
+
const managed = Boolean(row.managedBy);
|
|
82
89
|
// 已下线的旧条目不在内置目录里,给不了 key 也拉不到模型。
|
|
83
|
-
const canEditKey = !
|
|
90
|
+
const canEditKey = !managed && !row.offline;
|
|
84
91
|
const keyDialogOpen = canEditKey && row.isOpen;
|
|
85
|
-
// 内置密钥的服务(如 Magpie)不填 key,但地址(端口)要能改。
|
|
86
|
-
const canEditUrl = row.autoKey && !row.offline;
|
|
87
|
-
const [urlDraft, setUrlDraft] = useState<string | null>(null);
|
|
88
|
-
const urlDialogOpen = canEditUrl && urlDraft !== null;
|
|
89
92
|
|
|
90
93
|
const tryAdopt = (): void => {
|
|
91
94
|
if (draftKey.trim() && !saving) onAdopt();
|
|
92
95
|
};
|
|
93
|
-
// 内置服务(Magpie)只开放端口:主机与路径固定,草稿里只放端口号。
|
|
94
|
-
const portValid = urlDraft !== null && /^\d{1,5}$/.test(urlDraft) && Number(urlDraft) >= 1 && Number(urlDraft) <= 65535;
|
|
95
|
-
const submitUrl = async (): Promise<void> => {
|
|
96
|
-
if (urlDraft === null || !portValid || saving || !row.baseUrl) return;
|
|
97
|
-
if (await onChangeBaseUrl(withPort(row.baseUrl, urlDraft))) setUrlDraft(null);
|
|
98
|
-
};
|
|
99
96
|
|
|
100
97
|
return (
|
|
101
98
|
<div className="border-b border-border last:border-b-0">
|
|
@@ -129,14 +126,31 @@ export function PresetProviderRowView({
|
|
|
129
126
|
)}
|
|
130
127
|
</div>
|
|
131
128
|
<div className="mt-0.5 truncate text-[11px] text-muted-foreground">
|
|
132
|
-
{
|
|
133
|
-
|
|
129
|
+
{managed && !row.adopted ? (
|
|
130
|
+
labels.managedNotConnected
|
|
131
|
+
) : (
|
|
132
|
+
<>
|
|
133
|
+
{labels.modelsCount(row.models.length)}
|
|
134
|
+
{managed ? ` · ${labels.managedConnected}` : ""}
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
134
137
|
</div>
|
|
135
138
|
</div>
|
|
136
139
|
</button>
|
|
137
140
|
|
|
138
141
|
<div className="flex h-8 items-center justify-end gap-1.5">
|
|
139
|
-
{
|
|
142
|
+
{managed && onOpenManagedGuide && (
|
|
143
|
+
<Button
|
|
144
|
+
variant="ghost"
|
|
145
|
+
size="sm"
|
|
146
|
+
onClick={onOpenManagedGuide}
|
|
147
|
+
className="h-7 gap-1 rounded-full px-2.5 text-[12px] text-muted-foreground hover:text-foreground"
|
|
148
|
+
>
|
|
149
|
+
<span className="icon-[mdi--help-circle-outline] h-3.5 w-3.5" />
|
|
150
|
+
{labels.managedGuide}
|
|
151
|
+
</Button>
|
|
152
|
+
)}
|
|
153
|
+
{row.adopted && !row.offline && !managed && (
|
|
140
154
|
<Button
|
|
141
155
|
variant="ghost"
|
|
142
156
|
size="icon-sm"
|
|
@@ -160,19 +174,7 @@ export function PresetProviderRowView({
|
|
|
160
174
|
<span className={cn("h-3.5 w-3.5", row.adopted ? "icon-[mdi--key-outline]" : "icon-[mdi--key-plus]")} />
|
|
161
175
|
</Button>
|
|
162
176
|
)}
|
|
163
|
-
{
|
|
164
|
-
<Button
|
|
165
|
-
variant="ghost"
|
|
166
|
-
size="icon-sm"
|
|
167
|
-
onClick={() => setUrlDraft(portOf(row.baseUrl))}
|
|
168
|
-
title={labels.editBaseUrl}
|
|
169
|
-
aria-label={labels.editBaseUrl}
|
|
170
|
-
className="text-muted-foreground hover:text-foreground"
|
|
171
|
-
>
|
|
172
|
-
<span className="icon-[mdi--link-variant] h-3.5 w-3.5" />
|
|
173
|
-
</Button>
|
|
174
|
-
)}
|
|
175
|
-
{row.adopted && !row.autoKey && (
|
|
177
|
+
{row.adopted && !managed && (
|
|
176
178
|
<Button
|
|
177
179
|
variant="ghost"
|
|
178
180
|
size="icon-sm"
|
|
@@ -184,7 +186,7 @@ export function PresetProviderRowView({
|
|
|
184
186
|
<span className="icon-[mdi--delete-outline] h-3.5 w-3.5" />
|
|
185
187
|
</Button>
|
|
186
188
|
)}
|
|
187
|
-
{!row.offline && (
|
|
189
|
+
{!row.offline && !managed && (
|
|
188
190
|
<Switch
|
|
189
191
|
size="sm"
|
|
190
192
|
checked={row.enabled}
|
|
@@ -257,69 +259,6 @@ export function PresetProviderRowView({
|
|
|
257
259
|
</DialogFooter>
|
|
258
260
|
</DialogContent>
|
|
259
261
|
</Dialog>
|
|
260
|
-
|
|
261
|
-
<Dialog open={urlDialogOpen} onOpenChange={(next) => !next && !saving && setUrlDraft(null)}>
|
|
262
|
-
<DialogContent className="sm:max-w-[420px]">
|
|
263
|
-
<DialogHeader>
|
|
264
|
-
<DialogTitle>{row.displayName}</DialogTitle>
|
|
265
|
-
<DialogDescription>{labels.editBaseUrl}</DialogDescription>
|
|
266
|
-
</DialogHeader>
|
|
267
|
-
<div className="flex flex-col gap-2">
|
|
268
|
-
<span className="text-[14px] font-medium text-foreground">
|
|
269
|
-
{labels.baseUrlPlaceholder}
|
|
270
|
-
</span>
|
|
271
|
-
<div className="flex items-center gap-2">
|
|
272
|
-
<span className="shrink-0 text-[14px] text-muted-foreground">{hostPrefix(row.baseUrl)}</span>
|
|
273
|
-
<InputField
|
|
274
|
-
value={urlDraft ?? ""}
|
|
275
|
-
onChange={(value) => setUrlDraft(value.replace(/\D/g, "").slice(0, 5))}
|
|
276
|
-
placeholder={labels.baseUrlPlaceholder}
|
|
277
|
-
disabled={saving}
|
|
278
|
-
autoFocus
|
|
279
|
-
aria-label={labels.editBaseUrl}
|
|
280
|
-
className="h-10 w-28 rounded-xl px-3.5 text-[15px] md:text-[15px]"
|
|
281
|
-
onKeyDown={(event) => {
|
|
282
|
-
if (event.key === "Enter") {
|
|
283
|
-
event.preventDefault();
|
|
284
|
-
void submitUrl();
|
|
285
|
-
}
|
|
286
|
-
}}
|
|
287
|
-
/>
|
|
288
|
-
</div>
|
|
289
|
-
</div>
|
|
290
|
-
<DialogFooter>
|
|
291
|
-
<Button variant="ghost" size="sm" onClick={() => setUrlDraft(null)} disabled={saving}>
|
|
292
|
-
{labels.cancel}
|
|
293
|
-
</Button>
|
|
294
|
-
<Button variant="primary" size="sm" onClick={() => void submitUrl()} disabled={!portValid || saving}>
|
|
295
|
-
{labels.save}
|
|
296
|
-
</Button>
|
|
297
|
-
</DialogFooter>
|
|
298
|
-
</DialogContent>
|
|
299
|
-
</Dialog>
|
|
300
262
|
</div>
|
|
301
263
|
);
|
|
302
264
|
}
|
|
303
|
-
|
|
304
|
-
function portOf(baseUrl: string | undefined): string {
|
|
305
|
-
try {
|
|
306
|
-
return baseUrl ? new URL(baseUrl).port : "";
|
|
307
|
-
} catch {
|
|
308
|
-
return "";
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/** 端口输入框左侧的固定前缀,如 `http://127.0.0.1:`。 */
|
|
313
|
-
function hostPrefix(baseUrl: string | undefined): string {
|
|
314
|
-
try {
|
|
315
|
-
return baseUrl ? `${new URL(baseUrl).protocol}//${new URL(baseUrl).hostname}:` : "";
|
|
316
|
-
} catch {
|
|
317
|
-
return "";
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function withPort(baseUrl: string, port: string): string {
|
|
322
|
-
const url = new URL(baseUrl);
|
|
323
|
-
url.port = port;
|
|
324
|
-
return url.toString().replace(/\/$/, "");
|
|
325
|
-
}
|
|
@@ -18,7 +18,6 @@ export interface ShortcutsSettingsViewProps {
|
|
|
18
18
|
readonly aiAssistSlot: ReactNode;
|
|
19
19
|
readonly onResetAll: () => void;
|
|
20
20
|
readonly shortcutActions: readonly ShortcutActionRowView[];
|
|
21
|
-
readonly quickPanelSection: ReactNode;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export function ShortcutsSettingsView({
|
|
@@ -30,7 +29,6 @@ export function ShortcutsSettingsView({
|
|
|
30
29
|
aiAssistSlot,
|
|
31
30
|
onResetAll,
|
|
32
31
|
shortcutActions,
|
|
33
|
-
quickPanelSection,
|
|
34
32
|
}: ShortcutsSettingsViewProps): JSX.Element {
|
|
35
33
|
return (
|
|
36
34
|
<div className="mx-auto w-full max-w-[680px] px-8 pt-2 pb-4">
|
|
@@ -58,8 +56,6 @@ export function ShortcutsSettingsView({
|
|
|
58
56
|
))}
|
|
59
57
|
</SettingSection>
|
|
60
58
|
|
|
61
|
-
{quickPanelSection}
|
|
62
|
-
|
|
63
59
|
<p className="mt-4 text-[12px] leading-relaxed text-muted-foreground/50">{shortcutHint}</p>
|
|
64
60
|
</div>
|
|
65
61
|
);
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
DialogFooter,
|
|
9
9
|
DialogHeader,
|
|
10
10
|
DialogTitle,
|
|
11
|
+
Switch,
|
|
11
12
|
} from "@vetta-org/ui";
|
|
13
|
+
import spaceEditorIllustrationUrl from "./assets/space-editor-illustration.webp";
|
|
12
14
|
import { InputField } from "./SettingsFormFields";
|
|
13
15
|
|
|
14
16
|
export interface SpaceEditorIconOption {
|
|
@@ -23,6 +25,8 @@ export interface SpaceEditorDialogViewLabels {
|
|
|
23
25
|
readonly name: string;
|
|
24
26
|
readonly namePlaceholder: string;
|
|
25
27
|
readonly icon: string;
|
|
28
|
+
readonly siblingProjects: string;
|
|
29
|
+
readonly siblingProjectsDescription: string;
|
|
26
30
|
readonly cancel: string;
|
|
27
31
|
readonly save: string;
|
|
28
32
|
}
|
|
@@ -32,9 +36,12 @@ export interface SpaceEditorDialogViewProps {
|
|
|
32
36
|
readonly name: string;
|
|
33
37
|
readonly icons: readonly SpaceEditorIconOption[];
|
|
34
38
|
readonly selectedIcon: string;
|
|
39
|
+
/** 空间内的会话能否看见同空间的兄弟项目(ADR-0159)。 */
|
|
40
|
+
readonly siblingProjects: boolean;
|
|
35
41
|
readonly canSave: boolean;
|
|
36
42
|
readonly onNameChange: (name: string) => void;
|
|
37
43
|
readonly onSelectIcon: (value: string) => void;
|
|
44
|
+
readonly onSiblingProjectsChange: (enabled: boolean) => void;
|
|
38
45
|
readonly onCancel: () => void;
|
|
39
46
|
readonly onSave: () => void;
|
|
40
47
|
}
|
|
@@ -44,9 +51,11 @@ export function SpaceEditorDialogView({
|
|
|
44
51
|
name,
|
|
45
52
|
icons,
|
|
46
53
|
selectedIcon,
|
|
54
|
+
siblingProjects,
|
|
47
55
|
canSave,
|
|
48
56
|
onNameChange,
|
|
49
57
|
onSelectIcon,
|
|
58
|
+
onSiblingProjectsChange,
|
|
50
59
|
onCancel,
|
|
51
60
|
onSave,
|
|
52
61
|
}: SpaceEditorDialogViewProps): JSX.Element {
|
|
@@ -57,63 +66,92 @@ export function SpaceEditorDialogView({
|
|
|
57
66
|
if (!open) onCancel();
|
|
58
67
|
}}
|
|
59
68
|
>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<div className="grid
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
aria-label={option.label}
|
|
94
|
-
title={option.label}
|
|
95
|
-
aria-pressed={active}
|
|
96
|
-
className={cn(
|
|
97
|
-
"text-muted-foreground",
|
|
98
|
-
active && "border border-primary bg-primary/10 text-primary hover:bg-primary/15",
|
|
99
|
-
)}
|
|
100
|
-
onClick={() => onSelectIcon(option.value)}
|
|
101
|
-
>
|
|
102
|
-
<span className={cn(option.iconClassName, "size-4")} aria-hidden="true" />
|
|
103
|
-
</Button>
|
|
104
|
-
);
|
|
105
|
-
})}
|
|
69
|
+
{/* 宽窗口左侧放插画;窗口窄于 sm 时只留表单,避免挤压输入区。 */}
|
|
70
|
+
<DialogContent className="max-w-[min(460px,calc(100%-2rem))] gap-0 overflow-hidden p-0 sm:max-w-[min(700px,calc(100%-2rem))] sm:grid-cols-[240px_minmax(0,1fr)]">
|
|
71
|
+
{/* 插画绝对定位铺满左列,高度只跟表单走,不让图片的原始比例撑高对话框。 */}
|
|
72
|
+
<div aria-hidden className="relative hidden sm:block">
|
|
73
|
+
<img
|
|
74
|
+
src={spaceEditorIllustrationUrl}
|
|
75
|
+
alt=""
|
|
76
|
+
draggable={false}
|
|
77
|
+
decoding="async"
|
|
78
|
+
className="absolute inset-0 size-full object-cover object-[50%_62%] select-none"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<div className="grid gap-5 p-6">
|
|
82
|
+
<DialogHeader>
|
|
83
|
+
<DialogTitle>{labels.title}</DialogTitle>
|
|
84
|
+
<DialogDescription>{labels.description}</DialogDescription>
|
|
85
|
+
</DialogHeader>
|
|
86
|
+
<form
|
|
87
|
+
className="grid gap-4"
|
|
88
|
+
onSubmit={(event) => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
if (canSave) onSave();
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<div className="grid gap-1.5">
|
|
94
|
+
<span className="text-[12px] font-medium text-muted-foreground">{labels.name}</span>
|
|
95
|
+
<InputField
|
|
96
|
+
value={name}
|
|
97
|
+
onChange={onNameChange}
|
|
98
|
+
placeholder={labels.namePlaceholder}
|
|
99
|
+
autoFocus
|
|
100
|
+
aria-label={labels.name}
|
|
101
|
+
/>
|
|
106
102
|
</div>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
103
|
+
<div className="grid gap-1.5">
|
|
104
|
+
<span className="text-[12px] font-medium text-muted-foreground">{labels.icon}</span>
|
|
105
|
+
<div className="grid grid-cols-10 gap-1" role="group" aria-label={labels.icon}>
|
|
106
|
+
{icons.map((option) => {
|
|
107
|
+
const active = option.value === selectedIcon;
|
|
108
|
+
return (
|
|
109
|
+
<Button
|
|
110
|
+
key={option.value}
|
|
111
|
+
type="button"
|
|
112
|
+
size="icon-sm"
|
|
113
|
+
variant="ghost"
|
|
114
|
+
aria-label={option.label}
|
|
115
|
+
title={option.label}
|
|
116
|
+
aria-pressed={active}
|
|
117
|
+
className={cn(
|
|
118
|
+
"text-muted-foreground",
|
|
119
|
+
active && "border border-primary bg-primary/10 text-primary hover:bg-primary/15",
|
|
120
|
+
)}
|
|
121
|
+
onClick={() => onSelectIcon(option.value)}
|
|
122
|
+
>
|
|
123
|
+
<span className={cn(option.iconClassName, "size-4")} aria-hidden="true" />
|
|
124
|
+
</Button>
|
|
125
|
+
);
|
|
126
|
+
})}
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
<div className="flex items-start justify-between gap-4 rounded-lg border border-border/60 px-3 py-2.5">
|
|
130
|
+
<div className="grid gap-0.5">
|
|
131
|
+
<span id="space-editor-sibling-projects" className="text-[13px] font-medium text-foreground">
|
|
132
|
+
{labels.siblingProjects}
|
|
133
|
+
</span>
|
|
134
|
+
<span className="text-[12px] leading-relaxed text-muted-foreground">
|
|
135
|
+
{labels.siblingProjectsDescription}
|
|
136
|
+
</span>
|
|
137
|
+
</div>
|
|
138
|
+
<Switch
|
|
139
|
+
className="mt-0.5 shrink-0"
|
|
140
|
+
checked={siblingProjects}
|
|
141
|
+
onCheckedChange={onSiblingProjectsChange}
|
|
142
|
+
aria-labelledby="space-editor-sibling-projects"
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
145
|
+
<DialogFooter>
|
|
146
|
+
<Button type="button" variant="ghost" onClick={onCancel}>
|
|
147
|
+
{labels.cancel}
|
|
148
|
+
</Button>
|
|
149
|
+
<Button type="submit" disabled={!canSave}>
|
|
150
|
+
{labels.save}
|
|
151
|
+
</Button>
|
|
152
|
+
</DialogFooter>
|
|
153
|
+
</form>
|
|
154
|
+
</div>
|
|
117
155
|
</DialogContent>
|
|
118
156
|
</Dialog>
|
|
119
157
|
);
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import { Button } from "@vetta-org/ui";
|
|
2
|
+
import { Button, cn } from "@vetta-org/ui";
|
|
3
3
|
import { SettingSection, type SettingSectionMeta } from "./SettingChrome";
|
|
4
4
|
|
|
5
|
+
export interface SpacesFeatureView {
|
|
6
|
+
readonly icon: string;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
export interface SpacesSettingsViewItem {
|
|
6
12
|
readonly id: string;
|
|
7
13
|
readonly name: string;
|
|
@@ -10,6 +16,10 @@ export interface SpacesSettingsViewItem {
|
|
|
10
16
|
|
|
11
17
|
export interface SpacesSettingsViewLabels {
|
|
12
18
|
readonly title: string;
|
|
19
|
+
/** 标题下的一句话:工作空间是什么。 */
|
|
20
|
+
readonly subtitle: string;
|
|
21
|
+
readonly featuresTitle: string;
|
|
22
|
+
readonly listTitle: string;
|
|
13
23
|
readonly newSpace: string;
|
|
14
24
|
readonly edit: (name: string) => string;
|
|
15
25
|
readonly remove: (name: string) => string;
|
|
@@ -20,6 +30,8 @@ export interface SpacesSettingsViewLabels {
|
|
|
20
30
|
export interface SpacesSettingsViewProps {
|
|
21
31
|
readonly labels: SpacesSettingsViewLabels;
|
|
22
32
|
readonly section: SettingSectionMeta;
|
|
33
|
+
/** 顶部讲解:工作空间怎么用、会影响什么。 */
|
|
34
|
+
readonly features: readonly SpacesFeatureView[];
|
|
23
35
|
readonly spaces: readonly SpacesSettingsViewItem[];
|
|
24
36
|
readonly onCreate: () => void;
|
|
25
37
|
readonly onEdit: (id: string) => void;
|
|
@@ -35,9 +47,16 @@ function SpaceIconBadge({ children }: { children: ReactNode }): JSX.Element {
|
|
|
35
47
|
);
|
|
36
48
|
}
|
|
37
49
|
|
|
50
|
+
/**
|
|
51
|
+
* 设置 → 工作空间。
|
|
52
|
+
*
|
|
53
|
+
* 只看列表的话,用户不知道工作空间是「侧栏分组」还是会挪动磁盘上的目录,也找不到切换入口;
|
|
54
|
+
* 所以和「启动器」页一样,先用一句话 + 分行讲解交代清楚,再给管理列表。
|
|
55
|
+
*/
|
|
38
56
|
export function SpacesSettingsView({
|
|
39
57
|
labels,
|
|
40
58
|
section,
|
|
59
|
+
features,
|
|
41
60
|
spaces,
|
|
42
61
|
onCreate,
|
|
43
62
|
onEdit,
|
|
@@ -46,15 +65,41 @@ export function SpacesSettingsView({
|
|
|
46
65
|
}: SpacesSettingsViewProps): JSX.Element {
|
|
47
66
|
return (
|
|
48
67
|
<div className="mx-auto w-full max-w-[680px] px-8 pt-2 pb-4">
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
<h1 className="mb-1.5 text-[20px] font-bold text-foreground">{labels.title}</h1>
|
|
69
|
+
<p className="mb-6 text-[13px] leading-relaxed text-muted-foreground">{labels.subtitle}</p>
|
|
70
|
+
|
|
71
|
+
<div className="mb-8">
|
|
72
|
+
<h2 className="mb-3 text-[15px] font-semibold text-foreground">{labels.featuresTitle}</h2>
|
|
73
|
+
<ul className="overflow-hidden rounded-xl border border-border bg-card">
|
|
74
|
+
{features.map((feature) => (
|
|
75
|
+
<li
|
|
76
|
+
key={feature.title}
|
|
77
|
+
className="flex items-center gap-3 border-b border-border px-4 py-3 last:border-b-0"
|
|
78
|
+
>
|
|
79
|
+
<span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">
|
|
80
|
+
<span aria-hidden="true" className={cn(feature.icon, "h-4 w-4")} />
|
|
81
|
+
</span>
|
|
82
|
+
<div className="min-w-0 flex-1">
|
|
83
|
+
<div className="text-[13px] font-medium text-foreground">{feature.title}</div>
|
|
84
|
+
<p className="mt-0.5 text-[12px] text-muted-foreground">{feature.description}</p>
|
|
85
|
+
</div>
|
|
86
|
+
</li>
|
|
87
|
+
))}
|
|
88
|
+
</ul>
|
|
55
89
|
</div>
|
|
56
90
|
|
|
57
|
-
<SettingSection
|
|
91
|
+
<SettingSection
|
|
92
|
+
section={section}
|
|
93
|
+
title={
|
|
94
|
+
<div className="flex items-center justify-between gap-3">
|
|
95
|
+
<span>{labels.listTitle}</span>
|
|
96
|
+
<Button size="sm" onClick={onCreate}>
|
|
97
|
+
<span className="icon-[solar--add-circle-linear] size-4" aria-hidden="true" />
|
|
98
|
+
{labels.newSpace}
|
|
99
|
+
</Button>
|
|
100
|
+
</div>
|
|
101
|
+
}
|
|
102
|
+
>
|
|
58
103
|
<div className="flex items-center gap-3 border-b border-border px-5 py-3.5">
|
|
59
104
|
<SpaceIconBadge>{labels.main.icon}</SpaceIconBadge>
|
|
60
105
|
<div className="min-w-0 flex-1 text-[13px] font-medium text-foreground">{labels.main.name}</div>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
|
|
4
|
+
export interface StorageBarSegment {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly bytes: number;
|
|
7
|
+
/** 只用主题变量拼出来的颜色。 */
|
|
8
|
+
readonly color: string;
|
|
9
|
+
/** 用斜线纹理代替实色,表示这部分可以腾出来。 */
|
|
10
|
+
readonly hatched?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** 斜线纹理:color 为线条色,底色由调用方决定。 */
|
|
14
|
+
export const hatch = (color: string): string =>
|
|
15
|
+
`repeating-linear-gradient(135deg, ${color} 0 2px, transparent 2px 7px)`;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 分段占用条:一段一类,宽度按体积分配。纯示意图,信息与键盘操作都在图例里。
|
|
19
|
+
* 清理后各段按比例回缩,右侧用浅底露出空出来的部分。
|
|
20
|
+
*/
|
|
21
|
+
export function StorageBar({
|
|
22
|
+
segments,
|
|
23
|
+
capacityBytes,
|
|
24
|
+
activeId,
|
|
25
|
+
onActiveChange,
|
|
26
|
+
}: {
|
|
27
|
+
readonly segments: readonly StorageBarSegment[];
|
|
28
|
+
/** 整条代表的体积;比各段之和大时,右侧露出空的部分。 */
|
|
29
|
+
readonly capacityBytes: number;
|
|
30
|
+
readonly activeId: string | null;
|
|
31
|
+
readonly onActiveChange: (id: string | null) => void;
|
|
32
|
+
}): JSX.Element {
|
|
33
|
+
const visible = capacityBytes > 0 ? segments.filter((segment) => segment.bytes > 0) : [];
|
|
34
|
+
const used = visible.reduce((sum, segment) => sum + segment.bytes, 0);
|
|
35
|
+
const free = visible.length === 0 ? 1 : Math.max(0, 1 - used / capacityBytes);
|
|
36
|
+
return (
|
|
37
|
+
<div aria-hidden="true" className="flex h-5 w-full" onMouseLeave={() => onActiveChange(null)}>
|
|
38
|
+
{visible.map((segment) => (
|
|
39
|
+
// 间隙算在段内,指针从一段移到另一段时不会落空。
|
|
40
|
+
<div
|
|
41
|
+
key={segment.id}
|
|
42
|
+
className="min-w-2.5 basis-0 pr-1 transition-[flex-grow] duration-500 ease-out last:pr-0 motion-reduce:transition-none"
|
|
43
|
+
style={{ flexGrow: (segment.bytes / capacityBytes) * 1000 }}
|
|
44
|
+
onMouseEnter={() => onActiveChange(segment.id)}
|
|
45
|
+
>
|
|
46
|
+
<div
|
|
47
|
+
className={cn(
|
|
48
|
+
"h-full rounded-md transition-opacity duration-200",
|
|
49
|
+
activeId !== null && activeId !== segment.id && "opacity-35",
|
|
50
|
+
)}
|
|
51
|
+
style={
|
|
52
|
+
segment.hatched
|
|
53
|
+
? {
|
|
54
|
+
backgroundColor: `color-mix(in srgb, ${segment.color} 22%, transparent)`,
|
|
55
|
+
backgroundImage: hatch(segment.color),
|
|
56
|
+
}
|
|
57
|
+
: { backgroundColor: segment.color }
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
))}
|
|
62
|
+
{free > 0.001 && (
|
|
63
|
+
<div
|
|
64
|
+
className="basis-0 rounded-md bg-muted-foreground/12"
|
|
65
|
+
style={{ flexGrow: free * 1000 }}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|