@worm-vue3-print/canvas 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -17
- package/dist/canvas.css +1 -1
- package/dist/components/CanvasArea.vue.d.ts +19 -8
- package/dist/components/CanvasPaper.vue.d.ts +3 -3
- package/dist/components/DesignerToolbar.vue.d.ts +3 -0
- package/dist/components/ExpressionEditor.vue.d.ts +1 -1
- package/dist/components/FieldTreePanel.vue.d.ts +1 -1
- package/dist/components/LayerPanel.vue.d.ts +1 -1
- package/dist/components/LeftPanel.vue.d.ts +1 -1
- package/dist/components/PrintDesigner.vue.d.ts +3 -1
- package/dist/components/PropertyPanel.vue.d.ts +1 -1
- package/dist/components/WatermarkConfig.vue.d.ts +1 -1
- package/dist/components/elements/BarcodeElement.vue.d.ts +1 -1
- package/dist/components/elements/BaseElement.vue.d.ts +3 -3
- package/dist/components/elements/HtmlElement.vue.d.ts +1 -1
- package/dist/components/elements/ImageElement.vue.d.ts +1 -1
- package/dist/components/elements/LineElement.vue.d.ts +1 -1
- package/dist/components/elements/LongTextElement.vue.d.ts +1 -1
- package/dist/components/elements/PageNumberElement.vue.d.ts +1 -1
- package/dist/components/elements/QrcodeElement.vue.d.ts +1 -1
- package/dist/components/elements/ShapeElement.vue.d.ts +1 -1
- package/dist/components/elements/TableContextMenu.vue.d.ts +1 -1
- package/dist/components/elements/TableElement.vue.d.ts +1 -1
- package/dist/components/elements/TextElement.vue.d.ts +1 -1
- package/dist/components/property/AdvancedGroup.vue.d.ts +1 -1
- package/dist/components/property/AppearanceGroup.vue.d.ts +1 -1
- package/dist/components/property/BindingControl.vue.d.ts +1 -1
- package/dist/components/property/BorderBgGroup.vue.d.ts +1 -1
- package/dist/components/property/CodeGroup.vue.d.ts +1 -1
- package/dist/components/property/PaginationGroup.vue.d.ts +1 -1
- package/dist/components/property/PositionSizeGroup.vue.d.ts +1 -1
- package/dist/components/property/TableCellGroup.vue.d.ts +1 -1
- package/dist/components/property/TableRowGroup.vue.d.ts +1 -1
- package/dist/components/property/TableSettingsGroup.vue.d.ts +1 -1
- package/dist/composables/useAdsorb.d.ts +3 -7
- package/dist/composables/useAdsorbManager.d.ts +2 -2
- package/dist/composables/useClipboard.d.ts +15 -15
- package/dist/composables/useDesignerState.d.ts +44 -44
- package/dist/composables/useDrag.d.ts +1 -1
- package/dist/composables/useGuides.d.ts +1 -1
- package/dist/composables/useHistory.d.ts +1 -1
- package/dist/composables/useHostAdapter.d.ts +1 -1
- package/dist/composables/useSelection.d.ts +1 -1
- package/dist/composables/useTableSelection.d.ts +1 -1
- package/dist/index.cjs +42 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3508 -4616
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/composables/useAlign.d.ts +0 -5
- package/dist/composables/useBindingDisplay.d.ts +0 -11
- package/dist/composables/useGroup.d.ts +0 -7
- package/dist/composables/useKeyboard.d.ts +0 -22
- package/dist/composables/useResize.d.ts +0 -26
- package/dist/render/browser-code-renderer.d.ts +0 -3
- package/dist/render/browser-pagination.d.ts +0 -17
- package/dist/types.d.ts +0 -287
- package/dist/utils/binding-registry.d.ts +0 -8
- package/dist/utils/binding.d.ts +0 -16
- package/dist/utils/default-config.d.ts +0 -13
- package/dist/utils/demo-data.d.ts +0 -2
- package/dist/utils/element-factory.d.ts +0 -4
- package/dist/utils/engine.d.ts +0 -2
- package/dist/utils/expression-eval.d.ts +0 -30
- package/dist/utils/field-groups.d.ts +0 -21
- package/dist/utils/migrate.d.ts +0 -2
- package/dist/utils/preset-colors.d.ts +0 -2
- package/dist/utils/property-search.d.ts +0 -18
- package/dist/utils/ruler.d.ts +0 -29
- package/dist/utils/scale.d.ts +0 -13
- package/dist/utils/table-matrix.d.ts +0 -69
- package/dist/utils/units.d.ts +0 -6
- package/dist/utils/zone-layout.d.ts +0 -27
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { RuntimeElement } from '../types';
|
|
2
|
-
export type AlignMode = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'distributeHor' | 'distributeVer';
|
|
3
|
-
export declare function useAlign(): {
|
|
4
|
-
align: (elements: RuntimeElement[], mode: AlignMode) => void;
|
|
5
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface BindingDisplayState {
|
|
2
|
-
status: 'unbound' | 'bound' | 'warning' | 'error';
|
|
3
|
-
badge: string;
|
|
4
|
-
badgeColor: string;
|
|
5
|
-
demoPreview: string;
|
|
6
|
-
warning?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function useBindingDisplay(): {
|
|
9
|
-
getBindingDisplayState: (element: any) => BindingDisplayState;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RuntimeElement } from '../types';
|
|
2
|
-
export declare function generateGroupId(): string;
|
|
3
|
-
export declare function useGroup(): {
|
|
4
|
-
group: (elements: RuntimeElement[], selectedIds: Set<string>) => RuntimeElement[];
|
|
5
|
-
ungroup: (elements: RuntimeElement[], selectedIds: Set<string>) => RuntimeElement[];
|
|
6
|
-
getGroupedIds: (elements: RuntimeElement[], selectedId: string) => Set<string>;
|
|
7
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface KeyboardHandlers {
|
|
2
|
-
onMove?: (dx: number, dy: number) => void;
|
|
3
|
-
onDelete?: () => void;
|
|
4
|
-
onCopy?: () => void;
|
|
5
|
-
onPaste?: () => void;
|
|
6
|
-
onSelectAll?: () => void;
|
|
7
|
-
onUndo?: () => void;
|
|
8
|
-
onRedo?: () => void;
|
|
9
|
-
onDuplicate?: () => void;
|
|
10
|
-
onResetZoom?: () => void;
|
|
11
|
-
onAlignLeft?: () => void;
|
|
12
|
-
onAlignRight?: () => void;
|
|
13
|
-
onAlignCenterH?: () => void;
|
|
14
|
-
onAlignTop?: () => void;
|
|
15
|
-
onAlignBottom?: () => void;
|
|
16
|
-
onGroup?: () => void;
|
|
17
|
-
onUngroup?: () => void;
|
|
18
|
-
}
|
|
19
|
-
export declare function useKeyboard(handlers: KeyboardHandlers): {
|
|
20
|
-
setup: () => void;
|
|
21
|
-
cleanup: () => void;
|
|
22
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ResizePoint } from '../types';
|
|
2
|
-
export interface ResizeRect {
|
|
3
|
-
left: number;
|
|
4
|
-
top: number;
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
}
|
|
8
|
-
export interface ResizeOptions {
|
|
9
|
-
minWidth?: number;
|
|
10
|
-
minHeight?: number;
|
|
11
|
-
getScale?: () => number;
|
|
12
|
-
/** 缩放起始时读取元素当前矩形(mm) */
|
|
13
|
-
getRect: () => ResizeRect;
|
|
14
|
-
onResize: (rect: ResizeRect) => void;
|
|
15
|
-
onStart?: () => void;
|
|
16
|
-
onStop?: () => void;
|
|
17
|
-
}
|
|
18
|
-
/** 8 方位缩放手柄,供模板 v-for 渲染 */
|
|
19
|
-
export declare const RESIZE_POINTS: ResizePoint[];
|
|
20
|
-
/** 根据方位与位移计算缩放后矩形(纯函数) */
|
|
21
|
-
export declare function calcResizeRect(point: ResizePoint, startRect: ResizeRect, dx: number, dy: number, minW: number, minH: number): ResizeRect;
|
|
22
|
-
/** 缩放交互逻辑:手柄由组件模板渲染,mousedown 时调用 startResize */
|
|
23
|
-
export declare function useResize(options: ResizeOptions): {
|
|
24
|
-
startResize: (point: ResizePoint, e: MouseEvent) => void;
|
|
25
|
-
cleanup: () => void;
|
|
26
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PrintTemplateData, PageLayout, CodeRenderer } from '@worm-vue3-print/core';
|
|
2
|
-
export interface BrowserRenderResult {
|
|
3
|
-
/** 最终多页 HTML 字符串 */
|
|
4
|
-
html: string;
|
|
5
|
-
/** 总页数 */
|
|
6
|
-
pageCount: number;
|
|
7
|
-
/** 分页布局(调试/高级用途) */
|
|
8
|
-
pageLayouts: PageLayout[];
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* 浏览器内完成「数据绑定 → 测量 → 分页 → 最终 HTML」全流程。
|
|
12
|
-
* @param template 模板 JSON(设计器 TemplateData 结构兼容)
|
|
13
|
-
* @param printData 业务数据
|
|
14
|
-
* @param baseUrl 图片相对路径拼接前缀
|
|
15
|
-
* @param codeRenderer 条码渲染器(browserCodeRenderer)
|
|
16
|
-
*/
|
|
17
|
-
export declare function renderHtmlPages(template: PrintTemplateData, printData?: Record<string, any> | Record<string, any>[], baseUrl?: string, codeRenderer?: CodeRenderer): Promise<BrowserRenderResult>;
|
package/dist/types.d.ts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/** 纸张尺寸 */
|
|
2
|
-
export type PaperSize = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'CUSTOM';
|
|
3
|
-
/** 元素所属区域(运行时标记,序列化时剥离;区域元素 left/top 相对所在区域左上角,单位 pt) */
|
|
4
|
-
export type ElementZone = 'content' | 'header' | 'footer';
|
|
5
|
-
/** 元素分页属性(非表格元素) */
|
|
6
|
-
export interface PaginationConfig {
|
|
7
|
-
pageable: boolean;
|
|
8
|
-
keepWithNext: boolean;
|
|
9
|
-
}
|
|
10
|
-
/** 表格分页配置 */
|
|
11
|
-
export interface TablePaginationConfig {
|
|
12
|
-
enabled: boolean;
|
|
13
|
-
}
|
|
14
|
-
/** 新模板数据模型(替代旧 PrintPanel / PrintTemplateJson) */
|
|
15
|
-
export interface TemplateData {
|
|
16
|
-
paperSize: PaperSize;
|
|
17
|
-
orientation: 'portrait' | 'landscape';
|
|
18
|
-
margins: {
|
|
19
|
-
top: number;
|
|
20
|
-
right: number;
|
|
21
|
-
bottom: number;
|
|
22
|
-
left: number;
|
|
23
|
-
};
|
|
24
|
-
header: {
|
|
25
|
-
height: number;
|
|
26
|
-
elements: TemplateElement[];
|
|
27
|
-
};
|
|
28
|
-
footer: {
|
|
29
|
-
height: number;
|
|
30
|
-
elements: TemplateElement[];
|
|
31
|
-
};
|
|
32
|
-
firstPageOverlay: {
|
|
33
|
-
height: number;
|
|
34
|
-
elements: TemplateElement[];
|
|
35
|
-
};
|
|
36
|
-
elements: TemplateElement[];
|
|
37
|
-
/** 元素坐标单位(新保存模板固定 'mm';旧数据无此字段按 pt 迁移) */
|
|
38
|
-
unit?: 'pt' | 'mm';
|
|
39
|
-
/** 自定义纸张宽度(mm),仅 paperSize='CUSTOM' 时有效 */
|
|
40
|
-
customWidth?: number;
|
|
41
|
-
/** 自定义纸张高度(mm),仅 paperSize='CUSTOM' 时有效 */
|
|
42
|
-
customHeight?: number;
|
|
43
|
-
/** 页面(纸张)背景色;未设置时默认白色 */
|
|
44
|
-
pageBackground?: string;
|
|
45
|
-
/** 水印配置 */
|
|
46
|
-
watermark?: WatermarkOptions;
|
|
47
|
-
/** 手动参考线(设计态辅助,序列化保留,渲染端忽略) */
|
|
48
|
-
guides?: AlignLine[];
|
|
49
|
-
}
|
|
50
|
-
/** 模板元素引用(用于 TemplateData 各区域) */
|
|
51
|
-
export type TemplateElement = PrintElementData;
|
|
52
|
-
/** 元素类型 */
|
|
53
|
-
export type ElementType = 'text' | 'image' | 'longText' | 'table' | 'hline' | 'vline' | 'rect' | 'oval' | 'barcode' | 'qrcode' | 'html' | 'pageNumber';
|
|
54
|
-
/** 对齐方式 */
|
|
55
|
-
export type TextAlign = 'left' | 'center' | 'right';
|
|
56
|
-
/** 垂直对齐方式(文本类元素,未设置时按顶部处理,与打印端一致) */
|
|
57
|
-
export type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
58
|
-
/** 缩放手柄方向 */
|
|
59
|
-
export type ResizePoint = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
60
|
-
/** 引导线 */
|
|
61
|
-
export interface AlignLine {
|
|
62
|
-
type: 'vertical' | 'horizontal';
|
|
63
|
-
position: number;
|
|
64
|
-
id?: string;
|
|
65
|
-
/** 引导线颜色(区分左/中/右对齐类型) */
|
|
66
|
-
color?: string;
|
|
67
|
-
}
|
|
68
|
-
/** 吸附结果 */
|
|
69
|
-
export interface AdsorbResult {
|
|
70
|
-
left: number;
|
|
71
|
-
top: number;
|
|
72
|
-
lines: AlignLine[];
|
|
73
|
-
}
|
|
74
|
-
/** 元素矩形(用于吸附检测) */
|
|
75
|
-
export interface ElementRect {
|
|
76
|
-
id: string;
|
|
77
|
-
left: number;
|
|
78
|
-
top: number;
|
|
79
|
-
width: number;
|
|
80
|
-
height: number;
|
|
81
|
-
}
|
|
82
|
-
/** 表格行类型:header 标题 / data 数据(全表唯一) / subtotal 当前页小计(每页末尾) / summary 整表汇总 */
|
|
83
|
-
export type TableRowType = 'header' | 'data' | 'subtotal' | 'summary';
|
|
84
|
-
/** 单边边框样式 */
|
|
85
|
-
export interface TableCellBorder {
|
|
86
|
-
width: number;
|
|
87
|
-
style: 'solid' | 'dashed' | 'dotted' | 'double' | 'none';
|
|
88
|
-
color: string;
|
|
89
|
-
}
|
|
90
|
-
/** 四边边框 */
|
|
91
|
-
export interface TableCellBorders {
|
|
92
|
-
top?: TableCellBorder;
|
|
93
|
-
right?: TableCellBorder;
|
|
94
|
-
bottom?: TableCellBorder;
|
|
95
|
-
left?: TableCellBorder;
|
|
96
|
-
}
|
|
97
|
-
/** 单元格内容类型 */
|
|
98
|
-
export type TableCellType = 'text' | 'barcode' | 'qrcode' | 'image';
|
|
99
|
-
/** 单元格 */
|
|
100
|
-
export interface TableCell {
|
|
101
|
-
id: string;
|
|
102
|
-
formatter?: string;
|
|
103
|
-
cellType?: TableCellType;
|
|
104
|
-
barcodeType?: string;
|
|
105
|
-
qrCodeLevel?: string;
|
|
106
|
-
showBarcodeText?: boolean;
|
|
107
|
-
rowspan?: number;
|
|
108
|
-
colspan?: number;
|
|
109
|
-
merged?: boolean;
|
|
110
|
-
align?: TextAlign;
|
|
111
|
-
valign?: 'top' | 'middle' | 'bottom';
|
|
112
|
-
fontFamily?: string;
|
|
113
|
-
fontSize?: number;
|
|
114
|
-
fontWeight?: string;
|
|
115
|
-
color?: string;
|
|
116
|
-
backgroundColor?: string;
|
|
117
|
-
borders?: TableCellBorders;
|
|
118
|
-
padding?: number;
|
|
119
|
-
wordWrap?: boolean;
|
|
120
|
-
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
121
|
-
maxWidth?: number;
|
|
122
|
-
maxHeight?: number;
|
|
123
|
-
}
|
|
124
|
-
/** 表格行 */
|
|
125
|
-
export interface TableRow {
|
|
126
|
-
id: string;
|
|
127
|
-
type: TableRowType;
|
|
128
|
-
height: number;
|
|
129
|
-
repeatOnPage?: boolean;
|
|
130
|
-
cells: TableCell[];
|
|
131
|
-
}
|
|
132
|
-
/** 单元格选区(r/c 均为 0 基,闭区间) */
|
|
133
|
-
export interface TableSelection {
|
|
134
|
-
elementId: string;
|
|
135
|
-
r1: number;
|
|
136
|
-
c1: number;
|
|
137
|
-
r2: number;
|
|
138
|
-
c2: number;
|
|
139
|
-
}
|
|
140
|
-
/** 表格历史字段绑定(兼容存量模板,实际取 fields[0].dataSource) */
|
|
141
|
-
export interface ElementFieldBinding {
|
|
142
|
-
text?: string;
|
|
143
|
-
dataSource?: string;
|
|
144
|
-
}
|
|
145
|
-
/** 元素选项(序列化到 JSON) */
|
|
146
|
-
export interface ElementOptions {
|
|
147
|
-
left: number;
|
|
148
|
-
top: number;
|
|
149
|
-
width: number;
|
|
150
|
-
height: number;
|
|
151
|
-
/** @deprecated 统一使用 formatter */
|
|
152
|
-
title?: string;
|
|
153
|
-
testData?: string;
|
|
154
|
-
fontSize?: number;
|
|
155
|
-
fontWeight?: string;
|
|
156
|
-
fontFamily?: string;
|
|
157
|
-
color?: string;
|
|
158
|
-
backgroundColor?: string;
|
|
159
|
-
textAlign?: TextAlign;
|
|
160
|
-
verticalAlign?: VerticalAlign;
|
|
161
|
-
lineHeight?: number;
|
|
162
|
-
letterSpacing?: number;
|
|
163
|
-
fixed?: boolean;
|
|
164
|
-
locked?: boolean;
|
|
165
|
-
/** 元素可见性(图层面板切换) */
|
|
166
|
-
visible?: boolean;
|
|
167
|
-
borderWidth?: number;
|
|
168
|
-
borderStyle?: string;
|
|
169
|
-
borderColor?: string;
|
|
170
|
-
contentPaddingLeft?: number;
|
|
171
|
-
contentPaddingTop?: number;
|
|
172
|
-
contentPaddingRight?: number;
|
|
173
|
-
contentPaddingBottom?: number;
|
|
174
|
-
textDecoration?: string;
|
|
175
|
-
textType?: 'barcode' | 'qrcode';
|
|
176
|
-
barcodeType?: string;
|
|
177
|
-
barWidth?: number;
|
|
178
|
-
barAutoWidth?: string;
|
|
179
|
-
qrCodeLevel?: string;
|
|
180
|
-
src?: string;
|
|
181
|
-
fit?: string;
|
|
182
|
-
hideTitle?: boolean;
|
|
183
|
-
draggable?: boolean;
|
|
184
|
-
axis?: string;
|
|
185
|
-
transform?: number;
|
|
186
|
-
zIndex?: number;
|
|
187
|
-
groupId?: string;
|
|
188
|
-
pagination?: PaginationConfig;
|
|
189
|
-
tablePagination?: TablePaginationConfig;
|
|
190
|
-
/** @deprecated 静态布局模式已移除,所有表格统一使用动态模式 */
|
|
191
|
-
tableMode?: 'dynamic' | 'static';
|
|
192
|
-
tableRows?: TableRow[];
|
|
193
|
-
tableColWidths?: number[];
|
|
194
|
-
tableDefaultFontSize?: number;
|
|
195
|
-
tableDefaultColor?: string;
|
|
196
|
-
tableDefaultPadding?: number;
|
|
197
|
-
/** 列表数据源路径(data 行迭代的数据数组) */
|
|
198
|
-
dataSource?: string;
|
|
199
|
-
/** @deprecated 兼容存量表格模型;列表数据源优先使用 dataSource */
|
|
200
|
-
fields?: ElementFieldBinding[];
|
|
201
|
-
formatter?: string;
|
|
202
|
-
styler?: string;
|
|
203
|
-
rowStyler?: string;
|
|
204
|
-
longTextIndent?: number;
|
|
205
|
-
leftSpaceRemoved?: boolean;
|
|
206
|
-
lHeight?: number;
|
|
207
|
-
}
|
|
208
|
-
/** 元素类型元数据 */
|
|
209
|
-
export interface PrintElementTypeMeta {
|
|
210
|
-
title?: string;
|
|
211
|
-
type: ElementType;
|
|
212
|
-
editable?: boolean;
|
|
213
|
-
formatter?: string;
|
|
214
|
-
styler?: string;
|
|
215
|
-
}
|
|
216
|
-
/** 序列化元素数据 */
|
|
217
|
-
export interface PrintElementData {
|
|
218
|
-
id?: string;
|
|
219
|
-
type?: ElementType;
|
|
220
|
-
options: ElementOptions;
|
|
221
|
-
printElementType: PrintElementTypeMeta;
|
|
222
|
-
}
|
|
223
|
-
/** 水印配置 */
|
|
224
|
-
export interface WatermarkOptions {
|
|
225
|
-
/** 水印模式:fixed=固定文本,binding=绑定字段 */
|
|
226
|
-
mode?: 'fixed' | 'binding';
|
|
227
|
-
/** 固定文本(mode=fixed 时使用) */
|
|
228
|
-
content?: string;
|
|
229
|
-
/** 绑定字段(mode=binding 时使用) */
|
|
230
|
-
binding?: string;
|
|
231
|
-
/** 测试值(设计态预览使用) */
|
|
232
|
-
testData?: string;
|
|
233
|
-
/** 旋转角度 */
|
|
234
|
-
rotate?: number;
|
|
235
|
-
/** 颜色 */
|
|
236
|
-
color?: string;
|
|
237
|
-
/** 透明度 */
|
|
238
|
-
opacity?: number;
|
|
239
|
-
/** 显示时间戳 */
|
|
240
|
-
timestamp?: boolean;
|
|
241
|
-
/** 时间格式 */
|
|
242
|
-
format?: string;
|
|
243
|
-
}
|
|
244
|
-
/** 运行时元素(设计器中带状态) */
|
|
245
|
-
export interface RuntimeElement {
|
|
246
|
-
id: string;
|
|
247
|
-
options: ElementOptions;
|
|
248
|
-
printElementType: PrintElementTypeMeta;
|
|
249
|
-
selected?: boolean;
|
|
250
|
-
/** 运行时所属区域,序列化时剥离,缺省视为 content */
|
|
251
|
-
zone?: ElementZone;
|
|
252
|
-
}
|
|
253
|
-
/** 业务字段(宿主查询后传入,核心不内置字段字典) */
|
|
254
|
-
export interface PrintBusinessField {
|
|
255
|
-
id?: string;
|
|
256
|
-
fieldKey: string;
|
|
257
|
-
fieldLabel: string;
|
|
258
|
-
/** 字段类型;'list' 表示明细列表字段(用于表格数据源选择) */
|
|
259
|
-
fieldType: string;
|
|
260
|
-
sortOrder: number;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* 绑定位置描述(用于属性面板自动渲染绑定控件)
|
|
264
|
-
*/
|
|
265
|
-
export interface BindingDescriptor {
|
|
266
|
-
/** 绑定的属性路径(如 'options.formatter'、'options.tableRows[0].cells[0].formatter') */
|
|
267
|
-
targetPath: string;
|
|
268
|
-
/** 显示名称 */
|
|
269
|
-
label: string;
|
|
270
|
-
/** 数据源上下文 */
|
|
271
|
-
dataSource: 'main' | 'list' | 'subtotal' | 'summary';
|
|
272
|
-
/** 绑定的列表字段(仅表格行需要) */
|
|
273
|
-
listField?: string;
|
|
274
|
-
/** 提示文本 */
|
|
275
|
-
placeholder?: string;
|
|
276
|
-
/** 是否允许清空 */
|
|
277
|
-
clearable?: boolean;
|
|
278
|
-
}
|
|
279
|
-
/** 截图请求载荷(设计器叠层对比用) */
|
|
280
|
-
export interface ScreenshotRequest {
|
|
281
|
-
templateJson: TemplateData;
|
|
282
|
-
printData: Record<string, any>;
|
|
283
|
-
}
|
|
284
|
-
/** 截图适配器:宿主依据模板 + 数据返回 PNG Blob */
|
|
285
|
-
export type RequestScreenshotFn = (req: ScreenshotRequest) => Promise<Blob>;
|
|
286
|
-
/** 图片上传适配器:宿主上传文件并返回可访问的图片 URL */
|
|
287
|
-
export type UploadImageFn = (file: File) => Promise<string>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BindingDescriptor } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* 元素绑定声明注册表
|
|
4
|
-
* 每个元素类型声明其支持的 formatter 绑定位置
|
|
5
|
-
*/
|
|
6
|
-
export declare const ELEMENT_BINDING_REGISTRY: Record<string, BindingDescriptor[]>;
|
|
7
|
-
export declare function getTableCellBindings(rowType: string, rowIndex: number, cellIndex: number, listField?: string): BindingDescriptor[];
|
|
8
|
-
export declare function getElementBindings(element: any): BindingDescriptor[];
|
package/dist/utils/binding.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { RuntimeElement } from '../types';
|
|
2
|
-
import './expression-eval';
|
|
3
|
-
/** 从业务字段创建带 formatter 绑定的文本元素 */
|
|
4
|
-
export declare function createFieldElement(field: {
|
|
5
|
-
fieldKey: string;
|
|
6
|
-
fieldLabel: string;
|
|
7
|
-
}): RuntimeElement;
|
|
8
|
-
/** 非设计态文本内容解析:用共享引擎渲染 formatter */
|
|
9
|
-
export declare function resolveTextBinding(options: {
|
|
10
|
-
formatter?: string;
|
|
11
|
-
}, data?: Record<string, any>[]): string;
|
|
12
|
-
/**
|
|
13
|
-
* 设计态条码/二维码单元格取值:{field} 占位符替换为 demo 数据
|
|
14
|
-
* (列表字段取数据源首项,全局字段按路径取),无匹配回退通用示例码值
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveBarcodeDesignValue(formatter: string | undefined, listSource?: Record<string, any>[]): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TemplateData } from '../types';
|
|
2
|
-
export declare const PAPER_PRESETS: Record<string, {
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
}>;
|
|
6
|
-
/**
|
|
7
|
-
* 获取纸张原始宽高(mm,未应用方向)
|
|
8
|
-
* CUSTOM 时读取 customWidth/customHeight,缺省回退 A4
|
|
9
|
-
*/
|
|
10
|
-
export declare function getPaperDimensions(t: Pick<TemplateData, 'paperSize' | 'orientation' | 'customWidth' | 'customHeight'>): {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { RuntimeElement, ElementType, ElementOptions } from '../types';
|
|
2
|
-
export declare function generateId(): string;
|
|
3
|
-
export declare function createDefaultOptions(type: ElementType): ElementOptions;
|
|
4
|
-
export declare function createRuntimeElement(type: ElementType, options?: Partial<ElementOptions>): RuntimeElement;
|
package/dist/utils/engine.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { formatMoney, formatDate, toUpperCaseAmount, ifFn } from '@worm-vue3-print/core';
|
|
2
|
-
export declare const EXTENDED_FUNCTIONS: {
|
|
3
|
-
MONEY: typeof formatMoney;
|
|
4
|
-
CONCAT: (...args: any[]) => string;
|
|
5
|
-
IF: typeof ifFn;
|
|
6
|
-
FORMAT: (value: any) => string;
|
|
7
|
-
SUBSTR: (str: string, start: number, len?: number) => string;
|
|
8
|
-
LEN: (str: string) => number;
|
|
9
|
-
ROUND: (num: number, decimals: number) => number;
|
|
10
|
-
NOW: () => string;
|
|
11
|
-
IFEMPTY: (value: any, defaultVal: string) => string;
|
|
12
|
-
PAD: (value: any, len: number, char: string) => string;
|
|
13
|
-
REPLACE: (str: string, from: string, to: string) => string;
|
|
14
|
-
JSON: (value: any) => string;
|
|
15
|
-
DATE: typeof formatDate;
|
|
16
|
-
UPPER: typeof toUpperCaseAmount;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* 在受限沙箱内求值表达式
|
|
20
|
-
* @param expr 表达式字符串
|
|
21
|
-
* @param context 上下文变量
|
|
22
|
-
* @param _callableNames 保留参数,实际使用共享引擎
|
|
23
|
-
*/
|
|
24
|
-
export declare function safeEval(expr: string, context: Record<string, any>, _callableNames?: string[]): any;
|
|
25
|
-
/**
|
|
26
|
-
* 模板字符串求值:{表达式} 内 safeEval 求值,外为字面文本。
|
|
27
|
-
* 聚合函数 SUM/AVG/COUNT/MIN/MAX(field) 预处理(需 ctx.rows)。
|
|
28
|
-
* 单个 {expr} 求值失败时保留原 {expr} 文本。
|
|
29
|
-
*/
|
|
30
|
-
export declare function evaluateTemplate(text: string, ctx: Record<string, any>): string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PrintBusinessField } from '../types';
|
|
2
|
-
export interface FieldGroup {
|
|
3
|
-
/** 分组键(fieldKey 首段);空串表示无分组的顶层字段 */
|
|
4
|
-
key: string;
|
|
5
|
-
/** 分组显示名:取容器字段的 fieldLabel,缺省回退为 key */
|
|
6
|
-
label: string;
|
|
7
|
-
/** 是否明细列表分组(容器字段 fieldType === 'list') */
|
|
8
|
-
isList: boolean;
|
|
9
|
-
/** 分组下的叶子字段 */
|
|
10
|
-
fields: PrintBusinessField[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 将宿主扁平字段按 fieldKey 首段分组:
|
|
14
|
-
* - 带点路径(supplier.name、goods.spec)归入首段分组;
|
|
15
|
-
* - 无点且作为其它字段前缀的记录视为分组容器(如 supplier/goods),
|
|
16
|
-
* 容器提供分组名称,fieldType='list' 标识明细列表(表格数据源);
|
|
17
|
-
* - 无点且无子字段的记录作为独立顶层字段。
|
|
18
|
-
*/
|
|
19
|
-
export declare function groupFields(fields: PrintBusinessField[]): FieldGroup[];
|
|
20
|
-
/** 按关键字过滤分组(匹配字段名/字段 key),无叶子的分组剔除 */
|
|
21
|
-
export declare function filterGroups(groups: FieldGroup[], keyword: string): FieldGroup[];
|
package/dist/utils/migrate.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** 属性面板搜索注册表:分组 → 表单项 → 关键词 */
|
|
2
|
-
export interface PropertyItem {
|
|
3
|
-
key: string;
|
|
4
|
-
keywords: string[];
|
|
5
|
-
}
|
|
6
|
-
export interface PropertyGroupDef {
|
|
7
|
-
group: string;
|
|
8
|
-
groupLabel: string;
|
|
9
|
-
items: PropertyItem[];
|
|
10
|
-
}
|
|
11
|
-
export declare const PROPERTY_REGISTRY: PropertyGroupDef[];
|
|
12
|
-
/** 正向包含匹配:任一关键词包含搜索词即命中;空搜索恒命中 */
|
|
13
|
-
export declare function matchKeywords(search: string, keywords: string[]): boolean;
|
|
14
|
-
/** 计算命中的分组与表单项 key 集合 */
|
|
15
|
-
export declare function searchProperties(search: string): {
|
|
16
|
-
groups: string[];
|
|
17
|
-
itemKeys: Set<string>;
|
|
18
|
-
};
|
package/dist/utils/ruler.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/** 视口固定尺条厚度(px),CanvasArea 布局与左上角块共用 */
|
|
2
|
-
export declare const RULER_THICKNESS = 22;
|
|
3
|
-
export interface RulerTick {
|
|
4
|
-
/** 刻度在纸面坐标系上的位置(mm,可为负,表示纸张原点之外) */
|
|
5
|
-
mm: number;
|
|
6
|
-
/** 是否为主刻度(带数字标签) */
|
|
7
|
-
major: boolean;
|
|
8
|
-
label?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* 按缩放选择主刻度步长(mm):取漂亮数序列中使屏幕间距
|
|
12
|
-
* 不小于 targetPx 的最小步长,保证任意缩放下标签不重叠
|
|
13
|
-
* @param scale 画布缩放比例(1 = 100%)
|
|
14
|
-
* @param targetPx 主刻度之间的目标屏幕间距(px)
|
|
15
|
-
*/
|
|
16
|
-
export declare function chooseMajorStepMM(scale: number, targetPx?: number): number;
|
|
17
|
-
/**
|
|
18
|
-
* 次刻度步长:5 系(5/50/500…)五等分、2 系(2/20/200…)二等分、
|
|
19
|
-
* 10 的幂从 10mm 起五等分(10→2mm、100→20mm),1mm 时无次刻度
|
|
20
|
-
*/
|
|
21
|
-
export declare function minorStepMM(majorStepMM: number): number | null;
|
|
22
|
-
/**
|
|
23
|
-
* 生成可见毫米范围内的全部刻度(升序):
|
|
24
|
-
* 从首个对齐的次刻度开始,主刻度带数字标签
|
|
25
|
-
* @param startMM 可见范围起点(纸面坐标,可为负)
|
|
26
|
-
* @param endMM 可见范围终点
|
|
27
|
-
* @param majorStepMM 主刻度步长(由 chooseMajorStepMM 选出)
|
|
28
|
-
*/
|
|
29
|
-
export declare function buildRulerTicks(startMM: number, endMM: number, majorStepMM: number): RulerTick[];
|
package/dist/utils/scale.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** 最小缩放百分比,低于此值画布难以查看与操作;放大方向不设上限 */
|
|
2
|
-
export declare const MIN_SCALE_PERCENT = 25;
|
|
3
|
-
/** 将缩放百分比钳制到允许范围:仅保留下限,放大不设上限 */
|
|
4
|
-
export declare function clampScalePercent(percent: number): number;
|
|
5
|
-
/**
|
|
6
|
-
* 滚轮缩放:乘性步进(默认 ×1.1 / ÷1.1),大倍数下仍保持平滑手感,
|
|
7
|
-
* 返回取整后的百分比,避免浮点累加产生脏显示(如 110.00000001)
|
|
8
|
-
* @param percent 当前缩放百分比
|
|
9
|
-
* @param direction 1 放大,-1 缩小
|
|
10
|
-
*/
|
|
11
|
-
export declare function nextWheelScale(percent: number, direction: 1 | -1, factor?: number): number;
|
|
12
|
-
/** 计算适应窗口的缩放百分比,仅钳制最小缩放,放大不设上限 */
|
|
13
|
-
export declare function computeFitScale(containerW: number, containerH: number, paperW: number, paperH: number, ratio?: number): number;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { TableRow, TableRowType, TableCell, TableCellBorder, ElementOptions } from '../types';
|
|
2
|
-
export interface CellRect {
|
|
3
|
-
r1: number;
|
|
4
|
-
c1: number;
|
|
5
|
-
r2: number;
|
|
6
|
-
c2: number;
|
|
7
|
-
}
|
|
8
|
-
export declare function createCell(partial?: Partial<TableCell>): TableCell;
|
|
9
|
-
/** 默认新建表格:3 列 × 4 行(标题/数据/小计/汇总),列宽均分 50mm,表格组件默认显示当前页小计行 */
|
|
10
|
-
export declare function createDefaultTable(): {
|
|
11
|
-
rows: TableRow[];
|
|
12
|
-
colWidths: number[];
|
|
13
|
-
};
|
|
14
|
-
/** 定位覆盖 (r,c) 的主格坐标(自身非 merged 即为主格) */
|
|
15
|
-
export declare function findMainCell(rows: TableRow[], r: number, c: number): {
|
|
16
|
-
r: number;
|
|
17
|
-
c: number;
|
|
18
|
-
};
|
|
19
|
-
/** 主格覆盖矩形 */
|
|
20
|
-
export declare function getSpanRect(rows: TableRow[], r: number, c: number): CellRect;
|
|
21
|
-
/** 由锚点/焦点推导矩形选区,并迭代扩展至完整包含所有跨越的合并格 */
|
|
22
|
-
export declare function normalizeSelection(rows: TableRow[], a: {
|
|
23
|
-
r: number;
|
|
24
|
-
c: number;
|
|
25
|
-
}, b: {
|
|
26
|
-
r: number;
|
|
27
|
-
c: number;
|
|
28
|
-
}): CellRect;
|
|
29
|
-
/** 合并合法性校验,返回拒绝原因或 null */
|
|
30
|
-
export declare function canMergeReason(rows: TableRow[], rect: CellRect): string | null;
|
|
31
|
-
/** 合并:左上为主格,非空内容空格拼接并入主格 */
|
|
32
|
-
export declare function mergeCells(rows: TableRow[], rect: CellRect): void;
|
|
33
|
-
/** 拆分选区内所有合并格:占位格恢复并复制主格样式 */
|
|
34
|
-
export declare function splitCells(rows: TableRow[], rect: CellRect): void;
|
|
35
|
-
/** 插入行。index 为参照行,position 决定插在其上方或下方 */
|
|
36
|
-
export declare function insertRow(rows: TableRow[], index: number, position: 'above' | 'below'): void;
|
|
37
|
-
/** 删除行;主格在被删行时移交下一行 */
|
|
38
|
-
export declare function deleteRow(rows: TableRow[], index: number): string | null;
|
|
39
|
-
/** 插入列 */
|
|
40
|
-
export declare function insertCol(rows: TableRow[], colWidths: number[], index: number, position: 'left' | 'right'): void;
|
|
41
|
-
/** 删除列;主格在被删列时移交右侧列 */
|
|
42
|
-
export declare function deleteCol(rows: TableRow[], colWidths: number[], index: number): string | null;
|
|
43
|
-
/** 行类型变更校验 + 写入。约束:header 顶部连续;data 唯一;subtotal/summary 在 data 之后;subtotal 在 summary 之前 */
|
|
44
|
-
export declare function setRowType(rows: TableRow[], index: number, type: TableRowType): string | null;
|
|
45
|
-
export type BorderPreset = 'all' | 'outer' | 'inner' | 'none';
|
|
46
|
-
/** 按预设批量写边框;none 时清空选区内所有格的 borders */
|
|
47
|
-
export declare function applyBorderPreset(rows: TableRow[], rect: CellRect, preset: BorderPreset, border: TableCellBorder): void;
|
|
48
|
-
/** 设计态下无边框单元格的辅助虚线:与背景网格线同风格(浅灰虚线),略深保证可读 */
|
|
49
|
-
export declare const GHOST_BORDER_CSS = "1px dashed rgba(0,0,0,0.18)";
|
|
50
|
-
/**
|
|
51
|
-
* 解析单元格某条边的最终 CSS border 值。
|
|
52
|
-
* - 有真实边框(style 非 none)→ 返回 `${width}pt ${style} ${color}`
|
|
53
|
-
* - 设计态且开关开启、且该边无边框 → 返回虚拟虚线(仅设计稿展示,不影响预览/打印)
|
|
54
|
-
* - 其余情况(预览态 / 开关关闭)→ 'none'
|
|
55
|
-
*/
|
|
56
|
-
export declare function resolveCellBorderCss(b: TableCellBorder | undefined, opts?: {
|
|
57
|
-
designMode?: boolean;
|
|
58
|
-
showGhostBorder?: boolean;
|
|
59
|
-
}): string;
|
|
60
|
-
/** 表格元素尺寸派生:options.width/height 恒等于列宽和/行高和(mm),与渲染端一致 */
|
|
61
|
-
export declare function syncTableElementSize(options: ElementOptions): void;
|
|
62
|
-
/** 列宽拖拽的最小列宽(mm),与属性面板列宽输入下限一致 */
|
|
63
|
-
export declare const MIN_COL_WIDTH_MM = 5;
|
|
64
|
-
/**
|
|
65
|
-
* 列宽拖拽钳制(纯函数,不修改入参,调用方负责回写):
|
|
66
|
-
* 返回目标列宽在 [MIN_COL_WIDTH_MM, maxTableWidth - 其余列和] 范围内的钳制值,
|
|
67
|
-
* 结果保留 0.1mm 精度。maxTableWidth 为 Infinity 时不设总宽上限。
|
|
68
|
-
*/
|
|
69
|
-
export declare function clampResizedColumnWidth(colWidths: number[], index: number, targetMm: number, maxTableWidth: number): number;
|
package/dist/utils/units.d.ts
DELETED