@worm-vue3-print/core 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/browser/index.cjs +1920 -0
- package/dist/browser/index.d.cts +23 -0
- package/dist/browser/index.d.ts +23 -0
- package/dist/browser/index.js +170 -0
- package/dist/chunk-HLCZHPUF.js +31 -0
- package/dist/chunk-JZIVNXZ7.js +1777 -0
- package/dist/designer/index.cjs +2419 -0
- package/dist/designer/index.d.cts +652 -0
- package/dist/designer/index.d.ts +652 -0
- package/dist/designer/index.js +1620 -0
- package/dist/index.d.cts +4 -184
- package/dist/index.d.ts +4 -184
- package/dist/index.js +36 -1764
- package/dist/types-BGBAbQD5.d.cts +184 -0
- package/dist/types-BGBAbQD5.d.ts +184 -0
- package/package.json +21 -4
|
@@ -0,0 +1,2419 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/designer/index.ts
|
|
21
|
+
var designer_exports = {};
|
|
22
|
+
__export(designer_exports, {
|
|
23
|
+
DEFAULT_DEMO_DATA: () => DEFAULT_DEMO_DATA,
|
|
24
|
+
ELEMENT_BINDING_REGISTRY: () => ELEMENT_BINDING_REGISTRY,
|
|
25
|
+
EXTENDED_FUNCTIONS: () => EXTENDED_FUNCTIONS,
|
|
26
|
+
FIT_SCALE_MIN_PERCENT: () => FIT_SCALE_MIN_PERCENT,
|
|
27
|
+
GHOST_BORDER_CSS: () => GHOST_BORDER_CSS,
|
|
28
|
+
MIN_COL_WIDTH_MM: () => MIN_COL_WIDTH_MM,
|
|
29
|
+
MIN_SCALE_PERCENT: () => MIN_SCALE_PERCENT,
|
|
30
|
+
PAPER_PRESETS: () => PAPER_PRESETS,
|
|
31
|
+
PRESET_COLORS: () => PRESET_COLORS,
|
|
32
|
+
PROPERTY_REGISTRY: () => PROPERTY_REGISTRY,
|
|
33
|
+
RESIZE_POINTS: () => RESIZE_POINTS,
|
|
34
|
+
RULER_THICKNESS: () => RULER_THICKNESS,
|
|
35
|
+
ZONE_ALLOWED_TYPES: () => ZONE_ALLOWED_TYPES,
|
|
36
|
+
applyBorderPreset: () => applyBorderPreset,
|
|
37
|
+
buildRulerTicks: () => buildRulerTicks,
|
|
38
|
+
calcResizeRect: () => calcResizeRect,
|
|
39
|
+
canMergeReason: () => canMergeReason,
|
|
40
|
+
chooseMajorStepMM: () => chooseMajorStepMM,
|
|
41
|
+
clampResizedColumnWidth: () => clampResizedColumnWidth,
|
|
42
|
+
clampScalePercent: () => clampScalePercent,
|
|
43
|
+
clampToZone: () => clampToZone,
|
|
44
|
+
computeAdsorb: () => computeAdsorb,
|
|
45
|
+
computeFitScale: () => computeFitScale,
|
|
46
|
+
createCell: () => createCell,
|
|
47
|
+
createDefaultOptions: () => createDefaultOptions,
|
|
48
|
+
createDefaultTable: () => createDefaultTable,
|
|
49
|
+
createFieldElement: () => createFieldElement,
|
|
50
|
+
createRuntimeElement: () => createRuntimeElement,
|
|
51
|
+
deleteCol: () => deleteCol,
|
|
52
|
+
deleteRow: () => deleteRow,
|
|
53
|
+
engine: () => engine2,
|
|
54
|
+
evaluateTemplate: () => evaluateTemplate2,
|
|
55
|
+
filterGroups: () => filterGroups,
|
|
56
|
+
finalizeElementZone: () => finalizeElementZone,
|
|
57
|
+
findMainCell: () => findMainCell,
|
|
58
|
+
generateGroupId: () => generateGroupId,
|
|
59
|
+
generateId: () => generateId,
|
|
60
|
+
getDemoData: () => getDemoData,
|
|
61
|
+
getElementBindings: () => getElementBindings,
|
|
62
|
+
getPaperDimensions: () => getPaperDimensions,
|
|
63
|
+
getPaperSizeMM: () => getPaperSizeMM,
|
|
64
|
+
getSpanRect: () => getSpanRect,
|
|
65
|
+
getTableCellBindings: () => getTableCellBindings,
|
|
66
|
+
getZoneRects: () => getZoneRects,
|
|
67
|
+
groupFields: () => groupFields,
|
|
68
|
+
insertCol: () => insertCol,
|
|
69
|
+
insertRow: () => insertRow,
|
|
70
|
+
matchKeywords: () => matchKeywords,
|
|
71
|
+
mergeCells: () => mergeCells,
|
|
72
|
+
minorStepMM: () => minorStepMM,
|
|
73
|
+
mmToPx: () => mmToPx,
|
|
74
|
+
nextWheelScale: () => nextWheelScale,
|
|
75
|
+
normalizeSelection: () => normalizeSelection,
|
|
76
|
+
normalizeTemplateUnits: () => normalizeTemplateUnits,
|
|
77
|
+
ptToMm: () => ptToMm,
|
|
78
|
+
pxToMm: () => pxToMm,
|
|
79
|
+
resolveBarcodeDesignValue: () => resolveBarcodeDesignValue,
|
|
80
|
+
resolveCellBorderCss: () => resolveCellBorderCss,
|
|
81
|
+
resolveTextBinding: () => resolveTextBinding,
|
|
82
|
+
safeEval: () => safeEval2,
|
|
83
|
+
searchProperties: () => searchProperties,
|
|
84
|
+
setRowType: () => setRowType,
|
|
85
|
+
splitCells: () => splitCells,
|
|
86
|
+
syncTableElementSize: () => syncTableElementSize,
|
|
87
|
+
useAlign: () => useAlign,
|
|
88
|
+
useBindingDisplay: () => useBindingDisplay,
|
|
89
|
+
useGroup: () => useGroup,
|
|
90
|
+
useKeyboard: () => useKeyboard,
|
|
91
|
+
useResize: () => useResize,
|
|
92
|
+
zoneFromPaperPoint: () => zoneFromPaperPoint
|
|
93
|
+
});
|
|
94
|
+
module.exports = __toCommonJS(designer_exports);
|
|
95
|
+
|
|
96
|
+
// src/designer/utils/units.ts
|
|
97
|
+
function ptToMm(pt) {
|
|
98
|
+
return pt / 2.83464566929;
|
|
99
|
+
}
|
|
100
|
+
function pxToMm(px) {
|
|
101
|
+
return px * (25.4 / 96);
|
|
102
|
+
}
|
|
103
|
+
function mmToPx(mm2) {
|
|
104
|
+
return mm2 * (96 / 25.4);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/designer/utils/scale.ts
|
|
108
|
+
var MIN_SCALE_PERCENT = 25;
|
|
109
|
+
var FIT_SCALE_MIN_PERCENT = 5;
|
|
110
|
+
function clampScalePercent(percent) {
|
|
111
|
+
return Math.max(MIN_SCALE_PERCENT, percent);
|
|
112
|
+
}
|
|
113
|
+
function nextWheelScale(percent, direction, factor = 1.1) {
|
|
114
|
+
const next = direction > 0 ? percent * factor : percent / factor;
|
|
115
|
+
return clampScalePercent(Math.round(next));
|
|
116
|
+
}
|
|
117
|
+
function computeFitScale(containerW, containerH, paperW, paperH, ratio = 0.9) {
|
|
118
|
+
if (paperW <= 0 || paperH <= 0) return 100;
|
|
119
|
+
const fit = Math.min(containerW / paperW, containerH / paperH) * ratio;
|
|
120
|
+
const pct = Math.round(fit * 100);
|
|
121
|
+
return Math.max(FIT_SCALE_MIN_PERCENT, pct);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/designer/utils/migrate.ts
|
|
125
|
+
var PT_KEYS = ["left", "top", "width", "height"];
|
|
126
|
+
function convertElement(el) {
|
|
127
|
+
const options = { ...el.options };
|
|
128
|
+
for (const key of PT_KEYS) {
|
|
129
|
+
const v = options[key];
|
|
130
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
131
|
+
;
|
|
132
|
+
options[key] = round2(ptToMm(v));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { ...el, options };
|
|
136
|
+
}
|
|
137
|
+
function round2(n) {
|
|
138
|
+
return Math.round(n * 100) / 100;
|
|
139
|
+
}
|
|
140
|
+
function normalizeTemplateUnits(data) {
|
|
141
|
+
if (data.unit === "mm") return data;
|
|
142
|
+
const convert = (els) => els?.map(convertElement) ?? [];
|
|
143
|
+
return {
|
|
144
|
+
...data,
|
|
145
|
+
unit: "mm",
|
|
146
|
+
elements: convert(data.elements),
|
|
147
|
+
header: data.header ? { ...data.header, elements: convert(data.header.elements) } : data.header,
|
|
148
|
+
footer: data.footer ? { ...data.footer, elements: convert(data.footer.elements) } : data.footer,
|
|
149
|
+
firstPageOverlay: data.firstPageOverlay ? { ...data.firstPageOverlay, elements: convert(data.firstPageOverlay.elements) } : data.firstPageOverlay
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/designer/utils/default-config.ts
|
|
154
|
+
var PAPER_PRESETS = {
|
|
155
|
+
A4: { width: 210, height: 297 },
|
|
156
|
+
A3: { width: 297, height: 420 },
|
|
157
|
+
A5: { width: 148, height: 210 },
|
|
158
|
+
Letter: { width: 216, height: 279 },
|
|
159
|
+
Legal: { width: 216, height: 356 }
|
|
160
|
+
};
|
|
161
|
+
function getPaperDimensions(t) {
|
|
162
|
+
let base;
|
|
163
|
+
if (t.paperSize === "CUSTOM") {
|
|
164
|
+
base = {
|
|
165
|
+
width: t.customWidth ?? 210,
|
|
166
|
+
height: t.customHeight ?? 297
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
base = PAPER_PRESETS[t.paperSize] || PAPER_PRESETS["A4"];
|
|
170
|
+
}
|
|
171
|
+
return t.orientation === "landscape" ? { width: base.height, height: base.width } : base;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/designer/utils/table-matrix.ts
|
|
175
|
+
function createCellIdGenerator() {
|
|
176
|
+
let seq = 0;
|
|
177
|
+
return function genCellId2() {
|
|
178
|
+
seq += 1;
|
|
179
|
+
return `cell-${Date.now().toString(36)}-${seq}`;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function createRowIdGenerator() {
|
|
183
|
+
let seq = 0;
|
|
184
|
+
return function genRowId2() {
|
|
185
|
+
seq += 1;
|
|
186
|
+
return `row-${Date.now().toString(36)}-${seq}`;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
var genCellId = createCellIdGenerator();
|
|
190
|
+
var genRowId = createRowIdGenerator();
|
|
191
|
+
var DEFAULT_BORDER = { width: 0.75, style: "solid", color: "#333333" };
|
|
192
|
+
function deepClone(v) {
|
|
193
|
+
return JSON.parse(JSON.stringify(v));
|
|
194
|
+
}
|
|
195
|
+
function createCell(partial) {
|
|
196
|
+
return {
|
|
197
|
+
id: genCellId(),
|
|
198
|
+
borders: {
|
|
199
|
+
top: { ...DEFAULT_BORDER },
|
|
200
|
+
right: { ...DEFAULT_BORDER },
|
|
201
|
+
bottom: { ...DEFAULT_BORDER },
|
|
202
|
+
left: { ...DEFAULT_BORDER }
|
|
203
|
+
},
|
|
204
|
+
...partial
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function createDefaultTable() {
|
|
208
|
+
const colWidths = [50, 50, 50];
|
|
209
|
+
const mk = (type, repeat) => ({
|
|
210
|
+
id: genRowId(),
|
|
211
|
+
type,
|
|
212
|
+
height: 8,
|
|
213
|
+
...repeat !== void 0 ? { repeatOnPage: repeat } : {},
|
|
214
|
+
cells: colWidths.map(() => createCell())
|
|
215
|
+
});
|
|
216
|
+
const header = mk("header", true);
|
|
217
|
+
header.cells.forEach((c, i) => {
|
|
218
|
+
c.formatter = `\u5217${i + 1}`;
|
|
219
|
+
c.align = "center";
|
|
220
|
+
c.fontWeight = "bold";
|
|
221
|
+
});
|
|
222
|
+
return { rows: [header, mk("data"), mk("subtotal"), mk("summary")], colWidths };
|
|
223
|
+
}
|
|
224
|
+
function findMainCell(rows, r, c) {
|
|
225
|
+
if (!rows[r].cells[c].merged) {
|
|
226
|
+
return { r, c };
|
|
227
|
+
}
|
|
228
|
+
for (let ri = r; ri >= 0; ri--) {
|
|
229
|
+
for (let ci = c; ci >= 0; ci--) {
|
|
230
|
+
const cell = rows[ri].cells[ci];
|
|
231
|
+
if (cell.merged) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const rs = cell.rowspan ?? 1;
|
|
235
|
+
const cs = cell.colspan ?? 1;
|
|
236
|
+
if (ri + rs - 1 >= r && ci + cs - 1 >= c) {
|
|
237
|
+
return { r: ri, c: ci };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return { r, c };
|
|
242
|
+
}
|
|
243
|
+
function getSpanRect(rows, r, c) {
|
|
244
|
+
const main = findMainCell(rows, r, c);
|
|
245
|
+
const cell = rows[main.r].cells[main.c];
|
|
246
|
+
return {
|
|
247
|
+
r1: main.r,
|
|
248
|
+
c1: main.c,
|
|
249
|
+
r2: main.r + (cell.rowspan ?? 1) - 1,
|
|
250
|
+
c2: main.c + (cell.colspan ?? 1) - 1
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function normalizeSelection(rows, a, b) {
|
|
254
|
+
let rect = {
|
|
255
|
+
r1: Math.min(a.r, b.r),
|
|
256
|
+
c1: Math.min(a.c, b.c),
|
|
257
|
+
r2: Math.max(a.r, b.r),
|
|
258
|
+
c2: Math.max(a.c, b.c)
|
|
259
|
+
};
|
|
260
|
+
for (; ; ) {
|
|
261
|
+
let changed = false;
|
|
262
|
+
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
263
|
+
for (let c = rect.c1; c <= rect.c2; c++) {
|
|
264
|
+
const span = getSpanRect(rows, r, c);
|
|
265
|
+
const merged = {
|
|
266
|
+
r1: Math.min(rect.r1, span.r1),
|
|
267
|
+
c1: Math.min(rect.c1, span.c1),
|
|
268
|
+
r2: Math.max(rect.r2, span.r2),
|
|
269
|
+
c2: Math.max(rect.c2, span.c2)
|
|
270
|
+
};
|
|
271
|
+
if (merged.r1 !== rect.r1 || merged.c1 !== rect.c1 || merged.r2 !== rect.r2 || merged.c2 !== rect.c2) {
|
|
272
|
+
rect = merged;
|
|
273
|
+
changed = true;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (!changed) {
|
|
278
|
+
return rect;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function canMergeReason(rows, rect) {
|
|
283
|
+
const cellCount = (rect.r2 - rect.r1 + 1) * (rect.c2 - rect.c1 + 1);
|
|
284
|
+
if (cellCount < 2) {
|
|
285
|
+
return "\u81F3\u5C11\u9009\u62E9 2 \u4E2A\u5355\u5143\u683C";
|
|
286
|
+
}
|
|
287
|
+
const types = /* @__PURE__ */ new Set();
|
|
288
|
+
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
289
|
+
types.add(rows[r].type);
|
|
290
|
+
}
|
|
291
|
+
if (types.size > 1) {
|
|
292
|
+
return "\u5408\u5E76\u533A\u57DF\u4E0D\u80FD\u8DE8\u8D8A\u4E0D\u540C\u7C7B\u578B\u7684\u884C";
|
|
293
|
+
}
|
|
294
|
+
const norm = normalizeSelection(rows, { r: rect.r1, c: rect.c1 }, { r: rect.r2, c: rect.c2 });
|
|
295
|
+
if (norm.r1 !== rect.r1 || norm.c1 !== rect.c1 || norm.r2 !== rect.r2 || norm.c2 !== rect.c2) {
|
|
296
|
+
return "\u9009\u533A\u4E0E\u5DF2\u6709\u5408\u5E76\u533A\u57DF\u90E8\u5206\u91CD\u53E0";
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
function mergeCells(rows, rect) {
|
|
301
|
+
const main = rows[rect.r1].cells[rect.c1];
|
|
302
|
+
const contents = [];
|
|
303
|
+
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
304
|
+
for (let c = rect.c1; c <= rect.c2; c++) {
|
|
305
|
+
const cell = rows[r].cells[c];
|
|
306
|
+
if (cell.formatter) {
|
|
307
|
+
contents.push(cell.formatter);
|
|
308
|
+
}
|
|
309
|
+
if (r === rect.r1 && c === rect.c1) {
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
cell.merged = true;
|
|
313
|
+
cell.rowspan = 1;
|
|
314
|
+
cell.colspan = 1;
|
|
315
|
+
cell.formatter = "";
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
main.rowspan = rect.r2 - rect.r1 + 1;
|
|
319
|
+
main.colspan = rect.c2 - rect.c1 + 1;
|
|
320
|
+
main.formatter = contents.join(" ");
|
|
321
|
+
}
|
|
322
|
+
function splitCells(rows, rect) {
|
|
323
|
+
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
324
|
+
for (let c = rect.c1; c <= rect.c2; c++) {
|
|
325
|
+
const cell = rows[r].cells[c];
|
|
326
|
+
if (!cell.merged && ((cell.rowspan ?? 1) > 1 || (cell.colspan ?? 1) > 1)) {
|
|
327
|
+
const span = getSpanRect(rows, r, c);
|
|
328
|
+
const styleSrc = cell;
|
|
329
|
+
for (let sr = span.r1; sr <= span.r2; sr++) {
|
|
330
|
+
for (let sc = span.c1; sc <= span.c2; sc++) {
|
|
331
|
+
const t = rows[sr].cells[sc];
|
|
332
|
+
t.merged = false;
|
|
333
|
+
t.rowspan = 1;
|
|
334
|
+
t.colspan = 1;
|
|
335
|
+
copyCellStyle(styleSrc, t);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
cell.rowspan = 1;
|
|
339
|
+
cell.colspan = 1;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function copyCellStyle(src, dst) {
|
|
345
|
+
if (src === dst) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
dst.align = src.align;
|
|
349
|
+
dst.valign = src.valign;
|
|
350
|
+
dst.fontSize = src.fontSize;
|
|
351
|
+
dst.fontWeight = src.fontWeight;
|
|
352
|
+
dst.color = src.color;
|
|
353
|
+
dst.backgroundColor = src.backgroundColor;
|
|
354
|
+
dst.borders = src.borders ? deepClone(src.borders) : void 0;
|
|
355
|
+
dst.padding = src.padding;
|
|
356
|
+
dst.wordWrap = src.wordWrap;
|
|
357
|
+
}
|
|
358
|
+
function insertRow(rows, index, position) {
|
|
359
|
+
const insertAt = position === "above" ? index : index + 1;
|
|
360
|
+
const ref = rows[index];
|
|
361
|
+
const colCount = ref.cells.length;
|
|
362
|
+
const type = ref.type === "data" ? "header" : ref.type;
|
|
363
|
+
const newRow = {
|
|
364
|
+
id: `row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
365
|
+
type,
|
|
366
|
+
height: ref.height,
|
|
367
|
+
cells: Array.from({ length: colCount }, () => createCell())
|
|
368
|
+
};
|
|
369
|
+
for (let c = 0; c < colCount; c++) {
|
|
370
|
+
if (insertAt > 0 && insertAt < rows.length) {
|
|
371
|
+
const span = getSpanRect(rows, insertAt - 1, c);
|
|
372
|
+
if (span.r1 < insertAt && span.r2 >= insertAt) {
|
|
373
|
+
const main = rows[span.r1].cells[span.c1];
|
|
374
|
+
main.rowspan = (main.rowspan ?? 1) + 1;
|
|
375
|
+
newRow.cells[c].merged = true;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
rows.splice(insertAt, 0, newRow);
|
|
380
|
+
}
|
|
381
|
+
function deleteRow(rows, index) {
|
|
382
|
+
if (rows.length <= 1) {
|
|
383
|
+
return "\u4E0D\u80FD\u5220\u9664\u6700\u540E\u4E00\u884C";
|
|
384
|
+
}
|
|
385
|
+
const row = rows[index];
|
|
386
|
+
const colCount = row.cells.length;
|
|
387
|
+
for (let c = 0; c < colCount; c++) {
|
|
388
|
+
const cell = row.cells[c];
|
|
389
|
+
if (!cell.merged && (cell.rowspan ?? 1) > 1) {
|
|
390
|
+
const next = rows[index + 1].cells[c];
|
|
391
|
+
Object.assign(next, deepClone(cell), { id: next.id });
|
|
392
|
+
next.rowspan = (cell.rowspan ?? 1) - 1;
|
|
393
|
+
next.merged = false;
|
|
394
|
+
} else if (cell.merged) {
|
|
395
|
+
const span = getSpanRect(rows, index, c);
|
|
396
|
+
if (span.r1 < index && span.c1 === c) {
|
|
397
|
+
const main = rows[span.r1].cells[span.c1];
|
|
398
|
+
main.rowspan = (main.rowspan ?? 1) - 1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
rows.splice(index, 1);
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
function insertCol(rows, colWidths, index, position) {
|
|
406
|
+
const insertAt = position === "left" ? index : index + 1;
|
|
407
|
+
colWidths.splice(insertAt, 0, colWidths[index]);
|
|
408
|
+
for (const row of rows) {
|
|
409
|
+
const newCell = createCell();
|
|
410
|
+
if (insertAt > 0 && insertAt < row.cells.length) {
|
|
411
|
+
const r = rows.indexOf(row);
|
|
412
|
+
const span = getSpanRect(rows, r, insertAt - 1);
|
|
413
|
+
if (span.c1 < insertAt && span.c2 >= insertAt) {
|
|
414
|
+
const main = rows[span.r1].cells[span.c1];
|
|
415
|
+
if (r === span.r1) {
|
|
416
|
+
main.colspan = (main.colspan ?? 1) + 1;
|
|
417
|
+
}
|
|
418
|
+
newCell.merged = true;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
row.cells.splice(insertAt, 0, newCell);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function deleteCol(rows, colWidths, index) {
|
|
425
|
+
if (colWidths.length <= 1) {
|
|
426
|
+
return "\u4E0D\u80FD\u5220\u9664\u6700\u540E\u4E00\u5217";
|
|
427
|
+
}
|
|
428
|
+
for (let r = 0; r < rows.length; r++) {
|
|
429
|
+
const cell = rows[r].cells[index];
|
|
430
|
+
if (!cell.merged && (cell.colspan ?? 1) > 1) {
|
|
431
|
+
const next = rows[r].cells[index + 1];
|
|
432
|
+
Object.assign(next, deepClone(cell), { id: next.id });
|
|
433
|
+
next.colspan = (cell.colspan ?? 1) - 1;
|
|
434
|
+
next.merged = false;
|
|
435
|
+
} else if (cell.merged) {
|
|
436
|
+
const span = getSpanRect(rows, r, index);
|
|
437
|
+
if (span.c1 < index && span.r1 === r) {
|
|
438
|
+
const main = rows[span.r1].cells[span.c1];
|
|
439
|
+
main.colspan = (main.colspan ?? 1) - 1;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
for (const row of rows) {
|
|
444
|
+
row.cells.splice(index, 1);
|
|
445
|
+
}
|
|
446
|
+
colWidths.splice(index, 1);
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
function setRowType(rows, index, type) {
|
|
450
|
+
if (type === "data") {
|
|
451
|
+
const existing = rows.findIndex((r, i) => r.type === "data" && i !== index);
|
|
452
|
+
if (existing >= 0) {
|
|
453
|
+
return `\u6570\u636E\u884C\u5DF2\u5B58\u5728\uFF08\u7B2C ${existing + 1} \u884C\uFF09\uFF0C\u5168\u8868\u6700\u591A\u4E00\u884C`;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (type === "header") {
|
|
457
|
+
for (let i = 0; i < index; i++) {
|
|
458
|
+
if (rows[i].type !== "header") {
|
|
459
|
+
return "\u6807\u9898\u884C\u5FC5\u987B\u4ECE\u8868\u683C\u9876\u90E8\u8FDE\u7EED\u8BBE\u7F6E";
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (type === "subtotal" || type === "summary") {
|
|
464
|
+
const dataIdx = rows.findIndex((r) => r.type === "data");
|
|
465
|
+
if (dataIdx < 0) {
|
|
466
|
+
return "\u8BF7\u5148\u8BBE\u7F6E\u6570\u636E\u884C\uFF0C\u5C0F\u8BA1/\u6C47\u603B\u884C\u5FC5\u987B\u4F4D\u4E8E\u6570\u636E\u884C\u4E4B\u540E";
|
|
467
|
+
}
|
|
468
|
+
if (index < dataIdx) {
|
|
469
|
+
return "\u5C0F\u8BA1/\u6C47\u603B\u884C\u5FC5\u987B\u4F4D\u4E8E\u6570\u636E\u884C\u4E4B\u540E";
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (type === "subtotal") {
|
|
473
|
+
if (rows.slice(0, index).some((r) => r.type === "summary")) {
|
|
474
|
+
return "\u5C0F\u8BA1\u884C\u5FC5\u987B\u4F4D\u4E8E\u6C47\u603B\u884C\u4E4B\u524D";
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (type === "summary") {
|
|
478
|
+
if (rows.slice(index + 1).some((r) => r.type === "subtotal")) {
|
|
479
|
+
return "\u6C47\u603B\u884C\u5FC5\u987B\u4F4D\u4E8E\u5C0F\u8BA1\u884C\u4E4B\u540E";
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (rows[index].type === "header" && type !== "header") {
|
|
483
|
+
for (let i = index + 1; i < rows.length; i++) {
|
|
484
|
+
if (rows[i].type === "header") {
|
|
485
|
+
return "\u53D6\u6D88\u8BE5\u6807\u9898\u884C\u4F1A\u5BFC\u81F4\u6807\u9898\u884C\u4E0D\u8FDE\u7EED\uFF0C\u8BF7\u5148\u8C03\u6574\u540E\u7EED\u6807\u9898\u884C";
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
rows[index].type = type;
|
|
490
|
+
if (type !== "header") {
|
|
491
|
+
delete rows[index].repeatOnPage;
|
|
492
|
+
}
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
function applyBorderPreset(rows, rect, preset, border) {
|
|
496
|
+
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
497
|
+
for (let c = rect.c1; c <= rect.c2; c++) {
|
|
498
|
+
const cell = rows[r].cells[c];
|
|
499
|
+
if (cell.merged) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (preset === "none") {
|
|
503
|
+
delete cell.borders;
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
const span = getSpanRect(rows, r, c);
|
|
507
|
+
const atTop = span.r1 === rect.r1;
|
|
508
|
+
const atBottom = span.r2 === rect.r2;
|
|
509
|
+
const atLeft = span.c1 === rect.c1;
|
|
510
|
+
const atRight = span.c2 === rect.c2;
|
|
511
|
+
const b = { ...cell.borders ?? {} };
|
|
512
|
+
if (preset === "all") {
|
|
513
|
+
b.top = { ...border };
|
|
514
|
+
b.bottom = { ...border };
|
|
515
|
+
b.left = { ...border };
|
|
516
|
+
b.right = { ...border };
|
|
517
|
+
} else if (preset === "outer") {
|
|
518
|
+
if (atTop) {
|
|
519
|
+
b.top = { ...border };
|
|
520
|
+
}
|
|
521
|
+
if (atBottom) {
|
|
522
|
+
b.bottom = { ...border };
|
|
523
|
+
}
|
|
524
|
+
if (atLeft) {
|
|
525
|
+
b.left = { ...border };
|
|
526
|
+
}
|
|
527
|
+
if (atRight) {
|
|
528
|
+
b.right = { ...border };
|
|
529
|
+
}
|
|
530
|
+
} else if (preset === "inner") {
|
|
531
|
+
if (!atTop) {
|
|
532
|
+
b.top = { ...border };
|
|
533
|
+
}
|
|
534
|
+
if (!atBottom) {
|
|
535
|
+
b.bottom = { ...border };
|
|
536
|
+
}
|
|
537
|
+
if (!atLeft) {
|
|
538
|
+
b.left = { ...border };
|
|
539
|
+
}
|
|
540
|
+
if (!atRight) {
|
|
541
|
+
b.right = { ...border };
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
cell.borders = b;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
var GHOST_BORDER_CSS = "1px dashed rgba(0,0,0,0.18)";
|
|
549
|
+
function resolveCellBorderCss(b, opts = {}) {
|
|
550
|
+
if (b && b.style !== "none") return `${b.width}pt ${b.style} ${b.color}`;
|
|
551
|
+
if (opts.designMode && opts.showGhostBorder !== false) return GHOST_BORDER_CSS;
|
|
552
|
+
return "none";
|
|
553
|
+
}
|
|
554
|
+
function syncTableElementSize(options) {
|
|
555
|
+
const wMm = (options.tableColWidths ?? []).reduce((s, w) => s + w, 0);
|
|
556
|
+
const hMm = (options.tableRows ?? []).reduce((s, r) => s + r.height, 0);
|
|
557
|
+
options.width = Math.round(wMm * 100) / 100;
|
|
558
|
+
options.height = Math.round(hMm * 100) / 100;
|
|
559
|
+
}
|
|
560
|
+
var MIN_COL_WIDTH_MM = 5;
|
|
561
|
+
function clampResizedColumnWidth(colWidths, index, targetMm, maxTableWidth) {
|
|
562
|
+
const others = colWidths.reduce((s, w, i) => i === index ? s : s + w, 0);
|
|
563
|
+
const cap = maxTableWidth === Infinity ? Infinity : Math.max(MIN_COL_WIDTH_MM, maxTableWidth - others);
|
|
564
|
+
const rounded = Math.round(targetMm * 10) / 10;
|
|
565
|
+
return Math.min(Math.max(rounded, MIN_COL_WIDTH_MM), cap);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/designer/utils/element-factory.ts
|
|
569
|
+
function generateId() {
|
|
570
|
+
return `el-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
571
|
+
}
|
|
572
|
+
function createDefaultOptions(type) {
|
|
573
|
+
const base = { left: 7, top: 17.6, width: 42.3, height: 7.1 };
|
|
574
|
+
switch (type) {
|
|
575
|
+
case "text":
|
|
576
|
+
return { ...base, formatter: "\u6587\u672C", fontSize: 12, textAlign: "left", height: 5.3 };
|
|
577
|
+
case "image":
|
|
578
|
+
return { ...base, width: 28.2, height: 28.2, fit: "contain" };
|
|
579
|
+
case "longText":
|
|
580
|
+
return { ...base, width: 141.1, height: 28.2, fontSize: 12, lineHeight: 18 };
|
|
581
|
+
case "table": {
|
|
582
|
+
const { rows, colWidths } = createDefaultTable();
|
|
583
|
+
const totalW = colWidths.reduce((s, w) => s + w, 0);
|
|
584
|
+
const totalH = rows.reduce((s, r) => s + r.height, 0);
|
|
585
|
+
return {
|
|
586
|
+
...base,
|
|
587
|
+
width: totalW,
|
|
588
|
+
height: totalH,
|
|
589
|
+
// 表格尺寸由列宽/行高(mm)派生,与渲染端一致
|
|
590
|
+
tableMode: "dynamic",
|
|
591
|
+
tableRows: rows,
|
|
592
|
+
tableColWidths: colWidths,
|
|
593
|
+
tableDefaultFontSize: 10,
|
|
594
|
+
tableDefaultColor: "#333333",
|
|
595
|
+
tableDefaultPadding: 1,
|
|
596
|
+
fields: [],
|
|
597
|
+
tablePagination: { enabled: true }
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
case "hline":
|
|
601
|
+
return { ...base, width: 70.6, height: 1.8, borderWidth: 0.75 };
|
|
602
|
+
case "vline":
|
|
603
|
+
return { ...base, width: 1.8, height: 35.3, borderWidth: 0.75 };
|
|
604
|
+
case "rect":
|
|
605
|
+
return { ...base, width: 28.2, height: 28.2, borderWidth: 1, borderColor: "#333" };
|
|
606
|
+
case "oval":
|
|
607
|
+
return { ...base, width: 28.2, height: 28.2, borderWidth: 1, borderColor: "#333" };
|
|
608
|
+
case "barcode":
|
|
609
|
+
return { ...base, width: 56.4, height: 14.1, title: "\u6761\u5F62\u7801", barcodeType: "code128", testData: "12345678" };
|
|
610
|
+
case "qrcode":
|
|
611
|
+
return { ...base, width: 28.2, height: 28.2, title: "\u4E8C\u7EF4\u7801", testData: "qrcode" };
|
|
612
|
+
case "html":
|
|
613
|
+
return { ...base, width: 28.2, height: 28.2 };
|
|
614
|
+
default:
|
|
615
|
+
return base;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function createRuntimeElement(type, options) {
|
|
619
|
+
const typeMetaMap = {
|
|
620
|
+
text: { title: "\u6587\u672C" },
|
|
621
|
+
image: { title: "\u56FE\u7247" },
|
|
622
|
+
longText: { title: "\u957F\u6587" },
|
|
623
|
+
table: { title: "\u8868\u683C" },
|
|
624
|
+
hline: { title: "\u6A2A\u7EBF" },
|
|
625
|
+
vline: { title: "\u7AD6\u7EBF" },
|
|
626
|
+
rect: { title: "\u77E9\u5F62" },
|
|
627
|
+
oval: { title: "\u692D\u5706" },
|
|
628
|
+
barcode: { title: "\u6761\u5F62\u7801" },
|
|
629
|
+
qrcode: { title: "\u4E8C\u7EF4\u7801" },
|
|
630
|
+
html: { title: "HTML" },
|
|
631
|
+
pageNumber: { title: "\u9875\u7801" }
|
|
632
|
+
};
|
|
633
|
+
return {
|
|
634
|
+
id: generateId(),
|
|
635
|
+
options: { ...createDefaultOptions(type), ...options },
|
|
636
|
+
printElementType: { type, title: typeMetaMap[type]?.title || type }
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// src/designer/utils/zone-layout.ts
|
|
641
|
+
var ZONE_ALLOWED_TYPES = ["text", "image", "hline", "vline", "rect", "oval", "barcode", "qrcode"];
|
|
642
|
+
function getPaperSizeMM(t) {
|
|
643
|
+
return getPaperDimensions(t);
|
|
644
|
+
}
|
|
645
|
+
function getZoneRects(t) {
|
|
646
|
+
const paper = getPaperSizeMM(t);
|
|
647
|
+
const m = t.margins;
|
|
648
|
+
const headerH = t.header.height;
|
|
649
|
+
const footerH = t.footer.height;
|
|
650
|
+
const contentW = paper.width - m.left - m.right;
|
|
651
|
+
const contentH = paper.height - m.top - m.bottom - headerH - footerH;
|
|
652
|
+
const rect = (l, tp, w, h) => ({
|
|
653
|
+
left: l,
|
|
654
|
+
top: tp,
|
|
655
|
+
width: w,
|
|
656
|
+
height: h
|
|
657
|
+
});
|
|
658
|
+
return {
|
|
659
|
+
header: rect(m.left, m.top, contentW, headerH),
|
|
660
|
+
content: rect(m.left, m.top + headerH, contentW, contentH),
|
|
661
|
+
footer: rect(m.left, paper.height - m.bottom - footerH, contentW, footerH)
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
function zoneFromPaperPoint(t, _x, y) {
|
|
665
|
+
const r = getZoneRects(t);
|
|
666
|
+
if (r.footer.height > 0 && y >= r.footer.top) return "footer";
|
|
667
|
+
if (r.header.height > 0 && y < r.header.top + r.header.height) return "header";
|
|
668
|
+
return "content";
|
|
669
|
+
}
|
|
670
|
+
function clampToZone(el, zone) {
|
|
671
|
+
const o = el.options;
|
|
672
|
+
o.width = Math.min(o.width, zone.width);
|
|
673
|
+
o.height = Math.min(o.height, zone.height);
|
|
674
|
+
o.left = Math.min(Math.max(0, o.left), zone.width - o.width);
|
|
675
|
+
o.top = Math.min(Math.max(0, o.top), zone.height - o.height);
|
|
676
|
+
}
|
|
677
|
+
function finalizeElementZone(el, t) {
|
|
678
|
+
const rects = getZoneRects(t);
|
|
679
|
+
const fromZone = el.zone || "content";
|
|
680
|
+
const from = rects[fromZone];
|
|
681
|
+
const cx = from.left + el.options.left + el.options.width / 2;
|
|
682
|
+
const cy = from.top + el.options.top + el.options.height / 2;
|
|
683
|
+
let target = zoneFromPaperPoint(t, cx, cy);
|
|
684
|
+
let rejected = false;
|
|
685
|
+
if (target !== "content" && !ZONE_ALLOWED_TYPES.includes(el.printElementType.type)) {
|
|
686
|
+
target = "content";
|
|
687
|
+
rejected = true;
|
|
688
|
+
}
|
|
689
|
+
if (target !== fromZone) {
|
|
690
|
+
const to = rects[target];
|
|
691
|
+
el.options.left = from.left + el.options.left - to.left;
|
|
692
|
+
el.options.top = from.top + el.options.top - to.top;
|
|
693
|
+
el.zone = target;
|
|
694
|
+
}
|
|
695
|
+
if (target !== "content") {
|
|
696
|
+
clampToZone(el, rects[target]);
|
|
697
|
+
} else if (rejected) {
|
|
698
|
+
clampToZone(el, rects.content);
|
|
699
|
+
}
|
|
700
|
+
return { rejected };
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// src/designer/utils/ruler.ts
|
|
704
|
+
var RULER_THICKNESS = 22;
|
|
705
|
+
var STEP_SEQUENCE = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1e3];
|
|
706
|
+
function chooseMajorStepMM(scale, targetPx = 64) {
|
|
707
|
+
const pxPerMM = scale * (96 / 25.4);
|
|
708
|
+
for (const step of STEP_SEQUENCE) {
|
|
709
|
+
if (step * pxPerMM >= targetPx) return step;
|
|
710
|
+
}
|
|
711
|
+
return STEP_SEQUENCE[STEP_SEQUENCE.length - 1];
|
|
712
|
+
}
|
|
713
|
+
function minorStepMM(majorStepMM) {
|
|
714
|
+
const exp = Math.floor(Math.log10(majorStepMM) + 1e-9);
|
|
715
|
+
const base = majorStepMM / 10 ** exp;
|
|
716
|
+
if (base === 5 || base === 1 && majorStepMM >= 10) return majorStepMM / 5;
|
|
717
|
+
if (base === 2) return majorStepMM / 2;
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
function roundMM(mm2) {
|
|
721
|
+
return Math.round(mm2 * 1e3) / 1e3;
|
|
722
|
+
}
|
|
723
|
+
function buildRulerTicks(startMM, endMM, majorStepMM) {
|
|
724
|
+
if (endMM < startMM || majorStepMM <= 0) return [];
|
|
725
|
+
const minor = minorStepMM(majorStepMM);
|
|
726
|
+
const fine = minor ?? majorStepMM;
|
|
727
|
+
const first = Math.ceil(startMM / fine - 1e-9) * fine;
|
|
728
|
+
const lastIndex = Math.floor((endMM - first) / fine + 1e-9);
|
|
729
|
+
const ticks = [];
|
|
730
|
+
for (let i = 0; i <= lastIndex; i++) {
|
|
731
|
+
const mm2 = roundMM(first + i * fine);
|
|
732
|
+
const isMajor = Math.abs(mm2 / majorStepMM - Math.round(mm2 / majorStepMM)) < 1e-6;
|
|
733
|
+
if (isMajor) {
|
|
734
|
+
ticks.push({ mm: mm2, major: true, label: String(mm2) });
|
|
735
|
+
} else {
|
|
736
|
+
ticks.push({ mm: mm2, major: false });
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return ticks;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// src/designer/utils/preset-colors.ts
|
|
743
|
+
var PRESET_COLORS = [
|
|
744
|
+
"#000000",
|
|
745
|
+
"#333333",
|
|
746
|
+
"#666666",
|
|
747
|
+
"#999999",
|
|
748
|
+
"#cccccc",
|
|
749
|
+
"#ffffff",
|
|
750
|
+
"#e53935",
|
|
751
|
+
"#fb8c00",
|
|
752
|
+
"#1e88e5",
|
|
753
|
+
"#43a047",
|
|
754
|
+
"#8d6e63",
|
|
755
|
+
"#00acc1"
|
|
756
|
+
];
|
|
757
|
+
|
|
758
|
+
// src/designer/utils/property-search.ts
|
|
759
|
+
var PROPERTY_REGISTRY = [
|
|
760
|
+
{
|
|
761
|
+
group: "position-size",
|
|
762
|
+
groupLabel: "\u4F4D\u7F6E\u4E0E\u5C3A\u5BF8",
|
|
763
|
+
items: [
|
|
764
|
+
{ key: "ps-left", keywords: ["X", "\u6A2A\u5750\u6807", "left", "\u4F4D\u7F6E"] },
|
|
765
|
+
{ key: "ps-top", keywords: ["Y", "\u7EB5\u5750\u6807", "top", "\u4F4D\u7F6E"] },
|
|
766
|
+
{ key: "ps-width", keywords: ["W", "\u5BBD\u5EA6", "width", "\u5C3A\u5BF8"] },
|
|
767
|
+
{ key: "ps-height", keywords: ["H", "\u9AD8\u5EA6", "height", "\u5C3A\u5BF8"] }
|
|
768
|
+
]
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
group: "appearance",
|
|
772
|
+
groupLabel: "\u5916\u89C2",
|
|
773
|
+
items: [
|
|
774
|
+
{ key: "ap-font-size", keywords: ["\u5B57\u4F53\u5927\u5C0F", "fontsize", "\u5B57\u53F7"] },
|
|
775
|
+
{ key: "ap-font-weight", keywords: ["\u5B57\u4F53\u7C97\u7EC6", "\u7C97\u4F53", "bold"] },
|
|
776
|
+
{ key: "ap-align", keywords: ["\u5BF9\u9F50", "align"] },
|
|
777
|
+
{ key: "ap-vertical-align", keywords: ["\u5782\u76F4\u5BF9\u9F50", "verticalalign", "\u9876\u5BF9\u9F50", "\u5E95\u5BF9\u9F50"] },
|
|
778
|
+
{ key: "ap-color", keywords: ["\u989C\u8272", "color"] },
|
|
779
|
+
{ key: "ap-bg-color", keywords: ["\u80CC\u666F\u8272", "background"] },
|
|
780
|
+
{ key: "ap-line-height", keywords: ["\u884C\u9AD8", "lineheight"] },
|
|
781
|
+
{ key: "ap-letter-spacing", keywords: ["\u5B57\u95F4\u8DDD", "letterspacing"] }
|
|
782
|
+
]
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
group: "content",
|
|
786
|
+
groupLabel: "\u5185\u5BB9",
|
|
787
|
+
items: [
|
|
788
|
+
{ key: "ct-title", keywords: ["\u5185\u5BB9", "\u6587\u672C", "title"] },
|
|
789
|
+
{ key: "ct-formatter", keywords: ["\u683C\u5F0F\u5316", "\u8868\u8FBE\u5F0F", "formatter"] },
|
|
790
|
+
{ key: "ct-table-mode", keywords: ["\u6570\u636E\u6A21\u5F0F", "\u9759\u6001\u5E03\u5C40", "\u52A8\u6001\u6570\u636E"] },
|
|
791
|
+
{ key: "ct-table-source", keywords: ["\u6570\u636E\u6E90", "\u5217\u8868\u5B57\u6BB5"] },
|
|
792
|
+
{ key: "ct-table-font", keywords: ["\u9ED8\u8BA4\u5B57\u53F7", "\u9ED8\u8BA4\u989C\u8272", "\u9ED8\u8BA4\u5185\u8FB9\u8DDD"] },
|
|
793
|
+
{ key: "ct-table-cols", keywords: ["\u5217\u5BBD", "\u8868\u683C\u5217"] }
|
|
794
|
+
]
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
group: "border-bg",
|
|
798
|
+
groupLabel: "\u8FB9\u6846\u4E0E\u80CC\u666F",
|
|
799
|
+
items: [
|
|
800
|
+
{ key: "bb-border-width", keywords: ["\u8FB9\u6846\u5BBD\u5EA6", "border"] },
|
|
801
|
+
{ key: "bb-border-color", keywords: ["\u8FB9\u6846\u989C\u8272"] },
|
|
802
|
+
{ key: "bb-bg-color", keywords: ["\u80CC\u666F\u8272", "background"] }
|
|
803
|
+
]
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
group: "binding",
|
|
807
|
+
groupLabel: "\u5B57\u6BB5\u7ED1\u5B9A",
|
|
808
|
+
items: [
|
|
809
|
+
{ key: "bd-formatter", keywords: ["\u683C\u5F0F\u5316", "\u8868\u8FBE\u5F0F", "formatter", "fx", "\u5B57\u6BB5", "\u7ED1\u5B9A", "field"] },
|
|
810
|
+
{ key: "bd-content", keywords: ["\u5185\u5BB9", "\u8868\u8FBE\u5F0F", "\u6587\u672C", "\u53D8\u91CF"] }
|
|
811
|
+
]
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
group: "pagination",
|
|
815
|
+
groupLabel: "\u5206\u9875",
|
|
816
|
+
items: [
|
|
817
|
+
{ key: "pg-enabled", keywords: ["\u5206\u9875", "pagination", "\u542F\u7528\u5206\u9875"] },
|
|
818
|
+
{ key: "pg-pageable", keywords: ["\u53C2\u4E0E\u5206\u9875", "pageable"] },
|
|
819
|
+
{ key: "pg-keep-with-next", keywords: ["\u540C\u9875", "keepWithNext"] }
|
|
820
|
+
]
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
group: "advanced",
|
|
824
|
+
groupLabel: "\u9AD8\u7EA7",
|
|
825
|
+
items: [
|
|
826
|
+
{ key: "ad-locked", keywords: ["\u9501\u5B9A", "lock"] },
|
|
827
|
+
{ key: "ad-fixed", keywords: ["\u6BCF\u9875\u91CD\u590D", "repeat"] },
|
|
828
|
+
{ key: "ad-z-index", keywords: ["\u5C42\u7EA7", "zindex"] },
|
|
829
|
+
{ key: "ad-delete", keywords: ["\u5220\u9664"] }
|
|
830
|
+
]
|
|
831
|
+
}
|
|
832
|
+
];
|
|
833
|
+
function matchKeywords(search, keywords) {
|
|
834
|
+
const s = search.trim().toLowerCase();
|
|
835
|
+
if (!s) {
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
return keywords.some((k) => k.toLowerCase().includes(s));
|
|
839
|
+
}
|
|
840
|
+
function searchProperties(search) {
|
|
841
|
+
const groups = [];
|
|
842
|
+
const itemKeys = /* @__PURE__ */ new Set();
|
|
843
|
+
for (const g of PROPERTY_REGISTRY) {
|
|
844
|
+
const matched = g.items.filter((item) => matchKeywords(search, [...item.keywords, g.groupLabel]));
|
|
845
|
+
if (matched.length > 0) {
|
|
846
|
+
groups.push(g.group);
|
|
847
|
+
for (const item of matched) {
|
|
848
|
+
itemKeys.add(item.key);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return { groups, itemKeys };
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// src/designer/utils/field-groups.ts
|
|
856
|
+
function groupFields(fields) {
|
|
857
|
+
const sorted = [...fields].sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0));
|
|
858
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
859
|
+
const groupOrder = [];
|
|
860
|
+
for (const f of sorted) {
|
|
861
|
+
const dot = f.fieldKey.indexOf(".");
|
|
862
|
+
if (dot === -1) continue;
|
|
863
|
+
const key = f.fieldKey.slice(0, dot);
|
|
864
|
+
let g = groupMap.get(key);
|
|
865
|
+
if (!g) {
|
|
866
|
+
g = { key, label: key, isList: false, fields: [] };
|
|
867
|
+
groupMap.set(key, g);
|
|
868
|
+
groupOrder.push(key);
|
|
869
|
+
}
|
|
870
|
+
g.fields.push(f);
|
|
871
|
+
}
|
|
872
|
+
const groups = [];
|
|
873
|
+
const standalone = [];
|
|
874
|
+
for (const f of sorted) {
|
|
875
|
+
if (f.fieldKey.includes(".")) continue;
|
|
876
|
+
const g = groupMap.get(f.fieldKey);
|
|
877
|
+
if (g) {
|
|
878
|
+
g.label = f.fieldLabel;
|
|
879
|
+
g.isList = f.fieldType === "list";
|
|
880
|
+
} else {
|
|
881
|
+
standalone.push(f);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (standalone.length) groups.push({ key: "", label: "", isList: false, fields: standalone });
|
|
885
|
+
for (const key of groupOrder) groups.push(groupMap.get(key));
|
|
886
|
+
return groups;
|
|
887
|
+
}
|
|
888
|
+
function filterGroups(groups, keyword) {
|
|
889
|
+
const kw = keyword.trim().toLowerCase();
|
|
890
|
+
if (!kw) return groups;
|
|
891
|
+
return groups.map((g) => ({
|
|
892
|
+
...g,
|
|
893
|
+
fields: g.fields.filter(
|
|
894
|
+
(f) => f.fieldLabel.toLowerCase().includes(kw) || f.fieldKey.toLowerCase().includes(kw)
|
|
895
|
+
)
|
|
896
|
+
})).filter((g) => g.fields.length > 0);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// src/designer/utils/binding-registry.ts
|
|
900
|
+
var ELEMENT_BINDING_REGISTRY = {
|
|
901
|
+
text: [
|
|
902
|
+
{ targetPath: "options.formatter", label: "\u5185\u5BB9", dataSource: "main" }
|
|
903
|
+
],
|
|
904
|
+
longText: [
|
|
905
|
+
{ targetPath: "options.formatter", label: "\u5185\u5BB9", dataSource: "main" },
|
|
906
|
+
{ targetPath: "options.styler", label: "\u6837\u5F0F", dataSource: "main" }
|
|
907
|
+
],
|
|
908
|
+
barcode: [
|
|
909
|
+
{ targetPath: "options.formatter", label: "\u5185\u5BB9", dataSource: "main" }
|
|
910
|
+
],
|
|
911
|
+
qrcode: [
|
|
912
|
+
{ targetPath: "options.formatter", label: "\u5185\u5BB9", dataSource: "main" }
|
|
913
|
+
],
|
|
914
|
+
image: [
|
|
915
|
+
{ targetPath: "options.src", label: "\u5185\u5BB9", dataSource: "main", placeholder: "\u8F93\u5165\u56FE\u7247\u8DEF\u5F84\uFF0C\u652F\u6301 /docfiles/... \u76F8\u5BF9\u8DEF\u5F84\u3001\u7EDD\u5BF9 URL \u6216 {\u5B57\u6BB5} \u8868\u8FBE\u5F0F" }
|
|
916
|
+
],
|
|
917
|
+
table: []
|
|
918
|
+
};
|
|
919
|
+
function getTableCellBindings(rowType, rowIndex, cellIndex, listField) {
|
|
920
|
+
if (rowType === "data") {
|
|
921
|
+
return [{
|
|
922
|
+
targetPath: `options.tableRows[${rowIndex}].cells[${cellIndex}].formatter`,
|
|
923
|
+
label: "\u5185\u5BB9",
|
|
924
|
+
dataSource: "list",
|
|
925
|
+
listField,
|
|
926
|
+
placeholder: "{name}"
|
|
927
|
+
}];
|
|
928
|
+
}
|
|
929
|
+
if (rowType === "subtotal") {
|
|
930
|
+
return [{
|
|
931
|
+
targetPath: `options.tableRows[${rowIndex}].cells[${cellIndex}].formatter`,
|
|
932
|
+
label: "\u5185\u5BB9",
|
|
933
|
+
dataSource: "subtotal",
|
|
934
|
+
placeholder: "{MONEY(SUM(amount))}"
|
|
935
|
+
}];
|
|
936
|
+
}
|
|
937
|
+
if (rowType === "summary") {
|
|
938
|
+
return [{
|
|
939
|
+
targetPath: `options.tableRows[${rowIndex}].cells[${cellIndex}].formatter`,
|
|
940
|
+
label: "\u5185\u5BB9",
|
|
941
|
+
dataSource: "summary",
|
|
942
|
+
placeholder: "{MONEY(SUM(amount))}"
|
|
943
|
+
}];
|
|
944
|
+
}
|
|
945
|
+
return [{
|
|
946
|
+
targetPath: `options.tableRows[${rowIndex}].cells[${cellIndex}].formatter`,
|
|
947
|
+
label: "\u5185\u5BB9",
|
|
948
|
+
dataSource: "main",
|
|
949
|
+
placeholder: "\u5408\u8BA1: {order.total}"
|
|
950
|
+
}];
|
|
951
|
+
}
|
|
952
|
+
function getElementBindings(element) {
|
|
953
|
+
const type = element.printElementType.type;
|
|
954
|
+
const staticBindings = ELEMENT_BINDING_REGISTRY[type] ?? [];
|
|
955
|
+
const dynamicBindings = [];
|
|
956
|
+
if (type === "table") {
|
|
957
|
+
const listField = element.options.dataSource;
|
|
958
|
+
for (const [ri, row] of (element.options.tableRows ?? []).entries()) {
|
|
959
|
+
for (const [ci, cell] of row.cells.entries()) {
|
|
960
|
+
if (cell.merged) continue;
|
|
961
|
+
dynamicBindings.push(...getTableCellBindings(row.type, ri, ci, listField));
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return [...staticBindings, ...dynamicBindings];
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// src/designer/utils/demo-data.ts
|
|
969
|
+
function getDemoData() {
|
|
970
|
+
return DEFAULT_DEMO_DATA;
|
|
971
|
+
}
|
|
972
|
+
var DEFAULT_DEMO_DATA = {
|
|
973
|
+
supplier: {
|
|
974
|
+
name: "\u946B\u8FBE\u4E94\u91D1\u6709\u9650\u516C\u53F8",
|
|
975
|
+
phone: "0571-88776655",
|
|
976
|
+
address: "\u676D\u5DDE\u5E02\u8427\u5C71\u533A\u7ECF\u6D4E\u5F00\u53D1\u533A88\u53F7"
|
|
977
|
+
},
|
|
978
|
+
receiver: {
|
|
979
|
+
name: "\u674E\u56DB",
|
|
980
|
+
phone: "13912345678",
|
|
981
|
+
address: "\u676D\u5DDE\u5E02\u4F59\u676D\u533A\u6587\u4E00\u897F\u8DEF998\u53F7"
|
|
982
|
+
},
|
|
983
|
+
order: {
|
|
984
|
+
no: "PO20260801001",
|
|
985
|
+
date: "2026-08-01",
|
|
986
|
+
total: 69543.75
|
|
987
|
+
},
|
|
988
|
+
// 50 条商品明细, 用于验证多页分页效果
|
|
989
|
+
goods: [
|
|
990
|
+
{ name: "\u78B3\u94A2\u87BA\u4E1D M8", spec: "M14\xD710", unit: "\u4E2A", qty: 100, price: 0.5, amount: 50, remark: "A\u7EA7" },
|
|
991
|
+
{ name: "\u4E0D\u9508\u94A2\u87BA\u6BCD M10", spec: "M16\xD711", unit: "\u5957", qty: 117, price: 0.75, amount: 87.75, remark: "" },
|
|
992
|
+
{ name: "\u5F39\u7C27\u57AB\u5708 M12", spec: "M6\xD712", unit: "\u76D2", qty: 134, price: 1, amount: 134, remark: "" },
|
|
993
|
+
{ name: "\u516D\u89D2\u87BA\u6813 M14", spec: "M5\xD713", unit: "\u652F", qty: 151, price: 1.25, amount: 188.75, remark: "" },
|
|
994
|
+
{ name: "\u5185\u516D\u89D2\u87BA\u9489 M16", spec: "M20\xD714", unit: "\u888B", qty: 168, price: 1.5, amount: 252, remark: "" },
|
|
995
|
+
{ name: "\u5E73\u57AB\u5708 M6", spec: "M4\xD715", unit: "\u4EF6", qty: 185, price: 1.75, amount: 323.75, remark: "" },
|
|
996
|
+
{ name: "\u81EA\u653B\u87BA\u9489 M5", spec: "M3\xD716", unit: "\u6839", qty: 202, price: 2, amount: 404, remark: "" },
|
|
997
|
+
{ name: "\u53CC\u5934\u87BA\u67F1 M20", spec: "M8\xD717", unit: "\u5305", qty: 219, price: 2.25, amount: 492.75, remark: "A\u7EA7" },
|
|
998
|
+
{ name: "\u7D27\u5B9A\u87BA\u9489 M4", spec: "M10\xD718", unit: "\u53EA", qty: 236, price: 2.5, amount: 590, remark: "" },
|
|
999
|
+
{ name: "\u5341\u5B57\u76D8\u5934\u9489 M3", spec: "M12\xD719", unit: "\u7EC4", qty: 253, price: 2.75, amount: 695.75, remark: "" },
|
|
1000
|
+
{ name: "\u78B3\u94A2\u87BA\u4E1D M8", spec: "M14\xD720", unit: "\u4E2A", qty: 270, price: 3, amount: 810, remark: "" },
|
|
1001
|
+
{ name: "\u4E0D\u9508\u94A2\u87BA\u6BCD M10", spec: "M16\xD721", unit: "\u5957", qty: 287, price: 3.25, amount: 932.75, remark: "" },
|
|
1002
|
+
{ name: "\u5F39\u7C27\u57AB\u5708 M12", spec: "M6\xD722", unit: "\u76D2", qty: 304, price: 3.5, amount: 1064, remark: "" },
|
|
1003
|
+
{ name: "\u516D\u89D2\u87BA\u6813 M14", spec: "M5\xD723", unit: "\u652F", qty: 321, price: 3.75, amount: 1203.75, remark: "" },
|
|
1004
|
+
{ name: "\u5185\u516D\u89D2\u87BA\u9489 M16", spec: "M20\xD724", unit: "\u888B", qty: 338, price: 4, amount: 1352, remark: "A\u7EA7" },
|
|
1005
|
+
{ name: "\u5E73\u57AB\u5708 M6", spec: "M4\xD725", unit: "\u4EF6", qty: 355, price: 4.25, amount: 1508.75, remark: "" },
|
|
1006
|
+
{ name: "\u81EA\u653B\u87BA\u9489 M5", spec: "M3\xD726", unit: "\u6839", qty: 372, price: 4.5, amount: 1674, remark: "" },
|
|
1007
|
+
{ name: "\u53CC\u5934\u87BA\u67F1 M20", spec: "M8\xD727", unit: "\u5305", qty: 389, price: 4.75, amount: 1847.75, remark: "" },
|
|
1008
|
+
{ name: "\u7D27\u5B9A\u87BA\u9489 M4", spec: "M10\xD728", unit: "\u53EA", qty: 406, price: 5, amount: 2030, remark: "" },
|
|
1009
|
+
{ name: "\u5341\u5B57\u76D8\u5934\u9489 M3", spec: "M12\xD729", unit: "\u7EC4", qty: 423, price: 5.25, amount: 2220.75, remark: "" },
|
|
1010
|
+
{ name: "\u78B3\u94A2\u87BA\u4E1D M8", spec: "M14\xD730", unit: "\u4E2A", qty: 440, price: 0.5, amount: 220, remark: "" },
|
|
1011
|
+
{ name: "\u4E0D\u9508\u94A2\u87BA\u6BCD M10", spec: "M16\xD731", unit: "\u5957", qty: 457, price: 0.75, amount: 342.75, remark: "A\u7EA7" },
|
|
1012
|
+
{ name: "\u5F39\u7C27\u57AB\u5708 M12", spec: "M6\xD732", unit: "\u76D2", qty: 474, price: 1, amount: 474, remark: "" },
|
|
1013
|
+
{ name: "\u516D\u89D2\u87BA\u6813 M14", spec: "M5\xD733", unit: "\u652F", qty: 491, price: 1.25, amount: 613.75, remark: "" },
|
|
1014
|
+
{ name: "\u5185\u516D\u89D2\u87BA\u9489 M16", spec: "M20\xD734", unit: "\u888B", qty: 508, price: 1.5, amount: 762, remark: "" },
|
|
1015
|
+
{ name: "\u5E73\u57AB\u5708 M6", spec: "M4\xD735", unit: "\u4EF6", qty: 525, price: 1.75, amount: 918.75, remark: "" },
|
|
1016
|
+
{ name: "\u81EA\u653B\u87BA\u9489 M5", spec: "M3\xD736", unit: "\u6839", qty: 542, price: 2, amount: 1084, remark: "" },
|
|
1017
|
+
{ name: "\u53CC\u5934\u87BA\u67F1 M20", spec: "M8\xD737", unit: "\u5305", qty: 559, price: 2.25, amount: 1257.75, remark: "" },
|
|
1018
|
+
{ name: "\u7D27\u5B9A\u87BA\u9489 M4", spec: "M10\xD738", unit: "\u53EA", qty: 576, price: 2.5, amount: 1440, remark: "A\u7EA7" },
|
|
1019
|
+
{ name: "\u5341\u5B57\u76D8\u5934\u9489 M3", spec: "M12\xD739", unit: "\u7EC4", qty: 593, price: 2.75, amount: 1630.75, remark: "" },
|
|
1020
|
+
{ name: "\u78B3\u94A2\u87BA\u4E1D M8", spec: "M14\xD740", unit: "\u4E2A", qty: 610, price: 3, amount: 1830, remark: "" },
|
|
1021
|
+
{ name: "\u4E0D\u9508\u94A2\u87BA\u6BCD M10", spec: "M16\xD741", unit: "\u5957", qty: 627, price: 3.25, amount: 2037.75, remark: "" },
|
|
1022
|
+
{ name: "\u5F39\u7C27\u57AB\u5708 M12", spec: "M6\xD742", unit: "\u76D2", qty: 644, price: 3.5, amount: 2254, remark: "" },
|
|
1023
|
+
{ name: "\u516D\u89D2\u87BA\u6813 M14", spec: "M5\xD743", unit: "\u652F", qty: 661, price: 3.75, amount: 2478.75, remark: "" },
|
|
1024
|
+
{ name: "\u5185\u516D\u89D2\u87BA\u9489 M16", spec: "M20\xD744", unit: "\u888B", qty: 678, price: 4, amount: 2712, remark: "" },
|
|
1025
|
+
{ name: "\u5E73\u57AB\u5708 M6", spec: "M4\xD745", unit: "\u4EF6", qty: 695, price: 4.25, amount: 2953.75, remark: "A\u7EA7" },
|
|
1026
|
+
{ name: "\u81EA\u653B\u87BA\u9489 M5", spec: "M3\xD746", unit: "\u6839", qty: 712, price: 4.5, amount: 3204, remark: "" },
|
|
1027
|
+
{ name: "\u53CC\u5934\u87BA\u67F1 M20", spec: "M8\xD747", unit: "\u5305", qty: 729, price: 4.75, amount: 3462.75, remark: "" },
|
|
1028
|
+
{ name: "\u7D27\u5B9A\u87BA\u9489 M4", spec: "M10\xD748", unit: "\u53EA", qty: 746, price: 5, amount: 3730, remark: "" },
|
|
1029
|
+
{ name: "\u5341\u5B57\u76D8\u5934\u9489 M3", spec: "M12\xD749", unit: "\u7EC4", qty: 763, price: 5.25, amount: 4005.75, remark: "" },
|
|
1030
|
+
{ name: "\u78B3\u94A2\u87BA\u4E1D M8", spec: "M14\xD710", unit: "\u4E2A", qty: 780, price: 0.5, amount: 390, remark: "" },
|
|
1031
|
+
{ name: "\u4E0D\u9508\u94A2\u87BA\u6BCD M10", spec: "M16\xD711", unit: "\u5957", qty: 797, price: 0.75, amount: 597.75, remark: "" },
|
|
1032
|
+
{ name: "\u5F39\u7C27\u57AB\u5708 M12", spec: "M6\xD712", unit: "\u76D2", qty: 814, price: 1, amount: 814, remark: "A\u7EA7" },
|
|
1033
|
+
{ name: "\u516D\u89D2\u87BA\u6813 M14", spec: "M5\xD713", unit: "\u652F", qty: 831, price: 1.25, amount: 1038.75, remark: "" },
|
|
1034
|
+
{ name: "\u5185\u516D\u89D2\u87BA\u9489 M16", spec: "M20\xD714", unit: "\u888B", qty: 848, price: 1.5, amount: 1272, remark: "" },
|
|
1035
|
+
{ name: "\u5E73\u57AB\u5708 M6", spec: "M4\xD715", unit: "\u4EF6", qty: 865, price: 1.75, amount: 1513.75, remark: "" },
|
|
1036
|
+
{ name: "\u81EA\u653B\u87BA\u9489 M5", spec: "M3\xD716", unit: "\u6839", qty: 882, price: 2, amount: 1764, remark: "" },
|
|
1037
|
+
{ name: "\u53CC\u5934\u87BA\u67F1 M20", spec: "M8\xD717", unit: "\u5305", qty: 899, price: 2.25, amount: 2022.75, remark: "" },
|
|
1038
|
+
{ name: "\u7D27\u5B9A\u87BA\u9489 M4", spec: "M10\xD718", unit: "\u53EA", qty: 916, price: 2.5, amount: 2290, remark: "" },
|
|
1039
|
+
{ name: "\u5341\u5B57\u76D8\u5934\u9489 M3", spec: "M12\xD719", unit: "\u7EC4", qty: 933, price: 2.75, amount: 2565.75, remark: "A\u7EA7" }
|
|
1040
|
+
]
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
// src/lexer.ts
|
|
1044
|
+
var DANGEROUS_PROPS = /* @__PURE__ */ new Set([
|
|
1045
|
+
"constructor",
|
|
1046
|
+
"__proto__",
|
|
1047
|
+
"prototype",
|
|
1048
|
+
"__defineGetter__",
|
|
1049
|
+
"__defineSetter__",
|
|
1050
|
+
"__lookupGetter__",
|
|
1051
|
+
"__lookupSetter__"
|
|
1052
|
+
]);
|
|
1053
|
+
var RESERVED_WORDS = /* @__PURE__ */ new Set([
|
|
1054
|
+
"new",
|
|
1055
|
+
"function",
|
|
1056
|
+
"class",
|
|
1057
|
+
"this",
|
|
1058
|
+
"delete",
|
|
1059
|
+
"typeof",
|
|
1060
|
+
"void",
|
|
1061
|
+
"in",
|
|
1062
|
+
"of",
|
|
1063
|
+
"var",
|
|
1064
|
+
"let",
|
|
1065
|
+
"const",
|
|
1066
|
+
"return",
|
|
1067
|
+
"if",
|
|
1068
|
+
"while",
|
|
1069
|
+
"for"
|
|
1070
|
+
]);
|
|
1071
|
+
function tokenize(input) {
|
|
1072
|
+
const tokens = [];
|
|
1073
|
+
let i = 0;
|
|
1074
|
+
const n = input.length;
|
|
1075
|
+
while (i < n) {
|
|
1076
|
+
const ch = input[i];
|
|
1077
|
+
if (/\s/.test(ch)) {
|
|
1078
|
+
i++;
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
if (/[0-9]/.test(ch) || ch === "." && i + 1 < n && /[0-9]/.test(input[i + 1])) {
|
|
1082
|
+
let j = i;
|
|
1083
|
+
while (j < n && /[0-9.]/.test(input[j])) j++;
|
|
1084
|
+
tokens.push({ type: "num", value: input.slice(i, j), position: i });
|
|
1085
|
+
i = j;
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
if (ch === "'" || ch === '"') {
|
|
1089
|
+
let j = i + 1;
|
|
1090
|
+
let s = "";
|
|
1091
|
+
while (j < n && input[j] !== ch) {
|
|
1092
|
+
if (input[j] === "\\" && j + 1 < n) {
|
|
1093
|
+
s += input[j + 1];
|
|
1094
|
+
j += 2;
|
|
1095
|
+
} else {
|
|
1096
|
+
s += input[j];
|
|
1097
|
+
j++;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (j >= n) throw new Error("\u5B57\u7B26\u4E32\u672A\u95ED\u5408");
|
|
1101
|
+
tokens.push({ type: "str", value: s, position: i });
|
|
1102
|
+
i = j + 1;
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
if (/[A-Za-z_$]/.test(ch)) {
|
|
1106
|
+
let j = i;
|
|
1107
|
+
while (j < n && /[A-Za-z0-9_$]/.test(input[j])) j++;
|
|
1108
|
+
const word = input.slice(i, j);
|
|
1109
|
+
if (RESERVED_WORDS.has(word)) {
|
|
1110
|
+
throw new Error(`\u4E0D\u5141\u8BB8\u4F7F\u7528\u5173\u952E\u5B57: ${word}`);
|
|
1111
|
+
}
|
|
1112
|
+
if (DANGEROUS_PROPS.has(word)) {
|
|
1113
|
+
throw new Error(`\u7981\u6B62\u8BBF\u95EE: ${word}`);
|
|
1114
|
+
}
|
|
1115
|
+
if (word === "true" || word === "false") {
|
|
1116
|
+
tokens.push({ type: "bool", value: word, position: i });
|
|
1117
|
+
} else {
|
|
1118
|
+
tokens.push({ type: "ident", value: word, position: i });
|
|
1119
|
+
}
|
|
1120
|
+
i = j;
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
const three = input.slice(i, i + 3);
|
|
1124
|
+
if (three === "===" || three === "!==") {
|
|
1125
|
+
tokens.push({ type: "punc", value: three, position: i });
|
|
1126
|
+
i += 3;
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
const two = input.slice(i, i + 2);
|
|
1130
|
+
if (two === "=>") throw new Error("\u4E0D\u5141\u8BB8\u51FD\u6570\u5B9A\u4E49");
|
|
1131
|
+
if (["==", "!=", "<=", ">=", "&&", "||"].includes(two)) {
|
|
1132
|
+
tokens.push({ type: "punc", value: two, position: i });
|
|
1133
|
+
i += 2;
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
if (ch === "=") throw new Error("\u4E0D\u5141\u8BB8\u8D4B\u503C");
|
|
1137
|
+
if (ch === ";") throw new Error("\u4E0D\u5141\u8BB8\u591A\u6761\u8BED\u53E5");
|
|
1138
|
+
if ("+-*/%()[]{},:.?!<>".includes(ch)) {
|
|
1139
|
+
tokens.push({ type: "punc", value: ch, position: i });
|
|
1140
|
+
i++;
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
throw new Error(`\u975E\u6CD5\u5B57\u7B26: ${ch}`);
|
|
1144
|
+
}
|
|
1145
|
+
return tokens;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/parser.ts
|
|
1149
|
+
function parse(tokens) {
|
|
1150
|
+
const parser = new Parser(tokens);
|
|
1151
|
+
return parser.parse();
|
|
1152
|
+
}
|
|
1153
|
+
var Parser = class {
|
|
1154
|
+
constructor(tokens) {
|
|
1155
|
+
this.pos = 0;
|
|
1156
|
+
this.tokens = tokens;
|
|
1157
|
+
}
|
|
1158
|
+
parse() {
|
|
1159
|
+
const node = this.parseTernary();
|
|
1160
|
+
if (this.pos < this.tokens.length) {
|
|
1161
|
+
throw new Error(`\u8868\u8FBE\u5F0F\u5B58\u5728\u591A\u4F59\u5185\u5BB9: ${this.tokens[this.pos].value}`);
|
|
1162
|
+
}
|
|
1163
|
+
return node;
|
|
1164
|
+
}
|
|
1165
|
+
peek() {
|
|
1166
|
+
return this.tokens[this.pos];
|
|
1167
|
+
}
|
|
1168
|
+
next() {
|
|
1169
|
+
const t = this.tokens[this.pos++];
|
|
1170
|
+
if (!t) throw new Error("\u8868\u8FBE\u5F0F\u610F\u5916\u7ED3\u675F");
|
|
1171
|
+
return t;
|
|
1172
|
+
}
|
|
1173
|
+
eatPunc(value) {
|
|
1174
|
+
const t = this.peek();
|
|
1175
|
+
if (t && t.type === "punc" && t.value === value) {
|
|
1176
|
+
this.pos++;
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
return false;
|
|
1180
|
+
}
|
|
1181
|
+
expectPunc(value) {
|
|
1182
|
+
if (!this.eatPunc(value)) {
|
|
1183
|
+
const pos = this.peek()?.position ?? 0;
|
|
1184
|
+
throw new Error(`\u4F4D\u7F6E ${pos}: \u671F\u671B "${value}"`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
// 三元运算符 ?: (优先级最低)
|
|
1188
|
+
parseTernary() {
|
|
1189
|
+
const cond = this.parseLogicalOr();
|
|
1190
|
+
if (this.eatPunc("?")) {
|
|
1191
|
+
const consequent = this.parseTernary();
|
|
1192
|
+
this.expectPunc(":");
|
|
1193
|
+
const alternate = this.parseTernary();
|
|
1194
|
+
return { type: "ternary", cond, consequent, alternate };
|
|
1195
|
+
}
|
|
1196
|
+
return cond;
|
|
1197
|
+
}
|
|
1198
|
+
// ||
|
|
1199
|
+
parseLogicalOr() {
|
|
1200
|
+
let left = this.parseLogicalAnd();
|
|
1201
|
+
while (this.eatPunc("||")) {
|
|
1202
|
+
const right = this.parseLogicalAnd();
|
|
1203
|
+
left = { type: "binary", op: "||", left, right };
|
|
1204
|
+
}
|
|
1205
|
+
return left;
|
|
1206
|
+
}
|
|
1207
|
+
// &&
|
|
1208
|
+
parseLogicalAnd() {
|
|
1209
|
+
let left = this.parseEquality();
|
|
1210
|
+
while (this.eatPunc("&&")) {
|
|
1211
|
+
const right = this.parseEquality();
|
|
1212
|
+
left = { type: "binary", op: "&&", left, right };
|
|
1213
|
+
}
|
|
1214
|
+
return left;
|
|
1215
|
+
}
|
|
1216
|
+
// == != === !==
|
|
1217
|
+
parseEquality() {
|
|
1218
|
+
let left = this.parseRelational();
|
|
1219
|
+
for (; ; ) {
|
|
1220
|
+
const t = this.peek();
|
|
1221
|
+
if (t?.type === "punc" && ["==", "!=", "===", "!=="].includes(t.value)) {
|
|
1222
|
+
this.pos++;
|
|
1223
|
+
const right = this.parseRelational();
|
|
1224
|
+
left = { type: "binary", op: t.value, left, right };
|
|
1225
|
+
} else {
|
|
1226
|
+
return left;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
// < > <= >=
|
|
1231
|
+
parseRelational() {
|
|
1232
|
+
let left = this.parseAdditive();
|
|
1233
|
+
for (; ; ) {
|
|
1234
|
+
const t = this.peek();
|
|
1235
|
+
if (t?.type === "punc" && ["<", ">", "<=", ">="].includes(t.value)) {
|
|
1236
|
+
this.pos++;
|
|
1237
|
+
const right = this.parseAdditive();
|
|
1238
|
+
left = { type: "binary", op: t.value, left, right };
|
|
1239
|
+
} else {
|
|
1240
|
+
return left;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
// + - (二元)
|
|
1245
|
+
parseAdditive() {
|
|
1246
|
+
let left = this.parseMultiplicative();
|
|
1247
|
+
for (; ; ) {
|
|
1248
|
+
const t = this.peek();
|
|
1249
|
+
if (t?.type === "punc" && (t.value === "+" || t.value === "-")) {
|
|
1250
|
+
this.pos++;
|
|
1251
|
+
const right = this.parseMultiplicative();
|
|
1252
|
+
left = { type: "binary", op: t.value, left, right };
|
|
1253
|
+
} else {
|
|
1254
|
+
return left;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
// * / %
|
|
1259
|
+
parseMultiplicative() {
|
|
1260
|
+
let left = this.parseUnary();
|
|
1261
|
+
for (; ; ) {
|
|
1262
|
+
const t = this.peek();
|
|
1263
|
+
if (t?.type === "punc" && ["*", "/", "%"].includes(t.value)) {
|
|
1264
|
+
this.pos++;
|
|
1265
|
+
const right = this.parseUnary();
|
|
1266
|
+
left = { type: "binary", op: t.value, left, right };
|
|
1267
|
+
} else {
|
|
1268
|
+
return left;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
// 一元 ! - +
|
|
1273
|
+
parseUnary() {
|
|
1274
|
+
const t = this.peek();
|
|
1275
|
+
if (t?.type === "punc" && ["!", "-", "+"].includes(t.value)) {
|
|
1276
|
+
this.pos++;
|
|
1277
|
+
const arg = this.parseUnary();
|
|
1278
|
+
return { type: "unary", op: t.value, arg, prefix: true };
|
|
1279
|
+
}
|
|
1280
|
+
return this.parsePostfix();
|
|
1281
|
+
}
|
|
1282
|
+
// 成员访问 x.y, x[i], 函数调用 f()
|
|
1283
|
+
parsePostfix() {
|
|
1284
|
+
let node = this.parsePrimary();
|
|
1285
|
+
for (; ; ) {
|
|
1286
|
+
if (this.eatPunc(".")) {
|
|
1287
|
+
const prop = this.next();
|
|
1288
|
+
if (prop.type !== "ident") {
|
|
1289
|
+
throw new Error(`\u4F4D\u7F6E ${prop.position}: \u6210\u5458\u8BBF\u95EE\u9700\u8981\u5C5E\u6027\u540D`);
|
|
1290
|
+
}
|
|
1291
|
+
node = {
|
|
1292
|
+
type: "member",
|
|
1293
|
+
object: node,
|
|
1294
|
+
property: prop.value,
|
|
1295
|
+
computed: false
|
|
1296
|
+
};
|
|
1297
|
+
} else if (this.eatPunc("[")) {
|
|
1298
|
+
const index = this.parseTernary();
|
|
1299
|
+
this.expectPunc("]");
|
|
1300
|
+
if (index.type === "str") {
|
|
1301
|
+
node = {
|
|
1302
|
+
type: "member",
|
|
1303
|
+
object: node,
|
|
1304
|
+
property: index.value,
|
|
1305
|
+
computed: false
|
|
1306
|
+
};
|
|
1307
|
+
} else {
|
|
1308
|
+
node = {
|
|
1309
|
+
type: "member",
|
|
1310
|
+
object: node,
|
|
1311
|
+
property: index.name ?? String(index.value),
|
|
1312
|
+
computed: true
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
} else if (this.peek()?.type === "punc" && this.peek()?.value === "(" && (node.type === "ident" || node.type === "member")) {
|
|
1316
|
+
this.pos++;
|
|
1317
|
+
const args = this.parseArgs();
|
|
1318
|
+
node = { type: "call", callee: node, args };
|
|
1319
|
+
} else {
|
|
1320
|
+
return node;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
parseArgs() {
|
|
1325
|
+
const args = [];
|
|
1326
|
+
if (this.eatPunc(")")) return args;
|
|
1327
|
+
for (; ; ) {
|
|
1328
|
+
args.push(this.parseTernary());
|
|
1329
|
+
if (this.eatPunc(")")) return args;
|
|
1330
|
+
this.expectPunc(",");
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
parsePrimary() {
|
|
1334
|
+
const t = this.next();
|
|
1335
|
+
if (t.type === "num") {
|
|
1336
|
+
const v = Number(t.value);
|
|
1337
|
+
if (isNaN(v)) throw new Error(`\u975E\u6CD5\u6570\u5B57: ${t.value}`);
|
|
1338
|
+
return { type: "num", value: v };
|
|
1339
|
+
}
|
|
1340
|
+
if (t.type === "str") {
|
|
1341
|
+
return { type: "str", value: t.value };
|
|
1342
|
+
}
|
|
1343
|
+
if (t.type === "bool") {
|
|
1344
|
+
return { type: "bool", value: t.value === "true" };
|
|
1345
|
+
}
|
|
1346
|
+
if (t.type === "ident") {
|
|
1347
|
+
return { type: "ident", name: t.value };
|
|
1348
|
+
}
|
|
1349
|
+
if (t.value === "(") {
|
|
1350
|
+
const inner = this.parseTernary();
|
|
1351
|
+
this.expectPunc(")");
|
|
1352
|
+
return inner;
|
|
1353
|
+
}
|
|
1354
|
+
if (t.value === "[") {
|
|
1355
|
+
const elements = [];
|
|
1356
|
+
if (!this.eatPunc("]")) {
|
|
1357
|
+
for (; ; ) {
|
|
1358
|
+
elements.push(this.parseTernary());
|
|
1359
|
+
if (this.eatPunc("]")) break;
|
|
1360
|
+
this.expectPunc(",");
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return { type: "array", elements };
|
|
1364
|
+
}
|
|
1365
|
+
if (t.value === "{") {
|
|
1366
|
+
const properties = [];
|
|
1367
|
+
if (!this.eatPunc("}")) {
|
|
1368
|
+
for (; ; ) {
|
|
1369
|
+
const keyToken = this.next();
|
|
1370
|
+
if (keyToken.type !== "ident" && keyToken.type !== "str") {
|
|
1371
|
+
throw new Error(`\u4F4D\u7F6E ${keyToken.position}: \u5BF9\u8C61\u952E\u5FC5\u987B\u662F\u6807\u8BC6\u7B26\u6216\u5B57\u7B26\u4E32`);
|
|
1372
|
+
}
|
|
1373
|
+
this.expectPunc(":");
|
|
1374
|
+
properties.push({ key: keyToken.value, value: this.parseTernary() });
|
|
1375
|
+
if (this.eatPunc("}")) break;
|
|
1376
|
+
this.expectPunc(",");
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
return { type: "object", properties };
|
|
1380
|
+
}
|
|
1381
|
+
throw new Error(`\u4F4D\u7F6E ${t.position}: \u610F\u5916\u7684\u7B26\u53F7: ${t.value}`);
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// src/evaluator.ts
|
|
1386
|
+
var SAFE_GLOBALS = {
|
|
1387
|
+
Math,
|
|
1388
|
+
Number,
|
|
1389
|
+
String,
|
|
1390
|
+
Boolean,
|
|
1391
|
+
parseInt,
|
|
1392
|
+
parseFloat,
|
|
1393
|
+
isNaN,
|
|
1394
|
+
true: true,
|
|
1395
|
+
false: false,
|
|
1396
|
+
null: null,
|
|
1397
|
+
undefined: void 0
|
|
1398
|
+
};
|
|
1399
|
+
var DANGEROUS_PROPS2 = /* @__PURE__ */ new Set([
|
|
1400
|
+
"constructor",
|
|
1401
|
+
"__proto__",
|
|
1402
|
+
"prototype",
|
|
1403
|
+
"__defineGetter__",
|
|
1404
|
+
"__defineSetter__",
|
|
1405
|
+
"__lookupGetter__",
|
|
1406
|
+
"__lookupSetter__"
|
|
1407
|
+
]);
|
|
1408
|
+
var CALLABLE_GLOBALS = /* @__PURE__ */ new Set(["Number", "String", "Boolean", "parseInt", "parseFloat", "isNaN"]);
|
|
1409
|
+
function evaluate(node, context, functions = {}) {
|
|
1410
|
+
switch (node.type) {
|
|
1411
|
+
case "num":
|
|
1412
|
+
return node.value;
|
|
1413
|
+
case "str":
|
|
1414
|
+
return node.value;
|
|
1415
|
+
case "bool":
|
|
1416
|
+
return node.value;
|
|
1417
|
+
case "ident":
|
|
1418
|
+
return evalIdent(node.name, context, functions);
|
|
1419
|
+
case "binary":
|
|
1420
|
+
return evalBinary(node, context, functions);
|
|
1421
|
+
case "unary":
|
|
1422
|
+
return evalUnary(node, context, functions);
|
|
1423
|
+
case "ternary":
|
|
1424
|
+
return evaluate(node.cond, context, functions) ? evaluate(node.consequent, context, functions) : evaluate(node.alternate, context, functions);
|
|
1425
|
+
case "member":
|
|
1426
|
+
return evalMember(node, context, functions);
|
|
1427
|
+
case "call":
|
|
1428
|
+
return evalCall(node, context, functions);
|
|
1429
|
+
case "array":
|
|
1430
|
+
return node.elements.map((e) => evaluate(e, context, functions));
|
|
1431
|
+
case "object":
|
|
1432
|
+
return Object.fromEntries(
|
|
1433
|
+
node.properties.map((p) => [p.key, evaluate(p.value, context, functions)])
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
function evalIdent(name, context, functions) {
|
|
1438
|
+
if (Object.prototype.hasOwnProperty.call(context, name)) {
|
|
1439
|
+
return context[name];
|
|
1440
|
+
}
|
|
1441
|
+
if (Object.prototype.hasOwnProperty.call(SAFE_GLOBALS, name)) {
|
|
1442
|
+
return SAFE_GLOBALS[name];
|
|
1443
|
+
}
|
|
1444
|
+
throw new Error(`\u672A\u5B9A\u4E49\u7684\u6807\u8BC6\u7B26: ${name}`);
|
|
1445
|
+
}
|
|
1446
|
+
function evalBinary(node, context, functions) {
|
|
1447
|
+
const left = evaluate(node.left, context, functions);
|
|
1448
|
+
const right = evaluate(node.right, context, functions);
|
|
1449
|
+
switch (node.op) {
|
|
1450
|
+
case "+":
|
|
1451
|
+
return left + right;
|
|
1452
|
+
case "-":
|
|
1453
|
+
return left - right;
|
|
1454
|
+
case "*":
|
|
1455
|
+
return left * right;
|
|
1456
|
+
case "/":
|
|
1457
|
+
return left / right;
|
|
1458
|
+
case "%":
|
|
1459
|
+
return left % right;
|
|
1460
|
+
case "<":
|
|
1461
|
+
return left < right;
|
|
1462
|
+
case ">":
|
|
1463
|
+
return left > right;
|
|
1464
|
+
case "<=":
|
|
1465
|
+
return left <= right;
|
|
1466
|
+
case ">=":
|
|
1467
|
+
return left >= right;
|
|
1468
|
+
case "==":
|
|
1469
|
+
return left == right;
|
|
1470
|
+
case "!=":
|
|
1471
|
+
return left != right;
|
|
1472
|
+
case "===":
|
|
1473
|
+
return left === right;
|
|
1474
|
+
case "!==":
|
|
1475
|
+
return left !== right;
|
|
1476
|
+
case "&&":
|
|
1477
|
+
return left && right;
|
|
1478
|
+
case "||":
|
|
1479
|
+
return left || right;
|
|
1480
|
+
default:
|
|
1481
|
+
throw new Error(`\u672A\u77E5\u8FD0\u7B97\u7B26: ${node.op}`);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
function evalUnary(node, context, functions) {
|
|
1485
|
+
const arg = evaluate(node.arg, context, functions);
|
|
1486
|
+
switch (node.op) {
|
|
1487
|
+
case "-":
|
|
1488
|
+
return -arg;
|
|
1489
|
+
case "+":
|
|
1490
|
+
return +arg;
|
|
1491
|
+
case "!":
|
|
1492
|
+
return !arg;
|
|
1493
|
+
default:
|
|
1494
|
+
throw new Error(`\u672A\u77E5\u4E00\u5143\u8FD0\u7B97\u7B26: ${node.op}`);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
function evalMember(node, context, functions) {
|
|
1498
|
+
const obj = evaluate(node.object, context, functions);
|
|
1499
|
+
if (obj == null) {
|
|
1500
|
+
throw new Error("\u65E0\u6CD5\u8BBF\u95EE\u7A7A\u503C\u7684\u5C5E\u6027");
|
|
1501
|
+
}
|
|
1502
|
+
if (DANGEROUS_PROPS2.has(node.property)) {
|
|
1503
|
+
throw new Error(`\u7981\u6B62\u8BBF\u95EE\u5C5E\u6027: ${node.property}`);
|
|
1504
|
+
}
|
|
1505
|
+
return obj[node.property];
|
|
1506
|
+
}
|
|
1507
|
+
function evalCall(node, context, functions) {
|
|
1508
|
+
if (node.callee.type === "ident" && CALLABLE_GLOBALS.has(node.callee.name)) {
|
|
1509
|
+
const fn = SAFE_GLOBALS[node.callee.name];
|
|
1510
|
+
const args = node.args.map((a) => evaluate(a, context, functions));
|
|
1511
|
+
return fn(...args);
|
|
1512
|
+
}
|
|
1513
|
+
if (node.callee.type === "member" && node.callee.object.type === "ident" && node.callee.object.name === "Math") {
|
|
1514
|
+
const method = Math[node.callee.property];
|
|
1515
|
+
if (typeof method !== "function") {
|
|
1516
|
+
throw new Error(`Math.${node.callee.property} \u4E0D\u662F\u65B9\u6CD5`);
|
|
1517
|
+
}
|
|
1518
|
+
const args = node.args.map((a) => evaluate(a, context, functions));
|
|
1519
|
+
return method(...args);
|
|
1520
|
+
}
|
|
1521
|
+
let fnName;
|
|
1522
|
+
if (node.callee.type === "ident") {
|
|
1523
|
+
fnName = node.callee.name;
|
|
1524
|
+
} else if (node.callee.type === "member") {
|
|
1525
|
+
throw new Error("\u4E0D\u652F\u6301\u65B9\u6CD5\u8C03\u7528\uFF0C\u8BF7\u4F7F\u7528\u9876\u7EA7\u51FD\u6570");
|
|
1526
|
+
}
|
|
1527
|
+
if (fnName && functions[fnName]) {
|
|
1528
|
+
const args = node.args.map((a) => evaluate(a, context, functions));
|
|
1529
|
+
return functions[fnName](...args);
|
|
1530
|
+
}
|
|
1531
|
+
if (fnName && Object.prototype.hasOwnProperty.call(context, fnName)) {
|
|
1532
|
+
throw new Error(`${fnName} \u4E0D\u662F\u51FD\u6570`);
|
|
1533
|
+
}
|
|
1534
|
+
throw new Error(`\u4E0D\u5141\u8BB8\u8C03\u7528: ${fnName ?? "\u8868\u8FBE\u5F0F"}`);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// src/template-parser.ts
|
|
1538
|
+
function parseTemplate(template) {
|
|
1539
|
+
const parts = [];
|
|
1540
|
+
let i = 0;
|
|
1541
|
+
const n = template.length;
|
|
1542
|
+
while (i < n) {
|
|
1543
|
+
if (template[i] === "{") {
|
|
1544
|
+
let depth = 1;
|
|
1545
|
+
let j2 = i + 1;
|
|
1546
|
+
while (j2 < n && depth > 0) {
|
|
1547
|
+
if (template[j2] === "{") depth++;
|
|
1548
|
+
else if (template[j2] === "}") depth--;
|
|
1549
|
+
j2++;
|
|
1550
|
+
}
|
|
1551
|
+
if (depth !== 0) {
|
|
1552
|
+
throw new Error(`\u4F4D\u7F6E ${i}: \u82B1\u62EC\u53F7\u672A\u95ED\u5408`);
|
|
1553
|
+
}
|
|
1554
|
+
const exprStr = template.slice(i + 1, j2 - 1);
|
|
1555
|
+
if (exprStr.trim() === "") {
|
|
1556
|
+
throw new Error(`\u4F4D\u7F6E ${i}: \u7A7A\u8868\u8FBE\u5F0F`);
|
|
1557
|
+
}
|
|
1558
|
+
const tokens = tokenize(exprStr);
|
|
1559
|
+
const expression = parse(tokens);
|
|
1560
|
+
parts.push({ type: "expr", expression });
|
|
1561
|
+
i = j2;
|
|
1562
|
+
continue;
|
|
1563
|
+
}
|
|
1564
|
+
let j = i;
|
|
1565
|
+
while (j < n && template[j] !== "{") {
|
|
1566
|
+
if (template[j] === "\\" && j + 1 < n && (template[j + 1] === "{" || template[j + 1] === "}")) {
|
|
1567
|
+
j += 2;
|
|
1568
|
+
} else {
|
|
1569
|
+
j++;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
parts.push({ type: "text", value: template.slice(i, j).replace(/\\([{}])/g, "$1") });
|
|
1573
|
+
i = j;
|
|
1574
|
+
}
|
|
1575
|
+
return { type: "template", parts };
|
|
1576
|
+
}
|
|
1577
|
+
function renderTemplate(ast, context, functions = {}) {
|
|
1578
|
+
let result = "";
|
|
1579
|
+
for (const part of ast.parts) {
|
|
1580
|
+
if (part.type === "text") {
|
|
1581
|
+
result += part.value;
|
|
1582
|
+
} else {
|
|
1583
|
+
const value = evaluate(part.expression, context, functions);
|
|
1584
|
+
result += String(value ?? "");
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
return result;
|
|
1588
|
+
}
|
|
1589
|
+
function compileTemplate(template, functions = {}) {
|
|
1590
|
+
const ast = parseTemplate(template);
|
|
1591
|
+
return (context) => renderTemplate(ast, context, functions);
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// src/utils.ts
|
|
1595
|
+
function getByPath(obj, path) {
|
|
1596
|
+
if (obj == null || path == null) return void 0;
|
|
1597
|
+
if (typeof obj === "object" && path in obj) return obj[path];
|
|
1598
|
+
const parts = path.split(".");
|
|
1599
|
+
let cur = obj;
|
|
1600
|
+
for (const p of parts) {
|
|
1601
|
+
if (cur == null) return void 0;
|
|
1602
|
+
cur = cur[p];
|
|
1603
|
+
}
|
|
1604
|
+
return cur;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
// src/functions/format.ts
|
|
1608
|
+
function formatMoney(value) {
|
|
1609
|
+
const num = Number(value);
|
|
1610
|
+
if (isNaN(num)) return String(value);
|
|
1611
|
+
const sign = num < 0 ? "-" : "";
|
|
1612
|
+
const abs = Math.abs(num);
|
|
1613
|
+
const [intPart, decPart] = abs.toFixed(2).split(".");
|
|
1614
|
+
const formatted = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1615
|
+
return `${sign}${formatted}.${decPart}`;
|
|
1616
|
+
}
|
|
1617
|
+
function formatDate(value, fmt) {
|
|
1618
|
+
let date;
|
|
1619
|
+
if (value instanceof Date) {
|
|
1620
|
+
date = value;
|
|
1621
|
+
} else if (typeof value === "number") {
|
|
1622
|
+
date = new Date(value);
|
|
1623
|
+
} else if (typeof value === "string") {
|
|
1624
|
+
date = new Date(value);
|
|
1625
|
+
} else {
|
|
1626
|
+
return String(value);
|
|
1627
|
+
}
|
|
1628
|
+
if (isNaN(date.getTime())) return String(value);
|
|
1629
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
1630
|
+
return fmt.replace("YYYY", String(date.getFullYear())).replace("MM", pad(date.getMonth() + 1)).replace("DD", pad(date.getDate())).replace("HH", pad(date.getHours())).replace("mm", pad(date.getMinutes())).replace("ss", pad(date.getSeconds()));
|
|
1631
|
+
}
|
|
1632
|
+
function toUpperCaseAmount(value) {
|
|
1633
|
+
const num = Number(value);
|
|
1634
|
+
if (isNaN(num)) return String(value);
|
|
1635
|
+
if (num === 0) return "\u96F6\u5143\u6574";
|
|
1636
|
+
const digits = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
|
|
1637
|
+
const units = ["", "\u62FE", "\u4F70", "\u4EDF"];
|
|
1638
|
+
const bigUnits = ["", "\u4E07", "\u4EBF"];
|
|
1639
|
+
const sign = num < 0 ? "\u8D1F" : "";
|
|
1640
|
+
const abs = Math.abs(num);
|
|
1641
|
+
const [intStr, decStr] = abs.toFixed(2).split(".");
|
|
1642
|
+
const intNum = parseInt(intStr, 10);
|
|
1643
|
+
let result = "";
|
|
1644
|
+
if (intNum > 0) {
|
|
1645
|
+
const intChars = intStr.split("").reverse();
|
|
1646
|
+
let groupIdx = 0;
|
|
1647
|
+
let lastDigit = 0;
|
|
1648
|
+
let needZero = false;
|
|
1649
|
+
for (let i = 0; i < intChars.length; i++) {
|
|
1650
|
+
const d = parseInt(intChars[i], 10);
|
|
1651
|
+
const unit = units[groupIdx % 4];
|
|
1652
|
+
const bigUnit = bigUnits[Math.floor(groupIdx / 4)];
|
|
1653
|
+
if (d === 0) {
|
|
1654
|
+
if (lastDigit !== 0) needZero = true;
|
|
1655
|
+
} else {
|
|
1656
|
+
if (needZero) {
|
|
1657
|
+
result = "\u96F6" + result;
|
|
1658
|
+
needZero = false;
|
|
1659
|
+
}
|
|
1660
|
+
result = digits[d] + unit + result;
|
|
1661
|
+
lastDigit = d;
|
|
1662
|
+
}
|
|
1663
|
+
if (groupIdx % 4 === 3 && groupIdx > 0) {
|
|
1664
|
+
result = bigUnit + result;
|
|
1665
|
+
}
|
|
1666
|
+
groupIdx++;
|
|
1667
|
+
}
|
|
1668
|
+
result += "\u5143";
|
|
1669
|
+
}
|
|
1670
|
+
const jiao = parseInt(decStr[0], 10);
|
|
1671
|
+
const fen = parseInt(decStr[1], 10);
|
|
1672
|
+
if (jiao === 0 && fen === 0) {
|
|
1673
|
+
result += "\u6574";
|
|
1674
|
+
} else {
|
|
1675
|
+
if (jiao > 0) {
|
|
1676
|
+
result += digits[jiao] + "\u89D2";
|
|
1677
|
+
}
|
|
1678
|
+
if (fen > 0) {
|
|
1679
|
+
result += digits[fen] + "\u5206";
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
return sign + result;
|
|
1683
|
+
}
|
|
1684
|
+
function ifFn(condition, trueVal, falseVal) {
|
|
1685
|
+
return condition ? trueVal : falseVal;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// src/functions/aggregate.ts
|
|
1689
|
+
function sum(rows, field) {
|
|
1690
|
+
return rows.reduce((acc, row) => acc + (Number(getByPath(row, field)) || 0), 0);
|
|
1691
|
+
}
|
|
1692
|
+
function avg(rows, field) {
|
|
1693
|
+
if (rows.length === 0) return 0;
|
|
1694
|
+
return sum(rows, field) / rows.length;
|
|
1695
|
+
}
|
|
1696
|
+
function count(rows, field) {
|
|
1697
|
+
return rows.length;
|
|
1698
|
+
}
|
|
1699
|
+
function min(rows, field) {
|
|
1700
|
+
if (rows.length === 0) return 0;
|
|
1701
|
+
return Math.min(...rows.map((row) => Number(getByPath(row, field)) || 0));
|
|
1702
|
+
}
|
|
1703
|
+
function max(rows, field) {
|
|
1704
|
+
if (rows.length === 0) return 0;
|
|
1705
|
+
return Math.max(...rows.map((row) => Number(getByPath(row, field)) || 0));
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// src/render/expression-eval.ts
|
|
1709
|
+
var RenderEngine = class {
|
|
1710
|
+
constructor() {
|
|
1711
|
+
this.functions = {};
|
|
1712
|
+
}
|
|
1713
|
+
registerFunction(name, fn) {
|
|
1714
|
+
this.functions[name] = fn;
|
|
1715
|
+
}
|
|
1716
|
+
evaluate(expression, context) {
|
|
1717
|
+
const tokens = tokenize(expression);
|
|
1718
|
+
const ast = parse(tokens);
|
|
1719
|
+
return evaluate(ast, context, this.functions);
|
|
1720
|
+
}
|
|
1721
|
+
render(template, context) {
|
|
1722
|
+
return compileTemplate(template, this.functions)(context);
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
var engine = new RenderEngine();
|
|
1726
|
+
var FORMAT_FUNCTIONS = {
|
|
1727
|
+
MONEY: formatMoney,
|
|
1728
|
+
DATE: formatDate,
|
|
1729
|
+
UPPER: toUpperCaseAmount,
|
|
1730
|
+
IF: ifFn,
|
|
1731
|
+
CONCAT: (...args) => args.filter((v) => v != null).map(String).join(""),
|
|
1732
|
+
IFEMPTY: (v, d) => v != null && v !== "" ? String(v) : d,
|
|
1733
|
+
ROUND: (n, d) => Number(Number(n).toFixed(d)),
|
|
1734
|
+
LEN: (s) => String(s).length
|
|
1735
|
+
};
|
|
1736
|
+
for (const [name, fn] of Object.entries(FORMAT_FUNCTIONS)) {
|
|
1737
|
+
engine.registerFunction(name, fn);
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
// src/index.ts
|
|
1741
|
+
var TemplateEngine = class {
|
|
1742
|
+
constructor(options) {
|
|
1743
|
+
this.functions = {};
|
|
1744
|
+
if (options?.functions) {
|
|
1745
|
+
this.functions = { ...options.functions };
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
registerFunction(name, fn) {
|
|
1749
|
+
this.functions[name] = fn;
|
|
1750
|
+
}
|
|
1751
|
+
evaluate(expression, context) {
|
|
1752
|
+
const tokens = tokenize(expression);
|
|
1753
|
+
const ast = parse(tokens);
|
|
1754
|
+
return evaluate(ast, context, this.functions);
|
|
1755
|
+
}
|
|
1756
|
+
render(template, context) {
|
|
1757
|
+
return compileTemplate(template, this.functions)(context);
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
// src/designer/utils/engine.ts
|
|
1762
|
+
var engine2 = new TemplateEngine();
|
|
1763
|
+
|
|
1764
|
+
// src/designer/utils/expression-eval.ts
|
|
1765
|
+
var EXTENDED_FUNCTIONS = {
|
|
1766
|
+
MONEY: formatMoney,
|
|
1767
|
+
CONCAT: (...args) => args.filter((v) => v != null).join(""),
|
|
1768
|
+
IF: ifFn,
|
|
1769
|
+
FORMAT: (value) => {
|
|
1770
|
+
if (typeof value !== "number") return String(value);
|
|
1771
|
+
return value.toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
1772
|
+
},
|
|
1773
|
+
SUBSTR: (str, start, len) => String(str).slice(start, len ? start + len : void 0),
|
|
1774
|
+
LEN: (str) => String(str).length,
|
|
1775
|
+
ROUND: (num, decimals) => Number(Number(num).toFixed(decimals)),
|
|
1776
|
+
NOW: () => (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
1777
|
+
IFEMPTY: (value, defaultVal) => value != null && value !== "" ? String(value) : defaultVal,
|
|
1778
|
+
PAD: (value, len, char) => String(value).padStart(len, char),
|
|
1779
|
+
REPLACE: (str, from, to) => String(str).replace(new RegExp(from, "g"), to),
|
|
1780
|
+
JSON: (value) => JSON.stringify(value, null, 2),
|
|
1781
|
+
DATE: formatDate,
|
|
1782
|
+
UPPER: toUpperCaseAmount
|
|
1783
|
+
};
|
|
1784
|
+
for (const [name, fn] of Object.entries(EXTENDED_FUNCTIONS)) {
|
|
1785
|
+
engine2.registerFunction(name, fn);
|
|
1786
|
+
}
|
|
1787
|
+
function aggregate(fn, field, rows) {
|
|
1788
|
+
switch (fn.toUpperCase()) {
|
|
1789
|
+
case "SUM":
|
|
1790
|
+
return sum(rows, field);
|
|
1791
|
+
case "AVG":
|
|
1792
|
+
return avg(rows, field);
|
|
1793
|
+
case "COUNT":
|
|
1794
|
+
return count(rows, field);
|
|
1795
|
+
case "MIN":
|
|
1796
|
+
return min(rows, field);
|
|
1797
|
+
case "MAX":
|
|
1798
|
+
return max(rows, field);
|
|
1799
|
+
default:
|
|
1800
|
+
return 0;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
function safeEval2(expr, context, _callableNames) {
|
|
1804
|
+
return engine2.evaluate(expr, context);
|
|
1805
|
+
}
|
|
1806
|
+
function evaluateTemplate2(text, ctx) {
|
|
1807
|
+
if (!text) return "";
|
|
1808
|
+
if (!text.includes("{")) return text;
|
|
1809
|
+
const rows = Array.isArray(ctx.rows) ? ctx.rows : [];
|
|
1810
|
+
let processedText = text.replace(/\{([^}]+)\}/g, (_match, inner) => {
|
|
1811
|
+
let expr = inner.trim();
|
|
1812
|
+
expr = expr.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g, (_m, fn, arg) => {
|
|
1813
|
+
const field = arg.trim().replace(/^['"]|['"]$/g, "");
|
|
1814
|
+
return String(aggregate(fn, field, rows));
|
|
1815
|
+
});
|
|
1816
|
+
return `{${expr}}`;
|
|
1817
|
+
});
|
|
1818
|
+
try {
|
|
1819
|
+
const result = engine2.render(processedText, ctx);
|
|
1820
|
+
return result;
|
|
1821
|
+
} catch {
|
|
1822
|
+
return text;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// src/designer/utils/binding.ts
|
|
1827
|
+
function createFieldElement(field) {
|
|
1828
|
+
return createRuntimeElement("text", {
|
|
1829
|
+
formatter: `{${field.fieldKey}}`,
|
|
1830
|
+
title: field.fieldLabel
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
function resolveTextBinding(options, data) {
|
|
1834
|
+
if (options.formatter) {
|
|
1835
|
+
if (!data || data.length === 0) return "";
|
|
1836
|
+
const row = data[0];
|
|
1837
|
+
try {
|
|
1838
|
+
return engine2.render(options.formatter, row ?? {});
|
|
1839
|
+
} catch {
|
|
1840
|
+
return options.formatter;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
return "";
|
|
1844
|
+
}
|
|
1845
|
+
function lookupDemoPath(path) {
|
|
1846
|
+
let cur = DEFAULT_DEMO_DATA;
|
|
1847
|
+
for (const seg of path.split(".")) {
|
|
1848
|
+
if (cur == null) return void 0;
|
|
1849
|
+
cur = Array.isArray(cur) ? cur[0]?.[seg] : cur[seg];
|
|
1850
|
+
}
|
|
1851
|
+
return cur;
|
|
1852
|
+
}
|
|
1853
|
+
function resolveBarcodeDesignValue(formatter, listSource) {
|
|
1854
|
+
const first = listSource?.[0];
|
|
1855
|
+
const resolved = (formatter ?? "").replace(/\{([^{}]+)\}/g, (_, expr) => {
|
|
1856
|
+
const key = expr.trim();
|
|
1857
|
+
const v = key.includes(".") ? lookupDemoPath(key) : first?.[key] ?? lookupDemoPath(key);
|
|
1858
|
+
return v == null ? "" : String(v);
|
|
1859
|
+
}).trim();
|
|
1860
|
+
return resolved || "1234567890128";
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
// src/designer/interactions/adsorb.ts
|
|
1864
|
+
var SNAP_COLORS = {
|
|
1865
|
+
left: "#3b82f6",
|
|
1866
|
+
center: "#10b981",
|
|
1867
|
+
right: "#f59e0b",
|
|
1868
|
+
top: "#3b82f6",
|
|
1869
|
+
middle: "#10b981",
|
|
1870
|
+
bottom: "#f59e0b"
|
|
1871
|
+
};
|
|
1872
|
+
function snapColor(mk) {
|
|
1873
|
+
if (mk === "vCenter") return SNAP_COLORS.center;
|
|
1874
|
+
if (mk === "hCenter") return SNAP_COLORS.middle;
|
|
1875
|
+
return SNAP_COLORS[mk] ?? SNAP_COLORS.left;
|
|
1876
|
+
}
|
|
1877
|
+
function computeAdsorb(movingRect, others, manualGuides, config = {}) {
|
|
1878
|
+
const adsorbMin = config.adsorbMin ?? 1;
|
|
1879
|
+
const adsorbLineMin = config.adsorbLineMin ?? 2;
|
|
1880
|
+
const showAdsorbLine = config.showAdsorbLine ?? true;
|
|
1881
|
+
let left = movingRect.left;
|
|
1882
|
+
let top = movingRect.top;
|
|
1883
|
+
const lines = [];
|
|
1884
|
+
const m = {
|
|
1885
|
+
left: movingRect.left,
|
|
1886
|
+
right: movingRect.left + movingRect.width,
|
|
1887
|
+
vCenter: movingRect.left + movingRect.width / 2,
|
|
1888
|
+
top: movingRect.top,
|
|
1889
|
+
bottom: movingRect.top + movingRect.height,
|
|
1890
|
+
hCenter: movingRect.top + movingRect.height / 2
|
|
1891
|
+
};
|
|
1892
|
+
let minDist = Infinity;
|
|
1893
|
+
for (const other of others) {
|
|
1894
|
+
if (other.id === movingRect.id) continue;
|
|
1895
|
+
const o = {
|
|
1896
|
+
left: other.left,
|
|
1897
|
+
right: other.left + other.width,
|
|
1898
|
+
vCenter: other.left + other.width / 2,
|
|
1899
|
+
top: other.top,
|
|
1900
|
+
bottom: other.top + other.height,
|
|
1901
|
+
hCenter: other.top + other.height / 2
|
|
1902
|
+
};
|
|
1903
|
+
const hPairs = [
|
|
1904
|
+
["left", "left"],
|
|
1905
|
+
["left", "vCenter"],
|
|
1906
|
+
["left", "right"],
|
|
1907
|
+
["vCenter", "left"],
|
|
1908
|
+
["vCenter", "vCenter"],
|
|
1909
|
+
["vCenter", "right"],
|
|
1910
|
+
["right", "left"],
|
|
1911
|
+
["right", "vCenter"],
|
|
1912
|
+
["right", "right"]
|
|
1913
|
+
];
|
|
1914
|
+
const vPairs = [
|
|
1915
|
+
["top", "top"],
|
|
1916
|
+
["top", "hCenter"],
|
|
1917
|
+
["top", "bottom"],
|
|
1918
|
+
["hCenter", "top"],
|
|
1919
|
+
["hCenter", "hCenter"],
|
|
1920
|
+
["hCenter", "bottom"],
|
|
1921
|
+
["bottom", "top"],
|
|
1922
|
+
["bottom", "hCenter"],
|
|
1923
|
+
["bottom", "bottom"]
|
|
1924
|
+
];
|
|
1925
|
+
for (const [mk, ok] of hPairs) {
|
|
1926
|
+
const dist = Math.abs(m[mk] - o[ok]);
|
|
1927
|
+
if (dist <= adsorbMin && dist < minDist) {
|
|
1928
|
+
minDist = dist;
|
|
1929
|
+
left = movingRect.left + (o[ok] - m[mk]);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
for (const [mk, ok] of vPairs) {
|
|
1933
|
+
const dist = Math.abs(m[mk] - o[ok]);
|
|
1934
|
+
if (dist <= adsorbMin && dist < minDist) {
|
|
1935
|
+
minDist = dist;
|
|
1936
|
+
top = movingRect.top + (o[ok] - m[mk]);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (manualGuides) {
|
|
1941
|
+
const m2 = {
|
|
1942
|
+
left,
|
|
1943
|
+
right: left + movingRect.width,
|
|
1944
|
+
vCenter: left + movingRect.width / 2,
|
|
1945
|
+
top,
|
|
1946
|
+
bottom: top + movingRect.height,
|
|
1947
|
+
hCenter: top + movingRect.height / 2
|
|
1948
|
+
};
|
|
1949
|
+
const hKeys = ["left", "vCenter", "right"];
|
|
1950
|
+
for (const pos of manualGuides.vertical) {
|
|
1951
|
+
for (const k of hKeys) {
|
|
1952
|
+
const d = Math.abs(m2[k] - pos);
|
|
1953
|
+
if (d <= adsorbMin && d < minDist) {
|
|
1954
|
+
minDist = d;
|
|
1955
|
+
left = movingRect.left + (pos - m2[k]);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
const vKeys = ["top", "hCenter", "bottom"];
|
|
1960
|
+
for (const pos of manualGuides.horizontal) {
|
|
1961
|
+
for (const k of vKeys) {
|
|
1962
|
+
const d = Math.abs(m2[k] - pos);
|
|
1963
|
+
if (d <= adsorbMin && d < minDist) {
|
|
1964
|
+
minDist = d;
|
|
1965
|
+
top = movingRect.top + (pos - m2[k]);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
const adjustedM = {
|
|
1971
|
+
left,
|
|
1972
|
+
right: left + movingRect.width,
|
|
1973
|
+
vCenter: left + movingRect.width / 2,
|
|
1974
|
+
top,
|
|
1975
|
+
bottom: top + movingRect.height,
|
|
1976
|
+
hCenter: top + movingRect.height / 2
|
|
1977
|
+
};
|
|
1978
|
+
if (showAdsorbLine) {
|
|
1979
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1980
|
+
for (const other of others) {
|
|
1981
|
+
if (other.id === movingRect.id) continue;
|
|
1982
|
+
const o = {
|
|
1983
|
+
left: other.left,
|
|
1984
|
+
right: other.left + other.width,
|
|
1985
|
+
vCenter: other.left + other.width / 2,
|
|
1986
|
+
top: other.top,
|
|
1987
|
+
bottom: other.top + other.height,
|
|
1988
|
+
hCenter: other.top + other.height / 2
|
|
1989
|
+
};
|
|
1990
|
+
const hPairs = [
|
|
1991
|
+
["left", "left"],
|
|
1992
|
+
["left", "vCenter"],
|
|
1993
|
+
["left", "right"],
|
|
1994
|
+
["vCenter", "left"],
|
|
1995
|
+
["vCenter", "vCenter"],
|
|
1996
|
+
["vCenter", "right"],
|
|
1997
|
+
["right", "left"],
|
|
1998
|
+
["right", "vCenter"],
|
|
1999
|
+
["right", "right"]
|
|
2000
|
+
];
|
|
2001
|
+
const vPairs = [
|
|
2002
|
+
["top", "top"],
|
|
2003
|
+
["top", "hCenter"],
|
|
2004
|
+
["top", "bottom"],
|
|
2005
|
+
["hCenter", "top"],
|
|
2006
|
+
["hCenter", "hCenter"],
|
|
2007
|
+
["hCenter", "bottom"],
|
|
2008
|
+
["bottom", "top"],
|
|
2009
|
+
["bottom", "hCenter"],
|
|
2010
|
+
["bottom", "bottom"]
|
|
2011
|
+
];
|
|
2012
|
+
for (const [mk, ok] of hPairs) {
|
|
2013
|
+
const dist = Math.abs(adjustedM[mk] - o[ok]);
|
|
2014
|
+
if (dist <= adsorbLineMin) {
|
|
2015
|
+
const key = `v:${o[ok]}`;
|
|
2016
|
+
if (!seen.has(key)) {
|
|
2017
|
+
seen.add(key);
|
|
2018
|
+
lines.push({ type: "vertical", position: o[ok], id: other.id, color: snapColor(mk) });
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
for (const [mk, ok] of vPairs) {
|
|
2023
|
+
const dist = Math.abs(adjustedM[mk] - o[ok]);
|
|
2024
|
+
if (dist <= adsorbLineMin) {
|
|
2025
|
+
const key = `h:${o[ok]}`;
|
|
2026
|
+
if (!seen.has(key)) {
|
|
2027
|
+
seen.add(key);
|
|
2028
|
+
lines.push({ type: "horizontal", position: o[ok], id: other.id, color: snapColor(mk) });
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
if (manualGuides) {
|
|
2035
|
+
for (const pos of manualGuides.vertical) {
|
|
2036
|
+
if (!lines.some((l) => l.type === "vertical" && l.position === pos)) {
|
|
2037
|
+
lines.push({ type: "vertical", position: pos });
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
for (const pos of manualGuides.horizontal) {
|
|
2041
|
+
if (!lines.some((l) => l.type === "horizontal" && l.position === pos)) {
|
|
2042
|
+
lines.push({ type: "horizontal", position: pos });
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
return { left, top, lines };
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
// src/designer/interactions/useAlign.ts
|
|
2050
|
+
function useAlign() {
|
|
2051
|
+
function align(elements, mode) {
|
|
2052
|
+
if (elements.length < 2) return;
|
|
2053
|
+
const bounds = {
|
|
2054
|
+
minLeft: Math.min(...elements.map((e) => e.options.left)),
|
|
2055
|
+
maxRight: Math.max(...elements.map((e) => e.options.left + e.options.width)),
|
|
2056
|
+
minTop: Math.min(...elements.map((e) => e.options.top)),
|
|
2057
|
+
maxBottom: Math.max(...elements.map((e) => e.options.top + e.options.height))
|
|
2058
|
+
};
|
|
2059
|
+
switch (mode) {
|
|
2060
|
+
case "left":
|
|
2061
|
+
elements.forEach((e) => {
|
|
2062
|
+
e.options.left = bounds.minLeft;
|
|
2063
|
+
});
|
|
2064
|
+
break;
|
|
2065
|
+
case "right":
|
|
2066
|
+
elements.forEach((e) => {
|
|
2067
|
+
e.options.left = bounds.maxRight - e.options.width;
|
|
2068
|
+
});
|
|
2069
|
+
break;
|
|
2070
|
+
case "top":
|
|
2071
|
+
elements.forEach((e) => {
|
|
2072
|
+
e.options.top = bounds.minTop;
|
|
2073
|
+
});
|
|
2074
|
+
break;
|
|
2075
|
+
case "bottom":
|
|
2076
|
+
elements.forEach((e) => {
|
|
2077
|
+
e.options.top = bounds.maxBottom - e.options.height;
|
|
2078
|
+
});
|
|
2079
|
+
break;
|
|
2080
|
+
case "vertical": {
|
|
2081
|
+
const centerX = bounds.minLeft + (bounds.maxRight - bounds.minLeft) / 2;
|
|
2082
|
+
elements.forEach((e) => {
|
|
2083
|
+
e.options.left = centerX - e.options.width / 2;
|
|
2084
|
+
});
|
|
2085
|
+
break;
|
|
2086
|
+
}
|
|
2087
|
+
case "horizontal": {
|
|
2088
|
+
const centerY = bounds.minTop + (bounds.maxBottom - bounds.minTop) / 2;
|
|
2089
|
+
elements.forEach((e) => {
|
|
2090
|
+
e.options.top = centerY - e.options.height / 2;
|
|
2091
|
+
});
|
|
2092
|
+
break;
|
|
2093
|
+
}
|
|
2094
|
+
case "distributeHor": {
|
|
2095
|
+
const sorted = [...elements].sort((a, b) => a.options.left - b.options.left);
|
|
2096
|
+
const totalW = sorted.reduce((s, e) => s + e.options.width, 0);
|
|
2097
|
+
const gap = (bounds.maxRight - bounds.minLeft - totalW) / (sorted.length - 1);
|
|
2098
|
+
let x = bounds.minLeft;
|
|
2099
|
+
sorted.forEach((e) => {
|
|
2100
|
+
e.options.left = x;
|
|
2101
|
+
x += e.options.width + gap;
|
|
2102
|
+
});
|
|
2103
|
+
break;
|
|
2104
|
+
}
|
|
2105
|
+
case "distributeVer": {
|
|
2106
|
+
const sorted = [...elements].sort((a, b) => a.options.top - b.options.top);
|
|
2107
|
+
const totalH = sorted.reduce((s, e) => s + e.options.height, 0);
|
|
2108
|
+
const gap = (bounds.maxBottom - bounds.minTop - totalH) / (sorted.length - 1);
|
|
2109
|
+
let y = bounds.minTop;
|
|
2110
|
+
sorted.forEach((e) => {
|
|
2111
|
+
e.options.top = y;
|
|
2112
|
+
y += e.options.height + gap;
|
|
2113
|
+
});
|
|
2114
|
+
break;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
return { align };
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
// src/designer/interactions/useGroup.ts
|
|
2122
|
+
function generateGroupId() {
|
|
2123
|
+
return `grp-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
2124
|
+
}
|
|
2125
|
+
function useGroup() {
|
|
2126
|
+
function group(elements, selectedIds) {
|
|
2127
|
+
const selected = elements.filter((e) => selectedIds.has(e.id));
|
|
2128
|
+
if (selected.length < 2) return elements;
|
|
2129
|
+
const groupId = generateGroupId();
|
|
2130
|
+
return elements.map(
|
|
2131
|
+
(e) => selectedIds.has(e.id) ? { ...e, options: { ...e.options, groupId } } : e
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
function ungroup(elements, selectedIds) {
|
|
2135
|
+
const selected = elements.filter((e) => selectedIds.has(e.id));
|
|
2136
|
+
const groupIds = new Set(selected.map((e) => e.options.groupId).filter(Boolean));
|
|
2137
|
+
return elements.map(
|
|
2138
|
+
(e) => e.options.groupId && groupIds.has(e.options.groupId) ? { ...e, options: { ...e.options, groupId: void 0 } } : e
|
|
2139
|
+
);
|
|
2140
|
+
}
|
|
2141
|
+
function getGroupedIds(elements, selectedId) {
|
|
2142
|
+
const el = elements.find((e) => e.id === selectedId);
|
|
2143
|
+
if (!el?.options.groupId) return /* @__PURE__ */ new Set([selectedId]);
|
|
2144
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2145
|
+
for (const e of elements) {
|
|
2146
|
+
if (e.options.groupId === el.options.groupId) {
|
|
2147
|
+
ids.add(e.id);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
return ids;
|
|
2151
|
+
}
|
|
2152
|
+
return { group, ungroup, getGroupedIds };
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
// src/designer/interactions/useKeyboard.ts
|
|
2156
|
+
var STEP = 1;
|
|
2157
|
+
var STEP_LARGE = 10;
|
|
2158
|
+
var STEP_SMALL = 0.5;
|
|
2159
|
+
function useKeyboard(handlers) {
|
|
2160
|
+
function onKeyDown(e) {
|
|
2161
|
+
const tag = e.target.tagName;
|
|
2162
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return;
|
|
2163
|
+
const ctrl = e.ctrlKey || e.metaKey;
|
|
2164
|
+
if (e.key.startsWith("Arrow")) {
|
|
2165
|
+
e.preventDefault();
|
|
2166
|
+
const step = e.shiftKey ? STEP_LARGE : e.ctrlKey ? STEP_SMALL : STEP;
|
|
2167
|
+
const dx = e.key === "ArrowLeft" ? -step : e.key === "ArrowRight" ? step : 0;
|
|
2168
|
+
const dy = e.key === "ArrowUp" ? -step : e.key === "ArrowDown" ? step : 0;
|
|
2169
|
+
handlers.onMove?.(dx, dy);
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2172
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
2173
|
+
e.preventDefault();
|
|
2174
|
+
handlers.onDelete?.();
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
if (ctrl) {
|
|
2178
|
+
const k = e.key.toLowerCase();
|
|
2179
|
+
if (k === "c") {
|
|
2180
|
+
e.preventDefault();
|
|
2181
|
+
handlers.onCopy?.();
|
|
2182
|
+
} else if (k === "v") {
|
|
2183
|
+
e.preventDefault();
|
|
2184
|
+
handlers.onPaste?.();
|
|
2185
|
+
} else if (k === "a") {
|
|
2186
|
+
e.preventDefault();
|
|
2187
|
+
handlers.onSelectAll?.();
|
|
2188
|
+
} else if (k === "d") {
|
|
2189
|
+
e.preventDefault();
|
|
2190
|
+
handlers.onDuplicate?.();
|
|
2191
|
+
} else if (k === "z") {
|
|
2192
|
+
e.preventDefault();
|
|
2193
|
+
e.shiftKey ? handlers.onRedo?.() : handlers.onUndo?.();
|
|
2194
|
+
} else if (k === "y") {
|
|
2195
|
+
e.preventDefault();
|
|
2196
|
+
handlers.onRedo?.();
|
|
2197
|
+
} else if (k === "1") {
|
|
2198
|
+
e.preventDefault();
|
|
2199
|
+
handlers.onResetZoom?.();
|
|
2200
|
+
} else if (k === "l") {
|
|
2201
|
+
e.preventDefault();
|
|
2202
|
+
handlers.onAlignLeft?.();
|
|
2203
|
+
} else if (k === "r") {
|
|
2204
|
+
e.preventDefault();
|
|
2205
|
+
handlers.onAlignRight?.();
|
|
2206
|
+
} else if (k === "e") {
|
|
2207
|
+
e.preventDefault();
|
|
2208
|
+
handlers.onAlignCenterH?.();
|
|
2209
|
+
} else if (k === "t") {
|
|
2210
|
+
e.preventDefault();
|
|
2211
|
+
handlers.onAlignTop?.();
|
|
2212
|
+
} else if (k === "b") {
|
|
2213
|
+
e.preventDefault();
|
|
2214
|
+
handlers.onAlignBottom?.();
|
|
2215
|
+
} else if (k === "g") {
|
|
2216
|
+
e.preventDefault();
|
|
2217
|
+
e.shiftKey ? handlers.onUngroup?.() : handlers.onGroup?.();
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
function setup() {
|
|
2222
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2223
|
+
}
|
|
2224
|
+
function cleanup() {
|
|
2225
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2226
|
+
}
|
|
2227
|
+
return { setup, cleanup };
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
// src/designer/interactions/useResize.ts
|
|
2231
|
+
var RESIZE_POINTS = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
2232
|
+
function calcResizeRect(point, startRect, dx, dy, minW, minH) {
|
|
2233
|
+
let { left, top, width, height } = startRect;
|
|
2234
|
+
switch (point) {
|
|
2235
|
+
case "e":
|
|
2236
|
+
width = Math.max(minW, startRect.width + dx);
|
|
2237
|
+
break;
|
|
2238
|
+
case "w":
|
|
2239
|
+
width = Math.max(minW, startRect.width - dx);
|
|
2240
|
+
left = startRect.left + startRect.width - width;
|
|
2241
|
+
break;
|
|
2242
|
+
case "s":
|
|
2243
|
+
height = Math.max(minH, startRect.height + dy);
|
|
2244
|
+
break;
|
|
2245
|
+
case "n":
|
|
2246
|
+
height = Math.max(minH, startRect.height - dy);
|
|
2247
|
+
top = startRect.top + startRect.height - height;
|
|
2248
|
+
break;
|
|
2249
|
+
case "se":
|
|
2250
|
+
width = Math.max(minW, startRect.width + dx);
|
|
2251
|
+
height = Math.max(minH, startRect.height + dy);
|
|
2252
|
+
break;
|
|
2253
|
+
case "sw":
|
|
2254
|
+
width = Math.max(minW, startRect.width - dx);
|
|
2255
|
+
left = startRect.left + startRect.width - width;
|
|
2256
|
+
height = Math.max(minH, startRect.height + dy);
|
|
2257
|
+
break;
|
|
2258
|
+
case "ne":
|
|
2259
|
+
width = Math.max(minW, startRect.width + dx);
|
|
2260
|
+
height = Math.max(minH, startRect.height - dy);
|
|
2261
|
+
top = startRect.top + startRect.height - height;
|
|
2262
|
+
break;
|
|
2263
|
+
case "nw":
|
|
2264
|
+
width = Math.max(minW, startRect.width - dx);
|
|
2265
|
+
left = startRect.left + startRect.width - width;
|
|
2266
|
+
height = Math.max(minH, startRect.height - dy);
|
|
2267
|
+
top = startRect.top + startRect.height - height;
|
|
2268
|
+
break;
|
|
2269
|
+
}
|
|
2270
|
+
return { left, top, width, height };
|
|
2271
|
+
}
|
|
2272
|
+
function useResize(options) {
|
|
2273
|
+
let startX = 0, startY = 0;
|
|
2274
|
+
let startRect = { left: 0, top: 0, width: 0, height: 0 };
|
|
2275
|
+
let activePoint = null;
|
|
2276
|
+
function startResize(point, e) {
|
|
2277
|
+
activePoint = point;
|
|
2278
|
+
startX = e.clientX;
|
|
2279
|
+
startY = e.clientY;
|
|
2280
|
+
startRect = { ...options.getRect() };
|
|
2281
|
+
options.onStart?.();
|
|
2282
|
+
document.addEventListener("mousemove", onResizeMove);
|
|
2283
|
+
document.addEventListener("mouseup", onResizeEnd);
|
|
2284
|
+
e.preventDefault();
|
|
2285
|
+
}
|
|
2286
|
+
function onResizeMove(e) {
|
|
2287
|
+
if (!activePoint) {
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2290
|
+
const scale = options.getScale?.() || 1;
|
|
2291
|
+
const dx = (e.clientX - startX) / scale;
|
|
2292
|
+
const dy = (e.clientY - startY) / scale;
|
|
2293
|
+
const minW = options.minWidth || 20;
|
|
2294
|
+
const minH = options.minHeight || 20;
|
|
2295
|
+
options.onResize(calcResizeRect(activePoint, startRect, dx, dy, minW, minH));
|
|
2296
|
+
}
|
|
2297
|
+
function onResizeEnd() {
|
|
2298
|
+
activePoint = null;
|
|
2299
|
+
options.onStop?.();
|
|
2300
|
+
document.removeEventListener("mousemove", onResizeMove);
|
|
2301
|
+
document.removeEventListener("mouseup", onResizeEnd);
|
|
2302
|
+
}
|
|
2303
|
+
function cleanup() {
|
|
2304
|
+
document.removeEventListener("mousemove", onResizeMove);
|
|
2305
|
+
document.removeEventListener("mouseup", onResizeEnd);
|
|
2306
|
+
}
|
|
2307
|
+
return { startResize, cleanup };
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
// src/designer/interactions/useBindingDisplay.ts
|
|
2311
|
+
function getNestedValue(obj, path) {
|
|
2312
|
+
return path.split(".").reduce((current, key) => current?.[key], obj);
|
|
2313
|
+
}
|
|
2314
|
+
function useBindingDisplay() {
|
|
2315
|
+
function getBindingDisplayState(element) {
|
|
2316
|
+
const formatter = element.options.formatter;
|
|
2317
|
+
const title = element.options.title;
|
|
2318
|
+
if (!formatter) {
|
|
2319
|
+
return {
|
|
2320
|
+
status: "unbound",
|
|
2321
|
+
badge: title || "\u6587\u672C",
|
|
2322
|
+
badgeColor: "#909399",
|
|
2323
|
+
demoPreview: title || "\u6587\u672C"
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
const demoData = getDemoData();
|
|
2327
|
+
const fieldMatch = formatter.match(/\{([^}]+)\}/);
|
|
2328
|
+
if (fieldMatch) {
|
|
2329
|
+
const fieldPath = fieldMatch[1];
|
|
2330
|
+
const demoValue = getNestedValue(demoData, fieldPath);
|
|
2331
|
+
return {
|
|
2332
|
+
status: "bound",
|
|
2333
|
+
badge: `fx ${formatter}`,
|
|
2334
|
+
badgeColor: "#409EFF",
|
|
2335
|
+
demoPreview: demoValue != null ? String(demoValue) : formatter
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
return {
|
|
2339
|
+
status: "bound",
|
|
2340
|
+
badge: `fx ${formatter}`,
|
|
2341
|
+
badgeColor: "#409EFF",
|
|
2342
|
+
demoPreview: formatter
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
return { getBindingDisplayState };
|
|
2346
|
+
}
|
|
2347
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2348
|
+
0 && (module.exports = {
|
|
2349
|
+
DEFAULT_DEMO_DATA,
|
|
2350
|
+
ELEMENT_BINDING_REGISTRY,
|
|
2351
|
+
EXTENDED_FUNCTIONS,
|
|
2352
|
+
FIT_SCALE_MIN_PERCENT,
|
|
2353
|
+
GHOST_BORDER_CSS,
|
|
2354
|
+
MIN_COL_WIDTH_MM,
|
|
2355
|
+
MIN_SCALE_PERCENT,
|
|
2356
|
+
PAPER_PRESETS,
|
|
2357
|
+
PRESET_COLORS,
|
|
2358
|
+
PROPERTY_REGISTRY,
|
|
2359
|
+
RESIZE_POINTS,
|
|
2360
|
+
RULER_THICKNESS,
|
|
2361
|
+
ZONE_ALLOWED_TYPES,
|
|
2362
|
+
applyBorderPreset,
|
|
2363
|
+
buildRulerTicks,
|
|
2364
|
+
calcResizeRect,
|
|
2365
|
+
canMergeReason,
|
|
2366
|
+
chooseMajorStepMM,
|
|
2367
|
+
clampResizedColumnWidth,
|
|
2368
|
+
clampScalePercent,
|
|
2369
|
+
clampToZone,
|
|
2370
|
+
computeAdsorb,
|
|
2371
|
+
computeFitScale,
|
|
2372
|
+
createCell,
|
|
2373
|
+
createDefaultOptions,
|
|
2374
|
+
createDefaultTable,
|
|
2375
|
+
createFieldElement,
|
|
2376
|
+
createRuntimeElement,
|
|
2377
|
+
deleteCol,
|
|
2378
|
+
deleteRow,
|
|
2379
|
+
engine,
|
|
2380
|
+
evaluateTemplate,
|
|
2381
|
+
filterGroups,
|
|
2382
|
+
finalizeElementZone,
|
|
2383
|
+
findMainCell,
|
|
2384
|
+
generateGroupId,
|
|
2385
|
+
generateId,
|
|
2386
|
+
getDemoData,
|
|
2387
|
+
getElementBindings,
|
|
2388
|
+
getPaperDimensions,
|
|
2389
|
+
getPaperSizeMM,
|
|
2390
|
+
getSpanRect,
|
|
2391
|
+
getTableCellBindings,
|
|
2392
|
+
getZoneRects,
|
|
2393
|
+
groupFields,
|
|
2394
|
+
insertCol,
|
|
2395
|
+
insertRow,
|
|
2396
|
+
matchKeywords,
|
|
2397
|
+
mergeCells,
|
|
2398
|
+
minorStepMM,
|
|
2399
|
+
mmToPx,
|
|
2400
|
+
nextWheelScale,
|
|
2401
|
+
normalizeSelection,
|
|
2402
|
+
normalizeTemplateUnits,
|
|
2403
|
+
ptToMm,
|
|
2404
|
+
pxToMm,
|
|
2405
|
+
resolveBarcodeDesignValue,
|
|
2406
|
+
resolveCellBorderCss,
|
|
2407
|
+
resolveTextBinding,
|
|
2408
|
+
safeEval,
|
|
2409
|
+
searchProperties,
|
|
2410
|
+
setRowType,
|
|
2411
|
+
splitCells,
|
|
2412
|
+
syncTableElementSize,
|
|
2413
|
+
useAlign,
|
|
2414
|
+
useBindingDisplay,
|
|
2415
|
+
useGroup,
|
|
2416
|
+
useKeyboard,
|
|
2417
|
+
useResize,
|
|
2418
|
+
zoneFromPaperPoint
|
|
2419
|
+
});
|