@vitrinka/web 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +78 -21
- package/build/hud.d.ts +9 -0
- package/build/hud.iife.js +411 -0
- package/build/hud.js +8 -0
- package/build/recorder/api.d.ts +2 -0
- package/build/recorder/block.d.ts +7 -0
- package/build/recorder/block.js +7 -0
- package/build/recorder/capture/click.d.ts +2 -4
- package/build/recorder/capture/click.js +2 -31
- package/build/recorder/capture/rrweb.d.ts +2 -2
- package/build/recorder/capture/rrweb.js +2 -2
- package/build/recorder/capture/selector.d.ts +8 -0
- package/build/recorder/capture/selector.js +35 -0
- package/build/recorder/config.d.ts +6 -0
- package/build/recorder/config.js +1 -0
- package/build/recorder/hud/AnnotateOverlay.d.ts +7 -1
- package/build/recorder/hud/AnnotateOverlay.js +51 -17
- package/build/recorder/hud/Hud.d.ts +16 -1
- package/build/recorder/hud/Hud.js +251 -83
- package/build/recorder/hud/LinkSheet.d.ts +3 -3
- package/build/recorder/hud/LinkSheet.js +1 -1
- package/build/recorder/hud/Menu.d.ts +30 -0
- package/build/recorder/hud/Menu.js +73 -0
- package/build/recorder/hud/RecorderPill.d.ts +36 -27
- package/build/recorder/hud/RecorderPill.js +212 -123
- package/build/recorder/hud/Sheet.d.ts +1 -1
- package/build/recorder/hud/Sheet.js +1 -1
- package/build/recorder/hud/Tooltip.d.ts +19 -0
- package/build/recorder/hud/Tooltip.js +94 -0
- package/build/recorder/hud/controller.d.ts +148 -0
- package/build/recorder/hud/controller.js +17 -0
- package/build/recorder/hud/flow.d.ts +54 -0
- package/build/recorder/hud/flow.js +39 -0
- package/build/recorder/hud/host.js +1 -1
- package/build/recorder/hud/icons.d.ts +7 -0
- package/build/recorder/hud/icons.js +19 -0
- package/build/recorder/hud/iife.d.ts +13 -0
- package/build/recorder/hud/iife.js +11 -0
- package/build/recorder/hud/layer.d.ts +29 -6
- package/build/recorder/hud/layer.js +67 -33
- package/build/recorder/hud/mount.d.ts +13 -0
- package/build/recorder/hud/mount.js +27 -0
- package/build/recorder/hud/place.d.ts +43 -0
- package/build/recorder/hud/place.js +63 -0
- package/build/recorder/hud/spots.d.ts +45 -0
- package/build/recorder/hud/spots.js +107 -0
- package/build/recorder/hud/status.d.ts +31 -0
- package/build/recorder/hud/status.js +67 -0
- package/build/recorder/hud/styles.d.ts +28 -18
- package/build/recorder/hud/styles.js +295 -122
- package/build/recorder/hud/useDock.d.ts +9 -8
- package/build/recorder/hud/useDock.js +41 -20
- package/build/recorder/index.d.ts +4 -2
- package/build/recorder/index.js +17 -19
- package/build/recorder/link.d.ts +1 -1
- package/build/recorder/link.js +8 -2
- package/build/recorder/me.d.ts +34 -0
- package/build/recorder/me.js +172 -0
- package/build/recorder/page-controller.d.ts +12 -0
- package/build/recorder/page-controller.js +100 -0
- package/build/recorder/queue.d.ts +4 -0
- package/build/recorder/queue.js +2 -0
- package/build/recorder/recents.d.ts +23 -0
- package/build/recorder/recents.js +80 -0
- package/build/recorder/session.d.ts +2 -2
- package/build/recorder/session.js +16 -1
- package/build/recorder/storage/index.js +2 -1
- package/package.json +9 -3
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The HUD's face
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
2
|
+
* The HUD's face: ONE glass pill whose faces are collapsible segments, so a
|
|
3
|
+
* change of face tweens the pill's size instead of swapping boxes.
|
|
4
|
+
*
|
|
5
|
+
* - Idle: a puck — a hollow ring before the device is linked, a muted dot
|
|
6
|
+
* once it is — whose label (and the ⋯ menu button) slide out on intent.
|
|
7
|
+
* - Recording: the handle (rec dot + clock) that unfolds into the tray
|
|
8
|
+
* (sync chip · ⏸ ✎ ⌖ ■ ⋯) on hover, focus or tap and folds back ~2.5s
|
|
9
|
+
* after the pointer and focus leave. On the middle row it stands up into a
|
|
10
|
+
* vertical pill (a measured morph, see useMorph).
|
|
11
|
+
* - Flows (flow.ts): the pill itself asks "Stop & save?" / "Unlink this
|
|
12
|
+
* device?", spins while saving, says "Saved · Open board" until dismissed,
|
|
13
|
+
* or says why it could not save. Always horizontal.
|
|
14
|
+
* - Tucked: a 6px edge tab.
|
|
15
|
+
* The handle, the puck and the tab are the drag handles. Tooltips are
|
|
16
|
+
* `data-tip` / `data-keys` on the triggers (Tooltip.tsx paints them).
|
|
9
17
|
*/
|
|
10
|
-
import { type
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
18
|
+
import { type ReactElement, type RefObject } from 'react';
|
|
19
|
+
import type { HudSnapshot } from './controller';
|
|
20
|
+
import type { Flow } from './flow';
|
|
21
|
+
import { type Place } from './spots';
|
|
13
22
|
import type { DockHandle } from './useDock';
|
|
14
23
|
export declare const MOD: string;
|
|
15
|
-
export
|
|
16
|
-
/**
|
|
17
|
-
export declare function
|
|
18
|
-
glyph: ReactElement | string;
|
|
19
|
-
cls: string;
|
|
20
|
-
line: string;
|
|
21
|
-
bad: boolean;
|
|
22
|
-
};
|
|
24
|
+
export type Face = 'tab' | 'idle' | 'rec' | 'flow';
|
|
25
|
+
/** Which face the pill shows. A flow wins over the recording it belongs to. */
|
|
26
|
+
export declare function faceOf(snap: HudSnapshot, flow: Flow, place: Place): Face;
|
|
23
27
|
export interface RecorderPillProps {
|
|
24
|
-
|
|
28
|
+
snap: HudSnapshot;
|
|
29
|
+
now: number;
|
|
30
|
+
flow: Flow;
|
|
31
|
+
/** A note or annotation was just accepted: the clock briefly says so. */
|
|
32
|
+
flash: boolean;
|
|
25
33
|
composing: boolean;
|
|
26
|
-
annotating: boolean;
|
|
27
|
-
stopping: boolean;
|
|
28
34
|
starting: boolean;
|
|
29
|
-
|
|
30
|
-
linked: boolean;
|
|
31
|
-
/** A stored link can be forgotten; an explicit key cannot. */
|
|
32
|
-
canUnlink: boolean;
|
|
35
|
+
menuOpen: boolean;
|
|
33
36
|
place: Place;
|
|
34
37
|
dragging: boolean;
|
|
35
38
|
handle: DockHandle;
|
|
39
|
+
pillRef: RefObject<HTMLDivElement | null>;
|
|
36
40
|
onMove: (place: Place) => void;
|
|
37
41
|
onLink: () => void;
|
|
38
|
-
onUnlink: () => void;
|
|
39
42
|
onStart: () => void;
|
|
40
43
|
onPause: () => void;
|
|
41
44
|
onNote: () => void;
|
|
42
45
|
onAnnotate: () => void;
|
|
43
|
-
|
|
46
|
+
/** Toggle the ⋯ menu; `byKeyboard` moves focus into it. */
|
|
47
|
+
onMenu: (byKeyboard: boolean) => void;
|
|
48
|
+
onAskStop: () => void;
|
|
49
|
+
onConfirm: () => void;
|
|
50
|
+
onCancel: () => void;
|
|
51
|
+
onRetry: () => void;
|
|
52
|
+
onDismiss: () => void;
|
|
44
53
|
}
|
|
45
54
|
export declare function RecorderPill(p: RecorderPillProps): ReactElement;
|
|
@@ -1,96 +1,169 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
* The HUD's face
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
3
|
+
* The HUD's face: ONE glass pill whose faces are collapsible segments, so a
|
|
4
|
+
* change of face tweens the pill's size instead of swapping boxes.
|
|
5
|
+
*
|
|
6
|
+
* - Idle: a puck — a hollow ring before the device is linked, a muted dot
|
|
7
|
+
* once it is — whose label (and the ⋯ menu button) slide out on intent.
|
|
8
|
+
* - Recording: the handle (rec dot + clock) that unfolds into the tray
|
|
9
|
+
* (sync chip · ⏸ ✎ ⌖ ■ ⋯) on hover, focus or tap and folds back ~2.5s
|
|
10
|
+
* after the pointer and focus leave. On the middle row it stands up into a
|
|
11
|
+
* vertical pill (a measured morph, see useMorph).
|
|
12
|
+
* - Flows (flow.ts): the pill itself asks "Stop & save?" / "Unlink this
|
|
13
|
+
* device?", spins while saving, says "Saved · Open board" until dismissed,
|
|
14
|
+
* or says why it could not save. Always horizontal.
|
|
15
|
+
* - Tucked: a 6px edge tab.
|
|
16
|
+
* The handle, the puck and the tab are the drag handles. Tooltips are
|
|
17
|
+
* `data-tip` / `data-keys` on the triggers (Tooltip.tsx paints them).
|
|
10
18
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { usePresence } from './layer';
|
|
19
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from 'react';
|
|
20
|
+
import { saveProgress } from './flow';
|
|
21
|
+
import { AlertIcon, AnnotateIcon, CheckIcon, CloseIcon, CircleCheckIcon, CloudOffIcon, MoreIcon, NewTabIcon, PauseIcon, PencilIcon, PlayIcon, SpinnerIcon, StopIcon, ArrowUpIcon, } from './icons';
|
|
22
|
+
import { isVertical, untuck } from './spots';
|
|
23
|
+
import { elapsedOf, fmtClock, syncChip } from './status';
|
|
17
24
|
export const MOD = /Mac|iPhone|iPad/.test(globalThis.navigator?.platform ?? '') ? '⌥⇧' : 'Alt⇧';
|
|
18
25
|
/** How long the tray stays unfolded after the pointer and focus leave it. */
|
|
19
26
|
const FOLD_MS = 2500;
|
|
20
27
|
/** …and after a touch interaction inside it (no hover to keep it open). */
|
|
21
28
|
const FOLD_TOUCH_MS = 4000;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return ms < 1000 ? 'just now' : ms < 60000 ? `${Math.round(ms / 1000)}s` : `${Math.round(ms / 60000)}m`;
|
|
29
|
+
/** The orientation morph (a resize: `--duration-resize`). */
|
|
30
|
+
const MORPH_MS = 300;
|
|
31
|
+
/** Which face the pill shows. A flow wins over the recording it belongs to. */
|
|
32
|
+
export function faceOf(snap, flow, place) {
|
|
33
|
+
if ('tuck' in place)
|
|
34
|
+
return 'tab';
|
|
35
|
+
if (flow.face !== 'none')
|
|
36
|
+
return 'flow';
|
|
37
|
+
return snap.recording ? 'rec' : 'idle';
|
|
32
38
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
return `${String(Math.floor(s / 60)).padStart(2, '0')}:${String(s % 60).padStart(2, '0')}`;
|
|
39
|
+
function reducedMotion() {
|
|
40
|
+
return globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
36
41
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The orientation morph: when `orient` flips, tween the pill from its last
|
|
44
|
+
* measured size to its new one, with the inner segments' own tweens held
|
|
45
|
+
* (`.morphing`) so the target is the settled size, then fade the content in.
|
|
46
|
+
*/
|
|
47
|
+
function useMorph(ref, orient) {
|
|
48
|
+
const size = useRef(null);
|
|
49
|
+
const prev = useRef(orient);
|
|
50
|
+
useLayoutEffect(() => {
|
|
51
|
+
const el = ref.current;
|
|
52
|
+
if (!el)
|
|
53
|
+
return;
|
|
54
|
+
const was = size.current;
|
|
55
|
+
const flipped = prev.current !== orient;
|
|
56
|
+
prev.current = orient;
|
|
57
|
+
if (flipped && was && !reducedMotion() && typeof el.animate === 'function') {
|
|
58
|
+
for (const a of el.getAnimations())
|
|
59
|
+
a.cancel();
|
|
60
|
+
el.classList.add('morphing');
|
|
61
|
+
const next = { w: el.offsetWidth, h: el.offsetHeight };
|
|
62
|
+
size.current = next;
|
|
63
|
+
const ease = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
64
|
+
const morph = el.animate([
|
|
65
|
+
{ width: `${was.w}px`, height: `${was.h}px` },
|
|
66
|
+
{ width: `${next.w}px`, height: `${next.h}px` },
|
|
67
|
+
], { duration: MORPH_MS, easing: ease });
|
|
68
|
+
for (const seg of el.querySelectorAll('.seg.on > .seg-in')) {
|
|
69
|
+
seg.animate([{ opacity: 0, filter: 'blur(2px)' }, { opacity: 1, filter: 'blur(0)' }], {
|
|
70
|
+
duration: 250,
|
|
71
|
+
delay: 80,
|
|
72
|
+
easing: 'ease-in-out',
|
|
73
|
+
fill: 'backwards',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const done = () => el.classList.remove('morphing');
|
|
77
|
+
morph.onfinish = done;
|
|
78
|
+
morph.oncancel = done;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
size.current = { w: el.offsetWidth, h: el.offsetHeight };
|
|
82
|
+
});
|
|
83
|
+
// Keep the last size current between commits (the tray and labels tween).
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const el = ref.current;
|
|
86
|
+
if (!el || typeof ResizeObserver !== 'function')
|
|
87
|
+
return;
|
|
88
|
+
const ro = new ResizeObserver(() => {
|
|
89
|
+
if (!el.classList.contains('morphing'))
|
|
90
|
+
size.current = { w: el.offsetWidth, h: el.offsetHeight };
|
|
91
|
+
});
|
|
92
|
+
ro.observe(el);
|
|
93
|
+
return () => ro.disconnect();
|
|
94
|
+
}, [ref]);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A collapsible segment: its width (height when vertical) tweens 0 ↔ content.
|
|
98
|
+
* A closing one is inert at once — its exit tween must not leave a Stop or
|
|
99
|
+
* Retry clickable. Imperative: React 18 and 19 disagree on the `inert` prop.
|
|
100
|
+
*/
|
|
101
|
+
function Seg({ on, className, children }) {
|
|
102
|
+
const ref = useRef(null);
|
|
103
|
+
useLayoutEffect(() => {
|
|
104
|
+
if (ref.current)
|
|
105
|
+
ref.current.inert = !on;
|
|
106
|
+
}, [on]);
|
|
107
|
+
return (_jsx("div", { ref: ref, className: `seg ${className}${on ? ' on' : ''}`, "aria-hidden": !on, children: _jsx("div", { className: "seg-in", children: children }) }));
|
|
108
|
+
}
|
|
109
|
+
function SyncGlyph({ chip }) {
|
|
110
|
+
if (chip.kind === 'synced')
|
|
111
|
+
return _jsx(CircleCheckIcon, {});
|
|
112
|
+
if (chip.kind === 'offline')
|
|
113
|
+
return _jsx(CloudOffIcon, {});
|
|
114
|
+
if (chip.kind === 'error')
|
|
115
|
+
return _jsx(AlertIcon, {});
|
|
116
|
+
return _jsx(ArrowUpIcon, {});
|
|
117
|
+
}
|
|
118
|
+
/** "Couldn't save" in a few words; the full sentence rides the tooltip. */
|
|
119
|
+
function shortFailure(message) {
|
|
120
|
+
if (/unreachable|offline|fetch|network/i.test(message))
|
|
121
|
+
return 'Offline — kept here';
|
|
122
|
+
if (/ended locally|rejected/i.test(message))
|
|
123
|
+
return 'Ended by the server';
|
|
124
|
+
return 'Couldn’t save';
|
|
56
125
|
}
|
|
57
126
|
export function RecorderPill(p) {
|
|
58
|
-
const [, tick] = useState(0);
|
|
59
|
-
const [menu, setMenu] = useState(false);
|
|
60
127
|
const [open, setOpen] = useState(false);
|
|
61
128
|
const fold = useRef(undefined);
|
|
62
129
|
const hovered = useRef(false);
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
130
|
+
const stopRef = useRef(null);
|
|
131
|
+
const keepRef = useRef(null);
|
|
132
|
+
const savedRef = useRef(null);
|
|
133
|
+
const puckRef = useRef(null);
|
|
134
|
+
const face = faceOf(p.snap, p.flow, p.place);
|
|
135
|
+
const rec = p.snap.recording;
|
|
136
|
+
const annotating = p.snap.annotating;
|
|
137
|
+
const hold = p.menuOpen || p.composing || annotating || face === 'flow';
|
|
138
|
+
// Content a closing segment keeps for its closing frames.
|
|
139
|
+
const lastRec = useRef(rec);
|
|
140
|
+
if (rec)
|
|
141
|
+
lastRec.current = rec;
|
|
142
|
+
const lastFlow = useRef(p.flow);
|
|
143
|
+
if (p.flow.face !== 'none')
|
|
144
|
+
lastFlow.current = p.flow;
|
|
145
|
+
const shownRec = rec ?? lastRec.current;
|
|
146
|
+
const shownFlow = p.flow.face !== 'none' ? p.flow : lastFlow.current;
|
|
67
147
|
useEffect(() => {
|
|
68
|
-
|
|
69
|
-
return () => clearInterval(t);
|
|
70
|
-
}, []);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (!p.rec) {
|
|
73
|
-
setMenu(false);
|
|
148
|
+
if (!rec)
|
|
74
149
|
setOpen(false);
|
|
75
|
-
|
|
76
|
-
}, [p.rec]);
|
|
150
|
+
}, [rec]);
|
|
77
151
|
const cancelFold = useCallback(() => clearTimeout(fold.current), []);
|
|
78
152
|
// A hovering pointer or keyboard focus inside keeps the tray; a tap's
|
|
79
153
|
// focus does not (touch has no "leave" to fold on).
|
|
80
154
|
const foldIn = useCallback((ms) => {
|
|
81
155
|
cancelFold();
|
|
82
156
|
fold.current = setTimeout(() => {
|
|
83
|
-
if (!hovered.current && !
|
|
157
|
+
if (!hovered.current && !p.pillRef.current?.querySelector(':focus-visible'))
|
|
84
158
|
setOpen(false);
|
|
85
159
|
}, ms);
|
|
86
|
-
}, [cancelFold]);
|
|
160
|
+
}, [cancelFold, p.pillRef]);
|
|
87
161
|
useEffect(() => cancelFold, [cancelFold]);
|
|
88
|
-
// A drag folds everything; a held tray (menu, sheet, annotate
|
|
89
|
-
// and folds on the usual delay once the hold ends
|
|
162
|
+
// A drag folds everything; a held tray (menu, sheet, annotate, a flow)
|
|
163
|
+
// never folds, and folds on the usual delay once the hold ends.
|
|
90
164
|
useEffect(() => {
|
|
91
165
|
if (p.dragging) {
|
|
92
166
|
cancelFold();
|
|
93
|
-
setMenu(false);
|
|
94
167
|
setOpen(false);
|
|
95
168
|
}
|
|
96
169
|
}, [p.dragging, cancelFold]);
|
|
@@ -100,28 +173,21 @@ export function RecorderPill(p) {
|
|
|
100
173
|
else if (open)
|
|
101
174
|
foldIn(FOLD_MS);
|
|
102
175
|
}, [hold, open, cancelFold, foldIn]);
|
|
103
|
-
|
|
104
|
-
// (imperative: React 18 and 19 disagree on the `inert` prop).
|
|
105
|
-
const trayRef = useRef(null);
|
|
106
|
-
const unfolded = open || hold;
|
|
107
|
-
useLayoutEffect(() => {
|
|
108
|
-
if (trayRef.current)
|
|
109
|
-
trayRef.current.inert = !unfolded;
|
|
110
|
-
});
|
|
176
|
+
const unfolded = open || (hold && face !== 'flow');
|
|
111
177
|
// Hover is read with NATIVE pointerenter/leave: React synthesises enter
|
|
112
178
|
// from over/out pairs and drops an `over` whose related target belongs to
|
|
113
179
|
// any React root — on a React page the pointer always arrives from the
|
|
114
180
|
// app's own tree, so a synthetic onPointerEnter never fires on the HUD.
|
|
115
181
|
const holdRef = useRef(hold);
|
|
116
182
|
holdRef.current = hold;
|
|
117
|
-
const
|
|
183
|
+
const hasPill = face !== 'tab';
|
|
118
184
|
useLayoutEffect(() => {
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
185
|
+
const pill = p.pillRef.current;
|
|
186
|
+
if (!pill)
|
|
121
187
|
return;
|
|
122
|
-
// The
|
|
123
|
-
// puck that was just clicked): that pointer never "enters"
|
|
124
|
-
if (
|
|
188
|
+
// The pill often changes face UNDER a resting pointer (the capsule
|
|
189
|
+
// replaces the puck that was just clicked): that pointer never "enters".
|
|
190
|
+
if (pill.matches(':hover')) {
|
|
125
191
|
hovered.current = true;
|
|
126
192
|
setOpen(true);
|
|
127
193
|
}
|
|
@@ -139,50 +205,51 @@ export function RecorderPill(p) {
|
|
|
139
205
|
if (!holdRef.current)
|
|
140
206
|
foldIn(FOLD_MS);
|
|
141
207
|
};
|
|
142
|
-
|
|
143
|
-
|
|
208
|
+
pill.addEventListener('pointerenter', enter);
|
|
209
|
+
pill.addEventListener('pointerleave', leave);
|
|
144
210
|
return () => {
|
|
145
|
-
|
|
146
|
-
|
|
211
|
+
pill.removeEventListener('pointerenter', enter);
|
|
212
|
+
pill.removeEventListener('pointerleave', leave);
|
|
147
213
|
};
|
|
148
|
-
}, [
|
|
149
|
-
//
|
|
214
|
+
}, [hasPill, cancelFold, foldIn, p.pillRef]);
|
|
215
|
+
// Focus follows the flow while the HUD holds it: Keep on a confirm, Open
|
|
216
|
+
// board once saved; back to ■ (or the puck) when the flow ends.
|
|
217
|
+
const prevFace = useRef(p.flow.face);
|
|
150
218
|
useEffect(() => {
|
|
151
|
-
|
|
219
|
+
const was = prevFace.current;
|
|
220
|
+
prevFace.current = p.flow.face;
|
|
221
|
+
if (was === p.flow.face)
|
|
152
222
|
return;
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return (_jsx("button", { type: "button", className: "tab", "aria-label": "Show recorder", "data-state": h?.bad ? 'bad' : p.rec && !p.rec.paused ? 'rec' : 'idle', ...p.handle, onClick: () => p.onMove({ spot: untuck(p.place) }) }));
|
|
175
|
-
}
|
|
176
|
-
if (!p.rec) {
|
|
177
|
-
const unlinked = !p.linked;
|
|
178
|
-
const label = unlinked ? 'Link recorder' : 'Start recording';
|
|
179
|
-
return (_jsxs("button", { type: "button", className: "puck glass", "data-state": unlinked ? 'unlinked' : p.starting ? 'busy' : 'ready', "aria-label": label, onClick: unlinked ? p.onLink : p.onStart, disabled: p.starting, ...p.handle, children: [_jsx("span", { className: "ring" }), _jsx("span", { className: "lab", "aria-hidden": "true", children: _jsx("span", { children: label }) })] }));
|
|
223
|
+
const pill = p.pillRef.current;
|
|
224
|
+
const root = pill?.getRootNode();
|
|
225
|
+
const active = root instanceof ShadowRoot ? root.activeElement : null;
|
|
226
|
+
const ours = active === null || Boolean(pill?.contains(active));
|
|
227
|
+
if (!ours && p.flow.face !== 'confirm')
|
|
228
|
+
return;
|
|
229
|
+
const target = p.flow.face === 'confirm'
|
|
230
|
+
? keepRef.current
|
|
231
|
+
: p.flow.face === 'saved'
|
|
232
|
+
? savedRef.current
|
|
233
|
+
: p.flow.face === 'none'
|
|
234
|
+
? (rec ? stopRef.current : puckRef.current)
|
|
235
|
+
: null;
|
|
236
|
+
// After the segment turns visible (visibility flips with the commit).
|
|
237
|
+
requestAnimationFrame(() => target?.focus({ preventScroll: true }));
|
|
238
|
+
}, [p.flow.face, rec, p.pillRef]);
|
|
239
|
+
const orient = face === 'rec' && 'spot' in p.place && isVertical(p.place.spot) ? 'v' : 'h';
|
|
240
|
+
useMorph(p.pillRef, orient);
|
|
241
|
+
if (face === 'tab') {
|
|
242
|
+
const bad = rec ? rec.sync.state === 'offline' || rec.sync.state === 'dead' : false;
|
|
243
|
+
return (_jsx("button", { type: "button", className: "tab", "aria-label": "Show recorder", "data-state": bad ? 'bad' : rec && !rec.paused ? 'rec' : 'idle', ...p.handle, onClick: () => p.onMove({ spot: untuck(p.place) }) }));
|
|
180
244
|
}
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
const state =
|
|
184
|
-
const
|
|
185
|
-
const
|
|
245
|
+
const chip = shownRec ? syncChip(shownRec.sync, p.now) : null;
|
|
246
|
+
const bad = chip?.kind === 'offline' || chip?.kind === 'error';
|
|
247
|
+
const state = bad ? 'bad' : !shownRec || shownRec.paused || shownRec.dead ? 'paused' : 'rec';
|
|
248
|
+
const unlinked = !p.snap.linked;
|
|
249
|
+
const puckLabel = unlinked ? 'Link recorder' : 'Start recording';
|
|
250
|
+
const confirming = p.flow.face === 'confirm';
|
|
251
|
+
const dataFace = face === 'flow' && confirming && rec ? 'flow-rec' : face;
|
|
252
|
+
const progress = saveProgress(p.flow, rec?.sync.queued ?? 0);
|
|
186
253
|
const onTouch = (e) => {
|
|
187
254
|
if (e.pointerType !== 'mouse' && open)
|
|
188
255
|
foldIn(FOLD_TOUCH_MS);
|
|
@@ -195,7 +262,7 @@ export function RecorderPill(p) {
|
|
|
195
262
|
setOpen(true);
|
|
196
263
|
};
|
|
197
264
|
const onBlur = (e) => {
|
|
198
|
-
if (
|
|
265
|
+
if (p.pillRef.current?.contains(e.relatedTarget))
|
|
199
266
|
return;
|
|
200
267
|
if (!hold)
|
|
201
268
|
foldIn(FOLD_MS);
|
|
@@ -204,9 +271,31 @@ export function RecorderPill(p) {
|
|
|
204
271
|
setOpen((o) => !o);
|
|
205
272
|
foldIn(FOLD_TOUCH_MS);
|
|
206
273
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
274
|
+
// The menu-button keys: ↓ opens the menu with focus on its first item (Enter/Space click through onMenu).
|
|
275
|
+
const onMoreKey = (e) => {
|
|
276
|
+
if (e.key !== 'ArrowDown' || p.menuOpen)
|
|
277
|
+
return;
|
|
278
|
+
e.preventDefault();
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
p.onMenu(true);
|
|
281
|
+
};
|
|
282
|
+
const onKey = (e) => {
|
|
283
|
+
if (e.key !== 'Escape')
|
|
284
|
+
return;
|
|
285
|
+
if (p.flow.face === 'confirm')
|
|
286
|
+
p.onCancel();
|
|
287
|
+
else if (p.flow.face === 'saved' || p.flow.face === 'failed')
|
|
288
|
+
p.onDismiss();
|
|
289
|
+
else
|
|
290
|
+
return;
|
|
291
|
+
e.preventDefault();
|
|
292
|
+
e.stopPropagation();
|
|
210
293
|
};
|
|
211
|
-
|
|
294
|
+
const flowShown = shownFlow.face;
|
|
295
|
+
const confirmAction = shownFlow.face === 'confirm' ? shownFlow.action : 'stop';
|
|
296
|
+
const savedUrl = shownFlow.face === 'saved' ? shownFlow.boardUrl : undefined;
|
|
297
|
+
const failure = shownFlow.face === 'failed' ? shownFlow.message : '';
|
|
298
|
+
return (_jsxs("div", { ref: p.pillRef, className: "pill glass", "data-e2e": "recorder-pill", "data-face": dataFace, "data-orient": orient, "data-state": state, "data-open": unfolded && face !== 'flow' ? '' : undefined, onPointerDown: onTouch, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKey, children: [_jsx(Seg, { on: face === 'idle', className: "s-idle", children: _jsxs("button", { ref: puckRef, type: "button", className: "puck", "data-state": unlinked ? 'unlinked' : p.starting ? 'busy' : 'ready', "aria-label": puckLabel, onClick: unlinked ? p.onLink : p.onStart, disabled: p.starting, ...p.handle, children: [_jsx("span", { className: "ring" }), _jsx("span", { className: "lab", "aria-hidden": "true", children: _jsx("span", { children: puckLabel }) })] }) }), _jsx(Seg, { on: face === 'idle' && unfolded, className: "s-more", children: _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "Recents \u00B7 settings", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) }) }), _jsx(Seg, { on: face === 'rec' || (confirming && rec !== null), className: "s-handle", children: _jsxs("button", { type: "button", className: "handle", "aria-label": "Recorder controls", "aria-expanded": unfolded && face === 'rec', onClick: toggle, ...p.handle, children: [_jsx("span", { className: "dot" }), _jsxs("span", { className: "clock", children: [_jsx(Seg, { on: !p.flash, className: "c-time", children: _jsx("span", { className: "time", children: shownRec ? fmtClock(elapsedOf(shownRec, p.now)) : '00:00' }) }), _jsx(Seg, { on: p.flash, className: "c-flash", children: _jsxs("span", { className: "flash", "data-e2e": "saved-flash", children: [_jsx(CheckIcon, {}), _jsx("span", { children: "Saved" })] }) })] })] }) }), _jsx(Seg, { on: face === 'rec' && unfolded, className: "s-tray", children: _jsxs("div", { className: "tools seg-row", children: [_jsx("span", { className: "sep" }), chip ? (_jsxs("span", { className: "sync", "data-kind": chip.kind, "data-tip": chip.title, role: "status", "aria-label": chip.title, "data-e2e": "sync-chip", children: [_jsx("span", { className: "swap", children: _jsx(SyncGlyph, { chip: chip }) }, `glyph-${chip.kind}`), _jsx("span", { className: "word swap", children: chip.label }, `word-${chip.label}`)] })) : null, _jsx("button", { type: "button", className: "tb b-pause", "aria-label": shownRec?.paused ? 'Resume' : 'Pause', "aria-keyshortcuts": "Alt+Shift+P", "data-tip": shownRec?.paused ? 'Resume' : 'Pause', "data-keys": `${MOD}P`, onClick: p.onPause, children: shownRec?.paused ? _jsx(PlayIcon, {}) : _jsx(PauseIcon, {}) }), _jsx("button", { type: "button", className: "tb b-note", "aria-label": "Note", "aria-keyshortcuts": "Alt+Shift+N", "data-tip": "Note", "data-keys": `${MOD}N`, onClick: p.onNote, children: _jsx(PencilIcon, {}) }), _jsx("button", { type: "button", className: annotating ? 'tb b-annotate on' : 'tb b-annotate', "aria-label": "Annotate", "aria-pressed": annotating, "aria-keyshortcuts": "Alt+Shift+A", "data-tip": "Annotate", "data-keys": `${MOD}A`, onClick: p.onAnnotate, children: _jsx(AnnotateIcon, {}) }), _jsx("button", { ref: stopRef, type: "button", className: "tb b-stop", "aria-label": "Stop", "aria-keyshortcuts": "Alt+Shift+S", "data-tip": "Stop & save", "data-keys": `${MOD}S`, onClick: p.onAskStop, children: _jsx(StopIcon, {}) }), _jsx("button", { type: "button", className: "tb b-more", "aria-label": "More", "aria-haspopup": "menu", "aria-expanded": p.menuOpen, "data-tip": "More", onClick: (e) => p.onMenu(e.detail === 0), onKeyDown: onMoreKey, children: _jsx(MoreIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'confirm', className: "s-confirm", children: _jsxs("div", { className: "flow confirm", role: "group", "aria-label": confirmAction === 'stop' ? 'Stop and save' : 'Unlink', children: [_jsx("span", { className: "q", children: confirmAction === 'stop' ? 'Stop & save?' : 'Unlink this device?' }), _jsx("button", { type: "button", className: "fb primary", onClick: p.onConfirm, children: confirmAction === 'stop' ? 'Stop' : 'Unlink' }), _jsx("button", { ref: keepRef, type: "button", className: "fb", onClick: p.onCancel, children: confirmAction === 'stop' ? 'Keep recording' : 'Cancel' })] }) }), _jsx(Seg, { on: p.flow.face === 'saving', className: "s-saving", children: _jsxs("div", { className: "flow saving", role: "status", "data-e2e": "saving", children: [_jsx(SpinnerIcon, {}), _jsx("span", { children: "Saving\u2026" }), progress !== null && rec ? _jsxs("span", { className: "muted", children: [rec.sync.queued, " left"] }) : null, _jsx("span", { className: "bar-track", "data-indeterminate": progress === null ? '' : undefined, role: "progressbar", "aria-label": "Saving", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": progress === null ? undefined : Math.round(progress * 100), style: { '--p': String(progress ?? 0) }, children: _jsx("i", {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'saved', className: "s-saved", children: _jsxs("div", { className: "flow saved", "data-e2e": "saved", children: [_jsx("span", { className: "ok t-check", "data-state": flowShown === 'saved' ? 'in' : undefined, children: _jsx(CheckIcon, {}) }), _jsx("span", { children: "Saved" }), savedUrl ? (_jsxs("a", { ref: (el) => {
|
|
299
|
+
savedRef.current = el;
|
|
300
|
+
}, className: "fb", href: savedUrl, target: "_blank", rel: "noopener noreferrer", children: ["Open board ", _jsx(NewTabIcon, {})] })) : (_jsx("span", { className: "muted", children: "in Recents" })), _jsx("button", { ref: savedUrl ? undefined : (el) => void (savedRef.current = el), type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) }), _jsx(Seg, { on: p.flow.face === 'failed', className: "s-failed", children: _jsxs("div", { className: "flow failed", role: "alert", "data-tip": failure, children: [_jsx("span", { className: "warn", children: _jsx(AlertIcon, {}) }), _jsx("span", { className: "msg", children: shortFailure(failure) }), rec ? (_jsx("button", { type: "button", className: "fb", onClick: p.onRetry, children: "Retry" })) : null, _jsx("button", { type: "button", className: "fb icon", "aria-label": "Dismiss", onClick: p.onDismiss, children: _jsx(CloseIcon, {}) })] }) })] }));
|
|
212
301
|
}
|
|
@@ -11,7 +11,7 @@ import { type ReactElement } from 'react';
|
|
|
11
11
|
export interface SheetProps {
|
|
12
12
|
/** Presence classes (`grow`/`rise` + `is-open`/`is-closing`). */
|
|
13
13
|
className: string;
|
|
14
|
-
/**
|
|
14
|
+
/** CSS transform-origin: the point nearest the dock it grows from. */
|
|
15
15
|
origin: string;
|
|
16
16
|
title: string;
|
|
17
17
|
ctx: string;
|
|
@@ -33,5 +33,5 @@ export function Sheet({ className, origin, title, ctx, pick, draft, onDraft, onS
|
|
|
33
33
|
send();
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
return (_jsxs("div", { className: `pop ${className}`,
|
|
36
|
+
return (_jsxs("div", { className: `pop ${className}`, style: { transformOrigin: origin }, role: "dialog", "aria-labelledby": "vt-pop-title", onKeyDown: onKey, children: [_jsxs("div", { className: "pop-head", children: [_jsxs("span", { className: "title", children: [_jsx("i", {}), _jsx("span", { id: "vt-pop-title", children: title })] }), _jsx("button", { type: "button", className: "closeb", "aria-label": "Close", onClick: onClose, children: _jsx(CloseIcon, {}) })] }), _jsx("textarea", { ref: ta, placeholder: "what's wrong / what to refine\u2026", value: draft, onChange: (e) => onDraft(e.target.value), onKeyDown: onTaKey }), _jsxs("div", { className: pick ? 'row' : 'row nodest', children: [pick ? (_jsxs("span", { className: "dest", role: "group", "aria-label": "Where this snap lands", children: [_jsx("button", { type: "button", "aria-pressed": !task, onClick: () => setTask(false), children: "board" }), _jsx("button", { type: "button", "aria-pressed": task, onClick: () => setTask(true), children: "task" })] })) : null, _jsx("span", { className: "ctx", children: ctx }), _jsxs("button", { type: "button", className: "sendb", onClick: send, children: [_jsx(ArrowUpIcon, {}), _jsx("span", { children: "Send" })] })] }), _jsx("div", { className: "hints", children: "\u21A9 send \u00B7 \u21E7\u21A9 newline \u00B7 esc cancel" })] }));
|
|
37
37
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HUD's one tooltip (transitions.dev 17): any element carrying
|
|
3
|
+
* `data-tip` (and optionally `data-keys`, the shortcut) under `root` shows it
|
|
4
|
+
* on mouse hover or keyboard focus. It is a fixed float placed by place.ts —
|
|
5
|
+
* toward the page centre from the dock, flipped and shifted into the
|
|
6
|
+
* viewport — so it never clips at the pill's or the screen's edge. The first
|
|
7
|
+
* appearance waits a beat (CSS); moving to a neighbour while it shows makes
|
|
8
|
+
* the bubble travel; leaving hides it at once. Visual only (`aria-hidden`):
|
|
9
|
+
* every trigger already carries its accessible name and `aria-keyshortcuts`.
|
|
10
|
+
*/
|
|
11
|
+
import { type ReactElement, type RefObject } from 'react';
|
|
12
|
+
import { type FloatSide } from './place';
|
|
13
|
+
export interface TooltipProps {
|
|
14
|
+
root: RefObject<HTMLElement | null>;
|
|
15
|
+
side: FloatSide;
|
|
16
|
+
/** A drag, an open menu or sheet: no tooltip. */
|
|
17
|
+
suppressed: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function Tooltip({ root, side, suppressed }: TooltipProps): ReactElement;
|