@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
|
@@ -30,31 +30,19 @@ export interface AppearanceModeOption {
|
|
|
30
30
|
readonly hint: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export interface AppearanceCursorOption {
|
|
34
|
-
readonly value: string;
|
|
35
|
-
readonly label: string;
|
|
36
|
-
readonly hint: string;
|
|
37
|
-
readonly icon?: string;
|
|
38
|
-
readonly preview?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
33
|
export interface AppearanceActionPickerViewLabels {
|
|
42
34
|
readonly modeSection: string;
|
|
43
35
|
readonly themeSection: string;
|
|
44
|
-
readonly cursorSection: string;
|
|
45
36
|
}
|
|
46
37
|
|
|
47
38
|
export interface AppearanceActionPickerViewProps {
|
|
48
39
|
readonly mode: AppearanceThemeMode;
|
|
49
40
|
readonly themeId: string;
|
|
50
|
-
readonly cursorStyle: string;
|
|
51
41
|
readonly themes: readonly AppearanceThemePreview[];
|
|
52
42
|
readonly modes: readonly AppearanceModeOption[];
|
|
53
|
-
readonly cursors: readonly AppearanceCursorOption[];
|
|
54
43
|
readonly labels: AppearanceActionPickerViewLabels;
|
|
55
44
|
readonly onModeChange: (mode: AppearanceThemeMode) => void;
|
|
56
45
|
readonly onThemeChange: (themeId: string) => void;
|
|
57
|
-
readonly onCursorStyleChange: (style: string) => void;
|
|
58
46
|
}
|
|
59
47
|
|
|
60
48
|
const BLOB_LAYOUT: { left: string; top: string; w: string; h: string; rotate: number }[] = [
|
|
@@ -125,7 +113,7 @@ function BlockCard({
|
|
|
125
113
|
style={{ background: palette.background }}
|
|
126
114
|
>
|
|
127
115
|
<div className="absolute inset-0 flex items-center justify-center">
|
|
128
|
-
<div className=
|
|
116
|
+
<div className="relative aspect-square w-[180%]" style={{ filter: "blur(28px) saturate(115%)" }}>
|
|
129
117
|
{BLOB_LAYOUT.map((b, i) => (
|
|
130
118
|
<div
|
|
131
119
|
key={`${theme.id}-${i}`}
|
|
@@ -139,7 +127,7 @@ function BlockCard({
|
|
|
139
127
|
}}
|
|
140
128
|
>
|
|
141
129
|
<div
|
|
142
|
-
className=
|
|
130
|
+
className="h-full w-full rounded-full"
|
|
143
131
|
style={{
|
|
144
132
|
background: colors[i],
|
|
145
133
|
animationDuration: `${5 + i * 1.3}s`,
|
|
@@ -187,61 +175,14 @@ function BlockCard({
|
|
|
187
175
|
);
|
|
188
176
|
}
|
|
189
177
|
|
|
190
|
-
function CursorCard({
|
|
191
|
-
value,
|
|
192
|
-
label,
|
|
193
|
-
hint,
|
|
194
|
-
icon,
|
|
195
|
-
preview,
|
|
196
|
-
active,
|
|
197
|
-
onSelect,
|
|
198
|
-
}: {
|
|
199
|
-
value: string;
|
|
200
|
-
label: string;
|
|
201
|
-
hint: string;
|
|
202
|
-
icon?: string;
|
|
203
|
-
preview?: string;
|
|
204
|
-
active: boolean;
|
|
205
|
-
onSelect: (value: string) => void;
|
|
206
|
-
}): ReactNode {
|
|
207
|
-
return (
|
|
208
|
-
<button
|
|
209
|
-
type="button"
|
|
210
|
-
onClick={() => onSelect(value)}
|
|
211
|
-
className={cn(
|
|
212
|
-
"group relative flex flex-col items-start gap-2 rounded-xl border bg-card px-4 py-3 text-left transition-colors",
|
|
213
|
-
active
|
|
214
|
-
? "border-primary/70 ring-1 ring-inset ring-primary/30"
|
|
215
|
-
: "border-border hover:border-primary/40 hover:bg-accent/40",
|
|
216
|
-
)}
|
|
217
|
-
>
|
|
218
|
-
<div className="flex w-full items-center justify-between">
|
|
219
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted/80">
|
|
220
|
-
{preview ? (
|
|
221
|
-
<img src={preview} alt="" className="h-7 w-7 object-contain" draggable={false} />
|
|
222
|
-
) : (
|
|
223
|
-
<span className={cn(icon, "h-6 w-6", active ? "text-primary" : "text-muted-foreground")} />
|
|
224
|
-
)}
|
|
225
|
-
</div>
|
|
226
|
-
{active && <span className="icon-[mdi--check-circle] h-4 w-4 text-primary" />}
|
|
227
|
-
</div>
|
|
228
|
-
<div className="text-[13px] font-medium text-foreground">{label}</div>
|
|
229
|
-
<div className="text-[11px] text-muted-foreground">{hint}</div>
|
|
230
|
-
</button>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
178
|
export function AppearanceActionPickerView({
|
|
235
179
|
mode,
|
|
236
180
|
themeId,
|
|
237
|
-
cursorStyle,
|
|
238
181
|
themes,
|
|
239
182
|
modes,
|
|
240
|
-
cursors,
|
|
241
183
|
labels,
|
|
242
184
|
onModeChange,
|
|
243
185
|
onThemeChange,
|
|
244
|
-
onCursorStyleChange,
|
|
245
186
|
}: AppearanceActionPickerViewProps): JSX.Element {
|
|
246
187
|
return (
|
|
247
188
|
<div className="space-y-5">
|
|
@@ -269,23 +210,6 @@ export function AppearanceActionPickerView({
|
|
|
269
210
|
))}
|
|
270
211
|
</div>
|
|
271
212
|
</fieldset>
|
|
272
|
-
<fieldset>
|
|
273
|
-
<legend className="mb-2.5 text-[13px] font-medium text-foreground">{labels.cursorSection}</legend>
|
|
274
|
-
<div className="grid grid-cols-2 gap-2.5">
|
|
275
|
-
{cursors.map((c) => (
|
|
276
|
-
<CursorCard
|
|
277
|
-
key={c.value}
|
|
278
|
-
value={c.value}
|
|
279
|
-
label={c.label}
|
|
280
|
-
hint={c.hint}
|
|
281
|
-
icon={c.icon}
|
|
282
|
-
preview={c.preview}
|
|
283
|
-
active={cursorStyle === c.value}
|
|
284
|
-
onSelect={onCursorStyleChange}
|
|
285
|
-
/>
|
|
286
|
-
))}
|
|
287
|
-
</div>
|
|
288
|
-
</fieldset>
|
|
289
213
|
</div>
|
|
290
214
|
);
|
|
291
215
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Drawer,
|
|
5
|
-
DrawerContent,
|
|
6
|
-
DrawerDescription,
|
|
7
|
-
DrawerFooter,
|
|
8
|
-
DrawerHeader,
|
|
9
|
-
DrawerTitle,
|
|
10
|
-
} from "@vetta-org/ui";
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Drawer, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle } from "@vetta-org/ui/drawer";
|
|
11
4
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
12
5
|
|
|
13
6
|
export interface AppearanceApprovalDrawerViewLabels {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Dialog, DialogContent } from "@vetta-org/ui/dialog";
|
|
4
|
+
import { Drawer, DrawerContent } from "@vetta-org/ui/drawer";
|
|
5
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
6
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
4
7
|
|
|
5
8
|
export interface BatchTasksApprovalFrameViewLabels {
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { useState, type JSX } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Dialog,
|
|
5
|
-
DialogContent,
|
|
6
|
-
DialogDescription,
|
|
7
|
-
DialogFooter,
|
|
8
|
-
DialogHeader,
|
|
9
|
-
DialogTitle,
|
|
10
|
-
} from "@vetta-org/ui";
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@vetta-org/ui/dialog";
|
|
11
4
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
12
5
|
|
|
13
6
|
export interface GenericActionApprovalField {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Dialog, DialogContent } from "@vetta-org/ui/dialog";
|
|
4
|
+
import { Drawer, DrawerContent } from "@vetta-org/ui/drawer";
|
|
5
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
6
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { useState, type JSX } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Dialog,
|
|
5
|
-
DialogContent,
|
|
6
|
-
DialogDescription,
|
|
7
|
-
DialogFooter,
|
|
8
|
-
DialogHeader,
|
|
9
|
-
DialogTitle,
|
|
10
|
-
} from "@vetta-org/ui";
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@vetta-org/ui/dialog";
|
|
11
4
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
12
5
|
|
|
13
6
|
export interface NavigationOpenApprovalField {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Dialog, DialogContent } from "@vetta-org/ui/dialog";
|
|
4
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
5
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
4
6
|
|
|
5
7
|
export interface SchedulerActionApprovalDialogViewLabels {
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DrawerContent,
|
|
6
|
-
DrawerDescription,
|
|
7
|
-
DrawerFooter,
|
|
8
|
-
DrawerHeader,
|
|
9
|
-
DrawerTitle,
|
|
10
|
-
cn,
|
|
11
|
-
} from "@vetta-org/ui";
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Drawer, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle } from "@vetta-org/ui/drawer";
|
|
4
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
12
5
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
13
6
|
|
|
14
7
|
export interface SchedulerEditApprovalDrawerViewLabels {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn } from "@vetta-org/ui";
|
|
1
|
+
import { cn, OVERLAY_BACKDROP_CLASS } from "@vetta-org/ui/utils";
|
|
2
2
|
import { AnimatePresence, motion } from "motion/react";
|
|
3
3
|
import {
|
|
4
4
|
createContext,
|
|
@@ -107,13 +107,13 @@ export interface ActivityPanelDesktopProps extends ComponentPropsWithoutRef<"asi
|
|
|
107
107
|
readonly present?: boolean;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
/** Desktop
|
|
110
|
+
/** Desktop layout boundary. The width snaps to its target so siblings reflow only once. */
|
|
111
111
|
export const ActivityPanelDesktop = forwardRef<HTMLElement, ActivityPanelDesktopProps>(
|
|
112
112
|
function ActivityPanelDesktop(
|
|
113
113
|
{ present = true, className, children, style, ...props },
|
|
114
114
|
forwardedRef,
|
|
115
115
|
) {
|
|
116
|
-
const { displayedWidth, isOpen
|
|
116
|
+
const { displayedWidth, isOpen } = useActivityPanelContext("Desktop");
|
|
117
117
|
if (!present) return null;
|
|
118
118
|
return (
|
|
119
119
|
<aside
|
|
@@ -125,7 +125,6 @@ export const ActivityPanelDesktop = forwardRef<HTMLElement, ActivityPanelDesktop
|
|
|
125
125
|
style={{
|
|
126
126
|
...style,
|
|
127
127
|
width: isOpen ? displayedWidth : 0,
|
|
128
|
-
transition: isResizing ? "none" : "width 0.2s ease-in-out",
|
|
129
128
|
}}
|
|
130
129
|
{...props}
|
|
131
130
|
>
|
|
@@ -137,20 +136,24 @@ export const ActivityPanelDesktop = forwardRef<HTMLElement, ActivityPanelDesktop
|
|
|
137
136
|
|
|
138
137
|
export interface ActivityPanelSurfaceProps extends ComponentPropsWithoutRef<"div"> {}
|
|
139
138
|
|
|
140
|
-
/** Visual
|
|
139
|
+
/** Visual surface that slides independently of the desktop layout boundary. */
|
|
141
140
|
export const ActivityPanelSurface = forwardRef<HTMLDivElement, ActivityPanelSurfaceProps>(
|
|
142
141
|
function ActivityPanelSurface({ className, children, style, ...props }, forwardedRef) {
|
|
143
|
-
const { displayedWidth, isOpen } = useActivityPanelContext("Surface");
|
|
142
|
+
const { displayedWidth, isOpen, isResizing } = useActivityPanelContext("Surface");
|
|
144
143
|
return (
|
|
145
144
|
<div
|
|
146
145
|
ref={forwardedRef}
|
|
147
146
|
aria-hidden={!isOpen}
|
|
147
|
+
inert={!isOpen}
|
|
148
148
|
className={cn(
|
|
149
|
-
"
|
|
149
|
+
"absolute inset-y-0 left-0 flex min-h-0 flex-col",
|
|
150
|
+
isResizing
|
|
151
|
+
? "transition-none"
|
|
152
|
+
: "transition-[transform,opacity] duration-200 ease-[cubic-bezier(0.22,0.61,0.36,1)] motion-reduce:transition-none",
|
|
150
153
|
isOpen ? "opacity-100" : "pointer-events-none opacity-0",
|
|
151
154
|
className,
|
|
152
155
|
)}
|
|
153
|
-
style={{ ...style, width: displayedWidth }}
|
|
156
|
+
style={{ ...style, width: displayedWidth, transform: isOpen ? "none" : "translateX(100%)" }}
|
|
154
157
|
{...props}
|
|
155
158
|
>
|
|
156
159
|
{children}
|
|
@@ -167,7 +170,7 @@ export const ActivityPanelHeader = forwardRef<HTMLDivElement, ActivityPanelHeade
|
|
|
167
170
|
<div
|
|
168
171
|
ref={forwardedRef}
|
|
169
172
|
className={cn(
|
|
170
|
-
"group/activity-tabs relative z-20 flex shrink-0 items-end pt-
|
|
173
|
+
"group/activity-tabs relative z-20 flex shrink-0 items-end pt-3",
|
|
171
174
|
className,
|
|
172
175
|
)}
|
|
173
176
|
{...props}
|
|
@@ -229,7 +232,7 @@ export function ActivityPanelSheet({
|
|
|
229
232
|
exit={{ opacity: 0 }}
|
|
230
233
|
transition={{ duration: 0.2 }}
|
|
231
234
|
onClick={close}
|
|
232
|
-
className={cn("fixed inset-0 z-40
|
|
235
|
+
className={cn("fixed inset-0 z-40", OVERLAY_BACKDROP_CLASS, backdropClassName)}
|
|
233
236
|
/>
|
|
234
237
|
<motion.div
|
|
235
238
|
key="activity-sheet"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { ActivityPanel } from "./ActivityPanel";
|
|
4
|
+
import { ActivityPanelFrame } from "./ActivityPanelFrame";
|
|
5
|
+
|
|
6
|
+
describe("ActivityPanelFrame", () => {
|
|
7
|
+
it("keeps only the top-left corner and the left and top edges", () => {
|
|
8
|
+
const markup = renderToStaticMarkup(
|
|
9
|
+
<ActivityPanelFrame>
|
|
10
|
+
<span>内容</span>
|
|
11
|
+
</ActivityPanelFrame>,
|
|
12
|
+
);
|
|
13
|
+
expect(markup).toContain("rounded-tl-xl");
|
|
14
|
+
expect(markup).toContain("border-l border-t border-border");
|
|
15
|
+
expect(markup).not.toContain("rounded-tr-");
|
|
16
|
+
expect(markup).not.toContain("rounded-bl-");
|
|
17
|
+
expect(markup).not.toContain("rounded-br-");
|
|
18
|
+
expect(markup).not.toContain("border-r");
|
|
19
|
+
expect(markup).not.toContain("border-b ");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("ActivityPanel header", () => {
|
|
24
|
+
it("leaves room between the tab row and the window header buttons", () => {
|
|
25
|
+
const markup = renderToStaticMarkup(
|
|
26
|
+
<ActivityPanel.Root isOpen width={360} minWidth={200} maxWidth={800} onOpenChange={() => undefined}>
|
|
27
|
+
<ActivityPanel.Header>标签</ActivityPanel.Header>
|
|
28
|
+
</ActivityPanel.Root>,
|
|
29
|
+
);
|
|
30
|
+
expect(markup).toContain("pt-3");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, JSX, ReactNode } from "react";
|
|
2
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
3
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
4
4
|
|
|
5
5
|
export interface ActivityPanelFrameProps extends ComponentPropsWithoutRef<"div"> {
|
|
@@ -16,7 +16,8 @@ export function ActivityPanelFrame({
|
|
|
16
16
|
return (
|
|
17
17
|
<div
|
|
18
18
|
className={cn(
|
|
19
|
-
|
|
19
|
+
// 只留左上圆角,以及左边、上边的描边;右边和底边贴内容区,不再画线和圆角。
|
|
20
|
+
"relative z-10 flex min-h-0 flex-1 flex-col overflow-visible rounded-tl-xl border-l border-t border-border bg-card dark:bg-muted",
|
|
20
21
|
className,
|
|
21
22
|
)}
|
|
22
23
|
data-theme-surface-root="activity.panel"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Button, ButtonGroup, ButtonGroupItem } from "@vetta-org/ui";
|
|
1
2
|
import type { FormEvent, JSX, Ref } from "react";
|
|
2
3
|
|
|
3
4
|
export interface BrowserPanelLabels {
|
|
@@ -37,29 +38,8 @@ export interface BrowserPanelViewProps {
|
|
|
37
38
|
onRetry: () => void;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
function
|
|
41
|
-
icon
|
|
42
|
-
title,
|
|
43
|
-
disabled,
|
|
44
|
-
onClick,
|
|
45
|
-
}: {
|
|
46
|
-
icon: string;
|
|
47
|
-
title: string;
|
|
48
|
-
disabled?: boolean;
|
|
49
|
-
onClick: () => void;
|
|
50
|
-
}): JSX.Element {
|
|
51
|
-
return (
|
|
52
|
-
<button
|
|
53
|
-
type="button"
|
|
54
|
-
title={title}
|
|
55
|
-
aria-label={title}
|
|
56
|
-
disabled={disabled}
|
|
57
|
-
onClick={onClick}
|
|
58
|
-
className="flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted-foreground/10 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30 disabled:hover:bg-transparent"
|
|
59
|
-
>
|
|
60
|
-
<span className={`${icon} h-4 w-4`} />
|
|
61
|
-
</button>
|
|
62
|
-
);
|
|
41
|
+
function toolbarIcon(icon: string): JSX.Element {
|
|
42
|
+
return <span className={`${icon} text-[14px]`} />;
|
|
63
43
|
}
|
|
64
44
|
|
|
65
45
|
/**
|
|
@@ -96,35 +76,58 @@ export function BrowserPanelView({
|
|
|
96
76
|
|
|
97
77
|
return (
|
|
98
78
|
<div className="flex min-h-0 flex-1 flex-col">
|
|
99
|
-
<div className="flex shrink-0 items-center gap-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
79
|
+
<div className="flex shrink-0 items-center gap-10 border-b border-border/60 px-3 py-1.5">
|
|
80
|
+
<ButtonGroup blur={false} className="shrink-0">
|
|
81
|
+
<ButtonGroupItem
|
|
82
|
+
icon={toolbarIcon("icon-[mdi--arrow-left]")}
|
|
83
|
+
title={labels.back}
|
|
84
|
+
aria-label={labels.back}
|
|
85
|
+
disabled={!canBack}
|
|
86
|
+
onClick={onBack}
|
|
87
|
+
/>
|
|
88
|
+
<ButtonGroupItem
|
|
89
|
+
icon={toolbarIcon("icon-[mdi--arrow-right]")}
|
|
90
|
+
title={labels.forward}
|
|
91
|
+
aria-label={labels.forward}
|
|
92
|
+
disabled={!canForward}
|
|
93
|
+
onClick={onForward}
|
|
94
|
+
/>
|
|
95
|
+
{loading ? (
|
|
96
|
+
<ButtonGroupItem
|
|
97
|
+
icon={toolbarIcon("icon-[mdi--close]")}
|
|
98
|
+
title={labels.stop}
|
|
99
|
+
aria-label={labels.stop}
|
|
100
|
+
onClick={onStop}
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
<ButtonGroupItem
|
|
104
|
+
icon={toolbarIcon("icon-[mdi--refresh]")}
|
|
105
|
+
title={labels.reload}
|
|
106
|
+
aria-label={labels.reload}
|
|
107
|
+
onClick={onReload}
|
|
108
|
+
/>
|
|
109
|
+
)}
|
|
110
|
+
</ButtonGroup>
|
|
112
111
|
<form onSubmit={onAddressSubmit} className="min-w-0 flex-1">
|
|
112
|
+
{/* 地址栏按按钮组的胶囊皮自绘:同款填充色与全圆角,focus 不描边,与左右两组留出间距。 */}
|
|
113
113
|
<input
|
|
114
114
|
type="text"
|
|
115
115
|
value={address}
|
|
116
116
|
spellCheck={false}
|
|
117
117
|
placeholder={labels.addressPlaceholder}
|
|
118
118
|
onChange={(e) => onAddressChange(e.target.value)}
|
|
119
|
-
className="h-
|
|
119
|
+
className="h-8 w-full rounded-full bg-foreground/[0.06] px-3.5 text-[12px] text-foreground outline-none transition-colors placeholder:text-muted-foreground/50 hover:bg-foreground/[0.08] dark:bg-white/[0.08] dark:hover:bg-white/[0.1]"
|
|
120
120
|
/>
|
|
121
121
|
</form>
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
<ButtonGroup blur={false} className="shrink-0">
|
|
123
|
+
<ButtonGroupItem
|
|
124
|
+
icon={toolbarIcon("icon-[mdi--open-in-new]")}
|
|
125
|
+
title={labels.openExternal}
|
|
126
|
+
aria-label={labels.openExternal}
|
|
127
|
+
disabled={!currentUrl}
|
|
128
|
+
onClick={onOpenExternal}
|
|
129
|
+
/>
|
|
130
|
+
</ButtonGroup>
|
|
128
131
|
</div>
|
|
129
132
|
|
|
130
133
|
<div className="relative flex min-h-0 flex-1">
|
|
@@ -154,13 +157,9 @@ export function BrowserPanelView({
|
|
|
154
157
|
<div className="absolute inset-0 flex flex-col items-center justify-center gap-3 bg-muted p-6 text-center">
|
|
155
158
|
<span className="icon-[mdi--alert-circle-outline] h-8 w-8 text-muted-foreground/40" />
|
|
156
159
|
<span className="text-[12px] text-muted-foreground/70">{labels.failed}</span>
|
|
157
|
-
<
|
|
158
|
-
type="button"
|
|
159
|
-
onClick={onRetry}
|
|
160
|
-
className="rounded-md border border-border bg-background px-3 py-1 text-[12px] text-foreground transition-colors hover:bg-muted-foreground/10"
|
|
161
|
-
>
|
|
160
|
+
<Button variant="outline" size="sm" onClick={onRetry}>
|
|
162
161
|
{labels.retry}
|
|
163
|
-
</
|
|
162
|
+
</Button>
|
|
164
163
|
</div>
|
|
165
164
|
)}
|
|
166
165
|
</div>
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { useEffect, useState, type JSX } from "react";
|
|
2
2
|
import { codeToHtml } from "shiki";
|
|
3
|
+
import { ReadonlyCodeView } from "../file-preview/ReadonlyCodeView";
|
|
3
4
|
import { getTextEditorLanguageId } from "../file-preview/text-editor-language";
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Shiki tokenizes the whole source on the renderer thread (about 1.4 ms per KB) and the
|
|
8
|
+
* result is one unvirtualized DOM tree; past this size the preview switches to CodeMirror.
|
|
9
|
+
*/
|
|
10
|
+
export const CODE_PREVIEW_HIGHLIGHT_LIMIT = 100_000;
|
|
11
|
+
|
|
5
12
|
export interface CodePreviewProps {
|
|
6
13
|
content: string;
|
|
7
14
|
extension: string;
|
|
8
15
|
theme: "light" | "dark";
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
export function CodePreview(
|
|
18
|
+
export function CodePreview(props: CodePreviewProps): JSX.Element {
|
|
19
|
+
if (props.content.length > CODE_PREVIEW_HIGHLIGHT_LIMIT) {
|
|
20
|
+
return <ReadonlyCodeView content={props.content} extension={props.extension} />;
|
|
21
|
+
}
|
|
22
|
+
return <HighlightedCodePreview {...props} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function HighlightedCodePreview({ content, extension, theme }: CodePreviewProps): JSX.Element {
|
|
12
26
|
const [html, setHtml] = useState<string | null>(null);
|
|
13
27
|
|
|
14
28
|
useEffect(() => {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { act, type ReactNode } from "react";
|
|
4
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { MarkdownPreviewView } from "./MarkdownPreviewView";
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
9
|
+
|
|
10
|
+
const mounted: Root[] = [];
|
|
11
|
+
|
|
12
|
+
function render(node: ReactNode): { container: HTMLDivElement } {
|
|
13
|
+
const container = document.createElement("div");
|
|
14
|
+
document.body.append(container);
|
|
15
|
+
const root = createRoot(container);
|
|
16
|
+
mounted.push(root);
|
|
17
|
+
act(() => root.render(node));
|
|
18
|
+
return { container };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const section = (index: number) => `## Section ${index}\n\n${"word ".repeat(600)}\n`;
|
|
22
|
+
|
|
23
|
+
describe("MarkdownPreviewView", () => {
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
for (const root of mounted.splice(0)) act(() => root.unmount());
|
|
26
|
+
vi.useRealTimers();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders a large document section by section without losing content", async () => {
|
|
30
|
+
vi.useFakeTimers();
|
|
31
|
+
const content = Array.from({ length: 40 }, (_, index) => section(index)).join("\n");
|
|
32
|
+
const { container } = render(<MarkdownPreviewView content={content} theme="light" onOpenExternal={() => {}} />);
|
|
33
|
+
|
|
34
|
+
const firstPass = container.querySelectorAll("h2").length;
|
|
35
|
+
expect(firstPass).toBeGreaterThan(0);
|
|
36
|
+
expect(firstPass).toBeLessThan(40);
|
|
37
|
+
|
|
38
|
+
// Each section schedules the next one after it commits.
|
|
39
|
+
for (let step = 0; step < 40; step++) {
|
|
40
|
+
await act(async () => {
|
|
41
|
+
await vi.runOnlyPendingTimersAsync();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
expect(container.querySelectorAll("h2")).toHaveLength(40);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("renders a small document in one pass", () => {
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<MarkdownPreviewView content={"# Title\n\nbody"} theme="light" onOpenExternal={() => {}} />,
|
|
50
|
+
);
|
|
51
|
+
expect(container.querySelector("h1")?.textContent).toBe("Title");
|
|
52
|
+
});
|
|
53
|
+
});
|