@pdfme/ui 2.2.0 → 3.0.0-beta.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 (94) hide show
  1. package/README.md +33 -35
  2. package/__mocks__/form-render.js +7 -0
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.LICENSE.txt +42 -4
  5. package/dist/index.js.map +1 -1
  6. package/dist/types/Designer.d.ts +3 -0
  7. package/dist/types/builtInPropPanel.d.ts +3 -0
  8. package/dist/types/builtInRenderer.d.ts +3 -0
  9. package/dist/types/class.d.ts +18 -38
  10. package/dist/types/components/CtlBar/Pager.d.ts +3 -2
  11. package/dist/types/components/CtlBar/Zoom.d.ts +3 -2
  12. package/dist/types/components/CtlBar/index.d.ts +3 -2
  13. package/dist/types/components/Designer/{Main → Canvas}/Guides.d.ts +2 -2
  14. package/dist/types/components/Designer/Canvas/Mask.d.ts +4 -0
  15. package/dist/types/components/Designer/Canvas/Moveable.d.ts +37 -0
  16. package/dist/types/components/Designer/{Main → Canvas}/Selecto.d.ts +2 -1
  17. package/dist/types/components/Designer/{Main → Canvas}/index.d.ts +3 -6
  18. package/dist/types/components/Designer/Sidebar/DetailView/AlignWidget.d.ts +4 -0
  19. package/dist/types/components/Designer/Sidebar/DetailView/WidgetRenderer.d.ts +7 -0
  20. package/dist/types/components/Designer/Sidebar/DetailView/index.d.ts +5 -4
  21. package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableContainer.d.ts +3 -2
  22. package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableItem.d.ts +1 -1
  23. package/dist/types/components/Designer/Sidebar/ListView/index.d.ts +3 -2
  24. package/dist/types/components/Designer/Sidebar/index.d.ts +3 -23
  25. package/dist/types/components/Designer/index.d.ts +6 -107
  26. package/dist/types/components/Divider.d.ts +2 -1
  27. package/dist/types/components/ErrorScreen.d.ts +7 -0
  28. package/dist/types/components/Paper.d.ts +3 -2
  29. package/dist/types/components/Preview.d.ts +10 -2
  30. package/dist/types/components/Renderer.d.ts +10 -0
  31. package/dist/types/components/Root.d.ts +1 -1
  32. package/dist/types/components/Spinner.d.ts +2 -1
  33. package/dist/types/components/UnitPager.d.ts +3 -2
  34. package/dist/types/constants.d.ts +3 -3
  35. package/dist/types/contexts.d.ts +4 -1
  36. package/dist/types/helper.d.ts +4 -46
  37. package/dist/types/hooks.d.ts +2 -2
  38. package/dist/types/i18n.d.ts +4 -2
  39. package/dist/types/index.d.ts +1 -4
  40. package/dist/types/types.d.ts +25 -0
  41. package/package.json +19 -8
  42. package/src/Designer.tsx +69 -21
  43. package/src/Form.tsx +18 -14
  44. package/src/Viewer.tsx +6 -2
  45. package/src/builtInPropPanel.ts +5 -0
  46. package/src/builtInRenderer.ts +5 -0
  47. package/src/class.ts +25 -2
  48. package/src/components/CtlBar/index.tsx +4 -7
  49. package/src/components/Designer/{Main → Canvas}/Guides.tsx +2 -2
  50. package/src/components/Designer/{Main → Canvas}/Moveable.tsx +23 -19
  51. package/src/components/Designer/{Main → Canvas}/index.tsx +77 -30
  52. package/src/components/Designer/Sidebar/DetailView/AlignWidget.tsx +182 -0
  53. package/src/components/Designer/Sidebar/DetailView/WidgetRenderer.tsx +28 -0
  54. package/src/components/Designer/Sidebar/DetailView/index.tsx +153 -22
  55. package/src/components/Designer/Sidebar/ListView/Item.tsx +1 -1
  56. package/src/components/Designer/Sidebar/ListView/SelectableSortableContainer.tsx +6 -6
  57. package/src/components/Designer/Sidebar/ListView/index.tsx +1 -4
  58. package/src/components/Designer/Sidebar/index.tsx +26 -60
  59. package/src/components/Designer/index.tsx +53 -32
  60. package/src/components/{Error.tsx → ErrorScreen.tsx} +2 -2
  61. package/src/components/Paper.tsx +35 -9
  62. package/src/components/Preview.tsx +48 -50
  63. package/src/components/Renderer.tsx +90 -0
  64. package/src/components/Root.tsx +5 -1
  65. package/src/constants.ts +4 -4
  66. package/src/contexts.ts +7 -0
  67. package/src/helper.ts +19 -122
  68. package/src/hooks.ts +6 -5
  69. package/src/i18n.ts +48 -11
  70. package/src/index.ts +1 -76
  71. package/src/types.ts +36 -0
  72. package/tsconfig.json +2 -1
  73. package/webpack.config.js +6 -1
  74. package/dist/types/components/Designer/Main/Mask.d.ts +0 -3
  75. package/dist/types/components/Designer/Main/Moveable.d.ts +0 -31
  76. package/dist/types/components/Designer/Sidebar/DetailView/ExampleInputEditor.d.ts +0 -6
  77. package/dist/types/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +0 -6
  78. package/dist/types/components/Designer/Sidebar/DetailView/TextPropEditor.d.ts +0 -6
  79. package/dist/types/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.d.ts +0 -6
  80. package/dist/types/components/Error.d.ts +0 -6
  81. package/dist/types/components/Schemas/BarcodeSchema.d.ts +0 -15
  82. package/dist/types/components/Schemas/ImageSchema.d.ts +0 -15
  83. package/dist/types/components/Schemas/SchemaUI.d.ts +0 -15
  84. package/dist/types/components/Schemas/TextSchema.d.ts +0 -28
  85. package/src/components/Designer/Sidebar/DetailView/ExampleInputEditor.tsx +0 -85
  86. package/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.tsx +0 -275
  87. package/src/components/Designer/Sidebar/DetailView/TextPropEditor.tsx +0 -357
  88. package/src/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.tsx +0 -87
  89. package/src/components/Schemas/BarcodeSchema.tsx +0 -124
  90. package/src/components/Schemas/ImageSchema.tsx +0 -87
  91. package/src/components/Schemas/SchemaUI.tsx +0 -62
  92. package/src/components/Schemas/TextSchema.tsx +0 -175
  93. /package/src/components/Designer/{Main → Canvas}/Mask.tsx +0 -0
  94. /package/src/components/Designer/{Main → Canvas}/Selecto.tsx +0 -0
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # PDFME
2
+
2
3
  <p>
