@daybook/feedback 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js ADDED
@@ -0,0 +1,535 @@
1
+ import { captureAnchor } from './anchor.js';
2
+ import { fromPaste, MAX_FILES, revoke, stage } from './files.js';
3
+ import { isTyping } from './hotkey.js';
4
+ /**
5
+ * The reporter-facing UI, rendered inside a shadow root.
6
+ *
7
+ * The shadow root is the point. The predecessor's widgets prefixed every class with `csz-fb-` and
8
+ * lived in the host document, which works until a host page has a `* { box-sizing }` reset, a
9
+ * high-stacking-context overlay, or its own `button {}` rule — and then the feedback tool is broken on
10
+ * exactly the page someone is trying to report a problem on. A shadow root means host CSS cannot
11
+ * reach in and ours cannot leak out.
12
+ */
13
+ export class FeedbackWidget {
14
+ constructor(options, onSubmit) {
15
+ this.options = options;
16
+ this.onSubmit = onSubmit;
17
+ this.mode = 'idle';
18
+ this.anchor = null;
19
+ this.detach = [];
20
+ /**
21
+ * What the widget is allowed to do, from the handshake.
22
+ *
23
+ * 'pending' renders an explanation instead of a launcher: somebody who cannot report yet should
24
+ * be told so, not left clicking a button that silently does nothing.
25
+ */
26
+ this.state = 'ready';
27
+ /** The reference of the last report, so the confirmation can quote it. */
28
+ this.reference = null;
29
+ this.host = document.createElement('div');
30
+ this.host.setAttribute('data-daybook-feedback', '');
31
+ // Above any host overlay, but not Number.MAX_SAFE_INTEGER — a host app with its own modal should
32
+ // still be able to sit above us deliberately.
33
+ this.host.style.cssText = 'position:fixed;inset:0;z-index:2147483000;pointer-events:none';
34
+ this.root = this.host.attachShadow({ mode: 'open' });
35
+ this.root.innerHTML =
36
+ `<style>${STYLES}</style><style id="theme"></style><div id="layer"></div>`;
37
+ }
38
+ /**
39
+ * Applies the tokens the handshake served.
40
+ *
41
+ * Custom properties on :host, never a stylesheet the server sent. The shadow root exists so the
42
+ * host page cannot reach in, and accepting arbitrary CSS from anywhere would hand that back —
43
+ * a theme is a fixed set of named values, and an unrecognised one is ignored rather than injected.
44
+ */
45
+ setTheme(theme) {
46
+ const style = this.root.getElementById('theme');
47
+ if (!style)
48
+ return;
49
+ if (!theme) {
50
+ style.textContent = '';
51
+ return;
52
+ }
53
+ const declarations = [];
54
+ // Each value is validated against a shape rather than passed through. A colour that is not a
55
+ // colour would otherwise close the property and let the rest of the string be read as CSS.
56
+ if (isColor(theme.accent))
57
+ declarations.push(`--pm-accent: ${theme.accent}`);
58
+ const radius = { none: '0', sm: '6px', md: '12px', lg: '18px' }[theme.cornerRadius ?? 'md'];
59
+ if (radius)
60
+ declarations.push(`--pm-radius: ${radius}`);
61
+ const corner = POSITIONS[theme.position ?? 'bottom-right'];
62
+ if (corner)
63
+ declarations.push(corner);
64
+ style.textContent = declarations.length > 0 ? `:host { ${declarations.join('; ')} }` : '';
65
+ this.launcherLabel = typeof theme.launcherLabel === 'string' && theme.launcherLabel.length > 0
66
+ ? theme.launcherLabel.slice(0, 24)
67
+ : undefined;
68
+ }
69
+ setState(state) {
70
+ this.state = state;
71
+ if (this.host.isConnected)
72
+ this.render();
73
+ }
74
+ mount() {
75
+ document.body.appendChild(this.host);
76
+ this.render();
77
+ if (this.options.hotkey !== null) {
78
+ const hotkey = (this.options.hotkey ?? 'f').toLowerCase();
79
+ const onKey = (event) => {
80
+ if (event.key === 'Escape') {
81
+ this.mode = 'idle';
82
+ this.anchor = null;
83
+ this.render();
84
+ return;
85
+ }
86
+ if (event.metaKey || event.ctrlKey || event.altKey)
87
+ return;
88
+ // Never while the reporter is typing — in the host app or in our own composer.
89
+ if (isTyping(event))
90
+ return;
91
+ // And never while the composer is open. Even with focus somewhere non-editable in the panel,
92
+ // a bare letter must not throw away what has been written — the second guard costs nothing
93
+ // and the failure it prevents loses the reporter's words.
94
+ if (this.mode === 'composing')
95
+ return;
96
+ if (event.key.toLowerCase() === hotkey) {
97
+ this.mode = this.mode === 'picking' ? 'idle' : 'picking';
98
+ this.render();
99
+ }
100
+ };
101
+ window.addEventListener('keydown', onKey);
102
+ this.detach.push(() => window.removeEventListener('keydown', onKey));
103
+ }
104
+ }
105
+ unmount() {
106
+ for (const undo of this.detach.splice(0))
107
+ undo();
108
+ this.host.remove();
109
+ }
110
+ open() {
111
+ this.mode = 'picking';
112
+ this.render();
113
+ }
114
+ setReporter(reporter) {
115
+ this.reporter = reporter;
116
+ }
117
+ render() {
118
+ const layer = this.root.getElementById('layer');
119
+ layer.innerHTML = '';
120
+ if (this.mode === 'idle') {
121
+ layer.appendChild(this.state === 'pending' ? this.pending() : this.launcher());
122
+ return;
123
+ }
124
+ if (this.mode === 'sent') {
125
+ layer.appendChild(this.sent());
126
+ return;
127
+ }
128
+ if (this.mode === 'picking') {
129
+ layer.appendChild(this.picker());
130
+ return;
131
+ }
132
+ layer.appendChild(this.composer());
133
+ }
134
+ /**
135
+ * Shown in place of the launcher when this person is waiting on approval.
136
+ *
137
+ * Explaining beats hiding. A widget that simply is not there reads as broken to somebody who was
138
+ * told their company uses it, and reads as nothing at all to somebody who was not — and the
139
+ * second case is what Blocked gets, deliberately, by never mounting at all.
140
+ */
141
+ pending() {
142
+ const note = document.createElement('div');
143
+ note.className = 'launcher launcher--pending';
144
+ note.setAttribute('role', 'status');
145
+ note.textContent = 'Feedback access pending approval';
146
+ return note;
147
+ }
148
+ /**
149
+ * What a reporter sees after Send.
150
+ *
151
+ * Closing silently answered "did that work?" with nothing, which is the one question everybody has
152
+ * — and it threw away the reference the wire contract deliberately makes human-quotable. It clears
153
+ * itself after a few seconds rather than needing a click: an acknowledgement that has to be
154
+ * dismissed is a second chore for having done somebody a favour.
155
+ */
156
+ sent() {
157
+ const note = document.createElement('div');
158
+ note.className = 'panel panel--sent';
159
+ note.setAttribute('role', 'status');
160
+ note.innerHTML = `
161
+ <div class="sent__tick" aria-hidden="true">&check;</div>
162
+ <div>
163
+ <div class="panel__title">Thank you — that is on its way.</div>
164
+ ${this.reference
165
+ ? `<div class="panel__anchor">Quote <strong>${escapeHtml(this.reference)}</strong> if you follow it up.</div>`
166
+ : ''}
167
+ </div>`;
168
+ const close = window.setTimeout(() => {
169
+ if (this.mode !== 'sent')
170
+ return;
171
+ this.mode = 'idle';
172
+ this.render();
173
+ }, 6000);
174
+ this.detach.push(() => window.clearTimeout(close));
175
+ return note;
176
+ }
177
+ launcher() {
178
+ const button = document.createElement('button');
179
+ button.className = 'launcher';
180
+ button.textContent = this.launcherLabel ?? 'Feedback';
181
+ button.title = this.options.hotkey === null
182
+ ? 'Report a problem'
183
+ : `Report a problem (${(this.options.hotkey ?? 'f').toUpperCase()})`;
184
+ button.onclick = () => { this.mode = 'picking'; this.render(); };
185
+ return button;
186
+ }
187
+ picker() {
188
+ const mask = document.createElement('div');
189
+ mask.className = 'mask';
190
+ mask.innerHTML = `<div class="hint">Click the thing that is wrong · <kbd>Esc</kbd> to cancel</div>`;
191
+ mask.onclick = (event) => {
192
+ // The mask has to stop intercepting before elementFromPoint runs, or every anchor resolves to
193
+ // the mask itself. The predecessor hit this too.
194
+ mask.style.pointerEvents = 'none';
195
+ this.anchor = captureAnchor(event.clientX, event.clientY);
196
+ mask.style.pointerEvents = '';
197
+ this.mode = 'composing';
198
+ this.render();
199
+ };
200
+ return mask;
201
+ }
202
+ composer() {
203
+ const panel = document.createElement('div');
204
+ panel.className = 'panel';
205
+ const anchorLabel = this.anchor?.elementText
206
+ ? `on “${this.anchor.elementText}”`
207
+ : this.anchor?.selector
208
+ ? `on ${this.anchor.selector}`
209
+ : 'on this page';
210
+ // The anchor leads, because it is the thing this widget has that a contact form does not: the
211
+ // reporter pointed at something, and saying what they pointed at is how they know we understood.
212
+ // "Report a problem" is a heading anybody could have written; the anchor is theirs.
213
+ panel.innerHTML = `
214
+ <div class="panel__head">
215
+ <div>
216
+ <div class="panel__anchor">${escapeHtml(anchorLabel)}</div>
217
+ <div class="panel__title">Report a problem</div>
218
+ </div>
219
+ <button id="close" class="panel__close" aria-label="Close">&times;</button>
220
+ </div>
221
+
222
+ <textarea id="message" rows="5" placeholder="What happened?"></textarea>
223
+
224
+ <!--
225
+ Under the message, not above it. Four filled buttons at the top were the loudest thing in the
226
+ panel and the least important decision in it — the default is right almost every time, and
227
+ what somebody came here to do is type.
228
+ -->
229
+ <div class="panel__kinds">
230
+ ${['bug', 'idea', 'praise', 'question'].map((k, i) => `<button class="kind${i === 0 ? ' kind--on' : ''}" data-kind="${k}">${k}</button>`).join('')}
231
+ </div>
232
+
233
+ <input id="email" type="email" placeholder="Email (optional, so we can reply)" autocomplete="email" />
234
+
235
+ <!-- One attachment area, not two. A checkbox for the screen and a dropzone for a file were
236
+ two ways to do the same thing, stacked, both dim. -->
237
+ <div id="drop" class="drop">
238
+ <label class="shot"><input id="shot" type="checkbox" ${this.options.screenshots === false ? '' : 'checked'} /> Capture the screen</label>
239
+ <span class="drop__or">or paste, drop, or
240
+ <input id="file" type="file" multiple accept="image/*,video/mp4,video/quicktime,video/webm" hidden />
241
+ <button id="browse" class="link">choose a file</button>
242
+ </span>
243
+ </div>
244
+
245
+ <div id="files" class="files"></div>
246
+ <div id="status" class="status"></div>
247
+
248
+ <div class="panel__foot">
249
+ <span class="panel__note">Sends the page, your browser, and recent errors.</span>
250
+ <button id="cancel" class="ghost">Cancel</button>
251
+ <button id="send" class="primary">Send</button>
252
+ </div>`;
253
+ const files = [];
254
+ const fileList = panel.querySelector('#files');
255
+ const drop = panel.querySelector('#drop');
256
+ const fileInput = panel.querySelector('#file');
257
+ const renderFiles = () => {
258
+ fileList.innerHTML = '';
259
+ files.forEach((file, index) => {
260
+ const row = document.createElement('div');
261
+ row.className = file.error ? 'file file--bad' : 'file';
262
+ row.innerHTML = file.preview
263
+ ? `<img src="${file.preview}" alt="" />`
264
+ : '<span class="file__icon">▦</span>';
265
+ const label = document.createElement('span');
266
+ label.className = 'file__name';
267
+ label.textContent = file.error ?? file.filename;
268
+ row.appendChild(label);
269
+ const remove = document.createElement('button');
270
+ remove.className = 'link';
271
+ remove.textContent = '×';
272
+ remove.onclick = () => {
273
+ revoke([file]);
274
+ files.splice(index, 1);
275
+ renderFiles();
276
+ };
277
+ row.appendChild(remove);
278
+ fileList.appendChild(row);
279
+ });
280
+ drop.style.display = files.length >= MAX_FILES ? 'none' : '';
281
+ };
282
+ const addFiles = (incoming) => {
283
+ files.push(...stage(incoming, files.length));
284
+ renderFiles();
285
+ };
286
+ fileInput.onchange = () => { if (fileInput.files)
287
+ addFiles(fileInput.files); };
288
+ panel.querySelector('#browse').onclick = () => fileInput.click();
289
+ // Paste anywhere in the panel, because a reporter who just hit Cmd+Shift+4 will paste wherever
290
+ // the caret happens to be.
291
+ panel.addEventListener('paste', event => {
292
+ const pasted = fromPaste(event);
293
+ if (pasted.length > 0) {
294
+ event.preventDefault();
295
+ addFiles(pasted);
296
+ }
297
+ });
298
+ drop.addEventListener('dragover', event => {
299
+ event.preventDefault();
300
+ drop.classList.add('drop--over');
301
+ });
302
+ drop.addEventListener('dragleave', () => drop.classList.remove('drop--over'));
303
+ drop.addEventListener('drop', event => {
304
+ event.preventDefault();
305
+ drop.classList.remove('drop--over');
306
+ addFiles(Array.from(event.dataTransfer?.files ?? []));
307
+ });
308
+ let kind = 'bug';
309
+ panel.querySelectorAll('.kind').forEach(button => {
310
+ button.onclick = () => {
311
+ kind = button.dataset.kind ?? 'bug';
312
+ panel.querySelectorAll('.kind').forEach(b => b.classList.remove('kind--on'));
313
+ button.classList.add('kind--on');
314
+ };
315
+ });
316
+ const message = panel.querySelector('#message');
317
+ const email = panel.querySelector('#email');
318
+ /*
319
+ * Do not ask for an address the host already knows.
320
+ *
321
+ * The reporter arrives through init() or identify() and was being used only to attribute the
322
+ * report — the field itself stayed empty, so a signed-in person was asked to type their own
323
+ * email every time. Reported by somebody who had just done exactly that.
324
+ *
325
+ * Pre-filled rather than replaced by a label, because reporting on behalf of a colleague is a
326
+ * real thing and the field is where you would go to do it.
327
+ */
328
+ const known = this.reporter?.email ?? this.options.reporter?.email;
329
+ if (known && !email.value)
330
+ email.value = known;
331
+ const shot = panel.querySelector('#shot');
332
+ const status = panel.querySelector('#status');
333
+ const send = panel.querySelector('#send');
334
+ const dismiss = () => {
335
+ revoke(files);
336
+ this.mode = 'idle';
337
+ this.anchor = null;
338
+ this.render();
339
+ };
340
+ panel.querySelector('#cancel').onclick = dismiss;
341
+ panel.querySelector('#close').onclick = dismiss;
342
+ const submit = async () => {
343
+ if (!message.value.trim()) {
344
+ status.textContent = 'Say what happened first.';
345
+ return;
346
+ }
347
+ send.disabled = true;
348
+ status.textContent = 'Sending…';
349
+ try {
350
+ this.reference = (await this.onSubmit({
351
+ message: message.value.trim(),
352
+ kind,
353
+ email: email.value.trim() || undefined,
354
+ anchor: this.anchor,
355
+ withScreenshot: shot.checked,
356
+ files: files.filter(f => !f.error),
357
+ })) || null;
358
+ revoke(files);
359
+ // Confirmed, not just closed.
360
+ //
361
+ // The panel used to vanish, which leaves the one question every reporter has — did that
362
+ // send? — answered by nothing at all. And the reference is the thing the wire contract
363
+ // calls human-quotable: it exists so somebody can say "F-0007" to support, which they
364
+ // cannot do if they never see it.
365
+ this.mode = 'sent';
366
+ this.anchor = null;
367
+ this.render();
368
+ }
369
+ catch (error) {
370
+ // Kept open with the text intact. Clearing a report because the network failed is how a
371
+ // reporter loses what they wrote and does not write it again.
372
+ send.disabled = false;
373
+ status.textContent = error instanceof Error
374
+ ? `${error.message} — saved, will retry.`
375
+ : 'Failed, saved and will retry.';
376
+ }
377
+ };
378
+ send.onclick = submit;
379
+ message.onkeydown = (event) => {
380
+ if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
381
+ submit();
382
+ };
383
+ setTimeout(() => message.focus(), 0);
384
+ return panel;
385
+ }
386
+ }
387
+ function escapeHtml(value) {
388
+ return value.replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
389
+ }
390
+ /**
391
+ * Scoped by the shadow root, so these plain names cannot collide with the host page. Colours are
392
+ * hard-coded rather than inherited for the same reason — a host app's dark mode should not make our
393
+ * text invisible.
394
+ */
395
+ /**
396
+ * Where the launcher and the panel sit, as a pair of custom properties.
397
+ *
398
+ * A fixed map rather than free text: the value goes into a stylesheet, and a position that is not
399
+ * one of these four is a string somebody chose.
400
+ */
401
+ const POSITIONS = {
402
+ 'bottom-right': '--pm-left: auto; --pm-right: 16px; --pm-top: auto; --pm-bottom: 16px',
403
+ 'bottom-left': '--pm-left: 16px; --pm-right: auto; --pm-top: auto; --pm-bottom: 16px',
404
+ 'top-right': '--pm-left: auto; --pm-right: 16px; --pm-top: 16px; --pm-bottom: auto',
405
+ 'top-left': '--pm-left: 16px; --pm-right: auto; --pm-top: 16px; --pm-bottom: auto',
406
+ };
407
+ /**
408
+ * A hex colour, an rgb()/hsl() call, or a plain CSS colour word.
409
+ *
410
+ * Validated because the value is interpolated into a stylesheet inside our own shadow root: without
411
+ * this, a theme value of `red; } :host { display: none` would close the declaration and let the
412
+ * rest through as CSS of the sender's choosing.
413
+ */
414
+ function isColor(value) {
415
+ return typeof value === 'string'
416
+ && /^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%/]+\)|hsla?\([\d\s.,%/deg]+\)|[a-z]{3,20})$/i.test(value.trim());
417
+ }
418
+ const STYLES = `
419
+ :host {
420
+ all: initial;
421
+
422
+ /* Defaults, overridden by the theme block the handshake fills in.
423
+ Offsets rather than a keyword: a custom property can hold a value, not a property name, so
424
+ "put it on the left" has to be four numbers and not one word. */
425
+ --pm-accent: #171717;
426
+ --pm-radius: 12px;
427
+ --pm-left: auto;
428
+ --pm-right: 16px;
429
+ --pm-top: auto;
430
+ --pm-bottom: 16px;
431
+ }
432
+ * { box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif }
433
+ #layer { position: fixed; inset: 0; pointer-events: none }
434
+ .launcher {
435
+ position: fixed; pointer-events: auto;
436
+ left: var(--pm-left); right: var(--pm-right);
437
+ top: var(--pm-top); bottom: var(--pm-bottom);
438
+ padding: 9px 14px; border: 0; border-radius: 999px; cursor: pointer;
439
+ background: var(--pm-accent); color: #fafafa; font-size: 13px; font-weight: 500;
440
+ box-shadow: 0 2px 12px rgba(0,0,0,.3);
441
+ }
442
+ .launcher:hover { filter: brightness(1.15) }
443
+ .launcher--pending { cursor: default; opacity: .85 }
444
+ .launcher--pending:hover { filter: none }
445
+ .mask {
446
+ position: fixed; inset: 0; pointer-events: auto; cursor: crosshair;
447
+ background: rgba(23,23,23,.12);
448
+ }
449
+ .hint {
450
+ position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
451
+ padding: 7px 12px; border-radius: 8px; background: #171717; color: #fafafa;
452
+ font-size: 12px; white-space: nowrap;
453
+ }
454
+ kbd {
455
+ padding: 1px 5px; border-radius: 4px; background: #404040;
456
+ font-family: ui-monospace, monospace; font-size: 11px;
457
+ }
458
+ .panel {
459
+ position: fixed; width: 380px; max-width: calc(100vw - 32px); pointer-events: auto;
460
+ left: var(--pm-left); right: var(--pm-right);
461
+ top: var(--pm-top); bottom: var(--pm-bottom);
462
+ padding: 16px; border-radius: var(--pm-radius); background: #fff; color: #171717;
463
+ box-shadow: 0 8px 32px rgba(0,0,0,.24); font-size: 13px;
464
+ }
465
+ .panel__head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px }
466
+ .panel__title { font-weight: 600; font-size: 14px }
467
+
468
+ /* The anchor leads: it is what the reporter pointed at, and the part they need to recognise. */
469
+ .panel__anchor {
470
+ color: #737373; font-size: 11px;
471
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
472
+ }
473
+ .panel__close {
474
+ margin-left: auto; border: 0; background: none; cursor: pointer;
475
+ color: #a3a3a3; font-size: 20px; line-height: 1; padding: 0 2px;
476
+ }
477
+ .panel__close:hover { color: #171717 }
478
+
479
+ /* A confirmation, not a form. */
480
+ .panel--sent { display: flex; align-items: center; gap: 10px }
481
+ .sent__tick {
482
+ flex: none; width: 24px; height: 24px; border-radius: 999px;
483
+ background: #ecfdf5; color: #047857;
484
+ display: grid; place-items: center; font-size: 14px;
485
+ }
486
+
487
+ .panel__kinds { display: flex; gap: 6px; margin: 8px 0 }
488
+ .kind {
489
+ flex: 1; padding: 5px 0; border: 1px solid #e5e5e5; border-radius: 7px;
490
+ background: #fff; color: #525252; cursor: pointer; font-size: 12px; text-transform: capitalize;
491
+ }
492
+ .kind--on { border-color: #171717; background: #171717; color: #fff }
493
+ textarea, input[type=email] {
494
+ width: 100%; padding: 8px; margin-bottom: 8px; border: 1px solid #e5e5e5;
495
+ border-radius: 8px; font-size: 13px; resize: vertical; color: #171717; background: #fff;
496
+ }
497
+ textarea:focus, input:focus { outline: 2px solid #171717; outline-offset: -1px }
498
+ .shot { display: flex; align-items: center; gap: 6px; color: #525252; font-size: 12px }
499
+
500
+ /*
501
+ One row. Cancel used to sit ABOVE Send in a stacked span, which read as a label for it rather than
502
+ an alternative to it — and put the escape hatch further from the thumb than the commit.
503
+ */
504
+ .panel__foot {
505
+ display: flex; align-items: center; gap: 8px; margin-top: 12px;
506
+ padding-top: 12px; border-top: 1px solid #f0f0f0;
507
+ }
508
+ .panel__note { flex: 1; color: #a3a3a3; font-size: 10px; line-height: 1.3 }
509
+ .primary, .ghost {
510
+ padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 500;
511
+ }
512
+ .primary { border: 0; background: #171717; color: #fff }
513
+ .primary:disabled { opacity: .5; cursor: default }
514
+ .ghost { border: 0; background: transparent; color: #737373 }
515
+ .status { margin-top: 6px; color: #b45309; font-size: 11px; min-height: 0 }
516
+ /*
517
+ One attachment area, holding both ways of adding a picture. They were a checkbox and a dropzone
518
+ stacked — two affordances for one job, and together the busiest part of a panel whose busiest part
519
+ should be the message.
520
+ */
521
+ .drop {
522
+ display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
523
+ margin-top: 8px; padding: 8px 10px; border: 1px dashed #d4d4d4; border-radius: 8px;
524
+ color: #a3a3a3; font-size: 11px;
525
+ }
526
+ .drop__or { color: #a3a3a3 }
527
+ .drop--over { border-color: #171717; color: #171717; background: #fafafa }
528
+ .files { display: flex; flex-direction: column; gap: 4px; margin-top: 8px }
529
+ .file { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #525252 }
530
+ .file--bad { color: #b45309 }
531
+ .file img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px }
532
+ .file__icon { width: 28px; text-align: center }
533
+ .file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
534
+ .link { border: 0; background: transparent; color: #525252; cursor: pointer; font-size: 11px; text-decoration: underline }
535
+ `;
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@daybook/feedback",
3
+ "version": "1.0.0",
4
+ "description": "In-app feedback for the web: point at what is wrong, and everything a triager needs is captured automatically.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc -p tsconfig.json && npm run bundle",
14
+ "typecheck": "tsc -p tsconfig.json --noEmit",
15
+ "test": "node --test test/*.test.js",
16
+ "bundle": "esbuild src/index.ts --bundle --format=iife --global-name=DaybookFeedback --minify --target=es2019 --outfile=dist/feedback.js",
17
+ "prepublishOnly": "npm run build && npm test"
18
+ },
19
+ "devDependencies": {
20
+ "esbuild": "^0.28.2",
21
+ "typescript": "^5.7.2"
22
+ },
23
+ "allowScripts": {
24
+ "esbuild@0.28.2": true
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./browser": "./dist/feedback.js"
32
+ },
33
+ "sideEffects": false,
34
+ "license": "MIT",
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "homepage": "https://daybook.team",
39
+ "keywords": [
40
+ "feedback",
41
+ "bug-report",
42
+ "widget",
43
+ "in-app-feedback",
44
+ "screenshot"
45
+ ]
46
+ }