@vetta-org/theme-ui 0.1.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.
Files changed (406) hide show
  1. package/package.json +195 -0
  2. package/src/action-approval/AppearanceActionPickerView.tsx +291 -0
  3. package/src/action-approval/AppearanceApprovalDrawerView.tsx +69 -0
  4. package/src/action-approval/AppearancePickerApprovalView.tsx +31 -0
  5. package/src/action-approval/ApprovalParts.tsx +376 -0
  6. package/src/action-approval/BatchTasksApprovalFrameView.tsx +138 -0
  7. package/src/action-approval/BatchTasksExecutionApprovalView.tsx +158 -0
  8. package/src/action-approval/BatchTasksTaskApprovalView.tsx +152 -0
  9. package/src/action-approval/GeneralSetExecutionModeApprovalView.tsx +76 -0
  10. package/src/action-approval/GenericActionApprovalView.tsx +127 -0
  11. package/src/action-approval/ManageActionApprovalFrameTypes.ts +27 -0
  12. package/src/action-approval/ManageActionApprovalFrameView.tsx +136 -0
  13. package/src/action-approval/NavigationOpenApprovalView.tsx +119 -0
  14. package/src/action-approval/SchedulerActionApprovalDialogView.tsx +191 -0
  15. package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +113 -0
  16. package/src/action-approval/SchedulerUpdateApprovalView.tsx +14 -0
  17. package/src/action-approval/ThemeChangeApprovalView.tsx +30 -0
  18. package/src/action-approval/WebhookDeleteApprovalView.tsx +56 -0
  19. package/src/action-approval/WebhookTestApprovalView.tsx +51 -0
  20. package/src/action-approval/cn.ts +4 -0
  21. package/src/action-approval/index.ts +88 -0
  22. package/src/activity/ActivityPanel.tsx +269 -0
  23. package/src/activity/ActivityPanelFrame.tsx +36 -0
  24. package/src/activity/BackgroundTasksTabPanelView.tsx +382 -0
  25. package/src/activity/BatchProgressTabPanelView.tsx +22 -0
  26. package/src/activity/BrowserPanelView.tsx +169 -0
  27. package/src/activity/ChatTabPanelView.tsx +36 -0
  28. package/src/activity/CodePreview.tsx +57 -0
  29. package/src/activity/DebugTabPanelView.tsx +67 -0
  30. package/src/activity/FileTabContentView.tsx +46 -0
  31. package/src/activity/FloatingActivityTabView.tsx +107 -0
  32. package/src/activity/HtmlPreviewView.tsx +135 -0
  33. package/src/activity/JourneyPanelView.tsx +327 -0
  34. package/src/activity/KnowledgeHistoryPanelView.tsx +93 -0
  35. package/src/activity/MarkdownPreviewView.tsx +217 -0
  36. package/src/activity/PluginTabPickerView.tsx +182 -0
  37. package/src/activity/RequestHistorySubTabView.tsx +102 -0
  38. package/src/activity/ScheduleExecutionTabPanelView.tsx +162 -0
  39. package/src/activity/TodoTabPanelView.tsx +66 -0
  40. package/src/activity/ToolCallsSubTabView.tsx +184 -0
  41. package/src/activity/WorkflowTabPanelView.tsx +129 -0
  42. package/src/activity/index.ts +110 -0
  43. package/src/app/AppBackground.tsx +24 -0
  44. package/src/app/AppBootLoadingView.tsx +51 -0
  45. package/src/app/RouteContentLoadingView.tsx +20 -0
  46. package/src/app/index.ts +13 -0
  47. package/src/app-boot.ts +1 -0
  48. package/src/app-shell/DefaultPageHeader.tsx +46 -0
  49. package/src/app-shell/DefaultWindowControls.tsx +32 -0
  50. package/src/app-shell/PageHeaderActionGroup.tsx +15 -0
  51. package/src/app-shell/PageHeaderContent.tsx +70 -0
  52. package/src/app-shell/PageHeaderFrame.tsx +53 -0
  53. package/src/app-shell/PageHeaderSidebarTrigger.tsx +21 -0
  54. package/src/app-shell/PageHeaderTitle.tsx +25 -0
  55. package/src/app-shell/PageHeaderWindowActions.tsx +22 -0
  56. package/src/app-shell/WindowControlButton.tsx +35 -0
  57. package/src/app-shell/index.ts +49 -0
  58. package/src/appearance/BackgroundImageFrame.tsx +57 -0
  59. package/src/appearance/CenterSliceImageFrame.tsx +64 -0
  60. package/src/appearance/CornerImageFrame.tsx +63 -0
  61. package/src/appearance/HorizontalSliceImageFrame.tsx +97 -0
  62. package/src/appearance/NineSliceImageFrame.tsx +65 -0
  63. package/src/appearance/ThemeSurface.tsx +91 -0
  64. package/src/appearance/index.ts +12 -0
  65. package/src/batch-tasks/BatchProjectArtifactFieldView.tsx +36 -0
  66. package/src/batch-tasks/BatchProjectDialogView.tsx +61 -0
  67. package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +108 -0
  68. package/src/batch-tasks/BatchProjectGroupView.tsx +77 -0
  69. package/src/batch-tasks/BatchProjectNameFieldView.tsx +29 -0
  70. package/src/batch-tasks/BatchProjectNotificationFieldView.tsx +42 -0
  71. package/src/batch-tasks/BatchProjectRuntimeFieldsView.tsx +67 -0
  72. package/src/batch-tasks/BatchTaskActionButtonsView.tsx +67 -0
  73. package/src/batch-tasks/BatchTaskCardView.tsx +142 -0
  74. package/src/batch-tasks/BatchTaskGridView.tsx +95 -0
  75. package/src/batch-tasks/BatchTaskListView.tsx +10 -0
  76. package/src/batch-tasks/BatchTaskProjectActionsView.tsx +73 -0
  77. package/src/batch-tasks/BatchTaskProjectBlockView.tsx +117 -0
  78. package/src/batch-tasks/BatchTaskProjectHeaderView.tsx +74 -0
  79. package/src/batch-tasks/BatchTasksPageView.tsx +126 -0
  80. package/src/batch-tasks/batchTaskUi.tsx +101 -0
  81. package/src/batch-tasks/index.ts +70 -0
  82. package/src/batch-tasks/types.ts +120 -0
  83. package/src/chat/ActionButtonBarView.tsx +45 -0
  84. package/src/chat/AgentAvatarView.tsx +59 -0
  85. package/src/chat/AppshotCardView.tsx +89 -0
  86. package/src/chat/AskUserQuestionView.tsx +177 -0
  87. package/src/chat/AssistantMessageView.tsx +147 -0
  88. package/src/chat/AtPanelView.tsx +220 -0
  89. package/src/chat/BackgroundTasksBadgeView.tsx +28 -0
  90. package/src/chat/BashTerminalCard.tsx +225 -0
  91. package/src/chat/ChatExportHostView.tsx +17 -0
  92. package/src/chat/ChatHeaderActionsView.tsx +75 -0
  93. package/src/chat/ContextRingView.tsx +100 -0
  94. package/src/chat/CopyIconButton.tsx +61 -0
  95. package/src/chat/DefaultGuidingWords.tsx +75 -0
  96. package/src/chat/DefaultSceneCarousel.tsx +113 -0
  97. package/src/chat/DefaultSkillBadgeRow.tsx +103 -0
  98. package/src/chat/DrawerCard.tsx +149 -0
  99. package/src/chat/EditDiffView.tsx +137 -0
  100. package/src/chat/ExecutionModeSelectorView.tsx +124 -0
  101. package/src/chat/ExportMessageListView.tsx +20 -0
  102. package/src/chat/GuideBadgeSwiperView.tsx +79 -0
  103. package/src/chat/InlineTokenChip.tsx +68 -0
  104. package/src/chat/InputActionBarView.tsx +112 -0
  105. package/src/chat/InputBarBackground.tsx +25 -0
  106. package/src/chat/InputBarCapsule.tsx +56 -0
  107. package/src/chat/InputBarContextMenuView.tsx +79 -0
  108. package/src/chat/InputBarPlaceholder.tsx +84 -0
  109. package/src/chat/InputBarToolbarButton.tsx +42 -0
  110. package/src/chat/KnowledgeToolViews.tsx +119 -0
  111. package/src/chat/LiveThinkingView.tsx +102 -0
  112. package/src/chat/MessageActions.tsx +109 -0
  113. package/src/chat/MessageBlockSegmentsView.tsx +203 -0
  114. package/src/chat/MessageBoundaryViews.tsx +93 -0
  115. package/src/chat/MessageCardsView.tsx +126 -0
  116. package/src/chat/MessageFeedContext.tsx +14 -0
  117. package/src/chat/MessageFeedLayoutView.tsx +97 -0
  118. package/src/chat/MessageFeedView.tsx +228 -0
  119. package/src/chat/MessageInputView.tsx +193 -0
  120. package/src/chat/MessageLayoutView.tsx +156 -0
  121. package/src/chat/MessageListFooterView.tsx +127 -0
  122. package/src/chat/MessageSelectionContextMenuView.tsx +66 -0
  123. package/src/chat/MessageTimelineView.tsx +261 -0
  124. package/src/chat/MessageView.tsx +82 -0
  125. package/src/chat/MessageVisualView.tsx +43 -0
  126. package/src/chat/ModelSelectorView.tsx +407 -0
  127. package/src/chat/NewSession.ts +107 -0
  128. package/src/chat/NewSessionBackground.tsx +54 -0
  129. package/src/chat/NewSessionPageLayoutView.tsx +96 -0
  130. package/src/chat/NewSessionPicker.tsx +270 -0
  131. package/src/chat/ProgressGroupView.tsx +323 -0
  132. package/src/chat/ProjectSelectorView.tsx +253 -0
  133. package/src/chat/QueueCardView.tsx +151 -0
  134. package/src/chat/ReadImageView.tsx +73 -0
  135. package/src/chat/SandboxGrantsBadgeView.tsx +101 -0
  136. package/src/chat/SandboxPermissionCard.tsx +64 -0
  137. package/src/chat/SceneCard.tsx +138 -0
  138. package/src/chat/SendButton.tsx +135 -0
  139. package/src/chat/SessionDropZoneView.tsx +85 -0
  140. package/src/chat/SessionViewerPageView.tsx +56 -0
  141. package/src/chat/SkillCard.tsx +56 -0
  142. package/src/chat/SkillPromptAreaView.tsx +129 -0
  143. package/src/chat/SuggestionBubblesView.tsx +58 -0
  144. package/src/chat/TextBlockView.tsx +770 -0
  145. package/src/chat/TextPreview.tsx +37 -0
  146. package/src/chat/ThinkingBlockView.tsx +183 -0
  147. package/src/chat/TodoCard.tsx +243 -0
  148. package/src/chat/TodoProgress.tsx +205 -0
  149. package/src/chat/TodoStatusBarView.tsx +140 -0
  150. package/src/chat/ToolCallBlockView.tsx +188 -0
  151. package/src/chat/UsageBarView.tsx +19 -0
  152. package/src/chat/UserMessageContextMenuView.tsx +87 -0
  153. package/src/chat/UserMessageView.tsx +241 -0
  154. package/src/chat/WorkflowFooterItemsView.tsx +170 -0
  155. package/src/chat/WriteContentView.tsx +12 -0
  156. package/src/chat/index.ts +524 -0
  157. package/src/chat/markdown-link.test.ts +238 -0
  158. package/src/chat/markdown-link.ts +279 -0
  159. package/src/chat/send-button.css +318 -0
  160. package/src/chat/useHorizontalDragScroll.ts +146 -0
  161. package/src/file-explorer/ConfirmDeleteDialogView.tsx +62 -0
  162. package/src/file-explorer/FileContextMenuView.tsx +209 -0
  163. package/src/file-explorer/FileTreeCreateRow.tsx +82 -0
  164. package/src/file-explorer/FileTreeNodeView.tsx +274 -0
  165. package/src/file-explorer/FileTreeView.tsx +301 -0
  166. package/src/file-explorer/FilesPanelView.tsx +91 -0
  167. package/src/file-explorer/drag-target.test.ts +34 -0
  168. package/src/file-explorer/drag-target.ts +26 -0
  169. package/src/file-explorer/fileIcons.ts +1 -0
  170. package/src/file-explorer/index.ts +28 -0
  171. package/src/file-explorer/nativeFileDrag.test.ts +30 -0
  172. package/src/file-explorer/nativeFileDrag.ts +14 -0
  173. package/src/file-explorer/types.ts +40 -0
  174. package/src/file-explorer/useFileTreeMarqueeSelection.ts +115 -0
  175. package/src/file-preview/FilePreviewDialogView.tsx +241 -0
  176. package/src/file-preview/FilePreviewView.tsx +162 -0
  177. package/src/file-preview/LightboxImageView.tsx +131 -0
  178. package/src/file-preview/PluginFilePreviewView.tsx +24 -0
  179. package/src/file-preview/PreviewBodyView.tsx +99 -0
  180. package/src/file-preview/PreviewErrorBoundary.tsx +51 -0
  181. package/src/file-preview/TextCodeEditorView.tsx +72 -0
  182. package/src/file-preview/TextFileEditorView.tsx +213 -0
  183. package/src/file-preview/index.ts +56 -0
  184. package/src/file-preview/keyboard-target.test.ts +49 -0
  185. package/src/file-preview/keyboard-target.ts +33 -0
  186. package/src/file-preview/syntax-tokens.css +77 -0
  187. package/src/file-preview/syntax-tokens.test.ts +31 -0
  188. package/src/file-preview/syntax-tokens.ts +155 -0
  189. package/src/file-preview/text-code-editor-theme.ts +321 -0
  190. package/src/file-preview/text-editor-language.test.ts +58 -0
  191. package/src/file-preview/text-editor-language.ts +182 -0
  192. package/src/file-preview/types.ts +29 -0
  193. package/src/flowing/FlowingPanelView.tsx +79 -0
  194. package/src/flowing/FlowingWorkflowView.tsx +54 -0
  195. package/src/flowing/UserNodeView.tsx +148 -0
  196. package/src/flowing/WorkflowBindDialogView.tsx +145 -0
  197. package/src/flowing/WorkflowProgressView.tsx +149 -0
  198. package/src/flowing/index.ts +27 -0
  199. package/src/flowing-chat/ChatBubbleView.tsx +219 -0
  200. package/src/flowing-chat/ChatComposerView.tsx +362 -0
  201. package/src/flowing-chat/ChatMembersBarView.tsx +86 -0
  202. package/src/flowing-chat/ChatPanelView.tsx +73 -0
  203. package/src/flowing-chat/index.ts +21 -0
  204. package/src/index.ts +22 -0
  205. package/src/knowledge/KnowledgeBaseSwitcherView.tsx +154 -0
  206. package/src/knowledge/KnowledgeBreadcrumbView.tsx +92 -0
  207. package/src/knowledge/KnowledgeContentsPanelView.tsx +77 -0
  208. package/src/knowledge/KnowledgeContextMenuView.tsx +70 -0
  209. package/src/knowledge/KnowledgeFilesSkeleton.tsx +22 -0
  210. package/src/knowledge/KnowledgeGridView.tsx +113 -0
  211. package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +85 -0
  212. package/src/knowledge/KnowledgeImportDialogView.tsx +153 -0
  213. package/src/knowledge/KnowledgeListView.tsx +107 -0
  214. package/src/knowledge/KnowledgePendingFilesDialogView.tsx +76 -0
  215. package/src/knowledge/KnowledgeProcessingBadgeView.tsx +18 -0
  216. package/src/knowledge/KnowledgeRenameDialogView.tsx +66 -0
  217. package/src/knowledge/KnowledgeSourcePickerView.tsx +60 -0
  218. package/src/knowledge/KnowledgeViewShared.tsx +103 -0
  219. package/src/knowledge/cn.ts +4 -0
  220. package/src/knowledge/coloredFileIcons.ts +1 -0
  221. package/src/knowledge/index.ts +66 -0
  222. package/src/knowledge/types.ts +31 -0
  223. package/src/knowledge/useMarqueeSelection.ts +95 -0
  224. package/src/layout/AppFrame.tsx +34 -0
  225. package/src/layout/MainContentFrame.tsx +54 -0
  226. package/src/layout/ResizeHandle.tsx +91 -0
  227. package/src/layout/SidebarDock.tsx +33 -0
  228. package/src/layout/SidebarOverlay.tsx +36 -0
  229. package/src/layout/index.ts +10 -0
  230. package/src/overlays/CommandMenuRow.tsx +119 -0
  231. package/src/overlays/CommandMenuView.tsx +183 -0
  232. package/src/overlays/ConfirmDialogView.tsx +109 -0
  233. package/src/overlays/DetailDrawer.tsx +63 -0
  234. package/src/overlays/DetailDrawerEnter.tsx +37 -0
  235. package/src/overlays/KnowledgeDropOverlayView.tsx +43 -0
  236. package/src/overlays/RouteErrorPageView.tsx +72 -0
  237. package/src/overlays/ToasterView.tsx +76 -0
  238. package/src/overlays/UpdateCheckerView.tsx +206 -0
  239. package/src/overlays/UpdateRestartDialogView.tsx +107 -0
  240. package/src/overlays/command-menu-types.ts +47 -0
  241. package/src/overlays/command-menu.css +69 -0
  242. package/src/overlays/detail-drawer-guard.test.ts +16 -0
  243. package/src/overlays/detail-drawer-guard.ts +13 -0
  244. package/src/overlays/index.ts +44 -0
  245. package/src/plugin-ui/index.ts +26 -0
  246. package/src/project/BatchQueueStatusView.tsx +352 -0
  247. package/src/project/ConversationTagDotsView.tsx +130 -0
  248. package/src/project/ConversationTagEditorDialogView.tsx +273 -0
  249. package/src/project/DefaultConversationSectionView.tsx +74 -0
  250. package/src/project/DefaultSessionListView.tsx +128 -0
  251. package/src/project/DefaultSessionRowView.tsx +125 -0
  252. package/src/project/NewProjectDialogView.tsx +140 -0
  253. package/src/project/ProjectContextMenuView.tsx +187 -0
  254. package/src/project/ProjectDetailPageView.tsx +351 -0
  255. package/src/project/ProjectGroupView.tsx +37 -0
  256. package/src/project/ProjectRowView.tsx +111 -0
  257. package/src/project/ProjectSessionsLoadingView.tsx +14 -0
  258. package/src/project/ProjectSessionsView.tsx +96 -0
  259. package/src/project/ProjectsLoadingView.tsx +15 -0
  260. package/src/project/ProjectsPanelMenusView.tsx +23 -0
  261. package/src/project/ProjectsPanelView.tsx +56 -0
  262. package/src/project/QuickScrollOverlay.tsx +188 -0
  263. package/src/project/ScheduleStatusView.tsx +110 -0
  264. package/src/project/SessionContextMenuView.tsx +71 -0
  265. package/src/project/SessionRenameInputView.tsx +49 -0
  266. package/src/project/SessionRowView.tsx +119 -0
  267. package/src/project/SidebarProjectsSectionView.tsx +35 -0
  268. package/src/project/index.ts +87 -0
  269. package/src/project/types.ts +21 -0
  270. package/src/project/useActiveSessionAutoScroll.ts +171 -0
  271. package/src/registry.ts +62 -0
  272. package/src/scheduler/AutomationPageView.tsx +159 -0
  273. package/src/scheduler/ExecutionHistoryView.tsx +179 -0
  274. package/src/scheduler/HistoryDrawerView.tsx +149 -0
  275. package/src/scheduler/TaskFormDialogView.tsx +60 -0
  276. package/src/scheduler/TaskListView.tsx +219 -0
  277. package/src/scheduler/index.ts +30 -0
  278. package/src/settings/AchievementNavigationButtonView.tsx +90 -0
  279. package/src/settings/AchievementPromotionDialogView.tsx +91 -0
  280. package/src/settings/AchievementSettingsView.tsx +44 -0
  281. package/src/settings/AppshotSettingsView.tsx +132 -0
  282. package/src/settings/ArchivedProjectsSettingsView.tsx +80 -0
  283. package/src/settings/BuiltinMcpSecretsDialogView.tsx +278 -0
  284. package/src/settings/BuiltinMcpSectionView.tsx +164 -0
  285. package/src/settings/EnvironmentSettingsView.tsx +176 -0
  286. package/src/settings/GeneralSettingsView.tsx +174 -0
  287. package/src/settings/ImChannelCardView.tsx +152 -0
  288. package/src/settings/ImChannelGuideDialogView.tsx +126 -0
  289. package/src/settings/ImFeishuDialogView.tsx +156 -0
  290. package/src/settings/ImLegacyImportBannerView.tsx +44 -0
  291. package/src/settings/ImLogDrawerView.tsx +75 -0
  292. package/src/settings/ImStatusBadgeView.tsx +39 -0
  293. package/src/settings/McpDefaultIcon.tsx +27 -0
  294. package/src/settings/McpJsonEditorView.tsx +56 -0
  295. package/src/settings/ModelsProviderFormView.tsx +128 -0
  296. package/src/settings/ModelsProvidersSectionView.tsx +52 -0
  297. package/src/settings/MotionSelect.tsx +125 -0
  298. package/src/settings/PermissionsSettingsView.tsx +106 -0
  299. package/src/settings/PetBubbleStylePreviewView.tsx +44 -0
  300. package/src/settings/PetSettingsView.tsx +165 -0
  301. package/src/settings/PresetProviderModelsListView.tsx +58 -0
  302. package/src/settings/PresetProviderRowView.tsx +302 -0
  303. package/src/settings/PresetProvidersSectionView.tsx +70 -0
  304. package/src/settings/QrBindDialogView.tsx +165 -0
  305. package/src/settings/QuickPanelSettingsSectionView.tsx +66 -0
  306. package/src/settings/RemoteMcpSectionView.tsx +192 -0
  307. package/src/settings/SettingChrome.tsx +104 -0
  308. package/src/settings/SettingsAiAssistButtonView.tsx +150 -0
  309. package/src/settings/SettingsAiAssistDialogView.tsx +251 -0
  310. package/src/settings/SettingsFormFields.tsx +121 -0
  311. package/src/settings/SettingsPageShellView.tsx +84 -0
  312. package/src/settings/SettingsSidebarView.tsx +133 -0
  313. package/src/settings/ShortcutRecorderView.tsx +88 -0
  314. package/src/settings/ShortcutsSettingsView.tsx +66 -0
  315. package/src/settings/SubscriptionActionsView.tsx +63 -0
  316. package/src/settings/SubscriptionCardsView.tsx +212 -0
  317. package/src/settings/TeamDetailView.tsx +148 -0
  318. package/src/settings/TeamDialogsView.tsx +151 -0
  319. package/src/settings/TeamListView.tsx +57 -0
  320. package/src/settings/TeamSettingsView.tsx +51 -0
  321. package/src/settings/TokenActivityChartView.tsx +286 -0
  322. package/src/settings/UsageStatsView.tsx +101 -0
  323. package/src/settings/WebhookEndpointListView.tsx +123 -0
  324. package/src/settings/WechatBindDialogView.tsx +45 -0
  325. package/src/settings/achievements/AchievementCurtains.tsx +50 -0
  326. package/src/settings/achievements/AchievementPromotionBadge3D.tsx +350 -0
  327. package/src/settings/achievements/AchievementPromotionConfetti.tsx +71 -0
  328. package/src/settings/achievements/AchievementTitle.tsx +52 -0
  329. package/src/settings/achievements/index.ts +13 -0
  330. package/src/settings/index.ts +226 -0
  331. package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +135 -0
  332. package/src/settings/shouldCloseEmptyApiKeyEditor.ts +40 -0
  333. package/src/settings/token-activity.test.ts +195 -0
  334. package/src/settings/token-activity.ts +320 -0
  335. package/src/shared/AvatarStackView.tsx +45 -0
  336. package/src/shared/BotAvatar.tsx +395 -0
  337. package/src/shared/CodeBlockCopyButton.tsx +48 -0
  338. package/src/shared/CollapsePanel.tsx +125 -0
  339. package/src/shared/ContextMenuView.tsx +134 -0
  340. package/src/shared/MacKeyboardPreview.tsx +260 -0
  341. package/src/shared/MarkdownTable.tsx +216 -0
  342. package/src/shared/MultiplierTag.tsx +15 -0
  343. package/src/shared/ScrollFade.tsx +114 -0
  344. package/src/shared/SegmentedControl.tsx +82 -0
  345. package/src/shared/SyntaxHighlightedCode.tsx +0 -0
  346. package/src/shared/TabBar.tsx +696 -0
  347. package/src/shared/TimePicker.tsx +96 -0
  348. package/src/shared/connected-tab-outline.test.ts +22 -0
  349. package/src/shared/connected-tab-outline.ts +39 -0
  350. package/src/shared/fileIcons.test.ts +28 -0
  351. package/src/shared/fileIcons.ts +322 -0
  352. package/src/shared/index.ts +38 -0
  353. package/src/shared/markdown-table-clipboard.ts +31 -0
  354. package/src/shared/provider-icon/icons.ts +56 -0
  355. package/src/shared/provider-icon/index.tsx +42 -0
  356. package/src/shared/provider-icon/svg-url.d.ts +4 -0
  357. package/src/shared/tab-drag.test.ts +14 -0
  358. package/src/shared/tab-drag.ts +15 -0
  359. package/src/shared/useDelayedUnmount.ts +36 -0
  360. package/src/sidebar/AddProjectMenuItem.tsx +21 -0
  361. package/src/sidebar/AddProjectMenuPopoverView.tsx +52 -0
  362. package/src/sidebar/AddProjectMenuTriggerView.tsx +50 -0
  363. package/src/sidebar/ChatMessageListView.tsx +66 -0
  364. package/src/sidebar/DefaultSidebar.tsx +91 -0
  365. package/src/sidebar/FlowingMessageListView.tsx +111 -0
  366. package/src/sidebar/MessageCenterDialogView.tsx +81 -0
  367. package/src/sidebar/MessageCenterEmptyState.tsx +24 -0
  368. package/src/sidebar/MessageCenterTabs.tsx +86 -0
  369. package/src/sidebar/MessageCenterToolbarButton.tsx +25 -0
  370. package/src/sidebar/MessageCenterTriggerView.tsx +39 -0
  371. package/src/sidebar/NotificationMessageListView.tsx +136 -0
  372. package/src/sidebar/ProjectsPanelEmptyState.tsx +20 -0
  373. package/src/sidebar/RunningPulseDot.tsx +10 -0
  374. package/src/sidebar/SessionStatusIcon.tsx +43 -0
  375. package/src/sidebar/SettingsMenuAccountSection.tsx +32 -0
  376. package/src/sidebar/SettingsMenuActionButton.tsx +24 -0
  377. package/src/sidebar/SettingsMenuDivider.tsx +5 -0
  378. package/src/sidebar/SettingsMenuQuotaSection.tsx +45 -0
  379. package/src/sidebar/SettingsMenuSettingsItem.tsx +18 -0
  380. package/src/sidebar/SettingsMenuThemeSection.tsx +51 -0
  381. package/src/sidebar/SettingsMenuTriggerView.tsx +65 -0
  382. package/src/sidebar/ShowMoreSessionsButton.tsx +37 -0
  383. package/src/sidebar/SidebarFilterSelectView.tsx +95 -0
  384. package/src/sidebar/SidebarNavBadgeView.tsx +58 -0
  385. package/src/sidebar/SidebarNavIcon.tsx +33 -0
  386. package/src/sidebar/SidebarNavItemButton.tsx +59 -0
  387. package/src/sidebar/SidebarNavMorePanel.tsx +199 -0
  388. package/src/sidebar/SidebarNavigation.tsx +223 -0
  389. package/src/sidebar/SidebarPanel.tsx +48 -0
  390. package/src/sidebar/SidebarTopBar.tsx +103 -0
  391. package/src/sidebar/SidebarUpdateIcon.tsx +79 -0
  392. package/src/sidebar/index.ts +118 -0
  393. package/src/sidebar/nav-badge-text.test.ts +23 -0
  394. package/src/sidebar/nav-badge-text.ts +19 -0
  395. package/src/sidebar/useSidebarNavDrag.ts +139 -0
  396. package/src/skills/PluginCardView.tsx +150 -0
  397. package/src/skills/SceneCardView.tsx +194 -0
  398. package/src/skills/SkillCardView.tsx +186 -0
  399. package/src/skills/SkillDetailDialogView.tsx +138 -0
  400. package/src/skills/SkillTagGroupView.tsx +56 -0
  401. package/src/skills/SkillToggleSwitch.tsx +31 -0
  402. package/src/skills/index.ts +29 -0
  403. package/src/skills/skill-icon.test.ts +38 -0
  404. package/src/skills/skill-icon.tsx +126 -0
  405. package/src/styles.css +75 -0
  406. package/src/utils/platform.ts +2 -0
