@pdfme/common 6.1.13-dev.13 → 6.1.13-dev.22
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/dynamicTemplate.d.ts +8 -0
- package/dist/expression.d.ts +12 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,14 @@ interface ModifyTemplateForDynamicTableArg {
|
|
|
11
11
|
_cache: Map<string | number, unknown>;
|
|
12
12
|
}) => Promise<DynamicLayoutCallbackResult>;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a readOnly table body.
|
|
16
|
+
* Uses input[schema.name] when present (array or JSON string) and never runs
|
|
17
|
+
* replacePlaceholders. Falls back to schema.content (Designer sample).
|
|
18
|
+
*/
|
|
19
|
+
export declare const getReadOnlyTableValue: (schema: Schema, input?: Record<string, unknown>) => string;
|
|
20
|
+
/** Get the input value for a schema */
|
|
21
|
+
export declare const getSchemaValue: (schema: Schema, input: Record<string, string>, schemas: Schema[][]) => string;
|
|
14
22
|
/**
|
|
15
23
|
* Process a template containing tables with dynamic heights
|
|
16
24
|
* and generate a new template with proper page breaks.
|
package/dist/expression.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import type { SchemaPageArray } from './types.js';
|
|
1
|
+
import type { Schema, SchemaPageArray } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a read-only schema's render value.
|
|
4
|
+
* Text `content` is an expression template. MVT `content` is a variable JSON
|
|
5
|
+
* map and must not go through {@link replacePlaceholders}. Other types (table,
|
|
6
|
+
* image, …) keep the previous generate/UI behavior of evaluating expressions.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveReadOnlyContent: (arg: {
|
|
9
|
+
schema: Schema;
|
|
10
|
+
variables: Record<string, unknown>;
|
|
11
|
+
schemas: SchemaPageArray;
|
|
12
|
+
}) => string;
|
|
2
13
|
export declare const replacePlaceholders: (arg: {
|
|
3
14
|
content: string;
|
|
4
15
|
variables: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type { PdfLinkAnnotationRect } from './helper.js';
|
|
|
5
5
|
import type { PageOrientation, PageSize, PageSizePreset } from './pageSize.js';
|
|
6
6
|
import { cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations } from './helper.js';
|
|
7
7
|
import { PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize } from './pageSize.js';
|
|
8
|
-
import { getDynamicTemplate } from './dynamicTemplate.js';
|
|
8
|
+
import { getDynamicTemplate, getReadOnlyTableValue, getSchemaValue } from './dynamicTemplate.js';
|
|
9
9
|
import { createDynamicLayoutSplitRange, getDynamicLayoutSplitRange } from './splitRange.js';
|
|
10
|
-
import { replacePlaceholders } from './expression.js';
|
|
10
|
+
import { replacePlaceholders, resolveReadOnlyContent } from './expression.js';
|
|
11
11
|
import { pluginRegistry } from './pluginRegistry.js';
|
|
12
|
-
export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, replacePlaceholders, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations, PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize, createDynamicLayoutSplitRange, getDynamicLayoutSplitRange, };
|
|
12
|
+
export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, getReadOnlyTableValue, getSchemaValue, replacePlaceholders, resolveReadOnlyContent, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, isUrlSafeToFetch, getInternalLinkTarget, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, registerInternalLinkAnchor, registerInternalLinkAnnotation, resetInternalLinkAnnotations, applyInternalLinkAnnotations, PAGE_SIZE_PRESETS, detectPaperSize, resolvePageSize, createDynamicLayoutSplitRange, getDynamicLayoutSplitRange, };
|
|
13
13
|
export type { Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, DynamicLayoutRange, DynamicLayoutSplitRange, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugin, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, UIRenderProps, Mode, DynamicLayoutArgs, DynamicLayoutCallbackResult, DynamicLayoutPatchArgs, DynamicLayoutResult, GetDynamicLayout, PdfLinkAnnotationRect, PageOrientation, PageSize, PageSizePreset, };
|
package/dist/index.js
CHANGED
|
@@ -942,6 +942,21 @@ var evaluatePlaceholders = (arg) => {
|
|
|
942
942
|
}
|
|
943
943
|
return resultContent;
|
|
944
944
|
};
|
|
945
|
+
/**
|
|
946
|
+
* Resolve a read-only schema's render value.
|
|
947
|
+
* Text `content` is an expression template. MVT `content` is a variable JSON
|
|
948
|
+
* map and must not go through {@link replacePlaceholders}. Other types (table,
|
|
949
|
+
* image, …) keep the previous generate/UI behavior of evaluating expressions.
|
|
950
|
+
*/
|
|
951
|
+
var resolveReadOnlyContent = (arg) => {
|
|
952
|
+
const content = arg.schema.content || "";
|
|
953
|
+
if (arg.schema.type === "multiVariableText") return content;
|
|
954
|
+
return replacePlaceholders({
|
|
955
|
+
content,
|
|
956
|
+
variables: arg.variables,
|
|
957
|
+
schemas: arg.schemas
|
|
958
|
+
});
|
|
959
|
+
};
|
|
945
960
|
var replacePlaceholders = (arg) => {
|
|
946
961
|
const { content, variables, schemas } = arg;
|
|
947
962
|
if (!content || typeof content !== "string" || !content.includes("{") || !content.includes("}")) return content;
|
|
@@ -971,10 +986,23 @@ var replacePlaceholders = (arg) => {
|
|
|
971
986
|
var EPSILON = .01;
|
|
972
987
|
/** Calculate the content height of a page (drawable area excluding padding) */
|
|
973
988
|
var getContentHeight = (basePdf) => basePdf.height - basePdf.padding[0] - basePdf.padding[2];
|
|
989
|
+
/**
|
|
990
|
+
* Resolve a readOnly table body.
|
|
991
|
+
* Uses input[schema.name] when present (array or JSON string) and never runs
|
|
992
|
+
* replacePlaceholders. Falls back to schema.content (Designer sample).
|
|
993
|
+
*/
|
|
994
|
+
var getReadOnlyTableValue = (schema, input) => {
|
|
995
|
+
if (input && Object.prototype.hasOwnProperty.call(input, schema.name)) {
|
|
996
|
+
const value = input[schema.name];
|
|
997
|
+
if (value !== void 0 && value !== null) return typeof value === "string" ? value : JSON.stringify(value);
|
|
998
|
+
}
|
|
999
|
+
return schema.content || "";
|
|
1000
|
+
};
|
|
974
1001
|
/** Get the input value for a schema */
|
|
975
1002
|
var getSchemaValue = (schema, input, schemas) => {
|
|
976
1003
|
if (!schema.readOnly) return input?.[schema.name] || "";
|
|
977
|
-
if (schema.type
|
|
1004
|
+
if (schema.type === "table") return getReadOnlyTableValue(schema, input);
|
|
1005
|
+
if (schema.type !== "text") return schema.content || "";
|
|
978
1006
|
return replacePlaceholders({
|
|
979
1007
|
content: schema.content || "",
|
|
980
1008
|
variables: input,
|
|
@@ -1213,6 +1241,6 @@ var pluginRegistry = (plugins) => {
|
|
|
1213
1241
|
};
|
|
1214
1242
|
};
|
|
1215
1243
|
//#endregion
|
|
1216
|
-
export { BLANK_A4_PDF, BLANK_PDF, CUSTOM_A4_PDF, DEFAULT_FONT_NAME, MM_TO_PT_RATIO, PAGE_SIZE_PRESETS, PDFME_VERSION, PT_TO_MM_RATIO, PT_TO_PX_RATIO, ZOOM, applyInternalLinkAnnotations, b64toUint8Array, checkDesignerProps, checkFont, checkGenerateProps, checkInputs, checkPreviewProps, checkTemplate, checkUIOptions, checkUIProps, cloneDeep, createDynamicLayoutSplitRange, detectPaperSize, getB64BasePdf, getDefaultFont, getDynamicLayoutSplitRange, getDynamicTemplate, getFallbackFontName, getInputFromTemplate, getInternalLinkTarget, isBlankPdf, isHexValid, isUrlSafeToFetch, mm2pt, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, pluginRegistry, pt2mm, pt2px, px2mm, registerInternalLinkAnchor, registerInternalLinkAnnotation, replacePlaceholders, resetInternalLinkAnnotations, resolvePageSize };
|
|
1244
|
+
export { BLANK_A4_PDF, BLANK_PDF, CUSTOM_A4_PDF, DEFAULT_FONT_NAME, MM_TO_PT_RATIO, PAGE_SIZE_PRESETS, PDFME_VERSION, PT_TO_MM_RATIO, PT_TO_PX_RATIO, ZOOM, applyInternalLinkAnnotations, b64toUint8Array, checkDesignerProps, checkFont, checkGenerateProps, checkInputs, checkPreviewProps, checkTemplate, checkUIOptions, checkUIProps, cloneDeep, createDynamicLayoutSplitRange, detectPaperSize, getB64BasePdf, getDefaultFont, getDynamicLayoutSplitRange, getDynamicTemplate, getFallbackFontName, getInputFromTemplate, getInternalLinkTarget, getReadOnlyTableValue, getSchemaValue, isBlankPdf, isHexValid, isUrlSafeToFetch, mm2pt, normalizeInternalLinkHref, normalizeLinkHref, normalizeSafeLinkUri, pluginRegistry, pt2mm, pt2px, px2mm, registerInternalLinkAnchor, registerInternalLinkAnnotation, replacePlaceholders, resetInternalLinkAnnotations, resolvePageSize, resolveReadOnlyContent };
|
|
1217
1245
|
|
|
1218
1246
|
//# sourceMappingURL=index.js.map
|