@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,33 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
1
|
+
import type { ComponentPropsWithoutRef, JSX, ReactNode } from "react";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 展开/收起的滑动时长(毫秒)。
|
|
7
|
+
*
|
|
8
|
+
* 同时是宿主延迟挂载重子树的时长,两处必须同源,否则一改时长,延迟挂载就会重新落回
|
|
9
|
+
* 滑动中间。
|
|
10
|
+
*/
|
|
11
|
+
export const SIDEBAR_DOCK_ANIMATION_MS = 240;
|
|
12
|
+
|
|
13
|
+
export interface SidebarDockProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
6
14
|
children: ReactNode;
|
|
7
15
|
visible: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 左栏宽度(px),与侧边栏面板自身的宽度同源(`sidebarWidthAtom`)。
|
|
18
|
+
*
|
|
19
|
+
* 必须显式给值、不能靠内容撑:抽屉式过渡要求布局宽度一步到位,而「按内容宽度」在
|
|
20
|
+
* 收起态量不到(面板已被移出占位盒子的尺寸计算)。
|
|
21
|
+
*
|
|
22
|
+
* 这是 committed 值。拖宽度时宿主把实时宽度直接写到这个占位元素与面板上(见
|
|
23
|
+
* `SidebarModel.setPanelRef`),不进 React——内容区照常逐帧跟着重排,实测仍是满帧。
|
|
24
|
+
*/
|
|
25
|
+
width: number;
|
|
8
26
|
}
|
|
9
27
|
|
|
28
|
+
/**
|
|
29
|
+
* 左栏的布局占位与展开/收起滑动。
|
|
30
|
+
*
|
|
31
|
+
* 这一层有三条性能约束,改动前先读完:
|
|
32
|
+
*
|
|
33
|
+
* 1. **布局只落一次,滑动走合成层。** 占位盒子的宽度在点击那一刻直接切到终值、不参与
|
|
34
|
+
* 过渡,面板则脱离占位盒子用 `transform` 滑进滑出。原先是逐帧过渡宽度,主内容区因此
|
|
35
|
+
* 被反复重排;而内容区里每一个 `ResizeObserver` 都会在每个布局步上各触发一次并带一次
|
|
36
|
+
* setState——插件的整页工作区视图(宫格列数、等比缩放预览、虚拟列表、图表)全靠它做
|
|
37
|
+
* 自适应,一次收缩实测 156 次回调、long task 175ms。改成一步到位后回调只剩一次,
|
|
38
|
+
* 且与视图里怎么写无关,第三方插件同样受益。
|
|
39
|
+
* 代价是内容的自适应(宫格换列、文字换行)在点击瞬间完成,而不是跟着滑动渐变——抽屉
|
|
40
|
+
* 动画的常规取舍。
|
|
41
|
+
*
|
|
42
|
+
* 2. **过渡纯 CSS**,不走 JS 动画:展开这一下主线程最忙,逐帧测量并写样式的动画第一个
|
|
43
|
+
* 被挤掉。
|
|
44
|
+
*
|
|
45
|
+
* 3. **子树挂过一次就留在树上**,不随收起卸载。整棵子树重挂一次是约 150ms 的同步渲染,
|
|
46
|
+
* 压在点击那一次 commit 里会把滑动的头几帧整段吃掉。
|
|
47
|
+
*
|
|
48
|
+
* 留住子树的代价必须还清:`inert` + `aria-hidden` 挡掉指针与 Tab(否则会多出一条看不见
|
|
49
|
+
* 却能走进去的侧边栏);`inert` 同时是「左栏不在位」的样式钩子——经典侧边栏贴边的负
|
|
50
|
+
* margin、主内容左缘补色都据它判定,见 renderer/styles.css。
|
|
51
|
+
*
|
|
52
|
+
* 收起态还必须 `opacity-0`:占位盒子的左缘停在 AppFrame 的 8px 内边距上,面板按自身宽度
|
|
53
|
+
* 滑出后右缘正好压在窗口最左那 8px 上(mac 经典侧边栏是半透明 tint + 右边框,会显成一条
|
|
54
|
+
* 竖白条)。透明度跟着一起过渡,滑出过程照旧可见。
|
|
55
|
+
*/
|
|
10
56
|
export function SidebarDock({
|
|
11
57
|
children,
|
|
12
58
|
className,
|
|
59
|
+
style,
|
|
13
60
|
visible,
|
|
61
|
+
width,
|
|
14
62
|
...props
|
|
15
63
|
}: SidebarDockProps): JSX.Element {
|
|
64
|
+
const mountedOnce = useRef(visible);
|
|
65
|
+
if (visible) mountedOnce.current = true;
|
|
16
66
|
return (
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
67
|
+
<div
|
|
68
|
+
// z-10:收起时面板要贴着已经铺开的内容区滑出去,不能被它盖住。
|
|
69
|
+
className={cn("relative z-10 shrink-0 overflow-visible", className)}
|
|
70
|
+
style={{ width: visible ? width : 0, ...style }}
|
|
71
|
+
{...(visible ? {} : { inert: true, "aria-hidden": true })}
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"absolute inset-y-0 left-0 transition-[transform,opacity] ease-[cubic-bezier(0.22,0.61,0.36,1)] motion-reduce:transition-none",
|
|
77
|
+
visible ? "opacity-100" : "opacity-0",
|
|
78
|
+
)}
|
|
79
|
+
style={{
|
|
80
|
+
width,
|
|
81
|
+
transform: visible ? "translateX(0)" : `translateX(-${width}px)`,
|
|
82
|
+
transitionDuration: `${SIDEBAR_DOCK_ANIMATION_MS}ms`,
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{mountedOnce.current ? children : null}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
32
88
|
);
|
|
33
89
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnimatePresence, motion, type HTMLMotionProps } from "motion/react";
|
|
2
2
|
import type { JSX, ReactNode } from "react";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
|
|
5
5
|
export interface SidebarOverlayProps extends Omit<HTMLMotionProps<"div">, "children"> {
|
|
6
6
|
children: ReactNode;
|
package/src/layout/index.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { MainContentFrame } from "./MainContentFrame";
|
|
|
5
5
|
export type { ResizeHandleProps } from "./ResizeHandle";
|
|
6
6
|
export { ResizeHandle } from "./ResizeHandle";
|
|
7
7
|
export type { SidebarDockProps } from "./SidebarDock";
|
|
8
|
-
export { SidebarDock } from "./SidebarDock";
|
|
8
|
+
export { SIDEBAR_DOCK_ANIMATION_MS, SidebarDock } from "./SidebarDock";
|
|
9
9
|
export type { SidebarOverlayProps } from "./SidebarOverlay";
|
|
10
10
|
export { SidebarOverlay } from "./SidebarOverlay";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { type ResizeHandleSide, resizeHandleDelta, resolveResizeHandleAxis } from "./ResizeHandle";
|
|
3
|
+
|
|
4
|
+
describe("resizeHandleDelta", () => {
|
|
5
|
+
it("贴在结束边的把手:顺着指针方向拖就是变大", () => {
|
|
6
|
+
expect(resizeHandleDelta("right", 12)).toBe(12);
|
|
7
|
+
expect(resizeHandleDelta("bottom", 12)).toBe(12);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("贴在起始边的把手:往回拖才是变大", () => {
|
|
11
|
+
expect(resizeHandleDelta("left", 12)).toBe(-12);
|
|
12
|
+
expect(resizeHandleDelta("top", 12)).toBe(-12);
|
|
13
|
+
// 底部面板的把手贴在自己上沿:往上拖(负位移)应当把面板拉高。
|
|
14
|
+
expect(resizeHandleDelta("top", -12)).toBe(12);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("resolveResizeHandleAxis", () => {
|
|
19
|
+
it("横向把手读 clientX,用列光标,轨道占满高度", () => {
|
|
20
|
+
for (const side of ["left", "right"] satisfies ResizeHandleSide[]) {
|
|
21
|
+
const axis = resolveResizeHandleAxis(side);
|
|
22
|
+
expect(axis.vertical).toBe(false);
|
|
23
|
+
expect(axis.cursorClass).toBe("cursor-col-resize");
|
|
24
|
+
expect(axis.overlayCursor).toBe("col-resize");
|
|
25
|
+
expect(axis.track).toContain("top-0");
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("纵向把手读 clientY,用行光标,轨道占满宽度", () => {
|
|
30
|
+
for (const side of ["top", "bottom"] satisfies ResizeHandleSide[]) {
|
|
31
|
+
const axis = resolveResizeHandleAxis(side);
|
|
32
|
+
expect(axis.vertical).toBe(true);
|
|
33
|
+
expect(axis.cursorClass).toBe("cursor-row-resize");
|
|
34
|
+
expect(axis.overlayCursor).toBe("row-resize");
|
|
35
|
+
expect(axis.track).toContain("left-0");
|
|
36
|
+
expect(axis.track).toContain("right-0");
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("把手贴在 side 指定的那条边上", () => {
|
|
41
|
+
expect(resolveResizeHandleAxis("left").edge).toBe("left-0");
|
|
42
|
+
expect(resolveResizeHandleAxis("right").edge).toBe("right-0");
|
|
43
|
+
expect(resolveResizeHandleAxis("top").edge).toBe("top-0");
|
|
44
|
+
expect(resolveResizeHandleAxis("bottom").edge).toBe("bottom-0");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("渐变方向跟着轴走,否则线条会在短边上被压没", () => {
|
|
48
|
+
expect(resolveResizeHandleAxis("right").gradientDirection).toBe("to bottom");
|
|
49
|
+
expect(resolveResizeHandleAxis("bottom").gradientDirection).toBe("to right");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { describe, expect, test } from "vitest";
|
|
4
|
+
import { TODO_PROGRESS_CSS } from "./chat/TodoProgress";
|
|
5
|
+
import { ACTIVITY_STATUS_DOT_CSS } from "./shared/ActivityStatusDot";
|
|
6
|
+
|
|
7
|
+
const stylesCss = readFileSync(join(import.meta.dirname, "styles.css"), "utf8");
|
|
8
|
+
const sendButtonCss = readFileSync(join(import.meta.dirname, "chat", "send-button.css"), "utf8");
|
|
9
|
+
|
|
10
|
+
/** 取出某个选择器的第一条规则体。 */
|
|
11
|
+
function ruleBody(css: string, selector: string): string {
|
|
12
|
+
const start = css.indexOf(`${selector} {`);
|
|
13
|
+
expect(start, `missing rule for ${selector}`).toBeGreaterThanOrEqual(0);
|
|
14
|
+
return css.slice(start, css.indexOf("}", start));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 「进行中」指示器在 theme-ui 的 CSS 里只有静止态:呼吸/波纹由宿主用 Web Animations 挂
|
|
19
|
+
* steps(16) 的合成器动画并锁同一相位。这里守住「不要再有人把 infinite 关键帧写回来」。
|
|
20
|
+
*/
|
|
21
|
+
describe("in-progress indicators declare no animation of their own", () => {
|
|
22
|
+
test("theme-ui styles carry no infinite keyframes for the indicator classes", () => {
|
|
23
|
+
expect(ruleBody(stylesCss, ".processing-shimmer")).not.toMatch(/animation\s*:/);
|
|
24
|
+
expect(stylesCss).not.toContain("@keyframes processing-shimmer");
|
|
25
|
+
expect(stylesCss).not.toContain("--vetta-live-phase");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("send button ripple rings rest invisible and are animated by the host", () => {
|
|
29
|
+
const body = ruleBody(sendButtonCss, ".send-button-ripple");
|
|
30
|
+
expect(body).toContain("opacity: 0;");
|
|
31
|
+
expect(body).not.toMatch(/animation\s*:/);
|
|
32
|
+
expect(sendButtonCss).not.toContain("@keyframes send-button-ripple");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("todo and activity-dot style snippets hold no keyframes", () => {
|
|
36
|
+
for (const css of [TODO_PROGRESS_CSS, ACTIVITY_STATUS_DOT_CSS]) {
|
|
37
|
+
expect(css).not.toContain("@keyframes");
|
|
38
|
+
expect(css).not.toMatch(/animation\s*:/);
|
|
39
|
+
}
|
|
40
|
+
// 光晕没有宿主动画时不该留下一圈静止的色块。
|
|
41
|
+
expect(ACTIVITY_STATUS_DOT_CSS).toContain(".activity-dot-halo { opacity: 0; }");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
2
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
3
|
+
import { CodeBlockCopyButtonView } from "../shared/CodeBlockCopyButton";
|
|
4
|
+
import { SyntaxHighlightedCode } from "../shared/SyntaxHighlightedCode";
|
|
5
|
+
import type { MarkdownCodeBlockProps } from "./definition";
|
|
6
|
+
|
|
7
|
+
interface CodeBlockState extends MarkdownCodeBlockProps {
|
|
8
|
+
copied: boolean;
|
|
9
|
+
copy: () => void;
|
|
10
|
+
}
|
|
11
|
+
const CodeBlockContext = createContext<CodeBlockState | null>(null);
|
|
12
|
+
|
|
13
|
+
function useCodeBlock(): CodeBlockState {
|
|
14
|
+
const context = useContext(CodeBlockContext);
|
|
15
|
+
if (!context) throw new Error("CodeBlock parts must be used within CodeBlock.Root");
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function CodeBlockRoot({ children, ...props }: MarkdownCodeBlockProps & { children: ReactNode }) {
|
|
20
|
+
const [copied, setCopied] = useState(false);
|
|
21
|
+
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
22
|
+
const version = useRef(0);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
version.current++;
|
|
25
|
+
setCopied(false);
|
|
26
|
+
return () => {
|
|
27
|
+
version.current++;
|
|
28
|
+
clearTimeout(timer.current);
|
|
29
|
+
};
|
|
30
|
+
}, [props.code]);
|
|
31
|
+
const copy = useCallback(() => {
|
|
32
|
+
const current = version.current;
|
|
33
|
+
void navigator.clipboard
|
|
34
|
+
.writeText(props.code)
|
|
35
|
+
.then(() => {
|
|
36
|
+
if (version.current !== current) return;
|
|
37
|
+
setCopied(true);
|
|
38
|
+
clearTimeout(timer.current);
|
|
39
|
+
timer.current = setTimeout(() => setCopied(false), 1500);
|
|
40
|
+
})
|
|
41
|
+
.catch(() => {
|
|
42
|
+
if (version.current === current) setCopied(false);
|
|
43
|
+
});
|
|
44
|
+
}, [props.code]);
|
|
45
|
+
return <CodeBlockContext.Provider value={{ ...props, copied, copy }}>{children}</CodeBlockContext.Provider>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function CodeBlockCopy({ children }: { children: ReactNode }) {
|
|
49
|
+
const { copied, copy, labels } = useCodeBlock();
|
|
50
|
+
return (
|
|
51
|
+
<CodeBlockCopyButtonView copied={copied} onCopy={copy} labels={labels}>
|
|
52
|
+
{children}
|
|
53
|
+
</CodeBlockCopyButtonView>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 代码块外壳,与 `MarkdownTable` 共用一套「外框 + 内面板」设计:
|
|
59
|
+
* 外框铺一层淡淡的前景色并留 3px 内边距,底部内面板回到 `background` 并自己收圆角。
|
|
60
|
+
* 语言标记不画底色、不画分隔线,直接坐在外框上(圆角取外框的 12px),
|
|
61
|
+
* 与表格表头一致:表头与表体靠颜色深浅分层,而不是靠分割线。
|
|
62
|
+
*/
|
|
63
|
+
export function CodeBlockFrame({ className, ...props }: ComponentPropsWithoutRef<"div">) {
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
{...props}
|
|
67
|
+
data-md-code-frame=""
|
|
68
|
+
className={cn(
|
|
69
|
+
"my-3 rounded-xl border border-border/60 bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] p-[3px] dark:bg-muted",
|
|
70
|
+
className,
|
|
71
|
+
)}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** 内面板:对应表格的 tbody 面板,圆角与外框同心(外框 12px 减去 3px 内边距)。 */
|
|
77
|
+
export function CodeBlockBody({ className, ...props }: ComponentPropsWithoutRef<"div">) {
|
|
78
|
+
return (
|
|
79
|
+
<div {...props} className={cn("overflow-hidden rounded-[9px] bg-background", className)} />
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function CodeBlockLanguage() {
|
|
84
|
+
const { lang } = useCodeBlock();
|
|
85
|
+
return lang ? (
|
|
86
|
+
<div className="px-4 py-2.5 text-[12px] font-medium text-muted-foreground/80">{lang}</div>
|
|
87
|
+
) : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function cn(...parts: Array<string | false | null | undefined>): string {
|
|
91
|
+
return parts.filter(Boolean).join(" ");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function CodeBlockContent() {
|
|
95
|
+
const { code, lang, theme, live } = useCodeBlock();
|
|
96
|
+
return (
|
|
97
|
+
<CodeBlockBody>
|
|
98
|
+
<SyntaxHighlightedCode code={code} lang={lang} theme={theme} fontSizeClass="text-[13px]" live={live} />
|
|
99
|
+
</CodeBlockBody>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function DefaultCodeBlock(props: MarkdownCodeBlockProps) {
|
|
104
|
+
return (
|
|
105
|
+
<CodeBlockRoot {...props}>
|
|
106
|
+
<CodeBlockCopy>
|
|
107
|
+
<CodeBlockFrame>
|
|
108
|
+
<CodeBlockLanguage />
|
|
109
|
+
<CodeBlockContent />
|
|
110
|
+
</CodeBlockFrame>
|
|
111
|
+
</CodeBlockCopy>
|
|
112
|
+
</CodeBlockRoot>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const CodeBlock = {
|
|
117
|
+
Root: CodeBlockRoot,
|
|
118
|
+
Copy: CodeBlockCopy,
|
|
119
|
+
Frame: CodeBlockFrame,
|
|
120
|
+
Body: CodeBlockBody,
|
|
121
|
+
Language: CodeBlockLanguage,
|
|
122
|
+
Content: CodeBlockContent,
|
|
123
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
function cn(...parts: Array<string | false | null | undefined>): string {
|
|
4
|
+
return parts.filter(Boolean).join(" ");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface InlineTokenChipProps {
|
|
8
|
+
readonly icon?: string;
|
|
9
|
+
readonly iconUrl?: string;
|
|
10
|
+
readonly iconNode?: ReactNode;
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly title?: string;
|
|
13
|
+
readonly tone?: "primary" | "member";
|
|
14
|
+
readonly className?: string;
|
|
15
|
+
readonly asButton?: boolean;
|
|
16
|
+
readonly onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Shared read/write representation for inline composer and user-message tokens. */
|
|
20
|
+
export function InlineTokenChip({
|
|
21
|
+
icon,
|
|
22
|
+
iconUrl,
|
|
23
|
+
iconNode,
|
|
24
|
+
label,
|
|
25
|
+
title,
|
|
26
|
+
tone = "primary",
|
|
27
|
+
className,
|
|
28
|
+
asButton = false,
|
|
29
|
+
onClick,
|
|
30
|
+
}: InlineTokenChipProps): JSX.Element {
|
|
31
|
+
const classes = cn(
|
|
32
|
+
"mx-px inline-block max-w-full select-none whitespace-pre rounded-md border px-1.5 align-baseline text-[12px] font-medium leading-[1.6]",
|
|
33
|
+
tone === "member"
|
|
34
|
+
? "border-primary/30 bg-primary/10 text-primary"
|
|
35
|
+
: "border-primary/25 bg-primary/10 text-primary",
|
|
36
|
+
asButton && "cursor-pointer hover:bg-primary/20",
|
|
37
|
+
className,
|
|
38
|
+
);
|
|
39
|
+
const content = (
|
|
40
|
+
<>
|
|
41
|
+
{iconNode ? (
|
|
42
|
+
<span className="mr-1 inline-flex h-3 w-3 items-center justify-center overflow-hidden align-[-0.15em]">
|
|
43
|
+
{iconNode}
|
|
44
|
+
</span>
|
|
45
|
+
) : iconUrl ? (
|
|
46
|
+
<img
|
|
47
|
+
src={iconUrl}
|
|
48
|
+
alt=""
|
|
49
|
+
draggable={false}
|
|
50
|
+
className="mr-1 inline-block h-3 w-3 rounded-sm align-[-0.15em] object-contain"
|
|
51
|
+
/>
|
|
52
|
+
) : icon ? (
|
|
53
|
+
<span className={`${icon} mr-1 inline-block h-3 w-3 align-[-0.15em]`} />
|
|
54
|
+
) : null}
|
|
55
|
+
{label}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return asButton ? (
|
|
60
|
+
<button type="button" className={classes} title={title ?? label} onClick={onClick} data-inline-token="true">
|
|
61
|
+
{content}
|
|
62
|
+
</button>
|
|
63
|
+
) : (
|
|
64
|
+
<span className={classes} title={title ?? label} data-inline-token="true">
|
|
65
|
+
{content}
|
|
66
|
+
</span>
|
|
67
|
+
);
|
|
68
|
+
}
|