@pdfme/ui 1.0.0-beta.5 → 1.0.0-beta.9
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/coverage/clover.xml +6 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +0 -0
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types/{ui/src/Designer.d.ts → Designer.d.ts} +0 -0
- package/dist/types/{ui/src/Form.d.ts → Form.d.ts} +0 -0
- package/dist/types/{ui/src/Viewer.d.ts → Viewer.d.ts} +0 -0
- package/dist/types/{ui/src/class.d.ts → class.d.ts} +1 -1
- package/dist/types/{ui/src/components → components}/Designer/Main/Guides.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Designer/Main/Mask.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Designer/Main/Moveable.d.ts +1 -1
- package/dist/types/{ui/src/components → components}/Designer/Main/Selecto.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Designer/Main/index.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/ExampleInputEditor.d.ts +4 -1
- package/dist/types/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +6 -0
- package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TextPropEditor.d.ts +4 -1
- package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TypeAndKeyEditor.d.ts +4 -1
- package/dist/types/components/Designer/Sidebar/DetailView/index.d.ts +6 -0
- package/dist/types/components/Designer/Sidebar/ListView/Item.d.ts +25 -0
- package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableContainer.d.ts +3 -0
- package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableItem.d.ts +14 -0
- package/dist/types/{ui/src/components/Designer/Sidebar/ListView.d.ts → components/Designer/Sidebar/ListView/index.d.ts} +2 -2
- package/dist/types/{ui/src/components → components}/Designer/Sidebar/index.d.ts +2 -7
- package/dist/types/{ui/src/components → components}/Designer/index.d.ts +0 -1
- package/dist/types/{ui/src/components → components}/Divider.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Error.d.ts +0 -1
- package/dist/types/{ui/src/components → components}/Paper.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Preview/Pager/Page.d.ts +0 -1
- package/dist/types/{ui/src/components → components}/Preview/Pager/Unit.d.ts +0 -1
- package/dist/types/{ui/src/components → components}/Preview/index.d.ts +0 -1
- package/dist/types/{ui/src/components → components}/Root.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Schemas/BarcodeSchema.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Schemas/ImageSchema.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Schemas/SchemaUI.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Schemas/TextSchema.d.ts +0 -0
- package/dist/types/{ui/src/components → components}/Spinner.d.ts +0 -0
- package/dist/types/{ui/src/constants.d.ts → constants.d.ts} +1 -0
- package/dist/types/{ui/src/contexts.d.ts → contexts.d.ts} +1 -1
- package/dist/types/{ui/src/helper.d.ts → helper.d.ts} +1 -1
- package/dist/types/{ui/src/hooks.d.ts → hooks.d.ts} +1 -0
- package/dist/types/{ui/src/i18n.d.ts → i18n.d.ts} +4 -2
- package/dist/types/{ui/src/index.d.ts → index.d.ts} +0 -0
- package/package.json +13 -11
- package/src/Designer.tsx +2 -1
- package/src/Form.tsx +1 -0
- package/src/Viewer.tsx +1 -0
- package/src/assets/icons/align-horizontal-center.svg +1 -0
- package/src/assets/icons/align-horizontal-left.svg +1 -0
- package/src/assets/icons/align-horizontal-right.svg +1 -0
- package/src/assets/icons/align-vertical-bottom.svg +1 -0
- package/src/assets/icons/align-vertical-middle.svg +1 -0
- package/src/assets/icons/align-vertical-top.svg +1 -0
- package/src/assets/icons/close.svg +4 -0
- package/src/assets/icons/horizontal-distribute.svg +1 -0
- package/src/assets/icons/vertical-distribute.svg +1 -0
- package/src/assets/imageExample.png +0 -0
- package/src/class.ts +5 -6
- package/src/components/Designer/Main/Moveable.tsx +1 -1
- package/src/components/Designer/Main/index.tsx +21 -15
- package/src/components/Designer/Sidebar/DetailView/ExampleInputEditor.tsx +28 -6
- package/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.tsx +115 -24
- package/src/components/Designer/Sidebar/DetailView/TextPropEditor.tsx +36 -6
- package/src/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.tsx +14 -6
- package/src/components/Designer/Sidebar/DetailView/index.tsx +19 -14
- package/src/components/Designer/Sidebar/ListView/Item.tsx +113 -0
- package/src/components/Designer/Sidebar/ListView/SelectableSortableContainer.tsx +162 -0
- package/src/components/Designer/Sidebar/ListView/SelectableSortableItem.tsx +78 -0
- package/src/components/Designer/Sidebar/ListView/index.tsx +118 -0
- package/src/components/Designer/Sidebar/index.tsx +26 -12
- package/src/components/Designer/index.tsx +12 -24
- package/src/components/Paper.tsx +1 -3
- package/src/components/Preview/Pager/Page.tsx +1 -1
- package/src/components/Preview/Pager/Unit.tsx +1 -1
- package/src/components/Preview/index.tsx +3 -4
- package/src/components/Root.tsx +2 -7
- package/src/components/Schemas/BarcodeSchema.tsx +37 -22
- package/src/components/Schemas/ImageSchema.tsx +71 -66
- package/src/components/Schemas/TextSchema.tsx +1 -1
- package/src/constants.ts +2 -0
- package/src/helper.ts +42 -37
- package/src/hooks.ts +11 -0
- package/src/i18n.ts +10 -7
- package/tsconfig.json +1 -1
- package/webpack.config.js +0 -18
- package/dist/types/common/src/constants.d.ts +0 -6
- package/dist/types/common/src/helper.d.ts +0 -15
- package/dist/types/common/src/index.d.ts +0 -6
- package/dist/types/common/src/schema.d.ts +0 -3613
- package/dist/types/common/src/type.d.ts +0 -64
- package/dist/types/ui/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +0 -3
- package/dist/types/ui/src/components/Designer/Sidebar/DetailView/index.d.ts +0 -3
- package/src/components/Designer/Sidebar/ListView.tsx +0 -180
File without changes
|
File without changes
|
File without changes
|
@@ -7,7 +7,7 @@ export declare abstract class BaseUIClass {
|
|
7
7
|
private readonly font;
|
8
8
|
private readonly setSize;
|
9
9
|
constructor(props: UIProps);
|
10
|
-
protected getI18n(): (key: "type" | "
|
10
|
+
protected getI18n(): (key: "type" | "field" | "cancel" | "fieldName" | "require" | "uniq" | "inputExample" | "edit" | "plsSelect" | "plsInputName" | "plsAddNewField" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "goToFirst" | "goToPrevious" | "goToNext" | "goToEnd" | "select" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName") => string;
|
11
11
|
protected getFont(): Record<string, {
|
12
12
|
fallback?: boolean | undefined;
|
13
13
|
subset?: boolean | undefined;
|
File without changes
|
File without changes
|
@@ -25,7 +25,7 @@ declare type Props = {
|
|
25
25
|
onResizeGroupEnd: ((e: OnResizeGroupEnd) => void) & (({ targets }: {
|
26
26
|
targets: (HTMLElement | SVGElement)[];
|
27
27
|
}) => void);
|
28
|
-
onClick: (
|
28
|
+
onClick: (e: OnClick) => void;
|
29
29
|
};
|
30
30
|
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<any>>;
|
31
31
|
export default _default;
|
File without changes
|
File without changes
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import { SchemaForUI } from '@pdfme/common';
|
1
2
|
import { SidebarProps } from '..';
|
2
|
-
declare const ExampleInputEditor: (props: Pick<SidebarProps, 'changeSchemas'
|
3
|
+
declare const ExampleInputEditor: (props: Pick<SidebarProps, 'changeSchemas'> & {
|
4
|
+
activeSchema: SchemaForUI;
|
5
|
+
}) => JSX.Element;
|
3
6
|
export default ExampleInputEditor;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { SchemaForUI } from '@pdfme/common';
|
2
|
+
import { SidebarProps } from '..';
|
3
|
+
declare const PositionAndSizeEditor: (props: Pick<SidebarProps, 'pageSize' | 'schemas' | 'changeSchemas' | 'activeElements'> & {
|
4
|
+
activeSchema: SchemaForUI;
|
5
|
+
}) => JSX.Element;
|
6
|
+
export default PositionAndSizeEditor;
|
package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TextPropEditor.d.ts
RENAMED
@@ -1,3 +1,6 @@
|
|
1
|
+
import { SchemaForUI } from '@pdfme/common';
|
1
2
|
import { SidebarProps } from '..';
|
2
|
-
declare const TextPropEditor: (props: Pick<SidebarProps, 'changeSchemas'
|
3
|
+
declare const TextPropEditor: (props: Pick<SidebarProps, 'changeSchemas'> & {
|
4
|
+
activeSchema: SchemaForUI;
|
5
|
+
}) => JSX.Element;
|
3
6
|
export default TextPropEditor;
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import { SchemaForUI } from '@pdfme/common';
|
1
2
|
import { SidebarProps } from '..';
|
2
|
-
declare const TypeAndKeyEditor: (props: Pick<SidebarProps, 'schemas' | 'changeSchemas'
|
3
|
+
declare const TypeAndKeyEditor: (props: Pick<SidebarProps, 'schemas' | 'changeSchemas'> & {
|
4
|
+
activeSchema: SchemaForUI;
|
5
|
+
}) => JSX.Element;
|
3
6
|
export default TypeAndKeyEditor;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { SchemaForUI } from '@pdfme/common';
|
2
|
+
import { SidebarProps } from '..';
|
3
|
+
declare const DetailView: (props: Pick<SidebarProps, 'schemas' | 'pageSize' | 'changeSchemas' | 'activeElements'> & {
|
4
|
+
activeSchema: SchemaForUI;
|
5
|
+
}) => JSX.Element;
|
6
|
+
export default DetailView;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DraggableSyntheticListeners } from '@dnd-kit/core';
|
3
|
+
interface Props {
|
4
|
+
value: React.ReactNode;
|
5
|
+
style?: React.CSSProperties;
|
6
|
+
status?: 'is-warning' | 'is-danger';
|
7
|
+
title?: string;
|
8
|
+
dragOverlay?: boolean;
|
9
|
+
onClick?: () => void;
|
10
|
+
onMouseEnter?: () => void;
|
11
|
+
onMouseLeave?: () => void;
|
12
|
+
dragging?: boolean;
|
13
|
+
sorting?: boolean;
|
14
|
+
transition?: string;
|
15
|
+
transform?: {
|
16
|
+
x: number;
|
17
|
+
y: number;
|
18
|
+
scaleX: number;
|
19
|
+
scaleY: number;
|
20
|
+
} | null;
|
21
|
+
fadeIn?: boolean;
|
22
|
+
listeners?: DraggableSyntheticListeners;
|
23
|
+
}
|
24
|
+
declare const Item: React.MemoExoticComponent<React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLLIElement>>>;
|
25
|
+
export default Item;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SchemaForUI } from '@pdfme/common';
|
3
|
+
interface Props {
|
4
|
+
isSelected: boolean;
|
5
|
+
style?: React.CSSProperties;
|
6
|
+
onSelect: (id: string, isShiftSelect: boolean) => void;
|
7
|
+
onEdit: (id: string) => void;
|
8
|
+
schema: SchemaForUI;
|
9
|
+
schemas: SchemaForUI[];
|
10
|
+
onMouseEnter: () => void;
|
11
|
+
onMouseLeave: () => void;
|
12
|
+
}
|
13
|
+
declare const SelectableSortableItem: ({ isSelected, style, onSelect, onEdit, schema, schemas, onMouseEnter, onMouseLeave, }: Props) => JSX.Element;
|
14
|
+
export default SelectableSortableItem;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { SidebarProps } from '
|
2
|
-
declare const ListView: (props: Pick<SidebarProps, 'schemas' | 'onSortEnd' | 'onEdit' | 'size' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId'>) => JSX.Element;
|
1
|
+
import { SidebarProps } from '..';
|
2
|
+
declare const ListView: (props: Pick<SidebarProps, 'schemas' | 'onSortEnd' | 'onEdit' | 'size' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId' | 'changeSchemas'>) => JSX.Element;
|
3
3
|
export default ListView;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/// <reference types="react" />
|
2
1
|
import { SchemaForUI, Size } from '@pdfme/common';
|
3
2
|
export declare type SidebarProps = {
|
4
3
|
height: number;
|
@@ -6,13 +5,9 @@ export declare type SidebarProps = {
|
|
6
5
|
onChangeHoveringSchemaId: (id: string | null) => void;
|
7
6
|
size: Size;
|
8
7
|
pageSize: Size;
|
9
|
-
|
10
|
-
activeSchema: SchemaForUI;
|
8
|
+
activeElements: HTMLElement[];
|
11
9
|
schemas: SchemaForUI[];
|
12
|
-
onSortEnd: (
|
13
|
-
oldIndex: number;
|
14
|
-
newIndex: number;
|
15
|
-
}) => void;
|
10
|
+
onSortEnd: (sortedSchemas: SchemaForUI[]) => void;
|
16
11
|
onEdit: (id: string) => void;
|
17
12
|
onEditEnd: () => void;
|
18
13
|
changeSchemas: (objs: {
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
export declare const I18nContext: import("react").Context<(key: "type" | "
|
2
|
+
export declare const I18nContext: import("react").Context<(key: "type" | "field" | "cancel" | "fieldName" | "require" | "uniq" | "inputExample" | "edit" | "plsSelect" | "plsInputName" | "plsAddNewField" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "goToFirst" | "goToPrevious" | "goToNext" | "goToEnd" | "select" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName") => string>;
|
3
3
|
export declare const FontContext: import("react").Context<Record<string, {
|
4
4
|
fallback?: boolean | undefined;
|
5
5
|
subset?: boolean | undefined;
|
@@ -3,7 +3,6 @@ export declare const uuid: () => string;
|
|
3
3
|
export declare const set: <T extends object>(obj: T, path: string | string[], value: any) => void;
|
4
4
|
export declare const debounce: <T extends Function>(cb: T, wait?: number) => T;
|
5
5
|
export declare const round: (number: number, precision: number) => number;
|
6
|
-
export declare const arrayMove: <T>(array: T[], from: number, to: number) => T[];
|
7
6
|
export declare const cloneDeep: <T>(value: T) => T;
|
8
7
|
export declare const flatten: <T>(arr: T[][]) => T[];
|
9
8
|
declare const esc = "esc";
|
@@ -16,6 +15,7 @@ export declare const initShortCuts: (arg: {
|
|
16
15
|
redo: () => void;
|
17
16
|
undo: () => void;
|
18
17
|
save: () => void;
|
18
|
+
selectAll: () => void;
|
19
19
|
}) => void;
|
20
20
|
export declare const destroyShortCuts: () => void;
|
21
21
|
export declare const readFiles: (files: FileList | null, type: 'text' | 'dataURL' | 'arrayBuffer') => Promise<string | ArrayBuffer>;
|
@@ -23,4 +23,5 @@ declare type ScrollPageCursorProps = {
|
|
23
23
|
onChangePageCursor: (page: number) => void;
|
24
24
|
};
|
25
25
|
export declare const useScrollPageCursor: ({ rootRef, pageSizes, scale, pageCursor, onChangePageCursor, }: ScrollPageCursorProps) => void;
|
26
|
+
export declare const useMountStatus: () => boolean;
|
26
27
|
export {};
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Lang } from '@pdfme/common';
|
2
2
|
declare type DictEn = typeof dictEn;
|
3
3
|
declare const dictEn: {
|
4
|
+
cancel: string;
|
4
5
|
field: string;
|
5
6
|
fieldName: string;
|
6
7
|
require: string;
|
@@ -17,14 +18,15 @@ declare const dictEn: {
|
|
17
18
|
addNewField: string;
|
18
19
|
editField: string;
|
19
20
|
type: string;
|
20
|
-
previewWarnMsg: string;
|
21
|
-
previewErrMsg: string;
|
22
21
|
goToFirst: string;
|
23
22
|
goToPrevious: string;
|
24
23
|
goToNext: string;
|
25
24
|
goToEnd: string;
|
26
25
|
select: string;
|
27
26
|
errorOccurred: string;
|
27
|
+
errorBulkUpdateFieldName: string;
|
28
|
+
commitBulkUpdateFieldName: string;
|
29
|
+
bulkUpdateFieldName: string;
|
28
30
|
};
|
29
31
|
export declare const curriedI18n: (lang: Lang) => (key: keyof DictEn) => string;
|
30
32
|
export {};
|
File without changes
|
package/package.json
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "1.0.0-beta.
|
3
|
+
"version": "1.0.0-beta.9",
|
4
4
|
"author": "hand-dot",
|
5
5
|
"license": "MIT",
|
6
6
|
"description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
|
7
7
|
"homepage": "https://pdfme.com",
|
8
|
-
"repository":
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "git@github.com:pdfme/pdfme.git"
|
11
|
+
},
|
9
12
|
"bugs": {
|
10
13
|
"url": "https://github.com/pdfme/pdfme/issues"
|
11
14
|
},
|
12
15
|
"main": "dist/index.js",
|
13
|
-
"module": "
|
14
|
-
"types": "dist/types/
|
16
|
+
"module": "dist/index.js",
|
17
|
+
"types": "dist/types/index.d.ts",
|
15
18
|
"engines": {
|
16
19
|
"node": ">=14"
|
17
20
|
},
|
18
21
|
"scripts": {
|
19
|
-
"develop": "webpack
|
22
|
+
"develop": "webpack --watch --mode development",
|
20
23
|
"build": "NODE_ENV=production webpack --mode production",
|
21
24
|
"clean": "rimraf dist",
|
22
25
|
"lint": "tsc --noEmit",
|
@@ -26,7 +29,9 @@
|
|
26
29
|
"prune": "ts-prune src"
|
27
30
|
},
|
28
31
|
"dependencies": {
|
29
|
-
"@
|
32
|
+
"@dnd-kit/core": "^5.0.1",
|
33
|
+
"@dnd-kit/sortable": "^6.0.0",
|
34
|
+
"@pdfme/common": "^1.0.0-beta.7",
|
30
35
|
"@scena/react-guides": "^0.16.0",
|
31
36
|
"hotkeys-js": "^3.8.7",
|
32
37
|
"pdfjs-dist": "^2.12.313",
|
@@ -34,7 +39,6 @@
|
|
34
39
|
"react-dom": "^17.0.2",
|
35
40
|
"react-moveable": "^0.30.3",
|
36
41
|
"react-selecto": "^1.12.0",
|
37
|
-
"react-sortable-hoc": "^2.0.0",
|
38
42
|
"worker-loader": "^3.0.8"
|
39
43
|
},
|
40
44
|
"devDependencies": {
|
@@ -46,7 +50,6 @@
|
|
46
50
|
"@types/react-dom": "^17.0.9",
|
47
51
|
"eslint-plugin-react": "^7.28.0",
|
48
52
|
"eslint-plugin-react-hooks": "^4.3.0",
|
49
|
-
"html-webpack-plugin": "^5.3.2",
|
50
53
|
"jest-canvas-mock": "^2.3.1",
|
51
54
|
"process": "^0.11.10"
|
52
55
|
},
|
@@ -79,6 +82,5 @@
|
|
79
82
|
},
|
80
83
|
"publishConfig": {
|
81
84
|
"access": "public"
|
82
|
-
}
|
83
|
-
|
84
|
-
}
|
85
|
+
}
|
86
|
+
}
|
package/src/Designer.tsx
CHANGED
@@ -5,6 +5,7 @@ import { BaseUIClass } from './class';
|
|
5
5
|
import { DESTROYED_ERR_MSG } from './constants';
|
6
6
|
import { I18nContext, FontContext } from './contexts';
|
7
7
|
import DesignerComponent from './components/Designer';
|
8
|
+
import { cloneDeep } from './helper';
|
8
9
|
|
9
10
|
class Designer extends BaseUIClass {
|
10
11
|
private onSaveTemplateCallback?: (template: Template) => void;
|
@@ -26,7 +27,7 @@ class Designer extends BaseUIClass {
|
|
26
27
|
|
27
28
|
public updateTemplate(template: Template) {
|
28
29
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
29
|
-
this.template = template;
|
30
|
+
this.template = cloneDeep(template);
|
30
31
|
if (this.onChangeTemplateCallback) {
|
31
32
|
this.onChangeTemplateCallback(template);
|
32
33
|
}
|
package/src/Form.tsx
CHANGED
package/src/Viewer.tsx
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><polygon points="11,2 13,2 13,7 21,7 21,10 13,10 13,14 18,14 18,17 13,17 13,22 11,22 11,17 6,17 6,14 11,14 11,10 3,10 3,7 11,7"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M4,22H2V2h2V22z M22,7H6v3h16V7z M16,14H6v3h10V14z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M20,2h2v20h-2V2z M2,10h16V7H2V10z M8,17h10v-3H8V17z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M22,22H2v-2h20V22z M10,2H7v16h3V2z M17,8h-3v10h3V8z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><polygon points="22,11 17,11 17,6 14,6 14,11 10,11 10,3 7,3 7,11 1.84,11 1.84,13 7,13 7,21 10,21 10,13 14,13 14,18 17,18 17,13 22,13"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M22,2v2H2V2H22z M7,22h3V6H7V22z M14,16h3V6h-3V16z"/></svg>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
|
2
|
+
<path d="M0 0h24v24H0V0z" fill="none" />
|
3
|
+
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
4
|
+
</svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M4,22H2V2h2V22z M22,2h-2v20h2V2z M13.5,7h-3v10h3V7z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M22,2v2H2V2H22z M7,10.5v3h10v-3H7z M2,20v2h20v-2H2z"/></svg>
|
Binary file
|
package/src/class.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import ReactDOM from 'react-dom';
|
2
2
|
import { curriedI18n } from './i18n';
|
3
3
|
import { DESTROYED_ERR_MSG, DEFAULT_LANG } from './constants';
|
4
|
-
import { debounce, flatten } from './helper';
|
4
|
+
import { debounce, flatten, cloneDeep } from './helper';
|
5
5
|
import {
|
6
6
|
Template,
|
7
7
|
Size,
|
@@ -76,7 +76,7 @@ export abstract class BaseUIClass {
|
|
76
76
|
const { domContainer, template, options } = props;
|
77
77
|
const { lang, font } = options || {};
|
78
78
|
this.domContainer = domContainer;
|
79
|
-
this.template = generateColumnsAndSampledataIfNeeded(template);
|
79
|
+
this.template = generateColumnsAndSampledataIfNeeded(cloneDeep(template));
|
80
80
|
this.size = {
|
81
81
|
height: this.domContainer.clientHeight || window.innerHeight,
|
82
82
|
width: this.domContainer.clientWidth || window.innerWidth,
|
@@ -107,7 +107,7 @@ export abstract class BaseUIClass {
|
|
107
107
|
|
108
108
|
public updateTemplate(template: Template) {
|
109
109
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
110
|
-
this.template = template;
|
110
|
+
this.template = cloneDeep(template);
|
111
111
|
this.render();
|
112
112
|
}
|
113
113
|
|
@@ -127,8 +127,7 @@ export abstract class PreviewUI extends BaseUIClass {
|
|
127
127
|
super(props);
|
128
128
|
checkPreviewProps(props);
|
129
129
|
|
130
|
-
this.inputs = props.inputs;
|
131
|
-
this.render();
|
130
|
+
this.inputs = cloneDeep(props.inputs);
|
132
131
|
}
|
133
132
|
|
134
133
|
public getInputs() {
|
@@ -139,7 +138,7 @@ export abstract class PreviewUI extends BaseUIClass {
|
|
139
138
|
|
140
139
|
public setInputs(inputs: { [key: string]: string }[]) {
|
141
140
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
142
|
-
this.inputs = inputs;
|
141
|
+
this.inputs = cloneDeep(inputs);
|
143
142
|
this.render();
|
144
143
|
}
|
145
144
|
|
@@ -25,7 +25,7 @@ type Props = {
|
|
25
25
|
(({ target }: { target: HTMLElement | SVGElement }) => void);
|
26
26
|
onResizeGroupEnd: ((e: OnResizeGroupEnd) => void) &
|
27
27
|
(({ targets }: { targets: (HTMLElement | SVGElement)[] }) => void);
|
28
|
-
onClick: (
|
28
|
+
onClick: (e: OnClick) => void;
|
29
29
|
};
|
30
30
|
|
31
31
|
const _Moveable = (
|
@@ -7,7 +7,7 @@ import React, {
|
|
7
7
|
forwardRef,
|
8
8
|
useCallback,
|
9
9
|
} from 'react';
|
10
|
-
import { OnDrag, OnResize } from 'react-moveable';
|
10
|
+
import { OnDrag, OnResize, OnClick } from 'react-moveable';
|
11
11
|
import { SchemaForUI, Size } from '@pdfme/common';
|
12
12
|
import { ZOOM, RULER_HEIGHT } from '../../../constants';
|
13
13
|
import { usePrevious } from '../../../hooks';
|
@@ -39,7 +39,7 @@ const DeleteButton = ({ activeElements: aes }: { activeElements: HTMLElement[] }
|
|
39
39
|
color: 'white',
|
40
40
|
border: 'none',
|
41
41
|
fontWeight: 'bold',
|
42
|
-
borderRadius:
|
42
|
+
borderRadius: 2,
|
43
43
|
background: 'rgb(68, 170, 255)',
|
44
44
|
}}
|
45
45
|
>
|
@@ -121,16 +121,15 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
121
121
|
}, [initEvents, destroyEvents]);
|
122
122
|
|
123
123
|
useEffect(() => {
|
124
|
+
moveable.current?.updateRect();
|
124
125
|
if (prevSchemas === null) {
|
125
|
-
moveable.current?.updateRect();
|
126
|
-
|
127
126
|
return;
|
128
127
|
}
|
129
128
|
|
130
|
-
const prevSchemaKeys =
|
131
|
-
const schemaKeys =
|
129
|
+
const prevSchemaKeys = JSON.stringify(prevSchemas[pageCursor] || {});
|
130
|
+
const schemaKeys = JSON.stringify(schemasList[pageCursor] || {});
|
132
131
|
|
133
|
-
if (prevSchemaKeys
|
132
|
+
if (prevSchemaKeys === schemaKeys) {
|
134
133
|
moveable.current?.updateRect();
|
135
134
|
}
|
136
135
|
}, [pageCursor, schemasList, prevSchemas]);
|
@@ -201,15 +200,13 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
201
200
|
const getGuideLines = (guides: GuidesInterface[], index: number) =>
|
202
201
|
guides[index] && guides[index].getGuides().map((g) => g * ZOOM);
|
203
202
|
|
204
|
-
const onClickMoveable = () => {
|
203
|
+
const onClickMoveable = (e: OnClick) => {
|
204
|
+
e.inputEvent.stopPropagation();
|
205
205
|
setEditing(true);
|
206
206
|
const ic = inputRef.current;
|
207
207
|
if (!ic) return;
|
208
|
-
ic.disabled = false;
|
209
208
|
ic.focus();
|
210
|
-
if (ic.type
|
211
|
-
ic.click();
|
212
|
-
} else {
|
209
|
+
if (ic.type !== 'file') {
|
213
210
|
ic.setSelectionRange(ic.value.length, ic.value.length);
|
214
211
|
}
|
215
212
|
};
|
@@ -241,8 +238,17 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
241
238
|
removeSchemas(activeElements.map((ae) => ae.id));
|
242
239
|
}
|
243
240
|
}}
|
244
|
-
onSelect={(
|
245
|
-
|
241
|
+
onSelect={({ added, removed, selected, inputEvent }) => {
|
242
|
+
const isClick = inputEvent.type === 'mousedown';
|
243
|
+
let newActiveElements: HTMLElement[] = isClick ? (selected as HTMLElement[]) : [];
|
244
|
+
if (!isClick && added.length > 0) {
|
245
|
+
newActiveElements = activeElements.concat(added as HTMLElement[]);
|
246
|
+
}
|
247
|
+
if (!isClick && removed.length > 0) {
|
248
|
+
newActiveElements = activeElements.filter((ae) => !removed.includes(ae));
|
249
|
+
}
|
250
|
+
|
251
|
+
onEdit(newActiveElements);
|
246
252
|
}}
|
247
253
|
/>
|
248
254
|
<Paper
|
@@ -298,7 +304,7 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
298
304
|
)}
|
299
305
|
renderSchema={({ schema }) => (
|
300
306
|
<SchemaUI
|
301
|
-
key={schema.
|
307
|
+
key={schema.id}
|
302
308
|
schema={schema}
|
303
309
|
onChangeHoveringSchemaId={onChangeHoveringSchemaId}
|
304
310
|
editable={editing && activeElements.map((ae) => ae.id).includes(schema.id)}
|