report-studio 0.0.1 → 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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +238 -4
  3. package/dist/designer.js +3209 -0
  4. package/dist/index.js +2 -4
  5. package/dist/viewer-D-c0lKzQ.js +1576 -0
  6. package/package.json +66 -33
  7. package/src/asset/images/icon.png +0 -0
  8. package/src/asset/images/logo.png +0 -0
  9. package/src/cli/index.js +282 -0
  10. package/src/cli/serve.js +135 -0
  11. package/src/designer/blank.js +53 -0
  12. package/src/designer/canvas.js +518 -0
  13. package/src/designer/designer.js +1900 -0
  14. package/src/designer/dialog.js +708 -0
  15. package/src/designer/fields.js +584 -0
  16. package/src/designer/geometry.js +154 -0
  17. package/src/designer/guides.js +370 -0
  18. package/src/designer/history.js +113 -0
  19. package/src/designer/icons.js +118 -0
  20. package/src/designer/index.html +28 -0
  21. package/src/designer/main.js +39 -0
  22. package/src/designer/menu.js +126 -0
  23. package/src/designer/panel.js +478 -0
  24. package/src/designer/preview.js +95 -0
  25. package/src/designer/rulers.js +231 -0
  26. package/src/designer/sample-data.js +240 -0
  27. package/src/designer/select.js +699 -0
  28. package/src/designer/structure.js +604 -0
  29. package/src/designer/styles.css +1616 -0
  30. package/src/designer/toast.js +62 -0
  31. package/src/designer/tokens.js +284 -0
  32. package/src/engine/csv.js +315 -0
  33. package/src/engine/group.js +304 -0
  34. package/src/engine/index.js +34 -0
  35. package/src/engine/measure.js +390 -0
  36. package/src/engine/paginate.js +861 -0
  37. package/src/engine/regions.js +175 -0
  38. package/src/engine/resolve.js +171 -0
  39. package/src/engine/search.js +129 -0
  40. package/src/engine/text-metrics.js +206 -0
  41. package/src/engine/validate.js +328 -0
  42. package/src/index.html +79 -0
  43. package/src/index.js +50 -0
  44. package/src/preview/chrome.css +505 -0
  45. package/src/preview/chrome.js +147 -0
  46. package/src/preview/index.html +28 -0
  47. package/src/preview/main.js +66 -0
  48. package/src/preview/styles.css +16 -0
  49. package/src/preview/viewer.js +745 -0
  50. package/src/render/items.js +425 -0
  51. package/src/render/render.js +98 -0
  52. package/src/render/report.css +202 -0
  53. package/src/server/routes.js +331 -0
  54. package/src/shared/brand.css +29 -0
  55. package/src/shared/dropdown.css +136 -0
  56. package/src/shared/dropdown.js +166 -0
  57. package/src/shared/modal.css +125 -0
  58. package/src/shared/prefix.js +13 -0
  59. package/src/shared/store.js +145 -0
  60. package/src/shared/theme.css +72 -0
  61. package/src/shared/window.js +138 -0
  62. package/src/vite/index.js +53 -0
  63. package/dist/react.js +0 -4
