zidane-ui 9.3.1 → 9.4.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/dist/adapters/live.d.ts +2 -0
- package/dist/adapters/live.js +3 -0
- package/dist/adapters/server-git-host.js +5 -2
- package/dist/adapters/server-host.js +17 -11
- package/dist/adapters/server-machines-host.js +7 -0
- package/dist/adapters/server-session-host.js +49 -0
- package/dist/adapters/server-settings-sections.js +4 -1
- package/dist/adapters/sse-host.js +3 -0
- package/dist/adapters/sse-protocol.d.ts +10 -0
- package/dist/appearance/ZoomIndicator.js +5 -8
- package/dist/chat/HostTranscript.js +15 -1
- package/dist/chat/SessionStreamsProvider.d.ts +1 -1
- package/dist/chat/Transcript.d.ts +3 -2
- package/dist/chat/Transcript.js +26 -7
- package/dist/chat/composer/ComposerEditor.js +1 -1
- package/dist/chat/composer/ModelOptionsPicker.js +6 -2
- package/dist/chat/composer/ModelPicker.d.ts +1 -1
- package/dist/chat/composer/PlacePicker.d.ts +3 -1
- package/dist/chat/composer/PlacePicker.js +5 -1
- package/dist/chat/composer/use-draft-target.js +15 -3
- package/dist/chat/headless/block-runs.js +26 -1
- package/dist/chat/headless/chip-views.js +1 -1
- package/dist/chat/headless/draft-target.d.ts +28 -1
- package/dist/chat/headless/draft-target.js +22 -1
- package/dist/chat/headless/hosts.d.ts +4 -0
- package/dist/chat/headless/index.d.ts +25 -25
- package/dist/chat/headless/index.js +6 -6
- package/dist/chat/headless/markdown-scan.d.ts +0 -2
- package/dist/chat/headless/markdown-scan.js +3 -8
- package/dist/chat/headless/markdown-stream.js +3 -3
- package/dist/chat/headless/prompt-origin.d.ts +2 -0
- package/dist/chat/headless/prompt-origin.js +6 -2
- package/dist/chat/headless/sidebar/directory.d.ts +10 -1
- package/dist/chat/headless/sidebar/directory.js +9 -1
- package/dist/chat/headless/sidebar/environment.d.ts +15 -4
- package/dist/chat/headless/sidebar/environment.js +27 -9
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/index.js +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +9 -2
- package/dist/chat/headless/sidebar/labels.js +8 -1
- package/dist/chat/headless/streams/actions.d.ts +2 -2
- package/dist/chat/headless/streams/actions.js +1 -1
- package/dist/chat/headless/streams/event-bytes.d.ts +12 -1
- package/dist/chat/headless/streams/event-bytes.js +13 -1
- package/dist/chat/headless/streams/store.d.ts +21 -5
- package/dist/chat/headless/streams/store.js +36 -7
- package/dist/chat/headless/streams/transcript-map.js +2 -5
- package/dist/chat/headless/streams/types.d.ts +2 -1
- package/dist/chat/headless/transcript/collapse.js +3 -0
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/index.js +2 -2
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.js +2 -2
- package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
- package/dist/chat/sidebar/SessionSidebar.js +23 -16
- package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
- package/dist/chat/sidebar/SidebarFold.js +17 -16
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
- package/dist/chat/sidebar/session-menu.d.ts +4 -0
- package/dist/chat/sidebar/session-menu.js +14 -2
- package/dist/chat/sidebar/sidebar-live.js +28 -4
- package/dist/chat/sidebar/useInboxRows.js +6 -6
- package/dist/chat/sidebar/useInboxTriage.js +50 -47
- package/dist/chat/sidebar/useSessionSearch.js +19 -18
- package/dist/chat/transcript/FileChip.js +28 -0
- package/dist/chat/transcript/LazyRow.d.ts +1 -1
- package/dist/chat/transcript/LazyRow.js +3 -4
- package/dist/chat/transcript/PromptEcho.js +3 -11
- package/dist/chat/transcript/SessionChip.d.ts +11 -0
- package/dist/chat/transcript/SessionChip.js +34 -0
- package/dist/chat/transcript/TranscriptRail.d.ts +1 -1
- package/dist/chat/transcript/chip-details.d.ts +11 -0
- package/dist/chat/transcript/chip-details.js +17 -1
- package/dist/chat/transcript/fold-worker.js +2 -1
- package/dist/chat/transcript/fold.js +11 -3
- package/dist/chat/transcript/index.d.ts +2 -2
- package/dist/chat/transcript/index.js +2 -2
- package/dist/chat/transcript/markdown-cache.d.ts +10 -1
- package/dist/chat/transcript/markdown-cache.js +37 -4
- package/dist/chat/transcript/markdown.js +27 -34
- package/dist/chat/transcript/media-gallery.js +13 -16
- package/dist/chat/transcript/messages.js +5 -4
- package/dist/chat/transcript/prompt.d.ts +1 -1
- package/dist/chat/transcript/row-mount.d.ts +27 -8
- package/dist/chat/transcript/row-mount.js +114 -80
- package/dist/chat/transcript/row-parking.d.ts +27 -0
- package/dist/chat/transcript/row-parking.js +37 -1
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/tool-parts.js +0 -1
- package/dist/chat/transcript/use-transcript-rows.d.ts +1 -1
- package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
- package/dist/chat/transcript/useHistoryBackfill.js +170 -0
- package/dist/chat/transcript/useTranscriptFind.js +2 -4
- package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
- package/dist/chat/transcript/useTranscriptScroll.js +12 -1
- package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
- package/dist/chat/transcript/useTranscriptSearch.js +6 -6
- package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
- package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
- package/dist/code/editor/FileTree.d.ts +2 -0
- package/dist/code/editor/FileTree.js +1 -1
- package/dist/code/editor/FileView.js +16 -25
- package/dist/code/editor/find/useFind.js +17 -17
- package/dist/code/editor/useCodeDocument.js +22 -19
- package/dist/code/editor/useDetachCleanup.js +4 -3
- package/dist/code/use-highlighted-html.js +12 -13
- package/dist/components/IconButton.d.ts +3 -1
- package/dist/components/IconButton.js +7 -2
- package/dist/components/IconButtonTip.d.ts +3 -1
- package/dist/components/IconButtonTip.js +2 -1
- package/dist/components/RowActionsMenu.js +7 -14
- package/dist/components/Tooltip.d.ts +4 -1
- package/dist/components/Tooltip.js +8 -6
- package/dist/components/assign-ref.d.ts +8 -0
- package/dist/components/assign-ref.js +12 -0
- package/dist/components/floating/FloatingSurface.js +2 -2
- package/dist/components/floating/HoverCard.js +32 -14
- package/dist/components/floating/Popover.js +4 -7
- package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
- package/dist/components/floating/useAnchoredPosition.js +7 -7
- package/dist/components/object-key.d.ts +7 -0
- package/dist/components/object-key.js +18 -0
- package/dist/components/palette/PaletteList.js +2 -7
- package/dist/components/tooltip-arming.d.ts +3 -0
- package/dist/components/tooltip-arming.js +8 -1
- package/dist/core.css +3 -3
- package/dist/dist/{index-C6-t1SS9.d.ts → index-BheVJOLc.d.ts} +1 -0
- package/dist/dist/index.d.ts +2 -2
- package/dist/files/FilesTab.js +0 -1
- package/dist/files/TreeColumn.d.ts +2 -4
- package/dist/files/TreeColumn.js +0 -5
- package/dist/files/headless/host.d.ts +3 -7
- package/dist/files/headless/labels.d.ts +0 -1
- package/dist/files/headless/labels.js +0 -1
- package/dist/files/headless/workspace-diff.js +1 -1
- package/dist/files/useCodeReview.js +1 -3
- package/dist/files/useFilesDiagnostics.d.ts +1 -1
- package/dist/files/useFilesDiagnostics.js +4 -11
- package/dist/files/useOpenFiles.js +9 -12
- package/dist/files/useWorkspace.d.ts +5 -7
- package/dist/files/useWorkspace.js +4 -15
- package/dist/git/GitBar.js +5 -3
- package/dist/git/MoveSessionDialog.d.ts +18 -8
- package/dist/git/MoveSessionDialog.js +32 -53
- package/dist/git/MoveToDialog.d.ts +61 -0
- package/dist/git/MoveToDialog.js +240 -0
- package/dist/git/SandboxManager.js +9 -4
- package/dist/git/SyncChip.js +11 -4
- package/dist/git/TeleportSessionDialog.d.ts +69 -0
- package/dist/git/TeleportSessionDialog.js +440 -0
- package/dist/git/headless/host.d.ts +14 -0
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +44 -1
- package/dist/git/headless/labels.js +50 -0
- package/dist/git/headless/sandboxes.d.ts +1 -1
- package/dist/git/headless/sandboxes.js +4 -3
- package/dist/git/headless/teleport.d.ts +76 -0
- package/dist/git/headless/teleport.js +19 -0
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +4 -2
- package/dist/git/useEnvironmentChoices.d.ts +5 -2
- package/dist/git/useEnvironmentChoices.js +12 -4
- package/dist/hooks/useLatest.d.ts +8 -0
- package/dist/hooks/useLatest.js +17 -0
- package/dist/hooks/useMinuteTick.d.ts +6 -2
- package/dist/hooks/useMinuteTick.js +12 -6
- package/dist/hooks/useNearViewport.js +11 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/keybindings/KeybindingsProvider.js +3 -4
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +18 -0
- package/dist/machines/AddServerForm.js +55 -3
- package/dist/machines/Banners.d.ts +2 -2
- package/dist/machines/Banners.js +3 -3
- package/dist/machines/DaemonMenu.js +1 -3
- package/dist/machines/HostsSection.js +5 -1
- package/dist/machines/OrganizationPanel.d.ts +25 -0
- package/dist/machines/OrganizationPanel.js +266 -0
- package/dist/machines/PersonalLayerPanel.d.ts +32 -0
- package/dist/machines/PersonalLayerPanel.js +360 -0
- package/dist/machines/headless/fixture-host.d.ts +10 -0
- package/dist/machines/headless/fixture-host.js +44 -0
- package/dist/machines/headless/host.d.ts +21 -1
- package/dist/machines/headless/index.d.ts +3 -1
- package/dist/machines/headless/index.js +3 -1
- package/dist/machines/headless/labels.d.ts +55 -0
- package/dist/machines/headless/labels.js +58 -1
- package/dist/machines/headless/layer.d.ts +64 -0
- package/dist/machines/headless/layer.js +56 -0
- package/dist/machines/headless/organization.d.ts +38 -0
- package/dist/machines/headless/organization.js +44 -0
- package/dist/machines/index.d.ts +3 -1
- package/dist/machines/index.js +3 -1
- package/dist/machines/testing/contract.d.ts +25 -1
- package/dist/machines/testing/contract.js +97 -1
- package/dist/motion/grow.js +12 -13
- package/dist/motion/swap.js +2 -5
- package/dist/motion/use-flip-list.d.ts +14 -0
- package/dist/motion/use-flip-list.js +17 -12
- package/dist/palette/headless/app-sources.js +37 -0
- package/dist/palette/headless/labels.js +3 -0
- package/dist/server/sse-handler.js +25 -2
- package/dist/session/DiffFileTree.js +1 -4
- package/dist/session/OpenSessionsDialog.d.ts +46 -0
- package/dist/session/OpenSessionsDialog.js +170 -0
- package/dist/session/PlanTracker.js +1 -2
- package/dist/session/ProjectHome.js +10 -9
- package/dist/session/RemindersPanel.js +10 -12
- package/dist/session/SecretsPanel.js +2 -1
- package/dist/session/SessionPeopleStack.d.ts +23 -0
- package/dist/session/SessionPeopleStack.js +65 -0
- package/dist/session/SessionPlaceMenu.js +5 -4
- package/dist/session/ShareSessionDialog.d.ts +32 -0
- package/dist/session/ShareSessionDialog.js +342 -0
- package/dist/session/TypingLine.d.ts +22 -0
- package/dist/session/TypingLine.js +31 -0
- package/dist/session/headless/host.d.ts +40 -1
- package/dist/session/headless/index.d.ts +4 -2
- package/dist/session/headless/index.js +3 -1
- package/dist/session/headless/labels.d.ts +49 -0
- package/dist/session/headless/labels.js +56 -0
- package/dist/session/headless/people.d.ts +29 -0
- package/dist/session/headless/people.js +53 -0
- package/dist/session/headless/place.d.ts +5 -0
- package/dist/session/headless/place.js +5 -1
- package/dist/session/headless/typing.d.ts +37 -0
- package/dist/session/headless/typing.js +60 -0
- package/dist/session/index.d.ts +5 -1
- package/dist/session/index.js +5 -1
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/headless/sections-host.d.ts +7 -2
- package/dist/settings/section.d.ts +15 -3
- package/dist/settings/section.js +15 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
- package/dist/settings/sections/keybindings/labels.d.ts +3 -0
- package/dist/settings/sections/keybindings/labels.js +3 -0
- package/dist/settings/sections/keybindings/rows.js +12 -0
- package/dist/settings/sections/logs/LogsSection.js +5 -8
- package/dist/styles.css +32 -7
- package/dist/terminal/HostTerminalSurface.js +28 -30
- package/dist/terminal/TerminalPanel.js +4 -12
- package/dist/terminal/TerminalProvider.d.ts +10 -2
- package/dist/terminal/TerminalProvider.js +10 -2
- package/dist/terminal/headless/labels.d.ts +0 -1
- package/dist/terminal/headless/labels.js +1 -2
- package/dist/terminal/headless/store.js +5 -1
- package/dist/workspace/LayoutBudget.js +1 -7
- package/package.json +2 -2
- package/src/styles/chat.css +3 -1
- package/src/styles/palette.css +3 -3
- package/src/styles/transcript.css +17 -3
- /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useFillViewportScrollback } from "./EarlierHistory.js";
|
|
2
2
|
import { createRecentMap } from "./recent-map.js";
|
|
3
|
+
import { useHistoryBackfill } from "./useHistoryBackfill.js";
|
|
3
4
|
import { useStickToBottom } from "./useStickToBottom.js";
|
|
4
5
|
import { useWheelHoverPause } from "./useWheelHoverPause.js";
|
|
5
6
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -21,7 +22,7 @@ const positions = createRecentMap(500);
|
|
|
21
22
|
* @param hydrated - Its events have loaded.
|
|
22
23
|
* @param inputs - The {@link TranscriptScrollInputs}.
|
|
23
24
|
*/
|
|
24
|
-
function useTranscriptScroll(sessionId, hydrated, { page, loadEarlier, selecting, keepPosition }) {
|
|
25
|
+
function useTranscriptScroll(sessionId, hydrated, { page, loadEarlier, selecting, keepPosition, eventBytes }) {
|
|
25
26
|
const scrollRef = useRef(null);
|
|
26
27
|
const { pinned, snapToBottom, glideToBottom, readPosition, restorePosition } = useStickToBottom(scrollRef, { paused: selecting });
|
|
27
28
|
useWheelHoverPause(scrollRef);
|
|
@@ -121,6 +122,16 @@ function useTranscriptScroll(sessionId, hydrated, { page, loadEarlier, selecting
|
|
|
121
122
|
loadEarlier,
|
|
122
123
|
slackPx: LOAD_EARLIER_PX
|
|
123
124
|
});
|
|
125
|
+
useHistoryBackfill(sessionId, {
|
|
126
|
+
ready: hydrated,
|
|
127
|
+
hasMore: page.hasMore,
|
|
128
|
+
loading: page.loadingEarlier,
|
|
129
|
+
loaded: page.firstSeq,
|
|
130
|
+
load: () => {
|
|
131
|
+
if (sessionId) loadEarlier(sessionId);
|
|
132
|
+
},
|
|
133
|
+
bytes: sessionId && eventBytes ? () => eventBytes(sessionId) : void 0
|
|
134
|
+
});
|
|
124
135
|
return {
|
|
125
136
|
scrollRef,
|
|
126
137
|
pinned,
|
|
@@ -44,12 +44,12 @@ export interface TranscriptSearchOptions {
|
|
|
44
44
|
* the user away from the match they're reading. Only a needle CHANGE
|
|
45
45
|
* scrolls.
|
|
46
46
|
*
|
|
47
|
-
* @param
|
|
47
|
+
* @param containerRef - The transcript's scroll container.
|
|
48
48
|
* @param query - The query as typed.
|
|
49
49
|
* @param revision - Changes identity when the transcript re-renders.
|
|
50
50
|
* @param options - The {@link TranscriptSearchOptions}.
|
|
51
51
|
*/
|
|
52
|
-
export declare function useTranscriptSearch(
|
|
52
|
+
export declare function useTranscriptSearch(containerRef: React.RefObject<HTMLElement | null>, query: string, revision: unknown, { terms, revealFirstMatch }?: TranscriptSearchOptions): TranscriptSearchState;
|
|
53
53
|
/**
|
|
54
54
|
* The `::highlight()` color rules, resolved once per mount.
|
|
55
55
|
* `::highlight()` pseudos can't reliably resolve CSS custom properties
|
|
@@ -141,12 +141,12 @@ function scrollToRange(range, root) {
|
|
|
141
141
|
* the user away from the match they're reading. Only a needle CHANGE
|
|
142
142
|
* scrolls.
|
|
143
143
|
*
|
|
144
|
-
* @param
|
|
144
|
+
* @param containerRef - The transcript's scroll container.
|
|
145
145
|
* @param query - The query as typed.
|
|
146
146
|
* @param revision - Changes identity when the transcript re-renders.
|
|
147
147
|
* @param options - The {@link TranscriptSearchOptions}.
|
|
148
148
|
*/
|
|
149
|
-
function useTranscriptSearch(
|
|
149
|
+
function useTranscriptSearch(containerRef, query, revision, { terms, revealFirstMatch = false } = {}) {
|
|
150
150
|
const [needle, setNeedle] = useState(NO_NEEDLE);
|
|
151
151
|
const [matches, setMatches] = useState({
|
|
152
152
|
count: 0,
|
|
@@ -193,7 +193,7 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
193
193
|
}, []);
|
|
194
194
|
useEffect(() => {
|
|
195
195
|
const owner = ownerRef.current;
|
|
196
|
-
const root =
|
|
196
|
+
const root = containerRef.current;
|
|
197
197
|
if (searching && !rowsMounted) return;
|
|
198
198
|
const needleChanged = prevNeedleRef.current !== needle.key;
|
|
199
199
|
if (needleChanged && prevNeedleRef.current !== "") revealArmed.current = false;
|
|
@@ -243,7 +243,7 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
243
243
|
needle,
|
|
244
244
|
searching,
|
|
245
245
|
revision,
|
|
246
|
-
|
|
246
|
+
containerRef,
|
|
247
247
|
rowsMounted
|
|
248
248
|
]);
|
|
249
249
|
/** Highlights are registered document-wide — drop ours on unmount. */
|
|
@@ -257,8 +257,8 @@ function useTranscriptSearch(container, query, revision, { terms, revealFirstMat
|
|
|
257
257
|
const next = (activeIndexRef.current + direction + ranges.length) % ranges.length;
|
|
258
258
|
setActiveIndex(next);
|
|
259
259
|
setHighlights(ownerRef.current, ranges, next);
|
|
260
|
-
scrollToRange(ranges[next],
|
|
261
|
-
}, []);
|
|
260
|
+
scrollToRange(ranges[next], containerRef.current);
|
|
261
|
+
}, [containerRef]);
|
|
262
262
|
return {
|
|
263
263
|
count: matches.count,
|
|
264
264
|
capped: matches.capped,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On
|
|
3
|
-
* mouseup inside the timeline, if the live
|
|
4
|
-
* transcript and is non-empty, write its
|
|
5
|
-
* clipboard. Debounced via `lastCopiedRef` so
|
|
6
|
-
* selection doesn't spam the clipboard.
|
|
2
|
+
* Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On a
|
|
3
|
+
* mouseup that ends a drag begun inside the timeline, if the live
|
|
4
|
+
* selection intersects the transcript and is non-empty, write its
|
|
5
|
+
* plain-text contents to the clipboard. Debounced via `lastCopiedRef` so
|
|
6
|
+
* dragging across the same selection doesn't spam the clipboard.
|
|
7
7
|
*
|
|
8
8
|
* Web equivalent of the TUI's OSC-52 path. We don't subscribe to
|
|
9
9
|
* `selectionchange` directly because that event fires per-character
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
// src/chat/transcript/useTranscriptSelectionCopy.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
4
|
+
* How far the pointer moves between press and release before it counts as a
|
|
5
|
+
* drag. Below it, a release is a click, even when the browser widens a double
|
|
6
|
+
* or triple click to a word or a line: clicking a row twice to open it must
|
|
7
|
+
* not copy its first word.
|
|
8
|
+
*/
|
|
9
|
+
const DRAG_SLOP_PX = 4;
|
|
10
|
+
/**
|
|
11
|
+
* Drag-select transcript copy — mirrors the TUI's OSC-52 hook. On a
|
|
12
|
+
* mouseup that ends a drag begun inside the timeline, if the live
|
|
13
|
+
* selection intersects the transcript and is non-empty, write its
|
|
14
|
+
* plain-text contents to the clipboard. Debounced via `lastCopiedRef` so
|
|
15
|
+
* dragging across the same selection doesn't spam the clipboard.
|
|
9
16
|
*
|
|
10
17
|
* Web equivalent of the TUI's OSC-52 path. We don't subscribe to
|
|
11
18
|
* `selectionchange` directly because that event fires per-character
|
|
@@ -18,7 +25,17 @@ function useTranscriptSelectionCopy(containerRef) {
|
|
|
18
25
|
useEffect(() => {
|
|
19
26
|
const root = containerRef.current;
|
|
20
27
|
if (!root) return;
|
|
21
|
-
|
|
28
|
+
let press = null;
|
|
29
|
+
const onMouseDown = (event) => {
|
|
30
|
+
press = {
|
|
31
|
+
x: event.clientX,
|
|
32
|
+
y: event.clientY
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const onMouseUp = (event) => {
|
|
36
|
+
const from = press;
|
|
37
|
+
press = null;
|
|
38
|
+
if (!from || Math.hypot(event.clientX - from.x, event.clientY - from.y) < DRAG_SLOP_PX) return;
|
|
22
39
|
window.setTimeout(() => {
|
|
23
40
|
const selection = window.getSelection();
|
|
24
41
|
if (!selection || selection.isCollapsed) return;
|
|
@@ -31,8 +48,12 @@ function useTranscriptSelectionCopy(containerRef) {
|
|
|
31
48
|
navigator.clipboard.writeText(text).catch(() => {});
|
|
32
49
|
}, 0);
|
|
33
50
|
};
|
|
51
|
+
root.addEventListener("mousedown", onMouseDown);
|
|
34
52
|
root.addEventListener("mouseup", onMouseUp);
|
|
35
|
-
return () =>
|
|
53
|
+
return () => {
|
|
54
|
+
root.removeEventListener("mousedown", onMouseDown);
|
|
55
|
+
root.removeEventListener("mouseup", onMouseUp);
|
|
56
|
+
};
|
|
36
57
|
}, [containerRef]);
|
|
37
58
|
}
|
|
38
59
|
export { useTranscriptSelectionCopy };
|
|
@@ -28,6 +28,8 @@ export interface TreeEntry {
|
|
|
28
28
|
kind: 'file' | 'dir';
|
|
29
29
|
/** Dimmed (gitignored). */
|
|
30
30
|
ignored?: boolean;
|
|
31
|
+
/** A folder whose contents are listed when it opens (`onExpandFolder`). */
|
|
32
|
+
deferred?: boolean;
|
|
31
33
|
}
|
|
32
34
|
/** A path's git status, painted on its row. */
|
|
33
35
|
export interface TreeGitStatus {
|
|
@@ -77,7 +77,7 @@ function FileTree({ controlRef, entries, gitStatus, selectedPath, onSelect, onOp
|
|
|
77
77
|
} }
|
|
78
78
|
} : {}
|
|
79
79
|
});
|
|
80
|
-
const lazyDirs = useMemo(() => entries.filter((e) => e.ignored && e.kind === "dir" && e.path.endsWith("/")).map((e) => e.path), [entries]);
|
|
80
|
+
const lazyDirs = useMemo(() => entries.filter((e) => (e.ignored || e.deferred) && e.kind === "dir" && e.path.endsWith("/")).map((e) => e.path), [entries]);
|
|
81
81
|
const lazyRef = useRef({
|
|
82
82
|
dirs: lazyDirs,
|
|
83
83
|
onExpandFolder
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLatest } from "../../hooks/useLatest.js";
|
|
1
2
|
import { useEditorEnvironment } from "./environment.js";
|
|
2
3
|
import { DIFFS_HOST_STYLE, DIFFS_UNSAFE_CSS, PREFERRED_HIGHLIGHTER, VIRTUALIZER_CONFIG } from "./pierre-theme.js";
|
|
3
4
|
import { revealOnHighlight } from "./reveal.js";
|
|
@@ -21,7 +22,7 @@ function FileViewInner({ name, contents, wrap = false, hideHeader = false, selec
|
|
|
21
22
|
const { shikiTheme: theme, appearance } = useEditorEnvironment();
|
|
22
23
|
const selectable = onSelectionEnd !== void 0;
|
|
23
24
|
const host = useDetachCleanup();
|
|
24
|
-
const latest =
|
|
25
|
+
const latest = useLatest({
|
|
25
26
|
onSelectionEnd,
|
|
26
27
|
onGutterAction,
|
|
27
28
|
onTokenEnter,
|
|
@@ -32,48 +33,38 @@ function FileViewInner({ name, contents, wrap = false, hideHeader = false, selec
|
|
|
32
33
|
edit,
|
|
33
34
|
wrap
|
|
34
35
|
});
|
|
35
|
-
latest.current = {
|
|
36
|
-
onSelectionEnd,
|
|
37
|
-
onGutterAction,
|
|
38
|
-
onTokenEnter,
|
|
39
|
-
onTokenLeave,
|
|
40
|
-
onTokenClick,
|
|
41
|
-
onHighlighted,
|
|
42
|
-
renderAnnotation,
|
|
43
|
-
edit,
|
|
44
|
-
wrap
|
|
45
|
-
};
|
|
46
36
|
const highlightedOnce = useRef(false);
|
|
47
37
|
const words = useMemo(() => wordHover({
|
|
48
|
-
enter: (t, e) => latest.
|
|
49
|
-
leave: () => latest.
|
|
50
|
-
}), []);
|
|
38
|
+
enter: (t, e) => latest().onTokenEnter?.(t, e),
|
|
39
|
+
leave: () => latest().onTokenLeave?.()
|
|
40
|
+
}), [latest]);
|
|
51
41
|
const stable = useMemo(() => ({
|
|
52
|
-
onLineSelectionEnd: (r) => latest.
|
|
53
|
-
onGutterUtilityClick: (r) => latest.
|
|
42
|
+
onLineSelectionEnd: (r) => latest().onSelectionEnd?.(r),
|
|
43
|
+
onGutterUtilityClick: (r) => latest().onGutterAction?.(r),
|
|
54
44
|
onTokenEnter: (t, e) => words.enter(t, e),
|
|
55
45
|
onTokenLeave: () => words.leave(),
|
|
56
46
|
onTokenClick: (t, e) => {
|
|
57
47
|
const token = words.token(t, e.clientX, e.clientY);
|
|
58
|
-
if (token) latest.
|
|
48
|
+
if (token) latest().onTokenClick?.(token, e);
|
|
59
49
|
},
|
|
60
|
-
renderAnnotation: (a) => latest.
|
|
61
|
-
onEditChange: (e) => latest.
|
|
50
|
+
renderAnnotation: (a) => latest().renderAnnotation?.(a) ?? null,
|
|
51
|
+
onEditChange: (e) => latest().edit?.onChange(e.file.contents, e.changes.map((c) => ({
|
|
62
52
|
range: c.range,
|
|
63
53
|
text: c.text
|
|
64
54
|
}))),
|
|
65
|
-
onEditComplete: (e) => latest.
|
|
55
|
+
onEditComplete: (e) => latest().edit?.onComplete?.(e) ?? "reject",
|
|
66
56
|
onPostRender: (node, instance, phase) => {
|
|
67
57
|
const highlighted = phase !== "unmount" && isHighlighted(instance, node);
|
|
68
58
|
revealOnHighlight(node, highlighted, phase, phase !== "unmount" && colorsFile(instance));
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
const current = latest();
|
|
60
|
+
scrollReachOnRender(node, !current.wrap, phase);
|
|
61
|
+
if (phase === "unmount" || highlightedOnce.current || !current.onHighlighted) return;
|
|
71
62
|
if (highlighted) {
|
|
72
63
|
highlightedOnce.current = true;
|
|
73
|
-
|
|
64
|
+
current.onHighlighted();
|
|
74
65
|
}
|
|
75
66
|
}
|
|
76
|
-
}), [words]);
|
|
67
|
+
}), [words, latest]);
|
|
77
68
|
const hasTokenHandlers = onTokenEnter !== void 0;
|
|
78
69
|
const hasTokenClick = onTokenClick !== void 0;
|
|
79
70
|
const hasGutter = onGutterAction !== void 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLatest } from "../../../hooks/useLatest.js";
|
|
1
2
|
import { clearFind, paintFind, rowOf } from "./find-highlight.js";
|
|
2
3
|
import { findAll } from "./find-model.js";
|
|
3
4
|
import { settleScroll } from "./settle-scroll.js";
|
|
@@ -23,23 +24,16 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
23
24
|
const [needle, setNeedle] = useState("");
|
|
24
25
|
const [opts, setOpts] = useState({ caseSensitive: false });
|
|
25
26
|
const [index, setIndex] = useState(0);
|
|
26
|
-
const latest =
|
|
27
|
-
parts,
|
|
27
|
+
const latest = useLatest({
|
|
28
28
|
surfaces,
|
|
29
29
|
scroller,
|
|
30
30
|
fallback
|
|
31
31
|
});
|
|
32
|
-
latest.current = {
|
|
33
|
-
parts,
|
|
34
|
-
surfaces,
|
|
35
|
-
scroller,
|
|
36
|
-
fallback
|
|
37
|
-
};
|
|
38
32
|
useEffect(() => {
|
|
39
33
|
const t = window.setTimeout(setNeedle, QUERY_DEBOUNCE_MS, query);
|
|
40
34
|
return () => window.clearTimeout(t);
|
|
41
35
|
}, [query]);
|
|
42
|
-
const { matches, capped } = useMemo(() => open && needle ? findAll(
|
|
36
|
+
const { matches, capped } = useMemo(() => open && needle ? findAll(parts(), needle, opts) : {
|
|
43
37
|
matches: [],
|
|
44
38
|
capped: false
|
|
45
39
|
}, [
|
|
@@ -69,13 +63,14 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
69
63
|
cancelAnimationFrame(frame.current);
|
|
70
64
|
frame.current = requestAnimationFrame(() => {
|
|
71
65
|
if (!open || !needle) return clearFind(me.current);
|
|
72
|
-
paintFind(me.current, latest.
|
|
66
|
+
paintFind(me.current, latest().surfaces(), needle, opts, current);
|
|
73
67
|
});
|
|
74
68
|
}, [
|
|
75
69
|
open,
|
|
76
70
|
needle,
|
|
77
71
|
opts,
|
|
78
|
-
current
|
|
72
|
+
current,
|
|
73
|
+
latest
|
|
79
74
|
]);
|
|
80
75
|
useEffect(() => {
|
|
81
76
|
paint();
|
|
@@ -83,14 +78,14 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
83
78
|
useEffect(() => () => clearFind(me.current), []);
|
|
84
79
|
useEffect(() => {
|
|
85
80
|
if (!open) return;
|
|
86
|
-
const root = latest.
|
|
81
|
+
const root = latest().scroller();
|
|
87
82
|
const watched = /* @__PURE__ */ new WeakSet();
|
|
88
83
|
const observer = new MutationObserver(() => {
|
|
89
84
|
watch();
|
|
90
85
|
paint();
|
|
91
86
|
});
|
|
92
87
|
function watch() {
|
|
93
|
-
for (const s of latest.
|
|
88
|
+
for (const s of latest().surfaces()) {
|
|
94
89
|
if (watched.has(s.root)) continue;
|
|
95
90
|
watched.add(s.root);
|
|
96
91
|
observer.observe(s.root, {
|
|
@@ -110,7 +105,11 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
110
105
|
observer.disconnect();
|
|
111
106
|
root?.removeEventListener("scroll", onScroll);
|
|
112
107
|
};
|
|
113
|
-
}, [
|
|
108
|
+
}, [
|
|
109
|
+
open,
|
|
110
|
+
paint,
|
|
111
|
+
latest
|
|
112
|
+
]);
|
|
114
113
|
const stop = useRef(null);
|
|
115
114
|
const currentRef = useRef(current);
|
|
116
115
|
useLayoutEffect(() => {
|
|
@@ -119,10 +118,10 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
119
118
|
const currentKey = current ? `${current.part}\0${current.side}\0${current.line}\0${current.start}` : "";
|
|
120
119
|
useEffect(() => {
|
|
121
120
|
stop.current?.();
|
|
122
|
-
const root = latest.
|
|
121
|
+
const root = latest().scroller();
|
|
123
122
|
const target = currentRef.current;
|
|
124
123
|
if (!open || !target || !root) return;
|
|
125
|
-
stop.current = settleScroll(root, () => rowOf(latest.
|
|
124
|
+
stop.current = settleScroll(root, () => rowOf(latest().surfaces(), target) ?? latest().fallback(target, root), {
|
|
126
125
|
offset: (r) => r.clientHeight * LAND_AT,
|
|
127
126
|
smooth
|
|
128
127
|
});
|
|
@@ -131,7 +130,8 @@ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
|
|
|
131
130
|
open,
|
|
132
131
|
currentKey,
|
|
133
132
|
jumps,
|
|
134
|
-
smooth
|
|
133
|
+
smooth,
|
|
134
|
+
latest
|
|
135
135
|
]);
|
|
136
136
|
const step = useCallback((direction) => {
|
|
137
137
|
if (matches.length === 0) return;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
// src/code/editor/useCodeDocument.ts
|
|
3
|
+
/** The same text at the same time: no news from disk. */
|
|
4
|
+
function sameText(a, b) {
|
|
5
|
+
return a.mtimeMs === b.mtimeMs && a.contents === b.contents;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Keeps one document's draft, dirty state and disk conflicts consistent; see the module comment.
|
|
5
9
|
*
|
|
@@ -55,25 +59,24 @@ function useCodeDocument({ doc, initialDraft = null, initialBase, save: write, r
|
|
|
55
59
|
if (reset) setResets((n) => n + 1);
|
|
56
60
|
onAdopt?.(next, reset);
|
|
57
61
|
}, [onAdopt]);
|
|
58
|
-
const seenDoc =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (doc
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const [seenDoc, setSeenDoc] = useState(() => sameText(doc, base) ? doc : null);
|
|
63
|
+
const [fromDisk, setFromDisk] = useState(null);
|
|
64
|
+
if (!seenDoc || !sameText(doc, seenDoc)) {
|
|
65
|
+
if (sameText(doc, base)) setSeenDoc(doc);
|
|
66
|
+
else if (dirty) {
|
|
67
|
+
if (!conflict) setConflict(true);
|
|
68
|
+
} else {
|
|
69
|
+
setSeenDoc(doc);
|
|
70
|
+
setBase(doc);
|
|
71
|
+
setConflict(false);
|
|
72
|
+
setResets((n) => n + 1);
|
|
73
|
+
setFromDisk(doc);
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
dirty,
|
|
75
|
-
adopt
|
|
76
|
-
]);
|
|
75
|
+
}
|
|
76
|
+
const adoptedFromDisk = useEffectEvent((next) => onAdopt?.(next, true));
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (fromDisk) adoptedFromDisk(fromDisk);
|
|
79
|
+
}, [fromDisk]);
|
|
77
80
|
const baseRef = useRef(base);
|
|
78
81
|
useLayoutEffect(() => {
|
|
79
82
|
baseRef.current = base;
|
|
@@ -17,15 +17,16 @@ function useDetachCleanup() {
|
|
|
17
17
|
const host = useRef(null);
|
|
18
18
|
const stash = useRef(/* @__PURE__ */ new Map());
|
|
19
19
|
useLayoutEffect(() => {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const stashed = stash.current;
|
|
21
|
+
for (const [root, children] of stashed) if (root.childElementCount === 0) root.append(...children);
|
|
22
|
+
stashed.clear();
|
|
22
23
|
const el = host.current;
|
|
23
24
|
return () => {
|
|
24
25
|
if (!el) return;
|
|
25
26
|
for (const c of el.querySelectorAll("diffs-container")) {
|
|
26
27
|
const root = c.shadowRoot;
|
|
27
28
|
if (!root) continue;
|
|
28
|
-
|
|
29
|
+
stashed.set(root, Array.from(root.childNodes));
|
|
29
30
|
root.replaceChildren();
|
|
30
31
|
}
|
|
31
32
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCodeHighlight } from "./CodeHighlightProvider.js";
|
|
2
|
-
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
2
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
// src/code/use-highlighted-html.ts
|
|
4
4
|
/**
|
|
5
5
|
* A block's highlighted HTML, shared by `HighlightedCode` and the views that
|
|
@@ -25,17 +25,17 @@ function useHighlightedHtml(code, language, enabled) {
|
|
|
25
25
|
const { highlighter, theme } = useCodeHighlight();
|
|
26
26
|
const hydrated = useHydrated();
|
|
27
27
|
const [painted, setPainted] = useState(null);
|
|
28
|
-
const
|
|
28
|
+
const firstRun = useRef(true);
|
|
29
|
+
const cached = enabled && hydrated ? highlighter.cached(code, language, theme) : void 0;
|
|
30
|
+
if (cached !== void 0 && !(painted?.code === code && painted.language === language && painted.html === cached)) setPainted({
|
|
31
|
+
code,
|
|
32
|
+
language,
|
|
33
|
+
html: cached
|
|
34
|
+
});
|
|
29
35
|
useEffect(() => {
|
|
30
36
|
if (!enabled) return;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
firstRunRef.done = true;
|
|
34
|
-
setPainted({
|
|
35
|
-
code,
|
|
36
|
-
language,
|
|
37
|
-
html: cached
|
|
38
|
-
});
|
|
37
|
+
if (highlighter.cached(code, language, theme) !== void 0) {
|
|
38
|
+
firstRun.current = false;
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
let cancelled = false;
|
|
@@ -48,8 +48,8 @@ function useHighlightedHtml(code, language, enabled) {
|
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
|
-
if (
|
|
52
|
-
|
|
51
|
+
if (firstRun.current) {
|
|
52
|
+
firstRun.current = false;
|
|
53
53
|
run();
|
|
54
54
|
return () => {
|
|
55
55
|
cancelled = true;
|
|
@@ -65,7 +65,6 @@ function useHighlightedHtml(code, language, enabled) {
|
|
|
65
65
|
language,
|
|
66
66
|
theme,
|
|
67
67
|
highlighter,
|
|
68
|
-
firstRunRef,
|
|
69
68
|
enabled
|
|
70
69
|
]);
|
|
71
70
|
if (painted && painted.code === code && painted.language === language) return painted.html;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* along a toolbar), never as the browser's native title. `shortcut` adds the
|
|
12
12
|
* key binding that does the same thing, as keycaps.
|
|
13
13
|
*/
|
|
14
|
-
import { ButtonHTMLAttributes, FocusEvent, MouseEvent, ReactElement, ReactNode } from "react";
|
|
14
|
+
import { ButtonHTMLAttributes, FocusEvent, MouseEvent, PointerEvent, ReactElement, ReactNode } from "react";
|
|
15
15
|
declare const SIZES: {
|
|
16
16
|
readonly xs: "w-5 h-5 text-zg-meta";
|
|
17
17
|
readonly sm: "w-6 h-6 text-zg-ui";
|
|
@@ -58,6 +58,8 @@ export interface IconButtonRenderProps {
|
|
|
58
58
|
'onMouseLeave': (e: MouseEvent<HTMLElement>) => void;
|
|
59
59
|
/** Bring the tooltip in on the first keyboard focus. */
|
|
60
60
|
'onFocus': (e: FocusEvent<HTMLElement>) => void;
|
|
61
|
+
/** Tells the tooltip the button was pressed, so it stays hidden. */
|
|
62
|
+
'onPointerDown': (e: PointerEvent<HTMLElement>) => void;
|
|
61
63
|
/** Set to an empty string while the button is `active`, otherwise absent. */
|
|
62
64
|
'data-active'?: '';
|
|
63
65
|
/** The icon followed by any badges or overlays. */
|
|
@@ -24,7 +24,7 @@ function iconButtonClass({ size = "md", tone = "neutral", overlay = false } = {}
|
|
|
24
24
|
* `active` states lift it to the raised chip. Use `render` to draw another element, such as a
|
|
25
25
|
* link, with the same look. The ref goes to the `button`.
|
|
26
26
|
*/
|
|
27
|
-
const IconButton = forwardRef(({ icon, label, size, active = false, tone, className = "", type = "button", title, children, render, shortcut, onMouseEnter, onMouseLeave, onFocus, ...rest }, ref) => {
|
|
27
|
+
const IconButton = forwardRef(({ icon, label, size, active = false, tone, className = "", type = "button", title, children, render, shortcut, onMouseEnter, onMouseLeave, onFocus, onPointerDown, ...rest }, ref) => {
|
|
28
28
|
const [el, setEl] = useState(null);
|
|
29
29
|
const arm = useTooltipArming();
|
|
30
30
|
const setRef = useCallback((node) => {
|
|
@@ -53,6 +53,10 @@ const IconButton = forwardRef(({ icon, label, size, active = false, tone, classN
|
|
|
53
53
|
arm.handlers.onFocus();
|
|
54
54
|
onFocus?.(e);
|
|
55
55
|
},
|
|
56
|
+
"onPointerDown": (e) => {
|
|
57
|
+
arm.handlers.onPointerDown();
|
|
58
|
+
onPointerDown?.(e);
|
|
59
|
+
},
|
|
56
60
|
"children": /* @__PURE__ */ jsxs(Fragment$1, { children: [typeof icon === "string" ? /* @__PURE__ */ jsx("span", {
|
|
57
61
|
className: icon,
|
|
58
62
|
"aria-hidden": true
|
|
@@ -65,7 +69,8 @@ const IconButton = forwardRef(({ icon, label, size, active = false, tone, classN
|
|
|
65
69
|
label: title ?? label,
|
|
66
70
|
shortcut,
|
|
67
71
|
initial: arm.armed,
|
|
68
|
-
pointerInside: arm.pointerInside
|
|
72
|
+
pointerInside: arm.pointerInside,
|
|
73
|
+
pressed: arm.pressed
|
|
69
74
|
})
|
|
70
75
|
});
|
|
71
76
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [render ? render(look) : /* @__PURE__ */ jsx("button", {
|
|
@@ -10,10 +10,12 @@ export interface IconButtonTipProps {
|
|
|
10
10
|
initial: 'hover' | 'focus';
|
|
11
11
|
/** The pointer is over the button now. */
|
|
12
12
|
pointerInside: () => boolean;
|
|
13
|
+
/** The button was pressed before the tooltip loaded. */
|
|
14
|
+
pressed: () => boolean;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Shows the button's label, with its keycaps, on hover or keyboard focus.
|
|
16
18
|
*
|
|
17
19
|
* @param props - {@link IconButtonTipProps}.
|
|
18
20
|
*/
|
|
19
|
-
export declare function IconButtonTip({ anchor, label, shortcut, initial, pointerInside }: IconButtonTipProps): import("react").JSX.Element;
|
|
21
|
+
export declare function IconButtonTip({ anchor, label, shortcut, initial, pointerInside, pressed }: IconButtonTipProps): import("react").JSX.Element;
|
|
@@ -12,11 +12,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
*
|
|
13
13
|
* @param props - {@link IconButtonTipProps}.
|
|
14
14
|
*/
|
|
15
|
-
function IconButtonTip({ anchor, label, shortcut, initial, pointerInside }) {
|
|
15
|
+
function IconButtonTip({ anchor, label, shortcut, initial, pointerInside, pressed }) {
|
|
16
16
|
return /* @__PURE__ */ jsx(AnchoredTooltip, {
|
|
17
17
|
anchor,
|
|
18
18
|
initial,
|
|
19
19
|
pointerInside,
|
|
20
|
+
pressed,
|
|
20
21
|
portal: true,
|
|
21
22
|
label: shortcut ? /* @__PURE__ */ jsxs("span", {
|
|
22
23
|
className: "inline-flex items-center gap-2",
|
|
@@ -2,7 +2,7 @@ import { FloatingSurface } from "./floating/FloatingSurface.js";
|
|
|
2
2
|
import { returnFocus, useDismiss } from "./floating/usePopover.js";
|
|
3
3
|
import { KeyCombo } from "./Keycap.js";
|
|
4
4
|
import { Menu, MenuRow, MenuSeparator, focusMenuRow } from "./Menu.js";
|
|
5
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { useEffect, useEffectEvent, useRef, useState } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// src/components/RowActionsMenu.tsx
|
|
8
8
|
/** How long the pointer rests on a row before the rows it holds open beside it. */
|
|
@@ -64,14 +64,6 @@ function ArmedRowActionsMenu({ open, anchorRef, position, onClose, items, classN
|
|
|
64
64
|
const surfaceRef = useRef(null);
|
|
65
65
|
const subSurfaceRef = useRef(null);
|
|
66
66
|
const returnTo = useRef(null);
|
|
67
|
-
const placement = useRef({
|
|
68
|
-
anchorRef,
|
|
69
|
-
position
|
|
70
|
-
});
|
|
71
|
-
placement.current = {
|
|
72
|
-
anchorRef,
|
|
73
|
-
position
|
|
74
|
-
};
|
|
75
67
|
const [sub, setSub] = useState(null);
|
|
76
68
|
if (!open && sub?.open) setSub({
|
|
77
69
|
...sub,
|
|
@@ -79,13 +71,14 @@ function ArmedRowActionsMenu({ open, anchorRef, position, onClose, items, classN
|
|
|
79
71
|
});
|
|
80
72
|
const subRows = sub ? items.find((item) => item.id === sub.id)?.items : void 0;
|
|
81
73
|
const hover = useRef({});
|
|
82
|
-
|
|
83
|
-
if (!open) return;
|
|
84
|
-
const { anchorRef: anchor, position: at } = placement.current;
|
|
74
|
+
const opened = useEffectEvent(() => {
|
|
85
75
|
const active = document.activeElement;
|
|
86
76
|
const before = active instanceof HTMLElement && active !== document.body && !active.closest(".zg-float") ? active : null;
|
|
87
|
-
returnTo.current = !
|
|
77
|
+
returnTo.current = !position && anchorRef?.current || before || returnTo.current;
|
|
88
78
|
if (surfaceRef.current) focusMenuRow(surfaceRef.current);
|
|
79
|
+
});
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (open) opened();
|
|
89
82
|
}, [open]);
|
|
90
83
|
useEffect(() => {
|
|
91
84
|
if (sub?.open && sub.focus && subSurfaceRef.current) focusMenuRow(subSurfaceRef.current);
|
|
@@ -188,7 +181,7 @@ function ArmedRowActionsMenu({ open, anchorRef, position, onClose, items, classN
|
|
|
188
181
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FloatingSurface, {
|
|
189
182
|
ref: surfaceRef,
|
|
190
183
|
open,
|
|
191
|
-
anchor: position ? { point: position } : {
|
|
184
|
+
anchor: position ? { point: position } : anchorRef ? { ref: anchorRef } : { element: null },
|
|
192
185
|
side: "bottom",
|
|
193
186
|
align: position ? "start" : "end",
|
|
194
187
|
offset: position ? 0 : 4,
|
|
@@ -67,6 +67,7 @@ export interface UseTooltip {
|
|
|
67
67
|
onMouseEnter: () => void;
|
|
68
68
|
onMouseLeave: () => void;
|
|
69
69
|
onFocus: () => void;
|
|
70
|
+
onPointerDown: () => void;
|
|
70
71
|
};
|
|
71
72
|
/** Render it next to the element (the bubble portals out; nothing shows in place). */
|
|
72
73
|
tip: ReactNode;
|
|
@@ -92,6 +93,8 @@ export interface AnchoredTooltipProps extends Omit<TooltipProps, 'children' | 'c
|
|
|
92
93
|
initial?: 'hover' | 'focus';
|
|
93
94
|
/** The pointer is over the anchor now, for `initial` hover. Default: the anchor matches `:hover`. */
|
|
94
95
|
pointerInside?: () => boolean;
|
|
96
|
+
/** The anchor was pressed before this mounted (a hover and a click in one go): it starts suppressed. */
|
|
97
|
+
pressed?: () => boolean;
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
100
|
* The tooltip on an element the caller already draws: it listens on `anchor` (no wrapper, no layout of
|
|
@@ -99,4 +102,4 @@ export interface AnchoredTooltipProps extends Omit<TooltipProps, 'children' | 'c
|
|
|
99
102
|
*
|
|
100
103
|
* @param props - {@link AnchoredTooltipProps}.
|
|
101
104
|
*/
|
|
102
|
-
export declare function AnchoredTooltip({ anchor, label, side, align, portal, maxWidth, disabled, initial, pointerInside: inside }: AnchoredTooltipProps): import("react").JSX.Element | null;
|
|
105
|
+
export declare function AnchoredTooltip({ anchor, label, side, align, portal, maxWidth, disabled, initial, pointerInside: inside, pressed }: AnchoredTooltipProps): import("react").JSX.Element | null;
|