@worm-vue3-print/common 0.0.0-stage → 1.4.0-beta.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/LICENSE +21 -0
- package/README.md +278 -2
- package/dist/browser-bundle.d.ts +14 -0
- package/dist/common.css +526 -0
- package/dist/common.js +1017 -0
- package/dist/core/default-template.d.ts +9 -0
- package/dist/core/format.d.ts +122 -0
- package/dist/core/h.d.ts +22 -0
- package/dist/core/icons.d.ts +10 -0
- package/dist/core/store.d.ts +163 -0
- package/dist/index.cjs +760 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7697 -0
- package/dist/print-designer.d.ts +187 -0
- package/dist/shell/binding.d.ts +21 -0
- package/dist/shell/canvas.d.ts +59 -0
- package/dist/shell/code.d.ts +11 -0
- package/dist/shell/color-picker.d.ts +44 -0
- package/dist/shell/controls.d.ts +138 -0
- package/dist/shell/crop-anchor.d.ts +29 -0
- package/dist/shell/elements.d.ts +27 -0
- package/dist/shell/expression-editor.d.ts +33 -0
- package/dist/shell/flow-list.d.ts +11 -0
- package/dist/shell/font-select.d.ts +24 -0
- package/dist/shell/format-bar.d.ts +15 -0
- package/dist/shell/help-content/changelog.d.ts +12 -0
- package/dist/shell/help-content/faq.d.ts +12 -0
- package/dist/shell/help-content/features.d.ts +12 -0
- package/dist/shell/help-content/getting-started.d.ts +12 -0
- package/dist/shell/help-content/index.d.ts +13 -0
- package/dist/shell/help-content/shortcuts.d.ts +12 -0
- package/dist/shell/help-modal.d.ts +19 -0
- package/dist/shell/page-extras.d.ts +11 -0
- package/dist/shell/panels.d.ts +17 -0
- package/dist/shell/prop-group.d.ts +11 -0
- package/dist/shell/property-panel.d.ts +15 -0
- package/dist/shell/property-search.d.ts +32 -0
- package/dist/shell/ruler.d.ts +29 -0
- package/dist/shell/table-props.d.ts +17 -0
- package/dist/shell/table.d.ts +22 -0
- package/dist/shell/toolbar-overflow.d.ts +28 -0
- package/dist/shell/toolbar.d.ts +8 -0
- package/dist/shell/watermark.d.ts +11 -0
- package/package.json +61 -4
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { UploadDesignBackgroundFn, UploadImageFn } from '@worm-vue3-print/core/designer';
|
|
8
|
+
import type { PrintFontDeclaration } from '@worm-vue3-print/core';
|
|
9
|
+
export declare class PrintDesignerElement extends HTMLElement {
|
|
10
|
+
private root;
|
|
11
|
+
private store;
|
|
12
|
+
private format;
|
|
13
|
+
private unsub;
|
|
14
|
+
private state;
|
|
15
|
+
private geom;
|
|
16
|
+
/** 接管全局快捷键的实例(同页多设计器时最后一个交互者),见 bindKeys */
|
|
17
|
+
private static active;
|
|
18
|
+
private docKeydown;
|
|
19
|
+
private ro;
|
|
20
|
+
private roArea;
|
|
21
|
+
/** 工具栏收纳的尺寸驱动源:容器宽度变化不触发重绘,需观察器重跑后置遍 */
|
|
22
|
+
private toolbarRo;
|
|
23
|
+
private scrollPos;
|
|
24
|
+
private marquee;
|
|
25
|
+
private menu;
|
|
26
|
+
private guidePreview;
|
|
27
|
+
private zoneResizing;
|
|
28
|
+
/** 表格右键菜单状态:由 shell/table.ts 读写,每帧随 renderTableContextMenu 一起出图 */
|
|
29
|
+
private tableMenu;
|
|
30
|
+
private exprTarget;
|
|
31
|
+
private exprMountedFor;
|
|
32
|
+
/** 帮助弹窗:canvas 的 helpVisible(showHelp 为 false 时强制收起,见 set showHelp) */
|
|
33
|
+
private helpVisible;
|
|
34
|
+
private unmountHelp;
|
|
35
|
+
private drag;
|
|
36
|
+
private snapTimer;
|
|
37
|
+
/** 悬浮提示浮层:挂在 shadow root 上(canvas 的 useHoverTip / .pd-hover-tip 等价物) */
|
|
38
|
+
private hoverTipEl;
|
|
39
|
+
private hoverTipTimer;
|
|
40
|
+
private resize;
|
|
41
|
+
private raf;
|
|
42
|
+
private lastSelKey;
|
|
43
|
+
private chromeKey;
|
|
44
|
+
/** 宿主注入:图片上传,返回可访问 URL 或 data URL(对应 canvas 的 UPLOAD_IMAGE_KEY) */
|
|
45
|
+
uploadImage?: UploadImageFn;
|
|
46
|
+
/** 宿主注入:设计背景图上传,返回可直接 <img src> 的完整路径(对应 canvas 的 UPLOAD_DESIGN_BACKGROUND_KEY) */
|
|
47
|
+
uploadDesignBackground?: UploadDesignBackgroundFn;
|
|
48
|
+
/** 模板级字体声明(对应 canvas 的 fonts prop):注入 @font-face、列出字体候选、随保存/导出写回模板 */
|
|
49
|
+
private _fonts?;
|
|
50
|
+
set fonts(v: readonly PrintFontDeclaration[] | undefined);
|
|
51
|
+
get fonts(): readonly PrintFontDeclaration[] | undefined;
|
|
52
|
+
/** 字体声明的 @font-face 样式节点(挂在 shadow root 内,设计期所见即出图所得) */
|
|
53
|
+
private fontFaceStyle;
|
|
54
|
+
private docFontFaceStyle;
|
|
55
|
+
constructor();
|
|
56
|
+
set template(v: unknown);
|
|
57
|
+
get template(): unknown;
|
|
58
|
+
set fields(v: unknown);
|
|
59
|
+
set isEdit(v: boolean);
|
|
60
|
+
/** canvas 口径:showHelp 控制「帮助入口 + 弹窗」,关闭时强制收起已打开的弹窗 */
|
|
61
|
+
set showHelp(v: boolean);
|
|
62
|
+
static get observedAttributes(): string[];
|
|
63
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
64
|
+
connectedCallback(): void;
|
|
65
|
+
/** 面板折叠态:与 canvas 的 useStudioChrome 共用 localStorage 键,同一浏览器里两边偏好互通 */
|
|
66
|
+
private readChrome;
|
|
67
|
+
private persistChrome;
|
|
68
|
+
disconnectedCallback(): void;
|
|
69
|
+
/**
|
|
70
|
+
* 注入 @font-face:既进 shadow root(画布文档内),也进宿主文档 head。
|
|
71
|
+
* 原因:`@font-face` 只在文档作用域参与字体加载,shadow 内单独声明不会触发下载,
|
|
72
|
+
* 只挂 shadow 会出现「computed font-family 正确但字形回落」。canvas 本身就注到 document。
|
|
73
|
+
*/
|
|
74
|
+
private applyFontFace;
|
|
75
|
+
/** 与 canvas 的 templateJsonWithFonts 同口径:宿主字体声明随保存/导出一起出图 */
|
|
76
|
+
private templateJsonWithFonts;
|
|
77
|
+
getTemplateJson(): string;
|
|
78
|
+
loadTemplate(input: unknown): void;
|
|
79
|
+
save(): void;
|
|
80
|
+
/** 拼版配置校验:getTemplateJson 是旁路,宿主导出/另存时需自行调用拦截 */
|
|
81
|
+
validateTemplate(): import("@worm-vue3-print/core").TilingIssue[];
|
|
82
|
+
/**
|
|
83
|
+
* 出纸裁切提示(旋转外接盒顶越页首、元素超出纸面左右缘),与 canvas 同名同口径。
|
|
84
|
+
* 预估口径:编辑期无实测高,自适应行高按设计盒估算 ⇒ 只提示、不阻断保存。
|
|
85
|
+
*/
|
|
86
|
+
getGeometryWarnings(): string[];
|
|
87
|
+
private applyTemplate;
|
|
88
|
+
private openExpression;
|
|
89
|
+
private closeExpression;
|
|
90
|
+
private syncExpression;
|
|
91
|
+
private openHelp;
|
|
92
|
+
private closeHelp;
|
|
93
|
+
private syncHelp;
|
|
94
|
+
/** 回写:targetPath 为 options.<字段>(含 tableRows[r].cells[c] 下标形)/ watermark.content */
|
|
95
|
+
private applyExpression;
|
|
96
|
+
/** 画布双击元素:与 canvas 的 DBL_EDITABLE_FIELD 白名单一致,锁定元素只选中不弹框 */
|
|
97
|
+
private dblEditElement;
|
|
98
|
+
/** 表格单元格双击:定位合并主格后编辑其 formatter(对照 canvas 的 onDblClickCell) */
|
|
99
|
+
private dblEditCell;
|
|
100
|
+
private get ctx();
|
|
101
|
+
private canvasUi;
|
|
102
|
+
private repaint;
|
|
103
|
+
private paint;
|
|
104
|
+
/**
|
|
105
|
+
* 自动缩小实测遍:与 canvas 的 useShrinkFit 同一算法(core/browser fitTextNode),
|
|
106
|
+
* 让「设计态看到的字号」等于「出纸字号」。覆盖元素级与表格单元格级两类探针节点。
|
|
107
|
+
*/
|
|
108
|
+
private applyShrinkFit;
|
|
109
|
+
private measureRuler;
|
|
110
|
+
/**
|
|
111
|
+
* 画布区尺寸变化(宿主改宽、面板折叠、窗口缩放、字体到位后重排)后重画标尺。
|
|
112
|
+
* 对应 canvas 的 ResizeObserver(measureRuler):整体重绘会换掉节点,故按当前节点重新挂载。
|
|
113
|
+
*/
|
|
114
|
+
private observeCanvasArea;
|
|
115
|
+
private syncRulers;
|
|
116
|
+
/** 拖拽过程中只重写受影响元素的几何,避免全量重渲染打断输入态 */
|
|
117
|
+
private patchElementDom;
|
|
118
|
+
private fire;
|
|
119
|
+
private onDrop;
|
|
120
|
+
/** 纸面 mm 落点(对应 canvas 的 toPaperPoint):不取整,越出纸张左上角即视为无效 */
|
|
121
|
+
private pointToPaperMm;
|
|
122
|
+
private onCanvasMouseDown;
|
|
123
|
+
private onCanvasMouseMove;
|
|
124
|
+
private clearCoord;
|
|
125
|
+
private onContextMenu;
|
|
126
|
+
private onElementContextMenu;
|
|
127
|
+
private openMenu;
|
|
128
|
+
private startMarquee;
|
|
129
|
+
/**
|
|
130
|
+
* 双击判定:同一目标两次左键 mousedown,间隔 <500ms 且位移 ≤6px 即视为一次双击。
|
|
131
|
+
* 不能用原生 dblclick:paint 是 clear(shell) 全量重建,第一击选中元素后旧节点即被替换,
|
|
132
|
+
* 第二击落在新节点上时 Chrome 不再派发 dblclick(实测 30ms 间隔亦为空);
|
|
133
|
+
* canvas 侧 Vue 原地 patch 节点不换,才没有这个问题。
|
|
134
|
+
*/
|
|
135
|
+
private taps;
|
|
136
|
+
private isDoubleTap;
|
|
137
|
+
private beginDrag;
|
|
138
|
+
/** 把 `.drag-ghost` 与 `.drag-preview` 同步到当前拖拽态(拖拽中不做整体重绘,定点改 DOM) */
|
|
139
|
+
private syncDragGhost;
|
|
140
|
+
/**
|
|
141
|
+
* Alt+拖拽落点生成副本(对应 canvas BaseElement.onDragEnd 的 alt 分支 + onCloneElement):
|
|
142
|
+
* 原元素留在原位、副本继承其全部样式但剥离组身份,选中落在副本、记一条历史。
|
|
143
|
+
*/
|
|
144
|
+
private finishAltClone;
|
|
145
|
+
/** 吸附闪烁点(对应 canvas CanvasPaper.showSnapIndicator:300ms 后自动消失,重复吸附则重启动画) */
|
|
146
|
+
private flashSnapIndicator;
|
|
147
|
+
private beginResize;
|
|
148
|
+
private beginZoneResize;
|
|
149
|
+
private beginGuideDrag;
|
|
150
|
+
private beginRulerGuide;
|
|
151
|
+
/**
|
|
152
|
+
* 标尺拖出参考线时的 mm 换算。canvas 是 `(clientX - rulerRect.left - originPx) / pxPerMM`,
|
|
153
|
+
* 而 originPx = paperRect.left - areaRect.left - 尺宽、rulerRect.left = areaRect.left + 尺宽,
|
|
154
|
+
* 两项相消后等价于「相对纸张本体的像素距离 / pxPerMM」——这里直接用后一形式,
|
|
155
|
+
* 早期实现漏掉尺宽与滚动量,同一屏幕点会算出与 canvas 不同的 mm(成对拖拽对拍揭穿)。
|
|
156
|
+
*/
|
|
157
|
+
private rulerPointToMM;
|
|
158
|
+
/**
|
|
159
|
+
* 统一缩放入口(对应 canvas CanvasArea.applyZoom):以容器内锚点为不动点,
|
|
160
|
+
* 缩放后校正滚动位置,保证锚点下的内容不漂移。
|
|
161
|
+
* 容器存在非对称 padding(44/28/32/44),锚点换算必须扣除,否则每次漂移 pad*(ratio-1)。
|
|
162
|
+
*/
|
|
163
|
+
private applyZoom;
|
|
164
|
+
/** 工具栏放大/缩小:与滚轮同一乘性步进,以视口几何中心为锚点 */
|
|
165
|
+
private zoomByStep;
|
|
166
|
+
/** 适应窗口(对应 canvas PrintDesigner.onFitWindow + CanvasArea.fitToWindow) */
|
|
167
|
+
private fitToWindow;
|
|
168
|
+
private onWheel;
|
|
169
|
+
private onScroll;
|
|
170
|
+
private bindPointer;
|
|
171
|
+
private showHoverTip;
|
|
172
|
+
private hideHoverTip;
|
|
173
|
+
private manualGuides;
|
|
174
|
+
/** 仅重绘吸附引导线,避免拖拽中全量重建 DOM */
|
|
175
|
+
private paintGuidesOnly;
|
|
176
|
+
private bindKeys;
|
|
177
|
+
/** document 级快捷键监听:随挂载/卸载成对增删(重连场景 store 已存在,bindKeys 不再执行) */
|
|
178
|
+
private attachDocKeys;
|
|
179
|
+
private detachDocKeys;
|
|
180
|
+
private onGlobalKeydown;
|
|
181
|
+
}
|
|
182
|
+
declare global {
|
|
183
|
+
interface HTMLElementTagNameMap {
|
|
184
|
+
'print-designer': PrintDesignerElement;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
export declare function definePrintDesigner(tag?: string): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { BindingDescriptor, RuntimeElement } from '@worm-vue3-print/core/designer';
|
|
8
|
+
import type { ShellCtx } from './controls';
|
|
9
|
+
import type { DesignerStore } from '../core/store';
|
|
10
|
+
/**
|
|
11
|
+
* 统一解析带点分段与数组下标的 targetPath 为段/索引混排数组(与 canvas 的 parsePath 同实现)
|
|
12
|
+
* 例:'options.formatter' → ['options','formatter']
|
|
13
|
+
* 例:'options.tableRows[0].cells[1].formatter' → ['options','tableRows',0,'cells',1,'formatter']
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseBindingPath(targetPath: string): (string | number)[];
|
|
16
|
+
export declare function readBindingValue(element: RuntimeElement, targetPath: string): string;
|
|
17
|
+
/** 写回:canvas 的 setBindingValue 是「先赋值、后 recordHistory」,此处保持同序 */
|
|
18
|
+
export declare function writeBindingValue(store: DesignerStore, element: RuntimeElement, targetPath: string, value: string): void;
|
|
19
|
+
/** 当前应渲染的绑定项:表格有选区时只出选中单元格,否则按注册表(与 canvas 同口径) */
|
|
20
|
+
export declare function bindingDescriptorsFor(ctx: ShellCtx, el: RuntimeElement): BindingDescriptor[];
|
|
21
|
+
export declare function bindingGroup(ctx: ShellCtx, el: RuntimeElement): import("../core/h").El;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { TemplateData } from '@worm-vue3-print/core/designer';
|
|
8
|
+
import type { ShellCtx } from './controls';
|
|
9
|
+
import type { RulerGeom } from './ruler';
|
|
10
|
+
export interface CanvasUI {
|
|
11
|
+
geom: RulerGeom;
|
|
12
|
+
marquee: {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
w: number;
|
|
17
|
+
h: number;
|
|
18
|
+
};
|
|
19
|
+
contextMenu: {
|
|
20
|
+
visible: boolean;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
flipX: number;
|
|
24
|
+
flipY: number;
|
|
25
|
+
targetId: string | null;
|
|
26
|
+
};
|
|
27
|
+
guidePreview: {
|
|
28
|
+
type: 'vertical' | 'horizontal';
|
|
29
|
+
position: number;
|
|
30
|
+
} | null;
|
|
31
|
+
zoneResizing: 'header' | 'footer' | null;
|
|
32
|
+
scrollX: number;
|
|
33
|
+
scrollY: number;
|
|
34
|
+
}
|
|
35
|
+
/** 三区矩形(mm,纸面坐标系):上边距→页眉→内容→页脚→下边距(同 CanvasPaper.zoneRectsMM) */
|
|
36
|
+
export declare function zoneRectsMM(t: TemplateData, paper: {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}): {
|
|
40
|
+
header: {
|
|
41
|
+
left: number;
|
|
42
|
+
top: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
46
|
+
content: {
|
|
47
|
+
left: number;
|
|
48
|
+
top: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
footer: {
|
|
53
|
+
left: number;
|
|
54
|
+
top: number;
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare function renderCanvasArea(ctx: ShellCtx, ui: CanvasUI): import("../core/h").El;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeElement } from '@worm-vue3-print/core/designer';
|
|
8
|
+
export declare function renderQrcode(el: RuntimeElement): import("../core/h").El;
|
|
9
|
+
export declare function renderBarcode(el: RuntimeElement): import("../core/h").El;
|
|
10
|
+
/** DOM 落位后绘制所有码类元素 */
|
|
11
|
+
export declare function hydrateCodes(root: ShadowRoot, elements: RuntimeElement[]): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { El } from '../core/h';
|
|
8
|
+
export interface ColorPickerOptions {
|
|
9
|
+
/** 当前色值;空串/undefined 均视为「未设置」 */
|
|
10
|
+
value?: string;
|
|
11
|
+
/** 是否允许清除(canvas 边框等必填场景传 false),默认 true */
|
|
12
|
+
clearable?: boolean;
|
|
13
|
+
/** 触发按钮 title(canvas 侧为色值或「自动」,本包保留调用方传入的字段名语义) */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** 追加在触发钮上的类名(canvas 给组件根挂的 class 会与其自身类名合并,如 `page-bg-picker`) */
|
|
16
|
+
triggerClass?: string;
|
|
17
|
+
/** 选中回调;undefined 表示清除(canvas emit '' 的等价归一) */
|
|
18
|
+
onChange: (value: string | undefined) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseHex(color: string): {
|
|
21
|
+
r: number;
|
|
22
|
+
g: number;
|
|
23
|
+
b: number;
|
|
24
|
+
} | null;
|
|
25
|
+
export declare function normalizeHex(color: string): string;
|
|
26
|
+
export declare function rgbToHex({ r, g, b }: {
|
|
27
|
+
r: number;
|
|
28
|
+
g: number;
|
|
29
|
+
b: number;
|
|
30
|
+
}): string;
|
|
31
|
+
export declare function rgbToHsv(r: number, g: number, b: number): {
|
|
32
|
+
h: number;
|
|
33
|
+
s: number;
|
|
34
|
+
v: number;
|
|
35
|
+
};
|
|
36
|
+
export declare function hsvToRgb(h_: number, s: number, v: number): {
|
|
37
|
+
r: number;
|
|
38
|
+
g: number;
|
|
39
|
+
b: number;
|
|
40
|
+
};
|
|
41
|
+
/** 触发按钮(对应 canvas 的 button.preset-color-trigger);点击在挂载根上开/关面板 */
|
|
42
|
+
export declare function colorPicker(opts: ColorPickerOptions): El;
|
|
43
|
+
/** 关闭当前打开的面板并解除全部监听(宿主 disconnectedCallback 亦可用) */
|
|
44
|
+
export declare function closeColorPicker(): void;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { PrintFontDeclaration } from '@worm-vue3-print/core';
|
|
8
|
+
import type { DesignerStore } from '../core/store';
|
|
9
|
+
/** 外壳局部 UI 状态(不落模板数据,仅影响渲染) */
|
|
10
|
+
export interface ShellState {
|
|
11
|
+
leftTab: 'elements' | 'fields' | 'layers';
|
|
12
|
+
leftCollapsed: boolean;
|
|
13
|
+
propTab: 'element' | 'page';
|
|
14
|
+
propCollapsed: boolean;
|
|
15
|
+
/** 打开的下拉面板 id(同一时刻只允许一个) */
|
|
16
|
+
openDd: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* 「更多」收纳面板的开关。与 openDd 分持:面板内还嵌着对齐/边框等下拉,
|
|
19
|
+
* 共用一个开关键会让内层下拉一打开就把外层「更多」顶掉(canvas 是每个实例独立 open)。
|
|
20
|
+
*/
|
|
21
|
+
openMore?: boolean;
|
|
22
|
+
/** 字段搜索关键字(仅影响左栏字段树) */
|
|
23
|
+
fieldSearch?: string;
|
|
24
|
+
/** 折叠的字段分组 key */
|
|
25
|
+
collapsedGroups: Set<string>;
|
|
26
|
+
/** 正在行内重命名的页面下标 */
|
|
27
|
+
renamingPage: number | null;
|
|
28
|
+
renameText?: string;
|
|
29
|
+
/** 属性台搜索关键字(门控分组与字段,对应 canvas PropertyPanel 的 searchText) */
|
|
30
|
+
propSearch?: string;
|
|
31
|
+
/** 展开中的字体下拉:整体重绘模型下必须外置,否则 repaint() 会让候选列表闪断 */
|
|
32
|
+
fontOpen?: {
|
|
33
|
+
id: string;
|
|
34
|
+
query: string;
|
|
35
|
+
highlighted: number;
|
|
36
|
+
} | null;
|
|
37
|
+
}
|
|
38
|
+
/** 外壳渲染上下文:工具栏动作以 fire(name, arg) 上报,由自定义元素分发 */
|
|
39
|
+
export interface ShellCtx {
|
|
40
|
+
store: DesignerStore;
|
|
41
|
+
/** 格式栏语义内核(shell/format-bar.ts 需要;由自定义元素注入) */
|
|
42
|
+
format: import('../core/format').FormatToolbar;
|
|
43
|
+
state: ShellState;
|
|
44
|
+
repaint: () => void;
|
|
45
|
+
fire: (action: string, arg?: unknown) => void;
|
|
46
|
+
/** 宿主能力开关 */
|
|
47
|
+
showHelp: boolean;
|
|
48
|
+
isEdit: boolean;
|
|
49
|
+
/** 宿主注入能力(图片上传、设计背景上传、字体清单),未注入时相关入口置灰 */
|
|
50
|
+
host: {
|
|
51
|
+
uploadImage?: (file: File) => Promise<string>;
|
|
52
|
+
uploadDesignBackground?: (file: File) => Promise<string>;
|
|
53
|
+
/** 模板级字体声明,与 canvas 的 PrintDesigner `fonts` prop 同类型(裸字符串族名不参与候选,与画布一致) */
|
|
54
|
+
fonts?: readonly PrintFontDeclaration[];
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** 带图标的工具栏按钮(对应 canvas 的 .tb-btn.tb-icon) */
|
|
58
|
+
export declare function tbIconBtn(ctx: ShellCtx, iconName: string, action: string, opts: {
|
|
59
|
+
tip: string;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
on?: boolean;
|
|
62
|
+
danger?: boolean;
|
|
63
|
+
arg?: unknown;
|
|
64
|
+
test?: string;
|
|
65
|
+
}): import("../core/h").El;
|
|
66
|
+
/** 下拉壳:触发钮 + 面板,面板内容由调用方给出(对应 canvas 的 ToolbarDropdown) */
|
|
67
|
+
export declare function dropdown(ctx: ShellCtx, id: string, opts: {
|
|
68
|
+
tip: string;
|
|
69
|
+
icon?: string;
|
|
70
|
+
text?: string;
|
|
71
|
+
textClass?: string;
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
testId?: string;
|
|
74
|
+
panelClass?: string;
|
|
75
|
+
}, panel: unknown[]): import("../core/h").El;
|
|
76
|
+
/** 步进数字输入(对应 canvas 的 property/StepperInput) */
|
|
77
|
+
export declare function stepper(opts: {
|
|
78
|
+
value?: number;
|
|
79
|
+
min?: number;
|
|
80
|
+
max?: number;
|
|
81
|
+
step?: number;
|
|
82
|
+
placeholder?: string;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
onCommit: (v: number) => void;
|
|
85
|
+
}): import("../core/h").El;
|
|
86
|
+
/** 属性行:pd-field > pd-label(.pd-label-t + 恢复默认值) + 控件 */
|
|
87
|
+
export declare function field(label: string, control: unknown, hint?: string, reset?: unknown): import("../core/h").El;
|
|
88
|
+
/** 字段说明图标:说明不常驻行内,悬浮或点击聚焦时才浮出(对应 canvas 的 button.pd-help) */
|
|
89
|
+
export declare const labelHelp: (tip: string) => import("../core/h").El;
|
|
90
|
+
/** 带说明图标的属性行:与 field() 同结构,差别只在说明挂图标而非常驻 .pd-hint 段落 */
|
|
91
|
+
export declare function fieldHelp(label: string, control: unknown, tip: string, reset?: unknown): import("../core/h").El;
|
|
92
|
+
/**
|
|
93
|
+
* 「恢复默认值」按钮,与 canvas 的 property/ResetButton.vue 逐字同构。
|
|
94
|
+
* 落点派生自 base[propKey]:判据一律 === 比出厂值,base 里取到 undefined 即「未设」,
|
|
95
|
+
* 写回它天然等于删键。0 与 undefined 是两个状态,不得用 ?? / || 归并。
|
|
96
|
+
* 外壳是全量重绘模型,灰/亮在构造时求值即可,不需要响应式。
|
|
97
|
+
* 按钮不带任何文本子节点——属性搜索按 .pd-label 的 textContent 匹配,写字会污染命中。
|
|
98
|
+
*/
|
|
99
|
+
export declare function resetButton(o: {
|
|
100
|
+
target: Record<string, any>;
|
|
101
|
+
base: Record<string, any>;
|
|
102
|
+
propKey: string;
|
|
103
|
+
/** 提示语数值:仅用于文案,不参与判定 */
|
|
104
|
+
tipValue?: number | string;
|
|
105
|
+
tipUnit?: string;
|
|
106
|
+
/** 覆盖整条提示(单元格级固定用「跟随表格默认」,回落目标是该表自己的默认) */
|
|
107
|
+
tipOverride?: string;
|
|
108
|
+
/** 覆盖写回通道:单元格组必须整选区恢复,不能让按钮只改当前展示的那一个 cell 对象 */
|
|
109
|
+
write?: (value: any) => void;
|
|
110
|
+
/** 写回后的收尾(重绘 / 记历史);不提供时只改对象 */
|
|
111
|
+
onReset?: () => void;
|
|
112
|
+
/** 多选批量档:不显示"已改"脏点(判据取自单格会误导),但按钮恒可点,写回整选区 */
|
|
113
|
+
force?: boolean;
|
|
114
|
+
}): import("../core/h").El;
|
|
115
|
+
/** 分节标题(对应 canvas 的 h3.pd-divider) */
|
|
116
|
+
export declare const divider: (text: string) => import("../core/h").El;
|
|
117
|
+
/** 颜色触发钮:预设色板面板(移植 canvas 的 PresetColorPicker.vue,面板实现见 shell/color-picker.ts)。
|
|
118
|
+
* onPick 收到的 undefined 表示「清除颜色」:canvas 侧 emit '' 后由消费方归一化为未设置,
|
|
119
|
+
* 本包在触发器层直接归一后透传,调用方 patch 即删除该颜色属性(签名保持 (v: string) 不变)。 */
|
|
120
|
+
export declare function colorTrigger(value: string | undefined, onPick: (v: string) => void, title?: string, triggerClass?: string): import("../core/h").El;
|
|
121
|
+
/** 单选组(对应 canvas 的 .pd-radio-group) */
|
|
122
|
+
export declare function radioGroup(name: string, options: {
|
|
123
|
+
value: string;
|
|
124
|
+
label: string;
|
|
125
|
+
}[], current: string, onChange: (v: string) => void, twoCol?: boolean): import("../core/h").El;
|
|
126
|
+
/**
|
|
127
|
+
* 裸下拉(无 label 包裹,用于 .border-style-row 这类横向控件行)。
|
|
128
|
+
* 不能只靠 <option selected> 属性:happy-dom/部分内核在"首项未选中、第三项选中"时会回落到第二项,
|
|
129
|
+
* 必须建真节点后显式 select.value = 当前值(与 selectField 同一套可靠赋值)。
|
|
130
|
+
*/
|
|
131
|
+
export declare function plainSelect(value: string, options: {
|
|
132
|
+
value: string;
|
|
133
|
+
label: string;
|
|
134
|
+
disabled?: boolean;
|
|
135
|
+
}[], onChange: (v: string) => void, attrs?: {
|
|
136
|
+
className?: string;
|
|
137
|
+
width?: string;
|
|
138
|
+
}): HTMLSelectElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { ShellCtx } from './controls';
|
|
8
|
+
export interface CropAnchorOpts {
|
|
9
|
+
fieldKey: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** 容器类名:canvas 只在单元格台包一层 `pd-cell-anchor`(`TableCellGroup.vue`),元素台没有包层;缺省沿用本包 `pd-crop-anchor` */
|
|
12
|
+
containerClass?: string;
|
|
13
|
+
/** 已解析的图片地址(表达式由宿主求值后传入);为空则回落内置示例图 */
|
|
14
|
+
src: string;
|
|
15
|
+
widthMm: number;
|
|
16
|
+
heightMm: number;
|
|
17
|
+
/** 缩放模式(CSS object-fit 原值,缺省按 contain):可挪余量按它逐轴结算 */
|
|
18
|
+
fit?: string;
|
|
19
|
+
/** 剪裁放大比例(%):只有 cover 消费,铺满后把画面再推大这么多 */
|
|
20
|
+
scale?: number;
|
|
21
|
+
/** 行尾「恢复默认值」图标:落点由宿主按所在层构造(元素级派生出厂值、单元格级删自身值),
|
|
22
|
+
* 本组件只负责把它摆进标签行右端,与 canvas 的 CropAnchorField 同一 DOM 结构 */
|
|
23
|
+
resetAnchor?: unknown;
|
|
24
|
+
resetScale?: unknown;
|
|
25
|
+
value?: string;
|
|
26
|
+
onCommit: (value: string | undefined) => void;
|
|
27
|
+
onScaleCommit: (value: number | undefined) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function cropAnchorField(ctx: ShellCtx, o: CropAnchorOpts): import("../core/h").El;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import { mmToPx } from '@worm-vue3-print/core/designer';
|
|
8
|
+
import type { RuntimeElement } from '@worm-vue3-print/core/designer';
|
|
9
|
+
import type { ShellCtx } from './controls';
|
|
10
|
+
/** 元素几何与边框(对齐 BaseElement.elementStyle) */
|
|
11
|
+
export declare function elementStyle(el: RuntimeElement, followMemberIds?: Set<string>): Record<string, string>;
|
|
12
|
+
/** 文本与长文本共用的行内样式:与 canvas 的 TextElement / LongTextElement 逐项一致(差异按类型分支) */
|
|
13
|
+
export declare function textLikeStyle(el: RuntimeElement): {
|
|
14
|
+
style: Record<string, string>;
|
|
15
|
+
fit: import("@worm-vue3-print/core").TextFit;
|
|
16
|
+
};
|
|
17
|
+
export declare function imageStyle(el: RuntimeElement): Record<string, string>;
|
|
18
|
+
/** 选中角标文本:与 canvas BaseElement 的 posLabel 逐字一致(四舍五入到整数 mm) */
|
|
19
|
+
export declare function positionLabel(o: {
|
|
20
|
+
left: number;
|
|
21
|
+
top: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}): string;
|
|
25
|
+
export declare function renderDesignElement(ctx: ShellCtx, el: RuntimeElement, followMemberIds?: Set<string>): import("../core/h").El;
|
|
26
|
+
/** mm → px(供画布几何换算复用同一口径) */
|
|
27
|
+
export { mmToPx };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { PrintBusinessField } from '@worm-vue3-print/core/designer';
|
|
8
|
+
import type { El } from '../core/h';
|
|
9
|
+
export interface ExpressionEditorTarget {
|
|
10
|
+
/** 元素 id(表格单元格时用于定位) */
|
|
11
|
+
elementId: string;
|
|
12
|
+
/** 要写回的目标路径,如 'options.formatter' 或 'cell:<rowId>:<colIndex>' */
|
|
13
|
+
targetPath: string;
|
|
14
|
+
/** 当前表达式文本 */
|
|
15
|
+
value: string;
|
|
16
|
+
/** 可选:字段绑定模式的初始字段 key */
|
|
17
|
+
binding?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ExpressionEditorOptions {
|
|
20
|
+
fields: PrintBusinessField[];
|
|
21
|
+
/** 求值预览用的样例行数据 */
|
|
22
|
+
demoData?: Record<string, any>;
|
|
23
|
+
/** 关闭弹窗 */
|
|
24
|
+
onClose: () => void;
|
|
25
|
+
/** 点确定:把最终表达式回写 */
|
|
26
|
+
onApply: (next: {
|
|
27
|
+
formatter?: string;
|
|
28
|
+
binding?: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
}
|
|
32
|
+
/** 渲染表达式编辑器弹窗的 DOM 描述(内部已含遮罩层,render 进 shadow 根下即可) */
|
|
33
|
+
export declare function renderExpressionEditor(opts: ExpressionEditorOptions, target: ExpressionEditorTarget): El;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { RuntimeElement } from '@worm-vue3-print/core/designer';
|
|
8
|
+
/** 与 canvas FlowListElement 的 DESIGN_FALLBACK_ITEMS 逐字一致:新拖入的元素也要看得见形状 */
|
|
9
|
+
export declare const FLOW_LIST_DEMO_ITEMS: string[];
|
|
10
|
+
export declare function flowListCells(el: RuntimeElement, data?: Record<string, any>[]): string[];
|
|
11
|
+
export declare function renderFlowListElement(el: RuntimeElement, data?: Record<string, any>[]): import("../core/h").El;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import type { FontCatalogOption, PrintFontDeclaration } from '@worm-vue3-print/core';
|
|
8
|
+
import type { ShellState } from './controls';
|
|
9
|
+
export interface FontSelectOptions {
|
|
10
|
+
/** 实例标识:同一时刻只允许一个字体下拉处于展开态 */
|
|
11
|
+
id: string;
|
|
12
|
+
/** 外壳状态:展开态落在这里,跨重绘保持 */
|
|
13
|
+
state: ShellState;
|
|
14
|
+
/** 宿主注入的字体清单:条目须是字体声明(family/label,`files` 由宿主侧携带),裸字符串不进候选——与画布同一判据 */
|
|
15
|
+
fonts?: readonly (FontCatalogOption | PrintFontDeclaration | null | undefined)[];
|
|
16
|
+
/** 当前族名;undefined 表示未设置,走全局兜底字体栈 */
|
|
17
|
+
value?: string;
|
|
18
|
+
/** 空值行文案(同时用作输入框 placeholder) */
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/** 禁用(如格式工具栏无可用目标时置灰) */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
onChange: (value: string | undefined) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function renderFontSelect(opts: FontSelectOptions): HTMLElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
import { field } from './controls';
|
|
8
|
+
import type { ShellCtx } from './controls';
|
|
9
|
+
import type { FormatToolbar } from '../core/format';
|
|
10
|
+
type FormatCtx = ShellCtx & {
|
|
11
|
+
format: FormatToolbar;
|
|
12
|
+
};
|
|
13
|
+
export declare function renderFormatBar(ctx: FormatCtx): import("../core/h").El;
|
|
14
|
+
/** 供状态栏/属性面板复用的排版行(保持与 canvas 同类名) */
|
|
15
|
+
export { field as formatField };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-vue3-print/common v1.4.0-beta.0
|
|
3
|
+
* Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
|
|
4
|
+
* SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|