@worm-vue3-print/core 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -7
- package/dist/browser/index.cjs +3686 -0
- package/dist/browser/index.d.cts +96 -0
- package/dist/browser/index.d.ts +96 -0
- package/dist/browser/index.js +325 -0
- package/dist/chunk-V4A5623C.js +31 -0
- package/dist/chunk-VFEURLAZ.js +3579 -0
- package/dist/designer/index.cjs +2641 -0
- package/dist/designer/index.d.cts +448 -0
- package/dist/designer/index.d.ts +448 -0
- package/dist/designer/index.js +1710 -0
- package/dist/dom-executor.iife.global.js +8 -0
- package/dist/driver-CsWkGK4a.d.cts +932 -0
- package/dist/driver-CsWkGK4a.d.ts +932 -0
- package/dist/index.cjs +1935 -120
- package/dist/index.d.cts +354 -185
- package/dist/index.d.ts +354 -185
- package/dist/index.js +197 -1765
- package/dist/node/index.cjs +41 -0
- package/dist/node/index.d.cts +6 -0
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +10 -0
- package/dist/ports-B63x7kCX.d.ts +102 -0
- package/dist/ports-q934kIC7.d.cts +102 -0
- package/package.json +26 -3
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { b as TemplateData, c as TableRow, d as TableCellBorder, e as TableCell, f as TableRowType, E as ElementOptions, g as ElementType, h as RuntimeElement, i as ElementZone, j as PrintBusinessField, B as BindingDescriptor, k as ElementRect, A as AdsorbResult, l as ResizePoint } from '../driver-CsWkGK4a.cjs';
|
|
2
|
+
export { m as AlignLine, n as DesignBackground, o as ElementFieldBinding, p as MultiPageTemplateData, q as PaginationConfig, r as PaperSize, s as PrintElementData, t as PrintElementTypeMeta, u as RequestScreenshotFn, S as ScreenshotRequest, v as TableCellBorders, w as TableCellType, x as TablePaginationConfig, y as TableSelection, z as TemplateElement, F as TextAlign, G as TextFit, U as UploadDesignBackgroundFn, H as UploadImageFn, V as VerticalAlign, W as WatermarkOptions } from '../driver-CsWkGK4a.cjs';
|
|
3
|
+
export { C as CellFitRowKind, D as DEFAULT_SHRINK_MIN_FONT_SIZE_PT, F as FitFontSize, M as MIN_SHRINK_FONT_SIZE_PT, c as cellFitCapMm, a as cellFitKey, b as cellFitWidthMm, f as floorFontSize, p as parseCellFitKey, r as resolveCellTextFit, d as resolveElementTextFit, e as resolveShrinkMinFontSize, g as roundFontSize } from '../ports-q934kIC7.cjs';
|
|
4
|
+
import { TemplateEngine, formatMoney, ifFn, formatDate, toUpperCaseAmount } from '../index.cjs';
|
|
5
|
+
|
|
6
|
+
/** 1 英寸 = 25.4mm */
|
|
7
|
+
declare const MM_PER_INCH = 25.4;
|
|
8
|
+
/**
|
|
9
|
+
* 以下 jsbarcode 生成参数单位统一为「模块」(1 模块 = 窄条宽度);调用时需乘以
|
|
10
|
+
* 每模块用户单位数(jsbarcode 的 width 选项)。设计器画布与出图端必须共用同一份。
|
|
11
|
+
*/
|
|
12
|
+
/** 条码静区(quiet zone)宽度(模块):EAN13/UPC/ITF14 等码制对静区有强制要求,缺失会直接扫不出 */
|
|
13
|
+
declare const BARCODE_QUIET_ZONE_MODULES = 10;
|
|
14
|
+
/** 条高(模块) */
|
|
15
|
+
declare const BARCODE_BAR_HEIGHT_MODULES = 30;
|
|
16
|
+
/** 条码下方文本缺省高度(模块,相对条高,非绝对 pt) */
|
|
17
|
+
declare const BARCODE_TEXT_FONT_SIZE_MODULES = 10;
|
|
18
|
+
/** 文本区与条码图形之间的间距(模块) */
|
|
19
|
+
declare const BARCODE_MARGIN_BOTTOM_MODULES = 2;
|
|
20
|
+
/** 基础模块宽度(mm):barWidth=2(每模块用户单位数 1)时每个模块的物理宽度 */
|
|
21
|
+
declare const BARCODE_MODULE_WIDTH_MM = 0.25;
|
|
22
|
+
/** 每模块的用户单位数:与出图端 jsbarcode 的 width 同口径(barWidth=2 → 1,barWidth=4 → 2) */
|
|
23
|
+
declare function barcodeUnitsPerModule(barWidth?: number): number;
|
|
24
|
+
/** 每模块的首选物理宽度(mm):条宽倍率每 +1,增加 BARCODE_MODULE_WIDTH_MM / 2 */
|
|
25
|
+
declare function barcodePreferredModuleWidthMm(barWidth?: number): number;
|
|
26
|
+
interface BarcodeSizeInput {
|
|
27
|
+
/** 总宽度(模块,含左右静区) */
|
|
28
|
+
unitWidth: number;
|
|
29
|
+
/** 总高度(模块,条高 + 文本区 + 间距) */
|
|
30
|
+
unitHeight: number;
|
|
31
|
+
/** 可用框宽度(mm);≤0 视为未知(不对条码做宽度约束) */
|
|
32
|
+
boxWidthMm: number;
|
|
33
|
+
/** 可用框高度(mm);≤0 视为未知 */
|
|
34
|
+
boxHeightMm: number;
|
|
35
|
+
/** 打印机分辨率(点/英寸);非正数或缺失视为「不对齐点阵」 */
|
|
36
|
+
dpi?: number;
|
|
37
|
+
/** 条码模块宽度倍率(2-4),缺省 2 */
|
|
38
|
+
barWidth?: number;
|
|
39
|
+
}
|
|
40
|
+
interface BarcodeSize {
|
|
41
|
+
/** 结算后的每模块物理宽度(mm) */
|
|
42
|
+
moduleWidthMm: number;
|
|
43
|
+
/** 条码图形最终宽度(mm) */
|
|
44
|
+
widthMm: number;
|
|
45
|
+
/** 条码图形最终高度(mm) */
|
|
46
|
+
heightMm: number;
|
|
47
|
+
/** 每模块占用的打印点数(整数);未做点对齐时为 null */
|
|
48
|
+
dotsPerModule: number | null;
|
|
49
|
+
/** 是否因可用框放不下首选尺寸而发生了等比缩小 */
|
|
50
|
+
scaledDown: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 可用框(mm)并入最大宽高,得到结算尺寸的最终上限:
|
|
54
|
+
* - 可用框未知(≤0)时,最大宽高即上限;
|
|
55
|
+
* - 两者都未知时返回 0,交给 resolveBarcodeSize 的「不约束」分支。
|
|
56
|
+
* 调用侧(画布 / 出图)共用一份,避免「最大宽高在一端生效、在另一端不生效」。
|
|
57
|
+
*/
|
|
58
|
+
declare function barcodeAvailableBoxMm(boxMm: number | undefined, maxMm: number | undefined): number;
|
|
59
|
+
/**
|
|
60
|
+
* 求条码的落纸尺寸。
|
|
61
|
+
*
|
|
62
|
+
* 缩放是等比的:成品宽高始终等于各自的模块数乘以同一个每模块宽度,
|
|
63
|
+
* 所以「宽度不足」时高度同比缩小,条码不会被拉变形。
|
|
64
|
+
*/
|
|
65
|
+
declare function resolveBarcodeSize(input: BarcodeSizeInput): BarcodeSize;
|
|
66
|
+
|
|
67
|
+
/** pt 转 mm */
|
|
68
|
+
declare function ptToMm(pt: number): number;
|
|
69
|
+
/** px 转 mm(基于 96dpi 屏幕) */
|
|
70
|
+
declare function pxToMm(px: number): number;
|
|
71
|
+
/** mm 转 px(基于 96dpi 屏幕) */
|
|
72
|
+
declare function mmToPx(mm: number): number;
|
|
73
|
+
|
|
74
|
+
/** 最小缩放百分比,低于此值画布难以查看与操作;放大方向不设上限 */
|
|
75
|
+
declare const MIN_SCALE_PERCENT = 25;
|
|
76
|
+
/** 适应窗口时允许的最小缩放百分比(可低于交互缩放下限,保证超大纸张也能整版容纳) */
|
|
77
|
+
declare const FIT_SCALE_MIN_PERCENT = 5;
|
|
78
|
+
/** 将缩放百分比钳制到允许范围:仅保留下限,放大不设上限 */
|
|
79
|
+
declare function clampScalePercent(percent: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* 滚轮缩放:乘性步进(默认 ×1.1 / ÷1.1),大倍数下仍保持平滑手感,
|
|
82
|
+
* 返回取整后的百分比,避免浮点累加产生脏显示(如 110.00000001)
|
|
83
|
+
* @param percent 当前缩放百分比
|
|
84
|
+
* @param direction 1 放大,-1 缩小
|
|
85
|
+
*/
|
|
86
|
+
declare function nextWheelScale(percent: number, direction: 1 | -1, factor?: number): number;
|
|
87
|
+
/** 计算适应窗口的缩放百分比,允许小于交互缩放下限,保证整版纸张可见 */
|
|
88
|
+
declare function computeFitScale(containerW: number, containerH: number, paperW: number, paperH: number, ratio?: number): number;
|
|
89
|
+
|
|
90
|
+
declare function normalizeTemplateUnits(data: TemplateData): TemplateData;
|
|
91
|
+
|
|
92
|
+
/** 标签纸分组名(PAPER_PRESETS.group):该组纸型默认取消页眉、页脚与页边距 */
|
|
93
|
+
declare const LABEL_PAPER_GROUP = "\u6807\u7B7E\u7EB8";
|
|
94
|
+
interface PaperPreset {
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
/** 连续纸(热敏卷纸/小票纸):出纸高度按内容推导,纸宽可用 customWidth 覆盖 */
|
|
98
|
+
continuous?: boolean;
|
|
99
|
+
/** 设计器下拉显示名 */
|
|
100
|
+
label?: string;
|
|
101
|
+
/** 设计器下拉分组名 */
|
|
102
|
+
group?: string;
|
|
103
|
+
}
|
|
104
|
+
/** 纸张预设(mm);顺序即设计器下拉顺序,与 render 层 PAPER_DIMENSIONS 数值保持一致 */
|
|
105
|
+
declare const PAPER_PRESETS: Record<string, PaperPreset>;
|
|
106
|
+
/** 纸型是否连续纸(小票纸/热敏卷纸):出纸高度按渲染内容推导 */
|
|
107
|
+
declare function isContinuousPaperSize(paperSize: string | undefined): boolean;
|
|
108
|
+
/** 纸型是否标签纸:整张纸即一张标签,默认不留页边距、不占页眉页脚 */
|
|
109
|
+
declare function isLabelPaperSize(paperSize: string | undefined): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* 标签纸的默认版面:四边页边距归零、页眉页脚高度归零(整张纸都给内容区)。
|
|
112
|
+
* 页眉页脚里的元素保留,之后把高度改回即可恢复——切换纸型不应静默删掉用户内容。
|
|
113
|
+
* 只在「切到标签纸」时套用一次,用户随后仍可自行调整。
|
|
114
|
+
*/
|
|
115
|
+
declare function labelPaperDefaults(t: Pick<TemplateData, 'header' | 'footer'>): Pick<TemplateData, 'margins' | 'header' | 'footer'>;
|
|
116
|
+
/**
|
|
117
|
+
* 获取纸张原始宽高(mm,未应用方向)
|
|
118
|
+
* CUSTOM 时读取 customWidth/customHeight,缺省回退 A4;
|
|
119
|
+
* 连续纸时宽度取 customWidth(缺省取预设纸宽),高度取 customHeight(缺省 297,仅设计画布),方向强制纵向。
|
|
120
|
+
*/
|
|
121
|
+
declare function getPaperDimensions(t: Pick<TemplateData, 'paperSize' | 'orientation' | 'customWidth' | 'customHeight'>): {
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
interface CellRect {
|
|
127
|
+
r1: number;
|
|
128
|
+
c1: number;
|
|
129
|
+
r2: number;
|
|
130
|
+
c2: number;
|
|
131
|
+
}
|
|
132
|
+
declare function createCell(partial?: Partial<TableCell>): TableCell;
|
|
133
|
+
/** 默认新建表格:3 列 × 4 行(标题/数据/小计/汇总),列宽均分 50mm,表格组件默认显示当前页小计行 */
|
|
134
|
+
declare function createDefaultTable(): {
|
|
135
|
+
rows: TableRow[];
|
|
136
|
+
colWidths: number[];
|
|
137
|
+
};
|
|
138
|
+
/** 定位覆盖 (r,c) 的主格坐标(自身非 merged 即为主格) */
|
|
139
|
+
declare function findMainCell(rows: TableRow[], r: number, c: number): {
|
|
140
|
+
r: number;
|
|
141
|
+
c: number;
|
|
142
|
+
};
|
|
143
|
+
/** 主格覆盖矩形 */
|
|
144
|
+
declare function getSpanRect(rows: TableRow[], r: number, c: number): CellRect;
|
|
145
|
+
/** 由锚点/焦点推导矩形选区,并迭代扩展至完整包含所有跨越的合并格 */
|
|
146
|
+
declare function normalizeSelection(rows: TableRow[], a: {
|
|
147
|
+
r: number;
|
|
148
|
+
c: number;
|
|
149
|
+
}, b: {
|
|
150
|
+
r: number;
|
|
151
|
+
c: number;
|
|
152
|
+
}): CellRect;
|
|
153
|
+
/** 合并合法性校验,返回拒绝原因或 null */
|
|
154
|
+
declare function canMergeReason(rows: TableRow[], rect: CellRect): string | null;
|
|
155
|
+
/** 合并:左上为主格,非空内容空格拼接并入主格 */
|
|
156
|
+
declare function mergeCells(rows: TableRow[], rect: CellRect): void;
|
|
157
|
+
/** 拆分选区内所有合并格:占位格恢复并复制主格样式 */
|
|
158
|
+
declare function splitCells(rows: TableRow[], rect: CellRect): void;
|
|
159
|
+
/** 插入行。index 为参照行,position 决定插在其上方或下方 */
|
|
160
|
+
declare function insertRow(rows: TableRow[], index: number, position: 'above' | 'below'): void;
|
|
161
|
+
/** 删除行;主格在被删行时移交下一行 */
|
|
162
|
+
declare function deleteRow(rows: TableRow[], index: number): string | null;
|
|
163
|
+
/** 插入列 */
|
|
164
|
+
declare function insertCol(rows: TableRow[], colWidths: number[], index: number, position: 'left' | 'right'): void;
|
|
165
|
+
/** 删除列;主格在被删列时移交右侧列 */
|
|
166
|
+
declare function deleteCol(rows: TableRow[], colWidths: number[], index: number): string | null;
|
|
167
|
+
/** 行类型变更校验 + 写入。约束:header 顶部连续;data 唯一;subtotal/summary 在 data 之后;subtotal 在 summary 之前 */
|
|
168
|
+
declare function setRowType(rows: TableRow[], index: number, type: TableRowType): string | null;
|
|
169
|
+
type BorderPreset = 'all' | 'outer' | 'inner' | 'none';
|
|
170
|
+
/** 按预设批量写边框;none 时清空选区内所有格的 borders */
|
|
171
|
+
declare function applyBorderPreset(rows: TableRow[], rect: CellRect, preset: BorderPreset, border: TableCellBorder): void;
|
|
172
|
+
/** 设计态下无边框单元格的辅助虚线:与背景网格线同风格(浅灰虚线),略深保证可读 */
|
|
173
|
+
declare const GHOST_BORDER_CSS = "1px dashed rgba(0,0,0,0.18)";
|
|
174
|
+
/**
|
|
175
|
+
* 解析单元格某条边的最终 CSS border 值。
|
|
176
|
+
* - 有真实边框(style 非 none)→ 返回 `${width}pt ${style} ${color}`
|
|
177
|
+
* - 设计态且开关开启、且该边无边框 → 返回虚拟虚线(仅设计稿展示,不影响预览/打印)
|
|
178
|
+
* - 其余情况(预览态 / 开关关闭)→ 'none'
|
|
179
|
+
*/
|
|
180
|
+
declare function resolveCellBorderCss(b: TableCellBorder | undefined, opts?: {
|
|
181
|
+
designMode?: boolean;
|
|
182
|
+
showGhostBorder?: boolean;
|
|
183
|
+
}): string;
|
|
184
|
+
/** 表格元素尺寸派生:options.width/height 恒等于列宽和/行高和(mm),与渲染端一致 */
|
|
185
|
+
declare function syncTableElementSize(options: ElementOptions): void;
|
|
186
|
+
/** 列宽拖拽的最小列宽(mm),与属性面板列宽输入下限一致 */
|
|
187
|
+
declare const MIN_COL_WIDTH_MM = 5;
|
|
188
|
+
/**
|
|
189
|
+
* 列宽拖拽钳制(纯函数,不修改入参,调用方负责回写):
|
|
190
|
+
* 返回目标列宽在 [MIN_COL_WIDTH_MM, maxTableWidth - 其余列和] 范围内的钳制值,
|
|
191
|
+
* 结果保留 0.1mm 精度。maxTableWidth 为 Infinity 时不设总宽上限。
|
|
192
|
+
*/
|
|
193
|
+
declare function clampResizedColumnWidth(colWidths: number[], index: number, targetMm: number, maxTableWidth: number): number;
|
|
194
|
+
|
|
195
|
+
declare function generateId(): string;
|
|
196
|
+
declare function createDefaultOptions(type: ElementType): ElementOptions;
|
|
197
|
+
declare function createRuntimeElement(type: ElementType, options?: Partial<ElementOptions>): RuntimeElement;
|
|
198
|
+
|
|
199
|
+
/** 允许放入页眉/页脚的元素类型 */
|
|
200
|
+
declare const ZONE_ALLOWED_TYPES: string[];
|
|
201
|
+
interface ZoneRectPt {
|
|
202
|
+
left: number;
|
|
203
|
+
top: number;
|
|
204
|
+
width: number;
|
|
205
|
+
height: number;
|
|
206
|
+
}
|
|
207
|
+
/** 纸张宽高(mm,含方向;CUSTOM 读取 customWidth/customHeight,缺省回退 A4) */
|
|
208
|
+
declare function getPaperSizeMM(t: TemplateData): {
|
|
209
|
+
width: number;
|
|
210
|
+
height: number;
|
|
211
|
+
};
|
|
212
|
+
/** 三区在纸面坐标系中的矩形(mm),布局:上边距→页眉→内容→页脚→下边距 */
|
|
213
|
+
declare function getZoneRects(t: TemplateData): Record<ElementZone, ZoneRectPt>;
|
|
214
|
+
/** 纸面 mm 坐标 → 命中区域(高度为 0 的区域不参与命中) */
|
|
215
|
+
declare function zoneFromPaperPoint(t: TemplateData, _x: number, y: number): ElementZone;
|
|
216
|
+
/** 将元素局部坐标 clamp 到区域矩形内(原地修改) */
|
|
217
|
+
declare function clampToZone(el: RuntimeElement, zone: ZoneRectPt): void;
|
|
218
|
+
/**
|
|
219
|
+
* 拖拽/缩放结束后按元素中心点归区:
|
|
220
|
+
* 跨区时换算坐标并改写 zone;页眉/页脚内 clamp;类型不允许时拒绝跨入并 clamp 回内容区。
|
|
221
|
+
*/
|
|
222
|
+
declare function finalizeElementZone(el: RuntimeElement, t: TemplateData): {
|
|
223
|
+
rejected: boolean;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/** 视口固定尺条厚度(px),CanvasArea 布局与左上角块共用 */
|
|
227
|
+
declare const RULER_THICKNESS = 22;
|
|
228
|
+
interface RulerTick {
|
|
229
|
+
/** 刻度在纸面坐标系上的位置(mm,可为负,表示纸张原点之外) */
|
|
230
|
+
mm: number;
|
|
231
|
+
/** 是否为主刻度(带数字标签) */
|
|
232
|
+
major: boolean;
|
|
233
|
+
label?: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 按缩放选择主刻度步长(mm):取漂亮数序列中使屏幕间距
|
|
237
|
+
* 不小于 targetPx 的最小步长,保证任意缩放下标签不重叠
|
|
238
|
+
* @param scale 画布缩放比例(1 = 100%)
|
|
239
|
+
* @param targetPx 主刻度之间的目标屏幕间距(px)
|
|
240
|
+
*/
|
|
241
|
+
declare function chooseMajorStepMM(scale: number, targetPx?: number): number;
|
|
242
|
+
/**
|
|
243
|
+
* 次刻度步长:5 系(5/50/500…)五等分、2 系(2/20/200…)二等分、
|
|
244
|
+
* 10 的幂从 10mm 起五等分(10→2mm、100→20mm),1mm 时无次刻度
|
|
245
|
+
*/
|
|
246
|
+
declare function minorStepMM(majorStepMM: number): number | null;
|
|
247
|
+
/**
|
|
248
|
+
* 生成可见毫米范围内的全部刻度(升序):
|
|
249
|
+
* 从首个对齐的次刻度开始,主刻度带数字标签
|
|
250
|
+
* @param startMM 可见范围起点(纸面坐标,可为负)
|
|
251
|
+
* @param endMM 可见范围终点
|
|
252
|
+
* @param majorStepMM 主刻度步长(由 chooseMajorStepMM 选出)
|
|
253
|
+
*/
|
|
254
|
+
declare function buildRulerTicks(startMM: number, endMM: number, majorStepMM: number): RulerTick[];
|
|
255
|
+
|
|
256
|
+
/** 打印设计器常见预设颜色(12 色) */
|
|
257
|
+
declare const PRESET_COLORS: readonly ["#000000", "#333333", "#666666", "#999999", "#cccccc", "#ffffff", "#e53935", "#fb8c00", "#1e88e5", "#43a047", "#8d6e63", "#00acc1"];
|
|
258
|
+
|
|
259
|
+
/** 属性面板搜索注册表:分组 → 表单项 → 关键词 */
|
|
260
|
+
interface PropertyItem {
|
|
261
|
+
key: string;
|
|
262
|
+
keywords: string[];
|
|
263
|
+
}
|
|
264
|
+
interface PropertyGroupDef {
|
|
265
|
+
group: string;
|
|
266
|
+
groupLabel: string;
|
|
267
|
+
items: PropertyItem[];
|
|
268
|
+
}
|
|
269
|
+
declare const PROPERTY_REGISTRY: PropertyGroupDef[];
|
|
270
|
+
/** 正向包含匹配:任一关键词包含搜索词即命中;空搜索恒命中 */
|
|
271
|
+
declare function matchKeywords(search: string, keywords: string[]): boolean;
|
|
272
|
+
/** 计算命中的分组与表单项 key 集合 */
|
|
273
|
+
declare function searchProperties(search: string): {
|
|
274
|
+
groups: string[];
|
|
275
|
+
itemKeys: Set<string>;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
interface FieldGroup {
|
|
279
|
+
/** 分组键(fieldKey 首段);空串表示无分组的顶层字段 */
|
|
280
|
+
key: string;
|
|
281
|
+
/** 分组显示名:取容器字段的 fieldLabel,缺省回退为 key */
|
|
282
|
+
label: string;
|
|
283
|
+
/** 是否明细列表分组(容器字段 fieldType === 'list') */
|
|
284
|
+
isList: boolean;
|
|
285
|
+
/** 分组下的叶子字段 */
|
|
286
|
+
fields: PrintBusinessField[];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* 将宿主扁平字段按 fieldKey 首段分组:
|
|
290
|
+
* - 带点路径(supplier.name、goods.spec)归入首段分组;
|
|
291
|
+
* - 无点且作为其它字段前缀的记录视为分组容器(如 supplier/goods),
|
|
292
|
+
* 容器提供分组名称,fieldType='list' 标识明细列表(表格数据源);
|
|
293
|
+
* - 无点且无子字段的记录作为独立顶层字段。
|
|
294
|
+
*/
|
|
295
|
+
declare function groupFields(fields: PrintBusinessField[]): FieldGroup[];
|
|
296
|
+
/** 按关键字过滤分组(匹配字段名/字段 key),无叶子的分组剔除 */
|
|
297
|
+
declare function filterGroups(groups: FieldGroup[], keyword: string): FieldGroup[];
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 元素绑定声明注册表
|
|
301
|
+
* 每个元素类型声明其支持的 formatter 绑定位置
|
|
302
|
+
*/
|
|
303
|
+
declare const ELEMENT_BINDING_REGISTRY: Record<string, BindingDescriptor[]>;
|
|
304
|
+
declare function getTableCellBindings(rowType: string, rowIndex: number, cellIndex: number, listField?: string): BindingDescriptor[];
|
|
305
|
+
declare function getElementBindings(element: any): BindingDescriptor[];
|
|
306
|
+
|
|
307
|
+
declare function getDemoData(): Record<string, any>;
|
|
308
|
+
declare const DEFAULT_DEMO_DATA: Record<string, any>;
|
|
309
|
+
|
|
310
|
+
declare const engine: TemplateEngine;
|
|
311
|
+
|
|
312
|
+
declare const EXTENDED_FUNCTIONS: {
|
|
313
|
+
MONEY: typeof formatMoney;
|
|
314
|
+
CONCAT: (...args: any[]) => string;
|
|
315
|
+
IF: typeof ifFn;
|
|
316
|
+
FORMAT: (value: any) => string;
|
|
317
|
+
SUBSTR: (str: string, start: number, len?: number) => string;
|
|
318
|
+
LEN: (str: string) => number;
|
|
319
|
+
ROUND: (num: number, decimals: number) => number;
|
|
320
|
+
NOW: () => string;
|
|
321
|
+
IFEMPTY: (value: any, defaultVal: string) => string;
|
|
322
|
+
PAD: (value: any, len: number, char: string) => string;
|
|
323
|
+
REPLACE: (str: string, from: string, to: string) => string;
|
|
324
|
+
JSON: (value: any) => string;
|
|
325
|
+
DATE: typeof formatDate;
|
|
326
|
+
UPPER: typeof toUpperCaseAmount;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* 在受限沙箱内求值表达式
|
|
330
|
+
* @param expr 表达式字符串
|
|
331
|
+
* @param context 上下文变量
|
|
332
|
+
* @param _callableNames 保留参数,实际使用共享引擎
|
|
333
|
+
*/
|
|
334
|
+
declare function safeEval(expr: string, context: Record<string, any>, _callableNames?: string[]): any;
|
|
335
|
+
/**
|
|
336
|
+
* 模板字符串求值:{表达式} 内 safeEval 求值,外为字面文本。
|
|
337
|
+
* 聚合函数 SUM/AVG/COUNT/MIN/MAX(field) 预处理(需 ctx.rows)。
|
|
338
|
+
* 单个 {expr} 求值失败时保留原 {expr} 文本。
|
|
339
|
+
*/
|
|
340
|
+
declare function evaluateTemplate(text: string, ctx: Record<string, any>): string;
|
|
341
|
+
|
|
342
|
+
/** 从业务字段创建带 formatter 绑定的文本元素 */
|
|
343
|
+
declare function createFieldElement(field: {
|
|
344
|
+
fieldKey: string;
|
|
345
|
+
fieldLabel: string;
|
|
346
|
+
}): RuntimeElement;
|
|
347
|
+
/** 非设计态文本内容解析:用共享引擎渲染 formatter */
|
|
348
|
+
declare function resolveTextBinding(options: {
|
|
349
|
+
formatter?: string;
|
|
350
|
+
}, data?: Record<string, any>[]): string;
|
|
351
|
+
/**
|
|
352
|
+
* 设计态条码/二维码单元格取值:{field} 占位符替换为 demo 数据
|
|
353
|
+
* (列表字段取数据源首项,全局字段按路径取),无匹配回退通用示例码值
|
|
354
|
+
*/
|
|
355
|
+
declare function resolveBarcodeDesignValue(formatter: string | undefined, listSource?: Record<string, any>[]): string;
|
|
356
|
+
|
|
357
|
+
interface AdsorbConfig {
|
|
358
|
+
adsorbMin?: number;
|
|
359
|
+
adsorbLineMin?: number;
|
|
360
|
+
showAdsorbLine?: boolean;
|
|
361
|
+
}
|
|
362
|
+
/** 手动参考线(mm) */
|
|
363
|
+
interface ManualGuides {
|
|
364
|
+
vertical: number[];
|
|
365
|
+
horizontal: number[];
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* 计算拖动元素的吸附结果(新坐标 + 引导线)。
|
|
369
|
+
* @param movingRect 拖动元素矩形
|
|
370
|
+
* @param others 其他参与吸附的元素矩形
|
|
371
|
+
* @param manualGuides 手动参考线(可选)
|
|
372
|
+
* @param config 吸附阈值配置
|
|
373
|
+
*/
|
|
374
|
+
declare function computeAdsorb(movingRect: ElementRect, others: ElementRect[], manualGuides?: ManualGuides, config?: AdsorbConfig): AdsorbResult;
|
|
375
|
+
|
|
376
|
+
type AlignMode = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'distributeHor' | 'distributeVer';
|
|
377
|
+
declare function useAlign(): {
|
|
378
|
+
align: (elements: RuntimeElement[], mode: AlignMode) => void;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
declare function generateGroupId(): string;
|
|
382
|
+
declare function useGroup(): {
|
|
383
|
+
group: (elements: RuntimeElement[], selectedIds: Set<string>) => RuntimeElement[];
|
|
384
|
+
ungroup: (elements: RuntimeElement[], selectedIds: Set<string>) => RuntimeElement[];
|
|
385
|
+
getGroupedIds: (elements: RuntimeElement[], selectedId: string) => Set<string>;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
interface KeyboardHandlers {
|
|
389
|
+
onMove?: (dx: number, dy: number) => void;
|
|
390
|
+
onDelete?: () => void;
|
|
391
|
+
onCopy?: () => void;
|
|
392
|
+
onPaste?: () => void;
|
|
393
|
+
onSelectAll?: () => void;
|
|
394
|
+
onUndo?: () => void;
|
|
395
|
+
onRedo?: () => void;
|
|
396
|
+
onDuplicate?: () => void;
|
|
397
|
+
onResetZoom?: () => void;
|
|
398
|
+
onAlignLeft?: () => void;
|
|
399
|
+
onAlignRight?: () => void;
|
|
400
|
+
onAlignCenterH?: () => void;
|
|
401
|
+
onAlignTop?: () => void;
|
|
402
|
+
onAlignBottom?: () => void;
|
|
403
|
+
onGroup?: () => void;
|
|
404
|
+
onUngroup?: () => void;
|
|
405
|
+
}
|
|
406
|
+
declare function useKeyboard(handlers: KeyboardHandlers): {
|
|
407
|
+
setup: () => void;
|
|
408
|
+
cleanup: () => void;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
interface ResizeRect {
|
|
412
|
+
left: number;
|
|
413
|
+
top: number;
|
|
414
|
+
width: number;
|
|
415
|
+
height: number;
|
|
416
|
+
}
|
|
417
|
+
interface ResizeOptions {
|
|
418
|
+
minWidth?: number;
|
|
419
|
+
minHeight?: number;
|
|
420
|
+
getScale?: () => number;
|
|
421
|
+
/** 缩放起始时读取元素当前矩形(mm) */
|
|
422
|
+
getRect: () => ResizeRect;
|
|
423
|
+
onResize: (rect: ResizeRect) => void;
|
|
424
|
+
onStart?: () => void;
|
|
425
|
+
onStop?: () => void;
|
|
426
|
+
}
|
|
427
|
+
/** 8 方位缩放手柄,供模板 v-for 渲染 */
|
|
428
|
+
declare const RESIZE_POINTS: ResizePoint[];
|
|
429
|
+
/** 根据方位与位移计算缩放后矩形(纯函数) */
|
|
430
|
+
declare function calcResizeRect(point: ResizePoint, startRect: ResizeRect, dx: number, dy: number, minW: number, minH: number): ResizeRect;
|
|
431
|
+
/** 缩放交互逻辑:手柄由组件模板渲染,mousedown 时调用 startResize */
|
|
432
|
+
declare function useResize(options: ResizeOptions): {
|
|
433
|
+
startResize: (point: ResizePoint, e: MouseEvent) => void;
|
|
434
|
+
cleanup: () => void;
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
interface BindingDisplayState {
|
|
438
|
+
status: 'unbound' | 'bound' | 'warning' | 'error';
|
|
439
|
+
badge: string;
|
|
440
|
+
badgeColor: string;
|
|
441
|
+
demoPreview: string;
|
|
442
|
+
warning?: string;
|
|
443
|
+
}
|
|
444
|
+
declare function useBindingDisplay(): {
|
|
445
|
+
getBindingDisplayState: (element: any) => BindingDisplayState;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
export { type AdsorbConfig, AdsorbResult, type AlignMode, BARCODE_BAR_HEIGHT_MODULES, BARCODE_MARGIN_BOTTOM_MODULES, BARCODE_MODULE_WIDTH_MM, BARCODE_QUIET_ZONE_MODULES, BARCODE_TEXT_FONT_SIZE_MODULES, type BarcodeSize, type BarcodeSizeInput, BindingDescriptor, type BorderPreset, type CellRect, DEFAULT_DEMO_DATA, ELEMENT_BINDING_REGISTRY, EXTENDED_FUNCTIONS, ElementOptions, ElementRect, ElementType, ElementZone, FIT_SCALE_MIN_PERCENT, type FieldGroup, GHOST_BORDER_CSS, type KeyboardHandlers, LABEL_PAPER_GROUP, MIN_COL_WIDTH_MM, MIN_SCALE_PERCENT, MM_PER_INCH, type ManualGuides, PAPER_PRESETS, PRESET_COLORS, PROPERTY_REGISTRY, type PaperPreset, PrintBusinessField, type PropertyGroupDef, type PropertyItem, RESIZE_POINTS, RULER_THICKNESS, type ResizeOptions, ResizePoint, type ResizeRect, type RulerTick, RuntimeElement, TableCell, TableCellBorder, TableRow, TableRowType, TemplateData, ZONE_ALLOWED_TYPES, type ZoneRectPt, applyBorderPreset, barcodeAvailableBoxMm, barcodePreferredModuleWidthMm, barcodeUnitsPerModule, buildRulerTicks, calcResizeRect, canMergeReason, chooseMajorStepMM, clampResizedColumnWidth, clampScalePercent, clampToZone, computeAdsorb, computeFitScale, createCell, createDefaultOptions, createDefaultTable, createFieldElement, createRuntimeElement, deleteCol, deleteRow, engine, evaluateTemplate, filterGroups, finalizeElementZone, findMainCell, generateGroupId, generateId, getDemoData, getElementBindings, getPaperDimensions, getPaperSizeMM, getSpanRect, getTableCellBindings, getZoneRects, groupFields, insertCol, insertRow, isContinuousPaperSize, isLabelPaperSize, labelPaperDefaults, matchKeywords, mergeCells, minorStepMM, mmToPx, nextWheelScale, normalizeSelection, normalizeTemplateUnits, ptToMm, pxToMm, resolveBarcodeDesignValue, resolveBarcodeSize, resolveCellBorderCss, resolveTextBinding, safeEval, searchProperties, setRowType, splitCells, syncTableElementSize, useAlign, useBindingDisplay, useGroup, useKeyboard, useResize, zoneFromPaperPoint };
|