@pdfme/ui 5.2.0 → 5.2.1-dev.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.
@@ -3,5 +3,6 @@ export declare const DESTROYED_ERR_MSG = "[@pdfme/ui] this instance is already d
3
3
  export declare const SELECTABLE_CLASSNAME = "selectable";
4
4
  export declare const RULER_HEIGHT = 30;
5
5
  export declare const PAGE_GAP = 10;
6
+ export declare const LEFT_SIDEBAR_WIDTH = 45;
6
7
  export declare const RIGHT_SIDEBAR_WIDTH = 400;
7
8
  export declare const BACKGROUND_COLOR = "rgb(74, 74, 74)";
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Plugins, UIOptions } from '@pdfme/common';
3
- export declare const I18nContext: import("react").Context<(key: "type" | "width" | "height" | "rotate" | "opacity" | "required" | "cancel" | "close" | "field" | "fieldName" | "align" | "edit" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "validation.uniqueName" | "validation.hexColor" | "schemas.color" | "schemas.borderWidth" | "schemas.borderColor" | "schemas.backgroundColor" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.padding" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.text.format" | "schemas.mvt.typingInstructions" | "schemas.mvt.sampleField" | "schemas.mvt.variablesSampleData" | "schemas.barcodes.barColor" | "schemas.barcodes.includetext" | "schemas.table.alternateBackgroundColor" | "schemas.table.tableStyle" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle" | "schemas.date.format" | "schemas.select.options" | "schemas.select.optionPlaceholder", dict?: {
3
+ export declare const I18nContext: import("react").Context<(key: "type" | "width" | "height" | "rotate" | "opacity" | "required" | "cancel" | "close" | "field" | "fieldName" | "align" | "edit" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "validation.uniqueName" | "validation.hexColor" | "schemas.color" | "schemas.borderWidth" | "schemas.borderColor" | "schemas.backgroundColor" | "schemas.textColor" | "schemas.bgColor" | "schemas.horizontal" | "schemas.vertical" | "schemas.left" | "schemas.center" | "schemas.right" | "schemas.top" | "schemas.middle" | "schemas.bottom" | "schemas.padding" | "schemas.text.fontName" | "schemas.text.size" | "schemas.text.spacing" | "schemas.text.textAlign" | "schemas.text.verticalAlign" | "schemas.text.lineHeight" | "schemas.text.min" | "schemas.text.max" | "schemas.text.fit" | "schemas.text.dynamicFontSize" | "schemas.text.format" | "schemas.mvt.typingInstructions" | "schemas.mvt.sampleField" | "schemas.mvt.variablesSampleData" | "schemas.barcodes.barColor" | "schemas.barcodes.includetext" | "schemas.table.alternateBackgroundColor" | "schemas.table.tableStyle" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle" | "schemas.date.format" | "schemas.select.options" | "schemas.select.optionPlaceholder" | "schemas.radioGroup.groupName", dict?: {
4
4
  cancel: string;
5
5
  close: string;
6
6
  field: string;
@@ -68,6 +68,7 @@ export declare const I18nContext: import("react").Context<(key: "type" | "width"
68
68
  'schemas.date.format': string;
69
69
  'schemas.select.options': string;
70
70
  'schemas.select.optionPlaceholder': string;
71
+ 'schemas.radioGroup.groupName': string;
71
72
  } | undefined) => string>;
72
73
  export declare const FontContext: import("react").Context<Record<string, {
73
74
  data: string | ArrayBuffer | Uint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.2.0",
3
+ "version": "5.2.1-dev.2",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -8,9 +8,11 @@ import { theme, Button } from 'antd';
8
8
  import { useDraggable } from '@dnd-kit/core';
9
9
  import { CSS } from "@dnd-kit/utilities";
10
10
  import Renderer from '../Renderer';
11
+ import { LEFT_SIDEBAR_WIDTH } from '../../constants';
11
12
  import { PluginsRegistry } from '../../contexts';
12
13
  import PluginIcon from "./PluginIcon";
13
14
 
15
+
14
16
  const Draggable = (props: { plugin: Plugin<any>, scale: number, basePdf: BasePdf, children: React.ReactNode }) => {
15
17
  const { scale, basePdf, plugin } = props;
16
18
  const { token } = theme.useToken();
@@ -67,7 +69,7 @@ const LeftSidebar = ({ height, scale, basePdf }: { height: number, scale: number
67
69
  position: 'absolute',
68
70
  zIndex: 1,
69
71
  height,
70
- width: 45,
72
+ width: LEFT_SIDEBAR_WIDTH,
71
73
  background: token.colorBgLayout,
72
74
  textAlign: 'center',
73
75
  overflow: isDragging ? 'visible' : 'auto',
@@ -15,7 +15,7 @@ import { DndContext } from '@dnd-kit/core';
15
15
  import RightSidebar from './RightSidebar/index';
16
16
  import LeftSidebar from './LeftSidebar';
17
17
  import Canvas from './Canvas/index';
18
- import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../constants';
18
+ import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH, LEFT_SIDEBAR_WIDTH } from '../../constants';
19
19
  import { I18nContext, OptionsContext, PluginsRegistry } from '../../contexts';
20
20
  import {
21
21
  schemasList2template,
@@ -235,8 +235,9 @@ const TemplateEditor = ({
235
235
  void updateTemplate(template);
236
236
  }
237
237
 
238
- const sizeExcSidebar = {
239
- width: sidebarOpen ? size.width - RIGHT_SIDEBAR_WIDTH : size.width,
238
+ const canvasWidth = size.width - LEFT_SIDEBAR_WIDTH;
239
+ const sizeExcSidebars = {
240
+ width: sidebarOpen ? canvasWidth - RIGHT_SIDEBAR_WIDTH : canvasWidth,
240
241
  height: size.height,
241
242
  };
242
243
 
@@ -271,66 +272,69 @@ const TemplateEditor = ({
271
272
  }}
272
273
  onDragStart={onEditEnd}
273
274
  >
274
- <CtlBar
275
- size={sizeExcSidebar}
276
- pageCursor={pageCursor}
277
- pageNum={schemasList.length}
278
- setPageCursor={(p) => {
279
- if (!canvasRef.current) return;
280
- canvasRef.current.scrollTop = getPagesScrollTopByIndex(pageSizes, p, scale);
281
- setPageCursor(p);
282
- onEditEnd();
283
- }}
284
- zoomLevel={zoomLevel}
285
- setZoomLevel={setZoomLevel}
286
- {...pageManipulation}
287
- />
288
275
  <LeftSidebar
289
276
  height={canvasRef.current ? canvasRef.current.clientHeight : 0}
290
277
  scale={scale}
291
278
  basePdf={template.basePdf}
292
279
  />
293
280
 
294
- <RightSidebar
295
- hoveringSchemaId={hoveringSchemaId}
296
- onChangeHoveringSchemaId={onChangeHoveringSchemaId}
297
- height={canvasRef.current ? canvasRef.current.clientHeight : 0}
298
- size={size}
299
- pageSize={pageSizes[pageCursor] ?? []}
300
- activeElements={activeElements}
301
- schemasList={schemasList}
302
- schemas={schemasList[pageCursor] ?? []}
303
- changeSchemas={changeSchemas}
304
- onSortEnd={onSortEnd}
305
- onEdit={id => {
306
- const editingElem = document.getElementById(id);
307
- editingElem && onEdit([editingElem]);
308
- }}
309
- onEditEnd={onEditEnd}
310
- deselectSchema={onEditEnd}
311
- sidebarOpen={sidebarOpen}
312
- setSidebarOpen={setSidebarOpen}
313
- />
314
-
315
- <Canvas
316
- ref={canvasRef}
317
- paperRefs={paperRefs}
318
- basePdf={template.basePdf}
319
- hoveringSchemaId={hoveringSchemaId}
320
- onChangeHoveringSchemaId={onChangeHoveringSchemaId}
321
- height={size.height - RULER_HEIGHT * ZOOM}
322
- pageCursor={pageCursor}
323
- scale={scale}
324
- size={sizeExcSidebar}
325
- pageSizes={pageSizes}
326
- backgrounds={backgrounds}
327
- activeElements={activeElements}
328
- schemasList={schemasList}
329
- changeSchemas={changeSchemas}
330
- removeSchemas={removeSchemas}
331
- sidebarOpen={sidebarOpen}
332
- onEdit={onEdit}
333
- />
281
+ <div style={{ position: 'absolute', width: canvasWidth, marginLeft: LEFT_SIDEBAR_WIDTH }}>
282
+ <CtlBar
283
+ size={sizeExcSidebars}
284
+ pageCursor={pageCursor}
285
+ pageNum={schemasList.length}
286
+ setPageCursor={(p) => {
287
+ if (!canvasRef.current) return;
288
+ canvasRef.current.scrollTop = getPagesScrollTopByIndex(pageSizes, p, scale);
289
+ setPageCursor(p);
290
+ onEditEnd();
291
+ }}
292
+ zoomLevel={zoomLevel}
293
+ setZoomLevel={setZoomLevel}
294
+ {...pageManipulation}
295
+ />
296
+
297
+ <RightSidebar
298
+ hoveringSchemaId={hoveringSchemaId}
299
+ onChangeHoveringSchemaId={onChangeHoveringSchemaId}
300
+ height={canvasRef.current ? canvasRef.current.clientHeight : 0}
301
+ size={size}
302
+ pageSize={pageSizes[pageCursor] ?? []}
303
+ activeElements={activeElements}
304
+ schemasList={schemasList}
305
+ schemas={schemasList[pageCursor] ?? []}
306
+ changeSchemas={changeSchemas}
307
+ onSortEnd={onSortEnd}
308
+ onEdit={id => {
309
+ const editingElem = document.getElementById(id);
310
+ editingElem && onEdit([editingElem]);
311
+ }}
312
+ onEditEnd={onEditEnd}
313
+ deselectSchema={onEditEnd}
314
+ sidebarOpen={sidebarOpen}
315
+ setSidebarOpen={setSidebarOpen}
316
+ />
317
+
318
+ <Canvas
319
+ ref={canvasRef}
320
+ paperRefs={paperRefs}
321
+ basePdf={template.basePdf}
322
+ hoveringSchemaId={hoveringSchemaId}
323
+ onChangeHoveringSchemaId={onChangeHoveringSchemaId}
324
+ height={size.height - RULER_HEIGHT * ZOOM}
325
+ pageCursor={pageCursor}
326
+ scale={scale}
327
+ size={sizeExcSidebars}
328
+ pageSizes={pageSizes}
329
+ backgrounds={backgrounds}
330
+ activeElements={activeElements}
331
+ schemasList={schemasList}
332
+ changeSchemas={changeSchemas}
333
+ removeSchemas={removeSchemas}
334
+ sidebarOpen={sidebarOpen}
335
+ onEdit={onEdit}
336
+ />
337
+ </div>
334
338
  </DndContext>
335
339
  </Root>
336
340
  );
package/src/constants.ts CHANGED
@@ -8,6 +8,8 @@ export const RULER_HEIGHT = 30;
8
8
 
9
9
  export const PAGE_GAP = 10;
10
10
 
11
+ export const LEFT_SIDEBAR_WIDTH = 45;
12
+
11
13
  export const RIGHT_SIDEBAR_WIDTH = 400;
12
14
 
13
15
  export const BACKGROUND_COLOR = 'rgb(74, 74, 74)';
package/src/i18n.ts CHANGED
@@ -71,6 +71,7 @@ const dictEn: { [key in keyof Dict]: string } = {
71
71
  'schemas.date.format': 'Date Format',
72
72
  'schemas.select.options': 'Options',
73
73
  'schemas.select.optionPlaceholder': 'Enter an option',
74
+ 'schemas.radioGroup.groupName': 'Group Name',
74
75
  };
75
76
 
76
77
  const dictZh: { [key in keyof Dict]: string } = {
@@ -141,6 +142,7 @@ const dictZh: { [key in keyof Dict]: string } = {
141
142
  'schemas.date.format': '日期格式',
142
143
  'schemas.select.options': '选项',
143
144
  'schemas.select.optionPlaceholder': '请输入选项',
145
+ 'schemas.radioGroup.groupName': '组名',
144
146
  };
145
147
 
146
148
  const dictJa: { [key in keyof Dict]: string } = {
@@ -211,6 +213,7 @@ const dictJa: { [key in keyof Dict]: string } = {
211
213
  'schemas.date.format': '日付形式',
212
214
  'schemas.select.options': 'オプション',
213
215
  'schemas.select.optionPlaceholder': 'オプションを入力してください',
216
+ 'schemas.radioGroup.groupName': 'グループ名',
214
217
  };
215
218
 
216
219
  const dictKo: { [key in keyof Dict]: string } = {
@@ -281,6 +284,7 @@ const dictKo: { [key in keyof Dict]: string } = {
281
284
  'schemas.date.format': '날짜 형식',
282
285
  'schemas.select.options': '옵션',
283
286
  'schemas.select.optionPlaceholder': '옵션을 입력하세요',
287
+ 'schemas.radioGroup.groupName': '그룹 이름',
284
288
  };
285
289
 
286
290
  const dictAr: { [key in keyof Dict]: string } = {
@@ -352,6 +356,7 @@ const dictAr: { [key in keyof Dict]: string } = {
352
356
  'schemas.date.format': 'تنسيق التاريخ',
353
357
  'schemas.select.options': 'خيارات',
354
358
  'schemas.select.optionPlaceholder': 'أدخل خيارًا',
359
+ 'schemas.radioGroup.groupName': 'اسم المجموعة',
355
360
  };
356
361
 
357
362
  const dictTh: { [key in keyof Dict]: string } = {
@@ -422,6 +427,7 @@ const dictTh: { [key in keyof Dict]: string } = {
422
427
  'schemas.date.format': 'รูปแบบวันที่',
423
428
  'schemas.select.options': 'ตัวเลือก',
424
429
  'schemas.select.optionPlaceholder': 'กรอกตัวเลือก',
430
+ 'schemas.radioGroup.groupName': 'ชื่อกลุ่ม',
425
431
  };
426
432
 
427
433
  const dictIt: { [key in keyof Dict]: string } = {
@@ -495,6 +501,7 @@ const dictIt: { [key in keyof Dict]: string } = {
495
501
  'schemas.date.format': 'Formato data',
496
502
  'schemas.select.options': 'Opzioni',
497
503
  'schemas.select.optionPlaceholder': 'Inserisci un\'opzione',
504
+ 'schemas.radioGroup.groupName': 'Nome del Gruppo',
498
505
  };
499
506
 
500
507
  const dictPl: { [key in keyof Dict]: string } = {
@@ -565,6 +572,7 @@ const dictPl: { [key in keyof Dict]: string } = {
565
572
  'schemas.date.format': 'Format daty',
566
573
  'schemas.select.options': 'Opcje',
567
574
  'schemas.select.optionPlaceholder': 'Wpisz opcję',
575
+ 'schemas.radioGroup.groupName': 'Nazwa grupy',
568
576
  };
569
577
 
570
578
  const dictDe: { [key in keyof Dict]: string } = {
@@ -638,6 +646,7 @@ const dictDe: { [key in keyof Dict]: string } = {
638
646
  'schemas.date.format': 'Datumsformat',
639
647
  'schemas.select.options': 'Optionen',
640
648
  'schemas.select.optionPlaceholder': 'Geben Sie eine Option ein',
649
+ 'schemas.radioGroup.groupName': 'Gruppenname',
641
650
  };
642
651
 
643
652
  const dictEs: { [key in keyof Dict]: string } = {
@@ -710,6 +719,7 @@ const dictEs: { [key in keyof Dict]: string } = {
710
719
  'schemas.date.format': 'Formato de fecha',
711
720
  'schemas.select.options': 'Opciones',
712
721
  'schemas.select.optionPlaceholder': 'Ingrese una opción',
722
+ 'schemas.radioGroup.groupName': 'Nombre del grupo',
713
723
  };
714
724
 
715
725
  const dictFr: { [key in keyof Dict]: string } = {
@@ -783,6 +793,7 @@ const dictFr: { [key in keyof Dict]: string } = {
783
793
  'schemas.date.format': 'Format de date',
784
794
  'schemas.select.options': 'Options',
785
795
  'schemas.select.optionPlaceholder': 'Entrez une option',
796
+ 'schemas.radioGroup.groupName': 'Nom du groupe',
786
797
  };
787
798
 
788
799
  const dictionaries: { [key in Lang]: Dict } = {