@pdfme/ui 1.1.10 → 1.2.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/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +10 -1
- package/dist/index.js.map +1 -1
- package/dist/types/class.d.ts +4 -0
- package/dist/types/components/Designer/Sidebar/index.d.ts +4 -1
- package/dist/types/components/Designer/index.d.ts +9 -1
- package/dist/types/components/Schemas/SchemaUI.d.ts +1 -1
- package/dist/types/components/Schemas/TextSchema.d.ts +4 -0
- package/dist/types/helper.d.ts +4 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +5 -2
- package/src/components/Designer/Main/Guides.tsx +1 -0
- package/src/components/Designer/Main/index.tsx +17 -3
- package/src/components/Designer/Sidebar/DetailView/ExampleInputEditor.tsx +5 -4
- package/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.tsx +15 -5
- package/src/components/Designer/Sidebar/DetailView/TextPropEditor.tsx +123 -18
- package/src/components/Designer/Sidebar/ListView/index.tsx +1 -0
- package/src/components/Designer/Sidebar/index.tsx +20 -2
- package/src/components/Designer/index.tsx +1 -1
- package/src/components/Preview.tsx +1 -1
- package/src/components/Schemas/SchemaUI.tsx +3 -3
- package/src/components/Schemas/TextSchema.tsx +18 -5
- package/src/helper.ts +17 -19
- package/src/hooks.ts +5 -6
- package/src/i18n.ts +34 -2
- package/src/index.ts +2 -2
- package/tsconfig.json +1 -1
package/src/helper.ts
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
// TODO
|
2
|
-
// 昔のpdfmeのソースからwebpackのビルドに戻す
|
3
|
-
// 多分tree-shakingは動かないかもしれないけど、とりあえず動くようにするべき
|
1
|
+
// TODO Update pdfjs-dist. (might be able to reduce the bundle size.)
|
4
2
|
// @ts-ignore
|
5
3
|
import PDFJSWorker from 'pdfjs-dist/build/pdf.worker.entry.js';
|
6
4
|
import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist/legacy/build/pdf.js';
|
@@ -306,22 +304,22 @@ const sortSchemasList = (template: Template, pageNum: number): SchemaForUI[][] =
|
|
306
304
|
acc.push(
|
307
305
|
template.schemas[i]
|
308
306
|
? Object.entries(template.schemas[i])
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
307
|
+
.sort((a, b) => {
|
308
|
+
const aIndex = (template.columns ?? []).findIndex((c) => c === a[0]);
|
309
|
+
const bIndex = (template.columns ?? []).findIndex((c) => c === b[0]);
|
310
|
+
|
311
|
+
return aIndex > bIndex ? 1 : -1;
|
312
|
+
})
|
313
|
+
.map((e) => {
|
314
|
+
const [key, value] = e;
|
315
|
+
const data = template.sampledata ? template.sampledata[0][key] : '';
|
316
|
+
|
317
|
+
return Object.assign(value, {
|
318
|
+
key,
|
319
|
+
data,
|
320
|
+
id: uuid(),
|
321
|
+
});
|
322
|
+
})
|
325
323
|
: []
|
326
324
|
);
|
327
325
|
|
package/src/hooks.ts
CHANGED
@@ -23,7 +23,8 @@ export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorP
|
|
23
23
|
const [scale, setScale] = useState(0);
|
24
24
|
const [error, setError] = useState<Error | null>(null);
|
25
25
|
|
26
|
-
const init =
|
26
|
+
const init = async (prop: { template: Template; size: Size; }) => {
|
27
|
+
const { template, size } = prop;
|
27
28
|
const _basePdf = await getB64BasePdf(template.basePdf);
|
28
29
|
const pdfBlob = b64toBlob(_basePdf);
|
29
30
|
const _pageSizes = await getPdfPageSizes(pdfBlob);
|
@@ -37,18 +38,16 @@ export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorP
|
|
37
38
|
);
|
38
39
|
|
39
40
|
return { backgrounds: _backgrounds, pageSizes: _pageSizes, scale: _scale };
|
40
|
-
}
|
41
|
-
|
41
|
+
};
|
42
42
|
useEffect(() => {
|
43
|
-
init()
|
43
|
+
init({ template, size })
|
44
44
|
.then(({ pageSizes, scale, backgrounds }) => {
|
45
45
|
setPageSizes(pageSizes), setScale(scale), setBackgrounds(backgrounds);
|
46
46
|
})
|
47
47
|
.catch((e: Error) => {
|
48
|
-
console.error(e);
|
49
48
|
setError(e);
|
50
49
|
});
|
51
|
-
}, [
|
50
|
+
}, [template, size]);
|
52
51
|
|
53
52
|
return { backgrounds, pageSizes, scale: scale * zoomLevel, error };
|
54
53
|
};
|
package/src/i18n.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Lang } from '@pdfme/common';
|
2
|
-
import { DEFAULT_LANG } from './constants';
|
3
2
|
|
4
3
|
type DictEn = typeof dictEn;
|
5
4
|
|
@@ -48,6 +47,39 @@ const dictJa: { [key in keyof DictEn]: string } = {
|
|
48
47
|
bulkUpdateFieldName: '項目名を一括変更',
|
49
48
|
};
|
50
49
|
|
51
|
-
const
|
50
|
+
const dictAr: { [key in keyof DictEn]: string } = {
|
51
|
+
cancel: 'إلغاء',
|
52
|
+
field: 'الحقل',
|
53
|
+
fieldName: 'اسم الحقل',
|
54
|
+
require: 'مطلوب',
|
55
|
+
uniq: 'يجب أن يكون فريداً',
|
56
|
+
inputExample: 'مثال',
|
57
|
+
edit: 'تعديل',
|
58
|
+
plsInputName: 'الرجاء إدخال الاسم',
|
59
|
+
fieldMustUniq: 'يجب أن يكون الحقل فريداً',
|
60
|
+
notUniq: '(غير فريد)',
|
61
|
+
noKeyName: 'لا يوجد اسم للحقل',
|
62
|
+
fieldsList: 'قائمة الحقول',
|
63
|
+
addNewField: 'إضافة حقل جديد',
|
64
|
+
editField: 'تعديل الحقل',
|
65
|
+
type: 'النوع',
|
66
|
+
errorOccurred: 'حدث خطأ',
|
67
|
+
errorBulkUpdateFieldName: 'لا يمكن تنفيذ التغيير لأنه تم تغيير عدد العناصر.',
|
68
|
+
commitBulkUpdateFieldName: 'تنفيذ التغييرات',
|
69
|
+
bulkUpdateFieldName: 'تغيير الأسماء',
|
70
|
+
};
|
71
|
+
|
72
|
+
const i18n = (lang: Lang, key: keyof DictEn) => {
|
73
|
+
switch (lang) {
|
74
|
+
case 'ar':
|
75
|
+
return dictAr[key];
|
76
|
+
|
77
|
+
case 'ja':
|
78
|
+
return dictJa[key];
|
79
|
+
|
80
|
+
default:
|
81
|
+
return dictEn[key];
|
82
|
+
}
|
83
|
+
};
|
52
84
|
|
53
85
|
export const curriedI18n = (lang: Lang) => (key: keyof DictEn) => i18n(lang, key);
|
package/src/index.ts
CHANGED
@@ -4,7 +4,7 @@ import Viewer from './Viewer';
|
|
4
4
|
|
5
5
|
import {
|
6
6
|
BLANK_PDF,
|
7
|
-
|
7
|
+
DEFAULT_FONT_VALUE,
|
8
8
|
isTextSchema,
|
9
9
|
isImageSchema,
|
10
10
|
isBarcodeSchema,
|
@@ -44,7 +44,7 @@ export {
|
|
44
44
|
Viewer,
|
45
45
|
Form,
|
46
46
|
BLANK_PDF,
|
47
|
-
|
47
|
+
DEFAULT_FONT_VALUE,
|
48
48
|
isTextSchema,
|
49
49
|
isImageSchema,
|
50
50
|
isBarcodeSchema,
|
package/tsconfig.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"allowSyntheticDefaultImports": true,
|
14
14
|
"strict": true,
|
15
15
|
"types": ["node", "jest", "@types/jest"],
|
16
|
-
"typeRoots": ["node_modules/@types"],
|
16
|
+
"typeRoots": ["../node_modules/@types", "../common/dist/types/src/index.d.ts"],
|
17
17
|
"sourceMap": true
|
18
18
|
},
|
19
19
|
"baseUrl": ".",
|