@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
|
-
import { Button } from "@vetta-org/ui";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
|
|
5
5
|
export interface MessageCenterTriggerViewProps {
|
|
6
6
|
readonly open: boolean;
|
|
@@ -1,20 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Button } from "@vetta-org/ui/button";
|
|
2
|
+
import type { JSX, ReactNode } from "react";
|
|
2
3
|
|
|
3
4
|
export interface ProjectsPanelEmptyStateLabels {
|
|
4
|
-
title: string;
|
|
5
5
|
description: string;
|
|
6
|
+
newConversation: string;
|
|
7
|
+
title: string;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export interface ProjectsPanelEmptyStateProps {
|
|
9
11
|
labels: ProjectsPanelEmptyStateLabels;
|
|
12
|
+
onNewConversation: () => void;
|
|
13
|
+
/** Secondary action slot, e.g. the add-project menu. */
|
|
14
|
+
projectAction: ReactNode;
|
|
10
15
|
}
|
|
11
16
|
|
|
12
|
-
export function ProjectsPanelEmptyState({
|
|
17
|
+
export function ProjectsPanelEmptyState({
|
|
18
|
+
labels,
|
|
19
|
+
onNewConversation,
|
|
20
|
+
projectAction,
|
|
21
|
+
}: ProjectsPanelEmptyStateProps): JSX.Element {
|
|
13
22
|
return (
|
|
14
|
-
<div className="
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
<div className="px-1 py-2">
|
|
24
|
+
<div className="flex flex-col gap-3 rounded-2xl bg-card p-3.5">
|
|
25
|
+
<div className="flex flex-col gap-1">
|
|
26
|
+
<p className="text-[14px] font-semibold text-foreground">{labels.title}</p>
|
|
27
|
+
<p className="text-[12px] leading-relaxed text-muted-foreground">{labels.description}</p>
|
|
28
|
+
</div>
|
|
29
|
+
<div className="flex flex-col gap-2">
|
|
30
|
+
<Button variant="primary" size="lg" className="w-full text-[13px]" onClick={onNewConversation}>
|
|
31
|
+
<span className="icon-[solar--chat-round-line-linear] h-4 w-4 shrink-0" />
|
|
32
|
+
{labels.newConversation}
|
|
33
|
+
</Button>
|
|
34
|
+
{projectAction}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
18
37
|
</div>
|
|
19
38
|
);
|
|
20
39
|
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
3
|
|
|
4
4
|
export interface SessionStatusIconProps {
|
|
5
5
|
active: boolean;
|
|
6
6
|
running: boolean;
|
|
7
7
|
scheduled: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 会话正等着用户处理(提问 / 审批 / 询问 / 授权)。优先于其它状态:
|
|
10
|
+
* 「在转」说明 agent 还在干活,「停住 + 问号」才说明它在等人,两者同时出现会互相盖住信息。
|
|
11
|
+
*/
|
|
12
|
+
waiting?: boolean;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
export function SessionStatusIcon({
|
|
11
16
|
active,
|
|
12
17
|
running,
|
|
13
18
|
scheduled,
|
|
19
|
+
waiting = false,
|
|
14
20
|
}: SessionStatusIconProps): JSX.Element {
|
|
21
|
+
if (waiting) {
|
|
22
|
+
return (
|
|
23
|
+
<span
|
|
24
|
+
data-session-leading-icon="true"
|
|
25
|
+
data-session-waiting="true"
|
|
26
|
+
className="icon-[solar--question-circle-bold] h-3.5 w-3.5 shrink-0 text-amber-500 motion-safe:animate-pulse"
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
15
30
|
if (running) {
|
|
16
31
|
return (
|
|
17
32
|
<span
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { SettingsMenuTriggerView } from "./SettingsMenuTriggerView";
|
|
5
|
+
|
|
6
|
+
describe("SettingsMenuTriggerView", () => {
|
|
7
|
+
it("renders one button of the sidebar button group with the settings glyph", () => {
|
|
8
|
+
const markup = renderToStaticMarkup(
|
|
9
|
+
<SettingsMenuTriggerView active={false} iconOnly settingsFallbackLabel="设置" />,
|
|
10
|
+
);
|
|
11
|
+
expect(markup).toContain('data-slot="button-group"');
|
|
12
|
+
expect(markup).toContain('aria-label="设置"');
|
|
13
|
+
expect(markup).toContain("icon-[solar--settings-minimalistic-linear]");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("marks the item as pressed while the settings page is open", () => {
|
|
17
|
+
const markup = renderToStaticMarkup(
|
|
18
|
+
<SettingsMenuTriggerView active iconOnly settingsFallbackLabel="Settings" />,
|
|
19
|
+
);
|
|
20
|
+
expect(markup).toContain('aria-pressed="true"');
|
|
21
|
+
expect(markup).toContain("data-active");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("forwards the button ref so the sidebar can anchor the trigger", () => {
|
|
25
|
+
const ref = createRef<HTMLButtonElement>();
|
|
26
|
+
expect(() =>
|
|
27
|
+
renderToStaticMarkup(<SettingsMenuTriggerView ref={ref} active={false} iconOnly settingsFallbackLabel="设置" />),
|
|
28
|
+
).not.toThrow();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("shows the claw state in the label and keeps a badge only while online", () => {
|
|
32
|
+
const offline = renderToStaticMarkup(
|
|
33
|
+
<SettingsMenuTriggerView active={false} iconOnly settingsFallbackLabel="设置" />,
|
|
34
|
+
);
|
|
35
|
+
const online = renderToStaticMarkup(
|
|
36
|
+
<SettingsMenuTriggerView active={false} iconOnly settingsFallbackLabel="设置" clawOnline clawTitle="Claw 在线" />,
|
|
37
|
+
);
|
|
38
|
+
expect(offline).not.toContain("bg-primary");
|
|
39
|
+
expect(online).toContain("设置 · Claw 在线");
|
|
40
|
+
expect(online).toContain("bg-primary");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,65 +1,43 @@
|
|
|
1
|
-
import { forwardRef, type ComponentPropsWithoutRef, type JSX
|
|
2
|
-
import {
|
|
1
|
+
import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
|
|
2
|
+
import { ButtonGroup, ButtonGroupItem } from "@vetta-org/ui/button-group";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
4
|
|
|
4
5
|
export interface SettingsMenuTriggerViewProps extends ComponentPropsWithoutRef<"button"> {
|
|
5
|
-
|
|
6
|
-
/** Claw 在线状态徽章(脉冲点 + "Claw"),仅在线时展示。取代原工作模式 badge 位。 */
|
|
6
|
+
/** Claw 在线状态徽章,仅在线时展示。 */
|
|
7
7
|
readonly clawOnline?: boolean;
|
|
8
8
|
readonly clawTitle?: string;
|
|
9
|
-
|
|
9
|
+
/** 当前是否停在设置页,用于按钮组的高亮状态。 */
|
|
10
|
+
readonly active?: boolean;
|
|
11
|
+
readonly iconOnly?: boolean;
|
|
10
12
|
readonly settingsFallbackLabel: string;
|
|
11
|
-
readonly userLabel?: string | null;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
function ClawBadge({ title }: { title?: string }): JSX.Element {
|
|
16
|
-
return (
|
|
17
|
-
<span
|
|
18
|
-
className="relative flex h-5 max-w-full shrink-0 items-center gap-1 rounded-full bg-secondary px-1.5 text-[10px] font-medium leading-none text-secondary-foreground"
|
|
19
|
-
title={title}
|
|
20
|
-
>
|
|
21
|
-
<span className="relative flex h-1 w-1 shrink-0">
|
|
22
|
-
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-secondary-foreground opacity-70" />
|
|
23
|
-
<span className="relative inline-flex h-1 w-1 rounded-full bg-secondary-foreground" />
|
|
24
|
-
</span>
|
|
25
|
-
<span className="truncate">Claw</span>
|
|
26
|
-
</span>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
/** 底部工作空间切换同款按钮组里的一个 item,点击后直接进入设置页。 */
|
|
31
16
|
export const SettingsMenuTriggerView = forwardRef<HTMLButtonElement, SettingsMenuTriggerViewProps>(
|
|
32
17
|
function SettingsMenuTriggerView(
|
|
33
|
-
{
|
|
18
|
+
{ className, clawOnline, clawTitle, active, iconOnly, settingsFallbackLabel, ...props },
|
|
34
19
|
ref,
|
|
35
20
|
): JSX.Element {
|
|
21
|
+
const label = clawOnline && clawTitle ? `${settingsFallbackLabel} · ${clawTitle}` : settingsFallbackLabel;
|
|
22
|
+
|
|
36
23
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</>
|
|
55
|
-
) : (
|
|
56
|
-
<>
|
|
57
|
-
<span className="icon-[solar--settings-linear] h-3.5 w-3.5 shrink-0" />
|
|
58
|
-
<span className="min-w-0 flex-1 truncate text-left">{settingsFallbackLabel}</span>
|
|
59
|
-
{clawOnline && <ClawBadge title={clawTitle} />}
|
|
60
|
-
</>
|
|
61
|
-
)}
|
|
62
|
-
</button>
|
|
24
|
+
<ButtonGroup blur={false} className="no-drag shrink-0">
|
|
25
|
+
<ButtonGroupItem
|
|
26
|
+
ref={ref}
|
|
27
|
+
active={Boolean(active)}
|
|
28
|
+
aria-label={label}
|
|
29
|
+
title={label}
|
|
30
|
+
icon={<span aria-hidden="true" className="icon-[solar--settings-minimalistic-linear] size-4 shrink-0" />}
|
|
31
|
+
label={iconOnly ? undefined : settingsFallbackLabel}
|
|
32
|
+
badge={
|
|
33
|
+
clawOnline ? (
|
|
34
|
+
<span aria-hidden="true" className="absolute top-1 right-1 size-1.5 rounded-full bg-primary" />
|
|
35
|
+
) : undefined
|
|
36
|
+
}
|
|
37
|
+
className={cn(!iconOnly && "w-full justify-start", className)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
</ButtonGroup>
|
|
63
41
|
);
|
|
64
42
|
},
|
|
65
43
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment, useState, type JSX } from "react";
|
|
2
|
-
import { Popover, PopoverContent, PopoverTrigger } from "@vetta-org/ui";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@vetta-org/ui/popover";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
|
+
import { SIDEBAR_SECTION_TRIGGER_CLASS, SidebarSectionTriggerLabel } from "./SidebarSectionTriggerLabel";
|
|
4
5
|
|
|
5
6
|
export interface SidebarFilterSelectOption {
|
|
6
7
|
readonly value: string;
|
|
@@ -30,16 +31,7 @@ export function SidebarFilterSelectView({
|
|
|
30
31
|
return (
|
|
31
32
|
<Popover open={open} onOpenChange={setOpen}>
|
|
32
33
|
<PopoverTrigger asChild>
|
|
33
|
-
<button
|
|
34
|
-
type="button"
|
|
35
|
-
className={cn(
|
|
36
|
-
// 与侧栏「更多」触发器对齐:icon h-4 + gap-2。
|
|
37
|
-
"no-drag flex min-w-0 cursor-pointer items-center gap-2 rounded-md px-1.5 py-0.5 text-[12px] font-medium transition-colors",
|
|
38
|
-
open
|
|
39
|
-
? "bg-accent text-foreground"
|
|
40
|
-
: "text-muted-foreground/80 hover:bg-accent hover:text-foreground",
|
|
41
|
-
)}
|
|
42
|
-
>
|
|
34
|
+
<button type="button" className={cn("no-drag", SIDEBAR_SECTION_TRIGGER_CLASS)}>
|
|
43
35
|
{showGridIcon && <span className="icon-[solar--widget-4-linear] h-4 w-4 shrink-0" />}
|
|
44
36
|
{/* 选中标签档时把颜色带到收起态,否则收起后只剩一个名字,认不出是哪个标签。 */}
|
|
45
37
|
{current?.dotColor ? (
|
|
@@ -49,15 +41,15 @@ export function SidebarFilterSelectView({
|
|
|
49
41
|
style={{ backgroundColor: current.dotColor }}
|
|
50
42
|
/>
|
|
51
43
|
) : null}
|
|
52
|
-
<
|
|
53
|
-
<span className="icon-[solar--alt-arrow-down-linear] h-3 w-3 shrink-0" />
|
|
44
|
+
<SidebarSectionTriggerLabel label={current?.label ?? ""} open={open} />
|
|
54
45
|
</button>
|
|
55
46
|
</PopoverTrigger>
|
|
56
47
|
<PopoverContent
|
|
57
48
|
side="bottom"
|
|
58
49
|
align="start"
|
|
59
50
|
sideOffset={4}
|
|
60
|
-
|
|
51
|
+
// Match the inner radius to the inset from the popover edge.
|
|
52
|
+
className="max-h-[60vh] w-[160px] gap-0 overflow-y-auto rounded-xl p-(--sidebar-filter-inset) [--sidebar-filter-inset:--spacing(1)]"
|
|
61
53
|
>
|
|
62
54
|
{options.map((option) => (
|
|
63
55
|
<Fragment key={option.value}>
|
|
@@ -69,7 +61,7 @@ export function SidebarFilterSelectView({
|
|
|
69
61
|
setOpen(false);
|
|
70
62
|
}}
|
|
71
63
|
className={cn(
|
|
72
|
-
"flex w-full items-center gap-2 rounded-
|
|
64
|
+
"flex w-full items-center gap-2 rounded-[max(0px,calc(var(--radius-xl)_-_var(--sidebar-filter-inset)))] px-2 py-[5px] text-[12px] font-medium transition-colors",
|
|
73
65
|
value === option.value
|
|
74
66
|
? "bg-primary text-primary-foreground"
|
|
75
67
|
: "text-foreground hover:bg-accent",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
|
|
2
2
|
import type { SidebarNavItem } from "@vetta-org/theme-sdk/sidebar";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
import { SidebarNavBadgeView } from "./SidebarNavBadgeView";
|
|
5
5
|
import { SidebarNavIcon } from "./SidebarNavIcon";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
2
|
import type { SidebarNavItem } from "@vetta-org/theme-sdk/sidebar";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
import { SidebarNavBadgeView } from "./SidebarNavBadgeView";
|
|
5
5
|
import type { SidebarNavDragHandlers, SidebarNavRegion } from "./useSidebarNavDrag";
|
|
6
6
|
import { SidebarNavIcon } from "./SidebarNavIcon";
|
|
@@ -23,6 +23,7 @@ export interface SidebarNavMorePanelProps {
|
|
|
23
23
|
labels: SidebarNavMorePanelLabels;
|
|
24
24
|
moreItems: readonly SidebarNavItem[];
|
|
25
25
|
onItemClick: (item: SidebarNavItem) => void;
|
|
26
|
+
onItemIntent?: (item: SidebarNavItem) => void;
|
|
26
27
|
onPin: (key: string) => void;
|
|
27
28
|
onReset: () => void;
|
|
28
29
|
onUnpin: (key: string) => void;
|
|
@@ -33,16 +34,19 @@ function DropLine({ visible }: { visible: boolean }): JSX.Element {
|
|
|
33
34
|
return (
|
|
34
35
|
<span
|
|
35
36
|
aria-hidden
|
|
36
|
-
className={cn("mx-1 block h-px rounded-full
|
|
37
|
+
className={cn("mx-1 block h-px rounded-full", visible ? "bg-primary" : "bg-transparent")}
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
// 行内不加任何 transition:弹层里 20+ 行,每行的 hover 过渡(尤其 pin 按钮的 opacity)
|
|
43
|
+
// 会在指针划过时反复创建合成层动画,实测 hover 帧间隔从 14ms 劣化到 p95 70ms。
|
|
41
44
|
function NavRow({
|
|
42
45
|
drag,
|
|
43
46
|
item,
|
|
44
47
|
labels,
|
|
45
48
|
onClick,
|
|
49
|
+
onIntent,
|
|
46
50
|
onTogglePin,
|
|
47
51
|
pinDisabled,
|
|
48
52
|
region,
|
|
@@ -51,6 +55,7 @@ function NavRow({
|
|
|
51
55
|
item: SidebarNavItem;
|
|
52
56
|
labels: SidebarNavMorePanelLabels;
|
|
53
57
|
onClick: () => void;
|
|
58
|
+
onIntent?: () => void;
|
|
54
59
|
onTogglePin: (() => void) | null;
|
|
55
60
|
pinDisabled: boolean;
|
|
56
61
|
region: SidebarNavRegion;
|
|
@@ -60,7 +65,7 @@ function NavRow({
|
|
|
60
65
|
return (
|
|
61
66
|
<div
|
|
62
67
|
className={cn(
|
|
63
|
-
"group/nav-row flex items-center gap-1 rounded-md pr-1
|
|
68
|
+
"group/nav-row flex items-center gap-1 rounded-md pr-1",
|
|
64
69
|
drag.draggingKey === item.key && "opacity-40",
|
|
65
70
|
)}
|
|
66
71
|
draggable={dragProps.draggable}
|
|
@@ -80,8 +85,10 @@ function NavRow({
|
|
|
80
85
|
type="button"
|
|
81
86
|
title={item.title ?? item.label}
|
|
82
87
|
onClick={onClick}
|
|
88
|
+
onFocus={onIntent}
|
|
89
|
+
onMouseEnter={onIntent}
|
|
83
90
|
className={cn(
|
|
84
|
-
"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1.5 py-1.5 text-[13px]
|
|
91
|
+
"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1.5 py-1.5 text-[13px]",
|
|
85
92
|
item.active ? "bg-accent font-semibold text-foreground" : "text-foreground hover:bg-accent/50",
|
|
86
93
|
)}
|
|
87
94
|
>
|
|
@@ -98,7 +105,7 @@ function NavRow({
|
|
|
98
105
|
aria-pressed={pinned}
|
|
99
106
|
onClick={onTogglePin}
|
|
100
107
|
className={cn(
|
|
101
|
-
"flex h-6 w-6 shrink-0 items-center justify-center rounded-md
|
|
108
|
+
"flex h-6 w-6 shrink-0 items-center justify-center rounded-md",
|
|
102
109
|
pinned
|
|
103
110
|
? "text-primary hover:bg-accent/60"
|
|
104
111
|
: "text-muted-foreground/50 opacity-0 hover:bg-accent/60 hover:text-foreground focus-visible:opacity-100 group-hover/nav-row:opacity-100",
|
|
@@ -125,6 +132,7 @@ export function SidebarNavMorePanel({
|
|
|
125
132
|
labels,
|
|
126
133
|
moreItems,
|
|
127
134
|
onItemClick,
|
|
135
|
+
onItemIntent,
|
|
128
136
|
onPin,
|
|
129
137
|
onReset,
|
|
130
138
|
onUnpin,
|
|
@@ -133,6 +141,8 @@ export function SidebarNavMorePanel({
|
|
|
133
141
|
const pinnedRegion = drag.regionProps("pinned");
|
|
134
142
|
const moreRegion = drag.regionProps("more");
|
|
135
143
|
const hasLockedTail = moreItems[moreItems.length - 1]?.locked === true;
|
|
144
|
+
// 置顶区里被锁定的项(「新会话」)永远固定在侧栏顶部,不可拖、不可取消置顶,列在这里只是噪音。
|
|
145
|
+
const visiblePinnedItems = pinnedItems.filter((item) => item.locked !== true);
|
|
136
146
|
|
|
137
147
|
return (
|
|
138
148
|
<div className="flex max-h-[70vh] flex-col gap-1 overflow-y-auto">
|
|
@@ -145,13 +155,13 @@ export function SidebarNavMorePanel({
|
|
|
145
155
|
onClick={onReset}
|
|
146
156
|
title={labels.reset}
|
|
147
157
|
aria-label={labels.reset}
|
|
148
|
-
className="-me-1 flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/60
|
|
158
|
+
className="-me-1 flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/60 hover:bg-accent/50 hover:text-foreground"
|
|
149
159
|
>
|
|
150
160
|
<span aria-hidden className="icon-[solar--restart-linear] h-3.5 w-3.5" />
|
|
151
161
|
</button>
|
|
152
162
|
</div>
|
|
153
163
|
<div className="flex flex-col" onDragOver={pinnedRegion.onDragOver} onDrop={pinnedRegion.onDrop}>
|
|
154
|
-
{
|
|
164
|
+
{visiblePinnedItems.map((item) => (
|
|
155
165
|
<div key={item.key}>
|
|
156
166
|
<DropLine visible={drag.isDropBefore(item.key, "pinned")} />
|
|
157
167
|
<NavRow
|
|
@@ -159,6 +169,7 @@ export function SidebarNavMorePanel({
|
|
|
159
169
|
item={item}
|
|
160
170
|
labels={labels}
|
|
161
171
|
onClick={() => onItemClick(item)}
|
|
172
|
+
onIntent={onItemIntent ? () => onItemIntent(item) : undefined}
|
|
162
173
|
onTogglePin={item.locked === true ? null : () => onUnpin(item.key)}
|
|
163
174
|
pinDisabled={false}
|
|
164
175
|
region="pinned"
|
|
@@ -185,6 +196,7 @@ export function SidebarNavMorePanel({
|
|
|
185
196
|
item={item}
|
|
186
197
|
labels={labels}
|
|
187
198
|
onClick={() => onItemClick(item)}
|
|
199
|
+
onIntent={onItemIntent ? () => onItemIntent(item) : undefined}
|
|
188
200
|
onTogglePin={item.locked === true ? null : () => onPin(item.key)}
|
|
189
201
|
pinDisabled={!canPinMore}
|
|
190
202
|
region="more"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useMemo, type JSX, type RefCallback } from "react";
|
|
2
2
|
import { useThemeComponent } from "@vetta-org/theme-sdk";
|
|
3
3
|
import type { NavIndicatorBounds, SidebarNavItem } from "@vetta-org/theme-sdk/sidebar";
|
|
4
|
-
import { cn
|
|
4
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@vetta-org/ui/popover";
|
|
5
6
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
6
7
|
import { SidebarNavBadgeView } from "./SidebarNavBadgeView";
|
|
7
8
|
import { SidebarNavIcon } from "./SidebarNavIcon";
|
|
@@ -29,6 +30,7 @@ export interface SidebarNavigationProps {
|
|
|
29
30
|
/** 「更多」自定义面板文案;缺省时退化为不带自定义能力的旧列表。 */
|
|
30
31
|
navCustomizeLabels?: SidebarNavMorePanelLabels;
|
|
31
32
|
onItemClick: (item: SidebarNavItem) => void;
|
|
33
|
+
onItemIntent?: (item: SidebarNavItem) => void;
|
|
32
34
|
onMoreOpenChange?: (open: boolean) => void;
|
|
33
35
|
onNavMove?: (key: string, region: "pinned" | "more", beforeKey: string | null) => void;
|
|
34
36
|
onPinNavItem?: (key: string) => void;
|
|
@@ -52,6 +54,7 @@ export function SidebarNavigation({
|
|
|
52
54
|
moreOpen = false,
|
|
53
55
|
navCustomizeLabels,
|
|
54
56
|
onItemClick,
|
|
57
|
+
onItemIntent,
|
|
55
58
|
onMoreOpenChange,
|
|
56
59
|
onNavMove,
|
|
57
60
|
onPinNavItem,
|
|
@@ -75,20 +78,19 @@ export function SidebarNavigation({
|
|
|
75
78
|
const drag = useSidebarNavDrag(onNavMove ?? noop, itemsByRegion);
|
|
76
79
|
|
|
77
80
|
return (
|
|
78
|
-
<nav className={cn("relative flex flex-col gap-0.5 px-1.5 pb-
|
|
81
|
+
<nav className={cn("relative flex flex-col gap-0.5 px-1.5 pb-1 pt-2", className)}>
|
|
79
82
|
{indicatorBounds && (
|
|
80
|
-
//
|
|
81
|
-
//
|
|
83
|
+
// 纵向用测量出的 top/height 直接落位(无补间);横向不吃测量值,靠 inset-x
|
|
84
|
+
// 跟着 <nav> 内容宽度走——拖宽侧边栏时宽度是实时写进 DOM 的,不会重渲染,
|
|
85
|
+
// 测量宽度要等松手才更新,指示条就会短一截。
|
|
82
86
|
<span
|
|
83
87
|
data-sidebar-nav-indicator=""
|
|
84
88
|
className={cn(
|
|
85
|
-
"pointer-events-none absolute
|
|
86
|
-
"transition-[transform,width,height] duration-200 ease-out motion-reduce:transition-none",
|
|
89
|
+
"pointer-events-none absolute inset-x-1.5 top-0 z-10 overflow-visible rounded-md bg-accent",
|
|
87
90
|
classNames?.indicator,
|
|
88
91
|
)}
|
|
89
92
|
style={{
|
|
90
|
-
transform: `translate3d(
|
|
91
|
-
width: indicatorBounds.width,
|
|
93
|
+
transform: `translate3d(0, ${indicatorBounds.top}px, 0)`,
|
|
92
94
|
height: indicatorBounds.height,
|
|
93
95
|
}}
|
|
94
96
|
>
|
|
@@ -123,6 +125,8 @@ export function SidebarNavigation({
|
|
|
123
125
|
}}
|
|
124
126
|
item={item}
|
|
125
127
|
onClick={() => onItemClick(item)}
|
|
128
|
+
onFocus={() => onItemIntent?.(item)}
|
|
129
|
+
onMouseEnter={() => onItemIntent?.(item)}
|
|
126
130
|
ref={setItemRef(index)}
|
|
127
131
|
/>
|
|
128
132
|
</div>
|
|
@@ -174,8 +178,10 @@ export function SidebarNavigation({
|
|
|
174
178
|
<PopoverContent
|
|
175
179
|
side="right"
|
|
176
180
|
align="start"
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
// 负偏移让弹层压进侧栏一点,不要飘在侧栏外面。
|
|
182
|
+
sideOffset={-40}
|
|
183
|
+
// 外观(无边框、大圆角、柔和投影)由 PopoverContent 基础样式统一提供,这里只管尺寸。
|
|
184
|
+
className="w-[240px] gap-0.5 overflow-hidden p-2"
|
|
179
185
|
>
|
|
180
186
|
{customizable && navCustomizeLabels ? (
|
|
181
187
|
<SidebarNavMorePanel
|
|
@@ -188,6 +194,7 @@ export function SidebarNavigation({
|
|
|
188
194
|
onItemClick(item);
|
|
189
195
|
onMoreOpenChange?.(false);
|
|
190
196
|
}}
|
|
197
|
+
onItemIntent={onItemIntent}
|
|
191
198
|
onPin={onPinNavItem ?? noop}
|
|
192
199
|
onUnpin={onUnpinNavItem ?? noop}
|
|
193
200
|
onReset={onResetNavLayout ?? noop}
|
|
@@ -198,12 +205,14 @@ export function SidebarNavigation({
|
|
|
198
205
|
key={item.key}
|
|
199
206
|
type="button"
|
|
200
207
|
title={item.title ?? item.label}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
onClick={() => {
|
|
209
|
+
onItemClick(item);
|
|
210
|
+
onMoreOpenChange?.(false);
|
|
211
|
+
}}
|
|
212
|
+
onFocus={() => onItemIntent?.(item)}
|
|
213
|
+
onMouseEnter={() => onItemIntent?.(item)}
|
|
205
214
|
className={cn(
|
|
206
|
-
"flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-[13px]
|
|
215
|
+
"flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-[13px]",
|
|
207
216
|
item.active
|
|
208
217
|
? "bg-accent font-semibold text-foreground"
|
|
209
218
|
: "text-foreground hover:bg-accent/50",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { JSX, ReactNode } from "react";
|
|
1
|
+
import type { JSX, ReactNode, RefCallback } from "react";
|
|
2
2
|
import { useThemeSurface } from "@vetta-org/theme-sdk/appearance";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
5
5
|
import { ResizeHandle } from "../layout/ResizeHandle";
|
|
6
6
|
|
|
@@ -10,6 +10,13 @@ export interface SidebarPanelProps {
|
|
|
10
10
|
contentClassName?: string;
|
|
11
11
|
onResize: (delta: number) => void;
|
|
12
12
|
onResizeEnd: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* 面板根节点的 ref。
|
|
15
|
+
*
|
|
16
|
+
* 拖宽度时宿主直接往它写 `style.width`(不进 React,也不经过 `:root` 上的自定义属性),
|
|
17
|
+
* 见 theme-sdk 的 `SidebarModel.setPanelRef`。`width` 是 committed 值,松手时才由 React 写回。
|
|
18
|
+
*/
|
|
19
|
+
panelRef?: RefCallback<HTMLDivElement>;
|
|
13
20
|
width: number;
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -19,6 +26,7 @@ export function SidebarPanel({
|
|
|
19
26
|
contentClassName,
|
|
20
27
|
onResize,
|
|
21
28
|
onResizeEnd,
|
|
29
|
+
panelRef,
|
|
22
30
|
width,
|
|
23
31
|
}: SidebarPanelProps): JSX.Element {
|
|
24
32
|
const surface = useThemeSurface("sidebar.panel");
|
|
@@ -31,6 +39,7 @@ export function SidebarPanel({
|
|
|
31
39
|
className,
|
|
32
40
|
)}
|
|
33
41
|
data-theme-surface-root="sidebar.panel"
|
|
42
|
+
ref={panelRef}
|
|
34
43
|
style={{ width }}
|
|
35
44
|
>
|
|
36
45
|
<ThemeSurface slot="sidebar.panel" />
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
|
|
4
|
+
export const SIDEBAR_SECTION_TRIGGER_CLASS =
|
|
5
|
+
"group/section-trigger inline-flex min-w-0 cursor-pointer items-center gap-1 rounded-md py-1 pl-2.5 pr-2 text-start text-[13px] font-medium text-foreground focus-visible:outline-1 focus-visible:outline-ring focus-visible:outline-offset-[-1px]";
|
|
6
|
+
|
|
7
|
+
export function SidebarSectionTriggerLabel({ label, open }: { label: string; open: boolean }): JSX.Element {
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<span className="truncate group-hover/section-trigger:opacity-70">{label}</span>
|
|
11
|
+
<span
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
className={cn(
|
|
14
|
+
"size-3 shrink-0",
|
|
15
|
+
open ? "icon-[solar--alt-arrow-down-linear]" : "icon-[solar--alt-arrow-right-linear]",
|
|
16
|
+
)}
|
|
17
|
+
/>
|
|
18
|
+
</>
|
|
19
|
+
);
|
|
20
|
+
}
|