@pdfme/ui 3.0.1 → 3.1.0-dev.1
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/__mocks__/assetsTransformer.js +7 -0
- package/__mocks__/pdfjs-dist.js +15 -0
- package/dist/__vite-browser-external-jWVCDlBL.js +4 -0
- package/dist/index.js +1115 -3
- package/dist/path2d-polyfill.esm-yIGK7UQJ.js +214 -0
- package/dist/style.css +1 -0
- package/dist/types/class.d.ts +3 -3
- package/dist/types/components/AppContextProvider.d.ts +11 -0
- package/dist/types/components/{CtlBar/index.d.ts → CtlBar.d.ts} +2 -2
- package/dist/types/components/Designer/Canvas/Selecto.d.ts +3 -2
- package/dist/types/components/Designer/Sidebar/DetailView/AlignWidget.d.ts +1 -1
- package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableContainer.d.ts +1 -1
- package/dist/types/components/Renderer.d.ts +1 -1
- package/dist/types/components/UnitPager.d.ts +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/contexts.d.ts +46 -4
- package/dist/types/helper.d.ts +2 -1
- package/dist/types/hooks.d.ts +19 -2
- package/dist/types/i18n.d.ts +3 -27
- package/dist/types/theme.d.ts +2 -0
- package/package.json +17 -11
- package/src/Designer.tsx +27 -53
- package/src/Form.tsx +22 -23
- package/src/Viewer.tsx +10 -11
- package/src/class.ts +5 -5
- package/src/components/AppContextProvider.tsx +63 -0
- package/src/components/CtlBar.tsx +125 -0
- package/src/components/Designer/Canvas/Guides.tsx +18 -23
- package/src/components/Designer/Canvas/Mask.tsx +2 -1
- package/src/components/Designer/Canvas/Moveable.tsx +60 -60
- package/src/components/Designer/Canvas/Selecto.tsx +33 -20
- package/src/components/Designer/Canvas/index.tsx +21 -15
- package/src/components/Designer/Sidebar/DetailView/AlignWidget.tsx +53 -89
- package/src/components/Designer/Sidebar/DetailView/index.tsx +41 -30
- package/src/components/Designer/Sidebar/ListView/Item.tsx +30 -19
- package/src/components/Designer/Sidebar/ListView/SelectableSortableContainer.tsx +9 -6
- package/src/components/Designer/Sidebar/ListView/SelectableSortableItem.tsx +4 -1
- package/src/components/Designer/Sidebar/ListView/index.tsx +76 -71
- package/src/components/Designer/Sidebar/index.tsx +25 -49
- package/src/components/Designer/index.tsx +24 -82
- package/src/components/ErrorScreen.tsx +13 -11
- package/src/components/Preview.tsx +5 -2
- package/src/components/Renderer.tsx +10 -6
- package/src/components/Root.tsx +2 -8
- package/src/components/Spinner.tsx +12 -31
- package/src/components/UnitPager.tsx +72 -55
- package/src/constants.ts +2 -0
- package/src/contexts.ts +4 -5
- package/src/helper.ts +8 -5
- package/src/hooks.ts +136 -3
- package/src/i18n.ts +168 -59
- package/src/theme.ts +20 -0
- package/tsconfig.json +35 -13
- package/vite.config.ts +27 -0
- package/dist/index.js.LICENSE.txt +0 -142
- package/dist/index.js.map +0 -1
- package/dist/types/components/CtlBar/Pager.d.ts +0 -8
- package/dist/types/components/CtlBar/Zoom.d.ts +0 -7
- package/dist/types/components/Divider.d.ts +0 -3
- package/src/components/CtlBar/Pager.tsx +0 -53
- package/src/components/CtlBar/Zoom.tsx +0 -56
- package/src/components/CtlBar/index.tsx +0 -46
- package/src/components/Divider.tsx +0 -7
- package/webpack.config.js +0 -40
@@ -1,34 +1,36 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
3
|
-
ChevronLeftIcon,
|
4
|
-
ChevronDoubleLeftIcon,
|
5
|
-
ChevronRightIcon,
|
6
|
-
ChevronDoubleRightIcon,
|
7
|
-
} from '@heroicons/react/24/outline';
|
8
2
|
import { Size } from '@pdfme/common';
|
3
|
+
import { theme, Typography, Button } from 'antd';
|
4
|
+
import {
|
5
|
+
LeftOutlined,
|
6
|
+
RightOutlined,
|
7
|
+
DoubleLeftOutlined,
|
8
|
+
DoubleRightOutlined,
|
9
|
+
} from '@ant-design/icons';
|
10
|
+
const { Text } = Typography;
|
11
|
+
|
12
|
+
type UnitButtonProps = {
|
13
|
+
type: 'left' | 'right' | 'doubleLeft' | 'doubleRight';
|
14
|
+
onClick: () => void;
|
15
|
+
disabled: boolean;
|
16
|
+
textStyle: { color: string; fontSize: number; margin: number };
|
17
|
+
};
|
9
18
|
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
backgroundColor: '#777777bd',
|
16
|
-
borderRadius: 2,
|
17
|
-
padding: '0.5rem',
|
18
|
-
display: 'flex',
|
19
|
-
alignItems: 'center',
|
20
|
-
justifyContent: 'space-around',
|
21
|
-
boxSizing: 'border-box',
|
22
|
-
width: 110,
|
23
|
-
height: buttonHeight,
|
19
|
+
const icons = {
|
20
|
+
left: LeftOutlined,
|
21
|
+
right: RightOutlined,
|
22
|
+
doubleLeft: DoubleLeftOutlined,
|
23
|
+
doubleRight: DoubleRightOutlined,
|
24
24
|
};
|
25
25
|
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
const UnitButton: React.FC<UnitButtonProps> = ({ type, onClick, disabled, textStyle }) => {
|
27
|
+
const Icon = icons[type];
|
28
|
+
|
29
|
+
return (
|
30
|
+
<Button type="text" onClick={onClick} disabled={disabled}>
|
31
|
+
<Icon style={{ color: textStyle.color }} />
|
32
|
+
</Button>
|
33
|
+
);
|
32
34
|
};
|
33
35
|
|
34
36
|
type Props = {
|
@@ -39,7 +41,27 @@ type Props = {
|
|
39
41
|
};
|
40
42
|
|
41
43
|
const UnitPager = ({ size, unitCursor, unitNum, setUnitCursor }: Props) => {
|
42
|
-
if (unitNum <= 1) return
|
44
|
+
if (unitNum <= 1) return null;
|
45
|
+
|
46
|
+
const { token } = theme.useToken();
|
47
|
+
|
48
|
+
const buttonWrapStyle: React.CSSProperties = {
|
49
|
+
pointerEvents: 'initial',
|
50
|
+
position: 'sticky',
|
51
|
+
zIndex: 1,
|
52
|
+
display: 'flex',
|
53
|
+
alignItems: 'center',
|
54
|
+
boxSizing: 'border-box',
|
55
|
+
height: 40,
|
56
|
+
padding: token.paddingSM,
|
57
|
+
borderRadius: token.borderRadius,
|
58
|
+
backgroundColor: token.colorBgMask,
|
59
|
+
};
|
60
|
+
const textStyle = {
|
61
|
+
color: token.colorWhite,
|
62
|
+
fontSize: token.fontSize,
|
63
|
+
margin: token.marginXS,
|
64
|
+
};
|
43
65
|
|
44
66
|
return (
|
45
67
|
<div style={{ position: 'absolute', ...size }}>
|
@@ -48,54 +70,49 @@ const UnitPager = ({ size, unitCursor, unitNum, setUnitCursor }: Props) => {
|
|
48
70
|
position: 'sticky',
|
49
71
|
width: '100%',
|
50
72
|
zIndex: 1,
|
51
|
-
|
52
|
-
top: `calc(50% - ${buttonHeight / 2}px)`,
|
73
|
+
top: `calc(50% - ${(buttonWrapStyle.height as number) / 2}px)`,
|
53
74
|
display: 'flex',
|
54
75
|
alignItems: 'center',
|
55
76
|
}}
|
56
77
|
>
|
57
78
|
{unitCursor > 0 && (
|
58
79
|
<div style={{ left: '1rem', marginLeft: '1rem', ...buttonWrapStyle }}>
|
59
|
-
<
|
60
|
-
|
61
|
-
disabled={unitCursor <= 0}
|
80
|
+
<UnitButton
|
81
|
+
type="doubleLeft"
|
62
82
|
onClick={() => setUnitCursor(0)}
|
63
|
-
>
|
64
|
-
<ChevronDoubleLeftIcon width={20} height={20} color={'#fff'} />
|
65
|
-
</button>
|
66
|
-
<button
|
67
|
-
style={{ paddingLeft: '0.5rem', ...btnStyle }}
|
68
83
|
disabled={unitCursor <= 0}
|
84
|
+
textStyle={textStyle}
|
85
|
+
/>
|
86
|
+
<UnitButton
|
87
|
+
type="left"
|
69
88
|
onClick={() => setUnitCursor(unitCursor - 1)}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<strong style={
|
89
|
+
disabled={unitCursor <= 0}
|
90
|
+
textStyle={textStyle}
|
91
|
+
/>
|
92
|
+
<Text strong style={textStyle}>
|
74
93
|
{unitCursor + 1}/{unitNum}
|
75
|
-
</
|
94
|
+
</Text>
|
76
95
|
</div>
|
77
96
|
)}
|
78
97
|
{unitCursor + 1 < unitNum && (
|
79
98
|
<div
|
80
99
|
style={{ right: '1rem', marginLeft: 'auto', marginRight: '1rem', ...buttonWrapStyle }}
|
81
100
|
>
|
82
|
-
<strong style={
|
101
|
+
<Text strong style={textStyle}>
|
83
102
|
{unitCursor + 1}/{unitNum}
|
84
|
-
</
|
85
|
-
<
|
86
|
-
|
87
|
-
disabled={unitCursor + 1 >= unitNum}
|
103
|
+
</Text>
|
104
|
+
<UnitButton
|
105
|
+
type="right"
|
88
106
|
onClick={() => setUnitCursor(unitCursor + 1)}
|
89
|
-
>
|
90
|
-
<ChevronRightIcon width={20} height={20} color={'#fff'} />
|
91
|
-
</button>
|
92
|
-
<button
|
93
|
-
style={{ paddingRight: '0.5rem', ...btnStyle }}
|
94
107
|
disabled={unitCursor + 1 >= unitNum}
|
108
|
+
textStyle={textStyle}
|
109
|
+
/>
|
110
|
+
<UnitButton
|
111
|
+
type="doubleRight"
|
95
112
|
onClick={() => setUnitCursor(unitNum - 1)}
|
96
|
-
|
97
|
-
|
98
|
-
|
113
|
+
disabled={unitCursor + 1 >= unitNum}
|
114
|
+
textStyle={textStyle}
|
115
|
+
/>
|
99
116
|
</div>
|
100
117
|
)}
|
101
118
|
</div>
|
package/src/constants.ts
CHANGED
package/src/contexts.ts
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
import { createContext } from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { getDefaultFont, Plugins } from '@pdfme/common';
|
2
|
+
import { i18n } from './i18n';
|
3
|
+
import { getDefaultFont, Plugins, UIOptions } from '@pdfme/common';
|
5
4
|
import { builtInPlugins } from '@pdfme/schemas';
|
6
5
|
|
7
|
-
export const I18nContext = createContext(
|
6
|
+
export const I18nContext = createContext(i18n);
|
8
7
|
|
9
8
|
export const FontContext = createContext(getDefaultFont());
|
10
9
|
|
11
10
|
export const PluginsRegistry = createContext<Plugins>(builtInPlugins);
|
12
11
|
|
13
|
-
export const OptionsContext = createContext({});
|
12
|
+
export const OptionsContext = createContext<UIOptions>({});
|
package/src/helper.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist';
|
2
2
|
// @ts-ignore
|
3
|
-
import
|
4
|
-
|
5
|
-
|
3
|
+
import * as pdfWorker from 'pdfjs-dist/build/pdf.worker.mjs';
|
4
|
+
GlobalWorkerOptions.workerSrc = pdfWorker;
|
5
|
+
|
6
6
|
import hotkeys from 'hotkeys-js';
|
7
7
|
import {
|
8
8
|
ZOOM,
|
@@ -14,7 +14,7 @@ import {
|
|
14
14
|
Schema,
|
15
15
|
Size,
|
16
16
|
} from '@pdfme/common';
|
17
|
-
import { RULER_HEIGHT } from './constants';
|
17
|
+
import { RULER_HEIGHT } from './constants.js';
|
18
18
|
|
19
19
|
export const uuid = () =>
|
20
20
|
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
@@ -440,3 +440,6 @@ export const getPagesScrollTopByIndex = (
|
|
440
440
|
.slice(0, index)
|
441
441
|
.reduce((acc, cur) => acc + (cur.height * ZOOM + RULER_HEIGHT * scale) * scale, 0);
|
442
442
|
};
|
443
|
+
|
444
|
+
export const getSidebarContentHeight = (sidebarHeight: number) =>
|
445
|
+
sidebarHeight - RULER_HEIGHT - RULER_HEIGHT / 2 - 115;
|
package/src/hooks.ts
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
import { RefObject, useRef, useState, useCallback, useEffect } from 'react';
|
2
|
-
import { ZOOM, Template, Size, getB64BasePdf } from '@pdfme/common';
|
3
|
-
|
4
|
-
import {
|
2
|
+
import { ZOOM, Template, Size, getB64BasePdf, SchemaForUI, ChangeSchemas } from '@pdfme/common';
|
3
|
+
|
4
|
+
import {
|
5
|
+
fmtTemplate,
|
6
|
+
uuid,
|
7
|
+
cloneDeep,
|
8
|
+
getUniqSchemaKey,
|
9
|
+
moveCommandToChangeSchemasArg,
|
10
|
+
pdf2Pngs,
|
11
|
+
getPdfPageSizes,
|
12
|
+
b64toBlob,
|
13
|
+
initShortCuts,
|
14
|
+
destroyShortCuts,
|
15
|
+
} from './helper.js';
|
16
|
+
import { RULER_HEIGHT } from './constants.js';
|
5
17
|
|
6
18
|
export const usePrevious = <T>(value: T) => {
|
7
19
|
const ref = useRef<T | null>(null);
|
@@ -115,3 +127,124 @@ export const useMountStatus = () => {
|
|
115
127
|
|
116
128
|
return isMounted;
|
117
129
|
};
|
130
|
+
|
131
|
+
interface UseInitEventsParams {
|
132
|
+
pageCursor: number;
|
133
|
+
pageSizes: Size[];
|
134
|
+
activeElements: HTMLElement[];
|
135
|
+
template: Template;
|
136
|
+
schemasList: SchemaForUI[][];
|
137
|
+
changeSchemas: ChangeSchemas;
|
138
|
+
commitSchemas: (newSchemas: SchemaForUI[]) => void;
|
139
|
+
removeSchemas: (ids: string[]) => void;
|
140
|
+
onSaveTemplate: (t: Template) => void;
|
141
|
+
past: React.MutableRefObject<SchemaForUI[][]>;
|
142
|
+
future: React.MutableRefObject<SchemaForUI[][]>;
|
143
|
+
setSchemasList: React.Dispatch<React.SetStateAction<SchemaForUI[][]>>;
|
144
|
+
onEdit: (targets: HTMLElement[]) => void;
|
145
|
+
onEditEnd: () => void;
|
146
|
+
}
|
147
|
+
|
148
|
+
export const useInitEvents = ({
|
149
|
+
pageCursor,
|
150
|
+
pageSizes,
|
151
|
+
activeElements,
|
152
|
+
template,
|
153
|
+
schemasList,
|
154
|
+
changeSchemas,
|
155
|
+
commitSchemas,
|
156
|
+
removeSchemas,
|
157
|
+
onSaveTemplate,
|
158
|
+
past,
|
159
|
+
future,
|
160
|
+
setSchemasList,
|
161
|
+
onEdit,
|
162
|
+
onEditEnd,
|
163
|
+
}: UseInitEventsParams) => {
|
164
|
+
const copiedSchemas = useRef<SchemaForUI[] | null>(null);
|
165
|
+
|
166
|
+
const modifiedTemplate = fmtTemplate(template, schemasList);
|
167
|
+
|
168
|
+
const initEvents = useCallback(() => {
|
169
|
+
const getActiveSchemas = () => {
|
170
|
+
const ids = activeElements.map((ae) => ae.id);
|
171
|
+
|
172
|
+
return schemasList[pageCursor].filter((s) => ids.includes(s.id));
|
173
|
+
};
|
174
|
+
const timeTravel = (mode: 'undo' | 'redo') => {
|
175
|
+
const isUndo = mode === 'undo';
|
176
|
+
const stack = isUndo ? past : future;
|
177
|
+
if (stack.current.length <= 0) return;
|
178
|
+
(isUndo ? future : past).current.push(cloneDeep(schemasList[pageCursor]));
|
179
|
+
const s = cloneDeep(schemasList);
|
180
|
+
s[pageCursor] = stack.current.pop()!;
|
181
|
+
setSchemasList(s);
|
182
|
+
};
|
183
|
+
initShortCuts({
|
184
|
+
move: (command, isShift) => {
|
185
|
+
const pageSize = pageSizes[pageCursor];
|
186
|
+
const activeSchemas = getActiveSchemas();
|
187
|
+
const arg = moveCommandToChangeSchemasArg({ command, activeSchemas, pageSize, isShift });
|
188
|
+
changeSchemas(arg);
|
189
|
+
},
|
190
|
+
|
191
|
+
copy: () => {
|
192
|
+
const activeSchemas = getActiveSchemas();
|
193
|
+
if (activeSchemas.length === 0) return;
|
194
|
+
copiedSchemas.current = activeSchemas;
|
195
|
+
},
|
196
|
+
paste: () => {
|
197
|
+
if (!copiedSchemas.current || copiedSchemas.current.length === 0) return;
|
198
|
+
const schema = schemasList[pageCursor];
|
199
|
+
const stackUniqSchemaKeys: string[] = [];
|
200
|
+
const pasteSchemas = copiedSchemas.current.map((cs) => {
|
201
|
+
const id = uuid();
|
202
|
+
const key = getUniqSchemaKey({ copiedSchemaKey: cs.key, schema, stackUniqSchemaKeys });
|
203
|
+
const { height, width, position: p } = cs;
|
204
|
+
const ps = pageSizes[pageCursor];
|
205
|
+
const position = {
|
206
|
+
x: p.x + 10 > ps.width - width ? ps.width - width : p.x + 10,
|
207
|
+
y: p.y + 10 > ps.height - height ? ps.height - height : p.y + 10,
|
208
|
+
};
|
209
|
+
|
210
|
+
return Object.assign(cloneDeep(cs), { id, key, position });
|
211
|
+
});
|
212
|
+
commitSchemas(schemasList[pageCursor].concat(pasteSchemas));
|
213
|
+
onEdit(pasteSchemas.map((s) => document.getElementById(s.id)!));
|
214
|
+
copiedSchemas.current = pasteSchemas;
|
215
|
+
},
|
216
|
+
redo: () => timeTravel('redo'),
|
217
|
+
undo: () => timeTravel('undo'),
|
218
|
+
save: () => onSaveTemplate && onSaveTemplate(modifiedTemplate),
|
219
|
+
remove: () => removeSchemas(getActiveSchemas().map((s) => s.id)),
|
220
|
+
esc: onEditEnd,
|
221
|
+
selectAll: () => onEdit(schemasList[pageCursor].map((s) => document.getElementById(s.id)!)),
|
222
|
+
});
|
223
|
+
}, [
|
224
|
+
activeElements,
|
225
|
+
pageCursor,
|
226
|
+
pageSizes,
|
227
|
+
changeSchemas,
|
228
|
+
commitSchemas,
|
229
|
+
schemasList,
|
230
|
+
onSaveTemplate,
|
231
|
+
modifiedTemplate,
|
232
|
+
removeSchemas,
|
233
|
+
past,
|
234
|
+
future,
|
235
|
+
setSchemasList,
|
236
|
+
copiedSchemas,
|
237
|
+
onEdit,
|
238
|
+
onEditEnd,
|
239
|
+
]);
|
240
|
+
|
241
|
+
const destroyEvents = useCallback(() => {
|
242
|
+
destroyShortCuts();
|
243
|
+
}, []);
|
244
|
+
|
245
|
+
useEffect(() => {
|
246
|
+
initEvents();
|
247
|
+
|
248
|
+
return destroyEvents;
|
249
|
+
}, [initEvents, destroyEvents]);
|
250
|
+
};
|
package/src/i18n.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
import { Lang } from '@pdfme/common';
|
1
|
+
import type { Lang, Dict } from '@pdfme/common';
|
2
|
+
import { DEFAULT_LANG } from './constants.js';
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
const dictEn = {
|
4
|
+
const dictEn: { [key in keyof Dict]: string } = {
|
6
5
|
cancel: 'Cancel',
|
7
6
|
field: 'field',
|
8
7
|
fieldName: 'Name',
|
9
|
-
|
10
|
-
|
8
|
+
align: 'Align',
|
9
|
+
width: 'Width',
|
10
|
+
height: 'Height',
|
11
|
+
rotate: 'Rotate',
|
11
12
|
edit: 'Edit',
|
12
13
|
plsInputName: 'Please input name',
|
13
14
|
fieldMustUniq: 'Name of field is not unique',
|
@@ -22,17 +23,37 @@ const dictEn = {
|
|
22
23
|
'Cannot commit the change because the number of items has been changed.',
|
23
24
|
commitBulkUpdateFieldName: 'Commit Changes',
|
24
25
|
bulkUpdateFieldName: 'Bulk update field names',
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
'schemas.textColor': 'Text Color',
|
27
|
+
'schemas.bgColor': 'Background Color',
|
28
|
+
'schemas.horizontal': 'Horizontal',
|
29
|
+
'schemas.vertical': 'Vertical',
|
30
|
+
'schemas.left': 'Left',
|
31
|
+
'schemas.center': 'Center',
|
32
|
+
'schemas.right': 'Right',
|
33
|
+
'schemas.top': 'Top',
|
34
|
+
'schemas.middle': 'Middle',
|
35
|
+
'schemas.bottom': 'Bottom',
|
36
|
+
'schemas.text.fontName': 'Font Name',
|
37
|
+
'schemas.text.size': 'Size',
|
38
|
+
'schemas.text.spacing': 'Spacing',
|
39
|
+
'schemas.text.textAlign': 'Text Align',
|
40
|
+
'schemas.text.verticalAlign': 'Vertical Align',
|
41
|
+
'schemas.text.lineHeight': 'Line Height',
|
42
|
+
'schemas.text.min': 'Min',
|
43
|
+
'schemas.text.max': 'Max',
|
44
|
+
'schemas.text.fit': 'Fit',
|
45
|
+
'schemas.text.dynamicFontSize': 'Dynamic Font Size',
|
46
|
+
'schemas.barcodes.barColor': 'Bar Color',
|
28
47
|
};
|
29
48
|
|
30
|
-
const dictJa: { [key in keyof
|
49
|
+
const dictJa: { [key in keyof Dict]: string } = {
|
31
50
|
cancel: 'キャンセル',
|
32
51
|
field: '入力項目',
|
33
52
|
fieldName: '項目名',
|
34
|
-
|
35
|
-
|
53
|
+
align: '整列',
|
54
|
+
width: '幅',
|
55
|
+
height: '高さ',
|
56
|
+
rotate: '回転',
|
36
57
|
edit: '編集する',
|
37
58
|
plsInputName: '項目名を入力してください',
|
38
59
|
fieldMustUniq: '他の入力項目名と被っています',
|
@@ -46,17 +67,37 @@ const dictJa: { [key in keyof DictEn]: string } = {
|
|
46
67
|
errorBulkUpdateFieldName: '項目数が変更されているため変更をコミットできません。',
|
47
68
|
commitBulkUpdateFieldName: '変更を反映',
|
48
69
|
bulkUpdateFieldName: '項目名を一括変更',
|
49
|
-
|
50
|
-
|
51
|
-
|
70
|
+
'schemas.textColor': 'テキストの色',
|
71
|
+
'schemas.bgColor': '背景色',
|
72
|
+
'schemas.horizontal': '水平',
|
73
|
+
'schemas.vertical': '垂直',
|
74
|
+
'schemas.left': '左',
|
75
|
+
'schemas.center': '中央',
|
76
|
+
'schemas.right': '右',
|
77
|
+
'schemas.top': '上',
|
78
|
+
'schemas.middle': '中間',
|
79
|
+
'schemas.bottom': '下',
|
80
|
+
'schemas.text.fontName': 'フォント名',
|
81
|
+
'schemas.text.size': 'サイズ',
|
82
|
+
'schemas.text.spacing': '間隔',
|
83
|
+
'schemas.text.textAlign': 'テキストの揃え',
|
84
|
+
'schemas.text.verticalAlign': '垂直方向の揃え',
|
85
|
+
'schemas.text.lineHeight': '行の高さ',
|
86
|
+
'schemas.text.min': '最小',
|
87
|
+
'schemas.text.max': '最大',
|
88
|
+
'schemas.text.fit': 'フィット',
|
89
|
+
'schemas.text.dynamicFontSize': '動的フォントサイズ',
|
90
|
+
'schemas.barcodes.barColor': 'バーの色',
|
52
91
|
};
|
53
92
|
|
54
|
-
const dictAr: { [key in keyof
|
93
|
+
const dictAr: { [key in keyof Dict]: string } = {
|
55
94
|
cancel: 'إلغاء',
|
56
95
|
field: 'الحقل',
|
57
96
|
fieldName: 'اسم الحقل',
|
58
|
-
|
59
|
-
|
97
|
+
align: 'محاذاة',
|
98
|
+
width: 'العرض',
|
99
|
+
height: 'الارتفاع',
|
100
|
+
rotate: 'تدوير',
|
60
101
|
edit: 'تعديل',
|
61
102
|
plsInputName: 'الرجاء إدخال الاسم',
|
62
103
|
fieldMustUniq: 'يجب أن يكون الحقل فريداً',
|
@@ -70,17 +111,37 @@ const dictAr: { [key in keyof DictEn]: string } = {
|
|
70
111
|
errorBulkUpdateFieldName: 'لا يمكن تنفيذ التغيير لأنه تم تغيير عدد العناصر.',
|
71
112
|
commitBulkUpdateFieldName: 'تنفيذ التغييرات',
|
72
113
|
bulkUpdateFieldName: 'تغيير الأسماء',
|
73
|
-
|
74
|
-
|
75
|
-
|
114
|
+
'schemas.textColor': 'لون الخط',
|
115
|
+
'schemas.bgColor': 'لون الخلفية',
|
116
|
+
'schemas.horizontal': 'أفقي',
|
117
|
+
'schemas.vertical': 'عمودي',
|
118
|
+
'schemas.left': 'يسار',
|
119
|
+
'schemas.center': 'مركز',
|
120
|
+
'schemas.right': 'يمين',
|
121
|
+
'schemas.top': 'أعلى',
|
122
|
+
'schemas.middle': 'وسط',
|
123
|
+
'schemas.bottom': 'أسفل',
|
124
|
+
'schemas.text.fontName': 'اسم الخط',
|
125
|
+
'schemas.text.size': 'الحجم',
|
126
|
+
'schemas.text.spacing': 'التباعد',
|
127
|
+
'schemas.text.textAlign': 'محاذاة النص',
|
128
|
+
'schemas.text.verticalAlign': 'محاذاة عمودية',
|
129
|
+
'schemas.text.lineHeight': 'ارتفاع السطر',
|
130
|
+
'schemas.text.min': 'الحد الأدنى',
|
131
|
+
'schemas.text.max': 'الحد الأقصى',
|
132
|
+
'schemas.text.fit': 'ملاءمة',
|
133
|
+
'schemas.text.dynamicFontSize': 'حجم الخط الديناميكي',
|
134
|
+
'schemas.barcodes.barColor': 'لون الشريط',
|
76
135
|
};
|
77
136
|
|
78
|
-
const dictTh: { [key in keyof
|
137
|
+
const dictTh: { [key in keyof Dict]: string } = {
|
79
138
|
cancel: 'ยกเลิก',
|
80
139
|
field: 'ฟิลด์',
|
81
140
|
fieldName: 'ชื่อฟิลด์',
|
82
|
-
|
83
|
-
|
141
|
+
align: 'จัดเรียง',
|
142
|
+
width: 'ความกว้าง',
|
143
|
+
height: 'ความสูง',
|
144
|
+
rotate: 'หมุน',
|
84
145
|
edit: 'แก้ไข',
|
85
146
|
plsInputName: 'กรุณาใส่ชื่อ',
|
86
147
|
fieldMustUniq: 'ชื่อฟิลด์ต้องไม่ซ้ำกัน',
|
@@ -94,17 +155,37 @@ const dictTh: { [key in keyof DictEn]: string } = {
|
|
94
155
|
errorBulkUpdateFieldName: 'ไม่สามารถยืนยันการแก้ไขได้เนื่องจากจำนวนรายการมีการเปลี่ยนแปลง',
|
95
156
|
commitBulkUpdateFieldName: 'ยืนยันการแก้ไข',
|
96
157
|
bulkUpdateFieldName: 'แก้ไขชื่อฟิลด์เป็นชุด',
|
97
|
-
|
98
|
-
|
99
|
-
|
158
|
+
'schemas.textColor': 'สีข้อความ',
|
159
|
+
'schemas.bgColor': 'สีพื้นหลัง',
|
160
|
+
'schemas.horizontal': 'แนวนอน',
|
161
|
+
'schemas.vertical': 'แนวตั้ง',
|
162
|
+
'schemas.left': 'ซ้าย',
|
163
|
+
'schemas.center': 'ตรงกลาง',
|
164
|
+
'schemas.right': 'ขวา',
|
165
|
+
'schemas.top': 'ด้านบน',
|
166
|
+
'schemas.middle': 'ตรงกลาง',
|
167
|
+
'schemas.bottom': 'ด้านล่าง',
|
168
|
+
'schemas.text.fontName': 'ชื่อแบบอักษร',
|
169
|
+
'schemas.text.size': 'ขนาด',
|
170
|
+
'schemas.text.spacing': 'ระยะห่าง',
|
171
|
+
'schemas.text.textAlign': 'จัดแนวข้อความ',
|
172
|
+
'schemas.text.verticalAlign': 'จัดแนวแนวตั้ง',
|
173
|
+
'schemas.text.lineHeight': 'ความสูงของบรรทัด',
|
174
|
+
'schemas.text.min': 'ต่ำสุด',
|
175
|
+
'schemas.text.max': 'สูงสุด',
|
176
|
+
'schemas.text.fit': 'พอดี',
|
177
|
+
'schemas.text.dynamicFontSize': 'ขนาดตัวอักษรแบบไดนามิก',
|
178
|
+
'schemas.barcodes.barColor': 'สีบาร์',
|
100
179
|
};
|
101
180
|
|
102
|
-
const dictIt: { [key in keyof
|
181
|
+
const dictIt: { [key in keyof Dict]: string } = {
|
103
182
|
cancel: 'Annulla',
|
104
183
|
field: 'Campo',
|
105
184
|
fieldName: 'Nome',
|
106
|
-
|
107
|
-
|
185
|
+
align: 'Allinea',
|
186
|
+
width: 'Larghezza',
|
187
|
+
height: 'Altezza',
|
188
|
+
rotate: 'Ruota',
|
108
189
|
edit: 'Modifica',
|
109
190
|
plsInputName: 'Inserisci il nome per favore',
|
110
191
|
fieldMustUniq: 'Il nome del campo non è univoco',
|
@@ -119,17 +200,37 @@ const dictIt: { [key in keyof DictEn]: string } = {
|
|
119
200
|
'Non è possibile salvare le modifiche perché il numero di elementi è cambiato.',
|
120
201
|
commitBulkUpdateFieldName: 'Salva cambiamenti',
|
121
202
|
bulkUpdateFieldName: 'Modifica nomi campi in blocco',
|
122
|
-
|
123
|
-
|
124
|
-
|
203
|
+
'schemas.textColor': 'Colore testo',
|
204
|
+
'schemas.bgColor': 'Colore sfondo',
|
205
|
+
'schemas.horizontal': 'Orizzontale',
|
206
|
+
'schemas.vertical': 'Verticale',
|
207
|
+
'schemas.left': 'Sinistra',
|
208
|
+
'schemas.center': 'Centro',
|
209
|
+
'schemas.right': 'Destra',
|
210
|
+
'schemas.top': 'Sopra',
|
211
|
+
'schemas.middle': 'Medio',
|
212
|
+
'schemas.bottom': 'Sotto',
|
213
|
+
'schemas.text.fontName': 'Nome del font',
|
214
|
+
'schemas.text.size': 'Dimensione',
|
215
|
+
'schemas.text.spacing': 'Spaziatura',
|
216
|
+
'schemas.text.textAlign': 'Allineamento testo',
|
217
|
+
'schemas.text.verticalAlign': 'Allineamento verticale',
|
218
|
+
'schemas.text.lineHeight': 'Altezza della linea',
|
219
|
+
'schemas.text.min': 'Minimo',
|
220
|
+
'schemas.text.max': 'Massimo',
|
221
|
+
'schemas.text.fit': 'Adatta',
|
222
|
+
'schemas.text.dynamicFontSize': 'Dimensione font dinamica',
|
223
|
+
'schemas.barcodes.barColor': 'Colore barra',
|
125
224
|
};
|
126
225
|
|
127
|
-
const dictPl: { [key in keyof
|
226
|
+
const dictPl: { [key in keyof Dict]: string } = {
|
128
227
|
cancel: 'Anuluj',
|
129
228
|
field: 'pole',
|
130
229
|
fieldName: 'Klucz pola',
|
131
|
-
|
132
|
-
|
230
|
+
align: 'Wyrównanie',
|
231
|
+
width: 'Szerokość',
|
232
|
+
height: 'Wysokość',
|
233
|
+
rotate: 'Obrót',
|
133
234
|
edit: 'Edytuj',
|
134
235
|
plsInputName: 'Wymagane wprowadzenie klucza pola',
|
135
236
|
fieldMustUniq: 'Klucz pola nie jest unikalny',
|
@@ -143,30 +244,38 @@ const dictPl: { [key in keyof DictEn]: string } = {
|
|
143
244
|
errorBulkUpdateFieldName: 'Nie można wprowadzić zmian ponieważ liczba elementów uległa zmianie.',
|
144
245
|
commitBulkUpdateFieldName: 'Zaakceptuj zmiany',
|
145
246
|
bulkUpdateFieldName: 'Masowo aktualizuj klucze pól',
|
146
|
-
|
147
|
-
|
148
|
-
|
247
|
+
'schemas.textColor': 'Kolor tekstu',
|
248
|
+
'schemas.bgColor': 'Kolor tła',
|
249
|
+
'schemas.horizontal': 'Poziomo',
|
250
|
+
'schemas.vertical': 'Pionowo',
|
251
|
+
'schemas.left': 'Lewo',
|
252
|
+
'schemas.center': 'Centrum',
|
253
|
+
'schemas.right': 'Prawo',
|
254
|
+
'schemas.top': 'Góra',
|
255
|
+
'schemas.middle': 'Środek',
|
256
|
+
'schemas.bottom': 'Dół',
|
257
|
+
'schemas.text.fontName': 'Nazwa czcionki',
|
258
|
+
'schemas.text.size': 'Rozmiar',
|
259
|
+
'schemas.text.spacing': 'Odstępy',
|
260
|
+
'schemas.text.textAlign': 'Wyrównanie tekstu',
|
261
|
+
'schemas.text.verticalAlign': 'Wyrównanie pionowe',
|
262
|
+
'schemas.text.lineHeight': 'Wysokość linii',
|
263
|
+
'schemas.text.min': 'Minimum',
|
264
|
+
'schemas.text.max': 'Maksimum',
|
265
|
+
'schemas.text.fit': 'Dopasowanie',
|
266
|
+
'schemas.text.dynamicFontSize': 'Dynamiczny rozmiar czcionki',
|
267
|
+
'schemas.barcodes.barColor': 'Kolor paska',
|
149
268
|
};
|
150
269
|
|
151
|
-
const
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
case 'ar':
|
159
|
-
return dictAr[key];
|
160
|
-
|
161
|
-
case 'ja':
|
162
|
-
return dictJa[key];
|
163
|
-
|
164
|
-
case 'it':
|
165
|
-
return dictIt[key];
|
166
|
-
|
167
|
-
default:
|
168
|
-
return dictEn[key];
|
169
|
-
}
|
270
|
+
const dictionaries: { [key in Lang]: Dict } = {
|
271
|
+
en: dictEn,
|
272
|
+
ja: dictJa,
|
273
|
+
ar: dictAr,
|
274
|
+
th: dictTh,
|
275
|
+
it: dictIt,
|
276
|
+
pl: dictPl,
|
170
277
|
};
|
171
278
|
|
172
|
-
export const
|
279
|
+
export const getDict = (lang: Lang): Dict => dictionaries[lang] || dictionaries[DEFAULT_LANG];
|
280
|
+
|
281
|
+
export const i18n = (key: keyof Dict, dict?: Dict) => (dict || getDict(DEFAULT_LANG))[key];
|