@vitrinka/web 0.7.2 → 0.8.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/CHANGELOG.md +162 -0
- package/README.md +130 -23
- package/build/hud.iife.js +15 -15
- package/build/one.iife.js +1 -1
- package/build/recorder/api.d.ts +5 -3
- package/build/recorder/api.js +5 -3
- package/build/recorder/config.d.ts +6 -2
- package/build/recorder/hud/Hud.d.ts +3 -1
- package/build/recorder/hud/Hud.js +2 -2
- package/build/recorder/hud/Menu.d.ts +7 -1
- package/build/recorder/hud/Menu.js +2 -2
- package/build/recorder/hud/host.d.ts +13 -0
- package/build/recorder/hud/host.js +96 -1
- package/build/recorder/hud/icons.d.ts +2 -0
- package/build/recorder/hud/icons.js +4 -0
- package/build/recorder/hud/mount.d.ts +2 -0
- package/build/recorder/hud/mount.js +1 -0
- package/build/recorder/index.d.ts +6 -0
- package/build/recorder/index.js +3 -0
- package/build/recorder/link.js +1 -1
- package/build/recorder/storage/index.d.ts +1 -1
- package/build/recorder/storage/index.js +3 -2
- package/build/recorder/storage/lock.js +85 -3
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/attachments.d.ts +56 -0
- package/build/report/attachments.js +91 -0
- package/build/report/drag.d.ts +18 -0
- package/build/report/drag.js +34 -0
- package/build/report/element.d.ts +11 -2
- package/build/report/element.js +106 -15
- package/build/report/engine.d.ts +13 -1
- package/build/report/engine.js +31 -4
- package/build/report/face.d.ts +23 -0
- package/build/report/face.js +92 -0
- package/build/report/i18n.d.ts +77 -3
- package/build/report/i18n.js +127 -6
- package/build/report/place.d.ts +26 -0
- package/build/report/place.js +33 -0
- package/build/report/reader.d.ts +42 -0
- package/build/report/reader.js +39 -0
- package/build/report/recorder-face.js +6 -2
- package/build/report/sent.d.ts +16 -0
- package/build/report/sent.js +39 -0
- package/build/report/settings.d.ts +32 -0
- package/build/report/settings.js +47 -0
- package/build/report/styles.d.ts +1 -1
- package/build/report/styles.js +223 -53
- package/build/report/widget.d.ts +122 -3
- package/build/report/widget.js +1125 -107
- package/build/report/wire.d.ts +59 -9
- package/build/report/wire.js +114 -14
- package/build/report-widget.mjs +232 -62
- package/package.json +1 -1
package/build/report/widget.js
CHANGED
|
@@ -4,34 +4,61 @@
|
|
|
4
4
|
* - A large floating "Report a problem" button (hidden with `button: false`;
|
|
5
5
|
* the host then opens it from its own control, `open-selector`, or
|
|
6
6
|
* `open()`), and the reporter's own shortcut (keybind.ts).
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* - ONE card (vt-8020 D10 A), one fixed size from drafting through sending
|
|
8
|
+
* to thanks: the reporter's word for it (vt-8020 D11 chips), "What went wrong?",
|
|
9
|
+
* one numbered note line per mark, and Send — the capture frozen when the
|
|
10
|
+
* card opens (the buffer rolls on).
|
|
11
|
+
* - "Show us where" marks the frozen page under a top bar (vt-8020 D6 A): a segmented
|
|
12
|
+
* circle · box · arrow · hide, and Cancel, which leaves marking and drops
|
|
13
|
+
* this pass's marks (vt-8020 D12). The card stays on screen while marking, parked
|
|
14
|
+
* in the corner that covers none of the marks (place.ts). No element
|
|
15
|
+
* selector. Until the first mark exists a coach card rides beside the
|
|
16
|
+
* pointer with a tiny loop of the gesture and the words "click, hold and
|
|
17
|
+
* move".
|
|
18
|
+
* - The reporter's files (vt-8020 D9, attachments.ts): 📎 in the card's foot,
|
|
19
|
+
* paste or drop onto the card; chips above the foot, refused at once past
|
|
20
|
+
* the project's caps, sent on the wire's attachment leg.
|
|
21
|
+
* - The button drags to any corner, or moves with Alt+arrows (drag.ts); the
|
|
22
|
+
* card rests beside it. Settings adds the size (S · M · L, settings.ts)
|
|
23
|
+
* and the technical details a support conversation asks for.
|
|
13
24
|
* - Rendered once into the shared HUD host's shadow root (top layer,
|
|
14
25
|
* shielded, blocked from rrweb); `paint()` rewrites text and state in place,
|
|
15
26
|
* so a locale switch keeps the typed draft, the marks and their notes.
|
|
16
27
|
* Drafts live in memory only.
|
|
17
28
|
*/
|
|
29
|
+
import { LinkExpired, linkWorkspace, pollLink, startLink } from '@vitrinka/link';
|
|
30
|
+
import { api, VitrinkaApiError } from '../recorder/api';
|
|
18
31
|
import { redactUrl } from '../recorder/capture/redact';
|
|
32
|
+
import { clearLink, defaultLinkLabel, readLink, storeLink } from '../recorder/config';
|
|
33
|
+
import { readRecents } from '../recorder/recents';
|
|
19
34
|
import { createHudHost, createSheetHost, insideHud, sheetTarget } from '../recorder/hud/host';
|
|
20
35
|
import { listen } from '../recorder/hud/listen';
|
|
36
|
+
import { RECORDER_VERSION } from '../recorder/version';
|
|
37
|
+
import { admit, DEFAULT_ATTACHMENT_CAPS, formatBytes, pastedName, typesLabel } from './attachments';
|
|
38
|
+
import { cornerToward, DRAG_THRESHOLD, nearestCorner, readDock, saveDock } from './drag';
|
|
39
|
+
import { memberLinked, rememberDisplayMode } from './face';
|
|
21
40
|
import { acquireEngine, releaseEngine } from './engine';
|
|
22
|
-
import { browserLocale, parseLocale, strings } from './i18n';
|
|
41
|
+
import { browserLocale, parseLocale, REPORT_KINDS, strings } from './i18n';
|
|
23
42
|
import { normalizeIdentity, onSharedIdentity, sharedIdentity } from './identity';
|
|
24
43
|
import { keybindLabel, loadKeybind, matchesKeybind, readKeybindPress, saveKeybind, watchKeybind } from './keybind';
|
|
25
44
|
import { arrowEnds, arrowHead, isMark, rectBetween, renumber, toWire, } from './markers';
|
|
45
|
+
import { cornerRect, pickCorner } from './place';
|
|
46
|
+
import { listMine, openSession, sessionLive } from './reader';
|
|
47
|
+
import { noteSent, readSent } from './sent';
|
|
48
|
+
import { readSize, SIZE_KEY, SIZE_SCALE, SIZES, techDetails, writePref } from './settings';
|
|
26
49
|
import { REPORT_CSS } from './styles';
|
|
27
|
-
import { ReportJob } from './wire';
|
|
50
|
+
import { EMPTY_CAPTURE, prepareCapture, ReportJob } from './wire';
|
|
28
51
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
29
52
|
const TITLE_CAP = 100;
|
|
30
|
-
const EMPTY_CAPTURE = { chunks: [], truncated: false, console: [], network: [] };
|
|
31
53
|
const TOOLS = ['circle', 'box', 'arrow', 'hide'];
|
|
32
54
|
/** A keyboard mark starts as this, centred; arrows move it 10 px, Shift+arrows resize it. */
|
|
33
55
|
const KB_DRAFT = { w: 160, h: 80 };
|
|
34
56
|
const MIN_KB_SIZE = 16;
|
|
57
|
+
/** The one card's size (vt-8020 D10: it never changes between states) and the clear band the marking bar keeps at the top. */
|
|
58
|
+
const CARD = { w: 380, h: 460 };
|
|
59
|
+
const BAR_CLEAR = 72;
|
|
60
|
+
/** The gap a parked card keeps on a side it did not rest against. */
|
|
61
|
+
const PARK_EDGE = 16;
|
|
35
62
|
const KB_STEPS = {
|
|
36
63
|
ArrowLeft: [-10, 0],
|
|
37
64
|
ArrowRight: [10, 0],
|
|
@@ -40,7 +67,19 @@ const KB_STEPS = {
|
|
|
40
67
|
};
|
|
41
68
|
const ICON = {
|
|
42
69
|
close: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
|
43
|
-
|
|
70
|
+
// A toothed cog: the sun-like ring of rays read as brightness, not settings.
|
|
71
|
+
gear: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.9 1.5h2.2l.35 1.75a5 5 0 011.3.75l1.7-.57 1.1 1.9-1.35 1.18a5 5 0 010 1.5l1.35 1.18-1.1 1.9-1.7-.57a5 5 0 01-1.3.75L9.1 14.5H6.9l-.35-1.75a5 5 0 01-1.3-.75l-1.7.57-1.1-1.9 1.35-1.18a5 5 0 010-1.5L2.45 6.81l1.1-1.9 1.7.57a5 5 0 011.3-.75z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>',
|
|
72
|
+
circle: '<svg viewBox="0 0 16 16" aria-hidden="true"><ellipse cx="8" cy="8" rx="6" ry="4.6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
73
|
+
box: '<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.2" y="3.4" width="11.6" height="9.2" rx="1.8" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
74
|
+
arrow: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 13L12.5 3.5M7 3.5h5.5V9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
75
|
+
hide: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8s2.3-4 6-4 6 4 6 4-2.3 4-6 4-6-4-6-4z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M3 13L13 3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',
|
|
76
|
+
dots: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="3.5" cy="8" r="1.3" fill="currentColor"/><circle cx="8" cy="8" r="1.3" fill="currentColor"/><circle cx="12.5" cy="8" r="1.3" fill="currentColor"/></svg>',
|
|
77
|
+
left: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5L5.5 8l4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
78
|
+
ext: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9 3h4v4M13 3L7.5 8.5M11 9.5V13H3V5h3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
79
|
+
list: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 4h8M5.5 8h8M5.5 12h8M2.5 4h.01M2.5 8h.01M2.5 12h.01" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
|
80
|
+
clock: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8l2.2 1.6" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',
|
|
81
|
+
rec: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><circle cx="8" cy="8" r="2.8" fill="currentColor"/></svg>',
|
|
82
|
+
link: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M7 9a3 3 0 004.2 0l2-2a3 3 0 00-4.2-4.2l-.8.8M9 7a3 3 0 00-4.2 0l-2 2a3 3 0 004.2 4.2l.8-.8" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',
|
|
44
83
|
clip: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',
|
|
45
84
|
chevron: '<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
46
85
|
pen: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',
|
|
@@ -98,47 +137,153 @@ function deepActiveElement() {
|
|
|
98
137
|
return null;
|
|
99
138
|
return active instanceof HTMLElement || active instanceof SVGElement ? active : null;
|
|
100
139
|
}
|
|
140
|
+
/** Up to two initials of a name, or an email's first letter. */
|
|
141
|
+
function initials(label) {
|
|
142
|
+
const words = label.split('@')[0]?.split(/[\s._-]+/).filter(Boolean) ?? [];
|
|
143
|
+
return words.slice(0, 2).map((w) => w[0]?.toUpperCase() ?? '').join('') || '?';
|
|
144
|
+
}
|
|
145
|
+
/** A menu row's text: the span after its icon. */
|
|
146
|
+
function setLabel(el, text) {
|
|
147
|
+
const span = el.querySelector('span');
|
|
148
|
+
if (span)
|
|
149
|
+
span.textContent = text;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A segmented control's sliding indicator under its picked segment (the marking bar's shapes, the settings' sizes);
|
|
153
|
+
* unmeasurable while hidden. It slides only from one pick to the next: its first placement, and `land` (its bar just
|
|
154
|
+
* appeared), put it in place on the frame it shows — slid there, it would grow from width 0 at the control's edge
|
|
155
|
+
* (or from where a hidden bar last left it), with the picked segment bare until it arrived.
|
|
156
|
+
*/
|
|
157
|
+
function placeIndicator(seg, ind, btn, land = false) {
|
|
158
|
+
if (!btn || !btn.offsetWidth)
|
|
159
|
+
return;
|
|
160
|
+
const jump = land || !seg.classList.contains('measured');
|
|
161
|
+
if (jump)
|
|
162
|
+
ind.style.transition = 'none';
|
|
163
|
+
ind.style.width = `${btn.offsetWidth}px`;
|
|
164
|
+
ind.style.transform = `translateX(${btn.offsetLeft}px)`;
|
|
165
|
+
seg.classList.add('measured');
|
|
166
|
+
if (!jump)
|
|
167
|
+
return;
|
|
168
|
+
// The read commits the placement as the style the slide starts from, so restoring the slide animates nothing.
|
|
169
|
+
void ind.offsetWidth;
|
|
170
|
+
ind.style.removeProperty('transition');
|
|
171
|
+
}
|
|
172
|
+
/** A text field has the focus — its own editing keys (⌘Z included) are its. */
|
|
173
|
+
function typing() {
|
|
174
|
+
const el = deepActiveElement();
|
|
175
|
+
return el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || (el instanceof HTMLElement && el.isContentEditable);
|
|
176
|
+
}
|
|
101
177
|
/** The widget's DOM, built once into the HUD host's shadow mount. */
|
|
102
178
|
function buildDom(mount) {
|
|
103
179
|
const fabLabel = h('span');
|
|
104
180
|
const fabKbd = h('kbd');
|
|
105
181
|
const fab = h('button', { class: 'fab', type: 'button', part: 'button', 'aria-haspopup': 'dialog' }, fabLabel, fabKbd);
|
|
106
182
|
const title = h('h2', { id: 'vr-title' });
|
|
107
|
-
|
|
183
|
+
// Who you are, at a glance (vt-8020 D5 A): the chip opens the account popover, ⋯ the menu.
|
|
184
|
+
const whoAv = h('span', { class: 'av', 'aria-hidden': 'true' });
|
|
185
|
+
const whoName = h('span', { class: 'who-name' });
|
|
186
|
+
const whoBtn = h('button', { class: 'who', type: 'button', 'aria-haspopup': 'dialog', 'aria-expanded': 'false' }, whoAv, whoName);
|
|
187
|
+
const more = h('button', { class: 'icon', type: 'button', 'aria-haspopup': 'menu', 'aria-expanded': 'false' }, icon(ICON.dots));
|
|
108
188
|
const closeBtn = h('button', { class: 'icon', type: 'button' }, icon(ICON.close));
|
|
109
|
-
const head = h('header', { class: 'head' }, title,
|
|
189
|
+
const head = h('header', { class: 'head' }, title, whoBtn, more, closeBtn);
|
|
190
|
+
const accName = h('strong');
|
|
191
|
+
const accMail = h('span', { class: 'acc-mail' });
|
|
192
|
+
const accVia = h('p', { class: 'acc-via' });
|
|
193
|
+
const accLinked = h('p', { class: 'acc-linked' });
|
|
194
|
+
const accUnlink = h('button', { class: 'link', type: 'button' });
|
|
195
|
+
const accLink = h('button', { class: 'pop-item', type: 'button' }, icon(ICON.link), h('span'));
|
|
196
|
+
const accPortal = h('a', { class: 'pop-item', target: '_blank', rel: 'noopener noreferrer' }, icon(ICON.ext), h('span'));
|
|
197
|
+
const accountPop = h('div', { class: 'pop acc', role: 'dialog' }, h('div', { class: 'acc-who' }, accName, accMail, accVia), h('div', { class: 'acc-member' }, accLinked, accUnlink), accLink, accPortal);
|
|
198
|
+
const menuItem = (glyph) => h('button', { class: 'pop-item', type: 'button', role: 'menuitem' }, icon(glyph), h('span'));
|
|
199
|
+
const mReports = menuItem(ICON.list);
|
|
200
|
+
const mRecents = menuItem(ICON.clock);
|
|
201
|
+
const mRecord = menuItem(ICON.rec);
|
|
202
|
+
// Why Record waits, a second line under its label: its description, so aria-hidden keeps it out of the name.
|
|
203
|
+
const mRecordWhy = h('small', { class: 'pop-why', id: 'vr-record-why', 'aria-hidden': 'true' });
|
|
204
|
+
mRecord.append(mRecordWhy);
|
|
205
|
+
const mSettings = menuItem(ICON.gear);
|
|
206
|
+
const mOpen = h('a', { class: 'pop-item', role: 'menuitem', target: '_blank', rel: 'noopener noreferrer' }, icon(ICON.ext), h('span'));
|
|
207
|
+
const morePop = h('div', { class: 'pop more', role: 'menu' }, mReports, mRecents, mRecord, mSettings, mOpen);
|
|
208
|
+
const kindsLabel = h('span', { class: 'sr', id: 'vr-kinds' });
|
|
209
|
+
const kindButtons = new Map();
|
|
210
|
+
for (const k of REPORT_KINDS)
|
|
211
|
+
kindButtons.set(k, h('button', { type: 'button', role: 'radio', 'aria-checked': 'false', 'data-kind': k }));
|
|
212
|
+
const kinds = h('div', { class: 'kinds', role: 'radiogroup', 'aria-labelledby': 'vr-kinds' }, kindsLabel, ...kindButtons.values());
|
|
110
213
|
const prompt = h('label', { class: 'prompt', for: 'vr-desc' });
|
|
111
214
|
const desc = h('textarea', { class: 'desc', id: 'vr-desc', rows: '3' });
|
|
215
|
+
const lines = h('ol', { class: 'lines' });
|
|
216
|
+
const linesEmpty = h('p', { class: 'ln-empty' });
|
|
112
217
|
const attachedText = h('span');
|
|
113
218
|
const discloseText = h('span');
|
|
114
219
|
const disclose = h('button', { class: 'link', type: 'button', 'aria-expanded': 'false', 'aria-controls': 'vr-included' }, discloseText, icon(ICON.chevron));
|
|
115
220
|
const attached = h('div', { class: 'attached' }, icon(ICON.clip), attachedText, h('span', { 'aria-hidden': 'true' }, '·'), disclose);
|
|
116
221
|
const included = h('ul', { class: 'included', id: 'vr-included' });
|
|
117
|
-
const markedChips = h('span', { class: 'chips' });
|
|
118
|
-
const markedText = h('span');
|
|
119
|
-
const marked = h('div', { class: 'marked' }, markedChips, markedText);
|
|
120
222
|
const notifyBox = h('input', { type: 'checkbox' });
|
|
121
223
|
const notifyText = h('span');
|
|
122
224
|
const notify = h('label', { class: 'notify' }, notifyBox, notifyText);
|
|
123
225
|
const error = h('p', { class: 'error', role: 'alert' });
|
|
124
226
|
const whereText = h('span');
|
|
125
|
-
const where = h('button', { class: 'where', type: 'button' }, icon(ICON.pen), whereText);
|
|
227
|
+
const where = h('button', { class: 'where', type: 'button', 'aria-pressed': 'false' }, icon(ICON.pen), whereText);
|
|
126
228
|
const send = h('button', { class: 'send', type: 'button' });
|
|
127
|
-
const describe = h('div', { class: 'pane describe' }, prompt, desc,
|
|
229
|
+
const describe = h('div', { class: 'pane describe' }, kinds, prompt, desc, h('div', { class: 'lines-wrap' }, lines, linesEmpty), attached, included, notify, error);
|
|
230
|
+
// The reporter's files (vt-8020 D9): 📎 opens the picker (paste and drop land on the card too);
|
|
231
|
+
// the chips sit in a tray above the foot that scrolls — the card never grows.
|
|
232
|
+
const attach = h('button', { class: 'icon', type: 'button' }, icon(ICON.clip));
|
|
233
|
+
const fileInput = h('input', { type: 'file', multiple: '', tabindex: '-1', 'aria-hidden': 'true', hidden: '' });
|
|
234
|
+
const fileNote = h('p', { class: 'file-note', role: 'status' });
|
|
235
|
+
const files = h('ul', { class: 'files' });
|
|
236
|
+
const tray = h('div', { class: 'tray' }, fileNote, files);
|
|
237
|
+
// The bottom actions, the chat-input foot of the board's composer: attachments, `where`, Send.
|
|
238
|
+
const foot = h('div', { class: 'foot' }, attach, fileInput, where, send);
|
|
128
239
|
const bindLabel = h('span', { class: 'label', id: 'vr-bind-label' });
|
|
129
240
|
const bindBtn = h('button', { class: 'bind', type: 'button', 'aria-pressed': 'false', 'aria-describedby': 'vr-bind-label' });
|
|
130
241
|
const unbind = h('button', { class: 'link', type: 'button' });
|
|
131
242
|
const bindHint = h('p', { class: 'hint' });
|
|
132
243
|
const bindReason = h('p', { class: 'reason', role: 'status' });
|
|
133
244
|
const back = h('button', { class: 'link', type: 'button' });
|
|
134
|
-
|
|
245
|
+
// Size (vt-8020 D9): the marking bar's segmented control, its indicator sliding under the pick.
|
|
246
|
+
const sizeLabel = h('span', { class: 'label', id: 'vr-size-label' });
|
|
247
|
+
const sizeButtons = new Map();
|
|
248
|
+
for (const z of SIZES)
|
|
249
|
+
sizeButtons.set(z, h('button', { type: 'button', role: 'radio', 'aria-checked': 'false', 'data-size': z }));
|
|
250
|
+
const sizeInd = h('span', { class: 'seg-ind', 'aria-hidden': 'true' });
|
|
251
|
+
const sizeSeg = h('div', { class: 'seg', role: 'radiogroup', 'aria-labelledby': 'vr-size-label' }, sizeInd, ...sizeButtons.values());
|
|
252
|
+
// Technical details: read-only, for support conversations.
|
|
253
|
+
const techText = h('span');
|
|
254
|
+
const techBtn = h('button', { class: 'link', type: 'button', 'aria-expanded': 'false', 'aria-controls': 'vr-tech' }, techText, icon(ICON.chevron));
|
|
255
|
+
const tech = h('dl', { class: 'tech', id: 'vr-tech' });
|
|
256
|
+
const settings = h('div', { class: 'pane settings' }, h('div', { class: 'row' }, bindLabel, bindBtn), bindReason, bindHint, h('div', { class: 'row size-row' }, sizeLabel, sizeSeg), h('div', { class: 'tech-wrap' }, techBtn, tech), h('div', { class: 'settings-foot' }, back, unbind));
|
|
135
257
|
const sentTitle = h('h3');
|
|
136
258
|
const sentBody = h('p', { class: 'sent-body' });
|
|
137
259
|
const seeText = h('span');
|
|
138
260
|
const see = h('a', { class: 'see', target: '_blank', rel: 'noopener noreferrer' }, seeText);
|
|
139
261
|
const sentClose = h('button', { class: 'link', type: 'button' });
|
|
140
262
|
const sent = h('div', { class: 'pane sent', role: 'status' }, h('div', { class: 'sent-head' }, icon(ICON.check), sentTitle), sentBody, h('div', { class: 'sent-actions' }, see, sentClose));
|
|
141
|
-
|
|
263
|
+
// A list opens in the card body with ← back (vt-8020 D5); the card keeps its size.
|
|
264
|
+
const backRow = () => h('button', { class: 'back', type: 'button' }, icon(ICON.left), h('span'));
|
|
265
|
+
const repBack = backRow();
|
|
266
|
+
const repStatus = h('p', { class: 'list-status' });
|
|
267
|
+
const repRows = h('ul', { class: 'rows' });
|
|
268
|
+
const repLocal = h('p', { class: 'list-note' });
|
|
269
|
+
const repPortal = h('a', { class: 'link', target: '_blank', rel: 'noopener noreferrer' });
|
|
270
|
+
const reports = h('div', { class: 'pane list' }, repBack, repStatus, repRows, repLocal, repPortal);
|
|
271
|
+
const recBack = backRow();
|
|
272
|
+
const recStatus = h('p', { class: 'list-status' });
|
|
273
|
+
const recRows = h('ul', { class: 'rows' });
|
|
274
|
+
const recents = h('div', { class: 'pane list' }, recBack, recStatus, recRows);
|
|
275
|
+
const linkBack = backRow();
|
|
276
|
+
const linkLabel = h('p', { class: 'list-note' });
|
|
277
|
+
const linkCode = h('div', { class: 'code' });
|
|
278
|
+
const linkOpenText = h('span');
|
|
279
|
+
const linkOpen = h('a', { class: 'see', target: '_blank', rel: 'noopener noreferrer' }, linkOpenText);
|
|
280
|
+
const linkQr = h('img', { class: 'qr', alt: '' });
|
|
281
|
+
const linkHint = h('p', { class: 'hint' });
|
|
282
|
+
const linkWait = h('p', { class: 'list-status', role: 'status' });
|
|
283
|
+
const linkRetry = h('button', { class: 'link', type: 'button' });
|
|
284
|
+
const linking = h('div', { class: 'pane linking' }, linkBack, linkLabel, linkCode, h('div', { class: 'link-go' }, linkOpen, linkQr), linkHint, linkWait, linkRetry);
|
|
285
|
+
const body = h('div', { class: 'body' }, describe, settings, sent, reports, recents, linking);
|
|
286
|
+
const card = h('section', { class: 'card', role: 'dialog', 'aria-modal': 'false', 'aria-labelledby': 'vr-title' }, head, accountPop, morePop, body, tray, foot);
|
|
142
287
|
const ink = svgEl('svg', { class: 'ink', 'aria-hidden': 'true' });
|
|
143
288
|
const defs = svgEl('defs', {});
|
|
144
289
|
const headMarker = svgEl('marker', { id: 'vr-head', viewBox: '0 0 10 10', refX: 7, refY: 5, markerWidth: 5, markerHeight: 5, orient: 'auto-start-reverse' });
|
|
@@ -153,28 +298,47 @@ function buildDom(mount) {
|
|
|
153
298
|
const coachKeys = h('p', { class: 'keys', id: 'vr-keys' });
|
|
154
299
|
const coach = h('div', { class: 'coach', role: 'status' });
|
|
155
300
|
coach.append(icon(coachArt(reducedMotion())), coachText, coachMore, coachKeys);
|
|
301
|
+
// The top bar (vt-8020 D6): one plain line, the shape as a segmented control whose indicator slides, Cancel.
|
|
156
302
|
const toolButtons = new Map();
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
303
|
+
const toolLabels = new Map();
|
|
304
|
+
for (const t of TOOLS) {
|
|
305
|
+
const label = h('span');
|
|
306
|
+
toolLabels.set(t, label);
|
|
307
|
+
toolButtons.set(t, h('button', { type: 'button', role: 'radio', 'aria-checked': 'false', 'data-tool': t }, icon(ICON[t]), label));
|
|
308
|
+
}
|
|
309
|
+
const segInd = h('span', { class: 'seg-ind', 'aria-hidden': 'true' });
|
|
310
|
+
const seg = h('div', { class: 'seg', role: 'radiogroup' }, segInd, ...toolButtons.values());
|
|
311
|
+
const barLead = h('span', { class: 'tb-lead' });
|
|
312
|
+
const cancel = h('button', { type: 'button', class: 'tb-quiet' });
|
|
313
|
+
const askText = h('span', { class: 'tb-ask' });
|
|
314
|
+
const discard = h('button', { type: 'button', class: 'tb-discard' });
|
|
315
|
+
const keep = h('button', { type: 'button', class: 'tb-quiet' });
|
|
316
|
+
const ask = h('span', { class: 'tb-confirm', role: 'group' }, askText, discard, keep);
|
|
317
|
+
const toolbar = h('div', { class: 'tb', role: 'toolbar' }, barLead, seg, h('span', { class: 'tb-sep', 'aria-hidden': 'true' }), cancel, ask);
|
|
162
318
|
// Focusable: from the keyboard, Enter places a mark the arrows then move (markKey).
|
|
163
319
|
const mark = h('div', { class: 'mark', tabindex: '0', role: 'application', 'aria-describedby': 'vr-keys' }, pins, coach, toolbar);
|
|
164
320
|
mark.prepend(ink);
|
|
165
|
-
|
|
321
|
+
// The card after the marking layer: it stays on top of it, usable, while the reporter marks.
|
|
322
|
+
const root = h('div', { class: 'vr' }, fab, mark, card);
|
|
166
323
|
const style = h('style');
|
|
167
324
|
style.textContent = REPORT_CSS;
|
|
168
325
|
// The sheet rides inside the root: the whole tree moves into an open dialog and back (followDialog).
|
|
169
326
|
root.prepend(style);
|
|
170
327
|
mount.append(root);
|
|
171
328
|
return {
|
|
172
|
-
root, fab, fabLabel, fabKbd, card, title,
|
|
173
|
-
|
|
329
|
+
root, fab, fabLabel, fabKbd, card, head, title, whoBtn, whoAv, whoName, more, closeBtn, body, foot,
|
|
330
|
+
accountPop, accName, accMail, accVia, accLinked, accUnlink, accLink, accPortal,
|
|
331
|
+
morePop, mReports, mRecents, mRecord, mRecordWhy, mSettings, mOpen,
|
|
332
|
+
reports, repBack, repStatus, repRows, repLocal, repPortal, recents, recBack, recStatus, recRows,
|
|
333
|
+
linking, linkBack, linkLabel, linkCode, linkOpen, linkOpenText, linkQr, linkHint, linkWait, linkRetry,
|
|
334
|
+
describe, kinds, kindsLabel, kindButtons, prompt, desc, lines, linesEmpty, attached, attachedText, disclose, discloseText, included,
|
|
174
335
|
notify, notifyBox, notifyText, error, where, whereText, send,
|
|
336
|
+
attach, fileInput, fileNote, files, tray,
|
|
175
337
|
settings, bindLabel, bindBtn, unbind, bindHint, bindReason, back,
|
|
338
|
+
sizeLabel, sizeButtons, sizeInd, sizeSeg, techText, techBtn, tech,
|
|
176
339
|
sent, sentTitle, sentBody, see, seeText, sentClose,
|
|
177
|
-
mark, ink, shapes, draft, pins, coach, coachText, coachMore, coachKeys,
|
|
340
|
+
mark, ink, shapes, draft, pins, coach, coachText, coachMore, coachKeys,
|
|
341
|
+
toolbar, barLead, seg, segInd, toolButtons, toolLabels, cancel, ask, askText, discard, keep,
|
|
178
342
|
};
|
|
179
343
|
}
|
|
180
344
|
export class ReportWidget {
|
|
@@ -200,6 +364,7 @@ export class ReportWidget {
|
|
|
200
364
|
frozen = null;
|
|
201
365
|
job = null;
|
|
202
366
|
sending = false;
|
|
367
|
+
/** Which leg a failed send stopped at: nothing reached the server, a file, or the replay. */
|
|
203
368
|
error = '';
|
|
204
369
|
result = null;
|
|
205
370
|
notify = false;
|
|
@@ -207,11 +372,45 @@ export class ReportWidget {
|
|
|
207
372
|
includedOpen = false;
|
|
208
373
|
recordingBind = false;
|
|
209
374
|
bindRefused = false;
|
|
210
|
-
/** The
|
|
211
|
-
|
|
375
|
+
/** The reporter's own word for it (vt-8020 D11); null until they pick one. */
|
|
376
|
+
kind = null;
|
|
377
|
+
/** The marks that existed when this marking pass began: Cancel keeps exactly these (vt-8020 D12). */
|
|
378
|
+
passKeys = new Set();
|
|
379
|
+
/** Cancel asked "Discard N marks?" and waits for the answer. */
|
|
380
|
+
confirming = false;
|
|
381
|
+
/** The corner the card is parked in once marking has moved it; null = its anchored place. */
|
|
382
|
+
parked = null;
|
|
383
|
+
/** The insets marking parks the card with, read where it rested when marking started (insetsAt). */
|
|
384
|
+
parkInsets = null;
|
|
385
|
+
/** The corner the button docks in (drag.ts); the card rests beside it and marking parks it from there. */
|
|
386
|
+
dock = readDock();
|
|
387
|
+
size = readSize();
|
|
388
|
+
techOpen = false;
|
|
389
|
+
/** A press on the button: it becomes a drag once it travels DRAG_THRESHOLD; `grab` is where the pointer holds it. */
|
|
390
|
+
fabDrag = null;
|
|
391
|
+
/** The click that ends a drag is the drop, not a press of the button. */
|
|
392
|
+
swallowClick = false;
|
|
393
|
+
/** The button's glide to its new corner, while it runs. */
|
|
394
|
+
glide = null;
|
|
395
|
+
/** The reporter's attachments (vt-8020 D9), in the order added, and the reason the last refused one got. */
|
|
396
|
+
files = [];
|
|
397
|
+
fileRefusal = null;
|
|
398
|
+
pastes = 0;
|
|
399
|
+
chips = new Map();
|
|
400
|
+
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
401
|
+
recordSwitch = null;
|
|
402
|
+
menu = null;
|
|
403
|
+
/** The reporter session the host's signed token was traded for (vt-8020 D4), and that token. */
|
|
404
|
+
session = null;
|
|
405
|
+
sessionToken = '';
|
|
406
|
+
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
407
|
+
member = null;
|
|
408
|
+
mine = { rows: [], state: 'ok' };
|
|
409
|
+
linkFlow = null;
|
|
212
410
|
drawing = null;
|
|
213
411
|
offs = [];
|
|
214
412
|
pins = new Map();
|
|
413
|
+
lines = new Map();
|
|
215
414
|
/** Per hide mark: the page nodes it covered when drawn (they are blanked in the capture). */
|
|
216
415
|
hideIds = new Map();
|
|
217
416
|
/** Native dialogs in the order they opened (seeded with those already open, in DOM order). */
|
|
@@ -302,6 +501,9 @@ export class ReportWidget {
|
|
|
302
501
|
this.frozen = this.engine?.freeze() ?? null;
|
|
303
502
|
this.paint();
|
|
304
503
|
requestAnimationFrame(() => this.e.desc.focus());
|
|
504
|
+
// Who you are fills the chip as soon as the server says it.
|
|
505
|
+
void this.refreshWho();
|
|
506
|
+
void this.refreshMember();
|
|
305
507
|
}
|
|
306
508
|
close() {
|
|
307
509
|
if (!this.isOpen)
|
|
@@ -311,6 +513,7 @@ export class ReportWidget {
|
|
|
311
513
|
this.stopRecordingBind();
|
|
312
514
|
this.isOpen = false;
|
|
313
515
|
this.view = 'describe';
|
|
516
|
+
this.unpark();
|
|
314
517
|
this.paint();
|
|
315
518
|
// Focus goes back where it came from — the host's control, the field the
|
|
316
519
|
// shortcut fired in — else to the button; never lost to <body> when the
|
|
@@ -338,13 +541,23 @@ export class ReportWidget {
|
|
|
338
541
|
setOpenSelector(sel) {
|
|
339
542
|
this.openSelector = sel || null;
|
|
340
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* The way to the recorder pill (vt-8020 D8): element.ts sets it only for a
|
|
546
|
+
* linked vitrinka member — the menu then offers "Record" — and clears it
|
|
547
|
+
* with null; reporters never get one.
|
|
548
|
+
*/
|
|
549
|
+
setRecordSwitch(fn) {
|
|
550
|
+
this.recordSwitch = fn;
|
|
551
|
+
this.paint();
|
|
552
|
+
}
|
|
341
553
|
identify(input) {
|
|
342
554
|
// null (or a malformed identity) is this widget going anonymous; undefined hands it back to the page-wide one.
|
|
343
555
|
this.identity = input === undefined ? undefined : normalizeIdentity(input);
|
|
344
|
-
this.
|
|
556
|
+
this.whoChanged();
|
|
345
557
|
}
|
|
346
558
|
unmount() {
|
|
347
559
|
this.stopRecordingBind();
|
|
560
|
+
this.linkFlow?.abort.abort();
|
|
348
561
|
for (const off of this.offs.splice(0).reverse())
|
|
349
562
|
off();
|
|
350
563
|
releaseEngine(this.engine);
|
|
@@ -358,9 +571,138 @@ export class ReportWidget {
|
|
|
358
571
|
const on = (el, type, fn) => {
|
|
359
572
|
el.addEventListener(type, fn);
|
|
360
573
|
};
|
|
361
|
-
on(e.fab, 'click', () =>
|
|
574
|
+
on(e.fab, 'click', () => {
|
|
575
|
+
if (this.swallowClick) {
|
|
576
|
+
this.swallowClick = false;
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (this.isOpen)
|
|
580
|
+
this.close();
|
|
581
|
+
else
|
|
582
|
+
this.open();
|
|
583
|
+
});
|
|
584
|
+
// The button moves to any corner (vt-8020 D9): dragged, or Alt+arrows while it has the focus.
|
|
585
|
+
on(e.fab, 'pointerdown', (ev) => this.fabDown(ev));
|
|
586
|
+
on(e.fab, 'pointermove', (ev) => this.fabMove(ev));
|
|
587
|
+
on(e.fab, 'pointerup', (ev) => this.fabUp(ev, true));
|
|
588
|
+
on(e.fab, 'pointercancel', (ev) => this.fabUp(ev, false));
|
|
589
|
+
on(e.fab, 'keydown', (ev) => {
|
|
590
|
+
if (!ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey)
|
|
591
|
+
return;
|
|
592
|
+
const next = cornerToward(this.dock, ev.key);
|
|
593
|
+
if (!next)
|
|
594
|
+
return;
|
|
595
|
+
ev.preventDefault(); // Alt+← is the browser's Back
|
|
596
|
+
if (next !== this.dock)
|
|
597
|
+
this.moveDock(next);
|
|
598
|
+
});
|
|
599
|
+
on(e.attach, 'click', () => e.fileInput.click());
|
|
600
|
+
on(e.fileInput, 'change', () => {
|
|
601
|
+
this.addFiles([...(e.fileInput.files ?? [])]);
|
|
602
|
+
e.fileInput.value = ''; // the same file picked again is a new pick
|
|
603
|
+
});
|
|
604
|
+
// A pasted or dropped file joins the attachments; pasted or dropped text stays the field's.
|
|
605
|
+
on(e.card, 'paste', (ev) => {
|
|
606
|
+
const pasted = [...(ev.clipboardData?.files ?? [])];
|
|
607
|
+
if (!pasted.length || !this.canAttach())
|
|
608
|
+
return;
|
|
609
|
+
// Office puts copied text beside an image of it: the text wins, unless it is only the copied file's name (the pill's rule, Sheet.tsx).
|
|
610
|
+
const text = ev.clipboardData?.getData('text/plain').trim() ?? '';
|
|
611
|
+
if (text && !pasted.some((f) => f.name && text.includes(f.name)))
|
|
612
|
+
return;
|
|
613
|
+
ev.preventDefault();
|
|
614
|
+
this.addFiles(pasted.map((f) => {
|
|
615
|
+
const name = pastedName(f.name, ++this.pastes);
|
|
616
|
+
return name === f.name ? f : new File([f], name, { type: f.type, lastModified: f.lastModified });
|
|
617
|
+
}));
|
|
618
|
+
});
|
|
619
|
+
on(e.card, 'dragover', (ev) => {
|
|
620
|
+
if (!ev.dataTransfer?.types.includes('Files') || !this.canAttach())
|
|
621
|
+
return;
|
|
622
|
+
ev.preventDefault();
|
|
623
|
+
ev.dataTransfer.dropEffect = 'copy';
|
|
624
|
+
e.card.classList.add('dropping');
|
|
625
|
+
});
|
|
626
|
+
on(e.card, 'dragleave', (ev) => {
|
|
627
|
+
if (ev.relatedTarget instanceof Node && e.card.contains(ev.relatedTarget))
|
|
628
|
+
return;
|
|
629
|
+
e.card.classList.remove('dropping');
|
|
630
|
+
});
|
|
631
|
+
on(e.card, 'drop', (ev) => {
|
|
632
|
+
e.card.classList.remove('dropping');
|
|
633
|
+
const dropped = [...(ev.dataTransfer?.files ?? [])];
|
|
634
|
+
if (!dropped.length || !this.canAttach())
|
|
635
|
+
return;
|
|
636
|
+
ev.preventDefault();
|
|
637
|
+
this.addFiles(dropped);
|
|
638
|
+
});
|
|
639
|
+
for (const [z, btn] of e.sizeButtons) {
|
|
640
|
+
on(btn, 'click', () => {
|
|
641
|
+
this.size = z;
|
|
642
|
+
writePref(SIZE_KEY, z);
|
|
643
|
+
this.paint();
|
|
644
|
+
// A parked card is placed by its painted size: re-place it at the new one, in its corner at once.
|
|
645
|
+
if (this.parked)
|
|
646
|
+
this.placeCard(true);
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
on(e.techBtn, 'click', () => {
|
|
650
|
+
this.techOpen = !this.techOpen;
|
|
651
|
+
this.paint();
|
|
652
|
+
});
|
|
362
653
|
on(e.closeBtn, 'click', () => this.close());
|
|
363
|
-
on(e.
|
|
654
|
+
on(e.whoBtn, 'click', () => this.toggleMenu('account'));
|
|
655
|
+
on(e.more, 'click', () => this.toggleMenu('more'));
|
|
656
|
+
const fromMenu = (fn) => () => {
|
|
657
|
+
this.menu = null;
|
|
658
|
+
fn();
|
|
659
|
+
this.paint();
|
|
660
|
+
};
|
|
661
|
+
// A role=menu moves its focus with the arrows, Home and End over the items on show (the pill's Menu.tsx onKey).
|
|
662
|
+
on(e.morePop, 'keydown', (ev) => {
|
|
663
|
+
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(ev.key))
|
|
664
|
+
return;
|
|
665
|
+
const items = [...e.morePop.querySelectorAll('[role="menuitem"]')].filter((el) => !el.hidden && !(el instanceof HTMLButtonElement && el.disabled));
|
|
666
|
+
if (!items.length)
|
|
667
|
+
return;
|
|
668
|
+
ev.preventDefault();
|
|
669
|
+
const root = e.morePop.getRootNode();
|
|
670
|
+
const at = items.indexOf(root.activeElement);
|
|
671
|
+
const last = items.length - 1;
|
|
672
|
+
const down = ev.key === 'ArrowDown';
|
|
673
|
+
const next = ev.key === 'Home' ? 0 : ev.key === 'End' ? last : at < 0 ? (down ? 0 : last) : (at + (down ? 1 : -1) + items.length) % items.length;
|
|
674
|
+
items[next]?.focus();
|
|
675
|
+
});
|
|
676
|
+
on(e.mReports, 'click', fromMenu(() => void this.openReports()));
|
|
677
|
+
on(e.mRecents, 'click', fromMenu(() => this.show('recents')));
|
|
678
|
+
const switchFace = fromMenu(() => this.recordSwitch?.());
|
|
679
|
+
// A waiting Record stays focusable so it can say why (paintAccount), so its press must do nothing: the menu stays open.
|
|
680
|
+
on(e.mRecord, 'click', () => {
|
|
681
|
+
if (!this.recordWaits())
|
|
682
|
+
switchFace();
|
|
683
|
+
});
|
|
684
|
+
on(e.mSettings, 'click', fromMenu(() => this.show('settings')));
|
|
685
|
+
on(e.mOpen, 'click', fromMenu(() => undefined));
|
|
686
|
+
on(e.accPortal, 'click', fromMenu(() => undefined));
|
|
687
|
+
on(e.accLink, 'click', fromMenu(() => this.startLinkFlow()));
|
|
688
|
+
on(e.accUnlink, 'click', () => {
|
|
689
|
+
clearLink();
|
|
690
|
+
this.member = null;
|
|
691
|
+
this.paint();
|
|
692
|
+
});
|
|
693
|
+
for (const b of [e.repBack, e.recBack, e.linkBack])
|
|
694
|
+
on(b, 'click', () => this.show('describe'));
|
|
695
|
+
on(e.linkRetry, 'click', () => this.startLinkFlow());
|
|
696
|
+
// A press anywhere in the card but the open popover (or its button) closes it.
|
|
697
|
+
on(e.card, 'pointerdown', (ev) => {
|
|
698
|
+
const t = ev.target;
|
|
699
|
+
if (!this.menu || !(t instanceof Node))
|
|
700
|
+
return;
|
|
701
|
+
if ([e.accountPop, e.morePop, e.whoBtn, e.more].some((el) => el.contains(t)))
|
|
702
|
+
return;
|
|
703
|
+
this.menu = null;
|
|
704
|
+
this.paint();
|
|
705
|
+
});
|
|
364
706
|
on(e.back, 'click', () => this.show('describe'));
|
|
365
707
|
on(e.sentClose, 'click', () => this.close());
|
|
366
708
|
on(e.desc, 'input', () => this.paint());
|
|
@@ -371,7 +713,7 @@ export class ReportWidget {
|
|
|
371
713
|
on(e.notifyBox, 'change', () => {
|
|
372
714
|
this.notify = e.notifyBox.checked;
|
|
373
715
|
});
|
|
374
|
-
on(e.where, 'click', () => this.startMarking());
|
|
716
|
+
on(e.where, 'click', () => (this.marking ? this.endMarking(true) : this.startMarking()));
|
|
375
717
|
on(e.send, 'click', () => void this.send());
|
|
376
718
|
on(e.bindBtn, 'click', () => (this.recordingBind ? this.stopRecordingBind() : this.startRecordingBind()));
|
|
377
719
|
on(e.unbind, 'click', () => {
|
|
@@ -379,11 +721,26 @@ export class ReportWidget {
|
|
|
379
721
|
saveKeybind(null);
|
|
380
722
|
this.paint();
|
|
381
723
|
});
|
|
724
|
+
for (const [kind, btn] of e.kindButtons) {
|
|
725
|
+
// A second press on the picked word unpicks it: the word is optional.
|
|
726
|
+
on(btn, 'click', () => {
|
|
727
|
+
this.kind = this.kind === kind ? null : kind;
|
|
728
|
+
this.paint();
|
|
729
|
+
});
|
|
730
|
+
}
|
|
382
731
|
on(e.card, 'keydown', (ev) => {
|
|
383
|
-
|
|
732
|
+
// Marking's own Escape (the window listener) already acted on it.
|
|
733
|
+
if (ev.key !== 'Escape' || this.recordingBind || ev.defaultPrevented)
|
|
384
734
|
return;
|
|
385
735
|
ev.preventDefault();
|
|
386
|
-
|
|
736
|
+
// Esc steps back one layer: an open popover, then a list or settings, then the card itself.
|
|
737
|
+
if (this.menu) {
|
|
738
|
+
const opener = this.menu === 'account' ? e.whoBtn : e.more;
|
|
739
|
+
this.menu = null;
|
|
740
|
+
this.paint();
|
|
741
|
+
opener.focus();
|
|
742
|
+
}
|
|
743
|
+
else if (this.view !== 'describe' && this.view !== 'sent')
|
|
387
744
|
this.show('describe');
|
|
388
745
|
else
|
|
389
746
|
this.close();
|
|
@@ -393,18 +750,24 @@ export class ReportWidget {
|
|
|
393
750
|
this.tool = tool;
|
|
394
751
|
this.renderKbDraft();
|
|
395
752
|
this.paint();
|
|
753
|
+
this.placeSeg();
|
|
396
754
|
// From the keyboard (no pointer: detail 0), go straight back to drawing with it.
|
|
397
755
|
if (ev.detail === 0)
|
|
398
756
|
e.mark.focus();
|
|
399
757
|
});
|
|
400
758
|
}
|
|
401
759
|
on(e.mark, 'keydown', (ev) => this.markKey(ev));
|
|
402
|
-
on(e.
|
|
403
|
-
|
|
760
|
+
on(e.cancel, 'click', () => this.cancelMarking());
|
|
761
|
+
on(e.discard, 'click', () => {
|
|
762
|
+
this.markers = renumberDrawn(this.markers.filter((m) => this.passKeys.has(m.key)));
|
|
404
763
|
this.renderMarks();
|
|
764
|
+
this.endMarking(true);
|
|
765
|
+
});
|
|
766
|
+
on(e.keep, 'click', () => {
|
|
767
|
+
this.confirming = false;
|
|
405
768
|
this.paint();
|
|
769
|
+
e.cancel.focus();
|
|
406
770
|
});
|
|
407
|
-
on(e.done, 'click', () => this.endMarking(true));
|
|
408
771
|
on(e.mark, 'pointerdown', (ev) => this.pointerDown(ev));
|
|
409
772
|
on(e.mark, 'pointermove', (ev) => this.pointerMove(ev));
|
|
410
773
|
on(e.mark, 'pointerup', (ev) => this.pointerUp(ev));
|
|
@@ -417,13 +780,23 @@ export class ReportWidget {
|
|
|
417
780
|
return;
|
|
418
781
|
if (this.marking && ev.key === 'Escape') {
|
|
419
782
|
ev.preventDefault();
|
|
420
|
-
// Esc drops a keyboard mark being placed
|
|
421
|
-
if (this.
|
|
783
|
+
// Esc answers an open "Discard?" with Keep, drops a keyboard mark being placed, and only then leaves marking — keeping the marks.
|
|
784
|
+
if (this.confirming)
|
|
785
|
+
e.keep.click();
|
|
786
|
+
else if (this.kbDraft)
|
|
422
787
|
this.cancelDraft();
|
|
423
788
|
else
|
|
424
789
|
this.endMarking(true);
|
|
425
790
|
return;
|
|
426
791
|
}
|
|
792
|
+
// ⌘Z / Ctrl+Z takes the newest mark back — unless a field is being typed in, whose own undo wins.
|
|
793
|
+
if (this.marking && (ev.metaKey || ev.ctrlKey) && !ev.shiftKey && !ev.altKey && ev.key.toLowerCase() === 'z' && !typing()) {
|
|
794
|
+
ev.preventDefault();
|
|
795
|
+
this.markers = renumberDrawn(this.markers.slice(0, -1));
|
|
796
|
+
this.renderMarks();
|
|
797
|
+
this.paint();
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
427
800
|
if (this.keybind && matchesKeybind(ev, this.keybind)) {
|
|
428
801
|
ev.preventDefault();
|
|
429
802
|
if (this.isOpen)
|
|
@@ -449,11 +822,17 @@ export class ReportWidget {
|
|
|
449
822
|
ev.preventDefault();
|
|
450
823
|
this.open();
|
|
451
824
|
}));
|
|
825
|
+
this.offs.push(listen(window, 'resize', () => {
|
|
826
|
+
if (this.parked)
|
|
827
|
+
this.placeCard(true);
|
|
828
|
+
if (this.marking)
|
|
829
|
+
this.placeSeg();
|
|
830
|
+
}));
|
|
452
831
|
this.offs.push(watchKeybind((b) => {
|
|
453
832
|
this.keybind = b;
|
|
454
833
|
this.paint();
|
|
455
834
|
}));
|
|
456
|
-
this.offs.push(onSharedIdentity(() => this.
|
|
835
|
+
this.offs.push(onSharedIdentity(() => this.whoChanged()));
|
|
457
836
|
// The recorder took the page's capture over: stop saying minutes are attached.
|
|
458
837
|
if (this.engine)
|
|
459
838
|
this.offs.push(this.engine.onChange(() => this.paint()));
|
|
@@ -493,16 +872,202 @@ export class ReportWidget {
|
|
|
493
872
|
}
|
|
494
873
|
show(view) {
|
|
495
874
|
this.stopRecordingBind();
|
|
875
|
+
if (view !== 'link' && this.linkFlow) {
|
|
876
|
+
this.linkFlow.abort.abort();
|
|
877
|
+
this.linkFlow = null;
|
|
878
|
+
}
|
|
496
879
|
this.view = view;
|
|
497
880
|
this.paint();
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
881
|
+
const focus = { describe: this.e.desc, settings: this.e.bindBtn, sent: null, reports: this.e.repBack, recents: this.e.recBack, link: this.e.linkBack }[view];
|
|
882
|
+
if (focus)
|
|
883
|
+
requestAnimationFrame(() => focus.focus());
|
|
884
|
+
}
|
|
885
|
+
// -- the account and the lists (vt-8020 D2–D5) ------------------------------
|
|
886
|
+
target() {
|
|
887
|
+
return { url: this.opts.base, key: this.opts.key };
|
|
888
|
+
}
|
|
889
|
+
toggleMenu(which) {
|
|
890
|
+
this.menu = this.menu === which ? null : which;
|
|
891
|
+
if (this.menu === 'account') {
|
|
892
|
+
void this.refreshWho();
|
|
893
|
+
void this.refreshMember();
|
|
894
|
+
}
|
|
895
|
+
this.paint();
|
|
896
|
+
const pop = this.menu === 'account' ? this.e.accountPop : this.menu === 'more' ? this.e.morePop : null;
|
|
897
|
+
const first = pop?.querySelector('button:not([hidden]), a:not([hidden])');
|
|
898
|
+
first?.focus();
|
|
899
|
+
}
|
|
900
|
+
/** The host's signed token traded once for a reporter session; renewed only when it is about to lapse. Answers the session in force. */
|
|
901
|
+
async refreshWho() {
|
|
902
|
+
const who = this.who();
|
|
903
|
+
if (!who || !('token' in who)) {
|
|
904
|
+
this.session = null;
|
|
905
|
+
this.sessionToken = '';
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
908
|
+
if (this.sessionToken === who.token && sessionLive(this.session))
|
|
909
|
+
return this.session;
|
|
910
|
+
this.sessionToken = who.token;
|
|
911
|
+
let opened = null;
|
|
912
|
+
try {
|
|
913
|
+
opened = await openSession(this.target(), who.token);
|
|
914
|
+
}
|
|
915
|
+
catch (e) {
|
|
916
|
+
console.warn('vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only', e);
|
|
917
|
+
}
|
|
918
|
+
// The person changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
919
|
+
if (this.sessionToken !== who.token)
|
|
920
|
+
return null;
|
|
921
|
+
this.session = opened;
|
|
922
|
+
this.paint();
|
|
923
|
+
return this.session;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* identify() or the page-wide identity moved: a session and a list read for
|
|
927
|
+
* the previous person never stay on screen for the next one, and an open My
|
|
928
|
+
* reports reloads for whoever is here now.
|
|
929
|
+
*/
|
|
930
|
+
whoChanged() {
|
|
931
|
+
if (this.whoToken() !== this.sessionToken) {
|
|
932
|
+
this.session = null;
|
|
933
|
+
this.sessionToken = '';
|
|
934
|
+
this.mine = { rows: [], state: 'ok' };
|
|
935
|
+
if (this.isOpen)
|
|
936
|
+
void (this.view === 'reports' ? this.loadReports() : this.refreshWho());
|
|
937
|
+
}
|
|
938
|
+
this.paint();
|
|
939
|
+
}
|
|
940
|
+
async refreshMember() {
|
|
941
|
+
// The browser-wide link goes only to the vitrinka it was minted on: its token never reaches another widget's base.
|
|
942
|
+
const link = memberLinked(this.opts.base) ? readLink() : null;
|
|
943
|
+
if (!link) {
|
|
944
|
+
if (this.member) {
|
|
945
|
+
this.member = null;
|
|
946
|
+
this.paint();
|
|
947
|
+
}
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
try {
|
|
951
|
+
const me = await api('GET', '/api/v1/recorder/me', undefined, { target: { url: this.opts.base, key: link.token } });
|
|
952
|
+
this.member = { email: me.user?.email ?? '', name: me.user?.name ?? '', workspace: me.workspace?.slug ?? link.workspace };
|
|
953
|
+
// A dev-mode member starts on the pill next mount (face.ts startFace).
|
|
954
|
+
rememberDisplayMode(me.displayMode);
|
|
955
|
+
}
|
|
956
|
+
catch (e) {
|
|
957
|
+
console.warn('vitrinka: the linked vitrinka account could not be read', e);
|
|
958
|
+
this.member = { email: '', name: '', workspace: link.workspace };
|
|
959
|
+
}
|
|
960
|
+
this.paint();
|
|
961
|
+
}
|
|
962
|
+
async openReports() {
|
|
963
|
+
this.show('reports');
|
|
964
|
+
await this.loadReports();
|
|
965
|
+
}
|
|
966
|
+
async loadReports() {
|
|
967
|
+
const asked = this.whoToken();
|
|
968
|
+
const session = await this.refreshWho();
|
|
969
|
+
// The person changed meanwhile: whoChanged already reloads for the next one.
|
|
970
|
+
if (this.whoToken() !== asked)
|
|
971
|
+
return;
|
|
972
|
+
if (!session) {
|
|
973
|
+
this.mine = { rows: [], state: 'ok' };
|
|
974
|
+
this.paint();
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
this.mine = { rows: [], state: 'loading' };
|
|
978
|
+
this.paint();
|
|
979
|
+
let mine;
|
|
980
|
+
try {
|
|
981
|
+
mine = { rows: await this.listMineRenewing(session), state: 'ok' };
|
|
982
|
+
}
|
|
983
|
+
catch (e) {
|
|
984
|
+
console.warn('vitrinka: My reports could not be loaded', e);
|
|
985
|
+
mine = { rows: [], state: 'failed' };
|
|
986
|
+
}
|
|
987
|
+
// A list read for the previous person is dropped; whoChanged already reloads for the next one.
|
|
988
|
+
if (this.whoToken() !== asked)
|
|
989
|
+
return;
|
|
990
|
+
this.mine = mine;
|
|
991
|
+
this.paint();
|
|
992
|
+
}
|
|
993
|
+
/** My reports; a 401 means the reporter session lapsed or the host's key rotated: trade the token again, then ask once more. */
|
|
994
|
+
async listMineRenewing(session) {
|
|
995
|
+
try {
|
|
996
|
+
return (await listMine(this.target(), session.session)).reports;
|
|
997
|
+
}
|
|
998
|
+
catch (e) {
|
|
999
|
+
if (!(e instanceof VitrinkaApiError) || e.status !== 401)
|
|
1000
|
+
throw e;
|
|
1001
|
+
this.session = null;
|
|
1002
|
+
this.sessionToken = '';
|
|
1003
|
+
const renewed = await this.refreshWho();
|
|
1004
|
+
if (!renewed)
|
|
1005
|
+
throw e;
|
|
1006
|
+
return (await listMine(this.target(), renewed.session)).reports;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
/** The pill's member link (vt-8020 D3): a code approved in vitrinka mints this browser's own recorder key. */
|
|
1010
|
+
startLinkFlow() {
|
|
1011
|
+
this.linkFlow?.abort.abort();
|
|
1012
|
+
const flow = { start: null, state: 'starting', abort: new AbortController() };
|
|
1013
|
+
this.linkFlow = flow;
|
|
1014
|
+
this.show('link');
|
|
1015
|
+
const base = this.opts.base;
|
|
1016
|
+
const workspace = linkWorkspace(base);
|
|
1017
|
+
void (async () => {
|
|
1018
|
+
try {
|
|
1019
|
+
flow.start = await startLink(base, { label: defaultLinkLabel(), workspace });
|
|
1020
|
+
flow.state = 'waiting';
|
|
1021
|
+
this.paint();
|
|
1022
|
+
const linked = await pollLink(base, flow.start.device_code, {
|
|
1023
|
+
interval: flow.start.interval,
|
|
1024
|
+
expiresIn: flow.start.expires_in,
|
|
1025
|
+
workspace,
|
|
1026
|
+
signal: flow.abort.signal,
|
|
1027
|
+
});
|
|
1028
|
+
// The link names the vitrinka it belongs to: face.ts offers the pill only on that base.
|
|
1029
|
+
storeLink({ ...linked, base });
|
|
1030
|
+
this.linkFlow = null;
|
|
1031
|
+
this.show('describe');
|
|
1032
|
+
await this.refreshMember();
|
|
1033
|
+
}
|
|
1034
|
+
catch (e) {
|
|
1035
|
+
if (flow.abort.signal.aborted)
|
|
1036
|
+
return;
|
|
1037
|
+
flow.state = e instanceof LinkExpired ? 'expired' : 'failed';
|
|
1038
|
+
if (flow.state === 'failed')
|
|
1039
|
+
console.warn('vitrinka: linking the vitrinka account failed', e);
|
|
1040
|
+
this.paint();
|
|
1041
|
+
}
|
|
1042
|
+
})();
|
|
1043
|
+
}
|
|
1044
|
+
/** "2 h ago" in the widget's language. */
|
|
1045
|
+
ago(at) {
|
|
1046
|
+
const rtf = new Intl.RelativeTimeFormat(this.locale, { numeric: 'auto' });
|
|
1047
|
+
const s = Math.round((at - Date.now()) / 1000);
|
|
1048
|
+
const steps = [[60, 'second'], [60, 'minute'], [24, 'hour'], [30, 'day'], [12, 'month'], [Infinity, 'year']];
|
|
1049
|
+
let v = s;
|
|
1050
|
+
for (const [size, unit] of steps) {
|
|
1051
|
+
if (Math.abs(v) < size)
|
|
1052
|
+
return rtf.format(v, unit);
|
|
1053
|
+
v = Math.round(v / size);
|
|
1054
|
+
}
|
|
1055
|
+
return rtf.format(v, 'year');
|
|
1056
|
+
}
|
|
1057
|
+
/** One list row: a title, a quiet state chip and its age; a link when the server minted an address. */
|
|
1058
|
+
row(title, state, at, url) {
|
|
1059
|
+
const kids = [h('span', { class: 'row-t' }, title), h('span', { class: 'step' }, state), h('span', { class: 'age' }, this.ago(at))];
|
|
1060
|
+
const inner = url ? h('a', { class: 'row', href: url, target: '_blank', rel: 'noopener noreferrer' }, ...kids) : h('div', { class: 'row' }, ...kids);
|
|
1061
|
+
return h('li', {}, inner);
|
|
502
1062
|
}
|
|
503
1063
|
who() {
|
|
504
1064
|
return this.identity !== undefined ? this.identity : sharedIdentity();
|
|
505
1065
|
}
|
|
1066
|
+
/** The signed token of the person here now; '' for an asserted or anonymous reporter. */
|
|
1067
|
+
whoToken() {
|
|
1068
|
+
const who = this.who();
|
|
1069
|
+
return who && 'token' in who ? who.token : '';
|
|
1070
|
+
}
|
|
506
1071
|
// -- the shortcut recorder ----------------------------------------------
|
|
507
1072
|
stopBindListener = null;
|
|
508
1073
|
startRecordingBind() {
|
|
@@ -536,27 +1101,252 @@ export class ReportWidget {
|
|
|
536
1101
|
this.stopBindListener = null;
|
|
537
1102
|
this.paint();
|
|
538
1103
|
}
|
|
1104
|
+
// -- the reporter's files (vt-8020 D9) ---------------------------------------
|
|
1105
|
+
/** Files join while the report is being written — not while it is on its way (Retry sends it as it was). */
|
|
1106
|
+
canAttach() {
|
|
1107
|
+
return this.isOpen && this.view === 'describe' && !this.sending && !this.job?.id;
|
|
1108
|
+
}
|
|
1109
|
+
caps() {
|
|
1110
|
+
return this.config?.attachments ?? DEFAULT_ATTACHMENT_CAPS;
|
|
1111
|
+
}
|
|
1112
|
+
addFiles(incoming) {
|
|
1113
|
+
if (!incoming.length)
|
|
1114
|
+
return;
|
|
1115
|
+
const { files, refusal } = admit(this.files, incoming, this.caps());
|
|
1116
|
+
this.files = [...this.files, ...files];
|
|
1117
|
+
this.fileRefusal = refusal;
|
|
1118
|
+
this.renderFiles();
|
|
1119
|
+
this.paint();
|
|
1120
|
+
}
|
|
1121
|
+
removeFile(f) {
|
|
1122
|
+
this.files = this.files.filter((x) => x !== f);
|
|
1123
|
+
this.fileRefusal = null;
|
|
1124
|
+
this.renderFiles();
|
|
1125
|
+
this.paint();
|
|
1126
|
+
// Its ✕ is gone: the focus goes to 📎, never lost to <body>.
|
|
1127
|
+
this.e.attach.focus();
|
|
1128
|
+
}
|
|
1129
|
+
/** One chip per file, built once; paint() writes their sizes and labels. */
|
|
1130
|
+
renderFiles() {
|
|
1131
|
+
const live = new Set(this.files);
|
|
1132
|
+
for (const [f, chip] of this.chips) {
|
|
1133
|
+
if (live.has(f))
|
|
1134
|
+
continue;
|
|
1135
|
+
chip.el.remove();
|
|
1136
|
+
this.chips.delete(f);
|
|
1137
|
+
}
|
|
1138
|
+
for (const f of this.files) {
|
|
1139
|
+
if (this.chips.has(f))
|
|
1140
|
+
continue;
|
|
1141
|
+
const size = h('span', { class: 'file-size' });
|
|
1142
|
+
const rm = h('button', { class: 'ln-x', type: 'button' }, icon(ICON.close));
|
|
1143
|
+
const el = h('li', { class: 'file' }, h('span', { class: 'file-name' }, f.name), size, rm);
|
|
1144
|
+
rm.addEventListener('click', () => this.removeFile(f));
|
|
1145
|
+
this.e.files.append(el);
|
|
1146
|
+
this.chips.set(f, { el, size, rm });
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
/** The one line a refused file gets: the cap it broke, by name. */
|
|
1150
|
+
refusalText(r) {
|
|
1151
|
+
const s = this.s;
|
|
1152
|
+
if (!r)
|
|
1153
|
+
return '';
|
|
1154
|
+
if (r.kind === 'size')
|
|
1155
|
+
return s.fileTooBig(r.name, formatBytes(r.cap, this.locale));
|
|
1156
|
+
if (r.kind === 'count')
|
|
1157
|
+
return s.tooManyFiles(r.cap);
|
|
1158
|
+
return s.fileType(r.name, typesLabel(this.caps().types, s.typeNames, this.locale));
|
|
1159
|
+
}
|
|
1160
|
+
// -- the button's corner (vt-8020 D9) ---------------------------------------
|
|
1161
|
+
fabDown(ev) {
|
|
1162
|
+
this.swallowClick = false;
|
|
1163
|
+
if (ev.button !== 0 || !ev.isPrimary)
|
|
1164
|
+
return;
|
|
1165
|
+
const r = this.e.fab.getBoundingClientRect();
|
|
1166
|
+
this.fabDrag = { pointer: ev.pointerId, start: { x: ev.clientX, y: ev.clientY }, grab: { x: ev.clientX - r.left, y: ev.clientY - r.top }, moved: false };
|
|
1167
|
+
try {
|
|
1168
|
+
this.e.fab.setPointerCapture(ev.pointerId);
|
|
1169
|
+
}
|
|
1170
|
+
catch {
|
|
1171
|
+
// a synthetic pointer: no capture needed
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
/** Past the threshold the press is a drag: the button rides the pointer, inside the viewport. */
|
|
1175
|
+
fabMove(ev) {
|
|
1176
|
+
const d = this.fabDrag;
|
|
1177
|
+
if (!d || ev.pointerId !== d.pointer)
|
|
1178
|
+
return;
|
|
1179
|
+
if (!d.moved && Math.hypot(ev.clientX - d.start.x, ev.clientY - d.start.y) < DRAG_THRESHOLD)
|
|
1180
|
+
return;
|
|
1181
|
+
d.moved = true;
|
|
1182
|
+
const fab = this.e.fab;
|
|
1183
|
+
fab.classList.add('dragging');
|
|
1184
|
+
const r = fab.getBoundingClientRect();
|
|
1185
|
+
const vw = globalThis.innerWidth || 800;
|
|
1186
|
+
const vh = globalThis.innerHeight || 600;
|
|
1187
|
+
const s = fab.style;
|
|
1188
|
+
s.left = `${Math.min(Math.max(0, ev.clientX - d.grab.x), vw - r.width)}px`;
|
|
1189
|
+
s.top = `${Math.min(Math.max(0, ev.clientY - d.grab.y), vh - r.height)}px`;
|
|
1190
|
+
s.right = 'auto';
|
|
1191
|
+
s.bottom = 'auto';
|
|
1192
|
+
}
|
|
1193
|
+
/** A drop docks the button in the nearest corner (a cancelled drag goes home); a press that never travelled stays a click. */
|
|
1194
|
+
fabUp(ev, drop) {
|
|
1195
|
+
const d = this.fabDrag;
|
|
1196
|
+
if (!d || ev.pointerId !== d.pointer)
|
|
1197
|
+
return;
|
|
1198
|
+
this.fabDrag = null;
|
|
1199
|
+
if (!d.moved)
|
|
1200
|
+
return;
|
|
1201
|
+
const fab = this.e.fab;
|
|
1202
|
+
const at = fab.getBoundingClientRect();
|
|
1203
|
+
fab.classList.remove('dragging');
|
|
1204
|
+
for (const p of ['left', 'top', 'right', 'bottom'])
|
|
1205
|
+
fab.style.removeProperty(p);
|
|
1206
|
+
// The click this pointerup is about to fire is the drop; a click that never comes must not eat the next one.
|
|
1207
|
+
this.swallowClick = true;
|
|
1208
|
+
setTimeout(() => {
|
|
1209
|
+
this.swallowClick = false;
|
|
1210
|
+
}, 0);
|
|
1211
|
+
const vw = globalThis.innerWidth || 800;
|
|
1212
|
+
const vh = globalThis.innerHeight || 600;
|
|
1213
|
+
this.moveDock(drop ? nearestCorner({ x: at.left + at.width / 2, y: at.top + at.height / 2 }, vw, vh) : this.dock, at);
|
|
1214
|
+
}
|
|
1215
|
+
/** Docks the button in `c` and remembers it; it glides there from `from` (the drop point, else where it was). */
|
|
1216
|
+
moveDock(c, from) {
|
|
1217
|
+
const fab = this.e.fab;
|
|
1218
|
+
const before = from ?? fab.getBoundingClientRect();
|
|
1219
|
+
this.dock = c;
|
|
1220
|
+
saveDock(c);
|
|
1221
|
+
this.paint();
|
|
1222
|
+
if (fab.hidden || reducedMotion())
|
|
1223
|
+
return;
|
|
1224
|
+
const after = fab.getBoundingClientRect();
|
|
1225
|
+
const dx = before.left - after.left;
|
|
1226
|
+
const dy = before.top - after.top;
|
|
1227
|
+
if (!dx && !dy)
|
|
1228
|
+
return;
|
|
1229
|
+
// FLIP: start where it was, then let the placement transition carry it home.
|
|
1230
|
+
this.glide?.abort();
|
|
1231
|
+
const glide = new AbortController();
|
|
1232
|
+
this.glide = glide;
|
|
1233
|
+
fab.classList.remove('gliding');
|
|
1234
|
+
fab.style.setProperty('translate', `${dx}px ${dy}px`);
|
|
1235
|
+
void fab.offsetWidth;
|
|
1236
|
+
fab.classList.add('gliding');
|
|
1237
|
+
fab.style.setProperty('translate', '0px 0px');
|
|
1238
|
+
// Only this glide's own end: the hover lift transitions too, and a newer glide replaces this one.
|
|
1239
|
+
const done = (ev) => {
|
|
1240
|
+
if (ev.propertyName !== 'translate')
|
|
1241
|
+
return;
|
|
1242
|
+
glide.abort();
|
|
1243
|
+
fab.classList.remove('gliding');
|
|
1244
|
+
fab.style.removeProperty('translate');
|
|
1245
|
+
};
|
|
1246
|
+
fab.addEventListener('transitionend', done, { signal: glide.signal });
|
|
1247
|
+
fab.addEventListener('transitioncancel', done, { signal: glide.signal });
|
|
1248
|
+
}
|
|
539
1249
|
// -- marking --------------------------------------------------------------
|
|
540
1250
|
startMarking() {
|
|
541
1251
|
if (this.job?.id)
|
|
542
1252
|
return; // the report is on its way: Retry finishes it as it was marked
|
|
543
1253
|
this.marking = true;
|
|
544
|
-
this.
|
|
1254
|
+
this.confirming = false;
|
|
1255
|
+
this.passKeys = new Set(this.markers.map((m) => m.key));
|
|
1256
|
+
// Marking parks the card from where it is (beside the button's dock, or a corner an earlier pass
|
|
1257
|
+
// chose), with the insets it has there: starting never moves it — only a mark landing under it does.
|
|
1258
|
+
const corner = this.parked ?? this.dock;
|
|
1259
|
+
this.parkInsets = this.insetsAt(corner, this.e.card.getBoundingClientRect());
|
|
1260
|
+
this.parked = corner;
|
|
545
1261
|
this.renderMarks();
|
|
546
1262
|
this.paint();
|
|
1263
|
+
this.placeCard();
|
|
1264
|
+
this.placeSeg(true);
|
|
547
1265
|
const vw = globalThis.innerWidth || 800;
|
|
548
|
-
|
|
549
|
-
this.placeCoach({ x: vw / 2 - 150, y: vh - 260 }, false);
|
|
1266
|
+
this.placeCoach({ x: vw / 2 - 150, y: BAR_CLEAR + 12 }, false);
|
|
550
1267
|
this.e.mark.focus();
|
|
551
1268
|
}
|
|
1269
|
+
/** Leaves marking; the card stays where marking parked it until it closes (it never jumps back). */
|
|
552
1270
|
endMarking(backToCard) {
|
|
553
1271
|
this.cancelDraft();
|
|
554
1272
|
this.marking = false;
|
|
555
|
-
this.
|
|
1273
|
+
this.confirming = false;
|
|
556
1274
|
this.paint();
|
|
557
1275
|
if (backToCard && this.isOpen)
|
|
558
1276
|
requestAnimationFrame(() => this.e.desc.focus());
|
|
559
1277
|
}
|
|
1278
|
+
/** Cancel (vt-8020 D12): leave marking and drop this pass's marks — asking first when there are any. */
|
|
1279
|
+
cancelMarking() {
|
|
1280
|
+
const added = this.markers.filter((m) => !this.passKeys.has(m.key)).length;
|
|
1281
|
+
if (added === 0) {
|
|
1282
|
+
this.endMarking(true);
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
this.confirming = true;
|
|
1286
|
+
this.paint();
|
|
1287
|
+
this.e.discard.focus();
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* The card's live insets in `corner` (the nearer side, and the bottom or the top — never above the
|
|
1291
|
+
* marking bar's band), the far side at the default: `cornerRect(corner)` is then exactly where it is.
|
|
1292
|
+
*/
|
|
1293
|
+
insetsAt(corner, r) {
|
|
1294
|
+
const vw = globalThis.innerWidth || 800;
|
|
1295
|
+
const vh = globalThis.innerHeight || 600;
|
|
1296
|
+
const bar = BAR_CLEAR * SIZE_SCALE[this.size];
|
|
1297
|
+
const atBottom = corner === 'br' || corner === 'bl';
|
|
1298
|
+
return {
|
|
1299
|
+
edge: Math.max(0, Math.min(r.left, vw - r.right)),
|
|
1300
|
+
top: atBottom ? bar : Math.max(bar, r.top),
|
|
1301
|
+
bottom: atBottom ? Math.max(0, vh - r.bottom) : PARK_EDGE,
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
/** The card's box as painted (the size setting scales it, styles: `--vr-scale`) and the insets marking parks it with. */
|
|
1305
|
+
frame() {
|
|
1306
|
+
const vw = globalThis.innerWidth || 800;
|
|
1307
|
+
const vh = globalThis.innerHeight || 600;
|
|
1308
|
+
const k = SIZE_SCALE[this.size];
|
|
1309
|
+
const insets = this.parkInsets ?? { top: BAR_CLEAR * k, bottom: PARK_EDGE, edge: PARK_EDGE };
|
|
1310
|
+
const r = this.e.card.getBoundingClientRect();
|
|
1311
|
+
return { vw, vh, w: r.width || Math.min(CARD.w * k, vw - 32), h: r.height || Math.min(CARD.h * k, vh - insets.top - insets.bottom), ...insets };
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Parks the card in the corner that covers none of the marks; it glides there (styles: `.card.parked`).
|
|
1315
|
+
* `reanchor`: the corner itself changed (a new size, a resized viewport) — kept in the same corner, the card
|
|
1316
|
+
* lands there on the frame it changes, as an anchored card does; slid there, a parked card (scaled from its
|
|
1317
|
+
* top-left) would first overhang its corner by the size difference, then glide back.
|
|
1318
|
+
*/
|
|
1319
|
+
placeCard(reanchor = false) {
|
|
1320
|
+
if (!this.parked)
|
|
1321
|
+
return;
|
|
1322
|
+
const f = this.frame();
|
|
1323
|
+
const was = this.parked;
|
|
1324
|
+
this.parked = pickCorner(this.parked, this.markers.map((m) => m.rect), f);
|
|
1325
|
+
const r = cornerRect(this.parked, f);
|
|
1326
|
+
const card = this.e.card;
|
|
1327
|
+
const land = reanchor && this.parked === was;
|
|
1328
|
+
if (land)
|
|
1329
|
+
card.style.transition = 'none';
|
|
1330
|
+
card.classList.add('parked');
|
|
1331
|
+
card.style.left = `${r.x}px`;
|
|
1332
|
+
card.style.top = `${r.y}px`;
|
|
1333
|
+
if (!land)
|
|
1334
|
+
return;
|
|
1335
|
+
// The read commits the new place as the style the glide starts from, so restoring the glide moves nothing.
|
|
1336
|
+
void card.offsetWidth;
|
|
1337
|
+
card.style.removeProperty('transition');
|
|
1338
|
+
}
|
|
1339
|
+
unpark() {
|
|
1340
|
+
this.parked = null;
|
|
1341
|
+
this.parkInsets = null;
|
|
1342
|
+
this.e.card.classList.remove('parked');
|
|
1343
|
+
this.e.card.style.removeProperty('left');
|
|
1344
|
+
this.e.card.style.removeProperty('top');
|
|
1345
|
+
}
|
|
1346
|
+
/** The segmented control's indicator under the picked shape; `land`: the bar just appeared, so it does not slide. */
|
|
1347
|
+
placeSeg(land = false) {
|
|
1348
|
+
placeIndicator(this.e.seg, this.e.segInd, this.e.toolButtons.get(this.tool), land);
|
|
1349
|
+
}
|
|
560
1350
|
onChrome(t) {
|
|
561
1351
|
return t instanceof Node && (this.e.toolbar.contains(t) || this.e.pins.contains(t));
|
|
562
1352
|
}
|
|
@@ -567,7 +1357,6 @@ export class ReportWidget {
|
|
|
567
1357
|
const root = this.e.root.getRootNode();
|
|
568
1358
|
if (root instanceof ShadowRoot && root.activeElement instanceof HTMLElement)
|
|
569
1359
|
root.activeElement.blur();
|
|
570
|
-
this.noteOpen = null;
|
|
571
1360
|
this.drawing = { start: { x: ev.clientX, y: ev.clientY }, shape: this.tool, pointer: ev.pointerId };
|
|
572
1361
|
try {
|
|
573
1362
|
this.e.mark.setPointerCapture(ev.pointerId);
|
|
@@ -576,7 +1365,6 @@ export class ReportWidget {
|
|
|
576
1365
|
// a synthetic pointer: no capture needed
|
|
577
1366
|
}
|
|
578
1367
|
this.e.coach.classList.add('pressing');
|
|
579
|
-
this.renderPins();
|
|
580
1368
|
}
|
|
581
1369
|
pointerMove(ev) {
|
|
582
1370
|
if (!this.markers.length)
|
|
@@ -605,10 +1393,10 @@ export class ReportWidget {
|
|
|
605
1393
|
this.hideIds.set(key, ids);
|
|
606
1394
|
}
|
|
607
1395
|
this.markers = renumberDrawn([...this.markers, { key, n: this.markers.length + 1, shape, rect, note: '', ...(head ? { head } : {}) }]);
|
|
608
|
-
this.noteOpen = key;
|
|
609
1396
|
this.renderMarks();
|
|
610
1397
|
this.paint();
|
|
611
|
-
|
|
1398
|
+
// Drawing a shape opens its note: the new line in the card takes the typing.
|
|
1399
|
+
this.lines.get(key)?.note.focus();
|
|
612
1400
|
}
|
|
613
1401
|
cancelDraft() {
|
|
614
1402
|
this.drawing = null;
|
|
@@ -692,61 +1480,76 @@ export class ReportWidget {
|
|
|
692
1480
|
pin.el.remove();
|
|
693
1481
|
this.pins.delete(key);
|
|
694
1482
|
}
|
|
1483
|
+
for (const [key, line] of this.lines) {
|
|
1484
|
+
if (live.has(key))
|
|
1485
|
+
continue;
|
|
1486
|
+
line.el.remove();
|
|
1487
|
+
this.lines.delete(key);
|
|
1488
|
+
}
|
|
1489
|
+
const remove = (key) => {
|
|
1490
|
+
this.markers = renumberDrawn(this.markers.filter((x) => x.key !== key));
|
|
1491
|
+
this.renderMarks();
|
|
1492
|
+
this.paint();
|
|
1493
|
+
};
|
|
695
1494
|
for (const m of this.markers) {
|
|
696
1495
|
if (this.pins.has(m.key))
|
|
697
1496
|
continue;
|
|
698
1497
|
const num = h('button', { class: 'num', type: 'button' });
|
|
699
|
-
const note = h('input', { class: 'note', type: 'text', maxlength: '500' });
|
|
700
1498
|
const rm = h('button', { class: 'rm', type: 'button' }, icon(ICON.close));
|
|
701
|
-
const el = h('div', { class: 'pin' }, num,
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
});
|
|
1499
|
+
const el = h('div', { class: 'pin' }, num, rm);
|
|
1500
|
+
// The pin points at its note: a press on the number puts the caret in its line.
|
|
1501
|
+
num.addEventListener('click', () => this.lines.get(m.key)?.note.focus());
|
|
1502
|
+
rm.addEventListener('click', () => remove(m.key));
|
|
1503
|
+
this.e.pins.append(el);
|
|
1504
|
+
this.pins.set(m.key, { el, num, rm });
|
|
1505
|
+
const lineNum = h('span', { class: 'ln-n', 'aria-hidden': 'true' });
|
|
1506
|
+
const note = h('input', { class: 'ln-t', type: 'text', maxlength: '500' });
|
|
1507
|
+
const lineRm = h('button', { class: 'ln-x', type: 'button' }, icon(ICON.close));
|
|
1508
|
+
const line = h('li', { class: 'ln' }, lineNum, note, lineRm);
|
|
707
1509
|
note.addEventListener('input', () => {
|
|
708
1510
|
this.markers = this.markers.map((x) => (x.key === m.key ? { ...x, note: note.value } : x));
|
|
709
|
-
|
|
710
|
-
note.addEventListener('focus', () => {
|
|
711
|
-
this.noteOpen = m.key;
|
|
712
|
-
this.renderPins();
|
|
1511
|
+
this.paint();
|
|
713
1512
|
});
|
|
714
1513
|
note.addEventListener('keydown', (ev) => {
|
|
715
|
-
if (ev.key !== 'Enter')
|
|
1514
|
+
if (ev.key !== 'Enter' || !this.marking)
|
|
716
1515
|
return;
|
|
717
1516
|
ev.preventDefault();
|
|
718
1517
|
// Back to the page, ready for the next mark from the keyboard.
|
|
719
1518
|
this.e.mark.focus();
|
|
720
1519
|
});
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
this.
|
|
1520
|
+
lineRm.addEventListener('click', () => remove(m.key));
|
|
1521
|
+
this.e.lines.append(line);
|
|
1522
|
+
this.lines.set(m.key, { el: line, num: lineNum, note, rm: lineRm });
|
|
1523
|
+
}
|
|
1524
|
+
// Renumbering after a removal keeps the lines in mark order.
|
|
1525
|
+
for (const m of this.markers) {
|
|
1526
|
+
const line = this.lines.get(m.key);
|
|
1527
|
+
if (line)
|
|
1528
|
+
this.e.lines.append(line.el);
|
|
728
1529
|
}
|
|
729
1530
|
this.renderPins();
|
|
1531
|
+
if (this.parked)
|
|
1532
|
+
this.placeCard();
|
|
730
1533
|
}
|
|
731
|
-
/** Pin numbers
|
|
1534
|
+
/** Pin numbers and positions, line numbers and labels; text in place (the locale may have changed). */
|
|
732
1535
|
renderPins() {
|
|
733
1536
|
const vw = globalThis.innerWidth || 800;
|
|
734
1537
|
for (const m of this.markers) {
|
|
735
1538
|
const pin = this.pins.get(m.key);
|
|
736
|
-
|
|
1539
|
+
const line = this.lines.get(m.key);
|
|
1540
|
+
if (!pin || !line)
|
|
737
1541
|
continue;
|
|
738
1542
|
const anchor = m.shape === 'arrow' ? arrowEnds(m.rect, m.head ?? 'se').tail : { x: m.rect.x, y: m.rect.y };
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
pin.el.style.left = `${Math.min(Math.max(4, anchor.x - 12), vw - width)}px`;
|
|
742
|
-
pin.el.style.top = `${Math.max(4, anchor.y - 12)}px`;
|
|
1543
|
+
pin.el.style.left = `${Math.min(Math.max(4, anchor.x - 12), vw - 60)}px`;
|
|
1544
|
+
pin.el.style.top = `${Math.max(BAR_CLEAR - 12, anchor.y - 12)}px`;
|
|
743
1545
|
pin.num.textContent = String(m.n);
|
|
744
1546
|
pin.num.setAttribute('aria-label', this.s.mark(m.n));
|
|
745
|
-
pin.note.hidden = !showNote;
|
|
746
|
-
pin.rm.hidden = !showNote;
|
|
747
|
-
pin.note.placeholder = this.s.notePlaceholder;
|
|
748
|
-
pin.note.setAttribute('aria-label', `${this.s.mark(m.n)} — ${this.s.notePlaceholder}`);
|
|
749
1547
|
pin.rm.setAttribute('aria-label', this.s.removeMark(m.n));
|
|
1548
|
+
line.num.textContent = String(m.n);
|
|
1549
|
+
line.el.classList.toggle('hide', m.shape === 'hide');
|
|
1550
|
+
line.note.placeholder = this.s.notePlaceholder;
|
|
1551
|
+
line.note.setAttribute('aria-label', `${this.s.mark(m.n)} — ${this.s.notePlaceholder}`);
|
|
1552
|
+
line.rm.setAttribute('aria-label', this.s.removeMark(m.n));
|
|
750
1553
|
}
|
|
751
1554
|
}
|
|
752
1555
|
// -- sending --------------------------------------------------------------
|
|
@@ -768,12 +1571,31 @@ export class ReportWidget {
|
|
|
768
1571
|
...(who ? { identity: who, notify: this.notify } : {}),
|
|
769
1572
|
markers: toWire(this.markers),
|
|
770
1573
|
locale: this.locale,
|
|
1574
|
+
...(this.kind ? { type: this.kind } : {}),
|
|
771
1575
|
};
|
|
772
1576
|
}
|
|
1577
|
+
/** The words the report goes with: the description, else the first mark's note — either one is enough to send. */
|
|
1578
|
+
words() {
|
|
1579
|
+
return this.e.desc.value.trim() || (this.markers.find((m) => m.note.trim())?.note.trim() ?? '');
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* The card holds something the reporter made and has not sent: words in the
|
|
1583
|
+
* description or a mark's note (a note lives on its mark), a mark, the
|
|
1584
|
+
* picked word for it, a file.
|
|
1585
|
+
*/
|
|
1586
|
+
hasDraft() {
|
|
1587
|
+
return this.e.desc.value.trim() !== '' || this.markers.length > 0 || this.kind !== null || this.files.length > 0;
|
|
1588
|
+
}
|
|
1589
|
+
/** Record unmounts this card for the pill (vt-8020 D8), so it waits while the card holds a draft or a report sending or waiting on Try again — the switch would lose it. */
|
|
1590
|
+
recordWaits() {
|
|
1591
|
+
return this.sending || this.job !== null || this.hasDraft();
|
|
1592
|
+
}
|
|
773
1593
|
async send() {
|
|
774
|
-
const description = this.
|
|
1594
|
+
const description = this.words();
|
|
775
1595
|
if (this.sending || !description)
|
|
776
1596
|
return;
|
|
1597
|
+
if (this.marking)
|
|
1598
|
+
this.endMarking(false);
|
|
777
1599
|
this.sending = true;
|
|
778
1600
|
this.error = '';
|
|
779
1601
|
this.paint();
|
|
@@ -786,15 +1608,18 @@ export class ReportWidget {
|
|
|
786
1608
|
for (const m of this.markers)
|
|
787
1609
|
for (const id of this.hideIds.get(m.key) ?? [])
|
|
788
1610
|
marked.add(id);
|
|
789
|
-
const
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
})
|
|
794
|
-
: EMPTY_CAPTURE;
|
|
795
|
-
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key });
|
|
1611
|
+
const engine = this.engine;
|
|
1612
|
+
const frozen = this.frozen ?? { clip: null, stored: Promise.resolve(new Map()) };
|
|
1613
|
+
const capture = engine ? await prepareCapture(() => engine.build(frozen, this.markers, marked)) : EMPTY_CAPTURE;
|
|
1614
|
+
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key }, this.files);
|
|
796
1615
|
}
|
|
797
1616
|
this.result = await this.job.run(this.envelope(description, this.job.capture));
|
|
1617
|
+
noteSent(this.opts.base, globalThis.location?.host ?? '', {
|
|
1618
|
+
title: titleOf(description),
|
|
1619
|
+
at: Date.now(),
|
|
1620
|
+
status: this.result.status,
|
|
1621
|
+
...(this.result.reportUrl ? { url: this.result.reportUrl } : {}),
|
|
1622
|
+
});
|
|
798
1623
|
this.sentNotify = this.notify && this.who() !== null;
|
|
799
1624
|
this.view = 'sent';
|
|
800
1625
|
this.job = null;
|
|
@@ -802,15 +1627,19 @@ export class ReportWidget {
|
|
|
802
1627
|
this.e.desc.value = '';
|
|
803
1628
|
this.markers = [];
|
|
804
1629
|
this.hideIds.clear();
|
|
1630
|
+
this.kind = null;
|
|
805
1631
|
this.notify = false;
|
|
806
1632
|
this.e.notifyBox.checked = false;
|
|
807
1633
|
this.includedOpen = false;
|
|
1634
|
+
this.files = [];
|
|
1635
|
+
this.fileRefusal = null;
|
|
808
1636
|
this.renderMarks();
|
|
1637
|
+
this.renderFiles();
|
|
809
1638
|
this.engine?.clear();
|
|
810
1639
|
}
|
|
811
1640
|
catch (e) {
|
|
812
1641
|
console.warn('vitrinka: the report did not go through — Retry resumes it', e);
|
|
813
|
-
this.error = this.job?.id ? '
|
|
1642
|
+
this.error = !this.job?.id ? 'create' : this.job.filesPending ? 'files' : 'capture';
|
|
814
1643
|
}
|
|
815
1644
|
finally {
|
|
816
1645
|
this.sending = false;
|
|
@@ -839,26 +1668,199 @@ export class ReportWidget {
|
|
|
839
1668
|
items.push(s.incIdentity);
|
|
840
1669
|
if (this.markers.length)
|
|
841
1670
|
items.push(s.incMarks);
|
|
1671
|
+
if (this.files.length)
|
|
1672
|
+
items.push(s.incFiles);
|
|
842
1673
|
return items;
|
|
843
1674
|
}
|
|
1675
|
+
/** Who the face says you are (vt-8020 D2): the host's person, then the linked member; never a guess. */
|
|
1676
|
+
paintAccount() {
|
|
1677
|
+
const { e, s } = this;
|
|
1678
|
+
const who = this.who();
|
|
1679
|
+
const person = !who ? null : 'email' in who ? { name: who.name ?? '', email: who.email } : this.session ? { name: this.session.reporter.name ?? '', email: this.session.reporter.email } : null;
|
|
1680
|
+
const label = person?.name || person?.email || '';
|
|
1681
|
+
e.whoAv.textContent = who ? initials(label) : '?';
|
|
1682
|
+
e.whoName.textContent = label.split(/[\s@]/)[0] ?? '';
|
|
1683
|
+
e.whoName.hidden = !label;
|
|
1684
|
+
e.whoBtn.setAttribute('aria-label', `${s.account}: ${label || (who ? '' : s.anonymous)}`.replace(/: $/, ''));
|
|
1685
|
+
e.whoBtn.setAttribute('aria-expanded', String(this.menu === 'account'));
|
|
1686
|
+
e.more.setAttribute('aria-label', s.menu);
|
|
1687
|
+
e.more.setAttribute('aria-expanded', String(this.menu === 'more'));
|
|
1688
|
+
e.accountPop.hidden = this.menu !== 'account';
|
|
1689
|
+
e.morePop.hidden = this.menu !== 'more';
|
|
1690
|
+
e.accountPop.setAttribute('aria-label', s.account);
|
|
1691
|
+
e.morePop.setAttribute('aria-label', s.menu);
|
|
1692
|
+
e.accName.textContent = who ? person?.name || person?.email || '' : s.anonymous;
|
|
1693
|
+
e.accMail.textContent = person?.name ? person.email : '';
|
|
1694
|
+
e.accMail.hidden = !e.accMail.textContent;
|
|
1695
|
+
// Only a token the host signed is a sign-in; an asserted email waits for the team like an anonymous report.
|
|
1696
|
+
e.accVia.textContent = who && 'token' in who ? s.signedInByApp : s.anonymousHint;
|
|
1697
|
+
const member = this.member;
|
|
1698
|
+
e.accLinked.hidden = !member;
|
|
1699
|
+
e.accUnlink.hidden = !member;
|
|
1700
|
+
e.accLinked.textContent = member ? s.linkedAs(member.email || member.name || member.workspace) : '';
|
|
1701
|
+
e.accUnlink.textContent = s.unlink;
|
|
1702
|
+
e.accLink.hidden = Boolean(member);
|
|
1703
|
+
setLabel(e.accLink, s.linkVitrinka);
|
|
1704
|
+
const portal = this.session?.portalUrl;
|
|
1705
|
+
e.accPortal.hidden = !portal;
|
|
1706
|
+
if (portal)
|
|
1707
|
+
e.accPortal.setAttribute('href', portal);
|
|
1708
|
+
setLabel(e.accPortal, s.openPortal);
|
|
1709
|
+
setLabel(e.mReports, s.myReports);
|
|
1710
|
+
setLabel(e.mRecents, s.recentRecordings);
|
|
1711
|
+
setLabel(e.mRecord, s.record);
|
|
1712
|
+
setLabel(e.mSettings, s.settings);
|
|
1713
|
+
// Recording lives where the pill does: only a linked member gets it, its recents and the way to vitrinka.
|
|
1714
|
+
e.mRecents.hidden = !this.recordSwitch;
|
|
1715
|
+
e.mRecord.hidden = !this.recordSwitch;
|
|
1716
|
+
// A waiting Record says why (recordWaits). aria-disabled, never `disabled`: the menu's arrows still reach it,
|
|
1717
|
+
// so a keyboard and screen-reader user hears the reason too; its click is guarded in bind().
|
|
1718
|
+
const waits = this.recordWaits();
|
|
1719
|
+
if (waits)
|
|
1720
|
+
e.mRecord.setAttribute('aria-disabled', 'true');
|
|
1721
|
+
else
|
|
1722
|
+
e.mRecord.removeAttribute('aria-disabled');
|
|
1723
|
+
e.mRecordWhy.hidden = !waits;
|
|
1724
|
+
e.mRecordWhy.textContent = s.recordHasDraft;
|
|
1725
|
+
if (waits)
|
|
1726
|
+
e.mRecord.setAttribute('aria-describedby', e.mRecordWhy.id);
|
|
1727
|
+
else
|
|
1728
|
+
e.mRecord.removeAttribute('aria-describedby');
|
|
1729
|
+
const open = member ? this.opts.base : portal;
|
|
1730
|
+
e.mOpen.hidden = !open;
|
|
1731
|
+
if (open)
|
|
1732
|
+
e.mOpen.setAttribute('href', open);
|
|
1733
|
+
setLabel(e.mOpen, member ? s.openVitrinka : s.openPortal);
|
|
1734
|
+
}
|
|
1735
|
+
paintReports() {
|
|
1736
|
+
const { e, s } = this;
|
|
1737
|
+
setLabel(e.repBack, s.myReports);
|
|
1738
|
+
const local = !this.session;
|
|
1739
|
+
const rows = local
|
|
1740
|
+
? readSent(this.opts.base, globalThis.location?.host ?? '').map((r) => this.row(r.title, r.status === 'quarantined' ? s.waiting : s.steps.received ?? '', r.at, r.url))
|
|
1741
|
+
: this.mine.rows.map((r) => this.row(r.title, s.steps[r.step] ?? r.step, Date.parse(r.updatedAt), r.url));
|
|
1742
|
+
e.repRows.replaceChildren(...rows);
|
|
1743
|
+
const state = local ? 'ok' : this.mine.state;
|
|
1744
|
+
e.repStatus.hidden = state === 'ok' && rows.length > 0;
|
|
1745
|
+
e.repStatus.textContent = state === 'loading' ? s.loading : state === 'failed' ? s.listFailed : s.noReports;
|
|
1746
|
+
e.repLocal.hidden = !local || rows.length === 0;
|
|
1747
|
+
e.repLocal.textContent = s.fromThisBrowser;
|
|
1748
|
+
const portal = this.session?.portalUrl;
|
|
1749
|
+
e.repPortal.hidden = !portal;
|
|
1750
|
+
if (portal)
|
|
1751
|
+
e.repPortal.setAttribute('href', portal);
|
|
1752
|
+
e.repPortal.textContent = s.openPortal;
|
|
1753
|
+
}
|
|
1754
|
+
paintRecents() {
|
|
1755
|
+
const { e, s } = this;
|
|
1756
|
+
setLabel(e.recBack, s.recentRecordings);
|
|
1757
|
+
const rows = readRecents().map((r) => this.row(r.title, '', r.startedAt, r.boardUrl));
|
|
1758
|
+
e.recRows.replaceChildren(...rows);
|
|
1759
|
+
e.recStatus.hidden = rows.length > 0;
|
|
1760
|
+
e.recStatus.textContent = s.noRecordings;
|
|
1761
|
+
}
|
|
1762
|
+
paintLink() {
|
|
1763
|
+
const { e, s } = this;
|
|
1764
|
+
const flow = this.linkFlow;
|
|
1765
|
+
setLabel(e.linkBack, s.linkVitrinka);
|
|
1766
|
+
e.linkLabel.textContent = s.linkCode;
|
|
1767
|
+
e.linkCode.textContent = flow?.start?.user_code ?? '…';
|
|
1768
|
+
e.linkOpenText.textContent = s.openVitrinka;
|
|
1769
|
+
const start = flow?.start;
|
|
1770
|
+
e.linkOpen.hidden = !start;
|
|
1771
|
+
if (start)
|
|
1772
|
+
e.linkOpen.setAttribute('href', start.verifyUrl);
|
|
1773
|
+
// The QR is for another device: a fine pointer (a desk) shows it, a phone is already the other device.
|
|
1774
|
+
const fine = globalThis.matchMedia?.('(pointer: fine)').matches ?? true;
|
|
1775
|
+
e.linkQr.hidden = !start || !fine;
|
|
1776
|
+
if (start && fine && e.linkQr.getAttribute('src') !== start.qrUrl)
|
|
1777
|
+
e.linkQr.setAttribute('src', start.qrUrl);
|
|
1778
|
+
e.linkHint.textContent = s.linkHint;
|
|
1779
|
+
const state = flow?.state ?? 'failed';
|
|
1780
|
+
e.linkWait.textContent = state === 'expired' ? s.linkExpired : state === 'failed' ? s.linkFailed : state === 'waiting' ? s.linkWaiting : s.loading;
|
|
1781
|
+
e.linkRetry.hidden = state !== 'expired' && state !== 'failed';
|
|
1782
|
+
e.linkRetry.textContent = s.retry;
|
|
1783
|
+
}
|
|
1784
|
+
/** 📎, the picker's types, the tray of chips and the refusal line — the tray shows only while there is something in it. */
|
|
1785
|
+
paintFiles() {
|
|
1786
|
+
const { e, s } = this;
|
|
1787
|
+
const locked = this.sending || Boolean(this.job?.id);
|
|
1788
|
+
e.attach.setAttribute('aria-label', s.attach);
|
|
1789
|
+
e.attach.disabled = locked;
|
|
1790
|
+
// maxCount 0: the project switched attaching off — no 📎 to press.
|
|
1791
|
+
e.attach.hidden = this.caps().maxCount === 0;
|
|
1792
|
+
e.fileInput.setAttribute('accept', this.caps().types.join(','));
|
|
1793
|
+
e.tray.hidden = this.view !== 'describe' || (this.files.length === 0 && !this.fileRefusal);
|
|
1794
|
+
e.files.hidden = this.files.length === 0;
|
|
1795
|
+
e.files.setAttribute('aria-label', s.incFiles);
|
|
1796
|
+
e.fileNote.hidden = !this.fileRefusal;
|
|
1797
|
+
e.fileNote.textContent = this.refusalText(this.fileRefusal);
|
|
1798
|
+
for (const [f, chip] of this.chips) {
|
|
1799
|
+
chip.size.textContent = formatBytes(f.size, this.locale);
|
|
1800
|
+
chip.rm.setAttribute('aria-label', s.removeFile(f.name));
|
|
1801
|
+
chip.rm.disabled = locked;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
/** Size and technical details (vt-8020 D9); the size indicator is measured once the pane shows. */
|
|
1805
|
+
paintSettings() {
|
|
1806
|
+
const { e, s } = this;
|
|
1807
|
+
e.sizeLabel.textContent = s.size;
|
|
1808
|
+
for (const [z, btn] of e.sizeButtons) {
|
|
1809
|
+
btn.textContent = s.sizes[z];
|
|
1810
|
+
btn.setAttribute('aria-checked', String(this.size === z));
|
|
1811
|
+
}
|
|
1812
|
+
e.techText.textContent = s.techDetails;
|
|
1813
|
+
e.techBtn.setAttribute('aria-expanded', String(this.techOpen));
|
|
1814
|
+
e.tech.hidden = !this.techOpen;
|
|
1815
|
+
if (this.techOpen && this.view === 'settings') {
|
|
1816
|
+
const rows = techDetails({ version: RECORDER_VERSION, base: this.opts.base, config: this.config, engine: this.engine !== null, locale: this.locale }, s);
|
|
1817
|
+
e.tech.replaceChildren(...rows.flatMap(([k, v]) => [h('dt', {}, k), h('dd', {}, v)]));
|
|
1818
|
+
}
|
|
1819
|
+
if (this.view === 'settings')
|
|
1820
|
+
placeIndicator(e.sizeSeg, e.sizeInd, e.sizeButtons.get(this.size));
|
|
1821
|
+
}
|
|
844
1822
|
paint() {
|
|
845
1823
|
const { e, s } = this;
|
|
846
1824
|
const who = this.who();
|
|
847
1825
|
e.root.setAttribute('lang', this.locale);
|
|
848
1826
|
e.root.classList.toggle('nobutton', !this.button);
|
|
1827
|
+
// The dock and the size (vt-8020 D9): the stylesheet places and scales everything from these two.
|
|
1828
|
+
e.root.dataset.dock = this.dock;
|
|
1829
|
+
e.root.style.setProperty('--vr-scale', String(SIZE_SCALE[this.size]));
|
|
849
1830
|
e.fab.hidden = !this.button || this.marking;
|
|
850
1831
|
e.fabLabel.textContent = s.button;
|
|
851
1832
|
e.fab.setAttribute('aria-expanded', String(this.isOpen));
|
|
1833
|
+
e.fab.setAttribute('aria-description', s.moveHint);
|
|
1834
|
+
e.fab.setAttribute('aria-keyshortcuts', 'Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight');
|
|
852
1835
|
e.fabKbd.hidden = !this.keybind;
|
|
853
1836
|
e.fabKbd.textContent = this.keybind ? keybindLabel(this.keybind) : '';
|
|
854
|
-
|
|
1837
|
+
// The one card stays up while marking (vt-8020 D10): its note lines and Send are where the reporter finishes.
|
|
1838
|
+
e.card.hidden = !this.isOpen;
|
|
1839
|
+
e.card.classList.toggle('busy', this.sending);
|
|
855
1840
|
e.title.textContent = s.title;
|
|
856
|
-
e.gear.setAttribute('aria-label', s.settings);
|
|
857
|
-
e.gear.setAttribute('aria-pressed', String(this.view === 'settings'));
|
|
858
1841
|
e.closeBtn.setAttribute('aria-label', s.close);
|
|
1842
|
+
this.paintAccount();
|
|
859
1843
|
e.describe.hidden = this.view !== 'describe';
|
|
860
1844
|
e.settings.hidden = this.view !== 'settings';
|
|
861
1845
|
e.sent.hidden = this.view !== 'sent';
|
|
1846
|
+
e.reports.hidden = this.view !== 'reports';
|
|
1847
|
+
e.recents.hidden = this.view !== 'recents';
|
|
1848
|
+
e.linking.hidden = this.view !== 'link';
|
|
1849
|
+
if (this.view === 'reports')
|
|
1850
|
+
this.paintReports();
|
|
1851
|
+
if (this.view === 'recents')
|
|
1852
|
+
this.paintRecents();
|
|
1853
|
+
if (this.view === 'link')
|
|
1854
|
+
this.paintLink();
|
|
1855
|
+
e.foot.hidden = this.view !== 'describe';
|
|
1856
|
+
this.paintFiles();
|
|
1857
|
+
e.kindsLabel.textContent = s.kindsLabel;
|
|
1858
|
+
for (const [kind, btn] of e.kindButtons) {
|
|
1859
|
+
btn.textContent = s.kinds[kind];
|
|
1860
|
+
btn.setAttribute('aria-checked', String(this.kind === kind));
|
|
1861
|
+
// The type rides only the create: once the report is on its way a retry cannot change it.
|
|
1862
|
+
btn.disabled = this.sending || Boolean(this.job?.id);
|
|
1863
|
+
}
|
|
862
1864
|
e.prompt.textContent = s.prompt;
|
|
863
1865
|
e.desc.placeholder = s.placeholder;
|
|
864
1866
|
e.attachedText.textContent = s.attached(this.config?.profile.windowSec ?? 60);
|
|
@@ -868,17 +1870,23 @@ export class ReportWidget {
|
|
|
868
1870
|
e.disclose.setAttribute('aria-expanded', String(this.includedOpen));
|
|
869
1871
|
e.included.hidden = !this.includedOpen;
|
|
870
1872
|
e.included.replaceChildren(...this.includedItems().map((t) => h('li', {}, t)));
|
|
871
|
-
e.
|
|
872
|
-
e.
|
|
873
|
-
e.
|
|
1873
|
+
e.desc.disabled = this.sending;
|
|
1874
|
+
e.lines.hidden = this.markers.length === 0;
|
|
1875
|
+
e.linesEmpty.hidden = !this.marking || this.markers.length > 0;
|
|
1876
|
+
e.linesEmpty.textContent = s.linesEmpty;
|
|
1877
|
+
for (const line of this.lines.values()) {
|
|
1878
|
+
line.note.disabled = this.sending;
|
|
1879
|
+
line.rm.disabled = this.sending;
|
|
1880
|
+
}
|
|
874
1881
|
e.notify.hidden = who === null;
|
|
875
1882
|
e.notifyText.textContent = s.notify;
|
|
876
1883
|
e.error.hidden = this.error === '';
|
|
877
|
-
e.error.textContent =
|
|
1884
|
+
e.error.textContent = { '': '', create: s.errorCreate, files: s.errorFiles, capture: s.errorCapture }[this.error];
|
|
878
1885
|
e.whereText.textContent = s.showWhere;
|
|
1886
|
+
e.where.setAttribute('aria-pressed', String(this.marking));
|
|
879
1887
|
e.where.disabled = this.sending || Boolean(this.job?.id);
|
|
880
1888
|
e.send.textContent = this.sending ? s.sending : this.error ? s.retry : s.send;
|
|
881
|
-
e.send.disabled = this.sending ||
|
|
1889
|
+
e.send.disabled = this.sending || this.words() === '';
|
|
882
1890
|
e.bindLabel.textContent = s.shortcut;
|
|
883
1891
|
e.bindBtn.setAttribute('aria-pressed', String(this.recordingBind));
|
|
884
1892
|
e.bindBtn.setAttribute('aria-label', `${s.shortcut}: ${this.keybind ? keybindLabel(this.keybind) : s.notSet} — ${s.recordShortcut}`);
|
|
@@ -889,8 +1897,10 @@ export class ReportWidget {
|
|
|
889
1897
|
e.bindReason.hidden = !this.bindRefused;
|
|
890
1898
|
e.bindReason.textContent = this.bindRefused ? s.needModifier : '';
|
|
891
1899
|
e.back.textContent = s.back;
|
|
1900
|
+
this.paintSettings();
|
|
892
1901
|
e.sentTitle.textContent = s.sentTitle;
|
|
893
|
-
|
|
1902
|
+
// Filed or waiting: an unsigned report is checked by the team before it is filed, and says so.
|
|
1903
|
+
e.sentBody.textContent = this.result?.status === 'quarantined' ? s.sentQueued : this.sentNotify ? s.sentNotify : s.sentBody;
|
|
894
1904
|
e.seeText.textContent = s.seeReport;
|
|
895
1905
|
const url = this.result?.reportUrl;
|
|
896
1906
|
e.see.hidden = !url;
|
|
@@ -901,13 +1911,20 @@ export class ReportWidget {
|
|
|
901
1911
|
e.sentClose.textContent = s.close;
|
|
902
1912
|
e.mark.hidden = !this.marking;
|
|
903
1913
|
e.toolbar.setAttribute('aria-label', s.toolbar);
|
|
1914
|
+
e.seg.setAttribute('aria-label', s.toolbar);
|
|
1915
|
+
e.barLead.textContent = s.barLead;
|
|
904
1916
|
for (const [tool, btn] of e.toolButtons) {
|
|
905
|
-
|
|
906
|
-
|
|
1917
|
+
const label = e.toolLabels.get(tool);
|
|
1918
|
+
if (label)
|
|
1919
|
+
label.textContent = s.tools[tool];
|
|
1920
|
+
btn.setAttribute('aria-checked', String(this.tool === tool));
|
|
907
1921
|
}
|
|
908
|
-
e.
|
|
909
|
-
e.
|
|
910
|
-
e.
|
|
1922
|
+
e.cancel.textContent = s.cancelMarking;
|
|
1923
|
+
e.cancel.hidden = this.confirming;
|
|
1924
|
+
e.ask.hidden = !this.confirming;
|
|
1925
|
+
e.askText.textContent = s.discardMarks(this.markers.filter((m) => !this.passKeys.has(m.key)).length);
|
|
1926
|
+
e.discard.textContent = s.discard;
|
|
1927
|
+
e.keep.textContent = s.keep;
|
|
911
1928
|
e.coach.hidden = !this.marking || this.markers.length > 0;
|
|
912
1929
|
e.coachText.textContent = s.coach;
|
|
913
1930
|
e.coachMore.textContent = s.coachMore;
|
|
@@ -918,8 +1935,9 @@ export class ReportWidget {
|
|
|
918
1935
|
if (label.textContent)
|
|
919
1936
|
label.textContent = s.hidden;
|
|
920
1937
|
}
|
|
921
|
-
this.renderPins();
|
|
922
1938
|
}
|
|
1939
|
+
// Always: the note lines live in the card, so their labels follow the locale outside marking too.
|
|
1940
|
+
this.renderPins();
|
|
923
1941
|
}
|
|
924
1942
|
}
|
|
925
1943
|
function renumberDrawn(markers) {
|