@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
|
@@ -20,7 +20,7 @@ export function SettingRow({
|
|
|
20
20
|
border?: boolean;
|
|
21
21
|
}): JSX.Element {
|
|
22
22
|
return (
|
|
23
|
-
<div className={cn("flex items-center justify-between gap-6 px-
|
|
23
|
+
<div className={cn("flex items-center justify-between gap-6 px-4 py-2.5", border && "border-b border-border")}>
|
|
24
24
|
<div className="min-w-0 flex-1 basis-0">
|
|
25
25
|
<div className="truncate text-[13px] font-medium text-foreground" title={title}>
|
|
26
26
|
{title}
|
|
@@ -55,7 +55,7 @@ export function SettingSection({
|
|
|
55
55
|
renderedTitle !== false &&
|
|
56
56
|
!(typeof renderedTitle === "string" && renderedTitle.trim() === "");
|
|
57
57
|
return (
|
|
58
|
-
<div className="mb-6
|
|
58
|
+
<div className="mb-6 py-1.5" data-setting-section-highlight-target={section.id}>
|
|
59
59
|
{hasTitle &&
|
|
60
60
|
(typeof renderedTitle === "string" ? (
|
|
61
61
|
<h2
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { forwardRef, type JSX } from "react";
|
|
2
|
-
import { motion, useReducedMotion, type Variants } from "motion/react";
|
|
3
2
|
import { cn } from "@vetta-org/ui";
|
|
4
3
|
|
|
5
4
|
export interface SettingsAiAssistButtonViewProps {
|
|
@@ -8,143 +7,34 @@ export interface SettingsAiAssistButtonViewProps {
|
|
|
8
7
|
readonly onClick?: () => void;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
const wandVariants: Variants = {
|
|
12
|
-
idle: { rotate: 0, scale: 1 },
|
|
13
|
-
pulse: {
|
|
14
|
-
rotate: [0, -8, 8, -4, 0],
|
|
15
|
-
transition: {
|
|
16
|
-
duration: 2.4,
|
|
17
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
18
|
-
ease: "easeInOut",
|
|
19
|
-
repeatDelay: 1.2,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
hover: {
|
|
23
|
-
scale: 1.08,
|
|
24
|
-
rotate: 12,
|
|
25
|
-
transition: { type: "spring", stiffness: 380, damping: 22 },
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
10
|
/**
|
|
30
|
-
* Compact AI-assist CTA:
|
|
11
|
+
* Compact AI-assist CTA: magic-wand icon + short label.
|
|
12
|
+
* 静态图标:这枚按钮常驻在设置页与自动化页的顶栏,循环的魔杖晃动与闪烁星点
|
|
13
|
+
* 会让整窗每帧重绘,在毛玻璃窗口上 GPU 代价被放大。悬停只做 CSS 颜色过渡。
|
|
31
14
|
* Ref-forwarding so it can act as PopoverTrigger (asChild).
|
|
32
15
|
*/
|
|
33
16
|
export const SettingsAiAssistButtonView = forwardRef<HTMLButtonElement, SettingsAiAssistButtonViewProps>(
|
|
34
17
|
function SettingsAiAssistButtonView({ label, className, onClick }, ref): JSX.Element {
|
|
35
|
-
const reduceMotion = useReducedMotion();
|
|
36
|
-
|
|
37
18
|
return (
|
|
38
|
-
<
|
|
19
|
+
<button
|
|
39
20
|
ref={ref}
|
|
40
21
|
type="button"
|
|
41
22
|
onClick={onClick}
|
|
42
23
|
title={label}
|
|
43
24
|
aria-label={label}
|
|
44
25
|
data-settings-ai-assist-trigger=""
|
|
45
|
-
initial="idle"
|
|
46
|
-
animate={reduceMotion ? "idle" : "pulse"}
|
|
47
|
-
whileHover={reduceMotion ? undefined : "hover"}
|
|
48
|
-
whileTap={reduceMotion ? undefined : { scale: 0.95 }}
|
|
49
26
|
className={cn(
|
|
50
|
-
"
|
|
27
|
+
"inline-flex h-7 shrink-0 cursor-pointer items-center gap-1.5 rounded-md border border-transparent px-1.5",
|
|
51
28
|
"bg-transparent text-[12px] font-medium text-primary outline-none select-none",
|
|
52
|
-
"transition-
|
|
29
|
+
"transition-colors duration-150 hover:bg-primary/10",
|
|
53
30
|
"focus-visible:border-ring",
|
|
54
31
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
55
32
|
className,
|
|
56
33
|
)}
|
|
57
34
|
>
|
|
58
|
-
<span className="
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
variants={wandVariants}
|
|
62
|
-
className="icon-[solar--magic-stick-3-bold] relative z-[1] h-3.5 w-3.5"
|
|
63
|
-
/>
|
|
64
|
-
<TwinkleStar
|
|
65
|
-
reduceMotion={!!reduceMotion}
|
|
66
|
-
className="-top-1 -right-1"
|
|
67
|
-
size={5}
|
|
68
|
-
delay={0}
|
|
69
|
-
hoverX={3}
|
|
70
|
-
hoverY={-4}
|
|
71
|
-
/>
|
|
72
|
-
<TwinkleStar
|
|
73
|
-
reduceMotion={!!reduceMotion}
|
|
74
|
-
className="-bottom-1 -left-1"
|
|
75
|
-
size={3.5}
|
|
76
|
-
delay={0.45}
|
|
77
|
-
hoverX={-3}
|
|
78
|
-
hoverY={3}
|
|
79
|
-
/>
|
|
80
|
-
<TwinkleStar
|
|
81
|
-
reduceMotion={!!reduceMotion}
|
|
82
|
-
className="-top-0.5 -left-1.5"
|
|
83
|
-
size={2.5}
|
|
84
|
-
delay={0.9}
|
|
85
|
-
hoverX={-4}
|
|
86
|
-
hoverY={-2}
|
|
87
|
-
/>
|
|
88
|
-
</span>
|
|
89
|
-
<span className="relative z-[1] whitespace-nowrap">{label}</span>
|
|
90
|
-
</motion.button>
|
|
35
|
+
<span aria-hidden className="icon-[solar--magic-stick-3-bold] h-3.5 w-3.5 shrink-0" />
|
|
36
|
+
<span className="whitespace-nowrap">{label}</span>
|
|
37
|
+
</button>
|
|
91
38
|
);
|
|
92
39
|
},
|
|
93
40
|
);
|
|
94
|
-
|
|
95
|
-
function TwinkleStar({
|
|
96
|
-
className,
|
|
97
|
-
size,
|
|
98
|
-
delay,
|
|
99
|
-
hoverX,
|
|
100
|
-
hoverY,
|
|
101
|
-
reduceMotion,
|
|
102
|
-
}: {
|
|
103
|
-
className: string;
|
|
104
|
-
size: number;
|
|
105
|
-
delay: number;
|
|
106
|
-
hoverX: number;
|
|
107
|
-
hoverY: number;
|
|
108
|
-
reduceMotion: boolean;
|
|
109
|
-
}): JSX.Element {
|
|
110
|
-
const variants: Variants = {
|
|
111
|
-
idle: { opacity: 0.85, scale: 1, x: 0, y: 0 },
|
|
112
|
-
pulse: {
|
|
113
|
-
opacity: [0.25, 1, 0.35, 1, 0.25],
|
|
114
|
-
scale: [0.7, 1.15, 0.85, 1.1, 0.7],
|
|
115
|
-
x: 0,
|
|
116
|
-
y: 0,
|
|
117
|
-
transition: {
|
|
118
|
-
duration: 2.2,
|
|
119
|
-
repeat: Number.POSITIVE_INFINITY,
|
|
120
|
-
ease: "easeInOut",
|
|
121
|
-
delay,
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
hover: {
|
|
125
|
-
x: hoverX,
|
|
126
|
-
y: hoverY,
|
|
127
|
-
scale: 1.35,
|
|
128
|
-
opacity: 1,
|
|
129
|
-
transition: { type: "spring", stiffness: 380, damping: 22 },
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<motion.span
|
|
135
|
-
aria-hidden
|
|
136
|
-
variants={variants}
|
|
137
|
-
animate={reduceMotion ? "idle" : undefined}
|
|
138
|
-
className={cn("pointer-events-none absolute z-[2] text-primary", className)}
|
|
139
|
-
style={{ width: size, height: size }}
|
|
140
|
-
>
|
|
141
|
-
<svg
|
|
142
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
143
|
-
viewBox="0 0 784.11 815.53"
|
|
144
|
-
className="h-full w-full fill-current drop-shadow-[0_0_4px_color-mix(in_srgb,var(--primary)_70%,transparent)]"
|
|
145
|
-
>
|
|
146
|
-
<path d="M392.05 0c-20.9,210.08-184.06,378.41-392.05,407.78 207.96,29.37 371.12,197.68 392.05,407.74 20.93-210.06 184.09-378.37 392.05-407.74-207.98-29.38-371.16-197.69-392.06-407.78z" />
|
|
147
|
-
</svg>
|
|
148
|
-
</motion.span>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FocusEventHandler, JSX, KeyboardEvent } from "react";
|
|
2
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { cn, INPUT_FILL_CLASS, Input, TEXTAREA_FILL_CLASS } from "@vetta-org/ui";
|
|
3
3
|
import { MotionSelect } from "./MotionSelect";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -54,7 +54,7 @@ export function InputField({
|
|
|
54
54
|
className?: string;
|
|
55
55
|
}): JSX.Element {
|
|
56
56
|
return (
|
|
57
|
-
<
|
|
57
|
+
<Input
|
|
58
58
|
type={type}
|
|
59
59
|
value={value}
|
|
60
60
|
disabled={disabled}
|
|
@@ -64,10 +64,7 @@ export function InputField({
|
|
|
64
64
|
placeholder={placeholder}
|
|
65
65
|
autoFocus={autoFocus}
|
|
66
66
|
aria-label={ariaLabel}
|
|
67
|
-
className={cn(
|
|
68
|
-
"h-8 w-full rounded-lg border border-border bg-card px-2.5 text-[12px] font-medium text-foreground placeholder:text-muted-foreground/40 outline-none transition-colors hover:bg-accent focus-visible:border-primary/50 disabled:cursor-not-allowed disabled:opacity-50",
|
|
69
|
-
className,
|
|
70
|
-
)}
|
|
67
|
+
className={cn(INPUT_FILL_CLASS, className)}
|
|
71
68
|
/>
|
|
72
69
|
);
|
|
73
70
|
}
|
|
@@ -89,7 +86,7 @@ export function TextareaField({
|
|
|
89
86
|
onChange={(e) => onChange(e.target.value)}
|
|
90
87
|
placeholder={placeholder}
|
|
91
88
|
rows={rows}
|
|
92
|
-
className="w-full resize-none
|
|
89
|
+
className={cn(TEXTAREA_FILL_CLASS, "w-full resize-none font-mono")}
|
|
93
90
|
/>
|
|
94
91
|
);
|
|
95
92
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type JSX, useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { cn } from "@vetta-org/ui";
|
|
3
3
|
|
|
4
4
|
export interface SettingsSidebarChildItem {
|
|
@@ -24,6 +24,7 @@ export interface SettingsSidebarViewProps {
|
|
|
24
24
|
readonly betaBadgeLabel: string;
|
|
25
25
|
readonly narrow: boolean;
|
|
26
26
|
readonly onSelectTab: (tab: string) => void;
|
|
27
|
+
readonly onTabIntent?: (tab: string) => void;
|
|
27
28
|
/** 下级入口不是设置标签,导航由宿主决定。 */
|
|
28
29
|
readonly onSelectChild?: (key: string) => void;
|
|
29
30
|
/** 当前正在显示的下级入口;它所属的标签会自动展开并高亮该项。 */
|
|
@@ -37,11 +38,58 @@ function ChildIcon({ item }: { item: SettingsSidebarChildItem }): JSX.Element {
|
|
|
37
38
|
return <span className={cn(item.icon, "h-3.5 w-3.5 shrink-0")} />;
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/** 渐隐高度:够看出「上/下还有内容」,又不吃掉整行。 */
|
|
42
|
+
const FADE_SIZE = 24;
|
|
43
|
+
|
|
44
|
+
type FadeEdges = { top: boolean; bottom: boolean };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 隐藏滚动条的纵向滚动容器,用顶部/底部渐隐提示还能往哪边滚。
|
|
48
|
+
* 用 mask 而不是叠色块,换主题后不会露出色差;只在该方向真有内容时才淡出,避免无端吃掉首尾行。
|
|
49
|
+
*/
|
|
50
|
+
function useFadeEdges(): {
|
|
51
|
+
ref: React.RefObject<HTMLElement | null>;
|
|
52
|
+
sync: () => void;
|
|
53
|
+
maskImage: string | undefined;
|
|
54
|
+
} {
|
|
55
|
+
const ref = useRef<HTMLElement | null>(null);
|
|
56
|
+
const [edges, setEdges] = useState<FadeEdges>({ top: false, bottom: false });
|
|
57
|
+
|
|
58
|
+
const sync = useCallback(() => {
|
|
59
|
+
const el = ref.current;
|
|
60
|
+
if (!el) return;
|
|
61
|
+
const top = el.scrollTop > 4;
|
|
62
|
+
const bottom = el.scrollHeight - el.scrollTop - el.clientHeight > 4;
|
|
63
|
+
setEdges((prev) => (prev.top === top && prev.bottom === bottom ? prev : { top, bottom }));
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
// 展开/收起下级入口会改变内容高度,光靠 onScroll 追不上,连内容一起观察。
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const el = ref.current;
|
|
69
|
+
if (!el) return;
|
|
70
|
+
sync();
|
|
71
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
72
|
+
const observer = new ResizeObserver(sync);
|
|
73
|
+
observer.observe(el);
|
|
74
|
+
for (const child of Array.from(el.children)) observer.observe(child);
|
|
75
|
+
return () => observer.disconnect();
|
|
76
|
+
}, [sync]);
|
|
77
|
+
|
|
78
|
+
let maskImage: string | undefined;
|
|
79
|
+
if (edges.top || edges.bottom) {
|
|
80
|
+
const start = edges.top ? `transparent, black ${FADE_SIZE}px` : "black, black";
|
|
81
|
+
const end = edges.bottom ? `black calc(100% - ${FADE_SIZE}px), transparent` : "black, black";
|
|
82
|
+
maskImage = `linear-gradient(to bottom, ${start}, ${end})`;
|
|
83
|
+
}
|
|
84
|
+
return { ref, sync, maskImage };
|
|
85
|
+
}
|
|
86
|
+
|
|
40
87
|
export function SettingsSidebarView({
|
|
41
88
|
activeTab,
|
|
42
89
|
betaBadgeLabel,
|
|
43
90
|
narrow,
|
|
44
91
|
onSelectTab,
|
|
92
|
+
onTabIntent,
|
|
45
93
|
onSelectChild,
|
|
46
94
|
activeChildKey,
|
|
47
95
|
tabs,
|
|
@@ -53,12 +101,23 @@ export function SettingsSidebarView({
|
|
|
53
101
|
? (tabs.find((tab) => tab.children?.some((child) => child.key === activeChildKey))?.key ?? null)
|
|
54
102
|
: null;
|
|
55
103
|
|
|
104
|
+
const { ref, sync, maskImage } = useFadeEdges();
|
|
105
|
+
|
|
56
106
|
return (
|
|
57
|
-
<div className={cn("flex shrink-0 flex-col", narrow ? "w-14" : "w-[200px]")}>
|
|
107
|
+
<div className={cn("flex min-h-0 shrink-0 flex-col", narrow ? "w-14" : "w-[200px]")}>
|
|
58
108
|
<div className={cn("drag-region", narrow ? "h-12" : "px-5 pb-2 pt-2")}>
|
|
59
109
|
{!narrow && <h1 className="text-[20px] font-bold text-foreground">{title}</h1>}
|
|
60
110
|
</div>
|
|
61
|
-
<nav
|
|
111
|
+
<nav
|
|
112
|
+
ref={ref}
|
|
113
|
+
onScroll={sync}
|
|
114
|
+
style={maskImage ? { maskImage, WebkitMaskImage: maskImage } : undefined}
|
|
115
|
+
// no-scrollbar:全局 overlay 滚动条规则无 layer,Tailwind 的 hidden 压不过它。
|
|
116
|
+
className={cn(
|
|
117
|
+
"no-scrollbar flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",
|
|
118
|
+
narrow ? "px-2" : "px-2.5",
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
62
121
|
{tabs.map((item) => {
|
|
63
122
|
// 窄侧栏没有文字位置,展开的清单读不出来,此时只保留「点进页面」。
|
|
64
123
|
const expandable = !narrow && (item.children?.length ?? 0) > 0;
|
|
@@ -79,6 +138,8 @@ export function SettingsSidebarView({
|
|
|
79
138
|
aria-expanded={expandable ? expanded : undefined}
|
|
80
139
|
// 进页面与展开清单合成一个动作:点行即导航,清单跟着选中态展开。
|
|
81
140
|
onClick={() => onSelectTab(item.key)}
|
|
141
|
+
onFocus={() => onTabIntent?.(item.key)}
|
|
142
|
+
onMouseEnter={() => onTabIntent?.(item.key)}
|
|
82
143
|
className={cn(
|
|
83
144
|
"flex min-w-0 flex-1 items-center rounded-lg outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",
|
|
84
145
|
narrow ? "justify-center px-0 py-2" : "gap-2.5 py-[7px] ps-2.5 pe-2.5",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { act, useState, type JSX } from "react";
|
|
4
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
5
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
+
import { ShortcutRecorderView, type ShortcutRecorderViewProps } from "./ShortcutRecorderView";
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
9
|
+
|
|
10
|
+
const mounted: Array<{ root: Root; container: HTMLDivElement }> = [];
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
for (const { root, container } of mounted.splice(0)) {
|
|
14
|
+
act(() => root.unmount());
|
|
15
|
+
container.remove();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const eventToShortcut = (event: KeyboardEvent) => (event.key === "k" ? "mod+k" : null);
|
|
20
|
+
|
|
21
|
+
/** 受控录音器的宿主:把 onChange / onReset 落到可见状态上,断言用户看到的结果。 */
|
|
22
|
+
function RecorderHost({
|
|
23
|
+
initialValue,
|
|
24
|
+
initialIsDefault,
|
|
25
|
+
onResetLabel,
|
|
26
|
+
}: {
|
|
27
|
+
initialValue: string;
|
|
28
|
+
initialIsDefault: boolean;
|
|
29
|
+
onResetLabel: string;
|
|
30
|
+
}): JSX.Element {
|
|
31
|
+
const [value, setValue] = useState(initialValue);
|
|
32
|
+
const [isDefault, setIsDefault] = useState(initialIsDefault);
|
|
33
|
+
const props: ShortcutRecorderViewProps = {
|
|
34
|
+
value,
|
|
35
|
+
isDefault,
|
|
36
|
+
onChange: (next) => {
|
|
37
|
+
setValue(next);
|
|
38
|
+
setIsDefault(false);
|
|
39
|
+
},
|
|
40
|
+
onReset: () => {
|
|
41
|
+
setValue(initialValue);
|
|
42
|
+
setIsDefault(true);
|
|
43
|
+
},
|
|
44
|
+
placeholder: "Press shortcut",
|
|
45
|
+
resetLabel: onResetLabel,
|
|
46
|
+
eventToShortcut,
|
|
47
|
+
};
|
|
48
|
+
return <ShortcutRecorderView {...props} />;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function renderHost(initialValue = "mod+shift+k", initialIsDefault = true) {
|
|
52
|
+
const container = document.createElement("div");
|
|
53
|
+
document.body.append(container);
|
|
54
|
+
const root = createRoot(container);
|
|
55
|
+
mounted.push({ root, container });
|
|
56
|
+
act(() => root.render(<RecorderHost initialValue={initialValue} initialIsDefault={initialIsDefault} onResetLabel="Reset binding" />));
|
|
57
|
+
const button = container.querySelector("button");
|
|
58
|
+
if (!button) throw new Error("recorder button missing");
|
|
59
|
+
return { container, button: button as HTMLButtonElement };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe("ShortcutRecorderView", () => {
|
|
63
|
+
it("shows the bound shortcut as keycaps instead of a formatted string", () => {
|
|
64
|
+
const { button } = renderHost();
|
|
65
|
+
expect(button.querySelectorAll("kbd")).toHaveLength(3);
|
|
66
|
+
expect(button.textContent).toContain("K");
|
|
67
|
+
expect(button.textContent).not.toContain("mod+shift+k");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("adopts the settings select trigger skin without a visible border", () => {
|
|
71
|
+
const { button } = renderHost();
|
|
72
|
+
// 与 SELECT_TRIGGER_CLASS 同皮:边框占位透明,底面 muted,悬停 accent。
|
|
73
|
+
expect(button.className).toContain("border-transparent");
|
|
74
|
+
expect(button.className).toContain("bg-muted");
|
|
75
|
+
expect(button.className).toContain("hover:bg-accent");
|
|
76
|
+
expect(button.className).not.toContain("border-input");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("records the next key press and shows the new binding", () => {
|
|
80
|
+
const { button } = renderHost();
|
|
81
|
+
|
|
82
|
+
act(() => button.click());
|
|
83
|
+
expect(button.textContent).toContain("Press shortcut");
|
|
84
|
+
|
|
85
|
+
act(() => {
|
|
86
|
+
document.dispatchEvent(new KeyboardEvent("keydown", { key: "k", metaKey: true, bubbles: true }));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(button.textContent).not.toContain("Press shortcut");
|
|
90
|
+
expect(button.querySelectorAll("kbd")).toHaveLength(2);
|
|
91
|
+
expect(button.textContent).toContain("K");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("offers reset only for customized bindings and clears it after reset", () => {
|
|
95
|
+
const defaults = renderHost("mod+shift+k", true);
|
|
96
|
+
expect(defaults.container.querySelectorAll("button")).toHaveLength(1);
|
|
97
|
+
|
|
98
|
+
const customized = renderHost("mod+k", false);
|
|
99
|
+
const buttons = [...customized.container.querySelectorAll("button")];
|
|
100
|
+
expect(buttons).toHaveLength(2);
|
|
101
|
+
const reset = buttons.find((el) => el !== customized.button);
|
|
102
|
+
expect(reset?.title).toBe("Reset binding");
|
|
103
|
+
|
|
104
|
+
act(() => reset?.click());
|
|
105
|
+
expect(customized.container.querySelectorAll("button")).toHaveLength(1);
|
|
106
|
+
expect(customized.button.textContent).toContain("K");
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState, type JSX } from "react";
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
|
+
import { VettaKbd } from "../shared/VettaKbd";
|
|
3
5
|
|
|
4
6
|
export interface ShortcutRecorderViewProps {
|
|
5
7
|
readonly value: string;
|
|
@@ -10,8 +12,6 @@ export interface ShortcutRecorderViewProps {
|
|
|
10
12
|
readonly resetLabel: string;
|
|
11
13
|
/** Host provides platform-specific key → shortcut parsing. */
|
|
12
14
|
readonly eventToShortcut: (event: KeyboardEvent) => string | null;
|
|
13
|
-
/** Host provides display formatting for a stored shortcut. */
|
|
14
|
-
readonly formatShortcut: (shortcut: string) => string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function ShortcutRecorderView({
|
|
@@ -22,7 +22,6 @@ export function ShortcutRecorderView({
|
|
|
22
22
|
placeholder,
|
|
23
23
|
resetLabel,
|
|
24
24
|
eventToShortcut,
|
|
25
|
-
formatShortcut,
|
|
26
25
|
}: ShortcutRecorderViewProps): JSX.Element {
|
|
27
26
|
const [recording, setRecording] = useState(false);
|
|
28
27
|
const [pendingKeys, setPendingKeys] = useState<string | null>(null);
|
|
@@ -58,7 +57,7 @@ export function ShortcutRecorderView({
|
|
|
58
57
|
};
|
|
59
58
|
}, [recording, onChange, eventToShortcut]);
|
|
60
59
|
|
|
61
|
-
const
|
|
60
|
+
const displayedShortcut = pendingKeys ?? value;
|
|
62
61
|
|
|
63
62
|
return (
|
|
64
63
|
<div className="flex items-center gap-2">
|
|
@@ -70,13 +69,20 @@ export function ShortcutRecorderView({
|
|
|
70
69
|
setPendingKeys(null);
|
|
71
70
|
}}
|
|
72
71
|
className={cn(
|
|
73
|
-
|
|
72
|
+
// 与设置页下拉(SELECT_TRIGGER_CLASS)一致:无可见边框,边界靠透明边框占位。
|
|
73
|
+
"flex h-8 min-w-[120px] items-center justify-center gap-1.5 rounded-lg border px-2.5 text-[12px] font-medium transition-colors outline-none",
|
|
74
74
|
recording
|
|
75
|
-
? "animate-pulse border-primary bg-primary/10 text-foreground"
|
|
76
|
-
: "border-
|
|
75
|
+
? "animate-pulse border-primary/50 bg-primary/10 text-foreground"
|
|
76
|
+
: "border-transparent bg-muted text-foreground hover:bg-accent focus-visible:border-primary/50",
|
|
77
77
|
)}
|
|
78
78
|
>
|
|
79
|
-
{recording ?
|
|
79
|
+
{recording ? (
|
|
80
|
+
<span className="text-[12px]">{placeholder}</span>
|
|
81
|
+
) : displayedShortcut ? (
|
|
82
|
+
<VettaKbd keys={displayedShortcut} size="sm" />
|
|
83
|
+
) : (
|
|
84
|
+
<span className="text-[12px] text-muted-foreground">—</span>
|
|
85
|
+
)}
|
|
80
86
|
</button>
|
|
81
87
|
{!isDefault && (
|
|
82
88
|
<Button variant="ghost" size="icon-xs" onClick={onReset} title={resetLabel}>
|
|
@@ -38,7 +38,7 @@ export function ShortcutsSettingsView({
|
|
|
38
38
|
<h1 className="text-[20px] font-bold text-foreground">{title}</h1>
|
|
39
39
|
<div className="flex flex-wrap items-center gap-2">
|
|
40
40
|
{aiAssistSlot}
|
|
41
|
-
<Button variant="
|
|
41
|
+
<Button variant="field" onClick={onResetAll}>
|
|
42
42
|
<span className="icon-[mdi--restore] h-3.5 w-3.5" />
|
|
43
43
|
{resetAllLabel}
|
|
44
44
|
</Button>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
cn,
|
|
5
|
+
Dialog,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogDescription,
|
|
8
|
+
DialogFooter,
|
|
9
|
+
DialogHeader,
|
|
10
|
+
DialogTitle,
|
|
11
|
+
} from "@vetta-org/ui";
|
|
12
|
+
import { InputField } from "./SettingsFormFields";
|
|
13
|
+
|
|
14
|
+
export interface SpaceEditorIconOption {
|
|
15
|
+
readonly value: string;
|
|
16
|
+
readonly label: string;
|
|
17
|
+
readonly iconClassName: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SpaceEditorDialogViewLabels {
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly description: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly namePlaceholder: string;
|
|
25
|
+
readonly icon: string;
|
|
26
|
+
readonly cancel: string;
|
|
27
|
+
readonly save: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SpaceEditorDialogViewProps {
|
|
31
|
+
readonly labels: SpaceEditorDialogViewLabels;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly icons: readonly SpaceEditorIconOption[];
|
|
34
|
+
readonly selectedIcon: string;
|
|
35
|
+
readonly canSave: boolean;
|
|
36
|
+
readonly onNameChange: (name: string) => void;
|
|
37
|
+
readonly onSelectIcon: (value: string) => void;
|
|
38
|
+
readonly onCancel: () => void;
|
|
39
|
+
readonly onSave: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function SpaceEditorDialogView({
|
|
43
|
+
labels,
|
|
44
|
+
name,
|
|
45
|
+
icons,
|
|
46
|
+
selectedIcon,
|
|
47
|
+
canSave,
|
|
48
|
+
onNameChange,
|
|
49
|
+
onSelectIcon,
|
|
50
|
+
onCancel,
|
|
51
|
+
onSave,
|
|
52
|
+
}: SpaceEditorDialogViewProps): JSX.Element {
|
|
53
|
+
return (
|
|
54
|
+
<Dialog
|
|
55
|
+
open
|
|
56
|
+
onOpenChange={(open) => {
|
|
57
|
+
if (!open) onCancel();
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<DialogContent className="sm:max-w-[460px]">
|
|
61
|
+
<DialogHeader>
|
|
62
|
+
<DialogTitle>{labels.title}</DialogTitle>
|
|
63
|
+
<DialogDescription>{labels.description}</DialogDescription>
|
|
64
|
+
</DialogHeader>
|
|
65
|
+
<form
|
|
66
|
+
className="grid gap-4"
|
|
67
|
+
onSubmit={(event) => {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
if (canSave) onSave();
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<div className="grid gap-1.5">
|
|
73
|
+
<span className="text-[12px] font-medium text-muted-foreground">{labels.name}</span>
|
|
74
|
+
<InputField
|
|
75
|
+
value={name}
|
|
76
|
+
onChange={onNameChange}
|
|
77
|
+
placeholder={labels.namePlaceholder}
|
|
78
|
+
autoFocus
|
|
79
|
+
aria-label={labels.name}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
<div className="grid gap-1.5">
|
|
83
|
+
<span className="text-[12px] font-medium text-muted-foreground">{labels.icon}</span>
|
|
84
|
+
<div className="grid grid-cols-10 gap-1" role="group" aria-label={labels.icon}>
|
|
85
|
+
{icons.map((option) => {
|
|
86
|
+
const active = option.value === selectedIcon;
|
|
87
|
+
return (
|
|
88
|
+
<Button
|
|
89
|
+
key={option.value}
|
|
90
|
+
type="button"
|
|
91
|
+
size="icon-sm"
|
|
92
|
+
variant="ghost"
|
|
93
|
+
aria-label={option.label}
|
|
94
|
+
title={option.label}
|
|
95
|
+
aria-pressed={active}
|
|
96
|
+
className={cn(
|
|
97
|
+
"text-muted-foreground",
|
|
98
|
+
active && "border border-primary bg-primary/10 text-primary hover:bg-primary/15",
|
|
99
|
+
)}
|
|
100
|
+
onClick={() => onSelectIcon(option.value)}
|
|
101
|
+
>
|
|
102
|
+
<span className={cn(option.iconClassName, "size-4")} aria-hidden="true" />
|
|
103
|
+
</Button>
|
|
104
|
+
);
|
|
105
|
+
})}
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
<DialogFooter>
|
|
109
|
+
<Button type="button" variant="ghost" onClick={onCancel}>
|
|
110
|
+
{labels.cancel}
|
|
111
|
+
</Button>
|
|
112
|
+
<Button type="submit" disabled={!canSave}>
|
|
113
|
+
{labels.save}
|
|
114
|
+
</Button>
|
|
115
|
+
</DialogFooter>
|
|
116
|
+
</form>
|
|
117
|
+
</DialogContent>
|
|
118
|
+
</Dialog>
|
|
119
|
+
);
|
|
120
|
+
}
|