report-studio 1.2.3 → 1.3.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/README.md +254 -3
- package/dist/designer-Dj330bWd.js +4690 -0
- package/dist/designer.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react-designer.js +1 -1
- package/dist/react.js +1 -1
- package/dist/viewer-BewnkhfP.js +4028 -0
- package/package.json +2 -2
- package/src/designer/blank.js +0 -1
- package/src/designer/canvas.js +172 -54
- package/src/designer/designer.js +313 -12
- package/src/designer/dialog.js +609 -5
- package/src/designer/fields.js +128 -11
- package/src/designer/geometry.js +77 -4
- package/src/designer/grouping.js +556 -0
- package/src/designer/icons.js +9 -0
- package/src/designer/menu.js +50 -6
- package/src/designer/panel.js +478 -38
- package/src/designer/rulers.js +14 -6
- package/src/designer/sample-data.js +112 -31
- package/src/designer/select.js +3 -2
- package/src/designer/structure.js +126 -12
- package/src/designer/styles.css +661 -27
- package/src/designer/tokens.js +38 -11
- package/src/engine/calculate.js +487 -0
- package/src/engine/csv.js +17 -9
- package/src/engine/format.js +483 -0
- package/src/engine/group.js +350 -70
- package/src/engine/highlight.js +224 -0
- package/src/engine/index.js +8 -1
- package/src/engine/measure.js +53 -26
- package/src/engine/paginate.js +189 -92
- package/src/engine/resolve.js +117 -10
- package/src/engine/rows.js +71 -8
- package/src/engine/search.js +12 -4
- package/src/engine/tables.js +309 -11
- package/src/engine/validate.js +265 -8
- package/src/engine/xlsx-style.js +50 -4
- package/src/engine/xlsx.js +91 -21
- package/src/index.js +18 -0
- package/src/render/items.js +61 -10
- package/src/render/report.css +0 -5
- package/types/index.d.ts +96 -8
- package/types/layout.d.ts +156 -2
- package/dist/designer-DQlfKnTr.js +0 -3416
- package/dist/viewer-BSPNCNRU.js +0 -2912
|
@@ -1,3416 +0,0 @@
|
|
|
1
|
-
import { A as e, B as t, E as n, M as r, N as i, O as a, P as o, T as s, V as c, _ as l, a as u, c as d, g as f, h as p, k as m, l as h, n as g, o as _, r as ee, s as te, t as ne, u as v } from "./viewer-BSPNCNRU.js";
|
|
2
|
-
//#region src/designer/fields.js
|
|
3
|
-
var y = [
|
|
4
|
-
{
|
|
5
|
-
label: "Helvetica",
|
|
6
|
-
value: "Helvetica, Arial, sans-serif"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
label: "Arial",
|
|
10
|
-
value: "Arial, Helvetica, sans-serif"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
label: "Verdana",
|
|
14
|
-
value: "Verdana, Geneva, sans-serif"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: "Trebuchet",
|
|
18
|
-
value: "\"Trebuchet MS\", Helvetica, sans-serif"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: "Georgia",
|
|
22
|
-
value: "Georgia, \"Times New Roman\", serif"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: "Times",
|
|
26
|
-
value: "\"Times New Roman\", Times, serif"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: "Courier",
|
|
30
|
-
value: "\"Courier New\", Courier, monospace"
|
|
31
|
-
}
|
|
32
|
-
], re = [{
|
|
33
|
-
label: "Regular",
|
|
34
|
-
value: "normal"
|
|
35
|
-
}, {
|
|
36
|
-
label: "Bold",
|
|
37
|
-
value: "bold"
|
|
38
|
-
}], ie = [{
|
|
39
|
-
label: "Upright",
|
|
40
|
-
value: "normal"
|
|
41
|
-
}, {
|
|
42
|
-
label: "Italic",
|
|
43
|
-
value: "italic"
|
|
44
|
-
}], b = [
|
|
45
|
-
{
|
|
46
|
-
label: "Left",
|
|
47
|
-
value: "left"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
label: "Centre",
|
|
51
|
-
value: "center"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
label: "Right",
|
|
55
|
-
value: "right"
|
|
56
|
-
}
|
|
57
|
-
], x = [
|
|
58
|
-
{
|
|
59
|
-
label: "Fit inside",
|
|
60
|
-
value: "contain"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
label: "Fill and crop",
|
|
64
|
-
value: "cover"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
label: "Stretch",
|
|
68
|
-
value: "fill"
|
|
69
|
-
}
|
|
70
|
-
], S = [{
|
|
71
|
-
label: "Horizontal",
|
|
72
|
-
value: "horizontal"
|
|
73
|
-
}, {
|
|
74
|
-
label: "Vertical",
|
|
75
|
-
value: "vertical"
|
|
76
|
-
}], C = [
|
|
77
|
-
{
|
|
78
|
-
label: "Solid",
|
|
79
|
-
value: "solid"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
label: "Dashed",
|
|
83
|
-
value: "dashed"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
label: "Dotted",
|
|
87
|
-
value: "dotted"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
label: "Double",
|
|
91
|
-
value: "double"
|
|
92
|
-
}
|
|
93
|
-
], w = [...C, {
|
|
94
|
-
label: "None",
|
|
95
|
-
value: "none"
|
|
96
|
-
}], T = (e, t, n = {}) => ({
|
|
97
|
-
key: e,
|
|
98
|
-
label: t,
|
|
99
|
-
type: "number",
|
|
100
|
-
...n
|
|
101
|
-
});
|
|
102
|
-
function E(e) {
|
|
103
|
-
let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
|
|
104
|
-
return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
|
|
105
|
-
}
|
|
106
|
-
var D = [
|
|
107
|
-
{
|
|
108
|
-
key: "field",
|
|
109
|
-
label: "Field",
|
|
110
|
-
type: "text"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
key: "label",
|
|
114
|
-
label: "Label",
|
|
115
|
-
type: "text"
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
key: "width",
|
|
119
|
-
label: "Width",
|
|
120
|
-
type: "number",
|
|
121
|
-
min: 1
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
key: "align",
|
|
125
|
-
label: "Align",
|
|
126
|
-
type: "choice",
|
|
127
|
-
options: b
|
|
128
|
-
}
|
|
129
|
-
];
|
|
130
|
-
function ae(e) {
|
|
131
|
-
if (!e) return [];
|
|
132
|
-
let t = {
|
|
133
|
-
title: "Position and size",
|
|
134
|
-
fields: [
|
|
135
|
-
T("x", "X"),
|
|
136
|
-
T("y", "Y"),
|
|
137
|
-
T("w", "Width", { min: 1 }),
|
|
138
|
-
...e.type === "table" ? [] : [T("h", "Height", { min: 1 })]
|
|
139
|
-
]
|
|
140
|
-
};
|
|
141
|
-
return e.type === "box" ? [
|
|
142
|
-
t,
|
|
143
|
-
{
|
|
144
|
-
title: "Border",
|
|
145
|
-
fields: [
|
|
146
|
-
{
|
|
147
|
-
key: "style.borderStyle",
|
|
148
|
-
label: "Style",
|
|
149
|
-
type: "choice",
|
|
150
|
-
options: w
|
|
151
|
-
},
|
|
152
|
-
T("style.borderWidth", "Width", { min: 1 }),
|
|
153
|
-
{
|
|
154
|
-
key: "style.borderColor",
|
|
155
|
-
label: "Colour",
|
|
156
|
-
type: "color"
|
|
157
|
-
},
|
|
158
|
-
T("style.radius", "Corner", { min: 0 })
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
title: "Fill",
|
|
163
|
-
fields: [{
|
|
164
|
-
key: "style.background",
|
|
165
|
-
label: "Background",
|
|
166
|
-
type: "color",
|
|
167
|
-
hint: "Leave a box unfilled to frame what is behind it"
|
|
168
|
-
}]
|
|
169
|
-
}
|
|
170
|
-
] : e.type === "image" ? [{
|
|
171
|
-
title: "Picture",
|
|
172
|
-
fields: [
|
|
173
|
-
{
|
|
174
|
-
key: "src",
|
|
175
|
-
label: "Image",
|
|
176
|
-
type: "image",
|
|
177
|
-
hint: "Stored in the layout file. Keep it small - a logo, not a photograph"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
key: "field",
|
|
181
|
-
label: "From data",
|
|
182
|
-
type: "text",
|
|
183
|
-
nullable: !0,
|
|
184
|
-
hint: "A data path such as company.logo, whose value is the picture's URL. It replaces the stored image when present"
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
key: "fit",
|
|
188
|
-
label: "Fit",
|
|
189
|
-
type: "choice",
|
|
190
|
-
options: x
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
key: "alt",
|
|
194
|
-
label: "Description",
|
|
195
|
-
type: "text",
|
|
196
|
-
hint: "Read out by a screen reader in place of the picture"
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
}, t] : e.type === "line" ? [t, {
|
|
200
|
-
title: "Line",
|
|
201
|
-
fields: [
|
|
202
|
-
{
|
|
203
|
-
key: "orientation",
|
|
204
|
-
label: "Runs",
|
|
205
|
-
type: "choice",
|
|
206
|
-
options: S
|
|
207
|
-
},
|
|
208
|
-
T("style.thickness", "Thickness", { min: 1 }),
|
|
209
|
-
{
|
|
210
|
-
key: "style.lineStyle",
|
|
211
|
-
label: "Style",
|
|
212
|
-
type: "choice",
|
|
213
|
-
options: C
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
key: "style.color",
|
|
217
|
-
label: "Colour",
|
|
218
|
-
type: "color"
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
}] : e.type === "table" ? [
|
|
222
|
-
t,
|
|
223
|
-
{
|
|
224
|
-
title: "Data",
|
|
225
|
-
fields: [{
|
|
226
|
-
key: "dataset",
|
|
227
|
-
label: "Dataset",
|
|
228
|
-
type: "text",
|
|
229
|
-
nullable: !0,
|
|
230
|
-
hint: "The key in the data object whose rows this table draws. Blank reads the report's dataset"
|
|
231
|
-
}, {
|
|
232
|
-
key: "groupBy",
|
|
233
|
-
label: "Group by",
|
|
234
|
-
type: "text",
|
|
235
|
-
nullable: !0,
|
|
236
|
-
hint: "A field to group these rows by, or blank. One table in a report can be grouped"
|
|
237
|
-
}]
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
title: "Rows",
|
|
241
|
-
fields: [T("rowHeight", "Row height", { min: 1 })]
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
title: "Header",
|
|
245
|
-
fields: [
|
|
246
|
-
{
|
|
247
|
-
key: "showHeader",
|
|
248
|
-
label: "Show header",
|
|
249
|
-
type: "toggle"
|
|
250
|
-
},
|
|
251
|
-
T("headerHeight", "Height", { min: 1 }),
|
|
252
|
-
{
|
|
253
|
-
key: "style.headerBackground",
|
|
254
|
-
label: "Fill",
|
|
255
|
-
type: "color"
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
key: "style.headerColor",
|
|
259
|
-
label: "Text",
|
|
260
|
-
type: "color",
|
|
261
|
-
hint: "Leave these alone to keep the stylesheet's own header"
|
|
262
|
-
}
|
|
263
|
-
]
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
title: "Appearance",
|
|
267
|
-
fields: [
|
|
268
|
-
{
|
|
269
|
-
key: "style.fontFamily",
|
|
270
|
-
label: "Font",
|
|
271
|
-
type: "choice",
|
|
272
|
-
options: y
|
|
273
|
-
},
|
|
274
|
-
T("style.fontSize", "Font size", { min: 1 }),
|
|
275
|
-
{
|
|
276
|
-
key: "style.color",
|
|
277
|
-
label: "Text",
|
|
278
|
-
type: "color"
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
key: "wrap",
|
|
282
|
-
label: "Wrap cells",
|
|
283
|
-
type: "toggle",
|
|
284
|
-
hint: "A cell wider than its column runs onto another line and the row grows; turn this off to keep every row one line, cut off with an ellipsis"
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
key: "style.borderStyle",
|
|
288
|
-
label: "Borders",
|
|
289
|
-
type: "choice",
|
|
290
|
-
options: w
|
|
291
|
-
},
|
|
292
|
-
T("style.borderWidth", "Border width", {
|
|
293
|
-
min: 1,
|
|
294
|
-
max: E(e)
|
|
295
|
-
}),
|
|
296
|
-
{
|
|
297
|
-
key: "style.borderColor",
|
|
298
|
-
label: "Border colour",
|
|
299
|
-
type: "color"
|
|
300
|
-
}
|
|
301
|
-
]
|
|
302
|
-
}
|
|
303
|
-
] : [
|
|
304
|
-
{
|
|
305
|
-
title: "Content",
|
|
306
|
-
fields: [{
|
|
307
|
-
key: "value",
|
|
308
|
-
label: "Value",
|
|
309
|
-
type: "textarea",
|
|
310
|
-
hint: "Placeholders in braces: {customer.name}, {page}, {sum(amount)}"
|
|
311
|
-
}]
|
|
312
|
-
},
|
|
313
|
-
t,
|
|
314
|
-
{
|
|
315
|
-
title: "Type",
|
|
316
|
-
fields: [
|
|
317
|
-
{
|
|
318
|
-
key: "style.fontFamily",
|
|
319
|
-
label: "Font",
|
|
320
|
-
type: "choice",
|
|
321
|
-
options: y
|
|
322
|
-
},
|
|
323
|
-
T("style.fontSize", "Size", { min: 1 }),
|
|
324
|
-
{
|
|
325
|
-
key: "style.fontWeight",
|
|
326
|
-
label: "Weight",
|
|
327
|
-
type: "choice",
|
|
328
|
-
options: re
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
key: "style.fontStyle",
|
|
332
|
-
label: "Style",
|
|
333
|
-
type: "choice",
|
|
334
|
-
options: ie
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
key: "style.align",
|
|
338
|
-
label: "Align",
|
|
339
|
-
type: "choice",
|
|
340
|
-
options: b
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
key: "style.color",
|
|
344
|
-
label: "Colour",
|
|
345
|
-
type: "color"
|
|
346
|
-
}
|
|
347
|
-
]
|
|
348
|
-
}
|
|
349
|
-
];
|
|
350
|
-
}
|
|
351
|
-
var O = [
|
|
352
|
-
{
|
|
353
|
-
label: "A2",
|
|
354
|
-
width: 1587,
|
|
355
|
-
height: 2245
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
label: "A3",
|
|
359
|
-
width: 1123,
|
|
360
|
-
height: 1587
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
label: "A4",
|
|
364
|
-
width: 794,
|
|
365
|
-
height: 1123
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
label: "A5",
|
|
369
|
-
width: 559,
|
|
370
|
-
height: 794
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
label: "A6",
|
|
374
|
-
width: 397,
|
|
375
|
-
height: 559
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
label: "Letter",
|
|
379
|
-
width: 816,
|
|
380
|
-
height: 1056
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
label: "Legal",
|
|
384
|
-
width: 816,
|
|
385
|
-
height: 1344
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
label: "Tabloid",
|
|
389
|
-
width: 1056,
|
|
390
|
-
height: 1632
|
|
391
|
-
}
|
|
392
|
-
], k = "custom";
|
|
393
|
-
function A(e) {
|
|
394
|
-
if (e?.paper === "custom") return k;
|
|
395
|
-
let t = e?.width, n = e?.height, r = O.find((e) => e.width === t && e.height === n || e.height === t && e.width === n);
|
|
396
|
-
return r ? r.label : k;
|
|
397
|
-
}
|
|
398
|
-
function j(e) {
|
|
399
|
-
return (e?.width ?? 0) > (e?.height ?? 0) ? "landscape" : "portrait";
|
|
400
|
-
}
|
|
401
|
-
function oe(e, t) {
|
|
402
|
-
let n = O.find((e) => e.label === t);
|
|
403
|
-
if (!n) return e.page.paper === "custom" ? !1 : (e.page.paper = k, !0);
|
|
404
|
-
let r = j(e.page) === "landscape", i = r ? n.height : n.width, a = r ? n.width : n.height, o = e.page.paper === k;
|
|
405
|
-
return delete e.page.paper, e.page.width === i && e.page.height === a ? o : (e.page.width = i, e.page.height = a, !0);
|
|
406
|
-
}
|
|
407
|
-
function se(e, t) {
|
|
408
|
-
if (t === "landscape" == (j(e.page) === "landscape")) return !1;
|
|
409
|
-
let { width: n, height: r } = e.page;
|
|
410
|
-
return e.page.width = r, e.page.height = n, !0;
|
|
411
|
-
}
|
|
412
|
-
function M(e) {
|
|
413
|
-
let t = A(e.page) === k, n = {
|
|
414
|
-
key: "paper",
|
|
415
|
-
label: "Paper",
|
|
416
|
-
type: "choice",
|
|
417
|
-
rebuilds: !0,
|
|
418
|
-
options: [...O.map((e) => ({
|
|
419
|
-
value: e.label,
|
|
420
|
-
label: `${e.label} ${e.width} x ${e.height}`
|
|
421
|
-
})), {
|
|
422
|
-
value: k,
|
|
423
|
-
label: "Custom"
|
|
424
|
-
}],
|
|
425
|
-
read: (e) => A(e.page),
|
|
426
|
-
write: (e, t) => oe(e, t)
|
|
427
|
-
};
|
|
428
|
-
return t ? [
|
|
429
|
-
n,
|
|
430
|
-
T("page.width", "Width", { min: 1 }),
|
|
431
|
-
T("page.height", "Height", { min: 1 })
|
|
432
|
-
] : [n, {
|
|
433
|
-
key: "orientation",
|
|
434
|
-
label: "Orientation",
|
|
435
|
-
type: "choice",
|
|
436
|
-
rebuilds: !0,
|
|
437
|
-
options: [{
|
|
438
|
-
value: "portrait",
|
|
439
|
-
label: "Portrait"
|
|
440
|
-
}, {
|
|
441
|
-
value: "landscape",
|
|
442
|
-
label: "Landscape"
|
|
443
|
-
}],
|
|
444
|
-
read: (e) => j(e.page),
|
|
445
|
-
write: (e, t) => se(e, t)
|
|
446
|
-
}];
|
|
447
|
-
}
|
|
448
|
-
function N(e) {
|
|
449
|
-
return e ? [
|
|
450
|
-
{
|
|
451
|
-
title: "Report",
|
|
452
|
-
fields: [
|
|
453
|
-
{
|
|
454
|
-
key: "name",
|
|
455
|
-
label: "Name",
|
|
456
|
-
type: "text"
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
key: "dataset",
|
|
460
|
-
label: "Dataset",
|
|
461
|
-
type: "text",
|
|
462
|
-
nullable: !0,
|
|
463
|
-
hint: "The key in the data object that drives the rows, for every table that does not name its own"
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
key: "groupBy",
|
|
467
|
-
label: "Group by",
|
|
468
|
-
type: "text",
|
|
469
|
-
nullable: !0,
|
|
470
|
-
hint: "A field name, or blank for no grouping. Groups the first table, unless a table sets its own"
|
|
471
|
-
}
|
|
472
|
-
]
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
title: "Page",
|
|
476
|
-
fields: M(e)
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
title: "Margins",
|
|
480
|
-
fields: [
|
|
481
|
-
T("page.margin.top", "Top", { min: 0 }),
|
|
482
|
-
T("page.margin.right", "Right", { min: 0 }),
|
|
483
|
-
T("page.margin.bottom", "Bottom", { min: 0 }),
|
|
484
|
-
T("page.margin.left", "Left", { min: 0 })
|
|
485
|
-
]
|
|
486
|
-
}
|
|
487
|
-
] : [];
|
|
488
|
-
}
|
|
489
|
-
function ce(e) {
|
|
490
|
-
return N(e).flatMap((e) => e.fields);
|
|
491
|
-
}
|
|
492
|
-
function le(e) {
|
|
493
|
-
return ae(e).flatMap((e) => e.fields);
|
|
494
|
-
}
|
|
495
|
-
function P(e) {
|
|
496
|
-
return e.split(".");
|
|
497
|
-
}
|
|
498
|
-
function F(e, t) {
|
|
499
|
-
if (t.read) return t.read(e);
|
|
500
|
-
let n = e;
|
|
501
|
-
for (let e of P(t.key)) {
|
|
502
|
-
if (n == null) return;
|
|
503
|
-
n = n[e];
|
|
504
|
-
}
|
|
505
|
-
return n;
|
|
506
|
-
}
|
|
507
|
-
function ue(e, t, n) {
|
|
508
|
-
let r = de(t, n);
|
|
509
|
-
if (r === void 0) return !1;
|
|
510
|
-
if (t.write) return t.write(e, r);
|
|
511
|
-
let i = P(t.key), a = i.pop(), o = e;
|
|
512
|
-
for (let e of i) (o[e] == null || typeof o[e] != "object") && (o[e] = {}), o = o[e];
|
|
513
|
-
return o[a] === r ? !1 : (o[a] = r, !0);
|
|
514
|
-
}
|
|
515
|
-
function de(e, t) {
|
|
516
|
-
if (e.type === "toggle") return !!t;
|
|
517
|
-
if (e.type === "number") {
|
|
518
|
-
if (t === "" || t == null) return;
|
|
519
|
-
let n = Number(t);
|
|
520
|
-
if (!Number.isFinite(n)) return;
|
|
521
|
-
let r = e.min == null ? n : Math.max(n, e.min);
|
|
522
|
-
return e.max == null ? r : Math.min(r, e.max);
|
|
523
|
-
}
|
|
524
|
-
if (t != null) return e.nullable && t === "" ? null : String(t);
|
|
525
|
-
}
|
|
526
|
-
//#endregion
|
|
527
|
-
//#region src/designer/blank.js
|
|
528
|
-
function fe() {
|
|
529
|
-
return {
|
|
530
|
-
version: 1,
|
|
531
|
-
name: "Untitled report",
|
|
532
|
-
page: {
|
|
533
|
-
width: 794,
|
|
534
|
-
height: 1123,
|
|
535
|
-
margin: {
|
|
536
|
-
top: 40,
|
|
537
|
-
right: 40,
|
|
538
|
-
bottom: 40,
|
|
539
|
-
left: 40
|
|
540
|
-
}
|
|
541
|
-
},
|
|
542
|
-
dataset: null,
|
|
543
|
-
groupBy: null,
|
|
544
|
-
bands: [
|
|
545
|
-
{
|
|
546
|
-
type: "pageHeader",
|
|
547
|
-
height: 60,
|
|
548
|
-
items: []
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
type: "detail",
|
|
552
|
-
items: []
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
type: "pageFooter",
|
|
556
|
-
height: 40,
|
|
557
|
-
items: []
|
|
558
|
-
}
|
|
559
|
-
]
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
function pe(e) {
|
|
563
|
-
return e == null ? !0 : typeof e != "object" || Array.isArray(e) ? !1 : Object.keys(e).length === 0;
|
|
564
|
-
}
|
|
565
|
-
var me = 3, he = [
|
|
566
|
-
"nw",
|
|
567
|
-
"n",
|
|
568
|
-
"ne",
|
|
569
|
-
"e",
|
|
570
|
-
"se",
|
|
571
|
-
"s",
|
|
572
|
-
"sw",
|
|
573
|
-
"w"
|
|
574
|
-
], ge = ["e", "w"];
|
|
575
|
-
function _e(e) {
|
|
576
|
-
return Math.round(e / 10) * 10;
|
|
577
|
-
}
|
|
578
|
-
function I(e) {
|
|
579
|
-
return {
|
|
580
|
-
x: e.x ?? 0,
|
|
581
|
-
y: e.y ?? 0,
|
|
582
|
-
w: e.w ?? 0,
|
|
583
|
-
h: o(e)
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
function L(e) {
|
|
587
|
-
return e.type === "table" ? "x" : "xy";
|
|
588
|
-
}
|
|
589
|
-
function R(e) {
|
|
590
|
-
return e === "x" ? [...ge] : [...he];
|
|
591
|
-
}
|
|
592
|
-
function z(e, t, n) {
|
|
593
|
-
return {
|
|
594
|
-
x: _e(e.x + t),
|
|
595
|
-
y: _e(e.y + n)
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
function ve(e, t, n, r, i = "xy") {
|
|
599
|
-
let { x: a, y: o, w: s, h: c } = t;
|
|
600
|
-
return e.includes("w") ? (s = Math.max(t.w - n, 20), a = t.x + t.w - s) : e.includes("e") && (s = Math.max(t.w + n, 20)), i === "xy" && (e.includes("n") ? (c = Math.max(t.h - r, 12), o = t.y + t.h - c) : e.includes("s") && (c = Math.max(t.h + r, 12))), {
|
|
601
|
-
x: a,
|
|
602
|
-
y: o,
|
|
603
|
-
w: s,
|
|
604
|
-
h: c
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
function ye(e, t) {
|
|
608
|
-
e.x = t.x, e.y = t.y, t.w != null && (e.w = t.w), t.h != null && e.type !== "table" && (e.h = t.h);
|
|
609
|
-
}
|
|
610
|
-
function be(e, { minor: t = 10, major: n = 50 } = {}) {
|
|
611
|
-
let r = [];
|
|
612
|
-
if (!(e > 0) || !(t > 0)) return r;
|
|
613
|
-
for (let i = 0; i <= e; i += t) r.push({
|
|
614
|
-
at: i,
|
|
615
|
-
major: i % n === 0
|
|
616
|
-
});
|
|
617
|
-
let i = r.at(-1);
|
|
618
|
-
return i && i.at !== e && r.push({
|
|
619
|
-
at: e,
|
|
620
|
-
major: !0
|
|
621
|
-
}), r;
|
|
622
|
-
}
|
|
623
|
-
function B(e) {
|
|
624
|
-
let t = e?.guides, n = (e) => (Array.isArray(e) ? e : []).filter(xe).map(Number).filter(Number.isFinite).sort((e, t) => e - t);
|
|
625
|
-
return {
|
|
626
|
-
x: n(t?.x),
|
|
627
|
-
y: n(t?.y)
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
function xe(e) {
|
|
631
|
-
return typeof e == "number" || typeof e == "string" && e.trim() !== "";
|
|
632
|
-
}
|
|
633
|
-
function V(e) {
|
|
634
|
-
(!e.guides || typeof e.guides != "object") && (e.guides = {
|
|
635
|
-
x: [],
|
|
636
|
-
y: []
|
|
637
|
-
});
|
|
638
|
-
for (let t of ["x", "y"]) Array.isArray(e.guides[t]) || (e.guides[t] = []);
|
|
639
|
-
return e.guides;
|
|
640
|
-
}
|
|
641
|
-
function Se(e, t, n) {
|
|
642
|
-
if (!xe(n)) return null;
|
|
643
|
-
let r = Math.round(Number(n));
|
|
644
|
-
if (!Number.isFinite(r)) return null;
|
|
645
|
-
let i = V(e);
|
|
646
|
-
return i[t].includes(r) || (i[t].push(r), i[t].sort((e, t) => e - t)), r;
|
|
647
|
-
}
|
|
648
|
-
function Ce(e, t, n) {
|
|
649
|
-
let r = V(e), i = r[t].indexOf(Math.round(Number(n)));
|
|
650
|
-
return i === -1 ? !1 : (r[t].splice(i, 1), !0);
|
|
651
|
-
}
|
|
652
|
-
function we(e, t, n, r) {
|
|
653
|
-
return Ce(e, t, n), Se(e, t, r);
|
|
654
|
-
}
|
|
655
|
-
function Te(e, t, n, r = 4) {
|
|
656
|
-
let i = null;
|
|
657
|
-
for (let a of B(e)[t]) {
|
|
658
|
-
let e = Math.abs(a - n);
|
|
659
|
-
e <= r && (i === null || e < Math.abs(i - n)) && (i = a);
|
|
660
|
-
}
|
|
661
|
-
return i;
|
|
662
|
-
}
|
|
663
|
-
function Ee(e, t) {
|
|
664
|
-
let n = B(e);
|
|
665
|
-
return t ? {
|
|
666
|
-
x: n.x,
|
|
667
|
-
y: n.y.map((e) => e - (t.originY ?? 0)).filter((e) => e >= 0 && e <= (t.h ?? 0))
|
|
668
|
-
} : {
|
|
669
|
-
x: n.x,
|
|
670
|
-
y: []
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region src/designer/canvas.js
|
|
675
|
-
var De = [
|
|
676
|
-
"pageHeader",
|
|
677
|
-
"reportHeader",
|
|
678
|
-
"reportFooter",
|
|
679
|
-
"pageFooter"
|
|
680
|
-
];
|
|
681
|
-
function Oe(e) {
|
|
682
|
-
return Array.from({ length: me }, () => Object.fromEntries((e || []).map((e) => [e.field, e.field])));
|
|
683
|
-
}
|
|
684
|
-
function H(e) {
|
|
685
|
-
return e.type === "text" ? {
|
|
686
|
-
...e,
|
|
687
|
-
text: e.value
|
|
688
|
-
} : e.type === "table" ? {
|
|
689
|
-
...e,
|
|
690
|
-
row: Oe(e.columns),
|
|
691
|
-
measuredHeight: o(e)
|
|
692
|
-
} : e;
|
|
693
|
-
}
|
|
694
|
-
function U(e) {
|
|
695
|
-
let { page: t } = e, r = t.height - t.margin.top - t.margin.bottom, i = Object.fromEntries((e.bands || []).map((e) => [e.type, e])), a = n({
|
|
696
|
-
bands: i,
|
|
697
|
-
contentHeight: r,
|
|
698
|
-
isFirstPage: !0,
|
|
699
|
-
isLastPage: !0
|
|
700
|
-
}), o = [];
|
|
701
|
-
for (let e of De) {
|
|
702
|
-
let t = a[e];
|
|
703
|
-
t && i[e] && o.push({
|
|
704
|
-
type: e,
|
|
705
|
-
...t,
|
|
706
|
-
band: i[e]
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
let c = a.detail, l = i.groupHeader, u = i.groupFooter, d = l ? s(l, r) : 0, f = u ? s(u, r) : 0;
|
|
710
|
-
return l && o.push({
|
|
711
|
-
type: "groupHeader",
|
|
712
|
-
top: c.top,
|
|
713
|
-
height: d,
|
|
714
|
-
band: l
|
|
715
|
-
}), i.detail && o.push({
|
|
716
|
-
type: "detail",
|
|
717
|
-
top: c.top + d,
|
|
718
|
-
height: Math.max(c.height - d - f, 0),
|
|
719
|
-
band: i.detail
|
|
720
|
-
}), u && o.push({
|
|
721
|
-
type: "groupFooter",
|
|
722
|
-
top: c.top + c.height - f,
|
|
723
|
-
height: f,
|
|
724
|
-
band: u
|
|
725
|
-
}), o;
|
|
726
|
-
}
|
|
727
|
-
function ke(e, t) {
|
|
728
|
-
let n = [...e.band.items || []].sort((e, t) => (e.y ?? 0) - (t.y ?? 0)).map(H);
|
|
729
|
-
return `
|
|
730
|
-
<div class="band dz-zone" data-band-type="${p(e.type)}"
|
|
731
|
-
style="position:absolute;top:${e.top + t.top}px;left:${t.left}px;right:${t.right}px;height:${e.height}px">
|
|
732
|
-
${l(n)}
|
|
733
|
-
</div>`;
|
|
734
|
-
}
|
|
735
|
-
function W(e, t) {
|
|
736
|
-
B(e);
|
|
737
|
-
let n = (e, t) => be(e).map((e) => `
|
|
738
|
-
<span class="dz-tick${e.major ? " is-major" : ""}"
|
|
739
|
-
style="${t === "x" ? "left" : "top"}:${e.at}px"
|
|
740
|
-
>${e.major ? `<i>${e.at}</i>` : ""}</span>`).join(""), r = (t) => `
|
|
741
|
-
<span class="dz-ruler-guides" data-role="ruler-guides"
|
|
742
|
-
data-axis="${t}">${Ae(e, t)}</span>`;
|
|
743
|
-
return `
|
|
744
|
-
<div class="dz-ruler-corner" data-role="ruler-corner"></div>
|
|
745
|
-
|
|
746
|
-
<div class="dz-ruler dz-ruler-x" data-role="ruler" data-axis="x"
|
|
747
|
-
style="width:${t.w}px" aria-hidden="true">
|
|
748
|
-
${n(t.w, "x")}${r("x")}
|
|
749
|
-
</div>
|
|
750
|
-
|
|
751
|
-
<div class="dz-ruler dz-ruler-y" data-role="ruler" data-axis="y"
|
|
752
|
-
style="height:${t.h}px" aria-hidden="true">
|
|
753
|
-
${n(t.h, "y")}${r("y")}
|
|
754
|
-
</div>`;
|
|
755
|
-
}
|
|
756
|
-
function Ae(e, t) {
|
|
757
|
-
return B(e)[t].map((e) => `
|
|
758
|
-
<span class="dz-ruler-guide"
|
|
759
|
-
style="${t === "x" ? "left" : "top"}:${e}px"></span>`).join("");
|
|
760
|
-
}
|
|
761
|
-
function je(e) {
|
|
762
|
-
let t = e.page.margin, n = B(e), r = n.x.map((e) => `
|
|
763
|
-
<span class="dz-rule dz-rule-v" data-role="guide" data-axis="x"
|
|
764
|
-
data-at="${e}" style="left:${e + t.left}px"></span>`), i = n.y.map((e) => `
|
|
765
|
-
<span class="dz-rule dz-rule-h" data-role="guide" data-axis="y"
|
|
766
|
-
data-at="${e}" style="top:${e + t.top}px"></span>`);
|
|
767
|
-
return [...r, ...i].join("");
|
|
768
|
-
}
|
|
769
|
-
function Me(e, t) {
|
|
770
|
-
return `<span class="dz-tag" data-band-tag="${p(e.type)}"
|
|
771
|
-
style="top:${e.top + t.top}px">${p(e.type)}</span>`;
|
|
772
|
-
}
|
|
773
|
-
function Ne(e, t) {
|
|
774
|
-
if (!t) return null;
|
|
775
|
-
let n = e.page.margin, r = U(e).find((e) => e.type === t.band);
|
|
776
|
-
if (!r) return null;
|
|
777
|
-
let i = (r.band.items || []).find((e) => e.id === t.id);
|
|
778
|
-
if (!i) return null;
|
|
779
|
-
let a = I(i);
|
|
780
|
-
return {
|
|
781
|
-
item: i,
|
|
782
|
-
box: {
|
|
783
|
-
...a,
|
|
784
|
-
x: a.x + n.left,
|
|
785
|
-
y: a.y + r.top + n.top
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
function G(e, { withHandles: t = !0, primary: n = !0 } = {}) {
|
|
790
|
-
let { box: r, item: i } = e, a = t ? R(L(i)).map((e) => `<span class="dz-handle dz-handle-${e}" data-handle="${e}"></span>`).join("") : "";
|
|
791
|
-
return `
|
|
792
|
-
<div class="dz-select${n ? "" : " is-secondary"}" data-role="select"
|
|
793
|
-
data-select-id="${p(i.id)}"
|
|
794
|
-
style="top:${r.y}px;left:${r.x}px;width:${r.w}px;height:${r.h}px">
|
|
795
|
-
${a}
|
|
796
|
-
</div>`;
|
|
797
|
-
}
|
|
798
|
-
function Pe(e, t) {
|
|
799
|
-
return (t || []).map((t) => Ne(e, t)).filter(Boolean);
|
|
800
|
-
}
|
|
801
|
-
function Fe(e, t = null, { rulers: n = !1 } = {}) {
|
|
802
|
-
let { page: r } = e, i = r.margin, a = U(e), o = Pe(e, t == null ? [] : [].concat(t)), s = `width:${r.width}px;height:${r.height}px;padding-top:${i.top}px;padding-right:${i.right}px;padding-bottom:${i.bottom}px;padding-left:${i.left}px;`, c = {
|
|
803
|
-
w: r.width - i.left - i.right,
|
|
804
|
-
h: r.height - i.top - i.bottom
|
|
805
|
-
};
|
|
806
|
-
return `
|
|
807
|
-
<div class="dz-sheet${n ? " has-rulers" : ""}"
|
|
808
|
-
style="--page-height:${r.height}px;--dz-margin-left:${i.left}px;
|
|
809
|
-
--dz-margin-top:${i.top}px">
|
|
810
|
-
${n ? W(e, c) : ""}
|
|
811
|
-
<div class="dz-gutter">
|
|
812
|
-
${a.map((e) => Me(e, i)).join("")}
|
|
813
|
-
</div>
|
|
814
|
-
<div class="page dz-page" style="${s}">
|
|
815
|
-
<div class="dz-rules" data-role="rules"
|
|
816
|
-
>${n ? je(e) : ""}</div>
|
|
817
|
-
${a.map((e) => ke(e, i)).join("")}
|
|
818
|
-
${o.map((e, t) => G(e, {
|
|
819
|
-
withHandles: o.length === 1,
|
|
820
|
-
primary: t === o.length - 1
|
|
821
|
-
})).join("")}
|
|
822
|
-
<div class="dz-guides" data-role="guides"></div>
|
|
823
|
-
</div>
|
|
824
|
-
</div>`;
|
|
825
|
-
}
|
|
826
|
-
function Ie(e, t) {
|
|
827
|
-
let n = U(e).find((e) => e.type === t);
|
|
828
|
-
if (!n) return null;
|
|
829
|
-
let r = e.page.margin;
|
|
830
|
-
return {
|
|
831
|
-
left: r.left,
|
|
832
|
-
top: n.top + r.top,
|
|
833
|
-
w: e.page.width - r.left - r.right,
|
|
834
|
-
h: n.height,
|
|
835
|
-
originX: 0,
|
|
836
|
-
originY: n.top
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
function Le(e, t = [], n = []) {
|
|
840
|
-
if (!e) return "";
|
|
841
|
-
let r = (t) => t + e.left, i = (t) => t + e.top, a = t.map((e) => e.axis === "x" ? `<span class="dz-guide dz-guide-v${e.centre ? " is-centre" : ""}"
|
|
842
|
-
style="left:${r(e.at)}px;top:${i(e.from)}px;
|
|
843
|
-
height:${Math.max(e.to - e.from, 0)}px"></span>` : `<span class="dz-guide dz-guide-h${e.centre ? " is-centre" : ""}"
|
|
844
|
-
style="top:${i(e.at)}px;left:${r(e.from)}px;
|
|
845
|
-
width:${Math.max(e.to - e.from, 0)}px"></span>`), o = n.map((e) => {
|
|
846
|
-
let t = Math.max(e.to - e.from, 0), n = `<i>${Math.round(e.distance)}</i>`, a = e.toBand ? " is-band" : "";
|
|
847
|
-
return e.axis === "y" ? `<span class="dz-gap dz-gap-v${a}"
|
|
848
|
-
style="left:${r(e.at)}px;top:${i(e.from)}px;
|
|
849
|
-
height:${t}px">${n}</span>` : `<span class="dz-gap dz-gap-h${a}"
|
|
850
|
-
style="top:${i(e.at)}px;left:${r(e.from)}px;
|
|
851
|
-
width:${t}px">${n}</span>`;
|
|
852
|
-
});
|
|
853
|
-
return [...a, ...o].join("");
|
|
854
|
-
}
|
|
855
|
-
function Re(e, t, n) {
|
|
856
|
-
let r = U(e).find((e) => e.type === t);
|
|
857
|
-
return r ? r.top + n : null;
|
|
858
|
-
}
|
|
859
|
-
function ze(e, t) {
|
|
860
|
-
let n = U(e);
|
|
861
|
-
if (!n.length) return null;
|
|
862
|
-
let r = [...n].sort((e, t) => e.top - t.top);
|
|
863
|
-
for (let e of r) if (t >= e.top && t < e.top + e.height) return e.type;
|
|
864
|
-
return t < r[0].top ? r[0].type : r.at(-1).type;
|
|
865
|
-
}
|
|
866
|
-
function Be(e, t, n) {
|
|
867
|
-
let r = Re(e, t, n?.y ?? 0);
|
|
868
|
-
return r === null ? null : ze(e, r);
|
|
869
|
-
}
|
|
870
|
-
var Ve = .01;
|
|
871
|
-
function He(e) {
|
|
872
|
-
return [
|
|
873
|
-
{
|
|
874
|
-
at: e.x,
|
|
875
|
-
centre: !1
|
|
876
|
-
},
|
|
877
|
-
{
|
|
878
|
-
at: e.x + (e.w ?? 0) / 2,
|
|
879
|
-
centre: !0
|
|
880
|
-
},
|
|
881
|
-
{
|
|
882
|
-
at: e.x + (e.w ?? 0),
|
|
883
|
-
centre: !1
|
|
884
|
-
}
|
|
885
|
-
];
|
|
886
|
-
}
|
|
887
|
-
function Ue(e) {
|
|
888
|
-
return [
|
|
889
|
-
{
|
|
890
|
-
at: e.y,
|
|
891
|
-
centre: !1
|
|
892
|
-
},
|
|
893
|
-
{
|
|
894
|
-
at: e.y + (e.h ?? 0) / 2,
|
|
895
|
-
centre: !0
|
|
896
|
-
},
|
|
897
|
-
{
|
|
898
|
-
at: e.y + (e.h ?? 0),
|
|
899
|
-
centre: !1
|
|
900
|
-
}
|
|
901
|
-
];
|
|
902
|
-
}
|
|
903
|
-
function We(e) {
|
|
904
|
-
if (!e?.length) return null;
|
|
905
|
-
let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x + (e.w ?? 0))), i = Math.max(...e.map((e) => e.y + (e.h ?? 0)));
|
|
906
|
-
return {
|
|
907
|
-
x: t,
|
|
908
|
-
y: n,
|
|
909
|
-
w: r - t,
|
|
910
|
-
h: i - n
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
function Ge(e, t, n, r = []) {
|
|
914
|
-
let i = n === "x" ? He : Ue, a = (r || []).filter(Number.isFinite).map((e) => ({
|
|
915
|
-
at: e,
|
|
916
|
-
centre: !1,
|
|
917
|
-
box: null
|
|
918
|
-
})), o = (e || []).flatMap((e) => i(e).map((t) => ({
|
|
919
|
-
...t,
|
|
920
|
-
box: e
|
|
921
|
-
}))), s = n === "x" ? t?.w ?? 0 : t?.h ?? 0, c = t ? i({
|
|
922
|
-
x: 0,
|
|
923
|
-
y: 0,
|
|
924
|
-
w: s,
|
|
925
|
-
h: s
|
|
926
|
-
}).map((e) => ({
|
|
927
|
-
...e,
|
|
928
|
-
box: null
|
|
929
|
-
})) : [];
|
|
930
|
-
return [
|
|
931
|
-
...a,
|
|
932
|
-
...o,
|
|
933
|
-
...c
|
|
934
|
-
];
|
|
935
|
-
}
|
|
936
|
-
function K(e, t, n = 6) {
|
|
937
|
-
let r = null;
|
|
938
|
-
for (let i of e) for (let e of t) {
|
|
939
|
-
let t = e.at - i.at;
|
|
940
|
-
Math.abs(t) > n || (!r || Math.abs(t) < Math.abs(r.delta) - Ve) && (r = {
|
|
941
|
-
delta: t,
|
|
942
|
-
at: e.at
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
return r;
|
|
946
|
-
}
|
|
947
|
-
function Ke(e, t, n, r, i) {
|
|
948
|
-
let a = t.filter((e) => Math.abs(e.at - n) < Ve);
|
|
949
|
-
if (!a.length) return [];
|
|
950
|
-
let o = a.some((e) => e.box === null), s = a.map((e) => e.box).filter(Boolean), c = r === "x" ? (e) => [e.y, e.y + (e.h ?? 0)] : (e) => [e.x, e.x + (e.w ?? 0)], l = r === "x" ? i?.h ?? 0 : i?.w ?? 0, u = [...c(e), ...s.flatMap(c)];
|
|
951
|
-
return [{
|
|
952
|
-
axis: r,
|
|
953
|
-
at: n,
|
|
954
|
-
from: o ? 0 : Math.min(...u),
|
|
955
|
-
to: o ? l : Math.max(...u),
|
|
956
|
-
centre: a.every((e) => e.centre)
|
|
957
|
-
}];
|
|
958
|
-
}
|
|
959
|
-
function qe(e, t, n, { snap: r = 6, guides: i } = {}) {
|
|
960
|
-
if (!e) return {
|
|
961
|
-
dx: 0,
|
|
962
|
-
dy: 0,
|
|
963
|
-
lines: []
|
|
964
|
-
};
|
|
965
|
-
let a = Ge(t, n, "x", i?.x), o = Ge(t, n, "y", i?.y), s = K(He(e), a, r), c = K(Ue(e), o, r), l = s?.delta ?? 0, u = c?.delta ?? 0, d = {
|
|
966
|
-
...e,
|
|
967
|
-
x: e.x + l,
|
|
968
|
-
y: e.y + u
|
|
969
|
-
};
|
|
970
|
-
return {
|
|
971
|
-
dx: l,
|
|
972
|
-
dy: u,
|
|
973
|
-
lines: [...s ? Ke(d, a, s.at, "x", n) : [], ...c ? Ke(d, o, c.at, "y", n) : []]
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
function Je(e, t, n) {
|
|
977
|
-
let [r, i] = n === "x" ? ["x", "w"] : ["y", "h"];
|
|
978
|
-
return e[r] < t[r] + (t[i] ?? 0) && e[r] + (e[i] ?? 0) > t[r];
|
|
979
|
-
}
|
|
980
|
-
function Ye(e, t, n, r) {
|
|
981
|
-
let i = r === "up" || r === "down", a = i ? "y" : "x", o = i ? "x" : "y", [s, c] = i ? ["y", "h"] : ["x", "w"], l = e[s], u = e[s] + (e[c] ?? 0), d = r === "up" || r === "left", f = (t || []).filter((t) => Je(e, t, o) ? d ? t[s] + (t[c] ?? 0) <= l : t[s] >= u : !1), p = i ? n?.h ?? 0 : n?.w ?? 0, m = f.length ? d ? Math.max(...f.map((e) => e[s] + (e[c] ?? 0))) : Math.min(...f.map((e) => e[s])) : d ? 0 : p, h = d ? l - m : m - u;
|
|
982
|
-
if (!(h >= 0)) return null;
|
|
983
|
-
let g = f.find((e) => Math.abs((d ? e[s] + (e[c] ?? 0) : e[s]) - m) < Ve), _ = g ? [Math.max(e[o], g[o]), Math.min(e[o] + (e[i ? "w" : "h"] ?? 0), g[o] + (g[i ? "w" : "h"] ?? 0))] : [e[o], e[o] + (e[i ? "w" : "h"] ?? 0)];
|
|
984
|
-
return {
|
|
985
|
-
side: r,
|
|
986
|
-
axis: a,
|
|
987
|
-
at: (_[0] + _[1]) / 2,
|
|
988
|
-
from: d ? m : u,
|
|
989
|
-
to: d ? l : m,
|
|
990
|
-
distance: h,
|
|
991
|
-
toBand: f.length === 0
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
function Xe(e, t, n) {
|
|
995
|
-
return e ? [
|
|
996
|
-
"up",
|
|
997
|
-
"down",
|
|
998
|
-
"left",
|
|
999
|
-
"right"
|
|
1000
|
-
].map((r) => Ye(e, t, n, r)).filter(Boolean) : [];
|
|
1001
|
-
}
|
|
1002
|
-
function Ze(e, t, n, r = {}) {
|
|
1003
|
-
let i = We(e);
|
|
1004
|
-
if (!i) return {
|
|
1005
|
-
dx: 0,
|
|
1006
|
-
dy: 0,
|
|
1007
|
-
lines: [],
|
|
1008
|
-
gaps: []
|
|
1009
|
-
};
|
|
1010
|
-
let { dx: a, dy: o, lines: s } = qe(i, t, n, r);
|
|
1011
|
-
return {
|
|
1012
|
-
dx: a,
|
|
1013
|
-
dy: o,
|
|
1014
|
-
lines: s,
|
|
1015
|
-
gaps: Xe({
|
|
1016
|
-
...i,
|
|
1017
|
-
x: i.x + a,
|
|
1018
|
-
y: i.y + o
|
|
1019
|
-
}, t, n)
|
|
1020
|
-
};
|
|
1021
|
-
}
|
|
1022
|
-
//#endregion
|
|
1023
|
-
//#region src/designer/select.js
|
|
1024
|
-
function Qe({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, remove: a = () => {}, duplicate: o = () => !1, getZoom: s = () => 1, enabled: c = () => !0, onTarget: l = () => {}, onGuides: u = () => {}, rulers: d = () => !1 }) {
|
|
1025
|
-
let f = null, p = 0, m = !1, h = e.ownerDocument;
|
|
1026
|
-
function g(t) {
|
|
1027
|
-
let n = e.querySelector(".dz-page");
|
|
1028
|
-
if (!n) return null;
|
|
1029
|
-
let r = n.getBoundingClientRect(), i = s() || 1, a = h.defaultView?.getComputedStyle(n);
|
|
1030
|
-
return {
|
|
1031
|
-
x: (t.clientX - r.left) / i - parseFloat(a?.paddingLeft || 0),
|
|
1032
|
-
y: (t.clientY - r.top) / i - parseFloat(a?.paddingTop || 0)
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
|
-
function _(e) {
|
|
1036
|
-
return e?.closest("[data-band-type]")?.dataset.bandType ?? null;
|
|
1037
|
-
}
|
|
1038
|
-
function ee(e) {
|
|
1039
|
-
let t = e?.closest("[data-item-id]");
|
|
1040
|
-
if (!t) return null;
|
|
1041
|
-
let n = _(t);
|
|
1042
|
-
return n ? {
|
|
1043
|
-
band: n,
|
|
1044
|
-
id: t.dataset.itemId,
|
|
1045
|
-
node: t
|
|
1046
|
-
} : null;
|
|
1047
|
-
}
|
|
1048
|
-
function te(e) {
|
|
1049
|
-
return e ? ((t().bands || []).find((t) => t.type === e.band)?.items || []).find((t) => t.id === e.id) ?? null : null;
|
|
1050
|
-
}
|
|
1051
|
-
function ne(e, n) {
|
|
1052
|
-
let r = (t().bands || []).find((t) => t.type === e), i = new Set(n.map((e) => e.where.id));
|
|
1053
|
-
return (r?.items || []).filter((e) => !i.has(e.id)).map(I);
|
|
1054
|
-
}
|
|
1055
|
-
function v() {
|
|
1056
|
-
return (n() || []).map((e) => ({
|
|
1057
|
-
where: e,
|
|
1058
|
-
item: te(e)
|
|
1059
|
-
})).filter((e) => e.item);
|
|
1060
|
-
}
|
|
1061
|
-
function y() {
|
|
1062
|
-
return v().at(-1) ?? null;
|
|
1063
|
-
}
|
|
1064
|
-
function re(e) {
|
|
1065
|
-
if (!c() || e.button !== 0 || d() && ie(e)) return;
|
|
1066
|
-
let t = e.target.closest?.("[data-handle]");
|
|
1067
|
-
if (t) {
|
|
1068
|
-
let n = y();
|
|
1069
|
-
if (!n) return;
|
|
1070
|
-
x(e, {
|
|
1071
|
-
mode: "resize",
|
|
1072
|
-
handle: t.dataset.handle,
|
|
1073
|
-
item: n.item
|
|
1074
|
-
});
|
|
1075
|
-
return;
|
|
1076
|
-
}
|
|
1077
|
-
let i = ee(e.target);
|
|
1078
|
-
if (!i) {
|
|
1079
|
-
r(null);
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
let a = {
|
|
1083
|
-
band: i.band,
|
|
1084
|
-
id: i.id
|
|
1085
|
-
}, s = (n() || []).some((e) => e.band === a.band && e.id === a.id);
|
|
1086
|
-
if (e.shiftKey) {
|
|
1087
|
-
r(a, { add: !0 });
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
if (e.altKey && (s || r(a), o())) {
|
|
1091
|
-
x(e, {
|
|
1092
|
-
mode: "move",
|
|
1093
|
-
collapseTo: null
|
|
1094
|
-
});
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
s || r(a), x(e, {
|
|
1098
|
-
mode: "move",
|
|
1099
|
-
collapseTo: s ? a : null
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
function ie(e) {
|
|
1103
|
-
let n = e.target.closest?.("[data-role=\"ruler\"]"), r = g(e);
|
|
1104
|
-
if (!r) return !1;
|
|
1105
|
-
if (n) {
|
|
1106
|
-
let a = n.dataset.axis, o = Se(t(), a, r[a]);
|
|
1107
|
-
return o === null ? !1 : (f = {
|
|
1108
|
-
mode: "guide",
|
|
1109
|
-
axis: a,
|
|
1110
|
-
at: o,
|
|
1111
|
-
created: !0,
|
|
1112
|
-
moved: !1,
|
|
1113
|
-
key: `guide:${++p}`
|
|
1114
|
-
}, b(e), i({
|
|
1115
|
-
live: !0,
|
|
1116
|
-
key: f.key
|
|
1117
|
-
}), !0);
|
|
1118
|
-
}
|
|
1119
|
-
if (!e.target.closest?.(".dz-page")) return !1;
|
|
1120
|
-
for (let n of ["x", "y"]) {
|
|
1121
|
-
let i = Te(t(), n, r[n]);
|
|
1122
|
-
if (i !== null) return f = {
|
|
1123
|
-
mode: "guide",
|
|
1124
|
-
axis: n,
|
|
1125
|
-
at: i,
|
|
1126
|
-
created: !1,
|
|
1127
|
-
moved: !1,
|
|
1128
|
-
key: `guide:${++p}`
|
|
1129
|
-
}, b(e), !0;
|
|
1130
|
-
}
|
|
1131
|
-
return !1;
|
|
1132
|
-
}
|
|
1133
|
-
function b(t) {
|
|
1134
|
-
e.setPointerCapture?.(t.pointerId), e.classList.add("is-dragging"), t.preventDefault();
|
|
1135
|
-
}
|
|
1136
|
-
function x(e, t) {
|
|
1137
|
-
let n = t.mode === "move" ? v().map((e) => ({
|
|
1138
|
-
...e,
|
|
1139
|
-
box: I(e.item)
|
|
1140
|
-
})) : [];
|
|
1141
|
-
f = {
|
|
1142
|
-
...t,
|
|
1143
|
-
group: n,
|
|
1144
|
-
band: y()?.where.band ?? null,
|
|
1145
|
-
target: null,
|
|
1146
|
-
startX: e.clientX,
|
|
1147
|
-
startY: e.clientY,
|
|
1148
|
-
box: t.item ? I(t.item) : null,
|
|
1149
|
-
moved: !1
|
|
1150
|
-
}, b(e);
|
|
1151
|
-
}
|
|
1152
|
-
function S(e) {
|
|
1153
|
-
if (!f) return;
|
|
1154
|
-
if (f.mode === "guide") {
|
|
1155
|
-
let n = g(e);
|
|
1156
|
-
if (!n) return;
|
|
1157
|
-
f.moved = !0, f.at = we(t(), f.axis, f.at, n[f.axis]), i({
|
|
1158
|
-
live: !0,
|
|
1159
|
-
key: f.key
|
|
1160
|
-
});
|
|
1161
|
-
return;
|
|
1162
|
-
}
|
|
1163
|
-
let n = s() || 1, r = (e.clientX - f.startX) / n, a = (e.clientY - f.startY) / n;
|
|
1164
|
-
if (E(e.altKey), !f.moved && Math.abs(r) < 1 && Math.abs(a) < 1) return;
|
|
1165
|
-
if (f.moved = !0, f.mode === "resize") {
|
|
1166
|
-
ye(f.item, ve(f.handle, f.box, r, a, L(f.item))), i({ live: !0 });
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
for (let e of f.group) ye(e.item, {
|
|
1170
|
-
...e.box,
|
|
1171
|
-
...z(e.box, r, a)
|
|
1172
|
-
});
|
|
1173
|
-
C(f.group);
|
|
1174
|
-
let o = t(), c = /* @__PURE__ */ new Set();
|
|
1175
|
-
for (let e of f.group) {
|
|
1176
|
-
let t = Be(o, e.where.band, e.item);
|
|
1177
|
-
t && t !== e.where.band && c.add(t);
|
|
1178
|
-
}
|
|
1179
|
-
f.target = c.size ? [...c] : null, l(f.target), i({ live: !0 });
|
|
1180
|
-
}
|
|
1181
|
-
function C(e) {
|
|
1182
|
-
let n = f?.band ? Ie(t(), f.band) : null;
|
|
1183
|
-
if (!n || !e.length) {
|
|
1184
|
-
u(null);
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
let r = ne(f.band, e), i = Ze(e.map((e) => I(e.item)), r, n, { guides: d() ? Ee(t(), n) : void 0 });
|
|
1188
|
-
if (i.dx || i.dy) for (let t of e) ye(t.item, {
|
|
1189
|
-
...I(t.item),
|
|
1190
|
-
x: (t.item.x ?? 0) + i.dx,
|
|
1191
|
-
y: (t.item.y ?? 0) + i.dy
|
|
1192
|
-
});
|
|
1193
|
-
u({
|
|
1194
|
-
band: f.band,
|
|
1195
|
-
lines: i.lines,
|
|
1196
|
-
gaps: m ? i.gaps : []
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
function w() {
|
|
1200
|
-
let e = v(), n = e.at(-1)?.where ?? null, r = n ? Ie(t(), n.band) : null;
|
|
1201
|
-
if (!r || !e.length) {
|
|
1202
|
-
u(null);
|
|
1203
|
-
return;
|
|
1204
|
-
}
|
|
1205
|
-
let i = e.map((e) => I(e.item));
|
|
1206
|
-
u({
|
|
1207
|
-
band: n.band,
|
|
1208
|
-
lines: [],
|
|
1209
|
-
gaps: Xe(We(i), ne(n.band, e), r)
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
function T() {
|
|
1213
|
-
if (f?.mode === "move") {
|
|
1214
|
-
C(f.group);
|
|
1215
|
-
return;
|
|
1216
|
-
}
|
|
1217
|
-
if (m) {
|
|
1218
|
-
w();
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
u(null);
|
|
1222
|
-
}
|
|
1223
|
-
function E(e) {
|
|
1224
|
-
return e === m ? !1 : (m = e, !0);
|
|
1225
|
-
}
|
|
1226
|
-
function D(n) {
|
|
1227
|
-
if (!f) return;
|
|
1228
|
-
if (e.releasePointerCapture?.(n.pointerId), e.classList.remove("is-dragging"), f.mode === "guide") {
|
|
1229
|
-
let { axis: e, at: n, key: r } = f;
|
|
1230
|
-
f = null;
|
|
1231
|
-
let a = ae(e);
|
|
1232
|
-
(n === null || n < 0 || a !== null && n > a) && Ce(t(), e, n), i({
|
|
1233
|
-
live: !1,
|
|
1234
|
-
key: r
|
|
1235
|
-
});
|
|
1236
|
-
return;
|
|
1237
|
-
}
|
|
1238
|
-
let a = f.moved, o = f.target, s = f.collapseTo;
|
|
1239
|
-
f = null, l(null), E(n.altKey), a ? i({
|
|
1240
|
-
live: !1,
|
|
1241
|
-
band: o
|
|
1242
|
-
}) : s && r(s), T();
|
|
1243
|
-
}
|
|
1244
|
-
function ae(e) {
|
|
1245
|
-
let n = t()?.page;
|
|
1246
|
-
return n?.margin ? e === "x" ? n.width - n.margin.left - n.margin.right : n.height - n.margin.top - n.margin.bottom : null;
|
|
1247
|
-
}
|
|
1248
|
-
function O(e) {
|
|
1249
|
-
if (!c() || e.target.closest?.("input, textarea, select")) return;
|
|
1250
|
-
if (e.key === "Alt") {
|
|
1251
|
-
E(!0) && T(), e.preventDefault();
|
|
1252
|
-
return;
|
|
1253
|
-
}
|
|
1254
|
-
if (e.key === "Escape") {
|
|
1255
|
-
r(null);
|
|
1256
|
-
return;
|
|
1257
|
-
}
|
|
1258
|
-
if (e.key === "Delete" || e.key === "Backspace") {
|
|
1259
|
-
if (!v().length) return;
|
|
1260
|
-
e.preventDefault(), a();
|
|
1261
|
-
return;
|
|
1262
|
-
}
|
|
1263
|
-
let t = {
|
|
1264
|
-
ArrowLeft: [-1, 0],
|
|
1265
|
-
ArrowRight: [1, 0],
|
|
1266
|
-
ArrowUp: [0, -1],
|
|
1267
|
-
ArrowDown: [0, 1]
|
|
1268
|
-
}[e.key];
|
|
1269
|
-
if (!t) return;
|
|
1270
|
-
let n = v();
|
|
1271
|
-
if (!n.length) return;
|
|
1272
|
-
let o = e.shiftKey ? 10 : 1;
|
|
1273
|
-
for (let { item: e } of n) e.x = (e.x ?? 0) + t[0] * o, e.y = (e.y ?? 0) + t[1] * o;
|
|
1274
|
-
e.preventDefault(), i({ live: !1 });
|
|
1275
|
-
}
|
|
1276
|
-
function k(e) {
|
|
1277
|
-
e.key === "Alt" && E(!1) && T();
|
|
1278
|
-
}
|
|
1279
|
-
function A() {
|
|
1280
|
-
E(!1) && T();
|
|
1281
|
-
}
|
|
1282
|
-
return e.addEventListener("pointerdown", re), e.addEventListener("pointermove", S), e.addEventListener("pointerup", D), e.addEventListener("pointercancel", D), h.addEventListener("keydown", O), h.addEventListener("keyup", k), h.defaultView?.addEventListener("blur", A), function() {
|
|
1283
|
-
e.removeEventListener("pointerdown", re), e.removeEventListener("pointermove", S), e.removeEventListener("pointerup", D), e.removeEventListener("pointercancel", D), h.removeEventListener("keydown", O), h.removeEventListener("keyup", k), h.defaultView?.removeEventListener("blur", A);
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
//#endregion
|
|
1287
|
-
//#region src/designer/structure.js
|
|
1288
|
-
var $e = [
|
|
1289
|
-
"pageHeader",
|
|
1290
|
-
"reportHeader",
|
|
1291
|
-
"groupHeader",
|
|
1292
|
-
"detail",
|
|
1293
|
-
"groupFooter",
|
|
1294
|
-
"reportFooter",
|
|
1295
|
-
"pageFooter"
|
|
1296
|
-
], et = {
|
|
1297
|
-
pageHeader: 40,
|
|
1298
|
-
reportHeader: 80,
|
|
1299
|
-
groupHeader: 36,
|
|
1300
|
-
groupFooter: 36,
|
|
1301
|
-
reportFooter: 60,
|
|
1302
|
-
pageFooter: 40
|
|
1303
|
-
}, tt = {
|
|
1304
|
-
reportHeader: "First page only",
|
|
1305
|
-
pageHeader: "Every page",
|
|
1306
|
-
groupHeader: "Before each group",
|
|
1307
|
-
detail: "The rows",
|
|
1308
|
-
groupFooter: "After each group",
|
|
1309
|
-
reportFooter: "Last page only",
|
|
1310
|
-
pageFooter: "Every page"
|
|
1311
|
-
};
|
|
1312
|
-
function q(e) {
|
|
1313
|
-
return Array.isArray(e?.bands) ? e.bands : [];
|
|
1314
|
-
}
|
|
1315
|
-
function nt(e) {
|
|
1316
|
-
return q(e).flatMap((e) => e.items || []).filter((e) => e?.type === "table").length;
|
|
1317
|
-
}
|
|
1318
|
-
function rt(e) {
|
|
1319
|
-
return Array.isArray(e?.bands);
|
|
1320
|
-
}
|
|
1321
|
-
function it(e) {
|
|
1322
|
-
let t = nt(e);
|
|
1323
|
-
if (t === 0) return e.dataset ?? null;
|
|
1324
|
-
let n = e.dataset || "rows", r = new Set(q(e).flatMap((e) => e.items || []).filter((e) => e?.type === "table").map((t) => t.dataset ?? e.dataset));
|
|
1325
|
-
for (let e = t + 1;; e++) if (!r.has(`${n}${e}`)) return `${n}${e}`;
|
|
1326
|
-
}
|
|
1327
|
-
function at(e, t) {
|
|
1328
|
-
e.y = X(t), delete e.groupBy;
|
|
1329
|
-
}
|
|
1330
|
-
function J(e, t) {
|
|
1331
|
-
return q(e).find((e) => e.type === t) ?? null;
|
|
1332
|
-
}
|
|
1333
|
-
function ot(e, t) {
|
|
1334
|
-
return J(e, t) != null;
|
|
1335
|
-
}
|
|
1336
|
-
function st(e, t) {
|
|
1337
|
-
if (!$e.includes(t) || ot(e, t)) return null;
|
|
1338
|
-
let n = {
|
|
1339
|
-
type: t,
|
|
1340
|
-
items: []
|
|
1341
|
-
};
|
|
1342
|
-
et[t] != null && (n.height = et[t]), Array.isArray(e.bands) || (e.bands = []);
|
|
1343
|
-
let r = (e) => $e.indexOf(e), i = e.bands.findIndex((e) => r(e.type) > r(t));
|
|
1344
|
-
return i === -1 ? e.bands.push(n) : e.bands.splice(i, 0, n), n;
|
|
1345
|
-
}
|
|
1346
|
-
function ct(e, t) {
|
|
1347
|
-
let n = q(e).findIndex((e) => e.type === t);
|
|
1348
|
-
return n === -1 ? !1 : (e.bands.splice(n, 1), !0);
|
|
1349
|
-
}
|
|
1350
|
-
function lt(e) {
|
|
1351
|
-
return new Set(q(e).flatMap((e) => (e.items || []).map((e) => e.id)));
|
|
1352
|
-
}
|
|
1353
|
-
function Y(e, t) {
|
|
1354
|
-
let n = lt(e);
|
|
1355
|
-
for (let e = 1;; e++) {
|
|
1356
|
-
let r = `${t}-${e}`;
|
|
1357
|
-
if (!n.has(r)) return r;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
function X(e) {
|
|
1361
|
-
let t = e.items || [];
|
|
1362
|
-
if (!t.length) return 0;
|
|
1363
|
-
let n = Math.max(...t.map((e) => (e.y ?? 0) + o(e)));
|
|
1364
|
-
return Math.ceil(n / 10) * 10;
|
|
1365
|
-
}
|
|
1366
|
-
function ut(e) {
|
|
1367
|
-
let { page: t } = e;
|
|
1368
|
-
return t.width - t.margin.left - t.margin.right;
|
|
1369
|
-
}
|
|
1370
|
-
function dt(e, t) {
|
|
1371
|
-
return {
|
|
1372
|
-
id: Y(e, "text"),
|
|
1373
|
-
type: "text",
|
|
1374
|
-
x: 0,
|
|
1375
|
-
y: X(t),
|
|
1376
|
-
w: 200,
|
|
1377
|
-
h: 20,
|
|
1378
|
-
value: "Text",
|
|
1379
|
-
style: {
|
|
1380
|
-
fontFamily: y[0].value,
|
|
1381
|
-
fontSize: 12,
|
|
1382
|
-
fontWeight: "normal",
|
|
1383
|
-
fontStyle: "normal",
|
|
1384
|
-
color: "#000000",
|
|
1385
|
-
align: "left",
|
|
1386
|
-
background: null,
|
|
1387
|
-
border: null,
|
|
1388
|
-
padding: 0
|
|
1389
|
-
}
|
|
1390
|
-
};
|
|
1391
|
-
}
|
|
1392
|
-
function ft(e, t, n = "horizontal") {
|
|
1393
|
-
let r = n === "vertical";
|
|
1394
|
-
return {
|
|
1395
|
-
id: Y(e, "line"),
|
|
1396
|
-
type: "line",
|
|
1397
|
-
x: 0,
|
|
1398
|
-
y: X(t),
|
|
1399
|
-
w: r ? 12 : ut(e),
|
|
1400
|
-
h: r ? 80 : 12,
|
|
1401
|
-
orientation: r ? "vertical" : "horizontal",
|
|
1402
|
-
style: {
|
|
1403
|
-
thickness: 1,
|
|
1404
|
-
lineStyle: "solid",
|
|
1405
|
-
color: "#000000"
|
|
1406
|
-
}
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
function pt(e, t) {
|
|
1410
|
-
return {
|
|
1411
|
-
id: Y(e, "box"),
|
|
1412
|
-
type: "box",
|
|
1413
|
-
x: 0,
|
|
1414
|
-
y: X(t),
|
|
1415
|
-
w: ut(e),
|
|
1416
|
-
h: 80,
|
|
1417
|
-
style: {
|
|
1418
|
-
borderStyle: "solid",
|
|
1419
|
-
borderWidth: 1,
|
|
1420
|
-
borderColor: "#000000",
|
|
1421
|
-
background: null,
|
|
1422
|
-
radius: 0
|
|
1423
|
-
}
|
|
1424
|
-
};
|
|
1425
|
-
}
|
|
1426
|
-
function mt(e, t) {
|
|
1427
|
-
return {
|
|
1428
|
-
id: Y(e, "image"),
|
|
1429
|
-
type: "image",
|
|
1430
|
-
x: 0,
|
|
1431
|
-
y: X(t),
|
|
1432
|
-
w: 160,
|
|
1433
|
-
h: 80,
|
|
1434
|
-
src: null,
|
|
1435
|
-
field: null,
|
|
1436
|
-
fit: "contain",
|
|
1437
|
-
alt: ""
|
|
1438
|
-
};
|
|
1439
|
-
}
|
|
1440
|
-
function ht(e) {
|
|
1441
|
-
return {
|
|
1442
|
-
field: `field${e}`,
|
|
1443
|
-
label: `Column ${e}`,
|
|
1444
|
-
width: 50,
|
|
1445
|
-
align: "left"
|
|
1446
|
-
};
|
|
1447
|
-
}
|
|
1448
|
-
function gt(e, t, n = 3) {
|
|
1449
|
-
let r = Math.max(1, Math.floor(Number(n) || 3));
|
|
1450
|
-
return {
|
|
1451
|
-
id: Y(e, "table"),
|
|
1452
|
-
type: "table",
|
|
1453
|
-
x: 0,
|
|
1454
|
-
y: X(t),
|
|
1455
|
-
w: ut(e),
|
|
1456
|
-
dataset: it(e),
|
|
1457
|
-
rowHeight: 24,
|
|
1458
|
-
headerHeight: 28,
|
|
1459
|
-
showHeader: !0,
|
|
1460
|
-
wrap: !0,
|
|
1461
|
-
columns: Array.from({ length: r }, (e, t) => ht(t + 1)),
|
|
1462
|
-
style: {
|
|
1463
|
-
fontFamily: "Helvetica, Arial, sans-serif",
|
|
1464
|
-
fontSize: 12,
|
|
1465
|
-
color: "#000000",
|
|
1466
|
-
borderStyle: "solid",
|
|
1467
|
-
borderWidth: 1,
|
|
1468
|
-
borderColor: "#cccccc"
|
|
1469
|
-
}
|
|
1470
|
-
};
|
|
1471
|
-
}
|
|
1472
|
-
function _t(e, t, n) {
|
|
1473
|
-
let r = J(e, t);
|
|
1474
|
-
return r ? (r.items ??= [], r.items.push(n), n) : null;
|
|
1475
|
-
}
|
|
1476
|
-
var vt = 10;
|
|
1477
|
-
function yt(e) {
|
|
1478
|
-
return String(e.id ?? "").replace(/-\d+$/, "") || e.type || "item";
|
|
1479
|
-
}
|
|
1480
|
-
function bt(e, t, n) {
|
|
1481
|
-
if (!Number.isFinite(e?.page?.width)) return Math.max(0, t);
|
|
1482
|
-
let r = Math.max(0, ut(e) - (n ?? 0));
|
|
1483
|
-
return Math.min(Math.max(0, t), r);
|
|
1484
|
-
}
|
|
1485
|
-
function xt(e, t, n) {
|
|
1486
|
-
let r = J(e, t);
|
|
1487
|
-
if (!r) return null;
|
|
1488
|
-
let i = (r.items || []).find((e) => e.id === n);
|
|
1489
|
-
if (!i || i.type === "table" && !rt(e)) return null;
|
|
1490
|
-
let a = structuredClone(i);
|
|
1491
|
-
return a.id = Y(e, yt(i)), a.x = bt(e, (i.x ?? 0) + vt, a.w), a.y = Math.max(0, (i.y ?? 0) + vt), a.type === "table" && at(a, r), r.items ??= [], r.items.push(a), a;
|
|
1492
|
-
}
|
|
1493
|
-
function St(e, t) {
|
|
1494
|
-
return Number.isFinite(e?.page?.height) ? U(e).find((e) => e.type === t)?.height ?? null : null;
|
|
1495
|
-
}
|
|
1496
|
-
function Ct(e, t, n, r) {
|
|
1497
|
-
let i = St(e, t);
|
|
1498
|
-
if (i == null) return Math.max(0, n);
|
|
1499
|
-
let a = Math.max(0, i - o(r));
|
|
1500
|
-
return Math.min(Math.max(0, n), a);
|
|
1501
|
-
}
|
|
1502
|
-
function wt(e, t, n) {
|
|
1503
|
-
let r = J(e, t);
|
|
1504
|
-
if (!r) return [];
|
|
1505
|
-
r.items ??= [];
|
|
1506
|
-
let i = [];
|
|
1507
|
-
for (let { band: a, item: o } of n || []) {
|
|
1508
|
-
if (!o || o.type === "table" && !rt(e)) continue;
|
|
1509
|
-
let n = structuredClone(o), s = Math.max(0, (o.y ?? 0) + vt);
|
|
1510
|
-
n.id = Y(e, yt(o)), n.x = bt(e, (o.x ?? 0) + vt, n.w), n.y = a === t ? s : Ct(e, t, s, n), n.type === "table" && at(n, r), r.items.push(n), i.push(n);
|
|
1511
|
-
}
|
|
1512
|
-
return i;
|
|
1513
|
-
}
|
|
1514
|
-
function Tt(e, t, n) {
|
|
1515
|
-
let r = J(e, t);
|
|
1516
|
-
if (!r) return !1;
|
|
1517
|
-
let i = (r.items || []).findIndex((e) => e.id === n);
|
|
1518
|
-
return i === -1 ? !1 : (r.items.splice(i, 1), !0);
|
|
1519
|
-
}
|
|
1520
|
-
function Et(e, t, n, r) {
|
|
1521
|
-
if (t === n) return !1;
|
|
1522
|
-
let i = J(e, t), a = J(e, n);
|
|
1523
|
-
if (!i || !a) return !1;
|
|
1524
|
-
let o = (i.items || []).find((e) => e.id === r);
|
|
1525
|
-
if (!o) return !1;
|
|
1526
|
-
let s = Re(e, t, o.y ?? 0);
|
|
1527
|
-
Tt(e, t, r), _t(e, n, o);
|
|
1528
|
-
let c = Re(e, n, 0);
|
|
1529
|
-
return s !== null && c !== null && (o.y = Math.round(s - c)), !0;
|
|
1530
|
-
}
|
|
1531
|
-
function Dt(e) {
|
|
1532
|
-
e.columns ??= [];
|
|
1533
|
-
let t = ht(e.columns.length + 1);
|
|
1534
|
-
return e.columns.push(t), t;
|
|
1535
|
-
}
|
|
1536
|
-
function Ot(e, t) {
|
|
1537
|
-
return !Array.isArray(e.columns) || e.columns.length <= 1 || t < 0 || t >= e.columns.length ? !1 : (e.columns.splice(t, 1), !0);
|
|
1538
|
-
}
|
|
1539
|
-
function kt(e, t) {
|
|
1540
|
-
return t && ot(e, t.band) ? t.band : ot(e, "detail") ? "detail" : q(e)[0]?.type ?? null;
|
|
1541
|
-
}
|
|
1542
|
-
//#endregion
|
|
1543
|
-
//#region src/designer/panel.js
|
|
1544
|
-
function At(e) {
|
|
1545
|
-
return `
|
|
1546
|
-
<div class="dz-panel-head">
|
|
1547
|
-
<span class="dz-panel-type">${p(e.type)}</span>
|
|
1548
|
-
<span class="dz-panel-id">${p(e.id)}</span>
|
|
1549
|
-
</div>
|
|
1550
|
-
${Nt(e, ae(e))}
|
|
1551
|
-
${e.type === "table" ? It(e) : ""}`;
|
|
1552
|
-
}
|
|
1553
|
-
function jt(e) {
|
|
1554
|
-
return `
|
|
1555
|
-
<div class="dz-panel-head">
|
|
1556
|
-
<span class="dz-panel-type">${e.length} items</span>
|
|
1557
|
-
</div>
|
|
1558
|
-
|
|
1559
|
-
<section class="dz-section">
|
|
1560
|
-
<ul class="dz-selected">
|
|
1561
|
-
${e.map((e) => `
|
|
1562
|
-
<li>
|
|
1563
|
-
<span class="dz-selected-type">${p(e.type)}</span>
|
|
1564
|
-
<span class="dz-selected-id">${p(e.id)}</span>
|
|
1565
|
-
</li>`).join("")}
|
|
1566
|
-
</ul>
|
|
1567
|
-
|
|
1568
|
-
<p class="dz-hint">
|
|
1569
|
-
Drag to move them together, or use the arrow keys.
|
|
1570
|
-
Select one on its own to change its properties.
|
|
1571
|
-
</p>
|
|
1572
|
-
</section>`;
|
|
1573
|
-
}
|
|
1574
|
-
function Mt(e) {
|
|
1575
|
-
return `
|
|
1576
|
-
<div class="dz-panel-head">
|
|
1577
|
-
<span class="dz-panel-type">report</span>
|
|
1578
|
-
<span class="dz-panel-id">${p(e.name ?? "Untitled")}</span>
|
|
1579
|
-
</div>
|
|
1580
|
-
${Nt(e, N(e))}
|
|
1581
|
-
${Lt(e)}`;
|
|
1582
|
-
}
|
|
1583
|
-
function Nt(e, t) {
|
|
1584
|
-
return t.map((t) => `
|
|
1585
|
-
<section class="dz-section">
|
|
1586
|
-
<h3>${p(t.title)}</h3>
|
|
1587
|
-
${t.fields.map((t) => Pt(e, t)).join("")}
|
|
1588
|
-
</section>`).join("");
|
|
1589
|
-
}
|
|
1590
|
-
function Pt(e, t, n = "") {
|
|
1591
|
-
let r = F(e, t), i = `dz-f-${t.key.replace(/\./g, "-")}${n ? `-${n}` : ""}`, a = n ? `data-field="${p(t.key)}" data-column="${p(n)}"` : `data-field="${p(t.key)}"`, o = t.type === "textarea" ? `<span class="dz-field-top">
|
|
1592
|
-
<label for="${i}">${p(t.label)}</label>
|
|
1593
|
-
<button type="button" class="dz-brace" data-action="insert-brace"
|
|
1594
|
-
data-for="${p(t.key)}"
|
|
1595
|
-
title="Wrap the selected text in braces, or insert a pair"
|
|
1596
|
-
aria-label="Insert a placeholder">{ }</button>
|
|
1597
|
-
</span>` : `<label for="${i}">${p(t.label)}</label>`;
|
|
1598
|
-
return `
|
|
1599
|
-
<div class="dz-field dz-field-${t.type}">
|
|
1600
|
-
${o}
|
|
1601
|
-
${Ft(i, a, t, r)}
|
|
1602
|
-
${t.hint ? `<p class="dz-hint">${p(t.hint)}</p>` : ""}
|
|
1603
|
-
</div>`;
|
|
1604
|
-
}
|
|
1605
|
-
function Ft(e, t, n, r) {
|
|
1606
|
-
switch (n.type) {
|
|
1607
|
-
case "textarea": return `
|
|
1608
|
-
<div class="dz-value">
|
|
1609
|
-
<div class="dz-value-marks" data-role="marks" aria-hidden="true"
|
|
1610
|
-
>${Bt(r ?? "")}</div>
|
|
1611
|
-
<textarea id="${e}" ${t} rows="2"
|
|
1612
|
-
spellcheck="false">${p(r ?? "")}</textarea>
|
|
1613
|
-
</div>`;
|
|
1614
|
-
case "choice": return `<select id="${e}" ${t}>${n.options.map((e) => `<option value="${p(e.value)}"${e.value === r ? " selected" : ""}
|
|
1615
|
-
>${p(e.label)}</option>`).join("")}</select>`;
|
|
1616
|
-
case "color": return `<input type="color" id="${e}" ${t}
|
|
1617
|
-
value="${p(r ?? "#000000")}">`;
|
|
1618
|
-
case "toggle": return `<input type="checkbox" id="${e}" ${t}
|
|
1619
|
-
${r ? "checked" : ""}>`;
|
|
1620
|
-
case "image": return `
|
|
1621
|
-
<div class="dz-image" id="${e}">
|
|
1622
|
-
${r ? `<img class="dz-image-thumb" src="${p(f(r))}" alt="">` : "<span class=\"dz-image-none\">No image stored</span>"}
|
|
1623
|
-
<div class="dz-image-actions">
|
|
1624
|
-
<button type="button" class="dz-add-row"
|
|
1625
|
-
data-action="upload-image">${r ? "Replace" : "Upload"}</button>
|
|
1626
|
-
${r ? "<button type=\"button\" class=\"dz-add-row\"\n data-action=\"clear-image\">Remove</button>" : ""}
|
|
1627
|
-
</div>
|
|
1628
|
-
</div>`;
|
|
1629
|
-
case "text": return `<input type="text" id="${e}" ${t}
|
|
1630
|
-
value="${p(r ?? "")}" spellcheck="false">`;
|
|
1631
|
-
default: return `<input type="number" id="${e}" ${t}
|
|
1632
|
-
value="${p(r ?? "")}"
|
|
1633
|
-
${n.min == null ? "" : `min="${n.min}"`}
|
|
1634
|
-
${n.max == null ? "" : `max="${n.max}"`} step="1">`;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
function It(e) {
|
|
1638
|
-
let t = e.columns || [];
|
|
1639
|
-
return `
|
|
1640
|
-
<section class="dz-section dz-columns">
|
|
1641
|
-
<h3>Columns</h3>
|
|
1642
|
-
${t.map((e, n) => `
|
|
1643
|
-
<div class="dz-column">
|
|
1644
|
-
<div class="dz-column-head">
|
|
1645
|
-
<span>${n + 1}</span>
|
|
1646
|
-
${t.length > 1 ? `
|
|
1647
|
-
<button type="button" class="dz-icon"
|
|
1648
|
-
data-action="remove-column" data-index="${n}"
|
|
1649
|
-
title="Remove this column"
|
|
1650
|
-
aria-label="Remove column ${n + 1}">×</button>` : ""}
|
|
1651
|
-
</div>
|
|
1652
|
-
${D.map((t) => Pt(e, t, String(n))).join("")}
|
|
1653
|
-
</div>`).join("")}
|
|
1654
|
-
<button type="button" class="dz-add-row" data-action="add-column">
|
|
1655
|
-
Add column</button>
|
|
1656
|
-
</section>`;
|
|
1657
|
-
}
|
|
1658
|
-
function Lt(e) {
|
|
1659
|
-
return `
|
|
1660
|
-
<section class="dz-section dz-bands">
|
|
1661
|
-
<h3>Bands</h3>
|
|
1662
|
-
${$e.map((t) => {
|
|
1663
|
-
let n = J(e, t), r = ot(e, t);
|
|
1664
|
-
return `
|
|
1665
|
-
<div class="dz-band-row${r ? " is-on" : ""}">
|
|
1666
|
-
<label class="dz-band-name">
|
|
1667
|
-
<input type="checkbox" data-band="${p(t)}" ${r ? "checked" : ""}>
|
|
1668
|
-
<span>${p(t)}</span>
|
|
1669
|
-
</label>
|
|
1670
|
-
${r && t !== "detail" ? `<input type="text" class="dz-band-height"
|
|
1671
|
-
data-band-height="${p(t)}"
|
|
1672
|
-
value="${p(n.height ?? "")}"
|
|
1673
|
-
placeholder="auto" spellcheck="false"
|
|
1674
|
-
aria-label="${p(t)} height">` : `<span class="dz-band-height-none">${t === "detail" ? "what is left" : ""}</span>`}
|
|
1675
|
-
<p class="dz-hint">${p(tt[t] ?? "")}</p>
|
|
1676
|
-
</div>`;
|
|
1677
|
-
}).join("")}
|
|
1678
|
-
</section>`;
|
|
1679
|
-
}
|
|
1680
|
-
function Rt({ panel: e, getTarget: t, getItem: n, changed: r, act: i, toggleBand: a, setBandHeight: o }) {
|
|
1681
|
-
function s(e) {
|
|
1682
|
-
let t = (e.closest?.(".dz-value"))?.querySelector("[data-role=\"marks\"]");
|
|
1683
|
-
t && (t.innerHTML = Bt(e.value));
|
|
1684
|
-
}
|
|
1685
|
-
function c(e) {
|
|
1686
|
-
let i = e.target.closest?.("[data-field], [data-band], [data-band-height]");
|
|
1687
|
-
if (!i) return;
|
|
1688
|
-
if (i.tagName === "TEXTAREA" && s(i), i.dataset.band != null) {
|
|
1689
|
-
a(i.dataset.band, i.checked);
|
|
1690
|
-
return;
|
|
1691
|
-
}
|
|
1692
|
-
if (i.dataset.bandHeight != null) {
|
|
1693
|
-
o(i.dataset.bandHeight, i.value);
|
|
1694
|
-
return;
|
|
1695
|
-
}
|
|
1696
|
-
if (i.dataset.column != null) {
|
|
1697
|
-
let e = n()?.columns?.[Number(i.dataset.column)];
|
|
1698
|
-
if (!e) return;
|
|
1699
|
-
let t = D.find((e) => e.key === i.dataset.field);
|
|
1700
|
-
t && ue(e, t, i.value) && r(`column:${i.dataset.column}:${t.key}`);
|
|
1701
|
-
return;
|
|
1702
|
-
}
|
|
1703
|
-
let c = t();
|
|
1704
|
-
if (!c) return;
|
|
1705
|
-
let l = c.fields.find((e) => e.key === i.dataset.field);
|
|
1706
|
-
if (!l) return;
|
|
1707
|
-
let u = l.type === "toggle" ? i.checked : i.value;
|
|
1708
|
-
ue(c.target, l, u) && r(`field:${l.key}`, { rebuild: !!l.rebuilds });
|
|
1709
|
-
}
|
|
1710
|
-
function l(e) {
|
|
1711
|
-
let t = e.target.closest?.("[data-action]");
|
|
1712
|
-
if (t) {
|
|
1713
|
-
if (e.preventDefault(), t.dataset.action === "insert-brace") {
|
|
1714
|
-
let e = t.closest(".dz-field")?.querySelector("textarea");
|
|
1715
|
-
e && Vt(e);
|
|
1716
|
-
return;
|
|
1717
|
-
}
|
|
1718
|
-
i(t.dataset.action, t.dataset);
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
function u(e) {
|
|
1722
|
-
let t = e.target;
|
|
1723
|
-
if (t.tagName !== "TEXTAREA") return;
|
|
1724
|
-
let n = t.closest(".dz-value")?.querySelector("[data-role=\"marks\"]");
|
|
1725
|
-
n && (n.scrollTop = t.scrollTop);
|
|
1726
|
-
}
|
|
1727
|
-
return e.addEventListener("scroll", u, !0), e.addEventListener("input", c), e.addEventListener("change", c), e.addEventListener("click", l), function() {
|
|
1728
|
-
e.removeEventListener("scroll", u, !0), e.removeEventListener("input", c), e.removeEventListener("change", c), e.removeEventListener("click", l);
|
|
1729
|
-
};
|
|
1730
|
-
}
|
|
1731
|
-
function zt(e, t, n) {
|
|
1732
|
-
let r = t ?? n;
|
|
1733
|
-
if (!r) return;
|
|
1734
|
-
let i = t ? le(t) : ce(n);
|
|
1735
|
-
for (let n of e.querySelectorAll("[data-field]")) {
|
|
1736
|
-
if (n === n.ownerDocument.activeElement) continue;
|
|
1737
|
-
let e = n.dataset.column != null, a = e ? t?.columns?.[Number(n.dataset.column)] : r;
|
|
1738
|
-
if (!a) continue;
|
|
1739
|
-
let o = (e ? D : i).find((e) => e.key === n.dataset.field);
|
|
1740
|
-
if (!o) continue;
|
|
1741
|
-
let s = F(a, o);
|
|
1742
|
-
if (o.type === "toggle") n.checked = !!s;
|
|
1743
|
-
else if (s != null && (n.value = String(s), n.tagName === "TEXTAREA")) {
|
|
1744
|
-
let e = n.closest(".dz-value")?.querySelector("[data-role=\"marks\"]");
|
|
1745
|
-
e && (e.innerHTML = Bt(n.value));
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
function Bt(e) {
|
|
1750
|
-
return `${p(String(e ?? "")).replace(/\{[^{}]*\}/g, (e) => `<mark class="dz-mark">${e}</mark>`)}\n`;
|
|
1751
|
-
}
|
|
1752
|
-
function Vt(e) {
|
|
1753
|
-
let t = e.selectionStart ?? e.value.length, n = e.selectionEnd ?? t, r = e.value.slice(t, n);
|
|
1754
|
-
e.value = `${e.value.slice(0, t)}{${r}}${e.value.slice(n)}`;
|
|
1755
|
-
let i = t + 1 + r.length;
|
|
1756
|
-
e.focus(), e.setSelectionRange(i, i), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
1757
|
-
}
|
|
1758
|
-
//#endregion
|
|
1759
|
-
//#region src/designer/icons.js
|
|
1760
|
-
var Z = (e) => `<svg viewBox="0 0 16 16" width="16" height="16"
|
|
1761
|
-
fill="none" stroke="currentColor" stroke-width="1.5"
|
|
1762
|
-
stroke-linecap="round" stroke-linejoin="round"
|
|
1763
|
-
aria-hidden="true" focusable="false">${e}</svg>`, Ht = {
|
|
1764
|
-
text: Z("<path d=\"M3 3.75h10M8 3.75v8.5M6.25 12.25h3.5\"/>"),
|
|
1765
|
-
table: Z("<rect x=\"2.25\" y=\"3.25\" width=\"11.5\" height=\"9.5\" rx=\"1.25\"/>\n <path d=\"M2.25 6.5h11.5M6.5 6.5v6.25M10 6.5v6.25\"/>"),
|
|
1766
|
-
image: Z("<rect x=\"2.25\" y=\"3.25\" width=\"11.5\" height=\"9.5\" rx=\"1.25\"/>\n <path d=\"m2.75 11.5 3.5-3.5 2.5 2.5 1.5-1.5 3 3\"/>\n <circle cx=\"10.25\" cy=\"6.25\" r=\"1\"/>"),
|
|
1767
|
-
box: Z("<rect x=\"2.5\" y=\"3.75\" width=\"11\" height=\"8.5\" rx=\"1.25\"/>"),
|
|
1768
|
-
line: Z("<path d=\"M2 8h3.5M7.25 8h1.5M10.5 8H14\"/>"),
|
|
1769
|
-
ruler: Z("<rect x=\"1.75\" y=\"5.25\" width=\"12.5\" height=\"5.5\" rx=\"1\"/>\n <path d=\"M4.5 5.25v2M7 5.25v3M9.5 5.25v2M12 5.25v3\"/>"),
|
|
1770
|
-
undo: Z("<path d=\"M6 4.5 2.75 7.75 6 11\"/>\n <path d=\"M2.75 7.75h6.75a3.75 3.75 0 0 1 0 7.5H7\"/>"),
|
|
1771
|
-
redo: Z("<path d=\"M10 4.5l3.25 3.25L10 11\"/>\n <path d=\"M13.25 7.75H6.5a3.75 3.75 0 0 0 0 7.5H9\"/>"),
|
|
1772
|
-
open: Z("<path d=\"M1.75 12.5V4a.75.75 0 0 1 .75-.75h3.4l1.5 1.75h5.35\n a.75.75 0 0 1 .75.75v1.5\"/>\n <path d=\"M1.75 12.5 3.6 7.5h11.15l-1.85 5z\"/>"),
|
|
1773
|
-
field: Z("<path d=\"M6.25 2.75c-1.5 0-2 .8-2 2v1.4c0 .9-.55 1.5-1.5 1.85\n .95.35 1.5.95 1.5 1.85v1.4c0 1.2.5 2 2 2\"/>\n <path d=\"M9.75 2.75c1.5 0 2 .8 2 2v1.4c0 .9.55 1.5 1.5 1.85\n -.95.35-1.5.95-1.5 1.85v1.4c0 1.2-.5 2-2 2\"/>"),
|
|
1774
|
-
external: Z("<path d=\"M9.5 2.75h3.75V6.5\"/>\n <path d=\"M13.25 2.75 7.5 8.5\"/>\n <path d=\"M11.5 9.25v3a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7\n a1 1 0 0 1 1-1h3\"/>"),
|
|
1775
|
-
preview: Z("<path d=\"M1 8s2.6-4.25 7-4.25S15 8 15 8s-2.6 4.25-7 4.25S1 8 1 8z\"/>\n <circle cx=\"8\" cy=\"8\" r=\"1.9\"/>"),
|
|
1776
|
-
design: Z("<path d=\"M11.4 2.85 13.15 4.6 5.3 12.45l-2.4.65.65-2.4z\"/>\n <path d=\"M10.15 4.1l1.75 1.75\"/>"),
|
|
1777
|
-
data: Z("<ellipse cx=\"8\" cy=\"4\" rx=\"5.25\" ry=\"2\"/>\n <path d=\"M2.75 4v8c0 1.1 2.35 2 5.25 2s5.25-.9 5.25-2V4\"/>\n <path d=\"M2.75 8c0 1.1 2.35 2 5.25 2s5.25-.9 5.25-2\"/>"),
|
|
1778
|
-
duplicate: Z("<rect x=\"2.5\" y=\"2.5\" width=\"8\" height=\"8\" rx=\"1.25\"/>\n <rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8\" rx=\"1.25\"/>"),
|
|
1779
|
-
copy: Z("<path d=\"M6 2.25h3.6L12.25 4.9v5.85a.75.75 0 0 1-.75.75H6\n a.75.75 0 0 1-.75-.75V3a.75.75 0 0 1 .75-.75z\"/>\n <path d=\"M9.35 2.4v2.65h2.75\"/>\n <path d=\"M3.9 5.5H3a.75.75 0 0 0-.75.75V13a.75.75 0 0 0 .75.75h5.4\n a.75.75 0 0 0 .75-.75v-.75\"/>"),
|
|
1780
|
-
delete: Z("<path d=\"M2.75 4.5h10.5\"/>\n <path d=\"M6.25 4.5V3.25a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 .75.75V4.5\"/>\n <path d=\"M4.4 4.5l.55 8.15a.85.85 0 0 0 .85.8h4.4a.85.85 0 0 0 .85-.8L11.6 4.5\"/>\n <path d=\"M6.85 7v3.75M9.15 7v3.75\"/>"),
|
|
1781
|
-
paste: Z("<path d=\"M6.25 3.25H4.5a.75.75 0 0 0-.75.75v8.75\n a.75.75 0 0 0 .75.75h7a.75.75 0 0 0 .75-.75V4\n a.75.75 0 0 0-.75-.75H9.75\"/>\n <rect x=\"6.25\" y=\"1.75\" width=\"3.5\" height=\"2.75\" rx=\".85\"/>"),
|
|
1782
|
-
save: Z("<path d=\"M2.75 3.25h8.5l2.5 2.5v7a.5.5 0 0 1-.5.5h-11\n a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5z\"/>\n <path d=\"M5 3.25v3.5h5.5v-3.5M5 13.25V9.5h6v3.75\"/>")
|
|
1783
|
-
};
|
|
1784
|
-
function Q(e) {
|
|
1785
|
-
return Ht[e] ?? "";
|
|
1786
|
-
}
|
|
1787
|
-
function Ut({ count: e = 0, canPaste: t = !1, canDuplicate: n = !0 } = {}) {
|
|
1788
|
-
let r = e > 1 ? ` ${e} items` : "", i = {
|
|
1789
|
-
action: "paste-items",
|
|
1790
|
-
glyph: "paste",
|
|
1791
|
-
label: "Paste",
|
|
1792
|
-
hint: "ctrl+V",
|
|
1793
|
-
disabled: !t
|
|
1794
|
-
};
|
|
1795
|
-
return e < 1 ? [i] : [
|
|
1796
|
-
{
|
|
1797
|
-
action: "duplicate-item",
|
|
1798
|
-
glyph: "duplicate",
|
|
1799
|
-
label: n ? `Duplicate${r}` : "This cannot be duplicated",
|
|
1800
|
-
hint: "ctrl+D, or alt-drag",
|
|
1801
|
-
disabled: !n
|
|
1802
|
-
},
|
|
1803
|
-
{
|
|
1804
|
-
action: "copy-items",
|
|
1805
|
-
glyph: "copy",
|
|
1806
|
-
label: `Copy${r}`,
|
|
1807
|
-
hint: "ctrl+C"
|
|
1808
|
-
},
|
|
1809
|
-
i,
|
|
1810
|
-
{ separator: !0 },
|
|
1811
|
-
{
|
|
1812
|
-
action: "delete-item",
|
|
1813
|
-
glyph: "delete",
|
|
1814
|
-
label: `Delete${r}`,
|
|
1815
|
-
hint: "del",
|
|
1816
|
-
tone: "danger"
|
|
1817
|
-
}
|
|
1818
|
-
];
|
|
1819
|
-
}
|
|
1820
|
-
function Wt(e) {
|
|
1821
|
-
return `<div class="dz-menu" data-role="menu" role="menu"
|
|
1822
|
-
aria-label="Item actions">${e.map((e) => e.separator ? "<span class=\"dz-menu-sep\" aria-hidden=\"true\"></span>" : `<button type="button" role="menuitem"
|
|
1823
|
-
class="dz-menu-item${e.tone ? ` is-${p(e.tone)}` : ""}"
|
|
1824
|
-
data-action="${p(e.action)}"
|
|
1825
|
-
title="${p(e.label)} (${p(e.hint)})"
|
|
1826
|
-
aria-label="${p(e.label)}"
|
|
1827
|
-
${e.disabled ? "disabled" : ""}
|
|
1828
|
-
>${Q(e.glyph)}</button>`).join("")}</div>`;
|
|
1829
|
-
}
|
|
1830
|
-
function Gt(e, t, n, r = 8) {
|
|
1831
|
-
let i = (e, t, n) => Math.min(Math.max(r, e), Math.max(r, n - t - r));
|
|
1832
|
-
return {
|
|
1833
|
-
left: i(e.x, t.width, n.width),
|
|
1834
|
-
top: i(e.y, t.height, n.height)
|
|
1835
|
-
};
|
|
1836
|
-
}
|
|
1837
|
-
//#endregion
|
|
1838
|
-
//#region src/designer/toast.js
|
|
1839
|
-
function Kt(e, t) {
|
|
1840
|
-
return !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((e, n) => e === t[n]);
|
|
1841
|
-
}
|
|
1842
|
-
function qt(e) {
|
|
1843
|
-
let t = e.length > 1;
|
|
1844
|
-
return `
|
|
1845
|
-
<div class="dz-toast dz-problems" role="alert" data-role="problems">
|
|
1846
|
-
<div class="dz-toast-text">
|
|
1847
|
-
<strong class="dz-toast-title">This report will not render yet</strong>
|
|
1848
|
-
<ul>${e.map((e) => `<li>${p(e)}</li>`).join("")}</ul>
|
|
1849
|
-
</div>
|
|
1850
|
-
<button type="button" class="dz-toast-close"
|
|
1851
|
-
data-action="dismiss-problems"
|
|
1852
|
-
title="Dismiss${t ? ` ${e.length} problems` : ""}"
|
|
1853
|
-
aria-label="Dismiss${t ? ` ${e.length} problems` : ""}"
|
|
1854
|
-
>×</button>
|
|
1855
|
-
</div>`;
|
|
1856
|
-
}
|
|
1857
|
-
//#endregion
|
|
1858
|
-
//#region src/shared/prefix.js
|
|
1859
|
-
var Jt = "/__reports";
|
|
1860
|
-
//#endregion
|
|
1861
|
-
//#region src/shared/store.js
|
|
1862
|
-
function Yt({ prefix: e = Jt, fetch: t = (...e) => globalThis.fetch(...e) } = {}) {
|
|
1863
|
-
async function n(n, r) {
|
|
1864
|
-
let i;
|
|
1865
|
-
try {
|
|
1866
|
-
i = await t(`${e}${n}`, r);
|
|
1867
|
-
} catch (e) {
|
|
1868
|
-
throw new Xt("Cannot reach the report server. Start it with `npx report-studio design`.", {
|
|
1869
|
-
cause: e,
|
|
1870
|
-
offline: !0
|
|
1871
|
-
});
|
|
1872
|
-
}
|
|
1873
|
-
let a = await i.json().catch(() => null);
|
|
1874
|
-
if (!i.ok) throw new Xt(a?.error ?? `the server answered ${i.status}`, { status: i.status });
|
|
1875
|
-
return a;
|
|
1876
|
-
}
|
|
1877
|
-
return {
|
|
1878
|
-
async list() {
|
|
1879
|
-
let e = await n("", { method: "GET" });
|
|
1880
|
-
return Array.isArray(e?.reports) ? e.reports : [];
|
|
1881
|
-
},
|
|
1882
|
-
load(e) {
|
|
1883
|
-
return n(`/${encodeURIComponent(e)}`, { method: "GET" });
|
|
1884
|
-
},
|
|
1885
|
-
save(e, t) {
|
|
1886
|
-
return n(`/${encodeURIComponent(e)}`, {
|
|
1887
|
-
method: "PUT",
|
|
1888
|
-
headers: { "Content-Type": "application/json" },
|
|
1889
|
-
body: JSON.stringify(t)
|
|
1890
|
-
});
|
|
1891
|
-
},
|
|
1892
|
-
remove(e) {
|
|
1893
|
-
return n(`/${encodeURIComponent(e)}`, { method: "DELETE" });
|
|
1894
|
-
},
|
|
1895
|
-
async loadData(e) {
|
|
1896
|
-
try {
|
|
1897
|
-
return await n(`/${encodeURIComponent(e)}/data`, { method: "GET" });
|
|
1898
|
-
} catch (e) {
|
|
1899
|
-
if (e.status === 404) return null;
|
|
1900
|
-
throw e;
|
|
1901
|
-
}
|
|
1902
|
-
},
|
|
1903
|
-
saveData(e, t) {
|
|
1904
|
-
return n(`/${encodeURIComponent(e)}/data`, {
|
|
1905
|
-
method: "PUT",
|
|
1906
|
-
headers: { "Content-Type": "application/json" },
|
|
1907
|
-
body: JSON.stringify(t, null, 2)
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
var Xt = class extends Error {
|
|
1913
|
-
constructor(e, { cause: t, status: n = null, offline: r = !1 } = {}) {
|
|
1914
|
-
super(e, { cause: t }), this.name = "StoreError", this.status = n, this.offline = r;
|
|
1915
|
-
}
|
|
1916
|
-
};
|
|
1917
|
-
function Zt(e) {
|
|
1918
|
-
let t = String(e ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64).replace(/-+$/, "");
|
|
1919
|
-
return /^[a-z0-9]/.test(t) ? t : "";
|
|
1920
|
-
}
|
|
1921
|
-
//#endregion
|
|
1922
|
-
//#region src/designer/sample-data.js
|
|
1923
|
-
var Qt = 6, $t = ["North", "South"], en = /(amount|amt|price|qty|quantity|total|subtotal|cost|rate|balance|discount|tax)$/i, tn = /\{\s*(\w+)\(([^)]*)\)\s*\}/g, nn = /(date|day|when)$/i, rn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAAAAADRSSBWAAAAC0lEQVR4nGO4eRcAApIBt+wBgUAAAAAASUVORK5CYII=";
|
|
1924
|
-
function an(t) {
|
|
1925
|
-
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1926
|
-
for (let i of Array.isArray(t?.bands) ? t.bands : []) {
|
|
1927
|
-
let t = e(i.type);
|
|
1928
|
-
for (let e of i.items || []) if (!(e.type !== "text" || typeof e.value != "string")) for (let [, i] of e.value.matchAll(a)) {
|
|
1929
|
-
let e = i.trim();
|
|
1930
|
-
!e || m(e) || (e.includes(".") || !t ? n.add(e) : r.add(e));
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
return {
|
|
1934
|
-
root: [...n],
|
|
1935
|
-
row: [...r]
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
function on(e) {
|
|
1939
|
-
let t = /* @__PURE__ */ new Set();
|
|
1940
|
-
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) {
|
|
1941
|
-
if (e.type !== "image" || typeof e.field != "string") continue;
|
|
1942
|
-
let n = e.field.trim();
|
|
1943
|
-
n && t.add(n);
|
|
1944
|
-
}
|
|
1945
|
-
return [...t];
|
|
1946
|
-
}
|
|
1947
|
-
function sn(e) {
|
|
1948
|
-
let n = /* @__PURE__ */ new Map(), r = e?.dataset || "rows", i = (e) => (n.has(e) || n.set(e, /* @__PURE__ */ new Set()), n.get(e));
|
|
1949
|
-
for (let t of Array.isArray(e?.bands) ? e.bands : []) for (let e of t.items || []) {
|
|
1950
|
-
if (e.type !== "table") continue;
|
|
1951
|
-
let t = i(e.dataset || r);
|
|
1952
|
-
for (let n of e.columns || []) n?.field && t.add(n.field);
|
|
1953
|
-
}
|
|
1954
|
-
let { row: a } = an(e), o = c(e), s = o?.by ?? e?.groupBy ?? null;
|
|
1955
|
-
if (a.length || s) {
|
|
1956
|
-
let n = i(o && t(o.table, e) || r);
|
|
1957
|
-
for (let e of a) n.add(e);
|
|
1958
|
-
s && n.add(s);
|
|
1959
|
-
}
|
|
1960
|
-
for (let t of mn(e)) i(t.dataset).add(t.field);
|
|
1961
|
-
return n;
|
|
1962
|
-
}
|
|
1963
|
-
function cn(e) {
|
|
1964
|
-
let t = {}, { root: n } = an(e), r = fn(e);
|
|
1965
|
-
for (let n of on(e)) hn(t, n, rn);
|
|
1966
|
-
for (let e of n) hn(t, e);
|
|
1967
|
-
let i = pn(e);
|
|
1968
|
-
for (let [n, a] of sn(e)) t[n] = gn([...a], i.get(n) ?? null, r);
|
|
1969
|
-
return t;
|
|
1970
|
-
}
|
|
1971
|
-
function ln(e, t) {
|
|
1972
|
-
let n = cn(t);
|
|
1973
|
-
if (typeof e != "object" || !e || Array.isArray(e)) return {
|
|
1974
|
-
data: n,
|
|
1975
|
-
added: !0
|
|
1976
|
-
};
|
|
1977
|
-
let r = structuredClone(e);
|
|
1978
|
-
return {
|
|
1979
|
-
data: r,
|
|
1980
|
-
added: un(r, n)
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
function un(e, t) {
|
|
1984
|
-
let n = !1;
|
|
1985
|
-
for (let [r, i] of Object.entries(t)) {
|
|
1986
|
-
let t = e[r];
|
|
1987
|
-
if (t === void 0) {
|
|
1988
|
-
e[r] = structuredClone(i), n = !0;
|
|
1989
|
-
continue;
|
|
1990
|
-
}
|
|
1991
|
-
dn(t) && dn(i) && un(t, i) && (n = !0);
|
|
1992
|
-
}
|
|
1993
|
-
return n;
|
|
1994
|
-
}
|
|
1995
|
-
function dn(e) {
|
|
1996
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1997
|
-
}
|
|
1998
|
-
function fn(e) {
|
|
1999
|
-
let t = /* @__PURE__ */ new Set();
|
|
2000
|
-
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) if (e.type === "text") for (let [, , n] of String(e.value ?? "").matchAll(tn)) {
|
|
2001
|
-
let e = n.trim();
|
|
2002
|
-
e && (t.add(e), e.includes(".") && t.add(e.slice(e.indexOf(".") + 1)));
|
|
2003
|
-
}
|
|
2004
|
-
return t;
|
|
2005
|
-
}
|
|
2006
|
-
function pn(e) {
|
|
2007
|
-
let n = /* @__PURE__ */ new Map(), r = c(e);
|
|
2008
|
-
return r && n.set(t(r.table, e) || e?.dataset || "rows", r.by), n;
|
|
2009
|
-
}
|
|
2010
|
-
function mn(e) {
|
|
2011
|
-
let t = [];
|
|
2012
|
-
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) if (e.type === "text") for (let [, , n] of String(e.value ?? "").matchAll(tn)) {
|
|
2013
|
-
let [e, ...r] = n.trim().split("."), i = r.join(".");
|
|
2014
|
-
e && i && t.push({
|
|
2015
|
-
dataset: e,
|
|
2016
|
-
field: i
|
|
2017
|
-
});
|
|
2018
|
-
}
|
|
2019
|
-
return t;
|
|
2020
|
-
}
|
|
2021
|
-
function hn(e, t, n) {
|
|
2022
|
-
let r = t.split(".").filter(Boolean);
|
|
2023
|
-
if (!r.length) return;
|
|
2024
|
-
let i = r.pop(), a = e;
|
|
2025
|
-
for (let e of r) (a[e] == null || typeof a[e] != "object") && (a[e] = {}), a = a[e];
|
|
2026
|
-
a[i] === void 0 && (a[i] = n ?? _n(i, 0));
|
|
2027
|
-
}
|
|
2028
|
-
function gn(e, t, n = /* @__PURE__ */ new Set()) {
|
|
2029
|
-
return e.length ? Array.from({ length: Qt }, (r, i) => {
|
|
2030
|
-
let a = {};
|
|
2031
|
-
for (let r of e) a[r] = r === t ? $t[i % $t.length] : _n(r, i, n.has(r));
|
|
2032
|
-
return a;
|
|
2033
|
-
}) : [];
|
|
2034
|
-
}
|
|
2035
|
-
function _n(e, t, n = !1) {
|
|
2036
|
-
return n || en.test(e) ? (t + 1) * 250 : nn.test(e) ? `2026-06-${String(t % 28 + 1).padStart(2, "0")}` : `${vn(e)} ${t + 1}`;
|
|
2037
|
-
}
|
|
2038
|
-
function vn(e) {
|
|
2039
|
-
let t = String(e).replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
|
2040
|
-
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
2041
|
-
}
|
|
2042
|
-
//#endregion
|
|
2043
|
-
//#region src/designer/tokens.js
|
|
2044
|
-
var yn = "field", bn = [
|
|
2045
|
-
{
|
|
2046
|
-
id: "page",
|
|
2047
|
-
prefer: [
|
|
2048
|
-
"pageFooter",
|
|
2049
|
-
"reportFooter",
|
|
2050
|
-
"pageHeader"
|
|
2051
|
-
],
|
|
2052
|
-
label: "Page number",
|
|
2053
|
-
value: "{page}",
|
|
2054
|
-
note: "The page this is printed on"
|
|
2055
|
-
},
|
|
2056
|
-
{
|
|
2057
|
-
id: "page-of",
|
|
2058
|
-
prefer: [
|
|
2059
|
-
"pageFooter",
|
|
2060
|
-
"reportFooter",
|
|
2061
|
-
"pageHeader"
|
|
2062
|
-
],
|
|
2063
|
-
label: "Page X of Y",
|
|
2064
|
-
value: "Page {page} of {totalPages}",
|
|
2065
|
-
note: "The usual footer line, written out"
|
|
2066
|
-
},
|
|
2067
|
-
{
|
|
2068
|
-
id: "total-pages",
|
|
2069
|
-
prefer: [
|
|
2070
|
-
"pageFooter",
|
|
2071
|
-
"reportFooter",
|
|
2072
|
-
"pageHeader"
|
|
2073
|
-
],
|
|
2074
|
-
label: "Total pages",
|
|
2075
|
-
value: "{totalPages}",
|
|
2076
|
-
note: "How many pages the report came to"
|
|
2077
|
-
},
|
|
2078
|
-
{
|
|
2079
|
-
id: "today",
|
|
2080
|
-
prefer: [
|
|
2081
|
-
"pageHeader",
|
|
2082
|
-
"reportHeader",
|
|
2083
|
-
"pageFooter"
|
|
2084
|
-
],
|
|
2085
|
-
label: "Today",
|
|
2086
|
-
value: "{today}",
|
|
2087
|
-
note: "The date the report was run"
|
|
2088
|
-
},
|
|
2089
|
-
{
|
|
2090
|
-
id: "count",
|
|
2091
|
-
prefer: ["groupFooter", "reportFooter"],
|
|
2092
|
-
label: "Row count",
|
|
2093
|
-
value: "{count()}",
|
|
2094
|
-
note: "How many rows are in scope",
|
|
2095
|
-
aggregate: !0
|
|
2096
|
-
},
|
|
2097
|
-
{
|
|
2098
|
-
id: "sum",
|
|
2099
|
-
prefer: ["groupFooter", "reportFooter"],
|
|
2100
|
-
label: "Sum",
|
|
2101
|
-
value: `{sum(${yn})}`,
|
|
2102
|
-
note: "Added up over the rows in scope",
|
|
2103
|
-
field: !0,
|
|
2104
|
-
aggregate: !0
|
|
2105
|
-
},
|
|
2106
|
-
{
|
|
2107
|
-
id: "avg",
|
|
2108
|
-
prefer: ["groupFooter", "reportFooter"],
|
|
2109
|
-
label: "Average",
|
|
2110
|
-
value: `{avg(${yn})}`,
|
|
2111
|
-
note: "The mean of the rows in scope",
|
|
2112
|
-
field: !0,
|
|
2113
|
-
aggregate: !0
|
|
2114
|
-
},
|
|
2115
|
-
{
|
|
2116
|
-
id: "min",
|
|
2117
|
-
prefer: ["groupFooter", "reportFooter"],
|
|
2118
|
-
label: "Smallest",
|
|
2119
|
-
value: `{min(${yn})}`,
|
|
2120
|
-
field: !0,
|
|
2121
|
-
aggregate: !0
|
|
2122
|
-
},
|
|
2123
|
-
{
|
|
2124
|
-
id: "max",
|
|
2125
|
-
prefer: ["groupFooter", "reportFooter"],
|
|
2126
|
-
label: "Largest",
|
|
2127
|
-
value: `{max(${yn})}`,
|
|
2128
|
-
field: !0,
|
|
2129
|
-
aggregate: !0
|
|
2130
|
-
}
|
|
2131
|
-
];
|
|
2132
|
-
function xn(e) {
|
|
2133
|
-
return bn.find((t) => t.id === e) ?? null;
|
|
2134
|
-
}
|
|
2135
|
-
function Sn(e) {
|
|
2136
|
-
return !!e?.field;
|
|
2137
|
-
}
|
|
2138
|
-
var Cn = ["groupHeader", "groupFooter"];
|
|
2139
|
-
function wn(e, t) {
|
|
2140
|
-
return e?.aggregate ? Cn.includes(t) ? "group" : "report" : null;
|
|
2141
|
-
}
|
|
2142
|
-
function Tn(e, t) {
|
|
2143
|
-
return e ? !e.bands?.length || e.bands.includes(t) : !1;
|
|
2144
|
-
}
|
|
2145
|
-
function En(e, t) {
|
|
2146
|
-
return e ? Sn(e) ? e.value.replace(yn, String(t || yn)) : e.value : "";
|
|
2147
|
-
}
|
|
2148
|
-
function Dn(e) {
|
|
2149
|
-
let t = /* @__PURE__ */ new Set();
|
|
2150
|
-
for (let [, n] of sn(e)) for (let e of n) t.add(e);
|
|
2151
|
-
e?.groupBy && t.add(e.groupBy);
|
|
2152
|
-
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) e?.type === "table" && typeof e.groupBy == "string" && e.groupBy && t.add(e.groupBy);
|
|
2153
|
-
return [...t].sort();
|
|
2154
|
-
}
|
|
2155
|
-
function On(e, t) {
|
|
2156
|
-
let n = $e.filter((t) => ot(e, t));
|
|
2157
|
-
if (!t?.bands?.length) return n;
|
|
2158
|
-
let r = n.filter((e) => t.bands.includes(e));
|
|
2159
|
-
return r.length ? r : n;
|
|
2160
|
-
}
|
|
2161
|
-
function kn(e, t, n = null) {
|
|
2162
|
-
let r = On(e, t);
|
|
2163
|
-
if (!r.length) return null;
|
|
2164
|
-
for (let e of t?.prefer ?? []) if (r.includes(e)) return e;
|
|
2165
|
-
return n && r.includes(n) && Tn(t, n) ? n : r[0];
|
|
2166
|
-
}
|
|
2167
|
-
function An(e, t) {
|
|
2168
|
-
let n = Sn(e) || e?.id === "count" || e?.id === "page" || e?.id === "total-pages";
|
|
2169
|
-
return {
|
|
2170
|
-
value: En(e, t),
|
|
2171
|
-
w: e?.id === "page-of" ? 200 : 120,
|
|
2172
|
-
align: n ? "right" : "left"
|
|
2173
|
-
};
|
|
2174
|
-
}
|
|
2175
|
-
//#endregion
|
|
2176
|
-
//#region src/designer/dialog.js
|
|
2177
|
-
var jn = 20;
|
|
2178
|
-
function Mn(e) {
|
|
2179
|
-
return In(e, "column-dialog", Ln(), (e, t) => {
|
|
2180
|
-
let n = e.querySelector("[data-role=\"count\"]");
|
|
2181
|
-
n.focus(), n.select(), e.querySelector("form").addEventListener("submit", (e) => {
|
|
2182
|
-
e.preventDefault();
|
|
2183
|
-
let r = Math.round(Number(n.value));
|
|
2184
|
-
t(Number.isFinite(r) && r > 0 ? Math.min(r, jn) : 3);
|
|
2185
|
-
});
|
|
2186
|
-
});
|
|
2187
|
-
}
|
|
2188
|
-
function Nn(e, t) {
|
|
2189
|
-
let n = t || [];
|
|
2190
|
-
return In(e, "open-dialog", Rn(n), (e, t) => {
|
|
2191
|
-
e.querySelector("[data-role=\"new\"]")?.addEventListener("click", () => t({ blank: !0 }));
|
|
2192
|
-
let r = e.querySelector("[data-role=\"report-dropdown\"]"), i = e.querySelector("[data-role=\"confirm\"]");
|
|
2193
|
-
if (!r || !n.length) {
|
|
2194
|
-
e.querySelector("[data-role=\"new\"]")?.focus();
|
|
2195
|
-
return;
|
|
2196
|
-
}
|
|
2197
|
-
let a = _(r), o = e.querySelector("[data-role=\"report-meta\"]"), s = () => {
|
|
2198
|
-
let e = n.find((e) => e.id === a.value) ?? n[0];
|
|
2199
|
-
e && (o.textContent = `${e.id}.json${e.readable === !1 ? " - will not parse" : ""}${zn(e.updatedAt)}`, o.toggleAttribute("data-unreadable", e.readable === !1));
|
|
2200
|
-
};
|
|
2201
|
-
a.addEventListener("change", s), s(), i.addEventListener("click", () => t({ id: a.value })), i.focus(), e.addEventListener("dz-closing", () => a.destroy());
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
function Pn(e, t = "") {
|
|
2205
|
-
return In(e, "save-dialog", Bn(t), (e, t) => {
|
|
2206
|
-
let n = e.querySelector("[data-role=\"report-name\"]"), r = e.querySelector("[data-role=\"filename\"]"), i = e.querySelector("[data-role=\"confirm\"]"), a = () => {
|
|
2207
|
-
let e = Zt(n.value);
|
|
2208
|
-
r.textContent = e ? `${e}.json` : "needs a letter or a digit", i.disabled = !e;
|
|
2209
|
-
};
|
|
2210
|
-
n.addEventListener("input", a), a(), n.focus(), n.select(), e.querySelector("form").addEventListener("submit", (e) => {
|
|
2211
|
-
e.preventDefault();
|
|
2212
|
-
let r = Zt(n.value);
|
|
2213
|
-
r && t({
|
|
2214
|
-
id: r,
|
|
2215
|
-
name: n.value.trim() || r
|
|
2216
|
-
});
|
|
2217
|
-
});
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
function Fn(e, t = "") {
|
|
2221
|
-
return In(e, "discard-dialog", Vn(t), (e, t) => {
|
|
2222
|
-
e.querySelector("[data-role=\"discard\"]").addEventListener("click", () => t(!0)), e.querySelector("[data-role=\"cancel\"]").focus();
|
|
2223
|
-
}).then((e) => e === !0);
|
|
2224
|
-
}
|
|
2225
|
-
function In(e, t, n, r) {
|
|
2226
|
-
return new Promise((i) => {
|
|
2227
|
-
let a = e.ownerDocument.createElement("div");
|
|
2228
|
-
a.className = "modal", a.dataset.role = t, a.innerHTML = n, e.appendChild(a);
|
|
2229
|
-
let o = !1;
|
|
2230
|
-
function s(e) {
|
|
2231
|
-
o || (o = !0, a.dispatchEvent(new CustomEvent("dz-closing")), a.remove(), i(e));
|
|
2232
|
-
}
|
|
2233
|
-
function c(e) {
|
|
2234
|
-
e.key === "Escape" && (e.stopPropagation(), e.preventDefault(), s(null));
|
|
2235
|
-
}
|
|
2236
|
-
for (let e of a.querySelectorAll("[data-role=\"cancel\"], [data-role=\"backdrop\"]")) e.addEventListener("click", () => s(null));
|
|
2237
|
-
a.addEventListener("keydown", c, !0), r(a, s);
|
|
2238
|
-
});
|
|
2239
|
-
}
|
|
2240
|
-
function Ln() {
|
|
2241
|
-
return `
|
|
2242
|
-
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2243
|
-
|
|
2244
|
-
<div class="modal-card" role="dialog" aria-modal="true"
|
|
2245
|
-
aria-labelledby="dz-columns-title">
|
|
2246
|
-
<h2 id="dz-columns-title">Add table</h2>
|
|
2247
|
-
|
|
2248
|
-
<form>
|
|
2249
|
-
<div class="dz-field dz-field-count">
|
|
2250
|
-
<label for="dz-columns">Columns</label>
|
|
2251
|
-
<input type="number" id="dz-columns" data-role="count"
|
|
2252
|
-
value="3" min="1" max="${jn}"
|
|
2253
|
-
step="1" required>
|
|
2254
|
-
</div>
|
|
2255
|
-
|
|
2256
|
-
<p class="modal-summary">
|
|
2257
|
-
Each column starts 50px wide. Rows come from your data, so there
|
|
2258
|
-
is no count to set here.
|
|
2259
|
-
</p>
|
|
2260
|
-
|
|
2261
|
-
<div class="modal-actions">
|
|
2262
|
-
<button type="button" data-role="cancel">Cancel</button>
|
|
2263
|
-
<button type="submit" class="is-primary" data-role="confirm">Add</button>
|
|
2264
|
-
</div>
|
|
2265
|
-
</form>
|
|
2266
|
-
</div>`;
|
|
2267
|
-
}
|
|
2268
|
-
function Rn(e) {
|
|
2269
|
-
let t = e || [], n = `
|
|
2270
|
-
<div class="dz-field dz-field-picker">
|
|
2271
|
-
<label id="dz-open-label">Report</label>
|
|
2272
|
-
|
|
2273
|
-
<div class="dropdown" data-role="report-dropdown">
|
|
2274
|
-
<button type="button" class="dropdown-trigger"
|
|
2275
|
-
aria-haspopup="listbox" aria-expanded="false"
|
|
2276
|
-
aria-labelledby="dz-open-label">
|
|
2277
|
-
<span class="dropdown-value"></span>
|
|
2278
|
-
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
2279
|
-
</button>
|
|
2280
|
-
|
|
2281
|
-
<ul class="dropdown-menu" role="listbox"
|
|
2282
|
-
aria-labelledby="dz-open-label" hidden>${t.map((e, t) => `
|
|
2283
|
-
<li class="dropdown-item" role="option" tabindex="-1"
|
|
2284
|
-
data-value="${p(e.id)}"
|
|
2285
|
-
${t === 0 ? "data-selected=\"true\"" : ""}
|
|
2286
|
-
>${p(e.name || e.id)}</li>`).join("")}</ul>
|
|
2287
|
-
</div>
|
|
2288
|
-
</div>
|
|
2289
|
-
|
|
2290
|
-
<p class="dz-report-meta" data-role="report-meta" aria-live="polite"></p>`;
|
|
2291
|
-
return `
|
|
2292
|
-
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2293
|
-
|
|
2294
|
-
<div class="modal-card is-roomy" role="dialog" aria-modal="true"
|
|
2295
|
-
aria-labelledby="dz-open-title">
|
|
2296
|
-
<h2 id="dz-open-title">Open report</h2>
|
|
2297
|
-
|
|
2298
|
-
${t.length ? n : "<p class=\"modal-summary\">\n No reports saved yet. Start a new one and save it.</p>"}
|
|
2299
|
-
|
|
2300
|
-
<div class="modal-actions">
|
|
2301
|
-
<button type="button" data-role="cancel">Cancel</button>
|
|
2302
|
-
<button type="button" data-role="new">New report</button>
|
|
2303
|
-
${t.length ? "<button type=\"button\" class=\"is-primary\" data-role=\"confirm\">Open</button>" : ""}
|
|
2304
|
-
</div>
|
|
2305
|
-
</div>`;
|
|
2306
|
-
}
|
|
2307
|
-
function zn(e) {
|
|
2308
|
-
if (!e) return "";
|
|
2309
|
-
let t = new Date(e);
|
|
2310
|
-
return Number.isNaN(t.getTime()) ? "" : ` - ${t.toLocaleDateString(void 0, {
|
|
2311
|
-
day: "numeric",
|
|
2312
|
-
month: "short",
|
|
2313
|
-
year: "numeric"
|
|
2314
|
-
})}`;
|
|
2315
|
-
}
|
|
2316
|
-
function Bn(e) {
|
|
2317
|
-
return `
|
|
2318
|
-
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2319
|
-
|
|
2320
|
-
<div class="modal-card" role="dialog" aria-modal="true"
|
|
2321
|
-
aria-labelledby="dz-save-title">
|
|
2322
|
-
<h2 id="dz-save-title">Save report</h2>
|
|
2323
|
-
|
|
2324
|
-
<form>
|
|
2325
|
-
<div class="dz-field dz-field-text">
|
|
2326
|
-
<label for="dz-save-name">Name</label>
|
|
2327
|
-
<input type="text" id="dz-save-name" data-role="report-name"
|
|
2328
|
-
value="${p(e)}" spellcheck="false" required>
|
|
2329
|
-
</div>
|
|
2330
|
-
|
|
2331
|
-
<p class="modal-summary">
|
|
2332
|
-
Saved as <code data-role="filename"></code>
|
|
2333
|
-
</p>
|
|
2334
|
-
|
|
2335
|
-
<div class="modal-actions">
|
|
2336
|
-
<button type="button" data-role="cancel">Cancel</button>
|
|
2337
|
-
<button type="submit" class="is-primary" data-role="confirm">Save</button>
|
|
2338
|
-
</div>
|
|
2339
|
-
</form>
|
|
2340
|
-
</div>`;
|
|
2341
|
-
}
|
|
2342
|
-
function Vn(e) {
|
|
2343
|
-
return `
|
|
2344
|
-
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2345
|
-
|
|
2346
|
-
<div class="modal-card" role="dialog" aria-modal="true"
|
|
2347
|
-
aria-labelledby="dz-discard-title">
|
|
2348
|
-
<h2 id="dz-discard-title">Unsaved changes</h2>
|
|
2349
|
-
|
|
2350
|
-
<p class="modal-summary">
|
|
2351
|
-
${e ? `<strong>${p(e)}</strong>` : "This report"} has changes that have not been saved. Opening another
|
|
2352
|
-
report closes this one, and the changes go with it.
|
|
2353
|
-
</p>
|
|
2354
|
-
|
|
2355
|
-
<div class="modal-actions">
|
|
2356
|
-
<button type="button" class="is-danger" data-role="discard">Discard changes</button>
|
|
2357
|
-
<button type="button" class="is-primary" data-role="cancel">Keep editing</button>
|
|
2358
|
-
</div>
|
|
2359
|
-
</div>`;
|
|
2360
|
-
}
|
|
2361
|
-
function Hn(e, t, { id: n = null, generated: r = !1 } = {}) {
|
|
2362
|
-
return In(e, "data-dialog", Un(t, n, r), (e, t) => {
|
|
2363
|
-
let n = e.querySelector("[data-role=\"payload\"]"), r = e.querySelector("[data-role=\"parse-error\"]"), i = e.querySelector("[data-role=\"confirm\"]"), a = () => {
|
|
2364
|
-
try {
|
|
2365
|
-
let e = JSON.parse(n.value), t = typeof e == "object" && !!e && !Array.isArray(e);
|
|
2366
|
-
r.textContent = t ? "" : "The payload must be a JSON object keyed by dataset name.", i.disabled = !t;
|
|
2367
|
-
} catch (e) {
|
|
2368
|
-
r.textContent = e.message, i.disabled = !0;
|
|
2369
|
-
}
|
|
2370
|
-
};
|
|
2371
|
-
n.addEventListener("input", a), a(), n.focus(), i.addEventListener("click", () => {
|
|
2372
|
-
try {
|
|
2373
|
-
t(JSON.parse(n.value));
|
|
2374
|
-
} catch {}
|
|
2375
|
-
});
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2378
|
-
function Un(e, t, n) {
|
|
2379
|
-
let r = t ? `${t}.data.json` : "a .data.json beside the report";
|
|
2380
|
-
return `
|
|
2381
|
-
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2382
|
-
|
|
2383
|
-
<div class="modal-card is-wide" role="dialog" aria-modal="true"
|
|
2384
|
-
aria-labelledby="dz-data-title">
|
|
2385
|
-
<h2 id="dz-data-title">Report data</h2>
|
|
2386
|
-
|
|
2387
|
-
<p class="modal-summary">
|
|
2388
|
-
${n ? "These keys were read off the report - every placeholder, every\n column, and the field it groups by. Replace the sample values\n with real ones." : "The data this report is currently previewed with."}
|
|
2389
|
-
Saved as <code>${p(r)}</code>.
|
|
2390
|
-
</p>
|
|
2391
|
-
|
|
2392
|
-
<textarea class="dz-payload" data-role="payload" rows="16"
|
|
2393
|
-
spellcheck="false" aria-label="Report data"
|
|
2394
|
-
>${p(JSON.stringify(e, null, 2))}</textarea>
|
|
2395
|
-
|
|
2396
|
-
<p class="dz-parse-error" data-role="parse-error" aria-live="polite"></p>
|
|
2397
|
-
|
|
2398
|
-
<div class="modal-actions">
|
|
2399
|
-
<button type="button" data-role="cancel">Cancel</button>
|
|
2400
|
-
<button type="button" class="is-primary" data-role="confirm">Save data</button>
|
|
2401
|
-
</div>
|
|
2402
|
-
</div>`;
|
|
2403
|
-
}
|
|
2404
|
-
function Wn(e, t, n = null) {
|
|
2405
|
-
let r = Dn(t);
|
|
2406
|
-
return In(e, "token-dialog", qn(t, r, n), (e, i) => {
|
|
2407
|
-
let a = e.querySelector("[data-role=\"field-row\"]"), o = e.querySelector("[data-role=\"token-warning\"]"), s = e.querySelector("[data-role=\"confirm\"]"), c = r.length ? _(e.querySelector("[data-role=\"field-dropdown\"]")) : null, l = e.querySelector("[data-role=\"band-dropdown\"]"), u = null, d = () => xn(e.querySelector("[name=\"dz-token\"]:checked")?.value);
|
|
2408
|
-
function f(e) {
|
|
2409
|
-
u?.destroy();
|
|
2410
|
-
let r = On(t, e), i = kn(t, e, n);
|
|
2411
|
-
l.innerHTML = Yn("band", r.map((e) => ({
|
|
2412
|
-
value: e,
|
|
2413
|
-
label: e
|
|
2414
|
-
})), i), u = _(l), u.addEventListener("change", () => p());
|
|
2415
|
-
}
|
|
2416
|
-
function p({ retarget: e = !1 } = {}) {
|
|
2417
|
-
let t = d();
|
|
2418
|
-
if (!t) return;
|
|
2419
|
-
a.hidden = !Sn(t), e && f(t);
|
|
2420
|
-
let n = u.value, r = Tn(t, n), i = r ? Kn(t, n) : Gn(t, n);
|
|
2421
|
-
o.textContent = i, o.hidden = !i, o.classList.toggle("is-note", r), s.textContent = r ? "Insert" : "Insert anyway";
|
|
2422
|
-
}
|
|
2423
|
-
for (let t of e.querySelectorAll("[name=\"dz-token\"]")) t.addEventListener("change", () => p({ retarget: !0 }));
|
|
2424
|
-
p({ retarget: !0 }), s.addEventListener("click", () => {
|
|
2425
|
-
let e = d();
|
|
2426
|
-
e && i({
|
|
2427
|
-
...An(e, Sn(e) ? c?.value || "field" : void 0),
|
|
2428
|
-
band: u.value
|
|
2429
|
-
});
|
|
2430
|
-
}), e.querySelector("[name=\"dz-token\"]")?.focus(), e.addEventListener("dz-closing", () => {
|
|
2431
|
-
c?.destroy(), u?.destroy();
|
|
2432
|
-
});
|
|
2433
|
-
});
|
|
2434
|
-
}
|
|
2435
|
-
function Gn(e, t) {
|
|
2436
|
-
return `${e.label} prints nothing in a ${t}.`;
|
|
2437
|
-
}
|
|
2438
|
-
function Kn(e, t) {
|
|
2439
|
-
let n = wn(e, t);
|
|
2440
|
-
return n === "group" ? `In a ${t}, ${e.label.toLowerCase()} is worked out over each group's own rows, once per group.` : n === "report" ? `In a ${t}, ${e.label.toLowerCase()} is worked out over every row in the report.` : "";
|
|
2441
|
-
}
|
|
2442
|
-
function qn(e, t, n) {
|
|
2443
|
-
let r = bn[0];
|
|
2444
|
-
return `
|
|
2445
|
-
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2446
|
-
|
|
2447
|
-
<div class="modal-card is-roomy" role="dialog" aria-modal="true"
|
|
2448
|
-
aria-labelledby="dz-token-title">
|
|
2449
|
-
<h2 id="dz-token-title">Insert field</h2>
|
|
2450
|
-
|
|
2451
|
-
<div class="dz-tokens" role="radiogroup" aria-labelledby="dz-token-title">
|
|
2452
|
-
${bn.map((e, t) => `
|
|
2453
|
-
<label class="dz-token">
|
|
2454
|
-
<input type="radio" name="dz-token" value="${p(e.id)}"
|
|
2455
|
-
${t === 0 ? "checked" : ""}>
|
|
2456
|
-
<span class="dz-token-body">
|
|
2457
|
-
<span class="dz-token-name">${p(e.label)}</span>
|
|
2458
|
-
<code class="dz-token-syntax">${p(e.value)}</code>
|
|
2459
|
-
${e.note ? `<span class="dz-token-note">${p(e.note)}</span>` : ""}
|
|
2460
|
-
</span>
|
|
2461
|
-
</label>`).join("")}
|
|
2462
|
-
</div>
|
|
2463
|
-
|
|
2464
|
-
${Jn("field", "Field", t.map((e) => ({
|
|
2465
|
-
value: e,
|
|
2466
|
-
label: e
|
|
2467
|
-
})), t[0], {
|
|
2468
|
-
hidden: !Sn(r),
|
|
2469
|
-
empty: "No fields yet - add a table first"
|
|
2470
|
-
})}
|
|
2471
|
-
|
|
2472
|
-
${Jn("band", "Band", On(e, r).map((e) => ({
|
|
2473
|
-
value: e,
|
|
2474
|
-
label: e
|
|
2475
|
-
})), kn(e, r, n))}
|
|
2476
|
-
|
|
2477
|
-
<p class="dz-token-warning" data-role="token-warning" aria-live="polite" hidden></p>
|
|
2478
|
-
|
|
2479
|
-
<div class="modal-actions">
|
|
2480
|
-
<button type="button" data-role="cancel">Cancel</button>
|
|
2481
|
-
<button type="button" class="is-primary" data-role="confirm">Insert</button>
|
|
2482
|
-
</div>
|
|
2483
|
-
</div>`;
|
|
2484
|
-
}
|
|
2485
|
-
function Jn(e, t, n, r, { hidden: i = !1, empty: a = "" } = {}) {
|
|
2486
|
-
return n.length ? `
|
|
2487
|
-
<div class="dz-field dz-field-picker" data-role="${e}-row"${i ? " hidden" : ""}>
|
|
2488
|
-
<label id="dz-${e}-label">${p(t)}</label>
|
|
2489
|
-
|
|
2490
|
-
<div class="dropdown" data-role="${e}-dropdown">
|
|
2491
|
-
${Yn(e, n, r)}
|
|
2492
|
-
</div>
|
|
2493
|
-
</div>` : `<p class="modal-summary">${p(a)}</p>`;
|
|
2494
|
-
}
|
|
2495
|
-
function Yn(e, t, n) {
|
|
2496
|
-
return `
|
|
2497
|
-
<button type="button" class="dropdown-trigger"
|
|
2498
|
-
aria-haspopup="listbox" aria-expanded="false"
|
|
2499
|
-
aria-labelledby="dz-${e}-label">
|
|
2500
|
-
<span class="dropdown-value"></span>
|
|
2501
|
-
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
2502
|
-
</button>
|
|
2503
|
-
|
|
2504
|
-
<ul class="dropdown-menu" role="listbox"
|
|
2505
|
-
aria-labelledby="dz-${e}-label" hidden>
|
|
2506
|
-
${t.map((e) => `
|
|
2507
|
-
<li class="dropdown-item" role="option" tabindex="-1"
|
|
2508
|
-
data-value="${p(e.value)}"
|
|
2509
|
-
${e.value === n ? "data-selected=\"true\"" : ""}
|
|
2510
|
-
>${p(e.label)}</li>`).join("")}
|
|
2511
|
-
</ul>`;
|
|
2512
|
-
}
|
|
2513
|
-
function Xn(e, t, { limit: n = 12 } = {}) {
|
|
2514
|
-
let r;
|
|
2515
|
-
try {
|
|
2516
|
-
r = v(e, t ?? {});
|
|
2517
|
-
} catch (e) {
|
|
2518
|
-
return {
|
|
2519
|
-
markup: Zn(e),
|
|
2520
|
-
pageCount: 0,
|
|
2521
|
-
error: e?.message ?? String(e)
|
|
2522
|
-
};
|
|
2523
|
-
}
|
|
2524
|
-
let i = r.pages.length;
|
|
2525
|
-
return {
|
|
2526
|
-
markup: `
|
|
2527
|
-
${h(i > n ? {
|
|
2528
|
-
...r,
|
|
2529
|
-
pages: r.pages.slice(0, n)
|
|
2530
|
-
} : r)}
|
|
2531
|
-
${i > n ? Qn(i, n) : ""}`,
|
|
2532
|
-
pageCount: i,
|
|
2533
|
-
error: null
|
|
2534
|
-
};
|
|
2535
|
-
}
|
|
2536
|
-
function Zn(e) {
|
|
2537
|
-
return `
|
|
2538
|
-
<div class="dz-problems" role="alert">
|
|
2539
|
-
<h2>This report will not run yet</h2>
|
|
2540
|
-
<ul>${(e instanceof r && e.issues?.length ? e.issues : [e?.message ?? String(e)]).map((e) => `<li>${p(e)}</li>`).join("")}</ul>
|
|
2541
|
-
</div>`;
|
|
2542
|
-
}
|
|
2543
|
-
function Qn(e, t) {
|
|
2544
|
-
return `
|
|
2545
|
-
<p class="dz-truncated">
|
|
2546
|
-
Showing the first ${t} of ${p(e)} pages.
|
|
2547
|
-
Open the preview screen to read them all.
|
|
2548
|
-
</p>`;
|
|
2549
|
-
}
|
|
2550
|
-
//#endregion
|
|
2551
|
-
//#region src/designer/history.js
|
|
2552
|
-
var $n = 100, $ = (e) => structuredClone(e), er = (e, t) => JSON.stringify(e) === JSON.stringify(t);
|
|
2553
|
-
function tr(e, { limit: t = $n } = {}) {
|
|
2554
|
-
let n = [$(e)], r = 0, i = null;
|
|
2555
|
-
return {
|
|
2556
|
-
push(e, a = null) {
|
|
2557
|
-
return er(e, n[r]) ? !1 : (r < n.length - 1 && (n = n.slice(0, r + 1), i = null), a != null && a === i ? (n[r] = $(e), !0) : (n.push($(e)), r++, i = a, n.length > t && (n.shift(), r--), !0));
|
|
2558
|
-
},
|
|
2559
|
-
undo() {
|
|
2560
|
-
return r === 0 ? null : (r--, i = null, $(n[r]));
|
|
2561
|
-
},
|
|
2562
|
-
redo() {
|
|
2563
|
-
return r >= n.length - 1 ? null : (r++, i = null, $(n[r]));
|
|
2564
|
-
},
|
|
2565
|
-
get canUndo() {
|
|
2566
|
-
return r > 0;
|
|
2567
|
-
},
|
|
2568
|
-
get canRedo() {
|
|
2569
|
-
return r < n.length - 1;
|
|
2570
|
-
},
|
|
2571
|
-
get length() {
|
|
2572
|
-
return n.length;
|
|
2573
|
-
},
|
|
2574
|
-
reset(e) {
|
|
2575
|
-
n = [$(e)], r = 0, i = null;
|
|
2576
|
-
}
|
|
2577
|
-
};
|
|
2578
|
-
}
|
|
2579
|
-
//#endregion
|
|
2580
|
-
//#region src/designer/designer.js
|
|
2581
|
-
var nr = [
|
|
2582
|
-
"image/png",
|
|
2583
|
-
"image/jpeg",
|
|
2584
|
-
"image/gif",
|
|
2585
|
-
"image/webp"
|
|
2586
|
-
], rr = 1024 * 1024, ir = 200 * 1024, ar = (e) => `${Math.round(e / 1024)} KB`, or = [
|
|
2587
|
-
"list",
|
|
2588
|
-
"load",
|
|
2589
|
-
"save"
|
|
2590
|
-
];
|
|
2591
|
-
function sr(e) {
|
|
2592
|
-
if (e == null) return;
|
|
2593
|
-
if (typeof e == "string") throw TypeError(`createDesigner: store must be an object with list, load and save functions, not a path ("${e}"). To keep reports in a folder, leave store out and serve the folder: \`npx report-studio design --dir ${e}\`, or reportStudio({ dir: '${e}' }) from 'report-studio/vite' in your vite.config.`);
|
|
2594
|
-
let t = or.filter((t) => typeof e?.[t] != "function");
|
|
2595
|
-
if (t.length > 0) throw TypeError(`createDesigner: store is missing ${t.join(", ")} - it must be an object with list, load and save functions (see the store contract), or left out to use the dev server's routes.`);
|
|
2596
|
-
}
|
|
2597
|
-
function cr({ width: e, height: t, features: n, ...r } = {}) {
|
|
2598
|
-
let i = d({
|
|
2599
|
-
title: r.layout?.name ? `${r.layout.name} - Designer` : "Report designer",
|
|
2600
|
-
width: e,
|
|
2601
|
-
height: t,
|
|
2602
|
-
features: n
|
|
2603
|
-
});
|
|
2604
|
-
if (!i) return null;
|
|
2605
|
-
let a = lr({
|
|
2606
|
-
...r,
|
|
2607
|
-
mount: i.mount
|
|
2608
|
-
}), o = te(globalThis, i.window, a.destroy);
|
|
2609
|
-
return {
|
|
2610
|
-
...a,
|
|
2611
|
-
window: i.window,
|
|
2612
|
-
destroy() {
|
|
2613
|
-
o(), a.destroy(), i.close();
|
|
2614
|
-
}
|
|
2615
|
-
};
|
|
2616
|
-
}
|
|
2617
|
-
function lr({ mount: e, layout: t, id: n = null, store: r, guardUnload: a = !0, onChange: o = null } = {}) {
|
|
2618
|
-
let s = typeof e == "string" ? document.querySelector(e) : e;
|
|
2619
|
-
if (!s) throw Error(`createDesigner: no element for mount ${JSON.stringify(e)}. Add <div id="report-designer"></div> to the page first.`);
|
|
2620
|
-
let c = s.ownerDocument;
|
|
2621
|
-
sr(r);
|
|
2622
|
-
let l = r ?? Yt(), d = {
|
|
2623
|
-
zoom: 1,
|
|
2624
|
-
fitWidth: !1,
|
|
2625
|
-
rulers: !1,
|
|
2626
|
-
layout: pe(t) ? fe() : t,
|
|
2627
|
-
selection: [],
|
|
2628
|
-
id: n,
|
|
2629
|
-
dirty: !1,
|
|
2630
|
-
clipboard: [],
|
|
2631
|
-
mode: "design",
|
|
2632
|
-
dismissed: null
|
|
2633
|
-
}, f = tr(d.layout);
|
|
2634
|
-
s.classList.add("report-designer"), s.tabIndex = -1, s.innerHTML = ur(d.layout);
|
|
2635
|
-
let p = s.querySelector("[data-role=\"canvas\"]"), m = s.querySelector("[data-role=\"stage\"]"), h = s.querySelector("[data-role=\"zoom-layer\"]"), te = s.querySelector("[data-role=\"panel\"]"), y = s.querySelector("[data-role=\"bar\"]"), re = s.querySelector("[data-role=\"foot\"]"), ie = s.querySelector(".dz-main"), b = s.querySelector("[data-role=\"toasts\"]"), x = s.querySelector("[data-role=\"pages\"]");
|
|
2636
|
-
function S() {
|
|
2637
|
-
return d.selection.at(-1) ?? null;
|
|
2638
|
-
}
|
|
2639
|
-
function C(e) {
|
|
2640
|
-
return e ? (J(d.layout, e.band)?.items || []).find((t) => t.id === e.id) ?? null : null;
|
|
2641
|
-
}
|
|
2642
|
-
function w() {
|
|
2643
|
-
return C(S());
|
|
2644
|
-
}
|
|
2645
|
-
function T() {
|
|
2646
|
-
return d.selection.map(C).filter(Boolean);
|
|
2647
|
-
}
|
|
2648
|
-
function E() {
|
|
2649
|
-
let e = i(d.layout);
|
|
2650
|
-
if (d.mode === "preview") {
|
|
2651
|
-
let t = Xn(d.layout, d.data);
|
|
2652
|
-
return h.innerHTML = t.markup, x.textContent = t.error ? "" : `${t.pageCount} page${t.pageCount === 1 ? "" : "s"}`, D(e), me(), e;
|
|
2653
|
-
}
|
|
2654
|
-
x.textContent = "";
|
|
2655
|
-
let t = "";
|
|
2656
|
-
try {
|
|
2657
|
-
t = Fe(d.layout, d.selection, { rulers: d.rulers });
|
|
2658
|
-
} catch {
|
|
2659
|
-
t = "";
|
|
2660
|
-
}
|
|
2661
|
-
return h.innerHTML = t, D(e), me(), e;
|
|
2662
|
-
}
|
|
2663
|
-
function D(e) {
|
|
2664
|
-
let t = d.mode !== "design" || e.length === 0 || Kt(e, d.dismissed);
|
|
2665
|
-
b.innerHTML = t ? "" : qt(e), e.length === 0 && (d.dismissed = null);
|
|
2666
|
-
}
|
|
2667
|
-
function ae() {
|
|
2668
|
-
O();
|
|
2669
|
-
let e = Pe(d.layout, d.selection);
|
|
2670
|
-
for (let [t, { item: n, box: r }] of e.entries()) {
|
|
2671
|
-
let e = d.selection[t], i = p.querySelector(`[data-role="select"][data-select-id="${dr(n.id)}"]`);
|
|
2672
|
-
i && Object.assign(i.style, {
|
|
2673
|
-
top: `${r.y}px`,
|
|
2674
|
-
left: `${r.x}px`,
|
|
2675
|
-
width: `${r.w}px`,
|
|
2676
|
-
height: `${r.h}px`
|
|
2677
|
-
});
|
|
2678
|
-
let a = p.querySelector(`[data-band-type="${dr(e.band)}"] [data-item-id="${dr(n.id)}"]`);
|
|
2679
|
-
a && (Object.assign(a.style, {
|
|
2680
|
-
top: `${n.y}px`,
|
|
2681
|
-
left: `${n.x}px`,
|
|
2682
|
-
width: `${n.w}px`
|
|
2683
|
-
}), n.type !== "table" && (a.style.height = `${n.h}px`));
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
function O() {
|
|
2687
|
-
let e = p.querySelector("[data-role=\"rules\"]");
|
|
2688
|
-
e && (e.innerHTML = d.rulers ? je(d.layout) : "");
|
|
2689
|
-
for (let e of p.querySelectorAll("[data-role=\"ruler-guides\"]")) e.innerHTML = Ae(d.layout, e.dataset.axis);
|
|
2690
|
-
}
|
|
2691
|
-
function k() {
|
|
2692
|
-
if (d.mode === "preview") return;
|
|
2693
|
-
let e = d.selection.length;
|
|
2694
|
-
te.innerHTML = e > 1 ? jt(T()) : w() ? At(w()) : Mt(d.layout);
|
|
2695
|
-
}
|
|
2696
|
-
let A = (e, t) => e?.band === t?.band && e?.id === t?.id;
|
|
2697
|
-
function j(e, { add: t = !1 } = {}) {
|
|
2698
|
-
let n = e == null ? [] : [].concat(e), r;
|
|
2699
|
-
if (!t) r = n;
|
|
2700
|
-
else {
|
|
2701
|
-
r = [...d.selection];
|
|
2702
|
-
for (let e of n) {
|
|
2703
|
-
let t = r.findIndex((t) => A(t, e));
|
|
2704
|
-
t === -1 ? r.push(e) : r.splice(t, 1);
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
r.length === d.selection.length && r.every((e, t) => A(e, d.selection[t])) || (d.selection = r, E(), k());
|
|
2708
|
-
}
|
|
2709
|
-
function oe(e = null) {
|
|
2710
|
-
f.push(d.layout, e) && (d.dirty = !0, N(), se());
|
|
2711
|
-
}
|
|
2712
|
-
function se() {
|
|
2713
|
-
if (typeof o == "function") try {
|
|
2714
|
-
o(d.layout);
|
|
2715
|
-
} catch (e) {
|
|
2716
|
-
console.error("createDesigner: onChange threw", e);
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
function M(e = null) {
|
|
2720
|
-
E(), k(), oe(e);
|
|
2721
|
-
}
|
|
2722
|
-
function N() {
|
|
2723
|
-
y.querySelector("[data-role=\"name\"]").textContent = d.layout.name ?? "", y.querySelector("[data-role=\"undo\"]").disabled = !f.canUndo, y.querySelector("[data-role=\"redo\"]").disabled = !f.canRedo;
|
|
2724
|
-
let e = y.querySelector("[data-role=\"size\"]");
|
|
2725
|
-
e && d.layout.page && (e.innerHTML = `${d.layout.page.width} × ${d.layout.page.height}`);
|
|
2726
|
-
let t = y.querySelector("[data-role=\"rulers\"]");
|
|
2727
|
-
t.setAttribute("aria-pressed", String(d.rulers)), t.classList.toggle("is-on", d.rulers);
|
|
2728
|
-
let n = re.querySelector("[data-role=\"add-table\"]");
|
|
2729
|
-
n.disabled = !rt(d.layout), y.dataset.dirty = String(d.dirty);
|
|
2730
|
-
let r = y.querySelector("[data-role=\"status\"]");
|
|
2731
|
-
r.textContent = d.dirty ? "Unsaved changes" : d.id ? `Saved as ${d.id}.json` : "Not saved yet";
|
|
2732
|
-
}
|
|
2733
|
-
function P(e, { id: t, dirty: n }) {
|
|
2734
|
-
d.layout = e, d.selection = [], d.mode = "design", d.data = null, t !== void 0 && (d.id = t), n !== void 0 && (d.dirty = n), ke(), se();
|
|
2735
|
-
}
|
|
2736
|
-
function F(e, t) {
|
|
2737
|
-
_t(d.layout, e, t), d.selection = [{
|
|
2738
|
-
band: e,
|
|
2739
|
-
id: t.id
|
|
2740
|
-
}], M(`add:${t.id}`), L(e);
|
|
2741
|
-
}
|
|
2742
|
-
function ue(e) {
|
|
2743
|
-
let t = new Set(e == null ? [] : [].concat(e));
|
|
2744
|
-
for (let e of p.querySelectorAll("[data-band-type]")) e.classList.toggle("is-target", t.has(e.dataset.bandType));
|
|
2745
|
-
for (let e of p.querySelectorAll("[data-band-tag]")) e.classList.toggle("is-target", t.has(e.dataset.bandTag));
|
|
2746
|
-
}
|
|
2747
|
-
function de(e) {
|
|
2748
|
-
let t = p.querySelector("[data-role=\"guides\"]");
|
|
2749
|
-
t && (t.innerHTML = e ? Le(Ie(d.layout, e.band), e.lines, e.gaps) : "");
|
|
2750
|
-
}
|
|
2751
|
-
function me() {
|
|
2752
|
-
h.style.transformOrigin = "top left", h.style.transform = `scale(${d.zoom})`;
|
|
2753
|
-
let e = h.offsetWidth, t = h.offsetHeight;
|
|
2754
|
-
e && t && (m.style.width = `${e * d.zoom}px`, m.style.height = `${t * d.zoom}px`), he();
|
|
2755
|
-
}
|
|
2756
|
-
function he() {
|
|
2757
|
-
if (H && !d.fitWidth) {
|
|
2758
|
-
let e = ee.find((e) => Math.abs(e - d.zoom) < 1e-9);
|
|
2759
|
-
H.value = e === void 0 ? "fit" : String(e);
|
|
2760
|
-
}
|
|
2761
|
-
y.querySelector("[data-role=\"zoom-out\"]").disabled = !d.fitWidth && d.zoom <= g, y.querySelector("[data-role=\"zoom-in\"]").disabled = !d.fitWidth && d.zoom >= ne;
|
|
2762
|
-
}
|
|
2763
|
-
function ge(e) {
|
|
2764
|
-
d.fitWidth = !1, d.zoom = Math.min(Math.max(e, g), ne), me();
|
|
2765
|
-
}
|
|
2766
|
-
function _e() {
|
|
2767
|
-
d.fitWidth = !0, H && (H.value = "fit");
|
|
2768
|
-
let e = p.clientWidth - 48, t = h.offsetWidth;
|
|
2769
|
-
e > 0 && t > 0 && (d.zoom = Math.min(Math.max(e / t, g), ne)), me();
|
|
2770
|
-
}
|
|
2771
|
-
function I(e) {
|
|
2772
|
-
let t = d.zoom;
|
|
2773
|
-
ge((e > 0 ? ee.find((e) => e > t + 1e-9) : [...ee].reverse().find((e) => e < t - 1e-9)) ?? t);
|
|
2774
|
-
}
|
|
2775
|
-
function L(e) {
|
|
2776
|
-
clearTimeout(L.timer), ue(e), L.timer = setTimeout(() => ue(null), 1200);
|
|
2777
|
-
}
|
|
2778
|
-
let R = null;
|
|
2779
|
-
function z() {
|
|
2780
|
-
R?.remove(), R = null;
|
|
2781
|
-
}
|
|
2782
|
-
function ve(e, t) {
|
|
2783
|
-
z(), ie.insertAdjacentHTML("beforeend", Wt(Ut({
|
|
2784
|
-
count: d.selection.length,
|
|
2785
|
-
canPaste: d.clipboard.length > 0,
|
|
2786
|
-
canDuplicate: rt(d.layout) || !T().some((e) => e.type === "table")
|
|
2787
|
-
}))), R = ie.querySelector("[data-role=\"menu\"]"), R.addEventListener("click", be);
|
|
2788
|
-
let n = ie.getBoundingClientRect(), r = R.getBoundingClientRect(), i = Gt({
|
|
2789
|
-
x: e - n.left,
|
|
2790
|
-
y: t - n.top
|
|
2791
|
-
}, {
|
|
2792
|
-
width: r.width,
|
|
2793
|
-
height: r.height
|
|
2794
|
-
}, {
|
|
2795
|
-
width: n.width,
|
|
2796
|
-
height: n.height
|
|
2797
|
-
});
|
|
2798
|
-
R.style.left = `${i.left}px`, R.style.top = `${i.top}px`, R.querySelector("button:not([disabled])")?.focus();
|
|
2799
|
-
}
|
|
2800
|
-
function ye(e) {
|
|
2801
|
-
if (d.mode !== "design") return;
|
|
2802
|
-
e.preventDefault();
|
|
2803
|
-
let t = e.target.closest?.("[data-item-id]"), n = t?.closest("[data-band-type]")?.dataset.bandType ?? null;
|
|
2804
|
-
if (t && n) {
|
|
2805
|
-
let e = {
|
|
2806
|
-
band: n,
|
|
2807
|
-
id: t.dataset.itemId
|
|
2808
|
-
};
|
|
2809
|
-
d.selection.some((t) => t.band === e.band && t.id === e.id) || j(e);
|
|
2810
|
-
} else j(null);
|
|
2811
|
-
ve(e.clientX, e.clientY);
|
|
2812
|
-
}
|
|
2813
|
-
function be(e) {
|
|
2814
|
-
let t = e.target.closest?.("[data-action]");
|
|
2815
|
-
!t || t.disabled || (e.preventDefault(), z(), V(t.dataset.action, t.dataset));
|
|
2816
|
-
}
|
|
2817
|
-
function B(e) {
|
|
2818
|
-
R && !R.contains(e.target) && z();
|
|
2819
|
-
}
|
|
2820
|
-
function xe(e) {
|
|
2821
|
-
R && e.key === "Escape" && z();
|
|
2822
|
-
}
|
|
2823
|
-
function V(e, t) {
|
|
2824
|
-
let n = w();
|
|
2825
|
-
switch (e) {
|
|
2826
|
-
case "add-text": {
|
|
2827
|
-
let e = kt(d.layout, S());
|
|
2828
|
-
if (!e) return;
|
|
2829
|
-
F(e, dt(d.layout, J(d.layout, e)));
|
|
2830
|
-
return;
|
|
2831
|
-
}
|
|
2832
|
-
case "add-box": {
|
|
2833
|
-
let e = kt(d.layout, S());
|
|
2834
|
-
if (!e) return;
|
|
2835
|
-
F(e, pt(d.layout, J(d.layout, e)));
|
|
2836
|
-
return;
|
|
2837
|
-
}
|
|
2838
|
-
case "add-image": {
|
|
2839
|
-
let e = kt(d.layout, S());
|
|
2840
|
-
if (!e) return;
|
|
2841
|
-
F(e, mt(d.layout, J(d.layout, e)));
|
|
2842
|
-
return;
|
|
2843
|
-
}
|
|
2844
|
-
case "upload-image":
|
|
2845
|
-
if (n?.type !== "image") return;
|
|
2846
|
-
Me(n);
|
|
2847
|
-
return;
|
|
2848
|
-
case "clear-image":
|
|
2849
|
-
if (n?.type !== "image" || !n.src) return;
|
|
2850
|
-
n.src = null, M(`image:${n.id}`);
|
|
2851
|
-
return;
|
|
2852
|
-
case "add-line": {
|
|
2853
|
-
let e = kt(d.layout, S());
|
|
2854
|
-
if (!e) return;
|
|
2855
|
-
F(e, ft(d.layout, J(d.layout, e), t?.orientation));
|
|
2856
|
-
return;
|
|
2857
|
-
}
|
|
2858
|
-
case "add-field":
|
|
2859
|
-
Wn(s, d.layout, S()?.band ?? null).then((e) => {
|
|
2860
|
-
if (!e) return;
|
|
2861
|
-
let t = J(d.layout, e.band);
|
|
2862
|
-
if (!t) return;
|
|
2863
|
-
let n = dt(d.layout, t);
|
|
2864
|
-
n.value = e.value, n.w = e.w, n.style.align = e.align, F(e.band, n);
|
|
2865
|
-
});
|
|
2866
|
-
return;
|
|
2867
|
-
case "add-table": {
|
|
2868
|
-
let e = kt(d.layout, S());
|
|
2869
|
-
if (!e || !rt(d.layout)) return;
|
|
2870
|
-
Mn(s).then((t) => {
|
|
2871
|
-
t != null && F(e, gt(d.layout, J(d.layout, e), t));
|
|
2872
|
-
});
|
|
2873
|
-
return;
|
|
2874
|
-
}
|
|
2875
|
-
case "duplicate-item": {
|
|
2876
|
-
if (!d.selection.length) return;
|
|
2877
|
-
let e = [...d.selection], t = [];
|
|
2878
|
-
for (let n of e) {
|
|
2879
|
-
let e = xt(d.layout, n.band, n.id);
|
|
2880
|
-
e && t.push({
|
|
2881
|
-
band: n.band,
|
|
2882
|
-
id: e.id
|
|
2883
|
-
});
|
|
2884
|
-
}
|
|
2885
|
-
if (!t.length) return;
|
|
2886
|
-
d.selection = t, M(`duplicate:${t.map((e) => e.id).join(",")}`), L([...new Set(t.map((e) => e.band))]);
|
|
2887
|
-
return;
|
|
2888
|
-
}
|
|
2889
|
-
case "dismiss-problems":
|
|
2890
|
-
d.dismissed = i(d.layout), b.innerHTML = "";
|
|
2891
|
-
return;
|
|
2892
|
-
case "copy-items": {
|
|
2893
|
-
if (!d.selection.length) return;
|
|
2894
|
-
let e = d.selection.map((e) => ({
|
|
2895
|
-
band: e.band,
|
|
2896
|
-
item: C(e)
|
|
2897
|
-
})).filter((e) => e.item).map((e) => ({
|
|
2898
|
-
band: e.band,
|
|
2899
|
-
item: structuredClone(e.item)
|
|
2900
|
-
}));
|
|
2901
|
-
if (!e.length) return;
|
|
2902
|
-
d.clipboard = e, W(e.length > 1 ? `Copied ${e.length} items` : "Copied", { ms: 2e3 });
|
|
2903
|
-
return;
|
|
2904
|
-
}
|
|
2905
|
-
case "paste-items": {
|
|
2906
|
-
if (!d.clipboard.length) return;
|
|
2907
|
-
let e = kt(d.layout, S());
|
|
2908
|
-
if (!e) return;
|
|
2909
|
-
let t = wt(d.layout, e, d.clipboard);
|
|
2910
|
-
if (!t.length) return;
|
|
2911
|
-
d.clipboard = t.map((t) => ({
|
|
2912
|
-
band: e,
|
|
2913
|
-
item: structuredClone(t)
|
|
2914
|
-
})), d.selection = t.map((t) => ({
|
|
2915
|
-
band: e,
|
|
2916
|
-
id: t.id
|
|
2917
|
-
})), M(`paste:${t.map((e) => e.id).join(",")}`), L(e);
|
|
2918
|
-
return;
|
|
2919
|
-
}
|
|
2920
|
-
case "delete-item": {
|
|
2921
|
-
if (!d.selection.length) return;
|
|
2922
|
-
let e = d.selection.map((e) => e.id).join(",");
|
|
2923
|
-
for (let e of d.selection) Tt(d.layout, e.band, e.id);
|
|
2924
|
-
d.selection = [], M(`delete:${e}`);
|
|
2925
|
-
return;
|
|
2926
|
-
}
|
|
2927
|
-
case "add-column":
|
|
2928
|
-
if (n?.type !== "table") return;
|
|
2929
|
-
Dt(n), M(`column:add:${n.id}`);
|
|
2930
|
-
return;
|
|
2931
|
-
case "remove-column":
|
|
2932
|
-
if (n?.type !== "table") return;
|
|
2933
|
-
Ot(n, Number(t.index)) && M(`column:remove:${n.id}`);
|
|
2934
|
-
return;
|
|
2935
|
-
case "undo": {
|
|
2936
|
-
let e = f.undo();
|
|
2937
|
-
e && P(e, { dirty: !0 });
|
|
2938
|
-
return;
|
|
2939
|
-
}
|
|
2940
|
-
case "redo": {
|
|
2941
|
-
let e = f.redo();
|
|
2942
|
-
e && P(e, { dirty: !0 });
|
|
2943
|
-
return;
|
|
2944
|
-
}
|
|
2945
|
-
case "open": return Ce();
|
|
2946
|
-
case "save": return we();
|
|
2947
|
-
case "data": return Ee();
|
|
2948
|
-
case "open-window": return De();
|
|
2949
|
-
case "zoom-in": return I(1);
|
|
2950
|
-
case "zoom-out": return I(-1);
|
|
2951
|
-
case "toggle-rulers":
|
|
2952
|
-
d.rulers = !d.rulers, E(), N();
|
|
2953
|
-
return;
|
|
2954
|
-
case "toggle-preview": return U();
|
|
2955
|
-
}
|
|
2956
|
-
}
|
|
2957
|
-
async function Se() {
|
|
2958
|
-
return !d.dirty || Fn(s, d.layout?.name ?? "");
|
|
2959
|
-
}
|
|
2960
|
-
async function Ce() {
|
|
2961
|
-
if (!await Se()) return;
|
|
2962
|
-
let e;
|
|
2963
|
-
try {
|
|
2964
|
-
e = await l.list();
|
|
2965
|
-
} catch (e) {
|
|
2966
|
-
return G(e);
|
|
2967
|
-
}
|
|
2968
|
-
let t = await Nn(s, e);
|
|
2969
|
-
if (t) {
|
|
2970
|
-
if (t.blank) {
|
|
2971
|
-
P(fe(), {
|
|
2972
|
-
id: null,
|
|
2973
|
-
dirty: !1
|
|
2974
|
-
}), f.reset(d.layout), N();
|
|
2975
|
-
return;
|
|
2976
|
-
}
|
|
2977
|
-
try {
|
|
2978
|
-
P(await l.load(t.id), {
|
|
2979
|
-
id: t.id,
|
|
2980
|
-
dirty: !1
|
|
2981
|
-
}), f.reset(d.layout), N();
|
|
2982
|
-
} catch (e) {
|
|
2983
|
-
G(e);
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
}
|
|
2987
|
-
async function we() {
|
|
2988
|
-
let e = d.id;
|
|
2989
|
-
if (!e) {
|
|
2990
|
-
let t = await Pn(s, d.layout.name ?? "");
|
|
2991
|
-
if (!t) return;
|
|
2992
|
-
e = t.id, d.layout.name = t.name;
|
|
2993
|
-
}
|
|
2994
|
-
try {
|
|
2995
|
-
await l.save(e, d.layout), d.id = e, d.dirty = !1, N(), await Te(e);
|
|
2996
|
-
} catch (e) {
|
|
2997
|
-
G(e);
|
|
2998
|
-
}
|
|
2999
|
-
}
|
|
3000
|
-
async function Te(e) {
|
|
3001
|
-
if (!(!l.loadData || !l.saveData)) try {
|
|
3002
|
-
let { data: t, added: n } = ln(await l.loadData(e), d.layout);
|
|
3003
|
-
n && await l.saveData(e, t);
|
|
3004
|
-
} catch {}
|
|
3005
|
-
}
|
|
3006
|
-
async function Ee() {
|
|
3007
|
-
let e = null;
|
|
3008
|
-
if (d.id && l.loadData) try {
|
|
3009
|
-
e = await l.loadData(d.id);
|
|
3010
|
-
} catch (e) {
|
|
3011
|
-
return G(e);
|
|
3012
|
-
}
|
|
3013
|
-
let t = e == null, n = await Hn(s, ln(e, d.layout).data, {
|
|
3014
|
-
id: d.id,
|
|
3015
|
-
generated: t
|
|
3016
|
-
});
|
|
3017
|
-
if (n) {
|
|
3018
|
-
if (!d.id) return G(/* @__PURE__ */ Error("Save the report first - its data file is named after it."));
|
|
3019
|
-
try {
|
|
3020
|
-
await l.saveData(d.id, n);
|
|
3021
|
-
} catch (e) {
|
|
3022
|
-
G(e);
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
}
|
|
3026
|
-
function De() {
|
|
3027
|
-
let e;
|
|
3028
|
-
try {
|
|
3029
|
-
e = v(d.layout, d.data ?? cn(d.layout));
|
|
3030
|
-
} catch (e) {
|
|
3031
|
-
G(e);
|
|
3032
|
-
return;
|
|
3033
|
-
}
|
|
3034
|
-
let t = u({
|
|
3035
|
-
paginated: e,
|
|
3036
|
-
title: d.layout?.name || "Report"
|
|
3037
|
-
});
|
|
3038
|
-
if (!t) {
|
|
3039
|
-
W("The browser blocked the report window - allow pop-ups for this page", {
|
|
3040
|
-
problem: !0,
|
|
3041
|
-
ms: 6e3
|
|
3042
|
-
});
|
|
3043
|
-
return;
|
|
3044
|
-
}
|
|
3045
|
-
Oe.add(t);
|
|
3046
|
-
}
|
|
3047
|
-
let Oe = /* @__PURE__ */ new Set(), H = null;
|
|
3048
|
-
async function U() {
|
|
3049
|
-
if (d.mode === "preview") {
|
|
3050
|
-
d.mode = "design", d.data = null, ke();
|
|
3051
|
-
return;
|
|
3052
|
-
}
|
|
3053
|
-
let e = null;
|
|
3054
|
-
if (d.id && l.loadData) try {
|
|
3055
|
-
e = await l.loadData(d.id);
|
|
3056
|
-
} catch {}
|
|
3057
|
-
d.data = ln(e, d.layout).data, d.mode = "preview", d.selection = [], ke();
|
|
3058
|
-
}
|
|
3059
|
-
function ke() {
|
|
3060
|
-
s.dataset.mode = d.mode;
|
|
3061
|
-
let e = y.querySelector("[data-action=\"toggle-preview\"]"), t = d.mode === "preview";
|
|
3062
|
-
e.innerHTML = Q(t ? "design" : "preview"), e.title = t ? "Back to the design (ctrl+E)" : "Run the report (ctrl+E)", e.setAttribute("aria-label", e.title), e.setAttribute("aria-pressed", String(t)), E(), k(), N();
|
|
3063
|
-
}
|
|
3064
|
-
function W(e, { problem: t = !1, ms: n = 6e3 } = {}) {
|
|
3065
|
-
let r = y.querySelector("[data-role=\"status\"]");
|
|
3066
|
-
r.textContent = e, t ? r.dataset.problem = "true" : delete r.dataset.problem, clearTimeout(G.timer), G.timer = setTimeout(() => {
|
|
3067
|
-
delete r.dataset.problem, N();
|
|
3068
|
-
}, n);
|
|
3069
|
-
}
|
|
3070
|
-
function Me(e) {
|
|
3071
|
-
let t = c.createElement("input");
|
|
3072
|
-
t.type = "file", t.accept = nr.join(","), t.addEventListener("change", () => {
|
|
3073
|
-
let n = t.files?.[0];
|
|
3074
|
-
if (!n) return;
|
|
3075
|
-
if (!nr.includes(n.type)) {
|
|
3076
|
-
W(`${n.name} is not a PNG, JPEG, GIF or WebP image`, { problem: !0 });
|
|
3077
|
-
return;
|
|
3078
|
-
}
|
|
3079
|
-
if (n.size > rr) {
|
|
3080
|
-
W(`${n.name} is ${ar(n.size)} - too large to store in a layout. Bind the image to a data field and supply its URL instead`, { problem: !0 });
|
|
3081
|
-
return;
|
|
3082
|
-
}
|
|
3083
|
-
let r = new (c.defaultView ?? globalThis).FileReader();
|
|
3084
|
-
r.addEventListener("load", () => {
|
|
3085
|
-
Ne(e) && (e.src = String(r.result), M(`image:${e.id}`), n.size > ir && W(`Stored ${n.name} (${ar(n.size)}) in the layout - every copy of the report carries it`));
|
|
3086
|
-
}), r.addEventListener("error", () => G(r.error)), r.readAsDataURL(n);
|
|
3087
|
-
}), t.click();
|
|
3088
|
-
}
|
|
3089
|
-
function Ne(e) {
|
|
3090
|
-
return (d.layout.bands ?? []).some((t) => (t.items ?? []).includes(e));
|
|
3091
|
-
}
|
|
3092
|
-
function G(e) {
|
|
3093
|
-
W(e instanceof Xt ? e.message : `Something went wrong: ${e?.message ?? e}`, { problem: !0 });
|
|
3094
|
-
}
|
|
3095
|
-
function Re(e, t) {
|
|
3096
|
-
t ? st(d.layout, e) : (ct(d.layout, e), d.selection = d.selection.filter((t) => t.band !== e)), M(`band:${e}`);
|
|
3097
|
-
}
|
|
3098
|
-
function ze(e, t) {
|
|
3099
|
-
let n = J(d.layout, e);
|
|
3100
|
-
if (!n) return;
|
|
3101
|
-
let r = String(t).trim();
|
|
3102
|
-
if (r === "") delete n.height;
|
|
3103
|
-
else if (/^-?[\d.]+\s*%$/.test(r)) n.height = r;
|
|
3104
|
-
else if (Number.isFinite(Number(r))) n.height = Number(r);
|
|
3105
|
-
else return;
|
|
3106
|
-
E(), oe(`band-height:${e}`);
|
|
3107
|
-
}
|
|
3108
|
-
s.dataset.mode = d.mode, H = _(y.querySelector("[data-role=\"zoom-dropdown\"]")), H.addEventListener("change", () => {
|
|
3109
|
-
H.value === "fit" ? _e() : ge(Number(H.value));
|
|
3110
|
-
});
|
|
3111
|
-
let Ve = () => {
|
|
3112
|
-
d.fitWidth && _e();
|
|
3113
|
-
}, He = c.defaultView ?? globalThis;
|
|
3114
|
-
He.addEventListener("resize", Ve);
|
|
3115
|
-
let Ue = (e) => {
|
|
3116
|
-
d.dirty && (e.preventDefault(), e.returnValue = "");
|
|
3117
|
-
};
|
|
3118
|
-
a && He.addEventListener("beforeunload", Ue), E(), k(), N();
|
|
3119
|
-
let We = Qe({
|
|
3120
|
-
canvas: p,
|
|
3121
|
-
getLayout: () => d.layout,
|
|
3122
|
-
getSelection: () => d.selection,
|
|
3123
|
-
select: j,
|
|
3124
|
-
remove: () => V("delete-item"),
|
|
3125
|
-
duplicate: () => {
|
|
3126
|
-
let e = d.selection.map((e) => e.id).join(",");
|
|
3127
|
-
return V("duplicate-item"), d.selection.map((e) => e.id).join(",") !== e;
|
|
3128
|
-
},
|
|
3129
|
-
enabled: () => d.mode === "design",
|
|
3130
|
-
getZoom: () => d.zoom,
|
|
3131
|
-
rulers: () => d.rulers,
|
|
3132
|
-
onTarget: ue,
|
|
3133
|
-
onGuides: de,
|
|
3134
|
-
commit: ({ live: e, band: t, key: n = null }) => {
|
|
3135
|
-
if (!e && t?.length) {
|
|
3136
|
-
let e = !1;
|
|
3137
|
-
d.selection = d.selection.map((t) => {
|
|
3138
|
-
let n = C(t), r = n ? Be(d.layout, t.band, n) : null;
|
|
3139
|
-
return r && r !== t.band && Et(d.layout, t.band, r, t.id) ? (e = !0, {
|
|
3140
|
-
band: r,
|
|
3141
|
-
id: t.id
|
|
3142
|
-
}) : t;
|
|
3143
|
-
}), e && k();
|
|
3144
|
-
}
|
|
3145
|
-
e ? ae() : E(), zt(te, w(), d.layout), e || oe(n ?? `move:${d.selection.map((e) => e.id).join(",")}`);
|
|
3146
|
-
}
|
|
3147
|
-
}), Ge = Rt({
|
|
3148
|
-
panel: te,
|
|
3149
|
-
getTarget: () => {
|
|
3150
|
-
let e = w();
|
|
3151
|
-
return e ? {
|
|
3152
|
-
target: e,
|
|
3153
|
-
fields: le(e)
|
|
3154
|
-
} : {
|
|
3155
|
-
target: d.layout,
|
|
3156
|
-
fields: ce(d.layout)
|
|
3157
|
-
};
|
|
3158
|
-
},
|
|
3159
|
-
getItem: w,
|
|
3160
|
-
changed: (e, { rebuild: t = !1 } = {}) => {
|
|
3161
|
-
E(), t && k(), oe(e);
|
|
3162
|
-
},
|
|
3163
|
-
act: V,
|
|
3164
|
-
toggleBand: Re,
|
|
3165
|
-
setBandHeight: ze
|
|
3166
|
-
});
|
|
3167
|
-
function K(e) {
|
|
3168
|
-
let t = e.target.closest?.("[data-action]");
|
|
3169
|
-
t && (e.preventDefault(), V(t.dataset.action, t.dataset));
|
|
3170
|
-
}
|
|
3171
|
-
function Ke(e) {
|
|
3172
|
-
return s.contains(e.target) ? !0 : e.target === c.body || e.target === c.documentElement;
|
|
3173
|
-
}
|
|
3174
|
-
function qe(e) {
|
|
3175
|
-
let t = e.target.closest?.("input, textarea, select, button, a, label, [tabindex]");
|
|
3176
|
-
t && t !== s || s.focus({ preventScroll: !0 });
|
|
3177
|
-
}
|
|
3178
|
-
function Je(e) {
|
|
3179
|
-
if (!Ke(e)) return;
|
|
3180
|
-
let t = e.key.toLowerCase();
|
|
3181
|
-
if (t === "z" && !e.ctrlKey && !e.metaKey) {
|
|
3182
|
-
if (e.target.closest?.("input, textarea, select")) return;
|
|
3183
|
-
e.preventDefault(), I(e.altKey ? -1 : 1);
|
|
3184
|
-
return;
|
|
3185
|
-
}
|
|
3186
|
-
if (e.ctrlKey || e.metaKey) {
|
|
3187
|
-
if (t === "c" || t === "v") {
|
|
3188
|
-
if (e.target.closest?.("input, textarea, select") || t === "c" && String(globalThis.getSelection?.() ?? "")) return;
|
|
3189
|
-
e.preventDefault(), V(t === "c" ? "copy-items" : "paste-items");
|
|
3190
|
-
return;
|
|
3191
|
-
}
|
|
3192
|
-
if (t === "s") {
|
|
3193
|
-
e.preventDefault(), V("save");
|
|
3194
|
-
return;
|
|
3195
|
-
}
|
|
3196
|
-
if (t === "o") {
|
|
3197
|
-
e.preventDefault(), V("open");
|
|
3198
|
-
return;
|
|
3199
|
-
}
|
|
3200
|
-
if (t === "e") {
|
|
3201
|
-
e.preventDefault(), V("toggle-preview");
|
|
3202
|
-
return;
|
|
3203
|
-
}
|
|
3204
|
-
if (t === "0") {
|
|
3205
|
-
e.preventDefault(), ge(1);
|
|
3206
|
-
return;
|
|
3207
|
-
}
|
|
3208
|
-
if (t === "z") {
|
|
3209
|
-
e.preventDefault(), V(e.shiftKey || e.altKey ? "redo" : "undo");
|
|
3210
|
-
return;
|
|
3211
|
-
}
|
|
3212
|
-
if (t === "y") {
|
|
3213
|
-
e.preventDefault(), V("redo");
|
|
3214
|
-
return;
|
|
3215
|
-
}
|
|
3216
|
-
t === "d" && (e.preventDefault(), V("duplicate-item"));
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
return y.addEventListener("click", K), re.addEventListener("click", K), b.addEventListener("click", K), s.addEventListener("pointerdown", qe), c.addEventListener("keydown", Je), p.addEventListener("contextmenu", ye), p.addEventListener("scroll", z), c.addEventListener("pointerdown", B), c.addEventListener("keydown", xe), {
|
|
3220
|
-
get layout() {
|
|
3221
|
-
return d.layout;
|
|
3222
|
-
},
|
|
3223
|
-
get mode() {
|
|
3224
|
-
return d.mode;
|
|
3225
|
-
},
|
|
3226
|
-
togglePreview: U,
|
|
3227
|
-
get sampleData() {
|
|
3228
|
-
return cn(d.layout);
|
|
3229
|
-
},
|
|
3230
|
-
get selection() {
|
|
3231
|
-
return S();
|
|
3232
|
-
},
|
|
3233
|
-
get selections() {
|
|
3234
|
-
return [...d.selection];
|
|
3235
|
-
},
|
|
3236
|
-
select: j,
|
|
3237
|
-
get id() {
|
|
3238
|
-
return d.id;
|
|
3239
|
-
},
|
|
3240
|
-
get dirty() {
|
|
3241
|
-
return d.dirty;
|
|
3242
|
-
},
|
|
3243
|
-
open(e, t = null) {
|
|
3244
|
-
return P(pe(e) ? fe() : e, {
|
|
3245
|
-
id: t,
|
|
3246
|
-
dirty: !1
|
|
3247
|
-
}), f.reset(d.layout), N(), i(d.layout);
|
|
3248
|
-
},
|
|
3249
|
-
save: we,
|
|
3250
|
-
redraw: E,
|
|
3251
|
-
destroy() {
|
|
3252
|
-
We(), Ge(), y.removeEventListener("click", K), re.removeEventListener("click", K), b.removeEventListener("click", K), s.removeEventListener("pointerdown", qe), c.removeEventListener("keydown", Je), p.removeEventListener("contextmenu", ye), p.removeEventListener("scroll", z), c.removeEventListener("pointerdown", B), c.removeEventListener("keydown", xe), (c.defaultView ?? globalThis).removeEventListener("resize", Ve), He.removeEventListener("beforeunload", Ue), H?.destroy(), z(), clearTimeout(G.timer), clearTimeout(L.timer);
|
|
3253
|
-
for (let e of Oe) e.destroy();
|
|
3254
|
-
Oe.clear(), s.innerHTML = "", s.classList.remove("report-designer");
|
|
3255
|
-
}
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
function ur(e) {
|
|
3259
|
-
let t = e.page ? `${e.page.width} × ${e.page.height}` : "";
|
|
3260
|
-
return `
|
|
3261
|
-
<header class="dz-bar" data-role="bar">
|
|
3262
|
-
<span class="dz-brand">Report Studio</span>
|
|
3263
|
-
|
|
3264
|
-
<span class="dz-title">
|
|
3265
|
-
<span class="dz-name" data-role="name">${fr(e.name ?? "")}</span>
|
|
3266
|
-
<span class="dz-status" data-role="status">Not saved yet</span>
|
|
3267
|
-
</span>
|
|
3268
|
-
|
|
3269
|
-
<div class="dz-bar-group">
|
|
3270
|
-
<button type="button" class="dz-tool" data-role="undo" data-action="undo"
|
|
3271
|
-
title="Undo (ctrl+Z)" aria-label="Undo" disabled
|
|
3272
|
-
>${Q("undo")}</button>
|
|
3273
|
-
<button type="button" class="dz-tool" data-role="redo" data-action="redo"
|
|
3274
|
-
title="Redo (ctrl+alt+Z or ctrl+shift+Z)" aria-label="Redo" disabled
|
|
3275
|
-
>${Q("redo")}</button>
|
|
3276
|
-
</div>
|
|
3277
|
-
|
|
3278
|
-
<div class="dz-bar-group">
|
|
3279
|
-
<button type="button" class="dz-tool" data-action="open"
|
|
3280
|
-
title="Open a report (ctrl+O)" aria-label="Open a report"
|
|
3281
|
-
>${Q("open")}</button>
|
|
3282
|
-
<button type="button" class="dz-tool" data-action="save"
|
|
3283
|
-
title="Save (ctrl+S)" aria-label="Save"
|
|
3284
|
-
>${Q("save")}</button>
|
|
3285
|
-
<button type="button" class="dz-tool" data-action="data"
|
|
3286
|
-
title="The data this report needs" aria-label="Report data"
|
|
3287
|
-
>${Q("data")}</button>
|
|
3288
|
-
</div>
|
|
3289
|
-
|
|
3290
|
-
<div class="dz-bar-group">
|
|
3291
|
-
<button type="button" class="dz-tool" data-role="rulers"
|
|
3292
|
-
data-action="toggle-rulers"
|
|
3293
|
-
title="Rulers and guides - drag off a ruler to place one"
|
|
3294
|
-
aria-label="Rulers and guides" aria-pressed="false"
|
|
3295
|
-
>${Q("ruler")}</button>
|
|
3296
|
-
<button type="button" class="dz-tool" data-action="toggle-preview"
|
|
3297
|
-
title="Run the report (ctrl+E)" aria-label="Run the report"
|
|
3298
|
-
aria-pressed="false"
|
|
3299
|
-
>${Q("preview")}</button>
|
|
3300
|
-
|
|
3301
|
-
<!--
|
|
3302
|
-
A button, not a link: the window is built from the design as it
|
|
3303
|
-
stands rather than fetched from a URL, so it works on a report
|
|
3304
|
-
that has never been saved - which a link to the preview screen
|
|
3305
|
-
could not, because that screen reads the report off the disk.
|
|
3306
|
-
-->
|
|
3307
|
-
<button type="button" class="dz-tool" data-role="open-preview"
|
|
3308
|
-
data-action="open-window"
|
|
3309
|
-
title="Open the report in its own window"
|
|
3310
|
-
aria-label="Open the report in its own window"
|
|
3311
|
-
>${Q("external")}</button>
|
|
3312
|
-
</div>
|
|
3313
|
-
|
|
3314
|
-
<span class="dz-pages" data-role="pages"></span>
|
|
3315
|
-
<span class="dz-size" data-role="size">${t}</span>
|
|
3316
|
-
|
|
3317
|
-
<!--
|
|
3318
|
-
The same three controls the viewer has, in the same order and with
|
|
3319
|
-
the same shortcuts. A designer and a preview of the same report
|
|
3320
|
-
should not zoom differently.
|
|
3321
|
-
-->
|
|
3322
|
-
<div class="dz-bar-group dz-zoom-group">
|
|
3323
|
-
<button type="button" class="dz-tool" data-role="zoom-out"
|
|
3324
|
-
data-action="zoom-out"
|
|
3325
|
-
title="Zoom out (alt+Z)" aria-label="Zoom out">−</button>
|
|
3326
|
-
|
|
3327
|
-
<div class="dropdown" data-role="zoom-dropdown">
|
|
3328
|
-
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
3329
|
-
aria-haspopup="listbox" aria-expanded="false"
|
|
3330
|
-
aria-label="Zoom level">
|
|
3331
|
-
<span class="dropdown-value">100%</span>
|
|
3332
|
-
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
3333
|
-
</button>
|
|
3334
|
-
|
|
3335
|
-
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
3336
|
-
aria-label="Zoom level" hidden>
|
|
3337
|
-
<li class="dropdown-item" role="option" tabindex="-1"
|
|
3338
|
-
data-value="fit">Fit width</li>
|
|
3339
|
-
${ee.map((e) => `
|
|
3340
|
-
<li class="dropdown-item" role="option" tabindex="-1"
|
|
3341
|
-
data-value="${e}"${e === 1 ? " data-selected=\"true\"" : ""}
|
|
3342
|
-
>${Math.round(e * 100)}%</li>`).join("")}
|
|
3343
|
-
</ul>
|
|
3344
|
-
</div>
|
|
3345
|
-
|
|
3346
|
-
<button type="button" class="dz-tool" data-role="zoom-in"
|
|
3347
|
-
data-action="zoom-in"
|
|
3348
|
-
title="Zoom in (Z)" aria-label="Zoom in">+</button>
|
|
3349
|
-
</div>
|
|
3350
|
-
</header>
|
|
3351
|
-
|
|
3352
|
-
<div class="dz-body">
|
|
3353
|
-
<div class="dz-main">
|
|
3354
|
-
<div class="dz-canvas" data-role="canvas">
|
|
3355
|
-
<!--
|
|
3356
|
-
Two boxes for one job. The inner one is scaled, and a
|
|
3357
|
-
transform changes nothing about layout - so at 200% there
|
|
3358
|
-
would be nothing to scroll. The outer one is given the
|
|
3359
|
-
scaled size in px, and is what the canvas scrolls.
|
|
3360
|
-
-->
|
|
3361
|
-
<div class="dz-stage" data-role="stage">
|
|
3362
|
-
<div class="dz-zoom-layer" data-role="zoom-layer"></div>
|
|
3363
|
-
</div>
|
|
3364
|
-
</div>
|
|
3365
|
-
|
|
3366
|
-
<!--
|
|
3367
|
-
The tools sit under the page rather than in the bar: the bar is
|
|
3368
|
-
about the report as a whole, and these act on the band you are
|
|
3369
|
-
looking at. Icon-only, so the strip stays out of the way of the
|
|
3370
|
-
thing being designed - the label lives on the button for a
|
|
3371
|
-
screen reader and in the tooltip for everyone else.
|
|
3372
|
-
-->
|
|
3373
|
-
<footer class="dz-foot" data-role="foot">
|
|
3374
|
-
<button type="button" class="dz-tool" data-action="add-text"
|
|
3375
|
-
title="Add a text box" aria-label="Add a text box"
|
|
3376
|
-
>${Q("text")}</button>
|
|
3377
|
-
<button type="button" class="dz-tool" data-role="add-table"
|
|
3378
|
-
data-action="add-table"
|
|
3379
|
-
title="Add a table" aria-label="Add a table"
|
|
3380
|
-
>${Q("table")}</button>
|
|
3381
|
-
<button type="button" class="dz-tool" data-action="add-line"
|
|
3382
|
-
title="Add a line" aria-label="Add a line"
|
|
3383
|
-
>${Q("line")}</button>
|
|
3384
|
-
<button type="button" class="dz-tool" data-action="add-box"
|
|
3385
|
-
title="Add a box" aria-label="Add a box"
|
|
3386
|
-
>${Q("box")}</button>
|
|
3387
|
-
<button type="button" class="dz-tool" data-action="add-image"
|
|
3388
|
-
title="Add an image" aria-label="Add an image"
|
|
3389
|
-
>${Q("image")}</button>
|
|
3390
|
-
<button type="button" class="dz-tool" data-action="add-field"
|
|
3391
|
-
title="Insert a page number, date or total"
|
|
3392
|
-
aria-label="Insert a field"
|
|
3393
|
-
>${Q("field")}</button>
|
|
3394
|
-
</footer>
|
|
3395
|
-
|
|
3396
|
-
<!--
|
|
3397
|
-
The corner messages, in the page area rather than the window.
|
|
3398
|
-
Pinned to the window they would hang over the properties rail -
|
|
3399
|
-
which is where the band switches are, and so where most of what
|
|
3400
|
-
the validator complains about is actually fixed.
|
|
3401
|
-
-->
|
|
3402
|
-
<div class="dz-toasts" data-role="toasts"></div>
|
|
3403
|
-
</div>
|
|
3404
|
-
|
|
3405
|
-
<aside class="dz-panel" data-role="panel" aria-label="Properties"></aside>
|
|
3406
|
-
</div>`;
|
|
3407
|
-
}
|
|
3408
|
-
function dr(e) {
|
|
3409
|
-
let t = String(e);
|
|
3410
|
-
return globalThis.CSS?.escape ? CSS.escape(t) : JSON.stringify(t).slice(1, -1);
|
|
3411
|
-
}
|
|
3412
|
-
function fr(e) {
|
|
3413
|
-
return e == null ? "" : String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3414
|
-
}
|
|
3415
|
-
//#endregion
|
|
3416
|
-
export { cr as n, lr as t };
|