@vetta-org/theme-ui 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +740 -20
- package/src/action-approval/AppearanceActionPickerView.tsx +2 -78
- package/src/action-approval/AppearanceApprovalDrawerView.tsx +2 -9
- package/src/action-approval/BatchTasksApprovalFrameView.tsx +4 -1
- package/src/action-approval/GenericActionApprovalView.tsx +2 -9
- package/src/action-approval/ManageActionApprovalFrameView.tsx +4 -1
- package/src/action-approval/NavigationOpenApprovalView.tsx +2 -9
- package/src/action-approval/SchedulerActionApprovalDialogView.tsx +3 -1
- package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +3 -10
- package/src/action-approval/index.ts +0 -1
- package/src/activity/ActivityPanel.tsx +13 -10
- package/src/activity/ActivityPanelFrame.test.tsx +32 -0
- package/src/activity/ActivityPanelFrame.tsx +3 -2
- package/src/activity/BackgroundTasksTabPanelView.tsx +1 -1
- package/src/activity/BrowserPanelView.tsx +48 -49
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +135 -62
- package/src/activity/PluginTabPickerView.tsx +5 -3
- package/src/activity/PortsTabPanelView.tsx +911 -0
- package/src/activity/ToolCallsSubTabView.tsx +1 -1
- package/src/activity/WorkflowTabPanelView.tsx +1 -1
- package/src/activity/index.ts +9 -0
- package/src/app/AppBackground.tsx +1 -1
- package/src/app/AppBootLoadingView.tsx +4 -2
- package/src/app-shell/DefaultWindowControls.tsx +1 -1
- package/src/app-shell/PageHeaderActionGroup.tsx +1 -1
- package/src/app-shell/PageHeaderContent.tsx +36 -7
- package/src/app-shell/PageHeaderFrame.tsx +15 -3
- package/src/app-shell/PageHeaderSidebarTrigger.tsx +1 -1
- package/src/app-shell/PageHeaderTitle.tsx +1 -1
- package/src/app-shell/WindowControlButton.tsx +1 -1
- package/src/app-shell/header-crowding.test.ts +62 -0
- package/src/app-shell/header-crowding.tsx +137 -0
- package/src/appearance/BackgroundImageFrame.tsx +1 -1
- package/src/appearance/CenterSliceImageFrame.tsx +1 -1
- package/src/appearance/CornerImageFrame.tsx +1 -1
- package/src/appearance/HorizontalSliceImageFrame.tsx +1 -1
- package/src/appearance/NineSliceImageFrame.tsx +1 -1
- package/src/appearance/ThemeSurface.tsx +1 -1
- package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +2 -1
- package/src/batch-tasks/BatchTaskProjectActionsView.test.tsx +97 -0
- package/src/batch-tasks/BatchTaskProjectActionsView.tsx +45 -35
- package/src/batch-tasks/batchTaskUi.tsx +0 -29
- package/src/bottom-panel/BottomPanelView.test.tsx +43 -0
- package/src/bottom-panel/BottomPanelView.tsx +222 -0
- package/src/bottom-panel/index.ts +26 -0
- package/src/chat/AgentAvatarView.tsx +1 -1
- package/src/chat/AnnotationViews.tsx +107 -0
- package/src/chat/AskUserQuestionView.tsx +18 -11
- package/src/chat/AssistantMessageView.tsx +48 -13
- package/src/chat/AtPanelView.test.tsx +61 -0
- package/src/chat/AtPanelView.tsx +63 -38
- package/src/chat/BashTerminalCard.tsx +1 -2
- package/src/chat/ChatHeaderActionsView.tsx +74 -18
- package/src/chat/CompactionStepView.test.tsx +34 -0
- package/src/chat/CompactionStepView.tsx +85 -0
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +806 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +128 -0
- package/src/chat/InlineModelPicker.test.tsx +81 -0
- package/src/chat/InlineModelPicker.tsx +201 -0
- package/src/chat/InlineTokenChip.tsx +2 -68
- package/src/chat/InputBarBackground.tsx +1 -1
- package/src/chat/InputBarPlaceholder.tsx +26 -3
- package/src/chat/LiveThinkingView.tsx +51 -37
- package/src/chat/MessageBoundaryViews.tsx +21 -0
- package/src/chat/MessageFeedContext.tsx +13 -5
- package/src/chat/MessageFeedLayoutView.tsx +29 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +6 -2
- package/src/chat/MessageLayoutView.tsx +1 -1
- package/src/chat/MessageSelectionContextMenuView.tsx +4 -1
- package/src/chat/MessageTimelineView.tsx +1 -1
- package/src/chat/MessageView.tsx +1 -1
- package/src/chat/MessageVisualView.tsx +1 -1
- package/src/chat/ModelConfiguration.tsx +283 -0
- package/src/chat/ModelSelectorTrigger.tsx +63 -0
- package/src/chat/ModelSelectorView.tsx +1037 -223
- package/src/chat/NewSession.ts +1 -37
- package/src/chat/NewSessionPicker.tsx +3 -2
- package/src/chat/ProjectSelectorView.tsx +3 -2
- package/src/chat/ReasoningStepSlider.tsx +61 -0
- package/src/chat/RemoteSessionBadgeView.tsx +24 -0
- package/src/chat/SkillPromptAreaView.tsx +5 -19
- package/src/chat/TeamMemberReplyCardView.test.tsx +33 -0
- package/src/chat/TeamMemberReplyCardView.tsx +133 -0
- package/src/chat/TextBlockView.tsx +7 -770
- package/src/chat/TodoProgress.tsx +25 -53
- package/src/chat/TodoStatusBarView.tsx +14 -5
- package/src/chat/UserMessageView.tsx +113 -33
- package/src/chat/header-action-narrow.test.ts +21 -0
- package/src/chat/header-action-narrow.ts +38 -0
- package/src/chat/index.ts +33 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/chat/send-button.css +4 -22
- package/src/chat/streaming-reveal.test.ts +218 -0
- package/src/chat/streaming-reveal.ts +13 -0
- package/src/file-explorer/ConfirmDeleteDialogView.tsx +2 -1
- package/src/file-explorer/FileContextMenuView.tsx +44 -11
- package/src/file-explorer/FileExplorerSettingsView.tsx +97 -0
- package/src/file-explorer/FileTreeCreateRow.tsx +1 -1
- package/src/file-explorer/FileTreeNodeView.tsx +59 -18
- package/src/file-explorer/FileTreeView.tsx +236 -129
- package/src/file-explorer/file-tree-dom.ts +23 -0
- package/src/file-explorer/file-tree-rows.test.ts +74 -0
- package/src/file-explorer/file-tree-rows.ts +168 -0
- package/src/file-explorer/index.ts +17 -0
- package/src/file-explorer/types.ts +3 -0
- package/src/file-explorer/useFileTreeMarqueeSelection.ts +24 -16
- package/src/file-preview/FilePreviewDialogView.tsx +2 -2
- package/src/file-preview/FilePreviewView.tsx +12 -2
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/index.ts +1 -0
- package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +1 -1
- package/src/layout/AppFrame.tsx +3 -2
- package/src/layout/MainContentFrame.tsx +7 -2
- package/src/layout/ResizeHandle.tsx +68 -17
- package/src/layout/SidebarDock.tsx +75 -19
- package/src/layout/SidebarOverlay.tsx +1 -1
- package/src/layout/index.ts +1 -1
- package/src/layout/resize-handle-axis.test.ts +51 -0
- package/src/live-indicators.test.ts +43 -0
- package/src/markdown/CodeBlock.tsx +123 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +418 -0
- package/src/markdown/MarkdownImage.tsx +41 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +82 -0
- package/src/markdown/RichCodeBlock.tsx +127 -0
- package/src/markdown/SvgPreview.tsx +45 -0
- package/src/markdown/WebsiteIcon.tsx +94 -0
- package/src/markdown/builtin-renderers.tsx +43 -0
- package/src/markdown/definition.tsx +49 -0
- package/src/markdown/host.tsx +18 -0
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +12 -0
- package/src/markdown/inline-tokens.ts +187 -0
- package/src/markdown/markdown-link.ts +279 -0
- package/src/markdown/math-client.ts +116 -0
- package/src/markdown/math-render.ts +23 -0
- package/src/markdown/math-syntax.ts +80 -0
- package/src/markdown/math.worker.ts +16 -0
- package/src/markdown/nodes.ts +15 -0
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +76 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +55 -0
- package/src/markdown/rich-syntax.ts +93 -0
- package/src/markdown/stable-blocks.test.ts +90 -0
- package/src/markdown/stable-blocks.ts +124 -0
- package/src/markdown/streaming-reveal.ts +297 -0
- package/src/markdown/streaming.test.ts +57 -0
- package/src/markdown/streaming.ts +211 -0
- package/src/markdown/use-render-snapshot.ts +24 -0
- package/src/markdown/use-rich-visibility.ts +24 -0
- package/src/overlays/CommandMenuRow.tsx +77 -17
- package/src/overlays/CommandMenuView.tsx +163 -118
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +55 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +217 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +203 -53
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +26 -1
- package/src/plugin-ui/index.ts +10 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +15 -24
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +114 -55
- package/src/project/ManageSessionsSplashView.tsx +439 -0
- package/src/project/NewProjectDialogView.tsx +3 -10
- package/src/project/ProjectContextMenuView.tsx +30 -139
- package/src/project/ProjectDetailPageView.test.tsx +140 -0
- package/src/project/ProjectDetailPageView.tsx +372 -165
- package/src/project/ProjectGroupView.tsx +1 -1
- package/src/project/ProjectRowView.tsx +29 -12
- package/src/project/ProjectSessionsView.tsx +25 -47
- package/src/project/QuickScrollOverlay.tsx +1 -1
- package/src/project/SessionContextMenuView.tsx +15 -7
- package/src/project/SessionRowMoreButton.tsx +50 -0
- package/src/project/SessionRowView.tsx +106 -63
- package/src/project/SessionTitleMarquee.tsx +54 -0
- package/src/project/SidebarProjectDisclosure.tsx +60 -0
- package/src/project/SidebarProjectsSectionView.tsx +6 -1
- package/src/project/index.ts +12 -0
- package/src/project/session-row-transition.ts +9 -0
- package/src/project/types.ts +4 -2
- package/src/project/useActiveSessionAutoScroll.ts +10 -4
- package/src/registry.ts +0 -2
- package/src/scheduler/AutomationDetailPaneView.tsx +68 -0
- package/src/scheduler/AutomationPageView.tsx +118 -121
- package/src/scheduler/ExecutionHistoryView.tsx +7 -5
- package/src/scheduler/TaskListView.tsx +52 -201
- package/src/scheduler/index.ts +7 -12
- package/src/settings/AppshotSettingsView.tsx +0 -1
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/BuiltinMcpSectionView.tsx +1 -1
- package/src/settings/EnvironmentGitRowView.tsx +156 -0
- package/src/settings/EnvironmentSettingsView.tsx +25 -3
- package/src/settings/GeneralSettingsView.tsx +18 -24
- package/src/settings/ImChannelGuideDialogView.tsx +2 -2
- package/src/settings/ImFeishuDialogView.tsx +1 -1
- package/src/settings/ImLegacyImportBannerView.tsx +1 -1
- package/src/settings/ImLogDrawerView.tsx +2 -1
- package/src/settings/JsonConfigInputView.tsx +171 -0
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +273 -0
- package/src/settings/ModelsFetchedModelsDrawerView.tsx +292 -0
- package/src/settings/ModelsProvidersSectionView.tsx +26 -23
- package/src/settings/MotionSelect.tsx +9 -7
- package/src/settings/NotificationSettingsView.tsx +79 -0
- package/src/settings/PermissionsSettingsView.tsx +3 -7
- package/src/settings/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +147 -185
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- package/src/settings/RemoteMcpSectionView.tsx +1 -1
- package/src/settings/SettingChrome.tsx +2 -2
- package/src/settings/SettingsAiAssistButtonView.tsx +9 -119
- package/src/settings/SettingsFormFields.tsx +4 -7
- package/src/settings/SettingsSidebarView.tsx +64 -3
- package/src/settings/ShortcutRecorderView.test.tsx +108 -0
- package/src/settings/ShortcutRecorderView.tsx +15 -9
- package/src/settings/ShortcutsSettingsView.tsx +1 -5
- package/src/settings/SpaceEditorDialogView.tsx +158 -0
- package/src/settings/SpacesSettingsView.tsx +150 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +59 -68
- package/src/shared/ActivityStatusDot.tsx +69 -0
- package/src/shared/AvatarStackView.tsx +13 -13
- package/src/shared/BotAvatar.tsx +11 -9
- package/src/shared/CodeBlockCopyButton.tsx +1 -1
- package/src/shared/ContextMenuView.tsx +4 -11
- package/src/shared/MarkdownTable.tsx +2 -2
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +10 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +23 -18
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +100 -0
- package/src/shared/connected-tab-outline.test.ts +2 -2
- package/src/shared/connected-tab-outline.ts +2 -1
- package/src/shared/index.ts +7 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/platform.ts +9 -0
- package/src/shared/provider-icon/icons.ts +4 -2
- package/src/shared/provider-icon/index.tsx +1 -1
- package/src/shared/provider-icon/magpie.svg +1 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +33 -24
- package/src/sidebar/DefaultSidebar.tsx +3 -1
- package/src/sidebar/MessageCenterDialogView.tsx +3 -2
- package/src/sidebar/MessageCenterEmptyState.tsx +1 -1
- package/src/sidebar/MessageCenterTabs.tsx +1 -1
- package/src/sidebar/MessageCenterToolbarButton.tsx +1 -1
- package/src/sidebar/MessageCenterTriggerView.tsx +2 -2
- package/src/sidebar/ProjectsPanelEmptyState.tsx +26 -7
- package/src/sidebar/SessionStatusIcon.tsx +16 -1
- package/src/sidebar/SettingsMenuThemeSection.tsx +1 -1
- package/src/sidebar/SettingsMenuTriggerView.test.tsx +42 -0
- package/src/sidebar/SettingsMenuTriggerView.tsx +29 -50
- package/src/sidebar/ShowMoreSessionsButton.tsx +1 -1
- package/src/sidebar/SidebarFilterSelectView.tsx +8 -16
- package/src/sidebar/SidebarNavBadgeView.tsx +1 -1
- package/src/sidebar/SidebarNavIcon.tsx +1 -1
- package/src/sidebar/SidebarNavItemButton.tsx +1 -1
- package/src/sidebar/SidebarNavMorePanel.tsx +19 -7
- package/src/sidebar/SidebarNavigation.tsx +24 -15
- package/src/sidebar/SidebarPanel.tsx +11 -2
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/sidebar/SidebarSectionTriggerLabel.tsx +20 -0
- package/src/sidebar/SidebarTopBar.tsx +10 -7
- package/src/sidebar/WaitingPulseBadge.tsx +19 -0
- package/src/sidebar/index.ts +1 -16
- package/src/skills/index.ts +0 -19
- package/src/skills/skill-icon.tsx +4 -8
- package/src/styles.css +26 -6
- package/src/chat/DefaultSceneCarousel.tsx +0 -113
- package/src/chat/SceneCard.tsx +0 -138
- package/src/scheduler/HistoryDrawerView.tsx +0 -149
- package/src/scheduler/TaskFormDialogView.tsx +0 -60
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -44
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -66
- package/src/settings/SubscriptionActionsView.tsx +0 -63
- package/src/settings/SubscriptionCardsView.tsx +0 -212
- package/src/settings/TeamDetailView.tsx +0 -148
- package/src/settings/TeamDialogsView.tsx +0 -151
- package/src/settings/TeamListView.tsx +0 -57
- package/src/settings/TeamSettingsView.tsx +0 -51
- package/src/settings/TokenActivityChartView.tsx +0 -286
- package/src/settings/UsageStatsView.tsx +0 -101
- package/src/settings/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
- package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +0 -135
- package/src/settings/shouldCloseEmptyApiKeyEditor.ts +0 -40
- package/src/settings/token-activity.test.ts +0 -195
- package/src/settings/token-activity.ts +0 -320
- package/src/sidebar/AddProjectMenuItem.tsx +0 -21
- package/src/sidebar/AddProjectMenuPopoverView.tsx +0 -52
- package/src/sidebar/NotificationMessageListView.tsx +0 -136
- package/src/sidebar/SettingsMenuAccountSection.tsx +0 -32
- package/src/sidebar/SettingsMenuQuotaSection.tsx +0 -45
- package/src/skills/SceneCardView.tsx +0 -194
- package/src/skills/SkillCardView.tsx +0 -186
- package/src/skills/SkillDetailDialogView.tsx +0 -138
- package/src/skills/SkillTagGroupView.tsx +0 -56
- package/src/skills/SkillToggleSwitch.tsx +0 -31
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { useState, type JSX } from "react";
|
|
2
|
-
import { Button } from "@vetta-org/ui";
|
|
3
|
-
import { SettingSection, type SettingSectionMeta } from "./SettingChrome";
|
|
4
|
-
|
|
5
|
-
export interface TeamMemberView {
|
|
6
|
-
readonly id: number | string;
|
|
7
|
-
readonly user_id: number;
|
|
8
|
-
readonly username: string;
|
|
9
|
-
readonly avatar?: string | null;
|
|
10
|
-
readonly role: "owner" | "admin" | "member" | string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface TeamDetailViewData {
|
|
14
|
-
readonly name: string;
|
|
15
|
-
readonly invite_code: string;
|
|
16
|
-
readonly members: readonly TeamMemberView[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface TeamDetailViewLabels {
|
|
20
|
-
readonly backToList: string;
|
|
21
|
-
readonly codeLabel: string;
|
|
22
|
-
readonly resetCode: string;
|
|
23
|
-
readonly members: string;
|
|
24
|
-
readonly memberCount: (count: number) => string;
|
|
25
|
-
readonly ownerRole: string;
|
|
26
|
-
readonly adminRole: string;
|
|
27
|
-
readonly memberRole: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface TeamDetailViewProps {
|
|
31
|
-
readonly detail: TeamDetailViewData;
|
|
32
|
-
readonly labels: TeamDetailViewLabels;
|
|
33
|
-
readonly infoSection: SettingSectionMeta;
|
|
34
|
-
readonly membersSection: SettingSectionMeta;
|
|
35
|
-
readonly onBack: () => void;
|
|
36
|
-
readonly onResetCode: () => void;
|
|
37
|
-
readonly onRemoveMember: (userId: number) => void;
|
|
38
|
-
readonly onLeave: () => void;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function memberRoleLabel(role: string, labels: TeamDetailViewLabels): string {
|
|
42
|
-
if (role === "owner") return labels.ownerRole;
|
|
43
|
-
if (role === "admin") return labels.adminRole;
|
|
44
|
-
return labels.memberRole;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function TeamDetailView({
|
|
48
|
-
detail,
|
|
49
|
-
labels,
|
|
50
|
-
infoSection,
|
|
51
|
-
membersSection,
|
|
52
|
-
onBack,
|
|
53
|
-
onResetCode,
|
|
54
|
-
onRemoveMember,
|
|
55
|
-
onLeave,
|
|
56
|
-
}: TeamDetailViewProps): JSX.Element {
|
|
57
|
-
const [copied, setCopied] = useState(false);
|
|
58
|
-
|
|
59
|
-
const handleCopyInviteCode = async () => {
|
|
60
|
-
await navigator.clipboard.writeText(detail.invite_code);
|
|
61
|
-
setCopied(true);
|
|
62
|
-
setTimeout(() => setCopied(false), 2000);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div className="space-y-4">
|
|
67
|
-
<button
|
|
68
|
-
type="button"
|
|
69
|
-
onClick={onBack}
|
|
70
|
-
className="flex items-center gap-1 text-[12px] text-muted-foreground transition-colors hover:text-foreground"
|
|
71
|
-
>
|
|
72
|
-
<span className="icon-[mdi--arrow-left] h-3.5 w-3.5" />
|
|
73
|
-
{labels.backToList}
|
|
74
|
-
</button>
|
|
75
|
-
|
|
76
|
-
<SettingSection section={infoSection} title={detail.name}>
|
|
77
|
-
<div className="flex items-center justify-between border-b border-border px-5 py-3.5">
|
|
78
|
-
<div>
|
|
79
|
-
<div className="text-[13px] font-medium text-foreground">{labels.codeLabel}</div>
|
|
80
|
-
<div className="mt-0.5 font-mono text-[11px] text-muted-foreground">{detail.invite_code}</div>
|
|
81
|
-
</div>
|
|
82
|
-
<div className="flex gap-1.5">
|
|
83
|
-
<Button variant="ghost" size="xs" onClick={() => void handleCopyInviteCode()}>
|
|
84
|
-
{copied ? (
|
|
85
|
-
<span className="icon-[mdi--check] h-3.5 w-3.5 text-emerald-400" />
|
|
86
|
-
) : (
|
|
87
|
-
<span className="icon-[mdi--content-copy] h-3.5 w-3.5" />
|
|
88
|
-
)}
|
|
89
|
-
</Button>
|
|
90
|
-
<Button variant="ghost" size="xs" onClick={onResetCode} title={labels.resetCode}>
|
|
91
|
-
<span className="icon-[mdi--refresh] h-3.5 w-3.5" />
|
|
92
|
-
</Button>
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
|
|
96
|
-
<div className="flex items-center justify-between px-5 py-3.5">
|
|
97
|
-
<div className="text-[13px] font-medium text-foreground">{labels.members}</div>
|
|
98
|
-
<div className="text-[12px] text-muted-foreground">
|
|
99
|
-
{labels.memberCount(detail.members.length)}
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
</SettingSection>
|
|
103
|
-
|
|
104
|
-
<SettingSection section={membersSection}>
|
|
105
|
-
{detail.members.map((member, i) => (
|
|
106
|
-
<div
|
|
107
|
-
key={member.id}
|
|
108
|
-
className={`flex items-center justify-between px-5 py-3 ${
|
|
109
|
-
i < detail.members.length - 1 ? "border-b border-border" : ""
|
|
110
|
-
}`}
|
|
111
|
-
>
|
|
112
|
-
<div className="flex items-center gap-3">
|
|
113
|
-
{member.avatar ? (
|
|
114
|
-
<img src={member.avatar} alt="" className="h-7 w-7 rounded-full" />
|
|
115
|
-
) : (
|
|
116
|
-
<div className="flex h-7 w-7 items-center justify-center rounded-full bg-accent text-[11px] font-medium text-muted-foreground">
|
|
117
|
-
{member.username[0]}
|
|
118
|
-
</div>
|
|
119
|
-
)}
|
|
120
|
-
<div>
|
|
121
|
-
<span className="text-[13px] text-foreground">{member.username}</span>
|
|
122
|
-
<span className="ml-2 text-[11px] text-muted-foreground">
|
|
123
|
-
{memberRoleLabel(member.role, labels)}
|
|
124
|
-
</span>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
{member.role !== "owner" && (
|
|
128
|
-
<Button
|
|
129
|
-
variant="ghost"
|
|
130
|
-
size="xs"
|
|
131
|
-
className="text-muted-foreground hover:text-destructive"
|
|
132
|
-
onClick={() => onRemoveMember(member.user_id)}
|
|
133
|
-
>
|
|
134
|
-
<span className="icon-[mdi--close] h-3.5 w-3.5" />
|
|
135
|
-
</Button>
|
|
136
|
-
)}
|
|
137
|
-
</div>
|
|
138
|
-
))}
|
|
139
|
-
</SettingSection>
|
|
140
|
-
|
|
141
|
-
{detail.members.some((member) => member.role !== "owner") && (
|
|
142
|
-
<div className="flex justify-end">
|
|
143
|
-
<Button variant="outline" size="sm" className="text-destructive" onClick={onLeave} />
|
|
144
|
-
</div>
|
|
145
|
-
)}
|
|
146
|
-
</div>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { useState, type JSX } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
Dialog,
|
|
5
|
-
DialogContent,
|
|
6
|
-
DialogFooter,
|
|
7
|
-
DialogHeader,
|
|
8
|
-
DialogTitle,
|
|
9
|
-
cn,
|
|
10
|
-
} from "@vetta-org/ui";
|
|
11
|
-
|
|
12
|
-
const inputClassName =
|
|
13
|
-
"h-8 w-full min-w-0 rounded-lg border border-border/60 bg-transparent px-2.5 py-1 text-base shadow-none transition-[border-color,background-color] outline-none placeholder:text-muted-foreground hover:border-border focus-visible:border-ring/60 md:text-sm dark:bg-input/20";
|
|
14
|
-
|
|
15
|
-
export interface TeamDialogLabelsView {
|
|
16
|
-
readonly createTitle: string;
|
|
17
|
-
readonly createPlaceholder: string;
|
|
18
|
-
readonly createFailed: string;
|
|
19
|
-
readonly creating: string;
|
|
20
|
-
readonly createButton: string;
|
|
21
|
-
readonly joinTitle: string;
|
|
22
|
-
readonly joinPlaceholder: string;
|
|
23
|
-
readonly joinFailed: string;
|
|
24
|
-
readonly joining: string;
|
|
25
|
-
readonly joinButton: string;
|
|
26
|
-
readonly cancel: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface CreateTeamDialogViewProps {
|
|
30
|
-
readonly open: boolean;
|
|
31
|
-
readonly labels: TeamDialogLabelsView;
|
|
32
|
-
readonly onOpenChange: (open: boolean) => void;
|
|
33
|
-
readonly onCreate: (name: string) => Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function CreateTeamDialogView({
|
|
37
|
-
open,
|
|
38
|
-
labels,
|
|
39
|
-
onOpenChange,
|
|
40
|
-
onCreate,
|
|
41
|
-
}: CreateTeamDialogViewProps): JSX.Element {
|
|
42
|
-
const [name, setName] = useState("");
|
|
43
|
-
const [loading, setLoading] = useState(false);
|
|
44
|
-
const [error, setError] = useState("");
|
|
45
|
-
|
|
46
|
-
const handleCreate = async () => {
|
|
47
|
-
if (!name.trim()) return;
|
|
48
|
-
setLoading(true);
|
|
49
|
-
setError("");
|
|
50
|
-
try {
|
|
51
|
-
await onCreate(name.trim());
|
|
52
|
-
setName("");
|
|
53
|
-
} catch (e: unknown) {
|
|
54
|
-
setError(e instanceof Error ? e.message : labels.createFailed);
|
|
55
|
-
} finally {
|
|
56
|
-
setLoading(false);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
62
|
-
<DialogContent>
|
|
63
|
-
<DialogHeader>
|
|
64
|
-
<DialogTitle>{labels.createTitle}</DialogTitle>
|
|
65
|
-
</DialogHeader>
|
|
66
|
-
<div className="space-y-3">
|
|
67
|
-
<input
|
|
68
|
-
placeholder={labels.createPlaceholder}
|
|
69
|
-
value={name}
|
|
70
|
-
onChange={(e) => setName(e.target.value)}
|
|
71
|
-
onKeyDown={(e) => e.key === "Enter" && void handleCreate()}
|
|
72
|
-
// biome-ignore lint/a11y/noAutofocus: preserve original dialog focus
|
|
73
|
-
autoFocus
|
|
74
|
-
className={cn(inputClassName)}
|
|
75
|
-
/>
|
|
76
|
-
{error && <p className="text-[12px] text-destructive">{error}</p>}
|
|
77
|
-
</div>
|
|
78
|
-
<DialogFooter>
|
|
79
|
-
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
80
|
-
{labels.cancel}
|
|
81
|
-
</Button>
|
|
82
|
-
<Button onClick={() => void handleCreate()} disabled={loading || !name.trim()}>
|
|
83
|
-
{loading ? labels.creating : labels.createButton}
|
|
84
|
-
</Button>
|
|
85
|
-
</DialogFooter>
|
|
86
|
-
</DialogContent>
|
|
87
|
-
</Dialog>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface JoinTeamDialogViewProps {
|
|
92
|
-
readonly open: boolean;
|
|
93
|
-
readonly labels: TeamDialogLabelsView;
|
|
94
|
-
readonly onOpenChange: (open: boolean) => void;
|
|
95
|
-
readonly onJoin: (code: string) => Promise<void>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function JoinTeamDialogView({
|
|
99
|
-
open,
|
|
100
|
-
labels,
|
|
101
|
-
onOpenChange,
|
|
102
|
-
onJoin,
|
|
103
|
-
}: JoinTeamDialogViewProps): JSX.Element {
|
|
104
|
-
const [code, setCode] = useState("");
|
|
105
|
-
const [loading, setLoading] = useState(false);
|
|
106
|
-
const [error, setError] = useState("");
|
|
107
|
-
|
|
108
|
-
const handleJoin = async () => {
|
|
109
|
-
if (!code.trim()) return;
|
|
110
|
-
setLoading(true);
|
|
111
|
-
setError("");
|
|
112
|
-
try {
|
|
113
|
-
await onJoin(code.trim());
|
|
114
|
-
setCode("");
|
|
115
|
-
} catch (e: unknown) {
|
|
116
|
-
setError(e instanceof Error ? e.message : labels.joinFailed);
|
|
117
|
-
} finally {
|
|
118
|
-
setLoading(false);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
124
|
-
<DialogContent>
|
|
125
|
-
<DialogHeader>
|
|
126
|
-
<DialogTitle>{labels.joinTitle}</DialogTitle>
|
|
127
|
-
</DialogHeader>
|
|
128
|
-
<div className="space-y-3">
|
|
129
|
-
<input
|
|
130
|
-
placeholder={labels.joinPlaceholder}
|
|
131
|
-
value={code}
|
|
132
|
-
onChange={(e) => setCode(e.target.value)}
|
|
133
|
-
onKeyDown={(e) => e.key === "Enter" && void handleJoin()}
|
|
134
|
-
// biome-ignore lint/a11y/noAutofocus: preserve original dialog focus
|
|
135
|
-
autoFocus
|
|
136
|
-
className={cn(inputClassName)}
|
|
137
|
-
/>
|
|
138
|
-
{error && <p className="text-[12px] text-destructive">{error}</p>}
|
|
139
|
-
</div>
|
|
140
|
-
<DialogFooter>
|
|
141
|
-
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
142
|
-
{labels.cancel}
|
|
143
|
-
</Button>
|
|
144
|
-
<Button onClick={() => void handleJoin()} disabled={loading || !code.trim()}>
|
|
145
|
-
{loading ? labels.joining : labels.joinButton}
|
|
146
|
-
</Button>
|
|
147
|
-
</DialogFooter>
|
|
148
|
-
</DialogContent>
|
|
149
|
-
</Dialog>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { JSX } from "react";
|
|
2
|
-
import { SettingSection, type SettingSectionMeta } from "./SettingChrome";
|
|
3
|
-
|
|
4
|
-
export interface TeamListItemView {
|
|
5
|
-
readonly id: number;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly roleLabel: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface TeamListViewProps {
|
|
11
|
-
readonly teams: readonly TeamListItemView[];
|
|
12
|
-
readonly loading: boolean;
|
|
13
|
-
readonly emptyLabel: string;
|
|
14
|
-
readonly section: SettingSectionMeta;
|
|
15
|
-
readonly onSelect: (id: number) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function TeamListView({
|
|
19
|
-
teams,
|
|
20
|
-
loading,
|
|
21
|
-
emptyLabel,
|
|
22
|
-
section,
|
|
23
|
-
onSelect,
|
|
24
|
-
}: TeamListViewProps): JSX.Element {
|
|
25
|
-
if (teams.length === 0) {
|
|
26
|
-
return (
|
|
27
|
-
<SettingSection section={section}>
|
|
28
|
-
<div className="px-5 py-8 text-center text-[13px] text-muted-foreground">{emptyLabel}</div>
|
|
29
|
-
</SettingSection>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<SettingSection section={section}>
|
|
35
|
-
{teams.map((team, i) => (
|
|
36
|
-
<button
|
|
37
|
-
key={team.id}
|
|
38
|
-
type="button"
|
|
39
|
-
onClick={() => onSelect(team.id)}
|
|
40
|
-
className={`flex w-full items-center justify-between px-5 py-3.5 text-left transition-colors hover:bg-accent/50 ${i < teams.length - 1 ? "border-b border-border" : ""}`}
|
|
41
|
-
disabled={loading}
|
|
42
|
-
>
|
|
43
|
-
<div className="flex items-center gap-3">
|
|
44
|
-
<div className="flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-[13px] font-bold text-primary">
|
|
45
|
-
{team.name[0]}
|
|
46
|
-
</div>
|
|
47
|
-
<div>
|
|
48
|
-
<div className="text-[13px] font-medium text-foreground">{team.name}</div>
|
|
49
|
-
<div className="text-[11px] text-muted-foreground">{team.roleLabel}</div>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
<span className="icon-[mdi--chevron-right] h-4 w-4 text-muted-foreground/50" />
|
|
53
|
-
</button>
|
|
54
|
-
))}
|
|
55
|
-
</SettingSection>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { JSX, ReactNode } from "react";
|
|
2
|
-
import { Button } from "@vetta-org/ui";
|
|
3
|
-
import type { SettingSectionMeta } from "./SettingChrome";
|
|
4
|
-
import { SettingHeading } from "./SettingChrome";
|
|
5
|
-
|
|
6
|
-
export interface TeamSettingsViewProps {
|
|
7
|
-
readonly tokenPresent: boolean;
|
|
8
|
-
readonly loginRequiredLabel: string;
|
|
9
|
-
readonly description: string;
|
|
10
|
-
readonly section: SettingSectionMeta;
|
|
11
|
-
readonly onJoinOpen: () => void;
|
|
12
|
-
readonly onCreateOpen: () => void;
|
|
13
|
-
readonly body: ReactNode;
|
|
14
|
-
readonly dialogs: ReactNode;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function TeamSettingsView({
|
|
18
|
-
tokenPresent,
|
|
19
|
-
loginRequiredLabel,
|
|
20
|
-
description,
|
|
21
|
-
section,
|
|
22
|
-
onJoinOpen,
|
|
23
|
-
onCreateOpen,
|
|
24
|
-
body,
|
|
25
|
-
dialogs,
|
|
26
|
-
}: TeamSettingsViewProps): JSX.Element {
|
|
27
|
-
if (!tokenPresent) {
|
|
28
|
-
return <div className="p-6 text-center text-[13px] text-muted-foreground">{loginRequiredLabel}</div>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className="mx-auto w-full max-w-2xl space-y-6 px-8 pb-12">
|
|
33
|
-
<div className="flex items-center justify-between">
|
|
34
|
-
<div>
|
|
35
|
-
<SettingHeading section={section} className="text-[18px] font-bold" />
|
|
36
|
-
<p className="mt-1 text-[12px] text-muted-foreground">{description}</p>
|
|
37
|
-
</div>
|
|
38
|
-
<div className="flex gap-2">
|
|
39
|
-
<Button variant="outline" size="sm" onClick={onJoinOpen}>
|
|
40
|
-
<span className="icon-[mdi--account-plus-outline] mr-1.5 h-3.5 w-3.5" />
|
|
41
|
-
</Button>
|
|
42
|
-
<Button size="sm" onClick={onCreateOpen}>
|
|
43
|
-
<span className="icon-[mdi--plus] mr-1.5 h-3.5 w-3.5" />
|
|
44
|
-
</Button>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
{body}
|
|
48
|
-
{dialogs}
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import { useEffect, useId, useMemo, useRef, useState, type JSX } from "react";
|
|
2
|
-
import {
|
|
3
|
-
activityBlockCount,
|
|
4
|
-
activityIntensityLevel,
|
|
5
|
-
activityMatrixHeightPx,
|
|
6
|
-
buildActivityColumns,
|
|
7
|
-
buildAreaGeometry,
|
|
8
|
-
buildHoverZones,
|
|
9
|
-
columnCapacity,
|
|
10
|
-
fitActivityColumns,
|
|
11
|
-
fitCurveColumns,
|
|
12
|
-
formatTokenCount,
|
|
13
|
-
trimLeadingIdleColumns,
|
|
14
|
-
TOKEN_ACTIVITY_GAP_PX,
|
|
15
|
-
TOKEN_ACTIVITY_MAX_ROWS,
|
|
16
|
-
type TokenActivityMode,
|
|
17
|
-
type UsageSeriesPointLike,
|
|
18
|
-
} from "./token-activity";
|
|
19
|
-
|
|
20
|
-
function cn(...parts: Array<string | false | null | undefined>): string {
|
|
21
|
-
return parts.filter(Boolean).join(" ");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface TokenActivityChartViewProps {
|
|
25
|
-
points: UsageSeriesPointLike[];
|
|
26
|
-
loading?: boolean;
|
|
27
|
-
/** When true, omit outer card chrome (for nesting inside another panel). */
|
|
28
|
-
embedded?: boolean;
|
|
29
|
-
labels: {
|
|
30
|
-
title: string;
|
|
31
|
-
daily: string;
|
|
32
|
-
weekly: string;
|
|
33
|
-
rolling: string;
|
|
34
|
-
empty: string;
|
|
35
|
-
tokens: (count: string) => string;
|
|
36
|
-
month: (yearMonth: string) => string;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const MODES: TokenActivityMode[] = ["daily", "weekly", "rolling"];
|
|
41
|
-
|
|
42
|
-
/** 相邻月份刻度的最小水平间距(px),小于此值只保留前一个刻度。 */
|
|
43
|
-
const MONTH_TICK_MIN_GAP_PX = 34;
|
|
44
|
-
|
|
45
|
-
/** 1..4 light → dark; index 0 unused. Alpha values from DESIGN token whitelist. */
|
|
46
|
-
const FILLED_CLASS: Record<number, string> = {
|
|
47
|
-
1: "bg-primary/25",
|
|
48
|
-
2: "bg-primary/40",
|
|
49
|
-
3: "bg-primary/60",
|
|
50
|
-
4: "bg-primary/80",
|
|
51
|
-
};
|
|
52
|
-
const FILLED_ACTIVE_CLASS: Record<number, string> = {
|
|
53
|
-
1: "bg-primary/40",
|
|
54
|
-
2: "bg-primary/60",
|
|
55
|
-
3: "bg-primary/80",
|
|
56
|
-
4: "bg-primary",
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export function TokenActivityChartView({
|
|
60
|
-
points,
|
|
61
|
-
loading,
|
|
62
|
-
embedded,
|
|
63
|
-
labels,
|
|
64
|
-
}: TokenActivityChartViewProps): JSX.Element {
|
|
65
|
-
const [mode, setMode] = useState<TokenActivityMode>("rolling");
|
|
66
|
-
const [hoverKey, setHoverKey] = useState<string | null>(null);
|
|
67
|
-
const trackRef = useRef<HTMLDivElement>(null);
|
|
68
|
-
const gradientId = useId();
|
|
69
|
-
const [width, setWidth] = useState(0);
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const el = trackRef.current;
|
|
73
|
-
if (!el) return;
|
|
74
|
-
const measure = () => setWidth(el.clientWidth);
|
|
75
|
-
measure();
|
|
76
|
-
const ro = new ResizeObserver(measure);
|
|
77
|
-
ro.observe(el);
|
|
78
|
-
return () => ro.disconnect();
|
|
79
|
-
}, [loading]);
|
|
80
|
-
|
|
81
|
-
const rawColumns = useMemo(() => buildActivityColumns(points, mode), [points, mode]);
|
|
82
|
-
const capacity = useMemo(() => columnCapacity(width), [width]);
|
|
83
|
-
const isCurve = mode === "rolling";
|
|
84
|
-
const columns = useMemo(
|
|
85
|
-
() =>
|
|
86
|
-
isCurve
|
|
87
|
-
? fitCurveColumns(trimLeadingIdleColumns(rawColumns), capacity)
|
|
88
|
-
: fitActivityColumns(rawColumns, capacity),
|
|
89
|
-
[rawColumns, capacity, isCurve],
|
|
90
|
-
);
|
|
91
|
-
const maxTokens = useMemo(() => {
|
|
92
|
-
const values = columns.filter((c) => !c.isPad).map((c) => c.tokens);
|
|
93
|
-
return Math.max(1, ...values, 0);
|
|
94
|
-
}, [columns]);
|
|
95
|
-
const hoverCol = hoverKey ? columns.find((c) => c.key === hoverKey && !c.isPad) : null;
|
|
96
|
-
const geometry = useMemo(
|
|
97
|
-
// 顶部留 8% 余量,否则最高点正好压在 viewBox 边缘、描边会被裁掉一半
|
|
98
|
-
() => (isCurve ? buildAreaGeometry(columns, maxTokens * 1.08) : null),
|
|
99
|
-
[isCurve, columns, maxTokens],
|
|
100
|
-
);
|
|
101
|
-
const curveHeight = useMemo(() => activityMatrixHeightPx(width, capacity), [width, capacity]);
|
|
102
|
-
const hoverPoint = hoverCol ? geometry?.points.find((p) => p.key === hoverCol.key) : undefined;
|
|
103
|
-
const hoverZones = useMemo(() => (geometry ? buildHoverZones(geometry.points) : []), [geometry]);
|
|
104
|
-
/** 月份刻度按列下标定位,相邻月份起始列可能只差一两列 —— 太近就跳过,避免文字叠在一起。 */
|
|
105
|
-
const monthTicks = useMemo(() => {
|
|
106
|
-
const ticks: Array<{ key: string; leftPercent: number; monthKey: string }> = [];
|
|
107
|
-
let lastLeftPx = Number.NEGATIVE_INFINITY;
|
|
108
|
-
columns.forEach((col, i) => {
|
|
109
|
-
if (!col.monthKey) return;
|
|
110
|
-
const ratio = isCurve
|
|
111
|
-
? (geometry?.points[i]?.x ?? 0) / 100
|
|
112
|
-
: i / Math.max(columns.length, 1);
|
|
113
|
-
if (width > 0 && width * ratio - lastLeftPx < MONTH_TICK_MIN_GAP_PX) return;
|
|
114
|
-
lastLeftPx = width * ratio;
|
|
115
|
-
ticks.push({ key: col.key, leftPercent: ratio * 100, monthKey: col.monthKey });
|
|
116
|
-
});
|
|
117
|
-
return ticks;
|
|
118
|
-
}, [columns, width, isCurve, geometry]);
|
|
119
|
-
|
|
120
|
-
const modeLabel = (m: TokenActivityMode): string => {
|
|
121
|
-
if (m === "daily") return labels.daily;
|
|
122
|
-
if (m === "weekly") return labels.weekly;
|
|
123
|
-
return labels.rolling;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<div
|
|
128
|
-
className={
|
|
129
|
-
embedded
|
|
130
|
-
? undefined
|
|
131
|
-
: "rounded-xl border border-border/50 bg-card/40 p-4 backdrop-blur-sm"
|
|
132
|
-
}
|
|
133
|
-
>
|
|
134
|
-
<div className="mb-3 flex flex-wrap items-center justify-between gap-2">
|
|
135
|
-
<h3 className="text-[13px] font-semibold text-foreground">{labels.title}</h3>
|
|
136
|
-
<div className="flex rounded-lg border border-border/50 bg-muted/30 p-0.5">
|
|
137
|
-
{MODES.map((m) => (
|
|
138
|
-
<button
|
|
139
|
-
key={m}
|
|
140
|
-
type="button"
|
|
141
|
-
onClick={() => setMode(m)}
|
|
142
|
-
className={cn(
|
|
143
|
-
"rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors",
|
|
144
|
-
mode === m
|
|
145
|
-
? "bg-background text-foreground ring-1 ring-inset ring-border/60"
|
|
146
|
-
: "text-muted-foreground hover:text-foreground",
|
|
147
|
-
)}
|
|
148
|
-
>
|
|
149
|
-
{modeLabel(m)}
|
|
150
|
-
</button>
|
|
151
|
-
))}
|
|
152
|
-
</div>
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
{loading ? (
|
|
156
|
-
<div className="h-[132px] animate-pulse rounded-lg bg-muted/40" />
|
|
157
|
-
) : (
|
|
158
|
-
<div className="relative">
|
|
159
|
-
{hoverCol && (
|
|
160
|
-
<div className="pointer-events-none absolute left-1/2 top-0 z-10 -translate-x-1/2 -translate-y-0.5 rounded-lg border border-border/60 bg-popover/95 px-2.5 py-1 text-[11px] text-popover-foreground">
|
|
161
|
-
<span className="text-muted-foreground">
|
|
162
|
-
{hoverCol.windowStart
|
|
163
|
-
? `${hoverCol.windowStart} → ${hoverCol.date}`
|
|
164
|
-
: hoverCol.date === hoverCol.endDate
|
|
165
|
-
? hoverCol.date
|
|
166
|
-
: `${hoverCol.date} → ${hoverCol.endDate}`}
|
|
167
|
-
</span>
|
|
168
|
-
{" · "}
|
|
169
|
-
{labels.tokens(formatTokenCount(hoverCol.tokens))}
|
|
170
|
-
</div>
|
|
171
|
-
)}
|
|
172
|
-
|
|
173
|
-
<div ref={trackRef} className="w-full overflow-hidden pt-5" onMouseLeave={() => setHoverKey(null)}>
|
|
174
|
-
{capacity > 0 && (
|
|
175
|
-
<div className="flex w-full flex-col gap-1.5">
|
|
176
|
-
{isCurve && geometry ? (
|
|
177
|
-
<div
|
|
178
|
-
className="relative w-full text-primary"
|
|
179
|
-
style={{ height: curveHeight || undefined }}
|
|
180
|
-
>
|
|
181
|
-
<svg
|
|
182
|
-
className="absolute inset-0 h-full w-full"
|
|
183
|
-
viewBox="0 0 100 100"
|
|
184
|
-
preserveAspectRatio="none"
|
|
185
|
-
aria-hidden="true"
|
|
186
|
-
focusable="false"
|
|
187
|
-
>
|
|
188
|
-
<defs>
|
|
189
|
-
<linearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
|
|
190
|
-
<stop offset="0%" stopColor="currentColor" stopOpacity="0.35" />
|
|
191
|
-
<stop offset="100%" stopColor="currentColor" stopOpacity="0.02" />
|
|
192
|
-
</linearGradient>
|
|
193
|
-
</defs>
|
|
194
|
-
{geometry.areaPath && <path d={geometry.areaPath} fill={`url(#${gradientId})`} />}
|
|
195
|
-
{geometry.linePath && (
|
|
196
|
-
<path
|
|
197
|
-
d={geometry.linePath}
|
|
198
|
-
fill="none"
|
|
199
|
-
stroke="currentColor"
|
|
200
|
-
strokeWidth={1.5}
|
|
201
|
-
strokeLinecap="round"
|
|
202
|
-
strokeLinejoin="round"
|
|
203
|
-
vectorEffect="non-scaling-stroke"
|
|
204
|
-
/>
|
|
205
|
-
)}
|
|
206
|
-
</svg>
|
|
207
|
-
{hoverPoint && (
|
|
208
|
-
<>
|
|
209
|
-
<span
|
|
210
|
-
className="pointer-events-none absolute top-0 bottom-0 w-px bg-primary/30"
|
|
211
|
-
style={{ left: `${hoverPoint.x}%` }}
|
|
212
|
-
/>
|
|
213
|
-
<span
|
|
214
|
-
className="pointer-events-none absolute size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary"
|
|
215
|
-
style={{ left: `${hoverPoint.x}%`, top: `${hoverPoint.y}%` }}
|
|
216
|
-
/>
|
|
217
|
-
</>
|
|
218
|
-
)}
|
|
219
|
-
{/* 曲线本身不可命中,用覆盖在数据点上的透明分区复用矩阵那套悬停逻辑 */}
|
|
220
|
-
{hoverZones.map((zone) => (
|
|
221
|
-
<div
|
|
222
|
-
key={zone.key}
|
|
223
|
-
className="absolute top-0 bottom-0"
|
|
224
|
-
style={{ left: `${zone.left}%`, width: `${zone.width}%` }}
|
|
225
|
-
onMouseEnter={() => setHoverKey(zone.key)}
|
|
226
|
-
/>
|
|
227
|
-
))}
|
|
228
|
-
</div>
|
|
229
|
-
) : (
|
|
230
|
-
<div className="flex w-full items-end" style={{ gap: TOKEN_ACTIVITY_GAP_PX }}>
|
|
231
|
-
{columns.map((col) => {
|
|
232
|
-
const filled = activityBlockCount(col.tokens, maxTokens);
|
|
233
|
-
const level = activityIntensityLevel(col.tokens, maxTokens);
|
|
234
|
-
const active = hoverKey === col.key;
|
|
235
|
-
const fillClass =
|
|
236
|
-
level > 0
|
|
237
|
-
? active
|
|
238
|
-
? FILLED_ACTIVE_CLASS[level]
|
|
239
|
-
: FILLED_CLASS[level]
|
|
240
|
-
: undefined;
|
|
241
|
-
return (
|
|
242
|
-
<div
|
|
243
|
-
key={col.key}
|
|
244
|
-
className="flex min-w-0 flex-1 flex-col-reverse"
|
|
245
|
-
style={{ gap: TOKEN_ACTIVITY_GAP_PX }}
|
|
246
|
-
onMouseEnter={() => {
|
|
247
|
-
if (!col.isPad) setHoverKey(col.key);
|
|
248
|
-
}}
|
|
249
|
-
>
|
|
250
|
-
{Array.from({ length: TOKEN_ACTIVITY_MAX_ROWS }, (_, row) => {
|
|
251
|
-
const isFilled = row < filled;
|
|
252
|
-
return (
|
|
253
|
-
<div
|
|
254
|
-
key={row}
|
|
255
|
-
className={cn(
|
|
256
|
-
"aspect-square w-full rounded-[2px] transition-colors",
|
|
257
|
-
isFilled ? fillClass : "bg-muted",
|
|
258
|
-
)}
|
|
259
|
-
/>
|
|
260
|
-
);
|
|
261
|
-
})}
|
|
262
|
-
</div>
|
|
263
|
-
);
|
|
264
|
-
})}
|
|
265
|
-
</div>
|
|
266
|
-
)}
|
|
267
|
-
|
|
268
|
-
<div className="relative mt-0.5 h-4">
|
|
269
|
-
{monthTicks.map((tick) => (
|
|
270
|
-
<span
|
|
271
|
-
key={tick.key}
|
|
272
|
-
className="absolute whitespace-nowrap text-[10px] text-muted-foreground"
|
|
273
|
-
style={{ left: `${tick.leftPercent}%` }}
|
|
274
|
-
>
|
|
275
|
-
{labels.month(tick.monthKey)}
|
|
276
|
-
</span>
|
|
277
|
-
))}
|
|
278
|
-
</div>
|
|
279
|
-
</div>
|
|
280
|
-
)}
|
|
281
|
-
</div>
|
|
282
|
-
</div>
|
|
283
|
-
)}
|
|
284
|
-
</div>
|
|
285
|
-
);
|
|
286
|
-
}
|