@pdfme/ui 5.3.3-dev.3 → 5.3.3-dev.4

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.
@@ -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" | "pl" | "zh" | "ja" | "ko" | "ar" | "th" | "it" | "de" | "es" | "fr";
13
+ protected getLang(): "en" | "zh" | "ja" | "ko" | "ar" | "th" | "pl" | "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 MAX_ZOOM = 2;
9
+ export declare const DEFAULT_MAX_ZOOM = 2;
@@ -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: "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?: {
3
+ export declare const I18nContext: import("react").Context<(key: "cancel" | "close" | "set" | "clear" | "field" | "fieldName" | "align" | "width" | "opacity" | "height" | "rotate" | "edit" | "required" | "editable" | "plsInputName" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "editField" | "type" | "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;
@@ -72,4 +72,5 @@ export declare const changeSchemas: (args: {
72
72
  };
73
73
  commitSchemas: (newSchemas: SchemaForUI[]) => void;
74
74
  }) => void;
75
+ export declare const getMaxZoom: () => number;
75
76
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.3.3-dev.3",
3
+ "version": "5.3.3-dev.4",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -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 { MAX_ZOOM } from '../constants';
8
+ import { getMaxZoom } from "../helper";
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 = MAX_ZOOM;
21
+ const maxZoom = getMaxZoom();
22
22
  const minZoom = 0.25;
23
23
 
24
24
  const nextZoomOut = zoomLevel - zoomStep;
package/src/constants.ts CHANGED
@@ -14,4 +14,4 @@ export const RIGHT_SIDEBAR_WIDTH = 400;
14
14
 
15
15
  export const BACKGROUND_COLOR = 'rgb(74, 74, 74)';
16
16
 
17
- export const MAX_ZOOM = 2;
17
+ export const DEFAULT_MAX_ZOOM = 2;
package/src/helper.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import hotkeys from 'hotkeys-js';
2
+ import { useContext } from 'react';
2
3
  import {
3
4
  cloneDeep,
4
5
  ZOOM,
@@ -12,7 +13,8 @@ import {
12
13
  Plugins,
13
14
  } from '@pdfme/common';
14
15
  import { pdf2size } from '@pdfme/converter';
15
- import { RULER_HEIGHT } from './constants.js';
16
+ import { DEFAULT_MAX_ZOOM, RULER_HEIGHT } from './constants.js';
17
+ import { OptionsContext } from './contexts';
16
18
 
17
19
  export const uuid = () =>
18
20
  'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
@@ -469,3 +471,9 @@ export const changeSchemas = (args: {
469
471
  }, cloneDeep(schemas));
470
472
  commitSchemas(newSchemas);
471
473
  };
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
@@ -20,8 +20,9 @@ import {
20
20
  arrayBufferToBase64,
21
21
  initShortCuts,
22
22
  destroyShortCuts,
23
+ getMaxZoom,
23
24
  } from './helper.js';
24
- import { RULER_HEIGHT, MAX_ZOOM } from './constants.js';
25
+ import { RULER_HEIGHT } from './constants.js';
25
26
 
26
27
  export const usePrevious = <T>(value: T) => {
27
28
  const ref = useRef<T | null>(null);
@@ -68,7 +69,7 @@ export const useUIPreProcessor = ({ template, size, zoomLevel }: UIPreProcessorP
68
69
 
69
70
  const [_pages, imgBuffers] = await Promise.all([
70
71
  pdf2size(b64toUint8Array(_basePdf)),
71
- pdf2img(b64toUint8Array(_basePdf), { scale: MAX_ZOOM }),
72
+ pdf2img(b64toUint8Array(_basePdf), { scale: getMaxZoom() }),
72
73
  ]);
73
74
 
74
75
  _pageSizes = _pages;