@pdfme/ui 5.3.11 → 5.3.12-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/index.es.js +40494 -42705
  2. package/dist/index.umd.js +231 -231
  3. package/dist/types/src/components/Designer/Canvas/Guides.d.ts +3 -9
  4. package/dist/types/src/components/Designer/Canvas/Moveable.d.ts +2 -49
  5. package/dist/types/src/components/Designer/Canvas/Selecto.d.ts +5 -16
  6. package/dist/types/src/components/Designer/PluginIcon.d.ts +2 -2
  7. package/dist/types/src/components/Designer/RightSidebar/ListView/Item.d.ts +17 -0
  8. package/dist/types/src/components/Renderer.d.ts +1 -10
  9. package/dist/types/src/constants.d.ts +1 -1
  10. package/dist/types/src/contexts.d.ts +1 -1
  11. package/dist/types/src/helper.d.ts +3 -4
  12. package/package.json +3 -3
  13. package/src/components/AppContextProvider.tsx +23 -10
  14. package/src/components/CtlBar.tsx +2 -2
  15. package/src/components/Designer/Canvas/Guides.tsx +4 -13
  16. package/src/components/Designer/Canvas/Moveable.tsx +21 -76
  17. package/src/components/Designer/Canvas/Selecto.tsx +12 -24
  18. package/src/components/Designer/Canvas/index.tsx +51 -72
  19. package/src/components/Designer/LeftSidebar.tsx +2 -2
  20. package/src/components/Designer/PluginIcon.tsx +15 -3
  21. package/src/components/Designer/RightSidebar/DetailView/AlignWidget.tsx +105 -19
  22. package/src/components/Designer/RightSidebar/DetailView/ButtonGroupWidget.tsx +14 -11
  23. package/src/components/Designer/RightSidebar/DetailView/index.tsx +170 -48
  24. package/src/components/Designer/RightSidebar/ListView/Item.tsx +114 -88
  25. package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +23 -3
  26. package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +21 -4
  27. package/src/components/Designer/index.tsx +14 -9
  28. package/src/components/Preview.tsx +5 -5
  29. package/src/components/Renderer.tsx +43 -37
  30. package/src/components/Root.tsx +1 -1
  31. package/src/constants.ts +1 -1
  32. package/src/contexts.ts +1 -1
  33. package/src/helper.ts +136 -38
  34. package/src/types/react-guides.d.ts +0 -22
  35. package/src/types/react-selecto.d.ts +0 -35
@@ -1,15 +1,9 @@
1
1
  import React, { Ref } from 'react';
2
+ import GuidesComponent from '@scena/react-guides';
2
3
  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
4
  declare const _Guides: ({ paperSize, horizontalRef, verticalRef, }: {
11
5
  paperSize: Size;
12
- horizontalRef: Ref<GuidesInterface> | undefined;
13
- verticalRef: Ref<GuidesInterface> | undefined;
6
+ horizontalRef: Ref<GuidesComponent> | undefined;
7
+ verticalRef: Ref<GuidesComponent> | undefined;
14
8
  }) => React.JSX.Element;
15
9
  export default _Guides;
@@ -1,52 +1,5 @@
1
1
  import React from 'react';
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
- }
2
+ import MoveableComponent, { OnDrag, OnRotate, OnRotateEnd, OnClick, OnResize } from 'react-moveable';
50
3
  type Props = {
51
4
  target: HTMLElement[];
52
5
  bounds: {
@@ -80,5 +33,5 @@ type Props = {
80
33
  }) => void;
81
34
  onClick: (e: OnClick) => void;
82
35
  };
83
- declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<any>>;
36
+ declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<MoveableComponent<{}>>>;
84
37
  export default _default;
@@ -1,21 +1,10 @@
1
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
- }
2
+ import { OnSelect as SelectoOnSelect, OnDragStart as SelectoOnDragStart } from 'react-selecto';
14
3
  type Props = {
15
4
  container: HTMLElement | null;
16
5
  continueSelect: boolean;
17
- onDragStart: (e: OnDragStart) => void;
18
- onSelect: (e: OnSelect) => void;
6
+ onDragStart: (e: SelectoOnDragStart) => void;
7
+ onSelect: (e: SelectoOnSelect) => void;
19
8
  };
