@pdfme/ui 5.3.8-dev.3 → 5.3.8-dev.36

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.
Files changed (49) hide show
  1. package/__mocks__/lucide-react.js +19 -0
  2. package/dist/index.es.js +18536 -18259
  3. package/dist/index.umd.js +169 -180
  4. package/dist/types/Designer.d.ts +1 -1
  5. package/dist/types/Form.d.ts +1 -1
  6. package/dist/types/Viewer.d.ts +1 -1
  7. package/dist/types/components/Designer/Canvas/Guides.d.ts +9 -3
  8. package/dist/types/components/Designer/Canvas/Moveable.d.ts +48 -1
  9. package/dist/types/components/Designer/Canvas/Selecto.d.ts +14 -3
  10. package/dist/types/components/Designer/RightSidebar/DetailView/index.d.ts +1 -1
  11. package/dist/types/components/Designer/RightSidebar/ListView/SelectableSortableContainer.d.ts +1 -1
  12. package/dist/types/components/Designer/RightSidebar/ListView/index.d.ts +1 -1
  13. package/dist/types/components/Designer/RightSidebar/index.d.ts +1 -1
  14. package/dist/types/contexts.d.ts +1 -1
  15. package/dist/types/index.d.ts +3 -3
  16. package/package.json +13 -9
  17. package/src/Designer.tsx +3 -3
  18. package/src/Form.tsx +3 -3
  19. package/src/Viewer.tsx +3 -3
  20. package/src/components/AppContextProvider.tsx +3 -3
  21. package/src/components/CtlBar.tsx +4 -2
  22. package/src/components/Designer/Canvas/Guides.tsx +17 -8
  23. package/src/components/Designer/Canvas/Mask.tsx +1 -1
  24. package/src/components/Designer/Canvas/Moveable.tsx +64 -5
  25. package/src/components/Designer/Canvas/Selecto.tsx +21 -6
  26. package/src/components/Designer/Canvas/index.tsx +68 -14
  27. package/src/components/Designer/LeftSidebar.tsx +4 -4
  28. package/src/components/Designer/PluginIcon.tsx +1 -1
  29. package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +1 -1
  30. package/src/components/Designer/RightSidebar/DetailView/index.tsx +13 -9
  31. package/src/components/Designer/RightSidebar/ListView/Item.tsx +1 -1
  32. package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +5 -5
  33. package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +4 -4
  34. package/src/components/Designer/RightSidebar/ListView/index.tsx +5 -5
  35. package/src/components/Designer/RightSidebar/index.tsx +4 -4
  36. package/src/components/Designer/index.tsx +10 -10
  37. package/src/components/ErrorScreen.tsx +2 -2
  38. package/src/components/Paper.tsx +2 -2
  39. package/src/components/Preview.tsx +10 -10
  40. package/src/components/Renderer.tsx +7 -7
  41. package/src/components/Root.tsx +3 -3
  42. package/src/components/StaticSchema.tsx +2 -2
  43. package/src/contexts.ts +2 -2
  44. package/src/helper.ts +27 -12
  45. package/src/index.ts +3 -3
  46. package/src/types/react-guides.d.ts +22 -0
  47. package/src/types/react-selecto.d.ts +35 -0
  48. package/tsconfig.json +2 -2
  49. /package/{vite.config.ts → vite.config.mts} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { Template, DesignerProps } from '@pdfme/common';
