@worm-vue3-print/core 1.2.2 → 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 +24 -7
- package/dist/browser/index.cjs +2025 -259
- package/dist/browser/index.d.cts +79 -6
- package/dist/browser/index.d.ts +79 -6
- package/dist/browser/index.js +283 -128
- package/dist/{chunk-HLCZHPUF.js → chunk-V4A5623C.js} +1 -1
- package/dist/chunk-VFEURLAZ.js +3579 -0
- package/dist/designer/index.cjs +233 -11
- package/dist/designer/index.d.cts +83 -287
- package/dist/designer/index.d.ts +83 -287
- package/dist/designer/index.js +114 -24
- 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 +355 -6
- package/dist/index.d.ts +355 -6
- package/dist/index.js +164 -4
- 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 +8 -2
- package/dist/chunk-JZIVNXZ7.js +0 -1777
- package/dist/types-BGBAbQD5.d.cts +0 -184
- package/dist/types-BGBAbQD5.d.ts +0 -184
package/dist/designer/index.d.ts
CHANGED
|
@@ -1,293 +1,68 @@
|
|
|
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.js';
|
|
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.js';
|
|
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-B63x7kCX.js';
|
|
1
4
|
import { TemplateEngine, formatMoney, ifFn, formatDate, toUpperCaseAmount } from '../index.js';
|
|
2
|
-
import '../types-BGBAbQD5.js';
|
|
3
5
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
height: number;
|
|
37
|
-
elements: TemplateElement[];
|
|
38
|
-
};
|
|
39
|
-
elements: TemplateElement[];
|
|
40
|
-
/** 元素坐标单位(新保存模板固定 'mm';旧数据无此字段按 pt 迁移) */
|
|
41
|
-
unit?: 'pt' | 'mm';
|
|
42
|
-
/** 自定义纸张宽度(mm),仅 paperSize='CUSTOM' 时有效 */
|
|
43
|
-
customWidth?: number;
|
|
44
|
-
/** 自定义纸张高度(mm),仅 paperSize='CUSTOM' 时有效 */
|
|
45
|
-
customHeight?: number;
|
|
46
|
-
/** 页面(纸张)背景色;未设置时默认白色 */
|
|
47
|
-
pageBackground?: string;
|
|
48
|
-
/** 水印配置 */
|
|
49
|
-
watermark?: WatermarkOptions;
|
|
50
|
-
/** 手动参考线(设计态辅助,序列化保留,渲染端忽略) */
|
|
51
|
-
guides?: AlignLine[];
|
|
52
|
-
}
|
|
53
|
-
/** 模板元素引用(用于 TemplateData 各区域) */
|
|
54
|
-
type TemplateElement = PrintElementData;
|
|
55
|
-
/** 元素类型 */
|
|
56
|
-
type ElementType = 'text' | 'image' | 'longText' | 'table' | 'hline' | 'vline' | 'rect' | 'oval' | 'barcode' | 'qrcode' | 'html' | 'pageNumber';
|
|
57
|
-
/** 对齐方式 */
|
|
58
|
-
type TextAlign = 'left' | 'center' | 'right';
|
|
59
|
-
/** 垂直对齐方式(文本类元素,未设置时按顶部处理,与打印端一致) */
|
|
60
|
-
type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
61
|
-
/** 缩放手柄方向 */
|
|
62
|
-
type ResizePoint = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
63
|
-
/** 引导线 */
|
|
64
|
-
interface AlignLine {
|
|
65
|
-
type: 'vertical' | 'horizontal';
|
|
66
|
-
position: number;
|
|
67
|
-
id?: string;
|
|
68
|
-
/** 引导线颜色(区分左/中/右对齐类型) */
|
|
69
|
-
color?: string;
|
|
70
|
-
}
|
|
71
|
-
/** 吸附结果 */
|
|
72
|
-
interface AdsorbResult {
|
|
73
|
-
left: number;
|
|
74
|
-
top: number;
|
|
75
|
-
lines: AlignLine[];
|
|
76
|
-
}
|
|
77
|
-
/** 元素矩形(用于吸附检测) */
|
|
78
|
-
interface ElementRect {
|
|
79
|
-
id: string;
|
|
80
|
-
left: number;
|
|
81
|
-
top: number;
|
|
82
|
-
width: number;
|
|
83
|
-
height: number;
|
|
84
|
-
}
|
|
85
|
-
/** 表格行类型:header 标题 / data 数据(全表唯一) / subtotal 当前页小计(每页末尾) / summary 整表汇总 */
|
|
86
|
-
type TableRowType = 'header' | 'data' | 'subtotal' | 'summary';
|
|
87
|
-
/** 单边边框样式 */
|
|
88
|
-
interface TableCellBorder {
|
|
89
|
-
width: number;
|
|
90
|
-
style: 'solid' | 'dashed' | 'dotted' | 'double' | 'none';
|
|
91
|
-
color: string;
|
|
92
|
-
}
|
|
93
|
-
/** 四边边框 */
|
|
94
|
-
interface TableCellBorders {
|
|
95
|
-
top?: TableCellBorder;
|
|
96
|
-
right?: TableCellBorder;
|
|
97
|
-
bottom?: TableCellBorder;
|
|
98
|
-
left?: TableCellBorder;
|
|
99
|
-
}
|
|
100
|
-
/** 单元格内容类型 */
|
|
101
|
-
type TableCellType = 'text' | 'barcode' | 'qrcode' | 'image';
|
|
102
|
-
/** 单元格 */
|
|
103
|
-
interface TableCell {
|
|
104
|
-
id: string;
|
|
105
|
-
formatter?: string;
|
|
106
|
-
cellType?: TableCellType;
|
|
107
|
-
barcodeType?: string;
|
|
108
|
-
qrCodeLevel?: string;
|
|
109
|
-
showBarcodeText?: boolean;
|
|
110
|
-
rowspan?: number;
|
|
111
|
-
colspan?: number;
|
|
112
|
-
merged?: boolean;
|
|
113
|
-
align?: TextAlign;
|
|
114
|
-
valign?: 'top' | 'middle' | 'bottom';
|
|
115
|
-
fontFamily?: string;
|
|
116
|
-
fontSize?: number;
|
|
117
|
-
fontWeight?: string;
|
|
118
|
-
color?: string;
|
|
119
|
-
backgroundColor?: string;
|
|
120
|
-
borders?: TableCellBorders;
|
|
121
|
-
padding?: number;
|
|
122
|
-
wordWrap?: boolean;
|
|
123
|
-
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
124
|
-
maxWidth?: number;
|
|
125
|
-
maxHeight?: number;
|
|
126
|
-
}
|
|
127
|
-
/** 表格行 */
|
|
128
|
-
interface TableRow {
|
|
129
|
-
id: string;
|
|
130
|
-
type: TableRowType;
|
|
131
|
-
height: number;
|
|
132
|
-
repeatOnPage?: boolean;
|
|
133
|
-
cells: TableCell[];
|
|
134
|
-
}
|
|
135
|
-
/** 单元格选区(r/c 均为 0 基,闭区间) */
|
|
136
|
-
interface TableSelection {
|
|
137
|
-
elementId: string;
|
|
138
|
-
r1: number;
|
|
139
|
-
c1: number;
|
|
140
|
-
r2: number;
|
|
141
|
-
c2: number;
|
|
142
|
-
}
|
|
143
|
-
/** 表格历史字段绑定(兼容存量模板,实际取 fields[0].dataSource) */
|
|
144
|
-
interface ElementFieldBinding {
|
|
145
|
-
text?: string;
|
|
146
|
-
dataSource?: string;
|
|
147
|
-
}
|
|
148
|
-
/** 元素选项(序列化到 JSON) */
|
|
149
|
-
interface ElementOptions {
|
|
150
|
-
left: number;
|
|
151
|
-
top: number;
|
|
152
|
-
width: number;
|
|
153
|
-
height: number;
|
|
154
|
-
/** @deprecated 统一使用 formatter */
|
|
155
|
-
title?: string;
|
|
156
|
-
testData?: string;
|
|
157
|
-
fontSize?: number;
|
|
158
|
-
fontWeight?: string;
|
|
159
|
-
fontFamily?: string;
|
|
160
|
-
color?: string;
|
|
161
|
-
backgroundColor?: string;
|
|
162
|
-
textAlign?: TextAlign;
|
|
163
|
-
verticalAlign?: VerticalAlign;
|
|
164
|
-
lineHeight?: number;
|
|
165
|
-
letterSpacing?: number;
|
|
166
|
-
fixed?: boolean;
|
|
167
|
-
locked?: boolean;
|
|
168
|
-
/** 元素可见性(图层面板切换) */
|
|
169
|
-
visible?: boolean;
|
|
170
|
-
borderWidth?: number;
|
|
171
|
-
borderStyle?: string;
|
|
172
|
-
borderColor?: string;
|
|
173
|
-
contentPaddingLeft?: number;
|
|
174
|
-
contentPaddingTop?: number;
|
|
175
|
-
contentPaddingRight?: number;
|
|
176
|
-
contentPaddingBottom?: number;
|
|
177
|
-
textDecoration?: string;
|
|
178
|
-
textType?: 'barcode' | 'qrcode';
|
|
179
|
-
barcodeType?: string;
|
|
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 */
|
|
180
38
|
barWidth?: number;
|
|
181
|
-
barAutoWidth?: string;
|
|
182
|
-
qrCodeLevel?: string;
|
|
183
|
-
src?: string;
|
|
184
|
-
fit?: string;
|
|
185
|
-
hideTitle?: boolean;
|
|
186
|
-
draggable?: boolean;
|
|
187
|
-
axis?: string;
|
|
188
|
-
transform?: number;
|
|
189
|
-
zIndex?: number;
|
|
190
|
-
groupId?: string;
|
|
191
|
-
pagination?: PaginationConfig;
|
|
192
|
-
tablePagination?: TablePaginationConfig;
|
|
193
|
-
/** @deprecated 静态布局模式已移除,所有表格统一使用动态模式 */
|
|
194
|
-
tableMode?: 'dynamic' | 'static';
|
|
195
|
-
tableRows?: TableRow[];
|
|
196
|
-
tableColWidths?: number[];
|
|
197
|
-
tableDefaultFontSize?: number;
|
|
198
|
-
tableDefaultColor?: string;
|
|
199
|
-
tableDefaultPadding?: number;
|
|
200
|
-
/** 列表数据源路径(data 行迭代的数据数组) */
|
|
201
|
-
dataSource?: string;
|
|
202
|
-
/** @deprecated 兼容存量表格模型;列表数据源优先使用 dataSource */
|
|
203
|
-
fields?: ElementFieldBinding[];
|
|
204
|
-
formatter?: string;
|
|
205
|
-
styler?: string;
|
|
206
|
-
rowStyler?: string;
|
|
207
|
-
longTextIndent?: number;
|
|
208
|
-
leftSpaceRemoved?: boolean;
|
|
209
|
-
lHeight?: number;
|
|
210
|
-
}
|
|
211
|
-
/** 元素类型元数据 */
|
|
212
|
-
interface PrintElementTypeMeta {
|
|
213
|
-
title?: string;
|
|
214
|
-
type: ElementType;
|
|
215
|
-
editable?: boolean;
|
|
216
|
-
formatter?: string;
|
|
217
|
-
styler?: string;
|
|
218
|
-
}
|
|
219
|
-
/** 序列化元素数据 */
|
|
220
|
-
interface PrintElementData {
|
|
221
|
-
id?: string;
|
|
222
|
-
type?: ElementType;
|
|
223
|
-
options: ElementOptions;
|
|
224
|
-
printElementType: PrintElementTypeMeta;
|
|
225
|
-
}
|
|
226
|
-
/** 水印配置 */
|
|
227
|
-
interface WatermarkOptions {
|
|
228
|
-
/** 水印模式:fixed=固定文本,binding=绑定字段 */
|
|
229
|
-
mode?: 'fixed' | 'binding';
|
|
230
|
-
/** 固定文本(mode=fixed 时使用) */
|
|
231
|
-
content?: string;
|
|
232
|
-
/** 绑定字段(mode=binding 时使用) */
|
|
233
|
-
binding?: string;
|
|
234
|
-
/** 测试值(设计态预览使用) */
|
|
235
|
-
testData?: string;
|
|
236
|
-
/** 旋转角度 */
|
|
237
|
-
rotate?: number;
|
|
238
|
-
/** 颜色 */
|
|
239
|
-
color?: string;
|
|
240
|
-
/** 透明度 */
|
|
241
|
-
opacity?: number;
|
|
242
|
-
/** 显示时间戳 */
|
|
243
|
-
timestamp?: boolean;
|
|
244
|
-
/** 时间格式 */
|
|
245
|
-
format?: string;
|
|
246
39
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
|
|
258
|
-
id?: string;
|
|
259
|
-
fieldKey: string;
|
|
260
|
-
fieldLabel: string;
|
|
261
|
-
/** 字段类型;'list' 表示明细列表字段(用于表格数据源选择) */
|
|
262
|
-
fieldType: string;
|
|
263
|
-
sortOrder: number;
|
|
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;
|
|
264
51
|
}
|
|
265
52
|
/**
|
|
266
|
-
*
|
|
53
|
+
* 可用框(mm)并入最大宽高,得到结算尺寸的最终上限:
|
|
54
|
+
* - 可用框未知(≤0)时,最大宽高即上限;
|
|
55
|
+
* - 两者都未知时返回 0,交给 resolveBarcodeSize 的「不约束」分支。
|
|
56
|
+
* 调用侧(画布 / 出图)共用一份,避免「最大宽高在一端生效、在另一端不生效」。
|
|
267
57
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
listField?: string;
|
|
277
|
-
/** 提示文本 */
|
|
278
|
-
placeholder?: string;
|
|
279
|
-
/** 是否允许清空 */
|
|
280
|
-
clearable?: boolean;
|
|
281
|
-
}
|
|
282
|
-
/** 截图请求载荷(设计器叠层对比用) */
|
|
283
|
-
interface ScreenshotRequest {
|
|
284
|
-
templateJson: TemplateData;
|
|
285
|
-
printData: Record<string, any>;
|
|
286
|
-
}
|
|
287
|
-
/** 截图适配器:宿主依据模板 + 数据返回 PNG Blob */
|
|
288
|
-
type RequestScreenshotFn = (req: ScreenshotRequest) => Promise<Blob>;
|
|
289
|
-
/** 图片上传适配器:宿主上传文件并返回可访问的图片 URL */
|
|
290
|
-
type UploadImageFn = (file: File) => Promise<string>;
|
|
58
|
+
declare function barcodeAvailableBoxMm(boxMm: number | undefined, maxMm: number | undefined): number;
|
|
59
|
+
/**
|
|
60
|
+
* 求条码的落纸尺寸。
|
|
61
|
+
*
|
|
62
|
+
* 缩放是等比的:成品宽高始终等于各自的模块数乘以同一个每模块宽度,
|
|
63
|
+
* 所以「宽度不足」时高度同比缩小,条码不会被拉变形。
|
|
64
|
+
*/
|
|
65
|
+
declare function resolveBarcodeSize(input: BarcodeSizeInput): BarcodeSize;
|
|
291
66
|
|
|
292
67
|
/** pt 转 mm */
|
|
293
68
|
declare function ptToMm(pt: number): number;
|
|
@@ -314,13 +89,34 @@ declare function computeFitScale(containerW: number, containerH: number, paperW:
|
|
|
314
89
|
|
|
315
90
|
declare function normalizeTemplateUnits(data: TemplateData): TemplateData;
|
|
316
91
|
|
|
317
|
-
|
|
92
|
+
/** 标签纸分组名(PAPER_PRESETS.group):该组纸型默认取消页眉、页脚与页边距 */
|
|
93
|
+
declare const LABEL_PAPER_GROUP = "\u6807\u7B7E\u7EB8";
|
|
94
|
+
interface PaperPreset {
|
|
318
95
|
width: number;
|
|
319
96
|
height: number;
|
|
320
|
-
|
|
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'>;
|
|
321
116
|
/**
|
|
322
117
|
* 获取纸张原始宽高(mm,未应用方向)
|
|
323
|
-
* CUSTOM 时读取 customWidth/customHeight,缺省回退 A4
|
|
118
|
+
* CUSTOM 时读取 customWidth/customHeight,缺省回退 A4;
|
|
119
|
+
* 连续纸时宽度取 customWidth(缺省取预设纸宽),高度取 customHeight(缺省 297,仅设计画布),方向强制纵向。
|
|
324
120
|
*/
|
|
325
121
|
declare function getPaperDimensions(t: Pick<TemplateData, 'paperSize' | 'orientation' | 'customWidth' | 'customHeight'>): {
|
|
326
122
|
width: number;
|
|
@@ -649,4 +445,4 @@ declare function useBindingDisplay(): {
|
|
|
649
445
|
getBindingDisplayState: (element: any) => BindingDisplayState;
|
|
650
446
|
};
|
|
651
447
|
|
|
652
|
-
export { type AdsorbConfig,
|
|
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 };
|
package/dist/designer/index.js
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TemplateEngine
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-V4A5623C.js";
|
|
4
4
|
import {
|
|
5
|
+
BARCODE_BAR_HEIGHT_MODULES,
|
|
6
|
+
BARCODE_MARGIN_BOTTOM_MODULES,
|
|
7
|
+
BARCODE_MODULE_WIDTH_MM,
|
|
8
|
+
BARCODE_QUIET_ZONE_MODULES,
|
|
9
|
+
BARCODE_TEXT_FONT_SIZE_MODULES,
|
|
10
|
+
DEFAULT_SHRINK_MIN_FONT_SIZE_PT,
|
|
11
|
+
MIN_SHRINK_FONT_SIZE_PT,
|
|
12
|
+
MM_PER_INCH,
|
|
5
13
|
avg,
|
|
14
|
+
barcodeAvailableBoxMm,
|
|
15
|
+
barcodePreferredModuleWidthMm,
|
|
16
|
+
barcodeUnitsPerModule,
|
|
17
|
+
cellFitCapMm,
|
|
18
|
+
cellFitKey,
|
|
19
|
+
cellFitWidthMm,
|
|
6
20
|
count,
|
|
21
|
+
floorFontSize,
|
|
7
22
|
formatDate,
|
|
8
23
|
formatMoney,
|
|
9
24
|
ifFn,
|
|
10
25
|
max,
|
|
11
26
|
min,
|
|
27
|
+
mmToPx,
|
|
28
|
+
parseCellFitKey,
|
|
29
|
+
ptToMm,
|
|
30
|
+
pxToMm,
|
|
31
|
+
resolveBarcodeSize,
|
|
32
|
+
resolveCellTextFit,
|
|
33
|
+
resolveElementTextFit,
|
|
34
|
+
resolveShrinkMinFontSize,
|
|
35
|
+
roundFontSize,
|
|
12
36
|
sum,
|
|
13
37
|
toUpperCaseAmount
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
|
|
16
|
-
// src/designer/utils/units.ts
|
|
17
|
-
function ptToMm(pt) {
|
|
18
|
-
return pt / 2.83464566929;
|
|
19
|
-
}
|
|
20
|
-
function pxToMm(px) {
|
|
21
|
-
return px * (25.4 / 96);
|
|
22
|
-
}
|
|
23
|
-
function mmToPx(mm) {
|
|
24
|
-
return mm * (96 / 25.4);
|
|
25
|
-
}
|
|
38
|
+
} from "../chunk-VFEURLAZ.js";
|
|
26
39
|
|
|
27
40
|
// src/designer/utils/scale.ts
|
|
28
41
|
var MIN_SCALE_PERCENT = 25;
|
|
@@ -71,24 +84,55 @@ function normalizeTemplateUnits(data) {
|
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
// src/designer/utils/default-config.ts
|
|
87
|
+
var LABEL_PAPER_GROUP = "\u6807\u7B7E\u7EB8";
|
|
74
88
|
var PAPER_PRESETS = {
|
|
75
|
-
A4: { width: 210, height: 297 },
|
|
76
|
-
A3: { width: 297, height: 420 },
|
|
77
|
-
A5: { width: 148, height: 210 },
|
|
78
|
-
Letter: { width: 216, height: 279 },
|
|
79
|
-
Legal: { width: 216, height: 356 }
|
|
89
|
+
A4: { width: 210, height: 297, label: "A4 210\xD7297mm", group: "\u5E38\u7528\u7EB8\u5F20" },
|
|
90
|
+
A3: { width: 297, height: 420, label: "A3 297\xD7420mm", group: "\u5E38\u7528\u7EB8\u5F20" },
|
|
91
|
+
A5: { width: 148, height: 210, label: "A5 148\xD7210mm", group: "\u5E38\u7528\u7EB8\u5F20" },
|
|
92
|
+
Letter: { width: 216, height: 279, label: "Letter 216\xD7279mm", group: "\u5E38\u7528\u7EB8\u5F20" },
|
|
93
|
+
Legal: { width: 216, height: 356, label: "Legal 216\xD7356mm", group: "\u5E38\u7528\u7EB8\u5F20" },
|
|
94
|
+
// 针式打印纸(241 系列等分):11 英寸整张 279.4mm 按等分取整
|
|
95
|
+
DOT_FULL: { width: 241, height: 279.4, label: "\u5168\u7B49\u5206 241\xD7279.4mm", group: "\u9488\u5F0F\u6253\u5370\u7EB8" },
|
|
96
|
+
DOT_HALF: { width: 241, height: 139.7, label: "\u4E8C\u7B49\u5206 241\xD7139.7mm", group: "\u9488\u5F0F\u6253\u5370\u7EB8" },
|
|
97
|
+
DOT_THIRD: { width: 241, height: 93.1, label: "\u4E09\u7B49\u5206 241\xD793.1mm", group: "\u9488\u5F0F\u6253\u5370\u7EB8" },
|
|
98
|
+
// 标签纸
|
|
99
|
+
LABEL_80X60: { width: 80, height: 60, label: "80\xD760mm", group: LABEL_PAPER_GROUP },
|
|
100
|
+
LABEL_60X40: { width: 60, height: 40, label: "60\xD740mm", group: LABEL_PAPER_GROUP },
|
|
101
|
+
LABEL_40X30: { width: 40, height: 30, label: "40\xD730mm", group: LABEL_PAPER_GROUP },
|
|
102
|
+
// 小票纸(热敏卷纸):高度仅为设计画布高度,出纸按内容推导
|
|
103
|
+
THERMAL_57: { width: 57, height: 297, continuous: true, label: "57mm", group: "\u5C0F\u7968\u7EB8" },
|
|
104
|
+
THERMAL_80: { width: 80, height: 297, continuous: true, label: "80mm", group: "\u5C0F\u7968\u7EB8" },
|
|
105
|
+
THERMAL_110: { width: 110, height: 297, continuous: true, label: "110mm", group: "\u5C0F\u7968\u7EB8" },
|
|
106
|
+
// 连续纸:默认 80mm 热敏;高度仅为设计画布高度,出纸按内容推导
|
|
107
|
+
CONTINUOUS: { width: 80, height: 297, continuous: true, label: "\u8FDE\u7EED\u7EB8\uFF08\u81EA\u5B9A\u4E49\u5BBD\u5EA6\uFF09", group: "\u8FDE\u7EED\u7EB8" }
|
|
80
108
|
};
|
|
109
|
+
function isContinuousPaperSize(paperSize) {
|
|
110
|
+
return !!paperSize && PAPER_PRESETS[paperSize]?.continuous === true;
|
|
111
|
+
}
|
|
112
|
+
function isLabelPaperSize(paperSize) {
|
|
113
|
+
return !!paperSize && PAPER_PRESETS[paperSize]?.group === LABEL_PAPER_GROUP;
|
|
114
|
+
}
|
|
115
|
+
function labelPaperDefaults(t) {
|
|
116
|
+
return {
|
|
117
|
+
margins: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
118
|
+
header: { ...t.header, height: 0 },
|
|
119
|
+
footer: { ...t.footer, height: 0 }
|
|
120
|
+
};
|
|
121
|
+
}
|
|
81
122
|
function getPaperDimensions(t) {
|
|
123
|
+
const continuous = isContinuousPaperSize(t.paperSize);
|
|
82
124
|
let base;
|
|
83
|
-
if (t.paperSize === "CUSTOM") {
|
|
125
|
+
if (t.paperSize === "CUSTOM" || continuous) {
|
|
126
|
+
const preset = PAPER_PRESETS[t.paperSize];
|
|
84
127
|
base = {
|
|
85
|
-
width: t.customWidth ?? 210,
|
|
86
|
-
height: t.customHeight ?? 297
|
|
128
|
+
width: t.customWidth ?? preset?.width ?? 210,
|
|
129
|
+
height: t.customHeight ?? preset?.height ?? 297
|
|
87
130
|
};
|
|
88
131
|
} else {
|
|
89
|
-
|
|
132
|
+
const preset = PAPER_PRESETS[t.paperSize] || PAPER_PRESETS["A4"];
|
|
133
|
+
base = { width: preset.width, height: preset.height };
|
|
90
134
|
}
|
|
91
|
-
return t.orientation === "landscape" ? { width: base.height, height: base.width } : base;
|
|
135
|
+
return t.orientation === "landscape" && !continuous ? { width: base.height, height: base.width } : base;
|
|
92
136
|
}
|
|
93
137
|
|
|
94
138
|
// src/designer/utils/table-matrix.ts
|
|
@@ -268,6 +312,7 @@ function copyCellStyle(src, dst) {
|
|
|
268
312
|
dst.align = src.align;
|
|
269
313
|
dst.valign = src.valign;
|
|
270
314
|
dst.fontSize = src.fontSize;
|
|
315
|
+
dst.fontFamily = src.fontFamily;
|
|
271
316
|
dst.fontWeight = src.fontWeight;
|
|
272
317
|
dst.color = src.color;
|
|
273
318
|
dst.backgroundColor = src.backgroundColor;
|
|
@@ -691,6 +736,7 @@ var PROPERTY_REGISTRY = [
|
|
|
691
736
|
group: "appearance",
|
|
692
737
|
groupLabel: "\u5916\u89C2",
|
|
693
738
|
items: [
|
|
739
|
+
{ key: "ap-font-family", keywords: ["\u5B57\u4F53", "\u5B57\u4F53\u540D", "\u5B57\u4F53\u65CF", "fontfamily"] },
|
|
694
740
|
{ key: "ap-font-size", keywords: ["\u5B57\u4F53\u5927\u5C0F", "fontsize", "\u5B57\u53F7"] },
|
|
695
741
|
{ key: "ap-font-weight", keywords: ["\u5B57\u4F53\u7C97\u7EC6", "\u7C97\u4F53", "bold"] },
|
|
696
742
|
{ key: "ap-align", keywords: ["\u5BF9\u9F50", "align"] },
|
|
@@ -698,7 +744,25 @@ var PROPERTY_REGISTRY = [
|
|
|
698
744
|
{ key: "ap-color", keywords: ["\u989C\u8272", "color"] },
|
|
699
745
|
{ key: "ap-bg-color", keywords: ["\u80CC\u666F\u8272", "background"] },
|
|
700
746
|
{ key: "ap-line-height", keywords: ["\u884C\u9AD8", "lineheight"] },
|
|
701
|
-
{ key: "ap-letter-spacing", keywords: ["\u5B57\u95F4\u8DDD", "letterspacing"] }
|
|
747
|
+
{ key: "ap-letter-spacing", keywords: ["\u5B57\u95F4\u8DDD", "letterspacing"] },
|
|
748
|
+
{ key: "ap-text-fit", keywords: ["\u6EA2\u51FA", "\u6EA2\u51FA\u663E\u793A", "\u622A\u65AD", "\u81EA\u52A8\u7F29\u5C0F", "\u81EA\u9002\u5E94\u884C\u9AD8", "textfit", "overflow"] },
|
|
749
|
+
{ key: "ap-shrink-min", keywords: ["\u6700\u5C0F\u5B57\u53F7", "\u7F29\u653E\u4E0B\u9650", "shrinkminfontsize"] },
|
|
750
|
+
{ key: "ap-word-wrap", keywords: ["\u81EA\u52A8\u6362\u884C", "\u4E0D\u6362\u884C", "wordwrap"] }
|
|
751
|
+
]
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
group: "code",
|
|
755
|
+
groupLabel: "\u6761\u7801\u8BBE\u7F6E",
|
|
756
|
+
items: [
|
|
757
|
+
{ key: "cd-type", keywords: ["\u7801\u5236", "\u6761\u7801\u7C7B\u578B", "\u6761\u5F62\u7801\u7C7B\u578B", "barcodetype", "code128", "ean13", "code39", "itf14"] },
|
|
758
|
+
{ key: "cd-dpi", keywords: ["\u6253\u5370\u673A\u5206\u8FA8\u7387", "dpi", "\u6253\u5370\u70B9", "\u70B9\u9635\u5BF9\u9F50", "203", "300"] },
|
|
759
|
+
{ key: "cd-bar-width", keywords: ["\u6761\u5BBD", "\u6761\u7C97\u7EC6", "barwidth", "\u6A21\u5757\u5BBD"] },
|
|
760
|
+
{ key: "cd-show-text", keywords: ["\u663E\u793A\u6587\u672C", "\u6761\u7801\u6587\u672C", "\u663E\u793A\u6570\u5B57"] },
|
|
761
|
+
{ key: "cd-font-size", keywords: ["\u6761\u7801\u5B57\u53F7", "\u6587\u672C\u5B57\u53F7"] },
|
|
762
|
+
{ key: "cd-ec-level", keywords: ["\u7EA0\u9519\u7EA7\u522B", "\u5BB9\u9519", "qrcodelevel"] },
|
|
763
|
+
{ key: "cd-fit", keywords: ["\u7F29\u653E\u6A21\u5F0F", "\u62C9\u4F38", "\u7B49\u6BD4", "fit", "contain", "cover"] },
|
|
764
|
+
{ key: "cd-max-width", keywords: ["\u6700\u5927\u5BBD\u5EA6", "\u6700\u5927\u5BBD", "maxwidth"] },
|
|
765
|
+
{ key: "cd-max-height", keywords: ["\u6700\u5927\u9AD8\u5EA6", "\u6700\u5927\u9AD8", "maxheight"] }
|
|
702
766
|
]
|
|
703
767
|
},
|
|
704
768
|
{
|
|
@@ -1476,6 +1540,7 @@ function useResize(options) {
|
|
|
1476
1540
|
let startRect = { left: 0, top: 0, width: 0, height: 0 };
|
|
1477
1541
|
let activePoint = null;
|
|
1478
1542
|
function startResize(point, e) {
|
|
1543
|
+
if (e.button !== 0) return;
|
|
1479
1544
|
activePoint = point;
|
|
1480
1545
|
startX = e.clientX;
|
|
1481
1546
|
startY = e.clientY;
|
|
@@ -1547,13 +1612,22 @@ function useBindingDisplay() {
|
|
|
1547
1612
|
return { getBindingDisplayState };
|
|
1548
1613
|
}
|
|
1549
1614
|
export {
|
|
1615
|
+
BARCODE_BAR_HEIGHT_MODULES,
|
|
1616
|
+
BARCODE_MARGIN_BOTTOM_MODULES,
|
|
1617
|
+
BARCODE_MODULE_WIDTH_MM,
|
|
1618
|
+
BARCODE_QUIET_ZONE_MODULES,
|
|
1619
|
+
BARCODE_TEXT_FONT_SIZE_MODULES,
|
|
1550
1620
|
DEFAULT_DEMO_DATA,
|
|
1621
|
+
DEFAULT_SHRINK_MIN_FONT_SIZE_PT,
|
|
1551
1622
|
ELEMENT_BINDING_REGISTRY,
|
|
1552
1623
|
EXTENDED_FUNCTIONS,
|
|
1553
1624
|
FIT_SCALE_MIN_PERCENT,
|
|
1554
1625
|
GHOST_BORDER_CSS,
|
|
1626
|
+
LABEL_PAPER_GROUP,
|
|
1555
1627
|
MIN_COL_WIDTH_MM,
|
|
1556
1628
|
MIN_SCALE_PERCENT,
|
|
1629
|
+
MIN_SHRINK_FONT_SIZE_PT,
|
|
1630
|
+
MM_PER_INCH,
|
|
1557
1631
|
PAPER_PRESETS,
|
|
1558
1632
|
PRESET_COLORS,
|
|
1559
1633
|
PROPERTY_REGISTRY,
|
|
@@ -1561,9 +1635,15 @@ export {
|
|
|
1561
1635
|
RULER_THICKNESS,
|
|
1562
1636
|
ZONE_ALLOWED_TYPES,
|
|
1563
1637
|
applyBorderPreset,
|
|
1638
|
+
barcodeAvailableBoxMm,
|
|
1639
|
+
barcodePreferredModuleWidthMm,
|
|
1640
|
+
barcodeUnitsPerModule,
|
|
1564
1641
|
buildRulerTicks,
|
|
1565
1642
|
calcResizeRect,
|
|
1566
1643
|
canMergeReason,
|
|
1644
|
+
cellFitCapMm,
|
|
1645
|
+
cellFitKey,
|
|
1646
|
+
cellFitWidthMm,
|
|
1567
1647
|
chooseMajorStepMM,
|
|
1568
1648
|
clampResizedColumnWidth,
|
|
1569
1649
|
clampScalePercent,
|
|
@@ -1582,6 +1662,7 @@ export {
|
|
|
1582
1662
|
filterGroups,
|
|
1583
1663
|
finalizeElementZone,
|
|
1584
1664
|
findMainCell,
|
|
1665
|
+
floorFontSize,
|
|
1585
1666
|
generateGroupId,
|
|
1586
1667
|
generateId,
|
|
1587
1668
|
getDemoData,
|
|
@@ -1594,6 +1675,9 @@ export {
|
|
|
1594
1675
|
groupFields,
|
|
1595
1676
|
insertCol,
|
|
1596
1677
|
insertRow,
|
|
1678
|
+
isContinuousPaperSize,
|
|
1679
|
+
isLabelPaperSize,
|
|
1680
|
+
labelPaperDefaults,
|
|
1597
1681
|
matchKeywords,
|
|
1598
1682
|
mergeCells,
|
|
1599
1683
|
minorStepMM,
|
|
@@ -1601,11 +1685,17 @@ export {
|
|
|
1601
1685
|
nextWheelScale,
|
|
1602
1686
|
normalizeSelection,
|
|
1603
1687
|
normalizeTemplateUnits,
|
|
1688
|
+
parseCellFitKey,
|
|
1604
1689
|
ptToMm,
|
|
1605
1690
|
pxToMm,
|
|
1606
1691
|
resolveBarcodeDesignValue,
|
|
1692
|
+
resolveBarcodeSize,
|
|
1607
1693
|
resolveCellBorderCss,
|
|
1694
|
+
resolveCellTextFit,
|
|
1695
|
+
resolveElementTextFit,
|
|
1696
|
+
resolveShrinkMinFontSize,
|
|
1608
1697
|
resolveTextBinding,
|
|
1698
|
+
roundFontSize,
|
|
1609
1699
|
safeEval,
|
|
1610
1700
|
searchProperties,
|
|
1611
1701
|
setRowType,
|