@vetta-org/theme-ui 0.1.0 → 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 +735 -7
- 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,168 @@
|
|
|
1
|
+
import type { FileExplorerCreatingEntry, FileExplorerEntry, FileExplorerEntryKind } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Initial row-height estimate (`py-[3px]` + `text-[12px]` at the preflight
|
|
5
|
+
* `line-height: 1.5`). Only used until the virtual list has measured a row:
|
|
6
|
+
* marquee hit-testing reads measured heights through {@link FileTreeRowMetrics},
|
|
7
|
+
* so this constant can never misplace a hit once rows are on screen.
|
|
8
|
+
*/
|
|
9
|
+
export const FILE_TREE_ROW_HEIGHT = 24;
|
|
10
|
+
/** Pixel overscan so keyboard/marquee hits near the edge stay mounted. */
|
|
11
|
+
export const FILE_TREE_OVERSCAN = 160;
|
|
12
|
+
|
|
13
|
+
export type FileTreeEntryRow = {
|
|
14
|
+
type: "entry";
|
|
15
|
+
key: string;
|
|
16
|
+
depth: number;
|
|
17
|
+
entry: FileExplorerEntry;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type FileTreeCreateRowModel = {
|
|
21
|
+
type: "create";
|
|
22
|
+
key: string;
|
|
23
|
+
depth: number;
|
|
24
|
+
parentPath: string;
|
|
25
|
+
kind: FileExplorerEntryKind;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type FileTreeRow = FileTreeEntryRow | FileTreeCreateRowModel;
|
|
29
|
+
|
|
30
|
+
export interface BuildFileTreeRowsInput {
|
|
31
|
+
rootDir: string;
|
|
32
|
+
cache: ReadonlyMap<string, readonly FileExplorerEntry[]>;
|
|
33
|
+
expandedDirs: ReadonlySet<string>;
|
|
34
|
+
creatingEntry: FileExplorerCreatingEntry | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface FileTreeMarqueeRect {
|
|
38
|
+
left: number;
|
|
39
|
+
top: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Row geometry source for hit-testing: measured px when known, an estimate otherwise. */
|
|
45
|
+
export interface FileTreeRowMetrics {
|
|
46
|
+
rowHeight(row: FileTreeRow): number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface FileTreeRowHeightStore extends FileTreeRowMetrics {
|
|
50
|
+
/** Record the measured height of a mounted row (keyed by `FileTreeRow.key`). */
|
|
51
|
+
record(key: string, height: number): void;
|
|
52
|
+
/** Drop measurements for rows that no longer exist. */
|
|
53
|
+
prune(liveKeys: ReadonlySet<string>): void;
|
|
54
|
+
/** Average measured height, or the fallback before anything was measured. */
|
|
55
|
+
estimatedRowHeight(): number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Keeps the heights the virtual list measured for mounted rows so geometry
|
|
60
|
+
* hit-tests (marquee) line up with what is actually painted. Unmounted rows use
|
|
61
|
+
* the average measured height, which matches how Virtuoso places items it has
|
|
62
|
+
* not measured yet.
|
|
63
|
+
*/
|
|
64
|
+
export function createFileTreeRowHeightStore(fallbackHeight: number = FILE_TREE_ROW_HEIGHT): FileTreeRowHeightStore {
|
|
65
|
+
const heights = new Map<string, number>();
|
|
66
|
+
let sum = 0;
|
|
67
|
+
|
|
68
|
+
function estimatedRowHeight(): number {
|
|
69
|
+
return heights.size === 0 ? fallbackHeight : sum / heights.size;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
record(key, height) {
|
|
74
|
+
if (!Number.isFinite(height) || height <= 0) return;
|
|
75
|
+
const previous = heights.get(key);
|
|
76
|
+
if (previous === height) return;
|
|
77
|
+
if (previous !== undefined) sum -= previous;
|
|
78
|
+
heights.set(key, height);
|
|
79
|
+
sum += height;
|
|
80
|
+
},
|
|
81
|
+
prune(liveKeys) {
|
|
82
|
+
for (const [key, height] of heights) {
|
|
83
|
+
if (liveKeys.has(key)) continue;
|
|
84
|
+
heights.delete(key);
|
|
85
|
+
sum -= height;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
estimatedRowHeight,
|
|
89
|
+
rowHeight(row) {
|
|
90
|
+
return heights.get(row.key) ?? estimatedRowHeight();
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function createRowKey(parentPath: string, kind: FileExplorerEntryKind): string {
|
|
96
|
+
return `create:${parentPath}:${kind}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function pushCreateRow(result: FileTreeRow[], creatingEntry: FileExplorerCreatingEntry, depth: number): void {
|
|
100
|
+
result.push({
|
|
101
|
+
type: "create",
|
|
102
|
+
key: createRowKey(creatingEntry.parentPath, creatingEntry.kind),
|
|
103
|
+
depth,
|
|
104
|
+
parentPath: creatingEntry.parentPath,
|
|
105
|
+
kind: creatingEntry.kind,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Flatten the visible tree in the same order as the previous full mount:
|
|
111
|
+
* root create row, then each entry followed by an inline create row for that
|
|
112
|
+
* entry, then expanded children.
|
|
113
|
+
*/
|
|
114
|
+
export function buildFileTreeRows({
|
|
115
|
+
rootDir,
|
|
116
|
+
cache,
|
|
117
|
+
expandedDirs,
|
|
118
|
+
creatingEntry,
|
|
119
|
+
}: BuildFileTreeRowsInput): FileTreeRow[] {
|
|
120
|
+
const result: FileTreeRow[] = [];
|
|
121
|
+
if (creatingEntry?.parentPath === rootDir) {
|
|
122
|
+
pushCreateRow(result, creatingEntry, 0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function walk(dirPath: string, depth: number): void {
|
|
126
|
+
const entries = cache.get(dirPath);
|
|
127
|
+
if (!entries) return;
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
result.push({ type: "entry", key: entry.path, depth, entry });
|
|
130
|
+
if (creatingEntry?.parentPath === entry.path) {
|
|
131
|
+
pushCreateRow(result, creatingEntry, depth + 1);
|
|
132
|
+
}
|
|
133
|
+
if (entry.isDirectory && expandedDirs.has(entry.path)) {
|
|
134
|
+
walk(entry.path, depth + 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
walk(rootDir, 0);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Hit-test a content-space marquee against row geometry.
|
|
145
|
+
* Off-screen rows stay selectable because this does not read the DOM; rows are
|
|
146
|
+
* stacked top-to-bottom using `metrics` (a fixed height or measured heights).
|
|
147
|
+
*/
|
|
148
|
+
export function hitTestFileTreeMarquee(
|
|
149
|
+
rows: readonly FileTreeRow[],
|
|
150
|
+
rect: FileTreeMarqueeRect,
|
|
151
|
+
metrics: number | FileTreeRowMetrics = FILE_TREE_ROW_HEIGHT,
|
|
152
|
+
): string[] {
|
|
153
|
+
if (rows.length === 0 || rect.width <= 0 || rect.height <= 0) return [];
|
|
154
|
+
if (typeof metrics === "number" && metrics <= 0) return [];
|
|
155
|
+
const top = rect.top;
|
|
156
|
+
const bottom = top + rect.height;
|
|
157
|
+
const hits: string[] = [];
|
|
158
|
+
let rowTop = 0;
|
|
159
|
+
for (const row of rows) {
|
|
160
|
+
if (rowTop >= bottom) break;
|
|
161
|
+
const height = typeof metrics === "number" ? metrics : metrics.rowHeight(row);
|
|
162
|
+
if (!(height > 0)) continue;
|
|
163
|
+
const rowBottom = rowTop + height;
|
|
164
|
+
if (rowBottom > top && row.type === "entry") hits.push(row.entry.path);
|
|
165
|
+
rowTop = rowBottom;
|
|
166
|
+
}
|
|
167
|
+
return hits;
|
|
168
|
+
}
|
|
@@ -9,6 +9,8 @@ export type {
|
|
|
9
9
|
FileContextMenuViewProps,
|
|
10
10
|
} from "./FileContextMenuView";
|
|
11
11
|
export { FileContextMenuView } from "./FileContextMenuView";
|
|
12
|
+
export type { FileExplorerSettingsViewProps } from "./FileExplorerSettingsView";
|
|
13
|
+
export { FileExplorerSettingsView } from "./FileExplorerSettingsView";
|
|
12
14
|
export type { FilesPanelViewLabels, FilesPanelViewProps } from "./FilesPanelView";
|
|
13
15
|
export { FilesPanelView } from "./FilesPanelView";
|
|
14
16
|
export type { FileTreeCreateRowProps } from "./FileTreeCreateRow";
|
|
@@ -17,6 +19,21 @@ export type { FileTreeNodeViewProps } from "./FileTreeNodeView";
|
|
|
17
19
|
export { FileTreeNodeView } from "./FileTreeNodeView";
|
|
18
20
|
export type { FileTreeViewProps } from "./FileTreeView";
|
|
19
21
|
export { FileTreeView } from "./FileTreeView";
|
|
22
|
+
export { FILE_TREE_ROOT_ATTR, findFileTreeElement } from "./file-tree-dom";
|
|
23
|
+
export type {
|
|
24
|
+
FileTreeCreateRowModel,
|
|
25
|
+
FileTreeEntryRow,
|
|
26
|
+
FileTreeRow,
|
|
27
|
+
FileTreeRowHeightStore,
|
|
28
|
+
FileTreeRowMetrics,
|
|
29
|
+
} from "./file-tree-rows";
|
|
30
|
+
export {
|
|
31
|
+
buildFileTreeRows,
|
|
32
|
+
createFileTreeRowHeightStore,
|
|
33
|
+
FILE_TREE_OVERSCAN,
|
|
34
|
+
FILE_TREE_ROW_HEIGHT,
|
|
35
|
+
hitTestFileTreeMarquee,
|
|
36
|
+
} from "./file-tree-rows";
|
|
20
37
|
export { getFileIcon } from "./fileIcons";
|
|
21
38
|
export type {
|
|
22
39
|
FileExplorerCreatingEntry,
|
|
@@ -20,6 +20,9 @@ export interface FileExplorerNodeDecoration {
|
|
|
20
20
|
icon?: ReactNode;
|
|
21
21
|
badge?: string;
|
|
22
22
|
tooltip?: string;
|
|
23
|
+
color?: "foreground" | "muted" | "accent" | "success" | "warning" | "error";
|
|
24
|
+
faded?: boolean;
|
|
25
|
+
strikethrough?: boolean;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export type FileExplorerEntryKind = "file" | "directory";
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type MouseEvent, type RefObject, useCallback, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
FILE_TREE_ROW_HEIGHT,
|
|
4
|
+
type FileTreeRow,
|
|
5
|
+
type FileTreeRowMetrics,
|
|
6
|
+
hitTestFileTreeMarquee,
|
|
7
|
+
} from "./file-tree-rows";
|
|
2
8
|
|
|
3
9
|
export interface FileTreeMarqueeRect {
|
|
4
10
|
left: number;
|
|
@@ -15,10 +21,14 @@ interface UseFileTreeMarqueeSelectionParams {
|
|
|
15
21
|
* Non-additive starts with `[]` before the drag threshold; then passes hit paths (or base∪hits).
|
|
16
22
|
*/
|
|
17
23
|
onMarqueeSelect: (paths: readonly string[]) => void;
|
|
24
|
+
/** Flattened visible rows; hit-testing uses row geometry so virtualized rows stay selectable. */
|
|
25
|
+
rows: readonly FileTreeRow[];
|
|
26
|
+
/** Measured row heights from the virtual list; falls back to `FILE_TREE_ROW_HEIGHT` when omitted. */
|
|
27
|
+
rowMetrics?: FileTreeRowMetrics;
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
interface UseFileTreeMarqueeSelectionResult {
|
|
21
|
-
scrollRef: RefObject<
|
|
31
|
+
scrollRef: RefObject<HTMLElement | null>;
|
|
22
32
|
marquee: FileTreeMarqueeRect | null;
|
|
23
33
|
onMouseDown: (event: MouseEvent) => void;
|
|
24
34
|
}
|
|
@@ -28,17 +38,23 @@ const ROW_SELECTOR = "[data-file-path]";
|
|
|
28
38
|
|
|
29
39
|
/**
|
|
30
40
|
* Drag-select on empty space in the file tree scroll container.
|
|
31
|
-
* Intersects
|
|
41
|
+
* Intersects flattened row geometry. cmd/ctrl/shift = additive (base ∪ hits).
|
|
32
42
|
* Swallows the trailing click after a real marquee so row/background click handlers do not wipe the selection.
|
|
33
43
|
*/
|
|
34
44
|
export function useFileTreeMarqueeSelection({
|
|
35
45
|
selectedPaths,
|
|
36
46
|
onMarqueeSelect,
|
|
47
|
+
rows,
|
|
48
|
+
rowMetrics,
|
|
37
49
|
}: UseFileTreeMarqueeSelectionParams): UseFileTreeMarqueeSelectionResult {
|
|
38
|
-
const scrollRef = useRef<
|
|
50
|
+
const scrollRef = useRef<HTMLElement>(null);
|
|
39
51
|
const [marquee, setMarquee] = useState<FileTreeMarqueeRect | null>(null);
|
|
40
52
|
const selectedPathsRef = useRef(selectedPaths);
|
|
41
53
|
selectedPathsRef.current = selectedPaths;
|
|
54
|
+
const rowsRef = useRef(rows);
|
|
55
|
+
rowsRef.current = rows;
|
|
56
|
+
const rowMetricsRef = useRef(rowMetrics);
|
|
57
|
+
rowMetricsRef.current = rowMetrics;
|
|
42
58
|
|
|
43
59
|
const onMouseDown = useCallback(
|
|
44
60
|
(event: MouseEvent) => {
|
|
@@ -75,19 +91,11 @@ export function useFileTreeMarqueeSelection({
|
|
|
75
91
|
moved = true;
|
|
76
92
|
e.preventDefault();
|
|
77
93
|
setMarquee({ left, top, width, height });
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const ir = el.getBoundingClientRect();
|
|
84
|
-
const ix = ir.left - rect.left + container.scrollLeft;
|
|
85
|
-
const iy = ir.top - rect.top + container.scrollTop;
|
|
86
|
-
const intersects = ix < right && ix + ir.width > left && iy < bottom && iy + ir.height > top;
|
|
87
|
-
if (!intersects) continue;
|
|
88
|
-
const path = el.dataset.filePath;
|
|
89
|
-
if (path) hits.push(path);
|
|
90
|
-
}
|
|
94
|
+
const hits = hitTestFileTreeMarquee(
|
|
95
|
+
rowsRef.current,
|
|
96
|
+
{ left, top, width, height },
|
|
97
|
+
rowMetricsRef.current ?? FILE_TREE_ROW_HEIGHT,
|
|
98
|
+
);
|
|
91
99
|
onMarqueeSelect(additive ? [...new Set([...basePaths, ...hits])] : hits);
|
|
92
100
|
};
|
|
93
101
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeSurface } from "../appearance";
|
|
2
|
-
import { cn } from "@vetta-org/ui";
|
|
2
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
3
|
import { AnimatePresence, motion } from "motion/react";
|
|
4
4
|
import type { JSX, MouseEvent, ReactNode } from "react";
|
|
5
5
|
import {
|
|
@@ -36,7 +36,7 @@ export interface FilePreviewDialogViewProps {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function isImage(item: FilePreviewItem): boolean {
|
|
39
|
-
return IMAGE_EXTENSIONS.has(getExtension(item.name));
|
|
39
|
+
return item.kind === "image" || IMAGE_EXTENSIONS.has(getExtension(item.name));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { cn } from "@vetta-org/ui";
|
|
1
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
2
2
|
import { useCallback, useState, type JSX, type ReactNode } from "react";
|
|
3
3
|
import type { FilePreviewContext, FilePreviewItem } from "./types";
|
|
4
4
|
|
|
5
5
|
export interface FilePreviewViewLabels {
|
|
6
6
|
showTree: string;
|
|
7
7
|
hideTree: string;
|
|
8
|
+
locate?: string;
|
|
8
9
|
prev: string;
|
|
9
10
|
next: string;
|
|
10
11
|
download: string;
|
|
@@ -22,6 +23,8 @@ export interface FilePreviewViewProps {
|
|
|
22
23
|
canNext: boolean;
|
|
23
24
|
onToggleSidebar?: () => void;
|
|
24
25
|
sidebarCollapsed?: boolean;
|
|
26
|
+
/** 在文件树中定位当前文件。 */
|
|
27
|
+
onLocate?: (item: FilePreviewItem) => void;
|
|
25
28
|
onDownload?: (item: FilePreviewItem) => void;
|
|
26
29
|
/** Host builds body; refreshNonce increments on toolbar refresh. */
|
|
27
30
|
renderBody: (item: FilePreviewItem, refreshNonce: number) => ReactNode;
|
|
@@ -41,6 +44,7 @@ export function FilePreviewView({
|
|
|
41
44
|
canNext,
|
|
42
45
|
onToggleSidebar,
|
|
43
46
|
sidebarCollapsed,
|
|
47
|
+
onLocate,
|
|
44
48
|
onDownload,
|
|
45
49
|
renderBody,
|
|
46
50
|
}: FilePreviewViewProps): JSX.Element | null {
|
|
@@ -67,6 +71,7 @@ export function FilePreviewView({
|
|
|
67
71
|
canNext={canNavigate && canNext}
|
|
68
72
|
onToggleSidebar={onToggleSidebar}
|
|
69
73
|
sidebarCollapsed={sidebarCollapsed}
|
|
74
|
+
onLocate={onLocate}
|
|
70
75
|
onDownload={onDownload}
|
|
71
76
|
/>
|
|
72
77
|
{renderBody(item, refreshNonce)}
|
|
@@ -86,6 +91,7 @@ function Header({
|
|
|
86
91
|
canNext,
|
|
87
92
|
onToggleSidebar,
|
|
88
93
|
sidebarCollapsed,
|
|
94
|
+
onLocate,
|
|
89
95
|
onDownload,
|
|
90
96
|
}: {
|
|
91
97
|
item: FilePreviewItem;
|
|
@@ -99,6 +105,7 @@ function Header({
|
|
|
99
105
|
canNext: boolean;
|
|
100
106
|
onToggleSidebar?: () => void;
|
|
101
107
|
sidebarCollapsed?: boolean;
|
|
108
|
+
onLocate?: (item: FilePreviewItem) => void;
|
|
102
109
|
onDownload?: (item: FilePreviewItem) => void;
|
|
103
110
|
}): JSX.Element {
|
|
104
111
|
const downloadable = !!item.url;
|
|
@@ -106,7 +113,7 @@ function Header({
|
|
|
106
113
|
<div className="flex shrink-0 items-center gap-1.5 border-b border-border/40 py-1.5 pl-2 pr-3">
|
|
107
114
|
{onToggleSidebar && (
|
|
108
115
|
<HeaderButton
|
|
109
|
-
icon="icon-[
|
|
116
|
+
icon="icon-[solar--sidebar-minimalistic-linear]"
|
|
110
117
|
title={sidebarCollapsed ? labels.showTree : labels.hideTree}
|
|
111
118
|
onClick={onToggleSidebar}
|
|
112
119
|
/>
|
|
@@ -114,6 +121,9 @@ function Header({
|
|
|
114
121
|
<h2 className="-ml-0.5 min-w-0 flex-1 truncate text-[13px] font-semibold text-foreground">
|
|
115
122
|
{item.name}
|
|
116
123
|
</h2>
|
|
124
|
+
{onLocate && item.path && labels.locate && (
|
|
125
|
+
<HeaderButton icon="icon-[solar--gps-linear]" title={labels.locate} onClick={() => onLocate(item)} />
|
|
126
|
+
)}
|
|
117
127
|
{position && (
|
|
118
128
|
<span className="shrink-0 text-[11px] tabular-nums text-muted-foreground/70">{position}</span>
|
|
119
129
|
)}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ export function KnowledgeHowItWorksDialogView({
|
|
|
36
36
|
return (
|
|
37
37
|
<Dialog open={open} onOpenChange={(next) => !next && onClose()}>
|
|
38
38
|
<DialogContent className="gap-0 p-0 sm:max-w-[560px]">
|
|
39
|
-
<DialogHeader className="gap-3
|
|
39
|
+
<DialogHeader className="gap-3 px-6 pb-5 pt-6">
|
|
40
40
|
<div className="flex items-start gap-3.5">
|
|
41
41
|
<div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-inset ring-primary/15">
|
|
42
42
|
<span className="icon-[mdi--lightbulb-on-outline] h-5 w-5" />
|
package/src/layout/AppFrame.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
1
2
|
import type { ComponentPropsWithoutRef, JSX, ReactNode } from "react";
|
|
2
|
-
import { cn } from "@vetta-org/ui";
|
|
3
3
|
|
|
4
4
|
export interface AppFrameProps extends ComponentPropsWithoutRef<"div"> {
|
|
5
5
|
children: ReactNode;
|
|
@@ -18,7 +18,8 @@ export function AppFrame({
|
|
|
18
18
|
}: AppFrameProps): JSX.Element {
|
|
19
19
|
return (
|
|
20
20
|
<div
|
|
21
|
-
|
|
21
|
+
// hidden 仍允许 focus/scrollIntoView 滚动外框,连带抬高侧边栏;滚动只属于内部视口。
|
|
22
|
+
className={cn("relative isolate flex h-screen w-screen flex-col overflow-clip bg-background", className)}
|
|
22
23
|
{...props}
|
|
23
24
|
>
|
|
24
25
|
{decoration}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, JSX, ReactNode } from "react";
|
|
2
2
|
import { useThemeComponent } from "@vetta-org/theme-sdk";
|
|
3
|
-
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
4
|
|
|
5
5
|
export interface MainContentFrameProps extends ComponentPropsWithoutRef<"main"> {
|
|
6
6
|
children: ReactNode;
|
|
@@ -39,7 +39,12 @@ export function MainContentFrame({
|
|
|
39
39
|
{...props}
|
|
40
40
|
>
|
|
41
41
|
<ThemedMainContentBackground />
|
|
42
|
-
<div
|
|
42
|
+
<div
|
|
43
|
+
className={cn(
|
|
44
|
+
"main-content-header z-[2] shrink-0",
|
|
45
|
+
headerOverlay ? "absolute inset-x-0 top-0" : "relative z-[1]",
|
|
46
|
+
)}
|
|
47
|
+
>
|
|
43
48
|
{header}
|
|
44
49
|
</div>
|
|
45
50
|
<div className={cn("relative z-[1] flex min-h-0 flex-1 overflow-visible", contentClassName)}>
|
|
@@ -1,20 +1,74 @@
|
|
|
1
1
|
import { useCallback, useRef, type JSX, type PointerEvent as ReactPointerEvent } from "react";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* `side` 是「把手贴在被拉伸元素的哪条边上」,不是拖拽方向。
|
|
5
|
+
* 语义统一为:正的 delta 让元素变大,所以贴在起始边(left / top)上的把手要取反。
|
|
6
|
+
*/
|
|
7
|
+
export type ResizeHandleSide = "left" | "right" | "top" | "bottom";
|
|
8
|
+
|
|
3
9
|
export interface ResizeHandleProps {
|
|
4
|
-
side:
|
|
10
|
+
side: ResizeHandleSide;
|
|
5
11
|
onResizeStart?: () => void;
|
|
6
12
|
onResize: (delta: number) => void;
|
|
7
13
|
onResizeEnd?: () => void;
|
|
8
14
|
}
|
|
9
15
|
|
|
16
|
+
export interface ResizeHandleAxis {
|
|
17
|
+
readonly vertical: boolean;
|
|
18
|
+
/** Tailwind 类名必须是字面量,所以光标分成类名与 overlay 用的原始值两份。 */
|
|
19
|
+
readonly cursorClass: string;
|
|
20
|
+
readonly overlayCursor: string;
|
|
21
|
+
readonly edge: string;
|
|
22
|
+
readonly track: string;
|
|
23
|
+
readonly line: string;
|
|
24
|
+
readonly glow: string;
|
|
25
|
+
readonly gradientDirection: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function resolveResizeHandleAxis(side: ResizeHandleSide): ResizeHandleAxis {
|
|
29
|
+
if (side === "top" || side === "bottom") {
|
|
30
|
+
return {
|
|
31
|
+
vertical: true,
|
|
32
|
+
cursorClass: "cursor-row-resize",
|
|
33
|
+
overlayCursor: "row-resize",
|
|
34
|
+
edge: side === "top" ? "top-0" : "bottom-0",
|
|
35
|
+
track: "left-0 right-0 h-[8px]",
|
|
36
|
+
line: "h-px w-[60%] left-1/2 -translate-x-1/2",
|
|
37
|
+
glow: "h-[5px] w-[55%] left-1/2 -translate-x-1/2 blur-[4px]",
|
|
38
|
+
gradientDirection: "to right",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
vertical: false,
|
|
43
|
+
cursorClass: "cursor-col-resize",
|
|
44
|
+
overlayCursor: "col-resize",
|
|
45
|
+
edge: side === "right" ? "right-0" : "left-0",
|
|
46
|
+
track: "top-0 bottom-0 w-[8px]",
|
|
47
|
+
line: "w-px h-[60%] top-1/2 -translate-y-1/2",
|
|
48
|
+
glow: "w-[5px] h-[55%] top-1/2 -translate-y-1/2 blur-[4px]",
|
|
49
|
+
gradientDirection: "to bottom",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 把指针位移折算成「元素该变大多少」。
|
|
55
|
+
* 贴在起始边(left / top)上的把手要取反:往左/上拖才是变大。
|
|
56
|
+
*/
|
|
57
|
+
export function resizeHandleDelta(side: ResizeHandleSide, pointerDelta: number): number {
|
|
58
|
+
return side === "right" || side === "bottom" ? pointerDelta : -pointerDelta;
|
|
59
|
+
}
|
|
60
|
+
|
|
10
61
|
export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd }: ResizeHandleProps): JSX.Element {
|
|
11
|
-
const
|
|
62
|
+
const startRef = useRef(0);
|
|
63
|
+
const axis = resolveResizeHandleAxis(side);
|
|
12
64
|
|
|
13
65
|
const onPointerDown = useCallback(
|
|
14
66
|
(e: ReactPointerEvent) => {
|
|
15
67
|
e.preventDefault();
|
|
16
68
|
onResizeStart?.();
|
|
17
|
-
|
|
69
|
+
const readPosition = (event: { clientX: number; clientY: number }) =>
|
|
70
|
+
axis.vertical ? event.clientY : event.clientX;
|
|
71
|
+
startRef.current = readPosition(e);
|
|
18
72
|
let pendingDelta = 0;
|
|
19
73
|
let animationFrame: number | null = null;
|
|
20
74
|
|
|
@@ -32,14 +86,14 @@ export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd }: Res
|
|
|
32
86
|
overlay.style.position = "fixed";
|
|
33
87
|
overlay.style.inset = "0";
|
|
34
88
|
overlay.style.zIndex = "9999";
|
|
35
|
-
overlay.style.cursor =
|
|
89
|
+
overlay.style.cursor = axis.overlayCursor;
|
|
36
90
|
document.body.appendChild(overlay);
|
|
37
91
|
|
|
38
92
|
const onPointerMove = (ev: PointerEvent) => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
pendingDelta += side
|
|
93
|
+
const position = readPosition(ev);
|
|
94
|
+
const delta = position - startRef.current;
|
|
95
|
+
startRef.current = position;
|
|
96
|
+
pendingDelta += resizeHandleDelta(side, delta);
|
|
43
97
|
if (animationFrame === null) animationFrame = requestAnimationFrame(flushResize);
|
|
44
98
|
};
|
|
45
99
|
|
|
@@ -57,14 +111,11 @@ export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd }: Res
|
|
|
57
111
|
document.addEventListener("pointerup", onPointerUp);
|
|
58
112
|
document.body.style.userSelect = "none";
|
|
59
113
|
},
|
|
60
|
-
[side, onResizeStart, onResize, onResizeEnd],
|
|
114
|
+
[axis.overlayCursor, axis.vertical, side, onResizeStart, onResize, onResizeEnd],
|
|
61
115
|
);
|
|
62
116
|
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
"linear-gradient(to bottom, transparent, color-mix(in srgb, var(--primary) 28%, transparent) 50%, transparent)";
|
|
66
|
-
const glowGradient =
|
|
67
|
-
"linear-gradient(to bottom, transparent, color-mix(in srgb, var(--primary) 15%, transparent) 50%, transparent)";
|
|
117
|
+
const lineGradient = `linear-gradient(${axis.gradientDirection}, transparent, color-mix(in srgb, var(--primary) 28%, transparent) 50%, transparent)`;
|
|
118
|
+
const glowGradient = `linear-gradient(${axis.gradientDirection}, transparent, color-mix(in srgb, var(--primary) 15%, transparent) 50%, transparent)`;
|
|
68
119
|
const fadeStyle = {
|
|
69
120
|
transition: "opacity 380ms cubic-bezier(0.22, 0.61, 0.36, 1)",
|
|
70
121
|
willChange: "opacity",
|
|
@@ -74,16 +125,16 @@ export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd }: Res
|
|
|
74
125
|
<div
|
|
75
126
|
data-resize-handle={side}
|
|
76
127
|
onPointerDown={onPointerDown}
|
|
77
|
-
className={`group absolute
|
|
128
|
+
className={`group absolute z-30 ${axis.cursorClass} ${axis.track} ${axis.edge}`}
|
|
78
129
|
>
|
|
79
130
|
<div
|
|
80
131
|
aria-hidden
|
|
81
|
-
className={`pointer-events-none absolute ${edge}
|
|
132
|
+
className={`pointer-events-none absolute ${axis.edge} ${axis.glow} rounded-full opacity-0 group-hover:opacity-100 group-active:opacity-100`}
|
|
82
133
|
style={{ ...fadeStyle, background: glowGradient }}
|
|
83
134
|
/>
|
|
84
135
|
<div
|
|
85
136
|
aria-hidden
|
|
86
|
-
className={`pointer-events-none absolute ${edge}
|
|
137
|
+
className={`pointer-events-none absolute ${axis.edge} ${axis.line} opacity-0 group-hover:opacity-100 group-active:opacity-100`}
|
|
87
138
|
style={{ ...fadeStyle, background: lineGradient }}
|
|
88
139
|
/>
|
|
89
140
|
</div>
|