report-studio 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -3
- package/dist/designer-Dj330bWd.js +4690 -0
- package/dist/designer.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react-designer.js +1 -1
- package/dist/react.js +1 -1
- package/dist/viewer-BewnkhfP.js +4028 -0
- package/package.json +2 -2
- package/src/designer/blank.js +0 -1
- package/src/designer/canvas.js +172 -54
- package/src/designer/designer.js +313 -12
- package/src/designer/dialog.js +609 -5
- package/src/designer/fields.js +128 -11
- package/src/designer/geometry.js +77 -4
- package/src/designer/grouping.js +556 -0
- package/src/designer/icons.js +9 -0
- package/src/designer/menu.js +50 -6
- package/src/designer/panel.js +478 -38
- package/src/designer/rulers.js +14 -6
- package/src/designer/sample-data.js +112 -31
- package/src/designer/select.js +3 -2
- package/src/designer/structure.js +126 -12
- package/src/designer/styles.css +661 -27
- package/src/designer/tokens.js +38 -11
- package/src/engine/calculate.js +487 -0
- package/src/engine/csv.js +17 -9
- package/src/engine/format.js +483 -0
- package/src/engine/group.js +350 -70
- package/src/engine/highlight.js +224 -0
- package/src/engine/index.js +8 -1
- package/src/engine/measure.js +53 -26
- package/src/engine/paginate.js +189 -92
- package/src/engine/resolve.js +117 -10
- package/src/engine/rows.js +71 -8
- package/src/engine/search.js +12 -4
- package/src/engine/tables.js +309 -11
- package/src/engine/validate.js +265 -8
- package/src/engine/xlsx-style.js +50 -4
- package/src/engine/xlsx.js +91 -21
- package/src/index.js +18 -0
- package/src/render/items.js +61 -10
- package/src/render/report.css +0 -5
- package/types/index.d.ts +96 -8
- package/types/layout.d.ts +156 -2
- package/dist/designer-DQlfKnTr.js +0 -3416
- package/dist/viewer-BSPNCNRU.js +0 -2912
|
@@ -0,0 +1,4690 @@
|
|
|
1
|
+
import { A as e, B as t, E as n, H as r, J as i, K as a, M as o, N as s, O as c, P as l, Q as u, T as d, V as f, W as p, X as m, Z as h, _ as g, a as ee, at as _, c as v, et as y, ft as b, g as x, h as S, k as C, l as w, lt as T, mt as E, n as te, nt as D, o as O, pt as k, q as ne, r as re, rt as ie, s as ae, t as oe, tt as se, u as ce, ut as le } from "./viewer-BewnkhfP.js";
|
|
2
|
+
//#region src/designer/grouping.js
|
|
3
|
+
var A = D, j = ":", ue = "@", M = {
|
|
4
|
+
groupHeader: "header",
|
|
5
|
+
groupFooter: "footer"
|
|
6
|
+
};
|
|
7
|
+
function N(e, t, n = 0) {
|
|
8
|
+
return `${e}${n > 0 ? `${ue}${n}` : ""}${j}${t}`;
|
|
9
|
+
}
|
|
10
|
+
function P(e) {
|
|
11
|
+
if (typeof e != "string") return null;
|
|
12
|
+
let t = e.indexOf(j);
|
|
13
|
+
if (t === -1) return null;
|
|
14
|
+
let [n, r, ...i] = e.slice(0, t).split(ue);
|
|
15
|
+
if (!A.includes(n) || i.length) return null;
|
|
16
|
+
let a = 0;
|
|
17
|
+
if (r !== void 0) {
|
|
18
|
+
if (!/^[1-9]\d*$/.test(r)) return null;
|
|
19
|
+
a = Number(r);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
kind: n,
|
|
23
|
+
table: e.slice(t + 1),
|
|
24
|
+
level: a
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function F(e) {
|
|
28
|
+
return P(e)?.kind ?? e;
|
|
29
|
+
}
|
|
30
|
+
function I(e) {
|
|
31
|
+
return A.includes(F(e));
|
|
32
|
+
}
|
|
33
|
+
function L(e) {
|
|
34
|
+
let t = P(e);
|
|
35
|
+
if (!t) return String(e ?? "");
|
|
36
|
+
let n = t.level > 0 ? ` ${t.level + 1}` : "";
|
|
37
|
+
return `${t.kind}${n} · ${t.table}`;
|
|
38
|
+
}
|
|
39
|
+
function de(e, t) {
|
|
40
|
+
return E(e).find((e) => e.id === t) ?? null;
|
|
41
|
+
}
|
|
42
|
+
function R(e, t) {
|
|
43
|
+
let n = b(e)[t];
|
|
44
|
+
return n && typeof n == "object" ? n : null;
|
|
45
|
+
}
|
|
46
|
+
function fe(e, t) {
|
|
47
|
+
let n = P(t);
|
|
48
|
+
if (!n) return null;
|
|
49
|
+
let r = R(de(e, n.table), n.level)?.[M[n.kind]];
|
|
50
|
+
return r && typeof r == "object" ? r : null;
|
|
51
|
+
}
|
|
52
|
+
function pe(e) {
|
|
53
|
+
let t = b(e).length, n = Array.from({ length: t }, (e, t) => t);
|
|
54
|
+
return [...n.map((e) => ({
|
|
55
|
+
kind: "groupHeader",
|
|
56
|
+
level: e
|
|
57
|
+
})), ...n.reverse().map((e) => ({
|
|
58
|
+
kind: "groupFooter",
|
|
59
|
+
level: e
|
|
60
|
+
}))].map(({ kind: t, level: n }) => ({
|
|
61
|
+
key: N(t, e.id, n),
|
|
62
|
+
kind: t,
|
|
63
|
+
level: n
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
function me(e) {
|
|
67
|
+
let t = [];
|
|
68
|
+
for (let n of E(e)) for (let { key: e, kind: r, level: i } of pe(n)) {
|
|
69
|
+
let a = R(n, i)?.[M[r]];
|
|
70
|
+
a && typeof a == "object" && t.push({
|
|
71
|
+
key: e,
|
|
72
|
+
kind: r,
|
|
73
|
+
table: n.id,
|
|
74
|
+
level: i,
|
|
75
|
+
band: a
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
80
|
+
function he(e) {
|
|
81
|
+
return E(e).filter((e) => b(e).length > 0).map((e) => {
|
|
82
|
+
let t = b(e).map((t, n) => ({
|
|
83
|
+
by: t?.by ?? "",
|
|
84
|
+
keys: A.map((t) => N(t, e.id, n))
|
|
85
|
+
}));
|
|
86
|
+
return {
|
|
87
|
+
table: e.id,
|
|
88
|
+
by: t[0].by,
|
|
89
|
+
keys: t[0].keys,
|
|
90
|
+
levels: t
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function ge(e, t, n) {
|
|
95
|
+
let r = P(t);
|
|
96
|
+
if (!r) return !1;
|
|
97
|
+
let i = R(de(e, r.table), r.level);
|
|
98
|
+
if (!i) return !1;
|
|
99
|
+
let a = M[r.kind];
|
|
100
|
+
return n ? i[a] ? !1 : (i[a] = {
|
|
101
|
+
type: r.kind,
|
|
102
|
+
height: 36,
|
|
103
|
+
items: []
|
|
104
|
+
}, i[a]) : i[a] ? (i[a] = null, !0) : !1;
|
|
105
|
+
}
|
|
106
|
+
var z = /* @__PURE__ */ new WeakMap();
|
|
107
|
+
function B(e, t, n = 0) {
|
|
108
|
+
if (n > 0) return V(e, n, t ?? "");
|
|
109
|
+
let r = R(e, 0);
|
|
110
|
+
if (t == null || t === "") return !r && !le(e) ? !1 : (r && z.set(e, b(e)), delete e.grouping, delete e.groupBy, !0);
|
|
111
|
+
if (r) return V(e, 0, t);
|
|
112
|
+
delete e.groupBy;
|
|
113
|
+
let i = z.get(e);
|
|
114
|
+
if (i?.length) {
|
|
115
|
+
z.delete(e);
|
|
116
|
+
let [n, ...r] = i;
|
|
117
|
+
return we([n.header, n.footer], n.by, t), e.grouping = [{
|
|
118
|
+
...n,
|
|
119
|
+
by: t
|
|
120
|
+
}, ...r], !0;
|
|
121
|
+
}
|
|
122
|
+
return e.grouping = [Te(t)], !0;
|
|
123
|
+
}
|
|
124
|
+
function V(e, t, n) {
|
|
125
|
+
let r = R(e, t);
|
|
126
|
+
return !r || r.by === n ? !1 : (!r.by && n && r.header && !(r.header.items ?? []).length && (r.header.items = [Ee(n)]), we([r.header, r.footer], r.by, n), r.by = n, !0);
|
|
127
|
+
}
|
|
128
|
+
function _e(e, t = "") {
|
|
129
|
+
return !Array.isArray(e?.grouping) || e.grouping.length === 0 || e.grouping.length >= 8 ? -1 : (e.grouping.push(t ? Te(t) : {
|
|
130
|
+
by: "",
|
|
131
|
+
header: {
|
|
132
|
+
type: "groupHeader",
|
|
133
|
+
height: 36,
|
|
134
|
+
items: []
|
|
135
|
+
},
|
|
136
|
+
footer: null
|
|
137
|
+
}), e.grouping.length - 1);
|
|
138
|
+
}
|
|
139
|
+
function ve(e, t, n, r) {
|
|
140
|
+
let i = R(e, t);
|
|
141
|
+
if (!i) return !1;
|
|
142
|
+
let a;
|
|
143
|
+
if (n === "sort") a = ie.includes(r) ? r : void 0;
|
|
144
|
+
else if (n === "newPage") a = r === !0 || void 0;
|
|
145
|
+
else return !1;
|
|
146
|
+
return i[n] === a ? !1 : (a === void 0 ? delete i[n] : i[n] = a, !0);
|
|
147
|
+
}
|
|
148
|
+
function ye(e, t) {
|
|
149
|
+
return R(e, t) ? b(e).length === 1 ? B(e, null) : (e.grouping.splice(t, 1), !0) : !1;
|
|
150
|
+
}
|
|
151
|
+
function be(e, t) {
|
|
152
|
+
if (t < 1 || !R(e, t) || !R(e, t - 1)) return !1;
|
|
153
|
+
let [n] = e.grouping.splice(t, 1);
|
|
154
|
+
return e.grouping.splice(t - 1, 0, n), !0;
|
|
155
|
+
}
|
|
156
|
+
function xe(e, t, n) {
|
|
157
|
+
if (t === n) return !1;
|
|
158
|
+
let r = b(de(e, t)), i = b(de(e, n)), a = !1;
|
|
159
|
+
return r.forEach((e, t) => {
|
|
160
|
+
let n = i[t];
|
|
161
|
+
!e || typeof e != "object" || !n || typeof n != "object" || (e.header = n.header ? structuredClone(n.header) : null, e.footer = n.footer ? structuredClone(n.footer) : null, we([e.header, e.footer], n.by, e.by), a = !0);
|
|
162
|
+
}), a;
|
|
163
|
+
}
|
|
164
|
+
function Se(e) {
|
|
165
|
+
return typeof e != "object" || !e ? !1 : e.groupBy != null || E(e).some(le);
|
|
166
|
+
}
|
|
167
|
+
function Ce(e) {
|
|
168
|
+
return Se(e) ? k(e) : e;
|
|
169
|
+
}
|
|
170
|
+
function we(e, t, n) {
|
|
171
|
+
if (!(!t || !n || t === n)) for (let r of e) for (let e of r?.items ?? []) e?.type === "text" && typeof e.value == "string" && (e.value = e.value.split(`{${t}}`).join(`{${n}}`));
|
|
172
|
+
}
|
|
173
|
+
function Te(e) {
|
|
174
|
+
return {
|
|
175
|
+
by: e,
|
|
176
|
+
header: {
|
|
177
|
+
type: "groupHeader",
|
|
178
|
+
height: 36,
|
|
179
|
+
items: [Ee(e)]
|
|
180
|
+
},
|
|
181
|
+
footer: null
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function Ee(e) {
|
|
185
|
+
return {
|
|
186
|
+
id: "group-label",
|
|
187
|
+
type: "text",
|
|
188
|
+
x: 0,
|
|
189
|
+
y: 8,
|
|
190
|
+
w: 300,
|
|
191
|
+
h: 20,
|
|
192
|
+
value: `{${e}}`,
|
|
193
|
+
style: {
|
|
194
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
195
|
+
fontSize: 12,
|
|
196
|
+
fontWeight: "bold",
|
|
197
|
+
fontStyle: "normal",
|
|
198
|
+
color: "#000000",
|
|
199
|
+
align: "left",
|
|
200
|
+
background: null,
|
|
201
|
+
border: null,
|
|
202
|
+
padding: 0
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/designer/fields.js
|
|
208
|
+
var De = [
|
|
209
|
+
{
|
|
210
|
+
label: "Helvetica",
|
|
211
|
+
value: "Helvetica, Arial, sans-serif"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: "Arial",
|
|
215
|
+
value: "Arial, Helvetica, sans-serif"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
label: "Verdana",
|
|
219
|
+
value: "Verdana, Geneva, sans-serif"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
label: "Trebuchet",
|
|
223
|
+
value: "\"Trebuchet MS\", Helvetica, sans-serif"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
label: "Georgia",
|
|
227
|
+
value: "Georgia, \"Times New Roman\", serif"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
label: "Times",
|
|
231
|
+
value: "\"Times New Roman\", Times, serif"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: "Courier",
|
|
235
|
+
value: "\"Courier New\", Courier, monospace"
|
|
236
|
+
}
|
|
237
|
+
], Oe = [{
|
|
238
|
+
label: "Regular",
|
|
239
|
+
value: "normal"
|
|
240
|
+
}, {
|
|
241
|
+
label: "Bold",
|
|
242
|
+
value: "bold"
|
|
243
|
+
}], ke = [{
|
|
244
|
+
label: "Upright",
|
|
245
|
+
value: "normal"
|
|
246
|
+
}, {
|
|
247
|
+
label: "Italic",
|
|
248
|
+
value: "italic"
|
|
249
|
+
}], Ae = [
|
|
250
|
+
{
|
|
251
|
+
label: "Left",
|
|
252
|
+
value: "left"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
label: "Centre",
|
|
256
|
+
value: "center"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
label: "Right",
|
|
260
|
+
value: "right"
|
|
261
|
+
}
|
|
262
|
+
], H = [
|
|
263
|
+
{
|
|
264
|
+
label: "Fit inside",
|
|
265
|
+
value: "contain"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
label: "Fill and crop",
|
|
269
|
+
value: "cover"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
label: "Stretch",
|
|
273
|
+
value: "fill"
|
|
274
|
+
}
|
|
275
|
+
], je = [{
|
|
276
|
+
label: "Horizontal",
|
|
277
|
+
value: "horizontal"
|
|
278
|
+
}, {
|
|
279
|
+
label: "Vertical",
|
|
280
|
+
value: "vertical"
|
|
281
|
+
}], Me = [
|
|
282
|
+
{
|
|
283
|
+
label: "Solid",
|
|
284
|
+
value: "solid"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
label: "Dashed",
|
|
288
|
+
value: "dashed"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
label: "Dotted",
|
|
292
|
+
value: "dotted"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
label: "Double",
|
|
296
|
+
value: "double"
|
|
297
|
+
}
|
|
298
|
+
], Ne = [...Me, {
|
|
299
|
+
label: "None",
|
|
300
|
+
value: "none"
|
|
301
|
+
}], U = (e, t, n = {}) => ({
|
|
302
|
+
key: e,
|
|
303
|
+
label: t,
|
|
304
|
+
type: "number",
|
|
305
|
+
...n
|
|
306
|
+
});
|
|
307
|
+
function Pe(e) {
|
|
308
|
+
let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
|
|
309
|
+
return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
|
|
310
|
+
}
|
|
311
|
+
var Fe = [
|
|
312
|
+
{
|
|
313
|
+
key: "field",
|
|
314
|
+
label: "Field",
|
|
315
|
+
type: "text"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
key: "label",
|
|
319
|
+
label: "Label",
|
|
320
|
+
type: "text"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
key: "width",
|
|
324
|
+
label: "Width",
|
|
325
|
+
type: "number",
|
|
326
|
+
min: 1
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
key: "align",
|
|
330
|
+
label: "Align",
|
|
331
|
+
type: "choice",
|
|
332
|
+
options: Ae
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
key: "expression",
|
|
336
|
+
label: "Calculation",
|
|
337
|
+
type: "text",
|
|
338
|
+
hint: "Blank shows the field as it is. A calculation - {qty} * {price}, round({amount} * 0.18, 2), percentage({amount}) - is worked out for each row and saved under this column's field"
|
|
339
|
+
}
|
|
340
|
+
];
|
|
341
|
+
function Ie(e) {
|
|
342
|
+
if (!e) return [];
|
|
343
|
+
let t = {
|
|
344
|
+
title: "Position and size",
|
|
345
|
+
fields: [
|
|
346
|
+
U("x", "X"),
|
|
347
|
+
U("y", "Y"),
|
|
348
|
+
U("w", "Width", { min: 1 }),
|
|
349
|
+
...e.type === "table" ? [] : [U("h", "Height", { min: 1 })]
|
|
350
|
+
]
|
|
351
|
+
};
|
|
352
|
+
return e.type === "box" ? [
|
|
353
|
+
t,
|
|
354
|
+
{
|
|
355
|
+
title: "Border",
|
|
356
|
+
fields: [
|
|
357
|
+
{
|
|
358
|
+
key: "style.borderStyle",
|
|
359
|
+
label: "Style",
|
|
360
|
+
type: "choice",
|
|
361
|
+
options: Ne
|
|
362
|
+
},
|
|
363
|
+
U("style.borderWidth", "Width", { min: 1 }),
|
|
364
|
+
{
|
|
365
|
+
key: "style.borderColor",
|
|
366
|
+
label: "Colour",
|
|
367
|
+
type: "color"
|
|
368
|
+
},
|
|
369
|
+
U("style.radius", "Corner", { min: 0 })
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
title: "Fill",
|
|
374
|
+
fields: [{
|
|
375
|
+
key: "style.background",
|
|
376
|
+
label: "Background",
|
|
377
|
+
type: "color",
|
|
378
|
+
hint: "Leave a box unfilled to frame what is behind it"
|
|
379
|
+
}]
|
|
380
|
+
}
|
|
381
|
+
] : e.type === "image" ? [{
|
|
382
|
+
title: "Picture",
|
|
383
|
+
fields: [
|
|
384
|
+
{
|
|
385
|
+
key: "src",
|
|
386
|
+
label: "Image",
|
|
387
|
+
type: "image",
|
|
388
|
+
hint: "Stored in the layout file. Keep it small - a logo, not a photograph"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
key: "field",
|
|
392
|
+
label: "From data",
|
|
393
|
+
type: "text",
|
|
394
|
+
nullable: !0,
|
|
395
|
+
hint: "A data path such as company.logo, whose value is the picture's URL. It replaces the stored image when present"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
key: "fit",
|
|
399
|
+
label: "Fit",
|
|
400
|
+
type: "choice",
|
|
401
|
+
options: H
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
key: "alt",
|
|
405
|
+
label: "Description",
|
|
406
|
+
type: "text",
|
|
407
|
+
hint: "Read out by a screen reader in place of the picture"
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
}, t] : e.type === "line" ? [t, {
|
|
411
|
+
title: "Line",
|
|
412
|
+
fields: [
|
|
413
|
+
{
|
|
414
|
+
key: "orientation",
|
|
415
|
+
label: "Runs",
|
|
416
|
+
type: "choice",
|
|
417
|
+
options: je
|
|
418
|
+
},
|
|
419
|
+
U("style.thickness", "Thickness", { min: 1 }),
|
|
420
|
+
{
|
|
421
|
+
key: "style.lineStyle",
|
|
422
|
+
label: "Style",
|
|
423
|
+
type: "choice",
|
|
424
|
+
options: Me
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
key: "style.color",
|
|
428
|
+
label: "Colour",
|
|
429
|
+
type: "color"
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
}] : e.type === "table" ? [
|
|
433
|
+
t,
|
|
434
|
+
{
|
|
435
|
+
title: "Data",
|
|
436
|
+
fields: [{
|
|
437
|
+
key: "dataset",
|
|
438
|
+
label: "Dataset",
|
|
439
|
+
type: "text",
|
|
440
|
+
nullable: !0,
|
|
441
|
+
hint: "The key in the data object whose rows this table draws. Blank reads the report's dataset"
|
|
442
|
+
}, Ge]
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
title: "Rows",
|
|
446
|
+
fields: [U("rowHeight", "Row height", { min: 1 })]
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
title: "Header",
|
|
450
|
+
fields: [
|
|
451
|
+
{
|
|
452
|
+
key: "showHeader",
|
|
453
|
+
label: "Show header",
|
|
454
|
+
type: "toggle"
|
|
455
|
+
},
|
|
456
|
+
U("headerHeight", "Height", { min: 1 }),
|
|
457
|
+
{
|
|
458
|
+
key: "style.headerBackground",
|
|
459
|
+
label: "Fill",
|
|
460
|
+
type: "color"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
key: "style.headerColor",
|
|
464
|
+
label: "Text",
|
|
465
|
+
type: "color",
|
|
466
|
+
hint: "Leave these alone to keep the stylesheet's own header"
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
title: "Appearance",
|
|
472
|
+
fields: [
|
|
473
|
+
{
|
|
474
|
+
key: "style.fontFamily",
|
|
475
|
+
label: "Font",
|
|
476
|
+
type: "choice",
|
|
477
|
+
options: De
|
|
478
|
+
},
|
|
479
|
+
U("style.fontSize", "Font size", { min: 1 }),
|
|
480
|
+
{
|
|
481
|
+
key: "style.color",
|
|
482
|
+
label: "Text",
|
|
483
|
+
type: "color"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
key: "wrap",
|
|
487
|
+
label: "Wrap cells",
|
|
488
|
+
type: "toggle",
|
|
489
|
+
hint: "A cell wider than its column runs onto another line and the row grows; turn this off to keep every row one line, cut off with an ellipsis"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
key: "style.borderStyle",
|
|
493
|
+
label: "Borders",
|
|
494
|
+
type: "choice",
|
|
495
|
+
options: Ne
|
|
496
|
+
},
|
|
497
|
+
U("style.borderWidth", "Border width", {
|
|
498
|
+
min: 1,
|
|
499
|
+
max: Pe(e)
|
|
500
|
+
}),
|
|
501
|
+
{
|
|
502
|
+
key: "style.borderColor",
|
|
503
|
+
label: "Border colour",
|
|
504
|
+
type: "color"
|
|
505
|
+
}
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
] : [
|
|
509
|
+
{
|
|
510
|
+
title: "Content",
|
|
511
|
+
fields: [{
|
|
512
|
+
key: "value",
|
|
513
|
+
label: "Value",
|
|
514
|
+
type: "textarea",
|
|
515
|
+
hint: "Placeholders in braces: {customer.name}, {page}, {sum(amount)}"
|
|
516
|
+
}]
|
|
517
|
+
},
|
|
518
|
+
t,
|
|
519
|
+
{
|
|
520
|
+
title: "Type",
|
|
521
|
+
fields: [
|
|
522
|
+
{
|
|
523
|
+
key: "style.fontFamily",
|
|
524
|
+
label: "Font",
|
|
525
|
+
type: "choice",
|
|
526
|
+
options: De
|
|
527
|
+
},
|
|
528
|
+
U("style.fontSize", "Size", { min: 1 }),
|
|
529
|
+
{
|
|
530
|
+
key: "style.fontWeight",
|
|
531
|
+
label: "Weight",
|
|
532
|
+
type: "choice",
|
|
533
|
+
options: Oe
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
key: "style.fontStyle",
|
|
537
|
+
label: "Style",
|
|
538
|
+
type: "choice",
|
|
539
|
+
options: ke
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
key: "style.align",
|
|
543
|
+
label: "Align",
|
|
544
|
+
type: "choice",
|
|
545
|
+
options: Ae
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
key: "style.color",
|
|
549
|
+
label: "Colour",
|
|
550
|
+
type: "color"
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
];
|
|
555
|
+
}
|
|
556
|
+
var W = [
|
|
557
|
+
{
|
|
558
|
+
label: "A2",
|
|
559
|
+
width: 1587,
|
|
560
|
+
height: 2245
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
label: "A3",
|
|
564
|
+
width: 1123,
|
|
565
|
+
height: 1587
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
label: "A4",
|
|
569
|
+
width: 794,
|
|
570
|
+
height: 1123
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
label: "A5",
|
|
574
|
+
width: 559,
|
|
575
|
+
height: 794
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
label: "A6",
|
|
579
|
+
width: 397,
|
|
580
|
+
height: 559
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
label: "Letter",
|
|
584
|
+
width: 816,
|
|
585
|
+
height: 1056
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
label: "Legal",
|
|
589
|
+
width: 816,
|
|
590
|
+
height: 1344
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
label: "Tabloid",
|
|
594
|
+
width: 1056,
|
|
595
|
+
height: 1632
|
|
596
|
+
}
|
|
597
|
+
], G = "custom";
|
|
598
|
+
function Le(e) {
|
|
599
|
+
if (e?.paper === "custom") return G;
|
|
600
|
+
let t = e?.width, n = e?.height, r = W.find((e) => e.width === t && e.height === n || e.height === t && e.width === n);
|
|
601
|
+
return r ? r.label : G;
|
|
602
|
+
}
|
|
603
|
+
function K(e) {
|
|
604
|
+
return (e?.width ?? 0) > (e?.height ?? 0) ? "landscape" : "portrait";
|
|
605
|
+
}
|
|
606
|
+
function Re(e, t) {
|
|
607
|
+
let n = W.find((e) => e.label === t);
|
|
608
|
+
if (!n) return e.page.paper === "custom" ? !1 : (e.page.paper = G, !0);
|
|
609
|
+
let r = K(e.page) === "landscape", i = r ? n.height : n.width, a = r ? n.width : n.height, o = e.page.paper === G;
|
|
610
|
+
return delete e.page.paper, e.page.width === i && e.page.height === a ? o : (e.page.width = i, e.page.height = a, !0);
|
|
611
|
+
}
|
|
612
|
+
function ze(e, t) {
|
|
613
|
+
if (t === "landscape" == (K(e.page) === "landscape")) return !1;
|
|
614
|
+
let { width: n, height: r } = e.page;
|
|
615
|
+
return e.page.width = r, e.page.height = n, !0;
|
|
616
|
+
}
|
|
617
|
+
function q(e) {
|
|
618
|
+
let t = Le(e.page) === G, n = {
|
|
619
|
+
key: "paper",
|
|
620
|
+
label: "Paper",
|
|
621
|
+
type: "choice",
|
|
622
|
+
rebuilds: !0,
|
|
623
|
+
options: [...W.map((e) => ({
|
|
624
|
+
value: e.label,
|
|
625
|
+
label: `${e.label} ${e.width} x ${e.height}`
|
|
626
|
+
})), {
|
|
627
|
+
value: G,
|
|
628
|
+
label: "Custom"
|
|
629
|
+
}],
|
|
630
|
+
read: (e) => Le(e.page),
|
|
631
|
+
write: (e, t) => Re(e, t)
|
|
632
|
+
};
|
|
633
|
+
return t ? [
|
|
634
|
+
n,
|
|
635
|
+
U("page.width", "Width", { min: 1 }),
|
|
636
|
+
U("page.height", "Height", { min: 1 })
|
|
637
|
+
] : [n, {
|
|
638
|
+
key: "orientation",
|
|
639
|
+
label: "Orientation",
|
|
640
|
+
type: "choice",
|
|
641
|
+
rebuilds: !0,
|
|
642
|
+
options: [{
|
|
643
|
+
value: "portrait",
|
|
644
|
+
label: "Portrait"
|
|
645
|
+
}, {
|
|
646
|
+
value: "landscape",
|
|
647
|
+
label: "Landscape"
|
|
648
|
+
}],
|
|
649
|
+
read: (e) => K(e.page),
|
|
650
|
+
write: (e, t) => ze(e, t)
|
|
651
|
+
}];
|
|
652
|
+
}
|
|
653
|
+
function Be(e) {
|
|
654
|
+
return e ? [
|
|
655
|
+
{
|
|
656
|
+
title: "Report",
|
|
657
|
+
fields: [{
|
|
658
|
+
key: "name",
|
|
659
|
+
label: "Name",
|
|
660
|
+
type: "text"
|
|
661
|
+
}, {
|
|
662
|
+
key: "dataset",
|
|
663
|
+
label: "Dataset",
|
|
664
|
+
type: "text",
|
|
665
|
+
nullable: !0,
|
|
666
|
+
hint: "The key in the data object that drives the rows, for every table that does not name its own"
|
|
667
|
+
}]
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
title: "Page",
|
|
671
|
+
fields: q(e)
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
title: "Margins",
|
|
675
|
+
fields: [
|
|
676
|
+
U("page.margin.top", "Top", { min: 0 }),
|
|
677
|
+
U("page.margin.right", "Right", { min: 0 }),
|
|
678
|
+
U("page.margin.bottom", "Bottom", { min: 0 }),
|
|
679
|
+
U("page.margin.left", "Left", { min: 0 })
|
|
680
|
+
]
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
title: "Numbers and dates",
|
|
684
|
+
fields: [
|
|
685
|
+
{
|
|
686
|
+
key: "format.grouping",
|
|
687
|
+
label: "Digit groups",
|
|
688
|
+
type: "choice",
|
|
689
|
+
options: [
|
|
690
|
+
{
|
|
691
|
+
value: "international",
|
|
692
|
+
label: "1,234,567"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
value: "indian",
|
|
696
|
+
label: "12,34,567 (Indian)"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
value: "none",
|
|
700
|
+
label: "1234567"
|
|
701
|
+
}
|
|
702
|
+
]
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
key: "format.symbol",
|
|
706
|
+
label: "Currency",
|
|
707
|
+
type: "choice",
|
|
708
|
+
options: a,
|
|
709
|
+
custom: !0,
|
|
710
|
+
hint: "The symbol currency formats print; Custom… for one not listed"
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
key: "format.symbolPosition",
|
|
714
|
+
label: "Symbol goes",
|
|
715
|
+
type: "choice",
|
|
716
|
+
options: [{
|
|
717
|
+
value: "before",
|
|
718
|
+
label: "Before ₹100"
|
|
719
|
+
}, {
|
|
720
|
+
value: "after",
|
|
721
|
+
label: "After 100 ₹"
|
|
722
|
+
}]
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
key: "format.pattern",
|
|
726
|
+
label: "Dates",
|
|
727
|
+
type: "choice",
|
|
728
|
+
options: Ve(e.format?.pattern),
|
|
729
|
+
hint: "How a date prints unless its own format says otherwise"
|
|
730
|
+
}
|
|
731
|
+
],
|
|
732
|
+
actions: [{
|
|
733
|
+
action: "format-india",
|
|
734
|
+
label: "Use Indian: ₹, 1,00,000, dd/MM/yyyy",
|
|
735
|
+
title: "Indian digit groups, the rupee and day/month/year dates"
|
|
736
|
+
}]
|
|
737
|
+
}
|
|
738
|
+
] : [];
|
|
739
|
+
}
|
|
740
|
+
function Ve(e) {
|
|
741
|
+
let t = ["yyyy-MM-dd", ...i.filter((e) => e !== "yyyy-MM-dd")];
|
|
742
|
+
return typeof e == "string" && e && !t.includes(e) && t.push(e), t.map((e) => ({
|
|
743
|
+
value: e,
|
|
744
|
+
label: y(He, {
|
|
745
|
+
type: "date",
|
|
746
|
+
pattern: e
|
|
747
|
+
})
|
|
748
|
+
}));
|
|
749
|
+
}
|
|
750
|
+
var He = "2026-06-17";
|
|
751
|
+
function Ue(e) {
|
|
752
|
+
return Be(e).flatMap((e) => e.fields);
|
|
753
|
+
}
|
|
754
|
+
function We(e) {
|
|
755
|
+
return Ie(e).flatMap((e) => e.fields);
|
|
756
|
+
}
|
|
757
|
+
var Ge = {
|
|
758
|
+
key: "groupBy",
|
|
759
|
+
label: "Group by",
|
|
760
|
+
type: "text",
|
|
761
|
+
nullable: !0,
|
|
762
|
+
hint: "A field to group these rows by, or blank. Each grouped table has its own group header and footer",
|
|
763
|
+
read: (e) => b(e)[0]?.by ?? e.groupBy ?? null,
|
|
764
|
+
write: (e, t) => B(e, t),
|
|
765
|
+
rebuilds: (e) => b(e).length > 0
|
|
766
|
+
};
|
|
767
|
+
function Ke(e) {
|
|
768
|
+
return e.split(".");
|
|
769
|
+
}
|
|
770
|
+
function qe(e, t) {
|
|
771
|
+
if (t.read) return t.read(e);
|
|
772
|
+
let n = e;
|
|
773
|
+
for (let e of Ke(t.key)) {
|
|
774
|
+
if (n == null) return;
|
|
775
|
+
n = n[e];
|
|
776
|
+
}
|
|
777
|
+
return n;
|
|
778
|
+
}
|
|
779
|
+
function Je(e, t) {
|
|
780
|
+
if (t.read || t.write) return !1;
|
|
781
|
+
let n = Ke(t.key), r = n.pop(), i = e;
|
|
782
|
+
for (let e of n) {
|
|
783
|
+
if (i?.[e] == null || typeof i[e] != "object") return !1;
|
|
784
|
+
i = i[e];
|
|
785
|
+
}
|
|
786
|
+
return i[r] == null ? !1 : (delete i[r], !0);
|
|
787
|
+
}
|
|
788
|
+
function Ye(e, t, n) {
|
|
789
|
+
let r = Xe(t, n);
|
|
790
|
+
if (r === void 0) return !1;
|
|
791
|
+
if (t.write) return t.write(e, r);
|
|
792
|
+
let i = Ke(t.key), a = i.pop(), o = e;
|
|
793
|
+
for (let e of i) (o[e] == null || typeof o[e] != "object") && (o[e] = {}), o = o[e];
|
|
794
|
+
return o[a] === r ? !1 : (o[a] = r, !0);
|
|
795
|
+
}
|
|
796
|
+
function Xe(e, t) {
|
|
797
|
+
if (e.type === "toggle") return !!t;
|
|
798
|
+
if (e.type === "number") {
|
|
799
|
+
if (t === "" || t == null) return;
|
|
800
|
+
let n = Number(t);
|
|
801
|
+
if (!Number.isFinite(n)) return;
|
|
802
|
+
let r = e.min == null ? n : Math.max(n, e.min);
|
|
803
|
+
return e.max == null ? r : Math.min(r, e.max);
|
|
804
|
+
}
|
|
805
|
+
if (t != null) return e.nullable && t === "" ? null : String(t);
|
|
806
|
+
}
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/designer/blank.js
|
|
809
|
+
function Ze() {
|
|
810
|
+
return {
|
|
811
|
+
version: 1,
|
|
812
|
+
name: "Untitled report",
|
|
813
|
+
page: {
|
|
814
|
+
width: 794,
|
|
815
|
+
height: 1123,
|
|
816
|
+
margin: {
|
|
817
|
+
top: 40,
|
|
818
|
+
right: 40,
|
|
819
|
+
bottom: 40,
|
|
820
|
+
left: 40
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
dataset: null,
|
|
824
|
+
bands: [
|
|
825
|
+
{
|
|
826
|
+
type: "pageHeader",
|
|
827
|
+
height: 60,
|
|
828
|
+
items: []
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
type: "detail",
|
|
832
|
+
items: []
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
type: "pageFooter",
|
|
836
|
+
height: 40,
|
|
837
|
+
items: []
|
|
838
|
+
}
|
|
839
|
+
]
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function Qe(e) {
|
|
843
|
+
return e == null ? !0 : typeof e != "object" || Array.isArray(e) ? !1 : Object.keys(e).length === 0;
|
|
844
|
+
}
|
|
845
|
+
var J = 3, $e = [
|
|
846
|
+
"nw",
|
|
847
|
+
"n",
|
|
848
|
+
"ne",
|
|
849
|
+
"e",
|
|
850
|
+
"se",
|
|
851
|
+
"s",
|
|
852
|
+
"sw",
|
|
853
|
+
"w"
|
|
854
|
+
], et = ["e", "w"];
|
|
855
|
+
function tt(e) {
|
|
856
|
+
return Math.round(e / 10) * 10;
|
|
857
|
+
}
|
|
858
|
+
function nt(e) {
|
|
859
|
+
let t = l(e);
|
|
860
|
+
return e?.type === "table" ? t + b(e).reduce((e, t) => e + it(t?.header) + it(t?.footer), 0) : t;
|
|
861
|
+
}
|
|
862
|
+
function rt(e) {
|
|
863
|
+
let t = b(e), n = e?.rowHeight ?? 0, r = e?.showHeader ? e.headerHeight ?? n : 0, i = [], a = (e, t, n) => {
|
|
864
|
+
if (!n) return;
|
|
865
|
+
let a = it(n);
|
|
866
|
+
i.push({
|
|
867
|
+
kind: e,
|
|
868
|
+
level: t,
|
|
869
|
+
band: n,
|
|
870
|
+
y: r,
|
|
871
|
+
h: a
|
|
872
|
+
}), r += a;
|
|
873
|
+
};
|
|
874
|
+
t.forEach((e, t) => a("groupHeader", t, e?.header)), r += 3 * n;
|
|
875
|
+
for (let e = t.length - 1; e >= 0; e--) a("groupFooter", e, t[e]?.footer);
|
|
876
|
+
return i;
|
|
877
|
+
}
|
|
878
|
+
function it(e) {
|
|
879
|
+
let t = Number(e?.height);
|
|
880
|
+
return e && Number.isFinite(t) && t > 0 ? t : 0;
|
|
881
|
+
}
|
|
882
|
+
function at(e) {
|
|
883
|
+
return {
|
|
884
|
+
x: e.x ?? 0,
|
|
885
|
+
y: e.y ?? 0,
|
|
886
|
+
w: e.w ?? 0,
|
|
887
|
+
h: nt(e)
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
function ot(e) {
|
|
891
|
+
return e.type === "table" ? "x" : "xy";
|
|
892
|
+
}
|
|
893
|
+
function st(e) {
|
|
894
|
+
return e === "x" ? [...et] : [...$e];
|
|
895
|
+
}
|
|
896
|
+
function ct(e, t, n) {
|
|
897
|
+
return {
|
|
898
|
+
x: tt(e.x + t),
|
|
899
|
+
y: tt(e.y + n)
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function lt(e, t, n, r, i = "xy") {
|
|
903
|
+
let { x: a, y: o, w: s, h: c } = t;
|
|
904
|
+
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))), {
|
|
905
|
+
x: a,
|
|
906
|
+
y: o,
|
|
907
|
+
w: s,
|
|
908
|
+
h: c
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function ut(e, t) {
|
|
912
|
+
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);
|
|
913
|
+
}
|
|
914
|
+
function dt(e, { minor: t = 10, major: n = 50 } = {}) {
|
|
915
|
+
let r = [];
|
|
916
|
+
if (!(e > 0) || !(t > 0)) return r;
|
|
917
|
+
for (let i = 0; i <= e; i += t) r.push({
|
|
918
|
+
at: i,
|
|
919
|
+
major: i % n === 0
|
|
920
|
+
});
|
|
921
|
+
let i = r.at(-1);
|
|
922
|
+
return i && i.at !== e && r.push({
|
|
923
|
+
at: e,
|
|
924
|
+
major: !0
|
|
925
|
+
}), r;
|
|
926
|
+
}
|
|
927
|
+
function ft(e) {
|
|
928
|
+
let t = e?.guides, n = (e) => (Array.isArray(e) ? e : []).filter(pt).map(Number).filter(Number.isFinite).sort((e, t) => e - t);
|
|
929
|
+
return {
|
|
930
|
+
x: n(t?.x),
|
|
931
|
+
y: n(t?.y)
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
function pt(e) {
|
|
935
|
+
return typeof e == "number" || typeof e == "string" && e.trim() !== "";
|
|
936
|
+
}
|
|
937
|
+
function mt(e) {
|
|
938
|
+
(!e.guides || typeof e.guides != "object") && (e.guides = {
|
|
939
|
+
x: [],
|
|
940
|
+
y: []
|
|
941
|
+
});
|
|
942
|
+
for (let t of ["x", "y"]) Array.isArray(e.guides[t]) || (e.guides[t] = []);
|
|
943
|
+
return e.guides;
|
|
944
|
+
}
|
|
945
|
+
function ht(e, t, n) {
|
|
946
|
+
if (!pt(n)) return null;
|
|
947
|
+
let r = Math.round(Number(n));
|
|
948
|
+
if (!Number.isFinite(r)) return null;
|
|
949
|
+
let i = mt(e);
|
|
950
|
+
return i[t].includes(r) || (i[t].push(r), i[t].sort((e, t) => e - t)), r;
|
|
951
|
+
}
|
|
952
|
+
function gt(e, t, n) {
|
|
953
|
+
let r = mt(e), i = r[t].indexOf(Math.round(Number(n)));
|
|
954
|
+
return i === -1 ? !1 : (r[t].splice(i, 1), !0);
|
|
955
|
+
}
|
|
956
|
+
function _t(e, t, n, r) {
|
|
957
|
+
return gt(e, t, n), ht(e, t, r);
|
|
958
|
+
}
|
|
959
|
+
function vt(e, t, n, r = 4) {
|
|
960
|
+
let i = null;
|
|
961
|
+
for (let a of ft(e)[t]) {
|
|
962
|
+
let e = Math.abs(a - n);
|
|
963
|
+
e <= r && (i === null || e < Math.abs(i - n)) && (i = a);
|
|
964
|
+
}
|
|
965
|
+
return i;
|
|
966
|
+
}
|
|
967
|
+
function yt(e, t) {
|
|
968
|
+
let n = ft(e);
|
|
969
|
+
if (!t) return {
|
|
970
|
+
x: n.x,
|
|
971
|
+
y: []
|
|
972
|
+
};
|
|
973
|
+
let r = t.originX ?? 0;
|
|
974
|
+
return {
|
|
975
|
+
x: r === 0 ? n.x : n.x.map((e) => e - r).filter((e) => e >= 0 && e <= (t.w ?? 0)),
|
|
976
|
+
y: n.y.map((e) => e - (t.originY ?? 0)).filter((e) => e >= 0 && e <= (t.h ?? 0))
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
//#endregion
|
|
980
|
+
//#region src/designer/canvas.js
|
|
981
|
+
var bt = [
|
|
982
|
+
"pageHeader",
|
|
983
|
+
"reportHeader",
|
|
984
|
+
"reportFooter",
|
|
985
|
+
"pageFooter"
|
|
986
|
+
];
|
|
987
|
+
function xt(e) {
|
|
988
|
+
return Array.from({ length: J }, () => Object.fromEntries((e || []).map((e) => [e.field, e.field])));
|
|
989
|
+
}
|
|
990
|
+
function St(e) {
|
|
991
|
+
if (e.type === "text") return {
|
|
992
|
+
...e,
|
|
993
|
+
text: e.value
|
|
994
|
+
};
|
|
995
|
+
if (e.type === "table") {
|
|
996
|
+
let t = rt(e);
|
|
997
|
+
if (!t.length) return {
|
|
998
|
+
...e,
|
|
999
|
+
row: xt(e.columns),
|
|
1000
|
+
measuredHeight: nt(e)
|
|
1001
|
+
};
|
|
1002
|
+
let n = (e) => ({
|
|
1003
|
+
height: e.h,
|
|
1004
|
+
level: e.level,
|
|
1005
|
+
items: [],
|
|
1006
|
+
background: e.band?.background ?? null
|
|
1007
|
+
}), r = (e) => t.filter((t) => t.kind === e).map(n);
|
|
1008
|
+
return {
|
|
1009
|
+
...e,
|
|
1010
|
+
groups: [{
|
|
1011
|
+
showHeader: !0,
|
|
1012
|
+
showFooter: !0,
|
|
1013
|
+
headerBands: r("groupHeader"),
|
|
1014
|
+
footerBands: r("groupFooter"),
|
|
1015
|
+
rows: xt(e.columns)
|
|
1016
|
+
}],
|
|
1017
|
+
measuredHeight: nt(e)
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
return e;
|
|
1021
|
+
}
|
|
1022
|
+
function Ct(e) {
|
|
1023
|
+
let { page: t } = e, r = t.height - t.margin.top - t.margin.bottom, i = t.width - t.margin.left - t.margin.right, a = Object.fromEntries((e.bands || []).map((e) => [e.type, e])), o = n({
|
|
1024
|
+
bands: a,
|
|
1025
|
+
contentHeight: r,
|
|
1026
|
+
isFirstPage: !0,
|
|
1027
|
+
isLastPage: !0
|
|
1028
|
+
}), s = [], c = (e, t, n, r) => ({
|
|
1029
|
+
type: e,
|
|
1030
|
+
top: t,
|
|
1031
|
+
left: 0,
|
|
1032
|
+
height: n,
|
|
1033
|
+
width: i,
|
|
1034
|
+
band: r
|
|
1035
|
+
});
|
|
1036
|
+
for (let e of bt) {
|
|
1037
|
+
let t = o[e];
|
|
1038
|
+
t && a[e] && s.push(c(e, t.top, t.height, a[e]));
|
|
1039
|
+
}
|
|
1040
|
+
let l = o.detail, u = (e) => a[e] ? d(a[e], r) : 0, f = u("groupHeader"), p = u("groupFooter");
|
|
1041
|
+
a.groupHeader && s.push(c("groupHeader", l.top, f, a.groupHeader)), a.detail && s.push(c("detail", l.top + f, Math.max(l.height - f - p, 0), a.detail)), a.groupFooter && s.push(c("groupFooter", l.top + l.height - p, p, a.groupFooter));
|
|
1042
|
+
for (let e of [...s]) for (let t of e.band.items || []) t?.type === "table" && s.push(...wt(t, e));
|
|
1043
|
+
return s;
|
|
1044
|
+
}
|
|
1045
|
+
function wt(e, t) {
|
|
1046
|
+
return rt(e).map(({ kind: n, level: r, band: i, y: a, h: o }) => {
|
|
1047
|
+
let s = N(n, e.id, r);
|
|
1048
|
+
return {
|
|
1049
|
+
type: s,
|
|
1050
|
+
kind: n,
|
|
1051
|
+
level: r,
|
|
1052
|
+
table: e.id,
|
|
1053
|
+
label: L(s),
|
|
1054
|
+
top: t.top + (e.y ?? 0) + a,
|
|
1055
|
+
left: t.left + (e.x ?? 0),
|
|
1056
|
+
height: o,
|
|
1057
|
+
width: e.w ?? 0,
|
|
1058
|
+
band: i
|
|
1059
|
+
};
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function Tt(e, t) {
|
|
1063
|
+
let n = [...e.band.items || []].sort((e, t) => (e.y ?? 0) - (t.y ?? 0)).map(St);
|
|
1064
|
+
return `
|
|
1065
|
+
<div class="band dz-zone" data-band-type="${S(e.type)}"
|
|
1066
|
+
style="${kt(e, t)}">
|
|
1067
|
+
${g(n)}
|
|
1068
|
+
</div>`;
|
|
1069
|
+
}
|
|
1070
|
+
function Et(e, t) {
|
|
1071
|
+
ft(e);
|
|
1072
|
+
let n = (e, t) => dt(e).map((e) => `
|
|
1073
|
+
<span class="dz-tick${e.major ? " is-major" : ""}"
|
|
1074
|
+
style="${t === "x" ? "left" : "top"}:${e.at}px"
|
|
1075
|
+
>${e.major ? `<i>${e.at}</i>` : ""}</span>`).join(""), r = (t) => `
|
|
1076
|
+
<span class="dz-ruler-guides" data-role="ruler-guides"
|
|
1077
|
+
data-axis="${t}">${Dt(e, t)}</span>`;
|
|
1078
|
+
return `
|
|
1079
|
+
<div class="dz-ruler-corner" data-role="ruler-corner"></div>
|
|
1080
|
+
|
|
1081
|
+
<div class="dz-ruler dz-ruler-x" data-role="ruler" data-axis="x"
|
|
1082
|
+
style="width:${t.w}px" aria-hidden="true">
|
|
1083
|
+
${n(t.w, "x")}${r("x")}
|
|
1084
|
+
</div>
|
|
1085
|
+
|
|
1086
|
+
<div class="dz-ruler dz-ruler-y" data-role="ruler" data-axis="y"
|
|
1087
|
+
style="height:${t.h}px" aria-hidden="true">
|
|
1088
|
+
${n(t.h, "y")}${r("y")}
|
|
1089
|
+
</div>`;
|
|
1090
|
+
}
|
|
1091
|
+
function Dt(e, t) {
|
|
1092
|
+
return ft(e)[t].map((e) => `
|
|
1093
|
+
<span class="dz-ruler-guide"
|
|
1094
|
+
style="${t === "x" ? "left" : "top"}:${e}px"></span>`).join("");
|
|
1095
|
+
}
|
|
1096
|
+
function Ot(e) {
|
|
1097
|
+
let t = e.page.margin, n = ft(e), r = n.x.map((e) => `
|
|
1098
|
+
<span class="dz-rule dz-rule-v" data-role="guide" data-axis="x"
|
|
1099
|
+
data-at="${e}" style="left:${e + t.left}px"></span>`), i = n.y.map((e) => `
|
|
1100
|
+
<span class="dz-rule dz-rule-h" data-role="guide" data-axis="y"
|
|
1101
|
+
data-at="${e}" style="top:${e + t.top}px"></span>`);
|
|
1102
|
+
return [...r, ...i].join("");
|
|
1103
|
+
}
|
|
1104
|
+
function kt(e, t) {
|
|
1105
|
+
return `position:absolute;top:${e.top + t.top}px;left:${e.left + t.left}px;width:${e.width}px;height:${e.height}px`;
|
|
1106
|
+
}
|
|
1107
|
+
function At(e, t) {
|
|
1108
|
+
return `<span class="dz-tag" data-band-tag="${S(e.type)}"
|
|
1109
|
+
style="top:${e.top + t.top}px">${S(e.label ?? e.type)}</span>`;
|
|
1110
|
+
}
|
|
1111
|
+
function jt(e, t) {
|
|
1112
|
+
if (!t) return null;
|
|
1113
|
+
let n = e.page.margin, r = Ct(e).find((e) => e.type === t.band);
|
|
1114
|
+
if (!r) return null;
|
|
1115
|
+
let i = (r.band.items || []).find((e) => e.id === t.id);
|
|
1116
|
+
if (!i) return null;
|
|
1117
|
+
let a = at(i);
|
|
1118
|
+
return {
|
|
1119
|
+
item: i,
|
|
1120
|
+
box: {
|
|
1121
|
+
...a,
|
|
1122
|
+
x: a.x + r.left + n.left,
|
|
1123
|
+
y: a.y + r.top + n.top
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
function Mt(e, { withHandles: t = !0, primary: n = !0 } = {}) {
|
|
1128
|
+
let { box: r, item: i } = e, a = t ? st(ot(i)).map((e) => `<span class="dz-handle dz-handle-${e}" data-handle="${e}"></span>`).join("") : "";
|
|
1129
|
+
return `
|
|
1130
|
+
<div class="dz-select${n ? "" : " is-secondary"}" data-role="select"
|
|
1131
|
+
data-select-id="${S(i.id)}"
|
|
1132
|
+
style="top:${r.y}px;left:${r.x}px;width:${r.w}px;height:${r.h}px">
|
|
1133
|
+
${a}
|
|
1134
|
+
</div>`;
|
|
1135
|
+
}
|
|
1136
|
+
function Nt(e, t) {
|
|
1137
|
+
return (t || []).map((t) => jt(e, t)).filter(Boolean);
|
|
1138
|
+
}
|
|
1139
|
+
function Pt(e, t = null, { rulers: n = !1 } = {}) {
|
|
1140
|
+
let { page: r } = e, i = r.margin, a = Ct(e), o = Nt(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 = {
|
|
1141
|
+
w: r.width - i.left - i.right,
|
|
1142
|
+
h: r.height - i.top - i.bottom
|
|
1143
|
+
};
|
|
1144
|
+
return `
|
|
1145
|
+
<div class="dz-sheet${n ? " has-rulers" : ""}"
|
|
1146
|
+
style="--page-height:${r.height}px;--dz-margin-left:${i.left}px;
|
|
1147
|
+
--dz-margin-top:${i.top}px">
|
|
1148
|
+
${n ? Et(e, c) : ""}
|
|
1149
|
+
<div class="dz-gutter">
|
|
1150
|
+
${a.map((e) => At(e, i)).join("")}
|
|
1151
|
+
</div>
|
|
1152
|
+
<div class="page dz-page" style="${s}">
|
|
1153
|
+
<div class="dz-rules" data-role="rules"
|
|
1154
|
+
>${n ? Ot(e) : ""}</div>
|
|
1155
|
+
${a.map((e) => Tt(e, i)).join("")}
|
|
1156
|
+
${o.map((e, t) => Mt(e, {
|
|
1157
|
+
withHandles: o.length === 1,
|
|
1158
|
+
primary: t === o.length - 1
|
|
1159
|
+
})).join("")}
|
|
1160
|
+
<div class="dz-guides" data-role="guides"></div>
|
|
1161
|
+
</div>
|
|
1162
|
+
</div>`;
|
|
1163
|
+
}
|
|
1164
|
+
function Ft(e, t) {
|
|
1165
|
+
let n = Ct(e).find((e) => e.type === t);
|
|
1166
|
+
if (!n) return null;
|
|
1167
|
+
let r = e.page.margin;
|
|
1168
|
+
return {
|
|
1169
|
+
left: n.left + r.left,
|
|
1170
|
+
top: n.top + r.top,
|
|
1171
|
+
w: n.width,
|
|
1172
|
+
h: n.height,
|
|
1173
|
+
originX: n.left,
|
|
1174
|
+
originY: n.top
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
function It(e, t = [], n = []) {
|
|
1178
|
+
if (!e) return "";
|
|
1179
|
+
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" : ""}"
|
|
1180
|
+
style="left:${r(e.at)}px;top:${i(e.from)}px;
|
|
1181
|
+
height:${Math.max(e.to - e.from, 0)}px"></span>` : `<span class="dz-guide dz-guide-h${e.centre ? " is-centre" : ""}"
|
|
1182
|
+
style="top:${i(e.at)}px;left:${r(e.from)}px;
|
|
1183
|
+
width:${Math.max(e.to - e.from, 0)}px"></span>`), o = n.map((e) => {
|
|
1184
|
+
let t = Math.max(e.to - e.from, 0), n = `<i>${Math.round(e.distance)}</i>`, a = e.toBand ? " is-band" : "";
|
|
1185
|
+
return e.axis === "y" ? `<span class="dz-gap dz-gap-v${a}"
|
|
1186
|
+
style="left:${r(e.at)}px;top:${i(e.from)}px;
|
|
1187
|
+
height:${t}px">${n}</span>` : `<span class="dz-gap dz-gap-h${a}"
|
|
1188
|
+
style="top:${i(e.at)}px;left:${r(e.from)}px;
|
|
1189
|
+
width:${t}px">${n}</span>`;
|
|
1190
|
+
});
|
|
1191
|
+
return [...a, ...o].join("");
|
|
1192
|
+
}
|
|
1193
|
+
function Lt(e, t, n, r) {
|
|
1194
|
+
let i = Ct(e).find((e) => e.type === t);
|
|
1195
|
+
return i ? {
|
|
1196
|
+
x: i.left + n,
|
|
1197
|
+
y: i.top + r
|
|
1198
|
+
} : null;
|
|
1199
|
+
}
|
|
1200
|
+
function Rt(e, t, n = null, { groupZones: r = !0 } = {}) {
|
|
1201
|
+
let i = Ct(e);
|
|
1202
|
+
if (!i.length) return null;
|
|
1203
|
+
let a = i.filter((e) => !e.table), o = (r ? i : a).filter((e) => t >= e.top && t < e.top + e.height && (!e.table || n != null && n >= e.left && n < e.left + e.width));
|
|
1204
|
+
if (o.length) return o.at(-1).type;
|
|
1205
|
+
if (!a.length) return null;
|
|
1206
|
+
let s = [...a].sort((e, t) => e.top - t.top);
|
|
1207
|
+
return t < s[0].top ? s[0].type : s.at(-1).type;
|
|
1208
|
+
}
|
|
1209
|
+
function zt(e, t, n) {
|
|
1210
|
+
let r = Lt(e, t, n?.x ?? 0, n?.y ?? 0);
|
|
1211
|
+
return r ? Rt(e, r.y, r.x, { groupZones: n?.type !== "table" }) : null;
|
|
1212
|
+
}
|
|
1213
|
+
//#endregion
|
|
1214
|
+
//#region src/designer/structure.js
|
|
1215
|
+
var Bt = [
|
|
1216
|
+
"pageHeader",
|
|
1217
|
+
"reportHeader",
|
|
1218
|
+
"groupHeader",
|
|
1219
|
+
"detail",
|
|
1220
|
+
"groupFooter",
|
|
1221
|
+
"reportFooter",
|
|
1222
|
+
"pageFooter"
|
|
1223
|
+
], Vt = {
|
|
1224
|
+
pageHeader: 40,
|
|
1225
|
+
reportHeader: 80,
|
|
1226
|
+
groupHeader: 36,
|
|
1227
|
+
groupFooter: 36,
|
|
1228
|
+
reportFooter: 60,
|
|
1229
|
+
pageFooter: 40
|
|
1230
|
+
}, Ht = {
|
|
1231
|
+
reportHeader: "First page only",
|
|
1232
|
+
pageHeader: "Every page",
|
|
1233
|
+
groupHeader: "Before each group",
|
|
1234
|
+
detail: "The rows",
|
|
1235
|
+
groupFooter: "After each group",
|
|
1236
|
+
reportFooter: "Last page only",
|
|
1237
|
+
pageFooter: "Every page"
|
|
1238
|
+
};
|
|
1239
|
+
function Ut(e) {
|
|
1240
|
+
return Array.isArray(e?.bands) ? e.bands : [];
|
|
1241
|
+
}
|
|
1242
|
+
function Wt(e) {
|
|
1243
|
+
return Ut(e).flatMap((e) => e.items || []).filter((e) => e?.type === "table").length;
|
|
1244
|
+
}
|
|
1245
|
+
function Gt(e) {
|
|
1246
|
+
return Array.isArray(e?.bands);
|
|
1247
|
+
}
|
|
1248
|
+
function Kt(e) {
|
|
1249
|
+
let t = Wt(e);
|
|
1250
|
+
if (t === 0) return e.dataset ?? null;
|
|
1251
|
+
let n = e.dataset || "rows", r = new Set(Ut(e).flatMap((e) => e.items || []).filter((e) => e?.type === "table").map((t) => t.dataset ?? e.dataset));
|
|
1252
|
+
for (let e = t + 1;; e++) if (!r.has(`${n}${e}`)) return `${n}${e}`;
|
|
1253
|
+
}
|
|
1254
|
+
function qt(e, t) {
|
|
1255
|
+
e.y = nn(t), delete e.groupBy;
|
|
1256
|
+
}
|
|
1257
|
+
function Y(e, t) {
|
|
1258
|
+
return P(t) ? fe(e, t) : Ut(e).find((e) => e.type === t) ?? null;
|
|
1259
|
+
}
|
|
1260
|
+
function Jt(e) {
|
|
1261
|
+
let t = me(e), n = [];
|
|
1262
|
+
for (let r of Bt) Xt(e, r) && n.push(r), A.includes(r) && n.push(...t.filter((e) => e.kind === r).map((e) => e.key));
|
|
1263
|
+
return n;
|
|
1264
|
+
}
|
|
1265
|
+
function Yt(e) {
|
|
1266
|
+
let t = he(e), n = Se(e), r = [];
|
|
1267
|
+
for (let i of Bt) if ((!A.includes(i) || Xt(e, i) || n) && r.push(i), A.includes(i)) {
|
|
1268
|
+
let e = A.indexOf(i);
|
|
1269
|
+
for (let n of t) {
|
|
1270
|
+
let t = i === "groupFooter" ? [...n.levels].reverse() : n.levels;
|
|
1271
|
+
r.push(...t.map((t) => t.keys[e]));
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return r;
|
|
1275
|
+
}
|
|
1276
|
+
function Xt(e, t) {
|
|
1277
|
+
return Y(e, t) != null;
|
|
1278
|
+
}
|
|
1279
|
+
function Zt(e, t) {
|
|
1280
|
+
if (P(t)) {
|
|
1281
|
+
let n = ge(e, t, !0);
|
|
1282
|
+
return n && typeof n == "object" ? n : null;
|
|
1283
|
+
}
|
|
1284
|
+
if (!Bt.includes(t) || Xt(e, t)) return null;
|
|
1285
|
+
let n = {
|
|
1286
|
+
type: t,
|
|
1287
|
+
items: []
|
|
1288
|
+
};
|
|
1289
|
+
Vt[t] != null && (n.height = Vt[t]), Array.isArray(e.bands) || (e.bands = []);
|
|
1290
|
+
let r = (e) => Bt.indexOf(e), i = e.bands.findIndex((e) => r(e.type) > r(t));
|
|
1291
|
+
return i === -1 ? e.bands.push(n) : e.bands.splice(i, 0, n), n;
|
|
1292
|
+
}
|
|
1293
|
+
function Qt(e, t) {
|
|
1294
|
+
if (P(t)) return ge(e, t, !1) === !0;
|
|
1295
|
+
let n = Ut(e).findIndex((e) => e.type === t);
|
|
1296
|
+
return n === -1 ? !1 : (e.bands.splice(n, 1), !0);
|
|
1297
|
+
}
|
|
1298
|
+
function $t(e) {
|
|
1299
|
+
return new Set([...Ut(e), ...me(e).map((e) => e.band)].flatMap((e) => (e.items || []).map((e) => e.id)));
|
|
1300
|
+
}
|
|
1301
|
+
function en(e, t) {
|
|
1302
|
+
return !(t?.type === "table" && I(e));
|
|
1303
|
+
}
|
|
1304
|
+
function tn(e, t) {
|
|
1305
|
+
let n = $t(e);
|
|
1306
|
+
for (let e = 1;; e++) {
|
|
1307
|
+
let r = `${t}-${e}`;
|
|
1308
|
+
if (!n.has(r)) return r;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function nn(e) {
|
|
1312
|
+
let t = e.items || [];
|
|
1313
|
+
if (!t.length) return 0;
|
|
1314
|
+
let n = Math.max(...t.map((e) => (e.y ?? 0) + nt(e)));
|
|
1315
|
+
return Math.ceil(n / 10) * 10;
|
|
1316
|
+
}
|
|
1317
|
+
function rn(e) {
|
|
1318
|
+
let { page: t } = e;
|
|
1319
|
+
return t.width - t.margin.left - t.margin.right;
|
|
1320
|
+
}
|
|
1321
|
+
function an(e, t) {
|
|
1322
|
+
return {
|
|
1323
|
+
id: tn(e, "text"),
|
|
1324
|
+
type: "text",
|
|
1325
|
+
x: 0,
|
|
1326
|
+
y: nn(t),
|
|
1327
|
+
w: 200,
|
|
1328
|
+
h: 20,
|
|
1329
|
+
value: "Text",
|
|
1330
|
+
style: {
|
|
1331
|
+
fontFamily: De[0].value,
|
|
1332
|
+
fontSize: 12,
|
|
1333
|
+
fontWeight: "normal",
|
|
1334
|
+
fontStyle: "normal",
|
|
1335
|
+
color: "#000000",
|
|
1336
|
+
align: "left",
|
|
1337
|
+
background: null,
|
|
1338
|
+
border: null,
|
|
1339
|
+
padding: 0
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
function on(e, t, n = "horizontal") {
|
|
1344
|
+
let r = n === "vertical";
|
|
1345
|
+
return {
|
|
1346
|
+
id: tn(e, "line"),
|
|
1347
|
+
type: "line",
|
|
1348
|
+
x: 0,
|
|
1349
|
+
y: nn(t),
|
|
1350
|
+
w: r ? 12 : rn(e),
|
|
1351
|
+
h: r ? 80 : 12,
|
|
1352
|
+
orientation: r ? "vertical" : "horizontal",
|
|
1353
|
+
style: {
|
|
1354
|
+
thickness: 1,
|
|
1355
|
+
lineStyle: "solid",
|
|
1356
|
+
color: "#000000"
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
function sn(e, t) {
|
|
1361
|
+
return {
|
|
1362
|
+
id: tn(e, "box"),
|
|
1363
|
+
type: "box",
|
|
1364
|
+
x: 0,
|
|
1365
|
+
y: nn(t),
|
|
1366
|
+
w: rn(e),
|
|
1367
|
+
h: 80,
|
|
1368
|
+
style: {
|
|
1369
|
+
borderStyle: "solid",
|
|
1370
|
+
borderWidth: 1,
|
|
1371
|
+
borderColor: "#000000",
|
|
1372
|
+
background: null,
|
|
1373
|
+
radius: 0
|
|
1374
|
+
}
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
function cn(e, t) {
|
|
1378
|
+
return {
|
|
1379
|
+
id: tn(e, "image"),
|
|
1380
|
+
type: "image",
|
|
1381
|
+
x: 0,
|
|
1382
|
+
y: nn(t),
|
|
1383
|
+
w: 160,
|
|
1384
|
+
h: 80,
|
|
1385
|
+
src: null,
|
|
1386
|
+
field: null,
|
|
1387
|
+
fit: "contain",
|
|
1388
|
+
alt: ""
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
function ln(e) {
|
|
1392
|
+
return {
|
|
1393
|
+
field: `field${e}`,
|
|
1394
|
+
label: `Column ${e}`,
|
|
1395
|
+
width: 50,
|
|
1396
|
+
align: "left"
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
function un(e, t, n = 3) {
|
|
1400
|
+
let r = Math.max(1, Math.floor(Number(n) || 3));
|
|
1401
|
+
return {
|
|
1402
|
+
id: tn(e, "table"),
|
|
1403
|
+
type: "table",
|
|
1404
|
+
x: 0,
|
|
1405
|
+
y: nn(t),
|
|
1406
|
+
w: rn(e),
|
|
1407
|
+
dataset: Kt(e),
|
|
1408
|
+
rowHeight: 24,
|
|
1409
|
+
headerHeight: 28,
|
|
1410
|
+
showHeader: !0,
|
|
1411
|
+
wrap: !0,
|
|
1412
|
+
columns: Array.from({ length: r }, (e, t) => ln(t + 1)),
|
|
1413
|
+
style: {
|
|
1414
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
1415
|
+
fontSize: 12,
|
|
1416
|
+
color: "#000000",
|
|
1417
|
+
borderStyle: "solid",
|
|
1418
|
+
borderWidth: 1,
|
|
1419
|
+
borderColor: "#cccccc"
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function dn(e, t, n) {
|
|
1424
|
+
let r = Y(e, t);
|
|
1425
|
+
return !r || !en(t, n) ? null : (r.items ??= [], r.items.push(n), n);
|
|
1426
|
+
}
|
|
1427
|
+
var fn = 10;
|
|
1428
|
+
function pn(e) {
|
|
1429
|
+
return String(e.id ?? "").replace(/-\d+$/, "") || e.type || "item";
|
|
1430
|
+
}
|
|
1431
|
+
function mn(e, t, n) {
|
|
1432
|
+
if (!Number.isFinite(e?.page?.width)) return Math.max(0, t);
|
|
1433
|
+
let r = Math.max(0, rn(e) - (n ?? 0));
|
|
1434
|
+
return Math.min(Math.max(0, t), r);
|
|
1435
|
+
}
|
|
1436
|
+
function hn(e, t, n) {
|
|
1437
|
+
let r = Y(e, t);
|
|
1438
|
+
if (!r) return null;
|
|
1439
|
+
let i = (r.items || []).find((e) => e.id === n);
|
|
1440
|
+
if (!i || i.type === "table" && !Gt(e)) return null;
|
|
1441
|
+
let a = structuredClone(i);
|
|
1442
|
+
return a.id = tn(e, pn(i)), a.x = mn(e, (i.x ?? 0) + fn, a.w), a.y = Math.max(0, (i.y ?? 0) + fn), a.type === "table" && qt(a, r), r.items ??= [], r.items.push(a), a;
|
|
1443
|
+
}
|
|
1444
|
+
function gn(e, t) {
|
|
1445
|
+
return Number.isFinite(e?.page?.height) ? Ct(e).find((e) => e.type === t)?.height ?? null : null;
|
|
1446
|
+
}
|
|
1447
|
+
function _n(e, t, n, r) {
|
|
1448
|
+
let i = gn(e, t);
|
|
1449
|
+
if (i == null) return Math.max(0, n);
|
|
1450
|
+
let a = Math.max(0, i - nt(r));
|
|
1451
|
+
return Math.min(Math.max(0, n), a);
|
|
1452
|
+
}
|
|
1453
|
+
function vn(e, t, n) {
|
|
1454
|
+
let r = Y(e, t);
|
|
1455
|
+
if (!r) return [];
|
|
1456
|
+
r.items ??= [];
|
|
1457
|
+
let i = [];
|
|
1458
|
+
for (let { band: a, item: o } of n || []) {
|
|
1459
|
+
if (!o || o.type === "table" && !Gt(e) || !en(t, o)) continue;
|
|
1460
|
+
let n = structuredClone(o), s = Math.max(0, (o.y ?? 0) + fn);
|
|
1461
|
+
n.id = tn(e, pn(o)), n.x = mn(e, (o.x ?? 0) + fn, n.w), n.y = a === t ? s : _n(e, t, s, n), n.type === "table" && qt(n, r), r.items.push(n), i.push(n);
|
|
1462
|
+
}
|
|
1463
|
+
return i;
|
|
1464
|
+
}
|
|
1465
|
+
function yn(e, t, n) {
|
|
1466
|
+
let r = Y(e, t);
|
|
1467
|
+
if (!r) return !1;
|
|
1468
|
+
let i = (r.items || []).findIndex((e) => e.id === n);
|
|
1469
|
+
return i === -1 ? !1 : (r.items.splice(i, 1), !0);
|
|
1470
|
+
}
|
|
1471
|
+
function bn(e, t, n, r) {
|
|
1472
|
+
if (t === n) return !1;
|
|
1473
|
+
let i = Y(e, t), a = Y(e, n);
|
|
1474
|
+
if (!i || !a) return !1;
|
|
1475
|
+
let o = (i.items || []).find((e) => e.id === r);
|
|
1476
|
+
if (!o || !en(n, o)) return !1;
|
|
1477
|
+
let s = Lt(e, t, o.x ?? 0, o.y ?? 0);
|
|
1478
|
+
yn(e, t, r), dn(e, n, o);
|
|
1479
|
+
let c = Lt(e, n, 0, 0);
|
|
1480
|
+
return s && c && (o.x = Math.round(s.x - c.x), o.y = Math.round(s.y - c.y)), !0;
|
|
1481
|
+
}
|
|
1482
|
+
function xn(e) {
|
|
1483
|
+
e.columns ??= [];
|
|
1484
|
+
let t = ln(e.columns.length + 1);
|
|
1485
|
+
return e.columns.push(t), t;
|
|
1486
|
+
}
|
|
1487
|
+
function Sn(e, t) {
|
|
1488
|
+
return !Array.isArray(e.columns) || e.columns.length <= 1 || t < 0 || t >= e.columns.length ? !1 : (e.columns.splice(t, 1), !0);
|
|
1489
|
+
}
|
|
1490
|
+
function Cn(e, t, { table: n = !1 } = {}) {
|
|
1491
|
+
return t && Xt(e, t.band) && !(n && I(t.band)) ? t.band : Xt(e, "detail") ? "detail" : Ut(e)[0]?.type ?? null;
|
|
1492
|
+
}
|
|
1493
|
+
var wn = .01;
|
|
1494
|
+
function Tn(e) {
|
|
1495
|
+
return [
|
|
1496
|
+
{
|
|
1497
|
+
at: e.x,
|
|
1498
|
+
centre: !1
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
at: e.x + (e.w ?? 0) / 2,
|
|
1502
|
+
centre: !0
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
at: e.x + (e.w ?? 0),
|
|
1506
|
+
centre: !1
|
|
1507
|
+
}
|
|
1508
|
+
];
|
|
1509
|
+
}
|
|
1510
|
+
function En(e) {
|
|
1511
|
+
return [
|
|
1512
|
+
{
|
|
1513
|
+
at: e.y,
|
|
1514
|
+
centre: !1
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
at: e.y + (e.h ?? 0) / 2,
|
|
1518
|
+
centre: !0
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
at: e.y + (e.h ?? 0),
|
|
1522
|
+
centre: !1
|
|
1523
|
+
}
|
|
1524
|
+
];
|
|
1525
|
+
}
|
|
1526
|
+
function Dn(e) {
|
|
1527
|
+
if (!e?.length) return null;
|
|
1528
|
+
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)));
|
|
1529
|
+
return {
|
|
1530
|
+
x: t,
|
|
1531
|
+
y: n,
|
|
1532
|
+
w: r - t,
|
|
1533
|
+
h: i - n
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
function On(e, t, n, r = []) {
|
|
1537
|
+
let i = n === "x" ? Tn : En, a = (r || []).filter(Number.isFinite).map((e) => ({
|
|
1538
|
+
at: e,
|
|
1539
|
+
centre: !1,
|
|
1540
|
+
box: null
|
|
1541
|
+
})), o = (e || []).flatMap((e) => i(e).map((t) => ({
|
|
1542
|
+
...t,
|
|
1543
|
+
box: e
|
|
1544
|
+
}))), s = n === "x" ? t?.w ?? 0 : t?.h ?? 0, c = t ? i({
|
|
1545
|
+
x: 0,
|
|
1546
|
+
y: 0,
|
|
1547
|
+
w: s,
|
|
1548
|
+
h: s
|
|
1549
|
+
}).map((e) => ({
|
|
1550
|
+
...e,
|
|
1551
|
+
box: null
|
|
1552
|
+
})) : [];
|
|
1553
|
+
return [
|
|
1554
|
+
...a,
|
|
1555
|
+
...o,
|
|
1556
|
+
...c
|
|
1557
|
+
];
|
|
1558
|
+
}
|
|
1559
|
+
function kn(e, t, n = 6) {
|
|
1560
|
+
let r = null;
|
|
1561
|
+
for (let i of e) for (let e of t) {
|
|
1562
|
+
let t = e.at - i.at;
|
|
1563
|
+
Math.abs(t) > n || (!r || Math.abs(t) < Math.abs(r.delta) - wn) && (r = {
|
|
1564
|
+
delta: t,
|
|
1565
|
+
at: e.at
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
return r;
|
|
1569
|
+
}
|
|
1570
|
+
function An(e, t, n, r, i) {
|
|
1571
|
+
let a = t.filter((e) => Math.abs(e.at - n) < wn);
|
|
1572
|
+
if (!a.length) return [];
|
|
1573
|
+
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)];
|
|
1574
|
+
return [{
|
|
1575
|
+
axis: r,
|
|
1576
|
+
at: n,
|
|
1577
|
+
from: o ? 0 : Math.min(...u),
|
|
1578
|
+
to: o ? l : Math.max(...u),
|
|
1579
|
+
centre: a.every((e) => e.centre)
|
|
1580
|
+
}];
|
|
1581
|
+
}
|
|
1582
|
+
function jn(e, t, n, { snap: r = 6, guides: i } = {}) {
|
|
1583
|
+
if (!e) return {
|
|
1584
|
+
dx: 0,
|
|
1585
|
+
dy: 0,
|
|
1586
|
+
lines: []
|
|
1587
|
+
};
|
|
1588
|
+
let a = On(t, n, "x", i?.x), o = On(t, n, "y", i?.y), s = kn(Tn(e), a, r), c = kn(En(e), o, r), l = s?.delta ?? 0, u = c?.delta ?? 0, d = {
|
|
1589
|
+
...e,
|
|
1590
|
+
x: e.x + l,
|
|
1591
|
+
y: e.y + u
|
|
1592
|
+
};
|
|
1593
|
+
return {
|
|
1594
|
+
dx: l,
|
|
1595
|
+
dy: u,
|
|
1596
|
+
lines: [...s ? An(d, a, s.at, "x", n) : [], ...c ? An(d, o, c.at, "y", n) : []]
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
function Mn(e, t, n) {
|
|
1600
|
+
let [r, i] = n === "x" ? ["x", "w"] : ["y", "h"];
|
|
1601
|
+
return e[r] < t[r] + (t[i] ?? 0) && e[r] + (e[i] ?? 0) > t[r];
|
|
1602
|
+
}
|
|
1603
|
+
function Nn(e, t, n, r) {
|
|
1604
|
+
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) => Mn(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;
|
|
1605
|
+
if (!(h >= 0)) return null;
|
|
1606
|
+
let g = f.find((e) => Math.abs((d ? e[s] + (e[c] ?? 0) : e[s]) - m) < wn), ee = 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)];
|
|
1607
|
+
return {
|
|
1608
|
+
side: r,
|
|
1609
|
+
axis: a,
|
|
1610
|
+
at: (ee[0] + ee[1]) / 2,
|
|
1611
|
+
from: d ? m : u,
|
|
1612
|
+
to: d ? l : m,
|
|
1613
|
+
distance: h,
|
|
1614
|
+
toBand: f.length === 0
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
function Pn(e, t, n) {
|
|
1618
|
+
return e ? [
|
|
1619
|
+
"up",
|
|
1620
|
+
"down",
|
|
1621
|
+
"left",
|
|
1622
|
+
"right"
|
|
1623
|
+
].map((r) => Nn(e, t, n, r)).filter(Boolean) : [];
|
|
1624
|
+
}
|
|
1625
|
+
function Fn(e, t, n, r = {}) {
|
|
1626
|
+
let i = Dn(e);
|
|
1627
|
+
if (!i) return {
|
|
1628
|
+
dx: 0,
|
|
1629
|
+
dy: 0,
|
|
1630
|
+
lines: [],
|
|
1631
|
+
gaps: []
|
|
1632
|
+
};
|
|
1633
|
+
let { dx: a, dy: o, lines: s } = jn(i, t, n, r);
|
|
1634
|
+
return {
|
|
1635
|
+
dx: a,
|
|
1636
|
+
dy: o,
|
|
1637
|
+
lines: s,
|
|
1638
|
+
gaps: Pn({
|
|
1639
|
+
...i,
|
|
1640
|
+
x: i.x + a,
|
|
1641
|
+
y: i.y + o
|
|
1642
|
+
}, t, n)
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
//#endregion
|
|
1646
|
+
//#region src/designer/select.js
|
|
1647
|
+
function In({ 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 }) {
|
|
1648
|
+
let f = null, p = 0, m = !1, h = e.ownerDocument;
|
|
1649
|
+
function g(t) {
|
|
1650
|
+
let n = e.querySelector(".dz-page");
|
|
1651
|
+
if (!n) return null;
|
|
1652
|
+
let r = n.getBoundingClientRect(), i = s() || 1, a = h.defaultView?.getComputedStyle(n);
|
|
1653
|
+
return {
|
|
1654
|
+
x: (t.clientX - r.left) / i - parseFloat(a?.paddingLeft || 0),
|
|
1655
|
+
y: (t.clientY - r.top) / i - parseFloat(a?.paddingTop || 0)
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
function ee(e) {
|
|
1659
|
+
return e?.closest("[data-band-type]")?.dataset.bandType ?? null;
|
|
1660
|
+
}
|
|
1661
|
+
function _(e) {
|
|
1662
|
+
let t = e?.closest("[data-item-id]");
|
|
1663
|
+
if (!t) return null;
|
|
1664
|
+
let n = ee(t);
|
|
1665
|
+
return n ? {
|
|
1666
|
+
band: n,
|
|
1667
|
+
id: t.dataset.itemId,
|
|
1668
|
+
node: t
|
|
1669
|
+
} : null;
|
|
1670
|
+
}
|
|
1671
|
+
function v(e) {
|
|
1672
|
+
return e ? (Y(t(), e.band)?.items || []).find((t) => t.id === e.id) ?? null : null;
|
|
1673
|
+
}
|
|
1674
|
+
function y(e, n) {
|
|
1675
|
+
let r = Y(t(), e), i = new Set(n.map((e) => e.where.id));
|
|
1676
|
+
return (r?.items || []).filter((e) => !i.has(e.id)).map(at);
|
|
1677
|
+
}
|
|
1678
|
+
function b() {
|
|
1679
|
+
return (n() || []).map((e) => ({
|
|
1680
|
+
where: e,
|
|
1681
|
+
item: v(e)
|
|
1682
|
+
})).filter((e) => e.item);
|
|
1683
|
+
}
|
|
1684
|
+
function x() {
|
|
1685
|
+
return b().at(-1) ?? null;
|
|
1686
|
+
}
|
|
1687
|
+
function S(e) {
|
|
1688
|
+
if (!c() || e.button !== 0 || d() && C(e)) return;
|
|
1689
|
+
let t = e.target.closest?.("[data-handle]");
|
|
1690
|
+
if (t) {
|
|
1691
|
+
let n = x();
|
|
1692
|
+
if (!n) return;
|
|
1693
|
+
T(e, {
|
|
1694
|
+
mode: "resize",
|
|
1695
|
+
handle: t.dataset.handle,
|
|
1696
|
+
item: n.item
|
|
1697
|
+
});
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
let i = _(e.target);
|
|
1701
|
+
if (!i) {
|
|
1702
|
+
r(null);
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
let a = {
|
|
1706
|
+
band: i.band,
|
|
1707
|
+
id: i.id
|
|
1708
|
+
}, s = (n() || []).some((e) => e.band === a.band && e.id === a.id);
|
|
1709
|
+
if (e.shiftKey) {
|
|
1710
|
+
r(a, { add: !0 });
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
if (e.altKey && (s || r(a), o())) {
|
|
1714
|
+
T(e, {
|
|
1715
|
+
mode: "move",
|
|
1716
|
+
collapseTo: null
|
|
1717
|
+
});
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
s || r(a), T(e, {
|
|
1721
|
+
mode: "move",
|
|
1722
|
+
collapseTo: s ? a : null
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
function C(e) {
|
|
1726
|
+
let n = e.target.closest?.("[data-role=\"ruler\"]"), r = g(e);
|
|
1727
|
+
if (!r) return !1;
|
|
1728
|
+
if (n) {
|
|
1729
|
+
let a = n.dataset.axis, o = ht(t(), a, r[a]);
|
|
1730
|
+
return o === null ? !1 : (f = {
|
|
1731
|
+
mode: "guide",
|
|
1732
|
+
axis: a,
|
|
1733
|
+
at: o,
|
|
1734
|
+
created: !0,
|
|
1735
|
+
moved: !1,
|
|
1736
|
+
key: `guide:${++p}`
|
|
1737
|
+
}, w(e), i({
|
|
1738
|
+
live: !0,
|
|
1739
|
+
key: f.key
|
|
1740
|
+
}), !0);
|
|
1741
|
+
}
|
|
1742
|
+
if (!e.target.closest?.(".dz-page")) return !1;
|
|
1743
|
+
for (let n of ["x", "y"]) {
|
|
1744
|
+
let i = vt(t(), n, r[n]);
|
|
1745
|
+
if (i !== null) return f = {
|
|
1746
|
+
mode: "guide",
|
|
1747
|
+
axis: n,
|
|
1748
|
+
at: i,
|
|
1749
|
+
created: !1,
|
|
1750
|
+
moved: !1,
|
|
1751
|
+
key: `guide:${++p}`
|
|
1752
|
+
}, w(e), !0;
|
|
1753
|
+
}
|
|
1754
|
+
return !1;
|
|
1755
|
+
}
|
|
1756
|
+
function w(t) {
|
|
1757
|
+
e.setPointerCapture?.(t.pointerId), e.classList.add("is-dragging"), t.preventDefault();
|
|
1758
|
+
}
|
|
1759
|
+
function T(e, t) {
|
|
1760
|
+
let n = t.mode === "move" ? b().map((e) => ({
|
|
1761
|
+
...e,
|
|
1762
|
+
box: at(e.item)
|
|
1763
|
+
})) : [];
|
|
1764
|
+
f = {
|
|
1765
|
+
...t,
|
|
1766
|
+
group: n,
|
|
1767
|
+
band: x()?.where.band ?? null,
|
|
1768
|
+
target: null,
|
|
1769
|
+
startX: e.clientX,
|
|
1770
|
+
startY: e.clientY,
|
|
1771
|
+
box: t.item ? at(t.item) : null,
|
|
1772
|
+
moved: !1
|
|
1773
|
+
}, w(e);
|
|
1774
|
+
}
|
|
1775
|
+
function E(e) {
|
|
1776
|
+
if (!f) return;
|
|
1777
|
+
if (f.mode === "guide") {
|
|
1778
|
+
let n = g(e);
|
|
1779
|
+
if (!n) return;
|
|
1780
|
+
f.moved = !0, f.at = _t(t(), f.axis, f.at, n[f.axis]), i({
|
|
1781
|
+
live: !0,
|
|
1782
|
+
key: f.key
|
|
1783
|
+
});
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
let n = s() || 1, r = (e.clientX - f.startX) / n, a = (e.clientY - f.startY) / n;
|
|
1787
|
+
if (k(e.altKey), !f.moved && Math.abs(r) < 1 && Math.abs(a) < 1) return;
|
|
1788
|
+
if (f.moved = !0, f.mode === "resize") {
|
|
1789
|
+
ut(f.item, lt(f.handle, f.box, r, a, ot(f.item))), i({ live: !0 });
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
for (let e of f.group) ut(e.item, {
|
|
1793
|
+
...e.box,
|
|
1794
|
+
...ct(e.box, r, a)
|
|
1795
|
+
});
|
|
1796
|
+
te(f.group);
|
|
1797
|
+
let o = t(), c = /* @__PURE__ */ new Set();
|
|
1798
|
+
for (let e of f.group) {
|
|
1799
|
+
let t = zt(o, e.where.band, e.item);
|
|
1800
|
+
t && t !== e.where.band && c.add(t);
|
|
1801
|
+
}
|
|
1802
|
+
f.target = c.size ? [...c] : null, l(f.target), i({ live: !0 });
|
|
1803
|
+
}
|
|
1804
|
+
function te(e) {
|
|
1805
|
+
let n = f?.band ? Ft(t(), f.band) : null;
|
|
1806
|
+
if (!n || !e.length) {
|
|
1807
|
+
u(null);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
let r = y(f.band, e), i = Fn(e.map((e) => at(e.item)), r, n, { guides: d() ? yt(t(), n) : void 0 });
|
|
1811
|
+
if (i.dx || i.dy) for (let t of e) ut(t.item, {
|
|
1812
|
+
...at(t.item),
|
|
1813
|
+
x: (t.item.x ?? 0) + i.dx,
|
|
1814
|
+
y: (t.item.y ?? 0) + i.dy
|
|
1815
|
+
});
|
|
1816
|
+
u({
|
|
1817
|
+
band: f.band,
|
|
1818
|
+
lines: i.lines,
|
|
1819
|
+
gaps: m ? i.gaps : []
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
function D() {
|
|
1823
|
+
let e = b(), n = e.at(-1)?.where ?? null, r = n ? Ft(t(), n.band) : null;
|
|
1824
|
+
if (!r || !e.length) {
|
|
1825
|
+
u(null);
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
let i = e.map((e) => at(e.item));
|
|
1829
|
+
u({
|
|
1830
|
+
band: n.band,
|
|
1831
|
+
lines: [],
|
|
1832
|
+
gaps: Pn(Dn(i), y(n.band, e), r)
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
function O() {
|
|
1836
|
+
if (f?.mode === "move") {
|
|
1837
|
+
te(f.group);
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
if (m) {
|
|
1841
|
+
D();
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
u(null);
|
|
1845
|
+
}
|
|
1846
|
+
function k(e) {
|
|
1847
|
+
return e === m ? !1 : (m = e, !0);
|
|
1848
|
+
}
|
|
1849
|
+
function ne(n) {
|
|
1850
|
+
if (!f) return;
|
|
1851
|
+
if (e.releasePointerCapture?.(n.pointerId), e.classList.remove("is-dragging"), f.mode === "guide") {
|
|
1852
|
+
let { axis: e, at: n, key: r } = f;
|
|
1853
|
+
f = null;
|
|
1854
|
+
let a = re(e);
|
|
1855
|
+
(n === null || n < 0 || a !== null && n > a) && gt(t(), e, n), i({
|
|
1856
|
+
live: !1,
|
|
1857
|
+
key: r
|
|
1858
|
+
});
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
let a = f.moved, o = f.target, s = f.collapseTo;
|
|
1862
|
+
f = null, l(null), k(n.altKey), a ? i({
|
|
1863
|
+
live: !1,
|
|
1864
|
+
band: o
|
|
1865
|
+
}) : s && r(s), O();
|
|
1866
|
+
}
|
|
1867
|
+
function re(e) {
|
|
1868
|
+
let n = t()?.page;
|
|
1869
|
+
return n?.margin ? e === "x" ? n.width - n.margin.left - n.margin.right : n.height - n.margin.top - n.margin.bottom : null;
|
|
1870
|
+
}
|
|
1871
|
+
function ie(e) {
|
|
1872
|
+
if (!c() || e.target.closest?.("input, textarea, select")) return;
|
|
1873
|
+
if (e.key === "Alt") {
|
|
1874
|
+
k(!0) && O(), e.preventDefault();
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
if (e.key === "Escape") {
|
|
1878
|
+
r(null);
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
1882
|
+
if (!b().length) return;
|
|
1883
|
+
e.preventDefault(), a();
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
let t = {
|
|
1887
|
+
ArrowLeft: [-1, 0],
|
|
1888
|
+
ArrowRight: [1, 0],
|
|
1889
|
+
ArrowUp: [0, -1],
|
|
1890
|
+
ArrowDown: [0, 1]
|
|
1891
|
+
}[e.key];
|
|
1892
|
+
if (!t) return;
|
|
1893
|
+
let n = b();
|
|
1894
|
+
if (!n.length) return;
|
|
1895
|
+
let o = e.shiftKey ? 10 : 1;
|
|
1896
|
+
for (let { item: e } of n) e.x = (e.x ?? 0) + t[0] * o, e.y = (e.y ?? 0) + t[1] * o;
|
|
1897
|
+
e.preventDefault(), i({ live: !1 });
|
|
1898
|
+
}
|
|
1899
|
+
function ae(e) {
|
|
1900
|
+
e.key === "Alt" && k(!1) && O();
|
|
1901
|
+
}
|
|
1902
|
+
function oe() {
|
|
1903
|
+
k(!1) && O();
|
|
1904
|
+
}
|
|
1905
|
+
return e.addEventListener("pointerdown", S), e.addEventListener("pointermove", E), e.addEventListener("pointerup", ne), e.addEventListener("pointercancel", ne), h.addEventListener("keydown", ie), h.addEventListener("keyup", ae), h.defaultView?.addEventListener("blur", oe), function() {
|
|
1906
|
+
e.removeEventListener("pointerdown", S), e.removeEventListener("pointermove", E), e.removeEventListener("pointerup", ne), e.removeEventListener("pointercancel", ne), h.removeEventListener("keydown", ie), h.removeEventListener("keyup", ae), h.defaultView?.removeEventListener("blur", oe);
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
//#endregion
|
|
1910
|
+
//#region src/designer/panel.js
|
|
1911
|
+
function Ln(e, t = null) {
|
|
1912
|
+
return `
|
|
1913
|
+
<div class="dz-panel-head">
|
|
1914
|
+
<span class="dz-panel-type">${S(e.type)}</span>
|
|
1915
|
+
<span class="dz-panel-id">${S(e.id)}</span>
|
|
1916
|
+
</div>
|
|
1917
|
+
${Gn(e, Ie(e))}
|
|
1918
|
+
${e.type === "text" ? `
|
|
1919
|
+
<section class="dz-section">
|
|
1920
|
+
<h3>Format</h3>
|
|
1921
|
+
<div class="dz-field dz-field-format">
|
|
1922
|
+
<label>Values</label>
|
|
1923
|
+
${Kn(e, t)}
|
|
1924
|
+
</div>
|
|
1925
|
+
<div class="dz-field dz-field-format">
|
|
1926
|
+
<label>Highlight</label>
|
|
1927
|
+
${qn(e.highlight, "edit-highlight")}
|
|
1928
|
+
</div>
|
|
1929
|
+
</section>` : ""}
|
|
1930
|
+
${e.type === "table" ? `
|
|
1931
|
+
<section class="dz-section">
|
|
1932
|
+
<h3>Row highlight</h3>
|
|
1933
|
+
<div class="dz-field dz-field-format">
|
|
1934
|
+
<label>Rows</label>
|
|
1935
|
+
${qn(e.rowHighlight, "edit-row-highlight")}
|
|
1936
|
+
</div>
|
|
1937
|
+
</section>` : ""}
|
|
1938
|
+
${e.type === "table" ? Rn(e, t) : ""}
|
|
1939
|
+
${e.type === "table" ? tr(e, t) : ""}`;
|
|
1940
|
+
}
|
|
1941
|
+
function Rn(e, t) {
|
|
1942
|
+
let n = b(e);
|
|
1943
|
+
if (!n.length) return "";
|
|
1944
|
+
let r = t ?? { bands: [{
|
|
1945
|
+
type: "detail",
|
|
1946
|
+
items: [e]
|
|
1947
|
+
}] }, i = t ? he(t).filter((t) => t.table !== e.id) : [];
|
|
1948
|
+
return `
|
|
1949
|
+
<section class="dz-section dz-bands dz-grouping">
|
|
1950
|
+
<h3>Grouping</h3>
|
|
1951
|
+
${n.map((t, i) => zn(r, e, t, i, n.length)).join("")}
|
|
1952
|
+
${n.length < 8 ? "\n <button type=\"button\" class=\"dz-add-row\" data-action=\"add-group-level\"\n title=\"Split each group of this table again, by another field\">\n Group within each group</button>" : ""}
|
|
1953
|
+
${i.map((e) => `
|
|
1954
|
+
<button type="button" class="dz-add-row" data-action="copy-grouping"
|
|
1955
|
+
data-from="${S(e.table)}"
|
|
1956
|
+
title="Replace this table's group header and footer with copies of ${S(e.table)}'s">
|
|
1957
|
+
Copy group design from ${S(e.table)}</button>`).join("")}
|
|
1958
|
+
</section>`;
|
|
1959
|
+
}
|
|
1960
|
+
function zn(e, t, n, r, i) {
|
|
1961
|
+
let a = typeof n?.by == "string" ? n.by : "", o = Bn(e, t, a, r);
|
|
1962
|
+
if (i === 1) return `${Hn(n, r)}${o}`;
|
|
1963
|
+
let s = `dz-f-group-level-${r}`;
|
|
1964
|
+
return `
|
|
1965
|
+
<div class="dz-group-level" data-level="${r}">
|
|
1966
|
+
<div class="dz-group-level-head">
|
|
1967
|
+
<span class="dz-group-level-name">Level ${r + 1}${a ? ` · <b>${S(a)}</b>` : ""}</span>
|
|
1968
|
+
<span class="dz-group-level-actions">
|
|
1969
|
+
${r > 0 ? `
|
|
1970
|
+
<button type="button" class="dz-icon" data-action="move-group-level-out"
|
|
1971
|
+
data-level="${r}"
|
|
1972
|
+
title="Group by this before the level above it"
|
|
1973
|
+
aria-label="Move level ${r + 1} out">↑</button>` : ""}
|
|
1974
|
+
<button type="button" class="dz-icon" data-action="remove-group-level"
|
|
1975
|
+
data-level="${r}"
|
|
1976
|
+
title="Stop grouping by this, and remove its header and footer"
|
|
1977
|
+
aria-label="Remove level ${r + 1}">×</button>
|
|
1978
|
+
</span>
|
|
1979
|
+
</div>
|
|
1980
|
+
${r > 0 ? `
|
|
1981
|
+
<div class="dz-field dz-field-text">
|
|
1982
|
+
<label for="${s}">Then group by</label>
|
|
1983
|
+
<input type="text" id="${s}" data-group-level="${r}"
|
|
1984
|
+
value="${S(a)}" spellcheck="false">
|
|
1985
|
+
<p class="dz-hint">A field to group each group above by</p>
|
|
1986
|
+
</div>` : ""}
|
|
1987
|
+
${Hn(n, r)}
|
|
1988
|
+
${o}
|
|
1989
|
+
</div>`;
|
|
1990
|
+
}
|
|
1991
|
+
function Bn(e, t, n, r) {
|
|
1992
|
+
let i = n || "group";
|
|
1993
|
+
return A.map((n) => ir(e, N(n, t.id, r), n === "groupHeader" ? {
|
|
1994
|
+
label: "Group header",
|
|
1995
|
+
note: `Before each ${i}`
|
|
1996
|
+
} : {
|
|
1997
|
+
label: "Group footer",
|
|
1998
|
+
note: `After each ${i}`
|
|
1999
|
+
})).join("");
|
|
2000
|
+
}
|
|
2001
|
+
var Vn = [
|
|
2002
|
+
{
|
|
2003
|
+
value: "",
|
|
2004
|
+
label: "As they come"
|
|
2005
|
+
},
|
|
2006
|
+
{
|
|
2007
|
+
value: "asc",
|
|
2008
|
+
label: "A to Z, 0 to 9"
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
value: "desc",
|
|
2012
|
+
label: "Z to A, 9 to 0"
|
|
2013
|
+
}
|
|
2014
|
+
];
|
|
2015
|
+
function Hn(e, t) {
|
|
2016
|
+
let n = typeof e?.sort == "string" ? e.sort : "", r = `dz-f-group-${t}`;
|
|
2017
|
+
return `
|
|
2018
|
+
<div class="dz-field dz-field-choice">
|
|
2019
|
+
<label for="${r}-sort">Order groups</label>
|
|
2020
|
+
<select id="${r}-sort" data-group-option="sort" data-level="${t}">
|
|
2021
|
+
${Vn.map((e) => `<option value="${e.value}"${e.value === n ? " selected" : ""}
|
|
2022
|
+
>${S(e.label)}</option>`).join("")}
|
|
2023
|
+
</select>
|
|
2024
|
+
</div>
|
|
2025
|
+
<div class="dz-field dz-field-toggle">
|
|
2026
|
+
<label for="${r}-page">New page for each group</label>
|
|
2027
|
+
<input type="checkbox" id="${r}-page" data-group-option="newPage" data-level="${t}"
|
|
2028
|
+
${e?.newPage === !0 ? "checked" : ""}>
|
|
2029
|
+
<p class="dz-hint">Every group but the first starts at the top of a page</p>
|
|
2030
|
+
</div>`;
|
|
2031
|
+
}
|
|
2032
|
+
function Un(e) {
|
|
2033
|
+
return `
|
|
2034
|
+
<div class="dz-panel-head">
|
|
2035
|
+
<span class="dz-panel-type">${e.length} items</span>
|
|
2036
|
+
</div>
|
|
2037
|
+
|
|
2038
|
+
<section class="dz-section">
|
|
2039
|
+
<ul class="dz-selected">
|
|
2040
|
+
${e.map((e) => `
|
|
2041
|
+
<li>
|
|
2042
|
+
<span class="dz-selected-type">${S(e.type)}</span>
|
|
2043
|
+
<span class="dz-selected-id">${S(e.id)}</span>
|
|
2044
|
+
</li>`).join("")}
|
|
2045
|
+
</ul>
|
|
2046
|
+
|
|
2047
|
+
<p class="dz-hint">
|
|
2048
|
+
Drag to move them together, or use the arrow keys.
|
|
2049
|
+
Select one on its own to change its properties.
|
|
2050
|
+
</p>
|
|
2051
|
+
</section>`;
|
|
2052
|
+
}
|
|
2053
|
+
function Wn(e) {
|
|
2054
|
+
return `
|
|
2055
|
+
<div class="dz-panel-head">
|
|
2056
|
+
<span class="dz-panel-type">report</span>
|
|
2057
|
+
<span class="dz-panel-id">${S(e.name ?? "Untitled")}</span>
|
|
2058
|
+
</div>
|
|
2059
|
+
${Gn(e, Be(e))}
|
|
2060
|
+
${nr(e)}`;
|
|
2061
|
+
}
|
|
2062
|
+
function Gn(e, t) {
|
|
2063
|
+
return t.map((t) => `
|
|
2064
|
+
<section class="dz-section">
|
|
2065
|
+
<h3>${S(t.title)}</h3>
|
|
2066
|
+
${t.fields.map((t) => Jn(e, t)).join("")}
|
|
2067
|
+
${(t.actions ?? []).map((e) => `
|
|
2068
|
+
<button type="button" class="dz-add-row dz-section-action"
|
|
2069
|
+
data-action="${S(e.action)}" title="${S(e.title ?? "")}">
|
|
2070
|
+
${S(e.label)}</button>`).join("")}
|
|
2071
|
+
</section>`).join("");
|
|
2072
|
+
}
|
|
2073
|
+
function Kn(e, t, n) {
|
|
2074
|
+
let r = h(e?.format, t?.format);
|
|
2075
|
+
return `
|
|
2076
|
+
<button type="button" class="dz-format" data-action="edit-format"
|
|
2077
|
+
${n == null ? "" : `data-index="${S(n)}"`}
|
|
2078
|
+
title="${S(r)} - click to change how values print">
|
|
2079
|
+
<span class="dz-format-summary">${S(r)}</span>
|
|
2080
|
+
<span class="dz-format-edit">Edit</span>
|
|
2081
|
+
</button>`;
|
|
2082
|
+
}
|
|
2083
|
+
function qn(e, t, n) {
|
|
2084
|
+
let r = p(e);
|
|
2085
|
+
return `
|
|
2086
|
+
<button type="button" class="dz-format" data-action="${S(t)}"
|
|
2087
|
+
${n == null ? "" : `data-index="${S(n)}"`}
|
|
2088
|
+
title="${S(r)} - click to style values by what they are">
|
|
2089
|
+
<span class="dz-format-summary">${S(r)}</span>
|
|
2090
|
+
<span class="dz-format-edit">Edit</span>
|
|
2091
|
+
</button>`;
|
|
2092
|
+
}
|
|
2093
|
+
function Jn(e, t, n = "") {
|
|
2094
|
+
let r = qe(e, t), i = `dz-f-${t.key.replace(/\./g, "-")}${n ? `-${n}` : ""}`, a = n ? `data-field="${S(t.key)}" data-column="${S(n)}"` : `data-field="${S(t.key)}"`, o = t.type === "textarea" ? `<span class="dz-field-top">
|
|
2095
|
+
<label for="${i}">${S(t.label)}</label>
|
|
2096
|
+
<button type="button" class="dz-brace" data-action="insert-brace"
|
|
2097
|
+
data-for="${S(t.key)}"
|
|
2098
|
+
title="Wrap the selected text in braces, or insert a pair"
|
|
2099
|
+
aria-label="Insert a placeholder">{ }</button>
|
|
2100
|
+
</span>` : `<label for="${i}">${S(t.label)}</label>`;
|
|
2101
|
+
return `
|
|
2102
|
+
<div class="dz-field dz-field-${t.type}">
|
|
2103
|
+
${o}
|
|
2104
|
+
${Yn(i, a, t, r)}
|
|
2105
|
+
${t.hint ? `<p class="dz-hint">${S(t.hint)}</p>` : ""}
|
|
2106
|
+
</div>`;
|
|
2107
|
+
}
|
|
2108
|
+
function Yn(e, t, n, r) {
|
|
2109
|
+
switch (n.type) {
|
|
2110
|
+
case "textarea": return `
|
|
2111
|
+
<div class="dz-value">
|
|
2112
|
+
<div class="dz-value-marks" data-role="marks" aria-hidden="true"
|
|
2113
|
+
>${sr(r ?? "")}</div>
|
|
2114
|
+
<textarea id="${e}" ${t} rows="2"
|
|
2115
|
+
spellcheck="false">${S(r ?? "")}</textarea>
|
|
2116
|
+
</div>`;
|
|
2117
|
+
case "choice": return n.custom ? Qn(e, t, n, r) : `<select id="${e}" ${t}>${n.options.map((e) => `<option value="${S(e.value)}"${e.value === r ? " selected" : ""}
|
|
2118
|
+
>${S(e.label)}</option>`).join("")}</select>`;
|
|
2119
|
+
case "color": return $n(e, t, n, r);
|
|
2120
|
+
case "toggle": return `<input type="checkbox" id="${e}" ${t}
|
|
2121
|
+
${r ? "checked" : ""}>`;
|
|
2122
|
+
case "image": return `
|
|
2123
|
+
<div class="dz-image" id="${e}">
|
|
2124
|
+
${r ? `<img class="dz-image-thumb" src="${S(x(r))}" alt="">` : "<span class=\"dz-image-none\">No image stored</span>"}
|
|
2125
|
+
<div class="dz-image-actions">
|
|
2126
|
+
<button type="button" class="dz-add-row"
|
|
2127
|
+
data-action="upload-image">${r ? "Replace" : "Upload"}</button>
|
|
2128
|
+
${r ? "<button type=\"button\" class=\"dz-add-row\"\n data-action=\"clear-image\">Remove</button>" : ""}
|
|
2129
|
+
</div>
|
|
2130
|
+
</div>`;
|
|
2131
|
+
case "text": return `<input type="text" id="${e}" ${t}
|
|
2132
|
+
value="${S(r ?? "")}" spellcheck="false">`;
|
|
2133
|
+
default: return `<input type="number" id="${e}" ${t}
|
|
2134
|
+
value="${S(r ?? "")}"
|
|
2135
|
+
${n.min == null ? "" : `min="${n.min}"`}
|
|
2136
|
+
${n.max == null ? "" : `max="${n.max}"`} step="1">`;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function Xn(e, t, n) {
|
|
2140
|
+
let r = typeof t?.background == "string" && t.background ? t.background : null;
|
|
2141
|
+
return `
|
|
2142
|
+
<span class="dz-swatch dz-band-fill${r ? "" : " is-none"}"
|
|
2143
|
+
title="${S(n)} background">
|
|
2144
|
+
<span class="dz-swatch-well">
|
|
2145
|
+
<input type="color" data-band-fill="${S(e)}" value="${S(r ?? "#ffffff")}"
|
|
2146
|
+
aria-label="${S(n)} background">
|
|
2147
|
+
</span>
|
|
2148
|
+
<button type="button" class="dz-icon dz-swatch-clear" data-action="clear-band-fill"
|
|
2149
|
+
data-fill-for="${S(e)}" title="No background"
|
|
2150
|
+
aria-label="Remove ${S(n)} background">×</button>
|
|
2151
|
+
</span>`;
|
|
2152
|
+
}
|
|
2153
|
+
var Zn = "__custom__";
|
|
2154
|
+
function Qn(e, t, n, r) {
|
|
2155
|
+
let i = n.options.some((e) => e.value === (r ?? "")), a = i ? r ?? "" : Zn;
|
|
2156
|
+
return `
|
|
2157
|
+
<span class="dz-choice-custom">
|
|
2158
|
+
<select id="${e}" ${t}>${[...n.options, {
|
|
2159
|
+
value: Zn,
|
|
2160
|
+
label: "Custom…"
|
|
2161
|
+
}].map((e) => `<option value="${S(e.value)}"${e.value === a ? " selected" : ""}
|
|
2162
|
+
>${S(e.label)}</option>`).join("")}</select>
|
|
2163
|
+
<input type="text" ${t} data-custom="true" value="${S(i ? "" : r ?? "")}"
|
|
2164
|
+
spellcheck="false" maxlength="6" aria-label="${S(n.label)}, custom"
|
|
2165
|
+
placeholder="such as CHF"${i ? " hidden" : ""}>
|
|
2166
|
+
</span>`;
|
|
2167
|
+
}
|
|
2168
|
+
function $n(e, t, n, r) {
|
|
2169
|
+
let i = r == null || r === "";
|
|
2170
|
+
return `
|
|
2171
|
+
<span class="dz-swatch${i ? " is-none" : ""}">
|
|
2172
|
+
<span class="dz-swatch-well">
|
|
2173
|
+
<input type="color" id="${e}" ${t} value="${S(i ? "#000000" : r)}">
|
|
2174
|
+
</span>
|
|
2175
|
+
<span class="dz-swatch-none" aria-hidden="true">None</span>
|
|
2176
|
+
<button type="button" class="dz-icon dz-swatch-clear" data-action="clear-color"
|
|
2177
|
+
data-for="${S(n.key)}"
|
|
2178
|
+
title="No colour" aria-label="Remove ${S(n.label)} colour">×</button>
|
|
2179
|
+
</span>`;
|
|
2180
|
+
}
|
|
2181
|
+
function er(e, t) {
|
|
2182
|
+
e.closest?.(".dz-swatch")?.classList.toggle("is-none", t);
|
|
2183
|
+
}
|
|
2184
|
+
function tr(e, t) {
|
|
2185
|
+
let n = e.columns || [];
|
|
2186
|
+
return `
|
|
2187
|
+
<section class="dz-section dz-columns">
|
|
2188
|
+
<h3>Columns</h3>
|
|
2189
|
+
${n.map((e, r) => `
|
|
2190
|
+
<div class="dz-column">
|
|
2191
|
+
<div class="dz-column-head">
|
|
2192
|
+
<span>${r + 1}</span>
|
|
2193
|
+
${n.length > 1 ? `
|
|
2194
|
+
<button type="button" class="dz-icon"
|
|
2195
|
+
data-action="remove-column" data-index="${r}"
|
|
2196
|
+
title="Remove this column"
|
|
2197
|
+
aria-label="Remove column ${r + 1}">×</button>` : ""}
|
|
2198
|
+
</div>
|
|
2199
|
+
${Fe.map((t) => Jn(e, t, String(r))).join("")}
|
|
2200
|
+
<div class="dz-field dz-field-format">
|
|
2201
|
+
<label>Format</label>
|
|
2202
|
+
${Kn(e, t, String(r))}
|
|
2203
|
+
</div>
|
|
2204
|
+
<div class="dz-field dz-field-format">
|
|
2205
|
+
<label>Highlight</label>
|
|
2206
|
+
${qn(e.highlight, "edit-highlight", String(r))}
|
|
2207
|
+
</div>
|
|
2208
|
+
</div>`).join("")}
|
|
2209
|
+
<button type="button" class="dz-add-row" data-action="add-column">
|
|
2210
|
+
Add column</button>
|
|
2211
|
+
</section>`;
|
|
2212
|
+
}
|
|
2213
|
+
function nr(e) {
|
|
2214
|
+
return `
|
|
2215
|
+
<section class="dz-section dz-bands">
|
|
2216
|
+
<h3>Bands</h3>
|
|
2217
|
+
${Yt(e).map((t) => ir(e, t)).join("")}
|
|
2218
|
+
</section>`;
|
|
2219
|
+
}
|
|
2220
|
+
function rr(e) {
|
|
2221
|
+
let t = P(e);
|
|
2222
|
+
if (!t) return Ht[e] ?? "";
|
|
2223
|
+
let n = t.level > 0 ? `level ${t.level + 1} group of ${t.table}` : `group of ${t.table}`;
|
|
2224
|
+
return t.kind === "groupHeader" ? `Before each ${n}` : `After each ${n}`;
|
|
2225
|
+
}
|
|
2226
|
+
function ir(e, t, n = {}) {
|
|
2227
|
+
let r = Y(e, t), i = Xt(e, t), a = n.label ?? L(t), o = n.note ?? rr(t), s = i && P(t) != null;
|
|
2228
|
+
return `
|
|
2229
|
+
<div class="dz-band-row${i ? " is-on" : ""}${s ? " has-fill" : ""}">
|
|
2230
|
+
<label class="dz-band-name">
|
|
2231
|
+
<input type="checkbox" data-band="${S(t)}" ${i ? "checked" : ""}>
|
|
2232
|
+
<span>${S(a)}</span>
|
|
2233
|
+
</label>
|
|
2234
|
+
${s ? Xn(t, r, a) : ""}
|
|
2235
|
+
${i && t !== "detail" ? `<input type="text" class="dz-band-height"
|
|
2236
|
+
data-band-height="${S(t)}"
|
|
2237
|
+
value="${S(r.height ?? "")}"
|
|
2238
|
+
placeholder="auto" spellcheck="false"
|
|
2239
|
+
aria-label="${S(a)} height">` : `<span class="dz-band-height-none">${t === "detail" ? "what is left" : ""}</span>`}
|
|
2240
|
+
${o ? `<p class="dz-hint">${S(o)}</p>` : ""}
|
|
2241
|
+
</div>`;
|
|
2242
|
+
}
|
|
2243
|
+
function ar({ panel: e, getTarget: t, getItem: n, changed: r, act: i, toggleBand: a, setBandHeight: o, setBandFill: s = () => {} }) {
|
|
2244
|
+
function c(e) {
|
|
2245
|
+
let t = (e.closest?.(".dz-value"))?.querySelector("[data-role=\"marks\"]");
|
|
2246
|
+
t && (t.innerHTML = sr(e.value));
|
|
2247
|
+
}
|
|
2248
|
+
function l(e) {
|
|
2249
|
+
let i = e.target.closest?.("[data-field], [data-band], [data-band-height], [data-band-fill], [data-group-level], [data-group-option]");
|
|
2250
|
+
if (!i) return;
|
|
2251
|
+
if (i.tagName === "TEXTAREA" && c(i), i.dataset.groupOption != null) {
|
|
2252
|
+
let e = n(), t = Number(i.dataset.level), a = i.dataset.groupOption, o = i.type === "checkbox" ? i.checked : i.value;
|
|
2253
|
+
e?.type === "table" && ve(e, t, a, o) && r(`group-option:${t}:${a}`);
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
if (i.dataset.groupLevel != null) {
|
|
2257
|
+
let e = n(), t = Number(i.dataset.groupLevel);
|
|
2258
|
+
e?.type === "table" && B(e, i.value.trim(), t) && r(`group-level:${t}`);
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
if (i.dataset.band != null) {
|
|
2262
|
+
a(i.dataset.band, i.checked);
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
if (i.dataset.bandHeight != null) {
|
|
2266
|
+
o(i.dataset.bandHeight, i.value);
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
if (i.dataset.bandFill != null) {
|
|
2270
|
+
er(i, !1), s(i.dataset.bandFill, i.value);
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
if (i.dataset.column != null) {
|
|
2274
|
+
let e = n()?.columns?.[Number(i.dataset.column)];
|
|
2275
|
+
if (!e) return;
|
|
2276
|
+
let t = Fe.find((e) => e.key === i.dataset.field);
|
|
2277
|
+
t && Ye(e, t, i.value) && r(`column:${i.dataset.column}:${t.key}`);
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
let l = t();
|
|
2281
|
+
if (!l) return;
|
|
2282
|
+
let u = l.fields.find((e) => e.key === i.dataset.field);
|
|
2283
|
+
if (!u) return;
|
|
2284
|
+
if (i.tagName === "SELECT" && i.value === Zn) {
|
|
2285
|
+
let e = i.parentElement?.querySelector("[data-custom]");
|
|
2286
|
+
e && (e.hidden = !1, e.focus());
|
|
2287
|
+
return;
|
|
2288
|
+
}
|
|
2289
|
+
let d = u.type === "toggle" ? i.checked : i.value;
|
|
2290
|
+
u.type === "color" && er(i, !1);
|
|
2291
|
+
let f = typeof u.rebuilds == "function" ? u.rebuilds : null, p = f ? f(l.target) : null;
|
|
2292
|
+
if (Ye(l.target, u, d)) {
|
|
2293
|
+
let e = f ? f(l.target) !== p : !!u.rebuilds;
|
|
2294
|
+
r(`field:${u.key}`, { rebuild: e });
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
function u(e) {
|
|
2298
|
+
let n = e.target.closest?.("[data-action]");
|
|
2299
|
+
if (n) {
|
|
2300
|
+
if (e.preventDefault(), n.dataset.action === "insert-brace") {
|
|
2301
|
+
let e = n.closest(".dz-field")?.querySelector("textarea");
|
|
2302
|
+
e && cr(e);
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
if (n.dataset.action === "clear-band-fill") {
|
|
2306
|
+
er(n, !0), s(n.dataset.fillFor, null);
|
|
2307
|
+
return;
|
|
2308
|
+
}
|
|
2309
|
+
if (n.dataset.action === "clear-color") {
|
|
2310
|
+
let e = t(), i = e?.fields.find((e) => e.key === n.dataset.for);
|
|
2311
|
+
i && Je(e.target, i) && (er(n, !0), r(`field:${i.key}`));
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
i(n.dataset.action, n.dataset);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
function d(e) {
|
|
2318
|
+
let t = e.target;
|
|
2319
|
+
if (t.tagName !== "TEXTAREA") return;
|
|
2320
|
+
let n = t.closest(".dz-value")?.querySelector("[data-role=\"marks\"]");
|
|
2321
|
+
n && (n.scrollTop = t.scrollTop);
|
|
2322
|
+
}
|
|
2323
|
+
return e.addEventListener("scroll", d, !0), e.addEventListener("input", l), e.addEventListener("change", l), e.addEventListener("click", u), function() {
|
|
2324
|
+
e.removeEventListener("scroll", d, !0), e.removeEventListener("input", l), e.removeEventListener("change", l), e.removeEventListener("click", u);
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
function or(e, t, n) {
|
|
2328
|
+
let r = t ?? n;
|
|
2329
|
+
if (!r) return;
|
|
2330
|
+
let i = t ? We(t) : Ue(n);
|
|
2331
|
+
for (let n of e.querySelectorAll("[data-field]")) {
|
|
2332
|
+
if (n === n.ownerDocument.activeElement) continue;
|
|
2333
|
+
let e = n.dataset.column != null, a = e ? t?.columns?.[Number(n.dataset.column)] : r;
|
|
2334
|
+
if (!a) continue;
|
|
2335
|
+
let o = (e ? Fe : i).find((e) => e.key === n.dataset.field);
|
|
2336
|
+
if (!o) continue;
|
|
2337
|
+
let s = qe(a, o);
|
|
2338
|
+
if (o.type === "color" && er(n, s == null || s === ""), o.custom) {
|
|
2339
|
+
let e = o.options.some((e) => e.value === (s ?? ""));
|
|
2340
|
+
n.dataset.custom ? (n.value = e ? "" : String(s ?? ""), n.hidden = e) : n.value = e ? String(s ?? "") : Zn;
|
|
2341
|
+
continue;
|
|
2342
|
+
}
|
|
2343
|
+
if (o.type === "toggle") n.checked = !!s;
|
|
2344
|
+
else if (s != null && (n.value = String(s), n.tagName === "TEXTAREA")) {
|
|
2345
|
+
let e = n.closest(".dz-value")?.querySelector("[data-role=\"marks\"]");
|
|
2346
|
+
e && (e.innerHTML = sr(n.value));
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
function sr(e) {
|
|
2351
|
+
return `${S(String(e ?? "")).replace(/\{[^{}]*\}/g, (e) => `<mark class="dz-mark">${e}</mark>`)}\n`;
|
|
2352
|
+
}
|
|
2353
|
+
function cr(e) {
|
|
2354
|
+
let t = e.selectionStart ?? e.value.length, n = e.selectionEnd ?? t, r = e.value.slice(t, n);
|
|
2355
|
+
e.value = `${e.value.slice(0, t)}{${r}}${e.value.slice(n)}`;
|
|
2356
|
+
let i = t + 1 + r.length;
|
|
2357
|
+
e.focus(), e.setSelectionRange(i, i), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
2358
|
+
}
|
|
2359
|
+
//#endregion
|
|
2360
|
+
//#region src/designer/icons.js
|
|
2361
|
+
var X = (e) => `<svg viewBox="0 0 16 16" width="16" height="16"
|
|
2362
|
+
fill="none" stroke="currentColor" stroke-width="1.5"
|
|
2363
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
2364
|
+
aria-hidden="true" focusable="false">${e}</svg>`, lr = {
|
|
2365
|
+
text: X("<path d=\"M3 3.75h10M8 3.75v8.5M6.25 12.25h3.5\"/>"),
|
|
2366
|
+
table: X("<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\"/>"),
|
|
2367
|
+
image: X("<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\"/>"),
|
|
2368
|
+
box: X("<rect x=\"2.5\" y=\"3.75\" width=\"11\" height=\"8.5\" rx=\"1.25\"/>"),
|
|
2369
|
+
line: X("<path d=\"M2 8h3.5M7.25 8h1.5M10.5 8H14\"/>"),
|
|
2370
|
+
ruler: X("<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\"/>"),
|
|
2371
|
+
undo: X("<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\"/>"),
|
|
2372
|
+
redo: X("<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\"/>"),
|
|
2373
|
+
open: X("<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\"/>"),
|
|
2374
|
+
field: X("<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\"/>"),
|
|
2375
|
+
external: X("<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\"/>"),
|
|
2376
|
+
preview: X("<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\"/>"),
|
|
2377
|
+
design: X("<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\"/>"),
|
|
2378
|
+
data: X("<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\"/>"),
|
|
2379
|
+
duplicate: X("<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\"/>"),
|
|
2380
|
+
copy: X("<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\"/>"),
|
|
2381
|
+
delete: X("<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\"/>"),
|
|
2382
|
+
paste: X("<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\"/>"),
|
|
2383
|
+
format: X("<path d=\"M12.25 3.75 3.75 12.25\"/>\n <circle cx=\"4.75\" cy=\"4.75\" r=\"1.75\"/>\n <circle cx=\"11.25\" cy=\"11.25\" r=\"1.75\"/>"),
|
|
2384
|
+
highlight: X("<path d=\"M9.75 2.75 13.25 6.25 8 11.5H4.5V8z\"/>\n <path d=\"M2.25 13.75h11.5\"/>"),
|
|
2385
|
+
save: X("<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\"/>")
|
|
2386
|
+
};
|
|
2387
|
+
function Z(e) {
|
|
2388
|
+
return lr[e] ?? "";
|
|
2389
|
+
}
|
|
2390
|
+
function ur({ count: e = 0, canPaste: t = !1, canDuplicate: n = !0, format: r = null, highlight: i = null, rows: a = !1 } = {}) {
|
|
2391
|
+
let o = e > 1 ? ` ${e} items` : "", s = {
|
|
2392
|
+
action: "paste-items",
|
|
2393
|
+
glyph: "paste",
|
|
2394
|
+
label: "Paste",
|
|
2395
|
+
hint: "ctrl+V",
|
|
2396
|
+
keys: "Ctrl+V",
|
|
2397
|
+
disabled: !t
|
|
2398
|
+
};
|
|
2399
|
+
if (e < 1) return [s];
|
|
2400
|
+
let c = [
|
|
2401
|
+
r && {
|
|
2402
|
+
action: "edit-format",
|
|
2403
|
+
glyph: "format",
|
|
2404
|
+
label: r.label,
|
|
2405
|
+
hint: "number, currency, percent or date",
|
|
2406
|
+
index: r.index
|
|
2407
|
+
},
|
|
2408
|
+
i && {
|
|
2409
|
+
action: "edit-highlight",
|
|
2410
|
+
glyph: "highlight",
|
|
2411
|
+
label: i.label,
|
|
2412
|
+
hint: "colour values by what they are",
|
|
2413
|
+
index: i.index
|
|
2414
|
+
},
|
|
2415
|
+
a && {
|
|
2416
|
+
action: "edit-row-highlight",
|
|
2417
|
+
glyph: "highlight",
|
|
2418
|
+
label: "Highlight rows…",
|
|
2419
|
+
hint: "shade whole rows by a field"
|
|
2420
|
+
}
|
|
2421
|
+
].filter(Boolean);
|
|
2422
|
+
return [
|
|
2423
|
+
...c.length ? [...c, { separator: !0 }] : [],
|
|
2424
|
+
{
|
|
2425
|
+
action: "duplicate-item",
|
|
2426
|
+
glyph: "duplicate",
|
|
2427
|
+
label: n ? `Duplicate${o}` : "This cannot be duplicated",
|
|
2428
|
+
hint: "ctrl+D, or alt-drag",
|
|
2429
|
+
keys: "Ctrl+D",
|
|
2430
|
+
disabled: !n
|
|
2431
|
+
},
|
|
2432
|
+
{
|
|
2433
|
+
action: "copy-items",
|
|
2434
|
+
glyph: "copy",
|
|
2435
|
+
label: `Copy${o}`,
|
|
2436
|
+
hint: "ctrl+C",
|
|
2437
|
+
keys: "Ctrl+C"
|
|
2438
|
+
},
|
|
2439
|
+
s,
|
|
2440
|
+
{ separator: !0 },
|
|
2441
|
+
{
|
|
2442
|
+
action: "delete-item",
|
|
2443
|
+
glyph: "delete",
|
|
2444
|
+
label: `Delete${o}`,
|
|
2445
|
+
hint: "del",
|
|
2446
|
+
keys: "Del",
|
|
2447
|
+
tone: "danger"
|
|
2448
|
+
}
|
|
2449
|
+
];
|
|
2450
|
+
}
|
|
2451
|
+
function dr(e) {
|
|
2452
|
+
return `<div class="dz-menu" data-role="menu" role="menu"
|
|
2453
|
+
aria-label="Item actions">${e.map((e) => e.separator ? "<span class=\"dz-menu-sep\" aria-hidden=\"true\"></span>" : `<button type="button" role="menuitem"
|
|
2454
|
+
class="dz-menu-item${e.tone ? ` is-${S(e.tone)}` : ""}"
|
|
2455
|
+
data-action="${S(e.action)}"
|
|
2456
|
+
${e.index == null ? "" : `data-index="${S(e.index)}"`}
|
|
2457
|
+
title="${S(e.label)} (${S(e.hint)})"
|
|
2458
|
+
aria-label="${S(e.label)}"
|
|
2459
|
+
${e.disabled ? "disabled" : ""}
|
|
2460
|
+
>${[
|
|
2461
|
+
`<span class="dz-menu-icon" aria-hidden="true">${Z(e.glyph)}</span>`,
|
|
2462
|
+
`<span class="dz-menu-label">${S(e.label)}</span>`,
|
|
2463
|
+
e.keys ? `<kbd class="dz-menu-keys">${S(e.keys)}</kbd>` : ""
|
|
2464
|
+
].join("")}</button>`).join("")}</div>`;
|
|
2465
|
+
}
|
|
2466
|
+
function fr(e, t, n, r = 8) {
|
|
2467
|
+
let i = (e, t, n) => Math.min(Math.max(r, e), Math.max(r, n - t - r));
|
|
2468
|
+
return {
|
|
2469
|
+
left: i(e.x, t.width, n.width),
|
|
2470
|
+
top: i(e.y, t.height, n.height)
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
//#endregion
|
|
2474
|
+
//#region src/designer/toast.js
|
|
2475
|
+
function pr(e, t) {
|
|
2476
|
+
return !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((e, n) => e === t[n]);
|
|
2477
|
+
}
|
|
2478
|
+
function mr(e) {
|
|
2479
|
+
let t = e.length > 1;
|
|
2480
|
+
return `
|
|
2481
|
+
<div class="dz-toast dz-problems" role="alert" data-role="problems">
|
|
2482
|
+
<div class="dz-toast-text">
|
|
2483
|
+
<strong class="dz-toast-title">This report will not render yet</strong>
|
|
2484
|
+
<ul>${e.map((e) => `<li>${S(e)}</li>`).join("")}</ul>
|
|
2485
|
+
</div>
|
|
2486
|
+
<button type="button" class="dz-toast-close"
|
|
2487
|
+
data-action="dismiss-problems"
|
|
2488
|
+
title="Dismiss${t ? ` ${e.length} problems` : ""}"
|
|
2489
|
+
aria-label="Dismiss${t ? ` ${e.length} problems` : ""}"
|
|
2490
|
+
>×</button>
|
|
2491
|
+
</div>`;
|
|
2492
|
+
}
|
|
2493
|
+
//#endregion
|
|
2494
|
+
//#region src/shared/prefix.js
|
|
2495
|
+
var hr = "/__reports";
|
|
2496
|
+
//#endregion
|
|
2497
|
+
//#region src/shared/store.js
|
|
2498
|
+
function gr({ prefix: e = hr, fetch: t = (...e) => globalThis.fetch(...e) } = {}) {
|
|
2499
|
+
async function n(n, r) {
|
|
2500
|
+
let i;
|
|
2501
|
+
try {
|
|
2502
|
+
i = await t(`${e}${n}`, r);
|
|
2503
|
+
} catch (e) {
|
|
2504
|
+
throw new _r("Cannot reach the report server. Start it with `npx report-studio design`.", {
|
|
2505
|
+
cause: e,
|
|
2506
|
+
offline: !0
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
let a = await i.json().catch(() => null);
|
|
2510
|
+
if (!i.ok) throw new _r(a?.error ?? `the server answered ${i.status}`, { status: i.status });
|
|
2511
|
+
return a;
|
|
2512
|
+
}
|
|
2513
|
+
return {
|
|
2514
|
+
async list() {
|
|
2515
|
+
let e = await n("", { method: "GET" });
|
|
2516
|
+
return Array.isArray(e?.reports) ? e.reports : [];
|
|
2517
|
+
},
|
|
2518
|
+
load(e) {
|
|
2519
|
+
return n(`/${encodeURIComponent(e)}`, { method: "GET" });
|
|
2520
|
+
},
|
|
2521
|
+
save(e, t) {
|
|
2522
|
+
return n(`/${encodeURIComponent(e)}`, {
|
|
2523
|
+
method: "PUT",
|
|
2524
|
+
headers: { "Content-Type": "application/json" },
|
|
2525
|
+
body: JSON.stringify(t)
|
|
2526
|
+
});
|
|
2527
|
+
},
|
|
2528
|
+
remove(e) {
|
|
2529
|
+
return n(`/${encodeURIComponent(e)}`, { method: "DELETE" });
|
|
2530
|
+
},
|
|
2531
|
+
async loadData(e) {
|
|
2532
|
+
try {
|
|
2533
|
+
return await n(`/${encodeURIComponent(e)}/data`, { method: "GET" });
|
|
2534
|
+
} catch (e) {
|
|
2535
|
+
if (e.status === 404) return null;
|
|
2536
|
+
throw e;
|
|
2537
|
+
}
|
|
2538
|
+
},
|
|
2539
|
+
saveData(e, t) {
|
|
2540
|
+
return n(`/${encodeURIComponent(e)}/data`, {
|
|
2541
|
+
method: "PUT",
|
|
2542
|
+
headers: { "Content-Type": "application/json" },
|
|
2543
|
+
body: JSON.stringify(t, null, 2)
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2548
|
+
var _r = class extends Error {
|
|
2549
|
+
constructor(e, { cause: t, status: n = null, offline: r = !1 } = {}) {
|
|
2550
|
+
super(e, { cause: t }), this.name = "StoreError", this.status = n, this.offline = r;
|
|
2551
|
+
}
|
|
2552
|
+
};
|
|
2553
|
+
function vr(e) {
|
|
2554
|
+
let t = String(e ?? "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64).replace(/-+$/, "");
|
|
2555
|
+
return /^[a-z0-9]/.test(t) ? t : "";
|
|
2556
|
+
}
|
|
2557
|
+
//#endregion
|
|
2558
|
+
//#region src/designer/sample-data.js
|
|
2559
|
+
var yr = 6, br = ["North", "South"], xr = /(amount|amt|price|qty|quantity|total|subtotal|cost|rate|balance|discount|tax)$/i, Sr = /\b(count|sum|avg|min|max)\(([^()]*)\)/g, Cr = /(date|day|when)$/i, wr = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAAAAADRSSBWAAAAC0lEQVR4nGO4eRcAApIBt+wBgUAAAAAASUVORK5CYII=";
|
|
2560
|
+
function Tr(e) {
|
|
2561
|
+
return Or(Er(e));
|
|
2562
|
+
}
|
|
2563
|
+
function Er(t) {
|
|
2564
|
+
return [...(Array.isArray(t?.bands) ? t.bands : []).map((t) => ({
|
|
2565
|
+
band: t,
|
|
2566
|
+
rowScoped: e(t?.type)
|
|
2567
|
+
})), ...Dr(E(t)).map((e) => ({
|
|
2568
|
+
band: e,
|
|
2569
|
+
rowScoped: !0
|
|
2570
|
+
}))];
|
|
2571
|
+
}
|
|
2572
|
+
function Dr(e) {
|
|
2573
|
+
return e.flatMap((e) => b(e)).flatMap((e) => [e?.header, e?.footer]).filter((e) => e && typeof e == "object" && Array.isArray(e.items));
|
|
2574
|
+
}
|
|
2575
|
+
function Or(e) {
|
|
2576
|
+
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
2577
|
+
for (let { band: r, rowScoped: i } of e) for (let e of r?.items || []) if (!(e.type !== "text" || typeof e.value != "string")) for (let [, r] of e.value.matchAll(c)) {
|
|
2578
|
+
let e = r.trim();
|
|
2579
|
+
!e || C(e) || (e.includes(".") || !i ? t.add(e) : n.add(e));
|
|
2580
|
+
}
|
|
2581
|
+
return {
|
|
2582
|
+
root: [...t],
|
|
2583
|
+
row: [...n]
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
function kr(e) {
|
|
2587
|
+
let t = /* @__PURE__ */ new Set();
|
|
2588
|
+
for (let { band: n } of Er(e)) for (let e of n.items || []) {
|
|
2589
|
+
if (e.type !== "image" || typeof e.field != "string") continue;
|
|
2590
|
+
let n = e.field.trim();
|
|
2591
|
+
n && t.add(n);
|
|
2592
|
+
}
|
|
2593
|
+
return [...t];
|
|
2594
|
+
}
|
|
2595
|
+
function Ar(e) {
|
|
2596
|
+
let n = /* @__PURE__ */ new Map(), r = e?.dataset || "rows", i = (e) => (n.has(e) || n.set(e, /* @__PURE__ */ new Set()), n.get(e));
|
|
2597
|
+
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) {
|
|
2598
|
+
if (e.type !== "table") continue;
|
|
2599
|
+
let n = i(e.dataset || r);
|
|
2600
|
+
for (let r of e.columns || []) if (f(r)) for (let e of t(r.expression)) n.add(e);
|
|
2601
|
+
else r?.field && n.add(r.field);
|
|
2602
|
+
}
|
|
2603
|
+
let a = T(e), o = /* @__PURE__ */ new Set();
|
|
2604
|
+
for (let t of a) {
|
|
2605
|
+
let n = i(_(t.table, e) || r), a = t.levels.flatMap((e) => [e.header, e.footer]).filter((e) => e && typeof e == "object");
|
|
2606
|
+
for (let e of t.levels) e.by && n.add(e.by);
|
|
2607
|
+
for (let e of a) o.add(e);
|
|
2608
|
+
for (let e of Or(a.map((e) => ({
|
|
2609
|
+
band: e,
|
|
2610
|
+
rowScoped: !0
|
|
2611
|
+
}))).row) n.add(e);
|
|
2612
|
+
}
|
|
2613
|
+
let s = Or(Er(e).filter(({ band: e }) => !o.has(e))).row, c = a.length ? null : e?.groupBy ?? null;
|
|
2614
|
+
if (s.length || c) {
|
|
2615
|
+
let e = i(r);
|
|
2616
|
+
for (let t of s) e.add(t);
|
|
2617
|
+
c && e.add(c);
|
|
2618
|
+
}
|
|
2619
|
+
for (let t of Lr(e)) i(t.dataset).add(t.field);
|
|
2620
|
+
return n;
|
|
2621
|
+
}
|
|
2622
|
+
function jr(e) {
|
|
2623
|
+
let t = {}, { root: n } = Tr(e), r = Fr(e);
|
|
2624
|
+
for (let n of kr(e)) Rr(t, n, wr);
|
|
2625
|
+
for (let e of n) Rr(t, e);
|
|
2626
|
+
let i = Ir(e);
|
|
2627
|
+
for (let [n, a] of Ar(e)) t[n] = zr([...a], i.get(n) ?? [], r);
|
|
2628
|
+
return t;
|
|
2629
|
+
}
|
|
2630
|
+
function Mr(e, t) {
|
|
2631
|
+
let n = jr(t);
|
|
2632
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return {
|
|
2633
|
+
data: n,
|
|
2634
|
+
added: !0
|
|
2635
|
+
};
|
|
2636
|
+
let r = structuredClone(e);
|
|
2637
|
+
return {
|
|
2638
|
+
data: r,
|
|
2639
|
+
added: Nr(r, n)
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
function Nr(e, t) {
|
|
2643
|
+
let n = !1;
|
|
2644
|
+
for (let [r, i] of Object.entries(t)) {
|
|
2645
|
+
let t = e[r];
|
|
2646
|
+
if (t === void 0) {
|
|
2647
|
+
e[r] = structuredClone(i), n = !0;
|
|
2648
|
+
continue;
|
|
2649
|
+
}
|
|
2650
|
+
Pr(t) && Pr(i) && Nr(t, i) && (n = !0);
|
|
2651
|
+
}
|
|
2652
|
+
return n;
|
|
2653
|
+
}
|
|
2654
|
+
function Pr(e) {
|
|
2655
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
2656
|
+
}
|
|
2657
|
+
function Fr(e) {
|
|
2658
|
+
let t = /* @__PURE__ */ new Set();
|
|
2659
|
+
for (let { band: n } of Er(e)) for (let e of n.items || []) if (e.type === "text") for (let [, , n] of String(e.value ?? "").matchAll(Sr)) {
|
|
2660
|
+
let e = n.trim();
|
|
2661
|
+
e && (t.add(e), e.includes(".") && t.add(e.slice(e.indexOf(".") + 1)));
|
|
2662
|
+
}
|
|
2663
|
+
return t;
|
|
2664
|
+
}
|
|
2665
|
+
function Ir(e) {
|
|
2666
|
+
let t = /* @__PURE__ */ new Map();
|
|
2667
|
+
for (let n of T(e)) {
|
|
2668
|
+
let r = _(n.table, e) || e?.dataset || "rows";
|
|
2669
|
+
t.has(r) || t.set(r, n.levels.map((e) => e.by).filter(Boolean));
|
|
2670
|
+
}
|
|
2671
|
+
return t;
|
|
2672
|
+
}
|
|
2673
|
+
function Lr(e) {
|
|
2674
|
+
let t = [];
|
|
2675
|
+
for (let { band: n } of Er(e)) for (let e of n.items || []) if (e.type === "text") for (let [, , n] of String(e.value ?? "").matchAll(Sr)) {
|
|
2676
|
+
let [e, ...r] = n.trim().split("."), i = r.join(".");
|
|
2677
|
+
e && i && t.push({
|
|
2678
|
+
dataset: e,
|
|
2679
|
+
field: i
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
return t;
|
|
2683
|
+
}
|
|
2684
|
+
function Rr(e, t, n) {
|
|
2685
|
+
let r = t.split(".").filter(Boolean);
|
|
2686
|
+
if (!r.length) return;
|
|
2687
|
+
let i = r.pop(), a = e;
|
|
2688
|
+
for (let e of r) (a[e] == null || typeof a[e] != "object") && (a[e] = {}), a = a[e];
|
|
2689
|
+
a[i] === void 0 && (a[i] = n ?? Br(i, 0));
|
|
2690
|
+
}
|
|
2691
|
+
function zr(e, t, n = /* @__PURE__ */ new Set()) {
|
|
2692
|
+
return e.length ? Array.from({ length: yr }, (r, i) => {
|
|
2693
|
+
let a = {};
|
|
2694
|
+
for (let r of e) {
|
|
2695
|
+
let e = t.indexOf(r);
|
|
2696
|
+
a[r] = e === -1 ? Br(r, i, n.has(r)) : e === 0 ? br[i % br.length] : `${Vr(r)} ${Math.floor(i / 2 ** e) % 2 + 1}`;
|
|
2697
|
+
}
|
|
2698
|
+
return a;
|
|
2699
|
+
}) : [];
|
|
2700
|
+
}
|
|
2701
|
+
function Br(e, t, n = !1) {
|
|
2702
|
+
return n || xr.test(e) ? (t + 1) * 250 : Cr.test(e) ? `2026-06-${String(t % 28 + 1).padStart(2, "0")}` : `${Vr(e)} ${t + 1}`;
|
|
2703
|
+
}
|
|
2704
|
+
function Vr(e) {
|
|
2705
|
+
let t = String(e).replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
|
2706
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
2707
|
+
}
|
|
2708
|
+
//#endregion
|
|
2709
|
+
//#region src/designer/tokens.js
|
|
2710
|
+
var Hr = "field", Ur = [
|
|
2711
|
+
{
|
|
2712
|
+
id: "page",
|
|
2713
|
+
prefer: [
|
|
2714
|
+
"pageFooter",
|
|
2715
|
+
"reportFooter",
|
|
2716
|
+
"pageHeader"
|
|
2717
|
+
],
|
|
2718
|
+
label: "Page number",
|
|
2719
|
+
value: "{page}",
|
|
2720
|
+
note: "The page this is printed on"
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
id: "page-of",
|
|
2724
|
+
prefer: [
|
|
2725
|
+
"pageFooter",
|
|
2726
|
+
"reportFooter",
|
|
2727
|
+
"pageHeader"
|
|
2728
|
+
],
|
|
2729
|
+
label: "Page X of Y",
|
|
2730
|
+
value: "Page {page} of {totalPages}",
|
|
2731
|
+
note: "The usual footer line, written out"
|
|
2732
|
+
},
|
|
2733
|
+
{
|
|
2734
|
+
id: "total-pages",
|
|
2735
|
+
prefer: [
|
|
2736
|
+
"pageFooter",
|
|
2737
|
+
"reportFooter",
|
|
2738
|
+
"pageHeader"
|
|
2739
|
+
],
|
|
2740
|
+
label: "Total pages",
|
|
2741
|
+
value: "{totalPages}",
|
|
2742
|
+
note: "How many pages the report came to"
|
|
2743
|
+
},
|
|
2744
|
+
{
|
|
2745
|
+
id: "today",
|
|
2746
|
+
prefer: [
|
|
2747
|
+
"pageHeader",
|
|
2748
|
+
"reportHeader",
|
|
2749
|
+
"pageFooter"
|
|
2750
|
+
],
|
|
2751
|
+
label: "Today",
|
|
2752
|
+
value: "{today}",
|
|
2753
|
+
note: "The date the report was run"
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
id: "count",
|
|
2757
|
+
prefer: ["groupFooter", "reportFooter"],
|
|
2758
|
+
label: "Row count",
|
|
2759
|
+
value: "{count()}",
|
|
2760
|
+
note: "How many rows are in scope",
|
|
2761
|
+
aggregate: !0
|
|
2762
|
+
},
|
|
2763
|
+
{
|
|
2764
|
+
id: "sum",
|
|
2765
|
+
prefer: ["groupFooter", "reportFooter"],
|
|
2766
|
+
label: "Sum",
|
|
2767
|
+
value: `{sum(${Hr})}`,
|
|
2768
|
+
note: "Added up over the rows in scope",
|
|
2769
|
+
field: !0,
|
|
2770
|
+
aggregate: !0
|
|
2771
|
+
},
|
|
2772
|
+
{
|
|
2773
|
+
id: "avg",
|
|
2774
|
+
prefer: ["groupFooter", "reportFooter"],
|
|
2775
|
+
label: "Average",
|
|
2776
|
+
value: `{avg(${Hr})}`,
|
|
2777
|
+
note: "The mean of the rows in scope",
|
|
2778
|
+
field: !0,
|
|
2779
|
+
aggregate: !0
|
|
2780
|
+
},
|
|
2781
|
+
{
|
|
2782
|
+
id: "min",
|
|
2783
|
+
prefer: ["groupFooter", "reportFooter"],
|
|
2784
|
+
label: "Smallest",
|
|
2785
|
+
value: `{min(${Hr})}`,
|
|
2786
|
+
field: !0,
|
|
2787
|
+
aggregate: !0
|
|
2788
|
+
},
|
|
2789
|
+
{
|
|
2790
|
+
id: "max",
|
|
2791
|
+
prefer: ["groupFooter", "reportFooter"],
|
|
2792
|
+
label: "Largest",
|
|
2793
|
+
value: `{max(${Hr})}`,
|
|
2794
|
+
field: !0,
|
|
2795
|
+
aggregate: !0
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
id: "percentage",
|
|
2799
|
+
prefer: [
|
|
2800
|
+
"groupFooter",
|
|
2801
|
+
"groupHeader",
|
|
2802
|
+
"reportFooter"
|
|
2803
|
+
],
|
|
2804
|
+
label: "Percentage of total",
|
|
2805
|
+
value: `{percentage(sum(${Hr}))}`,
|
|
2806
|
+
note: "This group's sum as a share of the whole table's - add , parent for a share of the group outside, or , 50000 for a share of a target",
|
|
2807
|
+
field: !0,
|
|
2808
|
+
aggregate: !0
|
|
2809
|
+
}
|
|
2810
|
+
];
|
|
2811
|
+
function Wr(e) {
|
|
2812
|
+
return Ur.find((t) => t.id === e) ?? null;
|
|
2813
|
+
}
|
|
2814
|
+
function Gr(e) {
|
|
2815
|
+
return !!e?.field;
|
|
2816
|
+
}
|
|
2817
|
+
var Kr = ["groupHeader", "groupFooter"];
|
|
2818
|
+
function qr(e, t) {
|
|
2819
|
+
return e?.aggregate ? Kr.includes(F(t)) ? "group" : "report" : null;
|
|
2820
|
+
}
|
|
2821
|
+
function Jr(e, t) {
|
|
2822
|
+
return e ? !e.bands?.length || e.bands.includes(F(t)) : !1;
|
|
2823
|
+
}
|
|
2824
|
+
function Yr(e, t) {
|
|
2825
|
+
return e ? Gr(e) ? e.value.replace(Hr, String(t || Hr)) : e.value : "";
|
|
2826
|
+
}
|
|
2827
|
+
function Xr(e) {
|
|
2828
|
+
let t = /* @__PURE__ */ new Set();
|
|
2829
|
+
for (let [, n] of Ar(e)) for (let e of n) t.add(e);
|
|
2830
|
+
e?.groupBy && t.add(e.groupBy);
|
|
2831
|
+
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of n.items || []) if (e?.type === "table") {
|
|
2832
|
+
typeof e.groupBy == "string" && e.groupBy && t.add(e.groupBy);
|
|
2833
|
+
for (let n of b(e)) typeof n?.by == "string" && n.by && t.add(n.by);
|
|
2834
|
+
}
|
|
2835
|
+
return [...t].sort();
|
|
2836
|
+
}
|
|
2837
|
+
function Zr(e, t) {
|
|
2838
|
+
let n = Jt(e);
|
|
2839
|
+
if (!t?.bands?.length) return n;
|
|
2840
|
+
let r = n.filter((e) => t.bands.includes(F(e)));
|
|
2841
|
+
return r.length ? r : n;
|
|
2842
|
+
}
|
|
2843
|
+
function Qr(e, t, n = null) {
|
|
2844
|
+
let r = Zr(e, t);
|
|
2845
|
+
if (!r.length) return null;
|
|
2846
|
+
for (let e of t?.prefer ?? []) {
|
|
2847
|
+
if (n && F(n) === e && r.includes(n)) return n;
|
|
2848
|
+
let t = r.find((t) => F(t) === e);
|
|
2849
|
+
if (t) return t;
|
|
2850
|
+
}
|
|
2851
|
+
return n && r.includes(n) && Jr(t, n) ? n : r[0];
|
|
2852
|
+
}
|
|
2853
|
+
function $r(e, t) {
|
|
2854
|
+
let n = Gr(e) || e?.id === "count" || e?.id === "page" || e?.id === "total-pages";
|
|
2855
|
+
return {
|
|
2856
|
+
value: Yr(e, t),
|
|
2857
|
+
w: e?.id === "page-of" ? 200 : 120,
|
|
2858
|
+
align: n ? "right" : "left"
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
//#endregion
|
|
2862
|
+
//#region src/designer/dialog.js
|
|
2863
|
+
var ei = 20;
|
|
2864
|
+
function ti(e) {
|
|
2865
|
+
return Q(e, "column-dialog", ai(), (e, t) => {
|
|
2866
|
+
let n = e.querySelector("[data-role=\"count\"]");
|
|
2867
|
+
n.focus(), n.select(), e.querySelector("form").addEventListener("submit", (e) => {
|
|
2868
|
+
e.preventDefault();
|
|
2869
|
+
let r = Math.round(Number(n.value));
|
|
2870
|
+
t(Number.isFinite(r) && r > 0 ? Math.min(r, ei) : 3);
|
|
2871
|
+
});
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
function ni(e, t) {
|
|
2875
|
+
let n = t || [];
|
|
2876
|
+
return Q(e, "open-dialog", oi(n), (e, t) => {
|
|
2877
|
+
e.querySelector("[data-role=\"new\"]")?.addEventListener("click", () => t({ blank: !0 }));
|
|
2878
|
+
let r = e.querySelector("[data-role=\"report-dropdown\"]"), i = e.querySelector("[data-role=\"confirm\"]");
|
|
2879
|
+
if (!r || !n.length) {
|
|
2880
|
+
e.querySelector("[data-role=\"new\"]")?.focus();
|
|
2881
|
+
return;
|
|
2882
|
+
}
|
|
2883
|
+
let a = O(r), o = e.querySelector("[data-role=\"report-meta\"]"), s = () => {
|
|
2884
|
+
let e = n.find((e) => e.id === a.value) ?? n[0];
|
|
2885
|
+
e && (o.textContent = `${e.id}.json${e.readable === !1 ? " - will not parse" : ""}${si(e.updatedAt)}`, o.toggleAttribute("data-unreadable", e.readable === !1));
|
|
2886
|
+
};
|
|
2887
|
+
a.addEventListener("change", s), s(), i.addEventListener("click", () => t({ id: a.value })), i.focus(), e.addEventListener("dz-closing", () => a.destroy());
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
function ri(e, t = "") {
|
|
2891
|
+
return Q(e, "save-dialog", ci(t), (e, t) => {
|
|
2892
|
+
let n = e.querySelector("[data-role=\"report-name\"]"), r = e.querySelector("[data-role=\"filename\"]"), i = e.querySelector("[data-role=\"confirm\"]"), a = () => {
|
|
2893
|
+
let e = vr(n.value);
|
|
2894
|
+
r.textContent = e ? `${e}.json` : "needs a letter or a digit", i.disabled = !e;
|
|
2895
|
+
};
|
|
2896
|
+
n.addEventListener("input", a), a(), n.focus(), n.select(), e.querySelector("form").addEventListener("submit", (e) => {
|
|
2897
|
+
e.preventDefault();
|
|
2898
|
+
let r = vr(n.value);
|
|
2899
|
+
r && t({
|
|
2900
|
+
id: r,
|
|
2901
|
+
name: n.value.trim() || r
|
|
2902
|
+
});
|
|
2903
|
+
});
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
function ii(e, t = "") {
|
|
2907
|
+
return Q(e, "discard-dialog", li(t), (e, t) => {
|
|
2908
|
+
e.querySelector("[data-role=\"discard\"]").addEventListener("click", () => t(!0)), e.querySelector("[data-role=\"cancel\"]").focus();
|
|
2909
|
+
}).then((e) => e === !0);
|
|
2910
|
+
}
|
|
2911
|
+
function Q(e, t, n, r) {
|
|
2912
|
+
return new Promise((i) => {
|
|
2913
|
+
let a = e.ownerDocument.createElement("div");
|
|
2914
|
+
a.className = "modal", a.dataset.role = t, a.innerHTML = n, e.appendChild(a);
|
|
2915
|
+
let o = !1;
|
|
2916
|
+
function s(e) {
|
|
2917
|
+
o || (o = !0, a.dispatchEvent(new CustomEvent("dz-closing")), a.remove(), i(e));
|
|
2918
|
+
}
|
|
2919
|
+
function c(e) {
|
|
2920
|
+
e.key === "Escape" && (e.stopPropagation(), e.preventDefault(), s(null));
|
|
2921
|
+
}
|
|
2922
|
+
for (let e of a.querySelectorAll("[data-role=\"cancel\"], [data-role=\"backdrop\"]")) e.addEventListener("click", () => s(null));
|
|
2923
|
+
a.addEventListener("keydown", c, !0), r(a, s);
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
function ai() {
|
|
2927
|
+
return `
|
|
2928
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2929
|
+
|
|
2930
|
+
<div class="modal-card" role="dialog" aria-modal="true"
|
|
2931
|
+
aria-labelledby="dz-columns-title">
|
|
2932
|
+
<h2 id="dz-columns-title">Add table</h2>
|
|
2933
|
+
|
|
2934
|
+
<form>
|
|
2935
|
+
<div class="dz-field dz-field-count">
|
|
2936
|
+
<label for="dz-columns">Columns</label>
|
|
2937
|
+
<input type="number" id="dz-columns" data-role="count"
|
|
2938
|
+
value="3" min="1" max="${ei}"
|
|
2939
|
+
step="1" required>
|
|
2940
|
+
</div>
|
|
2941
|
+
|
|
2942
|
+
<p class="modal-summary">
|
|
2943
|
+
Each column starts 50px wide. Rows come from your data, so there
|
|
2944
|
+
is no count to set here.
|
|
2945
|
+
</p>
|
|
2946
|
+
|
|
2947
|
+
<div class="modal-actions">
|
|
2948
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
2949
|
+
<button type="submit" class="is-primary" data-role="confirm">Add</button>
|
|
2950
|
+
</div>
|
|
2951
|
+
</form>
|
|
2952
|
+
</div>`;
|
|
2953
|
+
}
|
|
2954
|
+
function oi(e) {
|
|
2955
|
+
let t = e || [], n = `
|
|
2956
|
+
<div class="dz-field dz-field-picker">
|
|
2957
|
+
<label id="dz-open-label">Report</label>
|
|
2958
|
+
|
|
2959
|
+
<div class="dropdown" data-role="report-dropdown">
|
|
2960
|
+
<button type="button" class="dropdown-trigger"
|
|
2961
|
+
aria-haspopup="listbox" aria-expanded="false"
|
|
2962
|
+
aria-labelledby="dz-open-label">
|
|
2963
|
+
<span class="dropdown-value"></span>
|
|
2964
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
2965
|
+
</button>
|
|
2966
|
+
|
|
2967
|
+
<ul class="dropdown-menu" role="listbox"
|
|
2968
|
+
aria-labelledby="dz-open-label" hidden>${t.map((e, t) => `
|
|
2969
|
+
<li class="dropdown-item" role="option" tabindex="-1"
|
|
2970
|
+
data-value="${S(e.id)}"
|
|
2971
|
+
${t === 0 ? "data-selected=\"true\"" : ""}
|
|
2972
|
+
>${S(e.name || e.id)}</li>`).join("")}</ul>
|
|
2973
|
+
</div>
|
|
2974
|
+
</div>
|
|
2975
|
+
|
|
2976
|
+
<p class="dz-report-meta" data-role="report-meta" aria-live="polite"></p>`;
|
|
2977
|
+
return `
|
|
2978
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
2979
|
+
|
|
2980
|
+
<div class="modal-card is-roomy" role="dialog" aria-modal="true"
|
|
2981
|
+
aria-labelledby="dz-open-title">
|
|
2982
|
+
<h2 id="dz-open-title">Open report</h2>
|
|
2983
|
+
|
|
2984
|
+
${t.length ? n : "<p class=\"modal-summary\">\n No reports saved yet. Start a new one and save it.</p>"}
|
|
2985
|
+
|
|
2986
|
+
<div class="modal-actions">
|
|
2987
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
2988
|
+
<button type="button" data-role="new">New report</button>
|
|
2989
|
+
${t.length ? "<button type=\"button\" class=\"is-primary\" data-role=\"confirm\">Open</button>" : ""}
|
|
2990
|
+
</div>
|
|
2991
|
+
</div>`;
|
|
2992
|
+
}
|
|
2993
|
+
function si(e) {
|
|
2994
|
+
if (!e) return "";
|
|
2995
|
+
let t = new Date(e);
|
|
2996
|
+
return Number.isNaN(t.getTime()) ? "" : ` - ${t.toLocaleDateString(void 0, {
|
|
2997
|
+
day: "numeric",
|
|
2998
|
+
month: "short",
|
|
2999
|
+
year: "numeric"
|
|
3000
|
+
})}`;
|
|
3001
|
+
}
|
|
3002
|
+
function ci(e) {
|
|
3003
|
+
return `
|
|
3004
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
3005
|
+
|
|
3006
|
+
<div class="modal-card" role="dialog" aria-modal="true"
|
|
3007
|
+
aria-labelledby="dz-save-title">
|
|
3008
|
+
<h2 id="dz-save-title">Save report</h2>
|
|
3009
|
+
|
|
3010
|
+
<form>
|
|
3011
|
+
<div class="dz-field dz-field-text">
|
|
3012
|
+
<label for="dz-save-name">Name</label>
|
|
3013
|
+
<input type="text" id="dz-save-name" data-role="report-name"
|
|
3014
|
+
value="${S(e)}" spellcheck="false" required>
|
|
3015
|
+
</div>
|
|
3016
|
+
|
|
3017
|
+
<p class="modal-summary">
|
|
3018
|
+
Saved as <code data-role="filename"></code>
|
|
3019
|
+
</p>
|
|
3020
|
+
|
|
3021
|
+
<div class="modal-actions">
|
|
3022
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
3023
|
+
<button type="submit" class="is-primary" data-role="confirm">Save</button>
|
|
3024
|
+
</div>
|
|
3025
|
+
</form>
|
|
3026
|
+
</div>`;
|
|
3027
|
+
}
|
|
3028
|
+
function li(e) {
|
|
3029
|
+
return `
|
|
3030
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
3031
|
+
|
|
3032
|
+
<div class="modal-card" role="dialog" aria-modal="true"
|
|
3033
|
+
aria-labelledby="dz-discard-title">
|
|
3034
|
+
<h2 id="dz-discard-title">Unsaved changes</h2>
|
|
3035
|
+
|
|
3036
|
+
<p class="modal-summary">
|
|
3037
|
+
${e ? `<strong>${S(e)}</strong>` : "This report"} has changes that have not been saved. Opening another
|
|
3038
|
+
report closes this one, and the changes go with it.
|
|
3039
|
+
</p>
|
|
3040
|
+
|
|
3041
|
+
<div class="modal-actions">
|
|
3042
|
+
<button type="button" class="is-danger" data-role="discard">Discard changes</button>
|
|
3043
|
+
<button type="button" class="is-primary" data-role="cancel">Keep editing</button>
|
|
3044
|
+
</div>
|
|
3045
|
+
</div>`;
|
|
3046
|
+
}
|
|
3047
|
+
function ui(e, t, { id: n = null, generated: r = !1 } = {}) {
|
|
3048
|
+
return Q(e, "data-dialog", di(t, n, r), (e, t) => {
|
|
3049
|
+
let n = e.querySelector("[data-role=\"payload\"]"), r = e.querySelector("[data-role=\"parse-error\"]"), i = e.querySelector("[data-role=\"confirm\"]"), a = () => {
|
|
3050
|
+
try {
|
|
3051
|
+
let e = JSON.parse(n.value), t = typeof e == "object" && !!e && !Array.isArray(e);
|
|
3052
|
+
r.textContent = t ? "" : "The payload must be a JSON object keyed by dataset name.", i.disabled = !t;
|
|
3053
|
+
} catch (e) {
|
|
3054
|
+
r.textContent = e.message, i.disabled = !0;
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
n.addEventListener("input", a), a(), n.focus(), i.addEventListener("click", () => {
|
|
3058
|
+
try {
|
|
3059
|
+
t(JSON.parse(n.value));
|
|
3060
|
+
} catch {}
|
|
3061
|
+
});
|
|
3062
|
+
});
|
|
3063
|
+
}
|
|
3064
|
+
function di(e, t, n) {
|
|
3065
|
+
let r = t ? `${t}.data.json` : "a .data.json beside the report";
|
|
3066
|
+
return `
|
|
3067
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
3068
|
+
|
|
3069
|
+
<div class="modal-card is-wide" role="dialog" aria-modal="true"
|
|
3070
|
+
aria-labelledby="dz-data-title">
|
|
3071
|
+
<h2 id="dz-data-title">Report data</h2>
|
|
3072
|
+
|
|
3073
|
+
<p class="modal-summary">
|
|
3074
|
+
${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."}
|
|
3075
|
+
Saved as <code>${S(r)}</code>.
|
|
3076
|
+
</p>
|
|
3077
|
+
|
|
3078
|
+
<textarea class="dz-payload" data-role="payload" rows="16"
|
|
3079
|
+
spellcheck="false" aria-label="Report data"
|
|
3080
|
+
>${S(JSON.stringify(e, null, 2))}</textarea>
|
|
3081
|
+
|
|
3082
|
+
<p class="dz-parse-error" data-role="parse-error" aria-live="polite"></p>
|
|
3083
|
+
|
|
3084
|
+
<div class="modal-actions">
|
|
3085
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
3086
|
+
<button type="button" class="is-primary" data-role="confirm">Save data</button>
|
|
3087
|
+
</div>
|
|
3088
|
+
</div>`;
|
|
3089
|
+
}
|
|
3090
|
+
function fi(e, t, n = null) {
|
|
3091
|
+
let r = Xr(t);
|
|
3092
|
+
return Q(e, "token-dialog", hi(t, r, n), (e, i) => {
|
|
3093
|
+
let a = e.querySelector("[data-role=\"field-row\"]"), o = e.querySelector("[data-role=\"token-warning\"]"), s = e.querySelector("[data-role=\"confirm\"]"), c = r.length ? O(e.querySelector("[data-role=\"field-dropdown\"]")) : null, l = e.querySelector("[data-role=\"band-dropdown\"]"), u = null, d = () => Wr(e.querySelector("[name=\"dz-token\"]:checked")?.value);
|
|
3094
|
+
function f(e) {
|
|
3095
|
+
u?.destroy();
|
|
3096
|
+
let r = Zr(t, e), i = Qr(t, e, n);
|
|
3097
|
+
l.innerHTML = _i("band", r.map((e) => ({
|
|
3098
|
+
value: e,
|
|
3099
|
+
label: L(e)
|
|
3100
|
+
})), i), u = O(l), u.addEventListener("change", () => p());
|
|
3101
|
+
}
|
|
3102
|
+
function p({ retarget: e = !1 } = {}) {
|
|
3103
|
+
let t = d();
|
|
3104
|
+
if (!t) return;
|
|
3105
|
+
a.hidden = !Gr(t), e && f(t);
|
|
3106
|
+
let n = u.value, r = Jr(t, n), i = r ? mi(t, n) : pi(t, n);
|
|
3107
|
+
o.textContent = i, o.hidden = !i, o.classList.toggle("is-note", r), s.textContent = r ? "Insert" : "Insert anyway";
|
|
3108
|
+
}
|
|
3109
|
+
for (let t of e.querySelectorAll("[name=\"dz-token\"]")) t.addEventListener("change", () => p({ retarget: !0 }));
|
|
3110
|
+
p({ retarget: !0 }), s.addEventListener("click", () => {
|
|
3111
|
+
let e = d();
|
|
3112
|
+
e && i({
|
|
3113
|
+
...$r(e, Gr(e) ? c?.value || "field" : void 0),
|
|
3114
|
+
band: u.value
|
|
3115
|
+
});
|
|
3116
|
+
}), e.querySelector("[name=\"dz-token\"]")?.focus(), e.addEventListener("dz-closing", () => {
|
|
3117
|
+
c?.destroy(), u?.destroy();
|
|
3118
|
+
});
|
|
3119
|
+
});
|
|
3120
|
+
}
|
|
3121
|
+
function pi(e, t) {
|
|
3122
|
+
return `${e.label} prints nothing in a ${L(t)}.`;
|
|
3123
|
+
}
|
|
3124
|
+
function mi(e, t) {
|
|
3125
|
+
let n = qr(e, t);
|
|
3126
|
+
return n === "group" ? `In a ${L(t)}, ${e.label.toLowerCase()} is worked out over each group's own rows, once per group.` : n === "report" ? `In a ${L(t)}, ${e.label.toLowerCase()} is worked out over every row in the report.` : "";
|
|
3127
|
+
}
|
|
3128
|
+
function hi(e, t, n) {
|
|
3129
|
+
let r = Ur[0];
|
|
3130
|
+
return `
|
|
3131
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
3132
|
+
|
|
3133
|
+
<div class="modal-card is-roomy" role="dialog" aria-modal="true"
|
|
3134
|
+
aria-labelledby="dz-token-title">
|
|
3135
|
+
<h2 id="dz-token-title">Insert field</h2>
|
|
3136
|
+
|
|
3137
|
+
<div class="dz-tokens" role="radiogroup" aria-labelledby="dz-token-title">
|
|
3138
|
+
${Ur.map((e, t) => `
|
|
3139
|
+
<label class="dz-token">
|
|
3140
|
+
<input type="radio" name="dz-token" value="${S(e.id)}"
|
|
3141
|
+
${t === 0 ? "checked" : ""}>
|
|
3142
|
+
<span class="dz-token-body">
|
|
3143
|
+
<span class="dz-token-name">${S(e.label)}</span>
|
|
3144
|
+
<code class="dz-token-syntax">${S(e.value)}</code>
|
|
3145
|
+
${e.note ? `<span class="dz-token-note">${S(e.note)}</span>` : ""}
|
|
3146
|
+
</span>
|
|
3147
|
+
</label>`).join("")}
|
|
3148
|
+
</div>
|
|
3149
|
+
|
|
3150
|
+
${gi("field", "Field", t.map((e) => ({
|
|
3151
|
+
value: e,
|
|
3152
|
+
label: e
|
|
3153
|
+
})), t[0], {
|
|
3154
|
+
hidden: !Gr(r),
|
|
3155
|
+
empty: "No fields yet - add a table first"
|
|
3156
|
+
})}
|
|
3157
|
+
|
|
3158
|
+
${gi("band", "Band", Zr(e, r).map((e) => ({
|
|
3159
|
+
value: e,
|
|
3160
|
+
label: L(e)
|
|
3161
|
+
})), Qr(e, r, n))}
|
|
3162
|
+
|
|
3163
|
+
<p class="dz-token-warning" data-role="token-warning" aria-live="polite" hidden></p>
|
|
3164
|
+
|
|
3165
|
+
<div class="modal-actions">
|
|
3166
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
3167
|
+
<button type="button" class="is-primary" data-role="confirm">Insert</button>
|
|
3168
|
+
</div>
|
|
3169
|
+
</div>`;
|
|
3170
|
+
}
|
|
3171
|
+
function gi(e, t, n, r, { hidden: i = !1, empty: a = "" } = {}) {
|
|
3172
|
+
return n.length ? `
|
|
3173
|
+
<div class="dz-field dz-field-picker" data-role="${e}-row"${i ? " hidden" : ""}>
|
|
3174
|
+
<label id="dz-${e}-label">${S(t)}</label>
|
|
3175
|
+
|
|
3176
|
+
<div class="dropdown" data-role="${e}-dropdown">
|
|
3177
|
+
${_i(e, n, r)}
|
|
3178
|
+
</div>
|
|
3179
|
+
</div>` : `<p class="modal-summary">${S(a)}</p>`;
|
|
3180
|
+
}
|
|
3181
|
+
function _i(e, t, n) {
|
|
3182
|
+
return `
|
|
3183
|
+
<button type="button" class="dropdown-trigger"
|
|
3184
|
+
aria-haspopup="listbox" aria-expanded="false"
|
|
3185
|
+
aria-labelledby="dz-${e}-label">
|
|
3186
|
+
<span class="dropdown-value"></span>
|
|
3187
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
3188
|
+
</button>
|
|
3189
|
+
|
|
3190
|
+
<ul class="dropdown-menu" role="listbox"
|
|
3191
|
+
aria-labelledby="dz-${e}-label" hidden>
|
|
3192
|
+
${t.map((e) => `
|
|
3193
|
+
<li class="dropdown-item" role="option" tabindex="-1"
|
|
3194
|
+
data-value="${S(e.value)}"
|
|
3195
|
+
${e.value === n ? "data-selected=\"true\"" : ""}
|
|
3196
|
+
>${S(e.label)}</li>`).join("")}
|
|
3197
|
+
</ul>`;
|
|
3198
|
+
}
|
|
3199
|
+
var vi = [
|
|
3200
|
+
{
|
|
3201
|
+
value: "text",
|
|
3202
|
+
label: "As it comes"
|
|
3203
|
+
},
|
|
3204
|
+
{
|
|
3205
|
+
value: "number",
|
|
3206
|
+
label: "Number"
|
|
3207
|
+
},
|
|
3208
|
+
{
|
|
3209
|
+
value: "currency",
|
|
3210
|
+
label: "Currency"
|
|
3211
|
+
},
|
|
3212
|
+
{
|
|
3213
|
+
value: "percent",
|
|
3214
|
+
label: "Percent"
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
value: "date",
|
|
3218
|
+
label: "Date"
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
value: "datetime",
|
|
3222
|
+
label: "Date & time"
|
|
3223
|
+
}
|
|
3224
|
+
], yi = {
|
|
3225
|
+
number: [
|
|
3226
|
+
1234567.891,
|
|
3227
|
+
-1500,
|
|
3228
|
+
0
|
|
3229
|
+
],
|
|
3230
|
+
currency: [
|
|
3231
|
+
1234567.891,
|
|
3232
|
+
-1500,
|
|
3233
|
+
0
|
|
3234
|
+
],
|
|
3235
|
+
percent: [
|
|
3236
|
+
.1234,
|
|
3237
|
+
-.05,
|
|
3238
|
+
0
|
|
3239
|
+
],
|
|
3240
|
+
date: ["2026-06-17"],
|
|
3241
|
+
datetime: ["2026-06-17T15:04:00"]
|
|
3242
|
+
}, $ = "__custom__";
|
|
3243
|
+
function bi(e, t, n, { title: r = "Format" } = {}) {
|
|
3244
|
+
let i = u(t, n) ?? {
|
|
3245
|
+
...u({ type: "number" }, n),
|
|
3246
|
+
type: "text"
|
|
3247
|
+
};
|
|
3248
|
+
return Q(e, "format-dialog", Ei(i, r), (e, t) => {
|
|
3249
|
+
let r = e.querySelector("form"), a = (t) => e.querySelector(`[data-role="${t}"]`)?.value, o = () => {
|
|
3250
|
+
let t = e.querySelector("[name=\"format-type\"]:checked")?.value ?? "text", n = a("pattern");
|
|
3251
|
+
return {
|
|
3252
|
+
type: t,
|
|
3253
|
+
decimals: xi(a("decimals"), i.decimals),
|
|
3254
|
+
grouping: a("grouping"),
|
|
3255
|
+
negative: a("negative"),
|
|
3256
|
+
zero: a("zero"),
|
|
3257
|
+
symbol: a("symbolChoice") === $ ? (a("symbol") ?? "").trim() : a("symbolChoice") ?? "",
|
|
3258
|
+
symbolPosition: a("symbolPosition"),
|
|
3259
|
+
pattern: n === $ ? a("customPattern") || i.pattern : n
|
|
3260
|
+
};
|
|
3261
|
+
}, s = () => {
|
|
3262
|
+
let t = o(), n = [
|
|
3263
|
+
"number",
|
|
3264
|
+
"currency",
|
|
3265
|
+
"percent"
|
|
3266
|
+
].includes(t.type), r = t.type === "date" || t.type === "datetime";
|
|
3267
|
+
r && wi(e, t.type, t.pattern), e.querySelector("[data-role=\"number-options\"]").hidden = !n, e.querySelector("[data-role=\"currency-options\"]").hidden = t.type !== "currency", e.querySelector("[data-role=\"date-options\"]").hidden = !r, e.querySelector("[data-role=\"custom-row\"]").hidden = a("pattern") !== $, e.querySelector("[data-role=\"symbol-row\"]").hidden = a("symbolChoice") !== $;
|
|
3268
|
+
let i = o(), s = e.querySelector("[data-role=\"decimals\"]");
|
|
3269
|
+
s.value !== "" && Number(s.value) !== i.decimals && (s.value = String(i.decimals));
|
|
3270
|
+
let c = e.querySelector("[data-role=\"zero\"] option[value=\"zero\"]");
|
|
3271
|
+
c && (c.textContent = Si(i.decimals)), e.querySelector("[data-role=\"sample\"]").innerHTML = i.type === "text" ? "<span>Printed as the data has it</span>" : (yi[i.type] ?? []).map((e) => `<span>${S(y(e, i) || "(blank)")}</span>`).join("");
|
|
3272
|
+
};
|
|
3273
|
+
r.addEventListener("input", s), r.addEventListener("change", s), e.querySelector("[data-role=\"reset\"]").addEventListener("click", () => {
|
|
3274
|
+
let e = o().type;
|
|
3275
|
+
t({ format: e === "text" ? null : { type: e } });
|
|
3276
|
+
}), r.addEventListener("submit", (e) => {
|
|
3277
|
+
e.preventDefault(), t({ format: Ci(o(), n) });
|
|
3278
|
+
}), s(), e.querySelector("[name=\"format-type\"]:checked")?.focus();
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
function xi(e, t) {
|
|
3282
|
+
let n = Math.round(Number(e));
|
|
3283
|
+
return e === "" || e == null || !Number.isFinite(n) ? t : Math.min(6, Math.max(0, n));
|
|
3284
|
+
}
|
|
3285
|
+
function Si(e) {
|
|
3286
|
+
return 0 .toFixed(e);
|
|
3287
|
+
}
|
|
3288
|
+
function Ci(e, t) {
|
|
3289
|
+
if (e.type === "text") return null;
|
|
3290
|
+
let n = u({ type: e.type }, t), r = e.type === "date" || e.type === "datetime" ? ["pattern"] : [
|
|
3291
|
+
"decimals",
|
|
3292
|
+
"grouping",
|
|
3293
|
+
"negative",
|
|
3294
|
+
"zero",
|
|
3295
|
+
...e.type === "currency" ? ["symbol", "symbolPosition"] : []
|
|
3296
|
+
], i = { type: e.type };
|
|
3297
|
+
for (let t of r) e[t] !== n[t] && (i[t] = e[t]);
|
|
3298
|
+
return i;
|
|
3299
|
+
}
|
|
3300
|
+
function wi(e, t, n) {
|
|
3301
|
+
let r = e.querySelector("[data-role=\"pattern\"]");
|
|
3302
|
+
if (r.dataset.for === t) return;
|
|
3303
|
+
let a = t === "datetime" ? ne : i;
|
|
3304
|
+
r.innerHTML = Ti(a, t, a.includes(n) ? n : a[0]), r.dataset.for = t;
|
|
3305
|
+
}
|
|
3306
|
+
function Ti(e, t, n) {
|
|
3307
|
+
let r = yi[t][0];
|
|
3308
|
+
return [...e.map((e) => `<option value="${S(e)}"${e === n ? " selected" : ""}
|
|
3309
|
+
>${S(y(r, {
|
|
3310
|
+
type: t,
|
|
3311
|
+
pattern: e
|
|
3312
|
+
}))} (${S(e)})</option>`), `<option value="${$}"${e.includes(n) ? "" : " selected"}>Custom…</option>`].join("");
|
|
3313
|
+
}
|
|
3314
|
+
function Ei(e, t) {
|
|
3315
|
+
let n = (e) => (t) => `<option value="${S(t.value)}"
|
|
3316
|
+
${t.value === e ? "selected" : ""}>${S(t.label)}</option>`, r = (e, t, r, i) => `
|
|
3317
|
+
<div class="dz-field">
|
|
3318
|
+
<label for="dz-format-${e}">${S(t)}</label>
|
|
3319
|
+
<select id="dz-format-${e}" data-role="${e}">
|
|
3320
|
+
${r.map(n(i)).join("")}
|
|
3321
|
+
</select>
|
|
3322
|
+
</div>`, o = e.type === "datetime" ? "datetime" : "date", s = o === "datetime" ? ne : i, c = !s.includes(e.pattern), l = a.some((t) => t.value === e.symbol);
|
|
3323
|
+
return `
|
|
3324
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
3325
|
+
|
|
3326
|
+
<div class="modal-card dz-format-card" role="dialog" aria-modal="true"
|
|
3327
|
+
aria-labelledby="dz-format-title">
|
|
3328
|
+
<h2 id="dz-format-title">${S(t)}</h2>
|
|
3329
|
+
|
|
3330
|
+
<form>
|
|
3331
|
+
<fieldset class="dz-format-types">
|
|
3332
|
+
<legend>Type</legend>
|
|
3333
|
+
${vi.map((t) => `
|
|
3334
|
+
<label class="dz-format-type">
|
|
3335
|
+
<input type="radio" name="format-type" value="${t.value}"
|
|
3336
|
+
${t.value === e.type ? "checked" : ""}>
|
|
3337
|
+
<span>${S(t.label)}</span>
|
|
3338
|
+
</label>`).join("")}
|
|
3339
|
+
</fieldset>
|
|
3340
|
+
|
|
3341
|
+
<div class="dz-format-group" data-role="number-options">
|
|
3342
|
+
<div class="dz-field">
|
|
3343
|
+
<label for="dz-format-decimals">Decimals</label>
|
|
3344
|
+
<input type="number" id="dz-format-decimals" data-role="decimals"
|
|
3345
|
+
value="${e.decimals}" min="0" max="6" step="1">
|
|
3346
|
+
</div>
|
|
3347
|
+
${r("grouping", "Digit groups", [
|
|
3348
|
+
{
|
|
3349
|
+
value: "international",
|
|
3350
|
+
label: "1,234,567"
|
|
3351
|
+
},
|
|
3352
|
+
{
|
|
3353
|
+
value: "indian",
|
|
3354
|
+
label: "12,34,567 (Indian)"
|
|
3355
|
+
},
|
|
3356
|
+
{
|
|
3357
|
+
value: "none",
|
|
3358
|
+
label: "1234567"
|
|
3359
|
+
}
|
|
3360
|
+
], e.grouping)}
|
|
3361
|
+
${r("negative", "Negative", [
|
|
3362
|
+
{
|
|
3363
|
+
value: "minus",
|
|
3364
|
+
label: "-1,234"
|
|
3365
|
+
},
|
|
3366
|
+
{
|
|
3367
|
+
value: "brackets",
|
|
3368
|
+
label: "(1,234)"
|
|
3369
|
+
},
|
|
3370
|
+
{
|
|
3371
|
+
value: "trailing",
|
|
3372
|
+
label: "1,234-"
|
|
3373
|
+
}
|
|
3374
|
+
], e.negative)}
|
|
3375
|
+
${r("zero", "Zero shows as", [
|
|
3376
|
+
{
|
|
3377
|
+
value: "zero",
|
|
3378
|
+
label: Si(e.decimals)
|
|
3379
|
+
},
|
|
3380
|
+
{
|
|
3381
|
+
value: "dash",
|
|
3382
|
+
label: "-"
|
|
3383
|
+
},
|
|
3384
|
+
{
|
|
3385
|
+
value: "blank",
|
|
3386
|
+
label: "Nothing"
|
|
3387
|
+
}
|
|
3388
|
+
], e.zero)}
|
|
3389
|
+
</div>
|
|
3390
|
+
|
|
3391
|
+
<div class="dz-format-group" data-role="currency-options">
|
|
3392
|
+
${r("symbolChoice", "Symbol", [...a, {
|
|
3393
|
+
value: $,
|
|
3394
|
+
label: "Custom…"
|
|
3395
|
+
}], l ? e.symbol : $)}
|
|
3396
|
+
${r("symbolPosition", "Symbol goes", [{
|
|
3397
|
+
value: "before",
|
|
3398
|
+
label: "Before ₹100"
|
|
3399
|
+
}, {
|
|
3400
|
+
value: "after",
|
|
3401
|
+
label: "After 100 ₹"
|
|
3402
|
+
}], e.symbolPosition)}
|
|
3403
|
+
<div class="dz-field" data-role="symbol-row"${l ? " hidden" : ""}>
|
|
3404
|
+
<label for="dz-format-symbol">Custom symbol</label>
|
|
3405
|
+
<input type="text" id="dz-format-symbol" data-role="symbol"
|
|
3406
|
+
value="${S(l ? "" : e.symbol)}" maxlength="6"
|
|
3407
|
+
spellcheck="false" placeholder="such as CHF">
|
|
3408
|
+
</div>
|
|
3409
|
+
</div>
|
|
3410
|
+
|
|
3411
|
+
<div class="dz-format-group" data-role="date-options">
|
|
3412
|
+
<div class="dz-field">
|
|
3413
|
+
<label for="dz-format-pattern">Layout</label>
|
|
3414
|
+
<select id="dz-format-pattern" data-role="pattern" data-for="${o}">
|
|
3415
|
+
${Ti(s, o, c ? $ : e.pattern)}
|
|
3416
|
+
</select>
|
|
3417
|
+
</div>
|
|
3418
|
+
<div class="dz-field" data-role="custom-row"${c ? "" : " hidden"}>
|
|
3419
|
+
<label for="dz-format-custom">Pattern</label>
|
|
3420
|
+
<input type="text" id="dz-format-custom" data-role="customPattern"
|
|
3421
|
+
value="${S(c ? e.pattern : "")}" spellcheck="false"
|
|
3422
|
+
placeholder="dd/MM/yyyy">
|
|
3423
|
+
</div>
|
|
3424
|
+
<p class="modal-summary">
|
|
3425
|
+
yyyy year · MM month · MMM Jun · dd day · HH hour · hh 12-hour ·
|
|
3426
|
+
mm minute · a AM/PM
|
|
3427
|
+
</p>
|
|
3428
|
+
</div>
|
|
3429
|
+
|
|
3430
|
+
<div class="dz-format-sample">
|
|
3431
|
+
<span class="dz-format-sample-label">Sample</span>
|
|
3432
|
+
<span class="dz-format-sample-values" data-role="sample"></span>
|
|
3433
|
+
</div>
|
|
3434
|
+
|
|
3435
|
+
<div class="modal-actions">
|
|
3436
|
+
<button type="button" data-role="reset"
|
|
3437
|
+
title="Keep the type, and take everything else from the report's own settings">
|
|
3438
|
+
Report defaults</button>
|
|
3439
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
3440
|
+
<button type="submit" class="is-primary" data-role="confirm">Apply</button>
|
|
3441
|
+
</div>
|
|
3442
|
+
</form>
|
|
3443
|
+
</div>`;
|
|
3444
|
+
}
|
|
3445
|
+
var Di = [
|
|
3446
|
+
{
|
|
3447
|
+
value: "=",
|
|
3448
|
+
label: "equals"
|
|
3449
|
+
},
|
|
3450
|
+
{
|
|
3451
|
+
value: "!=",
|
|
3452
|
+
label: "is not"
|
|
3453
|
+
},
|
|
3454
|
+
{
|
|
3455
|
+
value: "<",
|
|
3456
|
+
label: "is less than"
|
|
3457
|
+
},
|
|
3458
|
+
{
|
|
3459
|
+
value: "<=",
|
|
3460
|
+
label: "is at most"
|
|
3461
|
+
},
|
|
3462
|
+
{
|
|
3463
|
+
value: ">",
|
|
3464
|
+
label: "is more than"
|
|
3465
|
+
},
|
|
3466
|
+
{
|
|
3467
|
+
value: ">=",
|
|
3468
|
+
label: "is at least"
|
|
3469
|
+
},
|
|
3470
|
+
{
|
|
3471
|
+
value: "between",
|
|
3472
|
+
label: "is between"
|
|
3473
|
+
},
|
|
3474
|
+
{
|
|
3475
|
+
value: "contains",
|
|
3476
|
+
label: "contains"
|
|
3477
|
+
},
|
|
3478
|
+
{
|
|
3479
|
+
value: "startsWith",
|
|
3480
|
+
label: "starts with"
|
|
3481
|
+
},
|
|
3482
|
+
{
|
|
3483
|
+
value: "empty",
|
|
3484
|
+
label: "is empty"
|
|
3485
|
+
},
|
|
3486
|
+
{
|
|
3487
|
+
value: "notEmpty",
|
|
3488
|
+
label: "is not empty"
|
|
3489
|
+
}
|
|
3490
|
+
], Oi = "", ki = "#b3261e";
|
|
3491
|
+
function Ai(e, t, { title: n = "Highlight", fields: i = [], rows: a = !1, format: o = null } = {}) {
|
|
3492
|
+
let s = structuredClone(Array.isArray(t) ? t : []), c = [.../* @__PURE__ */ new Set([...i, ...s.map((e) => e.when?.field).filter(Boolean)])], l = () => ({
|
|
3493
|
+
when: a ? {
|
|
3494
|
+
field: c[0] ?? "",
|
|
3495
|
+
op: "=",
|
|
3496
|
+
value: ""
|
|
3497
|
+
} : {
|
|
3498
|
+
op: "<",
|
|
3499
|
+
value: 0
|
|
3500
|
+
},
|
|
3501
|
+
style: { color: ki }
|
|
3502
|
+
});
|
|
3503
|
+
return s.length === 0 && s.push(l()), Q(e, "highlight-dialog", Ii(n), (e, t) => {
|
|
3504
|
+
let n = e.querySelector("[data-role=\"rules\"]"), i = () => {
|
|
3505
|
+
n.innerHTML = s.map((e, t) => Fi(e, t, s.length, c, a, o)).join("");
|
|
3506
|
+
}, u = (e) => {
|
|
3507
|
+
let t = se(e);
|
|
3508
|
+
return t === null ? e : t;
|
|
3509
|
+
};
|
|
3510
|
+
e.addEventListener("input", (e) => {
|
|
3511
|
+
let t = e.target.closest("[data-key]"), a = Number(t?.closest("[data-n]")?.dataset.n), c = s[a];
|
|
3512
|
+
if (!c) return;
|
|
3513
|
+
let l = t.dataset.key;
|
|
3514
|
+
if (l === "field") t.value === Oi ? delete c.when.field : c.when.field = t.value;
|
|
3515
|
+
else if (l === "op") {
|
|
3516
|
+
c.when.op = t.value, r.includes(t.value) && (delete c.when.value, delete c.when.to), i(), n.querySelector(`[data-n="${a}"] [data-key="op"]`)?.focus();
|
|
3517
|
+
return;
|
|
3518
|
+
} else l === "value" || l === "to" ? c.when[l] = u(t.value) : (l === "color" || l === "background") && (c.style[l] = t.value, t.closest(".dz-swatch")?.classList.remove("is-none"));
|
|
3519
|
+
Pi(n, a, c, o);
|
|
3520
|
+
}), e.addEventListener("change", (e) => {
|
|
3521
|
+
e.target.tagName === "SELECT" && e.target.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
3522
|
+
}), e.addEventListener("click", (e) => {
|
|
3523
|
+
let t = e.target.closest("[data-rule-action]");
|
|
3524
|
+
if (!t) return;
|
|
3525
|
+
e.preventDefault();
|
|
3526
|
+
let r = Number(t.closest("[data-n]")?.dataset.n), a = t.dataset.ruleAction;
|
|
3527
|
+
if (a === "add") {
|
|
3528
|
+
s.push(l()), i(), n.querySelector(`[data-n="${s.length - 1}"] select, [data-n="${s.length - 1}"] input`)?.focus();
|
|
3529
|
+
return;
|
|
3530
|
+
}
|
|
3531
|
+
let o = s[r];
|
|
3532
|
+
o && (a === "remove" && s.splice(r, 1), a === "up" && r > 0 && s.splice(r - 1, 0, ...s.splice(r, 1)), a === "clear" && delete o.style[t.dataset.key], a === "bold" && ji(o.style, "fontWeight", "bold"), a === "italic" && ji(o.style, "fontStyle", "italic"), i());
|
|
3533
|
+
}), e.querySelector("form").addEventListener("submit", (e) => {
|
|
3534
|
+
e.preventDefault();
|
|
3535
|
+
let n = s.filter(Mi);
|
|
3536
|
+
t({ rules: n.length ? n : null });
|
|
3537
|
+
}), i(), n.querySelector("select, input")?.focus();
|
|
3538
|
+
});
|
|
3539
|
+
}
|
|
3540
|
+
function ji(e, t, n) {
|
|
3541
|
+
e[t] === n ? delete e[t] : e[t] = n;
|
|
3542
|
+
}
|
|
3543
|
+
function Mi(e) {
|
|
3544
|
+
let { when: t } = e;
|
|
3545
|
+
if (!t || !Di.some((e) => e.value === t.op)) return !1;
|
|
3546
|
+
if (r.includes(t.op)) return !0;
|
|
3547
|
+
let n = (e) => e != null && String(e).trim() !== "";
|
|
3548
|
+
return t.op === "between" ? n(t.value) && n(t.to) : n(t.value);
|
|
3549
|
+
}
|
|
3550
|
+
function Ni(e, t) {
|
|
3551
|
+
let n = e.when?.value, r = n === void 0 || n === "" ? "Sample" : y(n, t) || "Sample", i = e.style ?? {};
|
|
3552
|
+
return `<span class="dz-hl-preview" data-role="preview" style="${S([
|
|
3553
|
+
i.color ? `color:${i.color}` : "",
|
|
3554
|
+
i.background ? `background:${i.background}` : "",
|
|
3555
|
+
i.fontWeight ? `font-weight:${i.fontWeight}` : "",
|
|
3556
|
+
i.fontStyle ? `font-style:${i.fontStyle}` : ""
|
|
3557
|
+
].filter(Boolean).join(";"))}">${S(r)}</span>`;
|
|
3558
|
+
}
|
|
3559
|
+
function Pi(e, t, n, r) {
|
|
3560
|
+
let i = e.querySelector(`[data-n="${t}"] [data-role="preview"]`);
|
|
3561
|
+
i && (i.outerHTML = Ni(n, r));
|
|
3562
|
+
}
|
|
3563
|
+
function Fi(e, t, n, i, a, o) {
|
|
3564
|
+
let s = e.when ?? {}, c = e.style ?? {}, l = r.includes(s.op), u = (e) => (t) => `<option value="${S(t.value)}"
|
|
3565
|
+
${t.value === e ? "selected" : ""}>${S(t.label)}</option>`, d = [...a ? [] : [{
|
|
3566
|
+
value: Oi,
|
|
3567
|
+
label: "this value"
|
|
3568
|
+
}], ...i.map((e) => ({
|
|
3569
|
+
value: e,
|
|
3570
|
+
label: e
|
|
3571
|
+
}))], f = (e, t) => {
|
|
3572
|
+
let n = !c[e];
|
|
3573
|
+
return `
|
|
3574
|
+
<span class="dz-hl-color">
|
|
3575
|
+
<span class="dz-hl-color-label">${S(t)}</span>
|
|
3576
|
+
<span class="dz-swatch${n ? " is-none" : ""}">
|
|
3577
|
+
<span class="dz-swatch-well">
|
|
3578
|
+
<input type="color" data-key="${e}" value="${S(n ? "#000000" : c[e])}"
|
|
3579
|
+
aria-label="${S(t)} colour">
|
|
3580
|
+
</span>
|
|
3581
|
+
<button type="button" class="dz-icon dz-swatch-clear" data-rule-action="clear"
|
|
3582
|
+
data-key="${e}" title="No ${S(t.toLowerCase())} colour"
|
|
3583
|
+
aria-label="Remove ${S(t.toLowerCase())} colour">×</button>
|
|
3584
|
+
</span>
|
|
3585
|
+
</span>`;
|
|
3586
|
+
};
|
|
3587
|
+
return `
|
|
3588
|
+
<div class="dz-hl-rule" data-n="${t}">
|
|
3589
|
+
<span class="dz-hl-label">${t === 0 ? "When" : "Else when"}</span>
|
|
3590
|
+
<div class="dz-hl-when">
|
|
3591
|
+
<select data-key="field" aria-label="What to test">
|
|
3592
|
+
${d.map(u(s.field ?? Oi)).join("")}
|
|
3593
|
+
</select>
|
|
3594
|
+
<select data-key="op" aria-label="Test">
|
|
3595
|
+
${Di.map(u(s.op)).join("")}
|
|
3596
|
+
</select>
|
|
3597
|
+
<span class="dz-hl-values">
|
|
3598
|
+
${l ? "<span class=\"dz-hl-novalue\">no value needed</span>" : `
|
|
3599
|
+
<input type="text" data-key="value" value="${S(s.value ?? "")}"
|
|
3600
|
+
spellcheck="false" aria-label="Value" placeholder="value">`}
|
|
3601
|
+
${s.op === "between" ? `
|
|
3602
|
+
<span class="dz-hl-and">and</span>
|
|
3603
|
+
<input type="text" data-key="to" value="${S(s.to ?? "")}"
|
|
3604
|
+
spellcheck="false" aria-label="Upper value" placeholder="value">` : ""}
|
|
3605
|
+
</span>
|
|
3606
|
+
</div>
|
|
3607
|
+
<span class="dz-hl-actions">
|
|
3608
|
+
${t > 0 ? `<button type="button" class="dz-icon" data-rule-action="up"
|
|
3609
|
+
title="Check this rule before the one above"
|
|
3610
|
+
aria-label="Move rule ${t + 1} up">↑</button>` : "<span class=\"dz-hl-slot\" aria-hidden=\"true\"></span>"}
|
|
3611
|
+
<button type="button" class="dz-icon" data-rule-action="remove"
|
|
3612
|
+
title="Remove this rule" aria-label="Remove rule ${t + 1}">×</button>
|
|
3613
|
+
</span>
|
|
3614
|
+
|
|
3615
|
+
<span class="dz-hl-label">Style</span>
|
|
3616
|
+
<div class="dz-hl-style">
|
|
3617
|
+
${f("color", "Text")}
|
|
3618
|
+
${f("background", "Fill")}
|
|
3619
|
+
<span class="dz-hl-toggles">
|
|
3620
|
+
<button type="button" class="dz-hl-toggle" data-rule-action="bold"
|
|
3621
|
+
aria-pressed="${c.fontWeight === "bold"}" title="Bold"
|
|
3622
|
+
aria-label="Bold"><b>B</b></button>
|
|
3623
|
+
<button type="button" class="dz-hl-toggle" data-rule-action="italic"
|
|
3624
|
+
aria-pressed="${c.fontStyle === "italic"}" title="Italic"
|
|
3625
|
+
aria-label="Italic"><i>I</i></button>
|
|
3626
|
+
</span>
|
|
3627
|
+
${Ni(e, o)}
|
|
3628
|
+
</div>
|
|
3629
|
+
</div>`;
|
|
3630
|
+
}
|
|
3631
|
+
function Ii(e) {
|
|
3632
|
+
return `
|
|
3633
|
+
<div class="modal-backdrop" data-role="backdrop"></div>
|
|
3634
|
+
|
|
3635
|
+
<div class="modal-card dz-highlight-card" role="dialog" aria-modal="true"
|
|
3636
|
+
aria-labelledby="dz-highlight-title">
|
|
3637
|
+
<h2 id="dz-highlight-title">${S(e)}</h2>
|
|
3638
|
+
|
|
3639
|
+
<form>
|
|
3640
|
+
<div class="dz-hl-rules" data-role="rules"></div>
|
|
3641
|
+
|
|
3642
|
+
<button type="button" class="dz-add-row" data-rule-action="add">Add rule</button>
|
|
3643
|
+
|
|
3644
|
+
<p class="modal-summary">
|
|
3645
|
+
Rules are checked in order, and the first one that holds is used.
|
|
3646
|
+
</p>
|
|
3647
|
+
|
|
3648
|
+
<div class="modal-actions">
|
|
3649
|
+
<button type="button" data-role="cancel">Cancel</button>
|
|
3650
|
+
<button type="submit" class="is-primary" data-role="confirm">Apply</button>
|
|
3651
|
+
</div>
|
|
3652
|
+
</form>
|
|
3653
|
+
</div>`;
|
|
3654
|
+
}
|
|
3655
|
+
function Li(e, t, { limit: n = 12 } = {}) {
|
|
3656
|
+
let r;
|
|
3657
|
+
try {
|
|
3658
|
+
r = ce(e, t ?? {});
|
|
3659
|
+
} catch (e) {
|
|
3660
|
+
return {
|
|
3661
|
+
markup: Ri(e),
|
|
3662
|
+
pageCount: 0,
|
|
3663
|
+
error: e?.message ?? String(e)
|
|
3664
|
+
};
|
|
3665
|
+
}
|
|
3666
|
+
let i = r.pages.length;
|
|
3667
|
+
return {
|
|
3668
|
+
markup: `
|
|
3669
|
+
${w(i > n ? {
|
|
3670
|
+
...r,
|
|
3671
|
+
pages: r.pages.slice(0, n)
|
|
3672
|
+
} : r)}
|
|
3673
|
+
${i > n ? zi(i, n) : ""}`,
|
|
3674
|
+
pageCount: i,
|
|
3675
|
+
error: null
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
function Ri(e) {
|
|
3679
|
+
return `
|
|
3680
|
+
<div class="dz-problems" role="alert">
|
|
3681
|
+
<h2>This report will not run yet</h2>
|
|
3682
|
+
<ul>${(e instanceof o && e.issues?.length ? e.issues : [e?.message ?? String(e)]).map((e) => `<li>${S(e)}</li>`).join("")}</ul>
|
|
3683
|
+
</div>`;
|
|
3684
|
+
}
|
|
3685
|
+
function zi(e, t) {
|
|
3686
|
+
return `
|
|
3687
|
+
<p class="dz-truncated">
|
|
3688
|
+
Showing the first ${t} of ${S(e)} pages.
|
|
3689
|
+
Open the preview screen to read them all.
|
|
3690
|
+
</p>`;
|
|
3691
|
+
}
|
|
3692
|
+
//#endregion
|
|
3693
|
+
//#region src/designer/history.js
|
|
3694
|
+
var Bi = 100, Vi = (e) => structuredClone(e), Hi = (e, t) => JSON.stringify(e) === JSON.stringify(t);
|
|
3695
|
+
function Ui(e, { limit: t = Bi } = {}) {
|
|
3696
|
+
let n = [Vi(e)], r = 0, i = null;
|
|
3697
|
+
return {
|
|
3698
|
+
push(e, a = null) {
|
|
3699
|
+
return Hi(e, n[r]) ? !1 : (r < n.length - 1 && (n = n.slice(0, r + 1), i = null), a != null && a === i ? (n[r] = Vi(e), !0) : (n.push(Vi(e)), r++, i = a, n.length > t && (n.shift(), r--), !0));
|
|
3700
|
+
},
|
|
3701
|
+
undo() {
|
|
3702
|
+
return r === 0 ? null : (r--, i = null, Vi(n[r]));
|
|
3703
|
+
},
|
|
3704
|
+
redo() {
|
|
3705
|
+
return r >= n.length - 1 ? null : (r++, i = null, Vi(n[r]));
|
|
3706
|
+
},
|
|
3707
|
+
get canUndo() {
|
|
3708
|
+
return r > 0;
|
|
3709
|
+
},
|
|
3710
|
+
get canRedo() {
|
|
3711
|
+
return r < n.length - 1;
|
|
3712
|
+
},
|
|
3713
|
+
get length() {
|
|
3714
|
+
return n.length;
|
|
3715
|
+
},
|
|
3716
|
+
reset(e) {
|
|
3717
|
+
n = [Vi(e)], r = 0, i = null;
|
|
3718
|
+
}
|
|
3719
|
+
};
|
|
3720
|
+
}
|
|
3721
|
+
//#endregion
|
|
3722
|
+
//#region src/designer/designer.js
|
|
3723
|
+
var Wi = [
|
|
3724
|
+
"image/png",
|
|
3725
|
+
"image/jpeg",
|
|
3726
|
+
"image/gif",
|
|
3727
|
+
"image/webp"
|
|
3728
|
+
], Gi = 1024 * 1024, Ki = 200 * 1024, qi = (e) => `${Math.round(e / 1024)} KB`, Ji = [
|
|
3729
|
+
"list",
|
|
3730
|
+
"load",
|
|
3731
|
+
"save"
|
|
3732
|
+
];
|
|
3733
|
+
function Yi(e) {
|
|
3734
|
+
if (e == null) return;
|
|
3735
|
+
if (typeof e == "string") throw TypeError(`createDesigner: store must be an object with list, load and save functions, not a path ("${e}"). To keep reports in a folder, leave store out and serve the folder: \`npx report-studio design --dir ${e}\`, or reportStudio({ dir: '${e}' }) from 'report-studio/vite' in your vite.config.`);
|
|
3736
|
+
let t = Ji.filter((t) => typeof e?.[t] != "function");
|
|
3737
|
+
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.`);
|
|
3738
|
+
}
|
|
3739
|
+
function Xi({ width: e, height: t, features: n, ...r } = {}) {
|
|
3740
|
+
let i = v({
|
|
3741
|
+
title: r.layout?.name ? `${r.layout.name} - Designer` : "Report designer",
|
|
3742
|
+
width: e,
|
|
3743
|
+
height: t,
|
|
3744
|
+
features: n
|
|
3745
|
+
});
|
|
3746
|
+
if (!i) return null;
|
|
3747
|
+
let a = Zi({
|
|
3748
|
+
...r,
|
|
3749
|
+
mount: i.mount
|
|
3750
|
+
}), o = ae(globalThis, i.window, a.destroy);
|
|
3751
|
+
return {
|
|
3752
|
+
...a,
|
|
3753
|
+
window: i.window,
|
|
3754
|
+
destroy() {
|
|
3755
|
+
o(), a.destroy(), i.close();
|
|
3756
|
+
}
|
|
3757
|
+
};
|
|
3758
|
+
}
|
|
3759
|
+
function Zi({ mount: e, layout: t, id: n = null, store: r, guardUnload: i = !0, onChange: a = null } = {}) {
|
|
3760
|
+
let o = typeof e == "string" ? document.querySelector(e) : e;
|
|
3761
|
+
if (!o) throw Error(`createDesigner: no element for mount ${JSON.stringify(e)}. Add <div id="report-designer"></div> to the page first.`);
|
|
3762
|
+
let c = o.ownerDocument;
|
|
3763
|
+
Yi(r);
|
|
3764
|
+
let l = r ?? gr(), d = {
|
|
3765
|
+
zoom: 1,
|
|
3766
|
+
fitWidth: !1,
|
|
3767
|
+
rulers: !1,
|
|
3768
|
+
layout: Qe(t) ? Ze() : Ce(t),
|
|
3769
|
+
selection: [],
|
|
3770
|
+
id: n,
|
|
3771
|
+
dirty: !1,
|
|
3772
|
+
clipboard: [],
|
|
3773
|
+
mode: "design",
|
|
3774
|
+
dismissed: null
|
|
3775
|
+
}, f = Ui(d.layout);
|
|
3776
|
+
o.classList.add("report-designer"), o.tabIndex = -1, o.innerHTML = Qi(d.layout);
|
|
3777
|
+
let p = o.querySelector("[data-role=\"canvas\"]"), h = o.querySelector("[data-role=\"stage\"]"), g = o.querySelector("[data-role=\"zoom-layer\"]"), _ = o.querySelector("[data-role=\"panel\"]"), v = o.querySelector("[data-role=\"bar\"]"), y = o.querySelector("[data-role=\"foot\"]"), b = o.querySelector(".dz-main"), x = o.querySelector("[data-role=\"toasts\"]"), S = o.querySelector("[data-role=\"pages\"]");
|
|
3778
|
+
function C() {
|
|
3779
|
+
return d.selection.at(-1) ?? null;
|
|
3780
|
+
}
|
|
3781
|
+
function w(e) {
|
|
3782
|
+
return e ? (Y(d.layout, e.band)?.items || []).find((t) => t.id === e.id) ?? null : null;
|
|
3783
|
+
}
|
|
3784
|
+
function T() {
|
|
3785
|
+
return w(C());
|
|
3786
|
+
}
|
|
3787
|
+
function E() {
|
|
3788
|
+
return d.selection.map(w).filter(Boolean);
|
|
3789
|
+
}
|
|
3790
|
+
function D() {
|
|
3791
|
+
let e = s(d.layout);
|
|
3792
|
+
if (d.mode === "preview") {
|
|
3793
|
+
let t = Li(d.layout, d.data);
|
|
3794
|
+
return g.innerHTML = t.markup, S.textContent = t.error ? "" : `${t.pageCount} page${t.pageCount === 1 ? "" : "s"}`, k(e), R(), e;
|
|
3795
|
+
}
|
|
3796
|
+
S.textContent = "";
|
|
3797
|
+
let t = "";
|
|
3798
|
+
try {
|
|
3799
|
+
t = Pt(d.layout, d.selection, { rulers: d.rulers });
|
|
3800
|
+
} catch {
|
|
3801
|
+
t = "";
|
|
3802
|
+
}
|
|
3803
|
+
return g.innerHTML = t, k(e), R(), e;
|
|
3804
|
+
}
|
|
3805
|
+
function k(e) {
|
|
3806
|
+
let t = d.mode !== "design" || e.length === 0 || pr(e, d.dismissed);
|
|
3807
|
+
x.innerHTML = t ? "" : mr(e), e.length === 0 && (d.dismissed = null);
|
|
3808
|
+
}
|
|
3809
|
+
function ne() {
|
|
3810
|
+
ae();
|
|
3811
|
+
let e = Nt(d.layout, d.selection);
|
|
3812
|
+
for (let [t, { item: n, box: r }] of e.entries()) {
|
|
3813
|
+
let e = d.selection[t], i = p.querySelector(`[data-role="select"][data-select-id="${$i(n.id)}"]`);
|
|
3814
|
+
i && Object.assign(i.style, {
|
|
3815
|
+
top: `${r.y}px`,
|
|
3816
|
+
left: `${r.x}px`,
|
|
3817
|
+
width: `${r.w}px`,
|
|
3818
|
+
height: `${r.h}px`
|
|
3819
|
+
});
|
|
3820
|
+
let a = p.querySelector(`[data-band-type="${$i(e.band)}"] [data-item-id="${$i(n.id)}"]`);
|
|
3821
|
+
a && (Object.assign(a.style, {
|
|
3822
|
+
top: `${n.y}px`,
|
|
3823
|
+
left: `${n.x}px`,
|
|
3824
|
+
width: `${n.w}px`
|
|
3825
|
+
}), n.type !== "table" && (a.style.height = `${n.h}px`));
|
|
3826
|
+
}
|
|
3827
|
+
e.some(({ item: e }) => e.type === "table") && ie();
|
|
3828
|
+
}
|
|
3829
|
+
function ie() {
|
|
3830
|
+
let e = d.layout.page.margin;
|
|
3831
|
+
for (let t of Ct(d.layout)) {
|
|
3832
|
+
if (!t.table) continue;
|
|
3833
|
+
let n = $i(t.type), r = p.querySelector(`.dz-zone[data-band-type="${n}"]`);
|
|
3834
|
+
r && r.setAttribute("style", kt(t, e));
|
|
3835
|
+
let i = p.querySelector(`[data-band-tag="${n}"]`);
|
|
3836
|
+
i && (i.style.top = `${t.top + e.top}px`);
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
function ae() {
|
|
3840
|
+
let e = p.querySelector("[data-role=\"rules\"]");
|
|
3841
|
+
e && (e.innerHTML = d.rulers ? Ot(d.layout) : "");
|
|
3842
|
+
for (let e of p.querySelectorAll("[data-role=\"ruler-guides\"]")) e.innerHTML = Dt(d.layout, e.dataset.axis);
|
|
3843
|
+
}
|
|
3844
|
+
function se() {
|
|
3845
|
+
if (d.mode === "preview") return;
|
|
3846
|
+
let e = d.selection.length;
|
|
3847
|
+
_.innerHTML = e > 1 ? Un(E()) : T() ? Ln(T(), d.layout) : Wn(d.layout);
|
|
3848
|
+
}
|
|
3849
|
+
let le = (e, t) => e?.band === t?.band && e?.id === t?.id;
|
|
3850
|
+
function A(e, { add: t = !1 } = {}) {
|
|
3851
|
+
let n = e == null ? [] : [].concat(e), r;
|
|
3852
|
+
if (!t) r = n;
|
|
3853
|
+
else {
|
|
3854
|
+
r = [...d.selection];
|
|
3855
|
+
for (let e of n) {
|
|
3856
|
+
let t = r.findIndex((t) => le(t, e));
|
|
3857
|
+
t === -1 ? r.push(e) : r.splice(t, 1);
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
r.length === d.selection.length && r.every((e, t) => le(e, d.selection[t])) || (d.selection = r, D(), se());
|
|
3861
|
+
}
|
|
3862
|
+
function j(e = null) {
|
|
3863
|
+
f.push(d.layout, e) && (d.dirty = !0, N(), ue());
|
|
3864
|
+
}
|
|
3865
|
+
function ue() {
|
|
3866
|
+
if (typeof a == "function") try {
|
|
3867
|
+
a(d.layout);
|
|
3868
|
+
} catch (e) {
|
|
3869
|
+
console.error("createDesigner: onChange threw", e);
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
function M(e = null) {
|
|
3873
|
+
D(), se(), j(e);
|
|
3874
|
+
}
|
|
3875
|
+
function N() {
|
|
3876
|
+
v.querySelector("[data-role=\"name\"]").textContent = d.layout.name ?? "", v.querySelector("[data-role=\"undo\"]").disabled = !f.canUndo, v.querySelector("[data-role=\"redo\"]").disabled = !f.canRedo;
|
|
3877
|
+
let e = v.querySelector("[data-role=\"size\"]");
|
|
3878
|
+
e && d.layout.page && (e.innerHTML = `${d.layout.page.width} × ${d.layout.page.height}`);
|
|
3879
|
+
let t = v.querySelector("[data-role=\"rulers\"]");
|
|
3880
|
+
t.setAttribute("aria-pressed", String(d.rulers)), t.classList.toggle("is-on", d.rulers);
|
|
3881
|
+
let n = y.querySelector("[data-role=\"add-table\"]");
|
|
3882
|
+
n.disabled = !Gt(d.layout), v.dataset.dirty = String(d.dirty);
|
|
3883
|
+
let r = v.querySelector("[data-role=\"status\"]");
|
|
3884
|
+
r.textContent = d.dirty ? "Unsaved changes" : d.id ? `Saved as ${d.id}.json` : "Not saved yet";
|
|
3885
|
+
}
|
|
3886
|
+
function F(e, { id: t, dirty: n }) {
|
|
3887
|
+
d.layout = Ce(e), d.selection = [], d.mode = "design", d.data = null, t !== void 0 && (d.id = t), n !== void 0 && (d.dirty = n), Le(), ue();
|
|
3888
|
+
}
|
|
3889
|
+
function I(e, t) {
|
|
3890
|
+
dn(d.layout, e, t), d.selection = [{
|
|
3891
|
+
band: e,
|
|
3892
|
+
id: t.id
|
|
3893
|
+
}], M(`add:${t.id}`), z(e);
|
|
3894
|
+
}
|
|
3895
|
+
function L(e) {
|
|
3896
|
+
let t = new Set(e == null ? [] : [].concat(e));
|
|
3897
|
+
for (let e of p.querySelectorAll("[data-band-type]")) e.classList.toggle("is-target", t.has(e.dataset.bandType));
|
|
3898
|
+
for (let e of p.querySelectorAll("[data-band-tag]")) e.classList.toggle("is-target", t.has(e.dataset.bandTag));
|
|
3899
|
+
}
|
|
3900
|
+
function de(e) {
|
|
3901
|
+
let t = p.querySelector("[data-role=\"guides\"]");
|
|
3902
|
+
t && (t.innerHTML = e ? It(Ft(d.layout, e.band), e.lines, e.gaps) : "");
|
|
3903
|
+
}
|
|
3904
|
+
function R() {
|
|
3905
|
+
g.style.transformOrigin = "top left", g.style.transform = `scale(${d.zoom})`;
|
|
3906
|
+
let e = g.offsetWidth, t = g.offsetHeight;
|
|
3907
|
+
e && t && (h.style.width = `${e * d.zoom}px`, h.style.height = `${t * d.zoom}px`), fe();
|
|
3908
|
+
}
|
|
3909
|
+
function fe() {
|
|
3910
|
+
if (W && !d.fitWidth) {
|
|
3911
|
+
let e = re.find((e) => Math.abs(e - d.zoom) < 1e-9);
|
|
3912
|
+
W.value = e === void 0 ? "fit" : String(e);
|
|
3913
|
+
}
|
|
3914
|
+
v.querySelector("[data-role=\"zoom-out\"]").disabled = !d.fitWidth && d.zoom <= te, v.querySelector("[data-role=\"zoom-in\"]").disabled = !d.fitWidth && d.zoom >= oe;
|
|
3915
|
+
}
|
|
3916
|
+
function pe(e) {
|
|
3917
|
+
d.fitWidth = !1, d.zoom = Math.min(Math.max(e, te), oe), R();
|
|
3918
|
+
}
|
|
3919
|
+
function he() {
|
|
3920
|
+
d.fitWidth = !0, W && (W.value = "fit");
|
|
3921
|
+
let e = p.clientWidth - 48, t = g.offsetWidth;
|
|
3922
|
+
e > 0 && t > 0 && (d.zoom = Math.min(Math.max(e / t, te), oe)), R();
|
|
3923
|
+
}
|
|
3924
|
+
function ge(e) {
|
|
3925
|
+
let t = d.zoom;
|
|
3926
|
+
pe((e > 0 ? re.find((e) => e > t + 1e-9) : [...re].reverse().find((e) => e < t - 1e-9)) ?? t);
|
|
3927
|
+
}
|
|
3928
|
+
function z(e) {
|
|
3929
|
+
clearTimeout(z.timer), L(e), z.timer = setTimeout(() => L(null), 1200);
|
|
3930
|
+
}
|
|
3931
|
+
let B = null;
|
|
3932
|
+
function V() {
|
|
3933
|
+
B?.remove(), B = null;
|
|
3934
|
+
}
|
|
3935
|
+
function ve(e, t, n = null) {
|
|
3936
|
+
V(), b.insertAdjacentHTML("beforeend", dr(ur({
|
|
3937
|
+
count: d.selection.length,
|
|
3938
|
+
canPaste: d.clipboard.length > 0,
|
|
3939
|
+
canDuplicate: Gt(d.layout) || !E().some((e) => e.type === "table"),
|
|
3940
|
+
...De(n)
|
|
3941
|
+
}))), B = b.querySelector("[data-role=\"menu\"]"), B.addEventListener("keydown", Oe), B.addEventListener("click", we);
|
|
3942
|
+
let r = b.getBoundingClientRect(), i = B.getBoundingClientRect(), a = fr({
|
|
3943
|
+
x: e - r.left,
|
|
3944
|
+
y: t - r.top
|
|
3945
|
+
}, {
|
|
3946
|
+
width: i.width,
|
|
3947
|
+
height: i.height
|
|
3948
|
+
}, {
|
|
3949
|
+
width: r.width,
|
|
3950
|
+
height: r.height
|
|
3951
|
+
});
|
|
3952
|
+
B.style.left = `${a.left}px`, B.style.top = `${a.top}px`, B.querySelector("button:not([disabled])")?.focus();
|
|
3953
|
+
}
|
|
3954
|
+
function Se(e) {
|
|
3955
|
+
if (d.mode !== "design") return;
|
|
3956
|
+
e.preventDefault();
|
|
3957
|
+
let t = e.target.closest?.("[data-item-id]"), n = t?.closest("[data-band-type]")?.dataset.bandType ?? null;
|
|
3958
|
+
if (t && n) {
|
|
3959
|
+
let e = {
|
|
3960
|
+
band: n,
|
|
3961
|
+
id: t.dataset.itemId
|
|
3962
|
+
};
|
|
3963
|
+
d.selection.some((t) => t.band === e.band && t.id === e.id) || A(e);
|
|
3964
|
+
} else A(null);
|
|
3965
|
+
ve(e.clientX, e.clientY, e.target);
|
|
3966
|
+
}
|
|
3967
|
+
function we(e) {
|
|
3968
|
+
let t = e.target.closest?.("[data-action]");
|
|
3969
|
+
!t || t.disabled || (e.preventDefault(), V(), H(t.dataset.action, t.dataset));
|
|
3970
|
+
}
|
|
3971
|
+
function Te(e) {
|
|
3972
|
+
if (d.selection.length !== 1) return null;
|
|
3973
|
+
let t = T();
|
|
3974
|
+
if (t?.type === "text") return { label: "Format…" };
|
|
3975
|
+
if (t?.type !== "table") return null;
|
|
3976
|
+
let n = Ee(e);
|
|
3977
|
+
if (n === null) return null;
|
|
3978
|
+
let r = t.columns[n];
|
|
3979
|
+
return {
|
|
3980
|
+
label: `Format "${r.label || r.field}" column…`,
|
|
3981
|
+
index: n
|
|
3982
|
+
};
|
|
3983
|
+
}
|
|
3984
|
+
function Ee(e) {
|
|
3985
|
+
let t = e?.closest?.("td, th");
|
|
3986
|
+
return !t || t.classList.contains("group-band-cell") ? null : T()?.columns?.[t.cellIndex] ? t.cellIndex : null;
|
|
3987
|
+
}
|
|
3988
|
+
function De(e) {
|
|
3989
|
+
let t = Te(e), n = d.selection.length === 1 ? T() : null, r = null;
|
|
3990
|
+
if (n?.type === "text" && (r = { label: "Highlight…" }), t && n?.type === "table") {
|
|
3991
|
+
let e = n.columns[t.index];
|
|
3992
|
+
r = {
|
|
3993
|
+
label: `Highlight "${e.label || e.field}" column…`,
|
|
3994
|
+
index: t.index
|
|
3995
|
+
};
|
|
3996
|
+
}
|
|
3997
|
+
return {
|
|
3998
|
+
format: t,
|
|
3999
|
+
highlight: r,
|
|
4000
|
+
rows: n?.type === "table"
|
|
4001
|
+
};
|
|
4002
|
+
}
|
|
4003
|
+
function Oe(e) {
|
|
4004
|
+
if (![
|
|
4005
|
+
"ArrowDown",
|
|
4006
|
+
"ArrowUp",
|
|
4007
|
+
"Home",
|
|
4008
|
+
"End"
|
|
4009
|
+
].includes(e.key)) return;
|
|
4010
|
+
e.preventDefault(), e.stopPropagation();
|
|
4011
|
+
let t = [...B.querySelectorAll("button:not([disabled])")];
|
|
4012
|
+
if (!t.length) return;
|
|
4013
|
+
let n = t.indexOf(B.ownerDocument.activeElement);
|
|
4014
|
+
t[{
|
|
4015
|
+
ArrowDown: (n + 1) % t.length,
|
|
4016
|
+
ArrowUp: (n - 1 + t.length) % t.length,
|
|
4017
|
+
Home: 0,
|
|
4018
|
+
End: t.length - 1
|
|
4019
|
+
}[e.key]].focus();
|
|
4020
|
+
}
|
|
4021
|
+
function ke(e) {
|
|
4022
|
+
B && !B.contains(e.target) && V();
|
|
4023
|
+
}
|
|
4024
|
+
function Ae(e) {
|
|
4025
|
+
B && e.key === "Escape" && V();
|
|
4026
|
+
}
|
|
4027
|
+
function H(e, t) {
|
|
4028
|
+
let n = T();
|
|
4029
|
+
switch (e) {
|
|
4030
|
+
case "add-text": {
|
|
4031
|
+
let e = Cn(d.layout, C());
|
|
4032
|
+
if (!e) return;
|
|
4033
|
+
I(e, an(d.layout, Y(d.layout, e)));
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
case "add-box": {
|
|
4037
|
+
let e = Cn(d.layout, C());
|
|
4038
|
+
if (!e) return;
|
|
4039
|
+
I(e, sn(d.layout, Y(d.layout, e)));
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
4042
|
+
case "add-image": {
|
|
4043
|
+
let e = Cn(d.layout, C());
|
|
4044
|
+
if (!e) return;
|
|
4045
|
+
I(e, cn(d.layout, Y(d.layout, e)));
|
|
4046
|
+
return;
|
|
4047
|
+
}
|
|
4048
|
+
case "upload-image":
|
|
4049
|
+
if (n?.type !== "image") return;
|
|
4050
|
+
Re(n);
|
|
4051
|
+
return;
|
|
4052
|
+
case "clear-image":
|
|
4053
|
+
if (n?.type !== "image" || !n.src) return;
|
|
4054
|
+
n.src = null, M(`image:${n.id}`);
|
|
4055
|
+
return;
|
|
4056
|
+
case "add-line": {
|
|
4057
|
+
let e = Cn(d.layout, C());
|
|
4058
|
+
if (!e) return;
|
|
4059
|
+
I(e, on(d.layout, Y(d.layout, e), t?.orientation));
|
|
4060
|
+
return;
|
|
4061
|
+
}
|
|
4062
|
+
case "add-field":
|
|
4063
|
+
fi(o, d.layout, C()?.band ?? null).then((e) => {
|
|
4064
|
+
if (!e) return;
|
|
4065
|
+
let t = Y(d.layout, e.band);
|
|
4066
|
+
if (!t) return;
|
|
4067
|
+
let n = an(d.layout, t);
|
|
4068
|
+
n.value = e.value, n.w = e.w, n.style.align = e.align, I(e.band, n);
|
|
4069
|
+
});
|
|
4070
|
+
return;
|
|
4071
|
+
case "add-table": {
|
|
4072
|
+
let e = Cn(d.layout, C(), { table: !0 });
|
|
4073
|
+
if (!e || !Gt(d.layout)) return;
|
|
4074
|
+
ti(o).then((t) => {
|
|
4075
|
+
t != null && I(e, un(d.layout, Y(d.layout, e), t));
|
|
4076
|
+
});
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
case "duplicate-item": {
|
|
4080
|
+
if (!d.selection.length) return;
|
|
4081
|
+
let e = [...d.selection], t = [];
|
|
4082
|
+
for (let n of e) {
|
|
4083
|
+
let e = hn(d.layout, n.band, n.id);
|
|
4084
|
+
e && t.push({
|
|
4085
|
+
band: n.band,
|
|
4086
|
+
id: e.id
|
|
4087
|
+
});
|
|
4088
|
+
}
|
|
4089
|
+
if (!t.length) return;
|
|
4090
|
+
d.selection = t, M(`duplicate:${t.map((e) => e.id).join(",")}`), z([...new Set(t.map((e) => e.band))]);
|
|
4091
|
+
return;
|
|
4092
|
+
}
|
|
4093
|
+
case "dismiss-problems":
|
|
4094
|
+
d.dismissed = s(d.layout), x.innerHTML = "";
|
|
4095
|
+
return;
|
|
4096
|
+
case "copy-items": {
|
|
4097
|
+
if (!d.selection.length) return;
|
|
4098
|
+
let e = d.selection.map((e) => ({
|
|
4099
|
+
band: e.band,
|
|
4100
|
+
item: w(e)
|
|
4101
|
+
})).filter((e) => e.item).map((e) => ({
|
|
4102
|
+
band: e.band,
|
|
4103
|
+
item: structuredClone(e.item)
|
|
4104
|
+
}));
|
|
4105
|
+
if (!e.length) return;
|
|
4106
|
+
d.clipboard = e, K(e.length > 1 ? `Copied ${e.length} items` : "Copied", { ms: 2e3 });
|
|
4107
|
+
return;
|
|
4108
|
+
}
|
|
4109
|
+
case "paste-items": {
|
|
4110
|
+
if (!d.clipboard.length) return;
|
|
4111
|
+
let e = Cn(d.layout, C());
|
|
4112
|
+
if (!e) return;
|
|
4113
|
+
let t = vn(d.layout, e, d.clipboard);
|
|
4114
|
+
if (!t.length) return;
|
|
4115
|
+
d.clipboard = t.map((t) => ({
|
|
4116
|
+
band: e,
|
|
4117
|
+
item: structuredClone(t)
|
|
4118
|
+
})), d.selection = t.map((t) => ({
|
|
4119
|
+
band: e,
|
|
4120
|
+
id: t.id
|
|
4121
|
+
})), M(`paste:${t.map((e) => e.id).join(",")}`), z(e);
|
|
4122
|
+
return;
|
|
4123
|
+
}
|
|
4124
|
+
case "delete-item": {
|
|
4125
|
+
if (!d.selection.length) return;
|
|
4126
|
+
let e = d.selection.map((e) => e.id).join(",");
|
|
4127
|
+
for (let e of d.selection) yn(d.layout, e.band, e.id);
|
|
4128
|
+
d.selection = [], M(`delete:${e}`);
|
|
4129
|
+
return;
|
|
4130
|
+
}
|
|
4131
|
+
case "copy-grouping":
|
|
4132
|
+
if (n?.type !== "table" || !t?.from) return;
|
|
4133
|
+
xe(d.layout, n.id, t.from) && (d.selection = d.selection.filter((e) => w(e)), M(`grouping:copy:${n.id}`));
|
|
4134
|
+
return;
|
|
4135
|
+
case "edit-format": {
|
|
4136
|
+
let e = t?.index != null && n?.type === "table", r = e ? n.columns?.[Number(t.index)] : n;
|
|
4137
|
+
if (!r || !e && n?.type !== "text") return;
|
|
4138
|
+
let i = e ? r.label || r.field || "column" : n.id, a = C();
|
|
4139
|
+
bi(o, r.format, d.layout.format, { title: `Format: ${i}` }).then((i) => {
|
|
4140
|
+
i && w(a) === n && (e && !n.columns?.includes(r) || (i.format ? r.format = i.format : delete r.format, M(`format:${n.id}${e ? `:${t.index}` : ""}`)));
|
|
4141
|
+
});
|
|
4142
|
+
return;
|
|
4143
|
+
}
|
|
4144
|
+
case "edit-highlight":
|
|
4145
|
+
case "edit-row-highlight": {
|
|
4146
|
+
let r = e === "edit-row-highlight", i = !r && t?.index != null && n?.type === "table", a = i ? n.columns?.[Number(t.index)] : n;
|
|
4147
|
+
if (!a || (r ? n.type !== "table" : !i && n.type !== "text")) return;
|
|
4148
|
+
let s = r ? "rowHighlight" : "highlight", c = r ? `${n.id} rows` : i ? a.label || a.field || "column" : n.id, l = n.type === "table" ? (n.columns ?? []).map((e) => e.field).filter(Boolean) : Xr(d.layout), f = C();
|
|
4149
|
+
Ai(o, a[s], {
|
|
4150
|
+
title: `Highlight: ${c}`,
|
|
4151
|
+
fields: i ? l.filter((e) => e !== a.field) : l,
|
|
4152
|
+
rows: r,
|
|
4153
|
+
format: i || n.type === "text" ? u(a.format, d.layout.format) : null
|
|
4154
|
+
}).then((e) => {
|
|
4155
|
+
e && w(f) === n && (i && !n.columns?.includes(a) || (e.rules ? a[s] = e.rules : delete a[s], M(`highlight:${n.id}${i ? `:${t.index}` : r ? ":rows" : ""}`)));
|
|
4156
|
+
});
|
|
4157
|
+
return;
|
|
4158
|
+
}
|
|
4159
|
+
case "format-india":
|
|
4160
|
+
d.layout.format = {
|
|
4161
|
+
...d.layout.format ?? {},
|
|
4162
|
+
...m
|
|
4163
|
+
}, M("format:report:india");
|
|
4164
|
+
return;
|
|
4165
|
+
case "add-group-level":
|
|
4166
|
+
if (n?.type !== "table") return;
|
|
4167
|
+
_e(n) !== -1 && M(`grouping:add-level:${n.id}`);
|
|
4168
|
+
return;
|
|
4169
|
+
case "remove-group-level":
|
|
4170
|
+
case "move-group-level-out": {
|
|
4171
|
+
if (n?.type !== "table") return;
|
|
4172
|
+
let r = Number(t?.level);
|
|
4173
|
+
(e === "remove-group-level" ? ye(n, r) : be(n, r)) && (d.selection = d.selection.filter((e) => P(e.band)?.table !== n.id), M(`grouping:${e}:${n.id}:${r}`));
|
|
4174
|
+
return;
|
|
4175
|
+
}
|
|
4176
|
+
case "add-column":
|
|
4177
|
+
if (n?.type !== "table") return;
|
|
4178
|
+
xn(n), M(`column:add:${n.id}`);
|
|
4179
|
+
return;
|
|
4180
|
+
case "remove-column":
|
|
4181
|
+
if (n?.type !== "table") return;
|
|
4182
|
+
Sn(n, Number(t.index)) && M(`column:remove:${n.id}`);
|
|
4183
|
+
return;
|
|
4184
|
+
case "undo": {
|
|
4185
|
+
let e = f.undo();
|
|
4186
|
+
e && F(e, { dirty: !0 });
|
|
4187
|
+
return;
|
|
4188
|
+
}
|
|
4189
|
+
case "redo": {
|
|
4190
|
+
let e = f.redo();
|
|
4191
|
+
e && F(e, { dirty: !0 });
|
|
4192
|
+
return;
|
|
4193
|
+
}
|
|
4194
|
+
case "open": return Me();
|
|
4195
|
+
case "save": return Ne();
|
|
4196
|
+
case "data": return Pe();
|
|
4197
|
+
case "open-window": return Fe();
|
|
4198
|
+
case "zoom-in": return ge(1);
|
|
4199
|
+
case "zoom-out": return ge(-1);
|
|
4200
|
+
case "toggle-rulers":
|
|
4201
|
+
d.rulers = !d.rulers, D(), N();
|
|
4202
|
+
return;
|
|
4203
|
+
case "toggle-preview": return G();
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
async function je() {
|
|
4207
|
+
return !d.dirty || ii(o, d.layout?.name ?? "");
|
|
4208
|
+
}
|
|
4209
|
+
async function Me() {
|
|
4210
|
+
if (!await je()) return;
|
|
4211
|
+
let e;
|
|
4212
|
+
try {
|
|
4213
|
+
e = await l.list();
|
|
4214
|
+
} catch (e) {
|
|
4215
|
+
return q(e);
|
|
4216
|
+
}
|
|
4217
|
+
let t = await ni(o, e);
|
|
4218
|
+
if (t) {
|
|
4219
|
+
if (t.blank) {
|
|
4220
|
+
F(Ze(), {
|
|
4221
|
+
id: null,
|
|
4222
|
+
dirty: !1
|
|
4223
|
+
}), f.reset(d.layout), N();
|
|
4224
|
+
return;
|
|
4225
|
+
}
|
|
4226
|
+
try {
|
|
4227
|
+
F(await l.load(t.id), {
|
|
4228
|
+
id: t.id,
|
|
4229
|
+
dirty: !1
|
|
4230
|
+
}), f.reset(d.layout), N();
|
|
4231
|
+
} catch (e) {
|
|
4232
|
+
q(e);
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
async function Ne() {
|
|
4237
|
+
let e = d.id;
|
|
4238
|
+
if (!e) {
|
|
4239
|
+
let t = await ri(o, d.layout.name ?? "");
|
|
4240
|
+
if (!t) return;
|
|
4241
|
+
e = t.id, d.layout.name = t.name;
|
|
4242
|
+
}
|
|
4243
|
+
try {
|
|
4244
|
+
await l.save(e, d.layout), d.id = e, d.dirty = !1, N(), await U(e);
|
|
4245
|
+
} catch (e) {
|
|
4246
|
+
q(e);
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
async function U(e) {
|
|
4250
|
+
if (!(!l.loadData || !l.saveData)) try {
|
|
4251
|
+
let { data: t, added: n } = Mr(await l.loadData(e), d.layout);
|
|
4252
|
+
n && await l.saveData(e, t);
|
|
4253
|
+
} catch {}
|
|
4254
|
+
}
|
|
4255
|
+
async function Pe() {
|
|
4256
|
+
let e = null;
|
|
4257
|
+
if (d.id && l.loadData) try {
|
|
4258
|
+
e = await l.loadData(d.id);
|
|
4259
|
+
} catch (e) {
|
|
4260
|
+
return q(e);
|
|
4261
|
+
}
|
|
4262
|
+
let t = e == null, n = await ui(o, Mr(e, d.layout).data, {
|
|
4263
|
+
id: d.id,
|
|
4264
|
+
generated: t
|
|
4265
|
+
});
|
|
4266
|
+
if (n) {
|
|
4267
|
+
if (!d.id) return q(/* @__PURE__ */ Error("Save the report first - its data file is named after it."));
|
|
4268
|
+
try {
|
|
4269
|
+
await l.saveData(d.id, n);
|
|
4270
|
+
} catch (e) {
|
|
4271
|
+
q(e);
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
function Fe() {
|
|
4276
|
+
let e;
|
|
4277
|
+
try {
|
|
4278
|
+
e = ce(d.layout, d.data ?? jr(d.layout));
|
|
4279
|
+
} catch (e) {
|
|
4280
|
+
q(e);
|
|
4281
|
+
return;
|
|
4282
|
+
}
|
|
4283
|
+
let t = ee({
|
|
4284
|
+
paginated: e,
|
|
4285
|
+
title: d.layout?.name || "Report"
|
|
4286
|
+
});
|
|
4287
|
+
if (!t) {
|
|
4288
|
+
K("The browser blocked the report window - allow pop-ups for this page", {
|
|
4289
|
+
problem: !0,
|
|
4290
|
+
ms: 6e3
|
|
4291
|
+
});
|
|
4292
|
+
return;
|
|
4293
|
+
}
|
|
4294
|
+
Ie.add(t);
|
|
4295
|
+
}
|
|
4296
|
+
let Ie = /* @__PURE__ */ new Set(), W = null;
|
|
4297
|
+
async function G() {
|
|
4298
|
+
if (d.mode === "preview") {
|
|
4299
|
+
d.mode = "design", d.data = null, Le();
|
|
4300
|
+
return;
|
|
4301
|
+
}
|
|
4302
|
+
let e = null;
|
|
4303
|
+
if (d.id && l.loadData) try {
|
|
4304
|
+
e = await l.loadData(d.id);
|
|
4305
|
+
} catch {}
|
|
4306
|
+
d.data = Mr(e, d.layout).data, d.mode = "preview", d.selection = [], Le();
|
|
4307
|
+
}
|
|
4308
|
+
function Le() {
|
|
4309
|
+
o.dataset.mode = d.mode;
|
|
4310
|
+
let e = v.querySelector("[data-action=\"toggle-preview\"]"), t = d.mode === "preview";
|
|
4311
|
+
e.innerHTML = Z(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)), D(), se(), N();
|
|
4312
|
+
}
|
|
4313
|
+
function K(e, { problem: t = !1, ms: n = 6e3 } = {}) {
|
|
4314
|
+
let r = v.querySelector("[data-role=\"status\"]");
|
|
4315
|
+
r.textContent = e, t ? r.dataset.problem = "true" : delete r.dataset.problem, clearTimeout(q.timer), q.timer = setTimeout(() => {
|
|
4316
|
+
delete r.dataset.problem, N();
|
|
4317
|
+
}, n);
|
|
4318
|
+
}
|
|
4319
|
+
function Re(e) {
|
|
4320
|
+
let t = c.createElement("input");
|
|
4321
|
+
t.type = "file", t.accept = Wi.join(","), t.addEventListener("change", () => {
|
|
4322
|
+
let n = t.files?.[0];
|
|
4323
|
+
if (!n) return;
|
|
4324
|
+
if (!Wi.includes(n.type)) {
|
|
4325
|
+
K(`${n.name} is not a PNG, JPEG, GIF or WebP image`, { problem: !0 });
|
|
4326
|
+
return;
|
|
4327
|
+
}
|
|
4328
|
+
if (n.size > Gi) {
|
|
4329
|
+
K(`${n.name} is ${qi(n.size)} - too large to store in a layout. Bind the image to a data field and supply its URL instead`, { problem: !0 });
|
|
4330
|
+
return;
|
|
4331
|
+
}
|
|
4332
|
+
let r = new (c.defaultView ?? globalThis).FileReader();
|
|
4333
|
+
r.addEventListener("load", () => {
|
|
4334
|
+
ze(e) && (e.src = String(r.result), M(`image:${e.id}`), n.size > Ki && K(`Stored ${n.name} (${qi(n.size)}) in the layout - every copy of the report carries it`));
|
|
4335
|
+
}), r.addEventListener("error", () => q(r.error)), r.readAsDataURL(n);
|
|
4336
|
+
}), t.click();
|
|
4337
|
+
}
|
|
4338
|
+
function ze(e) {
|
|
4339
|
+
return [...d.layout.bands ?? [], ...me(d.layout).map((e) => e.band)].some((t) => (t.items ?? []).includes(e));
|
|
4340
|
+
}
|
|
4341
|
+
function q(e) {
|
|
4342
|
+
K(e instanceof _r ? e.message : `Something went wrong: ${e?.message ?? e}`, { problem: !0 });
|
|
4343
|
+
}
|
|
4344
|
+
function Be(e, t) {
|
|
4345
|
+
t ? Zt(d.layout, e) : (Qt(d.layout, e), d.selection = d.selection.filter((t) => t.band !== e)), M(`band:${e}`);
|
|
4346
|
+
}
|
|
4347
|
+
function Ve(e, t) {
|
|
4348
|
+
let n = Y(d.layout, e);
|
|
4349
|
+
if (!n) return;
|
|
4350
|
+
let r = String(t).trim();
|
|
4351
|
+
if (!(P(e) && /%$/.test(r))) {
|
|
4352
|
+
if (r === "") delete n.height;
|
|
4353
|
+
else if (/^-?[\d.]+\s*%$/.test(r)) n.height = r;
|
|
4354
|
+
else if (Number.isFinite(Number(r))) n.height = Number(r);
|
|
4355
|
+
else return;
|
|
4356
|
+
D(), j(`band-height:${e}`);
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
function He(e, t) {
|
|
4360
|
+
if (!P(e)) return;
|
|
4361
|
+
let n = Y(d.layout, e);
|
|
4362
|
+
if (n) {
|
|
4363
|
+
if (t) {
|
|
4364
|
+
if (n.background === t) return;
|
|
4365
|
+
n.background = t;
|
|
4366
|
+
} else {
|
|
4367
|
+
if (n.background == null) return;
|
|
4368
|
+
delete n.background;
|
|
4369
|
+
}
|
|
4370
|
+
D(), j(`band-fill:${e}`);
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4373
|
+
o.dataset.mode = d.mode, W = O(v.querySelector("[data-role=\"zoom-dropdown\"]")), W.addEventListener("change", () => {
|
|
4374
|
+
W.value === "fit" ? he() : pe(Number(W.value));
|
|
4375
|
+
});
|
|
4376
|
+
let Ge = () => {
|
|
4377
|
+
d.fitWidth && he();
|
|
4378
|
+
}, Ke = c.defaultView ?? globalThis;
|
|
4379
|
+
Ke.addEventListener("resize", Ge);
|
|
4380
|
+
let qe = (e) => {
|
|
4381
|
+
d.dirty && (e.preventDefault(), e.returnValue = "");
|
|
4382
|
+
};
|
|
4383
|
+
i && Ke.addEventListener("beforeunload", qe), D(), se(), N();
|
|
4384
|
+
let Je = In({
|
|
4385
|
+
canvas: p,
|
|
4386
|
+
getLayout: () => d.layout,
|
|
4387
|
+
getSelection: () => d.selection,
|
|
4388
|
+
select: A,
|
|
4389
|
+
remove: () => H("delete-item"),
|
|
4390
|
+
duplicate: () => {
|
|
4391
|
+
let e = d.selection.map((e) => e.id).join(",");
|
|
4392
|
+
return H("duplicate-item"), d.selection.map((e) => e.id).join(",") !== e;
|
|
4393
|
+
},
|
|
4394
|
+
enabled: () => d.mode === "design",
|
|
4395
|
+
getZoom: () => d.zoom,
|
|
4396
|
+
rulers: () => d.rulers,
|
|
4397
|
+
onTarget: L,
|
|
4398
|
+
onGuides: de,
|
|
4399
|
+
commit: ({ live: e, band: t, key: n = null }) => {
|
|
4400
|
+
if (!e && t?.length) {
|
|
4401
|
+
let e = !1;
|
|
4402
|
+
d.selection = d.selection.map((t) => {
|
|
4403
|
+
let n = w(t), r = n ? zt(d.layout, t.band, n) : null;
|
|
4404
|
+
return r && r !== t.band && bn(d.layout, t.band, r, t.id) ? (e = !0, {
|
|
4405
|
+
band: r,
|
|
4406
|
+
id: t.id
|
|
4407
|
+
}) : t;
|
|
4408
|
+
}), e && se();
|
|
4409
|
+
}
|
|
4410
|
+
e ? ne() : D(), or(_, T(), d.layout), e || j(n ?? `move:${d.selection.map((e) => e.id).join(",")}`);
|
|
4411
|
+
}
|
|
4412
|
+
}), Ye = ar({
|
|
4413
|
+
panel: _,
|
|
4414
|
+
getTarget: () => {
|
|
4415
|
+
let e = T();
|
|
4416
|
+
return e ? {
|
|
4417
|
+
target: e,
|
|
4418
|
+
fields: We(e)
|
|
4419
|
+
} : {
|
|
4420
|
+
target: d.layout,
|
|
4421
|
+
fields: Ue(d.layout)
|
|
4422
|
+
};
|
|
4423
|
+
},
|
|
4424
|
+
getItem: T,
|
|
4425
|
+
changed: (e, { rebuild: t = !1 } = {}) => {
|
|
4426
|
+
D(), t && Xe(), j(e);
|
|
4427
|
+
},
|
|
4428
|
+
act: H,
|
|
4429
|
+
toggleBand: Be,
|
|
4430
|
+
setBandHeight: Ve,
|
|
4431
|
+
setBandFill: He
|
|
4432
|
+
});
|
|
4433
|
+
function Xe() {
|
|
4434
|
+
let e = c.activeElement, t = _.contains(e) ? e?.dataset?.field : null, n = t && typeof e.selectionStart == "number" ? [e.selectionStart, e.selectionEnd] : null;
|
|
4435
|
+
if (se(), !t) return;
|
|
4436
|
+
let r = _.querySelector(`[data-field="${$i(t)}"]:not([data-column])`);
|
|
4437
|
+
if (r && (r.focus(), n && typeof r.setSelectionRange == "function")) try {
|
|
4438
|
+
r.setSelectionRange(...n);
|
|
4439
|
+
} catch {}
|
|
4440
|
+
}
|
|
4441
|
+
function J(e) {
|
|
4442
|
+
let t = e.target.closest?.("[data-action]");
|
|
4443
|
+
t && (e.preventDefault(), H(t.dataset.action, t.dataset));
|
|
4444
|
+
}
|
|
4445
|
+
function $e(e) {
|
|
4446
|
+
return o.contains(e.target) ? !0 : e.target === c.body || e.target === c.documentElement;
|
|
4447
|
+
}
|
|
4448
|
+
function et(e) {
|
|
4449
|
+
let t = e.target.closest?.("input, textarea, select, button, a, label, [tabindex]");
|
|
4450
|
+
t && t !== o || o.focus({ preventScroll: !0 });
|
|
4451
|
+
}
|
|
4452
|
+
function tt(e) {
|
|
4453
|
+
if (!$e(e)) return;
|
|
4454
|
+
let t = e.key.toLowerCase();
|
|
4455
|
+
if (t === "z" && !e.ctrlKey && !e.metaKey) {
|
|
4456
|
+
if (e.target.closest?.("input, textarea, select")) return;
|
|
4457
|
+
e.preventDefault(), ge(e.altKey ? -1 : 1);
|
|
4458
|
+
return;
|
|
4459
|
+
}
|
|
4460
|
+
if (e.ctrlKey || e.metaKey) {
|
|
4461
|
+
if (t === "c" || t === "v") {
|
|
4462
|
+
if (e.target.closest?.("input, textarea, select") || t === "c" && String(globalThis.getSelection?.() ?? "")) return;
|
|
4463
|
+
e.preventDefault(), H(t === "c" ? "copy-items" : "paste-items");
|
|
4464
|
+
return;
|
|
4465
|
+
}
|
|
4466
|
+
if (t === "s") {
|
|
4467
|
+
e.preventDefault(), H("save");
|
|
4468
|
+
return;
|
|
4469
|
+
}
|
|
4470
|
+
if (t === "o") {
|
|
4471
|
+
e.preventDefault(), H("open");
|
|
4472
|
+
return;
|
|
4473
|
+
}
|
|
4474
|
+
if (t === "e") {
|
|
4475
|
+
e.preventDefault(), H("toggle-preview");
|
|
4476
|
+
return;
|
|
4477
|
+
}
|
|
4478
|
+
if (t === "0") {
|
|
4479
|
+
e.preventDefault(), pe(1);
|
|
4480
|
+
return;
|
|
4481
|
+
}
|
|
4482
|
+
if (t === "z") {
|
|
4483
|
+
e.preventDefault(), H(e.shiftKey || e.altKey ? "redo" : "undo");
|
|
4484
|
+
return;
|
|
4485
|
+
}
|
|
4486
|
+
if (t === "y") {
|
|
4487
|
+
e.preventDefault(), H("redo");
|
|
4488
|
+
return;
|
|
4489
|
+
}
|
|
4490
|
+
t === "d" && (e.preventDefault(), H("duplicate-item"));
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
return v.addEventListener("click", J), y.addEventListener("click", J), x.addEventListener("click", J), o.addEventListener("pointerdown", et), c.addEventListener("keydown", tt), p.addEventListener("contextmenu", Se), p.addEventListener("scroll", V), c.addEventListener("pointerdown", ke), c.addEventListener("keydown", Ae), {
|
|
4494
|
+
get layout() {
|
|
4495
|
+
return d.layout;
|
|
4496
|
+
},
|
|
4497
|
+
get mode() {
|
|
4498
|
+
return d.mode;
|
|
4499
|
+
},
|
|
4500
|
+
togglePreview: G,
|
|
4501
|
+
get sampleData() {
|
|
4502
|
+
return jr(d.layout);
|
|
4503
|
+
},
|
|
4504
|
+
get selection() {
|
|
4505
|
+
return C();
|
|
4506
|
+
},
|
|
4507
|
+
get selections() {
|
|
4508
|
+
return [...d.selection];
|
|
4509
|
+
},
|
|
4510
|
+
select: A,
|
|
4511
|
+
get id() {
|
|
4512
|
+
return d.id;
|
|
4513
|
+
},
|
|
4514
|
+
get dirty() {
|
|
4515
|
+
return d.dirty;
|
|
4516
|
+
},
|
|
4517
|
+
open(e, t = null) {
|
|
4518
|
+
return F(Qe(e) ? Ze() : e, {
|
|
4519
|
+
id: t,
|
|
4520
|
+
dirty: !1
|
|
4521
|
+
}), f.reset(d.layout), N(), s(d.layout);
|
|
4522
|
+
},
|
|
4523
|
+
save: Ne,
|
|
4524
|
+
redraw: D,
|
|
4525
|
+
destroy() {
|
|
4526
|
+
Je(), Ye(), v.removeEventListener("click", J), y.removeEventListener("click", J), x.removeEventListener("click", J), o.removeEventListener("pointerdown", et), c.removeEventListener("keydown", tt), p.removeEventListener("contextmenu", Se), p.removeEventListener("scroll", V), c.removeEventListener("pointerdown", ke), c.removeEventListener("keydown", Ae), (c.defaultView ?? globalThis).removeEventListener("resize", Ge), Ke.removeEventListener("beforeunload", qe), W?.destroy(), V(), clearTimeout(q.timer), clearTimeout(z.timer);
|
|
4527
|
+
for (let e of Ie) e.destroy();
|
|
4528
|
+
Ie.clear(), o.innerHTML = "", o.classList.remove("report-designer");
|
|
4529
|
+
}
|
|
4530
|
+
};
|
|
4531
|
+
}
|
|
4532
|
+
function Qi(e) {
|
|
4533
|
+
let t = e.page ? `${e.page.width} × ${e.page.height}` : "";
|
|
4534
|
+
return `
|
|
4535
|
+
<header class="dz-bar" data-role="bar">
|
|
4536
|
+
<span class="dz-brand">Report Studio</span>
|
|
4537
|
+
|
|
4538
|
+
<span class="dz-title">
|
|
4539
|
+
<span class="dz-name" data-role="name">${ea(e.name ?? "")}</span>
|
|
4540
|
+
<span class="dz-status" data-role="status">Not saved yet</span>
|
|
4541
|
+
</span>
|
|
4542
|
+
|
|
4543
|
+
<div class="dz-bar-group">
|
|
4544
|
+
<button type="button" class="dz-tool" data-role="undo" data-action="undo"
|
|
4545
|
+
title="Undo (ctrl+Z)" aria-label="Undo" disabled
|
|
4546
|
+
>${Z("undo")}</button>
|
|
4547
|
+
<button type="button" class="dz-tool" data-role="redo" data-action="redo"
|
|
4548
|
+
title="Redo (ctrl+alt+Z or ctrl+shift+Z)" aria-label="Redo" disabled
|
|
4549
|
+
>${Z("redo")}</button>
|
|
4550
|
+
</div>
|
|
4551
|
+
|
|
4552
|
+
<div class="dz-bar-group">
|
|
4553
|
+
<button type="button" class="dz-tool" data-action="open"
|
|
4554
|
+
title="Open a report (ctrl+O)" aria-label="Open a report"
|
|
4555
|
+
>${Z("open")}</button>
|
|
4556
|
+
<button type="button" class="dz-tool" data-action="save"
|
|
4557
|
+
title="Save (ctrl+S)" aria-label="Save"
|
|
4558
|
+
>${Z("save")}</button>
|
|
4559
|
+
<button type="button" class="dz-tool" data-action="data"
|
|
4560
|
+
title="The data this report needs" aria-label="Report data"
|
|
4561
|
+
>${Z("data")}</button>
|
|
4562
|
+
</div>
|
|
4563
|
+
|
|
4564
|
+
<div class="dz-bar-group">
|
|
4565
|
+
<button type="button" class="dz-tool" data-role="rulers"
|
|
4566
|
+
data-action="toggle-rulers"
|
|
4567
|
+
title="Rulers and guides - drag off a ruler to place one"
|
|
4568
|
+
aria-label="Rulers and guides" aria-pressed="false"
|
|
4569
|
+
>${Z("ruler")}</button>
|
|
4570
|
+
<button type="button" class="dz-tool" data-action="toggle-preview"
|
|
4571
|
+
title="Run the report (ctrl+E)" aria-label="Run the report"
|
|
4572
|
+
aria-pressed="false"
|
|
4573
|
+
>${Z("preview")}</button>
|
|
4574
|
+
|
|
4575
|
+
<!--
|
|
4576
|
+
A button, not a link: the window is built from the design as it
|
|
4577
|
+
stands rather than fetched from a URL, so it works on a report
|
|
4578
|
+
that has never been saved - which a link to the preview screen
|
|
4579
|
+
could not, because that screen reads the report off the disk.
|
|
4580
|
+
-->
|
|
4581
|
+
<button type="button" class="dz-tool" data-role="open-preview"
|
|
4582
|
+
data-action="open-window"
|
|
4583
|
+
title="Open the report in its own window"
|
|
4584
|
+
aria-label="Open the report in its own window"
|
|
4585
|
+
>${Z("external")}</button>
|
|
4586
|
+
</div>
|
|
4587
|
+
|
|
4588
|
+
<span class="dz-pages" data-role="pages"></span>
|
|
4589
|
+
<span class="dz-size" data-role="size">${t}</span>
|
|
4590
|
+
|
|
4591
|
+
<!--
|
|
4592
|
+
The same three controls the viewer has, in the same order and with
|
|
4593
|
+
the same shortcuts. A designer and a preview of the same report
|
|
4594
|
+
should not zoom differently.
|
|
4595
|
+
-->
|
|
4596
|
+
<div class="dz-bar-group dz-zoom-group">
|
|
4597
|
+
<button type="button" class="dz-tool" data-role="zoom-out"
|
|
4598
|
+
data-action="zoom-out"
|
|
4599
|
+
title="Zoom out (alt+Z)" aria-label="Zoom out">−</button>
|
|
4600
|
+
|
|
4601
|
+
<div class="dropdown" data-role="zoom-dropdown">
|
|
4602
|
+
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
4603
|
+
aria-haspopup="listbox" aria-expanded="false"
|
|
4604
|
+
aria-label="Zoom level">
|
|
4605
|
+
<span class="dropdown-value">100%</span>
|
|
4606
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
4607
|
+
</button>
|
|
4608
|
+
|
|
4609
|
+
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
4610
|
+
aria-label="Zoom level" hidden>
|
|
4611
|
+
<li class="dropdown-item" role="option" tabindex="-1"
|
|
4612
|
+
data-value="fit">Fit width</li>
|
|
4613
|
+
${re.map((e) => `
|
|
4614
|
+
<li class="dropdown-item" role="option" tabindex="-1"
|
|
4615
|
+
data-value="${e}"${e === 1 ? " data-selected=\"true\"" : ""}
|
|
4616
|
+
>${Math.round(e * 100)}%</li>`).join("")}
|
|
4617
|
+
</ul>
|
|
4618
|
+
</div>
|
|
4619
|
+
|
|
4620
|
+
<button type="button" class="dz-tool" data-role="zoom-in"
|
|
4621
|
+
data-action="zoom-in"
|
|
4622
|
+
title="Zoom in (Z)" aria-label="Zoom in">+</button>
|
|
4623
|
+
</div>
|
|
4624
|
+
</header>
|
|
4625
|
+
|
|
4626
|
+
<div class="dz-body">
|
|
4627
|
+
<div class="dz-main">
|
|
4628
|
+
<div class="dz-canvas" data-role="canvas">
|
|
4629
|
+
<!--
|
|
4630
|
+
Two boxes for one job. The inner one is scaled, and a
|
|
4631
|
+
transform changes nothing about layout - so at 200% there
|
|
4632
|
+
would be nothing to scroll. The outer one is given the
|
|
4633
|
+
scaled size in px, and is what the canvas scrolls.
|
|
4634
|
+
-->
|
|
4635
|
+
<div class="dz-stage" data-role="stage">
|
|
4636
|
+
<div class="dz-zoom-layer" data-role="zoom-layer"></div>
|
|
4637
|
+
</div>
|
|
4638
|
+
</div>
|
|
4639
|
+
|
|
4640
|
+
<!--
|
|
4641
|
+
The tools sit under the page rather than in the bar: the bar is
|
|
4642
|
+
about the report as a whole, and these act on the band you are
|
|
4643
|
+
looking at. Icon-only, so the strip stays out of the way of the
|
|
4644
|
+
thing being designed - the label lives on the button for a
|
|
4645
|
+
screen reader and in the tooltip for everyone else.
|
|
4646
|
+
-->
|
|
4647
|
+
<footer class="dz-foot" data-role="foot">
|
|
4648
|
+
<button type="button" class="dz-tool" data-action="add-text"
|
|
4649
|
+
title="Add a text box" aria-label="Add a text box"
|
|
4650
|
+
>${Z("text")}</button>
|
|
4651
|
+
<button type="button" class="dz-tool" data-role="add-table"
|
|
4652
|
+
data-action="add-table"
|
|
4653
|
+
title="Add a table" aria-label="Add a table"
|
|
4654
|
+
>${Z("table")}</button>
|
|
4655
|
+
<button type="button" class="dz-tool" data-action="add-line"
|
|
4656
|
+
title="Add a line" aria-label="Add a line"
|
|
4657
|
+
>${Z("line")}</button>
|
|
4658
|
+
<button type="button" class="dz-tool" data-action="add-box"
|
|
4659
|
+
title="Add a box" aria-label="Add a box"
|
|
4660
|
+
>${Z("box")}</button>
|
|
4661
|
+
<button type="button" class="dz-tool" data-action="add-image"
|
|
4662
|
+
title="Add an image" aria-label="Add an image"
|
|
4663
|
+
>${Z("image")}</button>
|
|
4664
|
+
<button type="button" class="dz-tool" data-action="add-field"
|
|
4665
|
+
title="Insert a page number, date or total"
|
|
4666
|
+
aria-label="Insert a field"
|
|
4667
|
+
>${Z("field")}</button>
|
|
4668
|
+
</footer>
|
|
4669
|
+
|
|
4670
|
+
<!--
|
|
4671
|
+
The corner messages, in the page area rather than the window.
|
|
4672
|
+
Pinned to the window they would hang over the properties rail -
|
|
4673
|
+
which is where the band switches are, and so where most of what
|
|
4674
|
+
the validator complains about is actually fixed.
|
|
4675
|
+
-->
|
|
4676
|
+
<div class="dz-toasts" data-role="toasts"></div>
|
|
4677
|
+
</div>
|
|
4678
|
+
|
|
4679
|
+
<aside class="dz-panel" data-role="panel" aria-label="Properties"></aside>
|
|
4680
|
+
</div>`;
|
|
4681
|
+
}
|
|
4682
|
+
function $i(e) {
|
|
4683
|
+
let t = String(e);
|
|
4684
|
+
return globalThis.CSS?.escape ? CSS.escape(t) : JSON.stringify(t).slice(1, -1);
|
|
4685
|
+
}
|
|
4686
|
+
function ea(e) {
|
|
4687
|
+
return e == null ? "" : String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
4688
|
+
}
|
|
4689
|
+
//#endregion
|
|
4690
|
+
export { Xi as n, Zi as t };
|