3
4
  <a href="https://github.com/pdfme/pdfme/blob/master/LICENSE.md">
4
5
  <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="pdfme is released under the MIT license." />
@@ -12,7 +13,7 @@
12
13
  <a href="https://npmcharts.com/compare/@pdfme/ui?minimal=true">
13
14
  <img src="https://img.shields.io/npm/dm/@pdfme/ui.svg" alt="Downloads per month on npm." />
14
15
  </a>
15
- <a href="https://pdfme.com/development-guide#contribution">
16
+ <a href="https://pdfme.com/docs/development-guide#contribution">
16
17
  <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome!" />
17
18
  </a>
18
19
  <a href="https://twitter.com/intent/tweet?text=Awesome+pdf+library%21&url=https://pdfme.com">
@@ -53,7 +54,7 @@ As an example, the author's service [https://labelmake.jp/](https://labelmake.jp
53
54
 
54
55
  ## Installation
55
56
 
56
- The operating requirements should be the node environment `>=16`.
57
+ The operating requirements should be the node environment `>=16`.
57
58
  There are two packages in pdfme, generator and UI.
58
59
 
59
60
  The package for generating PDF can be installed with the following command.
@@ -68,30 +69,34 @@ The packages for using PDF designer, forms and viewers can be installed with the
68
69
  npm i @pdfme/ui @pdfme/common
69
70
  ```
70
71
 
71
- *You must install `@pdfme/common` regardless of which package you use.
72
+ \*You must install `@pdfme/common` regardless of which package you use.
72
73
 
73
74
  The following type, function and classes are available in pdfme.
74
75
 
76
+ `@pdfme/common`
77
+
78
+ - [Template](https://pdfme.com/docs/getting-started#template)
79
+
75
80
  `@pdfme/generator`
76
81
 
77
82
  - [generate](https://pdfme.com/docs/getting-started#generator)
78
- - [Template](https://pdfme.com/docs/getting-started#template)
79
83
 
80
84
  `@pdfme/ui`
81
85
 
82
86
  - [Designer](https://pdfme.com/docs/getting-started#designer)
83
87
  - [Form](https://pdfme.com/docs/getting-started#form)
84
88
  - [Viewer](https://pdfme.com/docs/getting-started#viewer)
85
- - [Template](https://pdfme.com/docs/getting-started#template)
86
89
 
87
90
  If your environment uses webpack, import the necessary items as shown below.
88
91
 
89
92
  ```ts
