@pdfme/ui 5.3.8-dev.4 → 5.3.8-dev.42
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 +18561 -18317
- package/dist/index.umd.js +169 -180
- package/dist/types/Designer.d.ts +1 -1
- package/dist/types/Form.d.ts +1 -1
- package/dist/types/Viewer.d.ts +1 -1
- package/dist/types/components/Designer/Canvas/Guides.d.ts +9 -3
- package/dist/types/components/Designer/Canvas/Moveable.d.ts +48 -1
- package/dist/types/components/Designer/Canvas/Selecto.d.ts +14 -3
- package/dist/types/components/Designer/RightSidebar/DetailView/index.d.ts +1 -1
- package/dist/types/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +1 -1
- package/dist/types/components/Designer/RightSidebar/ListView/index.d.ts +1 -1
- package/dist/types/components/Designer/RightSidebar/index.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/eslint.config.mjs +41 -0
- package/package.json +17 -12
- package/src/Designer.tsx +3 -3
- package/src/Form.tsx +3 -3
- package/src/Viewer.tsx +3 -3
- package/src/components/AppContextProvider.tsx +3 -3
- package/src/components/CtlBar.tsx +4 -2
- package/src/components/Designer/Canvas/Guides.tsx +17 -8
- package/src/components/Designer/Canvas/Mask.tsx +1 -1
- package/src/components/Designer/Canvas/Moveable.tsx +64 -5
- package/src/components/Designer/Canvas/Selecto.tsx +21 -6
- package/src/components/Designer/Canvas/index.tsx +68 -14
- package/src/components/Designer/LeftSidebar.tsx +4 -4
- package/src/components/Designer/PluginIcon.tsx +1 -1
- package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +1 -1
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +12 -9
- package/src/components/Designer/RightSidebar/ListView/Item.tsx +1 -1
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +5 -5
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +4 -4
- package/src/components/Designer/RightSidebar/ListView/index.tsx +5 -5
- package/src/components/Designer/RightSidebar/index.tsx +4 -4
- package/src/components/Designer/index.tsx +10 -10
- package/src/components/ErrorScreen.tsx +2 -2
- package/src/components/Paper.tsx +2 -2
- package/src/components/Preview.tsx +10 -10
- package/src/components/Renderer.tsx +7 -7
- package/src/components/Root.tsx +3 -5
- package/src/components/StaticSchema.tsx +2 -2
- package/src/contexts.ts +2 -2
- package/src/helper.ts +27 -12
- 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 +3 -3
- package/.eslintrc.cjs +0 -16
- /package/{vite.config.ts → vite.config.mts} +0 -0
package/dist/types/Designer.d.ts
CHANGED
package/dist/types/Form.d.ts
CHANGED
package/dist/types/Viewer.d.ts
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
import React, { Ref } from 'react';
|
2
|
-
import Guides from '@scena/react-guides';
|
3
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
|
+
}
|
4
10
|
declare const _Guides: ({ paperSize, horizontalRef, verticalRef, }: {
|
5
11
|
paperSize: Size;
|
6
|
-
horizontalRef: Ref<
|
7
|
-
verticalRef: Ref<
|
12
|
+
horizontalRef: Ref<GuidesInterface> | undefined;
|
13
|
+
verticalRef: Ref<GuidesInterface> | undefined;
|
8
14
|
}) => React.JSX.Element;
|
9
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: {
|
@@ -1,10 +1,21 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
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
|
+
}
|
3
14
|
type Props = {
|
4
15
|
container: HTMLElement | null;
|
5
16
|
continueSelect: boolean;
|
6
|
-
onDragStart: (e:
|
7
|
-
onSelect: (e:
|
17
|
+
onDragStart: (e: OnDragStart) => void;
|
18
|
+
onSelect: (e: OnSelect) => void;
|
8
19
|
};
|
9
20
|
declare const _Selecto: (props: Props) => React.JSX.Element;
|
10
21
|
export default _Selecto;
|
@@ -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/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import type { SidebarProps } from '../../../../types';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
3
|
declare const SelectableSortableContainer: (props: Pick<SidebarProps, 'schemas' | 'onEdit' | 'onSortEnd' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId'>) => React.JSX.Element;
|
4
4
|
export default SelectableSortableContainer;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import type { SidebarProps } from '../../../../types';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
3
|
declare const ListView: (props: Pick<SidebarProps, 'schemas' | 'onSortEnd' | 'onEdit' | 'size' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId' | 'changeSchemas'>) => React.JSX.Element;
|
4
4
|
export default ListView;
|
package/dist/types/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import Designer from './Designer';
|
2
|
-
import Form from './Form';
|
3
|
-
import Viewer from './Viewer';
|
1
|
+
import Designer from './Designer.js';
|
2
|
+
import Form from './Form.js';
|
3
|
+
import Viewer from './Viewer.js';
|
4
4
|
export { Designer, Viewer, Form };
|
@@ -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.8-dev.
|
3
|
+
"version": "5.3.8-dev.42",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -30,17 +30,17 @@
|
|
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",
|
@@ -56,18 +56,19 @@
|
|
56
56
|
"@testing-library/react": "^12.1.2",
|
57
57
|
"@types/react": "^17.0.52",
|
58
58
|
"@types/react-dom": "^17.0.18",
|
59
|
+
"@ungap/structured-clone": "^1.3.0",
|
59
60
|
"@vitejs/plugin-react": "^4.2.0",
|
60
|
-
"css-loader": "^6.8.1",
|
61
61
|
"csstype": "^3.1.2",
|
62
|
-
"esbuild": "^0.
|
63
|
-
"eslint-plugin-react": "^7.
|
64
|
-
"eslint-plugin-react-hooks": "^
|
62
|
+
"esbuild": "^0.25.0",
|
63
|
+
"eslint-plugin-react": "^7.37.4",
|
64
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
65
|
+
"is-path-inside": "^3.0.3",
|
65
66
|
"jest-canvas-mock": "^2.3.1",
|
66
67
|
"jest-environment-jsdom": "^29.7.0",
|
67
68
|
"process": "^0.11.10",
|
68
69
|
"vite": "^5.0.0",
|
69
70
|
"vite-plugin-css-injected-by-js": "^3.3.0",
|
70
|
-
"vite-tsconfig-paths": "^
|
71
|
+
"vite-tsconfig-paths": "^5.1.4"
|
71
72
|
},
|
72
73
|
"peerDependencies": {
|
73
74
|
"@pdfme/common": "latest",
|
@@ -88,7 +89,8 @@
|
|
88
89
|
"^antd/es/": "antd/lib/",
|
89
90
|
"^form-render/es/": "form-render/lib/",
|
90
91
|
"^rc-picker/es/": "rc-picker/lib/",
|
91
|
-
"^lodash-es$": "lodash"
|
92
|
+
"^lodash-es$": "lodash",
|
93
|
+
"\\^lucide-react$": "<rootDir>/__mocks__/lucide-react.js"
|
92
94
|
},
|
93
95
|
"resolver": "ts-jest-resolver",
|
94
96
|
"moduleFileExtensions": [
|
@@ -107,6 +109,9 @@
|
|
107
109
|
"testMatch": [
|
108
110
|
"**/*.test.ts",
|
109
111
|
"**/*.test.tsx"
|
112
|
+
],
|
113
|
+
"transformIgnorePatterns": [
|
114
|
+
"/node_modules/(?!lucide-react)"
|
110
115
|
]
|
111
116
|
},
|
112
117
|
"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;
|
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;
|
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) {
|
@@ -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 = {
|
@@ -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 "../helper";
|
9
|
+
import { I18nContext } from '../contexts.js';
|
10
|
+
import { getMaxZoom } from "../helper.js";
|
9
11
|
|
10
12
|
const { Text } = Typography;
|
11
13
|
|
@@ -1,7 +1,7 @@
|
|
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,
|
@@ -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
|
);
|
@@ -1,7 +1,65 @@
|
|
1
1
|
import React, { useEffect, forwardRef, Ref } from 'react';
|
2
|
-
import
|
2
|
+
import MoveableComponent from 'react-moveable';
|
3
3
|
import { theme } from 'antd';
|
4
4
|
|
5
|
+
// Define the types locally since they're not exported properly
|
6
|
+
interface OnDrag {
|
7
|
+
target: HTMLElement | SVGElement;
|
8
|
+
left: number;
|
9
|
+
top: number;
|
10
|
+
// Add additional properties that might be used in the original library
|
11
|
+
beforeDelta: any;
|
12
|
+
beforeDist: any;
|
13
|
+
beforeTranslate: any;
|
14
|
+
delta: any;
|
15
|
+
dist: any;
|
16
|
+
transform: any;
|
17
|
+
translate: any;
|
18
|
+
}
|
19
|
+
|
20
|
+
interface OnResize {
|
21
|
+
target: HTMLElement | SVGElement;
|
22
|
+
width: number;
|
23
|
+
height: number;
|
24
|
+
direction: string;
|
25
|
+
// Add additional properties that might be used in the original library
|
26
|
+
offsetWidth: number;
|
27
|
+
offsetHeight: number;
|
28
|
+
dist: any;
|
29
|
+
delta: any;
|
30
|
+
transform: any;
|
31
|
+
translate: any;
|
32
|
+
}
|
33
|
+
|
34
|
+
interface OnRotate {
|
35
|
+
target: HTMLElement | SVGElement;
|
36
|
+
rotate: number;
|
37
|
+
// Add additional properties that might be used in the original library
|
38
|
+
beforeDist: any;
|
39
|
+
beforeDelta: any;
|
40
|
+
beforeRotate: any;
|
41
|
+
dist: any;
|
42
|
+
delta: any;
|
43
|
+
transform: any;
|
44
|
+
}
|
45
|
+
|
46
|
+
interface OnRotateEnd {
|
47
|
+
target: HTMLElement | SVGElement;
|
48
|
+
}
|
49
|
+
|
50
|
+
interface OnClick {
|
51
|
+
inputEvent: MouseEvent;
|
52
|
+
// Add additional properties that might be used in the original library
|
53
|
+
inputTarget: any;
|
54
|
+
isTarget: boolean;
|
55
|
+
containsTarget: boolean;
|
56
|
+
isDouble: boolean;
|
57
|
+
datas: any;
|
58
|
+
targets: any[];
|
59
|
+
clientX: number;
|
60
|
+
clientY: number;
|
61
|
+
}
|
62
|
+
|
5
63
|
type Props = {
|
6
64
|
target: HTMLElement[];
|
7
65
|
bounds: { left: number; top: number; bottom: number; right: number };
|
@@ -39,7 +97,8 @@ const _Moveable = (props: Props, ref: Ref<any>) => {
|
|
39
97
|
}, [props.target]);
|
40
98
|
|
41
99
|
return (
|
42
|
-
|
100
|
+
// @ts-ignore
|
101
|
+
<MoveableComponent
|
43
102
|
style={{ zIndex: 1 }}
|
44
103
|
className={className}
|
45
104
|
rootContainer={document ? document.body : undefined}
|
@@ -59,18 +118,18 @@ const _Moveable = (props: Props, ref: Ref<any>) => {
|
|
59
118
|
keepRatio={props.keepRatio}
|
60
119
|
onRotate={props.onRotate}
|
61
120
|
onRotateEnd={props.onRotateEnd}
|
62
|
-
onRotateGroup={({ events }) => {
|
121
|
+
onRotateGroup={({ events }: { events: any[] }) => {
|
63
122
|
events.forEach(props.onRotate);
|
64
123
|
}}
|
65
124
|
onRotateGroupEnd={props.onRotateGroupEnd}
|
66
125
|
onDrag={props.onDrag}
|
67
|
-
onDragGroup={({ events }) => {
|
126
|
+
onDragGroup={({ events }: { events: any[] }) => {
|
68
127
|
events.forEach(props.onDrag);
|
69
128
|
}}
|
70
129
|
onDragEnd={props.onDragEnd}
|
71
130
|
onDragGroupEnd={props.onDragGroupEnd}
|
72
131
|
onResize={props.onResize}
|
73
|
-
onResizeGroup={({ events }) => {
|
132
|
+
onResizeGroup={({ events }: { events: any[] }) => {
|
74
133
|
events.forEach(props.onResize);
|
75
134
|
}}
|
76
135
|
onResizeEnd={props.onResizeEnd}
|
@@ -1,13 +1,28 @@
|
|
1
1
|
import React, { useEffect } from 'react';
|
2
|
-
import
|
3
|
-
import { SELECTABLE_CLASSNAME } from '../../../constants';
|
2
|
+
import SelectoComponent from 'react-selecto';
|
3
|
+
import { SELECTABLE_CLASSNAME } from '../../../constants.js';
|
4
4
|
import { theme } from 'antd';
|
5
5
|
|
6
|
+
// Define the types locally to match what's expected in Canvas/index.tsx
|
7
|
+
interface OnDragStart {
|
8
|
+
inputEvent: MouseEvent;
|
9
|
+
stop: () => void;
|
10
|
+
isTrusted: boolean;
|
11
|
+
}
|
12
|
+
|
13
|
+
interface OnSelect {
|
14
|
+
selected: Element[];
|
15
|
+
added: Element[];
|
16
|
+
removed: Element[];
|
17
|
+
inputEvent: MouseEvent;
|
18
|
+
rect: DOMRect;
|
19
|
+
}
|
20
|
+
|
6
21
|
type Props = {
|
7
22
|
container: HTMLElement | null;
|
8
23
|
continueSelect: boolean;
|
9
|
-
onDragStart: (e:
|
10
|
-
onSelect: (e:
|
24
|
+
onDragStart: (e: OnDragStart) => void;
|
25
|
+
onSelect: (e: OnSelect) => void;
|
11
26
|
};
|
12
27
|
|
13
28
|
const className = 'pdfme-selecto';
|
@@ -24,7 +39,7 @@ const _Selecto = (props: Props) => {
|
|
24
39
|
}, [props.container]);
|
25
40
|
|
26
41
|
return (
|
27
|
-
<
|
42
|
+
<SelectoComponent
|
28
43
|
className={className}
|
29
44
|
selectFromInside={false}
|
30
45
|
selectByClick
|
@@ -34,7 +49,7 @@ const _Selecto = (props: Props) => {
|
|
34
49
|
container={props.container}
|
35
50
|
continueSelect={props.continueSelect}
|
36
51
|
onDragStart={props.onDragStart}
|
37
|
-
onSelect={props.onSelect}
|
52
|
+
onSelect={(e: any) => props.onSelect(e as OnSelect)}
|
38
53
|
/>
|
39
54
|
);
|
40
55
|
};
|
@@ -10,22 +10,74 @@ import React, {
|
|
10
10
|
useCallback,
|
11
11
|
} from 'react';
|
12
12
|
import { theme, Button } from 'antd';
|
13
|
-
import { OnDrag, OnResize, OnClick, OnRotate } from 'react-moveable';
|
14
13
|
import { ZOOM, SchemaForUI, Size, ChangeSchemas, BasePdf, isBlankPdf, replacePlaceholders } from '@pdfme/common';
|
15
|
-
import { PluginsRegistry } from '../../../contexts';
|
14
|
+
import { PluginsRegistry } from '../../../contexts.js';
|
16
15
|
import { X } from 'lucide-react';
|
17
|
-
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../../constants';
|
18
|
-
import { usePrevious } from '../../../hooks';
|
19
|
-
import { uuid, round, flatten } from '../../../helper';
|
20
|
-
import Paper from '../../Paper';
|
21
|
-
import Renderer from '../../Renderer';
|
22
|
-
import Selecto from './Selecto';
|
23
|
-
import Moveable from './Moveable';
|
24
|
-
import Guides from './Guides';
|
25
|
-
import Mask from './Mask';
|
26
|
-
import Padding from './Padding';
|
27
|
-
import StaticSchema from '../../StaticSchema';
|
16
|
+
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
|
17
|
+
import { usePrevious } from '../../../hooks.js';
|
18
|
+
import { uuid, round, flatten } from '../../../helper.js';
|
19
|
+
import Paper from '../../Paper.js';
|
20
|
+
import Renderer from '../../Renderer.js';
|
21
|
+
import Selecto from './Selecto.js';
|
22
|
+
import Moveable from './Moveable.js';
|
23
|
+
import Guides from './Guides.js';
|
24
|
+
import Mask from './Mask.js';
|
25
|
+
import Padding from './Padding.js';
|
26
|
+
import StaticSchema from '../../StaticSchema.js';
|
27
|
+
|
28
|
+
// Define the interfaces locally since they're not exported properly
|
29
|
+
interface OnDrag {
|
30
|
+
target: HTMLElement | SVGElement;
|
31
|
+
left: number;
|
32
|
+
top: number;
|
33
|
+
// Add additional properties that might be used in the original library
|
34
|
+
beforeDelta: any;
|
35
|
+
beforeDist: any;
|
36
|
+
beforeTranslate: any;
|
37
|
+
delta: any;
|
38
|
+
dist: any;
|
39
|
+
transform: any;
|
40
|
+
translate: any;
|
41
|
+
}
|
42
|
+
|
43
|
+
interface OnResize {
|
44
|
+
target: HTMLElement | SVGElement;
|
45
|
+
width: number;
|
46
|
+
height: number;
|
47
|
+
direction: string;
|
48
|
+
// Add additional properties that might be used in the original library
|
49
|
+
offsetWidth: number;
|
50
|
+
offsetHeight: number;
|
51
|
+
dist: any;
|
52
|
+
delta: any;
|
53
|
+
transform: any;
|
54
|
+
translate: any;
|
55
|
+
}
|
28
56
|
|
57
|
+
interface OnRotate {
|
58
|
+
target: HTMLElement | SVGElement;
|
59
|
+
rotate: number;
|
60
|
+
// Add additional properties that might be used in the original library
|
61
|
+
beforeDist: any;
|
62
|
+
beforeDelta: any;
|
63
|
+
beforeRotate: any;
|
64
|
+
dist: any;
|
65
|
+
delta: any;
|
66
|
+
transform: any;
|
67
|
+
}
|
68
|
+
|
69
|
+
interface OnClick {
|
70
|
+
inputEvent: MouseEvent;
|
71
|
+
// Add additional properties that might be used in the original library
|
72
|
+
inputTarget: any;
|
73
|
+
isTarget: boolean;
|
74
|
+
containsTarget: boolean;
|
75
|
+
isDouble: boolean;
|
76
|
+
datas: any;
|
77
|
+
targets: any[];
|
78
|
+
clientX: number;
|
79
|
+
clientY: number;
|
80
|
+
}
|
29
81
|
|
30
82
|
const mm2px = (mm: number) => mm * 3.7795275591;
|
31
83
|
|
@@ -357,7 +409,9 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
|
|
357
409
|
if (paperRefs.current[pageCursor] === inputEvent.target) {
|
358
410
|
onEdit([]);
|
359
411
|
}
|
360
|
-
if
|
412
|
+
// Check if the target is an HTMLElement and has an id property
|
413
|
+
const targetElement = inputEvent.target as HTMLElement;
|
414
|
+
if (targetElement && targetElement.id === DELETE_BTN_ID) {
|
361
415
|
removeSchemas(activeElements.map((ae) => ae.id));
|
362
416
|
}
|
363
417
|
}}
|