@agile-team/mach-report 2.9.1 → 2.11.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 +11 -7
- package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
- package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
- package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
- package/dist/ParamEditor-DRGxzxeO.js +381 -0
- package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
- package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
- package/dist/ReportPreview-DWXROHBP.cjs +6 -0
- package/dist/ReportPreview-DiNXhQI0.js +4138 -0
- package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
- package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -0
- package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
- package/dist/RuleEditor-D9wQHrkf.js +2024 -0
- package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
- package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +4 -0
- package/dist/analytics.d.ts +4 -0
- package/dist/analytics.js +40 -39
- package/dist/{assets-ahTRUXRk.cjs → assets-Bu6UohJx.cjs} +1 -1
- package/dist/{assets-DDsfEi8R.js → assets-DegqDNqY.js} +1 -1
- package/dist/batch-Bt3Fd27Z.cjs +1 -0
- package/dist/batch-mRqhhhjt.js +364 -0
- package/dist/{capabilities-Cm9hZ3uV.js → capabilities-CK_7hizc.js} +16 -16
- package/dist/capabilities-CsZ-pNHR.cjs +1 -0
- package/dist/computed-Bvk0W15F.js +521 -0
- package/dist/computed-CGV2a809.cjs +1 -0
- package/dist/config-B612mw0x.js +525 -0
- package/dist/config-BRoLo2oj.cjs +1 -0
- package/dist/designer.cjs +2 -2
- package/dist/designer.d.cts +695 -50
- package/dist/designer.d.ts +695 -50
- package/dist/designer.js +2213 -1748
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +205 -6
- package/dist/index.d.ts +205 -6
- package/dist/index.js +808 -1033
- package/dist/injection-keys-Db_DyLkm.cjs +1 -0
- package/dist/injection-keys-e85udZCp.js +7 -0
- package/dist/list-cell-BuYn4tGF.cjs +1 -0
- package/dist/list-cell-ClFra1zS.js +173 -0
- package/dist/matrix-DVyWiYsd.cjs +1 -0
- package/dist/matrix-yZsGnldA.js +227 -0
- package/dist/param-validation-BlHHXs6u.js +153 -0
- package/dist/param-validation-DCK039V1.cjs +1 -0
- package/dist/pdf.cjs +49 -49
- package/dist/pdf.d.cts +31 -1
- package/dist/pdf.d.ts +31 -1
- package/dist/pdf.js +4797 -4650
- package/dist/plugin-BDTU4D94.cjs +1 -0
- package/dist/plugin-Cd5G2QQn.js +22 -0
- package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
- package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
- package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
- package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
- package/dist/server/node.d.cts +48 -5
- package/dist/server/node.d.ts +48 -5
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +503 -317
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +252 -4
- package/dist/server.d.ts +252 -4
- package/dist/server.js +567 -469
- package/dist/style.css +1 -1
- package/dist/template-registry-WNXdkiET.js +506 -0
- package/dist/template-registry-ukBGlm8N.cjs +1 -0
- package/dist/template-review-BXp2oyqg.cjs +1 -0
- package/dist/template-review-BdcXSYbx.js +1616 -0
- package/dist/tree-BX380Rr7.cjs +1 -0
- package/dist/tree-CqcQ99NM.js +172 -0
- package/dist/useLocalDraft-C07SYRnC.js +11 -0
- package/dist/useLocalDraft-Yiw1wFgI.cjs +1 -0
- package/dist/{validate-DWPF7icl.js → validate-7s0yn6ii.js} +26 -26
- package/dist/validate-DsRiNw8h.cjs +1 -0
- package/dist/vue/async.d.cts +118 -6
- package/dist/vue/async.d.ts +118 -6
- package/dist/vue/index.d.cts +177 -11
- package/dist/vue/index.d.ts +177 -11
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +5 -5
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +116 -113
- package/dist/{import-template-CNMLJSQw.js → workbook-session-BKOTwcoq.js} +4290 -4227
- package/dist/{import-template-CpxunKVp.cjs → workbook-session-CLYLhZWu.cjs} +17 -17
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +9 -2
- package/dist/worker.d.ts +9 -2
- package/dist/worker.js +1 -1
- package/dist/xlsx.cjs +4 -2
- package/dist/xlsx.d.cts +159 -3
- package/dist/xlsx.d.ts +159 -3
- package/dist/xlsx.js +354 -192
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-DiaxvWpQ.cjs +0 -1
- package/dist/ExcelBindingWizard-RLJIXKKG.js +0 -816
- package/dist/ReportPreview-B5ZNEasW.js +0 -4439
- package/dist/ReportPreview-DRtVPUYo.cjs +0 -6
- package/dist/RuleEditor-CskN5Fr3.cjs +0 -1
- package/dist/RuleEditor-CtJFzKuY.js +0 -1578
- package/dist/TemplateReviewPanel-C_Lmzis6.cjs +0 -1
- package/dist/TemplateReviewPanel-Cn32OY4_.js +0 -173
- package/dist/binding-preview-B5834rml.cjs +0 -2
- package/dist/binding-preview-ChXjN5L5.js +0 -649
- package/dist/capabilities-DYzWL7KS.cjs +0 -1
- package/dist/matrix-CNPDJxED.js +0 -745
- package/dist/matrix-Div9Ilh3.cjs +0 -1
- package/dist/param-validation-BWNjLcN0.js +0 -116
- package/dist/param-validation-CiTxFeZ8.cjs +0 -1
- package/dist/plugin-BWwIgZXV.js +0 -25
- package/dist/plugin-Dg-J1Rbm.cjs +0 -1
- package/dist/template-registry-CHMYZ7SD.cjs +0 -1
- package/dist/template-registry-R61AMCr0.js +0 -433
- package/dist/template-review-hvWWQFsi.js +0 -1027
- package/dist/template-review-jEcOfmGr.cjs +0 -1
- package/dist/validate-BDiMqkJC.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("./computed-CGV2a809.cjs");class g extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function u(e,r,i,t){const n=e??r;if(!Number.isInteger(n)||n<1||n>i)throw new Error(`${t}应为 1–${i} 的整数`);return n}function w(e){return{rows:u(e.maxRows,1e5,1e6,"树行数预算"),depth:u(e.maxDepth,64,256,"树深度预算"),visits:u(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function m(e){return typeof e=="string"&&!!e.trim()}function c(e){return m(e)&&!["__proto__","prototype","constructor"].includes(e)}function E(e){if(m(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function p(e){return JSON.stringify([typeof e,e])}function F(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function y(e,r){const i=F(e);if(r?.some(t=>t.scope&&t.scope!=="row"||i.includes(t.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function h(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function k(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const i=new Set;for(const t of r){if(!t||!c(t.field)||i.has(t.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const n of[t.valueField,t.weightField])if(n!==void 0&&!c(n))throw new Error("树聚合来源字段应安全且非空");if([...F(e),e.labelField].includes(t.field))throw new Error("树聚合不能覆盖结构键或标签字段");i.add(t.field),s.createAggregateAccumulator({...t,field:t.valueField??t.field})}}function N(e){if(!c(e.idField)||!c(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!c(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!c(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function v(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(N(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");w(e),k(e)}function A(e,r,i,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(i.size>=t.rows)throw new g(t.rows);const n=E(e[r.idField]),l=p(n);if(i.has(l))throw new Error(`树节点业务键重复:${String(n)}`);const o={original:e,row:e,key:n,depth:0,children:[]};return i.set(l,o),o}function $(e,r,i,t,n){for(const o of e)h(n),A(o,r,i,t);const l=[];for(const o of i.values()){h(n);const a=o.row[r.parentField];if(a==null){l.push(o);continue}const d=i.get(p(E(a)));if(!d){if(r.orphan!=="root")throw new Error(`树节点 ${String(o.key)} 的父节点不存在`);l.push(o);continue}if(d===o)throw new Error("树节点不能以自身为父节点");o.parent=d,d.children.push(o)}return l}function M(e,r,i,t,n){const l=[],o=[{rows:e,next:0}];for(;o.length;){h(n);const a=o[o.length-1];if(a.next>=a.rows.length){o.pop();continue}const d=A(a.rows[a.next++],r,i,t);if(d.parent=a.parent,d.depth=o.length-1,o.length>t.depth)throw new Error(`树节点超出深度预算 ${t.depth}`);(a.parent?.children??l).push(d);const f=d.row[r.childrenField??"children"];if(f!=null){if(!Array.isArray(f))throw new Error("嵌套树 children 字段应为数组");f.length&&o.push({rows:f,next:0,parent:d})}}return l}function V(e,r,i,t){const n=[],l=[{nodes:e,next:0}];for(;l.length;){h(t);const o=l[l.length-1];if(o.next>=o.nodes.length){l.pop();continue}if(l.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);const a=o.nodes[o.next++];a.depth=l.length-1,n.push(a),a.children.length&&l.push({nodes:a.children,next:0})}if(n.length!==r)throw new Error("树父子关系存在循环");return n}function S(e,r,i,t){if(r.parentValues!=="leaf-aggregate")return;const n=r.aggregates,l=new Map;for(const a of e)a.children.length&&l.set(a,n.map(d=>s.createAggregateAccumulator({...d,field:d.valueField??d.field})));let o=0;for(const a of e)if(!a.children.length)for(let d=a.parent;d;d=d.parent){if(h(t),o+=n.length,o>i.visits)throw new Error(`树聚合超出访问预算 ${i.visits}`);for(const f of l.get(d))f.add(a.row)}for(const[a,d]of l)a.row={...a.row},n.forEach((f,T)=>{a.row[f.field]=d[T].value()})}function b(e,r,i){if(v(r),h(i),!Array.isArray(e))throw new Error("树数据应为节点数组");const t=w(r),n=new Map,l=r.input==="flat"?$(e,r,n,t,i):M(e,r,n,t,i);return V(l,n.size,t,i)}function x(e,r,i){return b(e,r,i).map(t=>t.original)}function O(e,r,i={}){const t=b(e,r,i.signal);if(y(r,i.computed?.fields),i.computed?.fields.length){const n=s.computeDataset(t.map(l=>l.row),{...i.computed,signal:i.signal}).rows;t.forEach((l,o)=>{l.row=n[o]})}return S(t,r,w(r),i.signal),{rows:t.map(n=>n.row),entries:t.map(n=>({row:n.row,original:n.original,key:n.key,depth:n.depth,hasChildren:!!n.children.length})),leaves:t.filter(n=>!n.children.length).map(n=>n.row)}}exports.TreeRowLimitError=g;exports.createTreeTable=O;exports.flattenTreeInput=x;exports.validateTreeComputed=y;exports.validateTreeOptions=v;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { d as A, e as w } from "./computed-Bvk0W15F.js";
|
|
2
|
+
class b extends Error {
|
|
3
|
+
constructor(r) {
|
|
4
|
+
super(`树节点超出行数预算 ${r}`), this.limit = r, this.code = "tree-row-limit", this.name = "TreeRowLimitError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function s(e, r, i, t) {
|
|
8
|
+
const n = e ?? r;
|
|
9
|
+
if (!Number.isInteger(n) || n < 1 || n > i) throw new Error(`${t}应为 1–${i} 的整数`);
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function u(e) {
|
|
13
|
+
return { rows: s(e.maxRows, 1e5, 1e6, "树行数预算"), depth: s(e.maxDepth, 64, 256, "树深度预算"), visits: s(e.maxAggregationVisits, 1e6, 1e7, "树聚合访问预算") };
|
|
14
|
+
}
|
|
15
|
+
function g(e) {
|
|
16
|
+
return typeof e == "string" && !!e.trim();
|
|
17
|
+
}
|
|
18
|
+
function c(e) {
|
|
19
|
+
return g(e) && !["__proto__", "prototype", "constructor"].includes(e);
|
|
20
|
+
}
|
|
21
|
+
function m(e) {
|
|
22
|
+
if (g(e) || typeof e == "number" && Number.isFinite(e)) return e;
|
|
23
|
+
throw new Error("树节点业务键应为非空字符串或有限数字");
|
|
24
|
+
}
|
|
25
|
+
function E(e) {
|
|
26
|
+
return JSON.stringify([typeof e, e]);
|
|
27
|
+
}
|
|
28
|
+
function p(e) {
|
|
29
|
+
return [e.idField, ...e.input === "flat" ? [e.parentField ?? ""] : [e.childrenField ?? "children"]];
|
|
30
|
+
}
|
|
31
|
+
function k(e, r) {
|
|
32
|
+
const i = p(e);
|
|
33
|
+
if (r?.some((t) => t.scope && t.scope !== "row" || i.includes(t.field))) throw new Error("树形布局仅支持不覆盖结构键的当前行计算");
|
|
34
|
+
}
|
|
35
|
+
function h(e) {
|
|
36
|
+
if (!e?.aborted) return;
|
|
37
|
+
const r = new Error("树报表处理已取消");
|
|
38
|
+
throw r.name = "AbortError", r;
|
|
39
|
+
}
|
|
40
|
+
function N(e) {
|
|
41
|
+
const r = e.aggregates ?? [];
|
|
42
|
+
if (!Array.isArray(r) || r.length > 32) throw new Error("树聚合最多 32 项");
|
|
43
|
+
if (e.parentValues !== "leaf-aggregate" && r.length) throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");
|
|
44
|
+
if (e.parentValues === "leaf-aggregate" && !r.length) throw new Error("叶子聚合策略至少需要一个聚合字段");
|
|
45
|
+
const i = /* @__PURE__ */ new Set();
|
|
46
|
+
for (const t of r) {
|
|
47
|
+
if (!t || !c(t.field) || i.has(t.field)) throw new Error("树聚合输出字段应安全、非空且唯一");
|
|
48
|
+
for (const n of [t.valueField, t.weightField]) if (n !== void 0 && !c(n)) throw new Error("树聚合来源字段应安全且非空");
|
|
49
|
+
if ([...p(e), e.labelField].includes(t.field)) throw new Error("树聚合不能覆盖结构键或标签字段");
|
|
50
|
+
i.add(t.field), w({ ...t, field: t.valueField ?? t.field });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function T(e) {
|
|
54
|
+
if (!c(e.idField) || !c(e.labelField)) throw new Error("树需要安全的业务键和标签字段");
|
|
55
|
+
if (e.input === "flat" && (!c(e.parentField) || e.parentField === e.idField)) throw new Error("扁平树需要独立的父键字段");
|
|
56
|
+
if (e.childrenField !== void 0 && !c(e.childrenField)) throw new Error("子节点字段应安全且非空");
|
|
57
|
+
if (e.input === "nested" && [e.idField, e.labelField].includes(e.childrenField ?? "children")) throw new Error("子节点字段不能覆盖业务键或标签字段");
|
|
58
|
+
}
|
|
59
|
+
function $(e) {
|
|
60
|
+
if (!e || typeof e != "object" || !["flat", "nested"].includes(e.input)) throw new Error("树输入应为 flat 或 nested");
|
|
61
|
+
if (T(e), e.orphan !== void 0 && !["error", "root"].includes(e.orphan)) throw new Error("树孤儿策略应为 error 或 root");
|
|
62
|
+
if (e.parentValues !== void 0 && !["source", "leaf-aggregate"].includes(e.parentValues)) throw new Error("未知树父级取值策略");
|
|
63
|
+
if (e.indentMm !== void 0 && (!Number.isFinite(e.indentMm) || e.indentMm < 0 || e.indentMm > 20)) throw new Error("树每级缩进应为 0–20 mm");
|
|
64
|
+
u(e), N(e);
|
|
65
|
+
}
|
|
66
|
+
function F(e, r, i, t) {
|
|
67
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("树节点应为对象");
|
|
68
|
+
if (i.size >= t.rows) throw new b(t.rows);
|
|
69
|
+
const n = m(e[r.idField]), l = E(n);
|
|
70
|
+
if (i.has(l)) throw new Error(`树节点业务键重复:${String(n)}`);
|
|
71
|
+
const o = { original: e, row: e, key: n, depth: 0, children: [] };
|
|
72
|
+
return i.set(l, o), o;
|
|
73
|
+
}
|
|
74
|
+
function M(e, r, i, t, n) {
|
|
75
|
+
for (const o of e)
|
|
76
|
+
h(n), F(o, r, i, t);
|
|
77
|
+
const l = [];
|
|
78
|
+
for (const o of i.values()) {
|
|
79
|
+
h(n);
|
|
80
|
+
const a = o.row[r.parentField];
|
|
81
|
+
if (a == null) {
|
|
82
|
+
l.push(o);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const f = i.get(E(m(a)));
|
|
86
|
+
if (!f) {
|
|
87
|
+
if (r.orphan !== "root") throw new Error(`树节点 ${String(o.key)} 的父节点不存在`);
|
|
88
|
+
l.push(o);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (f === o) throw new Error("树节点不能以自身为父节点");
|
|
92
|
+
o.parent = f, f.children.push(o);
|
|
93
|
+
}
|
|
94
|
+
return l;
|
|
95
|
+
}
|
|
96
|
+
function V(e, r, i, t, n) {
|
|
97
|
+
const l = [], o = [{ rows: e, next: 0 }];
|
|
98
|
+
for (; o.length; ) {
|
|
99
|
+
h(n);
|
|
100
|
+
const a = o[o.length - 1];
|
|
101
|
+
if (a.next >= a.rows.length) {
|
|
102
|
+
o.pop();
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const f = F(a.rows[a.next++], r, i, t);
|
|
106
|
+
if (f.parent = a.parent, f.depth = o.length - 1, o.length > t.depth) throw new Error(`树节点超出深度预算 ${t.depth}`);
|
|
107
|
+
(a.parent?.children ?? l).push(f);
|
|
108
|
+
const d = f.row[r.childrenField ?? "children"];
|
|
109
|
+
if (d != null) {
|
|
110
|
+
if (!Array.isArray(d)) throw new Error("嵌套树 children 字段应为数组");
|
|
111
|
+
d.length && o.push({ rows: d, next: 0, parent: f });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return l;
|
|
115
|
+
}
|
|
116
|
+
function x(e, r, i, t) {
|
|
117
|
+
const n = [], l = [{ nodes: e, next: 0 }];
|
|
118
|
+
for (; l.length; ) {
|
|
119
|
+
h(t);
|
|
120
|
+
const o = l[l.length - 1];
|
|
121
|
+
if (o.next >= o.nodes.length) {
|
|
122
|
+
l.pop();
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (l.length > i.depth) throw new Error(`树节点超出深度预算 ${i.depth}`);
|
|
126
|
+
const a = o.nodes[o.next++];
|
|
127
|
+
a.depth = l.length - 1, n.push(a), a.children.length && l.push({ nodes: a.children, next: 0 });
|
|
128
|
+
}
|
|
129
|
+
if (n.length !== r) throw new Error("树父子关系存在循环");
|
|
130
|
+
return n;
|
|
131
|
+
}
|
|
132
|
+
function S(e, r, i, t) {
|
|
133
|
+
if (r.parentValues !== "leaf-aggregate") return;
|
|
134
|
+
const n = r.aggregates, l = /* @__PURE__ */ new Map();
|
|
135
|
+
for (const a of e) a.children.length && l.set(a, n.map((f) => w({ ...f, field: f.valueField ?? f.field })));
|
|
136
|
+
let o = 0;
|
|
137
|
+
for (const a of e)
|
|
138
|
+
if (!a.children.length)
|
|
139
|
+
for (let f = a.parent; f; f = f.parent) {
|
|
140
|
+
if (h(t), o += n.length, o > i.visits) throw new Error(`树聚合超出访问预算 ${i.visits}`);
|
|
141
|
+
for (const d of l.get(f)) d.add(a.row);
|
|
142
|
+
}
|
|
143
|
+
for (const [a, f] of l)
|
|
144
|
+
a.row = { ...a.row }, n.forEach((d, v) => {
|
|
145
|
+
a.row[d.field] = f[v].value();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function y(e, r, i) {
|
|
149
|
+
if ($(r), h(i), !Array.isArray(e)) throw new Error("树数据应为节点数组");
|
|
150
|
+
const t = u(r), n = /* @__PURE__ */ new Map(), l = r.input === "flat" ? M(e, r, n, t, i) : V(e, r, n, t, i);
|
|
151
|
+
return x(l, n.size, t, i);
|
|
152
|
+
}
|
|
153
|
+
function O(e, r, i) {
|
|
154
|
+
return y(e, r, i).map((t) => t.original);
|
|
155
|
+
}
|
|
156
|
+
function R(e, r, i = {}) {
|
|
157
|
+
const t = y(e, r, i.signal);
|
|
158
|
+
if (k(r, i.computed?.fields), i.computed?.fields.length) {
|
|
159
|
+
const n = A(t.map((l) => l.row), { ...i.computed, signal: i.signal }).rows;
|
|
160
|
+
t.forEach((l, o) => {
|
|
161
|
+
l.row = n[o];
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return S(t, r, u(r), i.signal), { rows: t.map((n) => n.row), entries: t.map((n) => ({ row: n.row, original: n.original, key: n.key, depth: n.depth, hasChildren: !!n.children.length })), leaves: t.filter((n) => !n.children.length).map((n) => n.row) };
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
b as T,
|
|
168
|
+
k as a,
|
|
169
|
+
R as c,
|
|
170
|
+
O as f,
|
|
171
|
+
$ as v
|
|
172
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ref as c, computed as s } from "vue";
|
|
2
|
+
function r(o) {
|
|
3
|
+
const n = c(""), t = () => JSON.stringify(o()), a = s(() => n.value !== "" && t() !== n.value);
|
|
4
|
+
function e() {
|
|
5
|
+
n.value = t();
|
|
6
|
+
}
|
|
7
|
+
return e(), { pending: a, snapshot: t, accept: e };
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
r as u
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("vue");function a(s){const e=c.ref(""),t=()=>JSON.stringify(s()),u=c.computed(()=>e.value!==""&&t()!==e.value);function n(){e.value=t()}return n(),{pending:u,snapshot:t,accept:n}}exports.useLocalDraft=a;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function c(e, i, s) {
|
|
2
2
|
e.editable !== void 0 && typeof e.editable != "boolean" && s.push({ path: `${i}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && s.push({ path: `${i}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
c(e, i, s), g(e.source, `${i}.source`, s, !0), e.formula !== void 0 && typeof e.formula != "string" && s.push({ path: `${i}.formula`, message: "单元格公式应为字符串" });
|
|
4
|
+
function y(e, i, s) {
|
|
5
|
+
c(e, i, s), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && s.push({ path: `${i}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && s.push({ path: `${i}.derived`, message: "派生结果标记应为布尔值" }), g(e.source, `${i}.source`, s, !0), e.formula !== void 0 && typeof e.formula != "string" && s.push({ path: `${i}.formula`, message: "单元格公式应为字符串" });
|
|
6
6
|
}
|
|
7
7
|
function g(e, i, s, t = !1) {
|
|
8
8
|
if (e === void 0) return;
|
|
@@ -19,7 +19,7 @@ function g(e, i, s, t = !1) {
|
|
|
19
19
|
}
|
|
20
20
|
n.sourceToken !== void 0 && typeof n.sourceToken != "string" && s.push({ path: `${i}.sourceToken`, message: "来源令牌应为字符串" });
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const $ = /* @__PURE__ */ new Set([
|
|
23
23
|
"text",
|
|
24
24
|
"image",
|
|
25
25
|
"barcode",
|
|
@@ -29,17 +29,17 @@ const y = /* @__PURE__ */ new Set([
|
|
|
29
29
|
"rect",
|
|
30
30
|
"ellipse"
|
|
31
31
|
]);
|
|
32
|
-
function
|
|
32
|
+
function u(e) {
|
|
33
33
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function l(e, i, s, t) {
|
|
36
36
|
const n = e[i];
|
|
37
37
|
(typeof n != "number" || !Number.isFinite(n)) && t.push({ path: `${s}.${i}`, message: `应为有限数字,实际 ${JSON.stringify(n)}` });
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function v(e, i, s) {
|
|
40
40
|
if (e !== void 0) {
|
|
41
41
|
const t = `${i}.table`;
|
|
42
|
-
if (!
|
|
42
|
+
if (!u(e)) s.push({ path: t, message: "逻辑表来源应为对象" });
|
|
43
43
|
else {
|
|
44
44
|
g(e.source, `${t}.source`, s), (typeof e.id != "string" || !e.id.trim()) && s.push({ path: `${t}.id`, message: "逻辑表 ID 应为非空字符串" });
|
|
45
45
|
const n = e.role;
|
|
@@ -49,9 +49,9 @@ function A(e, i, s) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function A(e, i, s, t) {
|
|
53
53
|
if (e !== void 0)
|
|
54
|
-
if (!
|
|
54
|
+
if (!u(e) || !Array.isArray(e.cells))
|
|
55
55
|
s.push({ path: `${i}.grid.cells`, message: "grid.cells 应为二维数组" });
|
|
56
56
|
else {
|
|
57
57
|
const n = e.paddingMm;
|
|
@@ -60,15 +60,15 @@ function v(e, i, s, t) {
|
|
|
60
60
|
s.push({ path: `${i}.grid.cells.${o}`, message: "行应为数组" });
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
a.forEach((
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
if (!f
|
|
67
|
-
s.push({ path:
|
|
63
|
+
a.forEach((f, d) => {
|
|
64
|
+
if (f == null) return;
|
|
65
|
+
const h = `${i}.grid.cells.${o}.${d}`;
|
|
66
|
+
if (!u(f)) {
|
|
67
|
+
s.push({ path: h, message: "网格单元格应为对象或 null" });
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
r(
|
|
70
|
+
y(f, h, s), Array.isArray(f.children) && f.children.forEach((m, p) => {
|
|
71
|
+
r(m, `${i}.grid.cells.${o}.${d}.children.${p}`, s, t);
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
});
|
|
@@ -76,28 +76,28 @@ function v(e, i, s, t) {
|
|
|
76
76
|
}
|
|
77
77
|
function b(e, i, s) {
|
|
78
78
|
e !== void 0 && (Array.isArray(e) ? e.forEach((t, n) => {
|
|
79
|
-
(!
|
|
79
|
+
(!u(t) || !Array.isArray(t.segments)) && s.push({ path: `${i}.richParagraphs.${n}`, message: "段落缺少 segments 数组" });
|
|
80
80
|
}) : s.push({ path: `${i}.richParagraphs`, message: "richParagraphs 应为数组" }));
|
|
81
81
|
}
|
|
82
82
|
function r(e, i, s, t = []) {
|
|
83
|
-
if (!
|
|
83
|
+
if (!u(e)) {
|
|
84
84
|
s.push({ path: i, message: "组件应为对象" });
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
const n = e.kind;
|
|
88
|
-
typeof n != "string" ? s.push({ path: `${i}.kind`, message: "组件缺少 kind 字符串" }) :
|
|
88
|
+
typeof n != "string" ? s.push({ path: `${i}.kind`, message: "组件缺少 kind 字符串" }) : $.has(n) || t.push({
|
|
89
89
|
path: `${i}.kind`,
|
|
90
90
|
message: `未知组件类型 ${JSON.stringify(n)},将以兜底方式渲染`
|
|
91
91
|
});
|
|
92
92
|
for (const a of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
93
|
-
|
|
93
|
+
l(e, a, i, s);
|
|
94
94
|
typeof e.leftMm == "number" && e.leftMm < -100 && s.push({ path: `${i}.leftMm`, message: "几何数值异常(leftMm<-100)" });
|
|
95
95
|
for (const a of ["widthMm", "heightMm"])
|
|
96
96
|
typeof e[a] == "number" && e[a] < 0 && s.push({ path: `${i}.${a}`, message: "组件尺寸不能为负数" });
|
|
97
|
-
|
|
97
|
+
v(e.table, i, s), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && s.push({ path: `${i}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && s.push({ path: `${i}.lineDirection`, message: "线段方向应为 down 或 up" }), A(e.grid, i, s, t), b(e.richParagraphs, i, s);
|
|
98
98
|
}
|
|
99
99
|
function M(e, i, s, t = []) {
|
|
100
|
-
if (!
|
|
100
|
+
if (!u(e)) {
|
|
101
101
|
s.push({ path: i, message: "页应为对象" });
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
@@ -105,12 +105,12 @@ function M(e, i, s, t = []) {
|
|
|
105
105
|
(typeof n != "number" || !Number.isFinite(n) || n <= 0) && s.push({ path: `${i}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(n)}` }), (typeof a != "number" || !(a > 0 && a < 5e3)) && s.push({ path: `${i}.pageHeightMm`, message: `页高非法: ${JSON.stringify(a)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && s.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" });
|
|
106
106
|
const o = e.components;
|
|
107
107
|
Array.isArray(o) ? Array.isArray(o) && o.forEach(
|
|
108
|
-
(
|
|
108
|
+
(f, d) => r(f, `${i}.components.${d}`, s, t)
|
|
109
109
|
) : s.push({ path: `${i}.components`, message: "components 应为数组" });
|
|
110
110
|
}
|
|
111
111
|
function w(e) {
|
|
112
|
-
const i = [], s = [], t =
|
|
113
|
-
if (!Array.isArray(t))
|
|
112
|
+
const i = [], s = [], t = u(e) ? e.pages : void 0;
|
|
113
|
+
if (u(e) && e.requiresRecalculation !== void 0 && typeof e.requiresRecalculation != "boolean" && i.push({ path: "$.requiresRecalculation", message: "重算能力要求应为布尔值" }), !Array.isArray(t))
|
|
114
114
|
i.push({
|
|
115
115
|
path: "$.pages",
|
|
116
116
|
message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
|
|
@@ -121,7 +121,7 @@ function w(e) {
|
|
|
121
121
|
message: `页数异常大(${t.length} 页),渲染与打印耗时可能显著增加`
|
|
122
122
|
});
|
|
123
123
|
const n = t.reduce(
|
|
124
|
-
(a, o) => a + (
|
|
124
|
+
(a, o) => a + (u(o) && Array.isArray(o.components) ? o.components.length : 0),
|
|
125
125
|
0
|
|
126
126
|
);
|
|
127
127
|
n > 5e4 && s.push({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function g(e,s,i){e.editable!==void 0&&typeof e.editable!="boolean"&&i.push({path:`${s}.editable`,message:"编辑控制应为布尔值"}),e.valueType!==void 0&&!["text","number","boolean"].includes(e.valueType)&&i.push({path:`${s}.valueType`,message:"编辑类型应为 text、number 或 boolean"})}function $(e,s,i){g(e,s,i),e.indentMm!==void 0&&(typeof e.indentMm!="number"||!Number.isFinite(e.indentMm)||e.indentMm<0)&&i.push({path:`${s}.indentMm`,message:"单元格缩进应为有限非负数"}),e.derived!==void 0&&typeof e.derived!="boolean"&&i.push({path:`${s}.derived`,message:"派生结果标记应为布尔值"}),m(e.source,`${s}.source`,i,!0),e.formula!==void 0&&typeof e.formula!="string"&&i.push({path:`${s}.formula`,message:"单元格公式应为字符串"})}function m(e,s,i,t=!1){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)){i.push({path:s,message:"业务来源应为对象"});return}const a=e;for(const n of["datasetId",...t?["field"]:[]])(typeof a[n]!="string"||!a[n].trim())&&i.push({path:`${s}.${n}`,message:"业务标识应为非空字符串"});for(const n of["rowKey","revision"]){const o=a[n];o===void 0&&!(t&&n==="rowKey")||typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o))&&i.push({path:`${s}.${n}`,message:"业务键及修订号应为字符串或有限数字"})}a.sourceToken!==void 0&&typeof a.sourceToken!="string"&&i.push({path:`${s}.sourceToken`,message:"来源令牌应为字符串"})}const v=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function A(e,s,i,t){const a=e[s];(typeof a!="number"||!Number.isFinite(a))&&t.push({path:`${i}.${s}`,message:`应为有限数字,实际 ${JSON.stringify(a)}`})}function b(e,s,i){if(e!==void 0){const t=`${s}.table`;if(!u(e))i.push({path:t,message:"逻辑表来源应为对象"});else{m(e.source,`${t}.source`,i),(typeof e.id!="string"||!e.id.trim())&&i.push({path:`${t}.id`,message:"逻辑表 ID 应为非空字符串"});const a=e.role;["header","body","group-header","subtotal","grand-total"].includes(a)||i.push({path:`${t}.role`,message:"未知逻辑表行角色"});const n=e.rowIndex;(typeof n!="number"||!Number.isInteger(n)||(a==="header"?n!==-1:n<0))&&i.push({path:`${t}.rowIndex`,message:"表头索引应为 -1,内容行索引应为非负整数"}),(!Array.isArray(e.columnKeys)||e.columnKeys.some(o=>typeof o!="string"))&&i.push({path:`${t}.columnKeys`,message:"逻辑列字段应为字符串数组"}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&i.push({path:`${t}.layout`,message:"布局应为 page 或 wide"}),e.title!==void 0&&typeof e.title!="string"&&i.push({path:`${t}.title`,message:"逻辑表名称应为字符串"})}}}function M(e,s,i,t){if(e!==void 0)if(!u(e)||!Array.isArray(e.cells))i.push({path:`${s}.grid.cells`,message:"grid.cells 应为二维数组"});else{const a=e.paddingMm;a!==void 0&&(typeof a!="number"||!Number.isFinite(a)||a<0)&&i.push({path:`${s}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((n,o)=>{if(!Array.isArray(n)){i.push({path:`${s}.grid.cells.${o}`,message:"行应为数组"});return}n.forEach((f,d)=>{if(f==null)return;const r=`${s}.grid.cells.${o}.${d}`;if(!u(f)){i.push({path:r,message:"网格单元格应为对象或 null"});return}$(f,r,i),Array.isArray(f.children)&&f.children.forEach((l,y)=>{h(l,`${s}.grid.cells.${o}.${d}.children.${y}`,i,t)})})})}}function w(e,s,i){e!==void 0&&(Array.isArray(e)?e.forEach((t,a)=>{(!u(t)||!Array.isArray(t.segments))&&i.push({path:`${s}.richParagraphs.${a}`,message:"段落缺少 segments 数组"})}):i.push({path:`${s}.richParagraphs`,message:"richParagraphs 应为数组"}))}function h(e,s,i,t=[]){if(!u(e)){i.push({path:s,message:"组件应为对象"});return}const a=e.kind;typeof a!="string"?i.push({path:`${s}.kind`,message:"组件缺少 kind 字符串"}):v.has(a)||t.push({path:`${s}.kind`,message:`未知组件类型 ${JSON.stringify(a)},将以兜底方式渲染`});for(const n of["leftMm","topMm","widthMm","heightMm"])A(e,n,s,i);typeof e.leftMm=="number"&&e.leftMm<-100&&i.push({path:`${s}.leftMm`,message:"几何数值异常(leftMm<-100)"});for(const n of["widthMm","heightMm"])typeof e[n]=="number"&&e[n]<0&&i.push({path:`${s}.${n}`,message:"组件尺寸不能为负数"});b(e.table,s,i),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&i.push({path:`${s}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&i.push({path:`${s}.lineDirection`,message:"线段方向应为 down 或 up"}),M(e.grid,s,i,t),w(e.richParagraphs,s,i)}function p(e,s,i,t=[]){if(!u(e)){i.push({path:s,message:"页应为对象"});return}const a=e.pageWidthMm,n=e.pageHeightMm;(typeof a!="number"||!Number.isFinite(a)||a<=0)&&i.push({path:`${s}.pageWidthMm`,message:`页宽非法: ${JSON.stringify(a)}`}),(typeof n!="number"||!(n>0&&n<5e3))&&i.push({path:`${s}.pageHeightMm`,message:`页高非法: ${JSON.stringify(n)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&i.push({path:`${s}.layout`,message:"布局应为 page 或 wide"});const o=e.components;Array.isArray(o)?Array.isArray(o)&&o.forEach((f,d)=>h(f,`${s}.components.${d}`,i,t)):i.push({path:`${s}.components`,message:"components 应为数组"})}function c(e){const s=[],i=[],t=u(e)?e.pages:void 0;if(u(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&s.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(t))s.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{t.forEach((n,o)=>p(n,`$.pages.${o}`,s,i)),t.length>2e3&&i.push({path:"$.pages",message:`页数异常大(${t.length} 页),渲染与打印耗时可能显著增加`});const a=t.reduce((n,o)=>n+(u(o)&&Array.isArray(o.components)?o.components.length:0),0);a>5e4&&i.push({path:"$.pages",message:`组件总数异常大(${a} 个),可能触发浏览器性能限制`})}return{ok:s.length===0,errors:s,warnings:i}}function k(e){const s=c(e);if(!s.ok){const i=s.errors.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ");throw new Error(`渲染计划校验失败(${s.errors.length} 处): ${i}`)}return e.pages}exports.assertRenderPlan=k;exports.validateComponent=h;exports.validateEditableMetadata=g;exports.validatePage=p;exports.validateRenderPlan=c;
|