@pdfme/ui 5.1.7 → 5.2.0-dev.1
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 +76839 -72913
- package/dist/index.umd.js +411 -417
- package/dist/types/class.d.ts +159 -1
- package/dist/types/components/Paper.d.ts +2 -2
- package/dist/types/components/Renderer.d.ts +1 -0
- package/dist/types/components/StaticSchema.d.ts +10 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/contexts.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Designer/Canvas/index.tsx +52 -23
- package/src/components/Designer/LeftSidebar.tsx +3 -2
- package/src/components/Designer/index.tsx +61 -57
- package/src/components/Paper.tsx +2 -2
- package/src/components/Preview.tsx +44 -27
- package/src/components/Renderer.tsx +5 -3
- package/src/components/StaticSchema.tsx +28 -0
- package/src/constants.ts +2 -0
- /package/dist/{__vite-browser-external-jWVCDlBL.mjs → __vite-browser-external-DYxpcVy9.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useContext, ReactNode, useRef } from 'react';
|
|
2
|
-
import {Dict, Mode, ZOOM, UIRenderProps, SchemaForUI, BasePdf, Schema, Plugin, UIOptions} from '@pdfme/common';
|
|
2
|
+
import { Dict, Mode, ZOOM, UIRenderProps, SchemaForUI, BasePdf, Schema, Plugin, UIOptions } from '@pdfme/common';
|
|
3
3
|
import { theme as antdTheme } from 'antd';
|
|
4
4
|
import { SELECTABLE_CLASSNAME } from '../constants';
|
|
5
5
|
import { PluginsRegistry, OptionsContext, I18nContext } from '../contexts';
|
|
@@ -15,6 +15,7 @@ type RendererProps = Omit<
|
|
|
15
15
|
outline: string;
|
|
16
16
|
onChangeHoveringSchemaId?: (id: string | null) => void;
|
|
17
17
|
scale: number;
|
|
18
|
+
selectable?: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
type ReRenderCheckProps = {
|
|
@@ -43,12 +44,13 @@ const Wrapper = ({
|
|
|
43
44
|
outline,
|
|
44
45
|
onChangeHoveringSchemaId,
|
|
45
46
|
schema,
|
|
47
|
+
selectable = true
|
|
46
48
|
}: RendererProps & { children: ReactNode }) => (
|
|
47
49
|
<div
|
|
48
50
|
title={schema.name}
|
|
49
51
|
onMouseEnter={() => onChangeHoveringSchemaId && onChangeHoveringSchemaId(schema.id)}
|
|
50
52
|
onMouseLeave={() => onChangeHoveringSchemaId && onChangeHoveringSchemaId(null)}
|
|
51
|
-
className={SELECTABLE_CLASSNAME}
|
|
53
|
+
className={selectable ? SELECTABLE_CLASSNAME : ''}
|
|
52
54
|
id={schema.id}
|
|
53
55
|
style={{
|
|
54
56
|
position: 'absolute',
|
|
@@ -97,7 +99,7 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
|
97
99
|
return <></>;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
const reRenderDependencies = useRerenderDependencies({plugin, value, mode, scale, schema, options});
|
|
102
|
+
const reRenderDependencies = useRerenderDependencies({ plugin, value, mode, scale, schema, options });
|
|
101
103
|
|
|
102
104
|
useEffect(() => {
|
|
103
105
|
if (ref.current && schema.type) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isBlankPdf, replacePlaceholders, Template } from '@pdfme/common';
|
|
3
|
+
import Renderer from './Renderer';
|
|
4
|
+
import { uuid } from '../helper'
|
|
5
|
+
|
|
6
|
+
const StaticSchema = (props: { template: Template, input: Record<string, string>, scale: number, totalPages: number, currentPage: number }) => {
|
|
7
|
+
const { template: { schemas, basePdf }, input, scale, totalPages, currentPage } = props;
|
|
8
|
+
if (!isBlankPdf(basePdf) || !basePdf.staticSchema) return null;
|
|
9
|
+
return <>{basePdf.staticSchema.map((schema) => (
|
|
10
|
+
<Renderer
|
|
11
|
+
key={schema.name}
|
|
12
|
+
schema={{ ...schema, id: uuid() }}
|
|
13
|
+
basePdf={basePdf}
|
|
14
|
+
value={replacePlaceholders({
|
|
15
|
+
content: schema.content || '',
|
|
16
|
+
variables: { ...input, totalPages, currentPage },
|
|
17
|
+
schemas
|
|
18
|
+
})}
|
|
19
|
+
onChangeHoveringSchemaId={() => { void 0 }}
|
|
20
|
+
mode={'viewer'}
|
|
21
|
+
outline={`none`}
|
|
22
|
+
scale={scale}
|
|
23
|
+
selectable={false}
|
|
24
|
+
/>
|
|
25
|
+
))}</>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default StaticSchema;
|
package/src/constants.ts
CHANGED
|
File without changes
|