@@ -0,0 +1,478 @@
1
+ /**
2
+ * panel.js draws the properties rail and reports what was done to it.
3
+ *
4
+ * Like select.js, it decides nothing: which fields exist, what a value coerces
5
+ * to, and what adding a band or a column means are all fields.js and
6
+ * structure.js. This turns descriptors into controls and controls back into
7
+ * calls.
8
+ *
9
+ * The rail shows one of two things. With an item selected, that item's
10
+ * properties. With nothing selected, the report's own - name, page, margins and
11
+ * which bands exist - because those have to be editable somewhere and "nothing
12
+ * selected" is otherwise a wasted screen.
13
+ *
14
+ * It is redrawn when the *selection* changes and never while someone is typing
15
+ * in it: rebuilding an input under a cursor takes the focus and the caret with
16
+ * it, and typing "120" into a width becomes "1". Values that changed elsewhere,
17
+ * such as x and y during a drag, are synced onto the existing controls instead.
18
+ */
19
+
20
+ import {
21
+ fieldsFor, allFields, reportFields, allReportFields,
22
+ COLUMN_FIELDS, readField, writeField
23
+ } from './fields.js';
24
+ import { BAND_TYPES, BAND_NOTES, hasBand, findBand } from './structure.js';
25
+ import { esc } from '../render/items.js';
26
+
27
+
28
+ /**
29
+ * The rail describes what a thing is; what you can do to it lives in the pill
30
+ * that opens on a right-click, beside the item rather than at the edge of the
31
+ * screen. See menu.js.
32
+ */
33
+
34
+
35
+ /**
36
+ * The rail for a selected item.
37
+ * @param {object} item
38
+ * @returns {string} markup
39
+ */
40
+ export function drawPanel(item) {
41
+ return `
42
+ <div class="dz-panel-head">
43
+ <span class="dz-panel-type">${esc(item.type)}</span>
44
+ <span class="dz-panel-id">${esc(item.id)}</span>
45
+ </div>
46
+ ${sections(item, fieldsFor(item))}
47
+ ${item.type === 'table' ? columns(item) : ''}`;
48
+ }
49
+
50
+
51
+ /**
52
+ * The rail with several items selected.
53
+ *
54
+ * No property controls: writing one width onto six items is a different edit
55
+ * from the one the controls describe, and offering a box that means "all of
56
+ * them" where it has always meant "this one" is how a designer loses somebody's
57
+ * layout. What a group genuinely shares is that it can be moved and deleted,
58
+ * so that is what it offers.
59
+ *
60
+ * @param {object[]} items
61
+ * @returns {string} markup
62
+ */
63
+ export function drawManyPanel(items) {
64
+ return `
65
+ <div class="dz-panel-head">
66
+ <span class="dz-panel-type">${items.length} items</span>
67
+ </div>
68
+
69
+ <section class="dz-section">
70
+ <ul class="dz-selected">
71
+ ${items.map(item => `
72
+ <li>
73
+ <span class="dz-selected-type">${esc(item.type)}</span>
74
+ <span class="dz-selected-id">${esc(item.id)}</span>
75
+ </li>`).join('')}
76
+ </ul>
77
+
78
+ <p class="dz-hint">
79
+ Drag to move them together, or use the arrow keys.
80
+ Select one on its own to change its properties.
81
+ </p>
82
+ </section>`;
83
+ }
84
+
85
+
86
+ /**
87
+ * The rail with nothing selected: the report itself.
88
+ * @param {object} layout
89
+ * @returns {string} markup
90
+ */
91
+ export function drawReportPanel(layout) {
92
+ return `
93
+ <div class="dz-panel-head">
94
+ <span class="dz-panel-type">report</span>
95
+ <span class="dz-panel-id">${esc(layout.name ?? 'Untitled')}</span>
96
+ </div>
97
+ ${sections(layout, reportFields(layout))}
98
+ ${bands(layout)}`;
99
+ }
100
+
101
+
102
+ function sections(target, list) {
103
+ return list.map(section => `
104
+ <section class="dz-section">
105
+ <h3>${esc(section.title)}</h3>
106
+ ${section.fields.map(field => control(target, field)).join('')}
107
+ </section>`).join('');
108
+ }
109
+
110
+
111
+ function control(target, field, extra = '') {
112
+ const value = readField(target, field);
113
+ const id = `dz-f-${field.key.replace(/\./g, '-')}${extra ? `-${extra}` : ''}`;
114
+ const bind = extra
115
+ ? `data-field="${esc(field.key)}" data-column="${esc(extra)}"`
116
+ : `data-field="${esc(field.key)}"`;
117
+
118
+ /**
119
+ * The value box gets a button that writes the braces for you. Typing them
120
+ * by hand is the one part of this format nobody should have to do twice -
121
+ * and a placeholder is only a placeholder if both braces are there.
122
+ */
123
+ const label = field.type === 'textarea'
124
+ ? `<span class="dz-field-top">
125
+ <label for="${id}">${esc(field.label)}</label>
126
+ <button type="button" class="dz-brace" data-action="insert-brace"
127
+ data-for="${esc(field.key)}"
128
+ title="Wrap the selected text in braces, or insert a pair"
129
+ aria-label="Insert a placeholder">{&nbsp;}</button>
130
+ </span>`
131
+ : `<label for="${id}">${esc(field.label)}</label>`;
132
+
133
+ return `
134
+ <div class="dz-field dz-field-${field.type}">
135
+ ${label}
136
+ ${input(id, bind, field, value)}
137
+ ${field.hint ? `<p class="dz-hint">${esc(field.hint)}</p>` : ''}
138
+ </div>`;
139
+ }
140
+
141
+
142
+ function input(id, bind, field, value) {
143
+ switch (field.type) {
144
+ case 'textarea':
145
+ /**
146
+ * A textarea cannot style its own contents, so the placeholders are
147
+ * marked on a layer behind it and the box itself is given
148
+ * transparent text and a visible caret. The two are laid out
149
+ * identically - same font, padding and wrapping - so the marks sit
150
+ * exactly under the characters they belong to.
151
+ */
152
+ return `
153
+ <div class="dz-value">
154
+ <div class="dz-value-marks" data-role="marks" aria-hidden="true"
155
+ >${markPlaceholders(value ?? '')}</div>
156
+ <textarea id="${id}" ${bind} rows="2"
157
+ spellcheck="false">${esc(value ?? '')}</textarea>
158
+ </div>`;
159
+
160
+ case 'choice':
161
+ return `<select id="${id}" ${bind}>${field.options.map(o =>
162
+ `<option value="${esc(o.value)}"${o.value === value ? ' selected' : ''}
163
+ >${esc(o.label)}</option>`).join('')}</select>`;
164
+
165
+ case 'color':
166
+ /**
167
+ * A colour input cannot hold null, and several style fields are
168
+ * legitimately absent - so the swatch falls back to black and the
169
+ * value is only written once someone actually picks one.
170
+ */
171
+ return `<input type="color" id="${id}" ${bind}
172
+ value="${esc(value ?? '#000000')}">`;
173
+
174
+ case 'toggle':
175
+ return `<input type="checkbox" id="${id}" ${bind}
176
+ ${value ? 'checked' : ''}>`;
177
+
178
+ case 'text':
179
+ return `<input type="text" id="${id}" ${bind}
180
+ value="${esc(value ?? '')}" spellcheck="false">`;
181
+
182
+ default:
183
+ return `<input type="number" id="${id}" ${bind}
184
+ value="${esc(value ?? '')}"
185
+ ${field.min != null ? `min="${field.min}"` : ''}
186
+ ${field.max != null ? `max="${field.max}"` : ''} step="1">`;
187
+ }
188
+ }
189
+
190
+
191
+ /**
192
+ * A table's columns, one card each. Four controls on one row would be 60px wide
193
+ * apiece in a rail this narrow, so they stack and the card carries the number.
194
+ */
195
+ function columns(table) {
196
+ const list = table.columns || [];
197
+
198
+ return `
199
+ <section class="dz-section dz-columns">
200
+ <h3>Columns</h3>
201
+ ${list.map((column, index) => `
202
+ <div class="dz-column">
203
+ <div class="dz-column-head">
204
+ <span>${index + 1}</span>
205
+ ${list.length > 1 ? `
206
+ <button type="button" class="dz-icon"
207
+ data-action="remove-column" data-index="${index}"
208
+ title="Remove this column"
209
+ aria-label="Remove column ${index + 1}">&times;</button>` : ''}
210
+ </div>
211
+ ${COLUMN_FIELDS.map(field =>
212
+ control(column, field, String(index))).join('')}
213
+ </div>`).join('')}
214
+ <button type="button" class="dz-add-row" data-action="add-column">
215
+ Add column</button>
216
+ </section>`;
217
+ }
218
+
219
+
220
+ /**
221
+ * Which bands the report has.
222
+ *
223
+ * A checkbox each, in page order, rather than a list that can be reordered -
224
+ * validate.js allows one band of each type and regions.js decides where each
225
+ * sits, so there is no order here for anyone to choose.
226
+ */
227
+ function bands(layout) {
228
+ return `
229
+ <section class="dz-section dz-bands">
230
+ <h3>Bands</h3>
231
+ ${BAND_TYPES.map(type => {
232
+ const band = findBand(layout, type);
233
+ const on = hasBand(layout, type);
234
+
235
+ return `
236
+ <div class="dz-band-row${on ? ' is-on' : ''}">
237
+ <label class="dz-band-name">
238
+ <input type="checkbox" data-band="${esc(type)}" ${on ? 'checked' : ''}>
239
+ <span>${esc(type)}</span>
240
+ </label>
241
+ ${on && type !== 'detail'
242
+ ? `<input type="text" class="dz-band-height"
243
+ data-band-height="${esc(type)}"
244
+ value="${esc(band.height ?? '')}"
245
+ placeholder="auto" spellcheck="false"
246
+ aria-label="${esc(type)} height">`
247
+ : `<span class="dz-band-height-none">${
248
+ type === 'detail' ? 'what is left' : ''}</span>`}
249
+ <p class="dz-hint">${esc(BAND_NOTES[type] ?? '')}</p>
250
+ </div>`;
251
+ }).join('')}
252
+ </section>`;
253
+ }
254
+
255
+
256
+ /**
257
+ * Wires one delegated listener set onto the rail. The rail element survives a
258
+ * redraw of its contents, so these are attached once and never rebound.
259
+ *
260
+ * @param {object} options
261
+ * @param {Element} options.panel
262
+ * @param {() => {target: object, fields: object[]}|null} options.getTarget what the
263
+ * plain fields are bound to - the selected item, or the layout
264
+ * @param {() => object|null} options.getItem the selected item, for column edits
265
+ * @param {(key: string, options?: {rebuild?: boolean}) => void} options.changed
266
+ * called when an edit lands, with a key naming the control - consecutive edits
267
+ * from the same one are one step. `rebuild` says the rail's controls have to
268
+ * be built again, because which ones there are has changed
269
+ * @param {(action: string, data: DOMStringMap) => void} options.act a button was pressed
270
+ * @param {(type: string, on: boolean) => void} options.toggleBand
271
+ * @param {(type: string, height: string) => void} options.setBandHeight
272
+ * @returns {() => void} detaches
273
+ */
274
+ export function attachPanel({
275
+ panel, getTarget, getItem, changed, act, toggleBand, setBandHeight
276
+ }) {
277
+ /** keeps the marking layer under the text it belongs to */
278
+ function repaint(node) {
279
+ const box = node.closest?.('.dz-value');
280
+ const marks = box?.querySelector('[data-role="marks"]');
281
+
282
+ if (marks) marks.innerHTML = markPlaceholders(node.value);
283
+ }
284
+
285
+
286
+ function onInput(event) {
287
+ const node = event.target.closest?.('[data-field], [data-band], [data-band-height]');
288
+ if (!node) return;
289
+
290
+ if (node.tagName === 'TEXTAREA') repaint(node);
291
+
292
+ if (node.dataset.band != null) {
293
+ toggleBand(node.dataset.band, node.checked);
294
+ return;
295
+ }
296
+
297
+ if (node.dataset.bandHeight != null) {
298
+ setBandHeight(node.dataset.bandHeight, node.value);
299
+ return;
300
+ }
301
+
302
+ /** a column control is bound to the column, not to the item */
303
+ if (node.dataset.column != null) {
304
+ const item = getItem();
305
+ const column = item?.columns?.[Number(node.dataset.column)];
306
+ if (!column) return;
307
+
308
+ const field = COLUMN_FIELDS.find(f => f.key === node.dataset.field);
309
+ if (field && writeField(column, field, node.value)) {
310
+ changed(`column:${node.dataset.column}:${field.key}`);
311
+ }
312
+ return;
313
+ }
314
+
315
+ const bound = getTarget();
316
+ if (!bound) return;
317
+
318
+ const field = bound.fields.find(f => f.key === node.dataset.field);
319
+ if (!field) return;
320
+
321
+ const raw = field.type === 'toggle' ? node.checked : node.value;
322
+
323
+ if (writeField(bound.target, field, raw)) {
324
+ /**
325
+ * Some fields change which fields there are - choosing a named
326
+ * sheet takes the width and height boxes away, and Custom brings
327
+ * them back. The caller is told, because it owns the rail.
328
+ */
329
+ changed(`field:${field.key}`, { rebuild: Boolean(field.rebuilds) });
330
+ }
331
+ }
332
+
333
+ function onClick(event) {
334
+ const node = event.target.closest?.('[data-action]');
335
+ if (!node) return;
336
+
337
+ event.preventDefault();
338
+
339
+ /**
340
+ * Handled here rather than passed out: it needs the caret, which is a
341
+ * fact about this textarea and about nothing else in the designer.
342
+ */
343
+ if (node.dataset.action === 'insert-brace') {
344
+ const box = node.closest('.dz-field')?.querySelector('textarea');
345
+ if (box) insertBraces(box);
346
+ return;
347
+ }
348
+
349
+ act(node.dataset.action, node.dataset);
350
+ }
351
+
352
+ /**
353
+ * A long value scrolls inside the box, and the layer behind it must scroll
354
+ * by the same amount or the marks part company with the characters.
355
+ */
356
+ function onScroll(event) {
357
+ const node = event.target;
358
+ if (node.tagName !== 'TEXTAREA') return;
359
+
360
+ const marks = node.closest('.dz-value')?.querySelector('[data-role="marks"]');
361
+ if (marks) marks.scrollTop = node.scrollTop;
362
+ }
363
+
364
+ panel.addEventListener('scroll', onScroll, true);
365
+ panel.addEventListener('input', onInput);
366
+ /** a <select> and a colour picker report on change, not input */
367
+ panel.addEventListener('change', onInput);
368
+ panel.addEventListener('click', onClick);
369
+
370
+ return function detach() {
371
+ panel.removeEventListener('scroll', onScroll, true);
372
+ panel.removeEventListener('input', onInput);
373
+ panel.removeEventListener('change', onInput);
374
+ panel.removeEventListener('click', onClick);
375
+ };
376
+ }
377
+
378
+
379
+ /**
380
+ * Refreshes the controls from their object without rebuilding them - for values
381
+ * changed somewhere else, such as x and y after a drag.
382
+ *
383
+ * The focused control is skipped: writing to an input while it has the caret
384
+ * moves the caret to the end, so a drag that happened to run while a field was
385
+ * focused would reorder the digits in it.
386
+ *
387
+ * @param {Element} panel
388
+ * @param {object|null} item the selected item, or null for the report rail
389
+ * @param {object} layout
390
+ */
391
+ export function syncPanel(panel, item, layout) {
392
+ const target = item ?? layout;
393
+ if (!target) return;
394
+
395
+ const fields = item ? allFields(item) : allReportFields(layout);
396
+
397
+ for (const node of panel.querySelectorAll('[data-field]')) {
398
+ /** the panel's own document: a designer in its own window has another */
399
+ if (node === node.ownerDocument.activeElement) continue;
400
+
401
+ const isColumn = node.dataset.column != null;
402
+ const source = isColumn
403
+ ? item?.columns?.[Number(node.dataset.column)]
404
+ : target;
405
+
406
+ if (!source) continue;
407
+
408
+ const list = isColumn ? COLUMN_FIELDS : fields;
409
+ const field = list.find(f => f.key === node.dataset.field);
410
+ if (!field) continue;
411
+
412
+ const value = readField(source, field);
413
+
414
+ if (field.type === 'toggle') {
415
+ node.checked = Boolean(value);
416
+ } else if (value != null) {
417
+ node.value = String(value);
418
+
419
+ if (node.tagName === 'TEXTAREA') {
420
+ const marks = node.closest('.dz-value')
421
+ ?.querySelector('[data-role="marks"]');
422
+
423
+ if (marks) marks.innerHTML = markPlaceholders(node.value);
424
+ }
425
+ }
426
+ }
427
+ }
428
+
429
+
430
+ /**
431
+ * The value, with every `{placeholder}` wrapped so it can be coloured.
432
+ *
433
+ * Escaped first and marked second: `esc` leaves braces alone, so the pattern
434
+ * still matches, and nothing the user typed can become markup on the way.
435
+ *
436
+ * @param {string} text
437
+ * @returns {string} markup for the layer behind the textarea
438
+ */
439
+ export function markPlaceholders(text) {
440
+ const safe = esc(String(text ?? ''));
441
+
442
+ const marked = safe.replace(/\{[^{}]*\}/g,
443
+ match => `<mark class="dz-mark">${match}</mark>`);
444
+
445
+ /**
446
+ * A textarea keeps a line for a trailing newline and a div does not, so
447
+ * without this the layer comes up short and the marks drift off the text.
448
+ */
449
+ return `${marked}\n`;
450
+ }
451
+
452
+
453
+ /**
454
+ * Wraps the selection in braces, or inserts an empty pair.
455
+ *
456
+ * With text selected it becomes `{that text}` - which is how someone turns a
457
+ * word they have already typed into a field without retyping it. With nothing
458
+ * selected the caret lands between the braces, ready for the field name.
459
+ *
460
+ * @param {HTMLTextAreaElement} field
461
+ */
462
+ export function insertBraces(field) {
463
+ const start = field.selectionStart ?? field.value.length;
464
+ const end = field.selectionEnd ?? start;
465
+
466
+ const inner = field.value.slice(start, end);
467
+ const before = field.value.slice(0, start);
468
+ const after = field.value.slice(end);
469
+
470
+ field.value = `${before}{${inner}}${after}`;
471
+
472
+ const caret = start + 1 + inner.length;
473
+ field.focus();
474
+ field.setSelectionRange(caret, caret);
475
+
476
+ /** through the ordinary write path, so the layout and the layer both follow */
477
+ field.dispatchEvent(new Event('input', { bubbles: true }));
478
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * preview.js runs the report the designer is holding and draws the result.
3
+ *
4
+ * This is the moment the whole seam pays off (spec 2.2): the canvas has been
5
+ * drawing bands with items.js all along, and the preview draws pages with
6
+ * render.js, which draws its bands with items.js. So switching between them is
7
+ * a different *wrapper* around the same drawing - the design cannot look one
8
+ * way here and another way on paper, because there is only one way.
9
+ *
10
+ * What it adds over the canvas is everything the canvas cannot know: how many
11
+ * pages there are, where the breaks fall, what the aggregates come to, and
12
+ * whether a band that fitted at design time still fits once real rows arrive.
13
+ *
14
+ * It is a check, not the preview screen. Zoom, search, print and CSV live there
15
+ * (src/preview/), and the designer links to it rather than growing a second
16
+ * copy of a toolbar that already exists.
17
+ */
18
+
19
+ import { buildPages } from '../engine/index.js';
20
+ import { render } from '../render/render.js';
21
+ import { ReportError } from '../engine/validate.js';
22
+ import { esc } from '../render/items.js';
23
+
24
+
25
+ /**
26
+ * A ceiling, because real data has no reason to be small.
27
+ *
28
+ * Pagination itself is cheap and runs in full - the page *count* is one of the
29
+ * things worth previewing - but mounting five thousand pages of DOM to glance
30
+ * at a header is not. Spec 9 asks the real preview screen to mount only what is
31
+ * near the viewport; here the honest thing is to draw a bounded number and say
32
+ * so, rather than draw fewer and let it look like the report ends early.
33
+ */
34
+ export const PAGE_LIMIT = 12;
35
+
36
+
37
+ /**
38
+ * @param {object} layout
39
+ * @param {object} data
40
+ * @param {object} [options]
41
+ * @param {number} [options.limit]
42
+ * @returns {{markup: string, pageCount: number, error: string|null}}
43
+ */
44
+ export function drawPreview(layout, data, { limit = PAGE_LIMIT } = {}) {
45
+ let paginated;
46
+
47
+ try {
48
+ paginated = buildPages(layout, data ?? {});
49
+ } catch (error) {
50
+ return {
51
+ markup: problem(error),
52
+ pageCount: 0,
53
+ error: error?.message ?? String(error)
54
+ };
55
+ }
56
+
57
+ const pageCount = paginated.pages.length;
58
+ const shown = pageCount > limit
59
+ ? { ...paginated, pages: paginated.pages.slice(0, limit) }
60
+ : paginated;
61
+
62
+ return {
63
+ markup: `
64
+ ${render(shown)}
65
+ ${pageCount > limit ? truncated(pageCount, limit) : ''}`,
66
+ pageCount,
67
+ error: null
68
+ };
69
+ }
70
+
71
+
72
+ /**
73
+ * A layout the engine refuses is reported in its own words. ReportError already
74
+ * names the band and the field (spec 9.1), so there is nothing to translate.
75
+ */
76
+ function problem(error) {
77
+ const issues = error instanceof ReportError && error.issues?.length
78
+ ? error.issues
79
+ : [error?.message ?? String(error)];
80
+
81
+ return `
82
+ <div class="dz-problems" role="alert">
83
+ <h2>This report will not run yet</h2>
84
+ <ul>${issues.map(i => `<li>${esc(i)}</li>`).join('')}</ul>
85
+ </div>`;
86
+ }
87
+
88
+
89
+ function truncated(pageCount, limit) {
90
+ return `
91
+ <p class="dz-truncated">
92
+ Showing the first ${limit} of ${esc(pageCount)} pages.
93
+ Open the preview screen to read them all.
94
+ </p>`;
95
+ }