@pdfme/ui 5.3.8-dev.9 → 5.3.9-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__/lucide-react.js +19 -0
- package/dist/index.es.js +110013 -107261
- package/dist/index.umd.js +585 -556
- package/dist/types/__tests__/assets/helper.d.ts +3 -0
- package/dist/types/__tests__/components/Designer.test.d.ts +1 -0
- package/dist/types/__tests__/components/Preview.test.d.ts +1 -0
- package/dist/types/__tests__/helper.test.d.ts +1 -0
- package/dist/types/{Designer.d.ts → src/Designer.d.ts} +1 -1
- package/dist/types/{Form.d.ts → src/Form.d.ts} +1 -1
- package/dist/types/{Viewer.d.ts → src/Viewer.d.ts} +1 -1
- package/dist/types/{class.d.ts → src/class.d.ts} +2 -2
- package/dist/types/src/components/Designer/Canvas/Guides.d.ts +15 -0
- package/dist/types/{components → src/components}/Designer/Canvas/Moveable.d.ts +48 -1
- package/dist/types/src/components/Designer/Canvas/Selecto.d.ts +21 -0
- package/dist/types/{components → src/components}/Designer/LeftSidebar.d.ts +1 -1
- package/dist/types/{components → src/components}/Designer/PluginIcon.d.ts +1 -1
- package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/index.d.ts +1 -1
- package/dist/types/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +4 -0
- package/dist/types/src/components/Designer/RightSidebar/ListView/index.d.ts +4 -0
- package/dist/types/{components → src/components}/Designer/RightSidebar/index.d.ts +1 -1
- package/dist/types/{components → src/components}/Paper.d.ts +1 -1
- package/dist/types/{components → src/components}/Preview.d.ts +2 -2
- package/dist/types/src/contexts.d.ts +10 -0
- package/dist/types/{helper.d.ts → src/helper.d.ts} +2 -4
- package/dist/types/src/index.d.ts +4 -0
- package/eslint.config.mjs +41 -0
- package/package.json +21 -15
- package/src/Designer.tsx +7 -7
- package/src/Form.tsx +4 -6
- package/src/Viewer.tsx +4 -4
- package/src/components/AppContextProvider.tsx +4 -4
- package/src/components/CtlBar.tsx +4 -2
- package/src/components/Designer/Canvas/Guides.tsx +18 -9
- package/src/components/Designer/Canvas/Mask.tsx +1 -1
- package/src/components/Designer/Canvas/Moveable.tsx +66 -7
- package/src/components/Designer/Canvas/Padding.tsx +10 -8
- package/src/components/Designer/Canvas/Selecto.tsx +21 -6
- package/src/components/Designer/Canvas/index.tsx +95 -28
- package/src/components/Designer/LeftSidebar.tsx +60 -52
- package/src/components/Designer/PluginIcon.tsx +22 -9
- package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +45 -45
- package/src/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.tsx +3 -3
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +62 -31
- package/src/components/Designer/RightSidebar/ListView/Item.tsx +5 -5
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +60 -51
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +5 -6
- package/src/components/Designer/RightSidebar/ListView/index.tsx +15 -8
- package/src/components/Designer/RightSidebar/index.tsx +4 -4
- package/src/components/Designer/index.tsx +51 -29
- package/src/components/ErrorScreen.tsx +2 -2
- package/src/components/Paper.tsx +2 -2
- package/src/components/Preview.tsx +35 -24
- package/src/components/Renderer.tsx +42 -29
- package/src/components/Root.tsx +4 -6
- package/src/components/Spinner.tsx +1 -1
- package/src/components/StaticSchema.tsx +41 -23
- package/src/constants.ts +1 -1
- package/src/contexts.ts +2 -2
- package/src/helper.ts +37 -17
- package/src/hooks.ts +16 -8
- package/src/index.ts +3 -3
- package/src/types/react-guides.d.ts +22 -0
- package/src/types/react-selecto.d.ts +35 -0
- package/tsconfig.json +9 -11
- package/.eslintrc.cjs +0 -16
- package/dist/types/components/Designer/Canvas/Guides.d.ts +0 -9
- package/dist/types/components/Designer/Canvas/Selecto.d.ts +0 -10
- package/dist/types/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +0 -4
- package/dist/types/components/Designer/RightSidebar/ListView/index.d.ts +0 -4
- package/dist/types/contexts.d.ts +0 -85
- package/dist/types/index.d.ts +0 -4
- /package/dist/types/{components → src/components}/AppContextProvider.d.ts +0 -0
- /package/dist/types/{components → src/components}/CtlBar.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Mask.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/Padding.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/Canvas/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/AlignWidget.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/ButtonGroupWidget.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/WidgetRenderer.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/Item.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/RightSidebar/ListView/SelectableSortableItem.d.ts +0 -0
- /package/dist/types/{components → src/components}/Designer/index.d.ts +0 -0
- /package/dist/types/{components → src/components}/ErrorScreen.d.ts +0 -0
- /package/dist/types/{components → src/components}/Renderer.d.ts +0 -0
- /package/dist/types/{components → src/components}/Root.d.ts +0 -0
- /package/dist/types/{components → src/components}/Spinner.d.ts +0 -0
- /package/dist/types/{components → src/components}/StaticSchema.d.ts +0 -0
- /package/dist/types/{components → src/components}/UnitPager.d.ts +0 -0
- /package/dist/types/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/types/{hooks.d.ts → src/hooks.d.ts} +0 -0
- /package/dist/types/{i18n.d.ts → src/i18n.d.ts} +0 -0
- /package/dist/types/{theme.d.ts → src/theme.d.ts} +0 -0
- /package/dist/types/{types.d.ts → src/types.d.ts} +0 -0
- /package/{vite.config.ts → vite.config.mts} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
import '@testing-library/jest-dom';
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@testing-library/jest-dom';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -12,7 +12,7 @@ export declare abstract class BaseUIClass {
|
|
12
12
|
constructor(props: UIProps);
|
13
13
|
protected getLang(): "en" | "zh" | "ja" | "ko" | "ar" | "th" | "pl" | "it" | "de" | "es" | "fr";
|
14
14
|
protected getFont(): Record<string, {
|
15
|
-
data: string | ArrayBuffer | Uint8Array
|
15
|
+
data: string | ArrayBuffer | Uint8Array<ArrayBufferLike>;
|
16
16
|
fallback?: boolean | undefined;
|
17
17
|
subset?: boolean | undefined;
|
18
18
|
}>;
|
@@ -113,7 +113,7 @@ export declare abstract class BaseUIClass {
|
|
113
113
|
}>>;
|
114
114
|
__isSplit: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
115
115
|
}, import("zod").ZodTypeAny, "passthrough">>, "many">, "many">;
|
116
|
-
basePdf: import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodType<ArrayBuffer, import("zod").ZodTypeDef, ArrayBuffer>, import("zod").ZodType<Uint8Array
|
116
|
+
basePdf: import("zod").ZodUnion<[import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodType<ArrayBuffer, import("zod").ZodTypeDef, ArrayBuffer>, import("zod").ZodType<Uint8Array<ArrayBufferLike>, import("zod").ZodTypeDef, Uint8Array<ArrayBufferLike>>]>, import("zod").ZodObject<{
|
117
117
|
width: import("zod").ZodNumber;
|
118
118
|
height: import("zod").ZodNumber;
|
119
119
|
padding: import("zod").ZodTuple<[import("zod").ZodNumber, import("zod").ZodNumber, import("zod").ZodNumber, import("zod").ZodNumber], null>;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import React, { Ref } from 'react';
|
2
|
+
import { Size } from '@pdfme/common';
|
3
|
+
interface GuidesInterface {
|
4
|
+
getGuides(): number[];
|
5
|
+
scroll(pos: number): void;
|
6
|
+
scrollGuides(pos: number): void;
|
7
|
+
loadGuides(guides: number[]): void;
|
8
|
+
resize(): void;
|
9
|
+
}
|
10
|
+
declare const _Guides: ({ paperSize, horizontalRef, verticalRef, }: {
|
11
|
+
paperSize: Size;
|
12
|
+
horizontalRef: Ref<GuidesInterface> | undefined;
|
13
|
+
verticalRef: Ref<GuidesInterface> | undefined;
|
14
|
+
}) => React.JSX.Element;
|
15
|
+
export default _Guides;
|
@@ -1,5 +1,52 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
2
|
+
interface OnDrag {
|
3
|
+
target: HTMLElement | SVGElement;
|
4
|
+
left: number;
|
5
|
+
top: number;
|
6
|
+
beforeDelta: any;
|
7
|
+
beforeDist: any;
|
8
|
+
beforeTranslate: any;
|
9
|
+
delta: any;
|
10
|
+
dist: any;
|
11
|
+
transform: any;
|
12
|
+
translate: any;
|
13
|
+
}
|
14
|
+
interface OnResize {
|
15
|
+
target: HTMLElement | SVGElement;
|
16
|
+
width: number;
|
17
|
+
height: number;
|
18
|
+
direction: string;
|
19
|
+
offsetWidth: number;
|
20
|
+
offsetHeight: number;
|
21
|
+
dist: any;
|
22
|
+
delta: any;
|
23
|
+
transform: any;
|
24
|
+
translate: any;
|
25
|
+
}
|
26
|
+
interface OnRotate {
|
27
|
+
target: HTMLElement | SVGElement;
|
28
|
+
rotate: number;
|
29
|
+
beforeDist: any;
|
30
|
+
beforeDelta: any;
|
31
|
+
beforeRotate: any;
|
32
|
+
dist: any;
|
33
|
+
delta: any;
|
34
|
+
transform: any;
|
35
|
+
}
|
36
|
+
interface OnRotateEnd {
|
37
|
+
target: HTMLElement | SVGElement;
|
38
|
+
}
|
39
|
+
interface OnClick {
|
40
|
+
inputEvent: MouseEvent;
|
41
|
+
inputTarget: any;
|
42
|
+
isTarget: boolean;
|
43
|
+
containsTarget: boolean;
|
44
|
+
isDouble: boolean;
|
45
|
+
datas: any;
|
46
|
+
targets: any[];
|
47
|
+
clientX: number;
|
48
|
+
clientY: number;
|
49
|
+
}
|
3
50
|
type Props = {
|
4
51
|
target: HTMLElement[];
|
5
52
|
bounds: {
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
interface OnDragStart {
|
3
|
+
inputEvent: MouseEvent;
|
4
|
+
stop: () => void;
|
5
|
+
isTrusted: boolean;
|
6
|
+
}
|
7
|
+
interface OnSelect {
|
8
|
+
selected: Element[];
|
9
|
+
added: Element[];
|
10
|
+
removed: Element[];
|
11
|
+
inputEvent: MouseEvent;
|
12
|
+
rect: DOMRect;
|
13
|
+
}
|
14
|
+
type Props = {
|
15
|
+
container: HTMLElement | null;
|
16
|
+
continueSelect: boolean;
|
17
|
+
onDragStart: (e: OnDragStart) => void;
|
18
|
+
onSelect: (e: OnSelect) => void;
|
19
|
+
};
|
20
|
+
declare const _Selecto: (props: Props) => React.JSX.Element;
|
21
|
+
export default _Selecto;
|
package/dist/types/{components → src/components}/Designer/RightSidebar/DetailView/index.d.ts
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import type { SchemaForUI } from '@pdfme/common';
|
3
|
-
import type { SidebarProps } from '../../../../types';
|
3
|
+
import type { SidebarProps } from '../../../../types.js';
|
4
4
|
type DetailViewProps = Pick<SidebarProps, 'size' | 'schemas' | 'schemasList' | 'pageSize' | 'changeSchemas' | 'activeElements' | 'deselectSchema'> & {
|
5
5
|
activeSchema: SchemaForUI;
|
6
6
|
};
|
package/dist/types/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
|
+
declare const SelectableSortableContainer: (props: Pick<SidebarProps, "schemas" | "onEdit" | "onSortEnd" | "hoveringSchemaId" | "onChangeHoveringSchemaId">) => React.JSX.Element;
|
4
|
+
export default SelectableSortableContainer;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
|
+
declare const ListView: (props: Pick<SidebarProps, "schemas" | "onSortEnd" | "onEdit" | "size" | "hoveringSchemaId" | "onChangeHoveringSchemaId" | "changeSchemas">) => React.JSX.Element;
|
4
|
+
export default ListView;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { PreviewProps, Size } from '@pdfme/common';
|
3
3
|
declare const Preview: ({ template, inputs, size, onChangeInput, }: Omit<PreviewProps, "domContainer"> & {
|
4
|
-
onChangeInput?: (
|
4
|
+
onChangeInput?: (args: {
|
5
5
|
index: number;
|
6
6
|
value: string;
|
7
7
|
name: string;
|
8
|
-
}) => void
|
8
|
+
}) => void;
|
9
9
|
size: Size;
|
10
10
|
}) => React.JSX.Element;
|
11
11
|
export default Preview;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Plugins, UIOptions } from '@pdfme/common';
|
2
|
+
export declare const I18nContext: import("react").Context<(key: keyof import("@pdfme/common").Dict, dict?: import("@pdfme/common").Dict) => string>;
|
3
|
+
export declare const FontContext: import("react").Context<Record<string, {
|
4
|
+
data: string | ArrayBuffer | Uint8Array<ArrayBufferLike>;
|
5
|
+
fallback?: boolean | undefined;
|
6
|
+
subset?: boolean | undefined;
|
7
|
+
}>>;
|
8
|
+
export declare const PluginsRegistry: import("react").Context<Plugins>;
|
9
|
+
export declare const OptionsContext: import("react").Context<UIOptions>;
|
10
|
+
export declare const CacheContext: import("react").Context<Map<any, any>>;
|
@@ -4,9 +4,8 @@ export declare const set: <T extends object>(obj: T, path: string | string[], va
|
|
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
6
|
export declare const flatten: <T>(arr: T[][]) => T[];
|
7
|
-
declare const esc = "esc";
|
8
7
|
export declare const initShortCuts: (arg: {
|
9
|
-
move: (command:
|
8
|
+
move: (command: "up" | "down" | "left" | "right", isShift: boolean) => void;
|
10
9
|
remove: () => void;
|
11
10
|
esc: () => void;
|
12
11
|
copy: () => void;
|
@@ -46,7 +45,7 @@ export declare const getUniqueSchemaName: (arg: {
|
|
46
45
|
stackUniqueSchemaNames: string[];
|
47
46
|
}) => string;
|
48
47
|
export declare const moveCommandToChangeSchemasArg: (props: {
|
49
|
-
command:
|
48
|
+
command: "up" | "down" | "left" | "right";
|
50
49
|
activeSchemas: SchemaForUI[];
|
51
50
|
isShift: boolean;
|
52
51
|
pageSize: Size;
|
@@ -73,4 +72,3 @@ export declare const changeSchemas: (args: {
|
|
73
72
|
commitSchemas: (newSchemas: SchemaForUI[]) => void;
|
74
73
|
}) => void;
|
75
74
|
export declare const getMaxZoom: () => number;
|
76
|
-
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { fileURLToPath } from 'url';
|
2
|
+
import { dirname, resolve } from 'path';
|
3
|
+
import reactPlugin from 'eslint-plugin-react';
|
4
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
5
|
+
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
7
|
+
const __dirname = dirname(__filename);
|
8
|
+
|
9
|
+
// Import the root config
|
10
|
+
const rootConfigPath = resolve(__dirname, '../../eslint.config.mjs');
|
11
|
+
const rootConfig = await import(rootConfigPath);
|
12
|
+
|
13
|
+
export default [
|
14
|
+
...rootConfig.default,
|
15
|
+
{
|
16
|
+
files: ['src/**/*.ts', 'src/**/*.tsx'],
|
17
|
+
languageOptions: {
|
18
|
+
parserOptions: {
|
19
|
+
project: ['./tsconfig.json'],
|
20
|
+
tsconfigRootDir: __dirname,
|
21
|
+
ecmaFeatures: {
|
22
|
+
jsx: true,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
},
|
26
|
+
plugins: {
|
27
|
+
react: reactPlugin,
|
28
|
+
'react-hooks': reactHooksPlugin,
|
29
|
+
},
|
30
|
+
settings: {
|
31
|
+
react: {
|
32
|
+
version: 'detect',
|
33
|
+
},
|
34
|
+
},
|
35
|
+
rules: {
|
36
|
+
...reactPlugin.configs.recommended.rules,
|
37
|
+
'react-hooks/rules-of-hooks': 'error',
|
38
|
+
'react-hooks/exhaustive-deps': 'warn',
|
39
|
+
},
|
40
|
+
},
|
41
|
+
];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "5.3.
|
3
|
+
"version": "5.3.9-dev.1",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -30,44 +30,46 @@
|
|
30
30
|
"devBuildType:watch": "tsc --emitDeclarationOnly --watch",
|
31
31
|
"build": "vite build && tsc --emitDeclarationOnly",
|
32
32
|
"clean": "rimraf dist",
|
33
|
-
"lint": "eslint --ext .ts,.tsx src",
|
33
|
+
"lint": "eslint --ext .ts,.tsx src --config eslint.config.mjs --no-error-on-unmatched-pattern",
|
34
34
|
"test": "jest",
|
35
35
|
"prune": "ts-prune src",
|
36
36
|
"prettier": "prettier --write 'src/**/*.{ts,tsx}'"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@pdfme/converter": "*",
|
40
39
|
"@dnd-kit/core": "^6.0.8",
|
41
|
-
"@dnd-kit/sortable": "^
|
42
|
-
"@
|
43
|
-
"
|
40
|
+
"@dnd-kit/sortable": "^10.0.0",
|
41
|
+
"@pdfme/converter": "*",
|
42
|
+
"@scena/react-guides": "^0.28.2",
|
43
|
+
"antd": "^5.24.2",
|
44
44
|
"form-render": "^2.2.16",
|
45
45
|
"hotkeys-js": "^3.8.7",
|
46
46
|
"lucide-react": "^0.460.0",
|
47
47
|
"react": "^16.14.0",
|
48
48
|
"react-dom": "^16.14.0",
|
49
|
-
"react-moveable": "^0.
|
49
|
+
"react-moveable": "^0.56.0",
|
50
50
|
"react-selecto": "^1.12.0"
|
51
51
|
},
|
52
52
|
"devDependencies": {
|
53
53
|
"@pdfme/common": "file:../common",
|
54
54
|
"@pdfme/schemas": "file:../schemas",
|
55
|
-
"@testing-library/jest-dom": "^
|
55
|
+
"@testing-library/jest-dom": "^6.6.3",
|
56
56
|
"@testing-library/react": "^12.1.2",
|
57
|
+
"@types/jest": "^29.5.14",
|
57
58
|
"@types/react": "^17.0.52",
|
58
59
|
"@types/react-dom": "^17.0.18",
|
60
|
+
"@ungap/structured-clone": "^1.3.0",
|
59
61
|
"@vitejs/plugin-react": "^4.2.0",
|
60
|
-
"css-loader": "^6.8.1",
|
61
62
|
"csstype": "^3.1.2",
|
62
|
-
"esbuild": "^0.
|
63
|
-
"eslint-plugin-react": "^7.
|
64
|
-
"eslint-plugin-react-hooks": "^
|
63
|
+
"esbuild": "^0.25.0",
|
64
|
+
"eslint-plugin-react": "^7.37.4",
|
65
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
66
|
+
"is-path-inside": "^4.0.0",
|
65
67
|
"jest-canvas-mock": "^2.3.1",
|
66
68
|
"jest-environment-jsdom": "^29.7.0",
|
67
69
|
"process": "^0.11.10",
|
68
|
-
"vite": "^
|
70
|
+
"vite": "^6.2.0",
|
69
71
|
"vite-plugin-css-injected-by-js": "^3.3.0",
|
70
|
-
"vite-tsconfig-paths": "^
|
72
|
+
"vite-tsconfig-paths": "^5.1.4"
|
71
73
|
},
|
72
74
|
"peerDependencies": {
|
73
75
|
"@pdfme/common": "latest",
|
@@ -88,7 +90,8 @@
|
|
88
90
|
"^antd/es/": "antd/lib/",
|
89
91
|
"^form-render/es/": "form-render/lib/",
|
90
92
|
"^rc-picker/es/": "rc-picker/lib/",
|
91
|
-
"^lodash-es$": "lodash"
|
93
|
+
"^lodash-es$": "lodash",
|
94
|
+
"\\^lucide-react$": "<rootDir>/__mocks__/lucide-react.js"
|
92
95
|
},
|
93
96
|
"resolver": "ts-jest-resolver",
|
94
97
|
"moduleFileExtensions": [
|
@@ -107,6 +110,9 @@
|
|
107
110
|
"testMatch": [
|
108
111
|
"**/*.test.ts",
|
109
112
|
"**/*.test.tsx"
|
113
|
+
],
|
114
|
+
"transformIgnorePatterns": [
|
115
|
+
"/node_modules/(?!lucide-react)"
|
110
116
|
]
|
111
117
|
},
|
112
118
|
"publishConfig": {
|
package/src/Designer.tsx
CHANGED
@@ -8,10 +8,10 @@ import {
|
|
8
8
|
checkTemplate,
|
9
9
|
PDFME_VERSION,
|
10
10
|
} from '@pdfme/common';
|
11
|
-
import { BaseUIClass } from './class';
|
11
|
+
import { BaseUIClass } from './class.js';
|
12
12
|
import { DESTROYED_ERR_MSG } from './constants.js';
|
13
|
-
import DesignerComponent from './components/Designer/index';
|
14
|
-
import AppContextProvider from './components/AppContextProvider';
|
13
|
+
import DesignerComponent from './components/Designer/index.js';
|
14
|
+
import AppContextProvider from './components/AppContextProvider.js';
|
15
15
|
|
16
16
|
class Designer extends BaseUIClass {
|
17
17
|
private onSaveTemplateCallback?: (template: Template) => void;
|
@@ -47,9 +47,9 @@ class Designer extends BaseUIClass {
|
|
47
47
|
public onChangeTemplate(cb: (template: Template) => void) {
|
48
48
|
this.onChangeTemplateCallback = cb;
|
49
49
|
}
|
50
|
-
|
50
|
+
|
51
51
|
public getPageCursor() {
|
52
|
-
return this.pageCursor
|
52
|
+
return this.pageCursor;
|
53
53
|
}
|
54
54
|
|
55
55
|
protected render() {
|
@@ -78,12 +78,12 @@ class Designer extends BaseUIClass {
|
|
78
78
|
}
|
79
79
|
}}
|
80
80
|
onPageCursorChange={(newPageCursor: number) => {
|
81
|
-
this.pageCursor = newPageCursor
|
81
|
+
this.pageCursor = newPageCursor;
|
82
82
|
}}
|
83
83
|
size={this.size}
|
84
84
|
/>
|
85
85
|
</AppContextProvider>,
|
86
|
-
this.domContainer
|
86
|
+
this.domContainer,
|
87
87
|
);
|
88
88
|
}
|
89
89
|
}
|
package/src/Form.tsx
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
3
|
import { PreviewProps } from '@pdfme/common';
|
4
|
-
import { PreviewUI } from './class';
|
4
|
+
import { PreviewUI } from './class.js';
|
5
5
|
import { DESTROYED_ERR_MSG } from './constants.js';
|
6
|
-
import AppContextProvider from './components/AppContextProvider';
|
7
|
-
import Preview from './components/Preview';
|
6
|
+
import AppContextProvider from './components/AppContextProvider.js';
|
7
|
+
import Preview from './components/Preview.js';
|
8
8
|
|
9
9
|
class Form extends PreviewUI {
|
10
10
|
private onChangeInputCallback?: (arg: { index: number; value: string; name: string }) => void;
|
@@ -46,8 +46,6 @@ class Form extends PreviewUI {
|
|
46
46
|
});
|
47
47
|
}
|
48
48
|
|
49
|
-
|
50
|
-
|
51
49
|
protected render() {
|
52
50
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
53
51
|
ReactDOM.render(
|
@@ -75,7 +73,7 @@ class Form extends PreviewUI {
|
|
75
73
|
}}
|
76
74
|
/>
|
77
75
|
</AppContextProvider>,
|
78
|
-
this.domContainer
|
76
|
+
this.domContainer,
|
79
77
|
);
|
80
78
|
}
|
81
79
|
}
|
package/src/Viewer.tsx
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
3
|
import { PreviewProps } from '@pdfme/common';
|
4
|
-
import { PreviewUI } from './class';
|
4
|
+
import { PreviewUI } from './class.js';
|
5
5
|
import { DESTROYED_ERR_MSG } from './constants.js';
|
6
|
-
import Preview from './components/Preview';
|
7
|
-
import AppContextProvider from './components/AppContextProvider';
|
6
|
+
import Preview from './components/Preview.js';
|
7
|
+
import AppContextProvider from './components/AppContextProvider.js';
|
8
8
|
|
9
9
|
class Viewer extends PreviewUI {
|
10
10
|
constructor(props: PreviewProps) {
|
@@ -22,7 +22,7 @@ class Viewer extends PreviewUI {
|
|
22
22
|
>
|
23
23
|
<Preview template={this.template} size={this.size} inputs={this.inputs} />
|
24
24
|
</AppContextProvider>,
|
25
|
-
this.domContainer
|
25
|
+
this.domContainer,
|
26
26
|
);
|
27
27
|
}
|
28
28
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ConfigProvider as ThemeConfigProvider } from 'antd';
|
3
|
-
import { I18nContext, FontContext, PluginsRegistry, OptionsContext } from '../contexts';
|
4
|
-
import { i18n, getDict } from '../i18n';
|
5
|
-
import { defaultTheme } from '../theme';
|
3
|
+
import { I18nContext, FontContext, PluginsRegistry, OptionsContext } from '../contexts.js';
|
4
|
+
import { i18n, getDict } from '../i18n.js';
|
5
|
+
import { defaultTheme } from '../theme.js';
|
6
6
|
import type { Dict, Plugins, Font, Lang, UIOptions } from '@pdfme/common';
|
7
7
|
|
8
8
|
type Props = {
|
@@ -18,7 +18,7 @@ const isObject = (item: any): item is Record<string, any> =>
|
|
18
18
|
|
19
19
|
const deepMerge = <T extends Record<string, any>, U extends Record<string, any>>(
|
20
20
|
target: T,
|
21
|
-
source: U
|
21
|
+
source: U,
|
22
22
|
): T & U => {
|
23
23
|
let output = { ...target } as T & U;
|
24
24
|
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import React, { useContext } from 'react';
|
2
2
|
import { Size } from '@pdfme/common';
|
3
|
+
// Import icons from lucide-react
|
4
|
+
// Note: In tests, these will be mocked by the mock file in __mocks__/lucide-react.js
|
3
5
|
import { Plus, Minus, ChevronLeft, ChevronRight, Ellipsis } from 'lucide-react';
|
4
6
|
|
5
7
|
import type { MenuProps } from 'antd';
|
6
8
|
import { theme, Typography, Button, Dropdown } from 'antd';
|
7
|
-
import { I18nContext } from '../contexts';
|
8
|
-
import { getMaxZoom } from
|
9
|
+
import { I18nContext } from '../contexts.js';
|
10
|
+
import { getMaxZoom } from '../helper.js';
|
9
11
|
|
10
12
|
const { Text } = Typography;
|
11
13
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import React, { Ref } from 'react';
|
2
|
-
import
|
2
|
+
import GuidesComponent from '@scena/react-guides';
|
3
3
|
import { ZOOM, Size } from '@pdfme/common';
|
4
|
-
import { RULER_HEIGHT } from '../../../constants';
|
4
|
+
import { RULER_HEIGHT } from '../../../constants.js';
|
5
5
|
|
6
6
|
const guideStyle = (
|
7
7
|
top: number,
|
8
8
|
left: number,
|
9
9
|
height: number,
|
10
|
-
width: number
|
10
|
+
width: number,
|
11
11
|
): React.CSSProperties => ({
|
12
12
|
position: 'absolute',
|
13
13
|
top,
|
@@ -17,31 +17,40 @@ const guideStyle = (
|
|
17
17
|
background: '#333333',
|
18
18
|
});
|
19
19
|
|
20
|
+
// Define the interface for the Guides component
|
21
|
+
interface GuidesInterface {
|
22
|
+
getGuides(): number[];
|
23
|
+
scroll(pos: number): void;
|
24
|
+
scrollGuides(pos: number): void;
|
25
|
+
loadGuides(guides: number[]): void;
|
26
|
+
resize(): void;
|
27
|
+
}
|
28
|
+
|
20
29
|
const _Guides = ({
|
21
30
|
paperSize,
|
22
31
|
horizontalRef,
|
23
32
|
verticalRef,
|
24
33
|
}: {
|
25
34
|
paperSize: Size;
|
26
|
-
horizontalRef: Ref<
|
27
|
-
verticalRef: Ref<
|
35
|
+
horizontalRef: Ref<GuidesInterface> | undefined;
|
36
|
+
verticalRef: Ref<GuidesInterface> | undefined;
|
28
37
|
}) => (
|
29
38
|
<>
|
30
39
|
<div
|
31
40
|
className="ruler-container"
|
32
41
|
style={guideStyle(-RULER_HEIGHT, -RULER_HEIGHT, RULER_HEIGHT, RULER_HEIGHT)}
|
33
42
|
/>
|
34
|
-
<
|
43
|
+
<GuidesComponent
|
35
44
|
zoom={ZOOM}
|
36
45
|
style={guideStyle(-RULER_HEIGHT, 0, RULER_HEIGHT, paperSize.width)}
|
37
46
|
type="horizontal"
|
38
|
-
ref={horizontalRef}
|
47
|
+
ref={horizontalRef as any}
|
39
48
|
/>
|
40
|
-
<
|
49
|
+
<GuidesComponent
|
41
50
|
zoom={ZOOM}
|
42
51
|
style={guideStyle(0, -RULER_HEIGHT, paperSize.height, RULER_HEIGHT)}
|
43
52
|
type="vertical"
|
44
|
-
ref={verticalRef}
|
53
|
+
ref={verticalRef as any}
|
45
54
|
/>
|
46
55
|
</>
|
47
56
|
);
|