cursedbelt 5.95.0 → 5.96.1
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/react/canvas-hud/index.d.ts +2 -2
- package/dist/react/canvas-hud/index.d.ts.map +1 -1
- package/dist/react/canvas-hud/index.js +1 -1
- package/dist/react/canvas-hud/index.js.map +1 -1
- package/dist/react/canvas-hud/viewport.d.ts +32 -0
- package/dist/react/canvas-hud/viewport.d.ts.map +1 -1
- package/dist/react/canvas-hud/viewport.js +51 -0
- package/dist/react/canvas-hud/viewport.js.map +1 -1
- package/dist/react/components/AppShell.js +6 -1
- package/dist/react/components/AppShell.js.map +1 -1
- package/dist/react/components/ConfirmDialog.d.ts.map +1 -1
- package/dist/react/components/ConfirmDialog.js +1 -1
- package/dist/react/components/ConfirmDialog.js.map +1 -1
- package/dist/react/components/Popover.d.ts +7 -1
- package/dist/react/components/Popover.d.ts.map +1 -1
- package/dist/react/components/Popover.js +54 -4
- package/dist/react/components/Popover.js.map +1 -1
- package/dist/react/components/TagsEditor.d.ts +15 -0
- package/dist/react/components/TagsEditor.d.ts.map +1 -0
- package/dist/react/components/TagsEditor.js +93 -0
- package/dist/react/components/TagsEditor.js.map +1 -0
- package/dist/react/components/TagsPromptDialog.d.ts +25 -0
- package/dist/react/components/TagsPromptDialog.d.ts.map +1 -0
- package/dist/react/components/TagsPromptDialog.js +38 -0
- package/dist/react/components/TagsPromptDialog.js.map +1 -0
- package/dist/react/file-tree/FolderViewMenus.d.ts.map +1 -1
- package/dist/react/file-tree/FolderViewMenus.js +2 -0
- package/dist/react/file-tree/FolderViewMenus.js.map +1 -1
- package/dist/react/file-tree/useFolderView.d.ts +11 -1
- package/dist/react/file-tree/useFolderView.d.ts.map +1 -1
- package/dist/react/file-tree/useFolderView.js +3 -2
- package/dist/react/file-tree/useFolderView.js.map +1 -1
- package/dist/react/hooks/longPressContextMenu.d.ts +10 -1
- package/dist/react/hooks/longPressContextMenu.d.ts.map +1 -1
- package/dist/react/hooks/longPressContextMenu.js +37 -3
- package/dist/react/hooks/longPressContextMenu.js.map +1 -1
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/lib/floatingSide.d.ts +42 -0
- package/dist/react/lib/floatingSide.d.ts.map +1 -0
- package/dist/react/lib/floatingSide.js +54 -0
- package/dist/react/lib/floatingSide.js.map +1 -0
- package/dist/react/lib/tagList.d.ts +16 -0
- package/dist/react/lib/tagList.d.ts.map +1 -0
- package/dist/react/lib/tagList.js +30 -0
- package/dist/react/lib/tagList.js.map +1 -0
- package/dist/react/media/FocusViewer.d.ts +8 -1
- package/dist/react/media/FocusViewer.d.ts.map +1 -1
- package/dist/react/media/FocusViewer.js +10 -1
- package/dist/react/media/FocusViewer.js.map +1 -1
- package/dist/react/media/FrameGrabber.d.ts +3 -1
- package/dist/react/media/FrameGrabber.d.ts.map +1 -1
- package/dist/react/media/FrameGrabber.js +10 -5
- package/dist/react/media/FrameGrabber.js.map +1 -1
- package/dist/react/media/VideoChapterEditor.d.ts +3 -1
- package/dist/react/media/VideoChapterEditor.d.ts.map +1 -1
- package/dist/react/media/VideoChapterEditor.js +14 -6
- package/dist/react/media/VideoChapterEditor.js.map +1 -1
- package/dist/react/media/VideoCutEditor.d.ts +3 -1
- package/dist/react/media/VideoCutEditor.d.ts.map +1 -1
- package/dist/react/media/VideoCutEditor.js +14 -6
- package/dist/react/media/VideoCutEditor.js.map +1 -1
- package/dist/react/media/VideoTurner.d.ts +3 -1
- package/dist/react/media/VideoTurner.d.ts.map +1 -1
- package/dist/react/media/VideoTurner.js +13 -5
- package/dist/react/media/VideoTurner.js.map +1 -1
- package/dist/react/media/hlsSource.d.ts +27 -0
- package/dist/react/media/hlsSource.d.ts.map +1 -1
- package/dist/react/media/hlsSource.js +39 -0
- package/dist/react/media/hlsSource.js.map +1 -1
- package/dist/react/media-gallery/MediaGallery.d.ts.map +1 -1
- package/dist/react/media-gallery/MediaGallery.js +4 -4
- package/dist/react/media-gallery/MediaGallery.js.map +1 -1
- package/dist/react/tagsPrompt.d.ts +15 -0
- package/dist/react/tagsPrompt.d.ts.map +1 -0
- package/dist/react/tagsPrompt.js +30 -0
- package/dist/react/tagsPrompt.js.map +1 -0
- package/dist/styles-areas/fields.css +4 -4
- package/dist/styles-areas/overlays.css +3 -2
- package/dist/styles-utilities.css +7 -0
- package/dist/theme.css +13 -0
- package/package.json +9 -2
- package/scripts/styleAreas.ts +5 -0
- package/src/looks.spec.ts +34 -0
- package/src/react/canvas-hud/index.ts +10 -0
- package/src/react/canvas-hud/viewport.spec.ts +70 -0
- package/src/react/canvas-hud/viewport.ts +77 -0
- package/src/react/components/AppShell.spec.tsx +23 -0
- package/src/react/components/AppShell.tsx +6 -1
- package/src/react/components/ConfirmDialog.spec.tsx +41 -0
- package/src/react/components/ConfirmDialog.tsx +12 -2
- package/src/react/components/Popover.tsx +62 -5
- package/src/react/components/TagsEditor.tsx +140 -0
- package/src/react/components/TagsPromptDialog.spec.tsx +74 -0
- package/src/react/components/TagsPromptDialog.tsx +108 -0
- package/src/react/file-tree/FolderViewMenus.tsx +1 -0
- package/src/react/file-tree/folderViewTree.spec.tsx +15 -0
- package/src/react/file-tree/useFolderView.ts +13 -2
- package/src/react/hooks/longPressContextMenu.spec.ts +50 -0
- package/src/react/hooks/longPressContextMenu.ts +39 -3
- package/src/react/index.ts +3 -0
- package/src/react/lib/floatingSide.spec.ts +37 -0
- package/src/react/lib/floatingSide.ts +73 -0
- package/src/react/lib/tagList.spec.ts +19 -0
- package/src/react/lib/tagList.ts +29 -0
- package/src/react/media/FocusViewer.spec.tsx +19 -0
- package/src/react/media/FocusViewer.tsx +17 -0
- package/src/react/media/FrameGrabber.tsx +12 -5
- package/src/react/media/VideoChapterEditor.tsx +16 -6
- package/src/react/media/VideoCutEditor.tsx +17 -6
- package/src/react/media/VideoTurner.tsx +14 -5
- package/src/react/media/editorVideoSource.spec.tsx +71 -0
- package/src/react/media/hlsSource.ts +43 -0
- package/src/react/media-gallery/MediaGallery.tsx +4 -0
- package/src/react/tagsPrompt.tsx +33 -0
- package/src/styles-areas/fields.css +4 -4
- package/src/styles-areas/overlays.css +3 -2
- package/src/styles-utilities.css +7 -0
- package/src/theme.css +13 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type ReactNode, useState } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { DIALOG_MOTION } from '../lib/overlayMotion.js';
|
|
4
|
+
import { Button } from './Button.js';
|
|
5
|
+
import { Dialog, DialogContent, DialogDescription, DialogTitle } from './dialog.js';
|
|
6
|
+
import { TagsEditor, type TagsEditorProps } from './TagsEditor.js';
|
|
7
|
+
|
|
8
|
+
export interface TagsPromptDialogProps extends Pick<TagsEditorProps, 'suggestions' | 'placeholder' | 'normalize' | 'item'> {
|
|
9
|
+
open: boolean;
|
|
10
|
+
/** The tags the dialog closed on — the whole list, so a removal is the difference from `defaultValue`. */
|
|
11
|
+
onSubmit: (tags: string[]) => void | Promise<void>;
|
|
12
|
+
onCancel: () => void;
|
|
13
|
+
title: string;
|
|
14
|
+
message?: ReactNode;
|
|
15
|
+
/** The tags the item already carries — drawn as chips the moment it opens (forge task 3812:
|
|
16
|
+
* *"clicking 'Tag this track' doesn't show existing tags but it should"*). */
|
|
17
|
+
defaultValue?: readonly string[];
|
|
18
|
+
confirmLabel?: string;
|
|
19
|
+
cancelLabel?: string;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* {@link PromptDialog}'s shape with a {@link TagsEditor} for its field: the item's tags as chips,
|
|
26
|
+
* several added at once (comma/Enter, or a pasted list), × to take one off, the copy button and
|
|
27
|
+
* ⌘A/⌘C to carry them to another item. For the no-JSX case use `promptTags`
|
|
28
|
+
* (`cursedbelt/react/tags-prompt`), which mounts it once and resolves to the list or `null`.
|
|
29
|
+
*/
|
|
30
|
+
export function TagsPromptDialog({
|
|
31
|
+
open,
|
|
32
|
+
onSubmit,
|
|
33
|
+
onCancel,
|
|
34
|
+
title,
|
|
35
|
+
message,
|
|
36
|
+
defaultValue = [],
|
|
37
|
+
confirmLabel = 'Save tags',
|
|
38
|
+
cancelLabel = 'Cancel',
|
|
39
|
+
loading = false,
|
|
40
|
+
className,
|
|
41
|
+
suggestions,
|
|
42
|
+
placeholder,
|
|
43
|
+
normalize,
|
|
44
|
+
item,
|
|
45
|
+
...rest
|
|
46
|
+
}: TagsPromptDialogProps) {
|
|
47
|
+
const [tags, setTags] = useState<string[]>(() => [...defaultValue]);
|
|
48
|
+
|
|
49
|
+
/** A click on Save blurs the field first, which commits its draft; ⌘Enter does not, so it reads the draft from `content`. */
|
|
50
|
+
const handleSubmit = (content?: HTMLElement) => {
|
|
51
|
+
if (loading) return;
|
|
52
|
+
const raw = content?.querySelector<HTMLInputElement>('[data-tags-editor] input')?.value ?? '';
|
|
53
|
+
const pending = normalize ? normalize(raw) : raw.trim();
|
|
54
|
+
void onSubmit(pending && !tags.includes(pending) ? [...tags, pending] : tags);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Dialog
|
|
59
|
+
{...rest}
|
|
60
|
+
open={open}
|
|
61
|
+
onOpenChange={(v) => {
|
|
62
|
+
if (!v) onCancel();
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<DialogContent
|
|
66
|
+
data-cb-tags-prompt=''
|
|
67
|
+
className={cn(
|
|
68
|
+
'fixed top-1/2 left-1/2 flex w-[calc(100vw-2rem)] max-w-[var(--modal-w-sm)] -translate-x-1/2 -translate-y-1/2 flex-col gap-4',
|
|
69
|
+
'rounded-xl border border-border bg-popover p-6 text-popover-foreground shadow-overlay',
|
|
70
|
+
DIALOG_MOTION,
|
|
71
|
+
className,
|
|
72
|
+
)}
|
|
73
|
+
onOpenAutoFocus={(e) => {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
(e.currentTarget as HTMLElement | null)?.querySelector<HTMLInputElement>('[data-tags-editor] input')?.focus();
|
|
76
|
+
}}
|
|
77
|
+
onKeyDown={(e) => {
|
|
78
|
+
// ⌘/Ctrl+Enter saves from the field, where a bare Enter commits the tag being typed.
|
|
79
|
+
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
handleSubmit(e.currentTarget);
|
|
82
|
+
}
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<div className='flex flex-col gap-1.5'>
|
|
86
|
+
<DialogTitle className='text-base font-semibold'>{title}</DialogTitle>
|
|
87
|
+
{message ? <DialogDescription className='text-sm text-muted-foreground'>{message}</DialogDescription> : null}
|
|
88
|
+
</div>
|
|
89
|
+
<TagsEditor
|
|
90
|
+
value={tags}
|
|
91
|
+
onChange={setTags}
|
|
92
|
+
{...(suggestions ? { suggestions } : {})}
|
|
93
|
+
{...(placeholder ? { placeholder } : {})}
|
|
94
|
+
{...(normalize ? { normalize } : {})}
|
|
95
|
+
{...(item ? { item } : {})}
|
|
96
|
+
/>
|
|
97
|
+
<div className='flex justify-end gap-2'>
|
|
98
|
+
<Button data-cb-cancel variant='secondary' onClick={onCancel} disabled={loading} tooltip={cancelLabel}>
|
|
99
|
+
{cancelLabel}
|
|
100
|
+
</Button>
|
|
101
|
+
<Button data-cb-confirm variant='primary' onClick={() => handleSubmit()} loading={loading} tooltip={confirmLabel}>
|
|
102
|
+
{confirmLabel}
|
|
103
|
+
</Button>
|
|
104
|
+
</div>
|
|
105
|
+
</DialogContent>
|
|
106
|
+
</Dialog>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -345,6 +345,21 @@ describe('a row menu of the app\'s own', () => {
|
|
|
345
345
|
expect(renamed).toBe('home');
|
|
346
346
|
});
|
|
347
347
|
|
|
348
|
+
test('🔴 tagging: false takes Tags… off, so the app\'s own item tags what the folder HOLDS (forge task 3813)', () => {
|
|
349
|
+
render(
|
|
350
|
+
<Harness
|
|
351
|
+
options={{ tagging: false }}
|
|
352
|
+
rowMenu={() => [{ key: 'tag-songs', label: 'Tag the songs in it…' }]}
|
|
353
|
+
/>,
|
|
354
|
+
);
|
|
355
|
+
fireEvent.contextMenu(row('Home'));
|
|
356
|
+
expect(items().map((el) => el.querySelector('.truncate')?.textContent)).toEqual([
|
|
357
|
+
'Tag the songs in it…',
|
|
358
|
+
'Hide on this device',
|
|
359
|
+
'Hide everywhere',
|
|
360
|
+
]);
|
|
361
|
+
});
|
|
362
|
+
|
|
348
363
|
test('Hide and Tags… go ABOVE a trailing Delete — Delete stays last, under its rule', () => {
|
|
349
364
|
render(
|
|
350
365
|
<Harness
|
|
@@ -69,6 +69,8 @@ export interface FolderView {
|
|
|
69
69
|
tags: readonly TagCount[];
|
|
70
70
|
/** Whether "Hide on this device" is offered — false when the device half is not kept. */
|
|
71
71
|
deviceHiding: boolean;
|
|
72
|
+
/** Whether a folder's menu offers "Tags…" — false when the app tags what is IN a folder instead. */
|
|
73
|
+
tagging: boolean;
|
|
72
74
|
/** Which of the two lists hide this folder, if any. */
|
|
73
75
|
hiddenIn: (id: string) => HiddenScope | null;
|
|
74
76
|
|
|
@@ -118,6 +120,14 @@ export interface UseFolderViewOptions {
|
|
|
118
120
|
* `'memory'` is this page only, for an app whose folder ids may not be written to disk.
|
|
119
121
|
*/
|
|
120
122
|
device?: 'local' | 'memory';
|
|
123
|
+
/**
|
|
124
|
+
* `false` takes "Tags…" off a folder's menu, for an app whose folder tags belong on what the
|
|
125
|
+
* folder holds — music, where the owner wanted *"the tags to add on a folder [to] apply to all
|
|
126
|
+
* the tracks in the folder instead of applying to the folder"* (forge task 3813). The app puts
|
|
127
|
+
* its own item on the folder's `rowMenu`; the dots of marks already kept still draw, so it can
|
|
128
|
+
* carry them across. Default `true`.
|
|
129
|
+
*/
|
|
130
|
+
tagging?: boolean;
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
/** The marks, kept by the app — see {@link UseFolderViewOptions.store}. */
|
|
@@ -127,7 +137,7 @@ export interface FolderMarksStore {
|
|
|
127
137
|
write: (next: string | null) => void;
|
|
128
138
|
}
|
|
129
139
|
|
|
130
|
-
export function useFolderView({ key, store, device = 'local' }: UseFolderViewOptions): FolderView {
|
|
140
|
+
export function useFolderView({ key, store, device = 'local', tagging = true }: UseFolderViewOptions): FolderView {
|
|
131
141
|
// Hooks run unconditionally; an undefined key is the remembered preference that keeps nothing.
|
|
132
142
|
const [rememberedMarks, rememberMarks] = useRememberedPreference(store ? undefined : key);
|
|
133
143
|
const [rememberedLocal, rememberLocal] = useRememberedPreference(
|
|
@@ -186,6 +196,7 @@ export function useFolderView({ key, store, device = 'local' }: UseFolderViewOpt
|
|
|
186
196
|
local,
|
|
187
197
|
tags,
|
|
188
198
|
deviceHiding,
|
|
199
|
+
tagging,
|
|
189
200
|
hiddenIn: (id) => hiddenScope(marks, local, id),
|
|
190
201
|
hide: (ids, options) => {
|
|
191
202
|
if (options?.scope === 'device' && deviceHiding) saveLocal(setHidden(latestLocal.current, ids, true));
|
|
@@ -218,6 +229,6 @@ export function useFolderView({ key, store, device = 'local' }: UseFolderViewOpt
|
|
|
218
229
|
closePanel: () => setPanel(null),
|
|
219
230
|
onContextMenu,
|
|
220
231
|
}),
|
|
221
|
-
[marks, local, tags, deviceHiding, panel, saveMarks, saveLocal, onContextMenu],
|
|
232
|
+
[marks, local, tags, deviceHiding, tagging, panel, saveMarks, saveLocal, onContextMenu],
|
|
222
233
|
);
|
|
223
234
|
}
|
|
@@ -61,6 +61,56 @@ describe('bindLongPressContextMenu', () => {
|
|
|
61
61
|
expect(menus).toEqual([]);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
// The owner, 2026-10-27 (music): a tap that OPENED a folder popped the heading's view menu
|
|
65
|
+
// half a second later — the lift never bubbled through the bound element.
|
|
66
|
+
test('🔴 a lift heard anywhere ends the press — a node re-rendered away, a capture elsewhere', () => {
|
|
67
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
68
|
+
fireEvent.pointerUp(document.body, touch);
|
|
69
|
+
jest.advanceTimersByTime(LONG_PRESS_MS * 2);
|
|
70
|
+
|
|
71
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
72
|
+
fireEvent.pointerCancel(window, touch);
|
|
73
|
+
jest.advanceTimersByTime(LONG_PRESS_MS * 2);
|
|
74
|
+
expect(menus).toEqual([]);
|
|
75
|
+
|
|
76
|
+
// A lift of ANOTHER finger is not this press ending.
|
|
77
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
78
|
+
fireEvent.pointerUp(document.body, { ...touch, pointerId: 99 });
|
|
79
|
+
jest.advanceTimersByTime(LONG_PRESS_MS);
|
|
80
|
+
expect(menus.length).toBe(1);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('🔴 a tap’s click, or a scroll, during the press is not a hold', () => {
|
|
84
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
85
|
+
fireEvent.click(document.body);
|
|
86
|
+
jest.advanceTimersByTime(LONG_PRESS_MS * 2);
|
|
87
|
+
|
|
88
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
89
|
+
fireEvent.scroll(document.body);
|
|
90
|
+
jest.advanceTimersByTime(LONG_PRESS_MS * 2);
|
|
91
|
+
expect(menus).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('🔴 when what was pressed has moved out from under the finger, it is not a hold on it', () => {
|
|
95
|
+
const elsewhere = document.createElement('p');
|
|
96
|
+
document.body.append(elsewhere);
|
|
97
|
+
const was = document.elementFromPoint;
|
|
98
|
+
try {
|
|
99
|
+
document.elementFromPoint = () => elsewhere;
|
|
100
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
101
|
+
jest.advanceTimersByTime(LONG_PRESS_MS);
|
|
102
|
+
expect(menus).toEqual([]);
|
|
103
|
+
|
|
104
|
+
document.elementFromPoint = () => child;
|
|
105
|
+
fireEvent.pointerDown(child, { ...touch, clientX: 5, clientY: 5 });
|
|
106
|
+
jest.advanceTimersByTime(LONG_PRESS_MS);
|
|
107
|
+
expect(menus.length).toBe(1);
|
|
108
|
+
} finally {
|
|
109
|
+
document.elementFromPoint = was;
|
|
110
|
+
elsewhere.remove();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
64
114
|
test('the lift after a hold does not click what it was held on', () => {
|
|
65
115
|
let clicks = 0;
|
|
66
116
|
child.addEventListener('click', () => clicks++);
|
|
@@ -21,7 +21,16 @@
|
|
|
21
21
|
* document listener can read it as a press outside the menu that just opened and shut it;
|
|
22
22
|
* · `-webkit-touch-callout: none` while bound, so iOS does not put its own callout on top;
|
|
23
23
|
* · a press inside `ignore` (a selector) is not a hold — the file tree's grip, where a finger
|
|
24
|
-
* that stays down is about to drag
|
|
24
|
+
* that stays down is about to drag;
|
|
25
|
+
* · 🔴 a press that ENDED is never a hold, wherever its end was heard. The owner, 2026-10-27, on
|
|
26
|
+
* music: *"clicking open folder is blocking the view with a popup that says 'Show hidden
|
|
27
|
+
* folders' and 'Collapse all folders' … clicking a folder to open or close it should not
|
|
28
|
+
* popup a menu."* A tap that opens a folder re-renders what was under the finger, and a lift
|
|
29
|
+
* can then reach a node that is gone, or an element that captured the pointer, without ever
|
|
30
|
+
* bubbling through the bound one — so the timer outlived the tap and fired the heading's view
|
|
31
|
+
* menu half a second later. So while a hold is pending the lift, the cancel, a scroll and the
|
|
32
|
+
* tap's own `click` are heard at the WINDOW, and the hold fires only if what was pressed is
|
|
33
|
+
* still under the finger (a layout that moved under a resting finger is not a hold on it).
|
|
25
34
|
*/
|
|
26
35
|
/*
|
|
27
36
|
* 🔴 No runtime import, React's included: a rail heading loads this module LAZILY (forge task
|
|
@@ -50,11 +59,36 @@ export function bindLongPressContextMenu(
|
|
|
50
59
|
let firedUntil = 0;
|
|
51
60
|
let dispatching = false;
|
|
52
61
|
|
|
62
|
+
/** The window-wide ears of a pending hold — bound at the press, dropped with the timer. */
|
|
63
|
+
const onWindowEnd = (event: Event) => {
|
|
64
|
+
// Another finger lifting is not this press ending.
|
|
65
|
+
const id = (event as PointerEvent).pointerId;
|
|
66
|
+
if (id !== undefined && id !== pointerId) return;
|
|
67
|
+
cancel();
|
|
68
|
+
};
|
|
69
|
+
const onWindowTap = () => cancel();
|
|
70
|
+
const listen = (on: boolean) => {
|
|
71
|
+
const method = on ? 'addEventListener' : 'removeEventListener';
|
|
72
|
+
window[method]('pointerup', onWindowEnd, true);
|
|
73
|
+
window[method]('pointercancel', onWindowEnd, true);
|
|
74
|
+
window[method]('click', onWindowTap, true);
|
|
75
|
+
window[method]('scroll', onWindowTap, true);
|
|
76
|
+
};
|
|
77
|
+
|
|
53
78
|
const cancel = () => {
|
|
54
|
-
if (timer !== undefined)
|
|
79
|
+
if (timer !== undefined) {
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
listen(false);
|
|
82
|
+
}
|
|
55
83
|
timer = undefined;
|
|
56
84
|
};
|
|
57
85
|
|
|
86
|
+
/** Is what was pressed still what the finger rests on? `null` (no layout to ask) is a yes. */
|
|
87
|
+
const stillUnderFinger = (pressed: Element): boolean => {
|
|
88
|
+
const at = globalThis.document?.elementFromPoint?.(startX, startY);
|
|
89
|
+
return !at || pressed.contains(at) || at.contains(pressed);
|
|
90
|
+
};
|
|
91
|
+
|
|
58
92
|
const swallowClick = (event: MouseEvent) => {
|
|
59
93
|
window.removeEventListener('click', swallowClick, true);
|
|
60
94
|
if (Date.now() > firedUntil) return;
|
|
@@ -64,7 +98,8 @@ export function bindLongPressContextMenu(
|
|
|
64
98
|
|
|
65
99
|
const fire = () => {
|
|
66
100
|
timer = undefined;
|
|
67
|
-
|
|
101
|
+
listen(false);
|
|
102
|
+
if (!(target instanceof Element) || !target.isConnected || !stillUnderFinger(target)) return;
|
|
68
103
|
firedUntil = Date.now() + AFTERMATH_MS;
|
|
69
104
|
window.addEventListener('click', swallowClick, true);
|
|
70
105
|
setTimeout(() => window.removeEventListener('click', swallowClick, true), AFTERMATH_MS);
|
|
@@ -94,6 +129,7 @@ export function bindLongPressContextMenu(
|
|
|
94
129
|
startY = event.clientY;
|
|
95
130
|
target = event.target;
|
|
96
131
|
timer = setTimeout(fire, delayMs);
|
|
132
|
+
listen(true);
|
|
97
133
|
};
|
|
98
134
|
const onMove = (event: PointerEvent) => {
|
|
99
135
|
if (timer === undefined || event.pointerId !== pointerId) return;
|
package/src/react/index.ts
CHANGED
|
@@ -736,6 +736,9 @@ export {
|
|
|
736
736
|
} from './components/sharing/types.js';
|
|
737
737
|
export { type TabItem, Tabs, type TabsProps } from './components/Tabs.js';
|
|
738
738
|
export { TagsInput, type TagsInputProps } from './components/TagsInput.js';
|
|
739
|
+
export { TagsEditor, type TagsEditorProps } from './components/TagsEditor.js';
|
|
740
|
+
export { TagsPromptDialog, type TagsPromptDialogProps } from './components/TagsPromptDialog.js';
|
|
741
|
+
export { mergeTagLists, parseTagList, tagListText } from './lib/tagList.js';
|
|
739
742
|
export { TagStrip, type TagStripProps, type TagStripTag } from './components/TagStrip.js';
|
|
740
743
|
export {
|
|
741
744
|
Tooltip,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { floatingSideFor } from './floatingSide.js';
|
|
3
|
+
|
|
4
|
+
const gap = { offset: 4, padding: 16 };
|
|
5
|
+
/** An anchor box from its top and bottom edges, centered on a 1280-wide screen unless told. */
|
|
6
|
+
const box = (top: number, bottom: number, left = 600, right = 680) => ({ top, bottom, left, right });
|
|
7
|
+
|
|
8
|
+
describe('floatingSideFor (forge task 3776)', () => {
|
|
9
|
+
test('the side asked for, when the panel fits there', () => {
|
|
10
|
+
expect(floatingSideFor('bottom', box(100, 140), { width: 1280, height: 900 }, { width: 320, height: 500 }, gap)).toBe('bottom');
|
|
11
|
+
expect(floatingSideFor('top', box(700, 740), { width: 1280, height: 900 }, { width: 320, height: 500 }, gap)).toBe('top');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('the opposite side when only that one has the room', () => {
|
|
15
|
+
expect(floatingSideFor('bottom', box(600, 640), { width: 1280, height: 900 }, { width: 320, height: 500 }, gap)).toBe('top');
|
|
16
|
+
expect(floatingSideFor('top', box(100, 140), { width: 1280, height: 900 }, { width: 320, height: 500 }, gap)).toBe('bottom');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("beside the anchor when neither has it — photos' face at 1280×720, 322px above and 335px below", () => {
|
|
20
|
+
expect(floatingSideFor('bottom', box(322, 385, 600, 666), { width: 1280, height: 720 }, { width: 336, height: 540 }, gap)).toBe('right');
|
|
21
|
+
expect(floatingSideFor('bottom', box(322, 385, 900, 1000), { width: 1280, height: 720 }, { width: 336, height: 540 }, gap)).toBe('left');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('a phone with no room anywhere: the roomier of the asked-for side and its opposite', () => {
|
|
25
|
+
expect(floatingSideFor('bottom', box(300, 340, 20, 370), { width: 390, height: 640 }, { width: 350, height: 600 }, gap)).toBe('bottom');
|
|
26
|
+
expect(floatingSideFor('bottom', box(400, 440, 20, 370), { width: 390, height: 640 }, { width: 350, height: 600 }, gap)).toBe('top');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('a side panel too tall for the screen is not "beside" — it would be capped there too', () => {
|
|
30
|
+
expect(floatingSideFor('bottom', box(322, 385, 100, 160), { width: 1280, height: 720 }, { width: 336, height: 800 }, gap)).toBe('bottom');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('a left/right panel flips across, then goes below or above', () => {
|
|
34
|
+
expect(floatingSideFor('right', box(300, 340, 1000, 1100), { width: 1280, height: 900 }, { width: 320, height: 200 }, gap)).toBe('left');
|
|
35
|
+
expect(floatingSideFor('right', box(100, 140, 400, 900), { width: 1280, height: 900 }, { width: 420, height: 300 }, gap)).toBe('bottom');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which side of its anchor a floating panel opens on, decided from the panel's NATURAL size.
|
|
3
|
+
*
|
|
4
|
+
* 🔴 Radix's `flip` cannot do this for the belt's panels. `FLOATING_CONTENT_BASE` caps a panel's
|
|
5
|
+
* height at the room on its side (`--radix-popper-available-height`) so a long menu scrolls
|
|
6
|
+
* instead of running off the screen, and a panel capped to the room it has never overflows, so
|
|
7
|
+
* `flip` never fires. A tall panel opened toward the cramped side stayed there and shrank, with
|
|
8
|
+
* the roomy side empty. Measured 2026-10-26 in photos' "Who is this?" (forge task 3776): at
|
|
9
|
+
* 1280×720, a face with 322px above and 335px below kept the panel below it at 295px, its last
|
|
10
|
+
* button at y=841, off the screen.
|
|
11
|
+
*
|
|
12
|
+
* So the side is chosen here, against the height the content WOULD take uncapped (its
|
|
13
|
+
* `scrollHeight`): the side asked for if the panel fits there, else the opposite side, else
|
|
14
|
+
* BESIDE the anchor (where a wide screen has the whole height), else whichever of the asked-for
|
|
15
|
+
* side and its opposite has more room. The height cap stays. It is what keeps the last case on
|
|
16
|
+
* the screen.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export type FloatingSide = 'top' | 'right' | 'bottom' | 'left';
|
|
20
|
+
|
|
21
|
+
interface Rect {
|
|
22
|
+
top: number;
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
left: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Size {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const OPPOSITE: Record<FloatingSide, FloatingSide> = {
|
|
34
|
+
top: 'bottom',
|
|
35
|
+
bottom: 'top',
|
|
36
|
+
left: 'right',
|
|
37
|
+
right: 'left',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const isVertical = (side: FloatingSide): boolean => side === 'top' || side === 'bottom';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param requested the side the caller asked for
|
|
44
|
+
* @param anchor the trigger's or anchor's rect, in viewport pixels
|
|
45
|
+
* @param viewport the visible viewport
|
|
46
|
+
* @param panel the panel's natural size, uncapped
|
|
47
|
+
* @param gap the space kept between anchor and panel (`sideOffset`), plus the collision
|
|
48
|
+
* padding kept from the screen's edge
|
|
49
|
+
*/
|
|
50
|
+
export function floatingSideFor(
|
|
51
|
+
requested: FloatingSide,
|
|
52
|
+
anchor: Rect,
|
|
53
|
+
viewport: Size,
|
|
54
|
+
panel: Size,
|
|
55
|
+
gap: { offset: number; padding: number },
|
|
56
|
+
): FloatingSide {
|
|
57
|
+
const room: Record<FloatingSide, number> = {
|
|
58
|
+
top: anchor.top - gap.offset - gap.padding,
|
|
59
|
+
bottom: viewport.height - anchor.bottom - gap.offset - gap.padding,
|
|
60
|
+
left: anchor.left - gap.offset - gap.padding,
|
|
61
|
+
right: viewport.width - anchor.right - gap.offset - gap.padding,
|
|
62
|
+
};
|
|
63
|
+
const fits = (side: FloatingSide): boolean =>
|
|
64
|
+
isVertical(side)
|
|
65
|
+
? room[side] >= panel.height && panel.width <= viewport.width - 2 * gap.padding
|
|
66
|
+
: room[side] >= panel.width && panel.height <= viewport.height - 2 * gap.padding;
|
|
67
|
+
const opposite = OPPOSITE[requested];
|
|
68
|
+
if (fits(requested)) return requested;
|
|
69
|
+
if (fits(opposite)) return opposite;
|
|
70
|
+
const beside: FloatingSide[] = isVertical(requested) ? ['right', 'left'] : ['bottom', 'top'];
|
|
71
|
+
for (const side of beside) if (fits(side)) return side;
|
|
72
|
+
return room[requested] >= room[opposite] ? requested : opposite;
|
|
73
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { mergeTagLists, parseTagList, tagListText } from './tagList.js';
|
|
3
|
+
|
|
4
|
+
describe('tags on the clipboard', () => {
|
|
5
|
+
test('out as a comma line, back from commas, semicolons or lines — trimmed, each once', () => {
|
|
6
|
+
expect(tagListText(['beach', 'dog', 'golden hour'])).toBe('beach, dog, golden hour');
|
|
7
|
+
expect(parseTagList('beach, dog, golden hour')).toEqual(['beach', 'dog', 'golden hour']);
|
|
8
|
+
expect(parseTagList('Beach\ndog; Beach \r\n\n')).toEqual(['Beach', 'dog']);
|
|
9
|
+
expect(parseTagList(' ')).toEqual([]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("the app's own spelling rule decides what counts as the same tag", () => {
|
|
13
|
+
expect(parseTagList('Beach\ndogs; beach', (raw) => raw.trim().toLowerCase().replace(/s$/, ''))).toEqual(['beach', 'dog']);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('a paste adds what the item does not have yet, in the pasted order', () => {
|
|
17
|
+
expect(mergeTagLists(['dog'], ['beach', 'dog', 'sunset'])).toEqual(['dog', 'beach', 'sunset']);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tags on the clipboard — one spelling for both directions (forge task 3773 in photos; lifted for
|
|
3
|
+
* music's "copying tags like photos app does", forge task 3812). Tags go out as `a, b, c` and come
|
|
4
|
+
* back from that, from one per line, or from a mix, so what one item's tags copied as pastes onto
|
|
5
|
+
* another, and so does a list typed in a note.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The tags as a line a person can paste anywhere. */
|
|
9
|
+
export const tagListText = (tags: readonly string[]): string => tags.join(', ');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The tags in a pasted text — split on commas, semicolons and line breaks, each passed through
|
|
13
|
+
* `normalize` (the app's own spelling rule; trimming by default), empties dropped, each once, in order.
|
|
14
|
+
*/
|
|
15
|
+
export function parseTagList(text: string, normalize: (raw: string) => string = (raw) => raw.trim()): string[] {
|
|
16
|
+
const out: string[] = [];
|
|
17
|
+
for (const part of text.split(/[,;\n\r]+/)) {
|
|
18
|
+
const tag = normalize(part);
|
|
19
|
+
if (tag && !out.includes(tag)) out.push(tag);
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** `pasted` merged after `current`, without what is already there. */
|
|
25
|
+
export function mergeTagLists(current: readonly string[], pasted: readonly string[]): string[] {
|
|
26
|
+
const next = [...current];
|
|
27
|
+
for (const tag of pasted) if (!next.includes(tag)) next.push(tag);
|
|
28
|
+
return next;
|
|
29
|
+
}
|
|
@@ -32,3 +32,22 @@ describe('FocusViewer — which source the picture comes from', () => {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 🔴 A host's "Make a GIF" command opens the viewer ON the GIF — owner, 2026-10-27: *"it is
|
|
38
|
+
* unclear how to choose part of a video to make into a gif"*, when the panel was one button
|
|
39
|
+
* inside a viewer reached by "Focus and snapshot".
|
|
40
|
+
*/
|
|
41
|
+
describe('openGif', () => {
|
|
42
|
+
test('opens with the GIF section showing, from where the host was', () => {
|
|
43
|
+
render(
|
|
44
|
+
<FocusViewer onClose={() => {}} videoUrl="https://media.test/film.web.mp4" durationSeconds={60} startAt={12} openGif />,
|
|
45
|
+
);
|
|
46
|
+
expect(document.body.querySelector('section[aria-label="Make a GIF"]')).not.toBeNull();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('without it, the viewer opens on the film and the GIF waits for its button', () => {
|
|
50
|
+
render(<FocusViewer onClose={() => {}} videoUrl="https://media.test/film.web.mp4" durationSeconds={60} startAt={12} />);
|
|
51
|
+
expect(document.body.querySelector('section[aria-label="Make a GIF"]')).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -169,6 +169,13 @@ export interface FocusViewerProps {
|
|
|
169
169
|
title?: string;
|
|
170
170
|
/** Where the host's own player was when this opened. */
|
|
171
171
|
startAt?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Open with the GIF panel already showing, its section starting at {@link startAt}.
|
|
174
|
+
*
|
|
175
|
+
* 🔴 For a host's own "Make a GIF" command. Behind "Focus and snapshot" alone, the owner could
|
|
176
|
+
* not find it: *"it is unclear how to choose part of a video to make into a gif"* (2026-10-27).
|
|
177
|
+
*/
|
|
178
|
+
openGif?: boolean;
|
|
172
179
|
/** Duration the host already knows, so the surface is not blank until metadata lands. */
|
|
173
180
|
durationSeconds?: number | null;
|
|
174
181
|
/** Stills already kept beside this video, newest wherever the host wants them. */
|
|
@@ -228,6 +235,7 @@ export function FocusViewer({
|
|
|
228
235
|
hlsUrl,
|
|
229
236
|
title,
|
|
230
237
|
startAt = 0,
|
|
238
|
+
openGif = false,
|
|
231
239
|
durationSeconds,
|
|
232
240
|
snapshots = [],
|
|
233
241
|
onSaveSnapshot,
|
|
@@ -452,6 +460,15 @@ export function FocusViewer({
|
|
|
452
460
|
}, [gif, loopSection, gifProgress]);
|
|
453
461
|
|
|
454
462
|
/** Close the GIF panel, stopping a GIF still being made. */
|
|
463
|
+
// `openGif`: the section opens once the length is known, so it is clamped to the film.
|
|
464
|
+
const openedGif = useRef(false);
|
|
465
|
+
useEffect(() => {
|
|
466
|
+
if (!openGif || openedGif.current || duration <= 0) return;
|
|
467
|
+
openedGif.current = true;
|
|
468
|
+
void loadGifRecorder().catch(() => undefined);
|
|
469
|
+
setGif(gifSectionAt(startAt, duration));
|
|
470
|
+
}, [openGif, duration, startAt]);
|
|
471
|
+
|
|
455
472
|
const closeGif = (): void => {
|
|
456
473
|
gifAbort.current?.abort();
|
|
457
474
|
setGif(null);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './pictureEditor.css';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useEditorVideoSource } from './hlsSource.js';
|
|
3
4
|
import { ActionBar } from '../components/ActionBar.js';
|
|
4
5
|
import { Button } from '../components/Button.js';
|
|
5
6
|
import { Modal } from '../components/Modal.js';
|
|
@@ -42,6 +43,8 @@ export interface FrameGrabberProps {
|
|
|
42
43
|
* *"I see a black screen"* wearing a different dialog's clothes.
|
|
43
44
|
*/
|
|
44
45
|
src: string;
|
|
46
|
+
/** The adaptive ladder's master playlist — a source on its own (`useEditorVideoSource`). */
|
|
47
|
+
hlsUrl?: string | undefined;
|
|
45
48
|
/**
|
|
46
49
|
* True while the app is still finding the source (a signed URL being minted, bytes being
|
|
47
50
|
* fetched). It is the difference between "on its way" and "cannot be shown", and only the
|
|
@@ -143,6 +146,7 @@ type Grab = 'thumbnail' | 'picture';
|
|
|
143
146
|
*/
|
|
144
147
|
export function FrameGrabber({
|
|
145
148
|
src,
|
|
149
|
+
hlsUrl,
|
|
146
150
|
resolving = false,
|
|
147
151
|
name,
|
|
148
152
|
startAt = 0,
|
|
@@ -179,11 +183,12 @@ export function FrameGrabber({
|
|
|
179
183
|
*/
|
|
180
184
|
const cannotShow: string | null = resolving
|
|
181
185
|
? 'Finding this film…'
|
|
182
|
-
: !src
|
|
186
|
+
: !src && !hlsUrl
|
|
183
187
|
? 'This file has no video source to play here, so there are no frames to pick from.'
|
|
184
|
-
: failedSrc === src
|
|
188
|
+
: failedSrc === (hlsUrl || src)
|
|
185
189
|
? 'The film could not be loaded, so there are no frames to pick from.'
|
|
186
190
|
: null;
|
|
191
|
+
const source = useEditorVideoSource(videoRef, { src, hlsUrl }, cannotShow === null);
|
|
187
192
|
|
|
188
193
|
const canThumb = Boolean(onSaveThumbnail);
|
|
189
194
|
const canSnap = Boolean(onSaveSnapshot);
|
|
@@ -482,8 +487,8 @@ export function FrameGrabber({
|
|
|
482
487
|
<video
|
|
483
488
|
ref={videoRef}
|
|
484
489
|
// A new source is a new attempt — see `failedSrc`.
|
|
485
|
-
key={
|
|
486
|
-
src={src}
|
|
490
|
+
key={source.key}
|
|
491
|
+
src={source.src}
|
|
487
492
|
crossOrigin='anonymous'
|
|
488
493
|
playsInline
|
|
489
494
|
preload='metadata'
|
|
@@ -506,7 +511,9 @@ export function FrameGrabber({
|
|
|
506
511
|
if (startAt > 0) el.currentTime = startAt;
|
|
507
512
|
}}
|
|
508
513
|
onTimeUpdate={(event) => setAt(event.currentTarget.currentTime)}
|
|
509
|
-
onError={() =>
|
|
514
|
+
onError={(event) => {
|
|
515
|
+
if (source.exhausted(event.currentTarget)) setFailedSrc(source.key);
|
|
516
|
+
}}
|
|
510
517
|
/>
|
|
511
518
|
{grab === 'thumbnail' ? (
|
|
512
519
|
<canvas
|