2
- import { BaseUIClass } from './class';
2
+ import { BaseUIClass } from './class.js';
3
3
  declare class Designer extends BaseUIClass {
4
4
  private onSaveTemplateCallback?;
5
5
  private onChangeTemplateCallback?;
@@ -1,5 +1,5 @@
1
1
  import { PreviewProps } from '@pdfme/common';
2
- import { PreviewUI } from './class';
2
+ import { PreviewUI } from './class.js';
3
3
  declare class Form extends PreviewUI {
4
4
  private onChangeInputCallback?;
5
5
  constructor(props: PreviewProps);
@@ -1,5 +1,5 @@
1
1
  import { PreviewProps } from '@pdfme/common';
2
- import { PreviewUI } from './class';
2
+ import { PreviewUI } from './class.js';
3
3
  declare class Viewer extends PreviewUI {
4
4
  constructor(props: PreviewProps);
5
5
  protected render(): void;
@@ -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<Guides> | undefined;
7
- verticalRef: Ref<Guides> | undefined;
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
- import { OnDrag, OnResize, OnRotate, OnRotateEnd, OnClick } from 'react-moveable';
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
- import { OnDragStart as _OnDragStart, OnSelect as _OnSelect } from 'react-selecto';
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: _OnDragStart) => void;
7
- onSelect: (e: _OnSelect) => void;
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
  };
@@ -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;
@@ -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 Sidebar: (props: SidebarProps) => React.JSX.Element;
4
4
  export default Sidebar;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ /// <reference types="react" resolution-mode="require"/>
2
2
  import { Plugins, UIOptions } from '@pdfme/common';
3
3
  export declare const I18nContext: import("react").Context<(key: "cancel" | "close" | "set" | "clear" | "field" | "fieldName" | "align" | "width" | "opacity" | "height" | "rotate" | "edit" | "required" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "type" | "errorOccurred" | "errorBulkUpdateFieldName" | "commitBulkUpdateFieldName" | "bulkUpdateFieldName" | "addPageAfter" | "removePage" | "removePageConfirm" | "validation.uniqueName" | "validation.hexColor" | "validation.dateTimeFormat" | "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.showHead" | "schemas.table.headStyle" | "schemas.table.bodyStyle" | "schemas.table.columnStyle" | "schemas.date.format" | "schemas.date.locale" | "schemas.select.options" | "schemas.select.optionPlaceholder" | "schemas.radioGroup.groupName", dict?: {
4
4
  cancel: string;
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "@pdfme/ui",
3
- "version": "5.3.8-dev.3",
4
+ "version": "5.3.8-dev.36",
4
5
  "sideEffects": false,
5
6
  "author": "hand-dot",
6
7
  "license": "MIT",
@@ -36,11 +37,11 @@
36
37
  "prettier": "prettier --write 'src/**/*.{ts,tsx}'"
37
38
  },
38
39
  "dependencies": {
39
- "@pdfme/converter": "*",
40
40
  "@dnd-kit/core": "^6.0.8",
41
- "@dnd-kit/sortable": "^7.0.2",
42
- "@scena/react-guides": "^0.16.0",
43
- "antd": "^5.9.4",
41
+ "@dnd-kit/sortable": "^10.0.0",
42
+ "@pdfme/converter": "*",
43
+ "@scena/react-guides": "^0.28.2",
44
+ "antd": "^5.24.2",
44
45
  "form-render": "^2.2.16",
45
46
  "hotkeys-js": "^3.8.7",
46
47
  "lucide-react": "^0.460.0",
@@ -57,9 +58,8 @@
57
58
  "@types/react": "^17.0.52",
58
59
  "@types/react-dom": "^17.0.18",
59
60
  "@vitejs/plugin-react": "^4.2.0",
60
- "css-loader": "^6.8.1",
61
61
  "csstype": "^3.1.2",
62
- "esbuild": "^0.19.5",
62
+ "esbuild": "^0.25.0",
63
63
  "eslint-plugin-react": "^7.28.0",
64
64
  "eslint-plugin-react-hooks": "^4.3.0",
65
65
  "jest-canvas-mock": "^2.3.1",
@@ -67,7 +67,7 @@
67
67
  "process": "^0.11.10",
68
68
  "vite": "^5.0.0",
69
69
  "vite-plugin-css-injected-by-js": "^3.3.0",
70
- "vite-tsconfig-paths": "^4.2.1"
70
+ "vite-tsconfig-paths": "^5.1.4"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "@pdfme/common": "latest",
@@ -88,7 +88,8 @@
88
88
  "^antd/es/": "antd/lib/",
89
89
  "^form-render/es/": "form-render/lib/",
90
90
  "^rc-picker/es/": "rc-picker/lib/",
91
- "^lodash-es$": "lodash"
91
+ "^lodash-es$": "lodash",
92
+ "\\^lucide-react$": "<rootDir>/__mocks__/lucide-react.js"
92
93
  },
93
94
  "resolver": "ts-jest-resolver",
94
95
  "moduleFileExtensions": [
@@ -107,6 +108,9 @@
107
108
  "testMatch": [
108
109
  "**/*.test.ts",
109
110
  "**/*.test.tsx"
111
+ ],
112
+ "transformIgnorePatterns": [
113
+ "/node_modules/(?!lucide-react)"
110
114
  ]
111
115
  },
112
116
  "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 Guides from '@scena/react-guides';
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<Guides> | undefined;
27
- verticalRef: Ref<Guides> | undefined;
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
- <Guides
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
- <Guides
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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Size } from '@pdfme/common';
3
- import { RULER_HEIGHT } from '../../../constants';
3
+ import { RULER_HEIGHT } from '../../../constants.js';
4
4
  import { theme } from 'antd';
5
5
 
6
6
  const Mask = ({ width, height }: Size) => (
@@ -1,7 +1,65 @@
1
1
  import React, { useEffect, forwardRef, Ref } from 'react';
2
- import Moveable, { OnDrag, OnResize, OnRotate, OnRotateEnd, OnClick } from 'react-moveable';
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
- <Moveable
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 Selecto, { OnDragStart as _OnDragStart, OnSelect as _OnSelect } from 'react-selecto';
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: _OnDragStart) => void;
10
- onSelect: (e: _OnSelect) => void;
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
- <Selecto
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 (inputEvent.target?.id === DELETE_BTN_ID) {
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
  }}
@@ -7,10 +7,10 @@ import {
7
7
  import { theme, Button } from 'antd';
8
8
  import { useDraggable } from '@dnd-kit/core';
9
9
  import { CSS } from "@dnd-kit/utilities";
10
- import Renderer from '../Renderer';
11
- import { LEFT_SIDEBAR_WIDTH } from '../../constants';
12
- import { PluginsRegistry } from '../../contexts';
13
- import PluginIcon from "./PluginIcon";
10
+ import Renderer from '../Renderer.js';
11
+ import { LEFT_SIDEBAR_WIDTH } from '../../constants.js';
12
+ import { PluginsRegistry } from '../../contexts.js';
13
+ import PluginIcon from "./PluginIcon.js";
14
14
 
15
15
 
16
16
  const Draggable = (props: { plugin: Plugin<any>, scale: number, basePdf: BasePdf, children: React.ReactNode }) => {
@@ -1,6 +1,6 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { Plugin } from "@pdfme/common";
3
- import { OptionsContext } from '../../contexts';
3
+ import { OptionsContext } from '../../contexts.js';
4
4
  import { theme } from 'antd';
5
5
 
6
6
 
@@ -11,7 +11,7 @@ import {
11
11
  AlignVerticalSpaceAround,
12
12
  AlignHorizontalSpaceAround,
13
13
  } from 'lucide-react'
14
- import { round } from '../../../../helper';
14
+ import { round } from '../../../../helper.js';
15
15
 
16
16
  const AlignWidget = (props: PropPanelWidgetProps) => {
17
17
  const { activeElements, changeSchemas, schemas, pageSize, schema } = props;