operp-print-designer 1.1.0 → 1.1.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 CHANGED
@@ -55,6 +55,7 @@ function Previewer() {
55
55
  |------|------|------|------|
56
56
  | `isPreview` | `boolean` | 否 | 是否为预览模式(只读),默认为 `false` |
57
57
  | `initialTemplateData` | `TemplateData` | 否 | 初始模板数据,用于加载已有的模板 |
58
+ | `dataSource` | `PrintDesignerDataSource` | 否 | 外部数据源,传入后优先于模板内部数据源用于渲染和打印 |
58
59
  | `onSave` | `(data: TemplateData) => void` | 否 | 保存回调函数,当用户点击保存按钮时触发 |
59
60
  | `onPrint` | `() => void` | 否 | 打印回调函数,当用户点击打印按钮时触发 |
60
61
 
@@ -86,6 +87,15 @@ interface DataSource {
86
87
  }
87
88
  ```
88
89
 
90
+ ### PrintDesignerDataSource
91
+
92
+ ```typescript
93
+ interface PrintDesignerDataSource {
94
+ data?: Record<string, unknown>; // 对象数据
95
+ list?: Record<string, unknown>[]; // 列表数据
96
+ }
97
+ ```
98
+
89
99
  ### CanvasComponent
90
100
 
91
101
  ```typescript
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
2
  import 'react-grid-layout/css/styles.css';
3
3
  import 'react-resizable/css/styles.css';
4
+ import { DataSource } from '../types';
4
5
  declare const Canvas: React.FC<{
5
6
  isPreview?: boolean;
7
+ dataSources?: DataSource[];
6
8
  }>;
7
9
  export default Canvas;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import { TemplateData } from '../../types';
2
+ import { PrintDesignerDataSource, TemplateData } from '../../types';
3
3
  export interface PrintDesignerProps {
4
4
  /** 是否为预览模式(只读) */
5
5
  isPreview?: boolean;
6
6
  /** 初始模板数据 */
7
7
  initialTemplateData?: TemplateData;
8
+ /** 外部数据源。传入后优先于设计器内部数据源用于渲染和打印 */
9
+ dataSource?: PrintDesignerDataSource;
8
10
  /** 保存回调 */
9
11
  onSave?: (templateData: TemplateData) => void;
10
12
  /** 打印回调 */
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
- declare const PrintPreview: React.FC;
2
+ import { DataSource } from '../types';
3
+ declare const PrintPreview: React.FC<{
4
+ dataSources?: DataSource[];
5
+ }>;
3
6
  export default PrintPreview;
@@ -40,6 +40,7 @@ export declare const COMPONENT_DEFAULTS: {
40
40
  textAlign: "left";
41
41
  color: string;
42
42
  backgroundColor: string;
43
+ format: string;
43
44
  };
44
45
  image: {
45
46
  src: string;
@@ -51,6 +52,9 @@ export declare const COMPONENT_DEFAULTS: {
51
52
  cols: number;
52
53
  borderWidth: number;
53
54
  borderColor: string;
55
+ headerBackgroundColor: string;
56
+ headerColor: string;
57
+ headerFontSize: number;
54
58
  content: string;
55
59
  };
56
60
  barcode: {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ import PrintDesigner from './components/PrintDesigner';
2
2
  export default PrintDesigner;
3
3
  export { PrintDesigner };
4
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';
5
+ export type { CanvasComponent, CanvasComponentType, PageSettings, GridSettings, TemplateData, DataSource, DataSourceType, PrintDesignerDataSource, TableColumnConfig, DataBinding, DataBindingConfig, } from './types';
6
+ export { getRenderValue, getObjectFromDataSource, getArrayFromDataSource, formatRenderValue, safeParseJSON, getValueByPath, } from './utils/dataHelper';
7
7
  export { useDesignerStore } from './store';