@agile-team/mach-report 2.11.2 → 2.13.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 +30 -5
- package/THIRD_PARTY_NOTICES.md +270 -0
- package/dist/{ExcelBindingWizard-LWX6G1A2.js → ExcelBindingWizard-CeAf4QSE.js} +2 -2
- package/dist/{ExcelBindingWizard-a4kslPHF.cjs → ExcelBindingWizard-y0mT-AHR.cjs} +1 -1
- package/dist/{ReportBatchPanel-B5ClP9tm.js → ReportBatchPanel-CW2HV9I8.js} +1 -1
- package/dist/{ReportBatchPanel-Dc-SDkYA.cjs → ReportBatchPanel-Fp1ePFag.cjs} +1 -1
- package/dist/ReportPreview-BN6fk7Wz.cjs +6 -0
- package/dist/ReportPreview-D2Jkyh1U.js +4243 -0
- package/dist/{RuleEditor-C2QsOHOs.cjs → RuleEditor-ChRzNQuF.cjs} +1 -1
- package/dist/{RuleEditor-D9wQHrkf.js → RuleEditor-DzAmW5YH.js} +1 -1
- package/dist/analytics.d.cts +28 -0
- package/dist/analytics.d.ts +28 -0
- package/dist/assets-C2U-e-Sz.cjs +4 -0
- package/dist/assets-Q0wUwNrV.js +217 -0
- package/dist/code-options-BKXXY7NI.js +18 -0
- package/dist/code-options-BUTChiZZ.cjs +1 -0
- package/dist/codes.cjs +9 -0
- package/dist/codes.d.cts +223 -0
- package/dist/codes.d.ts +223 -0
- package/dist/codes.js +26917 -0
- package/dist/config-Bb7RiIO5.cjs +1 -0
- package/dist/{config-B612mw0x.js → config-XVwG87IA.js} +4 -0
- package/dist/designer.cjs +2 -2
- package/dist/designer.d.cts +283 -0
- package/dist/designer.d.ts +283 -0
- package/dist/designer.js +2852 -2010
- package/dist/grid-strokes-Cr7DwUux.cjs +1 -0
- package/dist/grid-strokes-DyyG1q_o.js +53 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +105 -1
- package/dist/index.d.ts +105 -1
- package/dist/index.js +488 -439
- package/dist/pdf.cjs +76 -59
- package/dist/pdf.d.cts +51 -0
- package/dist/pdf.d.ts +51 -0
- package/dist/pdf.js +32128 -32048
- package/dist/{plugin-Cd5G2QQn.js → plugin-D4wizDXB.js} +1 -1
- package/dist/{plugin-BDTU4D94.cjs → plugin-DzS6pxTA.cjs} +1 -1
- package/dist/record-bindings-By_UKZ2g.cjs +1 -0
- package/dist/{list-cell-ClFra1zS.js → record-bindings-D-5jQlTj.js} +67 -44
- package/dist/{region-binding-workflow-DhQvu1co.cjs → region-binding-workflow-BzfbxRiR.cjs} +1 -1
- package/dist/{region-binding-workflow-CXDmt9Bs.js → region-binding-workflow-CcUq8W2Q.js} +1 -1
- package/dist/server/node.d.cts +52 -1
- package/dist/server/node.d.ts +52 -1
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +239 -210
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +95 -3
- package/dist/server.d.ts +95 -3
- package/dist/server.js +457 -434
- package/dist/style.css +1 -1
- package/dist/{template-registry-WNXdkiET.js → template-registry-BjE1VS6g.js} +221 -157
- package/dist/template-registry-D3SjENi6.cjs +1 -0
- package/dist/template-review-DGwWOoCv.cjs +2 -0
- package/dist/{template-review-BdcXSYbx.js → template-review-PgEe_Wr9.js} +792 -666
- package/dist/validate-BJ5HIWY8.cjs +1 -0
- package/dist/validate-DbgEM1Hh.js +163 -0
- package/dist/vue/async.d.cts +125 -2
- package/dist/vue/async.d.ts +125 -2
- package/dist/vue/index.d.cts +121 -8
- package/dist/vue/index.d.ts +121 -8
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +5 -5
- package/dist/{workbook-session-BKOTwcoq.js → workbook-session-BPb3TMnT.js} +1 -1
- package/dist/{workbook-session-CLYLhZWu.cjs → workbook-session-DNa2RHNG.cjs} +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +52 -1
- package/dist/worker.d.ts +52 -1
- package/dist/worker.js +2 -2
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.d.cts +40 -0
- package/dist/xlsx.d.ts +40 -0
- package/dist/xlsx.js +3 -3
- package/package.json +16 -3
- package/dist/ReportPreview-DWXROHBP.cjs +0 -6
- package/dist/ReportPreview-DiNXhQI0.js +0 -4138
- package/dist/assets-Bu6UohJx.cjs +0 -1
- package/dist/assets-DegqDNqY.js +0 -160
- package/dist/config-BRoLo2oj.cjs +0 -1
- package/dist/list-cell-BuYn4tGF.cjs +0 -1
- package/dist/template-registry-ukBGlm8N.cjs +0 -1
- package/dist/template-review-BXp2oyqg.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
- package/dist/textwrap-DE1kgcJB.js +0 -110
- package/dist/validate-7s0yn6ii.js +0 -148
- package/dist/validate-DsRiNw8h.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { D as Z, a as
|
|
2
|
-
import { b as
|
|
3
|
-
import { e as
|
|
4
|
-
import { a as H, r as
|
|
5
|
-
import { C as
|
|
6
|
-
import { i as ee, a as
|
|
7
|
-
import { R as
|
|
8
|
-
import { a as
|
|
9
|
-
import { v as
|
|
10
|
-
import { d as
|
|
11
|
-
import { h as oe, w as
|
|
12
|
-
import { c as
|
|
13
|
-
import { R as
|
|
14
|
-
import {
|
|
15
|
-
import { r as
|
|
16
|
-
import { r as
|
|
17
|
-
import { O as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { R as
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
const Ye = {
|
|
1
|
+
import { D as Z, a as xe } from "./defaults-DXhiM1ZD.js";
|
|
2
|
+
import { b as Hn, c as _n, d as Bn, L as jn, S as Wn } from "./defaults-DXhiM1ZD.js";
|
|
3
|
+
import { R as Un, e as Vn, f as qn, p as Yn, b as Jn, t as Kn, d as Xn } from "./record-bindings-D-5jQlTj.js";
|
|
4
|
+
import { a as H, r as _, b as Q, c as j, d as Ee, m as ie, e as Te, p as O, f as Se, P as J } from "./style-CQ1PK8ZB.js";
|
|
5
|
+
import { C as Qn, M as er, g as tr, h as nr } from "./style-CQ1PK8ZB.js";
|
|
6
|
+
import { i as ee, a as Ce } from "./render-plan-Ck6koX9L.js";
|
|
7
|
+
import { R as ir } from "./render-plan-Ck6koX9L.js";
|
|
8
|
+
import { a as ar, v as sr, b as lr, c as cr } from "./validate-DbgEM1Hh.js";
|
|
9
|
+
import { v as Ve } from "./dataset-H5pFuQGU.js";
|
|
10
|
+
import { d as mr } from "./dataset-H5pFuQGU.js";
|
|
11
|
+
import { h as oe, r as ae, w as Re } from "./assets-Q0wUwNrV.js";
|
|
12
|
+
import { O as gr, c as ur, a as fr, b as pr, m as wr } from "./assets-Q0wUwNrV.js";
|
|
13
|
+
import { R as se, d as qe, a as Ye, p as Je } from "./template-review-PgEe_Wr9.js";
|
|
14
|
+
import { D as br, P as yr, b as Mr, c as xr, e as Er, f as Tr, g as Sr, h as Cr, i as Rr, j as Pr, k as Ar, l as kr, m as Ir, n as Nr, o as $r, q as Lr, r as Dr, s as Fr, t as Or, u as zr, v as Hr, w as _r, x as Br, y as jr, z as Wr } from "./template-review-PgEe_Wr9.js";
|
|
15
|
+
import { r as Pe } from "./grid-geometry-BNptEcMm.js";
|
|
16
|
+
import { r as Ae } from "./grid-strokes-DyyG1q_o.js";
|
|
17
|
+
import { r as G, n as ke, O as Ke } from "./capabilities-CK_7hizc.js";
|
|
18
|
+
import { i as Ur } from "./capabilities-CK_7hizc.js";
|
|
19
|
+
import { o as Xe } from "./progress-7OSZbFok.js";
|
|
20
|
+
import { c as Ze } from "./page-window-index-CIuT4BAv.js";
|
|
21
|
+
import { v as Ie, R as Ne, p as I } from "./template-registry-BjE1VS6g.js";
|
|
22
|
+
import { a as qr, c as Yr, d as Jr, s as Kr, b as Xr } from "./template-registry-BjE1VS6g.js";
|
|
23
|
+
import { R as Qr, a as ei, f as ti, i as ni, b as ri, c as ii, p as oi, r as ai, v as si, d as li } from "./param-validation-BlHHXs6u.js";
|
|
24
|
+
import { T as di, c as mi, v as hi } from "./tree-CqcQ99NM.js";
|
|
25
|
+
const Qe = {
|
|
27
26
|
root: "mr-root",
|
|
28
27
|
page: "mr-page",
|
|
29
28
|
comp: "mr-comp",
|
|
@@ -41,9 +40,9 @@ const Ye = {
|
|
|
41
40
|
unknown: "mr-unknown"
|
|
42
41
|
};
|
|
43
42
|
function E(e, t) {
|
|
44
|
-
return t?.classNames?.[e] ??
|
|
43
|
+
return t?.classNames?.[e] ?? Qe[e];
|
|
45
44
|
}
|
|
46
|
-
class
|
|
45
|
+
class et {
|
|
47
46
|
constructor() {
|
|
48
47
|
this.props = [];
|
|
49
48
|
}
|
|
@@ -65,50 +64,50 @@ class Ke {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
function y(e, t = "unset") {
|
|
68
|
-
return new
|
|
67
|
+
return new et().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
69
68
|
}
|
|
70
|
-
function
|
|
69
|
+
function $e(e, t, n) {
|
|
71
70
|
e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(Q(t))).add("text-align", t.align);
|
|
72
|
-
const r =
|
|
71
|
+
const r = _(t, n);
|
|
73
72
|
e.add("font-size", `${H(r.fontSizePx, 2)}px`);
|
|
74
73
|
}
|
|
75
|
-
function
|
|
74
|
+
function tt(e, t, n) {
|
|
76
75
|
const r = t.style ?? {};
|
|
77
|
-
|
|
76
|
+
$e(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
|
|
78
77
|
}
|
|
79
|
-
function
|
|
78
|
+
function nt(e, t, n, r, i, o) {
|
|
80
79
|
const s = e.cell, a = o.createElement("td");
|
|
81
80
|
a.className = E("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), s.colSpan && (a.colSpan = s.colSpan), s.rowSpan && (a.rowSpan = s.rowSpan);
|
|
82
|
-
const l =
|
|
83
|
-
|
|
81
|
+
const l = Te(t.style, s.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", l.backgroundColor).add("vertical-align", l.verticalAlign ?? "middle");
|
|
82
|
+
$e(c, l, r), c.applyTo(a);
|
|
84
83
|
const d = o.createElement("div");
|
|
85
84
|
d.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n + (s.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", l.verticalAlign === "top" ? "flex-start" : l.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), s.text != null && d.append(s.text);
|
|
86
|
-
for (const m of s.children ?? []) d.appendChild(
|
|
85
|
+
for (const m of s.children ?? []) d.appendChild(Le(m, r, i, o));
|
|
87
86
|
return a.appendChild(d), a;
|
|
88
87
|
}
|
|
89
|
-
function
|
|
90
|
-
return
|
|
88
|
+
function rt(e, t, n, r) {
|
|
89
|
+
return Ae(e, t).map((i) => {
|
|
91
90
|
const o = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, s = r.createElement("div");
|
|
92
91
|
s.className = "mr-grid-edge", s.setAttribute("aria-hidden", "true");
|
|
93
92
|
const a = i.kind === "h";
|
|
94
93
|
return y("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", o).applyTo(s), s;
|
|
95
94
|
});
|
|
96
95
|
}
|
|
97
|
-
function
|
|
96
|
+
function it(e, t, n, r, i) {
|
|
98
97
|
const o = i.createElement("table");
|
|
99
98
|
o.className = E("grid", r), o.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
|
|
100
|
-
const s =
|
|
99
|
+
const s = Pe(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
|
|
101
100
|
y("contents").applyTo(a), o.appendChild(a);
|
|
102
101
|
const l = e.cells.map(() => {
|
|
103
102
|
const d = i.createElement("tr");
|
|
104
103
|
return d.className = E("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
|
|
105
104
|
});
|
|
106
105
|
for (const d of s.cells)
|
|
107
|
-
l[d.ri].appendChild(
|
|
106
|
+
l[d.ri].appendChild(nt(d, t, e.paddingMm ?? 0.5, n, r, i));
|
|
108
107
|
const c = i.createElement("div");
|
|
109
|
-
return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...
|
|
108
|
+
return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...rt(s, t, n, i)), c;
|
|
110
109
|
}
|
|
111
|
-
function
|
|
110
|
+
function ot(e, t, n, r) {
|
|
112
111
|
const i = r.createElement("div");
|
|
113
112
|
i.className = E("paragraph", n), y("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
|
|
114
113
|
for (const o of e.segments || []) {
|
|
@@ -117,17 +116,17 @@ function et(e, t, n, r) {
|
|
|
117
116
|
const a = y("inline");
|
|
118
117
|
if (o.style) {
|
|
119
118
|
const l = o.style;
|
|
120
|
-
a.add("color", l.color).add("font-family", l.fontFamily).add("font-weight", l.bold != null ? l.bold ? "700" : "400" : void 0).add("font-style", l.italic != null ? l.italic ? "italic" : "normal" : void 0).add("text-decoration", l.underline != null ? l.underline ? "underline" : "none" : void 0), (l.fontSize != null || l.fontSizePx != null) && a.add("font-size", `${H(
|
|
119
|
+
a.add("color", l.color).add("font-family", l.fontFamily).add("font-weight", l.bold != null ? l.bold ? "700" : "400" : void 0).add("font-style", l.italic != null ? l.italic ? "italic" : "normal" : void 0).add("text-decoration", l.underline != null ? l.underline ? "underline" : "none" : void 0), (l.fontSize != null || l.fontSizePx != null) && a.add("font-size", `${H(_(l, t).fontSizePx, 2)}px`);
|
|
121
120
|
}
|
|
122
121
|
a.applyTo(s), i.appendChild(s);
|
|
123
122
|
}
|
|
124
123
|
return i;
|
|
125
124
|
}
|
|
126
|
-
function
|
|
127
|
-
if (
|
|
125
|
+
function at(e, t, n, r) {
|
|
126
|
+
if (Ce(e)) {
|
|
128
127
|
const i = r.createElement("div");
|
|
129
128
|
i.className = E("rich", n), y("block").applyTo(i);
|
|
130
|
-
for (const o of e.richParagraphs) i.appendChild(
|
|
129
|
+
for (const o of e.richParagraphs) i.appendChild(ot(o, t, n, r));
|
|
131
130
|
return i;
|
|
132
131
|
}
|
|
133
132
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
@@ -141,23 +140,23 @@ function tt(e, t, n, r) {
|
|
|
141
140
|
}
|
|
142
141
|
return e.text ?? "";
|
|
143
142
|
}
|
|
144
|
-
function
|
|
143
|
+
function st(e, t, n, r) {
|
|
145
144
|
const i = r.createElement("div");
|
|
146
145
|
i.className = E("text", n);
|
|
147
146
|
const o = e.style || {};
|
|
148
|
-
return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(
|
|
147
|
+
return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(at(e, t, n, r)), i;
|
|
149
148
|
}
|
|
150
|
-
function
|
|
149
|
+
function lt(e, t, n) {
|
|
151
150
|
const r = n.createElement("img");
|
|
152
151
|
return r.className = E("image", t), r.src = e.imageData, y("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
|
|
153
152
|
}
|
|
154
|
-
function
|
|
153
|
+
function fe(e, t, n, r) {
|
|
155
154
|
const i = r.createElement("div");
|
|
156
155
|
i.className = E("shape", n);
|
|
157
|
-
const o = e.style || {}, s = j(o), a =
|
|
156
|
+
const o = e.style || {}, s = j(o), a = Ee(o), l = `${H(s.widthPt * t / 72, 2)}px solid ${s.color}`, c = y("block");
|
|
158
157
|
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", l), a.right && c.add("border-right", l), a.bottom && c.add("border-bottom", l), a.left && c.add("border-left", l)) : e.kind === "ellipse" ? (a.inner && c.add("border", l).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", l), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
|
|
159
158
|
}
|
|
160
|
-
function
|
|
159
|
+
function ct(e, t, n) {
|
|
161
160
|
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = ie(e.widthMm, t), o = ie(e.heightMm, t);
|
|
162
161
|
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
163
162
|
const s = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
@@ -165,44 +164,44 @@ function it(e, t, n) {
|
|
|
165
164
|
const a = j({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
166
165
|
return s.setAttribute("stroke", a.color), s.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(s), r;
|
|
167
166
|
}
|
|
168
|
-
function
|
|
167
|
+
function Le(e, t, n, r) {
|
|
169
168
|
const i = r.createElement("div");
|
|
170
169
|
i.className = `${E("comp", n)} mr-kind-${e.kind}`;
|
|
171
170
|
const o = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
|
|
172
|
-
if (
|
|
173
|
-
return i.appendChild(
|
|
171
|
+
if (tt(o, e, t), o.applyTo(i), ee(e))
|
|
172
|
+
return i.appendChild(lt(e, n, r)), i;
|
|
174
173
|
if (e.kind === "text")
|
|
175
|
-
return i.appendChild(
|
|
174
|
+
return i.appendChild(st(e, t, n, r)), i;
|
|
176
175
|
if (e.grid) {
|
|
177
|
-
const a =
|
|
178
|
-
return a.appendChild(
|
|
176
|
+
const a = fe(e, t, n, r);
|
|
177
|
+
return a.appendChild(it(e.grid, e, t, n, r)), i.appendChild(a), i;
|
|
179
178
|
}
|
|
180
179
|
if (e.kind === "line" && e.lineDirection)
|
|
181
|
-
return i.appendChild(
|
|
180
|
+
return i.appendChild(ct(e, t, r)), i;
|
|
182
181
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
183
|
-
return i.appendChild(
|
|
182
|
+
return i.appendChild(fe(e, t, n, r)), i;
|
|
184
183
|
const s = r.createElement("div");
|
|
185
184
|
return s.className = E("unknown", n), y("block").applyTo(s), s.textContent = e.fallbackText ?? `[${e.kind}]`, s.dataset.mrUnsupported = e.kind, s.setAttribute("role", "note"), i.appendChild(s), i;
|
|
186
185
|
}
|
|
187
|
-
function
|
|
186
|
+
function dt(e, t, n, r) {
|
|
188
187
|
const i = r.createElement("div");
|
|
189
|
-
return i.className = E("page", n), y("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${H(
|
|
190
|
-
const a =
|
|
188
|
+
return i.className = E("page", n), y("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${H(_(void 0, t).fontSizePx, 2)}px`).add("line-height", String(Q(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", xe).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, s) => {
|
|
189
|
+
const a = Le(o, t, n, r);
|
|
191
190
|
a.dataset.mrComponentIndex = String(s), i.appendChild(a);
|
|
192
191
|
}), i;
|
|
193
192
|
}
|
|
194
|
-
function
|
|
193
|
+
function wn(e, t, n = {}) {
|
|
195
194
|
const r = n.dpi ?? 96;
|
|
196
195
|
G(e, "dom", n);
|
|
197
196
|
const i = t.createElement("div");
|
|
198
197
|
return i.className = E("root", n), y("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
|
|
199
|
-
i.appendChild(
|
|
198
|
+
i.appendChild(dt(o, r, n, t));
|
|
200
199
|
}), i;
|
|
201
200
|
}
|
|
202
201
|
function R(e) {
|
|
203
202
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
204
203
|
}
|
|
205
|
-
const
|
|
204
|
+
const mt = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
206
205
|
const i = new Image(), o = () => {
|
|
207
206
|
i.onload = null, i.onerror = null, t?.removeEventListener("abort", s);
|
|
208
207
|
}, s = () => {
|
|
@@ -214,63 +213,63 @@ const at = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.
|
|
|
214
213
|
o(), r(new Error("Image could not be decoded for Canvas output."));
|
|
215
214
|
}, t?.addEventListener("abort", s, { once: !0 }), i.src = e;
|
|
216
215
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
217
|
-
function
|
|
216
|
+
function ht(e, t, n) {
|
|
218
217
|
return R(n), n ? new Promise((r, i) => {
|
|
219
218
|
const o = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
220
219
|
n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", o));
|
|
221
220
|
}) : e(t);
|
|
222
221
|
}
|
|
223
|
-
async function
|
|
222
|
+
async function gt(e, t, n) {
|
|
224
223
|
const r = /* @__PURE__ */ new Map();
|
|
225
224
|
for (const i of e.components)
|
|
226
|
-
!ee(i) || r.has(i.imageData) || r.set(i.imageData, await
|
|
225
|
+
!ee(i) || r.has(i.imageData) || r.set(i.imageData, await ht(t, i.imageData, n));
|
|
227
226
|
return R(n), r;
|
|
228
227
|
}
|
|
229
|
-
function
|
|
228
|
+
function ut(e, t, n, r, i, o) {
|
|
230
229
|
const s = t, a = s.naturalWidth ?? s.width ?? i, l = s.naturalHeight ?? s.height ?? o;
|
|
231
230
|
if (a <= 0 || l <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
232
231
|
const c = Math.min(i / a, o / l), d = a * c, m = l * c;
|
|
233
232
|
e.drawImage(t, n + (i - d) / 2, r + (o - m) / 2, d, m);
|
|
234
233
|
}
|
|
235
|
-
function
|
|
236
|
-
return
|
|
234
|
+
function ft(e) {
|
|
235
|
+
return Ze(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
237
236
|
}
|
|
238
|
-
const
|
|
239
|
-
function
|
|
240
|
-
const n = t / 96 *
|
|
237
|
+
const le = 96 / 25.4;
|
|
238
|
+
function ce(e, t = 96) {
|
|
239
|
+
const n = t / 96 * le;
|
|
241
240
|
return {
|
|
242
241
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
243
242
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
244
243
|
};
|
|
245
244
|
}
|
|
246
|
-
function
|
|
245
|
+
function De(e, t, n, r = 64e6) {
|
|
247
246
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
248
247
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
249
|
-
const i =
|
|
248
|
+
const i = ce(e, n), o = Math.round(i.widthPx * t), s = Math.round(i.heightPx * t);
|
|
250
249
|
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(s) || o * s > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
251
250
|
return { width: o, height: s };
|
|
252
251
|
}
|
|
253
|
-
function
|
|
254
|
-
const i = document.createElement("canvas"), { widthPx: o, heightPx: s } =
|
|
252
|
+
function Fe(e, t, n, r) {
|
|
253
|
+
const i = document.createElement("canvas"), { widthPx: o, heightPx: s } = ce(e, n), a = De(e, t, n, r);
|
|
255
254
|
i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${s}px`;
|
|
256
255
|
const l = i.getContext("2d");
|
|
257
256
|
if (!l)
|
|
258
257
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
259
258
|
return l.scale(t, t), l.fillStyle = "#ffffff", l.fillRect(0, 0, o, s), { canvas: i, ctx: l };
|
|
260
259
|
}
|
|
261
|
-
function
|
|
262
|
-
return
|
|
260
|
+
function vn(e, t = 96) {
|
|
261
|
+
return _(e, t).fontSizePx;
|
|
263
262
|
}
|
|
264
|
-
function
|
|
263
|
+
function Oe(e, t, n, r, i, o, s, a = "top") {
|
|
265
264
|
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${s}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
|
|
266
265
|
const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
267
266
|
`), d = c.length * l;
|
|
268
267
|
let m = r;
|
|
269
|
-
a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h,
|
|
270
|
-
|
|
268
|
+
a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h, g) => {
|
|
269
|
+
pt(e, h, t, n, m + g * l + t.fontSizePx * 0.8, i);
|
|
271
270
|
}), e.textAlign = "left";
|
|
272
271
|
}
|
|
273
|
-
function
|
|
272
|
+
function pt(e, t, n, r, i, o) {
|
|
274
273
|
const s = Array.from(t), a = n.letterSpacingPx ?? 0;
|
|
275
274
|
if (!a) {
|
|
276
275
|
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
@@ -285,89 +284,89 @@ function mt(e, t, n, r, i, o) {
|
|
|
285
284
|
e.fillText(m, c + e.measureText(d).width + h * a, i), d += m;
|
|
286
285
|
});
|
|
287
286
|
}
|
|
288
|
-
function
|
|
289
|
-
for (const a of
|
|
287
|
+
function wt(e, t, n, r, i, o, s) {
|
|
288
|
+
for (const a of Ae(t, n))
|
|
290
289
|
e.strokeStyle = a.color, e.lineWidth = O(a.widthPt, s), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * o, i + a.from * o), e.lineTo(r + a.pos * o, i + a.to * o)) : (e.moveTo(r + a.from * o, i + a.pos * o), e.lineTo(r + a.to * o, i + a.pos * o)), e.stroke();
|
|
291
290
|
}
|
|
292
|
-
function
|
|
291
|
+
function vt(e, t, n, r, i, o) {
|
|
293
292
|
e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + i, r)), t.right && (e.moveTo(n + i, r), e.lineTo(n + i, r + o)), t.bottom && (e.moveTo(n + i, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
|
|
294
293
|
}
|
|
295
|
-
function
|
|
296
|
-
const m =
|
|
297
|
-
for (const
|
|
298
|
-
const f =
|
|
299
|
-
f && (e.fillStyle = f, e.fillRect(r +
|
|
294
|
+
function bt(e, t, n, r, i, o, s, a, l, c, d) {
|
|
295
|
+
const m = Pe(t, o / a, s / a);
|
|
296
|
+
for (const g of m.cells) {
|
|
297
|
+
const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
298
|
+
f && (e.fillStyle = f, e.fillRect(r + g.xMm * a, i + g.yMm * a, g.widthMm * a, g.heightMm * a));
|
|
300
299
|
}
|
|
301
|
-
|
|
300
|
+
wt(e, m, n, r, i, a, l);
|
|
302
301
|
const h = t.paddingMm ?? 0.5;
|
|
303
|
-
for (const
|
|
304
|
-
const f =
|
|
302
|
+
for (const g of m.cells) {
|
|
303
|
+
const f = g.cell.text ?? "";
|
|
305
304
|
if (!f) continue;
|
|
306
|
-
const
|
|
305
|
+
const v = Te(n.style, g.cell.style), N = _(v, l), C = g.cell.indentMm ?? 0, T = Math.max(0, g.widthMm - 2 * h - C), A = Re(f, T, { fontSizePt: N.fontSizePt, bold: v.bold, italic: v.italic, fontFamily: v.fontFamily ?? c, letterSpacingPt: v.letterSpacing }, d).join(`
|
|
307
306
|
`);
|
|
308
|
-
|
|
307
|
+
Oe(
|
|
309
308
|
e,
|
|
310
309
|
{
|
|
311
310
|
text: A,
|
|
312
|
-
fontSizePx:
|
|
313
|
-
bold:
|
|
314
|
-
italic:
|
|
315
|
-
color:
|
|
316
|
-
align:
|
|
317
|
-
lineHeight: Q(
|
|
318
|
-
letterSpacingPx: O(
|
|
311
|
+
fontSizePx: N.fontSizePx,
|
|
312
|
+
bold: v.bold ?? !1,
|
|
313
|
+
italic: v.italic,
|
|
314
|
+
color: Se(v, xe),
|
|
315
|
+
align: v.align ?? "left",
|
|
316
|
+
lineHeight: Q(v),
|
|
317
|
+
letterSpacingPx: O(v.letterSpacing ?? 0, l)
|
|
319
318
|
},
|
|
320
|
-
r + (
|
|
321
|
-
i + (
|
|
322
|
-
|
|
323
|
-
Math.max(0,
|
|
324
|
-
|
|
325
|
-
|
|
319
|
+
r + (g.xMm + h + C) * a,
|
|
320
|
+
i + (g.yMm + h) * a,
|
|
321
|
+
T * a,
|
|
322
|
+
Math.max(0, g.heightMm - 2 * h) * a,
|
|
323
|
+
v.fontFamily ?? c,
|
|
324
|
+
v.verticalAlign ?? "middle"
|
|
326
325
|
);
|
|
327
326
|
}
|
|
328
327
|
}
|
|
329
|
-
function
|
|
330
|
-
const c = t.style ?? {}, d =
|
|
328
|
+
function yt(e, t, n, r, i, o, s, a, l) {
|
|
329
|
+
const c = t.style ?? {}, d = _(c, s), m = Ce(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.field ?? "").join("")).join(`
|
|
331
330
|
`) : t.lines?.length ? t.lines.join(`
|
|
332
|
-
`) :
|
|
331
|
+
`) : Re(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, l).join(`
|
|
333
332
|
`);
|
|
334
|
-
|
|
333
|
+
Oe(e, {
|
|
335
334
|
text: m,
|
|
336
335
|
fontSizePx: d.fontSizePx,
|
|
337
336
|
bold: c.bold ?? !1,
|
|
338
337
|
italic: c.italic,
|
|
339
|
-
color:
|
|
338
|
+
color: Se(c),
|
|
340
339
|
align: c.align ?? "left",
|
|
341
340
|
lineHeight: Q(c),
|
|
342
341
|
letterSpacingPx: O(c.letterSpacing ?? 0, s)
|
|
343
342
|
}, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
|
|
344
343
|
}
|
|
345
|
-
function
|
|
344
|
+
function de(e, t, n, r, i, o, s) {
|
|
346
345
|
const a = t.leftMm * n, l = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
|
|
347
346
|
if (ee(t)) {
|
|
348
347
|
const h = s?.get(t.imageData);
|
|
349
|
-
h ?
|
|
348
|
+
h ? ut(e, h, a, l, c, d) : pe(e, t, a, l, c, d);
|
|
350
349
|
return;
|
|
351
350
|
}
|
|
352
351
|
if (t.grid) {
|
|
353
|
-
|
|
352
|
+
bt(e, t.grid, t, a, l, c, d, n, r, i, o);
|
|
354
353
|
return;
|
|
355
354
|
}
|
|
356
355
|
switch (t.kind) {
|
|
357
356
|
case "text": {
|
|
358
|
-
|
|
357
|
+
yt(e, t, a, l, c, d, r, i, o);
|
|
359
358
|
break;
|
|
360
359
|
}
|
|
361
360
|
case "rect": {
|
|
362
|
-
const h = j(m),
|
|
363
|
-
m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, l, c, d)),
|
|
361
|
+
const h = j(m), g = Ee(m);
|
|
362
|
+
m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, l, c, d)), g.inner && (e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), vt(e, g, a, l, c, d));
|
|
364
363
|
break;
|
|
365
364
|
}
|
|
366
365
|
case "line": {
|
|
367
366
|
const h = j({ ...m, borderColor: m.lineColor ?? m.borderColor });
|
|
368
367
|
e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), e.beginPath();
|
|
369
|
-
const
|
|
370
|
-
e.moveTo(a,
|
|
368
|
+
const g = t.lineDirection === "up" ? l + d : t.lineDirection === "down" ? l : l + d / 2, f = t.lineDirection === "up" ? l : t.lineDirection === "down" ? l + d : l + d / 2;
|
|
369
|
+
e.moveTo(a, g), e.lineTo(a + c, f), e.stroke();
|
|
371
370
|
break;
|
|
372
371
|
}
|
|
373
372
|
case "ellipse": {
|
|
@@ -376,14 +375,14 @@ function ce(e, t, n, r, i, o, s) {
|
|
|
376
375
|
break;
|
|
377
376
|
}
|
|
378
377
|
default:
|
|
379
|
-
|
|
378
|
+
pe(e, t, a, l, c, d);
|
|
380
379
|
break;
|
|
381
380
|
}
|
|
382
381
|
}
|
|
383
|
-
function
|
|
382
|
+
function pe(e, t, n, r, i, o) {
|
|
384
383
|
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
385
384
|
}
|
|
386
|
-
async function
|
|
385
|
+
async function bn(e, t = {}) {
|
|
387
386
|
if (typeof document > "u")
|
|
388
387
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
389
388
|
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
@@ -395,17 +394,17 @@ async function un(e, t = {}) {
|
|
|
395
394
|
const s = [...o.diagnostics, ...G(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", l = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
396
395
|
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
397
396
|
R(t.signal);
|
|
398
|
-
const m = await
|
|
397
|
+
const m = await ze(e.pages[d], d, i, s);
|
|
399
398
|
try {
|
|
400
|
-
l.push(await
|
|
399
|
+
l.push(await Mt(m, a, r, t.signal));
|
|
401
400
|
} finally {
|
|
402
401
|
m.width = 0, m.height = 0;
|
|
403
402
|
}
|
|
404
|
-
await
|
|
403
|
+
await Xe(t, l.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
405
404
|
}
|
|
406
405
|
return R(t.signal), { blobs: l, diagnostics: s };
|
|
407
406
|
}
|
|
408
|
-
function
|
|
407
|
+
function Mt(e, t, n, r) {
|
|
409
408
|
return R(r), new Promise((i, o) => {
|
|
410
409
|
const s = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
411
410
|
r?.addEventListener("abort", s, { once: !0 });
|
|
@@ -418,23 +417,23 @@ function pt(e, t, n, r) {
|
|
|
418
417
|
}
|
|
419
418
|
});
|
|
420
419
|
}
|
|
421
|
-
function
|
|
420
|
+
function yn(e, t = {}) {
|
|
422
421
|
if (R(t.signal), typeof document > "u")
|
|
423
422
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
424
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
423
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * le, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = G(e, "canvas", t), m = xt(e, a, l);
|
|
425
424
|
for (const h of m)
|
|
426
|
-
|
|
427
|
-
if (t.fidelity === "strict" && m.length) throw new
|
|
425
|
+
ke(h, t), d.push(h);
|
|
426
|
+
if (t.fidelity === "strict" && m.length) throw new Ke(d);
|
|
428
427
|
for (let h = a; h <= l; h++) {
|
|
429
428
|
R(t.signal);
|
|
430
|
-
const
|
|
431
|
-
for (const
|
|
432
|
-
|
|
429
|
+
const g = e.pages[h], { canvas: f, ctx: v } = Fe(g, n, r, t.maxCanvasPixels);
|
|
430
|
+
for (const N of g.components)
|
|
431
|
+
de(v, N, i, r, o, s);
|
|
433
432
|
c.push(f);
|
|
434
433
|
}
|
|
435
434
|
return { canvases: c, diagnostics: d };
|
|
436
435
|
}
|
|
437
|
-
function
|
|
436
|
+
function xt(e, t, n) {
|
|
438
437
|
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, s) => ee(o) ? [{
|
|
439
438
|
code: "async-image-required",
|
|
440
439
|
severity: "warning",
|
|
@@ -446,143 +445,147 @@ function wt(e, t, n) {
|
|
|
446
445
|
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
447
446
|
}] : []));
|
|
448
447
|
}
|
|
449
|
-
async function
|
|
448
|
+
async function Mn(e, t = {}) {
|
|
450
449
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
451
450
|
R(t.signal);
|
|
452
451
|
const n = await ae(e, { ...t, format: "canvas" });
|
|
453
452
|
e = n.plan;
|
|
454
453
|
const r = [...n.diagnostics, ...G(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
455
454
|
for (let s = Math.max(0, t.start ?? 0); s <= o; s++)
|
|
456
|
-
i.push(await
|
|
455
|
+
i.push(await ze(e.pages[s], s, t, r));
|
|
457
456
|
return { canvases: i, diagnostics: r };
|
|
458
457
|
}
|
|
459
|
-
async function
|
|
460
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, s = n.fontFamily ?? Z, a = await
|
|
458
|
+
async function ze(e, t, n, r) {
|
|
459
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, s = n.fontFamily ?? Z, a = await He(e, t, n, r);
|
|
461
460
|
R(n.signal);
|
|
462
|
-
const { canvas: l, ctx: c } =
|
|
463
|
-
for (const d of e.components)
|
|
461
|
+
const { canvas: l, ctx: c } = Fe(e, i, o, n.maxCanvasPixels);
|
|
462
|
+
for (const d of e.components) de(c, d, o / 25.4, o, s, n.measurer ?? oe, a);
|
|
464
463
|
return l;
|
|
465
464
|
}
|
|
466
|
-
async function
|
|
467
|
-
const i = n.imageLoader ??
|
|
468
|
-
return
|
|
465
|
+
async function He(e, t, n, r) {
|
|
466
|
+
const i = n.imageLoader ?? mt;
|
|
467
|
+
return gt(e, async (o, s) => {
|
|
469
468
|
try {
|
|
470
469
|
return await i(o, s);
|
|
471
470
|
} catch (a) {
|
|
472
471
|
if (s?.aborted) throw a;
|
|
473
472
|
const l = e.components.findIndex((m) => m.imageData === o), c = e.components[l], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: l, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
474
|
-
throw r.push(d),
|
|
473
|
+
throw r.push(d), ke(d, n), a;
|
|
475
474
|
}
|
|
476
475
|
}, n.signal);
|
|
477
476
|
}
|
|
478
|
-
function
|
|
479
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
480
|
-
let
|
|
481
|
-
const
|
|
482
|
-
function
|
|
483
|
-
const
|
|
484
|
-
|
|
477
|
+
function xn(e, t = {}) {
|
|
478
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * le, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = t.overscan ?? 1, l = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((u) => u.pageHeightMm * i), m = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * i)), h = { start: 0, end: -1 };
|
|
479
|
+
let g = null, f = null, v = null, N = null, C = [], T = 0, A = [], U = 0, B = new AbortController();
|
|
480
|
+
const he = [];
|
|
481
|
+
function je() {
|
|
482
|
+
const u = g;
|
|
483
|
+
u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, v = document.createElement("div"), N = document.createElement("div"), f.appendChild(v), C = [];
|
|
485
484
|
const M = Math.min(e.pages.length, 3 + a * 2);
|
|
486
485
|
for (let D = 0; D < M; D++) {
|
|
487
|
-
const
|
|
488
|
-
|
|
486
|
+
const b = document.createElement("div");
|
|
487
|
+
b.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(b), C.push(b);
|
|
489
488
|
}
|
|
490
|
-
f.appendChild(
|
|
489
|
+
f.appendChild(N), u.appendChild(f);
|
|
491
490
|
}
|
|
492
|
-
async function
|
|
493
|
-
const D = U,
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
if (D !== U || !
|
|
497
|
-
const { widthPx: ne, heightPx: re } =
|
|
498
|
-
let
|
|
499
|
-
(
|
|
500
|
-
const ue =
|
|
501
|
-
|
|
502
|
-
const F =
|
|
491
|
+
async function We(u, M) {
|
|
492
|
+
const D = U, b = await ae(e, { ...t, signal: B.signal, format: "canvas", start: M, end: M });
|
|
493
|
+
he.push(...b.diagnostics);
|
|
494
|
+
const S = b.plan.pages[M], Y = await He(S, M, { ...t, signal: B.signal }, he);
|
|
495
|
+
if (D !== U || !g) return;
|
|
496
|
+
const { widthPx: ne, heightPx: re } = ce(S, r);
|
|
497
|
+
let $ = u.firstElementChild;
|
|
498
|
+
(!$ || $.tagName !== "CANVAS") && ($ = document.createElement("canvas"), u.innerHTML = "", u.appendChild($));
|
|
499
|
+
const ue = De(S, n, r, t.maxCanvasPixels);
|
|
500
|
+
$.width = ue.width, $.height = ue.height, $.style.width = `${ne}px`, $.style.height = `${re}px`;
|
|
501
|
+
const F = $.getContext("2d");
|
|
503
502
|
if (F) {
|
|
504
503
|
F.setTransform(1, 0, 0, 1, 0, 0), F.scale(n, n), F.fillStyle = "#ffffff", F.fillRect(0, 0, ne, re);
|
|
505
|
-
for (const
|
|
506
|
-
|
|
507
|
-
|
|
504
|
+
for (const Ue of S.components)
|
|
505
|
+
de(F, Ue, i, r, o, s, Y);
|
|
506
|
+
$.dataset.canvasPage = String(M), u.style.height = `${re}px`, u.style.width = `${ne}px`;
|
|
508
507
|
}
|
|
509
508
|
}
|
|
510
|
-
function
|
|
511
|
-
U++, h.start =
|
|
512
|
-
const M = e.pages.length - 1 -
|
|
513
|
-
|
|
514
|
-
const D =
|
|
515
|
-
C.forEach((
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
const Y =
|
|
519
|
-
|
|
509
|
+
function Ge(u) {
|
|
510
|
+
U++, h.start = u.start, h.end = u.end, v.style.height = `${u.start * l + d.slice(0, u.start).reduce((b, S) => b + S, 0)}px`;
|
|
511
|
+
const M = e.pages.length - 1 - u.end;
|
|
512
|
+
N.style.height = `${M * l + d.slice(u.end + 1).reduce((b, S) => b + S, 0)}px`;
|
|
513
|
+
const D = u.end - u.start + 1;
|
|
514
|
+
C.forEach((b, S) => {
|
|
515
|
+
if (S < D) {
|
|
516
|
+
b.style.display = "";
|
|
517
|
+
const Y = u.start + S;
|
|
518
|
+
b.style.height = `${d[Y] ?? 0}px`;
|
|
520
519
|
} else
|
|
521
|
-
|
|
520
|
+
b.style.display = "none";
|
|
522
521
|
}), A = [];
|
|
523
|
-
for (let
|
|
524
|
-
const
|
|
525
|
-
if (!
|
|
526
|
-
|
|
522
|
+
for (let b = u.start; b <= u.end; b++) {
|
|
523
|
+
const S = C[b - u.start];
|
|
524
|
+
if (!S) continue;
|
|
525
|
+
S.firstElementChild?.dataset?.canvasPage !== String(b) && A.push(b);
|
|
527
526
|
}
|
|
528
527
|
te();
|
|
529
528
|
}
|
|
530
529
|
function te() {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
let
|
|
534
|
-
for (; A.length > 0 &&
|
|
530
|
+
T || A.length === 0 || (T = requestAnimationFrame(() => {
|
|
531
|
+
T = 0;
|
|
532
|
+
let u = Math.max(1, c);
|
|
533
|
+
for (; A.length > 0 && u-- > 0; ) {
|
|
535
534
|
const M = A.shift(), D = C[M - h.start];
|
|
536
|
-
D &&
|
|
535
|
+
D && We(D, M).catch(() => {
|
|
537
536
|
});
|
|
538
537
|
}
|
|
539
538
|
A.length > 0 && te();
|
|
540
539
|
}));
|
|
541
540
|
}
|
|
542
541
|
function V() {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
const
|
|
542
|
+
T || (T = requestAnimationFrame(() => {
|
|
543
|
+
T = 0;
|
|
544
|
+
const u = g, M = ft({
|
|
546
545
|
pageHeightsPx: d,
|
|
547
|
-
viewportHeightPx:
|
|
548
|
-
scrollTopPx:
|
|
546
|
+
viewportHeightPx: u.clientHeight,
|
|
547
|
+
scrollTopPx: u.scrollTop,
|
|
549
548
|
overscan: a,
|
|
550
549
|
gapPx: l
|
|
551
550
|
});
|
|
552
|
-
M.start !== h.start || M.end !== h.end ?
|
|
551
|
+
M.start !== h.start || M.end !== h.end ? Ge(M) : te();
|
|
553
552
|
}));
|
|
554
553
|
}
|
|
555
554
|
let q = null;
|
|
556
555
|
return {
|
|
557
|
-
attach(
|
|
556
|
+
attach(u) {
|
|
558
557
|
if (typeof document > "u")
|
|
559
558
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
560
|
-
R(t.signal),
|
|
559
|
+
R(t.signal), B = new AbortController(), t.signal?.addEventListener("abort", ge, { once: !0 }), G(e, "canvas", t), g = u, je(), u.addEventListener("scroll", V, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => V()), q.observe(u)), V();
|
|
561
560
|
},
|
|
562
561
|
destroy() {
|
|
563
|
-
U++,
|
|
562
|
+
U++, B.abort(), t.signal?.removeEventListener("abort", ge), T && cancelAnimationFrame(T), T = 0, q?.disconnect(), q = null, g?.removeEventListener("scroll", V), A = [], f?.remove(), g = null;
|
|
564
563
|
},
|
|
565
564
|
window() {
|
|
566
565
|
return { ...h };
|
|
567
566
|
}
|
|
568
567
|
};
|
|
569
|
-
function
|
|
570
|
-
|
|
568
|
+
function ge() {
|
|
569
|
+
B.abort(t.signal?.reason);
|
|
571
570
|
}
|
|
572
571
|
}
|
|
573
|
-
function
|
|
572
|
+
function _e(e, t, n) {
|
|
574
573
|
let r, i;
|
|
575
574
|
if (typeof e == "string") {
|
|
576
|
-
const o =
|
|
577
|
-
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(
|
|
575
|
+
const o = J[e];
|
|
576
|
+
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(J).join("/")})`);
|
|
578
577
|
r = o.widthMm, i = o.heightMm;
|
|
579
578
|
} else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
|
|
580
579
|
return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
|
|
581
580
|
}
|
|
582
|
-
class
|
|
581
|
+
class Et {
|
|
583
582
|
constructor() {
|
|
584
583
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
585
584
|
}
|
|
585
|
+
/** Fixed label pages repeat in record → copy → template-page order. */
|
|
586
|
+
repeat(t) {
|
|
587
|
+
return this.templateRepeat = t, this;
|
|
588
|
+
}
|
|
586
589
|
/**
|
|
587
590
|
* 声明报表参数(链式,可放在 .page() 前后任意位置):
|
|
588
591
|
* 渲染组件据此自动生成查询面板(也可由 paramDefs prop 提供,prop 优先)。
|
|
@@ -608,12 +611,12 @@ class bt {
|
|
|
608
611
|
*/
|
|
609
612
|
page(t = "a4", n = {}, r) {
|
|
610
613
|
this.collect();
|
|
611
|
-
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: s, heightMm: a } =
|
|
614
|
+
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: s, heightMm: a } = _e(
|
|
612
615
|
t,
|
|
613
616
|
typeof n == "number" ? n : void 0,
|
|
614
617
|
o.landscape
|
|
615
618
|
), l = o.margins ?? {};
|
|
616
|
-
return this.pending = new
|
|
619
|
+
return this.pending = new Tt(this, {
|
|
617
620
|
widthMm: s,
|
|
618
621
|
heightMm: a,
|
|
619
622
|
marginTopMm: l.marginTopMm ?? 10,
|
|
@@ -628,10 +631,14 @@ class bt {
|
|
|
628
631
|
build() {
|
|
629
632
|
if (this.collect(), this.pages.length === 0)
|
|
630
633
|
throw new Error("模板至少需要一页:先调用 .page() 添加内容");
|
|
631
|
-
return
|
|
634
|
+
return {
|
|
635
|
+
...this.templateParams ? { params: this.templateParams } : {},
|
|
636
|
+
...this.templateRepeat ? { repeat: this.templateRepeat } : {},
|
|
637
|
+
pages: this.pages
|
|
638
|
+
};
|
|
632
639
|
}
|
|
633
640
|
}
|
|
634
|
-
class
|
|
641
|
+
class Tt {
|
|
635
642
|
constructor(t, n) {
|
|
636
643
|
this.parent = t, this.page = n, this.components = [];
|
|
637
644
|
}
|
|
@@ -700,11 +707,11 @@ class vt {
|
|
|
700
707
|
return this.done().build();
|
|
701
708
|
}
|
|
702
709
|
}
|
|
703
|
-
function
|
|
704
|
-
return new
|
|
710
|
+
function En() {
|
|
711
|
+
return new Et();
|
|
705
712
|
}
|
|
706
|
-
function
|
|
707
|
-
return
|
|
713
|
+
function Tn(e, t = {}) {
|
|
714
|
+
return Ve([], e), e.fields.map((n) => ({
|
|
708
715
|
field: n.field,
|
|
709
716
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
710
717
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
@@ -715,11 +722,11 @@ function P(e, t, n = !1) {
|
|
|
715
722
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
716
723
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
717
724
|
}
|
|
718
|
-
function
|
|
725
|
+
function K(e, t, n) {
|
|
719
726
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
720
727
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
721
728
|
}
|
|
722
|
-
function
|
|
729
|
+
function St(e) {
|
|
723
730
|
const t = e.layout ?? "page";
|
|
724
731
|
if (t !== "page" && t !== "wide")
|
|
725
732
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -730,16 +737,16 @@ function yt(e) {
|
|
|
730
737
|
const n = e.columnWidthMm ?? 30;
|
|
731
738
|
return P(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
732
739
|
}
|
|
733
|
-
function
|
|
740
|
+
function Ct(e) {
|
|
734
741
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
735
742
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
736
743
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
737
|
-
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(
|
|
738
|
-
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
739
|
-
const n =
|
|
744
|
+
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(J, t))
|
|
745
|
+
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(J).join("/")})`);
|
|
746
|
+
const n = _e(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
|
|
740
747
|
return P(r, "纸张 widthMm"), P(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
|
|
741
748
|
}
|
|
742
|
-
function
|
|
749
|
+
function Rt(e) {
|
|
743
750
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
744
751
|
throw new Error("margins 必须是页边距对象");
|
|
745
752
|
const t = e.margins ?? {}, n = {
|
|
@@ -751,7 +758,7 @@ function xt(e) {
|
|
|
751
758
|
for (const [r, i] of Object.entries(n)) P(i, r, !0);
|
|
752
759
|
return n;
|
|
753
760
|
}
|
|
754
|
-
function
|
|
761
|
+
function Pt(e, t) {
|
|
755
762
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
756
763
|
if (typeof n != "string" || !n.trim())
|
|
757
764
|
throw new Error("dataset 必须是非空字符串");
|
|
@@ -764,28 +771,28 @@ function Et(e, t) {
|
|
|
764
771
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
765
772
|
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: s };
|
|
766
773
|
}
|
|
767
|
-
function
|
|
774
|
+
function At(e) {
|
|
768
775
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
769
776
|
throw new Error("listOptions 必须是列表配置对象");
|
|
770
777
|
const t = e.listOptions ?? {};
|
|
771
|
-
|
|
778
|
+
K(t.align, "listOptions.align", !0), K(t.headerAlign, "listOptions.headerAlign", !1);
|
|
772
779
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
773
780
|
const r = t[n];
|
|
774
781
|
r !== void 0 && P(r, `listOptions.${n}`, n === "paddingMm");
|
|
775
782
|
}
|
|
776
783
|
return t;
|
|
777
784
|
}
|
|
778
|
-
function
|
|
785
|
+
function kt(e) {
|
|
779
786
|
let t = 0, n = 0;
|
|
780
787
|
for (const [r, i] of e.entries()) {
|
|
781
788
|
if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
|
|
782
789
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
783
|
-
|
|
790
|
+
K(i.align, `columns[${r}].align`, !0), K(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && P(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (P(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
|
|
784
791
|
}
|
|
785
792
|
return { fixedWidthMm: t, maxFlex: n };
|
|
786
793
|
}
|
|
787
|
-
function
|
|
788
|
-
const { fixedWidthMm: i, maxFlex: o } =
|
|
794
|
+
function It(e, t, n, r) {
|
|
795
|
+
const { fixedWidthMm: i, maxFlex: o } = kt(e.columns);
|
|
789
796
|
if (t === "page" && i > r)
|
|
790
797
|
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
791
798
|
const s = r - i;
|
|
@@ -793,24 +800,24 @@ function Ct(e, t, n, r) {
|
|
|
793
800
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
794
801
|
const a = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
|
|
795
802
|
return { columns: e.columns.map(({ widthMm: c, flex: d, ...m }, h) => {
|
|
796
|
-
const
|
|
797
|
-
return P(
|
|
803
|
+
const g = c ?? (t === "wide" ? n * (d ?? 1) : s * ((d ?? 1) / o) / a);
|
|
804
|
+
return P(g, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: g };
|
|
798
805
|
}), fixedWidthMm: i, maxFlex: o };
|
|
799
806
|
}
|
|
800
|
-
function
|
|
807
|
+
function Sn(e) {
|
|
801
808
|
if (!e || typeof e != "object")
|
|
802
809
|
throw new Error("标准明细模板需要 options 对象");
|
|
803
810
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
804
811
|
throw new Error("columns 至少需要一列");
|
|
805
|
-
const { layout: t, columnWidthMm: n } =
|
|
812
|
+
const { layout: t, columnWidthMm: n } = St(e), r = Ct(e);
|
|
806
813
|
let i = r.widthMm;
|
|
807
|
-
const o = r.heightMm, s =
|
|
814
|
+
const o = r.heightMm, s = Rt(e);
|
|
808
815
|
let a = i - s.marginLeftMm - s.marginRightMm;
|
|
809
816
|
const l = o - s.marginTopMm - s.marginBottomMm;
|
|
810
817
|
if (t === "page" && a <= 0 || l <= 0)
|
|
811
818
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
812
|
-
const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } =
|
|
813
|
-
t === "wide" && (a = f.reduce((
|
|
819
|
+
const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = Pt(e, l), g = At(e), { columns: f, fixedWidthMm: v, maxFlex: N } = It(e, t, n, a);
|
|
820
|
+
t === "wide" && (a = f.reduce((T, A) => T + A.widthMm, 0), P(a, "宽表总列宽"), i = a + s.marginLeftMm + s.marginRightMm, P(i, "宽表总宽度"));
|
|
814
821
|
const C = { widthMm: i, heightMm: o, ...s, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
815
822
|
return m && C.components.push({
|
|
816
823
|
kind: "text",
|
|
@@ -823,7 +830,7 @@ function vn(e) {
|
|
|
823
830
|
}), C.components.push({
|
|
824
831
|
align: "auto",
|
|
825
832
|
headerAlign: "center",
|
|
826
|
-
...
|
|
833
|
+
...g,
|
|
827
834
|
kind: "list",
|
|
828
835
|
...t === "wide" ? { layout: t } : {},
|
|
829
836
|
...m ? { title: e.title } : {},
|
|
@@ -831,10 +838,47 @@ function vn(e) {
|
|
|
831
838
|
columns: f,
|
|
832
839
|
leftMm: s.marginLeftMm,
|
|
833
840
|
topMm: s.marginTopMm + h,
|
|
834
|
-
widthMm: t === "wide" ||
|
|
841
|
+
widthMm: t === "wide" || N > 0 ? a : v
|
|
835
842
|
}), e.params === void 0 ? { pages: [C] } : { params: e.params, pages: [C] };
|
|
836
843
|
}
|
|
837
|
-
function
|
|
844
|
+
function Cn(e) {
|
|
845
|
+
if (e.components !== void 0 && e.pages !== void 0) throw new TypeError("标签 components 与 pages 只能选择一种");
|
|
846
|
+
const { dataset: t, rowKey: n, copies: r, params: i } = e, o = e.pages ?? [{ components: e.components ?? [] }], s = {
|
|
847
|
+
repeat: { dataset: t, ...n === void 0 ? {} : { rowKey: n }, ...r === void 0 ? {} : { copies: r } },
|
|
848
|
+
...i === void 0 ? {} : { params: i },
|
|
849
|
+
pages: o.map((l) => ({
|
|
850
|
+
widthMm: l.widthMm ?? e.widthMm ?? 80,
|
|
851
|
+
heightMm: l.heightMm ?? e.heightMm ?? 55,
|
|
852
|
+
marginTopMm: 0,
|
|
853
|
+
marginRightMm: 0,
|
|
854
|
+
marginBottomMm: 0,
|
|
855
|
+
marginLeftMm: 0,
|
|
856
|
+
components: l.components,
|
|
857
|
+
...l.meta === void 0 ? {} : { meta: l.meta }
|
|
858
|
+
}))
|
|
859
|
+
}, a = Ie(s);
|
|
860
|
+
if (!a.ok) throw new Ne(a.errors);
|
|
861
|
+
return JSON.parse(JSON.stringify(s));
|
|
862
|
+
}
|
|
863
|
+
function Nt(e) {
|
|
864
|
+
if (!e || typeof e != "object" || !e.repeat)
|
|
865
|
+
throw new se("config", "defineLabelReport 需要带 repeat 的固定标签模板");
|
|
866
|
+
const t = Ie(e);
|
|
867
|
+
if (!t.ok) throw new Ne(t.errors);
|
|
868
|
+
return e.repeat.dataset;
|
|
869
|
+
}
|
|
870
|
+
function we(e, t) {
|
|
871
|
+
if (!Array.isArray(e)) throw new se("validate", "标签数据应为对象数组;请从业务响应中提取行数组");
|
|
872
|
+
return { [t]: e };
|
|
873
|
+
}
|
|
874
|
+
function Rn(e) {
|
|
875
|
+
const { template: t, rows: n, load: r, dataSchema: i, params: o, pagination: s, dataValidation: a } = e, l = Nt(t);
|
|
876
|
+
if (n !== void 0 == (r !== void 0) || r !== void 0 && typeof r != "function")
|
|
877
|
+
throw new se("config", "标签报表应且只能配置 rows 或 load 其中一种数据来源");
|
|
878
|
+
const c = { template: t, params: o, pagination: s, dataValidation: a, ...i === void 0 ? {} : { dataSchema: { [l]: i } } };
|
|
879
|
+
return r ? qe({ ...c, load: r, mapData: (d) => we(d, l) }) : { ...c, datasets: we(n, l) };
|
|
880
|
+
}
|
|
881
|
+
function Pn(e) {
|
|
838
882
|
return e;
|
|
839
883
|
}
|
|
840
884
|
class L extends Error {
|
|
@@ -850,12 +894,12 @@ function x(e) {
|
|
|
850
894
|
const t = new Error("模板操作已取消");
|
|
851
895
|
throw t.name = "AbortError", t;
|
|
852
896
|
}
|
|
853
|
-
function
|
|
897
|
+
function ve(e) {
|
|
854
898
|
const t = e ? Number(e.revision) : 0;
|
|
855
899
|
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new L("history", "修订号无效或已达上限");
|
|
856
900
|
return String(t + 1);
|
|
857
901
|
}
|
|
858
|
-
function
|
|
902
|
+
function An(e, t = {}) {
|
|
859
903
|
const n = async (s, a) => {
|
|
860
904
|
x(a);
|
|
861
905
|
const l = await e.read(s, a);
|
|
@@ -870,11 +914,11 @@ function Mn(e, t = {}) {
|
|
|
870
914
|
}, o = async (s, a, l, c) => {
|
|
871
915
|
if (t.beforePublish) {
|
|
872
916
|
x(l.signal);
|
|
873
|
-
const
|
|
874
|
-
if (!
|
|
917
|
+
const g = await t.beforePublish({ document: I(a), previous: s.published ? I(s.published) : void 0, signal: l.signal });
|
|
918
|
+
if (!g || g.ok !== !0) throw new L("review", g?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
|
|
875
919
|
x(l.signal);
|
|
876
920
|
}
|
|
877
|
-
const d =
|
|
921
|
+
const d = ve(s), m = I({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
878
922
|
return c !== void 0 && (h.restoredFrom = c), i({ id: s.id, revision: d, publishedRevision: d, published: m }, l, h);
|
|
879
923
|
};
|
|
880
924
|
return {
|
|
@@ -894,7 +938,7 @@ function Mn(e, t = {}) {
|
|
|
894
938
|
},
|
|
895
939
|
saveDraft: async (s, a) => {
|
|
896
940
|
a = { ...a }, x(a.signal);
|
|
897
|
-
const l = I(t.migrate ? await t.migrate(s) : s), c = await r(l.id, a), d =
|
|
941
|
+
const l = I(t.migrate ? await t.migrate(s) : s), c = await r(l.id, a), d = ve(c);
|
|
898
942
|
return i({
|
|
899
943
|
id: l.id,
|
|
900
944
|
revision: d,
|
|
@@ -920,7 +964,7 @@ function Mn(e, t = {}) {
|
|
|
920
964
|
}
|
|
921
965
|
};
|
|
922
966
|
}
|
|
923
|
-
function
|
|
967
|
+
function kn() {
|
|
924
968
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
925
969
|
return {
|
|
926
970
|
read: async (n, r) => {
|
|
@@ -948,7 +992,7 @@ function xn() {
|
|
|
948
992
|
}
|
|
949
993
|
};
|
|
950
994
|
}
|
|
951
|
-
function
|
|
995
|
+
function $t(e, t) {
|
|
952
996
|
const n = e.publishedRevision ?? e.published?.revision;
|
|
953
997
|
for (const r of [e.draftRevision, n]) if (r !== void 0 && (typeof r != "string" || !r.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
|
|
954
998
|
if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
|
|
@@ -956,25 +1000,25 @@ function Rt(e, t) {
|
|
|
956
1000
|
if (!e.published && n !== void 0 && n !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
|
|
957
1001
|
return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...n === void 0 ? {} : { publishedRevision: n } };
|
|
958
1002
|
}
|
|
959
|
-
function
|
|
1003
|
+
function In(e, t) {
|
|
960
1004
|
const n = I(e);
|
|
961
1005
|
if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
|
|
962
1006
|
const { revision: r, ...i } = n;
|
|
963
1007
|
return I({ ...i, id: t.id, name: t.name });
|
|
964
1008
|
}
|
|
965
|
-
function
|
|
1009
|
+
function Nn(e) {
|
|
966
1010
|
if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
|
|
967
1011
|
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [];
|
|
968
1012
|
for (const i of e) {
|
|
969
1013
|
const o = I(i.document);
|
|
970
1014
|
if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
|
|
971
1015
|
if (i.category !== void 0 && (typeof i.category != "string" || i.category.length > 128) || i.tags !== void 0 && (!Array.isArray(i.tags) || i.tags.length > 20 || i.tags.some((c) => typeof c != "string" || c.length > 128))) throw new TypeError("模板分类和标签无效");
|
|
972
|
-
const s =
|
|
1016
|
+
const s = $t(i, o), { template: a, ...l } = o;
|
|
973
1017
|
t.set(o.id, o), i.published ? n.set(o.id, I(i.published)) : s.publishedRevision && n.set(o.id, I(o)), r.push({ ...l, ...s, ...i.category ? { category: i.category } : {}, ...i.tags ? { tags: [...i.tags] } : {} });
|
|
974
1018
|
}
|
|
975
1019
|
return r.sort((i, o) => i.id < o.id ? -1 : 1), {
|
|
976
1020
|
search: async (i) => {
|
|
977
|
-
|
|
1021
|
+
be(i.signal);
|
|
978
1022
|
const o = i.limit ?? 30;
|
|
979
1023
|
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
|
|
980
1024
|
const s = i.query?.trim().toLocaleLowerCase() ?? "", a = r.filter((c) => (!i.category || c.category === i.category) && (!i.cursor || c.id > i.cursor) && (!s || [c.id, c.name, c.description, ...c.tags ?? []].some((d) => d?.toLocaleLowerCase().includes(s)))), l = /* @__PURE__ */ new Map();
|
|
@@ -982,26 +1026,26 @@ function Sn(e) {
|
|
|
982
1026
|
return JSON.parse(JSON.stringify({ items: a.slice(0, o), ...a.length > o ? { next: a[o - 1].id } : {}, categories: Array.from(l, ([c, d]) => ({ id: c, label: c, count: d })) }));
|
|
983
1027
|
},
|
|
984
1028
|
get: async (i, o) => {
|
|
985
|
-
|
|
1029
|
+
be(o.signal);
|
|
986
1030
|
const s = o.mode === "published" ? n.get(i) : t.get(i);
|
|
987
1031
|
return s ? I(s) : void 0;
|
|
988
1032
|
}
|
|
989
1033
|
};
|
|
990
1034
|
}
|
|
991
|
-
function
|
|
1035
|
+
function be(e) {
|
|
992
1036
|
if (!e?.aborted) return;
|
|
993
1037
|
const t = new Error("模板目录操作已取消");
|
|
994
1038
|
throw t.name = "AbortError", t;
|
|
995
1039
|
}
|
|
996
|
-
function
|
|
1040
|
+
function $n(e) {
|
|
997
1041
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
998
1042
|
`);
|
|
999
1043
|
}
|
|
1000
|
-
function
|
|
1044
|
+
function Lt(e, t) {
|
|
1001
1045
|
const n = e[e.length - 1];
|
|
1002
1046
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1003
1047
|
}
|
|
1004
|
-
function
|
|
1048
|
+
function Ln(e, t = 1e4) {
|
|
1005
1049
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1006
1050
|
const n = [[]];
|
|
1007
1051
|
let r = "", i = !1, o = !1, s = 0;
|
|
@@ -1041,9 +1085,9 @@ function Cn(e, t = 1e4) {
|
|
|
1041
1085
|
r += c;
|
|
1042
1086
|
}
|
|
1043
1087
|
if (i) throw new Error("Unclosed clipboard quote");
|
|
1044
|
-
return a(),
|
|
1088
|
+
return a(), Lt(n, e), n;
|
|
1045
1089
|
}
|
|
1046
|
-
class
|
|
1090
|
+
class Dt extends Error {
|
|
1047
1091
|
constructor(t, n, r) {
|
|
1048
1092
|
const i = typeof n.label == "string" ? n.label : "单元格", o = {
|
|
1049
1093
|
definition: `${i}的编辑器配置无效`,
|
|
@@ -1060,46 +1104,46 @@ class At extends Error {
|
|
|
1060
1104
|
}
|
|
1061
1105
|
}
|
|
1062
1106
|
function p(e, t, n) {
|
|
1063
|
-
throw new
|
|
1107
|
+
throw new Dt(t, e, n);
|
|
1064
1108
|
}
|
|
1065
|
-
function
|
|
1109
|
+
function Be(e) {
|
|
1066
1110
|
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1067
1111
|
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1068
1112
|
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1069
1113
|
}
|
|
1070
|
-
function
|
|
1114
|
+
function Ft(e) {
|
|
1071
1115
|
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1072
1116
|
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1073
1117
|
}
|
|
1074
|
-
function
|
|
1075
|
-
e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 &&
|
|
1118
|
+
function Ot(e, t) {
|
|
1119
|
+
e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && Ft(t) > e.precision && p(e, "precision", e.precision);
|
|
1076
1120
|
}
|
|
1077
|
-
function
|
|
1078
|
-
|
|
1121
|
+
function zt(e, t) {
|
|
1122
|
+
Be(t) || p(e, "date"), e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max);
|
|
1079
1123
|
}
|
|
1080
|
-
function
|
|
1124
|
+
function Ht(e) {
|
|
1081
1125
|
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && p(e, "definition");
|
|
1082
1126
|
}
|
|
1083
|
-
function
|
|
1084
|
-
[e.min, e.max].some((t) => t !== void 0 && !
|
|
1127
|
+
function _t(e) {
|
|
1128
|
+
[e.min, e.max].some((t) => t !== void 0 && !Be(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
|
|
1085
1129
|
}
|
|
1086
|
-
function
|
|
1130
|
+
function Bt(e, t) {
|
|
1087
1131
|
(!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
|
|
1088
1132
|
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1089
1133
|
for (const i of t.options)
|
|
1090
1134
|
(!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && p(t, "definition"), i.label !== void 0 && typeof i.label != "string" && p(t, "definition"), r.has(i.value) && p(t, "definition"), r.add(i.value);
|
|
1091
1135
|
}
|
|
1092
|
-
function
|
|
1136
|
+
function jt(e) {
|
|
1093
1137
|
e.required !== void 0 && typeof e.required != "boolean" && p(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition");
|
|
1094
1138
|
}
|
|
1095
|
-
function
|
|
1096
|
-
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"),
|
|
1139
|
+
function Wt(e, t) {
|
|
1140
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), jt(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && Ht(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && _t(t), t.type === "enum" && Bt(e, t);
|
|
1097
1141
|
}
|
|
1098
|
-
function
|
|
1099
|
-
if (!e.editable) throw new
|
|
1100
|
-
n &&
|
|
1101
|
-
const r =
|
|
1102
|
-
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" &&
|
|
1142
|
+
function Dn(e, t, n) {
|
|
1143
|
+
if (!e.editable) throw new Ye("readonly");
|
|
1144
|
+
n && Wt(e, n);
|
|
1145
|
+
const r = Je(e, t);
|
|
1146
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && Ot(n, r), n.type === "date" && zt(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
|
|
1103
1147
|
}
|
|
1104
1148
|
class w extends Error {
|
|
1105
1149
|
constructor(t) {
|
|
@@ -1111,15 +1155,15 @@ function z(e) {
|
|
|
1111
1155
|
const t = new Error("Calculation cancelled");
|
|
1112
1156
|
throw t.name = "AbortError", t;
|
|
1113
1157
|
}
|
|
1114
|
-
async function
|
|
1158
|
+
async function X(e, t = 1) {
|
|
1115
1159
|
const n = Math.floor(e.scanned / 2048);
|
|
1116
1160
|
if (e.scanned += t, e.scanned > e.maxScanned) throw new w("limit");
|
|
1117
1161
|
z(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), z(e.signal));
|
|
1118
1162
|
}
|
|
1119
|
-
function
|
|
1163
|
+
function me(e) {
|
|
1120
1164
|
return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
|
|
1121
1165
|
}
|
|
1122
|
-
function
|
|
1166
|
+
function ye(e, t, n) {
|
|
1123
1167
|
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
|
|
1124
1168
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1125
1169
|
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
|
|
@@ -1129,50 +1173,50 @@ function be(e, t, n) {
|
|
|
1129
1173
|
if (o && s && o.id === s.id) {
|
|
1130
1174
|
const a = s.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
|
|
1131
1175
|
if (a < 0) throw new w("selection");
|
|
1132
|
-
return { grid: o.id, row:
|
|
1176
|
+
return { grid: o.id, row: me(r) + t.rowIndex, column: a };
|
|
1133
1177
|
}
|
|
1134
1178
|
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1135
1179
|
}
|
|
1136
|
-
function
|
|
1137
|
-
const r =
|
|
1180
|
+
function Gt(e, t, n) {
|
|
1181
|
+
const r = ye(e, t.anchor, t.anchor), i = ye(e, t.focus, t.anchor);
|
|
1138
1182
|
if (r.grid !== i.grid) throw new w("selection");
|
|
1139
1183
|
const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
|
|
1140
1184
|
if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
|
|
1141
1185
|
return { grid: r.grid, rowStart: Math.min(r.row, i.row), rowEnd: Math.max(r.row, i.row), columnStart: Math.min(r.column, i.column), columnEnd: Math.max(r.column, i.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
|
|
1142
1186
|
}
|
|
1143
|
-
function
|
|
1187
|
+
function Ut(e) {
|
|
1144
1188
|
if (!e) return !1;
|
|
1145
1189
|
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1146
1190
|
return /[ymdhs]/i.test(t);
|
|
1147
1191
|
}
|
|
1148
|
-
function
|
|
1149
|
-
if (e.valueType === "text" || e.valueType === "boolean" ||
|
|
1192
|
+
function Vt(e) {
|
|
1193
|
+
if (e.valueType === "text" || e.valueType === "boolean" || Ut(e.numberFormat)) return null;
|
|
1150
1194
|
const t = e.value;
|
|
1151
1195
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1152
1196
|
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
|
|
1153
1197
|
return t;
|
|
1154
1198
|
}
|
|
1155
|
-
function
|
|
1199
|
+
function qt(e, t, n) {
|
|
1156
1200
|
if (e.seen.has(n)) return;
|
|
1157
1201
|
e.seen.add(n), e.selected++;
|
|
1158
|
-
const r = t ?
|
|
1202
|
+
const r = t ? Vt(t) : null;
|
|
1159
1203
|
r === null ? e.excluded++ : e.values.push(r);
|
|
1160
1204
|
}
|
|
1161
|
-
function
|
|
1205
|
+
function Yt(e, t, n, r) {
|
|
1162
1206
|
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1163
1207
|
}
|
|
1164
|
-
function
|
|
1208
|
+
function Jt(e, t, n) {
|
|
1165
1209
|
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1166
1210
|
}
|
|
1167
|
-
function
|
|
1168
|
-
const i = r.origin ?
|
|
1211
|
+
function Kt(e, t, n, r) {
|
|
1212
|
+
const i = r.origin ? me(e) + t : t, o = Jt(e, n, r);
|
|
1169
1213
|
return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
|
|
1170
1214
|
}
|
|
1171
|
-
function
|
|
1172
|
-
const n = t.origin ?
|
|
1215
|
+
function Xt(e, t) {
|
|
1216
|
+
const n = t.origin ? me(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1173
1217
|
return i > r ? i : 0;
|
|
1174
1218
|
}
|
|
1175
|
-
async function
|
|
1219
|
+
async function Zt(e, t, n, r, i) {
|
|
1176
1220
|
const o = e.grid;
|
|
1177
1221
|
if (t > r.maxScanned) throw new w("limit");
|
|
1178
1222
|
const s = o.colWidthsMm?.length ?? o.cells.reduce((l, c) => Math.max(l, c.length), 1);
|
|
@@ -1182,44 +1226,44 @@ async function Vt(e, t, n, r, i) {
|
|
|
1182
1226
|
l > 0 && l % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
|
|
1183
1227
|
let c = 0;
|
|
1184
1228
|
for (const d of o.cells[l]) {
|
|
1185
|
-
for (await
|
|
1229
|
+
for (await X(r); c < s && (a.get(c) ?? 0) > l; ) c++;
|
|
1186
1230
|
if (c >= s) break;
|
|
1187
1231
|
const m = Math.max(1, Math.min(d?.colSpan ?? 1, s - c)), h = Math.min(o.cells.length, l + Math.max(1, d?.rowSpan ?? 1));
|
|
1188
|
-
m > 1 && await
|
|
1232
|
+
m > 1 && await X(r, m - 1);
|
|
1189
1233
|
for (let f = c; f < c + m; f++) a.set(f, h);
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1234
|
+
const g = Kt(e, l, c, n);
|
|
1235
|
+
g && qt(i, d, g), c += m;
|
|
1192
1236
|
}
|
|
1193
1237
|
}
|
|
1194
1238
|
}
|
|
1195
|
-
async function
|
|
1239
|
+
async function Qt(e, t, n) {
|
|
1196
1240
|
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1197
1241
|
for (let i = 0; i < e.pages.length; i++) {
|
|
1198
|
-
await
|
|
1242
|
+
await X(n);
|
|
1199
1243
|
const o = e.pages[i];
|
|
1200
1244
|
for (let s = 0; s < o.components.length; s++) {
|
|
1201
|
-
await
|
|
1245
|
+
await X(n);
|
|
1202
1246
|
const a = o.components[s];
|
|
1203
|
-
if (!a.grid || !
|
|
1204
|
-
const l =
|
|
1205
|
-
l && await
|
|
1247
|
+
if (!a.grid || !Yt(a, i, s, t) || a.table && a.table.role !== "body") continue;
|
|
1248
|
+
const l = Xt(a, t);
|
|
1249
|
+
l && await Zt(a, l, t, n, r);
|
|
1206
1250
|
}
|
|
1207
1251
|
}
|
|
1208
1252
|
return r;
|
|
1209
1253
|
}
|
|
1210
|
-
function
|
|
1254
|
+
function W(e) {
|
|
1211
1255
|
if (!Number.isFinite(e)) throw new w("overflow");
|
|
1212
1256
|
return e;
|
|
1213
1257
|
}
|
|
1214
|
-
function
|
|
1258
|
+
function en(e) {
|
|
1215
1259
|
let t = 0, n = 0;
|
|
1216
1260
|
for (const r of e) {
|
|
1217
|
-
const i = r - n, o =
|
|
1261
|
+
const i = r - n, o = W(t + i);
|
|
1218
1262
|
n = o - t - i, t = o;
|
|
1219
1263
|
}
|
|
1220
1264
|
return t;
|
|
1221
1265
|
}
|
|
1222
|
-
async function
|
|
1266
|
+
async function Me(e, t) {
|
|
1223
1267
|
let n = [...e], r = new Array(e.length);
|
|
1224
1268
|
for (let o = 1; o < e.length; o *= 2) {
|
|
1225
1269
|
for (let s = 0; s < e.length; s += o * 2) {
|
|
@@ -1231,16 +1275,16 @@ async function ve(e, t) {
|
|
|
1231
1275
|
[n, r] = [r, n];
|
|
1232
1276
|
}
|
|
1233
1277
|
const i = Math.floor(n.length / 2);
|
|
1234
|
-
return n.length % 2 ? n[i] :
|
|
1278
|
+
return n.length % 2 ? n[i] : W(n[i - 1] / 2 + n[i] / 2);
|
|
1235
1279
|
}
|
|
1236
|
-
function
|
|
1237
|
-
const t =
|
|
1280
|
+
function tn(e) {
|
|
1281
|
+
const t = en(e);
|
|
1238
1282
|
let n = 1 / 0, r = -1 / 0;
|
|
1239
1283
|
for (const i of e)
|
|
1240
1284
|
n = Math.min(n, i), r = Math.max(r, i);
|
|
1241
1285
|
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1242
1286
|
}
|
|
1243
|
-
function
|
|
1287
|
+
function nn(e, t) {
|
|
1244
1288
|
if (typeof e != "string" || e.length > 256) throw new w("expression");
|
|
1245
1289
|
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1246
1290
|
if (!n.length || n.length > 64) throw new w("expression");
|
|
@@ -1254,8 +1298,8 @@ function Xt(e, t) {
|
|
|
1254
1298
|
if (n[r++] !== ")") throw new w("expression");
|
|
1255
1299
|
return c;
|
|
1256
1300
|
}
|
|
1257
|
-
if (l && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(l) && Object.prototype.hasOwnProperty.call(t, l)) return
|
|
1258
|
-
if (l && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(l)) return
|
|
1301
|
+
if (l && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(l) && Object.prototype.hasOwnProperty.call(t, l)) return W(t[l]);
|
|
1302
|
+
if (l && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(l)) return W(Number(l));
|
|
1259
1303
|
throw new w("expression");
|
|
1260
1304
|
}
|
|
1261
1305
|
function o(a, l) {
|
|
@@ -1266,7 +1310,7 @@ function Xt(e, t) {
|
|
|
1266
1310
|
r++;
|
|
1267
1311
|
const h = o(m + 1, l + 1);
|
|
1268
1312
|
if (d === "/" && h === 0) throw new w("division");
|
|
1269
|
-
c =
|
|
1313
|
+
c = W(d === "+" ? c + h : d === "-" ? c - h : d === "*" ? c * h : c / h);
|
|
1270
1314
|
}
|
|
1271
1315
|
return c;
|
|
1272
1316
|
}
|
|
@@ -1274,154 +1318,159 @@ function Xt(e, t) {
|
|
|
1274
1318
|
if (r !== n.length) throw new w("expression");
|
|
1275
1319
|
return s;
|
|
1276
1320
|
}
|
|
1277
|
-
function
|
|
1321
|
+
function rn(e) {
|
|
1278
1322
|
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1279
1323
|
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
|
|
1280
1324
|
if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
|
|
1281
1325
|
return { maxCells: t, maxScanned: n, precision: r };
|
|
1282
1326
|
}
|
|
1283
|
-
async function
|
|
1284
|
-
const r =
|
|
1327
|
+
async function Fn(e, t, n = {}) {
|
|
1328
|
+
const r = rn(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((l) => setTimeout(l, 0))) };
|
|
1285
1329
|
z(i.signal);
|
|
1286
|
-
const o = await
|
|
1330
|
+
const o = await Qt(e, Gt(e, t, r.maxCells), i), s = n.operation ?? "sum";
|
|
1287
1331
|
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(s)) throw new w("expression");
|
|
1288
1332
|
let a = null;
|
|
1289
1333
|
if (s === "count") a = o.values.length;
|
|
1290
1334
|
else if (o.values.length)
|
|
1291
|
-
if (s === "median") a = await
|
|
1335
|
+
if (s === "median") a = await Me(o.values, i);
|
|
1292
1336
|
else {
|
|
1293
|
-
const l =
|
|
1294
|
-
s === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (l.MEDIAN = await
|
|
1337
|
+
const l = tn(o.values);
|
|
1338
|
+
s === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (l.MEDIAN = await Me(o.values, i)), a = nn(n.expression ?? "", l)) : a = l[s.toUpperCase()];
|
|
1295
1339
|
}
|
|
1296
1340
|
if (z(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
|
|
1297
1341
|
return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
|
|
1298
1342
|
}
|
|
1299
1343
|
export {
|
|
1300
|
-
|
|
1301
|
-
|
|
1344
|
+
Qn as CSS_DPI,
|
|
1345
|
+
Hn as DEFAULT_BORDER_PT,
|
|
1302
1346
|
Z as DEFAULT_FONT_FAMILY,
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1347
|
+
_n as DEFAULT_FONT_PT,
|
|
1348
|
+
br as DEFAULT_LABEL_PAGE_LIMIT,
|
|
1349
|
+
Bn as DEFAULT_STROKE_COLOR,
|
|
1350
|
+
xe as DEFAULT_TEXT_COLOR,
|
|
1351
|
+
jn as LINE_HEIGHT,
|
|
1352
|
+
er as MM_PER_INCH,
|
|
1353
|
+
gr as OutputAssetError,
|
|
1354
|
+
Ke as OutputFidelityError,
|
|
1355
|
+
J as PAPER_SIZES,
|
|
1356
|
+
Tt as PageBuilder,
|
|
1357
|
+
yr as PaginateCellLimitError,
|
|
1358
|
+
Mr as PaginatePageLimitError,
|
|
1359
|
+
ir as RENDER_PLAN_SCHEMA_VERSION,
|
|
1360
|
+
qr as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1361
|
+
Un as ReportBindingError,
|
|
1316
1362
|
w as ReportCalculationError,
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1363
|
+
Ye as ReportCellEditError,
|
|
1364
|
+
Dt as ReportCellFieldError,
|
|
1365
|
+
Qr as ReportParamValidationError,
|
|
1366
|
+
se as ReportSourceError,
|
|
1367
|
+
Ne as ReportTemplateError,
|
|
1322
1368
|
L as ReportTemplateStoreError,
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1369
|
+
Wn as SCHEMA_VERSION_MACH,
|
|
1370
|
+
Et as TemplateBuilder,
|
|
1371
|
+
di as TreeRowLimitError,
|
|
1372
|
+
xr as applyReportCellEdit,
|
|
1373
|
+
Er as applyReportCellEditBatch,
|
|
1374
|
+
Tr as applyReportEditResult,
|
|
1375
|
+
ar as assertRenderPlan,
|
|
1376
|
+
ei as assertReportParams,
|
|
1377
|
+
Fn as calculateReportSelection,
|
|
1378
|
+
ur as charWidthEm,
|
|
1333
1379
|
E as classOf,
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1380
|
+
In as cloneReportTemplate,
|
|
1381
|
+
Tn as columnsFromContract,
|
|
1382
|
+
ft as computePageWindow,
|
|
1383
|
+
Sr as countTemplatePages,
|
|
1384
|
+
fr as createCanvasMeasurer,
|
|
1385
|
+
xn as createCanvasPager,
|
|
1386
|
+
pr as createHeuristicMeasurer,
|
|
1387
|
+
Cn as createLabelTemplate,
|
|
1388
|
+
Nn as createLocalTemplateCatalog,
|
|
1389
|
+
kn as createMemoryTemplateStore,
|
|
1390
|
+
Pn as createProviderReport,
|
|
1391
|
+
Cr as createReportCellEdit,
|
|
1392
|
+
Rr as createReportCellEditBatch,
|
|
1393
|
+
Pr as createReportCellResolver,
|
|
1394
|
+
Ar as createReportEditSession,
|
|
1395
|
+
kr as createReportSource,
|
|
1396
|
+
Sn as createTableTemplate,
|
|
1397
|
+
En as createTemplate,
|
|
1398
|
+
An as createTemplateManager,
|
|
1399
|
+
Yr as createTemplateRegistry,
|
|
1400
|
+
mi as createTreeTable,
|
|
1401
|
+
mr as datasetJsonSchema,
|
|
1402
|
+
Rn as defineLabelReport,
|
|
1403
|
+
qe as defineReport,
|
|
1404
|
+
Jr as defineReportTemplate,
|
|
1405
|
+
Ir as diffReportTemplates,
|
|
1406
|
+
Nr as estimateListLayoutCells,
|
|
1407
|
+
Vn as evalStyleRule,
|
|
1408
|
+
nn as evaluateReportAggregateExpression,
|
|
1409
|
+
$r as formatReportCellEdit,
|
|
1410
|
+
$n as formatReportClipboard,
|
|
1411
|
+
ti as formatReportDateRange,
|
|
1412
|
+
qn as formatValue,
|
|
1413
|
+
Lr as getReportCellContext,
|
|
1414
|
+
Dr as getReportEditSession,
|
|
1367
1415
|
oe as heuristicMeasurer,
|
|
1368
|
-
|
|
1416
|
+
Ur as inspectOutputCapabilities,
|
|
1369
1417
|
ee as isImageBackedComponent,
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1418
|
+
ni as isReportDate,
|
|
1419
|
+
ri as isReportMonth,
|
|
1420
|
+
ii as isReportYear,
|
|
1421
|
+
Ce as isRichText,
|
|
1422
|
+
ce as measurePageSizePx,
|
|
1423
|
+
wr as measureTextMm,
|
|
1424
|
+
Te as mergeComponentStyles,
|
|
1377
1425
|
ie as mmToPx,
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1426
|
+
tr as mmToPxFactor,
|
|
1427
|
+
Fr as paginateTemplate,
|
|
1428
|
+
Or as paginateTemplatePages,
|
|
1429
|
+
Yn as parseDateLocal,
|
|
1430
|
+
Dn as parseReportCellFieldInput,
|
|
1431
|
+
Je as parseReportCellInput,
|
|
1432
|
+
Ln as parseReportClipboard,
|
|
1433
|
+
oi as parseReportDateRange,
|
|
1386
1434
|
I as parseReportTemplate,
|
|
1387
|
-
|
|
1388
|
-
|
|
1435
|
+
vn as planFontSizePx,
|
|
1436
|
+
zr as projectListColumns,
|
|
1389
1437
|
O as ptToPx,
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1438
|
+
nr as pxToMm,
|
|
1439
|
+
Hr as registerReportEditSession,
|
|
1440
|
+
_r as relocateReportCellEdits,
|
|
1441
|
+
Le as renderComponent,
|
|
1442
|
+
dt as renderPage,
|
|
1443
|
+
wn as renderPlan,
|
|
1444
|
+
yn as renderPlanToCanvas,
|
|
1445
|
+
Mn as renderPlanToCanvasAsync,
|
|
1446
|
+
bn as renderPlanToImages,
|
|
1447
|
+
Br as reportCellEditKey,
|
|
1400
1448
|
G as reportOutputDiagnostics,
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1449
|
+
ai as reportParamsJsonSchema,
|
|
1450
|
+
Ee as resolveBoxBorders,
|
|
1451
|
+
Jn as resolveComponentBinding,
|
|
1452
|
+
_ as resolveFontSize,
|
|
1453
|
+
Pe as resolveGridLayout,
|
|
1405
1454
|
Q as resolveLineHeight,
|
|
1406
|
-
|
|
1455
|
+
_e as resolvePaper,
|
|
1407
1456
|
ae as resolvePlanAssets,
|
|
1408
1457
|
j as resolveStroke,
|
|
1409
|
-
|
|
1410
|
-
|
|
1458
|
+
Se as resolveTextColor,
|
|
1459
|
+
jr as reviewReportTemplate,
|
|
1411
1460
|
H as round,
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1461
|
+
Kr as serializeReportTemplate,
|
|
1462
|
+
Wr as summarizeReportCellEdits,
|
|
1463
|
+
Kn as toExcelNumberFormat,
|
|
1464
|
+
Xn as toNumber,
|
|
1465
|
+
sr as validateComponent,
|
|
1466
|
+
Ve as validateDatasetRows,
|
|
1467
|
+
lr as validatePage,
|
|
1468
|
+
cr as validateRenderPlan,
|
|
1469
|
+
Wt as validateReportCellFieldDefinition,
|
|
1470
|
+
si as validateReportParamDefinitions,
|
|
1471
|
+
li as validateReportParams,
|
|
1472
|
+
Ie as validateReportTemplate,
|
|
1473
|
+
Xr as validateReportTemplateDocument,
|
|
1474
|
+
hi as validateTreeOptions,
|
|
1475
|
+
Re as wrapText
|
|
1427
1476
|
};
|