@cluadwong/form-designer 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/dist/chunks/designer-ui.js +3092 -0
- package/dist/chunks/renderer-core.js +2635 -0
- package/dist/components/designer/CanvasSurface.vue.d.ts +64 -0
- package/dist/components/designer/CanvasSurface.vue.d.ts.map +1 -0
- package/dist/components/designer/DesignerToolbar.vue.d.ts +49 -0
- package/dist/components/designer/DesignerToolbar.vue.d.ts.map +1 -0
- package/dist/components/designer/FormDesigner.vue.d.ts +25 -0
- package/dist/components/designer/FormDesigner.vue.d.ts.map +1 -0
- package/dist/components/designer/HelpPanel.vue.d.ts +10 -0
- package/dist/components/designer/HelpPanel.vue.d.ts.map +1 -0
- package/dist/components/designer/InspectorPanel.vue.d.ts +48 -0
- package/dist/components/designer/InspectorPanel.vue.d.ts.map +1 -0
- package/dist/components/designer/NodeTreeItem.vue.d.ts +18 -0
- package/dist/components/designer/NodeTreeItem.vue.d.ts.map +1 -0
- package/dist/components/designer/PaletteSidebar.vue.d.ts +29 -0
- package/dist/components/designer/PaletteSidebar.vue.d.ts.map +1 -0
- package/dist/components/designer/StatusBar.vue.d.ts +25 -0
- package/dist/components/designer/StatusBar.vue.d.ts.map +1 -0
- package/dist/components/designer/composables/treeControl.d.ts +65 -0
- package/dist/components/designer/composables/treeControl.d.ts.map +1 -0
- package/dist/components/designer/composables/useFillData.d.ts +34 -0
- package/dist/components/designer/composables/useFillData.d.ts.map +1 -0
- package/dist/components/designer/composables/useNodeSelection.d.ts +56 -0
- package/dist/components/designer/composables/useNodeSelection.d.ts.map +1 -0
- package/dist/components/designer/composables/useSchemaDocument.d.ts +44 -0
- package/dist/components/designer/composables/useSchemaDocument.d.ts.map +1 -0
- package/dist/components/designer/composables/useSchemaEdits.d.ts +111 -0
- package/dist/components/designer/composables/useSchemaEdits.d.ts.map +1 -0
- package/dist/components/designer/config.d.ts +40 -0
- package/dist/components/designer/config.d.ts.map +1 -0
- package/dist/components/designer/export-api.d.ts +81 -0
- package/dist/components/designer/export-api.d.ts.map +1 -0
- package/dist/components/designer/inspectors/CellInspector.vue.d.ts +20 -0
- package/dist/components/designer/inspectors/CellInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/FieldPInspector.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/FieldPInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/GridInspector.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/GridInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/HeaderFooterFields.vue.d.ts +14 -0
- package/dist/components/designer/inspectors/HeaderFooterFields.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/HtmlInspector.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/HtmlInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/ImageInspector.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/ImageInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/IssuesPanel.vue.d.ts +11 -0
- package/dist/components/designer/inspectors/IssuesPanel.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/PageInspector.vue.d.ts +27 -0
- package/dist/components/designer/inspectors/PageInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/TableInspector.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/TableInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/TextInspector.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/TextInspector.vue.d.ts.map +1 -0
- package/dist/components/designer/inspectors/TextStyleFields.vue.d.ts +10 -0
- package/dist/components/designer/inspectors/TextStyleFields.vue.d.ts.map +1 -0
- package/dist/components/renderer-v2/FormRenderer.vue.d.ts +106 -0
- package/dist/components/renderer-v2/FormRenderer.vue.d.ts.map +1 -0
- package/dist/components/renderer-v2/GridFormRenderer.vue.d.ts +49 -0
- package/dist/components/renderer-v2/GridFormRenderer.vue.d.ts.map +1 -0
- package/dist/components/renderer-v2/GridSchemaNode.vue.d.ts +46 -0
- package/dist/components/renderer-v2/GridSchemaNode.vue.d.ts.map +1 -0
- package/dist/components/renderer-v2/HtmlBlock.vue.d.ts +16 -0
- package/dist/components/renderer-v2/HtmlBlock.vue.d.ts.map +1 -0
- package/dist/components/renderer-v2/PaperViewport.vue.d.ts +63 -0
- package/dist/components/renderer-v2/PaperViewport.vue.d.ts.map +1 -0
- package/dist/components/renderer-v2/collectFieldValues.d.ts +29 -0
- package/dist/components/renderer-v2/collectFieldValues.d.ts.map +1 -0
- package/dist/components/renderer-v2/index.d.ts +13 -0
- package/dist/components/renderer-v2/index.d.ts.map +1 -0
- package/dist/components/renderer-v2/measure-rows.d.ts +12 -0
- package/dist/components/renderer-v2/measure-rows.d.ts.map +1 -0
- package/dist/components/renderer-v2/page-size-style.d.ts +28 -0
- package/dist/components/renderer-v2/page-size-style.d.ts.map +1 -0
- package/dist/components/renderer-v2/print-form.d.ts +20 -0
- package/dist/components/renderer-v2/print-form.d.ts.map +1 -0
- package/dist/designer-ui.css +5 -0
- package/dist/designer.d.ts +16 -0
- package/dist/designer.d.ts.map +1 -0
- package/dist/designer.js +16 -0
- package/dist/engine-v2/derivation.d.ts +81 -0
- package/dist/engine-v2/derivation.d.ts.map +1 -0
- package/dist/engine-v2/index.d.ts +3 -0
- package/dist/engine-v2/index.d.ts.map +1 -0
- package/dist/engine-v2/node-address.d.ts +25 -0
- package/dist/engine-v2/node-address.d.ts.map +1 -0
- package/dist/engine-v2/pagination.d.ts +120 -0
- package/dist/engine-v2/pagination.d.ts.map +1 -0
- package/dist/i18n/en.d.ts +7 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +14 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/types.d.ts +5 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/zh-CN.d.ts +7 -0
- package/dist/i18n/zh-CN.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/renderer-core.css +1 -0
- package/dist/renderer.d.ts +22 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +93 -0
- package/dist/samples/types.d.ts +18 -0
- package/dist/samples/types.d.ts.map +1 -0
- package/dist/ticket-designer.css +5 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/schema-v2-index.d.ts +15 -0
- package/dist/types/schema-v2-index.d.ts.map +1 -0
- package/dist/types/schema-v2-operations.d.ts +124 -0
- package/dist/types/schema-v2-operations.d.ts.map +1 -0
- package/dist/types/schema-v2-serialization.d.ts +30 -0
- package/dist/types/schema-v2-serialization.d.ts.map +1 -0
- package/dist/types/schema-v2-table-rows.d.ts +17 -0
- package/dist/types/schema-v2-table-rows.d.ts.map +1 -0
- package/dist/types/schema-v2-validation.d.ts +10 -0
- package/dist/types/schema-v2-validation.d.ts.map +1 -0
- package/dist/types/schema-v2.d.ts +283 -0
- package/dist/types/schema-v2.d.ts.map +1 -0
- package/dist/utils/date-format.d.ts +34 -0
- package/dist/utils/date-format.d.ts.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,2635 @@
|
|
|
1
|
+
var pt = Object.defineProperty;
|
|
2
|
+
var yt = (e, t, n) => t in e ? pt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var je = (e, t, n) => yt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { defineComponent as Te, ref as X, onMounted as Fe, watch as ge, openBlock as A, createElementBlock as R, computed as K, resolveComponent as wt, normalizeStyle as z, normalizeClass as ae, Fragment as q, renderList as Y, createBlock as ye, toDisplayString as G, createCommentVNode as Ae, createTextVNode as bt, createElementVNode as O, onUnmounted as vt, nextTick as Je, onBeforeUnmount as Et, renderSlot as Tt, withCtx as St, createVNode as Mt } from "vue";
|
|
5
|
+
import "./designer-ui.js";
|
|
6
|
+
import xt from "dompurify";
|
|
7
|
+
import At from "@panzoom/panzoom";
|
|
8
|
+
import { VuePrintNext as Rt } from "vue-print-next";
|
|
9
|
+
const Nt = 10;
|
|
10
|
+
function un(e) {
|
|
11
|
+
return !!(e && e.type !== "grid-row" && e.type !== "grid-cell" && e.type !== "table-cell-template");
|
|
12
|
+
}
|
|
13
|
+
const Ft = {
|
|
14
|
+
A4: { short: 210, long: 297 },
|
|
15
|
+
A3: { short: 297, long: 420 }
|
|
16
|
+
};
|
|
17
|
+
function Be(e) {
|
|
18
|
+
const t = (e == null ? void 0 : e.size) === "A3" ? "A3" : "A4", n = Ft[t], r = t === "A3" ? "landscape" : "portrait";
|
|
19
|
+
return r === "portrait" ? { size: t, orientation: r, widthMm: n.short, heightMm: n.long } : { size: t, orientation: r, widthMm: n.long, heightMm: n.short };
|
|
20
|
+
}
|
|
21
|
+
function rt(e, t) {
|
|
22
|
+
return se(e).get(t);
|
|
23
|
+
}
|
|
24
|
+
function dn(e, t) {
|
|
25
|
+
var n;
|
|
26
|
+
return (n = rt(e, t)) == null ? void 0 : n.node;
|
|
27
|
+
}
|
|
28
|
+
function fn(e, t) {
|
|
29
|
+
var n;
|
|
30
|
+
return (n = rt(e, t)) == null ? void 0 : n.ownerCell;
|
|
31
|
+
}
|
|
32
|
+
function mn(e, t) {
|
|
33
|
+
const n = se(e), r = n.get(t);
|
|
34
|
+
if (!r) return [];
|
|
35
|
+
const i = [];
|
|
36
|
+
let o = r.parent;
|
|
37
|
+
for (; o; ) {
|
|
38
|
+
i.unshift(o);
|
|
39
|
+
const a = n.get(o.id);
|
|
40
|
+
o = (a == null ? void 0 : a.parent) ?? null;
|
|
41
|
+
}
|
|
42
|
+
return i;
|
|
43
|
+
}
|
|
44
|
+
function Ee(e, t, n, r, i) {
|
|
45
|
+
if (e.has(t.id))
|
|
46
|
+
throw new Error(`Duplicate Schema V2 node id: ${t.id}`);
|
|
47
|
+
e.set(t.id, { node: t, parent: n, path: r, ownerCell: i });
|
|
48
|
+
}
|
|
49
|
+
function Ge(e, t, n, r, i) {
|
|
50
|
+
Ee(e, t, n, r, i), t.type === "grid" ? t.rows.forEach((o, a) => kt(e, o, t, [...r, "rows", a])) : t.type === "table" && t.rowTemplate.forEach((o, a) => {
|
|
51
|
+
const l = [...r, "rowTemplate", a];
|
|
52
|
+
Ee(e, o, t, l), o.children.forEach(
|
|
53
|
+
(c, d) => Ge(e, c, o, [...l, "children", d], o)
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function kt(e, t, n, r) {
|
|
58
|
+
Ee(e, t, n, r), t.cells.forEach((i, o) => {
|
|
59
|
+
const a = [...r, "cells", o];
|
|
60
|
+
Ee(e, i, t, a), i.children.forEach(
|
|
61
|
+
(l, c) => Ge(e, l, i, [...a, "children", c], i)
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function se(e) {
|
|
66
|
+
const t = /* @__PURE__ */ new Map();
|
|
67
|
+
return e.pages.forEach((n, r) => {
|
|
68
|
+
const i = ["pages", r];
|
|
69
|
+
Ee(t, n, null, i), n.children.forEach(
|
|
70
|
+
(o, a) => Ge(t, o, n, [...i, "children", a])
|
|
71
|
+
);
|
|
72
|
+
}), t;
|
|
73
|
+
}
|
|
74
|
+
function F(e, t, n, r, i, o) {
|
|
75
|
+
e.push({ level: t, code: n, nodeId: r == null ? void 0 : r.id, path: i, message: o });
|
|
76
|
+
}
|
|
77
|
+
function le(e) {
|
|
78
|
+
return typeof e == "number" && Number.isFinite(e) && e > 0;
|
|
79
|
+
}
|
|
80
|
+
function nt(e) {
|
|
81
|
+
return e === "auto" ? !0 : typeof e == "number" ? le(e) : typeof e == "string" && /^\d+(?:\.\d+)?fr$/.test(e);
|
|
82
|
+
}
|
|
83
|
+
const It = 25.4 / 96, it = 13, Lt = 12;
|
|
84
|
+
function Ct(e) {
|
|
85
|
+
return /[\u3000-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/.test(e);
|
|
86
|
+
}
|
|
87
|
+
function ot(e, t) {
|
|
88
|
+
let n = 0;
|
|
89
|
+
for (const r of e) n += Ct(r) ? 1 : 0.5;
|
|
90
|
+
return n * t * It;
|
|
91
|
+
}
|
|
92
|
+
function be(e) {
|
|
93
|
+
return `${Math.round(e * 10) / 10}`;
|
|
94
|
+
}
|
|
95
|
+
function $t(e, t, n, r) {
|
|
96
|
+
var l, c;
|
|
97
|
+
if (!t || ((l = e.style) == null ? void 0 : l.writingMode) === "vertical-rl") return;
|
|
98
|
+
const i = ((c = e.style) == null ? void 0 : c.fontSize) ?? it;
|
|
99
|
+
let o;
|
|
100
|
+
if ((e.prefix || e.suffix) && (o = ot(`${e.prefix ?? ""}${e.suffix ?? ""}`, i) + Lt), o === void 0) return;
|
|
101
|
+
const a = t.widthMm - 2 * t.paddingMm;
|
|
102
|
+
o > a && F(
|
|
103
|
+
r,
|
|
104
|
+
"warning",
|
|
105
|
+
"CONTENT_OVERFLOW",
|
|
106
|
+
e,
|
|
107
|
+
n,
|
|
108
|
+
`字段内容估算宽度约 ${be(o)}mm,超过可用宽度 ${be(a)}mm,可能显示不全`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function Dt(e, t) {
|
|
112
|
+
return e.type === "grid" ? e.rows.reduce((n, r) => n + Math.max(0, r.height), 0) * t : e.type === "p" ? t : e.type === "table" ? Math.max(0, 1 + e.minRows) * t : e.type === "image" ? !e.src && !e.field ? 0 : Math.max(0, e.height ?? 0) : 0;
|
|
113
|
+
}
|
|
114
|
+
function Ht(e, t) {
|
|
115
|
+
const { heightMm: n } = Be(e.paper);
|
|
116
|
+
return n - t.margin.top - t.margin.bottom;
|
|
117
|
+
}
|
|
118
|
+
function Vt(e, t, n, r) {
|
|
119
|
+
const i = t.children.reduce(
|
|
120
|
+
(a, l) => a + Dt(l, e.baseRowHeight),
|
|
121
|
+
0
|
|
122
|
+
), o = Ht(e, t);
|
|
123
|
+
i > o && F(
|
|
124
|
+
r,
|
|
125
|
+
"warning",
|
|
126
|
+
"PAPER_OVERFLOW",
|
|
127
|
+
t,
|
|
128
|
+
n,
|
|
129
|
+
`页面内容最低高度约 ${be(i)}mm,超过一页可用高度 ${be(o)}mm,打印时会自动分成多页`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
function Pt(e, t, n) {
|
|
133
|
+
if (!e) return;
|
|
134
|
+
let r = 0;
|
|
135
|
+
for (let i = t; i < t + n; i += 1) {
|
|
136
|
+
const o = e[i];
|
|
137
|
+
if (typeof o == "number" && le(o))
|
|
138
|
+
r = (r ?? 0) + o;
|
|
139
|
+
else
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
return r;
|
|
143
|
+
}
|
|
144
|
+
function _t(e, t, n) {
|
|
145
|
+
if (!Array.isArray(e.rows) || e.rows.length === 0) {
|
|
146
|
+
F(n, "error", "INVALID_GRID_ROWS", e, t, "格子至少需要一行");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
e.rows.forEach((r, i) => Ot(r, e, [...t, "rows", i], n)), e.gap !== void 0 && !le(e.gap) && F(n, "warning", "INVALID_GRID_GAP", e, t, "格子间距必须是正数(mm)");
|
|
150
|
+
}
|
|
151
|
+
function Ot(e, t, n, r) {
|
|
152
|
+
if (le(e.height) || F(r, "error", "INVALID_ROW_HEIGHT", e, n, "行高必须是正数"), !Array.isArray(e.cells) || e.cells.length === 0) {
|
|
153
|
+
F(r, "error", "INVALID_GRID_CELLS", e, n, "该行至少需要一个格子");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
let i = 0;
|
|
157
|
+
e.cells.forEach((o, a) => {
|
|
158
|
+
Bt(o, [...n, "cells", a], r);
|
|
159
|
+
const l = o.colspan ?? 1;
|
|
160
|
+
(!Number.isInteger(l) || l < 1) && F(r, "error", "INVALID_COLSPAN", o, [...n, "cells", a], "合并格数必须是正整数"), i += Number.isInteger(l) && l > 0 ? l : 0;
|
|
161
|
+
}), t.rows.some((o) => o.cells.length > 0) && i < 1 && F(r, "error", "INVALID_GRID_COLUMNS", t, n, "该行没有可用的格子");
|
|
162
|
+
}
|
|
163
|
+
function Bt(e, t, n) {
|
|
164
|
+
e.width !== void 0 && !nt(e.width) && F(n, "error", "INVALID_CELL_WIDTH", e, t, "格子宽度必须是正数(mm)、比例(如 1fr)或 auto"), e.padding !== void 0 && (!Number.isFinite(e.padding) || e.padding < 0) && F(n, "error", "INVALID_CELL_PADDING", e, t, "内边距不能是负数");
|
|
165
|
+
}
|
|
166
|
+
function Gt(e, t, n) {
|
|
167
|
+
if (!Array.isArray(e.columns) || e.columns.length === 0) {
|
|
168
|
+
F(n, "error", "INVALID_TABLE_COLUMNS", e, t, "表格至少需要一列");
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const r = /* @__PURE__ */ new Set();
|
|
172
|
+
e.columns.forEach((o, a) => {
|
|
173
|
+
const l = [...t, "columns", a];
|
|
174
|
+
(!o.key.trim() || r.has(o.key)) && F(n, "error", "DUPLICATE_TABLE_COLUMN", e, l, `列字段重复或为空:${o.key}`), r.add(o.key), o.width !== void 0 && !nt(o.width) && F(n, "error", "INVALID_TABLE_COLUMN_WIDTH", e, l, `列「${o.key}」的宽度不合法`);
|
|
175
|
+
}), (!Number.isInteger(e.minRows) || e.minRows < 0) && F(n, "error", "INVALID_TABLE_MIN_ROWS", e, t, "表格最小行数必须是不小于 0 的整数");
|
|
176
|
+
const i = /* @__PURE__ */ new Set();
|
|
177
|
+
e.rowTemplate.forEach((o, a) => {
|
|
178
|
+
const l = [...t, "rowTemplate", a];
|
|
179
|
+
(!r.has(o.columnKey) || i.has(o.columnKey)) && F(n, "error", "INVALID_TABLE_TEMPLATE", o, l, `行模板引用了不存在的列:${o.columnKey}`), i.add(o.columnKey);
|
|
180
|
+
});
|
|
181
|
+
for (const o of r)
|
|
182
|
+
i.has(o) || F(n, "warning", "MISSING_TABLE_TEMPLATE", e, t, `列「${o}」缺少行模板`);
|
|
183
|
+
}
|
|
184
|
+
function He(e, t, n, r, i, o = !1) {
|
|
185
|
+
var l, c;
|
|
186
|
+
if (!(/* @__PURE__ */ new Set(["text", "p", "grid", "table", "image", "html"])).has(e.type)) {
|
|
187
|
+
F(
|
|
188
|
+
n,
|
|
189
|
+
"error",
|
|
190
|
+
"UNKNOWN_NODE_TYPE",
|
|
191
|
+
e,
|
|
192
|
+
t,
|
|
193
|
+
`未知组件类型:${String(e.type)}`
|
|
194
|
+
);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (e.type === "text") {
|
|
198
|
+
if (i && ((l = e.style) == null ? void 0 : l.writingMode) !== "vertical-rl") {
|
|
199
|
+
const d = ((c = e.style) == null ? void 0 : c.fontSize) ?? it, h = ot(e.text, d), p = i.widthMm - 2 * i.paddingMm;
|
|
200
|
+
h > p && F(
|
|
201
|
+
n,
|
|
202
|
+
"warning",
|
|
203
|
+
"CONTENT_OVERFLOW",
|
|
204
|
+
e,
|
|
205
|
+
t,
|
|
206
|
+
`文本估算宽度约 ${be(h)}mm,超过格子可用宽度 ${be(p)}mm,可能显示不全`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
e.text.trim() || F(n, "warning", "EMPTY_STATIC_TEXT", e, t, "文本内容为空");
|
|
210
|
+
} else e.type === "p" ? ($t(e, i, t, n), e.mode === "field" && !o && (e.field.trim() ? r.has(e.field) ? F(n, "warning", "DUPLICATE_FIELD", e, t, `字段名已被其他字段使用:${e.field}`) : r.set(e.field, e.id) : F(n, "warning", "EMPTY_FIELD", e, t, "字段名为空"))) : e.type === "grid" ? (_t(e, t, n), e.rows.forEach((d, h) => {
|
|
211
|
+
let p = 0;
|
|
212
|
+
d.cells.forEach((b, y) => {
|
|
213
|
+
const M = b.colspan ?? 1, w = M === 1 ? Pt(e.columns, p, 1) ?? (typeof b.width == "number" && le(b.width) ? b.width : void 0) : void 0, f = w !== void 0 ? { widthMm: w, paddingMm: b.padding ?? e.cellPadding ?? 0 } : void 0;
|
|
214
|
+
b.children.forEach(
|
|
215
|
+
(u, m) => He(u, [...t, "rows", h, "cells", y, "children", m], n, r, f, o)
|
|
216
|
+
), p += M;
|
|
217
|
+
});
|
|
218
|
+
})) : e.type === "table" ? (Gt(e, t, n), e.rowTemplate.forEach((d, h) => {
|
|
219
|
+
const p = e.columns.find((y) => y.key === d.columnKey), b = p && typeof p.width == "number" && le(p.width) ? { widthMm: p.width, paddingMm: 0 } : void 0;
|
|
220
|
+
d.children.forEach(
|
|
221
|
+
(y, M) => He(y, [...t, "rowTemplate", h, "children", M], n, r, b, !0)
|
|
222
|
+
);
|
|
223
|
+
})) : e.type === "image" && (!e.src && !e.field && F(n, "warning", "IMAGE_WITHOUT_SOURCE", e, t, "图片未设置地址或数据字段"), (e.width !== void 0 && !le(e.width) || e.height !== void 0 && !le(e.height)) && F(n, "error", "INVALID_IMAGE_DIMENSION", e, t, "图片宽高必须是正数"));
|
|
224
|
+
}
|
|
225
|
+
function ze(e) {
|
|
226
|
+
const t = [];
|
|
227
|
+
e.version !== 2 && F(t, "error", "INVALID_VERSION", void 0, void 0, "不是有效的表单模板文件(Schema V2)"), le(e.baseRowHeight) || F(t, "error", "INVALID_BASE_ROW_HEIGHT", void 0, ["baseRowHeight"], "基础行高必须是正数");
|
|
228
|
+
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = (o, a) => {
|
|
229
|
+
n.has(o.id) && F(t, "error", "DUPLICATE_ID", o, a, `存在重复的节点 ID:${o.id}`), n.add(o.id);
|
|
230
|
+
};
|
|
231
|
+
e.pages.forEach((o, a) => {
|
|
232
|
+
const l = ["pages", a];
|
|
233
|
+
i(o, l), o.children.length || F(t, "warning", "EMPTY_PAGE", o, l, "页面没有内容"), Vt(e, o, l, t), o.children.forEach(
|
|
234
|
+
(c, d) => He(c, [...l, "children", d], t, r, void 0)
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
try {
|
|
238
|
+
se(e);
|
|
239
|
+
} catch (o) {
|
|
240
|
+
F(t, "error", "INDEX_BUILD_FAILED", void 0, void 0, o instanceof Error ? o.message : String(o));
|
|
241
|
+
}
|
|
242
|
+
return t;
|
|
243
|
+
}
|
|
244
|
+
function P(e) {
|
|
245
|
+
return `${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
|
|
246
|
+
}
|
|
247
|
+
function me(e) {
|
|
248
|
+
const t = (n) => P(n);
|
|
249
|
+
return e.type === "grid-row" ? {
|
|
250
|
+
...e,
|
|
251
|
+
id: t("row"),
|
|
252
|
+
cells: e.cells.map((n) => me(n))
|
|
253
|
+
} : e.type === "grid-cell" ? {
|
|
254
|
+
...e,
|
|
255
|
+
id: t("cell"),
|
|
256
|
+
children: e.children.map(me)
|
|
257
|
+
} : e.type === "table-cell-template" ? {
|
|
258
|
+
...e,
|
|
259
|
+
id: t("template"),
|
|
260
|
+
children: e.children.map(me)
|
|
261
|
+
} : e.type === "page" ? { ...e, id: t("page"), children: e.children.map(me) } : e.type === "grid" ? {
|
|
262
|
+
...e,
|
|
263
|
+
id: t("grid"),
|
|
264
|
+
rows: e.rows.map((n) => ({
|
|
265
|
+
...n,
|
|
266
|
+
id: t("row"),
|
|
267
|
+
cells: n.cells.map((r) => ({
|
|
268
|
+
...r,
|
|
269
|
+
id: t("cell"),
|
|
270
|
+
children: r.children.map(me)
|
|
271
|
+
}))
|
|
272
|
+
}))
|
|
273
|
+
} : e.type === "table" ? {
|
|
274
|
+
...e,
|
|
275
|
+
id: t("table"),
|
|
276
|
+
rowTemplate: e.rowTemplate.map((n) => ({
|
|
277
|
+
...n,
|
|
278
|
+
id: t("template"),
|
|
279
|
+
children: n.children.map(me)
|
|
280
|
+
}))
|
|
281
|
+
} : { ...e, id: t(e.type) };
|
|
282
|
+
}
|
|
283
|
+
function zt(e) {
|
|
284
|
+
return me(e);
|
|
285
|
+
}
|
|
286
|
+
function We(e, t, n) {
|
|
287
|
+
const r = e.id === t ? n(e) : e;
|
|
288
|
+
return r.type === "grid" ? {
|
|
289
|
+
...r,
|
|
290
|
+
rows: r.rows.map((i) => Wt(i, t, n))
|
|
291
|
+
} : r.type === "table" ? {
|
|
292
|
+
...r,
|
|
293
|
+
rowTemplate: r.rowTemplate.map((i) => Kt(i, t, n))
|
|
294
|
+
} : r;
|
|
295
|
+
}
|
|
296
|
+
function Wt(e, t, n) {
|
|
297
|
+
const r = e.id === t ? n(e) : e;
|
|
298
|
+
return {
|
|
299
|
+
...r,
|
|
300
|
+
cells: r.cells.map((i) => Ut(i, t, n))
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function Ut(e, t, n) {
|
|
304
|
+
const r = e.id === t ? n(e) : e;
|
|
305
|
+
return {
|
|
306
|
+
...r,
|
|
307
|
+
children: r.children.map((i) => We(i, t, n))
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function Kt(e, t, n) {
|
|
311
|
+
const r = e.id === t ? n(e) : e;
|
|
312
|
+
return {
|
|
313
|
+
...r,
|
|
314
|
+
children: r.children.map((i) => We(i, t, n))
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function qt(e, t, n) {
|
|
318
|
+
const r = e.id === t ? n(e) : e;
|
|
319
|
+
return {
|
|
320
|
+
...r,
|
|
321
|
+
children: r.children.map((i) => We(i, t, n))
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function k(e, t, n) {
|
|
325
|
+
return {
|
|
326
|
+
...e,
|
|
327
|
+
pages: e.pages.map((r) => qt(r, t, n))
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function jt(e, t, n, r) {
|
|
331
|
+
return k(e, t, (i) => {
|
|
332
|
+
if (i.type !== "grid") return i;
|
|
333
|
+
const o = Math.max(0, Math.min(r ?? i.rows.length, i.rows.length)), a = [...i.rows];
|
|
334
|
+
return a.splice(o, 0, n), { ...i, rows: a };
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function hn(e, t, n = 1) {
|
|
338
|
+
return k(e, t, (r) => r.type !== "table" ? r : { ...r, minRows: Math.max(0, r.minRows + n) });
|
|
339
|
+
}
|
|
340
|
+
function gn(e, t, n) {
|
|
341
|
+
return k(
|
|
342
|
+
e,
|
|
343
|
+
t,
|
|
344
|
+
(r) => r.type === "grid" ? { ...r, border: n } : r
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
function pn(e, t, n) {
|
|
348
|
+
return k(
|
|
349
|
+
e,
|
|
350
|
+
t,
|
|
351
|
+
(r) => r.type === "table" ? { ...r, border: n } : r
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
function yn(e, t, n) {
|
|
355
|
+
return k(
|
|
356
|
+
e,
|
|
357
|
+
t,
|
|
358
|
+
(r) => r.type === "grid-row" ? { ...r, height: n } : r
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
function wn(e, t, n) {
|
|
362
|
+
return k(
|
|
363
|
+
e,
|
|
364
|
+
t,
|
|
365
|
+
(r) => r.type === "grid-cell" ? { ...r, width: n } : r
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
function bn(e, t, n) {
|
|
369
|
+
const r = Number.isFinite(n) && n > 0 ? n : 0;
|
|
370
|
+
return k(
|
|
371
|
+
e,
|
|
372
|
+
t,
|
|
373
|
+
(i) => i.type === "grid-cell" ? { ...i, padding: r } : i
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
function vn(e, t, n) {
|
|
377
|
+
return k(
|
|
378
|
+
e,
|
|
379
|
+
t,
|
|
380
|
+
(r) => r.type === "grid-cell" ? { ...r, align: n } : r
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
function En(e, t, n) {
|
|
384
|
+
return k(
|
|
385
|
+
e,
|
|
386
|
+
t,
|
|
387
|
+
(r) => r.type === "grid-cell" ? { ...r, verticalAlign: n } : r
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
function Tn(e, t, n) {
|
|
391
|
+
return k(
|
|
392
|
+
e,
|
|
393
|
+
t,
|
|
394
|
+
(r) => r.type === "grid" ? { ...r, ...n } : r
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
function Sn(e, t, n) {
|
|
398
|
+
const r = typeof n == "number" && Number.isFinite(n) && n > 0 ? n : void 0;
|
|
399
|
+
return k(
|
|
400
|
+
e,
|
|
401
|
+
t,
|
|
402
|
+
(i) => i.type === "grid" ? { ...i, gap: r } : i
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
function Re(e) {
|
|
406
|
+
const t = e.gap;
|
|
407
|
+
return typeof t == "number" && Number.isFinite(t) && t > 0 ? t : 0;
|
|
408
|
+
}
|
|
409
|
+
function Mn(e, t, n) {
|
|
410
|
+
return k(
|
|
411
|
+
e,
|
|
412
|
+
t,
|
|
413
|
+
(r) => r.type === "table" ? { ...r, minRows: Math.max(0, Math.floor(n)) } : r
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
function xn(e, t, n) {
|
|
417
|
+
return k(e, t, (r) => {
|
|
418
|
+
if (r.type !== "table") return r;
|
|
419
|
+
const i = new Set(r.columns.map((d) => d.key));
|
|
420
|
+
let o = r.columns.length + 1, a = `col${o}`;
|
|
421
|
+
for (; i.has(a); )
|
|
422
|
+
o += 1, a = `col${o}`;
|
|
423
|
+
const l = {
|
|
424
|
+
key: a,
|
|
425
|
+
title: (n == null ? void 0 : n.title) ?? "新列",
|
|
426
|
+
width: (n == null ? void 0 : n.width) ?? "1fr",
|
|
427
|
+
align: n == null ? void 0 : n.align
|
|
428
|
+
}, c = {
|
|
429
|
+
id: P(`${r.id}-${a}`),
|
|
430
|
+
type: "table-cell-template",
|
|
431
|
+
columnKey: a,
|
|
432
|
+
children: [
|
|
433
|
+
{
|
|
434
|
+
id: P(`${r.id}-${a}-p`),
|
|
435
|
+
type: "p",
|
|
436
|
+
mode: "field",
|
|
437
|
+
// 字段名由渲染期按「列key_行号」自动派生(见 schema-v2-table-rows.ts),
|
|
438
|
+
// 行模板内不手写 field;校验层对表格内字段跳过命名检查。
|
|
439
|
+
field: "",
|
|
440
|
+
underline: !0
|
|
441
|
+
}
|
|
442
|
+
]
|
|
443
|
+
};
|
|
444
|
+
return {
|
|
445
|
+
...r,
|
|
446
|
+
columns: [...r.columns, l],
|
|
447
|
+
rowTemplate: [...r.rowTemplate, c]
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function An(e, t, n) {
|
|
452
|
+
return k(e, t, (r) => r.type !== "table" || r.columns.length <= 1 ? r : {
|
|
453
|
+
...r,
|
|
454
|
+
columns: r.columns.filter((i) => i.key !== n),
|
|
455
|
+
rowTemplate: r.rowTemplate.filter((i) => i.columnKey !== n)
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function Rn(e, t, n, r) {
|
|
459
|
+
const i = r.trim();
|
|
460
|
+
return !i || i === n ? e : k(e, t, (o) => o.type !== "table" || o.columns.some((a) => a.key === i) ? o : {
|
|
461
|
+
...o,
|
|
462
|
+
columns: o.columns.map(
|
|
463
|
+
(a) => a.key === n ? { ...a, key: i } : a
|
|
464
|
+
),
|
|
465
|
+
rowTemplate: o.rowTemplate.map(
|
|
466
|
+
(a) => a.columnKey === n ? { ...a, columnKey: i, id: `${t}-${i}` } : a
|
|
467
|
+
)
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function Nn(e, t, n, r) {
|
|
471
|
+
return k(e, t, (i) => i.type !== "table" ? i : {
|
|
472
|
+
...i,
|
|
473
|
+
columns: i.columns.map(
|
|
474
|
+
(o) => o.key === n ? { ...o, ...r } : o
|
|
475
|
+
)
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
function Fn(e, t) {
|
|
479
|
+
return { ...e, baseRowHeight: Math.max(1, Math.min(99, Math.floor(t))) };
|
|
480
|
+
}
|
|
481
|
+
function kn(e, t) {
|
|
482
|
+
return { ...e, paper: t };
|
|
483
|
+
}
|
|
484
|
+
function In() {
|
|
485
|
+
return {
|
|
486
|
+
version: 2,
|
|
487
|
+
paper: { size: "A4" },
|
|
488
|
+
baseRowHeight: 8,
|
|
489
|
+
pages: [
|
|
490
|
+
{
|
|
491
|
+
id: P("page"),
|
|
492
|
+
type: "page",
|
|
493
|
+
mode: "fixed",
|
|
494
|
+
margin: { top: 12, right: 12, bottom: 12, left: 12 },
|
|
495
|
+
children: []
|
|
496
|
+
}
|
|
497
|
+
]
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function ke(e = 1, t = 1) {
|
|
501
|
+
const n = Math.max(1, Math.floor(e));
|
|
502
|
+
return {
|
|
503
|
+
id: P("row"),
|
|
504
|
+
type: "grid-row",
|
|
505
|
+
height: Math.max(1, Math.floor(t)),
|
|
506
|
+
cells: Array.from({ length: n }, (r, i) => ({
|
|
507
|
+
id: P(`cell-${i + 1}`),
|
|
508
|
+
type: "grid-cell",
|
|
509
|
+
width: "1fr",
|
|
510
|
+
children: []
|
|
511
|
+
}))
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function Jt(e, t, n) {
|
|
515
|
+
return k(
|
|
516
|
+
e,
|
|
517
|
+
t,
|
|
518
|
+
(r) => r.type === "grid-cell" || r.type === "table-cell-template" ? { ...r, children: [...r.children, n] } : r
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
function Ln(e, t, n) {
|
|
522
|
+
var l, c;
|
|
523
|
+
const r = se(e), i = r.get(t), o = r.get(n);
|
|
524
|
+
if ((i == null ? void 0 : i.node.type) !== "grid-cell" || (o == null ? void 0 : o.node.type) !== "grid-cell" || ((l = i.parent) == null ? void 0 : l.type) !== "grid-row" || i.parent.id !== ((c = o.parent) == null ? void 0 : c.id)) return e;
|
|
525
|
+
const a = i.parent.id;
|
|
526
|
+
return k(e, a, (d) => {
|
|
527
|
+
if (d.type !== "grid-row") return d;
|
|
528
|
+
const h = d.cells.findIndex((w) => w.id === t), p = d.cells.findIndex((w) => w.id === n);
|
|
529
|
+
if (h < 0 || p < 0 || h === p) return d;
|
|
530
|
+
const b = d.cells[h], y = d.cells[p], M = {
|
|
531
|
+
...b,
|
|
532
|
+
colspan: (b.colspan ?? 1) + (y.colspan ?? 1),
|
|
533
|
+
children: [...b.children, ...y.children]
|
|
534
|
+
};
|
|
535
|
+
return {
|
|
536
|
+
...d,
|
|
537
|
+
cells: d.cells.filter((w) => w.id !== n).map(
|
|
538
|
+
(w) => w.id === t ? M : w
|
|
539
|
+
)
|
|
540
|
+
};
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function Cn(e, t) {
|
|
544
|
+
const r = se(e).get(t);
|
|
545
|
+
if ((r == null ? void 0 : r.node.type) !== "grid-cell") return e;
|
|
546
|
+
const i = r.node.colspan ?? 1;
|
|
547
|
+
if (i <= 1) return e;
|
|
548
|
+
const o = r.parent;
|
|
549
|
+
return !o || o.type !== "grid-row" ? e : k(e, o.id, (a) => {
|
|
550
|
+
if (a.type !== "grid-row") return a;
|
|
551
|
+
const l = a.cells.findIndex((b) => b.id === t);
|
|
552
|
+
if (l < 0) return a;
|
|
553
|
+
const c = a.cells[l], { colspan: d, ...h } = c, p = Array.from({ length: i - 1 }, () => ({
|
|
554
|
+
id: P("cell"),
|
|
555
|
+
type: "grid-cell",
|
|
556
|
+
children: []
|
|
557
|
+
}));
|
|
558
|
+
return {
|
|
559
|
+
...a,
|
|
560
|
+
cells: [
|
|
561
|
+
...a.cells.slice(0, l),
|
|
562
|
+
h,
|
|
563
|
+
...p,
|
|
564
|
+
...a.cells.slice(l + 1)
|
|
565
|
+
]
|
|
566
|
+
};
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function $n(e, t) {
|
|
570
|
+
return k(e, t, (n) => {
|
|
571
|
+
if (n.type !== "grid-cell" || n.children.length === 0) return n;
|
|
572
|
+
const r = Ue({ rows: 1, columns: 1, border: "none" });
|
|
573
|
+
return r.rows[0].cells[0].children = n.children, { ...n, children: [r] };
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function at(e, t) {
|
|
577
|
+
let n;
|
|
578
|
+
const r = (o) => o.type === "grid" ? {
|
|
579
|
+
...o,
|
|
580
|
+
rows: o.rows.map((a) => ({
|
|
581
|
+
...a,
|
|
582
|
+
cells: a.cells.map((l) => ({
|
|
583
|
+
...l,
|
|
584
|
+
children: l.children.filter((c) => c.id === t ? (n = c, !1) : !0).map(r)
|
|
585
|
+
}))
|
|
586
|
+
}))
|
|
587
|
+
} : o.type === "table" ? {
|
|
588
|
+
...o,
|
|
589
|
+
rowTemplate: o.rowTemplate.map((a) => ({
|
|
590
|
+
...a,
|
|
591
|
+
children: a.children.filter((l) => l.id === t ? (n = l, !1) : !0).map(r)
|
|
592
|
+
}))
|
|
593
|
+
} : o;
|
|
594
|
+
return { schema: {
|
|
595
|
+
...e,
|
|
596
|
+
pages: e.pages.map((o) => ({
|
|
597
|
+
...o,
|
|
598
|
+
children: o.children.filter((a) => a.id === t ? (n = a, !1) : !0).map(r)
|
|
599
|
+
}))
|
|
600
|
+
}, node: n };
|
|
601
|
+
}
|
|
602
|
+
function Dn(e, t, n) {
|
|
603
|
+
var d, h;
|
|
604
|
+
const r = se(e), i = r.get(t), o = r.get(n);
|
|
605
|
+
if (!i || !o || o.node.type !== "grid-cell" && o.node.type !== "table-cell-template" || i.node.type === "page" || i.node.type === "grid-row" || i.node.type === "grid-cell" || i.node.type === "table-cell-template" || ((d = i.parent) == null ? void 0 : d.id) === n) return e;
|
|
606
|
+
let a = o.parent;
|
|
607
|
+
for (; a; ) {
|
|
608
|
+
if (a.id === t) return e;
|
|
609
|
+
a = ((h = r.get(a.id)) == null ? void 0 : h.parent) ?? null;
|
|
610
|
+
}
|
|
611
|
+
const { schema: l, node: c } = at(e, t);
|
|
612
|
+
return c ? Jt(l, n, c) : e;
|
|
613
|
+
}
|
|
614
|
+
const Hn = "application/x-ticket-node-move";
|
|
615
|
+
function Vn(e, t, n, r) {
|
|
616
|
+
var w;
|
|
617
|
+
const i = se(e), o = i.get(t), a = i.get(n);
|
|
618
|
+
if (!o || !a || a.node.type !== "grid-cell" && a.node.type !== "table-cell-template" || o.node.type === "page" || o.node.type === "grid-row" || o.node.type === "grid-cell" || o.node.type === "table-cell-template") return e;
|
|
619
|
+
let l = a.parent;
|
|
620
|
+
for (; l; ) {
|
|
621
|
+
if (l.id === t) return e;
|
|
622
|
+
l = ((w = i.get(l.id)) == null ? void 0 : w.parent) ?? null;
|
|
623
|
+
}
|
|
624
|
+
const c = o.parent, d = c && (c.type === "grid-cell" || c.type === "table-cell-template") ? c.children : null, h = d ? d.findIndex((f) => f.id === t) : -1, p = (c == null ? void 0 : c.id) === n;
|
|
625
|
+
if (p && h >= 0 && r === h) return e;
|
|
626
|
+
const { schema: b, node: y } = at(e, t);
|
|
627
|
+
if (!y) return e;
|
|
628
|
+
let M = Number.isFinite(r) ? Math.trunc(r) : 0;
|
|
629
|
+
return p && h >= 0 && M > h && (M -= 1), k(b, n, (f) => {
|
|
630
|
+
if (f.type !== "grid-cell" && f.type !== "table-cell-template") return f;
|
|
631
|
+
const u = Math.max(0, Math.min(M, f.children.length));
|
|
632
|
+
return { ...f, children: [...f.children.slice(0, u), y, ...f.children.slice(u)] };
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
function Pn(e, t, n) {
|
|
636
|
+
var c;
|
|
637
|
+
const i = (c = se(e).get(t)) == null ? void 0 : c.parent;
|
|
638
|
+
if (!i) return e;
|
|
639
|
+
const o = (d) => {
|
|
640
|
+
const h = d.findIndex((w) => w.id === t);
|
|
641
|
+
if (h < 0) return null;
|
|
642
|
+
const p = n === "up" ? h - 1 : h + 1;
|
|
643
|
+
if (p < 0 || p >= d.length) return null;
|
|
644
|
+
const b = d[h], y = d[p];
|
|
645
|
+
if (!b || !y) return null;
|
|
646
|
+
const M = [...d];
|
|
647
|
+
return M[h] = y, M[p] = b, M;
|
|
648
|
+
};
|
|
649
|
+
let a = null;
|
|
650
|
+
const l = k(e, i.id, (d) => {
|
|
651
|
+
const h = d.type === "grid-cell" || d.type === "table-cell-template" || d.type === "page" ? d.children : null;
|
|
652
|
+
if (!h) return d;
|
|
653
|
+
const p = o(h);
|
|
654
|
+
return p ? (a = p, { ...d, children: p }) : d;
|
|
655
|
+
});
|
|
656
|
+
return a ? l : e;
|
|
657
|
+
}
|
|
658
|
+
function _n(e, t) {
|
|
659
|
+
var c, d;
|
|
660
|
+
const n = se(e), r = t ? (d = (c = n.get(t)) == null ? void 0 : c.parent) == null ? void 0 : d.id : void 0, i = (h) => {
|
|
661
|
+
var b, y;
|
|
662
|
+
let p = h;
|
|
663
|
+
for (; p; ) {
|
|
664
|
+
if (p === t) return !0;
|
|
665
|
+
p = (y = (b = n.get(p)) == null ? void 0 : b.parent) == null ? void 0 : y.id;
|
|
666
|
+
}
|
|
667
|
+
return !1;
|
|
668
|
+
}, o = (h) => h !== r && !(t !== void 0 && i(h)), a = [], l = (h, p) => {
|
|
669
|
+
h.forEach((b) => {
|
|
670
|
+
if (b.type === "grid") {
|
|
671
|
+
const y = `${p}${b.id}`;
|
|
672
|
+
b.rows.forEach((M, w) => {
|
|
673
|
+
M.cells.forEach((f, u) => {
|
|
674
|
+
const m = `${y} · 第${w + 1}行第${u + 1}格`;
|
|
675
|
+
o(f.id) && a.push({ id: f.id, label: m }), l(f.children, `${m} › `);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
} else b.type === "table" && b.rowTemplate.forEach((y) => {
|
|
679
|
+
if (!o(y.id)) return;
|
|
680
|
+
const M = b.columns.find((w) => w.key === y.columnKey);
|
|
681
|
+
a.push({
|
|
682
|
+
id: y.id,
|
|
683
|
+
label: `${p}${b.id} · ${(M == null ? void 0 : M.title) ?? y.columnKey}列`
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
return e.pages.forEach((h) => l(h.children, "")), a;
|
|
689
|
+
}
|
|
690
|
+
function On(e, t) {
|
|
691
|
+
return e.pages[0] ? {
|
|
692
|
+
...e,
|
|
693
|
+
pages: e.pages.map(
|
|
694
|
+
(r, i) => i === 0 ? { ...r, children: [...r.children, t] } : r
|
|
695
|
+
)
|
|
696
|
+
} : e;
|
|
697
|
+
}
|
|
698
|
+
function Bn(e, t, n) {
|
|
699
|
+
return jt(e, t, n);
|
|
700
|
+
}
|
|
701
|
+
function Gn(e, t, n) {
|
|
702
|
+
const r = (i) => {
|
|
703
|
+
if (i.type === "grid") {
|
|
704
|
+
const o = i.rows.findIndex((a) => a.id === t);
|
|
705
|
+
if (o >= 0) {
|
|
706
|
+
const a = [...i.rows], l = zt(i.rows[o]), c = Math.max(0, Math.min(n ?? o + 1, a.length));
|
|
707
|
+
return a.splice(c, 0, l), { ...i, rows: a };
|
|
708
|
+
}
|
|
709
|
+
return {
|
|
710
|
+
...i,
|
|
711
|
+
rows: i.rows.map((a) => ({
|
|
712
|
+
...a,
|
|
713
|
+
cells: a.cells.map((l) => ({ ...l, children: l.children.map(r) }))
|
|
714
|
+
}))
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
return i.type === "table" ? {
|
|
718
|
+
...i,
|
|
719
|
+
rowTemplate: i.rowTemplate.map((o) => ({
|
|
720
|
+
...o,
|
|
721
|
+
children: o.children.map(r)
|
|
722
|
+
}))
|
|
723
|
+
} : i;
|
|
724
|
+
};
|
|
725
|
+
return {
|
|
726
|
+
...e,
|
|
727
|
+
pages: e.pages.map((i) => ({ ...i, children: i.children.map(r) }))
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
function zn(e, t) {
|
|
731
|
+
const n = (r) => r.type === "grid" ? {
|
|
732
|
+
...r,
|
|
733
|
+
rows: r.rows.filter((i) => i.id !== t).map((i) => ({
|
|
734
|
+
...i,
|
|
735
|
+
cells: i.cells.map((o) => ({
|
|
736
|
+
...o,
|
|
737
|
+
children: o.children.map(n)
|
|
738
|
+
}))
|
|
739
|
+
}))
|
|
740
|
+
} : r.type === "table" ? {
|
|
741
|
+
...r,
|
|
742
|
+
rowTemplate: r.rowTemplate.map((i) => ({
|
|
743
|
+
...i,
|
|
744
|
+
children: i.children.map(n)
|
|
745
|
+
}))
|
|
746
|
+
} : r;
|
|
747
|
+
return {
|
|
748
|
+
...e,
|
|
749
|
+
pages: e.pages.map((r) => ({ ...r, children: r.children.map(n) }))
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
function Ve(e, t) {
|
|
753
|
+
if (e.id === t) return null;
|
|
754
|
+
if (e.type === "grid") {
|
|
755
|
+
const n = e.rows.filter((r) => r.id !== t).map((r) => ({
|
|
756
|
+
...r,
|
|
757
|
+
cells: r.cells.filter((i) => i.id !== t).map((i) => ({
|
|
758
|
+
...i,
|
|
759
|
+
children: i.children.map((o) => Ve(o, t)).filter((o) => o !== null)
|
|
760
|
+
}))
|
|
761
|
+
})).filter((r) => r.cells.length > 0);
|
|
762
|
+
return n.length > 0 ? {
|
|
763
|
+
...e,
|
|
764
|
+
rows: n
|
|
765
|
+
} : null;
|
|
766
|
+
}
|
|
767
|
+
return e.type === "table" ? {
|
|
768
|
+
...e,
|
|
769
|
+
rowTemplate: e.rowTemplate.filter((n) => n.id !== t).map((n) => ({
|
|
770
|
+
...n,
|
|
771
|
+
children: n.children.map((r) => Ve(r, t)).filter((r) => r !== null)
|
|
772
|
+
}))
|
|
773
|
+
} : e;
|
|
774
|
+
}
|
|
775
|
+
function Wn(e, t) {
|
|
776
|
+
return {
|
|
777
|
+
...e,
|
|
778
|
+
pages: e.pages.filter((n) => n.id !== t).map((n) => ({
|
|
779
|
+
...n,
|
|
780
|
+
children: n.children.map((r) => Ve(r, t)).filter((r) => r !== null)
|
|
781
|
+
}))
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
function Un(e, t, n) {
|
|
785
|
+
return {
|
|
786
|
+
...e,
|
|
787
|
+
pages: e.pages.map((r) => ({
|
|
788
|
+
...r,
|
|
789
|
+
children: r.children.map((i) => {
|
|
790
|
+
if (i.type !== "grid") return i;
|
|
791
|
+
const o = i.rows.findIndex((c) => c.id === t);
|
|
792
|
+
if (o < 0) return i;
|
|
793
|
+
const a = n === "up" ? o - 1 : o + 1;
|
|
794
|
+
if (a < 0 || a >= i.rows.length) return i;
|
|
795
|
+
const l = [...i.rows];
|
|
796
|
+
return [l[o], l[a]] = [l[a], l[o]], { ...i, rows: l };
|
|
797
|
+
})
|
|
798
|
+
}))
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function Kn(e, t, n) {
|
|
802
|
+
const r = Math.max(1, Math.floor(n));
|
|
803
|
+
return k(e, t, (i) => {
|
|
804
|
+
if (i.type !== "grid-row") return i;
|
|
805
|
+
const o = i.cells, a = Array.from({ length: r }, (l, c) => o[c] ?? {
|
|
806
|
+
id: P(`cell-${c + 1}`),
|
|
807
|
+
type: "grid-cell",
|
|
808
|
+
width: "1fr",
|
|
809
|
+
children: []
|
|
810
|
+
});
|
|
811
|
+
return { ...i, cells: a };
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
function Yt(e = "1fr") {
|
|
815
|
+
return {
|
|
816
|
+
id: P("cell"),
|
|
817
|
+
type: "grid-cell",
|
|
818
|
+
width: e,
|
|
819
|
+
children: []
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
function lt(e, t) {
|
|
823
|
+
const n = e.cells.slice(0, t);
|
|
824
|
+
for (; n.length < t; ) n.push(Yt());
|
|
825
|
+
if (e.cells.length > t && n.length > 0) {
|
|
826
|
+
const r = e.cells.slice(t).flatMap((i) => i.children);
|
|
827
|
+
n[n.length - 1] = {
|
|
828
|
+
...n[n.length - 1],
|
|
829
|
+
children: [...n[n.length - 1].children, ...r]
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
return { ...e, cells: n };
|
|
833
|
+
}
|
|
834
|
+
function qn(e, t, n, r) {
|
|
835
|
+
const i = Math.max(1, Math.floor(n)), o = Math.max(1, Math.floor(r));
|
|
836
|
+
return k(e, t, (a) => {
|
|
837
|
+
var h, p;
|
|
838
|
+
if (a.type !== "grid") return a;
|
|
839
|
+
const l = a.rows.slice(0, i).map((b) => lt(b, o)), c = ((h = a.rows[0]) == null ? void 0 : h.height) ?? 1;
|
|
840
|
+
for (; l.length < i; )
|
|
841
|
+
l.push(ke(o, c));
|
|
842
|
+
if (a.rows.length > i && l.length > 0) {
|
|
843
|
+
const b = a.rows.slice(i).flatMap((w) => w.cells.flatMap((f) => f.children)), y = l[l.length - 1], M = y.cells[y.cells.length - 1];
|
|
844
|
+
y.cells[y.cells.length - 1] = {
|
|
845
|
+
...M,
|
|
846
|
+
children: [...M.children, ...b]
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
const d = (((p = l[0]) == null ? void 0 : p.cells) ?? []).map((b) => b.width ?? "1fr");
|
|
850
|
+
return { ...a, rows: l, columns: d };
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
function Xt(e) {
|
|
854
|
+
const t = e.rows.find((r) => r.cells.length > 0) ?? e.rows[0], n = [];
|
|
855
|
+
if (!t) return n;
|
|
856
|
+
for (const r of t.cells) {
|
|
857
|
+
const i = r.colspan ?? 1;
|
|
858
|
+
for (let o = 0; o < i; o += 1) n.push(r.width ?? "1fr");
|
|
859
|
+
}
|
|
860
|
+
return n;
|
|
861
|
+
}
|
|
862
|
+
function jn(e, t, n, r) {
|
|
863
|
+
return k(e, t, (i) => {
|
|
864
|
+
if (i.type !== "grid") return i;
|
|
865
|
+
const a = (i.columns ?? Xt(i)).slice();
|
|
866
|
+
return n >= 0 && n < a.length && (a[n] = r), {
|
|
867
|
+
...i,
|
|
868
|
+
columns: a,
|
|
869
|
+
rows: i.rows.map((l) => ({
|
|
870
|
+
...l,
|
|
871
|
+
cells: l.cells.map(
|
|
872
|
+
(c, d) => d === n ? { ...c, width: r } : c
|
|
873
|
+
)
|
|
874
|
+
}))
|
|
875
|
+
};
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
function Zt(e, t, n, r) {
|
|
879
|
+
const i = Math.max(1, Math.floor(n)), o = Math.max(1, Math.floor(r));
|
|
880
|
+
return k(e, t, (a) => {
|
|
881
|
+
var d, h;
|
|
882
|
+
if (a.type !== "grid-cell") return a;
|
|
883
|
+
const l = a.children.length === 1 && ((d = a.children[0]) == null ? void 0 : d.type) === "grid" ? a.children[0] : void 0;
|
|
884
|
+
if (l) {
|
|
885
|
+
const p = l.rows.slice(0, i).map((y) => lt(y, o)), b = ((h = l.rows[0]) == null ? void 0 : h.height) ?? 1;
|
|
886
|
+
for (; p.length < i; ) p.push(ke(o, b));
|
|
887
|
+
if (l.rows.length > i) {
|
|
888
|
+
const y = l.rows.slice(i).flatMap((f) => f.cells.flatMap((u) => u.children)), M = p[p.length - 1], w = M.cells[M.cells.length - 1];
|
|
889
|
+
M.cells[M.cells.length - 1] = { ...w, children: [...w.children, ...y] };
|
|
890
|
+
}
|
|
891
|
+
return {
|
|
892
|
+
...a,
|
|
893
|
+
children: [{ ...l, rows: p }]
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
const c = Ue({ rows: i, columns: o, border: "none" });
|
|
897
|
+
return c.rows[0].cells[0].children = a.children, { ...a, children: [c] };
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
function Jn(e, t, n) {
|
|
901
|
+
return Zt(e, t, n, 1);
|
|
902
|
+
}
|
|
903
|
+
function Yn(e = ke(), t = "all") {
|
|
904
|
+
return "type" in e ? {
|
|
905
|
+
id: P("grid"),
|
|
906
|
+
type: "grid",
|
|
907
|
+
border: t,
|
|
908
|
+
rows: [e]
|
|
909
|
+
} : Ue(e);
|
|
910
|
+
}
|
|
911
|
+
function Ue(e = {}) {
|
|
912
|
+
const t = Math.max(1, Math.floor(e.rows ?? 1)), n = Math.max(1, Math.floor(e.columns ?? 1)), r = Math.max(1, Math.floor(e.rowHeight ?? 1)), i = e.cellWidth ?? "1fr";
|
|
913
|
+
return {
|
|
914
|
+
id: P("grid"),
|
|
915
|
+
type: "grid",
|
|
916
|
+
border: e.border ?? "all",
|
|
917
|
+
columns: Array.from({ length: n }, () => i),
|
|
918
|
+
rows: Array.from({ length: t }, () => {
|
|
919
|
+
const o = ke(n, r);
|
|
920
|
+
return {
|
|
921
|
+
...o,
|
|
922
|
+
cells: o.cells.map((a) => ({ ...a, width: i }))
|
|
923
|
+
};
|
|
924
|
+
})
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
function Xn(e = "固定文本") {
|
|
928
|
+
return { id: P("text"), type: "text", text: e };
|
|
929
|
+
}
|
|
930
|
+
function Zn(e = "字段") {
|
|
931
|
+
return { id: P("p-field"), type: "p", mode: "field", field: e, underline: !0 };
|
|
932
|
+
}
|
|
933
|
+
function Qn() {
|
|
934
|
+
const e = P("table"), t = [
|
|
935
|
+
{ key: "col1", title: "列 1", width: "1fr" },
|
|
936
|
+
{ key: "col2", title: "列 2", width: "1fr" }
|
|
937
|
+
];
|
|
938
|
+
return {
|
|
939
|
+
id: e,
|
|
940
|
+
type: "table",
|
|
941
|
+
columns: t,
|
|
942
|
+
minRows: 4,
|
|
943
|
+
rowTemplate: t.map((n) => ({
|
|
944
|
+
id: P(`${e}-${n.key}`),
|
|
945
|
+
type: "table-cell-template",
|
|
946
|
+
columnKey: n.key,
|
|
947
|
+
children: [{
|
|
948
|
+
id: P(`${e}-${n.key}-p`),
|
|
949
|
+
type: "p",
|
|
950
|
+
mode: "field",
|
|
951
|
+
// 字段名由渲染期按「列key_行号」自动派生(见 schema-v2-table-rows.ts),
|
|
952
|
+
// 行模板内不手写 field;校验层对表格内字段跳过命名检查。
|
|
953
|
+
field: "",
|
|
954
|
+
underline: !0
|
|
955
|
+
}]
|
|
956
|
+
})),
|
|
957
|
+
border: "all"
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function ei(e = "") {
|
|
961
|
+
return {
|
|
962
|
+
id: P("html"),
|
|
963
|
+
type: "html",
|
|
964
|
+
html: e
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
function ti() {
|
|
968
|
+
return {
|
|
969
|
+
id: P("image"),
|
|
970
|
+
type: "image",
|
|
971
|
+
objectFit: "contain"
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
class ee extends Error {
|
|
975
|
+
constructor(n, r = []) {
|
|
976
|
+
super(n);
|
|
977
|
+
je(this, "issues");
|
|
978
|
+
this.name = "SchemaV2SerializationError", this.issues = r;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
function ue(e, t) {
|
|
982
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
983
|
+
throw new ee(`${t} must be an object`);
|
|
984
|
+
return e;
|
|
985
|
+
}
|
|
986
|
+
function Se(e, t) {
|
|
987
|
+
if (typeof e != "string" || !e)
|
|
988
|
+
throw new ee(`${t} must be a non-empty string`);
|
|
989
|
+
return e;
|
|
990
|
+
}
|
|
991
|
+
function Ke(e) {
|
|
992
|
+
const t = ue(e, "Schema node");
|
|
993
|
+
if (Se(t.id, "Schema node id"), typeof t.type != "string")
|
|
994
|
+
throw new ee(`Schema node ${t.id} is missing type`);
|
|
995
|
+
if (t.type === "grid") {
|
|
996
|
+
const n = t.gap, r = typeof n == "number" && Number.isFinite(n) && n > 0 ? n : void 0;
|
|
997
|
+
return {
|
|
998
|
+
...t,
|
|
999
|
+
border: t.border ?? "none",
|
|
1000
|
+
gap: r,
|
|
1001
|
+
rows: Array.isArray(t.rows) ? t.rows.map((i) => Qt(i)) : []
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
if (t.type === "table") {
|
|
1005
|
+
const n = Array.isArray(t.columns) ? t.columns : [];
|
|
1006
|
+
return {
|
|
1007
|
+
...t,
|
|
1008
|
+
columns: n,
|
|
1009
|
+
minRows: t.minRows ?? 0,
|
|
1010
|
+
rowTemplate: Array.isArray(t.rowTemplate) ? t.rowTemplate.map((r) => tr(r)) : []
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
return t.type === "text" ? { ...t, text: t.text ?? "" } : t.type === "p" ? t.mode === "field" ? { ...t, field: t.field ?? "" } : { ...t, type: "text", text: t.text ?? "" } : t.type === "html" ? { ...t, html: t.html ?? "" } : t.type === "image" ? { ...t, objectFit: t.objectFit ?? "contain" } : { ...t };
|
|
1014
|
+
}
|
|
1015
|
+
function Qt(e) {
|
|
1016
|
+
const t = ue(e, "Grid row");
|
|
1017
|
+
return Se(t.id, "Grid row id"), {
|
|
1018
|
+
...t,
|
|
1019
|
+
height: t.height ?? 1,
|
|
1020
|
+
cells: Array.isArray(t.cells) ? t.cells.map((n) => er(n)) : []
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
function er(e) {
|
|
1024
|
+
const t = ue(e, "Grid cell");
|
|
1025
|
+
return Se(t.id, "Grid cell id"), {
|
|
1026
|
+
...t,
|
|
1027
|
+
children: Array.isArray(t.children) ? t.children.map(Ke) : []
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
function tr(e) {
|
|
1031
|
+
const t = ue(e, "Table cell template");
|
|
1032
|
+
return Se(t.id, "Table cell template id"), {
|
|
1033
|
+
...t,
|
|
1034
|
+
children: Array.isArray(t.children) ? t.children.map(Ke) : []
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
function st(e) {
|
|
1038
|
+
const t = ue(e, "Schema");
|
|
1039
|
+
if (t.version !== 2)
|
|
1040
|
+
throw new ee("Expected Schema V2");
|
|
1041
|
+
if (!Array.isArray(t.pages))
|
|
1042
|
+
throw new ee("Schema pages must be an array");
|
|
1043
|
+
const n = ue(t.paper ?? {}, "Schema paper"), r = n.header, i = n.footer;
|
|
1044
|
+
return {
|
|
1045
|
+
version: 2,
|
|
1046
|
+
paper: {
|
|
1047
|
+
size: n.size ?? "A4",
|
|
1048
|
+
// `orientation` 为废弃键(方向自 P11-3 起由纸张尺寸派生,渲染/打印均忽略):
|
|
1049
|
+
// 归一化时直接丢弃,不向前携带;旧模板中残留的 orientation 仅在解析时被忽略,不会回写导出。
|
|
1050
|
+
// header / footer 为可选配置:存在则原样保留(此前 paper 只落 size,会导致导出丢失)。
|
|
1051
|
+
...r ? { header: r } : {},
|
|
1052
|
+
...i ? { footer: i } : {}
|
|
1053
|
+
},
|
|
1054
|
+
baseRowHeight: t.baseRowHeight ?? 8,
|
|
1055
|
+
pages: t.pages.map((o) => {
|
|
1056
|
+
const a = ue(o, "Page");
|
|
1057
|
+
if (Se(a.id, "Page id"), a.type !== void 0 && a.type !== "page")
|
|
1058
|
+
throw new ee(`Invalid page type: ${String(a.type)}`);
|
|
1059
|
+
const l = ue(a.margin ?? {}, "Page margin");
|
|
1060
|
+
return {
|
|
1061
|
+
...a,
|
|
1062
|
+
id: a.id,
|
|
1063
|
+
type: "page",
|
|
1064
|
+
mode: "fixed",
|
|
1065
|
+
margin: {
|
|
1066
|
+
top: l.top ?? 10,
|
|
1067
|
+
right: l.right ?? 10,
|
|
1068
|
+
bottom: l.bottom ?? 10,
|
|
1069
|
+
left: l.left ?? 10
|
|
1070
|
+
},
|
|
1071
|
+
children: Array.isArray(a.children) ? a.children.map(Ke) : []
|
|
1072
|
+
};
|
|
1073
|
+
})
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
function ri(e, t = !1) {
|
|
1077
|
+
const r = ze(e).filter((i) => i.level === "error");
|
|
1078
|
+
if (r.length) throw new ee("Cannot serialize invalid Schema V2", r);
|
|
1079
|
+
return JSON.stringify(e, null, t ? 2 : 0);
|
|
1080
|
+
}
|
|
1081
|
+
function ni(e) {
|
|
1082
|
+
let t = e;
|
|
1083
|
+
if (typeof e == "string")
|
|
1084
|
+
try {
|
|
1085
|
+
t = JSON.parse(e);
|
|
1086
|
+
} catch (o) {
|
|
1087
|
+
throw new ee(`Invalid Schema JSON: ${o instanceof Error ? o.message : String(o)}`);
|
|
1088
|
+
}
|
|
1089
|
+
const n = st(t), i = ze(n).filter((o) => o.level === "error");
|
|
1090
|
+
if (i.length) throw new ee("Schema V2 validation failed", i);
|
|
1091
|
+
return n;
|
|
1092
|
+
}
|
|
1093
|
+
function ii(e) {
|
|
1094
|
+
let t = e;
|
|
1095
|
+
if (typeof e == "string")
|
|
1096
|
+
try {
|
|
1097
|
+
t = JSON.parse(e);
|
|
1098
|
+
} catch (i) {
|
|
1099
|
+
return {
|
|
1100
|
+
schema: null,
|
|
1101
|
+
issues: [
|
|
1102
|
+
{
|
|
1103
|
+
level: "error",
|
|
1104
|
+
code: "INVALID_JSON",
|
|
1105
|
+
message: `Invalid Schema JSON: ${i instanceof Error ? i.message : String(i)}`
|
|
1106
|
+
}
|
|
1107
|
+
],
|
|
1108
|
+
ok: !1
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
let n;
|
|
1112
|
+
try {
|
|
1113
|
+
n = st(t);
|
|
1114
|
+
} catch (i) {
|
|
1115
|
+
return i instanceof ee ? { schema: null, issues: i.issues, ok: !1 } : {
|
|
1116
|
+
schema: null,
|
|
1117
|
+
issues: [
|
|
1118
|
+
{
|
|
1119
|
+
level: "error",
|
|
1120
|
+
code: "NORMALIZE_FAILED",
|
|
1121
|
+
message: i instanceof Error ? i.message : String(i)
|
|
1122
|
+
}
|
|
1123
|
+
],
|
|
1124
|
+
ok: !1
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
const r = ze(n);
|
|
1128
|
+
return { schema: n, issues: r, ok: !0 };
|
|
1129
|
+
}
|
|
1130
|
+
function Ye(e, t = []) {
|
|
1131
|
+
if ("field" in e && typeof e.field == "string" && e.field.length > 0 && t.push(e.field), e.type === "grid")
|
|
1132
|
+
for (const n of e.rows)
|
|
1133
|
+
for (const r of n.cells)
|
|
1134
|
+
for (const i of r.children)
|
|
1135
|
+
Ye(i, t);
|
|
1136
|
+
else if (e.type === "table")
|
|
1137
|
+
for (const n of e.rowTemplate)
|
|
1138
|
+
for (const r of n.children)
|
|
1139
|
+
Ye(r, t);
|
|
1140
|
+
return t;
|
|
1141
|
+
}
|
|
1142
|
+
const rr = ["data-node-id"], nr = /* @__PURE__ */ Te({
|
|
1143
|
+
__name: "HtmlBlock",
|
|
1144
|
+
props: {
|
|
1145
|
+
node: {},
|
|
1146
|
+
data: {},
|
|
1147
|
+
readonly: { type: Boolean },
|
|
1148
|
+
fieldPermissions: {}
|
|
1149
|
+
},
|
|
1150
|
+
emits: ["field-change"],
|
|
1151
|
+
setup(e, { emit: t }) {
|
|
1152
|
+
const n = e, r = t, i = () => n.data != null && !n.readonly;
|
|
1153
|
+
function o(w) {
|
|
1154
|
+
var f;
|
|
1155
|
+
return ((f = n.fieldPermissions) == null ? void 0 : f[w]) ?? "EDIT";
|
|
1156
|
+
}
|
|
1157
|
+
const a = X(null);
|
|
1158
|
+
function l(w) {
|
|
1159
|
+
return w ? w.replace(/@import[^;]+;?/gi, "").replace(/<\/style>/gi, "") : "";
|
|
1160
|
+
}
|
|
1161
|
+
function c(w) {
|
|
1162
|
+
return w.replace(
|
|
1163
|
+
/\{\{\s*([\p{L}\p{N}_.$-]+)\s*\}\}/gu,
|
|
1164
|
+
(f, u) => {
|
|
1165
|
+
const m = o(u);
|
|
1166
|
+
return m === "HIDDEN" ? `<span data-bind="${u}" data-masked>***</span>` : i() ? `<input data-bind="${u}"${m === "READ" ? " readonly" : ""} />` : `<span data-bind="${u}"></span>`;
|
|
1167
|
+
}
|
|
1168
|
+
);
|
|
1169
|
+
}
|
|
1170
|
+
function d() {
|
|
1171
|
+
const w = xt.sanitize(c(n.node.html ?? ""), {
|
|
1172
|
+
USE_PROFILES: { html: !0 },
|
|
1173
|
+
ADD_TAGS: ["input"],
|
|
1174
|
+
ADD_ATTR: ["target", "data-bind", "readonly", "contenteditable"],
|
|
1175
|
+
FORBID_TAGS: ["style", "script"]
|
|
1176
|
+
});
|
|
1177
|
+
return `<style>${l(n.node.css)}</style>${w}`;
|
|
1178
|
+
}
|
|
1179
|
+
function h(w) {
|
|
1180
|
+
w.querySelectorAll("[data-field]").forEach((f) => {
|
|
1181
|
+
const u = f.getAttribute("data-field");
|
|
1182
|
+
if (!u) return;
|
|
1183
|
+
const m = o(u), g = i() && m === "EDIT";
|
|
1184
|
+
if (m === "HIDDEN") {
|
|
1185
|
+
f.textContent = "***", f.setAttribute("data-masked", ""), f.setAttribute("contenteditable", "false");
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (i() && n.data) {
|
|
1189
|
+
const S = n.data[u], E = S == null ? "" : String(S);
|
|
1190
|
+
f.textContent !== E && (f.textContent = E);
|
|
1191
|
+
}
|
|
1192
|
+
f.setAttribute("contenteditable", g ? "true" : "false");
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
function p() {
|
|
1196
|
+
var f;
|
|
1197
|
+
y();
|
|
1198
|
+
const w = (f = a.value) == null ? void 0 : f.shadowRoot;
|
|
1199
|
+
w && h(w);
|
|
1200
|
+
}
|
|
1201
|
+
function b() {
|
|
1202
|
+
const w = a.value;
|
|
1203
|
+
w && (w.shadowRoot || w.attachShadow({ mode: "open" }), w.shadowRoot.innerHTML = d(), p(), M());
|
|
1204
|
+
}
|
|
1205
|
+
function y() {
|
|
1206
|
+
var f;
|
|
1207
|
+
const w = (f = a.value) == null ? void 0 : f.shadowRoot;
|
|
1208
|
+
!w || !n.data || w.querySelectorAll("[data-bind]").forEach((u) => {
|
|
1209
|
+
var E;
|
|
1210
|
+
const m = u.dataset.bind;
|
|
1211
|
+
if (!m) return;
|
|
1212
|
+
const g = (E = n.data) == null ? void 0 : E[m], S = g == null ? "" : String(g);
|
|
1213
|
+
u instanceof HTMLInputElement ? u.value !== S && (u.value = S) : u.hasAttribute("data-masked") || u.textContent !== S && (u.textContent = S);
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
function M() {
|
|
1217
|
+
var f;
|
|
1218
|
+
const w = (f = a.value) == null ? void 0 : f.shadowRoot;
|
|
1219
|
+
w && (w.querySelectorAll("input[data-bind]:not([readonly])").forEach((u) => {
|
|
1220
|
+
u.addEventListener("input", () => {
|
|
1221
|
+
const m = u.dataset.bind;
|
|
1222
|
+
m && r("field-change", m, u.value);
|
|
1223
|
+
});
|
|
1224
|
+
}), w.querySelectorAll("[data-field][contenteditable='true']").forEach((u) => {
|
|
1225
|
+
u.addEventListener("input", () => {
|
|
1226
|
+
const m = u.getAttribute("data-field");
|
|
1227
|
+
m && r("field-change", m, u.textContent ?? "");
|
|
1228
|
+
});
|
|
1229
|
+
}));
|
|
1230
|
+
}
|
|
1231
|
+
return Fe(b), ge(() => [n.node.html, n.node.css, n.fieldPermissions], b), ge(() => n.data, p, { deep: !0 }), (w, f) => (A(), R("div", {
|
|
1232
|
+
ref_key: "host",
|
|
1233
|
+
ref: a,
|
|
1234
|
+
class: "layout-html",
|
|
1235
|
+
"data-node-id": e.node.id
|
|
1236
|
+
}, null, 8, rr));
|
|
1237
|
+
}
|
|
1238
|
+
}), Ie = (e, t) => {
|
|
1239
|
+
const n = e.__vccOpts || e;
|
|
1240
|
+
for (const [r, i] of t)
|
|
1241
|
+
n[r] = i;
|
|
1242
|
+
return n;
|
|
1243
|
+
}, ir = /* @__PURE__ */ Ie(nr, [["__scopeId", "data-v-2c9190b4"]]);
|
|
1244
|
+
function ct(e, t = {}) {
|
|
1245
|
+
var n;
|
|
1246
|
+
if (!t.isDesign && e.field) {
|
|
1247
|
+
const r = (n = t.data) == null ? void 0 : n[e.field];
|
|
1248
|
+
if (r != null) return String(r);
|
|
1249
|
+
}
|
|
1250
|
+
return e.src && e.src !== "" ? e.src : null;
|
|
1251
|
+
}
|
|
1252
|
+
const or = 0, ar = "center", lr = "middle";
|
|
1253
|
+
function sr(e, t) {
|
|
1254
|
+
return {
|
|
1255
|
+
padding: e.padding ?? t.cellPadding ?? or,
|
|
1256
|
+
align: e.align ?? t.cellAlign ?? ar,
|
|
1257
|
+
verticalAlign: e.verticalAlign ?? t.cellVerticalAlign ?? lr
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
function ut(e, t) {
|
|
1261
|
+
return `${e}_${t}`;
|
|
1262
|
+
}
|
|
1263
|
+
function dt(e, t, n) {
|
|
1264
|
+
const r = ut(t, n), i = e.type === "p" && e.mode === "field" ? { ...e, field: r } : e;
|
|
1265
|
+
return i.type === "grid" ? {
|
|
1266
|
+
...i,
|
|
1267
|
+
rows: i.rows.map((o) => ({
|
|
1268
|
+
...o,
|
|
1269
|
+
cells: o.cells.map((a) => ({
|
|
1270
|
+
...a,
|
|
1271
|
+
children: a.children.map((l) => dt(l, t, n))
|
|
1272
|
+
}))
|
|
1273
|
+
}))
|
|
1274
|
+
} : i;
|
|
1275
|
+
}
|
|
1276
|
+
function cr(e, t) {
|
|
1277
|
+
const n = `${t}_`;
|
|
1278
|
+
if (!e.startsWith(n)) return null;
|
|
1279
|
+
const r = e.slice(n.length);
|
|
1280
|
+
if (!/^\d+$/.test(r)) return null;
|
|
1281
|
+
const i = Number(r);
|
|
1282
|
+
return Number.isFinite(i) ? i : null;
|
|
1283
|
+
}
|
|
1284
|
+
function we(e, t) {
|
|
1285
|
+
const n = Number.isFinite(e.minRows) ? Math.max(0, Math.floor(e.minRows)) : 0;
|
|
1286
|
+
if (!t) return n;
|
|
1287
|
+
let r = 0;
|
|
1288
|
+
for (const i of e.columns)
|
|
1289
|
+
for (const o of Object.keys(t)) {
|
|
1290
|
+
const a = cr(o, i.key);
|
|
1291
|
+
a != null && a > r && (r = a);
|
|
1292
|
+
}
|
|
1293
|
+
return Math.max(n, r);
|
|
1294
|
+
}
|
|
1295
|
+
function oi(e, t) {
|
|
1296
|
+
const n = [], r = (i, o) => {
|
|
1297
|
+
if (i.type === "p" && i.mode === "field") {
|
|
1298
|
+
o ? n.push({
|
|
1299
|
+
key: ut(o.columnKey, o.rowIndex),
|
|
1300
|
+
kind: "table-field",
|
|
1301
|
+
tableField: o.columnKey,
|
|
1302
|
+
row: o.rowIndex
|
|
1303
|
+
}) : i.field && n.push({ key: i.field, kind: "field" });
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
if (i.type === "table") {
|
|
1307
|
+
const a = we(i, t ?? null);
|
|
1308
|
+
for (const l of i.columns) {
|
|
1309
|
+
const c = i.rowTemplate.find((d) => d.columnKey === l.key);
|
|
1310
|
+
if (c)
|
|
1311
|
+
for (let d = 1; d <= a; d += 1)
|
|
1312
|
+
for (const h of c.children)
|
|
1313
|
+
r(h, { columnKey: l.key, rowIndex: d });
|
|
1314
|
+
}
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
if (i.type === "grid")
|
|
1318
|
+
for (const a of i.rows)
|
|
1319
|
+
for (const l of a.cells)
|
|
1320
|
+
for (const c of l.children)
|
|
1321
|
+
r(c, o);
|
|
1322
|
+
};
|
|
1323
|
+
for (const i of e.pages)
|
|
1324
|
+
for (const o of i.children)
|
|
1325
|
+
r(o);
|
|
1326
|
+
return n;
|
|
1327
|
+
}
|
|
1328
|
+
function ur(e, t) {
|
|
1329
|
+
if (!e) return [];
|
|
1330
|
+
const n = (r) => typeof r != "string" || r.trim() === "";
|
|
1331
|
+
return Object.entries(e).filter(([, r]) => (r == null ? void 0 : r.required) === !0).map(([r]) => r).filter((r) => n(t == null ? void 0 : t[r]));
|
|
1332
|
+
}
|
|
1333
|
+
const dr = ["data-node-id"], fr = ["data-layout-id"], mr = ["data-layout-id", "data-node-id"], hr = ["data-node-id"], gr = ["contenteditable", "data-field", "data-node-id", "onClick", "onBlur"], pr = {
|
|
1334
|
+
key: 0,
|
|
1335
|
+
class: "layout-p__label"
|
|
1336
|
+
}, yr = ["contenteditable", "data-field"], wr = {
|
|
1337
|
+
key: 3,
|
|
1338
|
+
class: "layout-p__value"
|
|
1339
|
+
}, br = {
|
|
1340
|
+
key: 4,
|
|
1341
|
+
class: "layout-p__label"
|
|
1342
|
+
}, vr = ["data-node-id"], Er = ["data-layout-id"], Tr = ["data-node-id", "data-field", "src", "alt"], Xe = "***", Ze = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='60'%3E%3Crect width='100%25' height='100%25' fill='%23f1f5f9' stroke='%23cbd5e1'/%3E%3Ctext x='50%25' y='50%25' font-size='10' fill='%2394a3b8' text-anchor='middle' dominant-baseline='middle'%3E图片%3C/text%3E%3C/svg%3E", Sr = /* @__PURE__ */ Te({
|
|
1343
|
+
name: "GridSchemaNodeV2",
|
|
1344
|
+
__name: "GridSchemaNode",
|
|
1345
|
+
props: {
|
|
1346
|
+
node: {},
|
|
1347
|
+
baseRowHeight: {},
|
|
1348
|
+
mode: {},
|
|
1349
|
+
data: {},
|
|
1350
|
+
readonly: { type: Boolean },
|
|
1351
|
+
suppressBorders: {},
|
|
1352
|
+
fieldPermissions: {}
|
|
1353
|
+
},
|
|
1354
|
+
emits: ["field-change", "action-trigger"],
|
|
1355
|
+
setup(e, { emit: t }) {
|
|
1356
|
+
const n = t, r = e;
|
|
1357
|
+
function i(s) {
|
|
1358
|
+
return s.type === "grid" && (s.border === "all" || s.border === "outer");
|
|
1359
|
+
}
|
|
1360
|
+
function o(s, T) {
|
|
1361
|
+
const N = s[T];
|
|
1362
|
+
if (!i(N)) return;
|
|
1363
|
+
const B = s[T - 1];
|
|
1364
|
+
return { left: !!B && i(B) };
|
|
1365
|
+
}
|
|
1366
|
+
const a = K(() => r.mode ? r.mode : r.data != null ? "preview" : "design"), l = K(() => a.value === "design"), c = K(
|
|
1367
|
+
() => a.value !== "design" && !r.readonly
|
|
1368
|
+
), d = (s) => s === void 0 || s === "auto" ? "auto" : typeof s == "number" ? `${s}mm` : s;
|
|
1369
|
+
function h(s) {
|
|
1370
|
+
const T = Re(s);
|
|
1371
|
+
return T > 0 ? { rowGap: `${T}mm` } : {};
|
|
1372
|
+
}
|
|
1373
|
+
function p(s, T) {
|
|
1374
|
+
const N = s.rows[T], B = s.columns && s.columns.length > 0 ? s.columns : N.cells.map((oe) => oe.width), ce = Re(s);
|
|
1375
|
+
return {
|
|
1376
|
+
gridTemplateColumns: B.map(d).join(" "),
|
|
1377
|
+
minHeight: `${N.height * r.baseRowHeight}mm`,
|
|
1378
|
+
// 列间距:gap 同时作用于行列。
|
|
1379
|
+
columnGap: ce > 0 ? `${ce}mm` : void 0
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
function b(s, T) {
|
|
1383
|
+
const N = sr(s, T), B = N.verticalAlign === "top" ? "flex-start" : N.verticalAlign === "bottom" ? "flex-end" : "center", ce = N.align === "center" ? "center" : N.align === "right" ? "flex-end" : "flex-start", oe = {
|
|
1384
|
+
gridColumn: s.colspan ? `span ${s.colspan}` : void 0,
|
|
1385
|
+
// 单元格行高倍数:设置时覆盖所在 Grid 行高(行容器按最高单元格撑开)。
|
|
1386
|
+
minHeight: s.rowHeight ? `${s.rowHeight * r.baseRowHeight}mm` : void 0,
|
|
1387
|
+
padding: `${N.padding}mm`,
|
|
1388
|
+
alignItems: B,
|
|
1389
|
+
justifyContent: ce
|
|
1390
|
+
};
|
|
1391
|
+
return s.flex ? { ...oe, flexWrap: "wrap" } : oe;
|
|
1392
|
+
}
|
|
1393
|
+
function y(s) {
|
|
1394
|
+
return {
|
|
1395
|
+
justifyContent: (s == null ? void 0 : s.align) === "center" ? "center" : (s == null ? void 0 : s.align) === "right" ? "flex-end" : "flex-start",
|
|
1396
|
+
alignItems: (s == null ? void 0 : s.verticalAlign) === "top" ? "flex-start" : (s == null ? void 0 : s.verticalAlign) === "bottom" ? "flex-end" : "center",
|
|
1397
|
+
textAlign: s == null ? void 0 : s.align,
|
|
1398
|
+
fontSize: s != null && s.fontSize ? `${s.fontSize}px` : void 0,
|
|
1399
|
+
lineHeight: s == null ? void 0 : s.lineHeight,
|
|
1400
|
+
fontWeight: s == null ? void 0 : s.fontWeight,
|
|
1401
|
+
writingMode: s == null ? void 0 : s.writingMode,
|
|
1402
|
+
whiteSpace: s == null ? void 0 : s.whiteSpace,
|
|
1403
|
+
color: s == null ? void 0 : s.color,
|
|
1404
|
+
fontFamily: s == null ? void 0 : s.fontFamily
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
function M(s) {
|
|
1408
|
+
return {
|
|
1409
|
+
...y(s.style),
|
|
1410
|
+
whiteSpace: "pre-wrap",
|
|
1411
|
+
width: I(s) ? void 0 : s.width
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
function w(s) {
|
|
1415
|
+
return !I(s) || !s.width ? {} : { width: s.width, flexGrow: 0 };
|
|
1416
|
+
}
|
|
1417
|
+
function f(s) {
|
|
1418
|
+
return y(s.style);
|
|
1419
|
+
}
|
|
1420
|
+
function u(s) {
|
|
1421
|
+
return {
|
|
1422
|
+
gridTemplateColumns: s.map((T) => d(T.width)).join(" ")
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
function m(s) {
|
|
1426
|
+
return {
|
|
1427
|
+
justifyContent: s.align === "center" ? "center" : s.align === "right" ? "flex-end" : "flex-start"
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
function g(s, T) {
|
|
1431
|
+
const N = (T == null ? void 0 : T.align) ?? s.align;
|
|
1432
|
+
return {
|
|
1433
|
+
justifyContent: N === "center" ? "center" : N === "right" ? "flex-end" : "flex-start",
|
|
1434
|
+
fontSize: T != null && T.fontSize ? `${T.fontSize}px` : void 0,
|
|
1435
|
+
fontWeight: (T == null ? void 0 : T.fontWeight) ?? void 0
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
function S(s, T) {
|
|
1439
|
+
return s.rowTemplate.find((N) => N.columnKey === T);
|
|
1440
|
+
}
|
|
1441
|
+
function E(s, T) {
|
|
1442
|
+
const N = we(s, T);
|
|
1443
|
+
return typeof s._paginateMaxRows == "number" && s._paginateMaxRows > 0 ? Math.min(N, s._paginateMaxRows) : N;
|
|
1444
|
+
}
|
|
1445
|
+
function $(s, T, N) {
|
|
1446
|
+
return dt(s, T, N);
|
|
1447
|
+
}
|
|
1448
|
+
function I(s) {
|
|
1449
|
+
return s.mode === "field" && !!(s.prefix || s.suffix);
|
|
1450
|
+
}
|
|
1451
|
+
const D = K(() => {
|
|
1452
|
+
var s;
|
|
1453
|
+
return r.node.type !== "p" || r.node.mode !== "field" ? "EDIT" : ((s = r.fieldPermissions) == null ? void 0 : s[r.node.field]) ?? "EDIT";
|
|
1454
|
+
});
|
|
1455
|
+
function _(s, T) {
|
|
1456
|
+
c.value && (s.mode !== "field" || !s.action || s.action === "text" || n("action-trigger", {
|
|
1457
|
+
nodeId: s.id,
|
|
1458
|
+
field: s.field,
|
|
1459
|
+
action: s.action,
|
|
1460
|
+
actionParams: s.actionParams
|
|
1461
|
+
}));
|
|
1462
|
+
}
|
|
1463
|
+
const v = K(() => D.value === "HIDDEN");
|
|
1464
|
+
function x(s) {
|
|
1465
|
+
return v.value ? Xe : ne(s);
|
|
1466
|
+
}
|
|
1467
|
+
function V(s) {
|
|
1468
|
+
return v.value ? [Xe] : H(s);
|
|
1469
|
+
}
|
|
1470
|
+
function L(s) {
|
|
1471
|
+
return l.value && s.mode === "field" && !I(s) ? "true" : void 0;
|
|
1472
|
+
}
|
|
1473
|
+
function te(s) {
|
|
1474
|
+
const T = s.innerText;
|
|
1475
|
+
return typeof T == "string" ? T : s.textContent ?? "";
|
|
1476
|
+
}
|
|
1477
|
+
function J(s, T) {
|
|
1478
|
+
!c.value || !s || n("field-change", s, te(T.target));
|
|
1479
|
+
}
|
|
1480
|
+
const re = X(null);
|
|
1481
|
+
function pe() {
|
|
1482
|
+
var T;
|
|
1483
|
+
if (r.node.type !== "p") return;
|
|
1484
|
+
const s = re.value;
|
|
1485
|
+
if (!(!s || !c.value) && s !== (((T = s.ownerDocument) == null ? void 0 : T.activeElement) ?? null)) {
|
|
1486
|
+
for (; s.firstChild; ) s.removeChild(s.firstChild);
|
|
1487
|
+
for (const N of V(r.node)) {
|
|
1488
|
+
const B = document.createElement("div");
|
|
1489
|
+
B.className = "layout-p__line", B.textContent = N, s.appendChild(B);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
ge(
|
|
1494
|
+
() => r.node.type === "p" ? ne(r.node) : "",
|
|
1495
|
+
pe
|
|
1496
|
+
), Fe(pe);
|
|
1497
|
+
function ne(s) {
|
|
1498
|
+
const T = r.data;
|
|
1499
|
+
if (T == null || !(s.field in T)) return s.default ?? "";
|
|
1500
|
+
const N = T[s.field];
|
|
1501
|
+
return N == null ? s.default ?? "" : String(N);
|
|
1502
|
+
}
|
|
1503
|
+
function H(s) {
|
|
1504
|
+
return ne(s).split(`
|
|
1505
|
+
`);
|
|
1506
|
+
}
|
|
1507
|
+
const W = X(!1), ie = K(
|
|
1508
|
+
() => r.node.type === "image" ? ct(r.node, {
|
|
1509
|
+
data: r.data,
|
|
1510
|
+
isDesign: a.value === "design"
|
|
1511
|
+
}) : null
|
|
1512
|
+
), de = K(() => W.value ? Ze : ie.value ?? Ze), Me = K(() => r.node.type === "image" && ie.value === null);
|
|
1513
|
+
ge(
|
|
1514
|
+
() => [
|
|
1515
|
+
r.node.type === "image" ? r.node.src : null,
|
|
1516
|
+
r.node.type === "image" ? r.node.field : null,
|
|
1517
|
+
r.data
|
|
1518
|
+
],
|
|
1519
|
+
() => {
|
|
1520
|
+
W.value = !1;
|
|
1521
|
+
},
|
|
1522
|
+
{ deep: !0 }
|
|
1523
|
+
);
|
|
1524
|
+
function Z() {
|
|
1525
|
+
W.value = !0;
|
|
1526
|
+
}
|
|
1527
|
+
return (s, T) => {
|
|
1528
|
+
var B, ce, oe, qe;
|
|
1529
|
+
const N = wt("GridSchemaNode", !0);
|
|
1530
|
+
return e.node.type === "grid" ? (A(), R("div", {
|
|
1531
|
+
key: 0,
|
|
1532
|
+
class: ae(["layout-grid", [
|
|
1533
|
+
`layout-grid--${e.node.border}`,
|
|
1534
|
+
{
|
|
1535
|
+
"layout-grid--no-top": (B = e.suppressBorders) == null ? void 0 : B.top,
|
|
1536
|
+
"layout-grid--no-right": (ce = e.suppressBorders) == null ? void 0 : ce.right,
|
|
1537
|
+
"layout-grid--no-bottom": (oe = e.suppressBorders) == null ? void 0 : oe.bottom,
|
|
1538
|
+
"layout-grid--no-left": (qe = e.suppressBorders) == null ? void 0 : qe.left
|
|
1539
|
+
}
|
|
1540
|
+
]]),
|
|
1541
|
+
style: z(h(e.node)),
|
|
1542
|
+
"data-node-id": e.node.id
|
|
1543
|
+
}, [
|
|
1544
|
+
(A(!0), R(q, null, Y(e.node.rows, (C, U) => (A(), R("div", {
|
|
1545
|
+
key: C.id,
|
|
1546
|
+
class: "layout-grid__row",
|
|
1547
|
+
style: z(p(e.node, U)),
|
|
1548
|
+
"data-layout-id": C.id
|
|
1549
|
+
}, [
|
|
1550
|
+
(A(!0), R(q, null, Y(C.cells, (Q) => (A(), R("div", {
|
|
1551
|
+
key: Q.id,
|
|
1552
|
+
class: ae(["layout-grid__cell", Q.flex ? "layout-grid__cell--flex" : {}]),
|
|
1553
|
+
style: z(b(Q, e.node)),
|
|
1554
|
+
"data-layout-id": Q.id,
|
|
1555
|
+
"data-node-id": Q.id
|
|
1556
|
+
}, [
|
|
1557
|
+
(A(!0), R(q, null, Y(Q.children, (ve, xe) => (A(), ye(N, {
|
|
1558
|
+
key: ve.id,
|
|
1559
|
+
node: ve,
|
|
1560
|
+
"base-row-height": e.baseRowHeight,
|
|
1561
|
+
mode: a.value,
|
|
1562
|
+
data: e.data,
|
|
1563
|
+
readonly: r.readonly,
|
|
1564
|
+
"field-permissions": r.fieldPermissions,
|
|
1565
|
+
"suppress-borders": o(Q.children, xe),
|
|
1566
|
+
onFieldChange: T[0] || (T[0] = (fe, Le) => n("field-change", fe, Le)),
|
|
1567
|
+
onActionTrigger: T[1] || (T[1] = (fe) => n("action-trigger", fe))
|
|
1568
|
+
}, null, 8, ["node", "base-row-height", "mode", "data", "readonly", "field-permissions", "suppress-borders"]))), 128))
|
|
1569
|
+
], 14, mr))), 128))
|
|
1570
|
+
], 12, fr))), 128))
|
|
1571
|
+
], 14, dr)) : e.node.type === "text" ? (A(), R("div", {
|
|
1572
|
+
key: 1,
|
|
1573
|
+
class: ae(["layout-text", {}]),
|
|
1574
|
+
style: z(f(e.node)),
|
|
1575
|
+
"data-node-id": e.node.id
|
|
1576
|
+
}, G(e.node.text), 13, hr)) : e.node.type === "p" ? (A(), R("div", {
|
|
1577
|
+
key: 2,
|
|
1578
|
+
class: ae(["layout-p", {
|
|
1579
|
+
"layout-p--field": !0,
|
|
1580
|
+
"layout-p--composite": I(e.node),
|
|
1581
|
+
"layout-p--underline": e.node.underline && !I(e.node),
|
|
1582
|
+
"layout-p--inner-border": e.node.innerBorder,
|
|
1583
|
+
"layout-p--hidden": D.value === "HIDDEN"
|
|
1584
|
+
}]),
|
|
1585
|
+
style: z(M(e.node)),
|
|
1586
|
+
contenteditable: I(e.node) ? void 0 : D.value === "EDIT" ? c.value ? "true" : L(e.node) : void 0,
|
|
1587
|
+
"data-field": e.node.field,
|
|
1588
|
+
"data-node-id": e.node.id,
|
|
1589
|
+
onClick: (C) => _(e.node),
|
|
1590
|
+
onBlur: (C) => J(e.node.field, C)
|
|
1591
|
+
}, [
|
|
1592
|
+
e.node.prefix ? (A(), R("span", pr, G(e.node.prefix), 1)) : Ae("", !0),
|
|
1593
|
+
I(e.node) ? (A(), R("span", {
|
|
1594
|
+
key: 1,
|
|
1595
|
+
class: ae(["layout-p__input", { "layout-p--underline": e.node.underline }]),
|
|
1596
|
+
style: z(w(e.node)),
|
|
1597
|
+
contenteditable: D.value === "EDIT" ? c.value ? "true" : r.readonly ? void 0 : "true" : void 0,
|
|
1598
|
+
"data-field": e.node.field,
|
|
1599
|
+
onBlur: T[2] || (T[2] = (C) => J(e.node.field, C))
|
|
1600
|
+
}, [
|
|
1601
|
+
e.node.innerBorder ? (A(!0), R(q, { key: 0 }, Y(V(e.node), (C, U) => (A(), R("div", {
|
|
1602
|
+
key: U,
|
|
1603
|
+
class: "layout-p__line"
|
|
1604
|
+
}, G(C), 1))), 128)) : (A(), R(q, { key: 1 }, [
|
|
1605
|
+
bt(G(x(e.node)), 1)
|
|
1606
|
+
], 64))
|
|
1607
|
+
], 46, yr)) : e.node.innerBorder ? (A(), R("span", {
|
|
1608
|
+
key: 2,
|
|
1609
|
+
ref_key: "innerLinesEl",
|
|
1610
|
+
ref: re,
|
|
1611
|
+
class: "layout-p__lines"
|
|
1612
|
+
}, [
|
|
1613
|
+
(A(!0), R(q, null, Y(V(e.node), (C, U) => (A(), R("div", {
|
|
1614
|
+
key: U,
|
|
1615
|
+
class: "layout-p__line"
|
|
1616
|
+
}, G(C), 1))), 128))
|
|
1617
|
+
], 512)) : (A(), R("span", wr, G(x(e.node)), 1)),
|
|
1618
|
+
e.node.suffix ? (A(), R("span", br, G(e.node.suffix), 1)) : Ae("", !0)
|
|
1619
|
+
], 46, gr)) : e.node.type === "table" ? (A(), R("table", {
|
|
1620
|
+
key: 3,
|
|
1621
|
+
class: ae(["layout-table", [`layout-table--${e.node.border ?? "all"}`]]),
|
|
1622
|
+
"data-node-id": e.node.id
|
|
1623
|
+
}, [
|
|
1624
|
+
O("thead", null, [
|
|
1625
|
+
O("tr", {
|
|
1626
|
+
class: "layout-table__row layout-table__header",
|
|
1627
|
+
style: z([
|
|
1628
|
+
u(e.node.columns),
|
|
1629
|
+
{ minHeight: `${e.baseRowHeight}mm` }
|
|
1630
|
+
])
|
|
1631
|
+
}, [
|
|
1632
|
+
(A(!0), R(q, null, Y(e.node.columns, (C) => (A(), R("th", {
|
|
1633
|
+
key: C.key,
|
|
1634
|
+
class: "layout-table__cell",
|
|
1635
|
+
style: z(g(C, e.node.headerStyle))
|
|
1636
|
+
}, G(C.title), 5))), 128))
|
|
1637
|
+
], 4)
|
|
1638
|
+
]),
|
|
1639
|
+
O("tbody", null, [
|
|
1640
|
+
(A(!0), R(q, null, Y(E(e.node, e.data), (C) => (A(), R("tr", {
|
|
1641
|
+
key: C,
|
|
1642
|
+
class: "layout-table__row",
|
|
1643
|
+
style: z([
|
|
1644
|
+
u(e.node.columns),
|
|
1645
|
+
{ minHeight: `${e.baseRowHeight}mm` }
|
|
1646
|
+
])
|
|
1647
|
+
}, [
|
|
1648
|
+
(A(!0), R(q, null, Y(e.node.columns, (U) => {
|
|
1649
|
+
var Q, ve;
|
|
1650
|
+
return A(), R("td", {
|
|
1651
|
+
key: U.key,
|
|
1652
|
+
class: "layout-table__cell",
|
|
1653
|
+
style: z(m(U)),
|
|
1654
|
+
"data-layout-id": (Q = S(e.node, U.key)) == null ? void 0 : Q.id
|
|
1655
|
+
}, [
|
|
1656
|
+
(A(!0), R(q, null, Y(((ve = S(e.node, U.key)) == null ? void 0 : ve.children) ?? [], (xe) => (A(), ye(N, {
|
|
1657
|
+
key: `${xe.id}-${C}`,
|
|
1658
|
+
node: $(xe, U.key, C),
|
|
1659
|
+
"base-row-height": e.baseRowHeight,
|
|
1660
|
+
mode: a.value,
|
|
1661
|
+
data: e.data,
|
|
1662
|
+
readonly: r.readonly,
|
|
1663
|
+
"field-permissions": r.fieldPermissions,
|
|
1664
|
+
onFieldChange: (fe, Le) => n("field-change", fe, Le),
|
|
1665
|
+
onActionTrigger: (fe) => n("action-trigger", fe)
|
|
1666
|
+
}, null, 8, ["node", "base-row-height", "mode", "data", "readonly", "field-permissions", "onFieldChange", "onActionTrigger"]))), 128))
|
|
1667
|
+
], 12, Er);
|
|
1668
|
+
}), 128))
|
|
1669
|
+
], 4))), 128))
|
|
1670
|
+
])
|
|
1671
|
+
], 10, vr)) : e.node.type === "html" ? (A(), ye(ir, {
|
|
1672
|
+
key: 4,
|
|
1673
|
+
node: e.node,
|
|
1674
|
+
data: e.data,
|
|
1675
|
+
readonly: r.readonly,
|
|
1676
|
+
"field-permissions": r.fieldPermissions,
|
|
1677
|
+
onFieldChange: (C, U) => n("field-change", C, U)
|
|
1678
|
+
}, null, 8, ["node", "data", "readonly", "field-permissions", "onFieldChange"])) : (A(), R("img", {
|
|
1679
|
+
key: 5,
|
|
1680
|
+
class: ae(["layout-image", { "layout-image--blank": Me.value }]),
|
|
1681
|
+
"data-node-id": e.node.id,
|
|
1682
|
+
"data-field": e.node.field,
|
|
1683
|
+
src: de.value,
|
|
1684
|
+
alt: e.node.field ?? e.node.src ?? "",
|
|
1685
|
+
style: z({
|
|
1686
|
+
width: e.node.width ? `${e.node.width}mm` : void 0,
|
|
1687
|
+
height: e.node.height ? `${e.node.height}mm` : void 0,
|
|
1688
|
+
objectFit: e.node.objectFit
|
|
1689
|
+
}),
|
|
1690
|
+
onError: Z
|
|
1691
|
+
}, null, 46, Tr));
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
}), Mr = /* @__PURE__ */ Ie(Sr, [["__scopeId", "data-v-3f4d7b64"]]), xr = "grid-form-page-size";
|
|
1695
|
+
let j = null;
|
|
1696
|
+
const Ce = /* @__PURE__ */ new Set();
|
|
1697
|
+
function Ar() {
|
|
1698
|
+
return typeof document > "u" ? null : (j || (j = document.createElement("style"), j.id = xr, j.setAttribute("data-generated-by", "GridFormRenderer"), document.head.appendChild(j)), j);
|
|
1699
|
+
}
|
|
1700
|
+
function Rr(e, t) {
|
|
1701
|
+
const n = Ar();
|
|
1702
|
+
n && (n.textContent = `@page { size: ${e}mm ${t}mm; margin: 0; }`);
|
|
1703
|
+
}
|
|
1704
|
+
function Nr() {
|
|
1705
|
+
const e = {};
|
|
1706
|
+
return Ce.add(e), () => {
|
|
1707
|
+
Ce.delete(e), Ce.size === 0 && j && (j.remove(), j = null);
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function ai() {
|
|
1711
|
+
return (j == null ? void 0 : j.textContent) ?? "";
|
|
1712
|
+
}
|
|
1713
|
+
const Fr = 96 / 25.4;
|
|
1714
|
+
function kr(e) {
|
|
1715
|
+
return e.offsetHeight / Fr;
|
|
1716
|
+
}
|
|
1717
|
+
const he = 1 / (96 / 25.4);
|
|
1718
|
+
function ft(e) {
|
|
1719
|
+
return e.border === "all" || e.border === "outer";
|
|
1720
|
+
}
|
|
1721
|
+
function Ne(e, t, n) {
|
|
1722
|
+
if (n) {
|
|
1723
|
+
const i = n(t);
|
|
1724
|
+
if (typeof i == "number" && Number.isFinite(i) && i > 0)
|
|
1725
|
+
return i;
|
|
1726
|
+
}
|
|
1727
|
+
let r = t.height;
|
|
1728
|
+
for (const i of t.cells)
|
|
1729
|
+
typeof i.rowHeight == "number" && Number.isFinite(i.rowHeight) && i.rowHeight > r && (r = i.rowHeight);
|
|
1730
|
+
return r * e;
|
|
1731
|
+
}
|
|
1732
|
+
function Pe(e, t, n, r, i, o) {
|
|
1733
|
+
const a = Re(t);
|
|
1734
|
+
let l = 0;
|
|
1735
|
+
return n.forEach((c, d) => {
|
|
1736
|
+
d > 0 && (l += a), l += Ne(e, c, o);
|
|
1737
|
+
}), ft(t) && (r || (l += he), i || (l += he)), l;
|
|
1738
|
+
}
|
|
1739
|
+
function Ir(e, t) {
|
|
1740
|
+
var c, d;
|
|
1741
|
+
const n = ((c = e.style) == null ? void 0 : c.fontSize) ?? 13, r = ((d = e.style) == null ? void 0 : d.lineHeight) ?? 1.35, i = n * r / (96 / 25.4), o = Math.max(0.1, n * 0.6 / (96 / 25.4)), a = Math.max(1, Math.floor(t / o));
|
|
1742
|
+
let l = 0;
|
|
1743
|
+
for (const h of e.text.split(`
|
|
1744
|
+
`))
|
|
1745
|
+
l += Math.max(1, Math.ceil(h.length / a));
|
|
1746
|
+
return l * i;
|
|
1747
|
+
}
|
|
1748
|
+
function Lr(e, t) {
|
|
1749
|
+
return typeof e.height == "number" && Number.isFinite(e.height) && e.height > 0 ? e.height : typeof e.width == "number" && Number.isFinite(e.width) && e.width > 0 ? e.width : t;
|
|
1750
|
+
}
|
|
1751
|
+
function _e(e, t, n) {
|
|
1752
|
+
const r = we(e, n);
|
|
1753
|
+
let o = (1 + (typeof e._paginateMaxRows == "number" && e._paginateMaxRows > 0 ? Math.min(r, e._paginateMaxRows) : r)) * t;
|
|
1754
|
+
return (e.border === "all" || e.border === "outer") && (o += 2 * he), o;
|
|
1755
|
+
}
|
|
1756
|
+
function Qe(e, t) {
|
|
1757
|
+
if (t.measureNode) {
|
|
1758
|
+
const n = t.measureNode(e);
|
|
1759
|
+
if (typeof n == "number" && Number.isFinite(n)) return n;
|
|
1760
|
+
}
|
|
1761
|
+
switch (e.type) {
|
|
1762
|
+
case "grid":
|
|
1763
|
+
return Pe(t.baseRowHeight, e, e.rows, !1, !1, t.measureRow);
|
|
1764
|
+
case "image":
|
|
1765
|
+
return ct(e, { data: t.data }) === null ? 0 : Lr(e, t.baseRowHeight);
|
|
1766
|
+
case "text":
|
|
1767
|
+
return Ir(e, t.contentWidthMm);
|
|
1768
|
+
case "table":
|
|
1769
|
+
return _e(e, t.baseRowHeight, t.data);
|
|
1770
|
+
case "html":
|
|
1771
|
+
return t.baseRowHeight;
|
|
1772
|
+
case "p":
|
|
1773
|
+
return t.baseRowHeight;
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
function mt(e, t) {
|
|
1777
|
+
const n = [], r = Math.max(1, t.bodyHeightMm), i = [];
|
|
1778
|
+
let o = [], a = 0;
|
|
1779
|
+
const l = () => {
|
|
1780
|
+
if (o.length > 0) {
|
|
1781
|
+
const f = i.length === 0;
|
|
1782
|
+
i.push({
|
|
1783
|
+
id: f ? e.id : `${e.id}__pp${i.length}`,
|
|
1784
|
+
sourcePageId: e.id,
|
|
1785
|
+
sourceIndex: i.length,
|
|
1786
|
+
index: 0,
|
|
1787
|
+
margin: e.margin,
|
|
1788
|
+
children: o
|
|
1789
|
+
}), o = [], a = 0;
|
|
1790
|
+
}
|
|
1791
|
+
}, c = (f) => a + f <= r + 1e-6, d = (f) => {
|
|
1792
|
+
o.push(f), a += Qe(f.node, t);
|
|
1793
|
+
}, h = (f) => {
|
|
1794
|
+
const u = Qe(f, t);
|
|
1795
|
+
c(u) || (l(), c(u) || n.push({
|
|
1796
|
+
nodeId: f.id,
|
|
1797
|
+
message: `节点(${f.type})高度约 ${u.toFixed(1)}mm 超过单页可用高 ${r.toFixed(1)}mm,已溢出裁剪`
|
|
1798
|
+
})), d({ node: f });
|
|
1799
|
+
}, p = (f) => {
|
|
1800
|
+
const u = Pe(t.baseRowHeight, f, f.rows, !1, !1, t.measureRow);
|
|
1801
|
+
let m = !1;
|
|
1802
|
+
for (const g of f.rows) {
|
|
1803
|
+
for (const S of g.cells) {
|
|
1804
|
+
for (const E of S.children)
|
|
1805
|
+
if (E.type === "table" && _e(E, t.baseRowHeight, t.data) > t.bodyHeightMm * 0.8) {
|
|
1806
|
+
m = !0;
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
if (m) break;
|
|
1810
|
+
}
|
|
1811
|
+
if (m) break;
|
|
1812
|
+
}
|
|
1813
|
+
if (c(u) && !m) {
|
|
1814
|
+
d({ node: f });
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
w(f);
|
|
1818
|
+
}, b = (f) => {
|
|
1819
|
+
const u = we(f, t.data), m = t.baseRowHeight, g = t.baseRowHeight, S = f.border === "all" || f.border === "outer", E = S ? he : 0, $ = g + u * m + (S ? 2 * E : 0);
|
|
1820
|
+
if (c($)) {
|
|
1821
|
+
d({ node: f });
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
let I = u, D = 0, _ = !0;
|
|
1825
|
+
for (; I > 0; ) {
|
|
1826
|
+
const v = r - a, x = _ ? g + E : E, V = Math.max(0, v - x);
|
|
1827
|
+
let L = V > 0 ? Math.floor(V / m) : 0;
|
|
1828
|
+
if (L === 0 && I > 0 && (L = 1, o.length > 0 && x + m > v + 1e-6)) {
|
|
1829
|
+
l();
|
|
1830
|
+
continue;
|
|
1831
|
+
}
|
|
1832
|
+
L = Math.min(L, I);
|
|
1833
|
+
const te = D + L >= u, J = {
|
|
1834
|
+
...f,
|
|
1835
|
+
_paginateMaxRows: L
|
|
1836
|
+
};
|
|
1837
|
+
d({
|
|
1838
|
+
node: J,
|
|
1839
|
+
suppressBorders: {
|
|
1840
|
+
top: !_,
|
|
1841
|
+
// 后续片段抑制上外框(连续外观)
|
|
1842
|
+
bottom: !te
|
|
1843
|
+
// 非末片段抑制下外框
|
|
1844
|
+
}
|
|
1845
|
+
}), I -= L, D += L, _ = !1, I > 0 && l();
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
function y(f) {
|
|
1849
|
+
const u = [];
|
|
1850
|
+
for (const m of f.cells)
|
|
1851
|
+
for (const g of m.children)
|
|
1852
|
+
g.type === "table" && u.push(g);
|
|
1853
|
+
return u;
|
|
1854
|
+
}
|
|
1855
|
+
function M(f, u) {
|
|
1856
|
+
return f.map((m) => {
|
|
1857
|
+
if (m.type === "grid")
|
|
1858
|
+
return {
|
|
1859
|
+
...m,
|
|
1860
|
+
rows: m.rows.map((g) => ({
|
|
1861
|
+
...g,
|
|
1862
|
+
cells: g.cells.map((S) => ({
|
|
1863
|
+
...S,
|
|
1864
|
+
children: M(S.children, u)
|
|
1865
|
+
}))
|
|
1866
|
+
}))
|
|
1867
|
+
};
|
|
1868
|
+
if (m.type === "table") {
|
|
1869
|
+
const g = u(m);
|
|
1870
|
+
if (typeof g == "number" && g > 0)
|
|
1871
|
+
return { ...m, _paginateMaxRows: g };
|
|
1872
|
+
}
|
|
1873
|
+
return m;
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
const w = (f) => {
|
|
1877
|
+
const u = f.rows, m = Re(f), g = ft(f), S = t.measureRow;
|
|
1878
|
+
let E = 0, $ = !0;
|
|
1879
|
+
for (; E < u.length; ) {
|
|
1880
|
+
const I = !$;
|
|
1881
|
+
let D = r - a;
|
|
1882
|
+
const _ = y(u[E]);
|
|
1883
|
+
let v = 0;
|
|
1884
|
+
for (const H of _)
|
|
1885
|
+
v += _e(H, t.baseRowHeight, t.data);
|
|
1886
|
+
const x = Ne(t.baseRowHeight, u[E], S), V = (g ? he : 0) + x;
|
|
1887
|
+
if (_.length > 0 && v > D - V && u.length - E === 1) {
|
|
1888
|
+
o.length > 0 && l();
|
|
1889
|
+
let H = 0;
|
|
1890
|
+
for (const de of _)
|
|
1891
|
+
H += we(de, t.data);
|
|
1892
|
+
let W = 0, ie = !0;
|
|
1893
|
+
for (; H > 0; ) {
|
|
1894
|
+
const de = r - a, Me = Math.max(0, de - V);
|
|
1895
|
+
let Z = Me > 0 ? Math.floor(Me / t.baseRowHeight) : 0;
|
|
1896
|
+
Z === 0 && H > 0 && (Z = 1), Z = Math.min(Z, H);
|
|
1897
|
+
const s = W + Z >= H, T = u[E].cells.map((N) => ({
|
|
1898
|
+
...N,
|
|
1899
|
+
children: M(N.children, (B) => {
|
|
1900
|
+
const oe = we(B, t.data) / Math.max(1, H + W);
|
|
1901
|
+
return Math.round(Z * oe);
|
|
1902
|
+
})
|
|
1903
|
+
}));
|
|
1904
|
+
d({
|
|
1905
|
+
node: { ...f, rows: [{ ...u[E], cells: T }] },
|
|
1906
|
+
suppressBorders: { top: !ie, bottom: !s }
|
|
1907
|
+
}), H -= Z, W += Z, ie = !1, H > 0 && l();
|
|
1908
|
+
}
|
|
1909
|
+
$ = !1, E = E + 1, E < u.length && l();
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
let L = E, te = I || !g ? 0 : he, J = 0;
|
|
1913
|
+
for (; L < u.length; ) {
|
|
1914
|
+
const H = Ne(t.baseRowHeight, u[L], S), W = (J > 0 ? m : 0) + H, de = L + 1 >= u.length && g ? he : 0;
|
|
1915
|
+
if (te + W + de <= D + 1e-6)
|
|
1916
|
+
te += W, J++, L++;
|
|
1917
|
+
else
|
|
1918
|
+
break;
|
|
1919
|
+
}
|
|
1920
|
+
if (J === 0) {
|
|
1921
|
+
o.length > 0 && l();
|
|
1922
|
+
const H = !$, W = E + 1 < u.length, ie = Pe(t.baseRowHeight, f, u.slice(E, E + 1), H, W, S);
|
|
1923
|
+
ie > r + 1e-6 && n.push({
|
|
1924
|
+
nodeId: f.id,
|
|
1925
|
+
message: `Grid 第 ${E + 1} 行高度约 ${ie.toFixed(1)}mm 超过单页可用高,已溢出裁剪`
|
|
1926
|
+
}), d({ node: { ...f, rows: u.slice(E, E + 1) }, suppressBorders: { top: H, bottom: W } }), $ = !1, E = E + 1, E < u.length && l();
|
|
1927
|
+
continue;
|
|
1928
|
+
}
|
|
1929
|
+
const re = L < u.length, pe = I, ne = re;
|
|
1930
|
+
d({
|
|
1931
|
+
node: { ...f, rows: u.slice(E, L), id: f.id },
|
|
1932
|
+
suppressBorders: { top: pe, bottom: ne }
|
|
1933
|
+
}), $ = !1, E = L, re && l();
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
for (const f of e.children)
|
|
1937
|
+
f.type === "grid" ? p(f) : f.type === "table" ? b(f) : h(f);
|
|
1938
|
+
return l(), i.length === 0 && i.push({
|
|
1939
|
+
id: e.id,
|
|
1940
|
+
sourcePageId: e.id,
|
|
1941
|
+
sourceIndex: 0,
|
|
1942
|
+
index: 0,
|
|
1943
|
+
margin: e.margin,
|
|
1944
|
+
children: []
|
|
1945
|
+
}), { pages: i, warnings: n };
|
|
1946
|
+
}
|
|
1947
|
+
function Cr(e, t) {
|
|
1948
|
+
const n = Be(e.paper), r = [], i = [];
|
|
1949
|
+
for (const o of e.pages) {
|
|
1950
|
+
const a = n.heightMm - o.margin.top - o.margin.bottom, l = n.widthMm - o.margin.left - o.margin.right, c = mt(o, {
|
|
1951
|
+
baseRowHeight: e.baseRowHeight,
|
|
1952
|
+
bodyHeightMm: a,
|
|
1953
|
+
contentWidthMm: l,
|
|
1954
|
+
data: (t == null ? void 0 : t.data) ?? null,
|
|
1955
|
+
measureNode: t == null ? void 0 : t.measureNode,
|
|
1956
|
+
measureRow: t == null ? void 0 : t.measureRow
|
|
1957
|
+
});
|
|
1958
|
+
r.push(...c.pages), i.push(...c.warnings);
|
|
1959
|
+
}
|
|
1960
|
+
return r.forEach((o, a) => o.index = a + 1), { pages: r, warnings: i };
|
|
1961
|
+
}
|
|
1962
|
+
const $r = ["data-node-id"], Dr = { class: "grid-form-band__zone" }, Hr = { class: "grid-form-band__zone grid-form-band__zone--center" }, Vr = { class: "grid-form-band__zone grid-form-band__zone--right" }, Pr = { class: "grid-form-band__zone" }, _r = { class: "grid-form-band__zone grid-form-band__zone--center" }, Or = { class: "grid-form-band__zone grid-form-band__zone--right" }, Br = /* @__PURE__ */ Te({
|
|
1963
|
+
name: "GridFormRenderer",
|
|
1964
|
+
__name: "GridFormRenderer",
|
|
1965
|
+
props: {
|
|
1966
|
+
schema: {},
|
|
1967
|
+
mode: {},
|
|
1968
|
+
data: {},
|
|
1969
|
+
readonly: { type: Boolean },
|
|
1970
|
+
bare: { type: Boolean },
|
|
1971
|
+
paginate: { type: Boolean, default: !0 },
|
|
1972
|
+
fieldPermissions: {}
|
|
1973
|
+
},
|
|
1974
|
+
emits: ["field-change", "action-trigger"],
|
|
1975
|
+
setup(e, { emit: t }) {
|
|
1976
|
+
const n = t, r = e, i = K(() => Be(r.schema.paper));
|
|
1977
|
+
ge(
|
|
1978
|
+
i,
|
|
1979
|
+
(u) => Rr(u.widthMm, u.heightMm),
|
|
1980
|
+
{ immediate: !0 }
|
|
1981
|
+
), vt(Nr());
|
|
1982
|
+
function o(u) {
|
|
1983
|
+
const m = i.value, g = r.paginate;
|
|
1984
|
+
return {
|
|
1985
|
+
position: "relative",
|
|
1986
|
+
width: `${m.widthMm}mm`,
|
|
1987
|
+
...g ? { height: `${m.heightMm}mm` } : { minHeight: `${m.heightMm}mm` },
|
|
1988
|
+
padding: `${u.top}mm ${u.right}mm ${u.bottom}mm ${u.left}mm`
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
const a = K(() => {
|
|
1992
|
+
const u = i.value;
|
|
1993
|
+
if (!r.paginate)
|
|
1994
|
+
return r.schema.pages.map((g, S) => ({
|
|
1995
|
+
id: g.id,
|
|
1996
|
+
sourcePageId: g.id,
|
|
1997
|
+
sourceIndex: S,
|
|
1998
|
+
index: S + 1,
|
|
1999
|
+
margin: g.margin,
|
|
2000
|
+
children: g.children.map((E) => ({ node: E }))
|
|
2001
|
+
}));
|
|
2002
|
+
const m = [];
|
|
2003
|
+
for (const g of r.schema.pages) {
|
|
2004
|
+
const S = u.heightMm - g.margin.top - g.margin.bottom, E = u.widthMm - g.margin.left - g.margin.right, $ = mt(g, {
|
|
2005
|
+
baseRowHeight: r.schema.baseRowHeight,
|
|
2006
|
+
bodyHeightMm: S,
|
|
2007
|
+
contentWidthMm: E,
|
|
2008
|
+
data: r.data ?? null
|
|
2009
|
+
});
|
|
2010
|
+
m.push(...$.pages);
|
|
2011
|
+
}
|
|
2012
|
+
return m.forEach((g, S) => g.index = S + 1), m;
|
|
2013
|
+
}), l = X(null);
|
|
2014
|
+
function c() {
|
|
2015
|
+
if (typeof document > "u") return null;
|
|
2016
|
+
const u = /* @__PURE__ */ new Map();
|
|
2017
|
+
return document.querySelectorAll(".grid-form-paper .layout-grid__row").forEach((m) => {
|
|
2018
|
+
const g = m.dataset.layoutId;
|
|
2019
|
+
if (!g) return;
|
|
2020
|
+
const S = kr(m);
|
|
2021
|
+
Number.isFinite(S) && S > 0 && u.set(g, S);
|
|
2022
|
+
}), u.size ? u : null;
|
|
2023
|
+
}
|
|
2024
|
+
function d() {
|
|
2025
|
+
if (!r.paginate || typeof document > "u") {
|
|
2026
|
+
l.value = null;
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
const u = c();
|
|
2030
|
+
if (!u) return;
|
|
2031
|
+
const m = Cr(r.schema, {
|
|
2032
|
+
data: r.data ?? null,
|
|
2033
|
+
measureRow: (g) => {
|
|
2034
|
+
const S = u.get(g.id);
|
|
2035
|
+
if (S !== void 0)
|
|
2036
|
+
return Math.max(S, Ne(r.schema.baseRowHeight, g));
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
l.value = m.pages;
|
|
2040
|
+
}
|
|
2041
|
+
ge(a, () => Je(d), { flush: "post" }), Fe(() => Je(d));
|
|
2042
|
+
const h = K(() => l.value ?? a.value);
|
|
2043
|
+
function p(u) {
|
|
2044
|
+
return (u == null ? void 0 : u.enabled) === !0;
|
|
2045
|
+
}
|
|
2046
|
+
function b(u) {
|
|
2047
|
+
const m = u == null ? void 0 : u.height;
|
|
2048
|
+
return typeof m == "number" && Number.isFinite(m) && m > 0 ? m : Nt;
|
|
2049
|
+
}
|
|
2050
|
+
function y(u, m, g) {
|
|
2051
|
+
return u ? u.replace(/\{page\}/g, String(m.index)).replace(/\{total\}/g, String(g)) : "";
|
|
2052
|
+
}
|
|
2053
|
+
function M(u, m, g) {
|
|
2054
|
+
var v, x, V;
|
|
2055
|
+
const S = (u == null ? void 0 : u.separator) !== !1, E = (u == null ? void 0 : u.separatorColor) ?? "#111827", I = `${(u == null ? void 0 : u.separatorWidth) ?? 1}px solid ${E}`, D = g === "top" ? m.top : m.bottom, _ = Math.min(b(u), D);
|
|
2056
|
+
return {
|
|
2057
|
+
left: `${m.left}mm`,
|
|
2058
|
+
right: `${m.right}mm`,
|
|
2059
|
+
height: `${_}mm`,
|
|
2060
|
+
...g === "top" ? { top: 0, ...S ? { borderBottom: I } : {} } : { bottom: 0, ...S ? { borderTop: I } : {} },
|
|
2061
|
+
fontSize: (v = u == null ? void 0 : u.style) != null && v.fontSize ? `${u.style.fontSize}px` : void 0,
|
|
2062
|
+
fontWeight: ((x = u == null ? void 0 : u.style) == null ? void 0 : x.fontWeight) ?? void 0,
|
|
2063
|
+
color: ((V = u == null ? void 0 : u.style) == null ? void 0 : V.color) ?? void 0
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
function w(u, m, g) {
|
|
2067
|
+
return { ...f(u.children.map((E) => E.node), m), ...g ?? {} };
|
|
2068
|
+
}
|
|
2069
|
+
function f(u, m) {
|
|
2070
|
+
const g = u[m];
|
|
2071
|
+
if (!(g.type === "grid" && (g.border === "all" || g.border === "outer"))) return;
|
|
2072
|
+
const E = u[m - 1];
|
|
2073
|
+
return { top: !!E && E.type === "grid" && (E.border === "all" || E.border === "outer") };
|
|
2074
|
+
}
|
|
2075
|
+
return (u, m) => (A(), R("div", {
|
|
2076
|
+
class: ae(["grid-form-canvas", { "grid-form-canvas--bare": e.bare }])
|
|
2077
|
+
}, [
|
|
2078
|
+
(A(!0), R(q, null, Y(h.value, (g) => {
|
|
2079
|
+
var S, E, $, I, D, _, v, x, V, L, te, J;
|
|
2080
|
+
return A(), R("main", {
|
|
2081
|
+
key: g.id,
|
|
2082
|
+
class: "grid-form-paper",
|
|
2083
|
+
style: z(o(g.margin)),
|
|
2084
|
+
"data-node-id": g.id
|
|
2085
|
+
}, [
|
|
2086
|
+
p(e.schema.paper.header) ? (A(), R("div", {
|
|
2087
|
+
key: 0,
|
|
2088
|
+
class: "grid-form-band grid-form-band--header",
|
|
2089
|
+
style: z(M(e.schema.paper.header, g.margin, "top"))
|
|
2090
|
+
}, [
|
|
2091
|
+
O("span", Dr, G(y((E = (S = e.schema.paper.header) == null ? void 0 : S.content) == null ? void 0 : E.left, g, h.value.length)), 1),
|
|
2092
|
+
O("span", Hr, G(y((I = ($ = e.schema.paper.header) == null ? void 0 : $.content) == null ? void 0 : I.center, g, h.value.length)), 1),
|
|
2093
|
+
O("span", Vr, G(y((_ = (D = e.schema.paper.header) == null ? void 0 : D.content) == null ? void 0 : _.right, g, h.value.length)), 1)
|
|
2094
|
+
], 4)) : Ae("", !0),
|
|
2095
|
+
(A(!0), R(q, null, Y(g.children, (re, pe) => (A(), ye(Mr, {
|
|
2096
|
+
key: re.node.id,
|
|
2097
|
+
node: re.node,
|
|
2098
|
+
"base-row-height": e.schema.baseRowHeight,
|
|
2099
|
+
mode: r.mode,
|
|
2100
|
+
data: e.data,
|
|
2101
|
+
readonly: r.readonly,
|
|
2102
|
+
"field-permissions": r.fieldPermissions,
|
|
2103
|
+
"suppress-borders": w(g, pe, re.suppressBorders),
|
|
2104
|
+
onFieldChange: m[0] || (m[0] = (ne, H) => n("field-change", ne, H)),
|
|
2105
|
+
onActionTrigger: m[1] || (m[1] = (ne) => n("action-trigger", ne))
|
|
2106
|
+
}, null, 8, ["node", "base-row-height", "mode", "data", "readonly", "field-permissions", "suppress-borders"]))), 128)),
|
|
2107
|
+
p(e.schema.paper.footer) ? (A(), R("div", {
|
|
2108
|
+
key: 1,
|
|
2109
|
+
class: "grid-form-band grid-form-band--footer",
|
|
2110
|
+
style: z(M(e.schema.paper.footer, g.margin, "bottom"))
|
|
2111
|
+
}, [
|
|
2112
|
+
O("span", Pr, G(y((x = (v = e.schema.paper.footer) == null ? void 0 : v.content) == null ? void 0 : x.left, g, h.value.length)), 1),
|
|
2113
|
+
O("span", _r, G(y((L = (V = e.schema.paper.footer) == null ? void 0 : V.content) == null ? void 0 : L.center, g, h.value.length)), 1),
|
|
2114
|
+
O("span", Or, G(y((J = (te = e.schema.paper.footer) == null ? void 0 : te.content) == null ? void 0 : J.right, g, h.value.length)), 1)
|
|
2115
|
+
], 4)) : Ae("", !0)
|
|
2116
|
+
], 12, $r);
|
|
2117
|
+
}), 128))
|
|
2118
|
+
], 2));
|
|
2119
|
+
}
|
|
2120
|
+
}), et = /* @__PURE__ */ Ie(Br, [["__scopeId", "data-v-f3e7b908"]]), li = "data-node-id", si = "data-layout-id", ci = "application/x-ticket-node-kind", Gr = {
|
|
2121
|
+
class: "paper-viewport__bar",
|
|
2122
|
+
role: "toolbar",
|
|
2123
|
+
"aria-label": "缩放控制"
|
|
2124
|
+
}, zr = { class: "paper-viewport__scale" }, Wr = "input, textarea, select, [contenteditable], [draggable='true']", Ur = /* @__PURE__ */ Te({
|
|
2125
|
+
__name: "PaperViewport",
|
|
2126
|
+
props: {
|
|
2127
|
+
initialScale: { default: 1 },
|
|
2128
|
+
fitOnMount: { type: Boolean, default: !1 },
|
|
2129
|
+
minScale: { default: 0.2 },
|
|
2130
|
+
maxScale: { default: 4 }
|
|
2131
|
+
},
|
|
2132
|
+
emits: ["scale-change"],
|
|
2133
|
+
setup(e, { expose: t, emit: n }) {
|
|
2134
|
+
const r = e, i = n, o = X(null), a = X(null), l = X(r.initialScale);
|
|
2135
|
+
let c = null, d = null;
|
|
2136
|
+
const h = K(() => `${Math.round(l.value * 100)}%`);
|
|
2137
|
+
function p() {
|
|
2138
|
+
const v = a.value;
|
|
2139
|
+
v && (v.querySelectorAll(".panzoom-exclude").forEach((x) => x.classList.remove("panzoom-exclude")), v.querySelectorAll(Wr).forEach((x) => {
|
|
2140
|
+
x.classList.add("panzoom-exclude"), x.matches("input, textarea, select, [contenteditable]") && (x.style.userSelect = "text");
|
|
2141
|
+
}));
|
|
2142
|
+
}
|
|
2143
|
+
const b = X(!1);
|
|
2144
|
+
function y(v) {
|
|
2145
|
+
const x = v;
|
|
2146
|
+
return !!(x && typeof x.closest == "function" && x.closest("input, textarea, select, [contenteditable]"));
|
|
2147
|
+
}
|
|
2148
|
+
function M() {
|
|
2149
|
+
var v;
|
|
2150
|
+
b.value || (b.value = !0, (v = o.value) == null || v.classList.add("is-space-pan"));
|
|
2151
|
+
}
|
|
2152
|
+
function w() {
|
|
2153
|
+
var v;
|
|
2154
|
+
b.value && (b.value = !1, (v = o.value) == null || v.classList.remove("is-space-pan"));
|
|
2155
|
+
}
|
|
2156
|
+
function f(v) {
|
|
2157
|
+
v.code !== "Space" && v.key !== " " || y(v.target) || (v.preventDefault(), M());
|
|
2158
|
+
}
|
|
2159
|
+
function u(v) {
|
|
2160
|
+
v.code !== "Space" && v.key !== " " || w();
|
|
2161
|
+
}
|
|
2162
|
+
function m(v) {
|
|
2163
|
+
const x = v.detail;
|
|
2164
|
+
typeof (x == null ? void 0 : x.scale) == "number" && x.scale !== l.value && (l.value = x.scale, i("scale-change", x.scale));
|
|
2165
|
+
}
|
|
2166
|
+
function g(v) {
|
|
2167
|
+
if (!c) return;
|
|
2168
|
+
const x = v.target;
|
|
2169
|
+
x && x.closest("input, textarea, select, [contenteditable]") || c.zoomWithWheel(v);
|
|
2170
|
+
}
|
|
2171
|
+
function S(v) {
|
|
2172
|
+
return Math.min(r.maxScale, Math.max(r.minScale, v));
|
|
2173
|
+
}
|
|
2174
|
+
function E() {
|
|
2175
|
+
const v = (c == null ? void 0 : c.getScale()) ?? l.value;
|
|
2176
|
+
c == null || c.zoom(S(v * 1.2));
|
|
2177
|
+
}
|
|
2178
|
+
function $() {
|
|
2179
|
+
const v = (c == null ? void 0 : c.getScale()) ?? l.value;
|
|
2180
|
+
c == null || c.zoom(S(v / 1.2));
|
|
2181
|
+
}
|
|
2182
|
+
function I() {
|
|
2183
|
+
c == null || c.reset({ animate: !1 });
|
|
2184
|
+
}
|
|
2185
|
+
function D() {
|
|
2186
|
+
const v = o.value, x = a.value;
|
|
2187
|
+
if (!v || !x || !c) return;
|
|
2188
|
+
const L = (x.firstElementChild ?? x).scrollWidth || 0;
|
|
2189
|
+
if (L <= 0 || v.clientWidth <= 0) {
|
|
2190
|
+
c.zoom(r.initialScale);
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
c.zoom(S(v.clientWidth / L));
|
|
2194
|
+
}
|
|
2195
|
+
function _() {
|
|
2196
|
+
return (c == null ? void 0 : c.getScale()) ?? l.value;
|
|
2197
|
+
}
|
|
2198
|
+
return t({ zoomIn: E, zoomOut: $, reset: I, fitWidth: D, getScale: _ }), Fe(() => {
|
|
2199
|
+
const v = a.value, x = o.value;
|
|
2200
|
+
if (!v || !x) return;
|
|
2201
|
+
const V = {
|
|
2202
|
+
minScale: r.minScale,
|
|
2203
|
+
maxScale: r.maxScale,
|
|
2204
|
+
startScale: r.initialScale,
|
|
2205
|
+
step: 0.3,
|
|
2206
|
+
cursor: "grab",
|
|
2207
|
+
touchAction: "none"
|
|
2208
|
+
};
|
|
2209
|
+
c = At(v, V), v.style.userSelect = "", x.style.userSelect = "", p(), d = new MutationObserver(p), d.observe(v, {
|
|
2210
|
+
childList: !0,
|
|
2211
|
+
subtree: !0,
|
|
2212
|
+
attributes: !0,
|
|
2213
|
+
attributeFilter: ["draggable", "contenteditable"]
|
|
2214
|
+
}), v.addEventListener("panzoomchange", m), x.addEventListener("wheel", g, { passive: !1 }), window.addEventListener("keydown", f), window.addEventListener("keyup", u), r.fitOnMount && D();
|
|
2215
|
+
}), Et(() => {
|
|
2216
|
+
d == null || d.disconnect(), d = null;
|
|
2217
|
+
const v = a.value, x = o.value;
|
|
2218
|
+
v == null || v.removeEventListener("panzoomchange", m), x == null || x.removeEventListener("wheel", g), window.removeEventListener("keydown", f), window.removeEventListener("keyup", u), c == null || c.resetStyle(), c == null || c.destroy(), c = null;
|
|
2219
|
+
}), (v, x) => (A(), R("div", {
|
|
2220
|
+
ref_key: "viewport",
|
|
2221
|
+
ref: o,
|
|
2222
|
+
class: ae(["paper-viewport", { "is-space-pan": b.value }])
|
|
2223
|
+
}, [
|
|
2224
|
+
O("div", {
|
|
2225
|
+
ref_key: "scaler",
|
|
2226
|
+
ref: a,
|
|
2227
|
+
class: "paper-viewport__scaler"
|
|
2228
|
+
}, [
|
|
2229
|
+
Tt(v.$slots, "default", {}, void 0, !0)
|
|
2230
|
+
], 512),
|
|
2231
|
+
O("div", Gr, [
|
|
2232
|
+
O("button", {
|
|
2233
|
+
type: "button",
|
|
2234
|
+
class: "paper-viewport__btn",
|
|
2235
|
+
title: "缩小",
|
|
2236
|
+
onClick: $
|
|
2237
|
+
}, " − "),
|
|
2238
|
+
O("span", zr, G(h.value), 1),
|
|
2239
|
+
O("button", {
|
|
2240
|
+
type: "button",
|
|
2241
|
+
class: "paper-viewport__btn",
|
|
2242
|
+
title: "放大",
|
|
2243
|
+
onClick: E
|
|
2244
|
+
}, " + "),
|
|
2245
|
+
O("button", {
|
|
2246
|
+
type: "button",
|
|
2247
|
+
class: "paper-viewport__btn paper-viewport__btn--text",
|
|
2248
|
+
title: "适应宽度",
|
|
2249
|
+
onClick: D
|
|
2250
|
+
}, " 适应 "),
|
|
2251
|
+
O("button", {
|
|
2252
|
+
type: "button",
|
|
2253
|
+
class: "paper-viewport__btn paper-viewport__btn--text",
|
|
2254
|
+
title: "重置为 100%",
|
|
2255
|
+
onClick: I
|
|
2256
|
+
}, " 重置 ")
|
|
2257
|
+
])
|
|
2258
|
+
], 2));
|
|
2259
|
+
}
|
|
2260
|
+
}), Kr = /* @__PURE__ */ Ie(Ur, [["__scopeId", "data-v-2b6e9ef6"]]), qr = {
|
|
2261
|
+
"toolbar.dirty": "● 未保存",
|
|
2262
|
+
"toolbar.saved": "已保存",
|
|
2263
|
+
"toolbar.newBlank": "新建空白",
|
|
2264
|
+
"toolbar.loadSamplePrefix": "载入",
|
|
2265
|
+
"toolbar.undo": "撤销",
|
|
2266
|
+
"toolbar.redo": "重做",
|
|
2267
|
+
"toolbar.module.template": "模板",
|
|
2268
|
+
"toolbar.saveTemplate": "保存模板",
|
|
2269
|
+
"toolbar.loadTemplate": "读取模板",
|
|
2270
|
+
"toolbar.exportTemplate": "导出文件",
|
|
2271
|
+
"toolbar.importTemplate": "导入文件",
|
|
2272
|
+
"toolbar.module.fillData": "填充数据",
|
|
2273
|
+
"toolbar.importFillData": "导入数据",
|
|
2274
|
+
"toolbar.exportFillData": "导出数据",
|
|
2275
|
+
"toolbar.loadFillData": "读取数据",
|
|
2276
|
+
"toolbar.saveFillData": "保存数据",
|
|
2277
|
+
"toolbar.preview": "预览",
|
|
2278
|
+
"toolbar.exitPreview": "退出预览",
|
|
2279
|
+
"toolbar.print": "打印",
|
|
2280
|
+
"toolbar.help": "帮助",
|
|
2281
|
+
"toolbar.importFillDataTip": "选择填写数据 JSON 文件并进入预览态",
|
|
2282
|
+
"toolbar.exportFillDataTip": "导出表单当前的字段与值 JSON(设计态 / 预览态均可,无字段则为空对象)",
|
|
2283
|
+
"toolbar.loadFillDataTip": "读取本地已保存的填写数据并进入预览态",
|
|
2284
|
+
"toolbar.saveFillDataTip": "保存表单当前的字段与值到本机(设计态 / 预览态均可,无字段则为空对象)",
|
|
2285
|
+
"toolbar.previewTip": "查看表单的实际填写效果;预览中可直接输入内容,并可导出为填写数据",
|
|
2286
|
+
"toolbar.helpTip": "查看使用说明"
|
|
2287
|
+
}, jr = {
|
|
2288
|
+
"toolbar.dirty": "● Unsaved",
|
|
2289
|
+
"toolbar.saved": "Saved",
|
|
2290
|
+
"toolbar.newBlank": "New Blank",
|
|
2291
|
+
"toolbar.loadSamplePrefix": "Load ",
|
|
2292
|
+
"toolbar.undo": "Undo",
|
|
2293
|
+
"toolbar.redo": "Redo",
|
|
2294
|
+
"toolbar.module.template": "Template",
|
|
2295
|
+
"toolbar.saveTemplate": "Save Template",
|
|
2296
|
+
"toolbar.loadTemplate": "Load Template",
|
|
2297
|
+
"toolbar.exportTemplate": "Export File",
|
|
2298
|
+
"toolbar.importTemplate": "Import File",
|
|
2299
|
+
"toolbar.module.fillData": "Fill Data",
|
|
2300
|
+
"toolbar.importFillData": "Import Data",
|
|
2301
|
+
"toolbar.exportFillData": "Export Data",
|
|
2302
|
+
"toolbar.loadFillData": "Load Data",
|
|
2303
|
+
"toolbar.saveFillData": "Save Data",
|
|
2304
|
+
"toolbar.preview": "Preview",
|
|
2305
|
+
"toolbar.exitPreview": "Exit Preview",
|
|
2306
|
+
"toolbar.print": "Print",
|
|
2307
|
+
"toolbar.help": "Help",
|
|
2308
|
+
"toolbar.importFillDataTip": "Choose a fill-data JSON file and enter preview",
|
|
2309
|
+
"toolbar.exportFillDataTip": "Export the form's field-value JSON (design or preview; empty object when no fields)",
|
|
2310
|
+
"toolbar.loadFillDataTip": "Load locally saved fill data and enter preview",
|
|
2311
|
+
"toolbar.saveFillDataTip": "Save the form's field-value JSON to this browser (design or preview; empty object when no fields)",
|
|
2312
|
+
"toolbar.previewTip": "See the actual filled form; you can input in preview and export as fill data",
|
|
2313
|
+
"toolbar.helpTip": "View usage instructions"
|
|
2314
|
+
}, Jr = ["zh-CN", "en"], Oe = "zh-CN", $e = {
|
|
2315
|
+
"zh-CN": qr,
|
|
2316
|
+
en: jr
|
|
2317
|
+
}, ht = X(Oe);
|
|
2318
|
+
function ui(e) {
|
|
2319
|
+
Jr.includes(e) && (ht.value = e);
|
|
2320
|
+
}
|
|
2321
|
+
function Yr(e, t, n) {
|
|
2322
|
+
let i = ($e[e] ?? $e[Oe])[t];
|
|
2323
|
+
return i == null && (i = $e[Oe][t] ?? t), i;
|
|
2324
|
+
}
|
|
2325
|
+
function di(e, t, n) {
|
|
2326
|
+
return Yr(n ?? ht.value, e);
|
|
2327
|
+
}
|
|
2328
|
+
const Xr = ".grid-form-paper", Zr = ".grid-form-canvas", gt = ".layout-html", De = "data-v2-print-scope";
|
|
2329
|
+
let Qr = 0;
|
|
2330
|
+
function en(e) {
|
|
2331
|
+
const t = [];
|
|
2332
|
+
e.querySelectorAll(gt).forEach((r) => {
|
|
2333
|
+
const i = r.shadowRoot;
|
|
2334
|
+
if (!i) return;
|
|
2335
|
+
const o = [];
|
|
2336
|
+
if (Array.from(i.childNodes).forEach((l) => {
|
|
2337
|
+
l.nodeType === Node.ELEMENT_NODE && l.tagName === "STYLE" || o.push(l);
|
|
2338
|
+
}), !o.length) return;
|
|
2339
|
+
o.forEach((l) => r.appendChild(l));
|
|
2340
|
+
const a = [];
|
|
2341
|
+
r.querySelectorAll("input, textarea").forEach((l) => {
|
|
2342
|
+
const c = l instanceof HTMLInputElement && (l.type === "checkbox" || l.type === "radio"), d = c ? "checked" : "value";
|
|
2343
|
+
a.push({ el: l, attr: d, prev: l.getAttribute(d) }), c ? l.checked ? l.setAttribute("checked", "") : l.removeAttribute("checked") : l.setAttribute("value", l.value);
|
|
2344
|
+
}), t.push({ host: r, nodes: o, controls: a });
|
|
2345
|
+
});
|
|
2346
|
+
let n = !1;
|
|
2347
|
+
return () => {
|
|
2348
|
+
n || (n = !0, t.forEach(({ host: r, nodes: i, controls: o }) => {
|
|
2349
|
+
o.forEach(({ el: l, attr: c, prev: d }) => {
|
|
2350
|
+
d === null ? l.removeAttribute(c) : l.setAttribute(c, d);
|
|
2351
|
+
});
|
|
2352
|
+
const a = r.shadowRoot;
|
|
2353
|
+
a && i.forEach((l) => a.appendChild(l));
|
|
2354
|
+
}));
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
function tn(e) {
|
|
2358
|
+
const t = [];
|
|
2359
|
+
return e.querySelectorAll(gt).forEach((n) => {
|
|
2360
|
+
var r;
|
|
2361
|
+
(r = n.shadowRoot) == null || r.querySelectorAll("style").forEach((i) => {
|
|
2362
|
+
const o = i.textContent ?? "";
|
|
2363
|
+
o.trim() && t.push(o);
|
|
2364
|
+
});
|
|
2365
|
+
}), t.length ? `<style>${t.join(`
|
|
2366
|
+
`)}</style>` : "";
|
|
2367
|
+
}
|
|
2368
|
+
function rn(e = {}) {
|
|
2369
|
+
if (typeof document > "u") return !1;
|
|
2370
|
+
const t = e.root !== void 0 ? e.root : document.querySelector(Zr);
|
|
2371
|
+
if (!t) return !1;
|
|
2372
|
+
const n = Array.from(t.querySelectorAll(Xr));
|
|
2373
|
+
if (!n.length) return !1;
|
|
2374
|
+
const r = String(Qr++);
|
|
2375
|
+
n.forEach((a) => a.setAttribute(De, r));
|
|
2376
|
+
const i = tn(t), o = en(t);
|
|
2377
|
+
try {
|
|
2378
|
+
new Rt({
|
|
2379
|
+
el: `[${De}="${r}"]`,
|
|
2380
|
+
popTitle: e.title ?? document.title,
|
|
2381
|
+
extraHead: i,
|
|
2382
|
+
// 刻意不传 paperSize / orientation / customSize —— 契约 2。
|
|
2383
|
+
closeCallback: o
|
|
2384
|
+
});
|
|
2385
|
+
} catch {
|
|
2386
|
+
return !1;
|
|
2387
|
+
} finally {
|
|
2388
|
+
o(), n.forEach((a) => a.removeAttribute(De));
|
|
2389
|
+
}
|
|
2390
|
+
return !0;
|
|
2391
|
+
}
|
|
2392
|
+
function fi(e, t = {}) {
|
|
2393
|
+
const { baseData: n, maskHidden: r } = t, i = {}, a = [
|
|
2394
|
+
...e instanceof Element && e.matches("[data-field]") ? [e] : [],
|
|
2395
|
+
...e.querySelectorAll("[data-field]")
|
|
2396
|
+
];
|
|
2397
|
+
for (const c of Array.from(a)) {
|
|
2398
|
+
const d = c.getAttribute("data-field");
|
|
2399
|
+
if (!d) continue;
|
|
2400
|
+
if (c.closest(".layout-p--hidden")) {
|
|
2401
|
+
if (r)
|
|
2402
|
+
i[d] = "***";
|
|
2403
|
+
else {
|
|
2404
|
+
const p = n == null ? void 0 : n[d];
|
|
2405
|
+
p != null && (i[d] = String(p));
|
|
2406
|
+
}
|
|
2407
|
+
continue;
|
|
2408
|
+
}
|
|
2409
|
+
if (c instanceof HTMLImageElement) {
|
|
2410
|
+
i[d] = c.getAttribute("src") ?? "";
|
|
2411
|
+
continue;
|
|
2412
|
+
}
|
|
2413
|
+
const h = c.innerText;
|
|
2414
|
+
i[d] = typeof h == "string" ? h : c.textContent ?? "";
|
|
2415
|
+
}
|
|
2416
|
+
const l = [
|
|
2417
|
+
...e instanceof HTMLElement && e.matches(".layout-html") ? [e] : [],
|
|
2418
|
+
...e.querySelectorAll(".layout-html")
|
|
2419
|
+
];
|
|
2420
|
+
for (const c of Array.from(l)) {
|
|
2421
|
+
const d = c.shadowRoot;
|
|
2422
|
+
d && (d.querySelectorAll("[data-bind]").forEach((h) => {
|
|
2423
|
+
const p = h.getAttribute("data-bind");
|
|
2424
|
+
if (p) {
|
|
2425
|
+
if (h.hasAttribute("data-masked")) {
|
|
2426
|
+
if (r)
|
|
2427
|
+
i[p] = "***";
|
|
2428
|
+
else {
|
|
2429
|
+
const b = n == null ? void 0 : n[p];
|
|
2430
|
+
b != null && (i[p] = String(b));
|
|
2431
|
+
}
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
if (h instanceof HTMLInputElement) {
|
|
2435
|
+
i[p] = h.value;
|
|
2436
|
+
return;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}), d.querySelectorAll("[data-field]").forEach((h) => {
|
|
2440
|
+
const p = h.getAttribute("data-field");
|
|
2441
|
+
if (!p) return;
|
|
2442
|
+
if (h.hasAttribute("data-masked")) {
|
|
2443
|
+
if (r)
|
|
2444
|
+
i[p] = "***";
|
|
2445
|
+
else {
|
|
2446
|
+
const y = n == null ? void 0 : n[p];
|
|
2447
|
+
y != null && (i[p] = String(y));
|
|
2448
|
+
}
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
const b = h.innerText;
|
|
2452
|
+
i[p] = typeof b == "string" ? b : h.textContent ?? "";
|
|
2453
|
+
}));
|
|
2454
|
+
}
|
|
2455
|
+
return i;
|
|
2456
|
+
}
|
|
2457
|
+
const tt = "preview", mi = /* @__PURE__ */ Te({
|
|
2458
|
+
__name: "FormRenderer",
|
|
2459
|
+
props: {
|
|
2460
|
+
schema: {},
|
|
2461
|
+
data: {},
|
|
2462
|
+
options: { default: () => ({}) }
|
|
2463
|
+
},
|
|
2464
|
+
emits: ["field-change", "update:data", "action"],
|
|
2465
|
+
setup(e, { expose: t, emit: n }) {
|
|
2466
|
+
const r = e, i = n, o = X({ ...r.data ?? {} });
|
|
2467
|
+
ge(
|
|
2468
|
+
() => r.data,
|
|
2469
|
+
(y) => {
|
|
2470
|
+
o.value = { ...y ?? {} };
|
|
2471
|
+
}
|
|
2472
|
+
);
|
|
2473
|
+
const a = K(() => {
|
|
2474
|
+
var y;
|
|
2475
|
+
return ((y = r.options) == null ? void 0 : y.readonly) ?? !0;
|
|
2476
|
+
});
|
|
2477
|
+
function l(y, M) {
|
|
2478
|
+
o.value = { ...o.value, [y]: M }, i("update:data", o.value), i("field-change", y, M);
|
|
2479
|
+
}
|
|
2480
|
+
function c(y) {
|
|
2481
|
+
i("action", y);
|
|
2482
|
+
}
|
|
2483
|
+
const d = X(null);
|
|
2484
|
+
function h() {
|
|
2485
|
+
var M;
|
|
2486
|
+
const y = (M = d.value) == null ? void 0 : M.$el;
|
|
2487
|
+
return rn({ root: y instanceof HTMLElement ? y : null });
|
|
2488
|
+
}
|
|
2489
|
+
function p() {
|
|
2490
|
+
return { ...o.value };
|
|
2491
|
+
}
|
|
2492
|
+
function b() {
|
|
2493
|
+
var y;
|
|
2494
|
+
return ur((y = r.options) == null ? void 0 : y.rules, o.value);
|
|
2495
|
+
}
|
|
2496
|
+
return t({ print: h, getFormData: p, validate: b }), (y, M) => {
|
|
2497
|
+
var w, f, u, m;
|
|
2498
|
+
return (w = e.options) != null && w.zoom ? (A(), ye(Kr, {
|
|
2499
|
+
key: 0,
|
|
2500
|
+
"fit-on-mount": ((f = e.options) == null ? void 0 : f.fitOnMount) ?? !1
|
|
2501
|
+
}, {
|
|
2502
|
+
default: St(() => {
|
|
2503
|
+
var g;
|
|
2504
|
+
return [
|
|
2505
|
+
Mt(et, {
|
|
2506
|
+
ref_key: "rendererRef",
|
|
2507
|
+
ref: d,
|
|
2508
|
+
schema: e.schema,
|
|
2509
|
+
mode: tt,
|
|
2510
|
+
data: o.value,
|
|
2511
|
+
readonly: a.value,
|
|
2512
|
+
"field-permissions": (g = e.options) == null ? void 0 : g.fieldPermissions,
|
|
2513
|
+
bare: !0,
|
|
2514
|
+
onFieldChange: l,
|
|
2515
|
+
onActionTrigger: c
|
|
2516
|
+
}, null, 8, ["schema", "data", "readonly", "field-permissions"])
|
|
2517
|
+
];
|
|
2518
|
+
}),
|
|
2519
|
+
_: 1
|
|
2520
|
+
}, 8, ["fit-on-mount"])) : (A(), ye(et, {
|
|
2521
|
+
key: 1,
|
|
2522
|
+
ref_key: "rendererRef",
|
|
2523
|
+
ref: d,
|
|
2524
|
+
schema: e.schema,
|
|
2525
|
+
mode: tt,
|
|
2526
|
+
data: o.value,
|
|
2527
|
+
readonly: a.value,
|
|
2528
|
+
"field-permissions": (u = e.options) == null ? void 0 : u.fieldPermissions,
|
|
2529
|
+
bare: (m = e.options) == null ? void 0 : m.bare,
|
|
2530
|
+
onFieldChange: l,
|
|
2531
|
+
onActionTrigger: c
|
|
2532
|
+
}, null, 8, ["schema", "data", "readonly", "field-permissions", "bare"]));
|
|
2533
|
+
};
|
|
2534
|
+
}
|
|
2535
|
+
});
|
|
2536
|
+
export {
|
|
2537
|
+
ee as $,
|
|
2538
|
+
Vn as A,
|
|
2539
|
+
Cn as B,
|
|
2540
|
+
Ln as C,
|
|
2541
|
+
Nt as D,
|
|
2542
|
+
zt as E,
|
|
2543
|
+
Wn as F,
|
|
2544
|
+
et as G,
|
|
2545
|
+
Xn as H,
|
|
2546
|
+
Zn as I,
|
|
2547
|
+
Qn as J,
|
|
2548
|
+
ei as K,
|
|
2549
|
+
si as L,
|
|
2550
|
+
ti as M,
|
|
2551
|
+
li as N,
|
|
2552
|
+
ui as O,
|
|
2553
|
+
ci as P,
|
|
2554
|
+
ze as Q,
|
|
2555
|
+
Cr as R,
|
|
2556
|
+
Kr as S,
|
|
2557
|
+
rn as T,
|
|
2558
|
+
Oe as U,
|
|
2559
|
+
mi as V,
|
|
2560
|
+
Mr as W,
|
|
2561
|
+
Ft as X,
|
|
2562
|
+
Xr as Y,
|
|
2563
|
+
Zr as Z,
|
|
2564
|
+
Ie as _,
|
|
2565
|
+
Hn as a,
|
|
2566
|
+
Bn as a0,
|
|
2567
|
+
hn as a1,
|
|
2568
|
+
dt as a2,
|
|
2569
|
+
ut as a3,
|
|
2570
|
+
Ye as a4,
|
|
2571
|
+
oi as a5,
|
|
2572
|
+
Gn as a6,
|
|
2573
|
+
Ue as a7,
|
|
2574
|
+
ke as a8,
|
|
2575
|
+
P as a9,
|
|
2576
|
+
Kn as aA,
|
|
2577
|
+
_e as aB,
|
|
2578
|
+
vn as aC,
|
|
2579
|
+
bn as aD,
|
|
2580
|
+
En as aE,
|
|
2581
|
+
wn as aF,
|
|
2582
|
+
yn as aG,
|
|
2583
|
+
$n as aH,
|
|
2584
|
+
ai as aa,
|
|
2585
|
+
ur as ab,
|
|
2586
|
+
mn as ac,
|
|
2587
|
+
dn as ad,
|
|
2588
|
+
rt as ae,
|
|
2589
|
+
fn as af,
|
|
2590
|
+
Pe as ag,
|
|
2591
|
+
Ne as ah,
|
|
2592
|
+
jt as ai,
|
|
2593
|
+
_n as aj,
|
|
2594
|
+
Un as ak,
|
|
2595
|
+
Dn as al,
|
|
2596
|
+
Pn as am,
|
|
2597
|
+
st as an,
|
|
2598
|
+
mt as ao,
|
|
2599
|
+
ii as ap,
|
|
2600
|
+
Nr as aq,
|
|
2601
|
+
zn as ar,
|
|
2602
|
+
Zt as as,
|
|
2603
|
+
lt as at,
|
|
2604
|
+
Re as au,
|
|
2605
|
+
ct as av,
|
|
2606
|
+
Be as aw,
|
|
2607
|
+
we as ax,
|
|
2608
|
+
Rr as ay,
|
|
2609
|
+
Jn as az,
|
|
2610
|
+
se as b,
|
|
2611
|
+
fi as c,
|
|
2612
|
+
In as d,
|
|
2613
|
+
Yn as e,
|
|
2614
|
+
On as f,
|
|
2615
|
+
Fn as g,
|
|
2616
|
+
Sn as h,
|
|
2617
|
+
un as i,
|
|
2618
|
+
Tn as j,
|
|
2619
|
+
jn as k,
|
|
2620
|
+
Nn as l,
|
|
2621
|
+
Rn as m,
|
|
2622
|
+
An as n,
|
|
2623
|
+
xn as o,
|
|
2624
|
+
ni as p,
|
|
2625
|
+
Mn as q,
|
|
2626
|
+
sr as r,
|
|
2627
|
+
ri as s,
|
|
2628
|
+
di as t,
|
|
2629
|
+
kn as u,
|
|
2630
|
+
qn as v,
|
|
2631
|
+
pn as w,
|
|
2632
|
+
gn as x,
|
|
2633
|
+
k as y,
|
|
2634
|
+
Jt as z
|
|
2635
|
+
};
|