@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
@@ -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 }) => {
|
@@ -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;
|
@@ -1,15 +1,18 @@
|
|
1
|
-
import
|
1
|
+
import { useForm } from 'form-render';
|
2
2
|
import React, { useRef, useContext, useState, useEffect } from 'react';
|
3
3
|
import type { ChangeSchemaItem, Dict, SchemaForUI, PropPanelWidgetProps, PropPanelSchema } from '@pdfme/common';
|
4
|
-
import type { SidebarProps } from '../../../../types';
|
4
|
+
import type { SidebarProps } from '../../../../types.js';
|
5
5
|
import { Menu } from 'lucide-react';
|
6
|
-
import { I18nContext, PluginsRegistry, OptionsContext } from '../../../../contexts';
|
7
|
-
import { getSidebarContentHeight, debounce } from '../../../../helper';
|
6
|
+
import { I18nContext, PluginsRegistry, OptionsContext } from '../../../../contexts.js';
|
7
|
+
import { getSidebarContentHeight, debounce } from '../../../../helper.js';
|
8
8
|
import { theme, Typography, Button, Divider } from 'antd';
|
9
|
-
import AlignWidget from './AlignWidget';
|
10
|
-
import WidgetRenderer from './WidgetRenderer';
|
11
|
-
import ButtonGroupWidget from './ButtonGroupWidget';
|
12
|
-
import { InternalNamePath, ValidateErrorEntity } from "rc-field-form/es/interface";
|
9
|
+
import AlignWidget from './AlignWidget.js';
|
10
|
+
import WidgetRenderer from './WidgetRenderer.js';
|
11
|
+
import ButtonGroupWidget from './ButtonGroupWidget.js';
|
12
|
+
import { InternalNamePath, ValidateErrorEntity } from "rc-field-form/es/interface.js";
|
13
|
+
|
14
|
+
// Import FormRender as a default import
|
15
|
+
import FormRenderComponent from 'form-render';
|
13
16
|
|
14
17
|
const { Text } = Typography;
|
15
18
|
|
@@ -272,7 +275,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
272
275
|
overflowX: 'hidden',
|
273
276
|
}}
|
274
277
|
>
|
275
|
-
<
|
278
|
+
<FormRenderComponent
|
276
279
|
form={form}
|
277
280
|
schema={propPanelSchema}
|
278
281
|
widgets={widgets}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useEffect, useContext } from 'react';
|
2
2
|
import { DraggableSyntheticListeners } from '@dnd-kit/core';
|
3
|
-
import { I18nContext } from '../../../../contexts';
|
3
|
+
import { I18nContext } from '../../../../contexts.js';
|
4
4
|
import { GripVertical, CircleAlert, Lock } from 'lucide-react'
|
5
5
|
import { Button, Typography } from 'antd';
|
6
6
|
|
@@ -16,12 +16,12 @@ import {
|
|
16
16
|
verticalListSortingStrategy,
|
17
17
|
} from '@dnd-kit/sortable';
|
18
18
|
import { SchemaForUI } from '@pdfme/common';
|
19
|
-
import type { SidebarProps } from '../../../../types';
|
20
|
-
import { PluginsRegistry } from '../../../../contexts';
|
21
|
-
import Item from './Item';
|
22
|
-
import SelectableSortableItem from './SelectableSortableItem';
|
19
|
+
import type { SidebarProps } from '../../../../types.js';
|
20
|
+
import { PluginsRegistry } from '../../../../contexts.js';
|
21
|
+
import Item from './Item.js';
|
22
|
+
import SelectableSortableItem from './SelectableSortableItem.js';
|
23
23
|
import { theme } from 'antd';
|
24
|
-
import PluginIcon from "../../PluginIcon";
|
24
|
+
import PluginIcon from "../../PluginIcon.js";
|
25
25
|
|
26
26
|
const SelectableSortableContainer = (
|
27
27
|
props: Pick<
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React, { useContext } from 'react';
|
2
2
|
import { useSortable } from '@dnd-kit/sortable';
|
3
3
|
import { SchemaForUI } from '@pdfme/common';
|
4
|
-
import { PluginsRegistry, I18nContext } from '../../../../contexts';
|
5
|
-
import Item from './Item';
|
6
|
-
import { useMountStatus } from '../../../../hooks';
|
4
|
+
import { PluginsRegistry, I18nContext } from '../../../../contexts.js';
|
5
|
+
import Item from './Item.js';
|
6
|
+
import { useMountStatus } from '../../../../hooks.js';
|
7
7
|
import { theme } from 'antd';
|
8
|
-
import PluginIcon from "../../PluginIcon";
|
8
|
+
import PluginIcon from "../../PluginIcon.js";
|
9
9
|
|
10
10
|
interface Props {
|
11
11
|
isSelected: boolean;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React, { useContext, useState } from 'react';
|
2
|
-
import type { SidebarProps } from '../../../../types';
|
3
|
-
import { RIGHT_SIDEBAR_WIDTH } from '../../../../constants';
|
4
|
-
import { I18nContext } from '../../../../contexts';
|
5
|
-
import { getSidebarContentHeight } from '../../../../helper';
|
2
|
+
import type { SidebarProps } from '../../../../types.js';
|
3
|
+
import { RIGHT_SIDEBAR_WIDTH } from '../../../../constants.js';
|
4
|
+
import { I18nContext } from '../../../../contexts.js';
|
5
|
+
import { getSidebarContentHeight } from '../../../../helper.js';
|
6
6
|
import { theme, Input, Typography, Divider, Button } from 'antd';
|
7
|
-
import SelectableSortableContainer from './SelectableSortableContainer';
|
7
|
+
import SelectableSortableContainer from './SelectableSortableContainer.js';
|
8
8
|
|
9
9
|
const { Text } = Typography;
|
10
10
|
const { TextArea } = Input;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { theme, Button } from 'antd';
|
3
|
-
import type { SidebarProps } from '../../../types';
|
4
|
-
import { RIGHT_SIDEBAR_WIDTH } from '../../../constants';
|
3
|
+
import type { SidebarProps } from '../../../types.js';
|
4
|
+
import { RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
|
5
5
|
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
6
|
-
import ListView from './ListView/index';
|
7
|
-
import DetailView from './DetailView/index';
|
6
|
+
import ListView from './ListView/index.js';
|
7
|
+
import DetailView from './DetailView/index.js';
|
8
8
|
|
9
9
|
const Sidebar = (props: SidebarProps) => {
|
10
10
|
const { sidebarOpen, setSidebarOpen, activeElements, schemas } = props;
|
@@ -12,11 +12,11 @@ import {
|
|
12
12
|
px2mm,
|
13
13
|
} from '@pdfme/common';
|
14
14
|
import { DndContext } from '@dnd-kit/core';
|
15
|
-
import RightSidebar from './RightSidebar/index';
|
16
|
-
import LeftSidebar from './LeftSidebar';
|
17
|
-
import Canvas from './Canvas/index';
|
18
|
-
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH, LEFT_SIDEBAR_WIDTH } from '../../constants';
|
19
|
-
import { I18nContext, OptionsContext, PluginsRegistry } from '../../contexts';
|
15
|
+
import RightSidebar from './RightSidebar/index.js';
|
16
|
+
import LeftSidebar from './LeftSidebar.js';
|
17
|
+
import Canvas from './Canvas/index.js';
|
18
|
+
import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH, LEFT_SIDEBAR_WIDTH } from '../../constants.js';
|
19
|
+
import { I18nContext, OptionsContext, PluginsRegistry } from '../../contexts.js';
|
20
20
|
import {
|
21
21
|
schemasList2template,
|
22
22
|
uuid,
|
@@ -25,11 +25,11 @@ import {
|
|
25
25
|
getPagesScrollTopByIndex,
|
26
26
|
changeSchemas as _changeSchemas,
|
27
27
|
getMaxZoom,
|
28
|
-
} from '../../helper';
|
29
|
-
import { useUIPreProcessor, useScrollPageCursor, useInitEvents } from '../../hooks';
|
30
|
-
import Root from '../Root';
|
31
|
-
import ErrorScreen from '../ErrorScreen';
|
32
|
-
import CtlBar from '../CtlBar';
|
28
|
+
} from '../../helper.js';
|
29
|
+
import { useUIPreProcessor, useScrollPageCursor, useInitEvents } from '../../hooks.js';
|
30
|
+
import Root from '../Root.js';
|
31
|
+
import ErrorScreen from '../ErrorScreen.js';
|
32
|
+
import CtlBar from '../CtlBar.js';
|
33
33
|
|
34
34
|
/**
|
35
35
|
* When the canvas scales there is a displacement of the starting position of the dragged schema.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useContext } from 'react';
|
2
2
|
import { Size } from '@pdfme/common';
|
3
|
-
import { I18nContext } from '../contexts';
|
4
|
-
import { BACKGROUND_COLOR } from '../constants';
|
3
|
+
import { I18nContext } from '../contexts.js';
|
4
|
+
import { BACKGROUND_COLOR } from '../constants.js';
|
5
5
|
import { theme, Result } from 'antd';
|
6
6
|
|
7
7
|
const ErrorScreen = ({ size, error }: { size: Size; error: Error }) => {
|
package/src/components/Paper.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { MutableRefObject, ReactNode, useContext } from 'react';
|
2
2
|
import { ZOOM, SchemaForUI, Size, getFallbackFontName } from '@pdfme/common';
|
3
|
-
import { FontContext } from '../contexts';
|
4
|
-
import { RULER_HEIGHT, PAGE_GAP } from '../constants';
|
3
|
+
import { FontContext } from '../contexts.js';
|
4
|
+
import { RULER_HEIGHT, PAGE_GAP } from '../constants.js';
|
5
5
|
|
6
6
|
const Paper = (props: {
|
7
7
|
paperRefs: MutableRefObject<HTMLDivElement[]>;
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import React, { useRef, useState, useEffect, useContext } from 'react';
|
2
2
|
import { Template, SchemaForUI, PreviewProps, Size, getDynamicTemplate, replacePlaceholders } from '@pdfme/common';
|
3
3
|
import { getDynamicHeightsForTable } from '@pdfme/schemas/utils';
|
4
|
-
import UnitPager from './UnitPager';
|
5
|
-
import Root from './Root';
|
6
|
-
import StaticSchema from './StaticSchema';
|
7
|
-
import ErrorScreen from './ErrorScreen';
|
8
|
-
import CtlBar from './CtlBar';
|
9
|
-
import Paper from './Paper';
|
10
|
-
import Renderer from './Renderer';
|
11
|
-
import { useUIPreProcessor, useScrollPageCursor } from '../hooks';
|
12
|
-
import { FontContext } from '../contexts';
|
13
|
-
import { template2SchemasList, getPagesScrollTopByIndex, getMaxZoom } from '../helper';
|
4
|
+
import UnitPager from './UnitPager.js';
|
5
|
+
import Root from './Root.js';
|
6
|
+
import StaticSchema from './StaticSchema.js';
|
7
|
+
import ErrorScreen from './ErrorScreen.js';
|
8
|
+
import CtlBar from './CtlBar.js';
|
9
|
+
import Paper from './Paper.js';
|
10
|
+
import Renderer from './Renderer.js';
|
11
|
+
import { useUIPreProcessor, useScrollPageCursor } from '../hooks.js';
|
12
|
+
import { FontContext } from '../contexts.js';
|
13
|
+
import { template2SchemasList, getPagesScrollTopByIndex, getMaxZoom } from '../helper.js';
|
14
14
|
import { theme } from 'antd';
|
15
15
|
|
16
16
|
const _cache = new Map();
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { useEffect, useContext, ReactNode, useRef, useMemo } from 'react';
|
2
2
|
import { Dict, Mode, ZOOM, UIRenderProps, SchemaForUI, BasePdf, Schema, Plugin, UIOptions, cloneDeep } from '@pdfme/common';
|
3
3
|
import { theme as antdTheme } from 'antd';
|
4
|
-
import { SELECTABLE_CLASSNAME } from '../constants';
|
5
|
-
import { PluginsRegistry, OptionsContext, I18nContext, CacheContext } from '../contexts';
|
4
|
+
import { SELECTABLE_CLASSNAME } from '../constants.js';
|
5
|
+
import { PluginsRegistry, OptionsContext, I18nContext, CacheContext } from '../contexts.js';
|
6
6
|
|
7
7
|
type RendererProps = Omit<
|
8
8
|
UIRenderProps<Schema>,
|
@@ -97,9 +97,9 @@ const Renderer = (props: RendererProps) => {
|
|
97
97
|
|
98
98
|
const ref = useRef<HTMLDivElement>(null);
|
99
99
|
const _cache = useContext(CacheContext);
|
100
|
-
const plugin = Object.values(pluginsRegistry).find(
|
100
|
+
const plugin = Object.values(pluginsRegistry || {}).find(
|
101
101
|
(plugin) => plugin?.propPanel.defaultSchema.type === schema.type
|
102
|
-
) as Plugin<any
|
102
|
+
) as Plugin<any> | undefined;
|
103
103
|
|
104
104
|
if (!plugin || !plugin.ui) {
|
105
105
|
console.error(`[@pdfme/ui] Renderer for type ${schema.type} not found.
|
@@ -112,7 +112,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
112
112
|
mode,
|
113
113
|
scale,
|
114
114
|
schema,
|
115
|
-
options,
|
115
|
+
options: options as UIOptions,
|
116
116
|
});
|
117
117
|
|
118
118
|
useEffect(() => {
|
@@ -130,10 +130,10 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
130
130
|
stopEditing,
|
131
131
|
tabIndex,
|
132
132
|
placeholder,
|
133
|
-
options,
|
133
|
+
options: options as UIOptions,
|
134
134
|
theme,
|
135
135
|
i18n,
|
136
|
-
_cache,
|
136
|
+
_cache: _cache as Map<any, any>,
|
137
137
|
});
|
138
138
|
}
|
139
139
|
return () => {
|
package/src/components/Root.tsx
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { useContext, forwardRef, ReactNode, Ref, useEffect } from 'react';
|
2
2
|
import { Size } from '@pdfme/common';
|
3
|
-
import { FontContext } from '../contexts';
|
4
|
-
import { BACKGROUND_COLOR } from '../constants';
|
5
|
-
import Spinner from './Spinner';
|
3
|
+
import { FontContext } from '../contexts.js';
|
4
|
+
import { BACKGROUND_COLOR } from '../constants.js';
|
5
|
+
import Spinner from './Spinner.js';
|
6
6
|
|
7
7
|
type Props = { size: Size; scale: number; children: ReactNode };
|
8
8
|
|
@@ -17,13 +17,11 @@ const Root = ({ size, scale, children }: Props, ref: Ref<HTMLDivElement>) => {
|
|
17
17
|
display: 'swap',
|
18
18
|
})
|
19
19
|
);
|
20
|
-
// @ts-ignore
|
21
20
|
const newFontFaces = fontFaces.filter((fontFace) => !document.fonts.has(fontFace));
|
22
21
|
|
23
22
|
Promise.allSettled(newFontFaces.map((f) => f.load())).then((loadedFontFaces) => {
|
24
23
|
loadedFontFaces.forEach((loadedFontFace) => {
|
25
24
|
if (loadedFontFace.status === 'fulfilled') {
|
26
|
-
// @ts-ignore
|
27
25
|
document.fonts.add(loadedFontFace.value);
|
28
26
|
}
|
29
27
|
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { isBlankPdf, replacePlaceholders, Template } from '@pdfme/common';
|
3
|
-
import Renderer from './Renderer';
|
4
|
-
import { uuid } from '../helper'
|
3
|
+
import Renderer from './Renderer.js';
|
4
|
+
import { uuid } from '../helper.js';
|
5
5
|
|
6
6
|
const StaticSchema = (props: { template: Template, input: Record<string, string>, scale: number, totalPages: number, currentPage: number }) => {
|
7
7
|
const { template: { schemas, basePdf }, input, scale, totalPages, currentPage } = props;
|
package/src/contexts.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createContext } from 'react';
|
2
|
-
import { i18n } from './i18n';
|
2
|
+
import { i18n } from './i18n.js';
|
3
3
|
import { getDefaultFont, Plugins, UIOptions } from '@pdfme/common';
|
4
4
|
import { builtInPlugins } from '@pdfme/schemas';
|
5
5
|
|
@@ -11,4 +11,4 @@ export const PluginsRegistry = createContext<Plugins>(builtInPlugins);
|
|
11
11
|
|
12
12
|
export const OptionsContext = createContext<UIOptions>({});
|
13
13
|
|
14
|
-
export const CacheContext = createContext<Map<any, any>>(new Map());
|
14
|
+
export const CacheContext = createContext<Map<any, any>>(new Map());
|
package/src/helper.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import hotkeysJs from 'hotkeys-js';
|
2
2
|
import { useContext } from 'react';
|
3
3
|
import {
|
4
4
|
cloneDeep,
|
@@ -14,7 +14,21 @@ import {
|
|
14
14
|
} from '@pdfme/common';
|
15
15
|
import { pdf2size } from '@pdfme/converter';
|
16
16
|
import { DEFAULT_MAX_ZOOM, RULER_HEIGHT } from './constants.js';
|
17
|
-
import { OptionsContext } from './contexts';
|
17
|
+
import { OptionsContext } from './contexts.js';
|
18
|
+
|
19
|
+
// Create a simple mock for hotkeys to avoid TypeScript errors
|
20
|
+
const hotkeys = function(keys: string, callback: (e: KeyboardEvent, handler: { shortcut: string }) => void) {
|
21
|
+
return (hotkeysJs as any)(keys, callback);
|
22
|
+
};
|
23
|
+
|
24
|
+
// Add properties to the hotkeys function
|
25
|
+
(hotkeys as any).shift = false;
|
26
|
+
(hotkeys as any).unbind = function(keys: string) {
|
27
|
+
// Do nothing if hotkeysJs doesn't have unbind
|
28
|
+
if (typeof (hotkeysJs as any).unbind === 'function') {
|
29
|
+
(hotkeysJs as any).unbind(keys);
|
30
|
+
}
|
31
|
+
};
|
18
32
|
|
19
33
|
export const uuid = () =>
|
20
34
|
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
@@ -125,27 +139,27 @@ export const initShortCuts = (arg: {
|
|
125
139
|
save: () => void;
|
126
140
|
selectAll: () => void;
|
127
141
|
}) => {
|
128
|
-
hotkeys(keys.join(), (e, handler) => {
|
142
|
+
hotkeys(keys.join(), (e: KeyboardEvent, handler: { shortcut: string }) => {
|
129
143
|
switch (handler.shortcut) {
|
130
144
|
case up:
|
131
145
|
case shiftUp:
|
132
146
|
e.preventDefault();
|
133
|
-
arg.move('up', hotkeys.shift);
|
147
|
+
arg.move('up', (hotkeys as any).shift);
|
134
148
|
break;
|
135
149
|
case down:
|
136
150
|
case shiftDown:
|
137
151
|
e.preventDefault();
|
138
|
-
arg.move('down', hotkeys.shift);
|
152
|
+
arg.move('down', (hotkeys as any).shift);
|
139
153
|
break;
|
140
154
|
case left:
|
141
155
|
case shiftLeft:
|
142
156
|
e.preventDefault();
|
143
|
-
arg.move('left', hotkeys.shift);
|
157
|
+
arg.move('left', (hotkeys as any).shift);
|
144
158
|
break;
|
145
159
|
case right:
|
146
160
|
case shiftRight:
|
147
161
|
e.preventDefault();
|
148
|
-
arg.move('right', hotkeys.shift);
|
162
|
+
arg.move('right', (hotkeys as any).shift);
|
149
163
|
break;
|
150
164
|
case rmWin:
|
151
165
|
case rmMac:
|
@@ -187,7 +201,7 @@ export const initShortCuts = (arg: {
|
|
187
201
|
};
|
188
202
|
|
189
203
|
export const destroyShortCuts = () => {
|
190
|
-
hotkeys.unbind(keys.join());
|
204
|
+
(hotkeys as any).unbind(keys.join());
|
191
205
|
};
|
192
206
|
|
193
207
|
/**
|
@@ -242,8 +256,8 @@ export const arrayBufferToBase64 = (arrayBuffer: ArrayBuffer): string => {
|
|
242
256
|
};
|
243
257
|
|
244
258
|
const convertSchemasForUI = (template: Template): SchemaForUI[][] => {
|
245
|
-
template.schemas.forEach((page) => {
|
246
|
-
page.forEach((schema) => {
|
259
|
+
template.schemas.forEach((page: any[]) => {
|
260
|
+
page.forEach((schema: any) => {
|
247
261
|
schema.id = uuid();
|
248
262
|
schema.content = schema.content || '';
|
249
263
|
});
|
@@ -265,7 +279,8 @@ export const template2SchemasList = async (_template: Template) => {
|
|
265
279
|
}));
|
266
280
|
} else {
|
267
281
|
const b64BasePdf = await getB64BasePdf(basePdf);
|
268
|
-
|
282
|
+
// Use the Uint8Array directly as pdf2size should accept it
|
283
|
+
pageSizes = await pdf2size(b64toUint8Array(b64BasePdf) as any);
|
269
284
|
}
|
270
285
|
|
271
286
|
const ssl = schemasForUI.length;
|
@@ -476,4 +491,4 @@ export const getMaxZoom = () => {
|
|
476
491
|
const options = useContext(OptionsContext);
|
477
492
|
|
478
493
|
return options.maxZoom ? (options.maxZoom as number) / 100 : DEFAULT_MAX_ZOOM;
|
479
|
-
}
|
494
|
+
}
|
package/src/index.ts
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
declare module '@scena/react-guides' {
|
2
|
+
import { Component, ForwardRefExoticComponent, RefAttributes } from 'react';
|
3
|
+
|
4
|
+
interface GuidesInterface {
|
5
|
+
getGuides(): number[];
|
6
|
+
scroll(pos: number): void;
|
7
|
+
scrollGuides(pos: number): void;
|
8
|
+
loadGuides(guides: number[]): void;
|
9
|
+
resize(): void;
|
10
|
+
}
|
11
|
+
|
12
|
+
interface GuidesProps {
|
13
|
+
zoom?: number;
|
14
|
+
style?: React.CSSProperties;
|
15
|
+
type?: 'horizontal' | 'vertical';
|
16
|
+
}
|
17
|
+
|
18
|
+
// Define the component as a ForwardRefExoticComponent to support refs
|
19
|
+
const GuidesComponent: ForwardRefExoticComponent<GuidesProps & RefAttributes<GuidesInterface>>;
|
20
|
+
|
21
|
+
export default GuidesComponent;
|
22
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
declare module 'react-selecto' {
|
2
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
3
|
+
|
4
|
+
interface OnDragStart {
|
5
|
+
inputEvent: MouseEvent;
|
6
|
+
stop: () => void;
|
7
|
+
isTrusted: boolean;
|
8
|
+
}
|
9
|
+
|
10
|
+
interface OnSelect {
|
11
|
+
selected: Element[];
|
12
|
+
added: Element[];
|
13
|
+
removed: Element[];
|
14
|
+
inputEvent: MouseEvent;
|
15
|
+
rect: DOMRect;
|
16
|
+
}
|
17
|
+
|
18
|
+
interface SelectoProps {
|
19
|
+
className?: string;
|
20
|
+
selectFromInside?: boolean;
|
21
|
+
selectByClick?: boolean;
|
22
|
+
preventDefault?: boolean;
|
23
|
+
hitRate?: number;
|
24
|
+
selectableTargets?: string[];
|
25
|
+
container?: HTMLElement | null;
|
26
|
+
continueSelect?: boolean;
|
27
|
+
onDragStart?: (e: OnDragStart) => void;
|
28
|
+
onSelect?: (e: OnSelect) => void;
|
29
|
+
}
|
30
|
+
|
31
|
+
// Define the component as a ForwardRefExoticComponent
|
32
|
+
const SelectoComponent: ForwardRefExoticComponent<SelectoProps & RefAttributes<any>>;
|
33
|
+
|
34
|
+
export default SelectoComponent;
|
35
|
+
}
|
package/tsconfig.json
CHANGED
@@ -7,14 +7,14 @@
|
|
7
7
|
"isolatedModules": true,
|
8
8
|
"declaration": true,
|
9
9
|
"declarationDir": "dist/types",
|
10
|
-
"module": "
|
10
|
+
"module": "NodeNext",
|
11
11
|
"lib": [
|
12
12
|
"ES2020",
|
13
13
|
"DOM",
|
14
14
|
"DOM.Iterable",
|
15
15
|
"ESNext"
|
16
16
|
],
|
17
|
-
"moduleResolution": "
|
17
|
+
"moduleResolution": "nodenext",
|
18
18
|
"allowSyntheticDefaultImports": true,
|
19
19
|
"strict": true,
|
20
20
|
"types": [
|
@@ -45,6 +45,6 @@
|
|
45
45
|
"node_modules",
|
46
46
|
"dist",
|
47
47
|
"**/*.test.ts",
|
48
|
-
"**/*.spec.ts"
|
48
|
+
"**/*.spec.ts"
|
49
49
|
]
|
50
50
|
}
|
package/.eslintrc.cjs
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
extends: ['../../eslint.base.js', "plugin:react/recommended", 'plugin:react-hooks/recommended'],
|
3
|
-
overrides: [
|
4
|
-
{
|
5
|
-
files: ['*.ts', '*.tsx'],
|
6
|
-
parserOptions: {
|
7
|
-
project: ['./tsconfig.json'],
|
8
|
-
},
|
9
|
-
},
|
10
|
-
],
|
11
|
-
settings: {
|
12
|
-
react: {
|
13
|
-
version: 'detect',
|
14
|
-
},
|
15
|
-
},
|
16
|
-
};
|
File without changes
|