@canvas-components/print-design 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +125 -3
- package/dist/index.cjs +7157 -0
- package/dist/index.d.cts +1291 -0
- package/dist/index.d.ts +1291 -0
- package/dist/index.js +7097 -0
- package/package.json +33 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1291 @@
|
|
|
1
|
+
import { BarcodeFormat } from '@canvas-components/barcode';
|
|
2
|
+
import { QrCodeLevel, QrCodeFormat, QrCodeMode, QrCodeContentTemplate, QrCodeContentFields } from '@canvas-components/qrcode';
|
|
3
|
+
|
|
4
|
+
/** 设计器显示单位;文档和打印计算始终使用毫米。 */
|
|
5
|
+
type PrintDesignUnit = "mm" | "cm" | "in" | "pt" | "px";
|
|
6
|
+
/** 每个显示单位对应的毫米数;px 按 CSS 96 DPI 换算。 */
|
|
7
|
+
declare const PRINT_DESIGN_UNIT_MM: Record<PrintDesignUnit, number>;
|
|
8
|
+
/** 将毫米值转换为界面显示值。 */
|
|
9
|
+
declare function toDisplayUnit(mm: number, unit?: PrintDesignUnit): number;
|
|
10
|
+
/** 将界面输入值转换回毫米。 */
|
|
11
|
+
declare function fromDisplayUnit(value: number, unit?: PrintDesignUnit): number;
|
|
12
|
+
/** 格式化辅助线和测距标签。 */
|
|
13
|
+
declare function formatDisplayUnit(mm: number, unit?: PrintDesignUnit): string;
|
|
14
|
+
|
|
15
|
+
/** 打印设计透视表字段区域。 */
|
|
16
|
+
type PrintPivotFieldArea = "filter" | "column" | "row" | "value";
|
|
17
|
+
type PrintPivotAggregator = "sum" | "avg" | "count" | "distinctCount" | "rowCount" | "mergedRowCount" | "min" | "max";
|
|
18
|
+
/** 可序列化的透视字段,路径沿用 ListTable 的 dataIndex 约定。 */
|
|
19
|
+
interface PrintPivotField {
|
|
20
|
+
key: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
/** 打印表格的表头文案;留空时沿用字段名称或自动汇总标题。 */
|
|
23
|
+
headerTitle?: string;
|
|
24
|
+
dataIndex?: string | (string | number)[];
|
|
25
|
+
defaultArea?: PrintPivotFieldArea;
|
|
26
|
+
indicator?: {
|
|
27
|
+
title?: string;
|
|
28
|
+
aggregator?: PrintPivotAggregator;
|
|
29
|
+
/** 值字段表头是否显示“求和项:”等汇总方式前缀。 */
|
|
30
|
+
showAggregatorPrefix?: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** 四个区域各自保留字段顺序。 */
|
|
34
|
+
interface PrintPivotFieldLayout {
|
|
35
|
+
filters: string[];
|
|
36
|
+
columns: string[];
|
|
37
|
+
rows: string[];
|
|
38
|
+
values: string[];
|
|
39
|
+
}
|
|
40
|
+
interface PrintPivotFilterState {
|
|
41
|
+
rows: Record<string, {
|
|
42
|
+
condition?: {
|
|
43
|
+
operator: "equals";
|
|
44
|
+
value?: unknown;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
columns: Record<string, {
|
|
48
|
+
condition?: {
|
|
49
|
+
operator: "equals";
|
|
50
|
+
value?: unknown;
|
|
51
|
+
};
|
|
52
|
+
}>;
|
|
53
|
+
filters?: Record<string, {
|
|
54
|
+
condition?: {
|
|
55
|
+
operator: "equals";
|
|
56
|
+
value?: unknown;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
/** 字段在行列筛选间互斥,值区域允许复用维度字段。 */
|
|
61
|
+
declare function movePrintPivotField(layout: PrintPivotFieldLayout, fieldKey: string, area: PrintPivotFieldArea, index?: number, sourceArea?: PrintPivotFieldArea): PrintPivotFieldLayout;
|
|
62
|
+
/** 从全部区域移除字段。 */
|
|
63
|
+
declare function removePrintPivotField(layout: PrintPivotFieldLayout, fieldKey: string): PrintPivotFieldLayout;
|
|
64
|
+
declare function findPrintPivotFieldArea(layout: PrintPivotFieldLayout, fieldKey: string): PrintPivotFieldArea | null;
|
|
65
|
+
declare function printPivotFieldTitle(field: PrintPivotField): string;
|
|
66
|
+
/** 获取字段对应的打印表头标题。 */
|
|
67
|
+
declare function printPivotFieldHeaderTitle(field: PrintPivotField): string;
|
|
68
|
+
declare function printPivotValueTitle(field: PrintPivotField): string;
|
|
69
|
+
|
|
70
|
+
/** 设计文档当前支持的 schema 版本。 */
|
|
71
|
+
declare const PRINT_DESIGN_SCHEMA_VERSION = 1;
|
|
72
|
+
/** 元素共有的毫米坐标与编辑状态。 */
|
|
73
|
+
interface PrintDesignElementBase {
|
|
74
|
+
id: string;
|
|
75
|
+
type: string;
|
|
76
|
+
name?: string;
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
/** 超出纸张时拆分到后续页、整体移到下一页、裁切或以省略号结束。 */
|
|
82
|
+
overflowPolicy?: "split" | "nextPage" | "clip" | "ellipsis";
|
|
83
|
+
/** 拆分绘制时,原组件中被裁切的垂直范围。 */
|
|
84
|
+
overflowCrop?: {
|
|
85
|
+
offset: number;
|
|
86
|
+
fullHeight: number;
|
|
87
|
+
};
|
|
88
|
+
rotation?: number;
|
|
89
|
+
opacity?: number;
|
|
90
|
+
visible?: boolean;
|
|
91
|
+
/** 组件显隐方式;动态模式从数据字段读取布尔状态。 */
|
|
92
|
+
visibility?: {
|
|
93
|
+
mode: "static" | "binding";
|
|
94
|
+
path?: string;
|
|
95
|
+
};
|
|
96
|
+
locked?: boolean;
|
|
97
|
+
/** 基础组件字段绑定;静态值仍保留在原属性中,切换模式不会丢失。 */
|
|
98
|
+
dataConfig?: {
|
|
99
|
+
mode: "static" | "binding";
|
|
100
|
+
bindings?: Record<string, string>;
|
|
101
|
+
};
|
|
102
|
+
/** 从外到内的组合路径,组合成员共用稳定 id。 */
|
|
103
|
+
groupPath?: {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
}[];
|
|
107
|
+
}
|
|
108
|
+
/** 文本元素。 */
|
|
109
|
+
interface PrintDesignTextElement extends PrintDesignElementBase {
|
|
110
|
+
type: "text";
|
|
111
|
+
text: string;
|
|
112
|
+
fontSize?: number;
|
|
113
|
+
fontFamily?: string;
|
|
114
|
+
fontWeight?: string;
|
|
115
|
+
color?: string;
|
|
116
|
+
/** 文本框边界线,单位毫米;用于打印时核对排版区域。 */
|
|
117
|
+
borderColor?: string;
|
|
118
|
+
borderWidth?: number;
|
|
119
|
+
textAlign?: CanvasTextAlign | "justify" | "distributed";
|
|
120
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
|
121
|
+
lineHeight?: number;
|
|
122
|
+
/** 下划线条数;0 表示不绘制。 */
|
|
123
|
+
underlineCount?: number;
|
|
124
|
+
underlineStyle?: "solid" | "dashed" | "dotted" | "wavy";
|
|
125
|
+
underlineColor?: string;
|
|
126
|
+
/** 下划线宽度与间距,单位毫米。 */
|
|
127
|
+
underlineWidth?: number;
|
|
128
|
+
underlineGap?: number;
|
|
129
|
+
/** 文本超出固定高度时的处理方式。 */
|
|
130
|
+
heightOverflow?: "clip" | "flow" | "ellipsis";
|
|
131
|
+
/** 按字数上限选择字号;超过所有区间时使用最大上限的字号。 */
|
|
132
|
+
fontSizeRules?: Array<{
|
|
133
|
+
maxChars: number;
|
|
134
|
+
fontSize: number;
|
|
135
|
+
}>;
|
|
136
|
+
/** 可选字体文件地址,与 fontFamily 配合加载。 */
|
|
137
|
+
fontSource?: string;
|
|
138
|
+
/** 分页生成的文本已按目标宽度断行,绘制时保留这些断行。 */
|
|
139
|
+
prewrapped?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** 打印用列表;单选与复选状态仅控制静态外观。 */
|
|
142
|
+
interface PrintDesignListElement extends PrintDesignElementBase {
|
|
143
|
+
type: "list";
|
|
144
|
+
listStyle: "ordered" | "unordered" | "radio" | "checkbox";
|
|
145
|
+
items: {
|
|
146
|
+
text: string;
|
|
147
|
+
checked?: boolean;
|
|
148
|
+
}[];
|
|
149
|
+
fontSize?: number;
|
|
150
|
+
color?: string;
|
|
151
|
+
rowHeight?: number;
|
|
152
|
+
}
|
|
153
|
+
/** 日期时间元素。 */
|
|
154
|
+
interface PrintDesignDateTimeElement extends PrintDesignElementBase {
|
|
155
|
+
type: "dateTime";
|
|
156
|
+
format?: string;
|
|
157
|
+
value?: string;
|
|
158
|
+
fontSize?: number;
|
|
159
|
+
color?: string;
|
|
160
|
+
}
|
|
161
|
+
/** 金额大写元素。 */
|
|
162
|
+
interface PrintDesignMoneyUpperElement extends PrintDesignElementBase {
|
|
163
|
+
type: "moneyUpper";
|
|
164
|
+
value: string | number;
|
|
165
|
+
amountFormat?: "chinese" | "formal" | "number";
|
|
166
|
+
fontSize?: number;
|
|
167
|
+
color?: string;
|
|
168
|
+
}
|
|
169
|
+
/** 页码元素。 */
|
|
170
|
+
interface PrintDesignPageNumberElement extends PrintDesignElementBase {
|
|
171
|
+
type: "pageNumber";
|
|
172
|
+
prefix?: string;
|
|
173
|
+
fontSize?: number;
|
|
174
|
+
color?: string;
|
|
175
|
+
}
|
|
176
|
+
/** 水印元素。 */
|
|
177
|
+
interface PrintDesignWatermarkElement extends PrintDesignElementBase {
|
|
178
|
+
type: "watermark";
|
|
179
|
+
text: string;
|
|
180
|
+
fontSize?: number;
|
|
181
|
+
color?: string;
|
|
182
|
+
rotation?: number;
|
|
183
|
+
/** 水印文字自身的旋转角度,不影响元素选中框。 */
|
|
184
|
+
textRotation?: number;
|
|
185
|
+
/** 文字重复行数,1–50。@default 1 */
|
|
186
|
+
rows?: number;
|
|
187
|
+
/** 文字重复列数,1–50。@default 1 */
|
|
188
|
+
columns?: number;
|
|
189
|
+
}
|
|
190
|
+
/** 形状元素。 */
|
|
191
|
+
interface PrintDesignShapeElement extends PrintDesignElementBase {
|
|
192
|
+
type: "shape";
|
|
193
|
+
shape: "rect" | "ellipse" | "line" | "triangle" | "circle" | "polygon" | "sector" | "star";
|
|
194
|
+
fill?: string;
|
|
195
|
+
stroke?: string;
|
|
196
|
+
strokeWidth?: number;
|
|
197
|
+
radius?: number;
|
|
198
|
+
/** 正多边形边数,范围 3–12。@default 5 */
|
|
199
|
+
sides?: number;
|
|
200
|
+
/** 扇形圆心角,范围 1–359 度。@default 120 */
|
|
201
|
+
sectorAngle?: number;
|
|
202
|
+
/** 形状内部居中的文本。 */
|
|
203
|
+
text?: string;
|
|
204
|
+
fontSize?: number;
|
|
205
|
+
textColor?: string;
|
|
206
|
+
}
|
|
207
|
+
/** 分割线元素。线条方向、外观与选择区域由元素属性控制。 */
|
|
208
|
+
interface PrintDesignDividerElement extends PrintDesignElementBase {
|
|
209
|
+
type: "divider";
|
|
210
|
+
orientation?: "horizontal" | "vertical";
|
|
211
|
+
stroke?: string;
|
|
212
|
+
strokeWidth?: number;
|
|
213
|
+
lineStyle?: "solid" | "dashed" | "dotted";
|
|
214
|
+
}
|
|
215
|
+
/** 可打印刻度尺。总刻度表示从 0 到该数值的等距区间数。 */
|
|
216
|
+
interface PrintDesignRulerElement extends PrintDesignElementBase {
|
|
217
|
+
type: "ruler";
|
|
218
|
+
orientation: "horizontal" | "vertical";
|
|
219
|
+
/** 数字与刻度位于基线的哪一侧:横向为上/下,纵向为左/右。@default "after" */
|
|
220
|
+
labelPosition?: "before" | "after";
|
|
221
|
+
totalTicks: number;
|
|
222
|
+
middleEvery?: number;
|
|
223
|
+
majorEvery?: number;
|
|
224
|
+
minorHeight?: number;
|
|
225
|
+
middleHeight?: number;
|
|
226
|
+
majorHeight?: number;
|
|
227
|
+
lineColor?: string;
|
|
228
|
+
labelColor?: string;
|
|
229
|
+
strokeWidth?: number;
|
|
230
|
+
fontSize?: number;
|
|
231
|
+
}
|
|
232
|
+
/** 网格单元格中的静态标记。 */
|
|
233
|
+
type PrintDesignGridMark = "none" | "x" | "*";
|
|
234
|
+
/** 单格静态标记及独立数据绑定;动态值无效时沿用静态值。 */
|
|
235
|
+
interface PrintDesignGridCell {
|
|
236
|
+
content?: PrintDesignGridMark;
|
|
237
|
+
contentMode?: "static" | "binding";
|
|
238
|
+
contentPath?: string;
|
|
239
|
+
backgroundColor?: string;
|
|
240
|
+
}
|
|
241
|
+
/** 可按单元格显示标记与背景色的打印网格。 */
|
|
242
|
+
interface PrintDesignGridElement extends PrintDesignElementBase {
|
|
243
|
+
type: "grid";
|
|
244
|
+
rows: number;
|
|
245
|
+
columns: number;
|
|
246
|
+
/** 在画布点击单元格时使用的标记。 */
|
|
247
|
+
paintMark?: "x" | "*";
|
|
248
|
+
/** 二维 0/1 选中数组的默认绑定路径;单元格可覆盖。 */
|
|
249
|
+
contentPath?: string;
|
|
250
|
+
/** 按行优先排列;每格可独立绑定选中状态。 */
|
|
251
|
+
cells?: PrintDesignGridCell[];
|
|
252
|
+
backgroundColor?: string;
|
|
253
|
+
/** 带有 X 或米字标记的单元格背景色;独立背景配置优先。 */
|
|
254
|
+
selectedBackgroundColor?: string;
|
|
255
|
+
lineColor?: string;
|
|
256
|
+
lineWidth?: number;
|
|
257
|
+
markColor?: string;
|
|
258
|
+
}
|
|
259
|
+
/** 条形或环形打印进度。尺寸、边框与圆角以毫米表示。 */
|
|
260
|
+
interface PrintDesignProgressElement extends PrintDesignElementBase {
|
|
261
|
+
type: "progress";
|
|
262
|
+
variant: "bar" | "ring";
|
|
263
|
+
/** 完成百分比,范围 0–100。 */
|
|
264
|
+
value: number;
|
|
265
|
+
/** 动态完成百分比字段,缺失或无效时使用静态 value。 */
|
|
266
|
+
valuePath?: string;
|
|
267
|
+
completedColor?: string;
|
|
268
|
+
remainingColor?: string;
|
|
269
|
+
borderColor?: string;
|
|
270
|
+
borderWidth?: number;
|
|
271
|
+
/** 条形圆角或环形进度端点圆角半径。 */
|
|
272
|
+
borderRadius?: number;
|
|
273
|
+
/** 环形轨道厚度。 */
|
|
274
|
+
thickness?: number;
|
|
275
|
+
/** 条形右侧或环形中心显示完成百分比。 */
|
|
276
|
+
showPercent?: boolean;
|
|
277
|
+
/** 百分比字号,单位 pt。 */
|
|
278
|
+
percentFontSize?: number;
|
|
279
|
+
percentColor?: string;
|
|
280
|
+
/** 按最高命中的阈值覆盖当前进度与百分比文字颜色。 */
|
|
281
|
+
colorRules?: Array<{
|
|
282
|
+
min: number;
|
|
283
|
+
completedColor: string;
|
|
284
|
+
percentColor: string;
|
|
285
|
+
}>;
|
|
286
|
+
}
|
|
287
|
+
/** 模拟时钟;颜色分别控制表盘、刻度、数字和三根指针。 */
|
|
288
|
+
interface PrintDesignClockElement extends PrintDesignElementBase {
|
|
289
|
+
type: "clock";
|
|
290
|
+
/** ISO 日期时间或 HH:mm[:ss];为空时使用系统时间。 */
|
|
291
|
+
value?: string;
|
|
292
|
+
/** 自动刷新间隔;none 固定显示传入时间。 */
|
|
293
|
+
refreshInterval?: "none" | "second" | "minute" | "hour";
|
|
294
|
+
/** 传入时间开始运行的时间戳,修改 value 时同步更新。 */
|
|
295
|
+
startedAt?: string;
|
|
296
|
+
showHourHand?: boolean;
|
|
297
|
+
showMinuteHand?: boolean;
|
|
298
|
+
showSecondHand?: boolean;
|
|
299
|
+
hourHandColor?: string;
|
|
300
|
+
minuteHandColor?: string;
|
|
301
|
+
secondHandColor?: string;
|
|
302
|
+
ringColor?: string;
|
|
303
|
+
/** 旧版统一刻度颜色;各级颜色未设置时作为回退值。 */
|
|
304
|
+
tickColor?: string;
|
|
305
|
+
showSmallTicks?: boolean;
|
|
306
|
+
showMediumTicks?: boolean;
|
|
307
|
+
showLargeTicks?: boolean;
|
|
308
|
+
smallTickColor?: string;
|
|
309
|
+
mediumTickColor?: string;
|
|
310
|
+
largeTickColor?: string;
|
|
311
|
+
numberColor?: string;
|
|
312
|
+
/** 刻度数字字号,单位 pt。 */
|
|
313
|
+
numberFontSize?: number;
|
|
314
|
+
}
|
|
315
|
+
/** 图片元素。 */
|
|
316
|
+
interface PrintDesignImageElement extends PrintDesignElementBase {
|
|
317
|
+
type: "image";
|
|
318
|
+
src: string;
|
|
319
|
+
fit?: "contain" | "cover" | "fill";
|
|
320
|
+
}
|
|
321
|
+
/** 条形码元素。 */
|
|
322
|
+
interface PrintDesignBarcodeElement extends PrintDesignElementBase {
|
|
323
|
+
type: "barcode";
|
|
324
|
+
value: string;
|
|
325
|
+
format?: BarcodeFormat;
|
|
326
|
+
color?: string;
|
|
327
|
+
backgroundColor?: string;
|
|
328
|
+
displayValue?: boolean;
|
|
329
|
+
}
|
|
330
|
+
/** 二维码元素。 */
|
|
331
|
+
interface PrintDesignQrCodeElement extends PrintDesignElementBase {
|
|
332
|
+
type: "qrcode";
|
|
333
|
+
value: string;
|
|
334
|
+
level?: QrCodeLevel;
|
|
335
|
+
format?: QrCodeFormat;
|
|
336
|
+
mode?: QrCodeMode;
|
|
337
|
+
contentTemplate?: QrCodeContentTemplate;
|
|
338
|
+
templateFields?: QrCodeContentFields;
|
|
339
|
+
color?: string;
|
|
340
|
+
backgroundColor?: string;
|
|
341
|
+
}
|
|
342
|
+
/** 图表数据编辑与绑定配置,字段路径相对于数据源中的每条记录。 */
|
|
343
|
+
interface PrintDesignChartData {
|
|
344
|
+
mode: "static" | "binding";
|
|
345
|
+
source?: string;
|
|
346
|
+
/** 数据源缺失时使用静态分类和系列作为默认内容。 */
|
|
347
|
+
fallbackToStatic?: boolean;
|
|
348
|
+
categoryField?: string;
|
|
349
|
+
categories: string[];
|
|
350
|
+
series: Array<{
|
|
351
|
+
name: string;
|
|
352
|
+
field?: string;
|
|
353
|
+
values: number[];
|
|
354
|
+
}>;
|
|
355
|
+
/** 雷达图指标上限。 */
|
|
356
|
+
max?: number;
|
|
357
|
+
}
|
|
358
|
+
/** 使用 chart 包现有渲染器绘制的静态图表元素。 */
|
|
359
|
+
interface PrintDesignChartElement extends PrintDesignElementBase {
|
|
360
|
+
type: "chart";
|
|
361
|
+
chartType: string;
|
|
362
|
+
chartData?: PrintDesignChartData;
|
|
363
|
+
option: unknown;
|
|
364
|
+
simple?: boolean;
|
|
365
|
+
}
|
|
366
|
+
/** 打印表格列配置,保留常用显示、汇总与编辑字段。 */
|
|
367
|
+
interface PrintDesignTableColumn {
|
|
368
|
+
key?: string;
|
|
369
|
+
title?: string | number | {
|
|
370
|
+
type: string;
|
|
371
|
+
text?: string;
|
|
372
|
+
alt?: string;
|
|
373
|
+
} | Array<{
|
|
374
|
+
type: string;
|
|
375
|
+
text?: string;
|
|
376
|
+
alt?: string;
|
|
377
|
+
}>;
|
|
378
|
+
dataIndex?: string | number | Array<string | number>;
|
|
379
|
+
children?: PrintDesignTableColumn[];
|
|
380
|
+
width?: number;
|
|
381
|
+
minWidth?: number;
|
|
382
|
+
maxWidth?: number;
|
|
383
|
+
align?: "left" | "center" | "right";
|
|
384
|
+
headerAlign?: "left" | "center" | "right";
|
|
385
|
+
hidden?: boolean;
|
|
386
|
+
ellipsis?: boolean;
|
|
387
|
+
cellType?: string;
|
|
388
|
+
cellStyle?: {
|
|
389
|
+
textAlign?: "left" | "center" | "right";
|
|
390
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
|
391
|
+
backgroundColor?: string;
|
|
392
|
+
color?: string;
|
|
393
|
+
};
|
|
394
|
+
headerStyle?: {
|
|
395
|
+
backgroundColor?: string;
|
|
396
|
+
color?: string;
|
|
397
|
+
};
|
|
398
|
+
summaryStyle?: {
|
|
399
|
+
backgroundColor?: string;
|
|
400
|
+
color?: string;
|
|
401
|
+
};
|
|
402
|
+
summary?: boolean | {
|
|
403
|
+
type?: string;
|
|
404
|
+
precision?: number;
|
|
405
|
+
showTypePrefix?: boolean;
|
|
406
|
+
preserveTrailingZeros?: boolean;
|
|
407
|
+
valueGetter?: (record: Record<string, unknown>) => string | number | null | undefined;
|
|
408
|
+
formatter?: (value: string | number, records: Record<string, unknown>[], column: PrintDesignTableColumn) => string;
|
|
409
|
+
};
|
|
410
|
+
summaryTitle?: string;
|
|
411
|
+
moneyFormat?: {
|
|
412
|
+
symbol?: string;
|
|
413
|
+
thousandsSeparator?: boolean | string;
|
|
414
|
+
decimalPlaces?: number;
|
|
415
|
+
precision?: number;
|
|
416
|
+
};
|
|
417
|
+
render?: (value: unknown, record: Record<string, unknown>, rowIndex: number, column: PrintDesignTableColumn) => unknown;
|
|
418
|
+
}
|
|
419
|
+
/** 表格组件。行高单位毫米,列宽沿用 ListTable 的逻辑像素。 */
|
|
420
|
+
interface PrintDesignTableElement extends PrintDesignElementBase {
|
|
421
|
+
type: "table";
|
|
422
|
+
columns: PrintDesignTableColumn[];
|
|
423
|
+
dataSource: Record<string, unknown>[];
|
|
424
|
+
dataMode?: "static" | "binding";
|
|
425
|
+
dataPath?: string;
|
|
426
|
+
/** 数据源缺失时使用 dataSource 作为默认内容,空数组仍视为有效数据。 */
|
|
427
|
+
fallbackToStatic?: boolean;
|
|
428
|
+
rowHeight?: number;
|
|
429
|
+
headerRowHeight?: number;
|
|
430
|
+
showHeader?: boolean;
|
|
431
|
+
fontSize?: number;
|
|
432
|
+
/** 单元格边框,宽度为逻辑像素;0 表示无边框。 */
|
|
433
|
+
cellBorder?: {
|
|
434
|
+
color?: string;
|
|
435
|
+
width?: number;
|
|
436
|
+
};
|
|
437
|
+
/** 默认水平对齐,列级配置优先。 */
|
|
438
|
+
cellAlign?: "left" | "center" | "right";
|
|
439
|
+
/** 默认垂直对齐,列级配置优先。 */
|
|
440
|
+
cellVerticalAlign?: "top" | "middle" | "bottom";
|
|
441
|
+
/** 单元格超出方式,沿用 ListTable 的换行与省略号模式。 */
|
|
442
|
+
cellOverflow?: "wrap" | "ellipsis";
|
|
443
|
+
/** 是否显示列配置生成的汇总行,默认显示。 */
|
|
444
|
+
showSummary?: boolean;
|
|
445
|
+
/** 汇总行高,单位毫米,默认沿用数据行高。 */
|
|
446
|
+
summaryRowHeight?: number;
|
|
447
|
+
/** 最多打印的数据行数,0 或未设置表示全部;不包含表头和汇总行。 */
|
|
448
|
+
printRowCount?: number;
|
|
449
|
+
/** 按打印行数补齐空白行,不修改原始数据,也不计入汇总。 */
|
|
450
|
+
fillEmptyRows?: boolean;
|
|
451
|
+
/** 各区域默认透明,列级样式可覆盖对应区域配置。 */
|
|
452
|
+
colors?: Partial<Record<"header" | "body" | "summary", {
|
|
453
|
+
backgroundColor?: string;
|
|
454
|
+
color?: string;
|
|
455
|
+
}>>;
|
|
456
|
+
}
|
|
457
|
+
/** 基于 ListTable 记录集生成的透视表;字段和区域配置保持可序列化。 */
|
|
458
|
+
interface PrintDesignPivotTableElement extends PrintDesignElementBase {
|
|
459
|
+
type: "pivotTable";
|
|
460
|
+
/** 按生成列键保存的列宽,单位为逻辑像素。 */
|
|
461
|
+
columnWidths?: Record<string, number>;
|
|
462
|
+
dataSource: Record<string, unknown>[];
|
|
463
|
+
dataMode?: "static" | "binding";
|
|
464
|
+
dataPath?: string;
|
|
465
|
+
fallbackToStatic?: boolean;
|
|
466
|
+
fields: PrintPivotField[];
|
|
467
|
+
layout: PrintPivotFieldLayout;
|
|
468
|
+
filters?: PrintPivotFilterState;
|
|
469
|
+
rowHeight?: number;
|
|
470
|
+
headerRowHeight?: number;
|
|
471
|
+
showHeader?: boolean;
|
|
472
|
+
fontSize?: number;
|
|
473
|
+
cellBorder?: {
|
|
474
|
+
color?: string;
|
|
475
|
+
width?: number;
|
|
476
|
+
};
|
|
477
|
+
colors?: PrintDesignTableElement["colors"];
|
|
478
|
+
/** 是否显示由透视数据生成的总计行。 */
|
|
479
|
+
showSummary?: boolean;
|
|
480
|
+
summaryRowHeight?: number;
|
|
481
|
+
/** 是否显示列分组的总计列。 */
|
|
482
|
+
showGrandTotal?: boolean;
|
|
483
|
+
}
|
|
484
|
+
/** 打印甘特图的时间精度。 */
|
|
485
|
+
type PrintGanttScale = "second" | "minute" | "hour" | "day" | "week" | "month";
|
|
486
|
+
/** 打印甘特图任务。 */
|
|
487
|
+
interface PrintGanttTask {
|
|
488
|
+
id: string;
|
|
489
|
+
title: string;
|
|
490
|
+
start?: string | number;
|
|
491
|
+
end?: string | number;
|
|
492
|
+
progress?: number;
|
|
493
|
+
color?: string;
|
|
494
|
+
progressColor?: string;
|
|
495
|
+
/** 当前任务的前置任务连线,to 默认为当前任务 ID。 */
|
|
496
|
+
dependencies?: Omit<PrintGanttDependency, "to">[];
|
|
497
|
+
tasks?: PrintGanttTask[];
|
|
498
|
+
}
|
|
499
|
+
/** 打印甘特图任务依赖。 */
|
|
500
|
+
interface PrintGanttDependency {
|
|
501
|
+
from: string;
|
|
502
|
+
to: string;
|
|
503
|
+
type?: "finish-to-start" | "start-to-start" | "finish-to-finish";
|
|
504
|
+
color?: string;
|
|
505
|
+
}
|
|
506
|
+
/** 可打印的甘特图快照。 */
|
|
507
|
+
interface PrintDesignGanttElement extends PrintDesignElementBase {
|
|
508
|
+
type: "gantt";
|
|
509
|
+
tasks: PrintGanttTask[];
|
|
510
|
+
showDependencies?: boolean;
|
|
511
|
+
dependencyColor?: string;
|
|
512
|
+
/** 依赖连线宽度,单位为逻辑像素。 */
|
|
513
|
+
dependencyLineWidth?: number;
|
|
514
|
+
dependencyArrow?: boolean;
|
|
515
|
+
dataMode?: "static" | "binding";
|
|
516
|
+
dataPath?: string;
|
|
517
|
+
fallbackToStatic?: boolean;
|
|
518
|
+
scale?: PrintGanttScale;
|
|
519
|
+
startDate?: string;
|
|
520
|
+
endDate?: string;
|
|
521
|
+
taskColumnTitle?: string;
|
|
522
|
+
taskColumnRatio?: number;
|
|
523
|
+
/** 任务列正文文字的水平对齐方式。 */
|
|
524
|
+
taskAlign?: "left" | "center" | "right";
|
|
525
|
+
taskColor?: string;
|
|
526
|
+
progressColor?: string;
|
|
527
|
+
/** 任务进度条圆角半径,单位毫米。 */
|
|
528
|
+
progressRadius?: number;
|
|
529
|
+
/** 任务进度条高度,单位毫米;不超过当前行高。 */
|
|
530
|
+
progressHeight?: number;
|
|
531
|
+
/** 每条任务的行高,单位毫米;未配置时平均填充组件高度。 */
|
|
532
|
+
rowHeight?: number;
|
|
533
|
+
/** 表头可关闭;表头高度以毫米保存。 */
|
|
534
|
+
showHeader?: boolean;
|
|
535
|
+
headerHeight?: number;
|
|
536
|
+
headerBackgroundColor?: string;
|
|
537
|
+
headerTextColor?: string;
|
|
538
|
+
/** 任务列标题和时间轴刻度的水平对齐方式。 */
|
|
539
|
+
headerAlign?: "left" | "center" | "right";
|
|
540
|
+
cellBackgroundColor?: string;
|
|
541
|
+
cellTextColor?: string;
|
|
542
|
+
/** 边框宽度沿用表格的逻辑像素单位;0 表示隐藏。 */
|
|
543
|
+
frameBorder?: {
|
|
544
|
+
color?: string;
|
|
545
|
+
width?: number;
|
|
546
|
+
};
|
|
547
|
+
headerBorder?: {
|
|
548
|
+
color?: string;
|
|
549
|
+
width?: number;
|
|
550
|
+
};
|
|
551
|
+
cellBorder?: {
|
|
552
|
+
color?: string;
|
|
553
|
+
width?: number;
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
/** 打印设计器支持的元素联合类型。 */
|
|
557
|
+
type PrintDesignElement = PrintDesignTextElement | PrintDesignListElement | PrintDesignDateTimeElement | PrintDesignMoneyUpperElement | PrintDesignPageNumberElement | PrintDesignWatermarkElement | PrintDesignShapeElement | PrintDesignDividerElement | PrintDesignRulerElement | PrintDesignGridElement | PrintDesignProgressElement | PrintDesignClockElement | PrintDesignImageElement | PrintDesignBarcodeElement | PrintDesignQrCodeElement | PrintDesignChartElement | PrintDesignTableElement | PrintDesignPivotTableElement | PrintDesignGanttElement;
|
|
558
|
+
/** 页面纸张方向。 */
|
|
559
|
+
type PrintDesignOrientation = "portrait" | "landscape";
|
|
560
|
+
/** 页面内边距,单位为毫米。 */
|
|
561
|
+
interface PrintDesignPageMargins {
|
|
562
|
+
top: number;
|
|
563
|
+
right: number;
|
|
564
|
+
bottom: number;
|
|
565
|
+
left: number;
|
|
566
|
+
}
|
|
567
|
+
/** 打印设计器页面。所有几何尺寸均以毫米保存。 */
|
|
568
|
+
interface PrintDesignPage {
|
|
569
|
+
id: string;
|
|
570
|
+
name: string;
|
|
571
|
+
width: number;
|
|
572
|
+
height: number;
|
|
573
|
+
orientation?: PrintDesignOrientation;
|
|
574
|
+
margins?: PrintDesignPageMargins;
|
|
575
|
+
background?: string;
|
|
576
|
+
/** 以页面原点为基准的辅助线位置,单位毫米;允许超出纸张边界。 */
|
|
577
|
+
guides?: {
|
|
578
|
+
vertical?: number[];
|
|
579
|
+
horizontal?: number[];
|
|
580
|
+
};
|
|
581
|
+
elements: PrintDesignElement[];
|
|
582
|
+
}
|
|
583
|
+
/** 可序列化的打印设计文档。 */
|
|
584
|
+
interface PrintDesignDocument {
|
|
585
|
+
id: string;
|
|
586
|
+
name: string;
|
|
587
|
+
schemaVersion: number;
|
|
588
|
+
dpi?: number;
|
|
589
|
+
pages: PrintDesignPage[];
|
|
590
|
+
}
|
|
591
|
+
/** 核心实例选项。 */
|
|
592
|
+
interface PrintDesignOptions {
|
|
593
|
+
/** 界面标尺和尺寸显示单位,文档坐标仍为毫米。@default "mm" */
|
|
594
|
+
displayUnit?: PrintDesignUnit;
|
|
595
|
+
document?: PrintDesignDocument;
|
|
596
|
+
/** 用于预览 {{field.path}} 文本变量的数据。 */
|
|
597
|
+
data?: Record<string, unknown>;
|
|
598
|
+
/** 临时显示的分页预览页;不修改设计文档。 */
|
|
599
|
+
preview?: {
|
|
600
|
+
page: PrintDesignPage;
|
|
601
|
+
data: Record<string, unknown>;
|
|
602
|
+
};
|
|
603
|
+
/** 模板变化回调。 */
|
|
604
|
+
onChange?: (document: PrintDesignDocument) => void;
|
|
605
|
+
/** 鼠标、按钮和 API 改变缩放比例时触发。 */
|
|
606
|
+
onZoomChange?: (zoom: number) => void;
|
|
607
|
+
/** 当前页面或元素选区变化回调。 */
|
|
608
|
+
onSelectionChange?: (selection: PrintDesignSelection) => void;
|
|
609
|
+
/** 当前活动页变化回调。 */
|
|
610
|
+
onActivePageChange?: (pageId: string) => void;
|
|
611
|
+
/** 初始画布缩放比例。@default 1 */
|
|
612
|
+
zoom?: number;
|
|
613
|
+
/** 只读模式。 */
|
|
614
|
+
readonly?: boolean;
|
|
615
|
+
/** 是否显示网格。@default false */
|
|
616
|
+
showGrid?: boolean;
|
|
617
|
+
/** 网格线颜色。默认 rgba(148, 163, 184, 0.24)。 */
|
|
618
|
+
gridColor?: string;
|
|
619
|
+
/** 网格步长,单位毫米,最小 0.1。@default 5 */
|
|
620
|
+
gridStep?: number;
|
|
621
|
+
/** 是否显示画布刻度尺。@default true */
|
|
622
|
+
showRulers?: boolean;
|
|
623
|
+
/** 是否显示并允许编辑辅助线。@default true */
|
|
624
|
+
showGuides?: boolean;
|
|
625
|
+
/** 是否显示页面边距辅助线。@default false */
|
|
626
|
+
showMarginGuides?: boolean;
|
|
627
|
+
/** 用户辅助线颜色。@default "#06b6d4" */
|
|
628
|
+
guideColor?: string;
|
|
629
|
+
/** 打印边距辅助线颜色。@default "#8b5cf6" */
|
|
630
|
+
marginGuideColor?: string;
|
|
631
|
+
/** 刻度尺字号,单位 CSS 像素,范围 8–16。@default 9 */
|
|
632
|
+
rulerFontSize?: number;
|
|
633
|
+
/** 刻度尺背景色。@default "#f8fafc" */
|
|
634
|
+
rulerBackground?: string;
|
|
635
|
+
/** 刻度线及刻度尺边界线颜色。@default "#cbd5e1" */
|
|
636
|
+
rulerLineColor?: string;
|
|
637
|
+
/** 刻度数字颜色。@default "#64748b" */
|
|
638
|
+
rulerTextColor?: string;
|
|
639
|
+
/** 辅助线数值字号,单位 CSS 像素,范围 8–24。@default 9 */
|
|
640
|
+
guideFontSize?: number;
|
|
641
|
+
/** 辅助线数值标签背景色。@default "#cffafe" */
|
|
642
|
+
guideBackground?: string;
|
|
643
|
+
/** 选中辅助线数值标签背景色。@default "#ffedd5" */
|
|
644
|
+
guideSelectedBackground?: string;
|
|
645
|
+
/** 图层状态标签文字与锁定图标颜色。@default "#ffffff" */
|
|
646
|
+
indicatorColor?: string;
|
|
647
|
+
/** 图层状态标签背景色。@default "#2563eb" */
|
|
648
|
+
indicatorBackground?: string;
|
|
649
|
+
/** 图层状态标签字号,单位 CSS 像素,范围 8–24。@default 11 */
|
|
650
|
+
indicatorFontSize?: number;
|
|
651
|
+
/** 图层状态标签相对组件的位置。@default "top-right" */
|
|
652
|
+
indicatorPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
653
|
+
/** 框选区域填充颜色。 */
|
|
654
|
+
marqueeFill?: string;
|
|
655
|
+
/** 框选区域边框颜色。 */
|
|
656
|
+
marqueeStroke?: string;
|
|
657
|
+
/** 框选区域边框线型。@default "dashed" */
|
|
658
|
+
marqueeLineStyle?: "solid" | "dashed" | "dotted";
|
|
659
|
+
/** 拖拽启动距离,单位 CSS 像素。@default 4 */
|
|
660
|
+
dragThreshold?: number;
|
|
661
|
+
/** 启用辅助线吸附。@default true */
|
|
662
|
+
snapToGuides?: boolean;
|
|
663
|
+
/** 吸附距离,单位 CSS 像素。@default 6 */
|
|
664
|
+
snapTolerance?: number;
|
|
665
|
+
/** 显示选中组件与最近组件的间距。@default true */
|
|
666
|
+
showMeasurements?: boolean;
|
|
667
|
+
/** 缩放过渡时长,单位毫秒;0 表示关闭。@default 180 */
|
|
668
|
+
zoomDuration?: number;
|
|
669
|
+
/** 调试辅助层配置;传入 true 显示元素边界、选区和命中目标。 */
|
|
670
|
+
debug?: boolean | PrintDesignDebugOptions;
|
|
671
|
+
}
|
|
672
|
+
/** 打印设计器调试辅助层配置。 */
|
|
673
|
+
interface PrintDesignDebugOptions {
|
|
674
|
+
enabled?: boolean;
|
|
675
|
+
showElementBounds?: boolean;
|
|
676
|
+
showSelectionBounds?: boolean;
|
|
677
|
+
showHitTarget?: boolean;
|
|
678
|
+
}
|
|
679
|
+
/** 编辑器当前选区。 */
|
|
680
|
+
interface PrintDesignSelection {
|
|
681
|
+
pageId: string;
|
|
682
|
+
elementIds: string[];
|
|
683
|
+
/** 当前选中的辅助线图层;与普通元素选区互斥。 */
|
|
684
|
+
guide?: {
|
|
685
|
+
axis: "vertical" | "horizontal";
|
|
686
|
+
index: number;
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
/** 页面导出选项。 */
|
|
690
|
+
interface PrintDesignExportOptions {
|
|
691
|
+
/** 导出和打印使用的数据源,默认使用实例 data。 */
|
|
692
|
+
data?: Record<string, unknown>;
|
|
693
|
+
/** 输出分辨率。@default 文档 dpi 或 300 */
|
|
694
|
+
dpi?: number;
|
|
695
|
+
/** 透明背景。@default false */
|
|
696
|
+
transparent?: boolean;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** 创建默认 A4 纵向设计文档。 */
|
|
700
|
+
declare function createPrintDesignDocument(overrides?: Partial<PrintDesignDocument>): PrintDesignDocument;
|
|
701
|
+
/** 创建指定大小的空白页面。 */
|
|
702
|
+
declare function createPrintDesignPage(name?: string, width?: number, height?: number): PrintDesignPage;
|
|
703
|
+
/** 创建稳定性足够的轻量级文档 id。 */
|
|
704
|
+
declare function createPrintDesignId(prefix?: string): string;
|
|
705
|
+
/** 校验并规范化导入的打印文档。 */
|
|
706
|
+
declare function parsePrintDesignDocument(input: unknown): PrintDesignDocument;
|
|
707
|
+
/** 将设计文档编码为格式化 JSON。 */
|
|
708
|
+
declare function serializePrintDesignDocument(document: PrintDesignDocument): string;
|
|
709
|
+
|
|
710
|
+
/** 将变量文本中的 {{path}} 替换为预览数据字段。 */
|
|
711
|
+
declare function resolveDesignText(text: string, data?: Record<string, unknown>): string;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* 绘制单个元素到 Canvas 2D 上下文。
|
|
715
|
+
*/
|
|
716
|
+
declare function drawPrintDesignElement(ctx: CanvasRenderingContext2D, element: PrintDesignElement, scale: number, data?: Record<string, unknown>, onImageLoad?: () => void): void;
|
|
717
|
+
/**
|
|
718
|
+
* 绘制页面到任意 2D 上下文,输出页面尺寸以毫米和目标 DPI 决定。
|
|
719
|
+
*/
|
|
720
|
+
declare function drawPrintDesignPage(ctx: CanvasRenderingContext2D, page: PrintDesignPage, options?: {
|
|
721
|
+
dpi?: number;
|
|
722
|
+
transparent?: boolean;
|
|
723
|
+
data?: Record<string, unknown>;
|
|
724
|
+
originX?: number;
|
|
725
|
+
originY?: number;
|
|
726
|
+
scale?: number;
|
|
727
|
+
onImageLoad?: () => void;
|
|
728
|
+
}): void;
|
|
729
|
+
/** 将指定页面渲染到新 Canvas,供高清导出和打印使用。 */
|
|
730
|
+
declare function renderPrintDesignPageToCanvas(document: PrintDesignDocument, pageId: string, options?: PrintDesignExportOptions): HTMLCanvasElement;
|
|
731
|
+
/** 在给定页面上查找坐标命中的最上层元素。 */
|
|
732
|
+
declare function hitTestPrintDesignPage(page: PrintDesignPage, point: {
|
|
733
|
+
x: number;
|
|
734
|
+
y: number;
|
|
735
|
+
}, tolerance?: number, data?: Record<string, unknown>): PrintDesignTextElement | PrintDesignListElement | PrintDesignDateTimeElement | PrintDesignMoneyUpperElement | PrintDesignPageNumberElement | PrintDesignWatermarkElement | PrintDesignShapeElement | PrintDesignDividerElement | PrintDesignRulerElement | PrintDesignGridElement | PrintDesignProgressElement | PrintDesignClockElement | PrintDesignImageElement | PrintDesignBarcodeElement | PrintDesignQrCodeElement | PrintDesignChartElement | PrintDesignTableElement | PrintDesignPivotTableElement | PrintDesignGanttElement | undefined;
|
|
736
|
+
/** 将 Canvas 像素坐标换算成页面毫米坐标。 */
|
|
737
|
+
declare function canvasPointToPageMillimeters(point: {
|
|
738
|
+
x: number;
|
|
739
|
+
y: number;
|
|
740
|
+
}, origin: {
|
|
741
|
+
x: number;
|
|
742
|
+
y: number;
|
|
743
|
+
}, cssPixelsPerMillimeter: number): {
|
|
744
|
+
x: number;
|
|
745
|
+
y: number;
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
/** HTML 打印转换的数据源与页面选择。 */
|
|
749
|
+
interface PrintDesignHtmlOptions {
|
|
750
|
+
data?: Record<string, unknown>;
|
|
751
|
+
/** 省略时输出文档中的所有页面。 */
|
|
752
|
+
pageIds?: readonly string[];
|
|
753
|
+
}
|
|
754
|
+
/** 将设计文档及数据转换为可直接交给浏览器打印的 HTML。 */
|
|
755
|
+
declare function transformPrintDesignToHtml(document: PrintDesignDocument, options?: PrintDesignHtmlOptions): string;
|
|
756
|
+
/** 将转换后的 HTML 写入打印窗口,等待图片加载后唤起浏览器打印。 */
|
|
757
|
+
declare function printPrintDesignHtml(popup: Window, html: string): void;
|
|
758
|
+
|
|
759
|
+
type ResizeHandle = "nw" | "ne" | "se" | "sw" | "n" | "s" | "w" | "e";
|
|
760
|
+
type Rect = Pick<PrintDesignElement, "x" | "y" | "width" | "height">;
|
|
761
|
+
|
|
762
|
+
/** 表格列边界拖拽快照,使用打印表格的可见布局宽度。 */
|
|
763
|
+
interface TableColumnResize {
|
|
764
|
+
elementId: string;
|
|
765
|
+
boundary: number;
|
|
766
|
+
widths: number[];
|
|
767
|
+
columns: PrintDesignTableColumn[];
|
|
768
|
+
rotation: number;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
type GroupResizeHandle = ResizeHandle;
|
|
772
|
+
|
|
773
|
+
interface DragSession {
|
|
774
|
+
tableColumn?: TableColumnResize;
|
|
775
|
+
mode: "table-column" | "move" | "resize" | "rotate" | "guide" | "pan" | "marquee";
|
|
776
|
+
marquee?: {
|
|
777
|
+
end: {
|
|
778
|
+
x: number;
|
|
779
|
+
y: number;
|
|
780
|
+
};
|
|
781
|
+
initialIds: string[];
|
|
782
|
+
};
|
|
783
|
+
pointerId: number;
|
|
784
|
+
start: {
|
|
785
|
+
x: number;
|
|
786
|
+
y: number;
|
|
787
|
+
};
|
|
788
|
+
startClient?: {
|
|
789
|
+
x: number;
|
|
790
|
+
y: number;
|
|
791
|
+
};
|
|
792
|
+
activated?: boolean;
|
|
793
|
+
groupResize?: {
|
|
794
|
+
handle: GroupResizeHandle;
|
|
795
|
+
bounds: Rect;
|
|
796
|
+
elements: PrintDesignElement[];
|
|
797
|
+
};
|
|
798
|
+
resize?: {
|
|
799
|
+
elementId: string;
|
|
800
|
+
handle: ResizeHandle;
|
|
801
|
+
initial: {
|
|
802
|
+
x: number;
|
|
803
|
+
y: number;
|
|
804
|
+
width: number;
|
|
805
|
+
height: number;
|
|
806
|
+
};
|
|
807
|
+
anchor: {
|
|
808
|
+
x: number;
|
|
809
|
+
y: number;
|
|
810
|
+
};
|
|
811
|
+
rotation: number;
|
|
812
|
+
};
|
|
813
|
+
rotate?: {
|
|
814
|
+
elementId: string;
|
|
815
|
+
center: {
|
|
816
|
+
x: number;
|
|
817
|
+
y: number;
|
|
818
|
+
};
|
|
819
|
+
startAngle: number;
|
|
820
|
+
initialRotation: number;
|
|
821
|
+
};
|
|
822
|
+
elementPositions: Map<string, {
|
|
823
|
+
x: number;
|
|
824
|
+
y: number;
|
|
825
|
+
}>;
|
|
826
|
+
documentBefore: PrintDesignDocument;
|
|
827
|
+
changed: boolean;
|
|
828
|
+
guide?: {
|
|
829
|
+
axis: "vertical" | "horizontal";
|
|
830
|
+
index: number;
|
|
831
|
+
created: boolean;
|
|
832
|
+
};
|
|
833
|
+
pan?: {
|
|
834
|
+
initialX: number;
|
|
835
|
+
initialY: number;
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
/** 共享打印设计器状态、生命周期与视口基础能力。 */
|
|
839
|
+
declare abstract class PrintDesignBase {
|
|
840
|
+
protected readonly container: HTMLElement;
|
|
841
|
+
protected readonly canvas: HTMLCanvasElement;
|
|
842
|
+
protected readonly context: CanvasRenderingContext2D;
|
|
843
|
+
protected readonly host: HTMLDivElement;
|
|
844
|
+
protected resizeObserver?: ResizeObserver;
|
|
845
|
+
protected options: PrintDesignOptions;
|
|
846
|
+
protected document: PrintDesignDocument;
|
|
847
|
+
protected activePageId: string;
|
|
848
|
+
protected selectedElementIds: string[];
|
|
849
|
+
protected history: PrintDesignDocument[];
|
|
850
|
+
protected future: PrintDesignDocument[];
|
|
851
|
+
protected cssWidth: number;
|
|
852
|
+
protected cssHeight: number;
|
|
853
|
+
protected zoom: number;
|
|
854
|
+
protected panX: number;
|
|
855
|
+
protected panY: number;
|
|
856
|
+
protected dragSession: DragSession | null;
|
|
857
|
+
protected spacePressed: boolean;
|
|
858
|
+
protected zoomTarget?: number;
|
|
859
|
+
protected zoomAnimationFrame: number | null;
|
|
860
|
+
protected selectedGuide: {
|
|
861
|
+
axis: "vertical" | "horizontal";
|
|
862
|
+
index: number;
|
|
863
|
+
} | null;
|
|
864
|
+
protected bindingHoverId: string | null;
|
|
865
|
+
protected debugPointer: {
|
|
866
|
+
x: number;
|
|
867
|
+
y: number;
|
|
868
|
+
} | null;
|
|
869
|
+
protected mounted: boolean;
|
|
870
|
+
/** 创建实例并准备 Canvas 宿主;调用 mount 后开始渲染。 */
|
|
871
|
+
constructor(container: HTMLElement, options?: PrintDesignOptions);
|
|
872
|
+
/** 将 Canvas 宿主挂载到容器并开始观察尺寸。 */
|
|
873
|
+
mount(): this;
|
|
874
|
+
/** 更新回调、数据、视口或外部传入的设计文档。 */
|
|
875
|
+
updateOptions(options: Partial<PrintDesignOptions>): this;
|
|
876
|
+
/** 清理观察器、事件和宿主节点。 */
|
|
877
|
+
destroy(): void;
|
|
878
|
+
protected abstract handleDoubleClick: (event: MouseEvent) => void;
|
|
879
|
+
protected abstract discardTextEditing(): void;
|
|
880
|
+
protected abstract handlePointerDown: (event: PointerEvent) => void;
|
|
881
|
+
protected abstract handlePointerMove: (event: PointerEvent) => void;
|
|
882
|
+
protected abstract handlePointerUp: (event: PointerEvent) => void;
|
|
883
|
+
protected abstract handlePointerLeave: (event: PointerEvent) => void;
|
|
884
|
+
protected abstract handleWheel: (event: WheelEvent) => void;
|
|
885
|
+
protected abstract handleKeyDown: (event: KeyboardEvent) => void;
|
|
886
|
+
/** 失焦时释放空格状态,避免再次进入画布后保持平移模式。 */
|
|
887
|
+
protected handleBlur: () => void;
|
|
888
|
+
protected abstract handleKeyUp: (event: KeyboardEvent) => void;
|
|
889
|
+
abstract render(): this;
|
|
890
|
+
abstract fitToView(): this;
|
|
891
|
+
abstract getDocument(): PrintDesignDocument;
|
|
892
|
+
abstract getSelection(): PrintDesignSelection;
|
|
893
|
+
abstract groupElements(elementIds?: string[]): this;
|
|
894
|
+
abstract ungroupElements(elementIds?: string[]): this;
|
|
895
|
+
abstract undo(): this;
|
|
896
|
+
abstract redo(): this;
|
|
897
|
+
abstract removeElements(elementIds?: string[]): this;
|
|
898
|
+
abstract removeGuide(axis: "vertical" | "horizontal", index: number): this;
|
|
899
|
+
abstract selectElements(elementIds: string[], expandGroups?: boolean): this;
|
|
900
|
+
abstract setZoom(zoom: number): this;
|
|
901
|
+
abstract getZoom(): number;
|
|
902
|
+
/** 停止视口动画,保持当前显示比例。 */
|
|
903
|
+
protected stopZoomAnimation(): void;
|
|
904
|
+
protected getActivePage(): PrintDesignPage;
|
|
905
|
+
/** 视口使用预览页时,保留实际活动页供编辑和导出使用。 */
|
|
906
|
+
protected getDisplayPage(): PrintDesignPage;
|
|
907
|
+
protected getPageIn(document: PrintDesignDocument): PrintDesignPage;
|
|
908
|
+
protected commitMutation(mutator: (document: PrintDesignDocument) => void): void;
|
|
909
|
+
protected pushHistory(document: PrintDesignDocument): void;
|
|
910
|
+
protected normalizeActivePageAfterHistory(): void;
|
|
911
|
+
protected emitChange(): void;
|
|
912
|
+
protected emitSelection(): void;
|
|
913
|
+
protected resizeCanvas: () => void;
|
|
914
|
+
protected normalizeZoom(zoom: number): number;
|
|
915
|
+
protected pageOrigin(): {
|
|
916
|
+
scale: number;
|
|
917
|
+
x: number;
|
|
918
|
+
y: number;
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/** 静态表格单元格编辑会话与文档历史,独立于文本元素编辑。 */
|
|
923
|
+
declare abstract class PrintDesignTableEditing extends PrintDesignBase {
|
|
924
|
+
private tableEditing;
|
|
925
|
+
protected beginTableEditing(element: PrintDesignTableElement, point: {
|
|
926
|
+
x: number;
|
|
927
|
+
y: number;
|
|
928
|
+
}): void;
|
|
929
|
+
/** 外部变更和选中状态变化使草稿失效;缩放、平移则同步浮层位置。 */
|
|
930
|
+
protected syncTableEditor(): void;
|
|
931
|
+
protected discardTableEditing(): void;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** 原生文本编辑浮层;草稿与文档隔离,提交时只产生一次撤销记录。 */
|
|
935
|
+
declare class PrintDesignTextEditor {
|
|
936
|
+
private host;
|
|
937
|
+
readonly elementId: string;
|
|
938
|
+
readonly pageId: string;
|
|
939
|
+
readonly initialText: string;
|
|
940
|
+
private onFinish;
|
|
941
|
+
private settings;
|
|
942
|
+
private input;
|
|
943
|
+
private composing;
|
|
944
|
+
private currentElement;
|
|
945
|
+
private currentOrigin;
|
|
946
|
+
constructor(host: HTMLElement, elementId: string, pageId: string, initialText: string, onFinish: (value: string | undefined, restoreFocus: boolean) => void, settings?: {
|
|
947
|
+
label?: string;
|
|
948
|
+
validate?: (value: string) => string | undefined;
|
|
949
|
+
});
|
|
950
|
+
/** 创建编辑框并选中原文。 */
|
|
951
|
+
mount(element: PrintDesignTextElement, origin: {
|
|
952
|
+
x: number;
|
|
953
|
+
y: number;
|
|
954
|
+
scale: number;
|
|
955
|
+
}): void;
|
|
956
|
+
/** 同步视口和字体,缩放、平移或容器变化时保持与文本重合。 */
|
|
957
|
+
update(element: PrintDesignTextElement, origin: {
|
|
958
|
+
x: number;
|
|
959
|
+
y: number;
|
|
960
|
+
scale: number;
|
|
961
|
+
}): void;
|
|
962
|
+
/** 关闭前先解除会话,防止移除节点触发 blur 后重复提交。 */
|
|
963
|
+
finish(commit: boolean, restoreFocus?: boolean): void;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/** 连接原生文本编辑会话、文档历史与画布坐标。 */
|
|
967
|
+
declare abstract class PrintDesignTextEditing extends PrintDesignTableEditing {
|
|
968
|
+
protected textEditor: PrintDesignTextEditor | null;
|
|
969
|
+
protected handleDoubleClick: (event: MouseEvent) => void;
|
|
970
|
+
/** 文档或页面切换后丢弃过期草稿,避免覆盖外部更新。 */
|
|
971
|
+
protected syncTextEditor(): void;
|
|
972
|
+
protected discardTextEditing(): void;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/** 负责页面、选区、辅助线及命中反馈的 Canvas 绘制。 */
|
|
976
|
+
declare abstract class PrintDesignRenderer extends PrintDesignTextEditing {
|
|
977
|
+
private clockTimer;
|
|
978
|
+
private clockTimerMs;
|
|
979
|
+
/** 仅为当前页面中启用刷新且可见的时钟维护一个定时器。 */
|
|
980
|
+
private syncClockTimer;
|
|
981
|
+
/** 卸载时释放自动刷新定时器。 */
|
|
982
|
+
destroy(): void;
|
|
983
|
+
/** 重绘当前页面。 */
|
|
984
|
+
render(): this;
|
|
985
|
+
private drawGrid;
|
|
986
|
+
private drawSelection;
|
|
987
|
+
/** 组合四边控制柄与外部图层重叠时,优先保留其它图层的选择。 */
|
|
988
|
+
protected hitTestGroupResizeHandle(point: {
|
|
989
|
+
x: number;
|
|
990
|
+
y: number;
|
|
991
|
+
}, page: PrintDesignPage, scale: number): {
|
|
992
|
+
handle: ResizeHandle;
|
|
993
|
+
bounds: Rect;
|
|
994
|
+
} | undefined;
|
|
995
|
+
protected hitTestResizeHandle(point: {
|
|
996
|
+
x: number;
|
|
997
|
+
y: number;
|
|
998
|
+
}, page: PrintDesignPage, scale: number): {
|
|
999
|
+
element: PrintDesignElement;
|
|
1000
|
+
handle: ResizeHandle;
|
|
1001
|
+
} | undefined;
|
|
1002
|
+
protected hitTestRotateHandle(point: {
|
|
1003
|
+
x: number;
|
|
1004
|
+
y: number;
|
|
1005
|
+
}, page: PrintDesignPage, scale: number): {
|
|
1006
|
+
element: PrintDesignElement;
|
|
1007
|
+
} | undefined;
|
|
1008
|
+
protected getRotatedCorner(element: PrintDesignElement, handle: ResizeHandle, scale: number): {
|
|
1009
|
+
x: number;
|
|
1010
|
+
y: number;
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/** 负责选择、拖拽、缩放、键盘和光标交互。 */
|
|
1015
|
+
declare abstract class PrintDesignInteraction extends PrintDesignRenderer {
|
|
1016
|
+
private panRenderFrame;
|
|
1017
|
+
/** 平移期间每帧最多重绘一次,避免高频 pointermove 重复绘制整页。 */
|
|
1018
|
+
private schedulePanRender;
|
|
1019
|
+
private startPanDrag;
|
|
1020
|
+
private startGuideDrag;
|
|
1021
|
+
protected handlePointerDown: (event: PointerEvent) => void;
|
|
1022
|
+
protected handlePointerMove: (event: PointerEvent) => void;
|
|
1023
|
+
protected handlePointerUp: (event: PointerEvent) => void;
|
|
1024
|
+
protected handlePointerLeave: () => void;
|
|
1025
|
+
/** 根据当前命中目标显示选择和拖动光标。 */
|
|
1026
|
+
private updateCursor;
|
|
1027
|
+
protected handleKeyDown: (event: KeyboardEvent) => void;
|
|
1028
|
+
protected handleKeyUp: (event: KeyboardEvent) => void;
|
|
1029
|
+
private removeSelectedGuide;
|
|
1030
|
+
protected normalizeSelectedGuide(): void;
|
|
1031
|
+
protected handleWheel: (event: WheelEvent) => void;
|
|
1032
|
+
private resizeElementFromPointer;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/** 管理组合关系,坐标仍保存在元素上,导出与打印共用既有绘制链路。 */
|
|
1036
|
+
declare abstract class PrintDesignGrouping extends PrintDesignInteraction {
|
|
1037
|
+
/** 重命名组合,同步更新所有成员的组合信息,支持撤销重做。 */
|
|
1038
|
+
renameGroup(groupId: string, name: string): this;
|
|
1039
|
+
/** 同级图层相对排序,整组移动;after 表示视觉列表中放在目标下方。 */
|
|
1040
|
+
moveLayerRelative(elementId: string, targetId: string, after: boolean, depth?: number): this;
|
|
1041
|
+
/** 将多个元素或已有组合合成一个新组合,并保持内部相对层级。 */
|
|
1042
|
+
groupElements(elementIds?: string[]): this;
|
|
1043
|
+
/** 取消选中组合的最外层,保留其内部嵌套组合。 */
|
|
1044
|
+
ungroupElements(elementIds?: string[]): this;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/** 图层位置对齐与排列;justify 等间距,distribute 等中心距。 */
|
|
1048
|
+
type PrintDesignLayerAlignment = "left" | "center" | "right" | "top" | "middle" | "bottom" | "justify-horizontal" | "justify-vertical" | "distribute-horizontal" | "distribute-vertical";
|
|
1049
|
+
/** 完整选中的组合视为整体,左侧单独选中的子项保持独立。 */
|
|
1050
|
+
declare function getPrintDesignAlignmentUnits(elements: PrintDesignElement[], ids: string[]): PrintDesignElement[][];
|
|
1051
|
+
|
|
1052
|
+
/** 菜单批量操作与实例内剪贴板;每次文档操作只提交一条历史。 */
|
|
1053
|
+
declare abstract class PrintDesignActions extends PrintDesignGrouping {
|
|
1054
|
+
private elementClipboard;
|
|
1055
|
+
/** 画布右键命中选区;点中已选项保留多选,空白清空选区。 */
|
|
1056
|
+
selectAtClientPoint(clientX: number, clientY: number): this;
|
|
1057
|
+
/** 复制选中元素,保留组合、数据及样式,不使用系统剪贴板。 */
|
|
1058
|
+
copyElements(): this;
|
|
1059
|
+
/** 当前实例是否有可粘贴元素。 */
|
|
1060
|
+
canPasteElements(): boolean;
|
|
1061
|
+
/** 剪切选区;锁定元素不可剪切。 */
|
|
1062
|
+
cutElements(): this;
|
|
1063
|
+
/** 粘贴为新元素及新组合,默认向右下偏移 5mm。 */
|
|
1064
|
+
pasteElements(): this;
|
|
1065
|
+
/** 创建选区副本,不覆盖实例剪贴板。 */
|
|
1066
|
+
duplicateElements(): this;
|
|
1067
|
+
private insertCopies;
|
|
1068
|
+
private selectedElements;
|
|
1069
|
+
/** 设置选区锁定或显隐状态。 */
|
|
1070
|
+
setSelectionState(patch: {
|
|
1071
|
+
locked?: boolean;
|
|
1072
|
+
visible?: boolean;
|
|
1073
|
+
}): this;
|
|
1074
|
+
/** 精确设置指定图层状态;组合节点由调用方传入全部成员,一次操作对应一次撤销。 */
|
|
1075
|
+
setElementsState(elementIds: string[], patch: {
|
|
1076
|
+
locked?: boolean;
|
|
1077
|
+
visible?: boolean;
|
|
1078
|
+
}): this;
|
|
1079
|
+
/** 全部解锁或显示当前页元素。 */
|
|
1080
|
+
setAllElementState(patch: {
|
|
1081
|
+
locked?: boolean;
|
|
1082
|
+
visible?: boolean;
|
|
1083
|
+
}): this;
|
|
1084
|
+
/** 批量调整选区层级,保持组合及选区内部相对顺序。 */
|
|
1085
|
+
moveSelectionLayer(direction: "front" | "back" | "forward" | "backward"): this;
|
|
1086
|
+
/** 单个图层/组合对齐纸张,多选对齐选区;每次操作提交一条历史。 */
|
|
1087
|
+
alignSelection(align: PrintDesignLayerAlignment): this;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/** 负责打印文档、页面与导出 API 的原生设计器实例。 */
|
|
1091
|
+
declare class PrintDesign extends PrintDesignActions {
|
|
1092
|
+
/** 获取文档副本。 */
|
|
1093
|
+
getDocument(): PrintDesignDocument;
|
|
1094
|
+
/** 替换当前文档并清空撤销历史。 */
|
|
1095
|
+
setDocument(document: PrintDesignDocument): this;
|
|
1096
|
+
/** 导出当前文档 JSON。 */
|
|
1097
|
+
toJSON(): string;
|
|
1098
|
+
/** 获取当前活动页 id。 */
|
|
1099
|
+
getActivePageId(): string;
|
|
1100
|
+
/** 切换当前活动页。 */
|
|
1101
|
+
setActivePage(pageId: string): this;
|
|
1102
|
+
/** 新增空白页面并切换到该页。 */
|
|
1103
|
+
addPage(page?: PrintDesignPage): string;
|
|
1104
|
+
/** 更新页面纸张、页边距或背景属性。 */
|
|
1105
|
+
updatePage(pageId: string, patch: Partial<PrintDesignPage>): this;
|
|
1106
|
+
/** 删除页面;文档至少保留一页。 */
|
|
1107
|
+
removePage(pageId: string): this;
|
|
1108
|
+
/** 获取当前选区副本。 */
|
|
1109
|
+
getSelection(): PrintDesignSelection;
|
|
1110
|
+
/** 选中指定辅助线图层。 */
|
|
1111
|
+
selectGuide(axis: "vertical" | "horizontal", index: number): this;
|
|
1112
|
+
/** 精确设置辅助线位置(毫米),允许负数及纸张外位置,支持撤销重做。 */
|
|
1113
|
+
updateGuide(axis: "vertical" | "horizontal", index: number, position: number): this;
|
|
1114
|
+
/** 删除指定辅助线图层。 */
|
|
1115
|
+
removeGuide(axis: "vertical" | "horizontal", index: number): this;
|
|
1116
|
+
/** 设置当前选中的元素。 */
|
|
1117
|
+
selectElements(elementIds: string[], expandGroups?: boolean): this;
|
|
1118
|
+
/** 将视口客户区坐标转换为当前页面毫米坐标;画布外或刻度尺区域返回 null。 */
|
|
1119
|
+
clientToPagePoint(clientX: number, clientY: number): {
|
|
1120
|
+
x: number;
|
|
1121
|
+
y: number;
|
|
1122
|
+
} | null;
|
|
1123
|
+
/** 新增元素并选中。 */
|
|
1124
|
+
addElement<T extends PrintDesignElement>(element: Omit<T, "id"> & {
|
|
1125
|
+
id?: string;
|
|
1126
|
+
}): string;
|
|
1127
|
+
/** 更新当前页中指定元素的属性。 */
|
|
1128
|
+
updateElement(elementId: string, patch: Partial<PrintDesignElement>): this;
|
|
1129
|
+
/** 删除当前选区或指定元素。 */
|
|
1130
|
+
removeElements(elementIds?: string[]): this;
|
|
1131
|
+
/** 调整元素在图层中的前后顺序。 */
|
|
1132
|
+
moveElementLayer(elementId: string, direction: "forward" | "backward" | "front" | "back"): this;
|
|
1133
|
+
/** 设置元素层级,索引从 0(底层)开始;越界值限制到当前页面范围。 */
|
|
1134
|
+
setElementLayer(elementId: string, layerIndex: number): this;
|
|
1135
|
+
/** 撤销上一条文档操作。 */
|
|
1136
|
+
undo(): this;
|
|
1137
|
+
/** 重做最近撤销的文档操作。 */
|
|
1138
|
+
redo(): this;
|
|
1139
|
+
/** 当前是否存在可撤销操作。 */
|
|
1140
|
+
canUndo(): boolean;
|
|
1141
|
+
/** 当前是否存在可重做操作。 */
|
|
1142
|
+
canRedo(): boolean;
|
|
1143
|
+
/** 获取当前缩放比例。 */
|
|
1144
|
+
getZoom(): number;
|
|
1145
|
+
/** 设置画布缩放比例并保持页面中心。 */
|
|
1146
|
+
setZoom(zoom: number): this;
|
|
1147
|
+
/** 缩放以适配当前画布。 */
|
|
1148
|
+
fitToView(): this;
|
|
1149
|
+
/** 导出指定页面的高分辨率 Canvas。 */
|
|
1150
|
+
exportPageToCanvas(pageId?: string, options?: PrintDesignExportOptions): HTMLCanvasElement;
|
|
1151
|
+
/** 导出指定页面为 PNG Blob。 */
|
|
1152
|
+
exportPageToBlob(pageId?: string, options?: PrintDesignExportOptions): Promise<Blob>;
|
|
1153
|
+
/** 将当前设计文档和数据转换为浏览器可打印的 HTML。 */
|
|
1154
|
+
transformToHtml(options?: PrintDesignHtmlOptions): string;
|
|
1155
|
+
/** 打印当前活动页。 */
|
|
1156
|
+
printActivePage(): boolean;
|
|
1157
|
+
/** 打印文档中的全部源页及其自动续页。 */
|
|
1158
|
+
printDocument(): boolean;
|
|
1159
|
+
/** 将选中的源页写入浏览器打印窗口。 */
|
|
1160
|
+
private printPages;
|
|
1161
|
+
}
|
|
1162
|
+
/** 获取当前设计器可见性状态的简单快照。 */
|
|
1163
|
+
declare function getPrintDesignPageSize(page: PrintDesignPage): {
|
|
1164
|
+
width: number;
|
|
1165
|
+
height: number;
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
/** CSS 参考分辨率:96 CSS px/in。 */
|
|
1169
|
+
declare const PRINT_DESIGN_CSS_DPI = 96;
|
|
1170
|
+
declare const PRINT_DESIGN_MM_PER_INCH = 25.4;
|
|
1171
|
+
/** 将毫米转换为 CSS 像素。 */
|
|
1172
|
+
declare function millimetersToPixels(value: number, dpi?: number): number;
|
|
1173
|
+
/** 将 CSS 像素转换为毫米。 */
|
|
1174
|
+
declare function pixelsToMillimeters(value: number, dpi?: number): number;
|
|
1175
|
+
|
|
1176
|
+
/** 按元素高度与分页策略生成可直接绘制和打印的物理页面。 */
|
|
1177
|
+
declare function paginatePrintDesignDocument(document: PrintDesignDocument, data?: Record<string, unknown>): PrintDesignDocument;
|
|
1178
|
+
|
|
1179
|
+
/** 按静态开关或绑定字段决定组件是否参与预览和打印。 */
|
|
1180
|
+
declare function resolvePrintDesignElementVisible(element: PrintDesignElement, data?: Record<string, unknown>): boolean;
|
|
1181
|
+
|
|
1182
|
+
/** `debug: true` 使用的默认调试配置。 */
|
|
1183
|
+
declare const DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS: {
|
|
1184
|
+
enabled: true;
|
|
1185
|
+
showElementBounds: true;
|
|
1186
|
+
showSelectionBounds: true;
|
|
1187
|
+
showHitTarget: true;
|
|
1188
|
+
};
|
|
1189
|
+
/** 将布尔值或对象式配置归一化。 */
|
|
1190
|
+
declare function resolvePrintDesignDebugOptions(debug: boolean | PrintDesignDebugOptions | undefined): Required<PrintDesignDebugOptions>;
|
|
1191
|
+
|
|
1192
|
+
/** 从已有图表选项提取可编辑数据,兼容未配置 chartData 的历史模板。 */
|
|
1193
|
+
declare function readChartData(element: PrintDesignChartElement): PrintDesignChartData;
|
|
1194
|
+
/** 生成静态或绑定后的图表选项,不修改原模板;绑定缺失时显示空数据。 */
|
|
1195
|
+
declare function resolveChartOption(element: PrintDesignChartElement, data?: Record<string, unknown>): unknown;
|
|
1196
|
+
|
|
1197
|
+
/** 按数组路径读取表格记录,可显式开启缺失数据源回退,空数组保持为空。 */
|
|
1198
|
+
declare function resolveTableRows(element: PrintDesignTableElement, data?: Record<string, unknown>): Record<string, unknown>[];
|
|
1199
|
+
/** 获取动态绑定原始数组,用于编辑器校验和预览。 */
|
|
1200
|
+
declare function resolveTableDataSource(data: Record<string, unknown>, path?: string): unknown;
|
|
1201
|
+
|
|
1202
|
+
/** 按表格记录集绑定规则取得透视表原始记录。 */
|
|
1203
|
+
declare function resolvePivotRows(element: PrintDesignPivotTableElement, data?: Record<string, unknown>): Record<string, unknown>[];
|
|
1204
|
+
/** 在打印设计包内生成二维透视矩阵,再复用表格绘制与分页。 */
|
|
1205
|
+
declare function materializePivotTable(element: PrintDesignPivotTableElement, data?: Record<string, unknown>): PrintDesignTableElement;
|
|
1206
|
+
|
|
1207
|
+
/** 打印设计器接受的可序列化任务列表。 */
|
|
1208
|
+
declare function isGanttTasks(value: unknown): value is PrintGanttTask[];
|
|
1209
|
+
/** 读取绑定任务;有效空数组不会触发默认内容回退。 */
|
|
1210
|
+
declare function resolveGanttTasks(element: PrintDesignGanttElement, data?: Record<string, unknown>): PrintGanttTask[];
|
|
1211
|
+
/** 从每条任务的前置关系生成连线,终点为该任务。 */
|
|
1212
|
+
declare function resolveGanttDependencies(element: PrintDesignGanttElement, data?: Record<string, unknown>): PrintGanttDependency[];
|
|
1213
|
+
|
|
1214
|
+
/** 约束行列数量。 */
|
|
1215
|
+
declare function normalizeGridCount(value: number): number;
|
|
1216
|
+
/** 调整网格尺寸时保留左上角重叠区域的静态标记。 */
|
|
1217
|
+
declare function resizeGridCells(cells: readonly PrintDesignGridCell[] | undefined, oldRows: number, oldColumns: number, newRows: number, newColumns: number): PrintDesignGridCell[];
|
|
1218
|
+
/** 将静态值和数据字段解析为按行优先排列的绘制单元格。 */
|
|
1219
|
+
declare function resolveGridCells(element: PrintDesignGridElement, data?: Record<string, unknown>): {
|
|
1220
|
+
rows: number;
|
|
1221
|
+
columns: number;
|
|
1222
|
+
cellWidth: number;
|
|
1223
|
+
cellHeight: number;
|
|
1224
|
+
cells: {
|
|
1225
|
+
content: PrintDesignGridMark;
|
|
1226
|
+
backgroundColor: string;
|
|
1227
|
+
}[];
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
/** 展平嵌套表头,保留隐藏列的数据编辑能力。 */
|
|
1231
|
+
declare function tableLeafColumns(columns: PrintDesignTableColumn[]): PrintDesignTableColumn[];
|
|
1232
|
+
/** 安全读取列字段。 */
|
|
1233
|
+
declare function readTableCell(row: Record<string, unknown>, path: PrintDesignTableColumn["dataIndex"]): unknown;
|
|
1234
|
+
/** 复制修改字段路径,保留同级数据及嵌套数组,避免改变原文档。 */
|
|
1235
|
+
declare function writeTableCell(row: Record<string, unknown>, path: PrintDesignTableColumn["dataIndex"], value: unknown): Record<string, unknown>;
|
|
1236
|
+
|
|
1237
|
+
/** 按可见叶列生成打印表格的汇总值。 */
|
|
1238
|
+
declare function computePrintTableSummaryValues(rows: Record<string, unknown>[], columns: PrintDesignTableColumn[]): Map<string, string>;
|
|
1239
|
+
|
|
1240
|
+
/** 图层树节点,组合节点以首个成员作为整体排序入口。 */
|
|
1241
|
+
interface PrintDesignLayerNode {
|
|
1242
|
+
id: string;
|
|
1243
|
+
name: string;
|
|
1244
|
+
element: PrintDesignElement;
|
|
1245
|
+
children?: PrintDesignLayerNode[];
|
|
1246
|
+
memberIds: string[];
|
|
1247
|
+
}
|
|
1248
|
+
/** 从自底向上的元素序列构建自顶向下的组合树。 */
|
|
1249
|
+
declare function buildPrintDesignLayerTree(elements: PrintDesignElement[], depth?: number): PrintDesignLayerNode[];
|
|
1250
|
+
|
|
1251
|
+
/** 读取自有字段,支持点路径和数字数组索引,不访问原型链。 */
|
|
1252
|
+
declare function resolvePrintDesignDataPath(data: Record<string, unknown>, path: string): unknown;
|
|
1253
|
+
|
|
1254
|
+
/** 基础组件可配置的数据字段;只允许覆盖声明过的内容/外观属性。 */
|
|
1255
|
+
interface PrintDesignDataField {
|
|
1256
|
+
key: string;
|
|
1257
|
+
label: string;
|
|
1258
|
+
type: "text" | "color" | "number";
|
|
1259
|
+
fallback: string | number;
|
|
1260
|
+
}
|
|
1261
|
+
/** 图表、表格沿用各自的数据结构,其余组件共用字段配置。 */
|
|
1262
|
+
declare function getPrintDesignDataFields(type: PrintDesignElement["type"]): PrintDesignDataField[];
|
|
1263
|
+
/** 兼容已有文本/编码模板,新配置显式区分静态和动态模式。 */
|
|
1264
|
+
declare function getPrintDesignElementDataConfig(element: PrintDesignElement): {
|
|
1265
|
+
mode: "static" | "binding";
|
|
1266
|
+
bindings?: Record<string, string>;
|
|
1267
|
+
};
|
|
1268
|
+
/** 解析绑定值;纯路径保留原始类型,模板用于组合多个字段。 */
|
|
1269
|
+
declare function resolvePrintDesignBinding(data: Record<string, unknown>, expression: string): unknown;
|
|
1270
|
+
/** 将绑定应用到绘制副本;缺失/类型不匹配时保留静态值,不修改模板。 */
|
|
1271
|
+
declare function resolvePrintDesignElementData(element: PrintDesignElement, data: Record<string, unknown>): PrintDesignElement;
|
|
1272
|
+
|
|
1273
|
+
/** ListTable 接入数据源:列配置与原始记录一起传入,核心层不依赖 React。 */
|
|
1274
|
+
interface PrintDesignTableDataSource {
|
|
1275
|
+
dataSource: Record<string, unknown>[];
|
|
1276
|
+
columns?: PrintDesignTableColumn[];
|
|
1277
|
+
}
|
|
1278
|
+
interface PrintDesignChartDataSource {
|
|
1279
|
+
labels: string[];
|
|
1280
|
+
keys?: string[];
|
|
1281
|
+
series: Array<{
|
|
1282
|
+
name: string;
|
|
1283
|
+
data: number[];
|
|
1284
|
+
}>;
|
|
1285
|
+
}
|
|
1286
|
+
/** 识别 ListTable 的记录集数据结构,不把普通对象当作数据行。 */
|
|
1287
|
+
declare function isPrintDesignTableDataSource(value: unknown): value is PrintDesignTableDataSource;
|
|
1288
|
+
/** 兼容 ReactListTable 图表弹窗所使用的 ListTableChartData。 */
|
|
1289
|
+
declare function isPrintDesignChartDataSource(value: unknown): value is PrintDesignChartDataSource;
|
|
1290
|
+
|
|
1291
|
+
export { DEFAULT_PRINT_DESIGN_DEBUG_OPTIONS, PRINT_DESIGN_CSS_DPI, PRINT_DESIGN_MM_PER_INCH, PRINT_DESIGN_SCHEMA_VERSION, PRINT_DESIGN_UNIT_MM, PrintDesign, type PrintDesignBarcodeElement, type PrintDesignChartData, type PrintDesignChartDataSource, type PrintDesignChartElement, type PrintDesignClockElement, type PrintDesignDataField, type PrintDesignDebugOptions, type PrintDesignDividerElement, type PrintDesignDocument, type PrintDesignElement, type PrintDesignElementBase, type PrintDesignExportOptions, type PrintDesignGanttElement, type PrintDesignGridCell, type PrintDesignGridElement, type PrintDesignGridMark, type PrintDesignHtmlOptions, type PrintDesignImageElement, type PrintDesignLayerAlignment, type PrintDesignLayerNode, type PrintDesignListElement, type PrintDesignOptions, type PrintDesignOrientation, type PrintDesignPage, type PrintDesignPageMargins, type PrintDesignPivotTableElement, type PrintDesignProgressElement, type PrintDesignQrCodeElement, type PrintDesignRulerElement, type PrintDesignSelection, type PrintDesignShapeElement, type PrintDesignTableColumn, type PrintDesignTableDataSource, type PrintDesignTableElement, type PrintDesignTextElement, type PrintDesignUnit, type PrintGanttDependency, type PrintGanttScale, type PrintGanttTask, type PrintPivotAggregator, type PrintPivotField, type PrintPivotFieldArea, type PrintPivotFieldLayout, type PrintPivotFilterState, buildPrintDesignLayerTree, canvasPointToPageMillimeters, computePrintTableSummaryValues, createPrintDesignDocument, createPrintDesignId, createPrintDesignPage, drawPrintDesignElement, drawPrintDesignPage, findPrintPivotFieldArea, formatDisplayUnit, fromDisplayUnit, getPrintDesignAlignmentUnits, getPrintDesignDataFields, getPrintDesignElementDataConfig, getPrintDesignPageSize, hitTestPrintDesignPage, isGanttTasks, isPrintDesignChartDataSource, isPrintDesignTableDataSource, materializePivotTable, millimetersToPixels, movePrintPivotField, normalizeGridCount, paginatePrintDesignDocument, parsePrintDesignDocument, pixelsToMillimeters, printPivotFieldHeaderTitle, printPivotFieldTitle, printPivotValueTitle, printPrintDesignHtml, readChartData, readTableCell, removePrintPivotField, renderPrintDesignPageToCanvas, resizeGridCells, resolveChartOption, resolveDesignText, resolveGanttDependencies, resolveGanttTasks, resolveGridCells, resolvePivotRows, resolvePrintDesignBinding, resolvePrintDesignDataPath, resolvePrintDesignDebugOptions, resolvePrintDesignElementData, resolvePrintDesignElementVisible, resolveTableDataSource, resolveTableRows, serializePrintDesignDocument, tableLeafColumns, toDisplayUnit, transformPrintDesignToHtml, writeTableCell };
|