@pdfme/ui 5.3.3-dev.5 → 5.3.3
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/dist/index.es.js +20706 -20704
- package/dist/index.umd.js +145 -145
- package/dist/types/class.d.ts +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/contexts.d.ts +1 -2
- package/dist/types/helper.d.ts +0 -1
- package/dist/types/hooks.d.ts +1 -2
- package/package.json +1 -1
- package/src/components/CtlBar.tsx +2 -2
- package/src/components/Designer/index.tsx +1 -3
- package/src/components/Preview.tsx +2 -3
- package/src/components/Renderer.tsx +3 -3
- package/src/constants.ts +1 -1
- package/src/contexts.ts +0 -2
- package/src/helper.ts +1 -9
- package/src/hooks.ts +5 -5
package/dist/types/class.d.ts
CHANGED
@@ -10,7 +10,7 @@ export declare abstract class BaseUIClass {
|
|
10
10
|
private readonly setSize;
|
11
11
|
resizeObserver: ResizeObserver;
|
12
12
|
constructor(props: UIProps);
|
13
|
-
protected getLang(): "en" | "zh" | "ja" | "ko" | "ar" | "th" | "
|
13
|
+
protected getLang(): "en" | "pl" | "zh" | "ja" | "ko" | "ar" | "th" | "it" | "de" | "es" | "fr";
|
14
14
|
protected getFont(): Record<string, {
|
15
15
|
data: string | ArrayBuffer | Uint8Array;
|
16
16
|
fallback?: boolean | undefined;
|
@@ -6,4 +6,4 @@ export declare const PAGE_GAP = 10;
|
|
6
6
|
export declare const LEFT_SIDEBAR_WIDTH = 45;
|
7
7
|
export declare const RIGHT_SIDEBAR_WIDTH = 400;
|
8
8
|
export declare const BACKGROUND_COLOR = "rgb(74, 74, 74)";
|
9
|
-
export declare const
|
9
|
+
export declare const MAX_ZOOM = 2;
|
package/dist/types/contexts.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { Plugins, UIOptions } from '@pdfme/common';
|
3
|
-
export declare const I18nContext: import("react").Context<(key: "
|
3
|
+
export declare const I18nContext: import("react").Context<(key: "type" | "width" | "height" | "rotate" | "opacity" | "required" | "cancel" | "close" | "set" | "clear" | "field" | "fieldName" | "align" | "edit" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "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;
|
5
5
|
close: string;
|
6
6
|
set: string;
|
@@ -82,4 +82,3 @@ export declare const FontContext: import("react").Context<Record<string, {
|
|
82
82
|
}>>;
|
83
83
|
export declare const PluginsRegistry: import("react").Context<Plugins>;
|
84
84
|
export declare const OptionsContext: import("react").Context<UIOptions>;
|
85
|
-
export declare const CacheContext: import("react").Context<Map<any, any>>;
|
package/dist/types/helper.d.ts
CHANGED
package/dist/types/hooks.d.ts
CHANGED
@@ -5,9 +5,8 @@ type UIPreProcessorProps = {
|
|
5
5
|
template: Template;
|
6
6
|
size: Size;
|
7
7
|
zoomLevel: number;
|
8
|
-
maxZoom: number;
|
9
8
|
};
|
10
|
-
export declare const useUIPreProcessor: ({ template, size, zoomLevel
|
9
|
+
export declare const useUIPreProcessor: ({ template, size, zoomLevel }: UIPreProcessorProps) => {
|
11
10
|
backgrounds: string[];
|
12
11
|
pageSizes: {
|
13
12
|
width: number;
|
package/package.json
CHANGED
@@ -5,7 +5,7 @@ import { Plus, Minus, ChevronLeft, ChevronRight, Ellipsis } from 'lucide-react';
|
|
5
5
|
import type { MenuProps } from 'antd';
|
6
6
|
import { theme, Typography, Button, Dropdown } from 'antd';
|
7
7
|
import { I18nContext } from '../contexts';
|
8
|
-
import {
|
8
|
+
import { MAX_ZOOM } from '../constants';
|
9
9
|
|
10
10
|
const { Text } = Typography;
|
11
11
|
|
@@ -18,7 +18,7 @@ type ZoomProps = {
|
|
18
18
|
|
19
19
|
const Zoom = ({ zoomLevel, setZoomLevel, style }: ZoomProps) => {
|
20
20
|
const zoomStep = 0.25;
|
21
|
-
const maxZoom =
|
21
|
+
const maxZoom = MAX_ZOOM;
|
22
22
|
const minZoom = 0.25;
|
23
23
|
|
24
24
|
const nextZoomOut = zoomLevel - zoomStep;
|
@@ -24,7 +24,6 @@ import {
|
|
24
24
|
template2SchemasList,
|
25
25
|
getPagesScrollTopByIndex,
|
26
26
|
changeSchemas as _changeSchemas,
|
27
|
-
getMaxZoom,
|
28
27
|
} from '../../helper';
|
29
28
|
import { useUIPreProcessor, useScrollPageCursor, useInitEvents } from '../../hooks';
|
30
29
|
import Root from '../Root';
|
@@ -64,7 +63,6 @@ const TemplateEditor = ({
|
|
64
63
|
const i18n = useContext(I18nContext);
|
65
64
|
const pluginsRegistry = useContext(PluginsRegistry);
|
66
65
|
const options = useContext(OptionsContext);
|
67
|
-
const maxZoom = getMaxZoom();
|
68
66
|
|
69
67
|
const [hoveringSchemaId, setHoveringSchemaId] = useState<string | null>(null);
|
70
68
|
const [activeElements, setActiveElements] = useState<HTMLElement[]>([]);
|
@@ -75,7 +73,7 @@ const TemplateEditor = ({
|
|
75
73
|
const [prevTemplate, setPrevTemplate] = useState<Template | null>(null);
|
76
74
|
|
77
75
|
const { backgrounds, pageSizes, scale, error, refresh } =
|
78
|
-
useUIPreProcessor({ template, size, zoomLevel
|
76
|
+
useUIPreProcessor({ template, size, zoomLevel });
|
79
77
|
|
80
78
|
const onEdit = (targets: HTMLElement[]) => {
|
81
79
|
setActiveElements(targets);
|
@@ -10,7 +10,7 @@ import Paper from './Paper';
|
|
10
10
|
import Renderer from './Renderer';
|
11
11
|
import { useUIPreProcessor, useScrollPageCursor } from '../hooks';
|
12
12
|
import { FontContext } from '../contexts';
|
13
|
-
import { template2SchemasList, getPagesScrollTopByIndex
|
13
|
+
import { template2SchemasList, getPagesScrollTopByIndex } from '../helper';
|
14
14
|
import { theme } from 'antd';
|
15
15
|
|
16
16
|
const _cache = new Map();
|
@@ -27,7 +27,6 @@ const Preview = ({
|
|
27
27
|
const { token } = theme.useToken();
|
28
28
|
|
29
29
|
const font = useContext(FontContext);
|
30
|
-
const maxZoom = getMaxZoom();
|
31
30
|
|
32
31
|
const containerRef = useRef<HTMLDivElement>(null);
|
33
32
|
const paperRefs = useRef<HTMLDivElement[]>([]);
|
@@ -38,7 +37,7 @@ const Preview = ({
|
|
38
37
|
const [schemasList, setSchemasList] = useState<SchemaForUI[][]>([[]] as SchemaForUI[][]);
|
39
38
|
|
40
39
|
const { backgrounds, pageSizes, scale, error, refresh } =
|
41
|
-
useUIPreProcessor({ template, size, zoomLevel
|
40
|
+
useUIPreProcessor({ template, size, zoomLevel });
|
42
41
|
|
43
42
|
const isForm = Boolean(onChangeInput);
|
44
43
|
|
@@ -2,7 +2,7 @@ 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
4
|
import { SELECTABLE_CLASSNAME } from '../constants';
|
5
|
-
import { PluginsRegistry, OptionsContext, I18nContext
|
5
|
+
import { PluginsRegistry, OptionsContext, I18nContext } from '../contexts';
|
6
6
|
|
7
7
|
type RendererProps = Omit<
|
8
8
|
UIRenderProps<Schema>,
|
@@ -96,7 +96,7 @@ const Renderer = (props: RendererProps) => {
|
|
96
96
|
|
97
97
|
|
98
98
|
const ref = useRef<HTMLDivElement>(null);
|
99
|
-
const _cache =
|
99
|
+
const _cache = useRef<Map<any, any>>(new Map());
|
100
100
|
const plugin = Object.values(pluginsRegistry).find(
|
101
101
|
(plugin) => plugin?.propPanel.defaultSchema.type === schema.type
|
102
102
|
) as Plugin<any>;
|
@@ -133,7 +133,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
133
133
|
options,
|
134
134
|
theme,
|
135
135
|
i18n,
|
136
|
-
_cache,
|
136
|
+
_cache: _cache.current,
|
137
137
|
});
|
138
138
|
}
|
139
139
|
return () => {
|
package/src/constants.ts
CHANGED
package/src/contexts.ts
CHANGED
@@ -10,5 +10,3 @@ export const FontContext = createContext(getDefaultFont());
|
|
10
10
|
export const PluginsRegistry = createContext<Plugins>(builtInPlugins);
|
11
11
|
|
12
12
|
export const OptionsContext = createContext<UIOptions>({});
|
13
|
-
|
14
|
-
export const CacheContext = createContext<Map<any, any>>(new Map());
|
package/src/helper.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import hotkeys from 'hotkeys-js';
|
2
|
-
import { useContext } from 'react';
|
3
2
|
import {
|
4
3
|
cloneDeep,
|
5
4
|
ZOOM,
|
@@ -13,8 +12,7 @@ import {
|
|
13
12
|
Plugins,
|
14
13
|
} from '@pdfme/common';
|
15
14
|
import { pdf2size } from '@pdfme/converter';
|
16
|
-
import {
|
17
|
-
import { OptionsContext } from './contexts';
|
15
|
+
import { RULER_HEIGHT } from './constants.js';
|
18
16
|
|
19
17
|
export const uuid = () =>
|
20
18
|
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
@@ -471,9 +469,3 @@ export const changeSchemas = (args: {
|
|
471
469
|
}, cloneDeep(schemas));
|
472
470
|
commitSchemas(newSchemas);
|
473
471
|
};
|
474
|
-
|
475
|
-
export const getMaxZoom = () => {
|
476
|
-
const options = useContext(OptionsContext);
|
477
|
-
|
478
|
-
return options.maxZoom ? (options.maxZoom as number) / 100 : DEFAULT_MAX_ZOOM;
|
479
|
-
}
|
package/src/hooks.ts
CHANGED
@@ -19,9 +19,9 @@ import {
|
|
19
19
|
moveCommandToChangeSchemasArg,
|
20
20
|
arrayBufferToBase64,
|
21
21
|
initShortCuts,
|
22
|
-
destroyShortCuts
|
22
|
+
destroyShortCuts,
|
23
23
|
} from './helper.js';
|
24
|
-
import { RULER_HEIGHT } from './constants.js';
|
24
|
+
import { RULER_HEIGHT, MAX_ZOOM } from './constants.js';
|
25
25
|
|
26
26
|
export const usePrevious = <T>(value: T) => {
|
27
27
|
const ref = useRef<T | null>(null);
|
@@ -35,9 +35,9 @@ export const usePrevious = <T>(value: T) => {
|
|
35
35
|
const getScale = (n: number, paper: number) =>
|
36
36
|
Math.floor((n / paper > 1 ? 1 : n / paper) * 100) / 100;
|
37
37
|
|
38
|
-
type UIPreProcessorProps = { template: Template; size: Size; zoomLevel: number
|
38
|
+
type UIPreProcessorProps = { template: Template; size: Size; zoomLevel: number };
|
39
39
|
|
40
|
-
export const useUIPreProcessor = ({ template, size, zoomLevel
|
40
|
+
export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorProps) => {
|
41
41
|
const [backgrounds, setBackgrounds] = useState<string[]>([]);
|
42
42
|
const [pageSizes, setPageSizes] = useState<Size[]>([]);
|
43
43
|
const [scale, setScale] = useState(0);
|
@@ -68,7 +68,7 @@ export const useUIPreProcessor = ({ template, size, zoomLevel, maxZoom }: UIPreP
|
|
68
68
|
|
69
69
|
const [_pages, imgBuffers] = await Promise.all([
|
70
70
|
pdf2size(b64toUint8Array(_basePdf)),
|
71
|
-
pdf2img(b64toUint8Array(_basePdf), { scale:
|
71
|
+
pdf2img(b64toUint8Array(_basePdf), { scale: MAX_ZOOM }),
|
72
72
|
]);
|
73
73
|
|
74
74
|
_pageSizes = _pages;
|