report-studio 1.2.0 → 1.2.2
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 +38 -2
- package/dist/{designer-qy59eEux.js → designer-DQlfKnTr.js} +928 -928
- package/dist/designer.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react-designer.js +1 -1
- package/dist/react.js +2 -1
- package/dist/viewer-BSPNCNRU.js +2912 -0
- package/package.json +1 -1
- package/src/designer/index.html +1 -1
- package/src/designer/styles.css +31 -8
- package/src/engine/csv.js +12 -197
- package/src/engine/index.js +1 -0
- package/src/engine/rows.js +456 -0
- package/src/engine/xlsx-drawing.js +313 -0
- package/src/engine/xlsx-style.js +457 -0
- package/src/engine/xlsx.js +1200 -0
- package/src/engine/zip.js +138 -0
- package/src/index.html +1 -1
- package/src/index.js +5 -1
- package/src/preview/chrome.css +75 -12
- package/src/preview/chrome.js +69 -55
- package/src/preview/index.html +1 -1
- package/src/preview/viewer.js +42 -1
- package/src/react/index.js +3 -3
- package/src/shared/brand.css +3 -1
- package/src/shared/theme.css +15 -3
- package/types/index.d.ts +53 -0
- package/dist/viewer-xa17tyMJ.js +0 -1721
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as e,
|
|
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
2
|
//#region src/designer/fields.js
|
|
3
|
-
var
|
|
3
|
+
var y = [
|
|
4
4
|
{
|
|
5
5
|
label: "Helvetica",
|
|
6
6
|
value: "Helvetica, Arial, sans-serif"
|
|
@@ -29,19 +29,19 @@ var x = [
|
|
|
29
29
|
label: "Courier",
|
|
30
30
|
value: "\"Courier New\", Courier, monospace"
|
|
31
31
|
}
|
|
32
|
-
],
|
|
32
|
+
], re = [{
|
|
33
33
|
label: "Regular",
|
|
34
34
|
value: "normal"
|
|
35
35
|
}, {
|
|
36
36
|
label: "Bold",
|
|
37
37
|
value: "bold"
|
|
38
|
-
}],
|
|
38
|
+
}], ie = [{
|
|
39
39
|
label: "Upright",
|
|
40
40
|
value: "normal"
|
|
41
41
|
}, {
|
|
42
42
|
label: "Italic",
|
|
43
43
|
value: "italic"
|
|
44
|
-
}],
|
|
44
|
+
}], b = [
|
|
45
45
|
{
|
|
46
46
|
label: "Left",
|
|
47
47
|
value: "left"
|
|
@@ -54,7 +54,7 @@ var x = [
|
|
|
54
54
|
label: "Right",
|
|
55
55
|
value: "right"
|
|
56
56
|
}
|
|
57
|
-
],
|
|
57
|
+
], x = [
|
|
58
58
|
{
|
|
59
59
|
label: "Fit inside",
|
|
60
60
|
value: "contain"
|
|
@@ -67,13 +67,13 @@ var x = [
|
|
|
67
67
|
label: "Stretch",
|
|
68
68
|
value: "fill"
|
|
69
69
|
}
|
|
70
|
-
],
|
|
70
|
+
], S = [{
|
|
71
71
|
label: "Horizontal",
|
|
72
72
|
value: "horizontal"
|
|
73
73
|
}, {
|
|
74
74
|
label: "Vertical",
|
|
75
75
|
value: "vertical"
|
|
76
|
-
}],
|
|
76
|
+
}], C = [
|
|
77
77
|
{
|
|
78
78
|
label: "Solid",
|
|
79
79
|
value: "solid"
|
|
@@ -90,20 +90,20 @@ var x = [
|
|
|
90
90
|
label: "Double",
|
|
91
91
|
value: "double"
|
|
92
92
|
}
|
|
93
|
-
],
|
|
93
|
+
], w = [...C, {
|
|
94
94
|
label: "None",
|
|
95
95
|
value: "none"
|
|
96
|
-
}],
|
|
96
|
+
}], T = (e, t, n = {}) => ({
|
|
97
97
|
key: e,
|
|
98
98
|
label: t,
|
|
99
99
|
type: "number",
|
|
100
100
|
...n
|
|
101
101
|
});
|
|
102
|
-
function
|
|
102
|
+
function E(e) {
|
|
103
103
|
let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
|
|
104
104
|
return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
|
|
105
105
|
}
|
|
106
|
-
var
|
|
106
|
+
var D = [
|
|
107
107
|
{
|
|
108
108
|
key: "field",
|
|
109
109
|
label: "Field",
|
|
@@ -124,18 +124,18 @@ var A = [
|
|
|
124
124
|
key: "align",
|
|
125
125
|
label: "Align",
|
|
126
126
|
type: "choice",
|
|
127
|
-
options:
|
|
127
|
+
options: b
|
|
128
128
|
}
|
|
129
129
|
];
|
|
130
|
-
function
|
|
130
|
+
function ae(e) {
|
|
131
131
|
if (!e) return [];
|
|
132
132
|
let t = {
|
|
133
133
|
title: "Position and size",
|
|
134
134
|
fields: [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
...e.type === "table" ? [] : [
|
|
135
|
+
T("x", "X"),
|
|
136
|
+
T("y", "Y"),
|
|
137
|
+
T("w", "Width", { min: 1 }),
|
|
138
|
+
...e.type === "table" ? [] : [T("h", "Height", { min: 1 })]
|
|
139
139
|
]
|
|
140
140
|
};
|
|
141
141
|
return e.type === "box" ? [
|
|
@@ -147,15 +147,15 @@ function ne(e) {
|
|
|
147
147
|
key: "style.borderStyle",
|
|
148
148
|
label: "Style",
|
|
149
149
|
type: "choice",
|
|
150
|
-
options:
|
|
150
|
+
options: w
|
|
151
151
|
},
|
|
152
|
-
|
|
152
|
+
T("style.borderWidth", "Width", { min: 1 }),
|
|
153
153
|
{
|
|
154
154
|
key: "style.borderColor",
|
|
155
155
|
label: "Colour",
|
|
156
156
|
type: "color"
|
|
157
157
|
},
|
|
158
|
-
|
|
158
|
+
T("style.radius", "Corner", { min: 0 })
|
|
159
159
|
]
|
|
160
160
|
},
|
|
161
161
|
{
|
|
@@ -187,7 +187,7 @@ function ne(e) {
|
|
|
187
187
|
key: "fit",
|
|
188
188
|
label: "Fit",
|
|
189
189
|
type: "choice",
|
|
190
|
-
options:
|
|
190
|
+
options: x
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
key: "alt",
|
|
@@ -203,14 +203,14 @@ function ne(e) {
|
|
|
203
203
|
key: "orientation",
|
|
204
204
|
label: "Runs",
|
|
205
205
|
type: "choice",
|
|
206
|
-
options:
|
|
206
|
+
options: S
|
|
207
207
|
},
|
|
208
|
-
|
|
208
|
+
T("style.thickness", "Thickness", { min: 1 }),
|
|
209
209
|
{
|
|
210
210
|
key: "style.lineStyle",
|
|
211
211
|
label: "Style",
|
|
212
212
|
type: "choice",
|
|
213
|
-
options:
|
|
213
|
+
options: C
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
216
|
key: "style.color",
|
|
@@ -238,7 +238,7 @@ function ne(e) {
|
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
title: "Rows",
|
|
241
|
-
fields: [
|
|
241
|
+
fields: [T("rowHeight", "Row height", { min: 1 })]
|
|
242
242
|
},
|
|
243
243
|
{
|
|
244
244
|
title: "Header",
|
|
@@ -248,7 +248,7 @@ function ne(e) {
|
|
|
248
248
|
label: "Show header",
|
|
249
249
|
type: "toggle"
|
|
250
250
|
},
|
|
251
|
-
|
|
251
|
+
T("headerHeight", "Height", { min: 1 }),
|
|
252
252
|
{
|
|
253
253
|
key: "style.headerBackground",
|
|
254
254
|
label: "Fill",
|
|
@@ -269,9 +269,9 @@ function ne(e) {
|
|
|
269
269
|
key: "style.fontFamily",
|
|
270
270
|
label: "Font",
|
|
271
271
|
type: "choice",
|
|
272
|
-
options:
|
|
272
|
+
options: y
|
|
273
273
|
},
|
|
274
|
-
|
|
274
|
+
T("style.fontSize", "Font size", { min: 1 }),
|
|
275
275
|
{
|
|
276
276
|
key: "style.color",
|
|
277
277
|
label: "Text",
|
|
@@ -287,11 +287,11 @@ function ne(e) {
|
|
|
287
287
|
key: "style.borderStyle",
|
|
288
288
|
label: "Borders",
|
|
289
289
|
type: "choice",
|
|
290
|
-
options:
|
|
290
|
+
options: w
|
|
291
291
|
},
|
|
292
|
-
|
|
292
|
+
T("style.borderWidth", "Border width", {
|
|
293
293
|
min: 1,
|
|
294
|
-
max:
|
|
294
|
+
max: E(e)
|
|
295
295
|
}),
|
|
296
296
|
{
|
|
297
297
|
key: "style.borderColor",
|
|
@@ -318,26 +318,26 @@ function ne(e) {
|
|
|
318
318
|
key: "style.fontFamily",
|
|
319
319
|
label: "Font",
|
|
320
320
|
type: "choice",
|
|
321
|
-
options:
|
|
321
|
+
options: y
|
|
322
322
|
},
|
|
323
|
-
|
|
323
|
+
T("style.fontSize", "Size", { min: 1 }),
|
|
324
324
|
{
|
|
325
325
|
key: "style.fontWeight",
|
|
326
326
|
label: "Weight",
|
|
327
327
|
type: "choice",
|
|
328
|
-
options:
|
|
328
|
+
options: re
|
|
329
329
|
},
|
|
330
330
|
{
|
|
331
331
|
key: "style.fontStyle",
|
|
332
332
|
label: "Style",
|
|
333
333
|
type: "choice",
|
|
334
|
-
options:
|
|
334
|
+
options: ie
|
|
335
335
|
},
|
|
336
336
|
{
|
|
337
337
|
key: "style.align",
|
|
338
338
|
label: "Align",
|
|
339
339
|
type: "choice",
|
|
340
|
-
options:
|
|
340
|
+
options: b
|
|
341
341
|
},
|
|
342
342
|
{
|
|
343
343
|
key: "style.color",
|
|
@@ -348,7 +348,7 @@ function ne(e) {
|
|
|
348
348
|
}
|
|
349
349
|
];
|
|
350
350
|
}
|
|
351
|
-
var
|
|
351
|
+
var O = [
|
|
352
352
|
{
|
|
353
353
|
label: "A2",
|
|
354
354
|
width: 1587,
|
|
@@ -389,46 +389,46 @@ var j = [
|
|
|
389
389
|
width: 1056,
|
|
390
390
|
height: 1632
|
|
391
391
|
}
|
|
392
|
-
],
|
|
393
|
-
function
|
|
394
|
-
if (e?.paper === "custom") return
|
|
395
|
-
let t = e?.width, n = e?.height, r =
|
|
396
|
-
return r ? r.label :
|
|
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
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function j(e) {
|
|
399
399
|
return (e?.width ?? 0) > (e?.height ?? 0) ? "landscape" : "portrait";
|
|
400
400
|
}
|
|
401
|
-
function
|
|
402
|
-
let n =
|
|
403
|
-
if (!n) return e.page.paper === "custom" ? !1 : (e.page.paper =
|
|
404
|
-
let r =
|
|
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
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
406
|
}
|
|
407
|
-
function
|
|
408
|
-
if (t === "landscape" == (
|
|
407
|
+
function se(e, t) {
|
|
408
|
+
if (t === "landscape" == (j(e.page) === "landscape")) return !1;
|
|
409
409
|
let { width: n, height: r } = e.page;
|
|
410
410
|
return e.page.width = r, e.page.height = n, !0;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
let t =
|
|
412
|
+
function M(e) {
|
|
413
|
+
let t = A(e.page) === k, n = {
|
|
414
414
|
key: "paper",
|
|
415
415
|
label: "Paper",
|
|
416
416
|
type: "choice",
|
|
417
417
|
rebuilds: !0,
|
|
418
|
-
options: [...
|
|
418
|
+
options: [...O.map((e) => ({
|
|
419
419
|
value: e.label,
|
|
420
420
|
label: `${e.label} ${e.width} x ${e.height}`
|
|
421
421
|
})), {
|
|
422
|
-
value:
|
|
422
|
+
value: k,
|
|
423
423
|
label: "Custom"
|
|
424
424
|
}],
|
|
425
|
-
read: (e) =>
|
|
426
|
-
write: (e, t) =>
|
|
425
|
+
read: (e) => A(e.page),
|
|
426
|
+
write: (e, t) => oe(e, t)
|
|
427
427
|
};
|
|
428
428
|
return t ? [
|
|
429
429
|
n,
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
T("page.width", "Width", { min: 1 }),
|
|
431
|
+
T("page.height", "Height", { min: 1 })
|
|
432
432
|
] : [n, {
|
|
433
433
|
key: "orientation",
|
|
434
434
|
label: "Orientation",
|
|
@@ -441,11 +441,11 @@ function F(e) {
|
|
|
441
441
|
value: "landscape",
|
|
442
442
|
label: "Landscape"
|
|
443
443
|
}],
|
|
444
|
-
read: (e) =>
|
|
445
|
-
write: (e, t) =>
|
|
444
|
+
read: (e) => j(e.page),
|
|
445
|
+
write: (e, t) => se(e, t)
|
|
446
446
|
}];
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
function N(e) {
|
|
449
449
|
return e ? [
|
|
450
450
|
{
|
|
451
451
|
title: "Report",
|
|
@@ -473,46 +473,46 @@ function I(e) {
|
|
|
473
473
|
},
|
|
474
474
|
{
|
|
475
475
|
title: "Page",
|
|
476
|
-
fields:
|
|
476
|
+
fields: M(e)
|
|
477
477
|
},
|
|
478
478
|
{
|
|
479
479
|
title: "Margins",
|
|
480
480
|
fields: [
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
485
|
]
|
|
486
486
|
}
|
|
487
487
|
] : [];
|
|
488
488
|
}
|
|
489
|
-
function
|
|
490
|
-
return
|
|
489
|
+
function ce(e) {
|
|
490
|
+
return N(e).flatMap((e) => e.fields);
|
|
491
491
|
}
|
|
492
|
-
function
|
|
493
|
-
return
|
|
492
|
+
function le(e) {
|
|
493
|
+
return ae(e).flatMap((e) => e.fields);
|
|
494
494
|
}
|
|
495
|
-
function
|
|
495
|
+
function P(e) {
|
|
496
496
|
return e.split(".");
|
|
497
497
|
}
|
|
498
|
-
function
|
|
498
|
+
function F(e, t) {
|
|
499
499
|
if (t.read) return t.read(e);
|
|
500
500
|
let n = e;
|
|
501
|
-
for (let e of
|
|
501
|
+
for (let e of P(t.key)) {
|
|
502
502
|
if (n == null) return;
|
|
503
503
|
n = n[e];
|
|
504
504
|
}
|
|
505
505
|
return n;
|
|
506
506
|
}
|
|
507
|
-
function
|
|
508
|
-
let r =
|
|
507
|
+
function ue(e, t, n) {
|
|
508
|
+
let r = de(t, n);
|
|
509
509
|
if (r === void 0) return !1;
|
|
510
510
|
if (t.write) return t.write(e, r);
|
|
511
|
-
let i =
|
|
511
|
+
let i = P(t.key), a = i.pop(), o = e;
|
|
512
512
|
for (let e of i) (o[e] == null || typeof o[e] != "object") && (o[e] = {}), o = o[e];
|
|
513
513
|
return o[a] === r ? !1 : (o[a] = r, !0);
|
|
514
514
|
}
|
|
515
|
-
function
|
|
515
|
+
function de(e, t) {
|
|
516
516
|
if (e.type === "toggle") return !!t;
|
|
517
517
|
if (e.type === "number") {
|
|
518
518
|
if (t === "" || t == null) return;
|
|
@@ -525,7 +525,7 @@ function ce(e, t) {
|
|
|
525
525
|
}
|
|
526
526
|
//#endregion
|
|
527
527
|
//#region src/designer/blank.js
|
|
528
|
-
function
|
|
528
|
+
function fe() {
|
|
529
529
|
return {
|
|
530
530
|
version: 1,
|
|
531
531
|
name: "Untitled report",
|
|
@@ -559,10 +559,10 @@ function le() {
|
|
|
559
559
|
]
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function pe(e) {
|
|
563
563
|
return e == null ? !0 : typeof e != "object" || Array.isArray(e) ? !1 : Object.keys(e).length === 0;
|
|
564
564
|
}
|
|
565
|
-
var
|
|
565
|
+
var me = 3, he = [
|
|
566
566
|
"nw",
|
|
567
567
|
"n",
|
|
568
568
|
"ne",
|
|
@@ -571,31 +571,31 @@ var de = 3, fe = [
|
|
|
571
571
|
"s",
|
|
572
572
|
"sw",
|
|
573
573
|
"w"
|
|
574
|
-
],
|
|
575
|
-
function
|
|
574
|
+
], ge = ["e", "w"];
|
|
575
|
+
function _e(e) {
|
|
576
576
|
return Math.round(e / 10) * 10;
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function I(e) {
|
|
579
579
|
return {
|
|
580
|
-
x:
|
|
581
|
-
y:
|
|
582
|
-
w:
|
|
583
|
-
h: e
|
|
580
|
+
x: e.x ?? 0,
|
|
581
|
+
y: e.y ?? 0,
|
|
582
|
+
w: e.w ?? 0,
|
|
583
|
+
h: o(e)
|
|
584
584
|
};
|
|
585
585
|
}
|
|
586
|
-
function
|
|
586
|
+
function L(e) {
|
|
587
587
|
return e.type === "table" ? "x" : "xy";
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
return e === "x" ? [...
|
|
589
|
+
function R(e) {
|
|
590
|
+
return e === "x" ? [...ge] : [...he];
|
|
591
591
|
}
|
|
592
|
-
function
|
|
592
|
+
function z(e, t, n) {
|
|
593
593
|
return {
|
|
594
|
-
x:
|
|
595
|
-
y:
|
|
594
|
+
x: _e(e.x + t),
|
|
595
|
+
y: _e(e.y + n)
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
|
-
function
|
|
598
|
+
function ve(e, t, n, r, i = "xy") {
|
|
599
599
|
let { x: a, y: o, w: s, h: c } = t;
|
|
600
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
601
|
x: a,
|
|
@@ -604,10 +604,10 @@ function he(e, t, n, r, i = "xy") {
|
|
|
604
604
|
h: c
|
|
605
605
|
};
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function ye(e, t) {
|
|
608
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
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function be(e, { minor: t = 10, major: n = 50 } = {}) {
|
|
611
611
|
let r = [];
|
|
612
612
|
if (!(e > 0) || !(t > 0)) return r;
|
|
613
613
|
for (let i = 0; i <= e; i += t) r.push({
|
|
@@ -620,17 +620,17 @@ function _e(e, { minor: t = 10, major: n = 50 } = {}) {
|
|
|
620
620
|
major: !0
|
|
621
621
|
}), r;
|
|
622
622
|
}
|
|
623
|
-
function
|
|
624
|
-
let t = e?.guides, n = (e) => (Array.isArray(e) ? e : []).filter(
|
|
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
625
|
return {
|
|
626
626
|
x: n(t?.x),
|
|
627
627
|
y: n(t?.y)
|
|
628
628
|
};
|
|
629
629
|
}
|
|
630
|
-
function
|
|
630
|
+
function xe(e) {
|
|
631
631
|
return typeof e == "number" || typeof e == "string" && e.trim() !== "";
|
|
632
632
|
}
|
|
633
|
-
function
|
|
633
|
+
function V(e) {
|
|
634
634
|
(!e.guides || typeof e.guides != "object") && (e.guides = {
|
|
635
635
|
x: [],
|
|
636
636
|
y: []
|
|
@@ -638,30 +638,30 @@ function W(e) {
|
|
|
638
638
|
for (let t of ["x", "y"]) Array.isArray(e.guides[t]) || (e.guides[t] = []);
|
|
639
639
|
return e.guides;
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
if (!
|
|
641
|
+
function Se(e, t, n) {
|
|
642
|
+
if (!xe(n)) return null;
|
|
643
643
|
let r = Math.round(Number(n));
|
|
644
644
|
if (!Number.isFinite(r)) return null;
|
|
645
|
-
let i =
|
|
645
|
+
let i = V(e);
|
|
646
646
|
return i[t].includes(r) || (i[t].push(r), i[t].sort((e, t) => e - t)), r;
|
|
647
647
|
}
|
|
648
|
-
function
|
|
649
|
-
let r =
|
|
648
|
+
function Ce(e, t, n) {
|
|
649
|
+
let r = V(e), i = r[t].indexOf(Math.round(Number(n)));
|
|
650
650
|
return i === -1 ? !1 : (r[t].splice(i, 1), !0);
|
|
651
651
|
}
|
|
652
|
-
function
|
|
653
|
-
return
|
|
652
|
+
function we(e, t, n, r) {
|
|
653
|
+
return Ce(e, t, n), Se(e, t, r);
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function Te(e, t, n, r = 4) {
|
|
656
656
|
let i = null;
|
|
657
|
-
for (let a of
|
|
657
|
+
for (let a of B(e)[t]) {
|
|
658
658
|
let e = Math.abs(a - n);
|
|
659
659
|
e <= r && (i === null || e < Math.abs(i - n)) && (i = a);
|
|
660
660
|
}
|
|
661
661
|
return i;
|
|
662
662
|
}
|
|
663
|
-
function
|
|
664
|
-
let n =
|
|
663
|
+
function Ee(e, t) {
|
|
664
|
+
let n = B(e);
|
|
665
665
|
return t ? {
|
|
666
666
|
x: n.x,
|
|
667
667
|
y: n.y.map((e) => e - (t.originY ?? 0)).filter((e) => e >= 0 && e <= (t.h ?? 0))
|
|
@@ -672,74 +672,74 @@ function Ce(e, t) {
|
|
|
672
672
|
}
|
|
673
673
|
//#endregion
|
|
674
674
|
//#region src/designer/canvas.js
|
|
675
|
-
var
|
|
675
|
+
var De = [
|
|
676
676
|
"pageHeader",
|
|
677
677
|
"reportHeader",
|
|
678
678
|
"reportFooter",
|
|
679
679
|
"pageFooter"
|
|
680
680
|
];
|
|
681
|
-
function
|
|
682
|
-
return Array.from({ length:
|
|
681
|
+
function Oe(e) {
|
|
682
|
+
return Array.from({ length: me }, () => Object.fromEntries((e || []).map((e) => [e.field, e.field])));
|
|
683
683
|
}
|
|
684
|
-
function
|
|
685
|
-
return
|
|
686
|
-
...
|
|
687
|
-
text:
|
|
688
|
-
} :
|
|
689
|
-
...
|
|
690
|
-
row:
|
|
691
|
-
measuredHeight: e
|
|
692
|
-
} :
|
|
693
|
-
}
|
|
694
|
-
function
|
|
695
|
-
let { page: t } = e,
|
|
696
|
-
bands:
|
|
697
|
-
contentHeight:
|
|
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
698
|
isFirstPage: !0,
|
|
699
699
|
isLastPage: !0
|
|
700
700
|
}), o = [];
|
|
701
|
-
for (let e of
|
|
702
|
-
let t =
|
|
703
|
-
t &&
|
|
701
|
+
for (let e of De) {
|
|
702
|
+
let t = a[e];
|
|
703
|
+
t && i[e] && o.push({
|
|
704
704
|
type: e,
|
|
705
705
|
...t,
|
|
706
|
-
band:
|
|
706
|
+
band: i[e]
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
|
-
let
|
|
710
|
-
return
|
|
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
711
|
type: "groupHeader",
|
|
712
|
-
top:
|
|
713
|
-
height: u,
|
|
714
|
-
band: c
|
|
715
|
-
}), r.detail && o.push({
|
|
716
|
-
type: "detail",
|
|
717
|
-
top: s.top + u,
|
|
718
|
-
height: Math.max(s.height - u - d, 0),
|
|
719
|
-
band: r.detail
|
|
720
|
-
}), l && o.push({
|
|
721
|
-
type: "groupFooter",
|
|
722
|
-
top: s.top + s.height - d,
|
|
712
|
+
top: c.top,
|
|
723
713
|
height: d,
|
|
724
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
725
|
}), o;
|
|
726
726
|
}
|
|
727
|
-
function
|
|
728
|
-
let n = [...e.band.items || []].sort((e, t) => (e.y ?? 0) - (t.y ?? 0)).map(
|
|
727
|
+
function ke(e, t) {
|
|
728
|
+
let n = [...e.band.items || []].sort((e, t) => (e.y ?? 0) - (t.y ?? 0)).map(H);
|
|
729
729
|
return `
|
|
730
|
-
<div class="band dz-zone" data-band-type="${
|
|
730
|
+
<div class="band dz-zone" data-band-type="${p(e.type)}"
|
|
731
731
|
style="position:absolute;top:${e.top + t.top}px;left:${t.left}px;right:${t.right}px;height:${e.height}px">
|
|
732
|
-
${
|
|
732
|
+
${l(n)}
|
|
733
733
|
</div>`;
|
|
734
734
|
}
|
|
735
|
-
function
|
|
736
|
-
|
|
737
|
-
let n = (e, t) =>
|
|
735
|
+
function W(e, t) {
|
|
736
|
+
B(e);
|
|
737
|
+
let n = (e, t) => be(e).map((e) => `
|
|
738
738
|
<span class="dz-tick${e.major ? " is-major" : ""}"
|
|
739
739
|
style="${t === "x" ? "left" : "top"}:${e.at}px"
|
|
740
740
|
>${e.major ? `<i>${e.at}</i>` : ""}</span>`).join(""), r = (t) => `
|
|
741
741
|
<span class="dz-ruler-guides" data-role="ruler-guides"
|
|
742
|
-
data-axis="${t}">${
|
|
742
|
+
data-axis="${t}">${Ae(e, t)}</span>`;
|
|
743
743
|
return `
|
|
744
744
|
<div class="dz-ruler-corner" data-role="ruler-corner"></div>
|
|
745
745
|
|
|
@@ -753,30 +753,30 @@ function q(e, t) {
|
|
|
753
753
|
${n(t.h, "y")}${r("y")}
|
|
754
754
|
</div>`;
|
|
755
755
|
}
|
|
756
|
-
function
|
|
757
|
-
return
|
|
756
|
+
function Ae(e, t) {
|
|
757
|
+
return B(e)[t].map((e) => `
|
|
758
758
|
<span class="dz-ruler-guide"
|
|
759
759
|
style="${t === "x" ? "left" : "top"}:${e}px"></span>`).join("");
|
|
760
760
|
}
|
|
761
|
-
function
|
|
762
|
-
let t = e.page.margin, n =
|
|
761
|
+
function je(e) {
|
|
762
|
+
let t = e.page.margin, n = B(e), r = n.x.map((e) => `
|
|
763
763
|
<span class="dz-rule dz-rule-v" data-role="guide" data-axis="x"
|
|
764
764
|
data-at="${e}" style="left:${e + t.left}px"></span>`), i = n.y.map((e) => `
|
|
765
765
|
<span class="dz-rule dz-rule-h" data-role="guide" data-axis="y"
|
|
766
766
|
data-at="${e}" style="top:${e + t.top}px"></span>`);
|
|
767
767
|
return [...r, ...i].join("");
|
|
768
768
|
}
|
|
769
|
-
function
|
|
770
|
-
return `<span class="dz-tag" data-band-tag="${
|
|
771
|
-
style="top:${e.top + t.top}px">${
|
|
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
772
|
}
|
|
773
|
-
function
|
|
773
|
+
function Ne(e, t) {
|
|
774
774
|
if (!t) return null;
|
|
775
|
-
let n = e.page.margin, r =
|
|
775
|
+
let n = e.page.margin, r = U(e).find((e) => e.type === t.band);
|
|
776
776
|
if (!r) return null;
|
|
777
777
|
let i = (r.band.items || []).find((e) => e.id === t.id);
|
|
778
778
|
if (!i) return null;
|
|
779
|
-
let a =
|
|
779
|
+
let a = I(i);
|
|
780
780
|
return {
|
|
781
781
|
item: i,
|
|
782
782
|
box: {
|
|
@@ -786,20 +786,20 @@ function Ae(e, t) {
|
|
|
786
786
|
}
|
|
787
787
|
};
|
|
788
788
|
}
|
|
789
|
-
function
|
|
790
|
-
let { box: r, item: i } = e, a = t ?
|
|
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
791
|
return `
|
|
792
792
|
<div class="dz-select${n ? "" : " is-secondary"}" data-role="select"
|
|
793
|
-
data-select-id="${
|
|
793
|
+
data-select-id="${p(i.id)}"
|
|
794
794
|
style="top:${r.y}px;left:${r.x}px;width:${r.w}px;height:${r.h}px">
|
|
795
795
|
${a}
|
|
796
796
|
</div>`;
|
|
797
797
|
}
|
|
798
|
-
function
|
|
799
|
-
return (t || []).map((t) =>
|
|
798
|
+
function Pe(e, t) {
|
|
799
|
+
return (t || []).map((t) => Ne(e, t)).filter(Boolean);
|
|
800
800
|
}
|
|
801
|
-
function
|
|
802
|
-
let { page: r } = e, i = r.margin, a =
|
|
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
803
|
w: r.width - i.left - i.right,
|
|
804
804
|
h: r.height - i.top - i.bottom
|
|
805
805
|
};
|
|
@@ -807,15 +807,15 @@ function Me(e, t = null, { rulers: n = !1 } = {}) {
|
|
|
807
807
|
<div class="dz-sheet${n ? " has-rulers" : ""}"
|
|
808
808
|
style="--page-height:${r.height}px;--dz-margin-left:${i.left}px;
|
|
809
809
|
--dz-margin-top:${i.top}px">
|
|
810
|
-
${n ?
|
|
810
|
+
${n ? W(e, c) : ""}
|
|
811
811
|
<div class="dz-gutter">
|
|
812
|
-
${a.map((e) =>
|
|
812
|
+
${a.map((e) => Me(e, i)).join("")}
|
|
813
813
|
</div>
|
|
814
814
|
<div class="page dz-page" style="${s}">
|
|
815
815
|
<div class="dz-rules" data-role="rules"
|
|
816
|
-
>${n ?
|
|
817
|
-
${a.map((e) =>
|
|
818
|
-
${o.map((e, t) =>
|
|
816
|
+
>${n ? je(e) : ""}</div>
|
|
817
|
+
${a.map((e) => ke(e, i)).join("")}
|
|
818
|
+
${o.map((e, t) => G(e, {
|
|
819
819
|
withHandles: o.length === 1,
|
|
820
820
|
primary: t === o.length - 1
|
|
821
821
|
})).join("")}
|
|
@@ -823,8 +823,8 @@ function Me(e, t = null, { rulers: n = !1 } = {}) {
|
|
|
823
823
|
</div>
|
|
824
824
|
</div>`;
|
|
825
825
|
}
|
|
826
|
-
function
|
|
827
|
-
let n =
|
|
826
|
+
function Ie(e, t) {
|
|
827
|
+
let n = U(e).find((e) => e.type === t);
|
|
828
828
|
if (!n) return null;
|
|
829
829
|
let r = e.page.margin;
|
|
830
830
|
return {
|
|
@@ -836,7 +836,7 @@ function Ne(e, t) {
|
|
|
836
836
|
originY: n.top
|
|
837
837
|
};
|
|
838
838
|
}
|
|
839
|
-
function
|
|
839
|
+
function Le(e, t = [], n = []) {
|
|
840
840
|
if (!e) return "";
|
|
841
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
842
|
style="left:${r(e.at)}px;top:${i(e.from)}px;
|
|
@@ -852,23 +852,23 @@ function Pe(e, t = [], n = []) {
|
|
|
852
852
|
});
|
|
853
853
|
return [...a, ...o].join("");
|
|
854
854
|
}
|
|
855
|
-
function
|
|
856
|
-
let r =
|
|
855
|
+
function Re(e, t, n) {
|
|
856
|
+
let r = U(e).find((e) => e.type === t);
|
|
857
857
|
return r ? r.top + n : null;
|
|
858
858
|
}
|
|
859
|
-
function
|
|
860
|
-
let n =
|
|
859
|
+
function ze(e, t) {
|
|
860
|
+
let n = U(e);
|
|
861
861
|
if (!n.length) return null;
|
|
862
862
|
let r = [...n].sort((e, t) => e.top - t.top);
|
|
863
863
|
for (let e of r) if (t >= e.top && t < e.top + e.height) return e.type;
|
|
864
864
|
return t < r[0].top ? r[0].type : r.at(-1).type;
|
|
865
865
|
}
|
|
866
|
-
function
|
|
867
|
-
let r =
|
|
868
|
-
return r === null ? null :
|
|
866
|
+
function Be(e, t, n) {
|
|
867
|
+
let r = Re(e, t, n?.y ?? 0);
|
|
868
|
+
return r === null ? null : ze(e, r);
|
|
869
869
|
}
|
|
870
|
-
var
|
|
871
|
-
function
|
|
870
|
+
var Ve = .01;
|
|
871
|
+
function He(e) {
|
|
872
872
|
return [
|
|
873
873
|
{
|
|
874
874
|
at: e.x,
|
|
@@ -884,7 +884,7 @@ function ze(e) {
|
|
|
884
884
|
}
|
|
885
885
|
];
|
|
886
886
|
}
|
|
887
|
-
function
|
|
887
|
+
function Ue(e) {
|
|
888
888
|
return [
|
|
889
889
|
{
|
|
890
890
|
at: e.y,
|
|
@@ -900,7 +900,7 @@ function Be(e) {
|
|
|
900
900
|
}
|
|
901
901
|
];
|
|
902
902
|
}
|
|
903
|
-
function
|
|
903
|
+
function We(e) {
|
|
904
904
|
if (!e?.length) return null;
|
|
905
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
906
|
return {
|
|
@@ -910,8 +910,8 @@ function Ve(e) {
|
|
|
910
910
|
h: i - n
|
|
911
911
|
};
|
|
912
912
|
}
|
|
913
|
-
function
|
|
914
|
-
let i = n === "x" ?
|
|
913
|
+
function Ge(e, t, n, r = []) {
|
|
914
|
+
let i = n === "x" ? He : Ue, a = (r || []).filter(Number.isFinite).map((e) => ({
|
|
915
915
|
at: e,
|
|
916
916
|
centre: !1,
|
|
917
917
|
box: null
|
|
@@ -933,19 +933,19 @@ function He(e, t, n, r = []) {
|
|
|
933
933
|
...c
|
|
934
934
|
];
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function K(e, t, n = 6) {
|
|
937
937
|
let r = null;
|
|
938
938
|
for (let i of e) for (let e of t) {
|
|
939
939
|
let t = e.at - i.at;
|
|
940
|
-
Math.abs(t) > n || (!r || Math.abs(t) < Math.abs(r.delta) -
|
|
940
|
+
Math.abs(t) > n || (!r || Math.abs(t) < Math.abs(r.delta) - Ve) && (r = {
|
|
941
941
|
delta: t,
|
|
942
942
|
at: e.at
|
|
943
943
|
});
|
|
944
944
|
}
|
|
945
945
|
return r;
|
|
946
946
|
}
|
|
947
|
-
function
|
|
948
|
-
let a = t.filter((e) => Math.abs(e.at - n) <
|
|
947
|
+
function Ke(e, t, n, r, i) {
|
|
948
|
+
let a = t.filter((e) => Math.abs(e.at - n) < Ve);
|
|
949
949
|
if (!a.length) return [];
|
|
950
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
951
|
return [{
|
|
@@ -956,13 +956,13 @@ function Ue(e, t, n, r, i) {
|
|
|
956
956
|
centre: a.every((e) => e.centre)
|
|
957
957
|
}];
|
|
958
958
|
}
|
|
959
|
-
function
|
|
959
|
+
function qe(e, t, n, { snap: r = 6, guides: i } = {}) {
|
|
960
960
|
if (!e) return {
|
|
961
961
|
dx: 0,
|
|
962
962
|
dy: 0,
|
|
963
963
|
lines: []
|
|
964
964
|
};
|
|
965
|
-
let a =
|
|
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
966
|
...e,
|
|
967
967
|
x: e.x + l,
|
|
968
968
|
y: e.y + u
|
|
@@ -970,17 +970,17 @@ function We(e, t, n, { snap: r = 6, guides: i } = {}) {
|
|
|
970
970
|
return {
|
|
971
971
|
dx: l,
|
|
972
972
|
dy: u,
|
|
973
|
-
lines: [...s ?
|
|
973
|
+
lines: [...s ? Ke(d, a, s.at, "x", n) : [], ...c ? Ke(d, o, c.at, "y", n) : []]
|
|
974
974
|
};
|
|
975
975
|
}
|
|
976
|
-
function
|
|
976
|
+
function Je(e, t, n) {
|
|
977
977
|
let [r, i] = n === "x" ? ["x", "w"] : ["y", "h"];
|
|
978
978
|
return e[r] < t[r] + (t[i] ?? 0) && e[r] + (e[i] ?? 0) > t[r];
|
|
979
979
|
}
|
|
980
|
-
function
|
|
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) =>
|
|
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
982
|
if (!(h >= 0)) return null;
|
|
983
|
-
let g = f.find((e) => Math.abs((d ? e[s] + (e[c] ?? 0) : e[s]) - m) <
|
|
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
984
|
return {
|
|
985
985
|
side: r,
|
|
986
986
|
axis: a,
|
|
@@ -991,28 +991,28 @@ function Ke(e, t, n, r) {
|
|
|
991
991
|
toBand: f.length === 0
|
|
992
992
|
};
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function Xe(e, t, n) {
|
|
995
995
|
return e ? [
|
|
996
996
|
"up",
|
|
997
997
|
"down",
|
|
998
998
|
"left",
|
|
999
999
|
"right"
|
|
1000
|
-
].map((r) =>
|
|
1000
|
+
].map((r) => Ye(e, t, n, r)).filter(Boolean) : [];
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1003
|
-
let i =
|
|
1002
|
+
function Ze(e, t, n, r = {}) {
|
|
1003
|
+
let i = We(e);
|
|
1004
1004
|
if (!i) return {
|
|
1005
1005
|
dx: 0,
|
|
1006
1006
|
dy: 0,
|
|
1007
1007
|
lines: [],
|
|
1008
1008
|
gaps: []
|
|
1009
1009
|
};
|
|
1010
|
-
let { dx: a, dy: o, lines: s } =
|
|
1010
|
+
let { dx: a, dy: o, lines: s } = qe(i, t, n, r);
|
|
1011
1011
|
return {
|
|
1012
1012
|
dx: a,
|
|
1013
1013
|
dy: o,
|
|
1014
1014
|
lines: s,
|
|
1015
|
-
gaps:
|
|
1015
|
+
gaps: Xe({
|
|
1016
1016
|
...i,
|
|
1017
1017
|
x: i.x + a,
|
|
1018
1018
|
y: i.y + o
|
|
@@ -1021,7 +1021,7 @@ function Je(e, t, n, r = {}) {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
//#endregion
|
|
1023
1023
|
//#region src/designer/select.js
|
|
1024
|
-
function
|
|
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
1025
|
let f = null, p = 0, m = !1, h = e.ownerDocument;
|
|
1026
1026
|
function g(t) {
|
|
1027
1027
|
let n = e.querySelector(".dz-page");
|
|
@@ -1045,29 +1045,29 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1045
1045
|
node: t
|
|
1046
1046
|
} : null;
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function te(e) {
|
|
1049
1049
|
return e ? ((t().bands || []).find((t) => t.type === e.band)?.items || []).find((t) => t.id === e.id) ?? null : null;
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1051
|
+
function ne(e, n) {
|
|
1052
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(
|
|
1053
|
+
return (r?.items || []).filter((e) => !i.has(e.id)).map(I);
|
|
1054
1054
|
}
|
|
1055
|
-
function
|
|
1055
|
+
function v() {
|
|
1056
1056
|
return (n() || []).map((e) => ({
|
|
1057
1057
|
where: e,
|
|
1058
|
-
item:
|
|
1058
|
+
item: te(e)
|
|
1059
1059
|
})).filter((e) => e.item);
|
|
1060
1060
|
}
|
|
1061
|
-
function
|
|
1062
|
-
return
|
|
1061
|
+
function y() {
|
|
1062
|
+
return v().at(-1) ?? null;
|
|
1063
1063
|
}
|
|
1064
|
-
function
|
|
1065
|
-
if (!c() || e.button !== 0 || d() &&
|
|
1064
|
+
function re(e) {
|
|
1065
|
+
if (!c() || e.button !== 0 || d() && ie(e)) return;
|
|
1066
1066
|
let t = e.target.closest?.("[data-handle]");
|
|
1067
1067
|
if (t) {
|
|
1068
|
-
let n =
|
|
1068
|
+
let n = y();
|
|
1069
1069
|
if (!n) return;
|
|
1070
|
-
|
|
1070
|
+
x(e, {
|
|
1071
1071
|
mode: "resize",
|
|
1072
1072
|
handle: t.dataset.handle,
|
|
1073
1073
|
item: n.item
|
|
@@ -1088,22 +1088,22 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1088
1088
|
return;
|
|
1089
1089
|
}
|
|
1090
1090
|
if (e.altKey && (s || r(a), o())) {
|
|
1091
|
-
|
|
1091
|
+
x(e, {
|
|
1092
1092
|
mode: "move",
|
|
1093
1093
|
collapseTo: null
|
|
1094
1094
|
});
|
|
1095
1095
|
return;
|
|
1096
1096
|
}
|
|
1097
|
-
s || r(a),
|
|
1097
|
+
s || r(a), x(e, {
|
|
1098
1098
|
mode: "move",
|
|
1099
1099
|
collapseTo: s ? a : null
|
|
1100
1100
|
});
|
|
1101
1101
|
}
|
|
1102
|
-
function
|
|
1102
|
+
function ie(e) {
|
|
1103
1103
|
let n = e.target.closest?.("[data-role=\"ruler\"]"), r = g(e);
|
|
1104
1104
|
if (!r) return !1;
|
|
1105
1105
|
if (n) {
|
|
1106
|
-
let a = n.dataset.axis, o =
|
|
1106
|
+
let a = n.dataset.axis, o = Se(t(), a, r[a]);
|
|
1107
1107
|
return o === null ? !1 : (f = {
|
|
1108
1108
|
mode: "guide",
|
|
1109
1109
|
axis: a,
|
|
@@ -1111,14 +1111,14 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1111
1111
|
created: !0,
|
|
1112
1112
|
moved: !1,
|
|
1113
1113
|
key: `guide:${++p}`
|
|
1114
|
-
},
|
|
1114
|
+
}, b(e), i({
|
|
1115
1115
|
live: !0,
|
|
1116
1116
|
key: f.key
|
|
1117
1117
|
}), !0);
|
|
1118
1118
|
}
|
|
1119
1119
|
if (!e.target.closest?.(".dz-page")) return !1;
|
|
1120
1120
|
for (let n of ["x", "y"]) {
|
|
1121
|
-
let i =
|
|
1121
|
+
let i = Te(t(), n, r[n]);
|
|
1122
1122
|
if (i !== null) return f = {
|
|
1123
1123
|
mode: "guide",
|
|
1124
1124
|
axis: n,
|
|
@@ -1126,67 +1126,67 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1126
1126
|
created: !1,
|
|
1127
1127
|
moved: !1,
|
|
1128
1128
|
key: `guide:${++p}`
|
|
1129
|
-
},
|
|
1129
|
+
}, b(e), !0;
|
|
1130
1130
|
}
|
|
1131
1131
|
return !1;
|
|
1132
1132
|
}
|
|
1133
|
-
function
|
|
1133
|
+
function b(t) {
|
|
1134
1134
|
e.setPointerCapture?.(t.pointerId), e.classList.add("is-dragging"), t.preventDefault();
|
|
1135
1135
|
}
|
|
1136
|
-
function
|
|
1137
|
-
let n = t.mode === "move" ?
|
|
1136
|
+
function x(e, t) {
|
|
1137
|
+
let n = t.mode === "move" ? v().map((e) => ({
|
|
1138
1138
|
...e,
|
|
1139
|
-
box:
|
|
1139
|
+
box: I(e.item)
|
|
1140
1140
|
})) : [];
|
|
1141
1141
|
f = {
|
|
1142
1142
|
...t,
|
|
1143
1143
|
group: n,
|
|
1144
|
-
band:
|
|
1144
|
+
band: y()?.where.band ?? null,
|
|
1145
1145
|
target: null,
|
|
1146
1146
|
startX: e.clientX,
|
|
1147
1147
|
startY: e.clientY,
|
|
1148
|
-
box: t.item ?
|
|
1148
|
+
box: t.item ? I(t.item) : null,
|
|
1149
1149
|
moved: !1
|
|
1150
|
-
},
|
|
1150
|
+
}, b(e);
|
|
1151
1151
|
}
|
|
1152
|
-
function
|
|
1152
|
+
function S(e) {
|
|
1153
1153
|
if (!f) return;
|
|
1154
1154
|
if (f.mode === "guide") {
|
|
1155
1155
|
let n = g(e);
|
|
1156
1156
|
if (!n) return;
|
|
1157
|
-
f.moved = !0, f.at =
|
|
1157
|
+
f.moved = !0, f.at = we(t(), f.axis, f.at, n[f.axis]), i({
|
|
1158
1158
|
live: !0,
|
|
1159
1159
|
key: f.key
|
|
1160
1160
|
});
|
|
1161
1161
|
return;
|
|
1162
1162
|
}
|
|
1163
1163
|
let n = s() || 1, r = (e.clientX - f.startX) / n, a = (e.clientY - f.startY) / n;
|
|
1164
|
-
if (
|
|
1164
|
+
if (E(e.altKey), !f.moved && Math.abs(r) < 1 && Math.abs(a) < 1) return;
|
|
1165
1165
|
if (f.moved = !0, f.mode === "resize") {
|
|
1166
|
-
|
|
1166
|
+
ye(f.item, ve(f.handle, f.box, r, a, L(f.item))), i({ live: !0 });
|
|
1167
1167
|
return;
|
|
1168
1168
|
}
|
|
1169
|
-
for (let e of f.group)
|
|
1169
|
+
for (let e of f.group) ye(e.item, {
|
|
1170
1170
|
...e.box,
|
|
1171
|
-
...
|
|
1171
|
+
...z(e.box, r, a)
|
|
1172
1172
|
});
|
|
1173
|
-
|
|
1173
|
+
C(f.group);
|
|
1174
1174
|
let o = t(), c = /* @__PURE__ */ new Set();
|
|
1175
1175
|
for (let e of f.group) {
|
|
1176
|
-
let t =
|
|
1176
|
+
let t = Be(o, e.where.band, e.item);
|
|
1177
1177
|
t && t !== e.where.band && c.add(t);
|
|
1178
1178
|
}
|
|
1179
1179
|
f.target = c.size ? [...c] : null, l(f.target), i({ live: !0 });
|
|
1180
1180
|
}
|
|
1181
|
-
function
|
|
1182
|
-
let n = f?.band ?
|
|
1181
|
+
function C(e) {
|
|
1182
|
+
let n = f?.band ? Ie(t(), f.band) : null;
|
|
1183
1183
|
if (!n || !e.length) {
|
|
1184
1184
|
u(null);
|
|
1185
1185
|
return;
|
|
1186
1186
|
}
|
|
1187
|
-
let r =
|
|
1188
|
-
if (i.dx || i.dy) for (let t of e)
|
|
1189
|
-
...
|
|
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
1190
|
x: (t.item.x ?? 0) + i.dx,
|
|
1191
1191
|
y: (t.item.y ?? 0) + i.dy
|
|
1192
1192
|
});
|
|
@@ -1196,59 +1196,59 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1196
1196
|
gaps: m ? i.gaps : []
|
|
1197
1197
|
});
|
|
1198
1198
|
}
|
|
1199
|
-
function
|
|
1200
|
-
let e =
|
|
1199
|
+
function w() {
|
|
1200
|
+
let e = v(), n = e.at(-1)?.where ?? null, r = n ? Ie(t(), n.band) : null;
|
|
1201
1201
|
if (!r || !e.length) {
|
|
1202
1202
|
u(null);
|
|
1203
1203
|
return;
|
|
1204
1204
|
}
|
|
1205
|
-
let i = e.map((e) =>
|
|
1205
|
+
let i = e.map((e) => I(e.item));
|
|
1206
1206
|
u({
|
|
1207
1207
|
band: n.band,
|
|
1208
1208
|
lines: [],
|
|
1209
|
-
gaps:
|
|
1209
|
+
gaps: Xe(We(i), ne(n.band, e), r)
|
|
1210
1210
|
});
|
|
1211
1211
|
}
|
|
1212
|
-
function
|
|
1212
|
+
function T() {
|
|
1213
1213
|
if (f?.mode === "move") {
|
|
1214
|
-
|
|
1214
|
+
C(f.group);
|
|
1215
1215
|
return;
|
|
1216
1216
|
}
|
|
1217
1217
|
if (m) {
|
|
1218
|
-
|
|
1218
|
+
w();
|
|
1219
1219
|
return;
|
|
1220
1220
|
}
|
|
1221
1221
|
u(null);
|
|
1222
1222
|
}
|
|
1223
|
-
function
|
|
1223
|
+
function E(e) {
|
|
1224
1224
|
return e === m ? !1 : (m = e, !0);
|
|
1225
1225
|
}
|
|
1226
|
-
function
|
|
1226
|
+
function D(n) {
|
|
1227
1227
|
if (!f) return;
|
|
1228
1228
|
if (e.releasePointerCapture?.(n.pointerId), e.classList.remove("is-dragging"), f.mode === "guide") {
|
|
1229
1229
|
let { axis: e, at: n, key: r } = f;
|
|
1230
1230
|
f = null;
|
|
1231
|
-
let a =
|
|
1232
|
-
(n === null || n < 0 || a !== null && n > a) &&
|
|
1231
|
+
let a = ae(e);
|
|
1232
|
+
(n === null || n < 0 || a !== null && n > a) && Ce(t(), e, n), i({
|
|
1233
1233
|
live: !1,
|
|
1234
1234
|
key: r
|
|
1235
1235
|
});
|
|
1236
1236
|
return;
|
|
1237
1237
|
}
|
|
1238
1238
|
let a = f.moved, o = f.target, s = f.collapseTo;
|
|
1239
|
-
f = null, l(null),
|
|
1239
|
+
f = null, l(null), E(n.altKey), a ? i({
|
|
1240
1240
|
live: !1,
|
|
1241
1241
|
band: o
|
|
1242
|
-
}) : s && r(s),
|
|
1242
|
+
}) : s && r(s), T();
|
|
1243
1243
|
}
|
|
1244
|
-
function
|
|
1244
|
+
function ae(e) {
|
|
1245
1245
|
let n = t()?.page;
|
|
1246
1246
|
return n?.margin ? e === "x" ? n.width - n.margin.left - n.margin.right : n.height - n.margin.top - n.margin.bottom : null;
|
|
1247
1247
|
}
|
|
1248
|
-
function
|
|
1248
|
+
function O(e) {
|
|
1249
1249
|
if (!c() || e.target.closest?.("input, textarea, select")) return;
|
|
1250
1250
|
if (e.key === "Alt") {
|
|
1251
|
-
|
|
1251
|
+
E(!0) && T(), e.preventDefault();
|
|
1252
1252
|
return;
|
|
1253
1253
|
}
|
|
1254
1254
|
if (e.key === "Escape") {
|
|
@@ -1256,7 +1256,7 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1256
1256
|
return;
|
|
1257
1257
|
}
|
|
1258
1258
|
if (e.key === "Delete" || e.key === "Backspace") {
|
|
1259
|
-
if (!
|
|
1259
|
+
if (!v().length) return;
|
|
1260
1260
|
e.preventDefault(), a();
|
|
1261
1261
|
return;
|
|
1262
1262
|
}
|
|
@@ -1267,25 +1267,25 @@ function Ye({ canvas: e, getLayout: t, getSelection: n, select: r, commit: i, re
|
|
|
1267
1267
|
ArrowDown: [0, 1]
|
|
1268
1268
|
}[e.key];
|
|
1269
1269
|
if (!t) return;
|
|
1270
|
-
let n =
|
|
1270
|
+
let n = v();
|
|
1271
1271
|
if (!n.length) return;
|
|
1272
1272
|
let o = e.shiftKey ? 10 : 1;
|
|
1273
1273
|
for (let { item: e } of n) e.x = (e.x ?? 0) + t[0] * o, e.y = (e.y ?? 0) + t[1] * o;
|
|
1274
1274
|
e.preventDefault(), i({ live: !1 });
|
|
1275
1275
|
}
|
|
1276
|
-
function
|
|
1277
|
-
e.key === "Alt" &&
|
|
1276
|
+
function k(e) {
|
|
1277
|
+
e.key === "Alt" && E(!1) && T();
|
|
1278
1278
|
}
|
|
1279
|
-
function
|
|
1280
|
-
|
|
1279
|
+
function A() {
|
|
1280
|
+
E(!1) && T();
|
|
1281
1281
|
}
|
|
1282
|
-
return e.addEventListener("pointerdown",
|
|
1283
|
-
e.removeEventListener("pointerdown",
|
|
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
1284
|
};
|
|
1285
1285
|
}
|
|
1286
1286
|
//#endregion
|
|
1287
1287
|
//#region src/designer/structure.js
|
|
1288
|
-
var
|
|
1288
|
+
var $e = [
|
|
1289
1289
|
"pageHeader",
|
|
1290
1290
|
"reportHeader",
|
|
1291
1291
|
"groupHeader",
|
|
@@ -1293,14 +1293,14 @@ var Xe = [
|
|
|
1293
1293
|
"groupFooter",
|
|
1294
1294
|
"reportFooter",
|
|
1295
1295
|
"pageFooter"
|
|
1296
|
-
],
|
|
1296
|
+
], et = {
|
|
1297
1297
|
pageHeader: 40,
|
|
1298
1298
|
reportHeader: 80,
|
|
1299
1299
|
groupHeader: 36,
|
|
1300
1300
|
groupFooter: 36,
|
|
1301
1301
|
reportFooter: 60,
|
|
1302
1302
|
pageFooter: 40
|
|
1303
|
-
},
|
|
1303
|
+
}, tt = {
|
|
1304
1304
|
reportHeader: "First page only",
|
|
1305
1305
|
pageHeader: "Every page",
|
|
1306
1306
|
groupHeader: "Before each group",
|
|
@@ -1309,75 +1309,75 @@ var Xe = [
|
|
|
1309
1309
|
reportFooter: "Last page only",
|
|
1310
1310
|
pageFooter: "Every page"
|
|
1311
1311
|
};
|
|
1312
|
-
function
|
|
1312
|
+
function q(e) {
|
|
1313
1313
|
return Array.isArray(e?.bands) ? e.bands : [];
|
|
1314
1314
|
}
|
|
1315
|
-
function
|
|
1316
|
-
return
|
|
1315
|
+
function nt(e) {
|
|
1316
|
+
return q(e).flatMap((e) => e.items || []).filter((e) => e?.type === "table").length;
|
|
1317
1317
|
}
|
|
1318
|
-
function
|
|
1318
|
+
function rt(e) {
|
|
1319
1319
|
return Array.isArray(e?.bands);
|
|
1320
1320
|
}
|
|
1321
|
-
function
|
|
1322
|
-
let t =
|
|
1321
|
+
function it(e) {
|
|
1322
|
+
let t = nt(e);
|
|
1323
1323
|
if (t === 0) return e.dataset ?? null;
|
|
1324
|
-
let n = e.dataset || "rows", r = new Set(
|
|
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
1325
|
for (let e = t + 1;; e++) if (!r.has(`${n}${e}`)) return `${n}${e}`;
|
|
1326
1326
|
}
|
|
1327
|
-
function
|
|
1328
|
-
e.y =
|
|
1327
|
+
function at(e, t) {
|
|
1328
|
+
e.y = X(t), delete e.groupBy;
|
|
1329
1329
|
}
|
|
1330
|
-
function
|
|
1331
|
-
return
|
|
1330
|
+
function J(e, t) {
|
|
1331
|
+
return q(e).find((e) => e.type === t) ?? null;
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
1333
|
+
function ot(e, t) {
|
|
1334
|
+
return J(e, t) != null;
|
|
1335
1335
|
}
|
|
1336
|
-
function
|
|
1337
|
-
if (
|
|
1336
|
+
function st(e, t) {
|
|
1337
|
+
if (!$e.includes(t) || ot(e, t)) return null;
|
|
1338
1338
|
let n = {
|
|
1339
1339
|
type: t,
|
|
1340
1340
|
items: []
|
|
1341
1341
|
};
|
|
1342
|
-
|
|
1343
|
-
let r = (e) =>
|
|
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
1344
|
return i === -1 ? e.bands.push(n) : e.bands.splice(i, 0, n), n;
|
|
1345
1345
|
}
|
|
1346
|
-
function
|
|
1347
|
-
let n =
|
|
1346
|
+
function ct(e, t) {
|
|
1347
|
+
let n = q(e).findIndex((e) => e.type === t);
|
|
1348
1348
|
return n === -1 ? !1 : (e.bands.splice(n, 1), !0);
|
|
1349
1349
|
}
|
|
1350
|
-
function
|
|
1351
|
-
return new Set(
|
|
1350
|
+
function lt(e) {
|
|
1351
|
+
return new Set(q(e).flatMap((e) => (e.items || []).map((e) => e.id)));
|
|
1352
1352
|
}
|
|
1353
|
-
function
|
|
1354
|
-
let n =
|
|
1353
|
+
function Y(e, t) {
|
|
1354
|
+
let n = lt(e);
|
|
1355
1355
|
for (let e = 1;; e++) {
|
|
1356
1356
|
let r = `${t}-${e}`;
|
|
1357
1357
|
if (!n.has(r)) return r;
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
|
-
function
|
|
1361
|
-
let
|
|
1362
|
-
if (!
|
|
1363
|
-
let
|
|
1364
|
-
return Math.ceil(
|
|
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
1365
|
}
|
|
1366
|
-
function
|
|
1366
|
+
function ut(e) {
|
|
1367
1367
|
let { page: t } = e;
|
|
1368
1368
|
return t.width - t.margin.left - t.margin.right;
|
|
1369
1369
|
}
|
|
1370
|
-
function
|
|
1370
|
+
function dt(e, t) {
|
|
1371
1371
|
return {
|
|
1372
|
-
id:
|
|
1372
|
+
id: Y(e, "text"),
|
|
1373
1373
|
type: "text",
|
|
1374
1374
|
x: 0,
|
|
1375
|
-
y:
|
|
1375
|
+
y: X(t),
|
|
1376
1376
|
w: 200,
|
|
1377
1377
|
h: 20,
|
|
1378
1378
|
value: "Text",
|
|
1379
1379
|
style: {
|
|
1380
|
-
fontFamily:
|
|
1380
|
+
fontFamily: y[0].value,
|
|
1381
1381
|
fontSize: 12,
|
|
1382
1382
|
fontWeight: "normal",
|
|
1383
1383
|
fontStyle: "normal",
|
|
@@ -1389,14 +1389,14 @@ function ut(e, t) {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
};
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1392
|
+
function ft(e, t, n = "horizontal") {
|
|
1393
1393
|
let r = n === "vertical";
|
|
1394
1394
|
return {
|
|
1395
|
-
id:
|
|
1395
|
+
id: Y(e, "line"),
|
|
1396
1396
|
type: "line",
|
|
1397
1397
|
x: 0,
|
|
1398
|
-
y:
|
|
1399
|
-
w: r ? 12 :
|
|
1398
|
+
y: X(t),
|
|
1399
|
+
w: r ? 12 : ut(e),
|
|
1400
1400
|
h: r ? 80 : 12,
|
|
1401
1401
|
orientation: r ? "vertical" : "horizontal",
|
|
1402
1402
|
style: {
|
|
@@ -1406,13 +1406,13 @@ function dt(e, t, n = "horizontal") {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
};
|
|
1408
1408
|
}
|
|
1409
|
-
function
|
|
1409
|
+
function pt(e, t) {
|
|
1410
1410
|
return {
|
|
1411
|
-
id:
|
|
1411
|
+
id: Y(e, "box"),
|
|
1412
1412
|
type: "box",
|
|
1413
1413
|
x: 0,
|
|
1414
|
-
y:
|
|
1415
|
-
w:
|
|
1414
|
+
y: X(t),
|
|
1415
|
+
w: ut(e),
|
|
1416
1416
|
h: 80,
|
|
1417
1417
|
style: {
|
|
1418
1418
|
borderStyle: "solid",
|
|
@@ -1423,12 +1423,12 @@ function ft(e, t) {
|
|
|
1423
1423
|
}
|
|
1424
1424
|
};
|
|
1425
1425
|
}
|
|
1426
|
-
function
|
|
1426
|
+
function mt(e, t) {
|
|
1427
1427
|
return {
|
|
1428
|
-
id:
|
|
1428
|
+
id: Y(e, "image"),
|
|
1429
1429
|
type: "image",
|
|
1430
1430
|
x: 0,
|
|
1431
|
-
y:
|
|
1431
|
+
y: X(t),
|
|
1432
1432
|
w: 160,
|
|
1433
1433
|
h: 80,
|
|
1434
1434
|
src: null,
|
|
@@ -1437,7 +1437,7 @@ function pt(e, t) {
|
|
|
1437
1437
|
alt: ""
|
|
1438
1438
|
};
|
|
1439
1439
|
}
|
|
1440
|
-
function
|
|
1440
|
+
function ht(e) {
|
|
1441
1441
|
return {
|
|
1442
1442
|
field: `field${e}`,
|
|
1443
1443
|
label: `Column ${e}`,
|
|
@@ -1445,20 +1445,20 @@ function mt(e) {
|
|
|
1445
1445
|
align: "left"
|
|
1446
1446
|
};
|
|
1447
1447
|
}
|
|
1448
|
-
function
|
|
1448
|
+
function gt(e, t, n = 3) {
|
|
1449
1449
|
let r = Math.max(1, Math.floor(Number(n) || 3));
|
|
1450
1450
|
return {
|
|
1451
|
-
id:
|
|
1451
|
+
id: Y(e, "table"),
|
|
1452
1452
|
type: "table",
|
|
1453
1453
|
x: 0,
|
|
1454
|
-
y:
|
|
1455
|
-
w:
|
|
1456
|
-
dataset:
|
|
1454
|
+
y: X(t),
|
|
1455
|
+
w: ut(e),
|
|
1456
|
+
dataset: it(e),
|
|
1457
1457
|
rowHeight: 24,
|
|
1458
1458
|
headerHeight: 28,
|
|
1459
1459
|
showHeader: !0,
|
|
1460
1460
|
wrap: !0,
|
|
1461
|
-
columns: Array.from({ length: r }, (e, t) =>
|
|
1461
|
+
columns: Array.from({ length: r }, (e, t) => ht(t + 1)),
|
|
1462
1462
|
style: {
|
|
1463
1463
|
fontFamily: "Helvetica, Arial, sans-serif",
|
|
1464
1464
|
fontSize: 12,
|
|
@@ -1469,88 +1469,88 @@ function ht(e, t, n = 3) {
|
|
|
1469
1469
|
}
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
1472
|
-
function
|
|
1473
|
-
let r =
|
|
1472
|
+
function _t(e, t, n) {
|
|
1473
|
+
let r = J(e, t);
|
|
1474
1474
|
return r ? (r.items ??= [], r.items.push(n), n) : null;
|
|
1475
1475
|
}
|
|
1476
|
-
var
|
|
1477
|
-
function
|
|
1476
|
+
var vt = 10;
|
|
1477
|
+
function yt(e) {
|
|
1478
1478
|
return String(e.id ?? "").replace(/-\d+$/, "") || e.type || "item";
|
|
1479
1479
|
}
|
|
1480
|
-
function
|
|
1480
|
+
function bt(e, t, n) {
|
|
1481
1481
|
if (!Number.isFinite(e?.page?.width)) return Math.max(0, t);
|
|
1482
|
-
let r = Math.max(0,
|
|
1482
|
+
let r = Math.max(0, ut(e) - (n ?? 0));
|
|
1483
1483
|
return Math.min(Math.max(0, t), r);
|
|
1484
1484
|
}
|
|
1485
|
-
function
|
|
1486
|
-
let r =
|
|
1485
|
+
function xt(e, t, n) {
|
|
1486
|
+
let r = J(e, t);
|
|
1487
1487
|
if (!r) return null;
|
|
1488
1488
|
let i = (r.items || []).find((e) => e.id === n);
|
|
1489
|
-
if (!i || i.type === "table" && !
|
|
1489
|
+
if (!i || i.type === "table" && !rt(e)) return null;
|
|
1490
1490
|
let a = structuredClone(i);
|
|
1491
|
-
return a.id =
|
|
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
1492
|
}
|
|
1493
|
-
function
|
|
1494
|
-
return Number.isFinite(e?.page?.height) ?
|
|
1493
|
+
function St(e, t) {
|
|
1494
|
+
return Number.isFinite(e?.page?.height) ? U(e).find((e) => e.type === t)?.height ?? null : null;
|
|
1495
1495
|
}
|
|
1496
|
-
function
|
|
1497
|
-
let
|
|
1498
|
-
if (
|
|
1499
|
-
let
|
|
1500
|
-
return Math.min(Math.max(0,
|
|
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
1501
|
}
|
|
1502
|
-
function
|
|
1503
|
-
let r =
|
|
1502
|
+
function wt(e, t, n) {
|
|
1503
|
+
let r = J(e, t);
|
|
1504
1504
|
if (!r) return [];
|
|
1505
1505
|
r.items ??= [];
|
|
1506
1506
|
let i = [];
|
|
1507
1507
|
for (let { band: a, item: o } of n || []) {
|
|
1508
|
-
if (!o || o.type === "table" && !
|
|
1509
|
-
let n = structuredClone(o), s = Math.max(0, (o.y ?? 0) +
|
|
1510
|
-
n.id =
|
|
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
1511
|
}
|
|
1512
1512
|
return i;
|
|
1513
1513
|
}
|
|
1514
|
-
function
|
|
1515
|
-
let r =
|
|
1514
|
+
function Tt(e, t, n) {
|
|
1515
|
+
let r = J(e, t);
|
|
1516
1516
|
if (!r) return !1;
|
|
1517
1517
|
let i = (r.items || []).findIndex((e) => e.id === n);
|
|
1518
1518
|
return i === -1 ? !1 : (r.items.splice(i, 1), !0);
|
|
1519
1519
|
}
|
|
1520
|
-
function
|
|
1520
|
+
function Et(e, t, n, r) {
|
|
1521
1521
|
if (t === n) return !1;
|
|
1522
|
-
let i =
|
|
1522
|
+
let i = J(e, t), a = J(e, n);
|
|
1523
1523
|
if (!i || !a) return !1;
|
|
1524
1524
|
let o = (i.items || []).find((e) => e.id === r);
|
|
1525
1525
|
if (!o) return !1;
|
|
1526
|
-
let s =
|
|
1527
|
-
|
|
1528
|
-
let c =
|
|
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
1529
|
return s !== null && c !== null && (o.y = Math.round(s - c)), !0;
|
|
1530
1530
|
}
|
|
1531
|
-
function
|
|
1531
|
+
function Dt(e) {
|
|
1532
1532
|
e.columns ??= [];
|
|
1533
|
-
let t =
|
|
1533
|
+
let t = ht(e.columns.length + 1);
|
|
1534
1534
|
return e.columns.push(t), t;
|
|
1535
1535
|
}
|
|
1536
|
-
function
|
|
1536
|
+
function Ot(e, t) {
|
|
1537
1537
|
return !Array.isArray(e.columns) || e.columns.length <= 1 || t < 0 || t >= e.columns.length ? !1 : (e.columns.splice(t, 1), !0);
|
|
1538
1538
|
}
|
|
1539
|
-
function
|
|
1540
|
-
return t &&
|
|
1539
|
+
function kt(e, t) {
|
|
1540
|
+
return t && ot(e, t.band) ? t.band : ot(e, "detail") ? "detail" : q(e)[0]?.type ?? null;
|
|
1541
1541
|
}
|
|
1542
1542
|
//#endregion
|
|
1543
1543
|
//#region src/designer/panel.js
|
|
1544
|
-
function
|
|
1544
|
+
function At(e) {
|
|
1545
1545
|
return `
|
|
1546
1546
|
<div class="dz-panel-head">
|
|
1547
|
-
<span class="dz-panel-type">${
|
|
1548
|
-
<span class="dz-panel-id">${
|
|
1547
|
+
<span class="dz-panel-type">${p(e.type)}</span>
|
|
1548
|
+
<span class="dz-panel-id">${p(e.id)}</span>
|
|
1549
1549
|
</div>
|
|
1550
|
-
${
|
|
1551
|
-
${e.type === "table" ?
|
|
1550
|
+
${Nt(e, ae(e))}
|
|
1551
|
+
${e.type === "table" ? It(e) : ""}`;
|
|
1552
1552
|
}
|
|
1553
|
-
function
|
|
1553
|
+
function jt(e) {
|
|
1554
1554
|
return `
|
|
1555
1555
|
<div class="dz-panel-head">
|
|
1556
1556
|
<span class="dz-panel-type">${e.length} items</span>
|
|
@@ -1560,8 +1560,8 @@ function At(e) {
|
|
|
1560
1560
|
<ul class="dz-selected">
|
|
1561
1561
|
${e.map((e) => `
|
|
1562
1562
|
<li>
|
|
1563
|
-
<span class="dz-selected-type">${
|
|
1564
|
-
<span class="dz-selected-id">${
|
|
1563
|
+
<span class="dz-selected-type">${p(e.type)}</span>
|
|
1564
|
+
<span class="dz-selected-id">${p(e.id)}</span>
|
|
1565
1565
|
</li>`).join("")}
|
|
1566
1566
|
</ul>
|
|
1567
1567
|
|
|
@@ -1571,55 +1571,55 @@ function At(e) {
|
|
|
1571
1571
|
</p>
|
|
1572
1572
|
</section>`;
|
|
1573
1573
|
}
|
|
1574
|
-
function
|
|
1574
|
+
function Mt(e) {
|
|
1575
1575
|
return `
|
|
1576
1576
|
<div class="dz-panel-head">
|
|
1577
1577
|
<span class="dz-panel-type">report</span>
|
|
1578
|
-
<span class="dz-panel-id">${
|
|
1578
|
+
<span class="dz-panel-id">${p(e.name ?? "Untitled")}</span>
|
|
1579
1579
|
</div>
|
|
1580
|
-
${
|
|
1581
|
-
${
|
|
1580
|
+
${Nt(e, N(e))}
|
|
1581
|
+
${Lt(e)}`;
|
|
1582
1582
|
}
|
|
1583
|
-
function
|
|
1583
|
+
function Nt(e, t) {
|
|
1584
1584
|
return t.map((t) => `
|
|
1585
1585
|
<section class="dz-section">
|
|
1586
|
-
<h3>${
|
|
1587
|
-
${t.fields.map((t) =>
|
|
1586
|
+
<h3>${p(t.title)}</h3>
|
|
1587
|
+
${t.fields.map((t) => Pt(e, t)).join("")}
|
|
1588
1588
|
</section>`).join("");
|
|
1589
1589
|
}
|
|
1590
|
-
function
|
|
1591
|
-
let r =
|
|
1592
|
-
<label for="${i}">${
|
|
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
1593
|
<button type="button" class="dz-brace" data-action="insert-brace"
|
|
1594
|
-
data-for="${
|
|
1594
|
+
data-for="${p(t.key)}"
|
|
1595
1595
|
title="Wrap the selected text in braces, or insert a pair"
|
|
1596
1596
|
aria-label="Insert a placeholder">{ }</button>
|
|
1597
|
-
</span>` : `<label for="${i}">${
|
|
1597
|
+
</span>` : `<label for="${i}">${p(t.label)}</label>`;
|
|
1598
1598
|
return `
|
|
1599
1599
|
<div class="dz-field dz-field-${t.type}">
|
|
1600
1600
|
${o}
|
|
1601
|
-
${
|
|
1602
|
-
${t.hint ? `<p class="dz-hint">${
|
|
1601
|
+
${Ft(i, a, t, r)}
|
|
1602
|
+
${t.hint ? `<p class="dz-hint">${p(t.hint)}</p>` : ""}
|
|
1603
1603
|
</div>`;
|
|
1604
1604
|
}
|
|
1605
|
-
function
|
|
1605
|
+
function Ft(e, t, n, r) {
|
|
1606
1606
|
switch (n.type) {
|
|
1607
1607
|
case "textarea": return `
|
|
1608
1608
|
<div class="dz-value">
|
|
1609
1609
|
<div class="dz-value-marks" data-role="marks" aria-hidden="true"
|
|
1610
|
-
>${
|
|
1610
|
+
>${Bt(r ?? "")}</div>
|
|
1611
1611
|
<textarea id="${e}" ${t} rows="2"
|
|
1612
|
-
spellcheck="false">${
|
|
1612
|
+
spellcheck="false">${p(r ?? "")}</textarea>
|
|
1613
1613
|
</div>`;
|
|
1614
|
-
case "choice": return `<select id="${e}" ${t}>${n.options.map((e) => `<option value="${
|
|
1615
|
-
>${
|
|
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
1616
|
case "color": return `<input type="color" id="${e}" ${t}
|
|
1617
|
-
value="${
|
|
1617
|
+
value="${p(r ?? "#000000")}">`;
|
|
1618
1618
|
case "toggle": return `<input type="checkbox" id="${e}" ${t}
|
|
1619
1619
|
${r ? "checked" : ""}>`;
|
|
1620
1620
|
case "image": return `
|
|
1621
1621
|
<div class="dz-image" id="${e}">
|
|
1622
|
-
${r ? `<img class="dz-image-thumb" src="${
|
|
1622
|
+
${r ? `<img class="dz-image-thumb" src="${p(f(r))}" alt="">` : "<span class=\"dz-image-none\">No image stored</span>"}
|
|
1623
1623
|
<div class="dz-image-actions">
|
|
1624
1624
|
<button type="button" class="dz-add-row"
|
|
1625
1625
|
data-action="upload-image">${r ? "Replace" : "Upload"}</button>
|
|
@@ -1627,14 +1627,14 @@ function Pt(e, t, n, r) {
|
|
|
1627
1627
|
</div>
|
|
1628
1628
|
</div>`;
|
|
1629
1629
|
case "text": return `<input type="text" id="${e}" ${t}
|
|
1630
|
-
value="${
|
|
1630
|
+
value="${p(r ?? "")}" spellcheck="false">`;
|
|
1631
1631
|
default: return `<input type="number" id="${e}" ${t}
|
|
1632
|
-
value="${
|
|
1632
|
+
value="${p(r ?? "")}"
|
|
1633
1633
|
${n.min == null ? "" : `min="${n.min}"`}
|
|
1634
1634
|
${n.max == null ? "" : `max="${n.max}"`} step="1">`;
|
|
1635
1635
|
}
|
|
1636
1636
|
}
|
|
1637
|
-
function
|
|
1637
|
+
function It(e) {
|
|
1638
1638
|
let t = e.columns || [];
|
|
1639
1639
|
return `
|
|
1640
1640
|
<section class="dz-section dz-columns">
|
|
@@ -1649,38 +1649,38 @@ function Ft(e) {
|
|
|
1649
1649
|
title="Remove this column"
|
|
1650
1650
|
aria-label="Remove column ${n + 1}">×</button>` : ""}
|
|
1651
1651
|
</div>
|
|
1652
|
-
${
|
|
1652
|
+
${D.map((t) => Pt(e, t, String(n))).join("")}
|
|
1653
1653
|
</div>`).join("")}
|
|
1654
1654
|
<button type="button" class="dz-add-row" data-action="add-column">
|
|
1655
1655
|
Add column</button>
|
|
1656
1656
|
</section>`;
|
|
1657
1657
|
}
|
|
1658
|
-
function
|
|
1658
|
+
function Lt(e) {
|
|
1659
1659
|
return `
|
|
1660
1660
|
<section class="dz-section dz-bands">
|
|
1661
1661
|
<h3>Bands</h3>
|
|
1662
|
-
${
|
|
1663
|
-
let n =
|
|
1662
|
+
${$e.map((t) => {
|
|
1663
|
+
let n = J(e, t), r = ot(e, t);
|
|
1664
1664
|
return `
|
|
1665
1665
|
<div class="dz-band-row${r ? " is-on" : ""}">
|
|
1666
1666
|
<label class="dz-band-name">
|
|
1667
|
-
<input type="checkbox" data-band="${
|
|
1668
|
-
<span>${
|
|
1667
|
+
<input type="checkbox" data-band="${p(t)}" ${r ? "checked" : ""}>
|
|
1668
|
+
<span>${p(t)}</span>
|
|
1669
1669
|
</label>
|
|
1670
1670
|
${r && t !== "detail" ? `<input type="text" class="dz-band-height"
|
|
1671
|
-
data-band-height="${
|
|
1672
|
-
value="${
|
|
1671
|
+
data-band-height="${p(t)}"
|
|
1672
|
+
value="${p(n.height ?? "")}"
|
|
1673
1673
|
placeholder="auto" spellcheck="false"
|
|
1674
|
-
aria-label="${
|
|
1675
|
-
<p class="dz-hint">${
|
|
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
1676
|
</div>`;
|
|
1677
1677
|
}).join("")}
|
|
1678
1678
|
</section>`;
|
|
1679
1679
|
}
|
|
1680
|
-
function
|
|
1680
|
+
function Rt({ panel: e, getTarget: t, getItem: n, changed: r, act: i, toggleBand: a, setBandHeight: o }) {
|
|
1681
1681
|
function s(e) {
|
|
1682
1682
|
let t = (e.closest?.(".dz-value"))?.querySelector("[data-role=\"marks\"]");
|
|
1683
|
-
t && (t.innerHTML =
|
|
1683
|
+
t && (t.innerHTML = Bt(e.value));
|
|
1684
1684
|
}
|
|
1685
1685
|
function c(e) {
|
|
1686
1686
|
let i = e.target.closest?.("[data-field], [data-band], [data-band-height]");
|
|
@@ -1696,8 +1696,8 @@ function Lt({ panel: e, getTarget: t, getItem: n, changed: r, act: i, toggleBand
|
|
|
1696
1696
|
if (i.dataset.column != null) {
|
|
1697
1697
|
let e = n()?.columns?.[Number(i.dataset.column)];
|
|
1698
1698
|
if (!e) return;
|
|
1699
|
-
let t =
|
|
1700
|
-
t &&
|
|
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
1701
|
return;
|
|
1702
1702
|
}
|
|
1703
1703
|
let c = t();
|
|
@@ -1705,14 +1705,14 @@ function Lt({ panel: e, getTarget: t, getItem: n, changed: r, act: i, toggleBand
|
|
|
1705
1705
|
let l = c.fields.find((e) => e.key === i.dataset.field);
|
|
1706
1706
|
if (!l) return;
|
|
1707
1707
|
let u = l.type === "toggle" ? i.checked : i.value;
|
|
1708
|
-
|
|
1708
|
+
ue(c.target, l, u) && r(`field:${l.key}`, { rebuild: !!l.rebuilds });
|
|
1709
1709
|
}
|
|
1710
1710
|
function l(e) {
|
|
1711
1711
|
let t = e.target.closest?.("[data-action]");
|
|
1712
1712
|
if (t) {
|
|
1713
1713
|
if (e.preventDefault(), t.dataset.action === "insert-brace") {
|
|
1714
1714
|
let e = t.closest(".dz-field")?.querySelector("textarea");
|
|
1715
|
-
e &&
|
|
1715
|
+
e && Vt(e);
|
|
1716
1716
|
return;
|
|
1717
1717
|
}
|
|
1718
1718
|
i(t.dataset.action, t.dataset);
|
|
@@ -1728,28 +1728,28 @@ function Lt({ panel: e, getTarget: t, getItem: n, changed: r, act: i, toggleBand
|
|
|
1728
1728
|
e.removeEventListener("scroll", u, !0), e.removeEventListener("input", c), e.removeEventListener("change", c), e.removeEventListener("click", l);
|
|
1729
1729
|
};
|
|
1730
1730
|
}
|
|
1731
|
-
function
|
|
1731
|
+
function zt(e, t, n) {
|
|
1732
1732
|
let r = t ?? n;
|
|
1733
1733
|
if (!r) return;
|
|
1734
|
-
let i = t ?
|
|
1734
|
+
let i = t ? le(t) : ce(n);
|
|
1735
1735
|
for (let n of e.querySelectorAll("[data-field]")) {
|
|
1736
1736
|
if (n === n.ownerDocument.activeElement) continue;
|
|
1737
1737
|
let e = n.dataset.column != null, a = e ? t?.columns?.[Number(n.dataset.column)] : r;
|
|
1738
1738
|
if (!a) continue;
|
|
1739
|
-
let o = (e ?
|
|
1739
|
+
let o = (e ? D : i).find((e) => e.key === n.dataset.field);
|
|
1740
1740
|
if (!o) continue;
|
|
1741
|
-
let s =
|
|
1741
|
+
let s = F(a, o);
|
|
1742
1742
|
if (o.type === "toggle") n.checked = !!s;
|
|
1743
1743
|
else if (s != null && (n.value = String(s), n.tagName === "TEXTAREA")) {
|
|
1744
1744
|
let e = n.closest(".dz-value")?.querySelector("[data-role=\"marks\"]");
|
|
1745
|
-
e && (e.innerHTML =
|
|
1745
|
+
e && (e.innerHTML = Bt(n.value));
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
1748
|
}
|
|
1749
|
-
function zt(e) {
|
|
1750
|
-
return `${v(String(e ?? "")).replace(/\{[^{}]*\}/g, (e) => `<mark class="dz-mark">${e}</mark>`)}\n`;
|
|
1751
|
-
}
|
|
1752
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
1753
|
let t = e.selectionStart ?? e.value.length, n = e.selectionEnd ?? t, r = e.value.slice(t, n);
|
|
1754
1754
|
e.value = `${e.value.slice(0, t)}{${r}}${e.value.slice(n)}`;
|
|
1755
1755
|
let i = t + 1 + r.length;
|
|
@@ -1757,34 +1757,34 @@ function Bt(e) {
|
|
|
1757
1757
|
}
|
|
1758
1758
|
//#endregion
|
|
1759
1759
|
//#region src/designer/icons.js
|
|
1760
|
-
var
|
|
1760
|
+
var Z = (e) => `<svg viewBox="0 0 16 16" width="16" height="16"
|
|
1761
1761
|
fill="none" stroke="currentColor" stroke-width="1.5"
|
|
1762
1762
|
stroke-linecap="round" stroke-linejoin="round"
|
|
1763
|
-
aria-hidden="true" focusable="false">${e}</svg>`,
|
|
1764
|
-
text:
|
|
1765
|
-
table:
|
|
1766
|
-
image:
|
|
1767
|
-
box:
|
|
1768
|
-
line:
|
|
1769
|
-
ruler:
|
|
1770
|
-
undo:
|
|
1771
|
-
redo:
|
|
1772
|
-
open:
|
|
1773
|
-
field:
|
|
1774
|
-
external:
|
|
1775
|
-
preview:
|
|
1776
|
-
design:
|
|
1777
|
-
data:
|
|
1778
|
-
duplicate:
|
|
1779
|
-
copy:
|
|
1780
|
-
delete:
|
|
1781
|
-
paste:
|
|
1782
|
-
save:
|
|
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
1783
|
};
|
|
1784
|
-
function
|
|
1785
|
-
return
|
|
1784
|
+
function Q(e) {
|
|
1785
|
+
return Ht[e] ?? "";
|
|
1786
1786
|
}
|
|
1787
|
-
function
|
|
1787
|
+
function Ut({ count: e = 0, canPaste: t = !1, canDuplicate: n = !0 } = {}) {
|
|
1788
1788
|
let r = e > 1 ? ` ${e} items` : "", i = {
|
|
1789
1789
|
action: "paste-items",
|
|
1790
1790
|
glyph: "paste",
|
|
@@ -1817,17 +1817,17 @@ function Ht({ count: e = 0, canPaste: t = !1, canDuplicate: n = !0 } = {}) {
|
|
|
1817
1817
|
}
|
|
1818
1818
|
];
|
|
1819
1819
|
}
|
|
1820
|
-
function
|
|
1820
|
+
function Wt(e) {
|
|
1821
1821
|
return `<div class="dz-menu" data-role="menu" role="menu"
|
|
1822
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-${
|
|
1824
|
-
data-action="${
|
|
1825
|
-
title="${
|
|
1826
|
-
aria-label="${
|
|
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
1827
|
${e.disabled ? "disabled" : ""}
|
|
1828
|
-
>${
|
|
1828
|
+
>${Q(e.glyph)}</button>`).join("")}</div>`;
|
|
1829
1829
|
}
|
|
1830
|
-
function
|
|
1830
|
+
function Gt(e, t, n, r = 8) {
|
|
1831
1831
|
let i = (e, t, n) => Math.min(Math.max(r, e), Math.max(r, n - t - r));
|
|
1832
1832
|
return {
|
|
1833
1833
|
left: i(e.x, t.width, n.width),
|
|
@@ -1836,16 +1836,16 @@ function Wt(e, t, n, r = 8) {
|
|
|
1836
1836
|
}
|
|
1837
1837
|
//#endregion
|
|
1838
1838
|
//#region src/designer/toast.js
|
|
1839
|
-
function
|
|
1839
|
+
function Kt(e, t) {
|
|
1840
1840
|
return !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((e, n) => e === t[n]);
|
|
1841
1841
|
}
|
|
1842
|
-
function
|
|
1842
|
+
function qt(e) {
|
|
1843
1843
|
let t = e.length > 1;
|
|
1844
1844
|
return `
|
|
1845
1845
|
<div class="dz-toast dz-problems" role="alert" data-role="problems">
|
|
1846
1846
|
<div class="dz-toast-text">
|
|
1847
1847
|
<strong class="dz-toast-title">This report will not render yet</strong>
|
|
1848
|
-
<ul>${e.map((e) => `<li>${
|
|
1848
|
+
<ul>${e.map((e) => `<li>${p(e)}</li>`).join("")}</ul>
|
|
1849
1849
|
</div>
|
|
1850
1850
|
<button type="button" class="dz-toast-close"
|
|
1851
1851
|
data-action="dismiss-problems"
|
|
@@ -1856,22 +1856,22 @@ function Kt(e) {
|
|
|
1856
1856
|
}
|
|
1857
1857
|
//#endregion
|
|
1858
1858
|
//#region src/shared/prefix.js
|
|
1859
|
-
var
|
|
1859
|
+
var Jt = "/__reports";
|
|
1860
1860
|
//#endregion
|
|
1861
1861
|
//#region src/shared/store.js
|
|
1862
|
-
function
|
|
1862
|
+
function Yt({ prefix: e = Jt, fetch: t = (...e) => globalThis.fetch(...e) } = {}) {
|
|
1863
1863
|
async function n(n, r) {
|
|
1864
1864
|
let i;
|
|
1865
1865
|
try {
|
|
1866
1866
|
i = await t(`${e}${n}`, r);
|
|
1867
1867
|
} catch (e) {
|
|
1868
|
-
throw new
|
|
1868
|
+
throw new Xt("Cannot reach the report server. Start it with `npx report-studio design`.", {
|
|
1869
1869
|
cause: e,
|
|
1870
1870
|
offline: !0
|
|
1871
1871
|
});
|
|
1872
1872
|
}
|
|
1873
1873
|
let a = await i.json().catch(() => null);
|
|
1874
|
-
if (!i.ok) throw new
|
|
1874
|
+
if (!i.ok) throw new Xt(a?.error ?? `the server answered ${i.status}`, { status: i.status });
|
|
1875
1875
|
return a;
|
|
1876
1876
|
}
|
|
1877
1877
|
return {
|
|
@@ -1909,25 +1909,25 @@ function Jt({ prefix: e = qt, fetch: t = (...e) => globalThis.fetch(...e) } = {}
|
|
|
1909
1909
|
}
|
|
1910
1910
|
};
|
|
1911
1911
|
}
|
|
1912
|
-
var
|
|
1912
|
+
var Xt = class extends Error {
|
|
1913
1913
|
constructor(e, { cause: t, status: n = null, offline: r = !1 } = {}) {
|
|
1914
1914
|
super(e, { cause: t }), this.name = "StoreError", this.status = n, this.offline = r;
|
|
1915
1915
|
}
|
|
1916
1916
|
};
|
|
1917
|
-
function
|
|
1917
|
+
function Zt(e) {
|
|
1918
1918
|
let t = String(e ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64).replace(/-+$/, "");
|
|
1919
1919
|
return /^[a-z0-9]/.test(t) ? t : "";
|
|
1920
1920
|
}
|
|
1921
1921
|
//#endregion
|
|
1922
1922
|
//#region src/designer/sample-data.js
|
|
1923
|
-
var
|
|
1924
|
-
function
|
|
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
1925
|
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1926
|
-
for (let i of Array.isArray(
|
|
1927
|
-
let
|
|
1928
|
-
for (let
|
|
1929
|
-
let
|
|
1930
|
-
!
|
|
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
1931
|
}
|
|
1932
1932
|
}
|
|
1933
1933
|
return {
|
|
@@ -1935,7 +1935,7 @@ function rn(e) {
|
|
|
1935
1935
|
row: [...r]
|
|
1936
1936
|
};
|
|
1937
1937
|
}
|
|
1938
|
-
function
|
|
1938
|
+
function on(e) {
|
|
1939
1939
|
let t = /* @__PURE__ */ new Set();
|
|
1940
1940
|
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) {
|
|
1941
1941
|
if (e.type !== "image" || typeof e.field != "string") continue;
|
|
@@ -1944,32 +1944,32 @@ function an(e) {
|
|
|
1944
1944
|
}
|
|
1945
1945
|
return [...t];
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1948
|
-
let
|
|
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
1949
|
for (let t of Array.isArray(e?.bands) ? e.bands : []) for (let e of t.items || []) {
|
|
1950
1950
|
if (e.type !== "table") continue;
|
|
1951
|
-
let t =
|
|
1951
|
+
let t = i(e.dataset || r);
|
|
1952
1952
|
for (let n of e.columns || []) n?.field && t.add(n.field);
|
|
1953
1953
|
}
|
|
1954
|
-
let { row:
|
|
1955
|
-
if (
|
|
1956
|
-
let
|
|
1957
|
-
for (let e of
|
|
1958
|
-
|
|
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
1959
|
}
|
|
1960
|
-
for (let t of
|
|
1961
|
-
return
|
|
1960
|
+
for (let t of mn(e)) i(t.dataset).add(t.field);
|
|
1961
|
+
return n;
|
|
1962
1962
|
}
|
|
1963
|
-
function
|
|
1964
|
-
let t = {}, { root: n } =
|
|
1965
|
-
for (let n of
|
|
1966
|
-
for (let e of n)
|
|
1967
|
-
let i =
|
|
1968
|
-
for (let [n, a] of
|
|
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
1969
|
return t;
|
|
1970
1970
|
}
|
|
1971
|
-
function
|
|
1972
|
-
let n =
|
|
1971
|
+
function ln(e, t) {
|
|
1972
|
+
let n = cn(t);
|
|
1973
1973
|
if (typeof e != "object" || !e || Array.isArray(e)) return {
|
|
1974
1974
|
data: n,
|
|
1975
1975
|
added: !0
|
|
@@ -1977,10 +1977,10 @@ function cn(e, t) {
|
|
|
1977
1977
|
let r = structuredClone(e);
|
|
1978
1978
|
return {
|
|
1979
1979
|
data: r,
|
|
1980
|
-
added:
|
|
1980
|
+
added: un(r, n)
|
|
1981
1981
|
};
|
|
1982
1982
|
}
|
|
1983
|
-
function
|
|
1983
|
+
function un(e, t) {
|
|
1984
1984
|
let n = !1;
|
|
1985
1985
|
for (let [r, i] of Object.entries(t)) {
|
|
1986
1986
|
let t = e[r];
|
|
@@ -1988,28 +1988,28 @@ function ln(e, t) {
|
|
|
1988
1988
|
e[r] = structuredClone(i), n = !0;
|
|
1989
1989
|
continue;
|
|
1990
1990
|
}
|
|
1991
|
-
|
|
1991
|
+
dn(t) && dn(i) && un(t, i) && (n = !0);
|
|
1992
1992
|
}
|
|
1993
1993
|
return n;
|
|
1994
1994
|
}
|
|
1995
|
-
function
|
|
1995
|
+
function dn(e) {
|
|
1996
1996
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1997
1997
|
}
|
|
1998
|
-
function
|
|
1998
|
+
function fn(e) {
|
|
1999
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(
|
|
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
2001
|
let e = n.trim();
|
|
2002
2002
|
e && (t.add(e), e.includes(".") && t.add(e.slice(e.indexOf(".") + 1)));
|
|
2003
2003
|
}
|
|
2004
2004
|
return t;
|
|
2005
2005
|
}
|
|
2006
|
-
function fn(e) {
|
|
2007
|
-
let t = /* @__PURE__ */ new Map(), i = r(e);
|
|
2008
|
-
return i && t.set(n(i.table, e) || e?.dataset || "rows", i.by), t;
|
|
2009
|
-
}
|
|
2010
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
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(
|
|
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
2013
|
let [e, ...r] = n.trim().split("."), i = r.join(".");
|
|
2014
2014
|
e && i && t.push({
|
|
2015
2015
|
dataset: e,
|
|
@@ -2018,30 +2018,30 @@ function pn(e) {
|
|
|
2018
2018
|
}
|
|
2019
2019
|
return t;
|
|
2020
2020
|
}
|
|
2021
|
-
function
|
|
2021
|
+
function hn(e, t, n) {
|
|
2022
2022
|
let r = t.split(".").filter(Boolean);
|
|
2023
2023
|
if (!r.length) return;
|
|
2024
2024
|
let i = r.pop(), a = e;
|
|
2025
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 ??
|
|
2026
|
+
a[i] === void 0 && (a[i] = n ?? _n(i, 0));
|
|
2027
2027
|
}
|
|
2028
|
-
function
|
|
2029
|
-
return e.length ? Array.from({ length:
|
|
2028
|
+
function gn(e, t, n = /* @__PURE__ */ new Set()) {
|
|
2029
|
+
return e.length ? Array.from({ length: Qt }, (r, i) => {
|
|
2030
2030
|
let a = {};
|
|
2031
|
-
for (let r of e) a[r] = r === t ?
|
|
2031
|
+
for (let r of e) a[r] = r === t ? $t[i % $t.length] : _n(r, i, n.has(r));
|
|
2032
2032
|
return a;
|
|
2033
2033
|
}) : [];
|
|
2034
2034
|
}
|
|
2035
|
-
function
|
|
2036
|
-
return n ||
|
|
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
2037
|
}
|
|
2038
|
-
function
|
|
2038
|
+
function vn(e) {
|
|
2039
2039
|
let t = String(e).replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
|
2040
2040
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
2041
2041
|
}
|
|
2042
2042
|
//#endregion
|
|
2043
2043
|
//#region src/designer/tokens.js
|
|
2044
|
-
var
|
|
2044
|
+
var yn = "field", bn = [
|
|
2045
2045
|
{
|
|
2046
2046
|
id: "page",
|
|
2047
2047
|
prefer: [
|
|
@@ -2098,7 +2098,7 @@ var vn = "field", yn = [
|
|
|
2098
2098
|
id: "sum",
|
|
2099
2099
|
prefer: ["groupFooter", "reportFooter"],
|
|
2100
2100
|
label: "Sum",
|
|
2101
|
-
value: `{sum(${
|
|
2101
|
+
value: `{sum(${yn})}`,
|
|
2102
2102
|
note: "Added up over the rows in scope",
|
|
2103
2103
|
field: !0,
|
|
2104
2104
|
aggregate: !0
|
|
@@ -2107,7 +2107,7 @@ var vn = "field", yn = [
|
|
|
2107
2107
|
id: "avg",
|
|
2108
2108
|
prefer: ["groupFooter", "reportFooter"],
|
|
2109
2109
|
label: "Average",
|
|
2110
|
-
value: `{avg(${
|
|
2110
|
+
value: `{avg(${yn})}`,
|
|
2111
2111
|
note: "The mean of the rows in scope",
|
|
2112
2112
|
field: !0,
|
|
2113
2113
|
aggregate: !0
|
|
@@ -2116,7 +2116,7 @@ var vn = "field", yn = [
|
|
|
2116
2116
|
id: "min",
|
|
2117
2117
|
prefer: ["groupFooter", "reportFooter"],
|
|
2118
2118
|
label: "Smallest",
|
|
2119
|
-
value: `{min(${
|
|
2119
|
+
value: `{min(${yn})}`,
|
|
2120
2120
|
field: !0,
|
|
2121
2121
|
aggregate: !0
|
|
2122
2122
|
},
|
|
@@ -2124,92 +2124,92 @@ var vn = "field", yn = [
|
|
|
2124
2124
|
id: "max",
|
|
2125
2125
|
prefer: ["groupFooter", "reportFooter"],
|
|
2126
2126
|
label: "Largest",
|
|
2127
|
-
value: `{max(${
|
|
2127
|
+
value: `{max(${yn})}`,
|
|
2128
2128
|
field: !0,
|
|
2129
2129
|
aggregate: !0
|
|
2130
2130
|
}
|
|
2131
2131
|
];
|
|
2132
|
-
function bn(e) {
|
|
2133
|
-
return yn.find((t) => t.id === e) ?? null;
|
|
2134
|
-
}
|
|
2135
2132
|
function xn(e) {
|
|
2136
|
-
return
|
|
2133
|
+
return bn.find((t) => t.id === e) ?? null;
|
|
2137
2134
|
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
return e?.aggregate ? Sn.includes(t) ? "group" : "report" : null;
|
|
2135
|
+
function Sn(e) {
|
|
2136
|
+
return !!e?.field;
|
|
2141
2137
|
}
|
|
2138
|
+
var Cn = ["groupHeader", "groupFooter"];
|
|
2142
2139
|
function wn(e, t) {
|
|
2143
|
-
return e ?
|
|
2140
|
+
return e?.aggregate ? Cn.includes(t) ? "group" : "report" : null;
|
|
2144
2141
|
}
|
|
2145
2142
|
function Tn(e, t) {
|
|
2146
|
-
return e ?
|
|
2143
|
+
return e ? !e.bands?.length || e.bands.includes(t) : !1;
|
|
2147
2144
|
}
|
|
2148
|
-
function En(e) {
|
|
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
2149
|
let t = /* @__PURE__ */ new Set();
|
|
2150
|
-
for (let [, n] of
|
|
2150
|
+
for (let [, n] of sn(e)) for (let e of n) t.add(e);
|
|
2151
2151
|
e?.groupBy && t.add(e.groupBy);
|
|
2152
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
2153
|
return [...t].sort();
|
|
2154
2154
|
}
|
|
2155
|
-
function
|
|
2156
|
-
let n =
|
|
2155
|
+
function On(e, t) {
|
|
2156
|
+
let n = $e.filter((t) => ot(e, t));
|
|
2157
2157
|
if (!t?.bands?.length) return n;
|
|
2158
2158
|
let r = n.filter((e) => t.bands.includes(e));
|
|
2159
2159
|
return r.length ? r : n;
|
|
2160
2160
|
}
|
|
2161
|
-
function
|
|
2162
|
-
let r =
|
|
2161
|
+
function kn(e, t, n = null) {
|
|
2162
|
+
let r = On(e, t);
|
|
2163
2163
|
if (!r.length) return null;
|
|
2164
2164
|
for (let e of t?.prefer ?? []) if (r.includes(e)) return e;
|
|
2165
|
-
return n && r.includes(n) &&
|
|
2165
|
+
return n && r.includes(n) && Tn(t, n) ? n : r[0];
|
|
2166
2166
|
}
|
|
2167
|
-
function
|
|
2168
|
-
let n =
|
|
2167
|
+
function An(e, t) {
|
|
2168
|
+
let n = Sn(e) || e?.id === "count" || e?.id === "page" || e?.id === "total-pages";
|
|
2169
2169
|
return {
|
|
2170
|
-
value:
|
|
2170
|
+
value: En(e, t),
|
|
2171
2171
|
w: e?.id === "page-of" ? 200 : 120,
|
|
2172
2172
|
align: n ? "right" : "left"
|
|
2173
2173
|
};
|
|
2174
2174
|
}
|
|
2175
2175
|
//#endregion
|
|
2176
2176
|
//#region src/designer/dialog.js
|
|
2177
|
-
var
|
|
2178
|
-
function
|
|
2179
|
-
return
|
|
2177
|
+
var jn = 20;
|
|
2178
|
+
function Mn(e) {
|
|
2179
|
+
return In(e, "column-dialog", Ln(), (e, t) => {
|
|
2180
2180
|
let n = e.querySelector("[data-role=\"count\"]");
|
|
2181
2181
|
n.focus(), n.select(), e.querySelector("form").addEventListener("submit", (e) => {
|
|
2182
2182
|
e.preventDefault();
|
|
2183
2183
|
let r = Math.round(Number(n.value));
|
|
2184
|
-
t(Number.isFinite(r) && r > 0 ? Math.min(r,
|
|
2184
|
+
t(Number.isFinite(r) && r > 0 ? Math.min(r, jn) : 3);
|
|
2185
2185
|
});
|
|
2186
2186
|
});
|
|
2187
2187
|
}
|
|
2188
|
-
function
|
|
2188
|
+
function Nn(e, t) {
|
|
2189
2189
|
let n = t || [];
|
|
2190
|
-
return
|
|
2190
|
+
return In(e, "open-dialog", Rn(n), (e, t) => {
|
|
2191
2191
|
e.querySelector("[data-role=\"new\"]")?.addEventListener("click", () => t({ blank: !0 }));
|
|
2192
2192
|
let r = e.querySelector("[data-role=\"report-dropdown\"]"), i = e.querySelector("[data-role=\"confirm\"]");
|
|
2193
2193
|
if (!r || !n.length) {
|
|
2194
2194
|
e.querySelector("[data-role=\"new\"]")?.focus();
|
|
2195
2195
|
return;
|
|
2196
2196
|
}
|
|
2197
|
-
let a =
|
|
2197
|
+
let a = _(r), o = e.querySelector("[data-role=\"report-meta\"]"), s = () => {
|
|
2198
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" : ""}${
|
|
2199
|
+
e && (o.textContent = `${e.id}.json${e.readable === !1 ? " - will not parse" : ""}${zn(e.updatedAt)}`, o.toggleAttribute("data-unreadable", e.readable === !1));
|
|
2200
2200
|
};
|
|
2201
2201
|
a.addEventListener("change", s), s(), i.addEventListener("click", () => t({ id: a.value })), i.focus(), e.addEventListener("dz-closing", () => a.destroy());
|
|
2202
2202
|
});
|
|
2203
2203
|
}
|
|
2204
|
-
function
|
|
2205
|
-
return
|
|
2204
|
+
function Pn(e, t = "") {
|
|
2205
|
+
return In(e, "save-dialog", Bn(t), (e, t) => {
|
|
2206
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 =
|
|
2207
|
+
let e = Zt(n.value);
|
|
2208
2208
|
r.textContent = e ? `${e}.json` : "needs a letter or a digit", i.disabled = !e;
|
|
2209
2209
|
};
|
|
2210
2210
|
n.addEventListener("input", a), a(), n.focus(), n.select(), e.querySelector("form").addEventListener("submit", (e) => {
|
|
2211
2211
|
e.preventDefault();
|
|
2212
|
-
let r =
|
|
2212
|
+
let r = Zt(n.value);
|
|
2213
2213
|
r && t({
|
|
2214
2214
|
id: r,
|
|
2215
2215
|
name: n.value.trim() || r
|
|
@@ -2217,12 +2217,12 @@ function Nn(e, t = "") {
|
|
|
2217
2217
|
});
|
|
2218
2218
|
});
|
|
2219
2219
|
}
|
|
2220
|
-
function
|
|
2221
|
-
return
|
|
2220
|
+
function Fn(e, t = "") {
|
|
2221
|
+
return In(e, "discard-dialog", Vn(t), (e, t) => {
|
|
2222
2222
|
e.querySelector("[data-role=\"discard\"]").addEventListener("click", () => t(!0)), e.querySelector("[data-role=\"cancel\"]").focus();
|
|
2223
2223
|
}).then((e) => e === !0);
|
|
2224
2224
|
}
|
|
2225
|
-
function
|
|
2225
|
+
function In(e, t, n, r) {
|
|
2226
2226
|
return new Promise((i) => {
|
|
2227
2227
|
let a = e.ownerDocument.createElement("div");
|
|
2228
2228
|
a.className = "modal", a.dataset.role = t, a.innerHTML = n, e.appendChild(a);
|
|
@@ -2237,7 +2237,7 @@ function Fn(e, t, n, r) {
|
|
|
2237
2237
|
a.addEventListener("keydown", c, !0), r(a, s);
|
|
2238
2238
|
});
|
|
2239
2239
|
}
|
|
2240
|
-
function
|
|
2240
|
+
function Ln() {
|
|
2241
2241
|
return `
|
|
2242
2242
|
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2243
2243
|
|
|
@@ -2249,7 +2249,7 @@ function In() {
|
|
|
2249
2249
|
<div class="dz-field dz-field-count">
|
|
2250
2250
|
<label for="dz-columns">Columns</label>
|
|
2251
2251
|
<input type="number" id="dz-columns" data-role="count"
|
|
2252
|
-
value="3" min="1" max="${
|
|
2252
|
+
value="3" min="1" max="${jn}"
|
|
2253
2253
|
step="1" required>
|
|
2254
2254
|
</div>
|
|
2255
2255
|
|
|
@@ -2265,7 +2265,7 @@ function In() {
|
|
|
2265
2265
|
</form>
|
|
2266
2266
|
</div>`;
|
|
2267
2267
|
}
|
|
2268
|
-
function
|
|
2268
|
+
function Rn(e) {
|
|
2269
2269
|
let t = e || [], n = `
|
|
2270
2270
|
<div class="dz-field dz-field-picker">
|
|
2271
2271
|
<label id="dz-open-label">Report</label>
|
|
@@ -2281,9 +2281,9 @@ function Ln(e) {
|
|
|
2281
2281
|
<ul class="dropdown-menu" role="listbox"
|
|
2282
2282
|
aria-labelledby="dz-open-label" hidden>${t.map((e, t) => `
|
|
2283
2283
|
<li class="dropdown-item" role="option" tabindex="-1"
|
|
2284
|
-
data-value="${
|
|
2284
|
+
data-value="${p(e.id)}"
|
|
2285
2285
|
${t === 0 ? "data-selected=\"true\"" : ""}
|
|
2286
|
-
>${
|
|
2286
|
+
>${p(e.name || e.id)}</li>`).join("")}</ul>
|
|
2287
2287
|
</div>
|
|
2288
2288
|
</div>
|
|
2289
2289
|
|
|
@@ -2304,7 +2304,7 @@ function Ln(e) {
|
|
|
2304
2304
|
</div>
|
|
2305
2305
|
</div>`;
|
|
2306
2306
|
}
|
|
2307
|
-
function
|
|
2307
|
+
function zn(e) {
|
|
2308
2308
|
if (!e) return "";
|
|
2309
2309
|
let t = new Date(e);
|
|
2310
2310
|
return Number.isNaN(t.getTime()) ? "" : ` - ${t.toLocaleDateString(void 0, {
|
|
@@ -2313,7 +2313,7 @@ function Rn(e) {
|
|
|
2313
2313
|
year: "numeric"
|
|
2314
2314
|
})}`;
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2316
|
+
function Bn(e) {
|
|
2317
2317
|
return `
|
|
2318
2318
|
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2319
2319
|
|
|
@@ -2325,7 +2325,7 @@ function zn(e) {
|
|
|
2325
2325
|
<div class="dz-field dz-field-text">
|
|
2326
2326
|
<label for="dz-save-name">Name</label>
|
|
2327
2327
|
<input type="text" id="dz-save-name" data-role="report-name"
|
|
2328
|
-
value="${
|
|
2328
|
+
value="${p(e)}" spellcheck="false" required>
|
|
2329
2329
|
</div>
|
|
2330
2330
|
|
|
2331
2331
|
<p class="modal-summary">
|
|
@@ -2339,7 +2339,7 @@ function zn(e) {
|
|
|
2339
2339
|
</form>
|
|
2340
2340
|
</div>`;
|
|
2341
2341
|
}
|
|
2342
|
-
function
|
|
2342
|
+
function Vn(e) {
|
|
2343
2343
|
return `
|
|
2344
2344
|
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2345
2345
|
|
|
@@ -2348,7 +2348,7 @@ function Bn(e) {
|
|
|
2348
2348
|
<h2 id="dz-discard-title">Unsaved changes</h2>
|
|
2349
2349
|
|
|
2350
2350
|
<p class="modal-summary">
|
|
2351
|
-
${e ? `<strong>${
|
|
2351
|
+
${e ? `<strong>${p(e)}</strong>` : "This report"} has changes that have not been saved. Opening another
|
|
2352
2352
|
report closes this one, and the changes go with it.
|
|
2353
2353
|
</p>
|
|
2354
2354
|
|
|
@@ -2358,8 +2358,8 @@ function Bn(e) {
|
|
|
2358
2358
|
</div>
|
|
2359
2359
|
</div>`;
|
|
2360
2360
|
}
|
|
2361
|
-
function
|
|
2362
|
-
return
|
|
2361
|
+
function Hn(e, t, { id: n = null, generated: r = !1 } = {}) {
|
|
2362
|
+
return In(e, "data-dialog", Un(t, n, r), (e, t) => {
|
|
2363
2363
|
let n = e.querySelector("[data-role=\"payload\"]"), r = e.querySelector("[data-role=\"parse-error\"]"), i = e.querySelector("[data-role=\"confirm\"]"), a = () => {
|
|
2364
2364
|
try {
|
|
2365
2365
|
let e = JSON.parse(n.value), t = typeof e == "object" && !!e && !Array.isArray(e);
|
|
@@ -2375,7 +2375,7 @@ function Vn(e, t, { id: n = null, generated: r = !1 } = {}) {
|
|
|
2375
2375
|
});
|
|
2376
2376
|
});
|
|
2377
2377
|
}
|
|
2378
|
-
function
|
|
2378
|
+
function Un(e, t, n) {
|
|
2379
2379
|
let r = t ? `${t}.data.json` : "a .data.json beside the report";
|
|
2380
2380
|
return `
|
|
2381
2381
|
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
@@ -2386,12 +2386,12 @@ function Hn(e, t, n) {
|
|
|
2386
2386
|
|
|
2387
2387
|
<p class="modal-summary">
|
|
2388
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>${
|
|
2389
|
+
Saved as <code>${p(r)}</code>.
|
|
2390
2390
|
</p>
|
|
2391
2391
|
|
|
2392
2392
|
<textarea class="dz-payload" data-role="payload" rows="16"
|
|
2393
2393
|
spellcheck="false" aria-label="Report data"
|
|
2394
|
-
>${
|
|
2394
|
+
>${p(JSON.stringify(e, null, 2))}</textarea>
|
|
2395
2395
|
|
|
2396
2396
|
<p class="dz-parse-error" data-role="parse-error" aria-live="polite"></p>
|
|
2397
2397
|
|
|
@@ -2401,30 +2401,30 @@ function Hn(e, t, n) {
|
|
|
2401
2401
|
</div>
|
|
2402
2402
|
</div>`;
|
|
2403
2403
|
}
|
|
2404
|
-
function
|
|
2405
|
-
let r =
|
|
2406
|
-
return
|
|
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 ?
|
|
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
2408
|
function f(e) {
|
|
2409
2409
|
u?.destroy();
|
|
2410
|
-
let r =
|
|
2411
|
-
l.innerHTML =
|
|
2410
|
+
let r = On(t, e), i = kn(t, e, n);
|
|
2411
|
+
l.innerHTML = Yn("band", r.map((e) => ({
|
|
2412
2412
|
value: e,
|
|
2413
2413
|
label: e
|
|
2414
|
-
})), i), u =
|
|
2414
|
+
})), i), u = _(l), u.addEventListener("change", () => p());
|
|
2415
2415
|
}
|
|
2416
2416
|
function p({ retarget: e = !1 } = {}) {
|
|
2417
2417
|
let t = d();
|
|
2418
2418
|
if (!t) return;
|
|
2419
|
-
a.hidden = !
|
|
2420
|
-
let n = u.value, r =
|
|
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
2421
|
o.textContent = i, o.hidden = !i, o.classList.toggle("is-note", r), s.textContent = r ? "Insert" : "Insert anyway";
|
|
2422
2422
|
}
|
|
2423
2423
|
for (let t of e.querySelectorAll("[name=\"dz-token\"]")) t.addEventListener("change", () => p({ retarget: !0 }));
|
|
2424
2424
|
p({ retarget: !0 }), s.addEventListener("click", () => {
|
|
2425
2425
|
let e = d();
|
|
2426
2426
|
e && i({
|
|
2427
|
-
...
|
|
2427
|
+
...An(e, Sn(e) ? c?.value || "field" : void 0),
|
|
2428
2428
|
band: u.value
|
|
2429
2429
|
});
|
|
2430
2430
|
}), e.querySelector("[name=\"dz-token\"]")?.focus(), e.addEventListener("dz-closing", () => {
|
|
@@ -2432,15 +2432,15 @@ function Un(e, t, n = null) {
|
|
|
2432
2432
|
});
|
|
2433
2433
|
});
|
|
2434
2434
|
}
|
|
2435
|
-
function
|
|
2435
|
+
function Gn(e, t) {
|
|
2436
2436
|
return `${e.label} prints nothing in a ${t}.`;
|
|
2437
2437
|
}
|
|
2438
|
-
function
|
|
2439
|
-
let n =
|
|
2438
|
+
function Kn(e, t) {
|
|
2439
|
+
let n = wn(e, t);
|
|
2440
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
2441
|
}
|
|
2442
|
-
function
|
|
2443
|
-
let r =
|
|
2442
|
+
function qn(e, t, n) {
|
|
2443
|
+
let r = bn[0];
|
|
2444
2444
|
return `
|
|
2445
2445
|
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2446
2446
|
|
|
@@ -2449,30 +2449,30 @@ function Kn(e, t, n) {
|
|
|
2449
2449
|
<h2 id="dz-token-title">Insert field</h2>
|
|
2450
2450
|
|
|
2451
2451
|
<div class="dz-tokens" role="radiogroup" aria-labelledby="dz-token-title">
|
|
2452
|
-
${
|
|
2452
|
+
${bn.map((e, t) => `
|
|
2453
2453
|
<label class="dz-token">
|
|
2454
|
-
<input type="radio" name="dz-token" value="${
|
|
2454
|
+
<input type="radio" name="dz-token" value="${p(e.id)}"
|
|
2455
2455
|
${t === 0 ? "checked" : ""}>
|
|
2456
2456
|
<span class="dz-token-body">
|
|
2457
|
-
<span class="dz-token-name">${
|
|
2458
|
-
<code class="dz-token-syntax">${
|
|
2459
|
-
${e.note ? `<span class="dz-token-note">${
|
|
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
2460
|
</span>
|
|
2461
2461
|
</label>`).join("")}
|
|
2462
2462
|
</div>
|
|
2463
2463
|
|
|
2464
|
-
${
|
|
2464
|
+
${Jn("field", "Field", t.map((e) => ({
|
|
2465
2465
|
value: e,
|
|
2466
2466
|
label: e
|
|
2467
2467
|
})), t[0], {
|
|
2468
|
-
hidden: !
|
|
2468
|
+
hidden: !Sn(r),
|
|
2469
2469
|
empty: "No fields yet - add a table first"
|
|
2470
2470
|
})}
|
|
2471
2471
|
|
|
2472
|
-
${
|
|
2472
|
+
${Jn("band", "Band", On(e, r).map((e) => ({
|
|
2473
2473
|
value: e,
|
|
2474
2474
|
label: e
|
|
2475
|
-
})),
|
|
2475
|
+
})), kn(e, r, n))}
|
|
2476
2476
|
|
|
2477
2477
|
<p class="dz-token-warning" data-role="token-warning" aria-live="polite" hidden></p>
|
|
2478
2478
|
|
|
@@ -2482,17 +2482,17 @@ function Kn(e, t, n) {
|
|
|
2482
2482
|
</div>
|
|
2483
2483
|
</div>`;
|
|
2484
2484
|
}
|
|
2485
|
-
function
|
|
2485
|
+
function Jn(e, t, n, r, { hidden: i = !1, empty: a = "" } = {}) {
|
|
2486
2486
|
return n.length ? `
|
|
2487
2487
|
<div class="dz-field dz-field-picker" data-role="${e}-row"${i ? " hidden" : ""}>
|
|
2488
|
-
<label id="dz-${e}-label">${
|
|
2488
|
+
<label id="dz-${e}-label">${p(t)}</label>
|
|
2489
2489
|
|
|
2490
2490
|
<div class="dropdown" data-role="${e}-dropdown">
|
|
2491
|
-
${
|
|
2491
|
+
${Yn(e, n, r)}
|
|
2492
2492
|
</div>
|
|
2493
|
-
</div>` : `<p class="modal-summary">${
|
|
2493
|
+
</div>` : `<p class="modal-summary">${p(a)}</p>`;
|
|
2494
2494
|
}
|
|
2495
|
-
function
|
|
2495
|
+
function Yn(e, t, n) {
|
|
2496
2496
|
return `
|
|
2497
2497
|
<button type="button" class="dropdown-trigger"
|
|
2498
2498
|
aria-haspopup="listbox" aria-expanded="false"
|
|
@@ -2505,18 +2505,18 @@ function Jn(e, t, n) {
|
|
|
2505
2505
|
aria-labelledby="dz-${e}-label" hidden>
|
|
2506
2506
|
${t.map((e) => `
|
|
2507
2507
|
<li class="dropdown-item" role="option" tabindex="-1"
|
|
2508
|
-
data-value="${
|
|
2508
|
+
data-value="${p(e.value)}"
|
|
2509
2509
|
${e.value === n ? "data-selected=\"true\"" : ""}
|
|
2510
|
-
>${
|
|
2510
|
+
>${p(e.label)}</li>`).join("")}
|
|
2511
2511
|
</ul>`;
|
|
2512
2512
|
}
|
|
2513
|
-
function
|
|
2513
|
+
function Xn(e, t, { limit: n = 12 } = {}) {
|
|
2514
2514
|
let r;
|
|
2515
2515
|
try {
|
|
2516
|
-
r =
|
|
2516
|
+
r = v(e, t ?? {});
|
|
2517
2517
|
} catch (e) {
|
|
2518
2518
|
return {
|
|
2519
|
-
markup:
|
|
2519
|
+
markup: Zn(e),
|
|
2520
2520
|
pageCount: 0,
|
|
2521
2521
|
error: e?.message ?? String(e)
|
|
2522
2522
|
};
|
|
@@ -2524,43 +2524,43 @@ function Yn(e, t, { limit: n = 12 } = {}) {
|
|
|
2524
2524
|
let i = r.pages.length;
|
|
2525
2525
|
return {
|
|
2526
2526
|
markup: `
|
|
2527
|
-
${
|
|
2527
|
+
${h(i > n ? {
|
|
2528
2528
|
...r,
|
|
2529
2529
|
pages: r.pages.slice(0, n)
|
|
2530
2530
|
} : r)}
|
|
2531
|
-
${i > n ?
|
|
2531
|
+
${i > n ? Qn(i, n) : ""}`,
|
|
2532
2532
|
pageCount: i,
|
|
2533
2533
|
error: null
|
|
2534
2534
|
};
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2536
|
+
function Zn(e) {
|
|
2537
2537
|
return `
|
|
2538
2538
|
<div class="dz-problems" role="alert">
|
|
2539
2539
|
<h2>This report will not run yet</h2>
|
|
2540
|
-
<ul>${(e instanceof
|
|
2540
|
+
<ul>${(e instanceof r && e.issues?.length ? e.issues : [e?.message ?? String(e)]).map((e) => `<li>${p(e)}</li>`).join("")}</ul>
|
|
2541
2541
|
</div>`;
|
|
2542
2542
|
}
|
|
2543
|
-
function
|
|
2543
|
+
function Qn(e, t) {
|
|
2544
2544
|
return `
|
|
2545
2545
|
<p class="dz-truncated">
|
|
2546
|
-
Showing the first ${t} of ${
|
|
2546
|
+
Showing the first ${t} of ${p(e)} pages.
|
|
2547
2547
|
Open the preview screen to read them all.
|
|
2548
2548
|
</p>`;
|
|
2549
2549
|
}
|
|
2550
2550
|
//#endregion
|
|
2551
2551
|
//#region src/designer/history.js
|
|
2552
|
-
var
|
|
2553
|
-
function tr(e, { limit: t =
|
|
2554
|
-
let n = [$
|
|
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
2555
|
return {
|
|
2556
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] = $
|
|
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
2558
|
},
|
|
2559
2559
|
undo() {
|
|
2560
|
-
return r === 0 ? null : (r--, i = null, $
|
|
2560
|
+
return r === 0 ? null : (r--, i = null, $(n[r]));
|
|
2561
2561
|
},
|
|
2562
2562
|
redo() {
|
|
2563
|
-
return r >= n.length - 1 ? null : (r++, i = null, $
|
|
2563
|
+
return r >= n.length - 1 ? null : (r++, i = null, $(n[r]));
|
|
2564
2564
|
},
|
|
2565
2565
|
get canUndo() {
|
|
2566
2566
|
return r > 0;
|
|
@@ -2572,7 +2572,7 @@ function tr(e, { limit: t = Qn } = {}) {
|
|
|
2572
2572
|
return n.length;
|
|
2573
2573
|
},
|
|
2574
2574
|
reset(e) {
|
|
2575
|
-
n = [$
|
|
2575
|
+
n = [$(e)], r = 0, i = null;
|
|
2576
2576
|
}
|
|
2577
2577
|
};
|
|
2578
2578
|
}
|
|
@@ -2595,7 +2595,7 @@ function sr(e) {
|
|
|
2595
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
2596
|
}
|
|
2597
2597
|
function cr({ width: e, height: t, features: n, ...r } = {}) {
|
|
2598
|
-
let i =
|
|
2598
|
+
let i = d({
|
|
2599
2599
|
title: r.layout?.name ? `${r.layout.name} - Designer` : "Report designer",
|
|
2600
2600
|
width: e,
|
|
2601
2601
|
height: t,
|
|
@@ -2605,7 +2605,7 @@ function cr({ width: e, height: t, features: n, ...r } = {}) {
|
|
|
2605
2605
|
let a = lr({
|
|
2606
2606
|
...r,
|
|
2607
2607
|
mount: i.mount
|
|
2608
|
-
}), o =
|
|
2608
|
+
}), o = te(globalThis, i.window, a.destroy);
|
|
2609
2609
|
return {
|
|
2610
2610
|
...a,
|
|
2611
2611
|
window: i.window,
|
|
@@ -2614,68 +2614,68 @@ function cr({ width: e, height: t, features: n, ...r } = {}) {
|
|
|
2614
2614
|
}
|
|
2615
2615
|
};
|
|
2616
2616
|
}
|
|
2617
|
-
function lr({ mount: e, layout: t, id: n = null, store: r, guardUnload:
|
|
2618
|
-
let
|
|
2619
|
-
if (!
|
|
2620
|
-
let c =
|
|
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
2621
|
sr(r);
|
|
2622
|
-
let l = r ??
|
|
2622
|
+
let l = r ?? Yt(), d = {
|
|
2623
2623
|
zoom: 1,
|
|
2624
2624
|
fitWidth: !1,
|
|
2625
2625
|
rulers: !1,
|
|
2626
|
-
layout:
|
|
2626
|
+
layout: pe(t) ? fe() : t,
|
|
2627
2627
|
selection: [],
|
|
2628
2628
|
id: n,
|
|
2629
2629
|
dirty: !1,
|
|
2630
2630
|
clipboard: [],
|
|
2631
2631
|
mode: "design",
|
|
2632
2632
|
dismissed: null
|
|
2633
|
-
}, f = tr(
|
|
2634
|
-
|
|
2635
|
-
let
|
|
2636
|
-
function
|
|
2637
|
-
return
|
|
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
2638
|
}
|
|
2639
|
-
function
|
|
2640
|
-
return e ? (
|
|
2639
|
+
function C(e) {
|
|
2640
|
+
return e ? (J(d.layout, e.band)?.items || []).find((t) => t.id === e.id) ?? null : null;
|
|
2641
2641
|
}
|
|
2642
|
-
function
|
|
2643
|
-
return
|
|
2642
|
+
function w() {
|
|
2643
|
+
return C(S());
|
|
2644
2644
|
}
|
|
2645
|
-
function
|
|
2646
|
-
return
|
|
2645
|
+
function T() {
|
|
2646
|
+
return d.selection.map(C).filter(Boolean);
|
|
2647
2647
|
}
|
|
2648
|
-
function
|
|
2649
|
-
let e = d
|
|
2650
|
-
if (
|
|
2651
|
-
let t =
|
|
2652
|
-
return
|
|
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
2653
|
}
|
|
2654
|
-
|
|
2654
|
+
x.textContent = "";
|
|
2655
2655
|
let t = "";
|
|
2656
2656
|
try {
|
|
2657
|
-
t =
|
|
2657
|
+
t = Fe(d.layout, d.selection, { rulers: d.rulers });
|
|
2658
2658
|
} catch {
|
|
2659
2659
|
t = "";
|
|
2660
2660
|
}
|
|
2661
|
-
return
|
|
2661
|
+
return h.innerHTML = t, D(e), me(), e;
|
|
2662
2662
|
}
|
|
2663
|
-
function
|
|
2664
|
-
let t =
|
|
2665
|
-
|
|
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
2666
|
}
|
|
2667
|
-
function
|
|
2668
|
-
|
|
2669
|
-
let e =
|
|
2667
|
+
function ae() {
|
|
2668
|
+
O();
|
|
2669
|
+
let e = Pe(d.layout, d.selection);
|
|
2670
2670
|
for (let [t, { item: n, box: r }] of e.entries()) {
|
|
2671
|
-
let e =
|
|
2671
|
+
let e = d.selection[t], i = p.querySelector(`[data-role="select"][data-select-id="${dr(n.id)}"]`);
|
|
2672
2672
|
i && Object.assign(i.style, {
|
|
2673
2673
|
top: `${r.y}px`,
|
|
2674
2674
|
left: `${r.x}px`,
|
|
2675
2675
|
width: `${r.w}px`,
|
|
2676
2676
|
height: `${r.h}px`
|
|
2677
2677
|
});
|
|
2678
|
-
let a =
|
|
2678
|
+
let a = p.querySelector(`[data-band-type="${dr(e.band)}"] [data-item-id="${dr(n.id)}"]`);
|
|
2679
2679
|
a && (Object.assign(a.style, {
|
|
2680
2680
|
top: `${n.y}px`,
|
|
2681
2681
|
left: `${n.x}px`,
|
|
@@ -2683,109 +2683,109 @@ function lr({ mount: e, layout: t, id: n = null, store: r, guardUnload: i = !0,
|
|
|
2683
2683
|
}), n.type !== "table" && (a.style.height = `${n.h}px`));
|
|
2684
2684
|
}
|
|
2685
2685
|
}
|
|
2686
|
-
function
|
|
2687
|
-
let e =
|
|
2688
|
-
e && (e.innerHTML =
|
|
2689
|
-
for (let e of
|
|
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
2690
|
}
|
|
2691
|
-
function
|
|
2692
|
-
if (
|
|
2693
|
-
let e =
|
|
2694
|
-
|
|
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
2695
|
}
|
|
2696
|
-
let
|
|
2697
|
-
function
|
|
2696
|
+
let A = (e, t) => e?.band === t?.band && e?.id === t?.id;
|
|
2697
|
+
function j(e, { add: t = !1 } = {}) {
|
|
2698
2698
|
let n = e == null ? [] : [].concat(e), r;
|
|
2699
2699
|
if (!t) r = n;
|
|
2700
2700
|
else {
|
|
2701
|
-
r = [...
|
|
2701
|
+
r = [...d.selection];
|
|
2702
2702
|
for (let e of n) {
|
|
2703
|
-
let t = r.findIndex((t) =>
|
|
2703
|
+
let t = r.findIndex((t) => A(t, e));
|
|
2704
2704
|
t === -1 ? r.push(e) : r.splice(t, 1);
|
|
2705
2705
|
}
|
|
2706
2706
|
}
|
|
2707
|
-
r.length ===
|
|
2707
|
+
r.length === d.selection.length && r.every((e, t) => A(e, d.selection[t])) || (d.selection = r, E(), k());
|
|
2708
2708
|
}
|
|
2709
|
-
function
|
|
2710
|
-
f.push(
|
|
2709
|
+
function oe(e = null) {
|
|
2710
|
+
f.push(d.layout, e) && (d.dirty = !0, N(), se());
|
|
2711
2711
|
}
|
|
2712
|
-
function
|
|
2713
|
-
if (typeof
|
|
2714
|
-
|
|
2712
|
+
function se() {
|
|
2713
|
+
if (typeof o == "function") try {
|
|
2714
|
+
o(d.layout);
|
|
2715
2715
|
} catch (e) {
|
|
2716
2716
|
console.error("createDesigner: onChange threw", e);
|
|
2717
2717
|
}
|
|
2718
2718
|
}
|
|
2719
|
-
function
|
|
2720
|
-
|
|
2721
|
-
}
|
|
2722
|
-
function I() {
|
|
2723
|
-
x.querySelector("[data-role=\"name\"]").textContent = u.layout.name ?? "", x.querySelector("[data-role=\"undo\"]").disabled = !f.canUndo, x.querySelector("[data-role=\"redo\"]").disabled = !f.canRedo;
|
|
2724
|
-
let e = x.querySelector("[data-role=\"size\"]");
|
|
2725
|
-
e && u.layout.page && (e.innerHTML = `${u.layout.page.width} × ${u.layout.page.height}`);
|
|
2726
|
-
let t = x.querySelector("[data-role=\"rulers\"]");
|
|
2727
|
-
t.setAttribute("aria-pressed", String(u.rulers)), t.classList.toggle("is-on", u.rulers);
|
|
2728
|
-
let n = S.querySelector("[data-role=\"add-table\"]");
|
|
2729
|
-
n.disabled = !tt(u.layout), x.dataset.dirty = String(u.dirty);
|
|
2730
|
-
let r = x.querySelector("[data-role=\"status\"]");
|
|
2731
|
-
r.textContent = u.dirty ? "Unsaved changes" : u.id ? `Saved as ${u.id}.json` : "Not saved yet";
|
|
2732
|
-
}
|
|
2733
|
-
function L(e, { id: t, dirty: n }) {
|
|
2734
|
-
u.layout = e, u.selection = [], u.mode = "design", u.data = null, t !== void 0 && (u.id = t), n !== void 0 && (u.dirty = n), Ee(), ie();
|
|
2719
|
+
function M(e = null) {
|
|
2720
|
+
E(), k(), oe(e);
|
|
2735
2721
|
}
|
|
2736
|
-
function
|
|
2737
|
-
|
|
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
2738
|
band: e,
|
|
2739
2739
|
id: t.id
|
|
2740
|
-
}],
|
|
2740
|
+
}], M(`add:${t.id}`), L(e);
|
|
2741
2741
|
}
|
|
2742
|
-
function
|
|
2742
|
+
function ue(e) {
|
|
2743
2743
|
let t = new Set(e == null ? [] : [].concat(e));
|
|
2744
|
-
for (let e of
|
|
2745
|
-
for (let e of
|
|
2746
|
-
}
|
|
2747
|
-
function ce(e) {
|
|
2748
|
-
let t = _.querySelector("[data-role=\"guides\"]");
|
|
2749
|
-
t && (t.innerHTML = e ? Pe(Ne(u.layout, e.band), e.lines, e.gaps) : "");
|
|
2750
|
-
}
|
|
2751
|
-
function de() {
|
|
2752
|
-
y.style.transformOrigin = "top left", y.style.transform = `scale(${u.zoom})`;
|
|
2753
|
-
let e = y.offsetWidth, t = y.offsetHeight;
|
|
2754
|
-
e && t && (v.style.width = `${e * u.zoom}px`, v.style.height = `${t * u.zoom}px`), fe();
|
|
2755
|
-
}
|
|
2756
|
-
function fe() {
|
|
2757
|
-
if (G && !u.fitWidth) {
|
|
2758
|
-
let e = g.find((e) => Math.abs(e - u.zoom) < 1e-9);
|
|
2759
|
-
G.value = e === void 0 ? "fit" : String(e);
|
|
2760
|
-
}
|
|
2761
|
-
x.querySelector("[data-role=\"zoom-out\"]").disabled = !u.fitWidth && u.zoom <= p, x.querySelector("[data-role=\"zoom-in\"]").disabled = !u.fitWidth && u.zoom >= ee;
|
|
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));
|
|
2762
2746
|
}
|
|
2763
|
-
function
|
|
2764
|
-
|
|
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) : "");
|
|
2765
2750
|
}
|
|
2766
2751
|
function me() {
|
|
2767
|
-
|
|
2768
|
-
let e =
|
|
2769
|
-
e
|
|
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();
|
|
2770
2755
|
}
|
|
2771
|
-
function
|
|
2772
|
-
|
|
2773
|
-
|
|
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;
|
|
2774
2762
|
}
|
|
2775
|
-
function
|
|
2776
|
-
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
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
2789
|
x: e - n.left,
|
|
2790
2790
|
y: t - n.top
|
|
2791
2791
|
}, {
|
|
@@ -2795,10 +2795,10 @@ function lr({ mount: e, layout: t, id: n = null, store: r, guardUnload: i = !0,
|
|
|
2795
2795
|
width: n.width,
|
|
2796
2796
|
height: n.height
|
|
2797
2797
|
});
|
|
2798
|
-
|
|
2798
|
+
R.style.left = `${i.left}px`, R.style.top = `${i.top}px`, R.querySelector("button:not([disabled])")?.focus();
|
|
2799
2799
|
}
|
|
2800
|
-
function
|
|
2801
|
-
if (
|
|
2800
|
+
function ye(e) {
|
|
2801
|
+
if (d.mode !== "design") return;
|
|
2802
2802
|
e.preventDefault();
|
|
2803
2803
|
let t = e.target.closest?.("[data-item-id]"), n = t?.closest("[data-band-type]")?.dataset.bandType ?? null;
|
|
2804
2804
|
if (t && n) {
|
|
@@ -2806,452 +2806,452 @@ function lr({ mount: e, layout: t, id: n = null, store: r, guardUnload: i = !0,
|
|
|
2806
2806
|
band: n,
|
|
2807
2807
|
id: t.dataset.itemId
|
|
2808
2808
|
};
|
|
2809
|
-
|
|
2810
|
-
} else
|
|
2811
|
-
|
|
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
2812
|
}
|
|
2813
|
-
function
|
|
2813
|
+
function be(e) {
|
|
2814
2814
|
let t = e.target.closest?.("[data-action]");
|
|
2815
|
-
!t || t.disabled || (e.preventDefault(),
|
|
2815
|
+
!t || t.disabled || (e.preventDefault(), z(), V(t.dataset.action, t.dataset));
|
|
2816
2816
|
}
|
|
2817
|
-
function
|
|
2818
|
-
|
|
2817
|
+
function B(e) {
|
|
2818
|
+
R && !R.contains(e.target) && z();
|
|
2819
2819
|
}
|
|
2820
|
-
function
|
|
2821
|
-
|
|
2820
|
+
function xe(e) {
|
|
2821
|
+
R && e.key === "Escape" && z();
|
|
2822
2822
|
}
|
|
2823
|
-
function
|
|
2824
|
-
let n =
|
|
2823
|
+
function V(e, t) {
|
|
2824
|
+
let n = w();
|
|
2825
2825
|
switch (e) {
|
|
2826
2826
|
case "add-text": {
|
|
2827
|
-
let e =
|
|
2827
|
+
let e = kt(d.layout, S());
|
|
2828
2828
|
if (!e) return;
|
|
2829
|
-
|
|
2829
|
+
F(e, dt(d.layout, J(d.layout, e)));
|
|
2830
2830
|
return;
|
|
2831
2831
|
}
|
|
2832
2832
|
case "add-box": {
|
|
2833
|
-
let e =
|
|
2833
|
+
let e = kt(d.layout, S());
|
|
2834
2834
|
if (!e) return;
|
|
2835
|
-
|
|
2835
|
+
F(e, pt(d.layout, J(d.layout, e)));
|
|
2836
2836
|
return;
|
|
2837
2837
|
}
|
|
2838
2838
|
case "add-image": {
|
|
2839
|
-
let e =
|
|
2839
|
+
let e = kt(d.layout, S());
|
|
2840
2840
|
if (!e) return;
|
|
2841
|
-
|
|
2841
|
+
F(e, mt(d.layout, J(d.layout, e)));
|
|
2842
2842
|
return;
|
|
2843
2843
|
}
|
|
2844
2844
|
case "upload-image":
|
|
2845
2845
|
if (n?.type !== "image") return;
|
|
2846
|
-
|
|
2846
|
+
Me(n);
|
|
2847
2847
|
return;
|
|
2848
2848
|
case "clear-image":
|
|
2849
2849
|
if (n?.type !== "image" || !n.src) return;
|
|
2850
|
-
n.src = null,
|
|
2850
|
+
n.src = null, M(`image:${n.id}`);
|
|
2851
2851
|
return;
|
|
2852
2852
|
case "add-line": {
|
|
2853
|
-
let e =
|
|
2853
|
+
let e = kt(d.layout, S());
|
|
2854
2854
|
if (!e) return;
|
|
2855
|
-
|
|
2855
|
+
F(e, ft(d.layout, J(d.layout, e), t?.orientation));
|
|
2856
2856
|
return;
|
|
2857
2857
|
}
|
|
2858
2858
|
case "add-field":
|
|
2859
|
-
|
|
2859
|
+
Wn(s, d.layout, S()?.band ?? null).then((e) => {
|
|
2860
2860
|
if (!e) return;
|
|
2861
|
-
let t =
|
|
2861
|
+
let t = J(d.layout, e.band);
|
|
2862
2862
|
if (!t) return;
|
|
2863
|
-
let n =
|
|
2864
|
-
n.value = e.value, n.w = e.w, n.style.align = e.align,
|
|
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
2865
|
});
|
|
2866
2866
|
return;
|
|
2867
2867
|
case "add-table": {
|
|
2868
|
-
let e =
|
|
2869
|
-
if (!e || !
|
|
2870
|
-
|
|
2871
|
-
t != null &&
|
|
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
2872
|
});
|
|
2873
2873
|
return;
|
|
2874
2874
|
}
|
|
2875
2875
|
case "duplicate-item": {
|
|
2876
|
-
if (!
|
|
2877
|
-
let e = [...
|
|
2876
|
+
if (!d.selection.length) return;
|
|
2877
|
+
let e = [...d.selection], t = [];
|
|
2878
2878
|
for (let n of e) {
|
|
2879
|
-
let e =
|
|
2879
|
+
let e = xt(d.layout, n.band, n.id);
|
|
2880
2880
|
e && t.push({
|
|
2881
2881
|
band: n.band,
|
|
2882
2882
|
id: e.id
|
|
2883
2883
|
});
|
|
2884
2884
|
}
|
|
2885
2885
|
if (!t.length) return;
|
|
2886
|
-
|
|
2886
|
+
d.selection = t, M(`duplicate:${t.map((e) => e.id).join(",")}`), L([...new Set(t.map((e) => e.band))]);
|
|
2887
2887
|
return;
|
|
2888
2888
|
}
|
|
2889
2889
|
case "dismiss-problems":
|
|
2890
|
-
|
|
2890
|
+
d.dismissed = i(d.layout), b.innerHTML = "";
|
|
2891
2891
|
return;
|
|
2892
2892
|
case "copy-items": {
|
|
2893
|
-
if (!
|
|
2894
|
-
let e =
|
|
2893
|
+
if (!d.selection.length) return;
|
|
2894
|
+
let e = d.selection.map((e) => ({
|
|
2895
2895
|
band: e.band,
|
|
2896
|
-
item:
|
|
2896
|
+
item: C(e)
|
|
2897
2897
|
})).filter((e) => e.item).map((e) => ({
|
|
2898
2898
|
band: e.band,
|
|
2899
2899
|
item: structuredClone(e.item)
|
|
2900
2900
|
}));
|
|
2901
2901
|
if (!e.length) return;
|
|
2902
|
-
|
|
2902
|
+
d.clipboard = e, W(e.length > 1 ? `Copied ${e.length} items` : "Copied", { ms: 2e3 });
|
|
2903
2903
|
return;
|
|
2904
2904
|
}
|
|
2905
2905
|
case "paste-items": {
|
|
2906
|
-
if (!
|
|
2907
|
-
let e =
|
|
2906
|
+
if (!d.clipboard.length) return;
|
|
2907
|
+
let e = kt(d.layout, S());
|
|
2908
2908
|
if (!e) return;
|
|
2909
|
-
let t =
|
|
2909
|
+
let t = wt(d.layout, e, d.clipboard);
|
|
2910
2910
|
if (!t.length) return;
|
|
2911
|
-
|
|
2911
|
+
d.clipboard = t.map((t) => ({
|
|
2912
2912
|
band: e,
|
|
2913
2913
|
item: structuredClone(t)
|
|
2914
|
-
})),
|
|
2914
|
+
})), d.selection = t.map((t) => ({
|
|
2915
2915
|
band: e,
|
|
2916
2916
|
id: t.id
|
|
2917
|
-
})),
|
|
2917
|
+
})), M(`paste:${t.map((e) => e.id).join(",")}`), L(e);
|
|
2918
2918
|
return;
|
|
2919
2919
|
}
|
|
2920
2920
|
case "delete-item": {
|
|
2921
|
-
if (!
|
|
2922
|
-
let e =
|
|
2923
|
-
for (let e of
|
|
2924
|
-
|
|
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
2925
|
return;
|
|
2926
2926
|
}
|
|
2927
2927
|
case "add-column":
|
|
2928
2928
|
if (n?.type !== "table") return;
|
|
2929
|
-
|
|
2929
|
+
Dt(n), M(`column:add:${n.id}`);
|
|
2930
2930
|
return;
|
|
2931
2931
|
case "remove-column":
|
|
2932
2932
|
if (n?.type !== "table") return;
|
|
2933
|
-
|
|
2933
|
+
Ot(n, Number(t.index)) && M(`column:remove:${n.id}`);
|
|
2934
2934
|
return;
|
|
2935
2935
|
case "undo": {
|
|
2936
2936
|
let e = f.undo();
|
|
2937
|
-
e &&
|
|
2937
|
+
e && P(e, { dirty: !0 });
|
|
2938
2938
|
return;
|
|
2939
2939
|
}
|
|
2940
2940
|
case "redo": {
|
|
2941
2941
|
let e = f.redo();
|
|
2942
|
-
e &&
|
|
2942
|
+
e && P(e, { dirty: !0 });
|
|
2943
2943
|
return;
|
|
2944
2944
|
}
|
|
2945
|
-
case "open": return
|
|
2946
|
-
case "save": return
|
|
2947
|
-
case "data": return
|
|
2948
|
-
case "open-window": return
|
|
2949
|
-
case "zoom-in": return
|
|
2950
|
-
case "zoom-out": return
|
|
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
2951
|
case "toggle-rulers":
|
|
2952
|
-
|
|
2952
|
+
d.rulers = !d.rulers, E(), N();
|
|
2953
2953
|
return;
|
|
2954
|
-
case "toggle-preview": return
|
|
2954
|
+
case "toggle-preview": return U();
|
|
2955
2955
|
}
|
|
2956
2956
|
}
|
|
2957
|
-
async function
|
|
2958
|
-
return !
|
|
2957
|
+
async function Se() {
|
|
2958
|
+
return !d.dirty || Fn(s, d.layout?.name ?? "");
|
|
2959
2959
|
}
|
|
2960
|
-
async function
|
|
2961
|
-
if (!await
|
|
2960
|
+
async function Ce() {
|
|
2961
|
+
if (!await Se()) return;
|
|
2962
2962
|
let e;
|
|
2963
2963
|
try {
|
|
2964
2964
|
e = await l.list();
|
|
2965
2965
|
} catch (e) {
|
|
2966
|
-
return
|
|
2966
|
+
return G(e);
|
|
2967
2967
|
}
|
|
2968
|
-
let t = await
|
|
2968
|
+
let t = await Nn(s, e);
|
|
2969
2969
|
if (t) {
|
|
2970
2970
|
if (t.blank) {
|
|
2971
|
-
|
|
2971
|
+
P(fe(), {
|
|
2972
2972
|
id: null,
|
|
2973
2973
|
dirty: !1
|
|
2974
|
-
}), f.reset(
|
|
2974
|
+
}), f.reset(d.layout), N();
|
|
2975
2975
|
return;
|
|
2976
2976
|
}
|
|
2977
2977
|
try {
|
|
2978
|
-
|
|
2978
|
+
P(await l.load(t.id), {
|
|
2979
2979
|
id: t.id,
|
|
2980
2980
|
dirty: !1
|
|
2981
|
-
}), f.reset(
|
|
2981
|
+
}), f.reset(d.layout), N();
|
|
2982
2982
|
} catch (e) {
|
|
2983
|
-
|
|
2983
|
+
G(e);
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
2987
|
-
async function
|
|
2988
|
-
let e =
|
|
2987
|
+
async function we() {
|
|
2988
|
+
let e = d.id;
|
|
2989
2989
|
if (!e) {
|
|
2990
|
-
let t = await
|
|
2990
|
+
let t = await Pn(s, d.layout.name ?? "");
|
|
2991
2991
|
if (!t) return;
|
|
2992
|
-
e = t.id,
|
|
2992
|
+
e = t.id, d.layout.name = t.name;
|
|
2993
2993
|
}
|
|
2994
2994
|
try {
|
|
2995
|
-
await l.save(e,
|
|
2995
|
+
await l.save(e, d.layout), d.id = e, d.dirty = !1, N(), await Te(e);
|
|
2996
2996
|
} catch (e) {
|
|
2997
|
-
|
|
2997
|
+
G(e);
|
|
2998
2998
|
}
|
|
2999
2999
|
}
|
|
3000
|
-
async function
|
|
3000
|
+
async function Te(e) {
|
|
3001
3001
|
if (!(!l.loadData || !l.saveData)) try {
|
|
3002
|
-
let { data: t, added: n } =
|
|
3002
|
+
let { data: t, added: n } = ln(await l.loadData(e), d.layout);
|
|
3003
3003
|
n && await l.saveData(e, t);
|
|
3004
3004
|
} catch {}
|
|
3005
3005
|
}
|
|
3006
|
-
async function
|
|
3006
|
+
async function Ee() {
|
|
3007
3007
|
let e = null;
|
|
3008
|
-
if (
|
|
3009
|
-
e = await l.loadData(
|
|
3008
|
+
if (d.id && l.loadData) try {
|
|
3009
|
+
e = await l.loadData(d.id);
|
|
3010
3010
|
} catch (e) {
|
|
3011
|
-
return
|
|
3011
|
+
return G(e);
|
|
3012
3012
|
}
|
|
3013
|
-
let t = e == null, n = await
|
|
3014
|
-
id:
|
|
3013
|
+
let t = e == null, n = await Hn(s, ln(e, d.layout).data, {
|
|
3014
|
+
id: d.id,
|
|
3015
3015
|
generated: t
|
|
3016
3016
|
});
|
|
3017
3017
|
if (n) {
|
|
3018
|
-
if (!
|
|
3018
|
+
if (!d.id) return G(/* @__PURE__ */ Error("Save the report first - its data file is named after it."));
|
|
3019
3019
|
try {
|
|
3020
|
-
await l.saveData(
|
|
3020
|
+
await l.saveData(d.id, n);
|
|
3021
3021
|
} catch (e) {
|
|
3022
|
-
|
|
3022
|
+
G(e);
|
|
3023
3023
|
}
|
|
3024
3024
|
}
|
|
3025
3025
|
}
|
|
3026
|
-
function
|
|
3026
|
+
function De() {
|
|
3027
3027
|
let e;
|
|
3028
3028
|
try {
|
|
3029
|
-
e =
|
|
3029
|
+
e = v(d.layout, d.data ?? cn(d.layout));
|
|
3030
3030
|
} catch (e) {
|
|
3031
|
-
|
|
3031
|
+
G(e);
|
|
3032
3032
|
return;
|
|
3033
3033
|
}
|
|
3034
|
-
let t =
|
|
3034
|
+
let t = u({
|
|
3035
3035
|
paginated: e,
|
|
3036
|
-
title:
|
|
3036
|
+
title: d.layout?.name || "Report"
|
|
3037
3037
|
});
|
|
3038
3038
|
if (!t) {
|
|
3039
|
-
|
|
3039
|
+
W("The browser blocked the report window - allow pop-ups for this page", {
|
|
3040
3040
|
problem: !0,
|
|
3041
3041
|
ms: 6e3
|
|
3042
3042
|
});
|
|
3043
3043
|
return;
|
|
3044
3044
|
}
|
|
3045
|
-
|
|
3045
|
+
Oe.add(t);
|
|
3046
3046
|
}
|
|
3047
|
-
let
|
|
3048
|
-
async function
|
|
3049
|
-
if (
|
|
3050
|
-
|
|
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
3051
|
return;
|
|
3052
3052
|
}
|
|
3053
3053
|
let e = null;
|
|
3054
|
-
if (
|
|
3055
|
-
e = await l.loadData(
|
|
3054
|
+
if (d.id && l.loadData) try {
|
|
3055
|
+
e = await l.loadData(d.id);
|
|
3056
3056
|
} catch {}
|
|
3057
|
-
|
|
3057
|
+
d.data = ln(e, d.layout).data, d.mode = "preview", d.selection = [], ke();
|
|
3058
3058
|
}
|
|
3059
|
-
function
|
|
3060
|
-
|
|
3061
|
-
let e =
|
|
3062
|
-
e.innerHTML =
|
|
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
3063
|
}
|
|
3064
|
-
function
|
|
3065
|
-
let r =
|
|
3066
|
-
r.textContent = e, t ? r.dataset.problem = "true" : delete r.dataset.problem, clearTimeout(
|
|
3067
|
-
delete r.dataset.problem,
|
|
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
3068
|
}, n);
|
|
3069
3069
|
}
|
|
3070
|
-
function
|
|
3070
|
+
function Me(e) {
|
|
3071
3071
|
let t = c.createElement("input");
|
|
3072
3072
|
t.type = "file", t.accept = nr.join(","), t.addEventListener("change", () => {
|
|
3073
3073
|
let n = t.files?.[0];
|
|
3074
3074
|
if (!n) return;
|
|
3075
3075
|
if (!nr.includes(n.type)) {
|
|
3076
|
-
|
|
3076
|
+
W(`${n.name} is not a PNG, JPEG, GIF or WebP image`, { problem: !0 });
|
|
3077
3077
|
return;
|
|
3078
3078
|
}
|
|
3079
3079
|
if (n.size > rr) {
|
|
3080
|
-
|
|
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
3081
|
return;
|
|
3082
3082
|
}
|
|
3083
3083
|
let r = new (c.defaultView ?? globalThis).FileReader();
|
|
3084
3084
|
r.addEventListener("load", () => {
|
|
3085
|
-
|
|
3086
|
-
}), r.addEventListener("error", () =>
|
|
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
3087
|
}), t.click();
|
|
3088
3088
|
}
|
|
3089
|
-
function
|
|
3090
|
-
return (
|
|
3089
|
+
function Ne(e) {
|
|
3090
|
+
return (d.layout.bands ?? []).some((t) => (t.items ?? []).includes(e));
|
|
3091
3091
|
}
|
|
3092
|
-
function
|
|
3093
|
-
|
|
3092
|
+
function G(e) {
|
|
3093
|
+
W(e instanceof Xt ? e.message : `Something went wrong: ${e?.message ?? e}`, { problem: !0 });
|
|
3094
3094
|
}
|
|
3095
|
-
function
|
|
3096
|
-
t ?
|
|
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
3097
|
}
|
|
3098
|
-
function
|
|
3099
|
-
let n =
|
|
3098
|
+
function ze(e, t) {
|
|
3099
|
+
let n = J(d.layout, e);
|
|
3100
3100
|
if (!n) return;
|
|
3101
3101
|
let r = String(t).trim();
|
|
3102
3102
|
if (r === "") delete n.height;
|
|
3103
3103
|
else if (/^-?[\d.]+\s*%$/.test(r)) n.height = r;
|
|
3104
3104
|
else if (Number.isFinite(Number(r))) n.height = Number(r);
|
|
3105
3105
|
else return;
|
|
3106
|
-
|
|
3106
|
+
E(), oe(`band-height:${e}`);
|
|
3107
3107
|
}
|
|
3108
|
-
|
|
3109
|
-
|
|
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
3110
|
});
|
|
3111
|
-
let
|
|
3112
|
-
|
|
3113
|
-
},
|
|
3114
|
-
|
|
3115
|
-
let
|
|
3116
|
-
|
|
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
3117
|
};
|
|
3118
|
-
|
|
3119
|
-
let
|
|
3120
|
-
canvas:
|
|
3121
|
-
getLayout: () =>
|
|
3122
|
-
getSelection: () =>
|
|
3123
|
-
select:
|
|
3124
|
-
remove: () =>
|
|
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
3125
|
duplicate: () => {
|
|
3126
|
-
let e =
|
|
3127
|
-
return
|
|
3126
|
+
let e = d.selection.map((e) => e.id).join(",");
|
|
3127
|
+
return V("duplicate-item"), d.selection.map((e) => e.id).join(",") !== e;
|
|
3128
3128
|
},
|
|
3129
|
-
enabled: () =>
|
|
3130
|
-
getZoom: () =>
|
|
3131
|
-
rulers: () =>
|
|
3132
|
-
onTarget:
|
|
3133
|
-
onGuides:
|
|
3129
|
+
enabled: () => d.mode === "design",
|
|
3130
|
+
getZoom: () => d.zoom,
|
|
3131
|
+
rulers: () => d.rulers,
|
|
3132
|
+
onTarget: ue,
|
|
3133
|
+
onGuides: de,
|
|
3134
3134
|
commit: ({ live: e, band: t, key: n = null }) => {
|
|
3135
3135
|
if (!e && t?.length) {
|
|
3136
3136
|
let e = !1;
|
|
3137
|
-
|
|
3138
|
-
let n =
|
|
3139
|
-
return r && r !== t.band &&
|
|
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
3140
|
band: r,
|
|
3141
3141
|
id: t.id
|
|
3142
3142
|
}) : t;
|
|
3143
|
-
}), e &&
|
|
3143
|
+
}), e && k();
|
|
3144
3144
|
}
|
|
3145
|
-
e ?
|
|
3145
|
+
e ? ae() : E(), zt(te, w(), d.layout), e || oe(n ?? `move:${d.selection.map((e) => e.id).join(",")}`);
|
|
3146
3146
|
}
|
|
3147
|
-
}),
|
|
3148
|
-
panel:
|
|
3147
|
+
}), Ge = Rt({
|
|
3148
|
+
panel: te,
|
|
3149
3149
|
getTarget: () => {
|
|
3150
|
-
let e =
|
|
3150
|
+
let e = w();
|
|
3151
3151
|
return e ? {
|
|
3152
3152
|
target: e,
|
|
3153
|
-
fields:
|
|
3153
|
+
fields: le(e)
|
|
3154
3154
|
} : {
|
|
3155
|
-
target:
|
|
3156
|
-
fields:
|
|
3155
|
+
target: d.layout,
|
|
3156
|
+
fields: ce(d.layout)
|
|
3157
3157
|
};
|
|
3158
3158
|
},
|
|
3159
|
-
getItem:
|
|
3159
|
+
getItem: w,
|
|
3160
3160
|
changed: (e, { rebuild: t = !1 } = {}) => {
|
|
3161
|
-
|
|
3161
|
+
E(), t && k(), oe(e);
|
|
3162
3162
|
},
|
|
3163
|
-
act:
|
|
3164
|
-
toggleBand:
|
|
3165
|
-
setBandHeight:
|
|
3163
|
+
act: V,
|
|
3164
|
+
toggleBand: Re,
|
|
3165
|
+
setBandHeight: ze
|
|
3166
3166
|
});
|
|
3167
|
-
function
|
|
3167
|
+
function K(e) {
|
|
3168
3168
|
let t = e.target.closest?.("[data-action]");
|
|
3169
|
-
t && (e.preventDefault(),
|
|
3169
|
+
t && (e.preventDefault(), V(t.dataset.action, t.dataset));
|
|
3170
3170
|
}
|
|
3171
|
-
function
|
|
3172
|
-
return
|
|
3171
|
+
function Ke(e) {
|
|
3172
|
+
return s.contains(e.target) ? !0 : e.target === c.body || e.target === c.documentElement;
|
|
3173
3173
|
}
|
|
3174
|
-
function
|
|
3174
|
+
function qe(e) {
|
|
3175
3175
|
let t = e.target.closest?.("input, textarea, select, button, a, label, [tabindex]");
|
|
3176
|
-
t && t !==
|
|
3176
|
+
t && t !== s || s.focus({ preventScroll: !0 });
|
|
3177
3177
|
}
|
|
3178
|
-
function
|
|
3179
|
-
if (!
|
|
3178
|
+
function Je(e) {
|
|
3179
|
+
if (!Ke(e)) return;
|
|
3180
3180
|
let t = e.key.toLowerCase();
|
|
3181
3181
|
if (t === "z" && !e.ctrlKey && !e.metaKey) {
|
|
3182
3182
|
if (e.target.closest?.("input, textarea, select")) return;
|
|
3183
|
-
e.preventDefault(),
|
|
3183
|
+
e.preventDefault(), I(e.altKey ? -1 : 1);
|
|
3184
3184
|
return;
|
|
3185
3185
|
}
|
|
3186
3186
|
if (e.ctrlKey || e.metaKey) {
|
|
3187
3187
|
if (t === "c" || t === "v") {
|
|
3188
3188
|
if (e.target.closest?.("input, textarea, select") || t === "c" && String(globalThis.getSelection?.() ?? "")) return;
|
|
3189
|
-
e.preventDefault(),
|
|
3189
|
+
e.preventDefault(), V(t === "c" ? "copy-items" : "paste-items");
|
|
3190
3190
|
return;
|
|
3191
3191
|
}
|
|
3192
3192
|
if (t === "s") {
|
|
3193
|
-
e.preventDefault(),
|
|
3193
|
+
e.preventDefault(), V("save");
|
|
3194
3194
|
return;
|
|
3195
3195
|
}
|
|
3196
3196
|
if (t === "o") {
|
|
3197
|
-
e.preventDefault(),
|
|
3197
|
+
e.preventDefault(), V("open");
|
|
3198
3198
|
return;
|
|
3199
3199
|
}
|
|
3200
3200
|
if (t === "e") {
|
|
3201
|
-
e.preventDefault(),
|
|
3201
|
+
e.preventDefault(), V("toggle-preview");
|
|
3202
3202
|
return;
|
|
3203
3203
|
}
|
|
3204
3204
|
if (t === "0") {
|
|
3205
|
-
e.preventDefault(),
|
|
3205
|
+
e.preventDefault(), ge(1);
|
|
3206
3206
|
return;
|
|
3207
3207
|
}
|
|
3208
3208
|
if (t === "z") {
|
|
3209
|
-
e.preventDefault(),
|
|
3209
|
+
e.preventDefault(), V(e.shiftKey || e.altKey ? "redo" : "undo");
|
|
3210
3210
|
return;
|
|
3211
3211
|
}
|
|
3212
3212
|
if (t === "y") {
|
|
3213
|
-
e.preventDefault(),
|
|
3213
|
+
e.preventDefault(), V("redo");
|
|
3214
3214
|
return;
|
|
3215
3215
|
}
|
|
3216
|
-
t === "d" && (e.preventDefault(),
|
|
3216
|
+
t === "d" && (e.preventDefault(), V("duplicate-item"));
|
|
3217
3217
|
}
|
|
3218
3218
|
}
|
|
3219
|
-
return
|
|
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
3220
|
get layout() {
|
|
3221
|
-
return
|
|
3221
|
+
return d.layout;
|
|
3222
3222
|
},
|
|
3223
3223
|
get mode() {
|
|
3224
|
-
return
|
|
3224
|
+
return d.mode;
|
|
3225
3225
|
},
|
|
3226
|
-
togglePreview:
|
|
3226
|
+
togglePreview: U,
|
|
3227
3227
|
get sampleData() {
|
|
3228
|
-
return
|
|
3228
|
+
return cn(d.layout);
|
|
3229
3229
|
},
|
|
3230
3230
|
get selection() {
|
|
3231
|
-
return
|
|
3231
|
+
return S();
|
|
3232
3232
|
},
|
|
3233
3233
|
get selections() {
|
|
3234
|
-
return [...
|
|
3234
|
+
return [...d.selection];
|
|
3235
3235
|
},
|
|
3236
|
-
select:
|
|
3236
|
+
select: j,
|
|
3237
3237
|
get id() {
|
|
3238
|
-
return
|
|
3238
|
+
return d.id;
|
|
3239
3239
|
},
|
|
3240
3240
|
get dirty() {
|
|
3241
|
-
return
|
|
3241
|
+
return d.dirty;
|
|
3242
3242
|
},
|
|
3243
3243
|
open(e, t = null) {
|
|
3244
|
-
return
|
|
3244
|
+
return P(pe(e) ? fe() : e, {
|
|
3245
3245
|
id: t,
|
|
3246
3246
|
dirty: !1
|
|
3247
|
-
}), f.reset(
|
|
3247
|
+
}), f.reset(d.layout), N(), i(d.layout);
|
|
3248
3248
|
},
|
|
3249
|
-
save:
|
|
3250
|
-
redraw:
|
|
3249
|
+
save: we,
|
|
3250
|
+
redraw: E,
|
|
3251
3251
|
destroy() {
|
|
3252
|
-
|
|
3253
|
-
for (let e of
|
|
3254
|
-
|
|
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
3255
|
}
|
|
3256
3256
|
};
|
|
3257
3257
|
}
|
|
@@ -3269,22 +3269,22 @@ function ur(e) {
|
|
|
3269
3269
|
<div class="dz-bar-group">
|
|
3270
3270
|
<button type="button" class="dz-tool" data-role="undo" data-action="undo"
|
|
3271
3271
|
title="Undo (ctrl+Z)" aria-label="Undo" disabled
|
|
3272
|
-
>${
|
|
3272
|
+
>${Q("undo")}</button>
|
|
3273
3273
|
<button type="button" class="dz-tool" data-role="redo" data-action="redo"
|
|
3274
3274
|
title="Redo (ctrl+alt+Z or ctrl+shift+Z)" aria-label="Redo" disabled
|
|
3275
|
-
>${
|
|
3275
|
+
>${Q("redo")}</button>
|
|
3276
3276
|
</div>
|
|
3277
3277
|
|
|
3278
3278
|
<div class="dz-bar-group">
|
|
3279
3279
|
<button type="button" class="dz-tool" data-action="open"
|
|
3280
3280
|
title="Open a report (ctrl+O)" aria-label="Open a report"
|
|
3281
|
-
>${
|
|
3281
|
+
>${Q("open")}</button>
|
|
3282
3282
|
<button type="button" class="dz-tool" data-action="save"
|
|
3283
3283
|
title="Save (ctrl+S)" aria-label="Save"
|
|
3284
|
-
>${
|
|
3284
|
+
>${Q("save")}</button>
|
|
3285
3285
|
<button type="button" class="dz-tool" data-action="data"
|
|
3286
3286
|
title="The data this report needs" aria-label="Report data"
|
|
3287
|
-
>${
|
|
3287
|
+
>${Q("data")}</button>
|
|
3288
3288
|
</div>
|
|
3289
3289
|
|
|
3290
3290
|
<div class="dz-bar-group">
|
|
@@ -3292,11 +3292,11 @@ function ur(e) {
|
|
|
3292
3292
|
data-action="toggle-rulers"
|
|
3293
3293
|
title="Rulers and guides - drag off a ruler to place one"
|
|
3294
3294
|
aria-label="Rulers and guides" aria-pressed="false"
|
|
3295
|
-
>${
|
|
3295
|
+
>${Q("ruler")}</button>
|
|
3296
3296
|
<button type="button" class="dz-tool" data-action="toggle-preview"
|
|
3297
3297
|
title="Run the report (ctrl+E)" aria-label="Run the report"
|
|
3298
3298
|
aria-pressed="false"
|
|
3299
|
-
>${
|
|
3299
|
+
>${Q("preview")}</button>
|
|
3300
3300
|
|
|
3301
3301
|
<!--
|
|
3302
3302
|
A button, not a link: the window is built from the design as it
|
|
@@ -3308,7 +3308,7 @@ function ur(e) {
|
|
|
3308
3308
|
data-action="open-window"
|
|
3309
3309
|
title="Open the report in its own window"
|
|
3310
3310
|
aria-label="Open the report in its own window"
|
|
3311
|
-
>${
|
|
3311
|
+
>${Q("external")}</button>
|
|
3312
3312
|
</div>
|
|
3313
3313
|
|
|
3314
3314
|
<span class="dz-pages" data-role="pages"></span>
|
|
@@ -3336,7 +3336,7 @@ function ur(e) {
|
|
|
3336
3336
|
aria-label="Zoom level" hidden>
|
|
3337
3337
|
<li class="dropdown-item" role="option" tabindex="-1"
|
|
3338
3338
|
data-value="fit">Fit width</li>
|
|
3339
|
-
${
|
|
3339
|
+
${ee.map((e) => `
|
|
3340
3340
|
<li class="dropdown-item" role="option" tabindex="-1"
|
|
3341
3341
|
data-value="${e}"${e === 1 ? " data-selected=\"true\"" : ""}
|
|
3342
3342
|
>${Math.round(e * 100)}%</li>`).join("")}
|
|
@@ -3373,24 +3373,24 @@ function ur(e) {
|
|
|
3373
3373
|
<footer class="dz-foot" data-role="foot">
|
|
3374
3374
|
<button type="button" class="dz-tool" data-action="add-text"
|
|
3375
3375
|
title="Add a text box" aria-label="Add a text box"
|
|
3376
|
-
>${
|
|
3376
|
+
>${Q("text")}</button>
|
|
3377
3377
|
<button type="button" class="dz-tool" data-role="add-table"
|
|
3378
3378
|
data-action="add-table"
|
|
3379
3379
|
title="Add a table" aria-label="Add a table"
|
|
3380
|
-
>${
|
|
3380
|
+
>${Q("table")}</button>
|
|
3381
3381
|
<button type="button" class="dz-tool" data-action="add-line"
|
|
3382
3382
|
title="Add a line" aria-label="Add a line"
|
|
3383
|
-
>${
|
|
3383
|
+
>${Q("line")}</button>
|
|
3384
3384
|
<button type="button" class="dz-tool" data-action="add-box"
|
|
3385
3385
|
title="Add a box" aria-label="Add a box"
|
|
3386
|
-
>${
|
|
3386
|
+
>${Q("box")}</button>
|
|
3387
3387
|
<button type="button" class="dz-tool" data-action="add-image"
|
|
3388
3388
|
title="Add an image" aria-label="Add an image"
|
|
3389
|
-
>${
|
|
3389
|
+
>${Q("image")}</button>
|
|
3390
3390
|
<button type="button" class="dz-tool" data-action="add-field"
|
|
3391
3391
|
title="Insert a page number, date or total"
|
|
3392
3392
|
aria-label="Insert a field"
|
|
3393
|
-
>${
|
|
3393
|
+
>${Q("field")}</button>
|
|
3394
3394
|
</footer>
|
|
3395
3395
|
|
|
3396
3396
|
<!--
|