@vetta-org/theme-ui 0.1.0 → 0.1.2
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 +735 -7
- package/src/action-approval/AppearanceActionPickerView.tsx +2 -78
- package/src/action-approval/AppearanceApprovalDrawerView.tsx +2 -9
- package/src/action-approval/BatchTasksApprovalFrameView.tsx +4 -1
- package/src/action-approval/GenericActionApprovalView.tsx +2 -9
- package/src/action-approval/ManageActionApprovalFrameView.tsx +4 -1
- package/src/action-approval/NavigationOpenApprovalView.tsx +2 -9
- package/src/action-approval/SchedulerActionApprovalDialogView.tsx +3 -1
- package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +3 -10
- package/src/action-approval/index.ts +0 -1
- package/src/activity/ActivityPanel.tsx +13 -10
- package/src/activity/ActivityPanelFrame.test.tsx +32 -0
- package/src/activity/ActivityPanelFrame.tsx +3 -2
- package/src/activity/BackgroundTasksTabPanelView.tsx +1 -1
- package/src/activity/BrowserPanelView.tsx +48 -49
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.tsx +56 -59
- package/src/activity/PluginTabPickerView.tsx +5 -3
- package/src/activity/PortsTabPanelView.tsx +911 -0
- package/src/activity/ToolCallsSubTabView.tsx +1 -1
- package/src/activity/WorkflowTabPanelView.tsx +1 -1
- package/src/activity/index.ts +9 -0
- package/src/app/AppBackground.tsx +1 -1
- package/src/app/AppBootLoadingView.tsx +4 -2
- package/src/app-shell/DefaultWindowControls.tsx +1 -1
- package/src/app-shell/PageHeaderActionGroup.tsx +1 -1
- package/src/app-shell/PageHeaderContent.tsx +36 -7
- package/src/app-shell/PageHeaderFrame.tsx +15 -3
- package/src/app-shell/PageHeaderSidebarTrigger.tsx +1 -1
- package/src/app-shell/PageHeaderTitle.tsx +1 -1
- package/src/app-shell/WindowControlButton.tsx +1 -1
- package/src/app-shell/header-crowding.test.ts +62 -0
- package/src/app-shell/header-crowding.tsx +137 -0
- package/src/appearance/BackgroundImageFrame.tsx +1 -1
- package/src/appearance/CenterSliceImageFrame.tsx +1 -1
- package/src/appearance/CornerImageFrame.tsx +1 -1
- package/src/appearance/HorizontalSliceImageFrame.tsx +1 -1
- package/src/appearance/NineSliceImageFrame.tsx +1 -1
- package/src/appearance/ThemeSurface.tsx +1 -1
- package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +2 -1
- package/src/batch-tasks/BatchTaskProjectActionsView.test.tsx +97 -0
- package/src/batch-tasks/BatchTaskProjectActionsView.tsx +45 -35
- package/src/batch-tasks/batchTaskUi.tsx +0 -29
- package/src/bottom-panel/BottomPanelView.test.tsx +43 -0
- package/src/bottom-panel/BottomPanelView.tsx +222 -0
- package/src/bottom-panel/index.ts +26 -0
- package/src/chat/AgentAvatarView.tsx +1 -1
- package/src/chat/AnnotationViews.tsx +107 -0
- package/src/chat/AskUserQuestionView.tsx +18 -11
- package/src/chat/AssistantMessageView.tsx +48 -13
- package/src/chat/AtPanelView.test.tsx +61 -0
- package/src/chat/AtPanelView.tsx +63 -38
- package/src/chat/BashTerminalCard.tsx +1 -2
- package/src/chat/ChatHeaderActionsView.tsx +74 -18
- package/src/chat/CompactionStepView.test.tsx +34 -0
- package/src/chat/CompactionStepView.tsx +85 -0
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +731 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +137 -0
- package/src/chat/InlineModelPicker.test.tsx +81 -0
- package/src/chat/InlineModelPicker.tsx +201 -0
- package/src/chat/InlineTokenChip.tsx +2 -68
- package/src/chat/InputBarBackground.tsx +1 -1
- package/src/chat/InputBarPlaceholder.tsx +26 -3
- package/src/chat/LiveThinkingView.tsx +51 -37
- package/src/chat/MessageBoundaryViews.tsx +21 -0
- package/src/chat/MessageFeedContext.tsx +13 -5
- package/src/chat/MessageFeedLayoutView.tsx +28 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +1 -1
- package/src/chat/MessageLayoutView.tsx +1 -1
- package/src/chat/MessageSelectionContextMenuView.tsx +4 -1
- package/src/chat/MessageTimelineView.tsx +1 -1
- package/src/chat/MessageView.tsx +1 -1
- package/src/chat/MessageVisualView.tsx +1 -1
- package/src/chat/ModelConfiguration.tsx +283 -0
- package/src/chat/ModelSelectorTrigger.tsx +63 -0
- package/src/chat/ModelSelectorView.tsx +1037 -223
- package/src/chat/NewSession.ts +1 -37
- package/src/chat/NewSessionPicker.tsx +3 -2
- package/src/chat/ProjectSelectorView.tsx +3 -2
- package/src/chat/ReasoningStepSlider.tsx +61 -0
- package/src/chat/RemoteSessionBadgeView.tsx +24 -0
- package/src/chat/SkillPromptAreaView.tsx +5 -19
- package/src/chat/TeamMemberReplyCardView.test.tsx +33 -0
- package/src/chat/TeamMemberReplyCardView.tsx +133 -0
- package/src/chat/TextBlockView.tsx +7 -770
- package/src/chat/TodoProgress.tsx +25 -53
- package/src/chat/TodoStatusBarView.tsx +14 -5
- package/src/chat/UserMessageView.tsx +113 -33
- package/src/chat/header-action-narrow.test.ts +21 -0
- package/src/chat/header-action-narrow.ts +38 -0
- package/src/chat/index.ts +32 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/send-button.css +4 -22
- package/src/chat/streaming-reveal.test.ts +218 -0
- package/src/chat/streaming-reveal.ts +13 -0
- package/src/file-explorer/ConfirmDeleteDialogView.tsx +2 -1
- package/src/file-explorer/FileContextMenuView.tsx +44 -11
- package/src/file-explorer/FileExplorerSettingsView.tsx +97 -0
- package/src/file-explorer/FileTreeCreateRow.tsx +1 -1
- package/src/file-explorer/FileTreeNodeView.tsx +59 -18
- package/src/file-explorer/FileTreeView.tsx +236 -129
- package/src/file-explorer/file-tree-dom.ts +23 -0
- package/src/file-explorer/file-tree-rows.test.ts +74 -0
- package/src/file-explorer/file-tree-rows.ts +168 -0
- package/src/file-explorer/index.ts +17 -0
- package/src/file-explorer/types.ts +3 -0
- package/src/file-explorer/useFileTreeMarqueeSelection.ts +24 -16
- package/src/file-preview/FilePreviewDialogView.tsx +2 -2
- package/src/file-preview/FilePreviewView.tsx +12 -2
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/index.ts +1 -0
- package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +1 -1
- package/src/layout/AppFrame.tsx +3 -2
- package/src/layout/MainContentFrame.tsx +7 -2
- package/src/layout/ResizeHandle.tsx +68 -17
- package/src/layout/SidebarDock.tsx +75 -19
- package/src/layout/SidebarOverlay.tsx +1 -1
- package/src/layout/index.ts +1 -1
- package/src/layout/resize-handle-axis.test.ts +51 -0
- package/src/live-indicators.test.ts +43 -0
- package/src/markdown/CodeBlock.tsx +123 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +411 -0
- package/src/markdown/MarkdownImage.tsx +51 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +43 -0
- package/src/markdown/RichCodeBlock.tsx +127 -0
- package/src/markdown/SvgPreview.tsx +45 -0
- package/src/markdown/WebsiteIcon.tsx +94 -0
- package/src/markdown/builtin-renderers.tsx +43 -0
- package/src/markdown/definition.tsx +49 -0
- package/src/markdown/host.tsx +18 -0
- package/src/markdown/index.ts +11 -0
- package/src/markdown/inline-tokens.ts +187 -0
- package/src/markdown/markdown-link.ts +279 -0
- package/src/markdown/math-client.ts +116 -0
- package/src/markdown/math-render.ts +23 -0
- package/src/markdown/math-syntax.ts +80 -0
- package/src/markdown/math.worker.ts +16 -0
- package/src/markdown/nodes.ts +15 -0
- package/src/markdown/preview-policy.ts +43 -0
- package/src/markdown/rich-labels.ts +49 -0
- package/src/markdown/rich-syntax.ts +93 -0
- package/src/markdown/stable-blocks.test.ts +90 -0
- package/src/markdown/stable-blocks.ts +124 -0
- package/src/markdown/streaming-reveal.ts +297 -0
- package/src/markdown/streaming.test.ts +57 -0
- package/src/markdown/streaming.ts +211 -0
- package/src/markdown/use-render-snapshot.ts +24 -0
- package/src/markdown/use-rich-visibility.ts +24 -0
- package/src/overlays/CommandMenuRow.tsx +38 -9
- package/src/overlays/CommandMenuView.tsx +77 -117
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/ReleaseNoteMarkdown.tsx +29 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +213 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +139 -54
- package/src/overlays/command-menu-types.ts +2 -0
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +14 -1
- package/src/plugin-ui/index.ts +8 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +4 -4
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +106 -55
- package/src/project/ManageSessionsSplashView.tsx +439 -0
- package/src/project/NewProjectDialogView.tsx +3 -10
- package/src/project/ProjectContextMenuView.tsx +30 -139
- package/src/project/ProjectDetailPageView.test.tsx +140 -0
- package/src/project/ProjectDetailPageView.tsx +372 -165
- package/src/project/ProjectGroupView.tsx +1 -1
- package/src/project/ProjectRowView.tsx +29 -12
- package/src/project/ProjectSessionsView.tsx +25 -47
- package/src/project/QuickScrollOverlay.tsx +1 -1
- package/src/project/SessionContextMenuView.tsx +15 -7
- package/src/project/SessionRowMoreButton.tsx +50 -0
- package/src/project/SessionRowView.tsx +106 -63
- package/src/project/SessionTitleMarquee.tsx +54 -0
- package/src/project/SidebarProjectDisclosure.tsx +60 -0
- package/src/project/SidebarProjectsSectionView.tsx +6 -1
- package/src/project/index.ts +12 -0
- package/src/project/session-row-transition.ts +9 -0
- package/src/project/types.ts +4 -2
- package/src/project/useActiveSessionAutoScroll.ts +10 -4
- package/src/registry.ts +0 -2
- package/src/scheduler/AutomationDetailPaneView.tsx +68 -0
- package/src/scheduler/AutomationPageView.tsx +118 -121
- package/src/scheduler/ExecutionHistoryView.tsx +7 -5
- package/src/scheduler/TaskListView.tsx +52 -201
- package/src/scheduler/index.ts +7 -12
- package/src/settings/AchievementSettingsView.tsx +0 -1
- package/src/settings/AppshotSettingsView.tsx +0 -1
- package/src/settings/BuiltinMcpSectionView.tsx +1 -1
- package/src/settings/EnvironmentGitRowView.tsx +156 -0
- package/src/settings/EnvironmentSettingsView.tsx +25 -3
- package/src/settings/GeneralSettingsView.tsx +17 -20
- package/src/settings/ImChannelGuideDialogView.tsx +2 -2
- package/src/settings/ImFeishuDialogView.tsx +1 -1
- package/src/settings/ImLegacyImportBannerView.tsx +1 -1
- package/src/settings/ImLogDrawerView.tsx +2 -1
- package/src/settings/JsonConfigInputView.tsx +171 -0
- package/src/settings/ModelsFetchedModelsDrawerView.tsx +292 -0
- package/src/settings/ModelsProvidersSectionView.tsx +26 -23
- package/src/settings/MotionSelect.tsx +9 -7
- package/src/settings/NotificationSettingsView.tsx +79 -0
- package/src/settings/PermissionsSettingsView.tsx +3 -7
- package/src/settings/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +205 -182
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -2
- package/src/settings/RemoteMcpSectionView.tsx +1 -1
- package/src/settings/SettingChrome.tsx +2 -2
- package/src/settings/SettingsAiAssistButtonView.tsx +9 -119
- package/src/settings/SettingsFormFields.tsx +4 -7
- package/src/settings/SettingsSidebarView.tsx +64 -3
- package/src/settings/ShortcutRecorderView.test.tsx +108 -0
- package/src/settings/ShortcutRecorderView.tsx +15 -9
- package/src/settings/ShortcutsSettingsView.tsx +1 -1
- package/src/settings/SpaceEditorDialogView.tsx +120 -0
- package/src/settings/SpacesSettingsView.tsx +105 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/index.ts +41 -29
- package/src/shared/ActivityStatusDot.tsx +69 -0
- package/src/shared/AvatarStackView.tsx +13 -13
- package/src/shared/BotAvatar.tsx +11 -9
- package/src/shared/CodeBlockCopyButton.tsx +1 -1
- package/src/shared/ContextMenuView.tsx +4 -11
- package/src/shared/MarkdownTable.tsx +2 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +22 -17
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +81 -0
- package/src/shared/connected-tab-outline.test.ts +2 -2
- package/src/shared/connected-tab-outline.ts +2 -1
- package/src/shared/index.ts +6 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/provider-icon/icons.ts +4 -2
- package/src/shared/provider-icon/index.tsx +1 -1
- package/src/shared/provider-icon/magpie.svg +1 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +25 -15
- package/src/sidebar/DefaultSidebar.tsx +3 -1
- package/src/sidebar/MessageCenterDialogView.tsx +3 -2
- package/src/sidebar/MessageCenterEmptyState.tsx +1 -1
- package/src/sidebar/MessageCenterTabs.tsx +1 -1
- package/src/sidebar/MessageCenterToolbarButton.tsx +1 -1
- package/src/sidebar/MessageCenterTriggerView.tsx +2 -2
- package/src/sidebar/ProjectsPanelEmptyState.tsx +26 -7
- package/src/sidebar/SessionStatusIcon.tsx +16 -1
- package/src/sidebar/SettingsMenuThemeSection.tsx +1 -1
- package/src/sidebar/SettingsMenuTriggerView.test.tsx +42 -0
- package/src/sidebar/SettingsMenuTriggerView.tsx +28 -50
- package/src/sidebar/ShowMoreSessionsButton.tsx +1 -1
- package/src/sidebar/SidebarFilterSelectView.tsx +8 -16
- package/src/sidebar/SidebarNavBadgeView.tsx +1 -1
- package/src/sidebar/SidebarNavIcon.tsx +1 -1
- package/src/sidebar/SidebarNavItemButton.tsx +1 -1
- package/src/sidebar/SidebarNavMorePanel.tsx +19 -7
- package/src/sidebar/SidebarNavigation.tsx +24 -15
- package/src/sidebar/SidebarPanel.tsx +11 -2
- package/src/sidebar/SidebarSectionTriggerLabel.tsx +20 -0
- package/src/sidebar/SidebarTopBar.tsx +10 -7
- package/src/sidebar/WaitingPulseBadge.tsx +19 -0
- package/src/sidebar/index.ts +1 -16
- package/src/skills/index.ts +0 -19
- package/src/skills/skill-icon.tsx +4 -8
- package/src/styles.css +24 -6
- package/src/chat/DefaultSceneCarousel.tsx +0 -113
- package/src/chat/SceneCard.tsx +0 -138
- package/src/scheduler/HistoryDrawerView.tsx +0 -149
- package/src/scheduler/TaskFormDialogView.tsx +0 -60
- package/src/settings/SubscriptionActionsView.tsx +0 -63
- package/src/settings/SubscriptionCardsView.tsx +0 -212
- package/src/settings/TeamDetailView.tsx +0 -148
- package/src/settings/TeamDialogsView.tsx +0 -151
- package/src/settings/TeamListView.tsx +0 -57
- package/src/settings/TeamSettingsView.tsx +0 -51
- package/src/settings/TokenActivityChartView.tsx +0 -286
- package/src/settings/UsageStatsView.tsx +0 -101
- package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +0 -135
- package/src/settings/shouldCloseEmptyApiKeyEditor.ts +0 -40
- package/src/settings/token-activity.test.ts +0 -195
- package/src/settings/token-activity.ts +0 -320
- package/src/sidebar/AddProjectMenuItem.tsx +0 -21
- package/src/sidebar/AddProjectMenuPopoverView.tsx +0 -52
- package/src/sidebar/NotificationMessageListView.tsx +0 -136
- package/src/sidebar/SettingsMenuAccountSection.tsx +0 -32
- package/src/sidebar/SettingsMenuQuotaSection.tsx +0 -45
- package/src/skills/SceneCardView.tsx +0 -194
- package/src/skills/SkillCardView.tsx +0 -186
- package/src/skills/SkillDetailDialogView.tsx +0 -138
- package/src/skills/SkillTagGroupView.tsx +0 -56
- package/src/skills/SkillToggleSwitch.tsx +0 -31
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { VettaKbd } from "./VettaKbd";
|
|
6
|
+
|
|
7
|
+
describe("VettaKbd", () => {
|
|
8
|
+
it("renders one embossed keycap per key for the target platform", () => {
|
|
9
|
+
const markup = renderToStaticMarkup(<VettaKbd keys="mod+shift+k" platform="mac" />);
|
|
10
|
+
expect(markup.match(/<kbd/g)).toHaveLength(3);
|
|
11
|
+
expect(markup).toContain("⌘");
|
|
12
|
+
expect(markup).toContain("⇧");
|
|
13
|
+
expect(markup).toContain("K");
|
|
14
|
+
// 浮雕观感来自与应用快照键盘预览同源的键帽阴影。
|
|
15
|
+
expect(markup).toContain("inset_0_1px_0_rgba(255,255,255,0.7)");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("switches the same shortcut to Windows labels", () => {
|
|
19
|
+
const markup = renderToStaticMarkup(<VettaKbd keys="mod+shift+k" platform="windows" />);
|
|
20
|
+
expect(markup).toContain("Ctrl");
|
|
21
|
+
expect(markup).toContain("Shift");
|
|
22
|
+
expect(markup).not.toContain("⌘");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("keeps keycaps readable on any surface by tinting the face with the foreground colour", () => {
|
|
26
|
+
const markup = renderToStaticMarkup(<VettaKbd keys="mod+k" platform="mac" />);
|
|
27
|
+
// 不能写死 card/muted 一类固定底面:这套键帽同时坐在设置页的 muted 字段和 popover 菜单上。
|
|
28
|
+
expect(markup).toContain("from-foreground/");
|
|
29
|
+
expect(markup).toContain("dark:from-foreground/");
|
|
30
|
+
expect(markup).not.toContain("from-card");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("exposes a readable label instead of raw glyphs", () => {
|
|
34
|
+
const markup = renderToStaticMarkup(<VettaKbd keys="mod+k" platform="mac" />);
|
|
35
|
+
expect(markup).toContain('role="img"');
|
|
36
|
+
expect(markup).toContain('aria-label="Command K"');
|
|
37
|
+
expect(markup).toContain('aria-hidden="true"');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("renders per-platform overrides and optional separators", () => {
|
|
41
|
+
const markup = renderToStaticMarkup(
|
|
42
|
+
<VettaKbd keys={["ctrl", { mac: "⌘", windows: "Win" }, "k"]} platform="windows" separator />,
|
|
43
|
+
);
|
|
44
|
+
expect(markup).toContain("Ctrl");
|
|
45
|
+
expect(markup).toContain("Win");
|
|
46
|
+
expect(markup.match(/>\+</g)).toHaveLength(2);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("renders nothing when there is no shortcut", () => {
|
|
50
|
+
expect(renderToStaticMarkup(<VettaKbd keys="" platform="mac" />)).toBe("");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Fragment, type JSX } from "react";
|
|
2
|
+
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import {
|
|
4
|
+
describeKbdKeys,
|
|
5
|
+
detectKbdPlatform,
|
|
6
|
+
resolveKbdKeys,
|
|
7
|
+
type VettaKbdKey,
|
|
8
|
+
type VettaKbdPlatform,
|
|
9
|
+
} from "./kbd-keys";
|
|
10
|
+
|
|
11
|
+
export type VettaKbdSize = "xs" | "sm";
|
|
12
|
+
|
|
13
|
+
export interface VettaKbdProps {
|
|
14
|
+
/** 快捷键串("mod+shift+k")或键位列表;列表项可写成按平台取值的对象。 */
|
|
15
|
+
readonly keys: string | readonly VettaKbdKey[];
|
|
16
|
+
/** 强制平台;默认按当前窗口平台判断。 */
|
|
17
|
+
readonly platform?: VettaKbdPlatform;
|
|
18
|
+
readonly size?: VettaKbdSize;
|
|
19
|
+
/** 键之间显示 "+" 连接符(默认只靠间距分组)。 */
|
|
20
|
+
readonly separator?: boolean;
|
|
21
|
+
readonly className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 轻拟物键帽:顶部内高光 + 底部落影,与应用快照的键盘预览同一套浮雕观感。
|
|
25
|
+
// 键面用前景色叠层而非固定底色,所以放在 card / muted / popover 上都能浮起来:
|
|
26
|
+
// 浅色主题靠淡灰压深底边,深色主题靠淡白提亮顶面。
|
|
27
|
+
const CAP_RAISED = cn(
|
|
28
|
+
"inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium leading-none",
|
|
29
|
+
"bg-gradient-to-b from-foreground/[0.03] to-foreground/[0.09] text-foreground",
|
|
30
|
+
"dark:from-foreground/[0.1] dark:to-foreground/[0.03]",
|
|
31
|
+
"border border-black/[0.08] dark:border-white/[0.08]",
|
|
32
|
+
"shadow-[inset_0_1px_0_rgba(255,255,255,0.7),0_1px_1.5px_rgba(0,0,0,0.14),0_2px_3px_-1px_rgba(0,0,0,0.12)]",
|
|
33
|
+
"dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.09),0_1.5px_2px_rgba(0,0,0,0.55)]",
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const SIZE_CLASS: Record<VettaKbdSize, string> = {
|
|
37
|
+
xs: "h-[18px] min-w-[18px] rounded-[4px] px-1 text-[10px]",
|
|
38
|
+
sm: "h-[22px] min-w-[22px] rounded-[5px] px-1.5 text-[11px]",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 快捷键键帽展示:把 "mod+shift+k" 这类串渲染成一组浮雕键帽。
|
|
43
|
+
*
|
|
44
|
+
* 平台差异由 keys 里的 token 承担:mod 在 mac 显示 ⌘、windows 显示 Ctrl;
|
|
45
|
+
* ctrl 在 mac 显示 ⌃、windows 显示 Ctrl;需要更细的分系统差异时直接传对象项。
|
|
46
|
+
*/
|
|
47
|
+
export function VettaKbd({
|
|
48
|
+
keys,
|
|
49
|
+
platform,
|
|
50
|
+
size = "xs",
|
|
51
|
+
separator = false,
|
|
52
|
+
className,
|
|
53
|
+
}: VettaKbdProps): JSX.Element | null {
|
|
54
|
+
const resolvedPlatform = platform ?? detectKbdPlatform();
|
|
55
|
+
const labels = resolveKbdKeys(keys, resolvedPlatform);
|
|
56
|
+
if (labels.length === 0) return null;
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<span
|
|
60
|
+
className={cn("inline-flex shrink-0 select-none items-center gap-1 align-middle", className)}
|
|
61
|
+
role="img"
|
|
62
|
+
aria-label={describeKbdKeys(keys, resolvedPlatform)}
|
|
63
|
+
>
|
|
64
|
+
{labels.map((label, index) => (
|
|
65
|
+
<Fragment
|
|
66
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: 组合键各段固定顺序,同一个键可能重复出现
|
|
67
|
+
key={`${index}-${label}`}
|
|
68
|
+
>
|
|
69
|
+
{separator && index > 0 && (
|
|
70
|
+
<span aria-hidden="true" className="text-[10px] font-medium leading-none text-muted-foreground/60">
|
|
71
|
+
+
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
<kbd aria-hidden="true" className={cn(CAP_RAISED, SIZE_CLASS[size])}>
|
|
75
|
+
{label}
|
|
76
|
+
</kbd>
|
|
77
|
+
</Fragment>
|
|
78
|
+
))}
|
|
79
|
+
</span>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -5,8 +5,8 @@ describe("createConnectedTabOutlineGeometry", () => {
|
|
|
5
5
|
it("creates one continuous outline around the tab and both join curves", () => {
|
|
6
6
|
expect(createConnectedTabOutlineGeometry(72)).toEqual({
|
|
7
7
|
fillPath:
|
|
8
|
-
"M 0 32 A 8 8 0 0 0 8 24 V 8 A 8 8 0 0 1 16 0 H 72 A 8 8 0 0 1 80 8 V 24 A 8 8 0 0 0 88 32 V
|
|
9
|
-
height:
|
|
8
|
+
"M 0 32 A 8 8 0 0 0 8 24 V 8 A 8 8 0 0 1 16 0 H 72 A 8 8 0 0 1 80 8 V 24 A 8 8 0 0 0 88 32 V 33 H 0 Z",
|
|
9
|
+
height: 33,
|
|
10
10
|
offsetX: 8,
|
|
11
11
|
outlinePath: "M 0 32 A 8 8 0 0 0 8 24 V 8 A 8 8 0 0 1 16 0 H 72 A 8 8 0 0 1 80 8 V 24 A 8 8 0 0 0 88 32",
|
|
12
12
|
width: 88,
|
package/src/shared/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { ActivityStatusDotProps, ActivityStatusDotTone } from "./ActivityStatusDot";
|
|
2
|
+
export { ACTIVITY_STATUS_DOT_CSS, ActivityStatusDot, ActivityStatusDotStyles } from "./ActivityStatusDot";
|
|
1
3
|
export type { AvatarStackViewProps } from "./AvatarStackView";
|
|
2
4
|
export { AvatarStackView } from "./AvatarStackView";
|
|
3
5
|
export { BotAvatar } from "./BotAvatar";
|
|
@@ -10,6 +12,8 @@ export type { CollapsePanelProps } from "./CollapsePanel";
|
|
|
10
12
|
export { CollapsePanel } from "./CollapsePanel";
|
|
11
13
|
export type { ContextMenuNode, ContextMenuViewProps } from "./ContextMenuView";
|
|
12
14
|
export { ContextMenuView } from "./ContextMenuView";
|
|
15
|
+
export type { VettaKbdKey, VettaKbdPlatform } from "./kbd-keys";
|
|
16
|
+
export { describeKbdKeys, detectKbdPlatform, resolveKbdKey, resolveKbdKeys, splitKbdKeys } from "./kbd-keys";
|
|
13
17
|
export type { MacKeyboardPreviewProps, MacKeyId } from "./MacKeyboardPreview";
|
|
14
18
|
export { MacKeyboardPreview } from "./MacKeyboardPreview";
|
|
15
19
|
export type { MarkdownTableProps } from "./MarkdownTable";
|
|
@@ -36,3 +40,5 @@ export { TabBar } from "./TabBar";
|
|
|
36
40
|
export type { TimePickerProps } from "./TimePicker";
|
|
37
41
|
export { TimePicker } from "./TimePicker";
|
|
38
42
|
export { useDelayedUnmount } from "./useDelayedUnmount";
|
|
43
|
+
export type { VettaKbdProps, VettaKbdSize } from "./VettaKbd";
|
|
44
|
+
export { VettaKbd } from "./VettaKbd";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { describeKbdKeys, resolveKbdKey, resolveKbdKeys, splitKbdKeys } from "./kbd-keys";
|
|
3
|
+
|
|
4
|
+
describe("splitKbdKeys", () => {
|
|
5
|
+
it("splits a shortcut string and keeps object entries as-is", () => {
|
|
6
|
+
expect(splitKbdKeys("mod+shift+k")).toEqual(["mod", "shift", "k"]);
|
|
7
|
+
expect(splitKbdKeys(" ")).toEqual([]);
|
|
8
|
+
expect(splitKbdKeys(["mod", { mac: "⌃" }])).toEqual(["mod", { mac: "⌃" }]);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("resolveKbdKeys", () => {
|
|
13
|
+
it("maps mod to the primary modifier of each platform", () => {
|
|
14
|
+
expect(resolveKbdKeys("mod+k", "mac")).toEqual(["⌘", "K"]);
|
|
15
|
+
expect(resolveKbdKeys("mod+k", "windows")).toEqual(["Ctrl", "K"]);
|
|
16
|
+
expect(resolveKbdKeys("mod+k", "linux")).toEqual(["Ctrl", "K"]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("keeps ctrl on the physical Control key instead of folding it into mod", () => {
|
|
20
|
+
expect(resolveKbdKeys("ctrl+1", "mac")).toEqual(["⌃", "1"]);
|
|
21
|
+
expect(resolveKbdKeys("ctrl+1", "windows")).toEqual(["Ctrl", "1"]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("uses mac symbols for modifiers and special keys", () => {
|
|
25
|
+
expect(resolveKbdKeys("mod+alt+shift+enter", "mac")).toEqual(["⌘", "⌥", "⇧", "⏎"]);
|
|
26
|
+
expect(resolveKbdKeys("mod+alt+shift+enter", "windows")).toEqual(["Ctrl", "Alt", "Shift", "Enter"]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders letters upper-case and function keys as F1..F12", () => {
|
|
30
|
+
expect(resolveKbdKeys("f5", "mac")).toEqual(["F5"]);
|
|
31
|
+
expect(resolveKbdKeys("mod+k", "mac")).toEqual(["⌘", "K"]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("accepts multi-word and camel-case tokens", () => {
|
|
35
|
+
expect(resolveKbdKeys("CmdOrCtrl+Page Up", "mac")).toEqual(["⌘", "⇞"]);
|
|
36
|
+
expect(resolveKbdKeys("commandorcontrol+Page Up", "windows")).toEqual(["Ctrl", "PgUp"]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("supports per-platform overrides and falls back to windows", () => {
|
|
40
|
+
const keys = ["ctrl", { mac: "⌘", windows: "Win" }, "space"];
|
|
41
|
+
expect(resolveKbdKeys(keys, "mac")).toEqual(["⌃", "⌘", "Space"]);
|
|
42
|
+
expect(resolveKbdKeys(keys, "windows")).toEqual(["Ctrl", "Win", "Space"]);
|
|
43
|
+
expect(resolveKbdKeys(keys, "linux")).toEqual(["Ctrl", "Win", "Space"]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("returns an empty list for an empty shortcut", () => {
|
|
47
|
+
expect(resolveKbdKeys("", "mac")).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("keeps unknown tokens readable instead of dropping them", () => {
|
|
51
|
+
expect(resolveKbdKey("volumeup", "mac")).toBe("volumeup");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("describeKbdKeys", () => {
|
|
56
|
+
it("reads modifier glyphs out as key names", () => {
|
|
57
|
+
expect(describeKbdKeys("mod+shift+k", "mac")).toBe("Command Shift K");
|
|
58
|
+
expect(describeKbdKeys("mod+shift+k", "windows")).toBe("Control Shift K");
|
|
59
|
+
expect(describeKbdKeys("ctrl+enter", "mac")).toBe("Control Return");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VettaKbd 的键位解析:把快捷键串或键位 token 解析成各平台的显示文案。
|
|
3
|
+
*
|
|
4
|
+
* 约定:
|
|
5
|
+
* - 快捷键串用 "+" 连接("mod+shift+k"),token 大小写不敏感,多单词写法按去空格匹配
|
|
6
|
+
* ("CmdOrCtrl" / "page up")。
|
|
7
|
+
* - "mod" 是平台主修饰键:mac 显示 ⌘,windows/linux 显示 Ctrl;"ctrl" 始终指物理 Control 键,
|
|
8
|
+
* 因此 mac 上显示 ⌃、windows 上显示 Ctrl。需要完全分系统时,把该项写成
|
|
9
|
+
* { mac: "⌃", windows: "Ctrl" } 这类对象。
|
|
10
|
+
* - mac 的修饰键与功能键按硬件印字显示符号(⌘ ⌥ ⌃ ⇧ ⏎ ⎋ ⌫ …),windows/linux 显示单词。
|
|
11
|
+
* 键盘印字不随界面语言翻译,故这里不接 i18n。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type VettaKbdPlatform = "mac" | "windows" | "linux";
|
|
15
|
+
|
|
16
|
+
/** 单项键位:token 字符串按平台解析;对象按平台直接给出文案。 */
|
|
17
|
+
export type VettaKbdKey = string | Partial<Record<VettaKbdPlatform, string>>;
|
|
18
|
+
|
|
19
|
+
type LabelTable = Record<string, string>;
|
|
20
|
+
|
|
21
|
+
const ARROW_LABELS: LabelTable = {
|
|
22
|
+
up: "↑",
|
|
23
|
+
arrowup: "↑",
|
|
24
|
+
down: "↓",
|
|
25
|
+
arrowdown: "↓",
|
|
26
|
+
left: "←",
|
|
27
|
+
arrowleft: "←",
|
|
28
|
+
right: "→",
|
|
29
|
+
arrowright: "→",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const MOD_ALIASES = ["mod", "cmdorctrl", "cmdorcontrol", "commandorcontrol", "controlormeta"];
|
|
33
|
+
|
|
34
|
+
function withMod(table: LabelTable, modLabel: string): LabelTable {
|
|
35
|
+
const out: LabelTable = { ...table };
|
|
36
|
+
for (const alias of MOD_ALIASES) out[alias] = modLabel;
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const MAC_LABELS: LabelTable = withMod(
|
|
41
|
+
{
|
|
42
|
+
...ARROW_LABELS,
|
|
43
|
+
cmd: "⌘",
|
|
44
|
+
command: "⌘",
|
|
45
|
+
meta: "⌘",
|
|
46
|
+
win: "⌘",
|
|
47
|
+
ctrl: "⌃",
|
|
48
|
+
control: "⌃",
|
|
49
|
+
alt: "⌥",
|
|
50
|
+
option: "⌥",
|
|
51
|
+
opt: "⌥",
|
|
52
|
+
shift: "⇧",
|
|
53
|
+
enter: "⏎",
|
|
54
|
+
return: "⏎",
|
|
55
|
+
backspace: "⌫",
|
|
56
|
+
delete: "⌦",
|
|
57
|
+
del: "⌦",
|
|
58
|
+
esc: "⎋",
|
|
59
|
+
escape: "⎋",
|
|
60
|
+
tab: "⇥",
|
|
61
|
+
capslock: "⇪",
|
|
62
|
+
caps: "⇪",
|
|
63
|
+
space: "Space",
|
|
64
|
+
spacebar: "Space",
|
|
65
|
+
home: "↖",
|
|
66
|
+
end: "↘",
|
|
67
|
+
pageup: "⇞",
|
|
68
|
+
pagedown: "⇟",
|
|
69
|
+
fn: "fn",
|
|
70
|
+
plus: "+",
|
|
71
|
+
minus: "-",
|
|
72
|
+
},
|
|
73
|
+
"⌘",
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const WINDOWS_LABELS: LabelTable = withMod(
|
|
77
|
+
{
|
|
78
|
+
...ARROW_LABELS,
|
|
79
|
+
cmd: "Win",
|
|
80
|
+
command: "Win",
|
|
81
|
+
meta: "Win",
|
|
82
|
+
win: "Win",
|
|
83
|
+
ctrl: "Ctrl",
|
|
84
|
+
control: "Ctrl",
|
|
85
|
+
alt: "Alt",
|
|
86
|
+
option: "Alt",
|
|
87
|
+
opt: "Alt",
|
|
88
|
+
shift: "Shift",
|
|
89
|
+
enter: "Enter",
|
|
90
|
+
return: "Enter",
|
|
91
|
+
backspace: "Backspace",
|
|
92
|
+
delete: "Del",
|
|
93
|
+
del: "Del",
|
|
94
|
+
esc: "Esc",
|
|
95
|
+
escape: "Esc",
|
|
96
|
+
tab: "Tab",
|
|
97
|
+
capslock: "Caps",
|
|
98
|
+
caps: "Caps",
|
|
99
|
+
space: "Space",
|
|
100
|
+
spacebar: "Space",
|
|
101
|
+
home: "Home",
|
|
102
|
+
end: "End",
|
|
103
|
+
pageup: "PgUp",
|
|
104
|
+
pagedown: "PgDn",
|
|
105
|
+
fn: "Fn",
|
|
106
|
+
plus: "+",
|
|
107
|
+
minus: "-",
|
|
108
|
+
},
|
|
109
|
+
"Ctrl",
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const LINUX_LABELS: LabelTable = {
|
|
113
|
+
...WINDOWS_LABELS,
|
|
114
|
+
cmd: "Super",
|
|
115
|
+
command: "Super",
|
|
116
|
+
meta: "Super",
|
|
117
|
+
win: "Super",
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const KEY_LABELS: Record<VettaKbdPlatform, LabelTable> = {
|
|
121
|
+
mac: MAC_LABELS,
|
|
122
|
+
windows: WINDOWS_LABELS,
|
|
123
|
+
linux: LINUX_LABELS,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const SPOKEN_MAC: LabelTable = {
|
|
127
|
+
...ARROW_LABELS,
|
|
128
|
+
up: "Up Arrow",
|
|
129
|
+
arrowup: "Up Arrow",
|
|
130
|
+
down: "Down Arrow",
|
|
131
|
+
arrowdown: "Down Arrow",
|
|
132
|
+
left: "Left Arrow",
|
|
133
|
+
arrowleft: "Left Arrow",
|
|
134
|
+
right: "Right Arrow",
|
|
135
|
+
arrowright: "Right Arrow",
|
|
136
|
+
cmd: "Command",
|
|
137
|
+
command: "Command",
|
|
138
|
+
meta: "Command",
|
|
139
|
+
win: "Command",
|
|
140
|
+
ctrl: "Control",
|
|
141
|
+
control: "Control",
|
|
142
|
+
alt: "Option",
|
|
143
|
+
option: "Option",
|
|
144
|
+
opt: "Option",
|
|
145
|
+
shift: "Shift",
|
|
146
|
+
enter: "Return",
|
|
147
|
+
return: "Return",
|
|
148
|
+
backspace: "Delete",
|
|
149
|
+
delete: "Forward Delete",
|
|
150
|
+
del: "Forward Delete",
|
|
151
|
+
esc: "Escape",
|
|
152
|
+
escape: "Escape",
|
|
153
|
+
tab: "Tab",
|
|
154
|
+
capslock: "Caps Lock",
|
|
155
|
+
caps: "Caps Lock",
|
|
156
|
+
space: "Space",
|
|
157
|
+
spacebar: "Space",
|
|
158
|
+
home: "Home",
|
|
159
|
+
end: "End",
|
|
160
|
+
pageup: "Page Up",
|
|
161
|
+
pagedown: "Page Down",
|
|
162
|
+
fn: "Fn",
|
|
163
|
+
plus: "Plus",
|
|
164
|
+
minus: "Minus",
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const SPOKEN_WINDOWS: LabelTable = {
|
|
168
|
+
...SPOKEN_MAC,
|
|
169
|
+
up: "Up Arrow",
|
|
170
|
+
cmd: "Windows",
|
|
171
|
+
command: "Windows",
|
|
172
|
+
meta: "Windows",
|
|
173
|
+
win: "Windows",
|
|
174
|
+
alt: "Alt",
|
|
175
|
+
option: "Alt",
|
|
176
|
+
opt: "Alt",
|
|
177
|
+
backspace: "Backspace",
|
|
178
|
+
delete: "Delete",
|
|
179
|
+
del: "Delete",
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const SPOKEN_LABELS: Record<VettaKbdPlatform, LabelTable> = {
|
|
183
|
+
mac: withMod(SPOKEN_MAC, "Command"),
|
|
184
|
+
windows: withMod(SPOKEN_WINDOWS, "Control"),
|
|
185
|
+
linux: withMod({ ...SPOKEN_WINDOWS, cmd: "Super", command: "Super", meta: "Super", win: "Super" }, "Control"),
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** 当前窗口所在平台;只在宿主确实拿不到平台信息时回落到 windows。 */
|
|
189
|
+
export function detectKbdPlatform(): VettaKbdPlatform {
|
|
190
|
+
if (typeof navigator === "undefined") return "windows";
|
|
191
|
+
const platform = navigator.platform?.toUpperCase() ?? "";
|
|
192
|
+
if (platform.includes("MAC")) return "mac";
|
|
193
|
+
if (platform.includes("WIN")) return "windows";
|
|
194
|
+
if (platform.includes("LINUX")) return "linux";
|
|
195
|
+
const ua = navigator.userAgent ?? "";
|
|
196
|
+
if (/Mac OS X|Macintosh/.test(ua)) return "mac";
|
|
197
|
+
if (/Windows/.test(ua)) return "windows";
|
|
198
|
+
return "linux";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function normalizeToken(token: string): string {
|
|
202
|
+
return token.trim().toLowerCase().replace(/\s+/g, "");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** 把快捷键串拆成键位;数组输入原样返回(保留分系统对象)。 */
|
|
206
|
+
export function splitKbdKeys(keys: string | readonly VettaKbdKey[]): VettaKbdKey[] {
|
|
207
|
+
if (typeof keys !== "string") return [...keys];
|
|
208
|
+
const trimmed = keys.trim();
|
|
209
|
+
if (!trimmed) return [];
|
|
210
|
+
return trimmed
|
|
211
|
+
.split("+")
|
|
212
|
+
.map((part) => part.trim())
|
|
213
|
+
.filter((part) => part.length > 0);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** 解析单个键位的显示文案。未知 token 原样返回,避免静默吞掉按键。 */
|
|
217
|
+
export function resolveKbdKey(key: VettaKbdKey, platform: VettaKbdPlatform = detectKbdPlatform()): string {
|
|
218
|
+
if (typeof key !== "string") {
|
|
219
|
+
return key[platform] ?? key.windows ?? key.mac ?? key.linux ?? "";
|
|
220
|
+
}
|
|
221
|
+
const token = normalizeToken(key);
|
|
222
|
+
if (!token) return "";
|
|
223
|
+
const label = KEY_LABELS[platform][token];
|
|
224
|
+
if (label !== undefined) return label;
|
|
225
|
+
if (/^f([1-9]|1[0-2])$/.test(token)) return token.toUpperCase();
|
|
226
|
+
if (token.length === 1) return token.toUpperCase();
|
|
227
|
+
return key.trim();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** 解析整串快捷键的显示文案(逐键)。 */
|
|
231
|
+
export function resolveKbdKeys(
|
|
232
|
+
keys: string | readonly VettaKbdKey[],
|
|
233
|
+
platform: VettaKbdPlatform = detectKbdPlatform(),
|
|
234
|
+
): string[] {
|
|
235
|
+
return splitKbdKeys(keys).map((key) => resolveKbdKey(key, platform));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** 逐键的读屏文案(键帽符号本身读不出含义)。 */
|
|
239
|
+
export function describeKbdKeys(
|
|
240
|
+
keys: string | readonly VettaKbdKey[],
|
|
241
|
+
platform: VettaKbdPlatform = detectKbdPlatform(),
|
|
242
|
+
): string {
|
|
243
|
+
const spoken = splitKbdKeys(keys).map((key) => {
|
|
244
|
+
if (typeof key !== "string") return resolveKbdKey(key, platform);
|
|
245
|
+
const token = normalizeToken(key);
|
|
246
|
+
const label = SPOKEN_LABELS[platform][token];
|
|
247
|
+
if (label !== undefined) return label;
|
|
248
|
+
if (/^f([1-9]|1[0-2])$/.test(token)) return token.toUpperCase();
|
|
249
|
+
if (token.length === 1) return token.toUpperCase();
|
|
250
|
+
return key.trim();
|
|
251
|
+
});
|
|
252
|
+
return spoken.filter((part) => part.length > 0).join(" ");
|
|
253
|
+
}
|
|
@@ -2,7 +2,7 @@ import claudeIcon from "@lobehub/icons-static-svg/icons/claude-color.svg?url";
|
|
|
2
2
|
import deepseekIcon from "@lobehub/icons-static-svg/icons/deepseek-color.svg?url";
|
|
3
3
|
import geminiIcon from "@lobehub/icons-static-svg/icons/gemini-color.svg?url";
|
|
4
4
|
import grokIcon from "@lobehub/icons-static-svg/icons/grok.svg?url";
|
|
5
|
-
import kimiIcon from "@lobehub/icons-static-svg/icons/kimi
|
|
5
|
+
import kimiIcon from "@lobehub/icons-static-svg/icons/kimi.svg?url";
|
|
6
6
|
import minimaxIcon from "@lobehub/icons-static-svg/icons/minimax-color.svg?url";
|
|
7
7
|
import nvidiaIcon from "@lobehub/icons-static-svg/icons/nvidia-color.svg?url";
|
|
8
8
|
import ollamaIcon from "@lobehub/icons-static-svg/icons/ollama.svg?url";
|
|
@@ -12,6 +12,7 @@ import qwenIcon from "@lobehub/icons-static-svg/icons/qwen-color.svg?url";
|
|
|
12
12
|
import xiaomiMimoIcon from "@lobehub/icons-static-svg/icons/xiaomimimo.svg?url";
|
|
13
13
|
import zaiIcon from "@lobehub/icons-static-svg/icons/zai.svg?url";
|
|
14
14
|
import zhipuIcon from "@lobehub/icons-static-svg/icons/zhipu-color.svg?url";
|
|
15
|
+
import magpieIcon from "./magpie.svg?url";
|
|
15
16
|
|
|
16
17
|
type ProviderIconAppearance = "color" | "monochrome";
|
|
17
18
|
|
|
@@ -27,7 +28,8 @@ const PROVIDER_ICON_ASSETS = {
|
|
|
27
28
|
deepseek: { src: deepseekIcon, appearance: "color" },
|
|
28
29
|
grok: { src: grokIcon, appearance: "monochrome" },
|
|
29
30
|
qwen: { src: qwenIcon, appearance: "color" },
|
|
30
|
-
kimi: { src: kimiIcon, appearance: "
|
|
31
|
+
kimi: { src: kimiIcon, appearance: "monochrome" },
|
|
32
|
+
magpie: { src: magpieIcon, appearance: "monochrome" },
|
|
31
33
|
minimax: { src: minimaxIcon, appearance: "color" },
|
|
32
34
|
nvidia: { src: nvidiaIcon, appearance: "color" },
|
|
33
35
|
ollama: { src: ollamaIcon, appearance: "monochrome" },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 44" fill="#000"><path fill-rule="evenodd" d="M1.5 5.5C1.3 5.7 1.2 6.5 1.2 6.9C1.2 6.9 1.2 7 1.2 7.1C1.1 7.4 1.3 8 1.4 8.3C1.4 8.4 1.5 8.5 1.5 8.7C1.5 8.9 1.7 9 1.8 9.3C2.2 9.9 2.2 10 2.3 10.1C2.4 10.2 2.5 10.3 2.6 10.5C2.8 10.8 3 11.1 3.2 11.3C3.3 11.3 3.4 11.6 3.6 11.8C3.8 12 4.1 12.4 4.2 12.5C4.7 13 5.2 13.7 5.4 13.9C6 14.5 6.5 15.1 6.7 15.3C6.7 15.4 6.9 15.5 6.9 15.7C7.3 15.9 7.7 16.5 7.9 16.8C7.9 16.8 8 16.9 8 16.9C8.1 16.9 8.2 17.2 8.2 17.3C8.2 17.3 8.1 17.2 8.1 17.1C7.9 16.9 7.9 16.9 7.6 16.6C7.5 16.5 7.4 16.5 7.4 16.3C7.2 16.2 6.7 15.7 6.3 15.2C6.1 15.1 6 14.9 6 14.9C5.9 14.8 5.7 14.7 5.7 14.6C5.6 14.5 5.4 14.3 5.3 14.2C5.1 14.1 4.9 13.8 4.7 13.5C4.5 13.3 4.2 13.1 4.1 12.9C4.1 12.9 3.8 12.7 3.8 12.5C3.5 12.3 3 11.8 2.8 11.4C1.8 10.5 0.9 9.6 0.7 9.6C0.6 9.7 0.6 9.8 0.5 10C0.5 10.1 0.6 10.2 0.5 10.3C0.5 10.4 0.6 10.5 0.6 10.6C0.5 10.7 0.5 10.9 0.6 11C0.5 11.1 0.6 11.4 0.6 11.5C0.9 12.9 1.3 13.8 2.8 14.9C2.9 15.1 3.3 15.3 3.4 15.4C3.4 15.5 3.6 15.6 3.7 15.7C4.2 16 6.4 17.8 7 18.4C7.4 18.8 7.4 18.8 7.5 18.9C7.6 19 7.7 19 7.7 19.1C7.7 19.2 7.8 19.2 7.9 19.2C7.9 19.3 8.1 19.4 8.1 19.5C8.2 19.6 8.2 19.7 8.3 19.7C8.3 19.7 8.3 19.7 8.2 19.7C8.2 19.6 8.1 19.6 8 19.6C7.9 19.5 7.9 19.4 7.8 19.4C7.7 19.3 7.6 19.2 7.6 19.2C7.6 19.1 7.5 19 7.3 18.9C7.2 18.9 6.9 18.6 6.7 18.4C6.1 17.8 4.5 16.6 3.5 16C3.4 15.8 3 15.6 2.9 15.5C2.6 15.3 1.5 14.6 0.9 14.3C0.7 14.1 0.6 14.1 0.6 14.2C0.5 14.5 0.8 15.9 0.9 16.1C0.9 16.2 1 16.2 0.9 16.3C1.2 16.8 1.9 17.6 2.7 18.3C2.8 18.5 4 19.2 4.7 19.5C6.2 20.5 6.6 20.7 7.4 21.5C8.2 22.2 8.7 22.7 9.3 23.6C9.5 24.1 9.9 24.4 10.3 25.3C10.4 25.5 10.5 25.8 10.5 25.8C10.7 25.8 10.8 25.7 11 25.4C11.6 25 11.9 24.6 12.3 24.3C12.8 24 13 23.8 13 23.7C13.1 23.7 13.1 23.8 13 24C12 24.8 11 26 10.2 26.9C10.1 27.1 9.9 27.5 9.7 27.7C9.5 27.8 9.4 28 9.4 28C9.4 28 9.3 28.3 9.1 28.5C8.6 29.2 7.7 30.8 7.7 30.9C7.7 31 7.8 31 8.3 30.8C9 30.4 9.5 30.2 10.4 30C11.7 29.6 12.5 29.6 11.6 30C10.5 30.2 9.7 30.6 9.2 31.2C8.8 31.7 8.8 31.7 9.3 31.7C10.1 31.8 10.9 31.9 11.6 32.2C12.8 32.7 13.5 33.1 15.5 34.8C16.4 35.5 17.3 36.2 17.8 36.4C17.9 36.5 18.1 36.7 18.2 36.8C19.1 37.3 21.2 38.1 22.3 38.3C22.4 38.3 22.7 38.3 22.8 38.3C22.8 38.5 23 38.5 23 38.5C23.1 38.5 23.2 38.5 23.3 38.5C23.6 38.6 25.9 38.6 26.1 38.5C26.2 38.5 26.3 38.5 26.4 38.5C26.5 38.5 26.6 38.5 26.7 38.3C26.7 38.3 27 38.3 27.1 38.3C28.3 38.1 30.2 37.3 31.4 36.7C31.5 36.7 31.7 36.4 31.8 36.4C32.2 36.2 33.2 35.4 33.4 35.2C34.2 34.5 35.5 33 35.8 32.6C35.8 32.5 36 32.2 36.1 32C36.4 31.8 36.6 31.4 36.6 31.2C36.7 31.1 36.8 30.9 36.9 30.8C37.2 30.4 37.5 29.6 37.7 29.2C37.7 29.1 37.8 28.7 37.9 28.7C38.1 28.5 38.4 27.1 38.5 26.8C39 25.2 39.1 23.7 39 22.4C39 22.2 38.9 21.9 38.9 21.8C38.9 21.7 38.9 21.6 38.9 21.4C38.6 20.5 38.5 19.9 38.2 19C37.9 18.5 37.5 17.5 37.3 17.2C37 16.8 36.8 15.8 36.8 15.2C36.8 13.8 37.7 12.7 39.6 12.2C40.1 12.1 41.3 11.8 42.1 11.7C43.5 11.5 43.5 11.5 43.4 11.3C42.9 10.7 40.9 9.9 39.2 9.7C37.9 9.5 38.1 9.5 37.6 9C37 8.6 36.4 8 36 7.9C36 7.8 35.8 7.8 35.7 7.7C35.1 7.3 34.2 7 33.1 6.9C32.6 6.7 31.6 6.9 31 7C29.6 7.3 28.3 8 27.3 9.2C26.7 9.8 26.2 10.8 25.7 11.7C25.5 12.1 24.8 13.4 24.7 13.7C24.6 13.9 24.5 14.1 24.1 14.7C23.5 15.7 22.1 16.9 20.6 17.8C20.5 18 20.3 18.2 20.1 18.3C19.7 18.5 19.4 18.8 19.1 19C18.9 19.1 18.7 19.3 18.5 19.4C18 19.8 17.2 20.3 17 20.5C16.9 20.5 16.8 20.6 16.7 20.7C16.3 20.8 16.1 20.9 16 20.9C15.5 20.8 14.9 20.5 14.2 20.2C13.7 19.8 12.7 18.9 12.4 18.6C12.3 18.5 12.2 18.4 12.1 18.2C11.9 18 11.2 17.1 11 16.6C10.9 16.5 10.8 16.4 10.7 16.3C10.7 16.2 10.6 16.1 10.6 15.9C10.5 15.9 10.4 15.7 10.4 15.6C10.3 15.5 10.2 15.2 10.1 15C10 14.8 9.8 14.4 9.7 14.2C9.6 14 9.5 13.7 9.4 13.6C9.4 13.4 9.3 13.2 9.2 13C9.2 12.8 9 12.6 9 12.5C8.9 12.3 8.7 12.1 8.7 12C8.7 12 8.5 11.7 8.5 11.7C8.3 11.2 8.2 10.9 7.5 10C6.4 8.3 4.2 6.4 2.7 5.8C2 5.5 1.6 5.4 1.5 5.5ZM28.4 16.7C29.2 16.9 29.7 17.2 29.9 17.7C30.1 18.2 30 18.9 29.6 19.4C29.2 19.9 28.2 20.9 27.6 21.2C26.8 21.7 25.3 22.4 24.2 22.7C23.9 22.8 23.6 22.9 23.5 22.9C22.8 23.2 20.7 23.7 19.6 24C19 24.2 18.4 24.3 18.1 24.4C17.9 24.4 16.1 24.9 15.3 25.1C14.6 25.2 14.7 25.1 15.7 23.6C16.4 22.7 18.5 20.6 19.4 19.9C20.8 18.8 21.4 18.4 23.2 17.6C23.8 17.4 25.6 16.8 25.9 16.8C25.9 16.8 26.3 16.8 26.6 16.7C26.8 16.7 28.2 16.7 28.4 16.7ZM30.4 20.2C30.5 20.3 30.6 20.6 30.6 20.7C31.7 23.1 33.4 24.6 35.6 25.3C36.1 25.5 36.7 25.7 37.2 25.8C37.7 25.8 37.8 25.9 37.8 26.1C37.7 26.2 37.7 26.3 37.7 26.5C37.7 26.6 37.7 26.8 37.6 27C37.4 28.5 36.8 29.9 36.1 31C36.1 31.2 35.9 31.4 35.9 31.6C35.7 31.9 35.2 32.6 34.7 33.3C32.6 35.6 29.7 37.3 26.6 37.8C26.5 37.8 26.3 37.9 26.2 37.9C25.8 37.9 23.7 37.9 23.3 37.9C23.2 37.9 23 37.8 22.9 37.8C21.1 37.6 19.3 36.8 18 35.7C17.7 35.4 17 34.7 16.8 34.5C16.3 33.8 16.1 33 16.3 32.5C16.5 31.8 16.8 31.6 17.9 31.1C19.1 30.5 19.4 30.4 20.2 30C21.4 29.4 23.2 28.4 23.9 27.9C23.9 27.8 24.2 27.7 24.5 27.6C26.3 26.3 28 24.6 28.9 22.9C29.5 22.2 29.7 21.6 29.9 20.7C30.1 20 30.2 19.9 30.4 20.2Z"/></svg>
|
|
@@ -1,34 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Button } from "@vetta-org/ui/button";
|
|
2
|
+
import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
|
|
2
3
|
|
|
3
4
|
function cn(...parts: Array<string | false | null | undefined>): string {
|
|
4
5
|
return parts.filter(Boolean).join(" ");
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export interface AddProjectMenuTriggerViewProps {
|
|
8
|
+
export interface AddProjectMenuTriggerViewProps extends ComponentPropsWithoutRef<"button"> {
|
|
8
9
|
label: string;
|
|
9
|
-
onClick: () => void;
|
|
10
10
|
open: boolean;
|
|
11
|
-
variant: "icon" | "navItem";
|
|
11
|
+
variant: "icon" | "navItem" | "primary" | "secondary";
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
// 作为 PopoverTrigger asChild 的子节点:需要转发 ref 并透传 Radix 注入的属性。
|
|
15
|
+
export const AddProjectMenuTriggerView = forwardRef<HTMLButtonElement, AddProjectMenuTriggerViewProps>(
|
|
16
|
+
function AddProjectMenuTriggerView({ label, open, variant, ...props }, ref): JSX.Element {
|
|
17
|
+
if (variant === "secondary") {
|
|
18
|
+
return (
|
|
19
|
+
<Button variant="secondary" size="lg" className="no-drag w-full text-[13px]" ref={ref}
|
|
20
|
+
{...props}>
|
|
21
|
+
<span className="icon-[solar--add-folder-linear] h-4 w-4 shrink-0" />
|
|
22
|
+
{label}
|
|
23
|
+
</Button>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
if (variant === "navItem") {
|
|
21
28
|
return (
|
|
22
29
|
<button
|
|
23
30
|
type="button"
|
|
24
31
|
title={label}
|
|
25
|
-
|
|
32
|
+
ref={ref}
|
|
33
|
+
{...props}
|
|
26
34
|
className={cn(
|
|
27
35
|
"no-drag flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-[13px] transition-colors",
|
|
28
36
|
open ? "bg-accent text-foreground" : "text-foreground hover:bg-accent",
|
|
29
37
|
)}
|
|
30
38
|
>
|
|
31
|
-
<span className="icon-[solar--add-
|
|
39
|
+
<span className="icon-[solar--add-linear] h-4 w-4 shrink-0" />
|
|
32
40
|
{label}
|
|
33
41
|
</button>
|
|
34
42
|
);
|
|
@@ -38,13 +46,15 @@ export function AddProjectMenuTriggerView({
|
|
|
38
46
|
<button
|
|
39
47
|
type="button"
|
|
40
48
|
title={label}
|
|
41
|
-
|
|
49
|
+
ref={ref}
|
|
50
|
+
{...props}
|
|
42
51
|
className={cn(
|
|
43
52
|
"flex items-center justify-center rounded-md p-1.5 text-foreground transition-opacity hover:bg-accent",
|
|
44
53
|
open ? "opacity-100" : "opacity-0 group-hover:opacity-60 group-hover:hover:opacity-100",
|
|
45
54
|
)}
|
|
46
55
|
>
|
|
47
|
-
<span className="icon-[solar--add-
|
|
56
|
+
<span className="icon-[solar--add-linear] h-4 w-4" />
|
|
48
57
|
</button>
|
|
49
58
|
);
|
|
50
|
-
}
|
|
59
|
+
},
|
|
60
|
+
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
2
|
import { useThemeComponent } from "@vetta-org/theme-sdk";
|
|
3
3
|
import type { SidebarClassNames, SidebarModel } from "@vetta-org/theme-sdk/sidebar";
|
|
4
|
-
import { cn } from "@vetta-org/ui";
|
|
4
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
5
5
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
6
6
|
import { SidebarNavigation } from "./SidebarNavigation";
|
|
7
7
|
import type { SidebarNavMorePanelLabels } from "./SidebarNavMorePanel";
|
|
@@ -35,6 +35,7 @@ export function DefaultSidebar({
|
|
|
35
35
|
<SidebarPanel
|
|
36
36
|
className={classNames?.panel}
|
|
37
37
|
contentClassName={classNames?.panelContent}
|
|
38
|
+
panelRef={model.setPanelRef}
|
|
38
39
|
width={model.width}
|
|
39
40
|
onResize={model.actions.resize}
|
|
40
41
|
onResizeEnd={model.actions.resizeEnd}
|
|
@@ -63,6 +64,7 @@ export function DefaultSidebar({
|
|
|
63
64
|
moreLabel={model.moreLabel}
|
|
64
65
|
moreOpen={model.moreOpen}
|
|
65
66
|
onItemClick={model.actions.openNavItem}
|
|
67
|
+
onItemIntent={model.actions.prefetchNavItem}
|
|
66
68
|
onMoreOpenChange={model.actions.setMoreOpen}
|
|
67
69
|
onNavMove={model.actions.moveNavItem}
|
|
68
70
|
onPinNavItem={model.actions.pinNavItem}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
2
|
import { AnimatePresence, motion } from "motion/react";
|
|
3
3
|
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
4
|
-
import { Button } from "@vetta-org/ui";
|
|
4
|
+
import { Button } from "@vetta-org/ui/button";
|
|
5
|
+
import { cn, OVERLAY_BACKDROP_CLASS } from "@vetta-org/ui/utils";
|
|
5
6
|
|
|
6
7
|
export const MESSAGE_CENTER_DIALOG_SPRING = {
|
|
7
8
|
type: "spring" as const,
|
|
@@ -37,7 +38,7 @@ export function MessageCenterDialogView({
|
|
|
37
38
|
animate={{ opacity: 1 }}
|
|
38
39
|
exit={{ opacity: 0 }}
|
|
39
40
|
transition={{ duration: 0.18 }}
|
|
40
|
-
className="no-drag fixed inset-0 z-50
|
|
41
|
+
className={cn("no-drag fixed inset-0 z-50", OVERLAY_BACKDROP_CLASS)}
|
|
41
42
|
/>
|
|
42
43
|
</DialogPrimitive.Overlay>
|
|
43
44
|
|