90
- import { Template, generate } from '@pdfme/generator';
93
+ import type { Template } from '@pdfme/common';
94
+ import { generate } from '@pdfme/generator';
91
95
  ```
92
96
 
93
97
  ```ts
94
- import { Template, Designer, Form, Viewer } from '@pdfme/ui';
98
+ import type { Template } from '@pdfme/common';
99
+ import { Designer, Form, Viewer } from '@pdfme/ui';
95
100
  ```
96
101
 
97
102
  **All objects use `Template`, which will be briefly explained in the next section.**
@@ -113,11 +118,9 @@ The following image is a good illustration of a template.
113
118
  **basePdf** can be given a `string`(base64), `ArrayBuffer`, or `Uint8Array`.
114
119
  A blank A4 PDF can be imported with `BLANK_PDF`. You can use it to check how it works.
115
120
 
116
- **schemas** currently has the following types of data available
117
-
118
- - text
119
- - image
120
- - Various types of barcodes
121
+ **schemas** can only utilize text by default, but you can load images and various barcodes like QR codes as plugins from the `@pdfme/schemas` package.
122
+ Additionally, you can create your own schemas, allowing you to render types other than the ones mentioned above.
123
+ Check detail about [Custom Schemas](https://pdfme.com/docs/custom-schemas) from here
121
124
 
122
125
  Let's take a look at some specific data.
123
126
  (If you are using TypeScript, you can import the Template type.)
@@ -125,8 +128,7 @@ Let's take a look at some specific data.
125
128
  ### Minimal Template
126
129
 
127
130
  ```ts
128
- import { Template, BLANK_PDF } from '@pdfme/generator';
129
- // import { Template, BLANK_PDF } from '@pdfme/ui'; <- Template types and BLANK_PDF can also be imported from @pdfme/ui.
131
+ import { Template, BLANK_PDF } from '@pdfme/common';
130
132
 
