@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.
@@ -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
@@ -8,6 +8,8 @@ export const RULER_HEIGHT = 30;
8
8
 
9
9
  export const PAGE_GAP = 10;
10
10
 
11
+ export const LEFT_SIDEBAR_WIDTH = 45;
12
+
11
13
  export const RIGHT_SIDEBAR_WIDTH = 400;
12
14
 
13
15
  export const BACKGROUND_COLOR = 'rgb(74, 74, 74)';