print-designer 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +155 -46
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,46 +1,155 @@
1
- # Getting Started with Create React App
2
-
3
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
-
5
- ## Available Scripts
6
-
7
- In the project directory, you can run:
8
-
9
- ### `npm start`
10
-
11
- Runs the app in the development mode.\
12
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
-
14
- The page will reload if you make edits.\
15
- You will also see any lint errors in the console.
16
-
17
- ### `npm test`
18
-
19
- Launches the test runner in the interactive watch mode.\
20
- See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
-
22
- ### `npm run build`
23
-
24
- Builds the app for production to the `build` folder.\
25
- It correctly bundles React in production mode and optimizes the build for the best performance.
26
-
27
- The build is minified and the filenames include the hashes.\
28
- Your app is ready to be deployed!
29
-
30
- See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
-
32
- ### `npm run eject`
33
-
34
- **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
-
36
- If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
-
38
- Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
-
40
- You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
-
42
- ## Learn More
43
-
44
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
-
46
- To learn React, check out the [React documentation](https://reactjs.org/).
1
+ # Print Designer
2
+
3
+ 一个功能强大的 React 报表设计器组件库,支持可视化设计、打印预览和 PDF 导出。
4
+
5
+ ## 特性
6
+
7
+ - 📐 **可视化设计** - 拖拽式设计界面,所见即所得
8
+ - 🎨 **丰富控件** - 支持文本、字段、图片、条码、二维码、线条等多种控件
9
+ - 📊 **带区设计** - 支持页头、页脚、明细带区等报表结构
10
+ - 🖨️ **打印预览** - 实时预览打印效果
11
+ - 📄 **PDF 导出** - 一键导出 PDF 文件
12
+ - 🔧 **高度可定制** - 灵活的属性配置和样式设置
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ npm install print-designer
18
+ ```
19
+
20
+ ## 快速开始
21
+
22
+ ```tsx
23
+ import { BandBoundaryDesigner } from 'print-designer';
24
+
25
+ const dataFields = [
26
+ { name: 'orderNo', label: '订单号', type: 'string' },
27
+ { name: 'customer', label: '客户名称', type: 'string' },
28
+ { name: 'amount', label: '金额', type: 'number' },
29
+ { name: 'products', label: '产品明细', type: 'array', children: [
30
+ { name: 'name', label: '产品名称', type: 'string' },
31
+ { name: 'qty', label: '数量', type: 'number' },
32
+ { name: 'price', label: '单价', type: 'number' },
33
+ ]},
34
+ ];
35
+
36
+ const previewData = {
37
+ orderNo: 'ORD-2024001',
38
+ customer: '测试客户',
39
+ amount: 1000,
40
+ products: [
41
+ { name: '产品A', qty: 10, price: 50 },
42
+ { name: '产品B', qty: 5, price: 100 },
43
+ ],
44
+ };
45
+
46
+ function App() {
47
+ return (
48
+ <BandBoundaryDesigner
49
+ dataFields={dataFields}
50
+ data={previewData}
51
+ onSave={(design) => {
52
+ console.log('保存设计:', design);
53
+ }}
54
+ />
55
+ );
56
+ }
57
+ ```
58
+
59
+ ## API
60
+
61
+ ### BandBoundaryDesigner
62
+
63
+ 主设计器组件。
64
+
65
+ | 属性 | 类型 | 必填 | 说明 |
66
+ |------|------|------|------|
67
+ | dataFields | `DataField[]` | ✓ | 数据字段定义 |
68
+ | data | `Record<string, any>` | | 预览数据 |
69
+ | initialDesign | `Band[]` | | 初始设计数据 |
70
+ | options | `Partial<DesignerOptions>` | | 设计器配置 |
71
+ | onDesignChange | `(bands: Band[]) => void` | | 设计变更回调 |
72
+ | onSave | `(design: any) => void` | | 保存回调 |
73
+ | onPreview | `() => void` | | 预览回调 |
74
+
75
+ ### DataField 类型
76
+
77
+ ```typescript
78
+ interface DataField {
79
+ name: string; // 字段名
80
+ label: string; // 显示名称
81
+ type: 'string' | 'number' | 'date' | 'boolean' | 'array';
82
+ children?: DataField[]; // 子字段(用于明细数据)
83
+ }
84
+ ```
85
+
86
+ ### 导出的组件
87
+
88
+ | 组件 | 说明 |
89
+ |------|------|
90
+ | BandBoundaryDesigner | 主设计器组件 |
91
+ | PrintPreview | 打印预览组件 |
92
+ | ObjectPropertyPanel | 对象属性面板 |
93
+ | BandPropertyPanel | 带区属性面板 |
94
+ | Toolbar | 工具栏 |
95
+ | ColorPicker | 颜色选择器 |
96
+ | FormulaEditor | 公式编辑器 |
97
+
98
+ ### 导出的工具函数
99
+
100
+ ```typescript
101
+ import {
102
+ getBandObjectsRenderData,
103
+ getObjectRenderData,
104
+ evaluateFormula,
105
+ validateFormula,
106
+ } from 'print-designer';
107
+ ```
108
+
109
+ ### 导出的常量
110
+
111
+ ```typescript
112
+ import {
113
+ controlTypes, // 控件类型列表
114
+ defaultBands, // 默认带区配置
115
+ borderStyles, // 边框样式选项
116
+ fontWeightOptions, // 字体粗细选项
117
+ barcodeTypeOptions, // 条码类型选项
118
+ // ... 更多常量
119
+ } from 'print-designer';
120
+ ```
121
+
122
+ ## 支持的控件类型
123
+
124
+ | 控件 | 说明 |
125
+ |------|------|
126
+ | text | 静态文本 |
127
+ | field | 数据字段 |
128
+ | calculated | 计算字段 |
129
+ | image | 图片 |
130
+ | barcode | 条形码 |
131
+ | qrcode | 二维码 |
132
+ | line | 线条 |
133
+ | rectangle | 矩形 |
134
+ | page_number | 页码 |
135
+ | current_date | 当前日期 |
136
+
137
+ ## 浏览器支持
138
+
139
+ - Chrome (推荐)
140
+ - Firefox
141
+ - Safari
142
+ - Edge
143
+
144
+ ## License
145
+
146
+ MIT
147
+
148
+ ## 作者
149
+
150
+ 程宜华 (chengyihua@acbnlink.com)
151
+
152
+ ## 链接
153
+
154
+ - [GitHub](https://github.com/chengyihua/print-designer)
155
+ - [npm](https://www.npmjs.com/package/print-designer)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "print-designer",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "报表设计器 React 组件库",
5
5
  "main": "dist/print-designer.umd.js",
6
6
  "module": "dist/print-designer.es.js",