operp-print-designer 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Print Designer 使用文档
1
+ # Operp Print Designer 使用文档
2
+
3
+ **Git 仓库地址**: https://gitee.com/garychk/operp-react-print
2
4
 
3
5
  ## 安装
4
6
 
@@ -87,7 +89,7 @@ interface DataSource {
87
89
  ### CanvasComponent
88
90
 
89
91
  ```typescript
90
- type CanvasComponentType = 'text' | 'image' | 'table' | 'barcode' | 'line';
92
+ type CanvasComponentType = 'text' | 'image' | 'table' | 'barcode' | 'qrcode' | 'line';
91
93
 
92
94
  interface CanvasComponent {
93
95
  id: string;
@@ -274,7 +276,7 @@ import 'operp-print-designer/dist/index.css';
274
276
  2. **TypeScript**: 该库使用 TypeScript 编写,自带类型定义。
275
277
 
276
278
  3. **数据绑定**: 数据源支持对象和数组两种类型:
277
- - **对象类型**: 适用于文本、条码、图片等组件的数据绑定
279
+ - **对象类型**: 适用于文本、图片、条码、二维码等组件的数据绑定
278
280
  - **数组类型**: 适用于表格组件的数据绑定
279
281
 
280
282
  4. **预览模式**: 当 `isPreview` 为 `true` 时,组件处于只读模式,用户不能编辑模板,只能预览和打印。
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ /** 简易条形码渲染组件(使用Canvas绘制) */
3
+ interface BarcodeProps {
4
+ value: string;
5
+ format: string;
6
+ }
7
+ declare const Barcode: React.FC<BarcodeProps>;
8
+ export default Barcode;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import 'react-grid-layout/css/styles.css';
3
+ import 'react-resizable/css/styles.css';
4
+ declare const Canvas: React.FC<{
5
+ isPreview?: boolean;
6
+ }>;
7
+ export default Canvas;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ComponentPanel: React.FC;
3
+ export default ComponentPanel;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const DataSourcePanel: React.FC;
3
+ export default DataSourcePanel;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const HeaderFooterDialog: React.FC;
3
+ export default HeaderFooterDialog;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const LeftPanel: React.FC;
3
+ export default LeftPanel;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const PageSettings: React.FC;
3
+ export default PageSettings;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { TemplateData } from '../../types';
3
+ export interface PrintDesignerProps {
4
+ /** 是否为预览模式(只读) */
5
+ isPreview?: boolean;
6
+ /** 初始模板数据 */
7
+ initialTemplateData?: TemplateData;
8
+ /** 保存回调 */
9
+ onSave?: (templateData: TemplateData) => void;
10
+ /** 打印回调 */
11
+ onPrint?: () => void;
12
+ }
13
+ declare const PrintDesigner: React.FC<PrintDesignerProps>;
14
+ export default PrintDesigner;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const PrintPreview: React.FC;
3
+ export default PrintPreview;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const PropertyPanel: React.FC;
3
+ export default PropertyPanel;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface QRCodeProps {
3
+ value: string;
4
+ errorLevel?: 'L' | 'M' | 'Q' | 'H';
5
+ color?: string;
6
+ backgroundColor?: string;
7
+ }
8
+ declare const QRCode: React.FC<QRCodeProps>;
9
+ export default QRCode;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface ToolbarProps {
3
+ /** 自定义保存回调 */
4
+ onCustomSave?: () => void;
5
+ /** 自定义打印回调 */
6
+ onCustomPrint?: () => void;
7
+ }
8
+ declare const Toolbar: React.FC<ToolbarProps>;
9
+ export default Toolbar;
@@ -0,0 +1,74 @@
1
+ import { PaperSizePreset } from '../types';
2
+ /** 纸张预设尺寸 - 宽高 mm (portrait) */
3
+ export declare const PAPER_SIZES: Record<Exclude<PaperSizePreset, 'custom'>, {
4
+ width: number;
5
+ height: number;
6
+ }>;
7
+ /** 默认页面设置 */
8
+ export declare const DEFAULT_PAGE_SETTINGS: {
9
+ paperSize: PaperSizePreset;
10
+ customWidth: number;
11
+ customHeight: number;
12
+ orientation: "portrait";
13
+ marginTop: number;
14
+ marginRight: number;
15
+ marginBottom: number;
16
+ marginLeft: number;
17
+ showHeader: boolean;
18
+ headerContent: string;
19
+ showFooter: boolean;
20
+ footerContent: string;
21
+ showPageNumber: boolean;
22
+ pageNumberFormat: string;
23
+ };
24
+ /** 缩放系数: 1mm 对应的像素 */
25
+ export declare const MM_TO_PX_RATIO = 3;
26
+ /** 默认网格设置 */
27
+ export declare const DEFAULT_GRID_SETTINGS: {
28
+ cellSize: number;
29
+ cols: number;
30
+ };
31
+ /** 组件类型中文名 */
32
+ export declare const COMPONENT_TYPE_LABELS: Record<string, string>;
33
+ /** 组件类型默认属性 */
34
+ export declare const COMPONENT_DEFAULTS: {
35
+ text: {
36
+ content: string;
37
+ fontSize: number;
38
+ fontWeight: "normal";
39
+ fontStyle: "normal";
40
+ textAlign: "left";
41
+ color: string;
42
+ backgroundColor: string;
43
+ };
44
+ image: {
45
+ src: string;
46
+ fit: "contain";
47
+ content: string;
48
+ };
49
+ table: {
50
+ rows: number;
51
+ cols: number;
52
+ borderWidth: number;
53
+ borderColor: string;
54
+ content: string;
55
+ };
56
+ barcode: {
57
+ value: string;
58
+ format: "CODE128";
59
+ content: string;
60
+ };
61
+ qrcode: {
62
+ value: string;
63
+ errorLevel: "M";
64
+ color: string;
65
+ backgroundColor: string;
66
+ content: string;
67
+ };
68
+ line: {
69
+ color: string;
70
+ thickness: number;
71
+ style: "solid";
72
+ content: string;
73
+ };
74
+ };
@@ -0,0 +1,7 @@
1
+ import PrintDesigner from './components/PrintDesigner';
2
+ export default PrintDesigner;
3
+ export { PrintDesigner };
4
+ export type { PrintDesignerProps } from './components/PrintDesigner';
5
+ export type { CanvasComponent, CanvasComponentType, PageSettings, GridSettings, TemplateData, DataSource, DataSourceType, TableColumnConfig, DataBinding, DataBindingConfig, } from './types';
6
+ export { getRenderValue, getObjectFromDataSource, getArrayFromDataSource, safeParseJSON, getValueByPath, } from './utils/dataHelper';
7
+ export { useDesignerStore } from './store';
@@ -1 +1 @@
1
- *{margin:0;padding:0;box-sizing:border-box}html,body,#root{width:100%;height:100%;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.app-container{display:flex;flex-direction:column;height:100vh;overflow:hidden}.app-body{display:flex;flex:1;overflow:hidden}.app-left-panel{width:280px;min-width:220px;display:flex;flex-direction:column;border-right:1px solid #e8e8e8;background:#fff;overflow:hidden}.app-left-top{flex-shrink:0}.app-left-bottom{flex:1;overflow:auto}.app-right-panel{width:260px;min-width:260px;border-left:1px solid #e8e8e8;background:#fff;overflow:auto}.canvas-grid{background-image:linear-gradient(rgba(0,0,0,.05) 1px,transparent 1px),linear-gradient(90deg,rgba(0,0,0,.05) 1px,transparent 1px);background-size:20px 20px}.react-grid-item.react-grid-placeholder{background:#1677ff!important;opacity:.15!important;border-radius:4px}.react-grid-layout{position:relative;transition:height .2s ease}.react-grid-item{transition:all .2s ease;transition-property:left,top,width,height}.react-grid-item img{pointer-events:none;-webkit-user-select:none;user-select:none}.react-grid-item.cssTransforms{transition-property:transform,width,height}.react-grid-item.resizing{transition:none;z-index:1;will-change:width,height}.react-grid-item.react-draggable-dragging{transition:none;z-index:3;will-change:transform}.react-grid-item.dropping{visibility:hidden}.react-grid-item.react-grid-placeholder{background:red;opacity:.2;transition-duration:.1s;z-index:2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.react-grid-item.react-grid-placeholder.placeholder-resizing{transition:none}.react-grid-item>.react-resizable-handle{position:absolute;width:20px;height:20px}.react-grid-item>.react-resizable-handle:after{content:"";position:absolute;right:3px;bottom:3px;width:5px;height:5px;border-right:2px solid rgba(0,0,0,.4);border-bottom:2px solid rgba(0,0,0,.4)}.react-resizable-hide>.react-resizable-handle{display:none}.react-grid-item>.react-resizable-handle.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-w,.react-grid-item>.react-resizable-handle.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-n,.react-grid-item>.react-resizable-handle.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}.react-resizable{position:relative}.react-resizable-handle{position:absolute;width:20px;height:20px;background-repeat:no-repeat;background-origin:content-box;box-sizing:border-box;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+);background-position:bottom right;padding:0 3px 3px 0}.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-resizable-handle-w,.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-resizable-handle-n,.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}
1
+ *{margin:0;padding:0;box-sizing:border-box}html,body,#root{width:100%;height:100%;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.app-container{display:flex;flex-direction:column;height:100vh;overflow:hidden}.app-body{display:flex;flex:1;overflow:hidden}.app-left-panel{position:relative;width:240px;min-width:220px;display:flex;flex-direction:column;border-right:1px solid #e8e8e8;background:#fff;overflow:hidden;transition:width .2s ease,min-width .2s ease}.app-left-top{flex-shrink:0}.app-left-bottom{flex:1;overflow:auto}.app-right-panel{position:relative;width:260px;min-width:260px;display:flex;flex-direction:column;border-left:1px solid #e8e8e8;background:#fff;overflow:auto;transition:width .2s ease,min-width .2s ease}.app-left-panel.collapsed,.app-right-panel.collapsed{width:40px;min-width:40px;align-items:center;justify-content:flex-start;overflow:hidden}.panel-collapse-trigger{position:absolute;top:8px;z-index:2;width:24px;height:24px;padding:0}.panel-collapse-trigger-left,.panel-collapse-trigger-right{right:8px}.panel-collapsed-trigger{width:32px;height:32px;margin-top:8px;padding:0}.canvas-grid{background-image:linear-gradient(rgba(0,0,0,.05) 1px,transparent 1px),linear-gradient(90deg,rgba(0,0,0,.05) 1px,transparent 1px);background-size:20px 20px}.react-grid-item.react-grid-placeholder{background:#1677ff!important;opacity:.15!important;border-radius:4px}.react-grid-layout{position:relative;transition:height .2s ease}.react-grid-item{transition:all .2s ease;transition-property:left,top,width,height}.react-grid-item img{pointer-events:none;-webkit-user-select:none;user-select:none}.react-grid-item.cssTransforms{transition-property:transform,width,height}.react-grid-item.resizing{transition:none;z-index:1;will-change:width,height}.react-grid-item.react-draggable-dragging{transition:none;z-index:3;will-change:transform}.react-grid-item.dropping{visibility:hidden}.react-grid-item.react-grid-placeholder{background:red;opacity:.2;transition-duration:.1s;z-index:2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.react-grid-item.react-grid-placeholder.placeholder-resizing{transition:none}.react-grid-item>.react-resizable-handle{position:absolute;width:20px;height:20px}.react-grid-item>.react-resizable-handle:after{content:"";position:absolute;right:3px;bottom:3px;width:5px;height:5px;border-right:2px solid rgba(0,0,0,.4);border-bottom:2px solid rgba(0,0,0,.4)}.react-resizable-hide>.react-resizable-handle{display:none}.react-grid-item>.react-resizable-handle.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-w,.react-grid-item>.react-resizable-handle.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-n,.react-grid-item>.react-resizable-handle.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}.react-resizable{position:relative}.react-resizable-handle{position:absolute;width:20px;height:20px;background-repeat:no-repeat;background-origin:content-box;box-sizing:border-box;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+);background-position:bottom right;padding:0 3px 3px 0}.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-resizable-handle-w,.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-resizable-handle-n,.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}