20
- declare const _Selecto: (props: Props) => React.JSX.Element;
21
- export default _Selecto;
9
+ declare const Selecto: (props: Props) => React.JSX.Element;
10
+ export default Selecto;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { Plugin } from '@pdfme/common';
2
+ import { Plugin, Schema } from '@pdfme/common';
3
3
  interface PluginIconProps {
4
- plugin: Plugin<any>;
4
+ plugin: Plugin<Schema>;
5
5
  label: string;
6
6
  size?: number;
7
7
  styles?: React.CSSProperties;
@@ -1,27 +1,44 @@
1
1
  import React from 'react';
2
2
  import { DraggableSyntheticListeners } from '@dnd-kit/core';
3
3
  interface Props {
4
+ /** Content to display in the item */
4
5
  value: React.ReactNode;
6
+ /** Optional icon to display */
5
7
  icon?: React.ReactNode;
8
+ /** Custom styles for the item */
6
9
  style?: React.CSSProperties;
10
+ /** Status indicator for the item */
7
11
  status?: 'is-warning' | 'is-danger';
12
+ /** Title attribute for the item */
8
13
  title?: string;
14
+ /** Whether the item is required */
9
15
  required?: boolean;
16
+ /** Whether the item is read-only */
10
17
  readOnly?: boolean;
18
+ /** Whether the item is being dragged as an overlay */
11
19
  dragOverlay?: boolean;
20
+ /** Click handler for the item */
12
21
  onClick?: () => void;
22
+ /** Mouse enter handler */
13
23
  onMouseEnter?: () => void;
24
+ /** Mouse leave handler */
14
25
  onMouseLeave?: () => void;
26
+ /** Whether the item is currently being dragged */
15
27
  dragging?: boolean;
28
+ /** Whether items are being sorted */
16
29
  sorting?: boolean;
30
+ /** CSS transition value */
17
31
  transition?: string;
32
+ /** Transform data for the item */
18
33
  transform?: {
19
34
  x: number;
20
35
  y: number;
21
36
  scaleX: number;
22
37
  scaleY: number;
23
38
  } | null;
39
+ /** Whether to fade the item in */
24
40
  fadeIn?: boolean;
41
+ /** Drag listeners from dnd-kit */
25
42
  listeners?: DraggableSyntheticListeners;
26
43
  }
27
44
  declare const Item: React.MemoExoticComponent<React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLLIElement>>>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Mode, UIRenderProps, SchemaForUI, BasePdf, Schema, Plugin, UIOptions } from '@pdfme/common';
2
+ import { UIRenderProps, SchemaForUI, BasePdf, Schema } from '@pdfme/common';
3
3
  type RendererProps = Omit<UIRenderProps<Schema>, 'schema' | 'rootElement' | 'options' | 'theme' | 'i18n' | '_cache'> & {
4
4
  basePdf: BasePdf;
5
5
  schema: SchemaForUI;
@@ -9,14 +9,5 @@ type RendererProps = Omit<UIRenderProps<Schema>, 'schema' | 'rootElement' | 'opt
9
9
  scale: number;
10
10
  selectable?: boolean;
11
11
  };
12
- type ReRenderCheckProps = {
13
- plugin: Plugin<any>;
14
- value: string;
15
- mode: Mode;
16
- scale: number;
17
- schema: SchemaForUI;
18
- options: UIOptions;
19
- };
20
- export declare const useRerenderDependencies: (arg: ReRenderCheckProps) => (string | number)[];
21
12
  declare const Renderer: (props: RendererProps) => React.JSX.Element;
22
13
  export default Renderer;
@@ -1,4 +1,4 @@
1
- export declare const DEFAULT_LANG: "en";
1
+ export declare const DEFAULT_LANG = "en";
2
2
  export declare const DESTROYED_ERR_MSG = "[@pdfme/ui] this instance is already destroyed";
3
3
  export declare const SELECTABLE_CLASSNAME = "selectable";
4
4
  export declare const RULER_HEIGHT = 30;
@@ -7,4 +7,4 @@ export declare const FontContext: import("react").Context<Record<string, {
7
7
  }>>;
8
8
  export declare const PluginsRegistry: import("react").Context<Plugins>;
9
9
  export declare const OptionsContext: import("react").Context<UIOptions>;
10
- export declare const CacheContext: import("react").Context<Map<any, any>>;
10
+ export declare const CacheContext: import("react").Context<Map<string | number, unknown>>;
@@ -1,7 +1,6 @@
1
1
  import { Template, BasePdf, SchemaForUI, Size, Plugins } from '@pdfme/common';