@@ -0,0 +1,395 @@
1
+ import { memo, useCallback, useEffect, useRef, useState, type JSX } from "react";
2
+ import { AnimatePresence, motion, useAnimation } from "motion/react";
3
+
4
+ type AvatarMood = "idle" | "left" | "right" | "think" | "blink" | "bounce" | "sleep";
5
+
6
+ const ACTIVE_MOODS: AvatarMood[] = ["left", "right", "think", "blink", "bounce", "sleep"];
7
+
8
+ const HOLD_MS: Record<Exclude<AvatarMood, "idle">, number> = {
9
+ left: 700,
10
+ right: 700,
11
+ think: 900,
12
+ blink: 320,
13
+ bounce: 760,
14
+ sleep: 1500,
15
+ };
16
+
17
+ interface SizeConfig {
18
+ wrapper: string;
19
+ wrapperPx: number;
20
+ body: string;
21
+ eye: string;
22
+ gap: string;
23
+ shadow: string;
24
+ bubble: string;
25
+ glowInset: string;
26
+ glowBlur: string;
27
+ factor: number;
28
+ }
29
+
30
+ const SIZES: Record<"sm" | "md" | "lg", SizeConfig> = {
31
+ sm: {
32
+ wrapper: "h-5 w-5",
33
+ wrapperPx: 20,
34
+ body: "h-5 w-5 rounded-md",
35
+ eye: "h-[3px] w-[3px]",
36
+ gap: "gap-[3px]",
37
+ shadow: "shadow-[0_2px_6px_-2px_var(--primary)]",
38
+ bubble: "h-1.5 w-1.5 -right-1 -top-1",
39
+ glowInset: "-inset-1",
40
+ glowBlur: "blur-[6px]",
41
+ factor: 1,
42
+ },
43
+ md: {
44
+ wrapper: "h-10 w-10",
45
+ wrapperPx: 40,
46
+ body: "h-10 w-10 rounded-[12px]",
47
+ eye: "h-1.5 w-1.5",
48
+ gap: "gap-1.5",
49
+ shadow: "shadow-[0_6px_18px_-6px_var(--primary)]",
50
+ bubble: "h-2 w-2 -right-1 -top-1",
51
+ glowInset: "-inset-2",
52
+ glowBlur: "blur-[12px]",
53
+ factor: 2,
54
+ },
55
+ lg: {
56
+ wrapper: "h-16 w-16",
57
+ wrapperPx: 64,
58
+ body: "h-16 w-16 rounded-[20px]",
59
+ eye: "h-2.5 w-2.5",
60
+ gap: "gap-2.5",
61
+ shadow: "shadow-[0_12px_32px_-8px_var(--primary)]",
62
+ bubble: "h-3 w-3 -right-1.5 -top-1.5",
63
+ glowInset: "-inset-3",
64
+ glowBlur: "blur-[18px]",
65
+ factor: 3,
66
+ },
67
+ };
68
+
69
+ interface BotAvatarProps {
70
+ /** When true, plays an idle "streaming" glow halo and triggers random gestures. */
71
+ active?: boolean;
72
+ /** When true, randomly cycles gestures regardless of `active`. Useful on Welcome. */
73
+ autoplay?: boolean;
74
+ /**
75
+ * Screensaver-style pacing: the avatar jumps to random positions within its
76
+ * parent container, pausing at each position to play a random gesture.
77
+ * DESIGN.md §5.3 exception — decorative continuous bouncing is intentional.
78
+ */
79
+ pacing?: boolean;
80
+ size?: "sm" | "md" | "lg";
81
+ className?: string;
82
+ /** Optional click override; default: trigger a random gesture. */
83
+ onClick?: () => void;
84
+ title?: string;
85
+ }
86
+
87
+ export const BotAvatar = memo(function BotAvatar({
88
+ active = false,
89
+ autoplay = false,
90
+ pacing = false,
91
+ size = "sm",
92
+ className = "",
93
+ onClick,
94
+ title = "戳一下",
95
+ }: BotAvatarProps): JSX.Element {
96
+ const cfg = SIZES[size];
97
+ const [mood, setMood] = useState<AvatarMood>("idle");
98
+ const [, forceTick] = useState(0);
99
+ const lastPlayedRef = useRef<AvatarMood>("idle");
100
+
101
+ // --- Pacing state ---
102
+ const [pacingDirection, setPacingDirection] = useState<"left" | "right" | "idle">("idle");
103
+ const containerWidthRef = useRef(0);
104
+ const cycleRef = useRef<ReturnType<typeof setTimeout>[]>([]);
105
+ const pacingRef = useRef(false);
106
+ pacingRef.current = pacing;
107
+ const currentXRef = useRef(0);
108
+ const bounceControls = useAnimation();
109
+
110
+ const containerRefCallback = useCallback((el: HTMLDivElement | null) => {
111
+ if (!el) return;
112
+ const parent = el.parentElement;
113
+ if (!parent) return;
114
+ containerWidthRef.current = parent.clientWidth;
115
+ const ro = new ResizeObserver((entries) => {
116
+ for (const entry of entries) {
117
+ containerWidthRef.current = entry.contentRect.width;
118
+ }
119
+ });
120
+ ro.observe(parent);
121
+ }, []);
122
+
123
+ const shouldSchedule = !pacing && (active || autoplay);
124
+
125
+ const pickRandomMood = useCallback((): AvatarMood => {
126
+ const choices = ACTIVE_MOODS.filter((m) => m !== lastPlayedRef.current);
127
+ return choices[Math.floor(Math.random() * choices.length)] ?? "blink";
128
+ }, []);
129
+
130
+ const triggerMood = useCallback((m: AvatarMood) => {
131
+ lastPlayedRef.current = m;
132
+ setMood(m);
133
+ forceTick((t) => t + 1);
134
+ }, []);
135
+
136
+ useEffect(() => {
137
+ if (mood === "idle") return;
138
+ const id = setTimeout(() => setMood("idle"), HOLD_MS[mood]);
139
+ return () => clearTimeout(id);
140
+ }, [mood]);
141
+
142
+ useEffect(() => {
143
+ if (!shouldSchedule || mood !== "idle") return;
144
+ const id = setTimeout(
145
+ () => triggerMood(pickRandomMood()),
146
+ 280 + Math.random() * 420,
147
+ );
148
+ return () => clearTimeout(id);
149
+ }, [shouldSchedule, mood, triggerMood, pickRandomMood]);
150
+
151
+ useEffect(() => {
152
+ if (!shouldSchedule) setMood("idle");
153
+ }, [shouldSchedule]);
154
+
155
+ // --- Pacing cycle: screensaver-style random jumping ---
156
+ const f = cfg.factor;
157
+ useEffect(() => {
158
+ if (!pacing) return;
159
+
160
+ const jump = async () => {
161
+ if (!pacingRef.current) return;
162
+ const maxOff = Math.max(0, containerWidthRef.current - cfg.wrapperPx);
163
+ const target = maxOff > 0 ? Math.random() * maxOff : 0;
164
+ const currentX = currentXRef.current;
165
+ const distance = Math.abs(target - currentX);
166
+ setPacingDirection(target > currentX ? "right" : "left");
167
+
168
+ // 抛物线踱步:x 线性补间,y 同时做 bounce
169
+ const hopDuration = Math.min(0.9, 0.35 + distance / 400);
170
+ await bounceControls.start({
171
+ x: target,
172
+ y: [0, -12 * f, 0],
173
+ transition: {
174
+ x: { duration: hopDuration, ease: "easeInOut" },
175
+ y: { duration: hopDuration, ease: "easeOut", times: [0, 0.5, 1] },
176
+ },
177
+ } as Parameters<typeof bounceControls.start>[0]);
178
+ currentXRef.current = target;
179
+
180
+ // Clear direction after landing
181
+ const t1 = setTimeout(() => setPacingDirection("idle"), 300);
182
+
183
+ // Pick and play random mood
184
+ const choices = ACTIVE_MOODS.filter((m) => m !== lastPlayedRef.current);
185
+ const m = (choices[Math.floor(Math.random() * choices.length)] ?? "blink") as Exclude<AvatarMood, "idle">;
186
+ lastPlayedRef.current = m;
187
+ setMood(m);
188
+ forceTick((t) => t + 1);
189
+
190
+ // Schedule next jump after mood finishes
191
+ const t2 = setTimeout(() => {
192
+ if (pacingRef.current) void jump();
193
+ }, HOLD_MS[m] + 800 + Math.random() * 400);
194
+
195
+ cycleRef.current.push(t1, t2);
196
+ };
197
+
198
+ void jump();
199
+
200
+ return () => {
201
+ for (const id of cycleRef.current) clearTimeout(id);
202
+ cycleRef.current = [];
203
+ };
204
+ }, [pacing, cfg.wrapperPx, f]); // eslint-disable-line react-hooks/exhaustive-deps
205
+
206
+ // Reset position when pacing is disabled
207
+ useEffect(() => {
208
+ if (!pacing) {
209
+ currentXRef.current = 0;
210
+ bounceControls.set({ x: 0, y: 0 });
211
+ setPacingDirection("idle");
212
+ }
213
+ }, [pacing]); // eslint-disable-line react-hooks/exhaustive-deps
214
+
215
+ const handleClick = useCallback(() => {
216
+ if (onClick) {
217
+ onClick();
218
+ return;
219
+ }
220
+ triggerMood(pickRandomMood());
221
+ }, [onClick, triggerMood, pickRandomMood]);
222
+
223
+ const dirRotate = pacingDirection === "right" ? 8 : pacingDirection === "left" ? -8 : 0;
224
+ const headAnim = (() => {
225
+ switch (mood) {
226
+ case "left":
227
+ return { rotate: -10 + dirRotate, scale: 1, y: 0, scaleX: 1, scaleY: 1 };
228
+ case "right":
229
+ return { rotate: 10 + dirRotate, scale: 1, y: 0, scaleX: 1, scaleY: 1 };
230
+ case "think":
231
+ return {
232
+ rotate: dirRotate !== 0 ? dirRotate : [0, 5, -5, 0],
233
+ y: [0, -1.5 * f, 0, -1 * f, 0],
234
+ scaleX: 1,
235
+ scaleY: 1,
236
+ };
237
+ case "blink":
238
+ return { rotate: dirRotate, scale: [1, 0.96, 1], y: 0 };
239
+ case "bounce":
240
+ return {
241
+ rotate: dirRotate,
242
+ y: [0, -8 * f, 0, -2 * f, 0],
243
+ scaleX: [1, 0.92, 1.28, 0.96, 1],
244
+ scaleY: [1, 1.18, 0.72, 1.08, 1],
245
+ };
246
+ case "sleep":
247
+ return {
248
+ rotate: -6 + dirRotate,
249
+ y: [0, -0.5 * f, 0, -0.5 * f, 0],
250
+ scaleX: 1,
251
+ scaleY: 1,
252
+ };
253
+ default:
254
+ return { rotate: dirRotate, scale: 1, y: 0, scaleX: 1, scaleY: 1 };
255
+ }
256
+ })();
257
+
258
+ const eyesShift = mood === "left" ? -1.4 * f : mood === "right" ? 1.4 * f : 0;
259
+ const eyesScaleY =
260
+ mood === "blink"
261
+ ? [1, 0.1, 1]
262
+ : mood === "sleep"
263
+ ? [1, 0.1, 0.1, 0.1, 1]
264
+ : 1;
265
+ const showThoughtBubble = mood === "think";
266
+ const showSleepZ = mood === "sleep";
267
+
268
+ const button = (
269
+ <button
270
+ type="button"
271
+ onClick={handleClick}
272
+ title={title}
273
+ className={`no-drag relative flex shrink-0 items-center justify-center focus:outline-none ${cfg.wrapper} ${className}`}
274
+ >
275
+ {active && (
276
+ <motion.span
277
+ aria-hidden
278
+ className={`absolute ${cfg.glowInset} rounded-[20px] bg-primary/30 ${cfg.glowBlur}`}
279
+ animate={{ opacity: [0.35, 0.65, 0.35], scale: [0.95, 1.05, 0.95] }}
280
+ transition={{ duration: 1.6, repeat: Infinity, ease: "easeInOut" }}
281
+ />
282
+ )}
283
+ <motion.div
284
+ className={`relative flex items-center justify-center ${cfg.body} bg-gradient-to-br from-primary to-primary/85 text-primary-foreground ${cfg.shadow}`}
285
+ animate={headAnim}
286
+ transition={{
287
+ type:
288
+ mood === "think" || mood === "blink" || mood === "bounce" || mood === "sleep"
289
+ ? "tween"
290
+ : "spring",
291
+ stiffness: 280,
292
+ damping: 16,
293
+ duration:
294
+ mood === "bounce"
295
+ ? 0.7
296
+ : mood === "sleep"
297
+ ? 1.4
298
+ : mood === "think"
299
+ ? 0.8
300
+ : mood === "blink"
301
+ ? 0.32
302
+ : undefined,
303
+ ease: mood === "bounce" ? "easeOut" : "easeInOut",
304
+ times: mood === "bounce" ? [0, 0.28, 0.55, 0.8, 1] : undefined,
305
+ }}
306
+ style={{ transformOrigin: mood === "bounce" ? "50% 100%" : "50% 50%" }}
307
+ >
308
+ <div className={`flex items-center ${cfg.gap}`}>
309
+ {/* Multi-keyframe scaleY (blink/sleep) must use tween — spring only allows 2 keyframes.
310
+ 默认白眼;黑白主题深色经 .bot-avatar-eye 覆盖为灰。 */}
311
+ <motion.span
312
+ className={`bot-avatar-eye block rounded-full bg-white ${cfg.eye}`}
313
+ animate={{ x: eyesShift, scaleY: eyesScaleY }}
314
+ transition={{
315
+ type: mood === "blink" || mood === "sleep" ? "tween" : "spring",
316
+ stiffness: 380,
317
+ damping: 22,
318
+ duration:
319
+ mood === "blink" ? 0.3 : mood === "sleep" ? 1.4 : undefined,
320
+ ease: "easeInOut",
321
+ }}
322
+ />
323
+ <motion.span
324
+ className={`bot-avatar-eye block rounded-full bg-white ${cfg.eye}`}
325
+ animate={{ x: eyesShift, scaleY: eyesScaleY }}
326
+ transition={{
327
+ type: mood === "blink" || mood === "sleep" ? "tween" : "spring",
328
+ stiffness: 380,
329
+ damping: 22,
330
+ duration:
331
+ mood === "blink" ? 0.3 : mood === "sleep" ? 1.4 : undefined,
332
+ ease: "easeInOut",
333
+ }}
334
+ />
335
+ </div>
336
+ </motion.div>
337
+ <AnimatePresence>
338
+ {showThoughtBubble && (
339
+ <motion.span
340
+ aria-hidden
341
+ className={`pointer-events-none absolute rounded-full bg-primary/70 ${cfg.bubble}`}
342
+ initial={{ opacity: 0, scale: 0.4, y: 0 }}
343
+ animate={{
344
+ opacity: [0, 1, 0],
345
+ scale: [0.4, 1, 0.7],
346
+ y: [-1 * f, -5 * f, -8 * f],
347
+ }}
348
+ exit={{ opacity: 0 }}
349
+ transition={{ duration: 0.9, ease: "easeOut" }}
350
+ />
351
+ )}
352
+ {showSleepZ && (
353
+ <motion.span
354
+ key="sleep-z"
355
+ aria-hidden
356
+ className="pointer-events-none absolute select-none font-bold leading-none text-primary/75"
357
+ style={{
358
+ right: -2 * f,
359
+ top: -2 * f,
360
+ fontSize: size === "lg" ? 13 : size === "md" ? 10 : 7,
361
+ }}
362
+ initial={{ opacity: 0, scale: 0.4, y: 0 }}
363
+ animate={{
364
+ opacity: [0, 1, 1, 0],
365
+ scale: [0.4, 1, 1.05, 0.8],
366
+ y: [0, -3 * f, -7 * f, -11 * f],
367
+ x: [0, 1 * f, -1 * f, 1 * f],
368
+ }}
369
+ exit={{ opacity: 0 }}
370
+ transition={{
371
+ duration: 1.4,
372
+ ease: "easeOut",
373
+ repeat: Infinity,
374
+ repeatDelay: 0.1,
375
+ }}
376
+ >
377
+ z
378
+ </motion.span>
379
+ )}
380
+ </AnimatePresence>
381
+ </button>
382
+ );
383
+
384
+ if (!pacing) return button;
385
+
386
+ return (
387
+ <motion.div
388
+ ref={containerRefCallback}
389
+ className="relative flex items-center"
390
+ animate={bounceControls}
391
+ >
392
+ {button}
393
+ </motion.div>
394
+ );
395
+ });
@@ -0,0 +1,48 @@
1
+ import type { JSX, MouseEvent, PointerEvent, ReactNode } from "react";
2
+
3
+ export interface CodeBlockCopyButtonLabels {
4
+ copy: string;
5
+ copied: string;
6
+ }
7
+
8
+ export interface CodeBlockCopyButtonViewProps {
9
+ children: ReactNode;
10
+ copied: boolean;
11
+ onCopy: () => void;
12
+ labels: CodeBlockCopyButtonLabels;
13
+ }
14
+
15
+ /** Props-driven copy chrome around a code block. Host owns clipboard state. */
16
+ export function CodeBlockCopyButtonView({
17
+ children,
18
+ copied,
19
+ onCopy,
20
+ labels,
21
+ }: CodeBlockCopyButtonViewProps): JSX.Element {
22
+ function stopMessageDrag(event: MouseEvent<HTMLButtonElement> | PointerEvent<HTMLButtonElement>): void {
23
+ event.preventDefault();
24
+ event.stopPropagation();
25
+ }
26
+
27
+ function handleCopy(event: MouseEvent<HTMLButtonElement>): void {
28
+ stopMessageDrag(event);
29
+ onCopy();
30
+ }
31
+
32
+ return (
33
+ <div className="group/code-block relative">
34
+ <button
35
+ type="button"
36
+ onPointerDown={stopMessageDrag}
37
+ onMouseDown={stopMessageDrag}
38
+ onClick={handleCopy}
39
+ aria-label={copied ? labels.copied : labels.copy}
40
+ title={copied ? labels.copied : labels.copy}
41
+ className="absolute right-2 top-2 z-20 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-[#30363d] bg-[#161b22]/95 text-[#c9d1d9] opacity-0 shadow-sm transition-opacity hover:bg-[#21262d] hover:text-white focus-visible:opacity-100 group-hover/code-block:opacity-100"
42
+ >
43
+ <span className={copied ? "icon-[mdi--check] h-4 w-4" : "icon-[solar--copy-linear] h-4 w-4"} />
44
+ </button>
45
+ {children}
46
+ </div>
47
+ );
48
+ }
@@ -0,0 +1,125 @@
1
+ import { useEffect, useRef, useState, type JSX, type ReactNode } from "react";
2
+
3
+ /**
4
+ * 折叠面板:CSS `grid-template-rows: 0fr → 1fr` 过渡,取代 framer-motion 的
5
+ * `height: 0 → auto`。
6
+ *
7
+ * 为什么换:motion 的 height:auto 是 JS 驱动的——每帧回到主线程写一次内联
8
+ * height,再触发一次强制样式重算。消息列表跑在 Virtuoso 上,外层
9
+ * ResizeObserver 会把这每一帧的尺寸变化都变成一次列表重测量,同时滚动跟随的
10
+ * rAF 也在读布局。低配机上三者叠在同一帧里,展开就明显掉帧。CSS 过渡走浏览器
11
+ * 自己的动画时间线,不占主线程 JS,也不经过 React 协调。
12
+ *
13
+ * 内容仍然按需挂载(没打开过就不在树里):工具卡片里有 markdown 与 shiki 高亮,
14
+ * 常驻挂载会把折叠的代价提前付掉。
15
+ *
16
+ * 收起分两步,见下面 `settled` 的说明——卸载一整棵工具卡片子树是一次很长的同步
17
+ * 提交,压在动画收尾那一帧上就是肉眼可见的一顿。
18
+ */
19
+
20
+ const DURATION_MS = 200;
21
+ /** 空闲期迟迟不来时的兜底:最多拖这么久也要把子树卸掉,别让 DOM 一直挂着。 */
22
+ const IDLE_UNMOUNT_TIMEOUT_MS = 2000;
23
+
24
+ type IdleHandle = { kind: "idle"; id: number } | { kind: "timeout"; id: number };
25
+
26
+ function scheduleIdle(callback: () => void): IdleHandle {
27
+ if (typeof window.requestIdleCallback === "function") {
28
+ return { kind: "idle", id: window.requestIdleCallback(callback, { timeout: IDLE_UNMOUNT_TIMEOUT_MS }) };
29
+ }
30
+ return { kind: "timeout", id: window.setTimeout(callback, IDLE_UNMOUNT_TIMEOUT_MS) };
31
+ }
32
+
33
+ function cancelIdle(handle: IdleHandle): void {
34
+ if (handle.kind === "idle") window.cancelIdleCallback(handle.id);
35
+ else window.clearTimeout(handle.id);
36
+ }
37
+
38
+ export interface CollapsePanelProps {
39
+ open: boolean;
40
+ children: ReactNode;
41
+ /** 面板容器 id(导出流程按 id 找面板)。 */
42
+ id?: string;
43
+ /** 导出流程的标记属性;`undefined` 时不落到 DOM 上。 */
44
+ exportPanel?: boolean;
45
+ /** 导出态下折叠的面板保留在 DOM 里但 `hidden`。 */
46
+ hidden?: boolean;
47
+ /** 内层内容容器的额外类名。 */
48
+ contentClassName?: string;
49
+ }
50
+
51
+ export function CollapsePanel({
52
+ open,
53
+ children,
54
+ id,
55
+ exportPanel = false,
56
+ hidden = false,
57
+ contentClassName,
58
+ }: CollapsePanelProps): JSX.Element | null {
59
+ // 首帧就是 open(导出态、forceExpanded)时直接落到展开态,不播入场动画,
60
+ // 与原来的 `<AnimatePresence initial={false}>` 行为一致。
61
+ const [mounted, setMounted] = useState(open);
62
+ const [expanded, setExpanded] = useState(open);
63
+ /**
64
+ * 折叠动画跑完 → 先 `display:none`。此时布局已经定稿(0fr 本来就是 0 高),
65
+ * 但子树不再参与布局与绘制;真正的 React 卸载挪到空闲期。
66
+ * 这样「收回」的最后一帧只剩一次样式变更,而不是一次上千节点的同步卸载。
67
+ */
68
+ const [settled, setSettled] = useState(!open);
69
+ const firstRunRef = useRef(true);
70
+ const idleHandleRef = useRef<IdleHandle | null>(null);
71
+
72
+ useEffect(() => {
73
+ const cancelPendingUnmount = (): void => {
74
+ if (!idleHandleRef.current) return;
75
+ cancelIdle(idleHandleRef.current);
76
+ idleHandleRef.current = null;
77
+ };
78
+
79
+ // 首帧的 state 就是目标状态,既不播动画也不排任何定时器——否则每个「初始收起」
80
+ // 的面板都会在挂载时白排一个 200ms timer,工作模式一条消息几十行就是几十个。
81
+ if (firstRunRef.current) {
82
+ firstRunRef.current = false;
83
+ return;
84
+ }
85
+
86
+ if (open) {
87
+ cancelPendingUnmount();
88
+ setMounted(true);
89
+ setSettled(false);
90
+ // 先以 0fr 挂载,下一帧再切 1fr,否则没有可过渡的起始值。
91
+ const frame = requestAnimationFrame(() => setExpanded(true));
92
+ return () => cancelAnimationFrame(frame);
93
+ }
94
+
95
+ setExpanded(false);
96
+ const timer = window.setTimeout(() => {
97
+ setSettled(true);
98
+ idleHandleRef.current = scheduleIdle(() => {
99
+ idleHandleRef.current = null;
100
+ setMounted(false);
101
+ });
102
+ }, DURATION_MS);
103
+ return () => {
104
+ window.clearTimeout(timer);
105
+ cancelPendingUnmount();
106
+ };
107
+ }, [open]);
108
+
109
+ if (!mounted) return null;
110
+
111
+ return (
112
+ <div
113
+ id={id}
114
+ data-export-collapse-panel={exportPanel ? "" : undefined}
115
+ hidden={hidden}
116
+ // `[&[hidden]]:hidden`:`grid` 是作者样式,会盖过 UA 的 `[hidden]{display:none}`,
117
+ // 所以导出态的 hidden 属性必须自己配一条规则。规则挂在属性上,导出脚本摘掉属性即可展开。
118
+ className={`${settled ? "hidden" : "grid"} [&[hidden]]:hidden transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)] motion-reduce:transition-none ${
119
+ expanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
120
+ }`}
121
+ >
122
+ <div className={`min-w-0 overflow-hidden ${contentClassName ?? ""}`}>{children}</div>
123
+ </div>
124
+ );
125
+ }
@@ -0,0 +1,134 @@
1
+ import {
2
+ cn,
3
+ DropdownMenu,
4
+ DropdownMenuContent,
5
+ DropdownMenuItem,
6
+ DropdownMenuSeparator,
7
+ DropdownMenuSub,
8
+ DropdownMenuSubContent,
9
+ DropdownMenuSubTrigger,
10
+ DropdownMenuTrigger,
11
+ } from "@vetta-org/ui";
12
+ import type { JSX } from "react";
13
+
14
+ /**
15
+ * 通用右键菜单节点树。支持任意层级嵌套(submenu 里还能再放 submenu),
16
+ * 交给 radix 承担对角线移动、边界翻转、键盘导航——手写菜单做不全这些。
17
+ */
18
+ export type ContextMenuNode =
19
+ | {
20
+ kind: "item";
21
+ id: string;
22
+ label: string;
23
+ /** iconify class,例如 `icon-[solar--pin-linear]` */
24
+ iconClassName?: string;
25
+ /** 左侧圆点颜色,用于标签这类以颜色为身份的菜单项 */
26
+ dotColor?: string;
27
+ /** 右侧勾选态 */
28
+ checked?: boolean;
29
+ danger?: boolean;
30
+ disabled?: boolean;
31
+ onSelect: () => void;
32
+ }
33
+ | {
34
+ kind: "submenu";
35
+ id: string;
36
+ label: string;
37
+ iconClassName?: string;
38
+ items: readonly ContextMenuNode[];
39
+ }
40
+ | { kind: "separator"; id: string };
41
+
42
+ export interface ContextMenuViewProps {
43
+ items: readonly ContextMenuNode[];
44
+ onClose: () => void;
45
+ /** 光标位置(视口坐标) */
46
+ x: number;
47
+ y: number;
48
+ className?: string;
49
+ }
50
+
51
+ const LABEL_CLASS = "flex-1 truncate text-[12px] font-medium";
52
+
53
+ function NodeIcon({
54
+ iconClassName,
55
+ dotColor,
56
+ }: {
57
+ iconClassName?: string;
58
+ dotColor?: string;
59
+ }): JSX.Element | null {
60
+ if (dotColor) {
61
+ return (
62
+ <span
63
+ aria-hidden="true"
64
+ data-context-menu-dot="true"
65
+ className="h-2.5 w-2.5 shrink-0 rounded-full"
66
+ style={{ backgroundColor: dotColor }}
67
+ />
68
+ );
69
+ }
70
+ if (iconClassName) return <span aria-hidden="true" className={cn(iconClassName, "h-3.5 w-3.5 shrink-0")} />;
71
+ return null;
72
+ }
73
+
74
+ function renderNodes(nodes: readonly ContextMenuNode[]): JSX.Element[] {
75
+ return nodes.map((node) => {
76
+ if (node.kind === "separator") return <DropdownMenuSeparator key={node.id} />;
77
+ if (node.kind === "submenu") {
78
+ return (
79
+ <DropdownMenuSub key={node.id}>
80
+ <DropdownMenuSubTrigger className="px-2 py-[5px]">
81
+ <NodeIcon iconClassName={node.iconClassName} />
82
+ <span className={LABEL_CLASS}>{node.label}</span>
83
+ </DropdownMenuSubTrigger>
84
+ <DropdownMenuSubContent className="max-h-[60vh] w-[180px] overflow-y-auto">
85
+ {renderNodes(node.items)}
86
+ </DropdownMenuSubContent>
87
+ </DropdownMenuSub>
88
+ );
89
+ }
90
+ return (
91
+ <DropdownMenuItem
92
+ key={node.id}
93
+ disabled={node.disabled}
94
+ onSelect={node.onSelect}
95
+ className={cn("px-2 py-[5px]", node.danger && "text-destructive")}
96
+ >
97
+ <NodeIcon iconClassName={node.iconClassName} dotColor={node.dotColor} />
98
+ <span className={LABEL_CLASS}>{node.label}</span>
99
+ {node.checked ? (
100
+ <span aria-hidden="true" className="icon-[solar--check-read-linear] h-3.5 w-3.5 shrink-0 text-primary" />
101
+ ) : null}
102
+ </DropdownMenuItem>
103
+ );
104
+ });
105
+ }
106
+
107
+ /**
108
+ * 以 `{x,y}` 处一个 0×0 的虚拟锚点驱动 radix 菜单,
109
+ * 从而保留调用方现有的「全局单例菜单 + 坐标」模型(见 sessionContextMenuAtom)。
110
+ */
111
+ export function ContextMenuView({ items, onClose, x, y, className }: ContextMenuViewProps): JSX.Element {
112
+ return (
113
+ <DropdownMenu
114
+ open
115
+ modal={false}
116
+ onOpenChange={(open) => {
117
+ if (!open) onClose();
118
+ }}
119
+ >
120
+ <DropdownMenuTrigger asChild>
121
+ <span aria-hidden="true" className="fixed h-0 w-0" style={{ left: `${x}px`, top: `${y}px` }} />
122
+ </DropdownMenuTrigger>
123
+ <DropdownMenuContent
124
+ align="start"
125
+ side="bottom"
126
+ sideOffset={0}
127
+ className={cn("w-[170px]", className)}
128
+ onCloseAutoFocus={(event) => event.preventDefault()}
129
+ >
130
+ {renderNodes(items)}
131
+ </DropdownMenuContent>
132
+ </DropdownMenu>
133
+ );
134
+ }