@vetta-org/theme-ui 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +740 -20
- 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/CodePreview.tsx +15 -1
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +135 -62
- 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/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +806 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +128 -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 +29 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +6 -2
- 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 +33 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- 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/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- 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/FileLinkBadge.tsx +77 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +418 -0
- package/src/markdown/MarkdownImage.tsx +41 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +82 -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/image-actions.ts +29 -0
- package/src/markdown/index.ts +12 -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.test.ts +31 -0
- package/src/markdown/preview-policy.ts +76 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +55 -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 +77 -17
- package/src/overlays/CommandMenuView.tsx +163 -118
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +55 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +217 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +203 -53
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +26 -1
- package/src/plugin-ui/index.ts +10 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +15 -24
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +114 -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/AppshotSettingsView.tsx +0 -1
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -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 +18 -24
- 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/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +273 -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/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/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +147 -185
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- 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 -5
- package/src/settings/SpaceEditorDialogView.tsx +158 -0
- package/src/settings/SpacesSettingsView.tsx +150 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +59 -68
- 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/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +10 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +23 -18
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +100 -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 +7 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/platform.ts +9 -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 +33 -24
- 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 +29 -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/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- 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 +26 -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/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -44
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -66
- 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/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
- 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,65 +1,44 @@
|
|
|
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 { chromeButtonGroupVariant } from "../shared/platform";
|
|
4
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
5
|
|
|
4
6
|
export interface SettingsMenuTriggerViewProps extends ComponentPropsWithoutRef<"button"> {
|
|
5
|
-
|
|
6
|
-
/** Claw 在线状态徽章(脉冲点 + "Claw"),仅在线时展示。取代原工作模式 badge 位。 */
|
|
7
|
+
/** Claw 在线状态徽章,仅在线时展示。 */
|
|
7
8
|
readonly clawOnline?: boolean;
|
|
8
9
|
readonly clawTitle?: string;
|
|
9
|
-
|
|
10
|
+
/** 当前是否停在设置页,用于按钮组的高亮状态。 */
|
|
11
|
+
readonly active?: boolean;
|
|
12
|
+
readonly iconOnly?: boolean;
|
|
10
13
|
readonly settingsFallbackLabel: string;
|
|
11
|
-
readonly userLabel?: string | null;
|
|
12
14
|
}
|
|
13
15
|
|
|
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
|
-
|
|
16
|
+
/** 底部工作空间切换同款按钮组里的一个 item,点击后直接进入设置页。 */
|
|
31
17
|
export const SettingsMenuTriggerView = forwardRef<HTMLButtonElement, SettingsMenuTriggerViewProps>(
|
|
32
18
|
function SettingsMenuTriggerView(
|
|
33
|
-
{
|
|
19
|
+
{ className, clawOnline, clawTitle, active, iconOnly, settingsFallbackLabel, ...props },
|
|
34
20
|
ref,
|
|
35
21
|
): JSX.Element {
|
|
22
|
+
const label = clawOnline && clawTitle ? `${settingsFallbackLabel} · ${clawTitle}` : settingsFallbackLabel;
|
|
23
|
+
|
|
36
24
|
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>
|
|
25
|
+
<ButtonGroup blur={false} variant={chromeButtonGroupVariant} className="no-drag shrink-0">
|
|
26
|
+
<ButtonGroupItem
|
|
27
|
+
ref={ref}
|
|
28
|
+
active={Boolean(active)}
|
|
29
|
+
aria-label={label}
|
|
30
|
+
title={label}
|
|
31
|
+
icon={<span aria-hidden="true" className="icon-[solar--settings-minimalistic-linear] size-4 shrink-0" />}
|
|
32
|
+
label={iconOnly ? undefined : settingsFallbackLabel}
|
|
33
|
+
badge={
|
|
34
|
+
clawOnline ? (
|
|
35
|
+
<span aria-hidden="true" className="absolute top-1 right-1 size-1.5 rounded-full bg-primary" />
|
|
36
|
+
) : undefined
|
|
37
|
+
}
|
|
38
|
+
className={cn(!iconOnly && "w-full justify-start", className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
</ButtonGroup>
|
|
63
42
|
);
|
|
64
43
|
},
|
|
65
44
|
);
|
|
@@ -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,91 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { act, createRef, type JSX } from "react";
|
|
4
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
5
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
+
import { SidebarSectionActionButton } from "./SidebarSectionActionButton";
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
9
|
+
|
|
10
|
+
const mounted: Array<{ root: Root; container: HTMLDivElement }> = [];
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
for (const { root, container } of mounted.splice(0)) {
|
|
14
|
+
act(() => root.unmount());
|
|
15
|
+
container.remove();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function mount(element: JSX.Element): HTMLButtonElement {
|
|
20
|
+
const container = document.createElement("div");
|
|
21
|
+
document.body.append(container);
|
|
22
|
+
const root = createRoot(container);
|
|
23
|
+
mounted.push({ root, container });
|
|
24
|
+
act(() => root.render(element));
|
|
25
|
+
return container.querySelector("button") as HTMLButtonElement;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("SidebarSectionActionButton", () => {
|
|
29
|
+
it("is a named, non-submitting button that forwards its ref and host attributes", () => {
|
|
30
|
+
const ref = createRef<HTMLButtonElement>();
|
|
31
|
+
const button = mount(
|
|
32
|
+
<SidebarSectionActionButton
|
|
33
|
+
ref={ref}
|
|
34
|
+
aria-haspopup="menu"
|
|
35
|
+
className="shrink-0"
|
|
36
|
+
iconClassName="icon-[solar--menu-dots-bold]"
|
|
37
|
+
label="View options"
|
|
38
|
+
/>,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
expect(ref.current).toBe(button);
|
|
42
|
+
expect(button.type).toBe("button");
|
|
43
|
+
expect(button.getAttribute("aria-label")).toBe("View options");
|
|
44
|
+
expect(button.getAttribute("aria-haspopup")).toBe("menu");
|
|
45
|
+
expect(button.classList.contains("shrink-0")).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("exposes the open state to assistive technology only when it triggers a menu", () => {
|
|
49
|
+
const menuTrigger = (expanded: boolean) =>
|
|
50
|
+
mount(
|
|
51
|
+
<SidebarSectionActionButton
|
|
52
|
+
aria-haspopup="menu"
|
|
53
|
+
expanded={expanded}
|
|
54
|
+
iconClassName="icon-[solar--menu-dots-bold]"
|
|
55
|
+
label="View options"
|
|
56
|
+
/>,
|
|
57
|
+
);
|
|
58
|
+
expect(menuTrigger(false).getAttribute("aria-expanded")).toBe("false");
|
|
59
|
+
expect(menuTrigger(true).getAttribute("aria-expanded")).toBe("true");
|
|
60
|
+
expect(
|
|
61
|
+
mount(<SidebarSectionActionButton expanded iconClassName="icon-[solar--add-linear]" label="Add" />).hasAttribute(
|
|
62
|
+
"aria-expanded",
|
|
63
|
+
),
|
|
64
|
+
).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("stays hidden until its row is hovered or it takes keyboard focus, unless it is always shown", () => {
|
|
68
|
+
const hover = mount(<SidebarSectionActionButton iconClassName="icon-[solar--add-linear]" label="Add" />);
|
|
69
|
+
expect(hover.dataset.reveal).toBe("hover");
|
|
70
|
+
expect(hover.classList).toContain("opacity-0");
|
|
71
|
+
expect(hover.classList).toContain("group-hover:opacity-60");
|
|
72
|
+
expect(hover.classList).toContain("focus-visible:opacity-100");
|
|
73
|
+
|
|
74
|
+
const always = mount(<SidebarSectionActionButton iconClassName="icon-[solar--add-linear]" label="Add" reveal="always" />);
|
|
75
|
+
expect(always.dataset.reveal).toBe("always");
|
|
76
|
+
expect(always.classList).not.toContain("opacity-0");
|
|
77
|
+
|
|
78
|
+
const open = mount(<SidebarSectionActionButton expanded iconClassName="icon-[solar--add-linear]" label="Add" />);
|
|
79
|
+
expect(open.classList).toContain("opacity-100");
|
|
80
|
+
expect(open.classList).not.toContain("opacity-0");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("reports whether its menu is open", () => {
|
|
84
|
+
expect(
|
|
85
|
+
mount(<SidebarSectionActionButton iconClassName="icon-[solar--add-linear]" label="Add" />).dataset.state,
|
|
86
|
+
).toBe("closed");
|
|
87
|
+
expect(
|
|
88
|
+
mount(<SidebarSectionActionButton expanded iconClassName="icon-[solar--add-linear]" label="Add" />).dataset.state,
|
|
89
|
+
).toBe("open");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
2
|
+
import { forwardRef, type ComponentPropsWithoutRef, type JSX } from "react";
|
|
3
|
+
|
|
4
|
+
export interface SidebarSectionActionButtonProps extends Omit<ComponentPropsWithoutRef<"button">, "children"> {
|
|
5
|
+
/** iconify class,例如 `icon-[solar--add-linear]`。 */
|
|
6
|
+
iconClassName: string;
|
|
7
|
+
/** 可访问名称,同时作为悬停提示。 */
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* `hover`:只在所在 `group` 被悬停时出现;`always`:常驻显示。
|
|
11
|
+
* 两者都在自身悬停时提到全亮。
|
|
12
|
+
*/
|
|
13
|
+
reveal?: "hover" | "always";
|
|
14
|
+
/** 关联的菜单或弹层正打开,保持全亮;作为菜单触发器(`aria-haspopup="menu"`)时同步为 `aria-expanded`。 */
|
|
15
|
+
expanded?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 侧栏分区标题行(项目、对话)右侧的图标按钮。
|
|
20
|
+
* 需要作为 Popover/Dropdown 的 `asChild` 触发器时会被注入 ref 与事件,故原样转发。
|
|
21
|
+
*/
|
|
22
|
+
export const SidebarSectionActionButton = forwardRef<HTMLButtonElement, SidebarSectionActionButtonProps>(
|
|
23
|
+
function SidebarSectionActionButton(
|
|
24
|
+
{ className, expanded = false, iconClassName, label, reveal = "hover", type = "button", ...props },
|
|
25
|
+
ref,
|
|
26
|
+
): JSX.Element {
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
ref={ref}
|
|
30
|
+
type={type}
|
|
31
|
+
title={label}
|
|
32
|
+
aria-label={label}
|
|
33
|
+
aria-expanded={props["aria-haspopup"] === "menu" ? expanded : undefined}
|
|
34
|
+
data-state={expanded ? "open" : "closed"}
|
|
35
|
+
data-reveal={reveal}
|
|
36
|
+
className={cn(
|
|
37
|
+
// 键盘聚焦时也要可见,不能只靠悬停才露出。
|
|
38
|
+
"flex items-center justify-center rounded-md p-1.5 text-foreground transition-opacity hover:bg-accent focus-visible:opacity-100",
|
|
39
|
+
expanded
|
|
40
|
+
? "opacity-100"
|
|
41
|
+
: reveal === "always"
|
|
42
|
+
? "opacity-60 hover:opacity-100"
|
|
43
|
+
: "opacity-0 group-hover:opacity-60 group-hover:hover:opacity-100",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
<span aria-hidden="true" className={cn(iconClassName, "h-4 w-4")} />
|
|
49
|
+
</button>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
);
|
|
@@ -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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
3
|
import { isMac } from "../utils/platform";
|
|
4
4
|
|
|
5
5
|
export interface SidebarTopBarClassNames {
|
|
@@ -45,10 +45,12 @@ export function SidebarTopBar({
|
|
|
45
45
|
<div
|
|
46
46
|
className={cn(
|
|
47
47
|
"flex h-11 min-w-0 shrink-0 items-center justify-between gap-1",
|
|
48
|
+
// macOS:内容整体上提 2px,与红绿灯的视觉中线对齐(同 PageHeaderFrame)。
|
|
49
|
+
isMac && "relative top-[-2px]",
|
|
48
50
|
!floating && "drag-region",
|
|
49
51
|
className,
|
|
50
52
|
)}
|
|
51
|
-
style={{ paddingLeft: isMac ?
|
|
53
|
+
style={{ paddingLeft: isMac ? "calc(78px / var(--ui-zoom, 1))" : 16, paddingRight: 6 }}
|
|
52
54
|
>
|
|
53
55
|
{/* brand 只占内容宽;Mac 常为空,避免 flex-1 吃掉 actions 的测量空间 */}
|
|
54
56
|
{isMac ? (
|
|
@@ -65,7 +67,10 @@ export function SidebarTopBar({
|
|
|
65
67
|
{/*
|
|
66
68
|
* flex-1:actions 始终吃掉剩余宽度,宿主放进来的自适应按钮才能随侧栏拉宽恢复完整文案。
|
|
67
69
|
*/}
|
|
68
|
-
<div
|
|
70
|
+
<div
|
|
71
|
+
className={cn("flex min-w-0 flex-1 items-center justify-end gap-1", classNames?.actions)}
|
|
72
|
+
data-titlebar-anchor=""
|
|
73
|
+
>
|
|
69
74
|
{actions}
|
|
70
75
|
{imOnline && (
|
|
71
76
|
<button
|
|
@@ -77,10 +82,8 @@ export function SidebarTopBar({
|
|
|
77
82
|
classNames?.clawButton,
|
|
78
83
|
)}
|
|
79
84
|
>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<span className="relative inline-flex h-1 w-1 rounded-full bg-secondary-foreground" />
|
|
83
|
-
</span>
|
|
85
|
+
{/* 在线是常驻状态:用静态圆点,不要 animate-ping(无限动画会让空闲窗口持续重绘)。 */}
|
|
86
|
+
<span className="inline-flex h-1 w-1 shrink-0 rounded-full bg-secondary-foreground" />
|
|
84
87
|
Claw
|
|
85
88
|
</button>
|
|
86
89
|
)}
|