2
2
  export declare const uuid: () => string;
3
- export declare const set: <T extends object>(obj: T, path: string | string[], value: any) => void;
4
- export declare const debounce: <T extends Function>(cb: T, wait?: number) => T;
3
+ export declare const debounce: <T extends (...args: unknown[]) => unknown>(cb: T, wait?: number) => T;
5
4
  export declare const round: (number: number, precision: number) => number;
6
5
  export declare const flatten: <T>(arr: T[][]) => T[];
7
6
  export declare const initShortCuts: (arg: {
@@ -59,7 +58,7 @@ export declare const getSidebarContentHeight: (sidebarHeight: number) => number;
59
58
  export declare const changeSchemas: (args: {
60
59
  objs: {
61
60
  key: string;
62
- value: any;
61
+ value: unknown;
63
62
  schemaId: string;
64
63
  }[];
65
64
  schemas: SchemaForUI[];
@@ -71,4 +70,4 @@ export declare const changeSchemas: (args: {
71
70
  };
72
71
  commitSchemas: (newSchemas: SchemaForUI[]) => void;
73
72
  }) => void;
74
- export declare const getMaxZoom: () => number;
73
+ export declare const useMaxZoom: () => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.3.11",
3
+ "version": "5.3.12-dev.2",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
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 --config eslint.config.mjs --no-error-on-unmatched-pattern",
33
+ "lint": "eslint --ext .ts,.tsx src --config eslint.config.mjs",
34
34
  "test": "jest",
35
35
  "prune": "ts-prune src",
36
36
  "prettier": "prettier --write 'src/**/*.{ts,tsx}'"
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@dnd-kit/core": "^6.0.8",
40
40
  "@dnd-kit/sortable": "^10.0.0",
41
- "@pdfme/converter": "*",
41
+ "@pdfme/converter": "file:../converter",
42
42
  "@scena/react-guides": "^0.28.2",
43
43
  "antd": "^5.24.2",
44
44
  "form-render": "^2.2.16",
@@ -13,25 +13,32 @@ type Props = {
13
13
  options: UIOptions;
14
14
  };
15
15
 
16
- const isObject = (item: any): item is Record<string, any> =>
17
- item && typeof item === 'object' && !Array.isArray(item);
16
+ const isObject = (item: unknown): item is Record<string, unknown> =>
17
+ Boolean(item) && typeof item === 'object' && !Array.isArray(item);
18
18
 
19
- const deepMerge = <T extends Record<string, any>, U extends Record<string, any>>(
19
+ const deepMerge = <T extends Record<string, unknown>, U extends Record<string, unknown>>(
20
20
  target: T,
21
21
  source: U,
22
22
  ): T & U => {
23
23
  let output = { ...target } as T & U;
24
24
 
25
25
  if (isObject(target) && isObject(source)) {
26
- Object.keys(source).forEach((key: keyof U) => {
27
- if (isObject(source[key])) {
26
+ Object.keys(source).forEach((key) => {
27
+ const sourceValue = source[key];
28
+ if (isObject(sourceValue)) {
28
29
  if (!(key in target)) {
29
- Object.assign(output, { [key]: source[key] });
30
+ Object.assign(output, { [key]: sourceValue });
30
31
  } else {
31
- output[key as keyof T & U] = deepMerge(target[key as keyof T] as any, source[key] as any);
32
+ const targetValue = target[key];
33
+ if (isObject(targetValue)) {
34
+ // Using Record<string, unknown> for recursive type
35
+ (output as Record<string, unknown>)[key] = deepMerge(targetValue, sourceValue);
36
+ } else {
37
+ Object.assign(output, { [key]: sourceValue });
38
+ }
32
39
  }
33
40
  } else {
34
- Object.assign(output, { [key]: source[key] });
41
+ Object.assign(output, { [key]: sourceValue });
35
42
  }
36
43
  });
37
44
  }
@@ -41,12 +48,18 @@ const deepMerge = <T extends Record<string, any>, U extends Record<string, any>>
41
48
  const AppContextProvider = ({ children, lang, font, plugins, options }: Props) => {
42
49
  let theme = defaultTheme;
43
50
  if (options.theme) {
44
- theme = deepMerge(theme, options.theme);
51
+ theme = deepMerge(
52
+ theme as unknown as Record<string, unknown>,
53
+ options.theme as unknown as Record<string, unknown>,
54
+ ) as typeof theme;
45
55
  }
46
56
 
47
57
  let dict = getDict(lang);
48
58
  if (options.labels) {
49
- dict = deepMerge(dict, options.labels);
59
+ dict = deepMerge(
60
+ dict as unknown as Record<string, unknown>,
61
+ options.labels as unknown as Record<string, unknown>,
62
+ ) as typeof dict;
50
63
  }
51
64
 
52
65
  return (
@@ -7,7 +7,7 @@ import { Plus, Minus, ChevronLeft, ChevronRight, Ellipsis } from 'lucide-react';
7
7
  import type { MenuProps } from 'antd';
8
8
  import { theme, Typography, Button, Dropdown } from 'antd';
9
9
  import { I18nContext } from '../contexts.js';
10
- import { getMaxZoom } from '../helper.js';
10
+ import { useMaxZoom } from '../helper.js';
11
11
 
12
12
  const { Text } = Typography;
13
13
 
@@ -20,7 +20,7 @@ type ZoomProps = {
20
20
 
21
21
  const Zoom = ({ zoomLevel, setZoomLevel, style }: ZoomProps) => {
22
22
  const zoomStep = 0.25;
23
- const maxZoom = getMaxZoom();
23
+ const maxZoom = useMaxZoom();
24
24
  const minZoom = 0.25;
25
25
 
26
26
  const nextZoomOut = zoomLevel - zoomStep;
@@ -17,23 +17,14 @@ 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
-
29
20
  const _Guides = ({
30
21
  paperSize,
31
22
  horizontalRef,
32
23
  verticalRef,
33
24
  }: {
34
25
  paperSize: Size;
35
- horizontalRef: Ref<GuidesInterface> | undefined;
36
- verticalRef: Ref<GuidesInterface> | undefined;
26
+ horizontalRef: Ref<GuidesComponent> | undefined;
27
+ verticalRef: Ref<GuidesComponent> | undefined;
37
28
  }) => (
38
29
  <>
39
30
  <div
@@ -44,13 +35,13 @@ const _Guides = ({
44
35
  zoom={ZOOM}
45
36
  style={guideStyle(-RULER_HEIGHT, 0, RULER_HEIGHT, paperSize.width)}
46
37
  type="horizontal"
47
- ref={horizontalRef as any}
38
+ ref={horizontalRef}
48
39
  />
49
40
  <GuidesComponent
50
41
  zoom={ZOOM}
51
42
  style={guideStyle(0, -RULER_HEIGHT, paperSize.height, RULER_HEIGHT)}
52
43
  type="vertical"
53
- ref={verticalRef as any}
44
+ ref={verticalRef}
54
45
  />
55
46
  </>
56
47
  );
@@ -1,65 +1,13 @@
1
1
  import React, { useEffect, forwardRef, Ref } from 'react';
2
- import MoveableComponent from 'react-moveable';
2
+ import MoveableComponent, {
3
+ OnDrag,
4
+ OnRotate,
5
+ OnRotateEnd,
6
+ OnClick,
7
+ OnResize,
8
+ } from 'react-moveable';
3
9
  import { theme } from 'antd';
4
10
 
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
-
63
11
  type Props = {
64
12
  target: HTMLElement[];
65
13
  bounds: { left: number; top: number; bottom: number; right: number };
@@ -81,29 +29,26 @@ type Props = {
81
29
 
82
30
  const className = 'pdfme-moveable';
83
31
 
84
- const _Moveable = (props: Props, ref: Ref<any>) => {
32
+ const Moveable = (props: Props, ref: Ref<MoveableComponent>) => {
85
33
  const { token } = theme.useToken();
86
34
  useEffect(() => {
87
- const containerElement = document.querySelector(`.${className}`) as HTMLElement | null;
88
- const containerElement2 = document.querySelectorAll(
89
- `.${className} .moveable-line`,
90
- ) as NodeListOf<HTMLElement>;
91
- if (containerElement) {
35
+ const containerElement = document.querySelector(`.${className}`);
36
+ const containerElement2 = document.querySelectorAll(`.${className} .moveable-line`);
37
+ if (containerElement instanceof HTMLElement) {
92
38
  containerElement.style.setProperty('--moveable-color', token.colorPrimary);
93
- Array.from(containerElement2).map((e) =>
94
- e.style.setProperty('--moveable-color', token.colorPrimary),
95
- );
39
+ Array.from(containerElement2).forEach((e) => {
40
+ if (e instanceof HTMLElement) {
41
+ e.style.setProperty('--moveable-color', token.colorPrimary);
42
+ }
43
+ });
96
44
  }
97
- }, [props.target]);
45
+ }, [props.target, token.colorPrimary]);
98
46
 
99
47
  return (
100
- // @ts-ignore
101
48
  <MoveableComponent
102
- style={{ zIndex: 1 }}
103
49
  className={className}
104
50
  rootContainer={document ? document.body : undefined}
105
51
  snappable
106
- snapCenter
107
52
  draggable
108
53
  rotatable={props.rotatable}
109
54
  resizable
@@ -118,18 +63,18 @@ const _Moveable = (props: Props, ref: Ref<any>) => {
118
63
  keepRatio={props.keepRatio}
119
64
  onRotate={props.onRotate}
120
65
  onRotateEnd={props.onRotateEnd}
121
- onRotateGroup={({ events }: { events: any[] }) => {
66
+ onRotateGroup={({ events }: { events: OnRotate[] }) => {
122
67
  events.forEach(props.onRotate);
123
68
  }}
124
69
  onRotateGroupEnd={props.onRotateGroupEnd}
125
70
  onDrag={props.onDrag}
126
- onDragGroup={({ events }: { events: any[] }) => {
71
+ onDragGroup={({ events }: { events: OnDrag[] }) => {
127
72
  events.forEach(props.onDrag);
128
73
  }}
129
74
  onDragEnd={props.onDragEnd}
130
75
  onDragGroupEnd={props.onDragGroupEnd}
131
76
  onResize={props.onResize}
132
- onResizeGroup={({ events }: { events: any[] }) => {
77
+ onResizeGroup={({ events }: { events: OnResize[] }) => {
133
78
  events.forEach(props.onResize);
134
79
  }}
135
80
  onResizeEnd={props.onResizeEnd}
@@ -139,4 +84,4 @@ const _Moveable = (props: Props, ref: Ref<any>) => {
139
84
  );
140
85
  };
141
86
 
142
- export default forwardRef<any, Props>(_Moveable);
87
+ export default forwardRef<MoveableComponent, Props>(Moveable);
@@ -1,42 +1,30 @@
1
1
  import React, { useEffect } from 'react';
2
- import SelectoComponent from 'react-selecto';
2
+ import SelectoComponent, {
3
+ OnSelect as SelectoOnSelect,
4
+ OnDragStart as SelectoOnDragStart,
5
+ } from 'react-selecto';
3
6
  import { SELECTABLE_CLASSNAME } from '../../../constants.js';
4
7
  import { theme } from 'antd';
5
8
 
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
-
21
9
  type Props = {
22
10
  container: HTMLElement | null;
23
11
  continueSelect: boolean;
24
- onDragStart: (e: OnDragStart) => void;
25
- onSelect: (e: OnSelect) => void;
12
+ onDragStart: (e: SelectoOnDragStart) => void;
13
+ onSelect: (e: SelectoOnSelect) => void;
26
14
  };
27
15
 
28
16
  const className = 'pdfme-selecto';
29
17
 
30
- const _Selecto = (props: Props) => {
18
+ const Selecto = (props: Props) => {
31
19
  const { token } = theme.useToken();
32
20
  useEffect(() => {
33
- const containerElement = document.querySelector('.' + className) as HTMLElement | null;
34
- if (containerElement) {
21
+ const containerElement = document.querySelector('.' + className);
22
+ if (containerElement instanceof HTMLElement) {
35
23
  containerElement.style.backgroundColor = token.colorPrimary;
36
24
  containerElement.style.opacity = '0.75';
37
25
  containerElement.style.borderColor = token.colorPrimaryBorder;
38
26
  }
39
- }, [props.container]);
27
+ }, [props.container, token.colorPrimary, token.colorPrimaryBorder]);
40
28
 
41
29
  return (
42
30
  <SelectoComponent
@@ -49,9 +37,9 @@ const _Selecto = (props: Props) => {
49
37
  container={props.container}
50
38
  continueSelect={props.continueSelect}
51
39
  onDragStart={props.onDragStart}
52
- onSelect={(e: any) => props.onSelect(e as OnSelect)}
40
+ onSelect={props.onSelect}
53
41
  />
54
42
  );
55
43
  };
56
44
 
57
- export default _Selecto;
45
+ export default Selecto;