report-studio 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +238 -4
- package/dist/designer.js +3209 -0
- package/dist/index.js +2 -4
- package/dist/viewer-D-c0lKzQ.js +1576 -0
- package/package.json +66 -33
- package/src/asset/images/icon.png +0 -0
- package/src/asset/images/logo.png +0 -0
- package/src/cli/index.js +282 -0
- package/src/cli/serve.js +135 -0
- package/src/designer/blank.js +53 -0
- package/src/designer/canvas.js +518 -0
- package/src/designer/designer.js +1900 -0
- package/src/designer/dialog.js +708 -0
- package/src/designer/fields.js +584 -0
- package/src/designer/geometry.js +154 -0
- package/src/designer/guides.js +370 -0
- package/src/designer/history.js +113 -0
- package/src/designer/icons.js +118 -0
- package/src/designer/index.html +28 -0
- package/src/designer/main.js +39 -0
- package/src/designer/menu.js +126 -0
- package/src/designer/panel.js +478 -0
- package/src/designer/preview.js +95 -0
- package/src/designer/rulers.js +231 -0
- package/src/designer/sample-data.js +240 -0
- package/src/designer/select.js +699 -0
- package/src/designer/structure.js +604 -0
- package/src/designer/styles.css +1616 -0
- package/src/designer/toast.js +62 -0
- package/src/designer/tokens.js +284 -0
- package/src/engine/csv.js +315 -0
- package/src/engine/group.js +304 -0
- package/src/engine/index.js +34 -0
- package/src/engine/measure.js +390 -0
- package/src/engine/paginate.js +861 -0
- package/src/engine/regions.js +175 -0
- package/src/engine/resolve.js +171 -0
- package/src/engine/search.js +129 -0
- package/src/engine/text-metrics.js +206 -0
- package/src/engine/validate.js +328 -0
- package/src/index.html +79 -0
- package/src/index.js +50 -0
- package/src/preview/chrome.css +505 -0
- package/src/preview/chrome.js +147 -0
- package/src/preview/index.html +28 -0
- package/src/preview/main.js +66 -0
- package/src/preview/styles.css +16 -0
- package/src/preview/viewer.js +745 -0
- package/src/render/items.js +425 -0
- package/src/render/render.js +98 -0
- package/src/render/report.css +202 -0
- package/src/server/routes.js +331 -0
- package/src/shared/brand.css +29 -0
- package/src/shared/dropdown.css +136 -0
- package/src/shared/dropdown.js +166 -0
- package/src/shared/modal.css +125 -0
- package/src/shared/prefix.js +13 -0
- package/src/shared/store.js +145 -0
- package/src/shared/theme.css +72 -0
- package/src/shared/window.js +138 -0
- package/src/vite/index.js +53 -0
- package/dist/react.js +0 -4
|
@@ -0,0 +1,1576 @@
|
|
|
1
|
+
//#region src/engine/validate.js
|
|
2
|
+
var e = [
|
|
3
|
+
"reportHeader",
|
|
4
|
+
"pageHeader",
|
|
5
|
+
"groupHeader",
|
|
6
|
+
"detail",
|
|
7
|
+
"groupFooter",
|
|
8
|
+
"reportFooter",
|
|
9
|
+
"pageFooter"
|
|
10
|
+
], t = [
|
|
11
|
+
"text",
|
|
12
|
+
"table",
|
|
13
|
+
"line",
|
|
14
|
+
"box"
|
|
15
|
+
], n = ["horizontal", "vertical"], r = [
|
|
16
|
+
"solid",
|
|
17
|
+
"dashed",
|
|
18
|
+
"dotted",
|
|
19
|
+
"double"
|
|
20
|
+
], i = [...r, "none"], a = class extends Error {
|
|
21
|
+
constructor(e, t = []) {
|
|
22
|
+
super(t.length ? `${e}\n - ${t.join("\n - ")}` : e), this.name = "ReportError", this.issues = t;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function o(t) {
|
|
26
|
+
let n = [];
|
|
27
|
+
if (typeof t != "object" || !t || Array.isArray(t)) return ["layout must be an object"];
|
|
28
|
+
if (c(t.page, n), !Array.isArray(t.bands)) return n.push("layout.bands must be an array"), n;
|
|
29
|
+
t.bands.length === 0 && n.push("layout.bands is empty - there is nothing to render"), t.groupBy != null && typeof t.groupBy != "string" && n.push("layout.groupBy must be a field name or null");
|
|
30
|
+
let r = /* @__PURE__ */ new Set();
|
|
31
|
+
return t.bands.forEach((t, i) => {
|
|
32
|
+
let a = `bands[${i}]`;
|
|
33
|
+
if (typeof t != "object" || !t) {
|
|
34
|
+
n.push(`${a} must be an object`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (e.includes(t.type) ? r.has(t.type) ? n.push(`${a}.type "${t.type}" appears more than once; the engine places one band of each type`) : r.add(t.type) : n.push(`${a}.type "${t.type}" is not one of: ${e.join(", ")}`), !Array.isArray(t.items)) {
|
|
38
|
+
n.push(`${a}.items must be an array`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
t.items.forEach((e, t) => l(e, `${a}.items[${t}]`, n));
|
|
42
|
+
}), t.groupBy != null && !r.has("groupHeader") && !r.has("groupFooter") && n.push("layout.groupBy is set but there is no groupHeader or groupFooter band to show it"), s(t.bands, n), n;
|
|
43
|
+
}
|
|
44
|
+
function s(e, t) {
|
|
45
|
+
let n = [];
|
|
46
|
+
for (let t of e) if (Array.isArray(t?.items)) for (let e of t.items) e?.type === "table" && n.push(e.id ?? "(unnamed)");
|
|
47
|
+
n.length > 1 && t.push(`layout has ${n.length} tables (${n.map((e) => `"${e}"`).join(", ")}); a report binds one - the rest would print their header and no rows`);
|
|
48
|
+
}
|
|
49
|
+
function c(e, t) {
|
|
50
|
+
if (typeof e != "object" || !e) {
|
|
51
|
+
t.push("layout.page must be an object with width, height and margin");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (let n of ["width", "height"]) typeof e[n] == "number" && e[n] > 0 || t.push(`layout.page.${n} must be a positive number`);
|
|
55
|
+
if (e.margin == null || typeof e.margin != "object") {
|
|
56
|
+
t.push("layout.page.margin must be an object with top, right, bottom and left");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
for (let n of [
|
|
60
|
+
"top",
|
|
61
|
+
"right",
|
|
62
|
+
"bottom",
|
|
63
|
+
"left"
|
|
64
|
+
]) typeof e.margin[n] == "number" && e.margin[n] >= 0 || t.push(`layout.page.margin.${n} must be a number of pixels`);
|
|
65
|
+
let n = e.height - (e.margin.top + e.margin.bottom);
|
|
66
|
+
n <= 0 && t.push(`layout.page margins leave no printable height (${n}px)`);
|
|
67
|
+
}
|
|
68
|
+
function l(e, n, r) {
|
|
69
|
+
if (typeof e != "object" || !e) {
|
|
70
|
+
r.push(`${n} must be an object`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!t.includes(e.type)) {
|
|
74
|
+
r.push(`${n}.type "${e.type}" is not one of: ${t.join(", ")}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if ((typeof e.id != "string" || e.id === "") && r.push(`${n}.id must be a non-empty string`), e.type === "text") {
|
|
78
|
+
typeof e.value != "string" && r.push(`${n}.value must be a string`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (e.type === "line") {
|
|
82
|
+
d(e, n, r);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (e.type === "box") {
|
|
86
|
+
u(e, n, r);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (typeof e.rowHeight == "number" && e.rowHeight > 0 || r.push(`${n}.rowHeight must be a positive number`), e.style?.borderStyle != null && !i.includes(e.style.borderStyle) && r.push(`${n}.style.borderStyle "${e.style.borderStyle}" is not one of: ` + i.join(", ")), e.style?.borderWidth != null && !(typeof e.style.borderWidth == "number" && e.style.borderWidth > 0) && r.push(`${n}.style.borderWidth must be a positive number of pixels`), !Array.isArray(e.columns) || e.columns.length === 0) {
|
|
90
|
+
r.push(`${n}.columns must be a non-empty array`);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
e.columns.forEach((e, t) => {
|
|
94
|
+
(e == null || typeof e.field != "string" || e.field === "") && r.push(`${n}.columns[${t}].field must be a non-empty string`);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function u(e, t, n) {
|
|
98
|
+
let r = e.style;
|
|
99
|
+
if (r != null) {
|
|
100
|
+
if (typeof r != "object" || Array.isArray(r)) {
|
|
101
|
+
n.push(`${t}.style must be an object`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
r.borderStyle != null && !i.includes(r.borderStyle) && n.push(`${t}.style.borderStyle "${r.borderStyle}" is not one of: ` + i.join(", "));
|
|
105
|
+
for (let e of ["borderWidth", "radius"]) {
|
|
106
|
+
let i = r[e], a = e === "radius" ? 0 : 1;
|
|
107
|
+
i != null && !(typeof i == "number" && i >= a) && n.push(`${t}.style.${e} must be a number of pixels` + (a ? " greater than zero" : " of zero or more"));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function d(e, t, i) {
|
|
112
|
+
e.orientation != null && !n.includes(e.orientation) && i.push(`${t}.orientation "${e.orientation}" is not one of: ` + n.join(", "));
|
|
113
|
+
let a = e.style;
|
|
114
|
+
if (a != null) {
|
|
115
|
+
if (typeof a != "object" || Array.isArray(a)) {
|
|
116
|
+
i.push(`${t}.style must be an object`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
a.thickness != null && !(typeof a.thickness == "number" && a.thickness > 0) && i.push(`${t}.style.thickness must be a positive number of pixels`), a.lineStyle != null && !r.includes(a.lineStyle) && i.push(`${t}.style.lineStyle "${a.lineStyle}" is not one of: ` + r.join(", "));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function f(e, t) {
|
|
123
|
+
let n = o(e);
|
|
124
|
+
if (n.length) throw new a(`${t}: the layout file is not usable`, n);
|
|
125
|
+
}
|
|
126
|
+
function p(e, t) {
|
|
127
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw new a(`${t}: data must be an object keyed by dataset name`);
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/engine/resolve.js
|
|
131
|
+
var m = /\{([^{}]+)\}/g, h = /^\w+\(.*\)$/, g = ["page", "totalPages"], _ = ["groupHeader", "groupFooter"], v = m;
|
|
132
|
+
function y(e) {
|
|
133
|
+
return h.test(e) || g.includes(e) || e === "today";
|
|
134
|
+
}
|
|
135
|
+
function b(e) {
|
|
136
|
+
return _.includes(e);
|
|
137
|
+
}
|
|
138
|
+
function x(e, t) {
|
|
139
|
+
f(e, "resolve"), p(t, "resolve");
|
|
140
|
+
let n = structuredClone(e);
|
|
141
|
+
for (let e of n.bands) {
|
|
142
|
+
let n = _.includes(e.type);
|
|
143
|
+
for (let r of e.items) r.type == "text" && (r.text = S(r, t, n));
|
|
144
|
+
}
|
|
145
|
+
return n;
|
|
146
|
+
}
|
|
147
|
+
function S(e, t, n) {
|
|
148
|
+
return e.value.replace(m, (r, i) => C(r, i.trim(), t, e, n));
|
|
149
|
+
}
|
|
150
|
+
function C(e, t, n, r, i) {
|
|
151
|
+
if (h.test(t) || g.includes(t)) return e;
|
|
152
|
+
if (t == "today") return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
153
|
+
let a = w(t, n);
|
|
154
|
+
return a == null ? i ? e : (console.warn(`Unresolved placeholder "{${t}}" on item "${r.id}".`), "") : String(a);
|
|
155
|
+
}
|
|
156
|
+
function w(e, t) {
|
|
157
|
+
return e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((e) => e !== "").reduce((e, t) => e?.[t], t);
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/engine/group.js
|
|
161
|
+
var T = /\{([^{}]+)\}/g;
|
|
162
|
+
function E(e, t) {
|
|
163
|
+
let n = structuredClone(e);
|
|
164
|
+
return n.groupBy == null ? O(n, t) : D(n, t);
|
|
165
|
+
}
|
|
166
|
+
function D(e, t) {
|
|
167
|
+
let n = e.bands, r = ee(n);
|
|
168
|
+
if (!r) throw new a(`group: layout.groupBy is "${e.groupBy}" but no band contains a table to group`);
|
|
169
|
+
let i = k(r, e, t), o = P(i, e.groupBy), s = M(n, o);
|
|
170
|
+
return r.groups = Object.entries(o).map(([e, t]) => ({
|
|
171
|
+
key: e,
|
|
172
|
+
rows: t,
|
|
173
|
+
aggregates: s[e]
|
|
174
|
+
})), te(n, i), e;
|
|
175
|
+
}
|
|
176
|
+
function O(e, t) {
|
|
177
|
+
let n = e.bands, r = ee(n), i = r ? k(r, e, t) : [];
|
|
178
|
+
return r && (r.row = i), te(n, i), e;
|
|
179
|
+
}
|
|
180
|
+
function k(e, t, n) {
|
|
181
|
+
let r = e.dataset ?? t.dataset, i = n[r];
|
|
182
|
+
if (i === void 0) throw new a(`group: table "${e.id}" is bound to dataset "${r}", which is not present in the data`);
|
|
183
|
+
if (!Array.isArray(i)) throw new a(`group: dataset "${r}" must be an array of rows, got ${typeof i}`);
|
|
184
|
+
return i;
|
|
185
|
+
}
|
|
186
|
+
function ee(e) {
|
|
187
|
+
for (let t of e) for (let e of t.items) if (e.type == "table") return e;
|
|
188
|
+
}
|
|
189
|
+
var A = ["groupHeader", "groupFooter"];
|
|
190
|
+
function te(e, t) {
|
|
191
|
+
for (let n of e) if (!A.includes(n.type)) for (let e of n.items) e.type == "text" && (e.text = ne(e.text ?? e.value, t));
|
|
192
|
+
}
|
|
193
|
+
function ne(e, t) {
|
|
194
|
+
return e.replace(T, (e, n) => {
|
|
195
|
+
let r = j(n.trim());
|
|
196
|
+
if (!r) return e;
|
|
197
|
+
let i = F(r, t);
|
|
198
|
+
return i == null ? "" : String(i);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function j(e) {
|
|
202
|
+
let t = e.match(/^(\w+)\((.*?)\)$/);
|
|
203
|
+
return t ? {
|
|
204
|
+
key: t[1],
|
|
205
|
+
field: t[2].trim()
|
|
206
|
+
} : null;
|
|
207
|
+
}
|
|
208
|
+
function M(e, t) {
|
|
209
|
+
let n = {};
|
|
210
|
+
for (let e of Object.keys(t)) n[e] = {};
|
|
211
|
+
for (let r of e) if (A.includes(r.type)) {
|
|
212
|
+
for (let e of r.items) if (e.type == "text") for (let r of N(e.value)) for (let [e, i] of Object.entries(t)) n[e][r.field] || (n[e][r.field] = {
|
|
213
|
+
count: null,
|
|
214
|
+
sum: null,
|
|
215
|
+
avg: null,
|
|
216
|
+
min: null,
|
|
217
|
+
max: null
|
|
218
|
+
}), n[e][r.field][r.key] = F(r, i);
|
|
219
|
+
}
|
|
220
|
+
return n;
|
|
221
|
+
}
|
|
222
|
+
function N(e) {
|
|
223
|
+
let t = [];
|
|
224
|
+
for (let [, n] of e.matchAll(T)) {
|
|
225
|
+
let e = j(n.trim());
|
|
226
|
+
e && t.push(e);
|
|
227
|
+
}
|
|
228
|
+
return t;
|
|
229
|
+
}
|
|
230
|
+
function P(e, t) {
|
|
231
|
+
let n = {};
|
|
232
|
+
for (let r of e) {
|
|
233
|
+
let e = r[t];
|
|
234
|
+
n[e] || (n[e] = []), n[e].push(r);
|
|
235
|
+
}
|
|
236
|
+
return n;
|
|
237
|
+
}
|
|
238
|
+
function F(e, t) {
|
|
239
|
+
if (e.key === "count") return t.length;
|
|
240
|
+
let n = t.map((t) => t?.[e.field]).filter((e) => e != null && e !== "").map(Number).filter((e) => Number.isFinite(e));
|
|
241
|
+
switch (e.key) {
|
|
242
|
+
case "sum": return n.length ? I(n.reduce((e, t) => e + t, 0)) : null;
|
|
243
|
+
case "avg": return n.length ? I(n.reduce((e, t) => e + t, 0) / n.length) : null;
|
|
244
|
+
case "max": return n.length ? Math.max(...n) : null;
|
|
245
|
+
case "min": return n.length ? Math.min(...n) : null;
|
|
246
|
+
default: return console.warn(`Unknown aggregate "${e.key}()"; it has no value.`), null;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function I(e) {
|
|
250
|
+
return Number(e.toPrecision(12));
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/engine/text-metrics.js
|
|
254
|
+
var L = 1.3, R = /* @__PURE__ */ new Map(), z = 1e4, B, re = !1;
|
|
255
|
+
function ie() {
|
|
256
|
+
if (re) return B;
|
|
257
|
+
re = !0;
|
|
258
|
+
try {
|
|
259
|
+
B = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
|
|
260
|
+
} catch {
|
|
261
|
+
B = null;
|
|
262
|
+
}
|
|
263
|
+
return B;
|
|
264
|
+
}
|
|
265
|
+
function ae(e = {}) {
|
|
266
|
+
return `${e.fontStyle || "normal"} ${e.fontWeight || "normal"} ${e.fontSize ?? 12}px ${e.fontFamily || "Helvetica, Arial, sans-serif"}`;
|
|
267
|
+
}
|
|
268
|
+
function V(e, t) {
|
|
269
|
+
let n = String(e ?? "");
|
|
270
|
+
if (n === "") return 0;
|
|
271
|
+
let r = ae(t), i = `${r}\u0000${n}`, a = R.get(i);
|
|
272
|
+
if (a !== void 0) return a;
|
|
273
|
+
let o = ie(), s;
|
|
274
|
+
return o ? (o.font = r, s = o.measureText(n).width) : s = oe(n, t), R.size >= z && R.clear(), R.set(i, s), s;
|
|
275
|
+
}
|
|
276
|
+
function oe(e, t = {}) {
|
|
277
|
+
let n = t.fontSize ?? 12, r = String(t.fontWeight) === "bold" || Number(t.fontWeight) >= 600, i = /mono|courier|consolas/i.test(t.fontFamily || ""), a = 0;
|
|
278
|
+
for (let t of e) {
|
|
279
|
+
if (i) {
|
|
280
|
+
a += .6;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
t === " " ? a += .26 : /[iljI.,:;'`|!\[\]()]/.test(t) ? a += .28 : /[ftr]/.test(t) ? a += .34 : /[A-Z]/.test(t) ? a += .68 : /[mwMW@]/.test(t) ? a += .88 : /[0-9]/.test(t) ? a += .56 : a += .52;
|
|
284
|
+
}
|
|
285
|
+
return a * n * (r ? 1.06 : 1);
|
|
286
|
+
}
|
|
287
|
+
function H(e, t, n) {
|
|
288
|
+
let r = String(e ?? "").split("\n");
|
|
289
|
+
if (!(t > 0)) return r;
|
|
290
|
+
let i = [];
|
|
291
|
+
for (let e of r) {
|
|
292
|
+
let r = e.split(/(\s+)/).filter((e) => e !== "");
|
|
293
|
+
if (r.length === 0) {
|
|
294
|
+
i.push("");
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
let a = "";
|
|
298
|
+
for (let e of r) {
|
|
299
|
+
let r = a + e;
|
|
300
|
+
for (a !== "" && V(r, n) > t ? (i.push(a.trimEnd()), a = e.trimStart()) : a = r; V(a, n) > t && a.trim().length > 1;) {
|
|
301
|
+
let e = a.length;
|
|
302
|
+
for (; e > 1 && V(a.slice(0, e), n) > t;) e--;
|
|
303
|
+
if (e >= a.length) break;
|
|
304
|
+
i.push(a.slice(0, e)), a = a.slice(e);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
i.push(a.trimEnd());
|
|
308
|
+
}
|
|
309
|
+
return i;
|
|
310
|
+
}
|
|
311
|
+
function se(e, t, n) {
|
|
312
|
+
let r = Math.ceil((n?.fontSize ?? 12) * L);
|
|
313
|
+
return H(e, t, n).length * r;
|
|
314
|
+
}
|
|
315
|
+
function ce(e) {
|
|
316
|
+
return {
|
|
317
|
+
fontSize: e.style?.fontSize ?? 12,
|
|
318
|
+
fontFamily: e.style?.fontFamily,
|
|
319
|
+
fontWeight: "normal",
|
|
320
|
+
fontStyle: "normal"
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function le(e) {
|
|
324
|
+
let t = (e.columns ?? []).map((e) => e.width ?? 0), n = t.reduce((e, t) => e + t, 0), r = e.w ?? n, i = n > 0 && r > n ? r / n : 1;
|
|
325
|
+
return t.map((e) => e * i);
|
|
326
|
+
}
|
|
327
|
+
function ue(e) {
|
|
328
|
+
if (e.style?.borderStyle === "none") return 0;
|
|
329
|
+
let t = Number(e.style?.borderWidth);
|
|
330
|
+
return Number.isFinite(t) && t > 0 ? t : 1;
|
|
331
|
+
}
|
|
332
|
+
function de(e) {
|
|
333
|
+
let t = le(e), n = ue(e), r = t.length - 1;
|
|
334
|
+
return t.map((e, t) => e - 16 - n * (t === r ? 2 : 1));
|
|
335
|
+
}
|
|
336
|
+
function fe(e, t) {
|
|
337
|
+
let n = e.rowHeight ?? 0, r = t ?? [];
|
|
338
|
+
if (e.wrap === !1) return r.map(() => n);
|
|
339
|
+
let i = ce(e), a = e.columns ?? [], o = de(e);
|
|
340
|
+
return r.map((e) => {
|
|
341
|
+
let t = n;
|
|
342
|
+
for (let [n, r] of a.entries()) {
|
|
343
|
+
let a = o[n];
|
|
344
|
+
if (!(a > 0)) continue;
|
|
345
|
+
let s = e?.[r.field];
|
|
346
|
+
s == null || s === "" || (t = Math.max(t, se(String(s), a, i)));
|
|
347
|
+
}
|
|
348
|
+
return t;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function U(e) {
|
|
352
|
+
if (!e.showHeader) return 0;
|
|
353
|
+
let t = e.headerHeight ?? e.rowHeight ?? 0;
|
|
354
|
+
if (e.wrap === !1) return t;
|
|
355
|
+
let n = (e.columns ?? []).map((e, t) => ({
|
|
356
|
+
...e,
|
|
357
|
+
field: `label${t}`
|
|
358
|
+
})), r = Object.fromEntries((e.columns ?? []).map((e, t) => [`label${t}`, e.label])), [i] = fe({
|
|
359
|
+
...e,
|
|
360
|
+
rowHeight: t,
|
|
361
|
+
columns: n
|
|
362
|
+
}, [r]);
|
|
363
|
+
return i ?? t;
|
|
364
|
+
}
|
|
365
|
+
function pe(e) {
|
|
366
|
+
if (e.type !== "table") return e.h ?? 0;
|
|
367
|
+
let t = e.rowHeight ?? 0;
|
|
368
|
+
return (e.showHeader ? e.headerHeight ?? t : 0) + 3 * t;
|
|
369
|
+
}
|
|
370
|
+
function me(e) {
|
|
371
|
+
let t = structuredClone(e), n = t.groupBy != null;
|
|
372
|
+
for (let e of t.bands) e.items && he(e, n, t);
|
|
373
|
+
return t;
|
|
374
|
+
}
|
|
375
|
+
function he(e, t, n) {
|
|
376
|
+
let r = 0;
|
|
377
|
+
for (let i of e.items) i.measuredHeight = _e(i, t, n), r = Math.max(r, (i.y ?? 0) + i.measuredHeight);
|
|
378
|
+
return e.contentHeight = r, e.measuredHeight = ge(e) ? r : Math.max(e.height ?? 0, r), e;
|
|
379
|
+
}
|
|
380
|
+
function ge(e) {
|
|
381
|
+
return e.items.some((e) => e.type === "table");
|
|
382
|
+
}
|
|
383
|
+
function _e(e, t, n) {
|
|
384
|
+
switch (e.type) {
|
|
385
|
+
case "text": return ve(e);
|
|
386
|
+
case "table": return be(e, t, n);
|
|
387
|
+
case "line": return ye(e);
|
|
388
|
+
case "box": return e.h ?? 0;
|
|
389
|
+
default: return console.warn(`Unknown item type "${e.type}" on item "${e.id}"; treating as zero height.`), 0;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function ve(e) {
|
|
393
|
+
let t = e.h ?? 0, n = se(e.text ?? e.value ?? "", e.w ?? 0, e.style);
|
|
394
|
+
return Math.max(t, n);
|
|
395
|
+
}
|
|
396
|
+
function ye(e) {
|
|
397
|
+
let t = e.h ?? 0;
|
|
398
|
+
return e.orientation === "vertical" ? t : Math.max(t, e.style?.thickness ?? 0);
|
|
399
|
+
}
|
|
400
|
+
function be(e, t, n) {
|
|
401
|
+
let r = U(e);
|
|
402
|
+
if (e.headerMeasured = r, !t) return e.rowHeights = fe(e, e.row), r + W(e.rowHeights);
|
|
403
|
+
let i = e.groups ?? [], a = xe(n, "groupHeader"), o = xe(n, "groupFooter"), s = 0;
|
|
404
|
+
for (let t of i) t.rowHeights = fe(e, t.rows), s += r + a + W(t.rowHeights) + o;
|
|
405
|
+
return s;
|
|
406
|
+
}
|
|
407
|
+
function W(e) {
|
|
408
|
+
return (e ?? []).reduce((e, t) => e + t, 0);
|
|
409
|
+
}
|
|
410
|
+
function xe(e, t) {
|
|
411
|
+
let n = e.bands.find((e) => e.type === t);
|
|
412
|
+
if (!n?.items) return 0;
|
|
413
|
+
let r = 0;
|
|
414
|
+
for (let e of n.items) {
|
|
415
|
+
let t = e.type === "text" ? ve(e) : 0;
|
|
416
|
+
r = Math.max(r, (e.y ?? 0) + t);
|
|
417
|
+
}
|
|
418
|
+
return Math.max(n.height ?? 0, r);
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/engine/regions.js
|
|
422
|
+
var Se = {
|
|
423
|
+
pageHeader: "10%",
|
|
424
|
+
reportHeader: "10%",
|
|
425
|
+
reportFooter: "10%",
|
|
426
|
+
pageFooter: "10%"
|
|
427
|
+
}, Ce = ["pageHeader", "reportHeader"], we = ["reportFooter", "pageFooter"];
|
|
428
|
+
function Te(e, t, n) {
|
|
429
|
+
let r = Ee(e, t);
|
|
430
|
+
return r === null ? Ee(n, t) ?? 0 : r;
|
|
431
|
+
}
|
|
432
|
+
function Ee(e, t) {
|
|
433
|
+
if (typeof e == "number" && Number.isFinite(e) && e >= 0) return e;
|
|
434
|
+
if (typeof e == "string") {
|
|
435
|
+
let n = e.trim().match(/^(-?[\d.]+)\s*%$/);
|
|
436
|
+
if (n) {
|
|
437
|
+
let e = Number(n[1]);
|
|
438
|
+
return Number.isFinite(e) && e >= 0 ? e / 100 * t : null;
|
|
439
|
+
}
|
|
440
|
+
let r = Number(e.trim().replace(/px$/i, ""));
|
|
441
|
+
if (Number.isFinite(r) && r >= 0) return r;
|
|
442
|
+
}
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
function G(e, t) {
|
|
446
|
+
if (!e) return 0;
|
|
447
|
+
let n = Te(e.height, t, Se[e.type]), r = e.measuredHeight ?? 0;
|
|
448
|
+
return r > n ? (console.warn(`Band "${e.type}" needs ${Math.ceil(r)}px but its zone is ${Math.round(n)}px; the zone has been grown to fit.`), r) : n;
|
|
449
|
+
}
|
|
450
|
+
function De({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
|
|
451
|
+
let i = {}, a = (e) => e === "reportHeader" ? n : e !== "reportFooter" || r, o = 0;
|
|
452
|
+
for (let n of Ce) {
|
|
453
|
+
let r = e[n];
|
|
454
|
+
if (!r || !a(n)) continue;
|
|
455
|
+
let s = G(r, t);
|
|
456
|
+
i[n] = {
|
|
457
|
+
top: o,
|
|
458
|
+
height: s
|
|
459
|
+
}, o += s;
|
|
460
|
+
}
|
|
461
|
+
let s = o, c = t;
|
|
462
|
+
for (let n of [...we].reverse()) {
|
|
463
|
+
let r = e[n];
|
|
464
|
+
if (!r || !a(n)) continue;
|
|
465
|
+
let o = G(r, t);
|
|
466
|
+
c -= o, i[n] = {
|
|
467
|
+
top: c,
|
|
468
|
+
height: o
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return i.detail = {
|
|
472
|
+
top: s,
|
|
473
|
+
height: Math.max(c - s, 0)
|
|
474
|
+
}, i;
|
|
475
|
+
}
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/engine/paginate.js
|
|
478
|
+
var Oe = /\{([^{}]+)\}/g, ke = ["page", "totalPages"];
|
|
479
|
+
function Ae(e) {
|
|
480
|
+
let t = structuredClone(e), n = {
|
|
481
|
+
page: t.page,
|
|
482
|
+
bands: t.bands,
|
|
483
|
+
group: t.groupBy,
|
|
484
|
+
assignedBands: {
|
|
485
|
+
reportHeader: t.bands.find((e) => e.type === "reportHeader"),
|
|
486
|
+
reportFooter: t.bands.find((e) => e.type === "reportFooter"),
|
|
487
|
+
pageHeader: t.bands.find((e) => e.type === "pageHeader"),
|
|
488
|
+
pageFooter: t.bands.find((e) => e.type === "pageFooter"),
|
|
489
|
+
detail: t.bands.find((e) => e.type === "detail"),
|
|
490
|
+
groupHeader: t.bands.find((e) => e.type === "groupHeader") || null,
|
|
491
|
+
groupFooter: t.bands.find((e) => e.type === "groupFooter") || null
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
return n.availableHeight = ze(t.page), n.regionsFor = (e, t) => De({
|
|
495
|
+
bands: n.assignedBands,
|
|
496
|
+
contentHeight: n.availableHeight,
|
|
497
|
+
isFirstPage: e === 1,
|
|
498
|
+
isLastPage: t
|
|
499
|
+
}), t.pages = Be(Pe(t.bands.filter((e) => ![
|
|
500
|
+
"reportHeader",
|
|
501
|
+
"reportFooter",
|
|
502
|
+
"pageHeader",
|
|
503
|
+
"pageFooter",
|
|
504
|
+
"groupHeader",
|
|
505
|
+
"groupFooter"
|
|
506
|
+
].includes(e.type)), n)), t;
|
|
507
|
+
}
|
|
508
|
+
function je(e, t, n, r = Infinity) {
|
|
509
|
+
let i = 0, a = 0;
|
|
510
|
+
for (; t + a < e.length && a < r;) {
|
|
511
|
+
let r = i + e[t + a];
|
|
512
|
+
if (r > n) break;
|
|
513
|
+
i = r, a++;
|
|
514
|
+
}
|
|
515
|
+
return a;
|
|
516
|
+
}
|
|
517
|
+
function Me(e, t, n) {
|
|
518
|
+
return W(e.slice(t, t + n));
|
|
519
|
+
}
|
|
520
|
+
function Ne(e, t, n) {
|
|
521
|
+
return Array.isArray(n) && n.length === (t ?? []).length ? n : (t ?? []).map(() => e.rowHeight ?? 0);
|
|
522
|
+
}
|
|
523
|
+
function Pe(e, t) {
|
|
524
|
+
let n = [], r = Re(1, t);
|
|
525
|
+
n.push(r);
|
|
526
|
+
let { assignedBands: i, availableHeight: a, group: o } = t, { reportFooter: s, reportHeader: c, groupHeader: l, groupFooter: u, pageHeader: d, pageFooter: f } = i, p = t.regionsFor(2, !1).detail.height;
|
|
527
|
+
c && r.regions.detail.height <= 0 && console.warn("The header zones leave no room for detail on page 1. Reduce the reportHeader or pageHeader height.");
|
|
528
|
+
let m = 0, h = 0, g = [], _ = () => r.regions.detail.height, v = (e, i, a) => (e.items.length > 0 && r.bands.push(e), r = Re(n.length + 1, t), n.push(r), m = 0, h = a, g = [], {
|
|
529
|
+
...i,
|
|
530
|
+
items: []
|
|
531
|
+
}), y = (e, t) => {
|
|
532
|
+
e.items.push(t), m = Math.max(m, (t.y ?? 0) + (t.measuredHeight ?? 0)), e.measuredHeight = m, r.usedHeight = a - _() + m;
|
|
533
|
+
}, b = (e) => {
|
|
534
|
+
let t = -Infinity, n = -Infinity;
|
|
535
|
+
for (let r of g) r.designBottom > e || (t = Math.max(t, r.designBottom), n = Math.max(n, r.actualBottom));
|
|
536
|
+
return t === -Infinity ? 0 : n - t;
|
|
537
|
+
}, x = (e) => {
|
|
538
|
+
let t = e - h;
|
|
539
|
+
return t + b(t);
|
|
540
|
+
};
|
|
541
|
+
for (let t of e) {
|
|
542
|
+
let e = {
|
|
543
|
+
...t,
|
|
544
|
+
items: []
|
|
545
|
+
};
|
|
546
|
+
h = 0, g = [];
|
|
547
|
+
let n = [...t.items].sort((e, t) => (e.y ?? 0) - (t.y ?? 0));
|
|
548
|
+
for (let r of n) {
|
|
549
|
+
let n = r.y ?? 0, i = x(n) + r.measuredHeight;
|
|
550
|
+
if (i > _() && r.type != "table") r.measuredHeight > p ? console.warn(`Item "${r.id}" is ${Math.ceil(r.measuredHeight)}px tall, past the ${p}px detail zone of an empty page; it will overflow.`) : e = v(e, t, n), y(e, {
|
|
551
|
+
...structuredClone(r),
|
|
552
|
+
y: x(n)
|
|
553
|
+
});
|
|
554
|
+
else if (i > _() && r.type == "table") {
|
|
555
|
+
let i = n - h;
|
|
556
|
+
if (o !== null) {
|
|
557
|
+
let a = l?.measuredHeight ?? 0, o = u?.measuredHeight ?? 0, s = r.headerMeasured ?? U(r), c = Math.max(r.rowHeight ?? 0, ...(r.groups ?? []).flatMap((e) => Ne(r, e.rows, e.rowHeights))), d = s + a + c + o;
|
|
558
|
+
d <= p || console.warn(`Table "${r.id}": table header + group header + one row + group footer (${d}px) exceeds the ${p}px printable page. Falling back to one row per page; rows will overflow their page.`);
|
|
559
|
+
let f = (e, t, n, r) => {
|
|
560
|
+
let i = n - a - s;
|
|
561
|
+
return r <= je(e, t, i - o, r) ? r : Math.min(je(e, t, i, r), r - 1);
|
|
562
|
+
}, m = [], h = 0;
|
|
563
|
+
for (let c of r.groups) {
|
|
564
|
+
let d = 0, g = c.rows.length, b = Ne(r, c.rows, c.rowHeights);
|
|
565
|
+
for (; d < g;) {
|
|
566
|
+
let x = _() - i - h, S = m.length === 0 && e.items.length === 0 && i === 0 && _() >= p, C = f(b, d, x, g - d);
|
|
567
|
+
if (C < 1 && S && (C = 1), C < 1) {
|
|
568
|
+
if (m.length > 0) {
|
|
569
|
+
let t = structuredClone(r);
|
|
570
|
+
t.groups = m, t.y = i, t.measuredHeight = h, y(e, t);
|
|
571
|
+
}
|
|
572
|
+
e = v(e, t, n), m = [], h = 0, i = 0;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
let w = c.rows.slice(d, d + C), T = b.slice(d, d + C);
|
|
576
|
+
d += w.length;
|
|
577
|
+
let E = d < g, D = W(T) + (a + s) + (E ? 0 : o);
|
|
578
|
+
h += D;
|
|
579
|
+
let O = {
|
|
580
|
+
key: c.key,
|
|
581
|
+
rows: w,
|
|
582
|
+
rowHeights: T,
|
|
583
|
+
aggregates: c.aggregates,
|
|
584
|
+
showHeader: !0,
|
|
585
|
+
showFooter: !E,
|
|
586
|
+
headerBand: K(l, c, w[0]),
|
|
587
|
+
footerBand: E ? null : K(u, c, w[0])
|
|
588
|
+
};
|
|
589
|
+
m.push(O);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (m.length > 0) {
|
|
593
|
+
let t = structuredClone(r);
|
|
594
|
+
t.groups = m, t.y = i, t.measuredHeight = h, y(e, t), m = [];
|
|
595
|
+
}
|
|
596
|
+
} else {
|
|
597
|
+
let a = r.row.length, o = 0, s = r.headerMeasured ?? U(r), c = Ne(r, r.row, r.rowHeights), l = Math.max(r.rowHeight ?? 0, ...c);
|
|
598
|
+
for (p - s >= l || console.warn(`Table "${r.id}": its tallest row is ${Math.ceil(l)}px, which with the ${s}px header exceeds the ${p}px printable page. Falling back to one row per page; rows will overflow their page.`); o < a;) {
|
|
599
|
+
let l = _() - i, u = je(c, o, l - s, a - o), d = e.items.length === 0 && i === 0 && _() >= p;
|
|
600
|
+
if (u < 1 && d && (u = 1), u < 1) {
|
|
601
|
+
e = v(e, t, n), i = 0;
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
u = Math.min(u, a - o);
|
|
605
|
+
let f = structuredClone(r), m = r.row.slice(o, o + u), h = Me(c, o, u) + s;
|
|
606
|
+
f.row = m, f.rowHeights = c.slice(o, o + u), f.y = i, f.measuredHeight = h, y(e, f), o += m.length, o < a && (e = v(e, t, n), i = 0);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
} else {
|
|
610
|
+
let t = r.type === "table" && r.groups ? {
|
|
611
|
+
...r,
|
|
612
|
+
groups: Ie(r, l, u)
|
|
613
|
+
} : r;
|
|
614
|
+
y(e, {
|
|
615
|
+
...structuredClone(t),
|
|
616
|
+
y: x(n)
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
let a = [...e.items].reverse().find((e) => e.id === r.id);
|
|
620
|
+
a && g.push({
|
|
621
|
+
designBottom: n - h + pe(r),
|
|
622
|
+
actualBottom: (a.y ?? 0) + (a.measuredHeight ?? 0)
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
e.items.length > 0 && (r.bands.push(e), e = {
|
|
626
|
+
...t,
|
|
627
|
+
items: []
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
if (s) {
|
|
631
|
+
let e = G(s, a);
|
|
632
|
+
r.usedHeight + e > a && (r = Re(n.length + 1, t), n.push(r)), r.bands.push(structuredClone(s)), r.usedHeight += e;
|
|
633
|
+
}
|
|
634
|
+
let S = n[n.length - 1];
|
|
635
|
+
return S.regions = t.regionsFor(S.pageNO, !!s), Fe(n), n;
|
|
636
|
+
}
|
|
637
|
+
function Fe(e) {
|
|
638
|
+
for (let t of e) for (let e of t.bands) {
|
|
639
|
+
let n = t.regions[e.type] ?? t.regions.detail;
|
|
640
|
+
e.top = n.top, e.zoneHeight = n.height;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function Ie(e, t, n) {
|
|
644
|
+
return e.groups.map((e) => ({
|
|
645
|
+
key: e.key,
|
|
646
|
+
rows: e.rows,
|
|
647
|
+
rowHeights: e.rowHeights,
|
|
648
|
+
aggregates: e.aggregates,
|
|
649
|
+
showHeader: !0,
|
|
650
|
+
showFooter: !0,
|
|
651
|
+
headerBand: K(t, e, e.rows[0]),
|
|
652
|
+
footerBand: K(n, e, e.rows[0])
|
|
653
|
+
}));
|
|
654
|
+
}
|
|
655
|
+
function K(e, t, n) {
|
|
656
|
+
if (!e) return null;
|
|
657
|
+
let r = structuredClone(e);
|
|
658
|
+
for (let e of r.items) e.type === "text" && (e.text = (e.text ?? e.value).replace(Oe, (e, r) => Le(e, r.trim(), t, n)));
|
|
659
|
+
return r;
|
|
660
|
+
}
|
|
661
|
+
function Le(e, t, n, r) {
|
|
662
|
+
if (ke.includes(t)) return e;
|
|
663
|
+
let i = t.match(/^(\w+)\((.*?)\)$/);
|
|
664
|
+
if (i) {
|
|
665
|
+
let [, e, t] = i, r = n.aggregates?.[t]?.[e.trim()];
|
|
666
|
+
return r == null ? "" : String(r);
|
|
667
|
+
}
|
|
668
|
+
let a = r?.[t];
|
|
669
|
+
return a == null ? "" : String(a);
|
|
670
|
+
}
|
|
671
|
+
function Re(e, t) {
|
|
672
|
+
let { pageHeader: n, pageFooter: r, reportHeader: i } = t.assignedBands, a = t.regionsFor(e, !1), o = [];
|
|
673
|
+
return n && o.push(structuredClone(n)), r && o.push(structuredClone(r)), i && e === 1 && o.push(structuredClone(i)), {
|
|
674
|
+
pageNO: e,
|
|
675
|
+
bands: o,
|
|
676
|
+
regions: a,
|
|
677
|
+
usedHeight: t.availableHeight - a.detail.height
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function ze(e) {
|
|
681
|
+
return e.height - (e.margin.top + e.margin.bottom);
|
|
682
|
+
}
|
|
683
|
+
function Be(e) {
|
|
684
|
+
for (let t of e) for (let n of t.bands) Ve(n, t.pageNO, e.length);
|
|
685
|
+
return e;
|
|
686
|
+
}
|
|
687
|
+
function Ve(e, t, n) {
|
|
688
|
+
for (let r of e?.items ?? []) {
|
|
689
|
+
if (r.type === "text") {
|
|
690
|
+
let e = r.text ?? r.value ?? "";
|
|
691
|
+
if (!e.includes("{")) continue;
|
|
692
|
+
r.text = e.replace(Oe, (e, r) => {
|
|
693
|
+
switch (r.trim()) {
|
|
694
|
+
case "page": return t;
|
|
695
|
+
case "totalPages": return n;
|
|
696
|
+
default: return e;
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
if (r.type === "table" && r.groups) for (let e of r.groups) Ve(e.headerBand, t, n), Ve(e.footerBand, t, n);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/engine/search.js
|
|
706
|
+
function He(e, t, { caseSensitive: n = !1 } = {}) {
|
|
707
|
+
let r = String(t ?? "");
|
|
708
|
+
if (r === "") return [];
|
|
709
|
+
let i = [];
|
|
710
|
+
for (let t of e ?? []) for (let e of t.bands ?? []) We(e, t.pageNO, e.type, r, n, i);
|
|
711
|
+
return i;
|
|
712
|
+
}
|
|
713
|
+
function Ue(e, t, n) {
|
|
714
|
+
return [...new Set(He(e, t, n).map((e) => e.pageNO))];
|
|
715
|
+
}
|
|
716
|
+
function We(e, t, n, r, i, a) {
|
|
717
|
+
for (let o of e?.items ?? []) {
|
|
718
|
+
if (o.type === "text") {
|
|
719
|
+
qe(a, o.text, {
|
|
720
|
+
pageNO: t,
|
|
721
|
+
bandType: n,
|
|
722
|
+
itemId: o.id,
|
|
723
|
+
field: null
|
|
724
|
+
}, r, i);
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
o.type === "table" && Ge(o, t, n, r, i, a);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function Ge(e, t, n, r, i, a) {
|
|
731
|
+
let o = e.columns ?? [];
|
|
732
|
+
if (e.showHeader) for (let s of o) qe(a, s.label, {
|
|
733
|
+
pageNO: t,
|
|
734
|
+
bandType: n,
|
|
735
|
+
itemId: e.id,
|
|
736
|
+
field: s.field
|
|
737
|
+
}, r, i);
|
|
738
|
+
if (e.row) {
|
|
739
|
+
Ke(e.row, o, e.id, t, n, r, i, a);
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
for (let s of e.groups ?? []) We(s.headerBand, t, "groupHeader", r, i, a), Ke(s.rows, o, e.id, t, n, r, i, a), s.showFooter && We(s.footerBand, t, "groupFooter", r, i, a);
|
|
743
|
+
}
|
|
744
|
+
function Ke(e, t, n, r, i, a, o, s) {
|
|
745
|
+
for (let c of e ?? []) for (let e of t) qe(s, c?.[e.field], {
|
|
746
|
+
pageNO: r,
|
|
747
|
+
bandType: i,
|
|
748
|
+
itemId: n,
|
|
749
|
+
field: e.field
|
|
750
|
+
}, a, o);
|
|
751
|
+
}
|
|
752
|
+
function qe(e, t, n, r, i) {
|
|
753
|
+
if (t == null) return;
|
|
754
|
+
let a = String(t), o = i ? a : a.toLowerCase(), s = i ? r : r.toLowerCase(), c = 0;
|
|
755
|
+
for (; c <= o.length - s.length;) {
|
|
756
|
+
let t = o.indexOf(s, c);
|
|
757
|
+
if (t === -1) break;
|
|
758
|
+
e.push({
|
|
759
|
+
...n,
|
|
760
|
+
text: a,
|
|
761
|
+
start: t,
|
|
762
|
+
end: t + s.length
|
|
763
|
+
}), c = t + s.length;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/engine/csv.js
|
|
768
|
+
var Je = /^[=+\-@\t\r]/;
|
|
769
|
+
function Ye(e, t = {}) {
|
|
770
|
+
let { delimiter: n = ",", newline: r = "\r\n", header: i = !0, groupColumn: a = !0, groupLabel: o = "Group", neutraliseFormulas: s = !0 } = t, c = nt(e);
|
|
771
|
+
if (!c) return "";
|
|
772
|
+
let l = a && c.rows.some((e) => e.group !== null), u = c.columns.map((e) => e.label ?? e.field), d = [];
|
|
773
|
+
i && d.push(rt(l ? [o, ...u] : u, n, s));
|
|
774
|
+
for (let { group: e, row: t } of c.rows) {
|
|
775
|
+
let r = c.columns.map((e) => t?.[e.field]);
|
|
776
|
+
d.push(rt(l ? [e, ...r] : r, n, s));
|
|
777
|
+
}
|
|
778
|
+
return d.join(r);
|
|
779
|
+
}
|
|
780
|
+
function Xe(e, t = {}) {
|
|
781
|
+
let { delimiter: n = ",", newline: r = "\r\n", neutraliseFormulas: i = !0 } = t, a = [];
|
|
782
|
+
for (let t of e ?? []) for (let e of Ze(t?.bands)) Qe(e, a);
|
|
783
|
+
return a.length === 0 ? "" : a.map((e) => rt(e, n, i)).join(r);
|
|
784
|
+
}
|
|
785
|
+
function Ze(e) {
|
|
786
|
+
return [...e ?? []].sort((e, t) => (e?.top ?? 0) - (t?.top ?? 0));
|
|
787
|
+
}
|
|
788
|
+
function Qe(e, t) {
|
|
789
|
+
let n = (e?.items ?? []).filter((e) => e?.type === "text" || e?.type === "table").sort((e, t) => (e.y ?? 0) - (t.y ?? 0) || (e.x ?? 0) - (t.x ?? 0)), r = null, i = () => {
|
|
790
|
+
r && t.push(r.cells), r = null;
|
|
791
|
+
};
|
|
792
|
+
for (let e of n) {
|
|
793
|
+
if (e.type === "table") {
|
|
794
|
+
i(), et(e, t);
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
if (r && $e(r.anchor, e)) {
|
|
798
|
+
r.cells.push(e.text);
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
i(), r = {
|
|
802
|
+
anchor: e,
|
|
803
|
+
cells: [e.text]
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
i();
|
|
807
|
+
}
|
|
808
|
+
function $e(e, t) {
|
|
809
|
+
let n = (e) => {
|
|
810
|
+
let t = e.y ?? 0;
|
|
811
|
+
return [t, t + (e.measuredHeight ?? e.h ?? 0)];
|
|
812
|
+
}, [r, i] = n(e), [a, o] = n(t);
|
|
813
|
+
return Math.min(i, o) - Math.max(r, a) >= Math.min(i - r, o - a) / 2;
|
|
814
|
+
}
|
|
815
|
+
function et(e, t) {
|
|
816
|
+
let n = () => e.columns.map((e) => e.label ?? e.field), r = (t) => e.columns.map((e) => t?.[e.field]);
|
|
817
|
+
if (!e.groups) {
|
|
818
|
+
e.showHeader && t.push(n());
|
|
819
|
+
for (let n of e.row ?? []) t.push(r(n));
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
for (let i of e.groups) {
|
|
823
|
+
i.showHeader && e.showHeader && t.push(n()), i.headerBand && Qe(i.headerBand, t);
|
|
824
|
+
for (let e of i.rows) t.push(r(e));
|
|
825
|
+
i.showFooter && i.footerBand && Qe(i.footerBand, t);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
function tt(e, t = "csv") {
|
|
829
|
+
return `${String(e?.name ?? "report").replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").trim() || "report"}.${t}`;
|
|
830
|
+
}
|
|
831
|
+
function nt(e) {
|
|
832
|
+
let t = null, n = null, r = [];
|
|
833
|
+
for (let i of e ?? []) for (let e of i.bands ?? []) for (let i of e.items ?? []) if (i.type === "table" && !(n !== null && i.id !== n)) {
|
|
834
|
+
if (t === null && (n = i.id, t = i.columns ?? []), i.row) {
|
|
835
|
+
for (let e of i.row) r.push({
|
|
836
|
+
group: null,
|
|
837
|
+
row: e
|
|
838
|
+
});
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
for (let e of i.groups ?? []) for (let t of e.rows) r.push({
|
|
842
|
+
group: e.key,
|
|
843
|
+
row: t
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
return t === null ? null : {
|
|
847
|
+
columns: t,
|
|
848
|
+
rows: r
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function rt(e, t, n) {
|
|
852
|
+
return e.map((e) => it(e, t, n)).join(t);
|
|
853
|
+
}
|
|
854
|
+
function it(e, t, n) {
|
|
855
|
+
if (e == null) return "";
|
|
856
|
+
let r = String(e);
|
|
857
|
+
return n && Je.test(r) && (r = `\t${r}`), r.includes(t) || r.includes("\"") || r.includes("\n") || r.includes("\r") ? `"${r.replace(/"/g, "\"\"")}"` : r;
|
|
858
|
+
}
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/engine/index.js
|
|
861
|
+
function at(e, t) {
|
|
862
|
+
return Ae(me(E(x(e, t), t)));
|
|
863
|
+
}
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/render/items.js
|
|
866
|
+
var q = (e) => `position:absolute;top:${J(e?.y)}px;left:${J(e?.x)}px;`;
|
|
867
|
+
function J(e, t = 0) {
|
|
868
|
+
let n = Number(e);
|
|
869
|
+
return Number.isFinite(n) ? n : t;
|
|
870
|
+
}
|
|
871
|
+
function Y(e, t = "") {
|
|
872
|
+
if (e == null) return t;
|
|
873
|
+
let n = String(e).replace(/[<>"'`&;{}\\]/g, "").replace(/url\s*\(/gi, "").replace(/\s+/g, " ").trim();
|
|
874
|
+
return n === "" ? t : n;
|
|
875
|
+
}
|
|
876
|
+
function X(e) {
|
|
877
|
+
return e == null ? "" : String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
878
|
+
}
|
|
879
|
+
function ot(e) {
|
|
880
|
+
return (e || []).map((e) => {
|
|
881
|
+
switch (e.type) {
|
|
882
|
+
case "text": return st(e);
|
|
883
|
+
case "table": return ht(e);
|
|
884
|
+
case "line": return ut(e);
|
|
885
|
+
case "box": return ct(e);
|
|
886
|
+
default: return console.warn(`Unknown item type "${e?.type}"; it is not drawn.`), "";
|
|
887
|
+
}
|
|
888
|
+
}).join("");
|
|
889
|
+
}
|
|
890
|
+
function st(e) {
|
|
891
|
+
let t = e.style ?? {};
|
|
892
|
+
return `
|
|
893
|
+
<p id="${X(e.id)}" style="
|
|
894
|
+
width:${J(e.w)}px;
|
|
895
|
+
height:${J(e.h)}px;
|
|
896
|
+
${q(e)}
|
|
897
|
+
font-size:${J(t.fontSize, 12)}px;
|
|
898
|
+
font-family:${Y(t.fontFamily, "inherit")};
|
|
899
|
+
font-weight:${Y(t.fontWeight, "normal")};
|
|
900
|
+
font-style:${Y(t.fontStyle, "normal")};
|
|
901
|
+
text-align:${Y(t.align, "left")};
|
|
902
|
+
color:${Y(t.color, "inherit")};
|
|
903
|
+
" data-item-id="${X(e.id)}" data-item-type="text">${X(e.text)}</p>
|
|
904
|
+
`;
|
|
905
|
+
}
|
|
906
|
+
function ct(e) {
|
|
907
|
+
let t = e.style ?? {}, n = `${Math.max(0, Number(t.borderWidth ?? 1)) || 1}px ${ft.includes(t.borderStyle) ? t.borderStyle : "solid"} ${Y(t.borderColor, "#000000")}`, r = Math.max(0, Number(t.radius ?? 0)) || 0, i = Y(t.background);
|
|
908
|
+
return `
|
|
909
|
+
<div id="${X(e.id)}" class="box" style="
|
|
910
|
+
width:${J(e.w)}px;
|
|
911
|
+
height:${J(e.h)}px;
|
|
912
|
+
${q(e)}
|
|
913
|
+
border:${n};
|
|
914
|
+
${r ? `border-radius:${r}px;` : ""}
|
|
915
|
+
${i ? `background:${i};` : ""}
|
|
916
|
+
" data-item-id="${X(e.id)}" data-item-type="box"></div>
|
|
917
|
+
`;
|
|
918
|
+
}
|
|
919
|
+
function lt(e) {
|
|
920
|
+
return `${Math.max(0, Number(e?.thickness ?? 1)) || 1}px ${dt.includes(e?.lineStyle) ? e.lineStyle : "solid"} ${Y(e?.color, "#000000")}`;
|
|
921
|
+
}
|
|
922
|
+
function ut(e) {
|
|
923
|
+
let t = e.orientation === "vertical", n = lt(e.style);
|
|
924
|
+
return `
|
|
925
|
+
<div id="${X(e.id)}" class="line${t ? " is-vertical" : ""}" style="
|
|
926
|
+
width:${J(e.w)}px;
|
|
927
|
+
height:${J(e.h)}px;
|
|
928
|
+
${q(e)}
|
|
929
|
+
" data-item-id="${X(e.id)}" data-item-type="line"><span class="line-mark"
|
|
930
|
+
style="${t ? `border-left:${n}` : `border-top:${n}`}"></span></div>
|
|
931
|
+
`;
|
|
932
|
+
}
|
|
933
|
+
var dt = [
|
|
934
|
+
"solid",
|
|
935
|
+
"dashed",
|
|
936
|
+
"dotted",
|
|
937
|
+
"double"
|
|
938
|
+
], ft = [...dt, "none"];
|
|
939
|
+
function pt(e) {
|
|
940
|
+
let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
|
|
941
|
+
return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
|
|
942
|
+
}
|
|
943
|
+
function mt(e) {
|
|
944
|
+
let t = e.style ?? {}, n = [];
|
|
945
|
+
ft.includes(t.borderStyle) && n.push(`--rs-rule-style:${t.borderStyle}`), t.borderColor && n.push(`--rs-rule-color:${Y(t.borderColor)}`), t.headerBackground && n.push(`--rs-head-bg:${Y(t.headerBackground)}`), t.headerColor && n.push(`--rs-head-color:${Y(t.headerColor)}`), t.fontFamily && n.push(`--rs-cell-family:${Y(t.fontFamily)}`);
|
|
946
|
+
let r = Number(t.fontSize);
|
|
947
|
+
Number.isFinite(r) && r > 0 && n.push(`--rs-cell-size:${r}px`), t.color && n.push(`--rs-cell-color:${Y(t.color)}`), e.wrap === !1 && n.push("--rs-cell-wrap:nowrap");
|
|
948
|
+
let i = Number(t.borderWidth);
|
|
949
|
+
return Number.isFinite(i) && i > 0 && n.push(`--rs-rule-width:${Math.min(i, pt(e))}px`), n.length ? `${n.join(";")};` : "";
|
|
950
|
+
}
|
|
951
|
+
function ht(e) {
|
|
952
|
+
return `
|
|
953
|
+
<table id="${X(e.id)}" style="width:${J(e.w)}px;height:${J(e.measuredHeight)}px;${q(e)}${mt(e)}" data-item-id="${X(e.id)}" data-item-type="table">
|
|
954
|
+
${e.groups ? xt(e) : bt(e)}
|
|
955
|
+
</table>
|
|
956
|
+
`;
|
|
957
|
+
}
|
|
958
|
+
function gt(e, t, n) {
|
|
959
|
+
return `<div class="cell" style="height:${J(e)}px;text-align:${Y(t, "left")}">${X(n)}</div>`;
|
|
960
|
+
}
|
|
961
|
+
function _t(e) {
|
|
962
|
+
let t = e.headerMeasured ?? e.headerHeight ?? e.rowHeight;
|
|
963
|
+
return `<thead>
|
|
964
|
+
<tr style="height:${J(t)}px">
|
|
965
|
+
${e.columns.map((e) => `<th style="width:${J(e.width)}px;">${gt(t, e.align, e.label)}</th>`).join("")}
|
|
966
|
+
</tr>
|
|
967
|
+
</thead>`;
|
|
968
|
+
}
|
|
969
|
+
function vt(e, t, n) {
|
|
970
|
+
return (t || []).map((t, r) => {
|
|
971
|
+
let i = n?.[r] ?? e.rowHeight;
|
|
972
|
+
return `<tr style="height:${J(i)}px">
|
|
973
|
+
${e.columns.map((e) => `<td style="width:${J(e.width)}px;">${gt(i, e.align, t[e.field])}</td>`).join("")}
|
|
974
|
+
</tr>`;
|
|
975
|
+
}).join("");
|
|
976
|
+
}
|
|
977
|
+
function yt(e, t, n) {
|
|
978
|
+
return e ? `<tr class="${n}">
|
|
979
|
+
<td colspan="${t}" class="group-band-cell">
|
|
980
|
+
<div class="band" style="position:relative;height:${J(e.measuredHeight > 0 ? e.measuredHeight : e.height ?? 0)}px">${ot(e.items)}</div>
|
|
981
|
+
</td>
|
|
982
|
+
</tr>` : "";
|
|
983
|
+
}
|
|
984
|
+
function bt(e) {
|
|
985
|
+
return `
|
|
986
|
+
${e.showHeader ? _t(e) : ""}
|
|
987
|
+
<tbody>
|
|
988
|
+
${vt(e, e.row, e.rowHeights)}
|
|
989
|
+
</tbody>
|
|
990
|
+
`;
|
|
991
|
+
}
|
|
992
|
+
function xt(e) {
|
|
993
|
+
let t = e.columns.length;
|
|
994
|
+
return e.groups.map((n) => `
|
|
995
|
+
${n.showHeader && e.showHeader ? _t(e) : ""}
|
|
996
|
+
<tbody>
|
|
997
|
+
${yt(n.headerBand, t, "group-header")}
|
|
998
|
+
${vt(e, n.rows, n.rowHeights)}
|
|
999
|
+
${n.showFooter ? yt(n.footerBand, t, "group-footer") : ""}
|
|
1000
|
+
</tbody>
|
|
1001
|
+
`).join("");
|
|
1002
|
+
}
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/render/render.js
|
|
1005
|
+
var St = (e) => `padding-top:${J(e?.top)}px;padding-left:${J(e?.left)}px;padding-bottom:${J(e?.bottom)}px;padding-right:${J(e?.right)}px;`, Ct = [
|
|
1006
|
+
"pageHeader",
|
|
1007
|
+
"reportHeader",
|
|
1008
|
+
"detail",
|
|
1009
|
+
"reportFooter",
|
|
1010
|
+
"pageFooter"
|
|
1011
|
+
];
|
|
1012
|
+
function wt(e) {
|
|
1013
|
+
let t = e.page;
|
|
1014
|
+
return `
|
|
1015
|
+
<main id="main-page">
|
|
1016
|
+
${e.pages.map((e) => `
|
|
1017
|
+
<section id="page-${X(e.pageNO)}" class="page" style="height:${J(t.height)}px; width:${J(t.width)}px; ${St(t.margin)};position:relative">
|
|
1018
|
+
${Tt(e, t)}
|
|
1019
|
+
</section>
|
|
1020
|
+
`).join("")}
|
|
1021
|
+
</main>
|
|
1022
|
+
`;
|
|
1023
|
+
}
|
|
1024
|
+
function Tt(e, t) {
|
|
1025
|
+
let n = (e) => {
|
|
1026
|
+
let t = Ct.indexOf(e);
|
|
1027
|
+
return t === -1 ? Ct.length : t;
|
|
1028
|
+
}, r = [...e.bands].sort(({ type: e }, { type: t }) => n(e) - n(t)), i = [];
|
|
1029
|
+
for (let n of r) i.push(Et(n, e.pageNO, t));
|
|
1030
|
+
return i.join("");
|
|
1031
|
+
}
|
|
1032
|
+
function Et(e, t, n) {
|
|
1033
|
+
let r = Number.isFinite(e.top), i = n?.margin ?? {
|
|
1034
|
+
top: 0,
|
|
1035
|
+
left: 0,
|
|
1036
|
+
right: 0
|
|
1037
|
+
}, a = r ? `position:absolute;top:${J(e.top) + J(i.top)}px;left:${J(i.left)}px;right:${J(i.right)}px;` : "position:relative;", o = Math.max(e.zoneHeight ?? 0, e.measuredHeight ?? 0);
|
|
1038
|
+
return `
|
|
1039
|
+
<div class="band" id="${X(e.type)}-${X(t)}" style="${a}${o > 0 ? `height:${J(o)}px` : ""}" data-band-type="${X(e.type)}">
|
|
1040
|
+
${ot(e.items)}
|
|
1041
|
+
</div>
|
|
1042
|
+
`;
|
|
1043
|
+
}
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/shared/window.js
|
|
1046
|
+
var Dt = 1280, Ot = 900;
|
|
1047
|
+
function kt(e, t) {
|
|
1048
|
+
for (let n of e.querySelectorAll("link[rel=\"stylesheet\"], style")) {
|
|
1049
|
+
if (n.tagName === "LINK") {
|
|
1050
|
+
let e = t.createElement("link");
|
|
1051
|
+
e.rel = "stylesheet", e.href = n.href, t.head.appendChild(e);
|
|
1052
|
+
continue;
|
|
1053
|
+
}
|
|
1054
|
+
let e = t.createElement("style");
|
|
1055
|
+
e.textContent = n.textContent, t.head.appendChild(e);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
function At({ title: e = "Report Studio", width: t = Dt, height: n = Ot, features: r, opener: i = globalThis } = {}) {
|
|
1059
|
+
let a = r ?? `width=${t},height=${n},resizable=yes,scrollbars=yes`, o = i.open?.("", "_blank", a);
|
|
1060
|
+
if (!o || !o.document) return null;
|
|
1061
|
+
let s = o.document;
|
|
1062
|
+
s.open(), s.write("<!doctype html><html><head><meta charset=\"utf-8\"></head><body></body></html>"), s.close(), s.title = e, kt(i.document, s);
|
|
1063
|
+
let c = s.createElement("div");
|
|
1064
|
+
return c.id = "report-studio", c.style.height = "100vh", s.body.style.margin = "0", s.body.appendChild(c), {
|
|
1065
|
+
window: o,
|
|
1066
|
+
document: s,
|
|
1067
|
+
mount: c,
|
|
1068
|
+
close: () => o.close()
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
function jt(e, t, n = () => {}) {
|
|
1072
|
+
let r = () => {
|
|
1073
|
+
n(), t.close();
|
|
1074
|
+
};
|
|
1075
|
+
return e.addEventListener("pagehide", r), () => e.removeEventListener("pagehide", r);
|
|
1076
|
+
}
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/shared/dropdown.js
|
|
1079
|
+
function Mt(e) {
|
|
1080
|
+
let t = e.querySelector(".dropdown-trigger"), n = e.querySelector(".dropdown-value"), r = e.querySelector(".dropdown-menu"), i = [...r.querySelectorAll(".dropdown-item")], a = /* @__PURE__ */ new Set(), o = () => t.ownerDocument, s = i.find((e) => e.dataset.selected === "true")?.dataset.value ?? i[0]?.dataset.value ?? "", c = Math.max(i.findIndex((e) => e.dataset.value === s), 0);
|
|
1081
|
+
function l() {
|
|
1082
|
+
i.forEach((e, t) => {
|
|
1083
|
+
let n = e.dataset.value === s;
|
|
1084
|
+
e.setAttribute("aria-selected", String(n)), e.classList.toggle("is-active", t === c);
|
|
1085
|
+
});
|
|
1086
|
+
let e = i.find((e) => e.dataset.value === s);
|
|
1087
|
+
e && (n.textContent = e.textContent.trim());
|
|
1088
|
+
}
|
|
1089
|
+
function u(e, { notify: t = !1 } = {}) {
|
|
1090
|
+
let n = i.find((t) => t.dataset.value === String(e));
|
|
1091
|
+
if (!n) return;
|
|
1092
|
+
let r = n.dataset.value !== s;
|
|
1093
|
+
if (s = n.dataset.value, c = i.indexOf(n), l(), t && r) for (let e of a) e();
|
|
1094
|
+
}
|
|
1095
|
+
let d = () => !r.hidden;
|
|
1096
|
+
function f() {
|
|
1097
|
+
d() || (r.hidden = !1, t.setAttribute("aria-expanded", "true"), c = Math.max(i.findIndex((e) => e.dataset.value === s), 0), l(), i[c]?.focus(), setTimeout(() => o().addEventListener("pointerdown", m), 0));
|
|
1098
|
+
}
|
|
1099
|
+
function p({ focusTrigger: e = !0 } = {}) {
|
|
1100
|
+
d() && (r.hidden = !0, t.setAttribute("aria-expanded", "false"), o().removeEventListener("pointerdown", m), e && t.focus());
|
|
1101
|
+
}
|
|
1102
|
+
function m(t) {
|
|
1103
|
+
e.contains(t.target) || p({ focusTrigger: !1 });
|
|
1104
|
+
}
|
|
1105
|
+
function h(e) {
|
|
1106
|
+
c = (e + i.length) % i.length, l(), i[c]?.focus();
|
|
1107
|
+
}
|
|
1108
|
+
function g(e) {
|
|
1109
|
+
[
|
|
1110
|
+
"ArrowDown",
|
|
1111
|
+
"ArrowUp",
|
|
1112
|
+
"Enter",
|
|
1113
|
+
" "
|
|
1114
|
+
].includes(e.key) && (e.preventDefault(), e.stopPropagation(), f());
|
|
1115
|
+
}
|
|
1116
|
+
function _(e) {
|
|
1117
|
+
let t = {
|
|
1118
|
+
ArrowDown: () => h(c + 1),
|
|
1119
|
+
ArrowUp: () => h(c - 1),
|
|
1120
|
+
Home: () => h(0),
|
|
1121
|
+
End: () => h(i.length - 1),
|
|
1122
|
+
Escape: () => p(),
|
|
1123
|
+
Enter: () => {
|
|
1124
|
+
u(i[c].dataset.value, { notify: !0 }), p();
|
|
1125
|
+
},
|
|
1126
|
+
" ": () => {
|
|
1127
|
+
u(i[c].dataset.value, { notify: !0 }), p();
|
|
1128
|
+
},
|
|
1129
|
+
Tab: () => p({ focusTrigger: !1 })
|
|
1130
|
+
}[e.key];
|
|
1131
|
+
t && (e.key !== "Tab" && (e.preventDefault(), e.stopPropagation()), t());
|
|
1132
|
+
}
|
|
1133
|
+
t.addEventListener("click", () => d() ? p() : f()), t.addEventListener("keydown", g), r.addEventListener("keydown", _);
|
|
1134
|
+
for (let e of i) e.addEventListener("click", () => {
|
|
1135
|
+
u(e.dataset.value, { notify: !0 }), p();
|
|
1136
|
+
});
|
|
1137
|
+
return l(), {
|
|
1138
|
+
get value() {
|
|
1139
|
+
return s;
|
|
1140
|
+
},
|
|
1141
|
+
set value(e) {
|
|
1142
|
+
u(e);
|
|
1143
|
+
},
|
|
1144
|
+
addEventListener(e, t) {
|
|
1145
|
+
e === "change" && a.add(t);
|
|
1146
|
+
},
|
|
1147
|
+
open: f,
|
|
1148
|
+
close: p,
|
|
1149
|
+
get isOpen() {
|
|
1150
|
+
return d();
|
|
1151
|
+
},
|
|
1152
|
+
destroy() {
|
|
1153
|
+
o().removeEventListener("pointerdown", m), a.clear();
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
//#endregion
|
|
1158
|
+
//#region src/preview/chrome.js
|
|
1159
|
+
function Nt({ title: e = "Report Studio" } = {}) {
|
|
1160
|
+
return `
|
|
1161
|
+
<!--
|
|
1162
|
+
A header, not role="toolbar": that role promises arrow-key roving focus
|
|
1163
|
+
between the controls, and here the arrow keys page the report instead.
|
|
1164
|
+
-->
|
|
1165
|
+
<header class="toolbar" data-role="bar" aria-label="Report tools">
|
|
1166
|
+
<div class="toolbar-brand">${e}</div>
|
|
1167
|
+
|
|
1168
|
+
<div class="toolbar-centre">
|
|
1169
|
+
<div class="toolbar-group toolbar-search">
|
|
1170
|
+
<!--
|
|
1171
|
+
Buttons cannot live inside an <input>, so the wrapper draws
|
|
1172
|
+
the field and the input inside it draws no chrome of its own.
|
|
1173
|
+
-->
|
|
1174
|
+
<div class="search-field">
|
|
1175
|
+
<input type="search" data-role="query" placeholder="Search the report (ctrl+K)"
|
|
1176
|
+
title="Search the report (ctrl+K)"
|
|
1177
|
+
aria-label="Search the report" spellcheck="false">
|
|
1178
|
+
<span class="hits" data-role="hits" data-state="idle" aria-live="polite"></span>
|
|
1179
|
+
<button type="button" data-role="hit-prev" title="Previous match (shift+enter)"
|
|
1180
|
+
aria-label="Previous match">↑</button>
|
|
1181
|
+
<button type="button" data-role="hit-next" title="Next match (enter)"
|
|
1182
|
+
aria-label="Next match">↓</button>
|
|
1183
|
+
</div>
|
|
1184
|
+
</div>
|
|
1185
|
+
|
|
1186
|
+
<div class="toolbar-group toolbar-zoom">
|
|
1187
|
+
<button type="button" data-role="zoom-out" title="Zoom out (ctrl+-)"
|
|
1188
|
+
aria-label="Zoom out">−</button>
|
|
1189
|
+
|
|
1190
|
+
<!--
|
|
1191
|
+
A listbox rather than a <select>: option items are drawn by
|
|
1192
|
+
the operating system, so they cannot take the palette.
|
|
1193
|
+
-->
|
|
1194
|
+
<div class="dropdown" data-role="zoom-dropdown">
|
|
1195
|
+
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
1196
|
+
aria-haspopup="listbox" aria-expanded="false" aria-label="Zoom level">
|
|
1197
|
+
<span class="dropdown-value">100%</span>
|
|
1198
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
1199
|
+
</button>
|
|
1200
|
+
|
|
1201
|
+
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
1202
|
+
aria-label="Zoom level" hidden>
|
|
1203
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="fit">Fit width</li>
|
|
1204
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.5">50%</li>
|
|
1205
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.75">75%</li>
|
|
1206
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1"
|
|
1207
|
+
data-selected="true">100%</li>
|
|
1208
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.25">125%</li>
|
|
1209
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.5">150%</li>
|
|
1210
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="2">200%</li>
|
|
1211
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="3">300%</li>
|
|
1212
|
+
</ul>
|
|
1213
|
+
</div>
|
|
1214
|
+
|
|
1215
|
+
<button type="button" data-role="zoom-in" title="Zoom in (ctrl++)"
|
|
1216
|
+
aria-label="Zoom in">+</button>
|
|
1217
|
+
</div>
|
|
1218
|
+
</div>
|
|
1219
|
+
|
|
1220
|
+
<div class="toolbar-group toolbar-save">
|
|
1221
|
+
<button type="button" data-role="print" title="Print or save as PDF (ctrl+P)">
|
|
1222
|
+
Print</button>
|
|
1223
|
+
<button type="button" data-role="export" title="Export the report (ctrl+X)">
|
|
1224
|
+
Export…</button>
|
|
1225
|
+
</div>
|
|
1226
|
+
</header>
|
|
1227
|
+
|
|
1228
|
+
<div class="viewport" data-role="viewport"></div>
|
|
1229
|
+
|
|
1230
|
+
<!-- paging floats over the report rather than taking a strip of it -->
|
|
1231
|
+
<div class="pager" data-role="pager" role="toolbar" aria-label="Page navigation">
|
|
1232
|
+
<button type="button" data-role="prev" title="Previous page (left arrow)"
|
|
1233
|
+
aria-label="Previous page">‹</button>
|
|
1234
|
+
|
|
1235
|
+
<label class="page-of">
|
|
1236
|
+
<input type="number" data-role="current" min="1" value="1" aria-label="Current page">
|
|
1237
|
+
<span>of</span>
|
|
1238
|
+
<span data-role="total">1</span>
|
|
1239
|
+
</label>
|
|
1240
|
+
|
|
1241
|
+
<button type="button" data-role="next" title="Next page (right arrow)"
|
|
1242
|
+
aria-label="Next page">›</button>
|
|
1243
|
+
</div>
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
<!--
|
|
1248
|
+
Hand-written rather than a <dialog>: the element is still unimplemented
|
|
1249
|
+
in the environment the specs run in, and a stubbed showModal would test
|
|
1250
|
+
the stub instead of the behaviour.
|
|
1251
|
+
-->
|
|
1252
|
+
<div class="modal" data-role="export-modal" hidden>
|
|
1253
|
+
<div class="modal-backdrop" data-role="export-backdrop"></div>
|
|
1254
|
+
|
|
1255
|
+
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="export-title">
|
|
1256
|
+
<h2 id="export-title">Export report</h2>
|
|
1257
|
+
|
|
1258
|
+
<div class="modal-formats" role="radiogroup" aria-labelledby="export-title">
|
|
1259
|
+
<label class="format">
|
|
1260
|
+
<input type="radio" name="export-format" value="pdf" checked>
|
|
1261
|
+
<span class="format-body">
|
|
1262
|
+
<span class="format-name">PDF</span>
|
|
1263
|
+
<span class="format-note">Opens the print dialog - choose "Save as PDF"</span>
|
|
1264
|
+
</span>
|
|
1265
|
+
</label>
|
|
1266
|
+
|
|
1267
|
+
<label class="format">
|
|
1268
|
+
<input type="radio" name="export-format" value="csv">
|
|
1269
|
+
<span class="format-body">
|
|
1270
|
+
<span class="format-name">CSV</span>
|
|
1271
|
+
<span class="format-note">Every text line and table row, in report order</span>
|
|
1272
|
+
</span>
|
|
1273
|
+
</label>
|
|
1274
|
+
</div>
|
|
1275
|
+
|
|
1276
|
+
<p class="modal-summary" data-role="export-summary" aria-live="polite"></p>
|
|
1277
|
+
|
|
1278
|
+
<div class="modal-actions">
|
|
1279
|
+
<button type="button" data-role="export-cancel">Cancel</button>
|
|
1280
|
+
<button type="button" class="is-primary" data-role="export-confirm">Export</button>
|
|
1281
|
+
</div>
|
|
1282
|
+
</div>
|
|
1283
|
+
</div>
|
|
1284
|
+
`;
|
|
1285
|
+
}
|
|
1286
|
+
//#endregion
|
|
1287
|
+
//#region src/preview/viewer.js
|
|
1288
|
+
var Z = [
|
|
1289
|
+
.5,
|
|
1290
|
+
.75,
|
|
1291
|
+
1,
|
|
1292
|
+
1.25,
|
|
1293
|
+
1.5,
|
|
1294
|
+
2,
|
|
1295
|
+
3
|
|
1296
|
+
], Q = Z[0], $ = Z[Z.length - 1];
|
|
1297
|
+
function Pt({ paginated: e, title: t, width: n, height: r, features: i, ...a } = {}) {
|
|
1298
|
+
let o = At({
|
|
1299
|
+
title: t ?? "Report",
|
|
1300
|
+
width: n,
|
|
1301
|
+
height: r,
|
|
1302
|
+
features: i
|
|
1303
|
+
});
|
|
1304
|
+
if (!o) return null;
|
|
1305
|
+
let s = Ft({
|
|
1306
|
+
...a,
|
|
1307
|
+
mount: o.mount,
|
|
1308
|
+
paginated: e,
|
|
1309
|
+
title: t
|
|
1310
|
+
}), c = jt(globalThis, o.window, s.destroy);
|
|
1311
|
+
return {
|
|
1312
|
+
...s,
|
|
1313
|
+
window: o.window,
|
|
1314
|
+
destroy() {
|
|
1315
|
+
c(), s.destroy(), o.close();
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
function Ft({ mount: e, paginated: t, title: n } = {}) {
|
|
1320
|
+
let r = typeof e == "string" ? document.querySelector(e) : e;
|
|
1321
|
+
if (!r) throw Error(`createViewer: no element for mount ${JSON.stringify(e)}. Add <div id="report"></div> to the page first.`);
|
|
1322
|
+
let i = r.ownerDocument, a = i.defaultView ?? globalThis;
|
|
1323
|
+
if (!t?.pages) throw Error("createViewer: paginated must be a buildPages(layout, data) result.");
|
|
1324
|
+
r.classList.add("report-viewer"), r.innerHTML = Nt({ title: n });
|
|
1325
|
+
let o = r.querySelector("[data-role=\"viewport\"]");
|
|
1326
|
+
o.innerHTML = wt(t);
|
|
1327
|
+
let s = [...o.querySelectorAll(".page")], c = s.length, l = o.querySelector("#main-page"), u = o, d = r.querySelector("[data-role=\"export-modal\"]"), f = (e) => r.querySelector(`[data-role="${e}"]`), p = {
|
|
1328
|
+
prev: f("prev"),
|
|
1329
|
+
next: f("next"),
|
|
1330
|
+
current: f("current"),
|
|
1331
|
+
total: f("total"),
|
|
1332
|
+
zoom: Mt(f("zoom-dropdown")),
|
|
1333
|
+
zoomIn: f("zoom-in"),
|
|
1334
|
+
zoomOut: f("zoom-out"),
|
|
1335
|
+
print: f("print"),
|
|
1336
|
+
exportOpen: f("export"),
|
|
1337
|
+
query: f("query"),
|
|
1338
|
+
hits: f("hits"),
|
|
1339
|
+
hitPrev: f("hit-prev"),
|
|
1340
|
+
hitNext: f("hit-next")
|
|
1341
|
+
}, m = d ? {
|
|
1342
|
+
root: d,
|
|
1343
|
+
card: d.querySelector(".modal-card"),
|
|
1344
|
+
backdrop: d.querySelector("[data-role=\"export-backdrop\"]"),
|
|
1345
|
+
summary: d.querySelector("[data-role=\"export-summary\"]"),
|
|
1346
|
+
cancel: d.querySelector("[data-role=\"export-cancel\"]"),
|
|
1347
|
+
confirm: d.querySelector("[data-role=\"export-confirm\"]"),
|
|
1348
|
+
formats: [...d.querySelectorAll("input[name=\"export-format\"]")]
|
|
1349
|
+
} : null, h = 0, g = [], _ = -1, v = 1, y = !1, b = null, x = a.onafterprint !== void 0;
|
|
1350
|
+
p.total.textContent = String(c), p.current.max = String(c);
|
|
1351
|
+
function S(e) {
|
|
1352
|
+
h = Math.min(Math.max(e, 0), c - 1), s.forEach((e, t) => e.classList.toggle("is-current", t === h)), p.current.value = String(h + 1), p.prev.disabled = h === 0, p.next.disabled = h === c - 1, B(), u.scrollTo?.({ top: 0 });
|
|
1353
|
+
}
|
|
1354
|
+
function C() {
|
|
1355
|
+
if (u.style.setProperty("--zoom", String(v)), l && (l.style.width = `${t.page.width * v}px`, l.style.height = `${t.page.height * v}px`), !y) {
|
|
1356
|
+
let e = Z.find((e) => Math.abs(e - v) < 1e-9);
|
|
1357
|
+
p.zoom.value = e === void 0 ? "fit" : String(e);
|
|
1358
|
+
}
|
|
1359
|
+
p.zoomOut.disabled = !y && v <= Q, p.zoomIn.disabled = !y && v >= $;
|
|
1360
|
+
}
|
|
1361
|
+
function w(e) {
|
|
1362
|
+
y = !1, v = Math.min(Math.max(e, Q), $), C();
|
|
1363
|
+
}
|
|
1364
|
+
function T() {
|
|
1365
|
+
y = !0, p.zoom.value = "fit";
|
|
1366
|
+
let e = u.clientWidth - 48;
|
|
1367
|
+
e > 0 && (v = Math.min(Math.max(e / t.page.width, Q), $)), C();
|
|
1368
|
+
}
|
|
1369
|
+
function E(e) {
|
|
1370
|
+
let t = v;
|
|
1371
|
+
w((e > 0 ? Z.find((e) => e > t + 1e-9) : [...Z].reverse().find((e) => e < t - 1e-9)) ?? t);
|
|
1372
|
+
}
|
|
1373
|
+
let D = {
|
|
1374
|
+
pdf: {
|
|
1375
|
+
available: () => !0,
|
|
1376
|
+
summary: () => `${c} page${c === 1 ? "" : "s"}, ${t.page.width}×${t.page.height}px each.`,
|
|
1377
|
+
run: () => O()
|
|
1378
|
+
},
|
|
1379
|
+
csv: {
|
|
1380
|
+
available: () => Xe(t.pages) !== "",
|
|
1381
|
+
summary: () => D.csv.available() ? `Downloads ${tt(t, "csv")}.` : "This report has nothing to write out.",
|
|
1382
|
+
run: () => A()
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
function O() {
|
|
1386
|
+
z(), a.print(), x || k();
|
|
1387
|
+
}
|
|
1388
|
+
function k() {
|
|
1389
|
+
p.query.value.trim() !== "" && B();
|
|
1390
|
+
}
|
|
1391
|
+
function ee() {
|
|
1392
|
+
let { width: e, height: n } = t.page, r = i.getElementById("report-page-size");
|
|
1393
|
+
r || (r = i.createElement("style"), r.id = "report-page-size", i.head.appendChild(r)), r.textContent = `@page { size: ${e}px ${n}px; margin: 0; }`;
|
|
1394
|
+
}
|
|
1395
|
+
function A() {
|
|
1396
|
+
let e = Xe(t.pages);
|
|
1397
|
+
return e === "" ? !1 : (te(new Blob(["", e], { type: "text/csv;charset=utf-8" }), tt(t, "csv")), !0);
|
|
1398
|
+
}
|
|
1399
|
+
function te(e, t) {
|
|
1400
|
+
let n = URL.createObjectURL(e), r = i.createElement("a");
|
|
1401
|
+
r.href = n, r.download = t, i.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
|
|
1402
|
+
}
|
|
1403
|
+
function ne() {
|
|
1404
|
+
return m?.formats.find((e) => e.checked)?.value ?? "pdf";
|
|
1405
|
+
}
|
|
1406
|
+
function j() {
|
|
1407
|
+
if (!m) return;
|
|
1408
|
+
for (let e of m.formats) {
|
|
1409
|
+
let t = D[e.value];
|
|
1410
|
+
e.disabled = !t || !t.available(), e.closest(".format")?.classList.toggle("is-unavailable", e.disabled);
|
|
1411
|
+
}
|
|
1412
|
+
if (m.formats.find((e) => e.checked)?.disabled) {
|
|
1413
|
+
let e = m.formats.find((e) => !e.disabled);
|
|
1414
|
+
e && (e.checked = !0);
|
|
1415
|
+
}
|
|
1416
|
+
let e = D[ne()];
|
|
1417
|
+
m.summary.textContent = e ? e.summary() : "", m.confirm.disabled = !e || !e.available();
|
|
1418
|
+
}
|
|
1419
|
+
function M() {
|
|
1420
|
+
m && (b = i.activeElement, m.root.hidden = !1, j(), (m.formats.find((e) => e.checked && !e.disabled) ?? m.formats.find((e) => !e.disabled) ?? m.cancel).focus());
|
|
1421
|
+
}
|
|
1422
|
+
function N() {
|
|
1423
|
+
!m || m.root.hidden || (m.root.hidden = !0, b?.focus?.(), b = null);
|
|
1424
|
+
}
|
|
1425
|
+
function P() {
|
|
1426
|
+
let e = D[ne()];
|
|
1427
|
+
e?.available() && (N(), e.run());
|
|
1428
|
+
}
|
|
1429
|
+
function F(e) {
|
|
1430
|
+
let t = [...m.card.querySelectorAll("button, input")].filter((e) => !e.disabled);
|
|
1431
|
+
if (!t.length) return;
|
|
1432
|
+
let n = t[0], r = t[t.length - 1];
|
|
1433
|
+
e.shiftKey && i.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && i.activeElement === r && (e.preventDefault(), n.focus());
|
|
1434
|
+
}
|
|
1435
|
+
function I() {
|
|
1436
|
+
let e = p.query.value.trim();
|
|
1437
|
+
if (z(), e === "") {
|
|
1438
|
+
g = [], _ = -1, p.hits.textContent = "", p.hits.dataset.state = "idle", R();
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
if (g = He(t.pages, e), _ = g.length ? 0 : -1, p.hits.dataset.state = g.length ? "found" : "empty", R(), !g.length) {
|
|
1442
|
+
p.hits.textContent = "no matches";
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
let n = Ue(t.pages, e).length;
|
|
1446
|
+
p.hits.textContent = `${g.length} on ${n} page${n === 1 ? "" : "s"}`, L(0);
|
|
1447
|
+
}
|
|
1448
|
+
function L(e) {
|
|
1449
|
+
if (!g.length) return;
|
|
1450
|
+
_ = (e + g.length) % g.length;
|
|
1451
|
+
let t = g[_].pageNO - 1;
|
|
1452
|
+
t === h ? B() : S(t), p.hits.textContent = `${_ + 1} of ${g.length}`, ie();
|
|
1453
|
+
}
|
|
1454
|
+
function R() {
|
|
1455
|
+
p.hitPrev.disabled = g.length === 0, p.hitNext.disabled = g.length === 0;
|
|
1456
|
+
}
|
|
1457
|
+
function z() {
|
|
1458
|
+
for (let e of u.querySelectorAll("mark.hit")) {
|
|
1459
|
+
let t = e.parentNode;
|
|
1460
|
+
t.replaceChild(i.createTextNode(e.textContent), e), t.normalize();
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
function B() {
|
|
1464
|
+
z();
|
|
1465
|
+
let e = p.query.value.trim();
|
|
1466
|
+
if (e === "") return;
|
|
1467
|
+
let t = s[h];
|
|
1468
|
+
if (!t) return;
|
|
1469
|
+
let n = e.toLowerCase(), r = i.createTreeWalker(t, NodeFilter.SHOW_TEXT), a = [];
|
|
1470
|
+
for (; r.nextNode();) {
|
|
1471
|
+
let e = r.currentNode;
|
|
1472
|
+
e.nodeValue.toLowerCase().includes(n) && a.push(e);
|
|
1473
|
+
}
|
|
1474
|
+
for (let e of a) re(e, n);
|
|
1475
|
+
}
|
|
1476
|
+
function re(e, t) {
|
|
1477
|
+
let n = e.nodeValue, r = i.createDocumentFragment(), a = 0;
|
|
1478
|
+
for (;;) {
|
|
1479
|
+
let e = n.toLowerCase().indexOf(t, a);
|
|
1480
|
+
if (e === -1) break;
|
|
1481
|
+
e > a && r.appendChild(i.createTextNode(n.slice(a, e)));
|
|
1482
|
+
let o = i.createElement("mark");
|
|
1483
|
+
o.className = "hit", o.textContent = n.slice(e, e + t.length), r.appendChild(o), a = e + t.length;
|
|
1484
|
+
}
|
|
1485
|
+
a < n.length && r.appendChild(i.createTextNode(n.slice(a))), e.parentNode.replaceChild(r, e);
|
|
1486
|
+
}
|
|
1487
|
+
function ie() {
|
|
1488
|
+
let e = [...u.querySelectorAll("mark.hit")];
|
|
1489
|
+
if (!e.length) return;
|
|
1490
|
+
let t = g.filter((e) => e.pageNO === h + 1).indexOf(g[_]), n = e[Math.max(t, 0)] ?? e[0];
|
|
1491
|
+
e.forEach((e) => e.classList.remove("is-focused")), n.classList.add("is-focused"), n.scrollIntoView?.({
|
|
1492
|
+
block: "center",
|
|
1493
|
+
behavior: "smooth"
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
if (p.prev.addEventListener("click", () => S(h - 1)), p.next.addEventListener("click", () => S(h + 1)), p.current.addEventListener("change", () => {
|
|
1497
|
+
let e = Number(p.current.value);
|
|
1498
|
+
Number.isFinite(e) ? S(e - 1) : p.current.value = String(h + 1);
|
|
1499
|
+
}), p.print?.addEventListener("click", O), p.exportOpen.addEventListener("click", M), m) {
|
|
1500
|
+
m.cancel.addEventListener("click", N), m.backdrop.addEventListener("click", N), m.confirm.addEventListener("click", P);
|
|
1501
|
+
for (let e of m.formats) e.addEventListener("change", j);
|
|
1502
|
+
m.root.addEventListener("keydown", (e) => {
|
|
1503
|
+
e.key === "Tab" && F(e), e.key === "Enter" && (e.preventDefault(), P());
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
p.zoomIn.addEventListener("click", () => E(1)), p.zoomOut.addEventListener("click", () => E(-1)), p.zoom.addEventListener("change", () => {
|
|
1507
|
+
p.zoom.value === "fit" ? T() : w(Number(p.zoom.value));
|
|
1508
|
+
});
|
|
1509
|
+
let ae = () => {
|
|
1510
|
+
y && T();
|
|
1511
|
+
};
|
|
1512
|
+
a.addEventListener("resize", ae), p.hitPrev.addEventListener("click", () => L(_ - 1)), p.hitNext.addEventListener("click", () => L(_ + 1));
|
|
1513
|
+
let V;
|
|
1514
|
+
p.query.addEventListener("input", () => {
|
|
1515
|
+
clearTimeout(V), V = setTimeout(I, 150);
|
|
1516
|
+
}), p.query.addEventListener("keydown", (e) => {
|
|
1517
|
+
e.key === "Enter" && (e.preventDefault(), g.length ? L(_ + (e.shiftKey ? -1 : 1)) : I());
|
|
1518
|
+
});
|
|
1519
|
+
let oe = (e) => {
|
|
1520
|
+
if (m && !m.root.hidden) {
|
|
1521
|
+
e.key === "Escape" && (e.preventDefault(), N());
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
if ((e.ctrlKey || e.metaKey) && ["k", "f"].includes(e.key.toLowerCase())) {
|
|
1525
|
+
e.preventDefault(), p.query.focus(), p.query.select();
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "p") {
|
|
1529
|
+
e.preventDefault(), O();
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (!(e.target === p.query || e.target === p.current)) {
|
|
1533
|
+
if ((e.ctrlKey || e.metaKey) && ["x", "s"].includes(e.key.toLowerCase())) {
|
|
1534
|
+
e.preventDefault(), M();
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
(e.key === "ArrowRight" || e.key === "PageDown") && S(h + 1), (e.key === "ArrowLeft" || e.key === "PageUp") && S(h - 1), e.key === "Home" && S(0), e.key === "End" && S(c - 1), (e.ctrlKey || e.metaKey) && ((e.key === "+" || e.key === "=") && (e.preventDefault(), E(1)), e.key === "-" && (e.preventDefault(), E(-1)), e.key === "0" && (e.preventDefault(), w(1)));
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
i.addEventListener("keydown", oe), x && a.addEventListener("afterprint", k);
|
|
1541
|
+
function H() {
|
|
1542
|
+
p.zoom.destroy(), i.removeEventListener("keydown", oe), a.removeEventListener("resize", ae), a.removeEventListener("afterprint", k), r.innerHTML = "", r.classList.remove("report-viewer");
|
|
1543
|
+
}
|
|
1544
|
+
return ee(), C(), S(0), R(), {
|
|
1545
|
+
show: S,
|
|
1546
|
+
next: () => S(h + 1),
|
|
1547
|
+
prev: () => S(h - 1),
|
|
1548
|
+
find: (e) => {
|
|
1549
|
+
p.query.value = e, I();
|
|
1550
|
+
},
|
|
1551
|
+
print: O,
|
|
1552
|
+
downloadCSV: A,
|
|
1553
|
+
openExport: M,
|
|
1554
|
+
closeExport: N,
|
|
1555
|
+
confirmExport: P,
|
|
1556
|
+
destroy: H,
|
|
1557
|
+
get exportOpen() {
|
|
1558
|
+
return m ? !m.root.hidden : !1;
|
|
1559
|
+
},
|
|
1560
|
+
setZoom: w,
|
|
1561
|
+
zoomIn: () => E(1),
|
|
1562
|
+
zoomOut: () => E(-1),
|
|
1563
|
+
fitWidth: T,
|
|
1564
|
+
get zoom() {
|
|
1565
|
+
return v;
|
|
1566
|
+
},
|
|
1567
|
+
get page() {
|
|
1568
|
+
return h + 1;
|
|
1569
|
+
},
|
|
1570
|
+
get pageCount() {
|
|
1571
|
+
return c;
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
//#endregion
|
|
1576
|
+
export { b as A, L as C, E as D, H as E, a as M, o as N, v as O, me as S, se as T, Ue as _, Pt as a, De as b, At as c, ot as d, at as f, He as g, Xe as h, Ft as i, x as j, y as k, wt as l, Ye as m, Q as n, Mt as o, tt as p, Z as r, jt as s, $ as t, X as u, Ae as v, V as w, pe as x, G as y };
|