131
133
  const template: Template = {
132
134
  basePdf: BLANK_PDF,
@@ -155,8 +157,6 @@ const template: Template = {
155
157
  };
156
158
  ```
157
159
 
158
- [For more information, please refer to the API documentation of the Template type here](https://pdfme.com/docs/api/common/#template).
159
-
160
160
  You can create a template from [Template Design page](https://pdfme.com/template-design). Or, if you want to integrate the template creation feature into your application, check out the [Designer section](https://pdfme.com/docs/getting-started#designer).
161
161
 
162
162
  ## Generator
@@ -166,7 +166,8 @@ The PDF generator function, `generate`, takes 2 arguments of `template` and `inp
166
166
  The code to generate a PDF file using the [template created above](https://pdfme.com/docs/getting-started#sample-template) is shown below.
167
167
 
168
168
  ```ts
169
- import { Template, generate } from '@pdfme/generator';
169
+ import type { Template } from '@pdfme/common';
170
+ import { generate } from '@pdfme/generator';
170
171
 
171
172
  const template: Template = {
172
173
  // skip... Check the Template section.
@@ -187,14 +188,14 @@ generate({ template, inputs }).then((pdf) => {
187
188
 
188
189
  You can create a PDF file like the below.
189
190
 
190
- ![](https://raw.githubusercontent.com/pdfme/pdfme/main/website/static/img/simplePdf.png)
191
+ ![](https://raw.githubusercontent.com/pdfme/pdfme/main/website/static/img/simple-pdf.png)
191
192
 
192
193
  Also, each element in the inputs array corresponds to a page in the PDF, you can create a multi-page PDF file by providing multiple elements of inputs.
193
194
 
194
- [For more information, please refer to the API documentation of the generate function here](https://pdfme.com/docs/api/generator/#generate).
195
-
196
195
  ## UI
197
196
 
197
+ The UI is composed of the Designer, Form, and Viewer classes.
198
+
198
199
  ### Designer
199
200
 
200
201
  The Designer allows you to edit the Template schemas, making it easy for anyone to create Template json objects.
@@ -204,7 +205,8 @@ You can design your own template from [Template Design page](https://pdfme.com/t
204
205
  Let's integrate the designer using the template created above as the default template.
205
206
 
206
207
  ```ts
207
- import { Template, Designer } from '@pdfme/ui';
208
+ import type { Template } from '@pdfme/common';
209
+ import { Designer } from '@pdfme/ui';
208
210
 
209
211
  const domContainer = document.getElementById('container');
210
212
  const template: Template = {
@@ -228,8 +230,6 @@ The designer instance can be manipulated with the following methods.
228
230
  - `onSaveTemplate`
229
231
  - `destroy`
230
232
 
231
- [For more information, please refer to the API documentation of the Designer class here](https://pdfme.com/docs/api/ui/classes/Designer).
232
-
233
233
  ### Form
234
234
 
235
235
  You can use templates to create forms and PDF viewers.
@@ -237,7 +237,8 @@ You can use templates to create forms and PDF viewers.
237
237
  The Form creates a UI for the user to enter schemas based on the template.
238
238
 
239
239
  ```ts
240
- import { Template, Form } from '@pdfme/ui';
240
+ import type { Template } from '@pdfme/common';
241
+ import { Form } from '@pdfme/ui';
241
242
 
242
243
  const domContainer = document.getElementById('container');
243
244
  const template: Template = {
@@ -262,8 +263,6 @@ generate({ template, inputs: form.getInputs() }).then((pdf) => {
262
263
  });
263
264
  ```
264
265
 
265
- [For more information, please refer to the API documentation of the Form class here](https://pdfme.com/docs/api/ui/classes/Form).
266
-
267
266
  ### Viewer
268
267
 
269
268
  Viewing a PDF file in a mobile browser is a pain, because it doesn't display well in an iframe.
@@ -273,7 +272,8 @@ The Viewer is a byproduct of the Form development process, but it allows you to
273
272
  Using the Viewer is basically the same as using the Form, except that user cannot edit it.
274
273
 
275
274
  ```ts
276
- import { Template, Viewer } from '@pdfme/ui';
275
+ import type { Template } from '@pdfme/common';
276
+ import { Viewer } from '@pdfme/ui';
277
277
 
278
278
  const domContainer = document.getElementById('container');
279
279
  const template: Template = {
@@ -286,20 +286,18 @@ const viewer = new Viewer({ domContainer, template, inputs });
286
286
 
287
287
  ![](https://raw.githubusercontent.com/pdfme/pdfme/main/website/static/img/viewer.png)
288
288
 
289
- [For more information, please refer to the API documentation of the Viewer class here](https://pdfme.com/docs/api/ui/classes/Viewer).
290
-
291
289
  ## Special Thanks
292
290
 
293
- - [pdf-lib](https://pdf-lib.js.org/):
291
+ - [pdf-lib](https://pdf-lib.js.org/): Used in PDF generation.
294
292
  - [fontkit](https://github.com/foliojs/fontkit): Used in font rendering.
295
293
  - [PDF.js](https://mozilla.github.io/pdf.js/): Used in PDF viewing.
296
294
  - [React](https://reactjs.org/): Used in building the UI.
295
+ - [form-render](https://xrender.fun/form-render): Used in building the UI.
296
+ - [antd](https://ant.design/): Used in building the UI.
297
297
  - [react-moveable](https://daybrush.com/moveable/), [react-selecto](https://github.com/daybrush/selecto), [@scena/react-guides](https://daybrush.com/guides/): Used in Designer UI.
298
298
  - [dnd-kit](https://github.com/clauderic/dnd-kit): Used in Designer UI.
299
- - [bwip-js](https://github.com/metafloor/bwip-js): Used in barcode generation.
300
- - [zod](https://github.com/colinhacks/zod): Used in Validation.
301
299
 
302
- I definitely could not have created pdfme without these libraries. I am grateful to the developers of these libraries.
300
+ I definitely could not have created pdfme without these libraries. I am grateful to the developers of these libraries.
303
301
 
304
- If you want to contribute to pdfme, please check the [Development Guide](https://pdfme.com/development-guide) page.
305
- We look forward to your contribution!
302
+ If you want to contribute to pdfme, please check the [Development Guide](https://pdfme.com/docs/development-guide) page.
303
+ We look forward to your contribution!
@@ -0,0 +1,7 @@
1
+ const useForm = jest.fn();
2
+ const FormRender = jest.fn();
3
+
4
+ module.exports = {
5
+ useForm,
6
+ default: FormRender,
7
+ };