@vetta-org/theme-ui 0.1.1 → 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 +733 -5
- 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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import type { HastElement, HastRoot, HastText } from "./nodes";
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_RATE_PER_MS,
|
|
5
|
+
planReveal,
|
|
6
|
+
REVEAL_TICK_MS,
|
|
7
|
+
STREAMING_IDLE_SETTLE_MS,
|
|
8
|
+
STREAMING_SETTLE_MS,
|
|
9
|
+
STREAMING_STALL_FLUSH_MS,
|
|
10
|
+
splitStreamingSegments,
|
|
11
|
+
} from "./streaming-reveal";
|
|
12
|
+
|
|
13
|
+
const WHITESPACE_ONLY = /^\s+$/;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 把流式尾块的正文按短语包成 `.streaming-chunk`,最新的两个短语再加 `-latest` / `-recent`:
|
|
17
|
+
* 宿主 CSS 让它们略暗,下一次放出短语时随重渲染一起变亮。不用 CSS 淡入动画——每个短语各跑一段
|
|
18
|
+
* 动画意味着流式全程连续出帧,毛玻璃窗口每帧都要整窗重合成;这样亮度只随放出节奏变,不多一帧。
|
|
19
|
+
*/
|
|
20
|
+
export function rehypeStreamingChunks() {
|
|
21
|
+
return (tree: HastRoot): void => {
|
|
22
|
+
const chunks: HastElement[] = [];
|
|
23
|
+
function visit(node: HastRoot | HastElement, inCode: boolean): void {
|
|
24
|
+
const newChildren: Array<(typeof node.children)[number]> = [];
|
|
25
|
+
for (const child of node.children) {
|
|
26
|
+
if (child.type === "text" && !inCode) {
|
|
27
|
+
for (const segment of splitStreamingSegments((child as HastText).value)) {
|
|
28
|
+
if (WHITESPACE_ONLY.test(segment)) {
|
|
29
|
+
newChildren.push({ type: "text", value: segment } as HastText);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const chunk: HastElement = {
|
|
33
|
+
type: "element",
|
|
34
|
+
tagName: "span",
|
|
35
|
+
properties: { className: ["streaming-chunk"] },
|
|
36
|
+
children: [{ type: "text", value: segment } as HastText],
|
|
37
|
+
};
|
|
38
|
+
chunks.push(chunk);
|
|
39
|
+
newChildren.push(chunk);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
newChildren.push(child);
|
|
43
|
+
if (child.type === "element") {
|
|
44
|
+
const tag = child.tagName;
|
|
45
|
+
// 表格也当字面量:单元格文字被拆成片段再逐步增长会反复触发列宽重算,
|
|
46
|
+
// 流式期表格会抖动。
|
|
47
|
+
visit(child, inCode || tag === "code" || tag === "pre" || tag === "table" || tag === "vetta-svg");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
node.children = newChildren as typeof node.children;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
visit(tree, false);
|
|
55
|
+
const latest = chunks.at(-1);
|
|
56
|
+
const recent = chunks.at(-2);
|
|
57
|
+
if (latest) latest.properties = { className: ["streaming-chunk", "streaming-chunk-latest"] };
|
|
58
|
+
if (recent) recent.properties = { className: ["streaming-chunk", "streaming-chunk-recent"] };
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface StreamingDisplayState {
|
|
63
|
+
displayText: string;
|
|
64
|
+
animateChunks: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function clearTimeoutRef(ref: { current: number | null }): void {
|
|
68
|
+
if (ref.current !== null) {
|
|
69
|
+
window.clearTimeout(ref.current);
|
|
70
|
+
ref.current = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** 到达速率的采样窗口:只看最近这么久。 */
|
|
75
|
+
const RATE_WINDOW_MS = 1500;
|
|
76
|
+
|
|
77
|
+
interface ArrivalSample {
|
|
78
|
+
readonly at: number;
|
|
79
|
+
readonly length: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** 最近窗口内的到达速率(字符/毫秒);样本不够时用默认值。 */
|
|
83
|
+
function estimateRate(samples: readonly ArrivalSample[], now: number): number {
|
|
84
|
+
const first = samples.find((sample) => now - sample.at <= RATE_WINDOW_MS) ?? samples[0];
|
|
85
|
+
const last = samples.at(-1);
|
|
86
|
+
if (!first || !last || last.at - first.at < 50 || last.length <= first.length) return DEFAULT_RATE_PER_MS;
|
|
87
|
+
return (last.length - first.length) / (last.at - first.at);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 流式尾块:把显示文本匀速追向宿主文本(节奏见 streaming-reveal),配合 rehype 分段做「最新短语略暗」。
|
|
92
|
+
* 放出由 `text` 变化(宿主每 100ms 一次的增量刷新)驱动,在布局效果里同步更新,与那次渲染落在同一帧;
|
|
93
|
+
* 没有新文本时由兜底 tick 收尾。尾部未写完的词、未闭合的行内语法先扣着;流结束后按节奏放完再撤掉分段。
|
|
94
|
+
*
|
|
95
|
+
* 从未作为尾块流式过的实例(历史消息、产品故事等由宿主自己驱动逐字的场景)直接镜像 `text`。
|
|
96
|
+
*/
|
|
97
|
+
export function useStreamingDisplayText(text: string, active: boolean): StreamingDisplayState {
|
|
98
|
+
const [displayText, setDisplayText] = useState(() => (active ? "" : text));
|
|
99
|
+
const [animateChunks, setAnimateChunks] = useState(active);
|
|
100
|
+
const displayRef = useRef(active ? "" : text);
|
|
101
|
+
const targetRef = useRef(text);
|
|
102
|
+
const activeRef = useRef(active);
|
|
103
|
+
const streamedRef = useRef(active);
|
|
104
|
+
const samplesRef = useRef<ArrivalSample[]>([]);
|
|
105
|
+
/** 显示文本上次实际推进的时间:扣留、等词写完期间预算按它累计,闭合后能一次放出整段。 */
|
|
106
|
+
const lastAdvanceAtRef = useRef(0);
|
|
107
|
+
const lastArrivalAtRef = useRef(0);
|
|
108
|
+
/** 扣留开始的时间;null 表示当前没有扣留。 */
|
|
109
|
+
const heldSinceRef = useRef<number | null>(null);
|
|
110
|
+
const tickTimerRef = useRef<number | null>(null);
|
|
111
|
+
const settleTimerRef = useRef<number | null>(null);
|
|
112
|
+
|
|
113
|
+
const settle = useCallback((): void => {
|
|
114
|
+
if (settleTimerRef.current !== null) return;
|
|
115
|
+
settleTimerRef.current = window.setTimeout(() => {
|
|
116
|
+
settleTimerRef.current = null;
|
|
117
|
+
streamedRef.current = false;
|
|
118
|
+
setAnimateChunks(false);
|
|
119
|
+
}, STREAMING_SETTLE_MS);
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
/** 已追平但流未结束:静默一会儿后只撤暗色,保留 streamedRef,新文本到达时布局效果会重新挂上。 */
|
|
123
|
+
const settleIdle = useCallback((): void => {
|
|
124
|
+
if (settleTimerRef.current !== null) return;
|
|
125
|
+
settleTimerRef.current = window.setTimeout(() => {
|
|
126
|
+
settleTimerRef.current = null;
|
|
127
|
+
setAnimateChunks(false);
|
|
128
|
+
}, STREAMING_IDLE_SETTLE_MS);
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
const reveal = useCallback(
|
|
132
|
+
function reveal(): void {
|
|
133
|
+
clearTimeoutRef(tickTimerRef);
|
|
134
|
+
const now = Date.now();
|
|
135
|
+
const target = targetRef.current;
|
|
136
|
+
const shown = displayRef.current.length;
|
|
137
|
+
const final = !activeRef.current;
|
|
138
|
+
const stalled = !final && now - lastArrivalAtRef.current >= STREAMING_STALL_FLUSH_MS;
|
|
139
|
+
const step = planReveal({
|
|
140
|
+
text: target,
|
|
141
|
+
revealed: shown,
|
|
142
|
+
final,
|
|
143
|
+
ratePerMs: estimateRate(samplesRef.current, now),
|
|
144
|
+
elapsedMs: lastAdvanceAtRef.current ? now - lastAdvanceAtRef.current : REVEAL_TICK_MS,
|
|
145
|
+
stalled,
|
|
146
|
+
heldMs: heldSinceRef.current === null ? 0 : now - heldSinceRef.current,
|
|
147
|
+
});
|
|
148
|
+
if (step?.held) heldSinceRef.current ??= now;
|
|
149
|
+
else heldSinceRef.current = null;
|
|
150
|
+
if (step && step.end > shown) {
|
|
151
|
+
const next = target.slice(0, step.end);
|
|
152
|
+
displayRef.current = next;
|
|
153
|
+
setDisplayText(next);
|
|
154
|
+
lastAdvanceAtRef.current = now;
|
|
155
|
+
}
|
|
156
|
+
if (displayRef.current.length >= target.length) lastAdvanceAtRef.current = now;
|
|
157
|
+
if (displayRef.current.length < target.length) {
|
|
158
|
+
tickTimerRef.current = window.setTimeout(reveal, REVEAL_TICK_MS);
|
|
159
|
+
} else if (final) {
|
|
160
|
+
settle();
|
|
161
|
+
} else {
|
|
162
|
+
settleIdle();
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
[settle, settleIdle],
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
useEffect(
|
|
169
|
+
() => () => {
|
|
170
|
+
clearTimeoutRef(tickTimerRef);
|
|
171
|
+
clearTimeoutRef(settleTimerRef);
|
|
172
|
+
},
|
|
173
|
+
[],
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// 用布局效果:放出后的 setState 会在浏览器绘制前同步重渲染,与宿主那次增量刷新落在同一帧。
|
|
177
|
+
useLayoutEffect(() => {
|
|
178
|
+
const textChanged = targetRef.current !== text;
|
|
179
|
+
targetRef.current = text;
|
|
180
|
+
activeRef.current = active;
|
|
181
|
+
if (active) streamedRef.current = true;
|
|
182
|
+
|
|
183
|
+
const shown = displayRef.current;
|
|
184
|
+
if (!streamedRef.current || !text.startsWith(shown)) {
|
|
185
|
+
// 从未流式过,或宿主改写了已显示内容(不是追加):直接对齐,不做节奏。
|
|
186
|
+
clearTimeoutRef(tickTimerRef);
|
|
187
|
+
clearTimeoutRef(settleTimerRef);
|
|
188
|
+
samplesRef.current = [];
|
|
189
|
+
heldSinceRef.current = null;
|
|
190
|
+
displayRef.current = text;
|
|
191
|
+
setDisplayText(text);
|
|
192
|
+
setAnimateChunks(false);
|
|
193
|
+
streamedRef.current = active;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
clearTimeoutRef(settleTimerRef);
|
|
198
|
+
// 只在有新内容要放时挂暗色:空闲撤暗后回合才结束(文本没变)时不能再暗一下。
|
|
199
|
+
if (textChanged || shown.length < text.length) setAnimateChunks(true);
|
|
200
|
+
const now = Date.now();
|
|
201
|
+
if (textChanged || lastArrivalAtRef.current === 0) {
|
|
202
|
+
lastArrivalAtRef.current = now;
|
|
203
|
+
const samples = samplesRef.current.filter((sample) => now - sample.at <= RATE_WINDOW_MS);
|
|
204
|
+
samples.push({ at: now, length: text.length });
|
|
205
|
+
samplesRef.current = samples;
|
|
206
|
+
}
|
|
207
|
+
reveal();
|
|
208
|
+
}, [text, active, reveal]);
|
|
209
|
+
|
|
210
|
+
return { displayText, animateChunks };
|
|
211
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/** Trailing throttle: continuous arrivals cannot postpone rendering indefinitely. */
|
|
4
|
+
export function useRenderSnapshot(source: string, active: boolean, live: boolean, interval = 250): string {
|
|
5
|
+
const [snapshot, setSnapshot] = useState(source);
|
|
6
|
+
const latest = useRef(source);
|
|
7
|
+
latest.current = source;
|
|
8
|
+
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!active || !live) {
|
|
11
|
+
clearTimeout(timer.current);
|
|
12
|
+
timer.current = undefined;
|
|
13
|
+
if (active) setSnapshot(source);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (snapshot === source || timer.current !== undefined) return;
|
|
17
|
+
timer.current = setTimeout(() => {
|
|
18
|
+
timer.current = undefined;
|
|
19
|
+
setSnapshot(latest.current);
|
|
20
|
+
}, interval);
|
|
21
|
+
}, [source, snapshot, active, live, interval]);
|
|
22
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
23
|
+
return active && !live ? source : snapshot;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/** A single visibility signal gates parsing, worker jobs and preview lifetimes. */
|
|
4
|
+
export function useRichVisibility<T extends HTMLElement = HTMLSpanElement>() {
|
|
5
|
+
const ref = useRef<T>(null);
|
|
6
|
+
const [intersecting, setIntersecting] = useState(false);
|
|
7
|
+
const [visible, setVisible] = useState(() => typeof document === "undefined" || !document.hidden);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const update = () => setVisible(!document.hidden);
|
|
10
|
+
document.addEventListener("visibilitychange", update);
|
|
11
|
+
const element = ref.current;
|
|
12
|
+
const observer =
|
|
13
|
+
typeof IntersectionObserver === "function"
|
|
14
|
+
? new IntersectionObserver((entries) => setIntersecting(entries.some((entry) => entry.isIntersecting)))
|
|
15
|
+
: null;
|
|
16
|
+
if (element && observer) observer.observe(element);
|
|
17
|
+
else setIntersecting(true);
|
|
18
|
+
return () => {
|
|
19
|
+
observer?.disconnect();
|
|
20
|
+
document.removeEventListener("visibilitychange", update);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
return { ref, active: intersecting && visible };
|
|
24
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { motion } from "motion/react";
|
|
2
|
-
import type
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { memo, type JSX } from "react";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
|
+
import { ConversationTagDotsView } from "../project/ConversationTagDotsView";
|
|
4
5
|
import type { CommandMenuHighlightRange, CommandMenuItemView } from "./command-menu-types";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -41,15 +42,20 @@ export interface CommandMenuRowProps {
|
|
|
41
42
|
readonly suppressSelectionAnimation: boolean;
|
|
42
43
|
readonly onActivate: (id: string) => void;
|
|
43
44
|
readonly onHover: (id: string) => void;
|
|
45
|
+
/** 给了就在悬停 / 选中时于行尾显示「更多」按钮,给不爱用键盘的人。 */
|
|
46
|
+
readonly onMore?: (id: string) => void;
|
|
47
|
+
readonly moreLabel?: string;
|
|
44
48
|
readonly registerRef: (id: string, element: HTMLButtonElement | null) => void;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
export function CommandMenuRow({
|
|
51
|
+
export const CommandMenuRow = memo(function CommandMenuRow({
|
|
48
52
|
item,
|
|
49
53
|
active,
|
|
50
54
|
suppressSelectionAnimation,
|
|
51
55
|
onActivate,
|
|
52
56
|
onHover,
|
|
57
|
+
onMore,
|
|
58
|
+
moreLabel,
|
|
53
59
|
registerRef,
|
|
54
60
|
}: CommandMenuRowProps): JSX.Element {
|
|
55
61
|
const disabled = Boolean(item.disabled);
|
|
@@ -70,7 +76,7 @@ export function CommandMenuRow({
|
|
|
70
76
|
if (!disabled) onActivate(item.id);
|
|
71
77
|
}}
|
|
72
78
|
className={cn(
|
|
73
|
-
"relative flex h-9 w-full items-center gap-2.5 rounded-lg px-2.5 text-left outline-none transition-colors",
|
|
79
|
+
"group relative flex h-9 w-full items-center gap-2.5 rounded-lg px-2.5 text-left outline-none transition-colors",
|
|
74
80
|
disabled ? "cursor-not-allowed opacity-45" : "cursor-pointer",
|
|
75
81
|
)}
|
|
76
82
|
style={{
|
|
@@ -91,10 +97,15 @@ export function CommandMenuRow({
|
|
|
91
97
|
className="absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-primary"
|
|
92
98
|
/>
|
|
93
99
|
)}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
{item.tagColors && item.tagColors.length > 0 ? (
|
|
101
|
+
// 与侧栏会话一致:标签色点占据行首图标的位置,多个标签就画多个。
|
|
102
|
+
<ConversationTagDotsView colors={item.tagColors} className="size-4" />
|
|
103
|
+
) : (
|
|
104
|
+
<span
|
|
105
|
+
aria-hidden="true"
|
|
106
|
+
className={cn(item.icon, "size-4 shrink-0", active ? "text-foreground" : "text-muted-foreground")}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
98
109
|
<span className="flex min-w-0 flex-1 items-baseline gap-2">
|
|
99
110
|
{/*
|
|
100
111
|
* 标题不参与收缩(shrink-0),只受 max-w 约束:标题和副标题都可收缩时,
|
|
@@ -114,6 +125,24 @@ export function CommandMenuRow({
|
|
|
114
125
|
{item.badge}
|
|
115
126
|
</span>
|
|
116
127
|
)}
|
|
128
|
+
{onMore && (
|
|
129
|
+
<span
|
|
130
|
+
role="button"
|
|
131
|
+
tabIndex={-1}
|
|
132
|
+
aria-label={moreLabel}
|
|
133
|
+
title={moreLabel}
|
|
134
|
+
onClick={(event) => {
|
|
135
|
+
event.stopPropagation();
|
|
136
|
+
onMore(item.id);
|
|
137
|
+
}}
|
|
138
|
+
className={cn(
|
|
139
|
+
"-mr-1 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-accent hover:text-foreground",
|
|
140
|
+
active ? "opacity-100" : "opacity-0 group-hover:opacity-100",
|
|
141
|
+
)}
|
|
142
|
+
>
|
|
143
|
+
<span aria-hidden="true" className="icon-[solar--menu-dots-bold] size-4" />
|
|
144
|
+
</span>
|
|
145
|
+
)}
|
|
117
146
|
</button>
|
|
118
147
|
);
|
|
119
|
-
}
|
|
148
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { AnimatePresence, motion } from "motion/react";
|
|
2
1
|
import { useCallback, useEffect, useRef, type JSX, type RefObject } from "react";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
4
|
-
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
5
2
|
import { CommandMenuRow } from "./CommandMenuRow";
|
|
6
3
|
import type { CommandMenuGroupView, CommandMenuViewLabels } from "./command-menu-types";
|
|
4
|
+
import { SplashFooter, SplashInputHeader } from "./SplashParts";
|
|
5
|
+
import { SplashPanel } from "./SplashPanel";
|
|
7
6
|
import "./command-menu.css";
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -41,7 +40,6 @@ export function CommandMenuView({
|
|
|
41
40
|
onActivateItem,
|
|
42
41
|
onClose,
|
|
43
42
|
}: CommandMenuViewProps): JSX.Element {
|
|
44
|
-
const overlayRef = useRef<HTMLDivElement | null>(null);
|
|
45
43
|
const rowRefs = useRef(new Map<string, HTMLButtonElement>());
|
|
46
44
|
|
|
47
45
|
const registerRef = useCallback((id: string, element: HTMLButtonElement | null) => {
|
|
@@ -60,124 +58,86 @@ export function CommandMenuView({
|
|
|
60
58
|
const anyLoading = groups.some((group) => group.loading);
|
|
61
59
|
|
|
62
60
|
return (
|
|
63
|
-
<
|
|
64
|
-
{open
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
<SplashPanel
|
|
62
|
+
open={open}
|
|
63
|
+
onClose={onClose}
|
|
64
|
+
label={labels.title}
|
|
65
|
+
header={
|
|
66
|
+
<SplashInputHeader
|
|
67
|
+
icon="icon-[solar--magnifer-linear]"
|
|
68
|
+
inputRef={inputRef}
|
|
69
|
+
label={labels.title}
|
|
70
|
+
value={query}
|
|
71
|
+
placeholder={labels.placeholder}
|
|
72
|
+
onChange={onQueryChange}
|
|
73
|
+
// 打开后的聚焦由宿主在 open 变化时负责(见 desktop CommandMenu)。
|
|
74
|
+
autoFocus={false}
|
|
75
|
+
inputProps={{
|
|
76
|
+
role: "combobox",
|
|
77
|
+
"aria-expanded": hasResults,
|
|
78
|
+
"aria-controls": "command-menu-list",
|
|
79
|
+
"aria-activedescendant": selectedId ? `command-menu-item-${selectedId}` : undefined,
|
|
76
80
|
}}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
className="command-menu-input-underline pointer-events-none absolute inset-x-3.5 bottom-0 h-px bg-border/70"
|
|
113
|
-
/>
|
|
114
|
-
</div>
|
|
115
|
-
|
|
81
|
+
/>
|
|
82
|
+
}
|
|
83
|
+
footer={
|
|
84
|
+
<SplashFooter>
|
|
85
|
+
<span>{labels.hintNavigate}</span>
|
|
86
|
+
<span>{labels.hintSelect}</span>
|
|
87
|
+
<span className="ml-auto">{labels.hintClose}</span>
|
|
88
|
+
</SplashFooter>
|
|
89
|
+
}
|
|
90
|
+
>
|
|
91
|
+
<div
|
|
92
|
+
id="command-menu-list"
|
|
93
|
+
role="listbox"
|
|
94
|
+
aria-label={labels.title}
|
|
95
|
+
className="min-h-0 max-h-[min(420px,56vh)] overflow-y-auto overscroll-contain px-1.5 py-1.5"
|
|
96
|
+
>
|
|
97
|
+
{groups.map((group) => {
|
|
98
|
+
if (group.items.length === 0 && !group.loading) return null;
|
|
99
|
+
return (
|
|
100
|
+
<div key={group.key} role="group" aria-label={group.label} className="mb-1 last:mb-0">
|
|
101
|
+
<div className="px-2 pb-1 pt-1.5 text-[11px] font-medium text-muted-foreground/70">
|
|
102
|
+
{group.label}
|
|
103
|
+
</div>
|
|
104
|
+
{group.items.map((item) => (
|
|
105
|
+
<CommandMenuRow
|
|
106
|
+
key={item.id}
|
|
107
|
+
item={item}
|
|
108
|
+
active={item.id === selectedId}
|
|
109
|
+
suppressSelectionAnimation={suppressSelectionAnimation}
|
|
110
|
+
onActivate={onActivateItem}
|
|
111
|
+
onHover={onHoverItem}
|
|
112
|
+
registerRef={registerRef}
|
|
113
|
+
/>
|
|
114
|
+
))}
|
|
115
|
+
{group.loading && (
|
|
116
116
|
<div
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
aria-label={labels.title}
|
|
120
|
-
className="min-h-0 max-h-[min(420px,56vh)] overflow-y-auto overscroll-contain px-1.5 py-1.5"
|
|
117
|
+
aria-label={labels.loading}
|
|
118
|
+
className="flex h-9 items-center gap-2.5 px-2.5"
|
|
121
119
|
>
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<div key={group.key} role="group" aria-label={group.label} className="mb-1 last:mb-0">
|
|
126
|
-
<div className="px-2 pb-1 pt-1.5 text-[11px] font-medium text-muted-foreground/70">
|
|
127
|
-
{group.label}
|
|
128
|
-
</div>
|
|
129
|
-
{group.items.map((item) => (
|
|
130
|
-
<CommandMenuRow
|
|
131
|
-
key={item.id}
|
|
132
|
-
item={item}
|
|
133
|
-
active={item.id === selectedId}
|
|
134
|
-
suppressSelectionAnimation={suppressSelectionAnimation}
|
|
135
|
-
onActivate={onActivateItem}
|
|
136
|
-
onHover={onHoverItem}
|
|
137
|
-
registerRef={registerRef}
|
|
138
|
-
/>
|
|
139
|
-
))}
|
|
140
|
-
{group.loading && (
|
|
141
|
-
<div
|
|
142
|
-
aria-label={labels.loading}
|
|
143
|
-
className="flex h-9 items-center gap-2.5 px-2.5"
|
|
144
|
-
>
|
|
145
|
-
{/* 固定高度骨架:异步结果到达时不产生高度跳变。 */}
|
|
146
|
-
<span className="size-4 shrink-0 animate-pulse rounded bg-muted" />
|
|
147
|
-
<span className="h-3 w-40 animate-pulse rounded bg-muted" />
|
|
148
|
-
</div>
|
|
149
|
-
)}
|
|
150
|
-
{group.overflowLabel && (
|
|
151
|
-
<div className="px-2.5 pb-1 pt-0.5 text-[11px] text-muted-foreground/60">
|
|
152
|
-
{group.overflowLabel}
|
|
153
|
-
</div>
|
|
154
|
-
)}
|
|
155
|
-
</div>
|
|
156
|
-
);
|
|
157
|
-
})}
|
|
158
|
-
|
|
159
|
-
{!hasResults && !anyLoading && (
|
|
160
|
-
<div className="flex flex-col items-center gap-1 px-3 py-10 text-center">
|
|
161
|
-
<span className="text-[13px] text-foreground">{labels.empty}</span>
|
|
162
|
-
<span className="text-[11px] text-muted-foreground">{labels.emptyHint}</span>
|
|
163
|
-
</div>
|
|
164
|
-
)}
|
|
120
|
+
{/* 固定高度骨架:异步结果到达时不产生高度跳变。 */}
|
|
121
|
+
<span className="size-4 shrink-0 animate-pulse rounded bg-muted" />
|
|
122
|
+
<span className="h-3 w-40 animate-pulse rounded bg-muted" />
|
|
165
123
|
</div>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
"text-[11px] text-muted-foreground/80",
|
|
171
|
-
)}
|
|
172
|
-
>
|
|
173
|
-
<span>{labels.hintNavigate}</span>
|
|
174
|
-
<span>{labels.hintSelect}</span>
|
|
175
|
-
<span className="ml-auto">{labels.hintClose}</span>
|
|
124
|
+
)}
|
|
125
|
+
{group.overflowLabel && (
|
|
126
|
+
<div className="px-2.5 pb-1 pt-0.5 text-[11px] text-muted-foreground/60">
|
|
127
|
+
{group.overflowLabel}
|
|
176
128
|
</div>
|
|
177
|
-
|
|
178
|
-
</
|
|
179
|
-
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
})}
|
|
133
|
+
|
|
134
|
+
{!hasResults && !anyLoading && (
|
|
135
|
+
<div className="flex flex-col items-center gap-1 px-3 py-10 text-center">
|
|
136
|
+
<span className="text-[13px] text-foreground">{labels.empty}</span>
|
|
137
|
+
<span className="text-[11px] text-muted-foreground">{labels.emptyHint}</span>
|
|
138
|
+
</div>
|
|
180
139
|
)}
|
|
181
|
-
|
|
140
|
+
</div>
|
|
141
|
+
</SplashPanel>
|
|
182
142
|
);
|
|
183
143
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AnimatePresence, motion } from "motion/react";
|
|
2
2
|
import type { JSX, RefObject } from "react";
|
|
3
3
|
import { ThemeSurface } from "../appearance/ThemeSurface";
|
|
4
|
+
import { cn, OVERLAY_BACKDROP_CLASS, PANEL_SHADOW_CLASS } from "@vetta-org/ui/utils";
|
|
4
5
|
|
|
5
6
|
export interface ConfirmDialogViewState {
|
|
6
7
|
readonly cancelLabel?: string;
|
|
@@ -28,8 +29,9 @@ export interface ConfirmDialogViewProps {
|
|
|
28
29
|
readonly state: ConfirmDialogViewState | null;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
// 与全局 Dialog 的按钮同尺寸;取消用透明底,确认用主色 / 危险色。
|
|
31
33
|
const buttonBase =
|
|
32
|
-
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-
|
|
34
|
+
"group/button inline-flex h-9 shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding px-4 text-[13px] font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50";
|
|
33
35
|
|
|
34
36
|
export function ConfirmDialogView({
|
|
35
37
|
labels,
|
|
@@ -51,7 +53,7 @@ export function ConfirmDialogView({
|
|
|
51
53
|
// pointer-events-auto: Vaul/Radix modal Drawer 会把 body 设为
|
|
52
54
|
// pointer-events: none;本层 portaled 到 body,不显式恢复则点击穿透,
|
|
53
55
|
// 首次点按钮只会关掉下层 sheet,需再点一次才命中 dialog。
|
|
54
|
-
className="pointer-events-auto fixed inset-0 z-[100] flex items-center justify-center
|
|
56
|
+
className={cn("pointer-events-auto fixed inset-0 z-[100] flex items-center justify-center", OVERLAY_BACKDROP_CLASS)}
|
|
55
57
|
onClick={(e) => {
|
|
56
58
|
if (e.target === overlayRef.current) onCancel();
|
|
57
59
|
}}
|
|
@@ -61,26 +63,29 @@ export function ConfirmDialogView({
|
|
|
61
63
|
animate={{ opacity: 1, scale: 1 }}
|
|
62
64
|
exit={{ opacity: 0, scale: 0.95 }}
|
|
63
65
|
transition={{ duration: 0.15, ease: [0.25, 0.1, 0.25, 1] }}
|
|
64
|
-
|
|
66
|
+
// 与全局 Dialog 同一套:无外边框、柔和投影、通栏底栏。overflow-hidden 让底栏跟随圆角。
|
|
67
|
+
className={cn("relative w-[min(400px,calc(100vw-32px))] overflow-hidden rounded-2xl bg-popover", PANEL_SHADOW_CLASS)}
|
|
65
68
|
>
|
|
66
69
|
<ThemeSurface slot="root.confirmDialog.panel" />
|
|
67
|
-
<div className="relative z-10
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
<div className="relative z-10">
|
|
71
|
+
<div className="p-6">
|
|
72
|
+
<h3 className="text-[17px] leading-snug font-semibold tracking-tight text-foreground">{state.title}</h3>
|
|
73
|
+
<p className="mt-2 max-h-[45vh] overflow-auto text-[13px] leading-relaxed break-words whitespace-pre-wrap text-muted-foreground">
|
|
74
|
+
{state.message}
|
|
75
|
+
</p>
|
|
76
|
+
{state.checkbox && (
|
|
77
|
+
<label className="mt-4 flex cursor-pointer items-center gap-2 text-[12px] text-muted-foreground">
|
|
78
|
+
<input
|
|
79
|
+
type="checkbox"
|
|
80
|
+
checked={state.checkbox.checked}
|
|
81
|
+
onChange={(event) => onCheckboxCheckedChange(event.currentTarget.checked)}
|
|
82
|
+
className="h-3.5 w-3.5 accent-primary"
|
|
83
|
+
/>
|
|
84
|
+
<span>{state.checkbox.label}</span>
|
|
85
|
+
</label>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
<div className="flex justify-end gap-2 border-t border-border/50 bg-muted/40 px-6 py-4">
|
|
84
89
|
<button
|
|
85
90
|
type="button"
|
|
86
91
|
onClick={onCancel}
|