@pdfme/schemas 6.1.2-dev.2 → 6.1.2-dev.21
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/dynamicLayout.js +1 -1
- package/dist/{dynamicTemplate-C7MdZxPm.js → dynamicTemplate-CRjx4Mjc.js} +2 -2
- package/dist/{dynamicTemplate-C7MdZxPm.js.map → dynamicTemplate-CRjx4Mjc.js.map} +1 -1
- package/dist/{helper-CEme39Uo.js → helper-Doen9Okh.js} +2 -2
- package/dist/{helper-CEme39Uo.js.map → helper-Doen9Okh.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/texts.js +1 -1
- package/package.json +1 -1
package/dist/dynamicLayout.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as createListItemSplitRange, c as getListItemRange, i as TEXT_LINE_SPLIT_UNIT, l as getTableBodyRange, n as LIST_ITEM_SPLIT_UNIT, o as createTableBodySplitRange, r as TABLE_BODY_SPLIT_UNIT, s as createTextLineSplitRange, t as BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS, u as getTextLineRange } from "./splitRange-DmVDtmzO.js";
|
|
2
2
|
import { n as getDynamicLayoutForTable } from "./dynamicTemplate-B4GCNLF9.js";
|
|
3
3
|
import { t as getDynamicLayoutForList } from "./dynamicTemplate-BwzF9C1L.js";
|
|
4
|
-
import { n as getDynamicLayoutForMultiVariableText, t as getDynamicLayoutForText } from "./dynamicTemplate-
|
|
4
|
+
import { n as getDynamicLayoutForMultiVariableText, t as getDynamicLayoutForText } from "./dynamicTemplate-CRjx4Mjc.js";
|
|
5
5
|
//#region src/dynamicLayout.ts
|
|
6
6
|
var isExpandableTextSchema = (schema) => (schema.type === "text" || schema.type === "multiVariableText") && schema.overflow === "expand";
|
|
7
7
|
var isDynamicLayoutSchema = (schema) => schema.type === "table" || schema.type === "list" || isExpandableTextSchema(schema);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as createTextLineSplitRange } from "./splitRange-DmVDtmzO.js";
|
|
2
2
|
import { a as measureTextLines, c as sumLineHeights, d as isInlineMarkdownTextSchema, n as getTextLineHeightsWithBox, r as getTextSplitBoxStyle } from "./measure-L5diay3k.js";
|
|
3
|
-
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-
|
|
3
|
+
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-Doen9Okh.js";
|
|
4
4
|
//#region src/multiVariableText/dynamicTemplate.ts
|
|
5
5
|
var getDynamicLayoutForMultiVariableText = async (value, args) => {
|
|
6
6
|
if (args.schema.type !== "multiVariableText") return { heights: [args.schema.height] };
|
|
@@ -72,4 +72,4 @@ var getDynamicLayoutForText = async (value, args) => {
|
|
|
72
72
|
//#endregion
|
|
73
73
|
export { getDynamicLayoutForMultiVariableText as n, getDynamicLayoutForText as t };
|
|
74
74
|
|
|
75
|
-
//# sourceMappingURL=dynamicTemplate-
|
|
75
|
+
//# sourceMappingURL=dynamicTemplate-CRjx4Mjc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicTemplate-
|
|
1
|
+
{"version":3,"file":"dynamicTemplate-CRjx4Mjc.js","names":[],"sources":["../src/multiVariableText/dynamicTemplate.ts","../src/text/dynamicTemplate.ts"],"sourcesContent":["import type { DynamicLayoutArgs, DynamicLayoutResult } from '@pdfme/common';\nimport { TEXT_OVERFLOW_EXPAND } from '../text/constants.js';\nimport {\n getTextLineHeightsWithBox,\n getTextSplitBoxStyle,\n measureTextLines,\n sumLineHeights,\n} from '../text/measure.js';\nimport { isInlineMarkdownTextSchema } from '../text/richText.js';\nimport type { MultiVariableTextSchema } from './types.js';\nimport {\n substituteVariables,\n substituteVariablesAsInlineMarkdownLiterals,\n validateVariables,\n} from './helper.js';\nimport { createTextLineSplitRange } from '../splitRange.js';\n\nexport const getDynamicLayoutForMultiVariableText = async (\n value: string,\n args: DynamicLayoutArgs,\n): Promise<DynamicLayoutResult> => {\n if (args.schema.type !== 'multiVariableText') return { heights: [args.schema.height] };\n\n const schema = args.schema as MultiVariableTextSchema;\n if (schema.overflow !== TEXT_OVERFLOW_EXPAND) {\n return { heights: [schema.height] };\n }\n\n let renderValue = value;\n if (!schema.readOnly) {\n if (!validateVariables(value, schema)) {\n return { heights: [schema.height] };\n }\n\n renderValue = isInlineMarkdownTextSchema(schema)\n ? substituteVariablesAsInlineMarkdownLiterals(schema.text || '', value)\n : substituteVariables(schema.text || '', value);\n }\n const { lineHeights } = await measureTextLines({\n value: renderValue,\n schema,\n font: args.options.font,\n _cache: args._cache,\n // `expand` owns the height decision, so measuring against a shrink-to-fit font size\n // would make the field keep its original box instead of growing.\n ignoreDynamicFontSize: true,\n });\n const heights = getTextLineHeightsWithBox(lineHeights, schema);\n const measuredHeight = sumLineHeights(heights);\n\n if (measuredHeight <= schema.height || lineHeights.length === 0) {\n return {\n heights: [schema.height],\n patchSplitSchema: () => ({ dynamicFontSize: undefined }),\n };\n }\n\n return {\n heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,\n patchSplitSchema: ({ start, end, isSplit }) => ({\n dynamicFontSize: undefined,\n __splitRange: lineHeights.length === 1 ? undefined : createTextLineSplitRange(start, end),\n __isSplit: isSplit,\n ...getTextSplitBoxStyle(schema, { start, end }, lineHeights.length),\n }),\n };\n};\n","import type { DynamicLayoutArgs, DynamicLayoutResult } from '@pdfme/common';\nimport { TEXT_OVERFLOW_EXPAND } from './constants.js';\nimport {\n getTextLineHeightsWithBox,\n getTextSplitBoxStyle,\n measureTextLines,\n sumLineHeights,\n} from './measure.js';\nimport type { TextSchema } from './types.js';\nimport { createTextLineSplitRange } from '../splitRange.js';\n\nexport const getDynamicLayoutForText = async (\n value: string,\n args: DynamicLayoutArgs,\n): Promise<DynamicLayoutResult> => {\n if (args.schema.type !== 'text') return { heights: [args.schema.height] };\n\n const schema = args.schema as TextSchema;\n if (schema.overflow !== TEXT_OVERFLOW_EXPAND) {\n return { heights: [schema.height] };\n }\n\n const { lineHeights } = await measureTextLines({\n value,\n schema,\n font: args.options.font,\n _cache: args._cache,\n // `expand` owns the height decision, so measuring against a shrink-to-fit font size\n // would make the field keep its original box instead of growing.\n ignoreDynamicFontSize: true,\n });\n const heights = getTextLineHeightsWithBox(lineHeights, schema);\n const measuredHeight = sumLineHeights(heights);\n\n if (measuredHeight <= schema.height || lineHeights.length === 0) {\n return {\n heights: [schema.height],\n patchSplitSchema: () => ({ dynamicFontSize: undefined }),\n };\n }\n\n return {\n heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,\n patchSplitSchema: ({ start, end, isSplit }) => ({\n dynamicFontSize: undefined,\n __splitRange: lineHeights.length === 1 ? undefined : createTextLineSplitRange(start, end),\n __isSplit: isSplit,\n ...getTextSplitBoxStyle(schema, { start, end }, lineHeights.length),\n }),\n };\n};\n"],"mappings":";;;;AAiBA,IAAa,uCAAuC,OAClD,OACA,SACiC;AACjC,KAAI,KAAK,OAAO,SAAS,oBAAqB,QAAO,EAAE,SAAS,CAAC,KAAK,OAAO,OAAO,EAAE;CAEtF,MAAM,SAAS,KAAK;AACpB,KAAI,OAAO,aAAA,SACT,QAAO,EAAE,SAAS,CAAC,OAAO,OAAO,EAAE;CAGrC,IAAI,cAAc;AAClB,KAAI,CAAC,OAAO,UAAU;AACpB,MAAI,CAAC,kBAAkB,OAAO,OAAO,CACnC,QAAO,EAAE,SAAS,CAAC,OAAO,OAAO,EAAE;AAGrC,gBAAc,2BAA2B,OAAO,GAC5C,4CAA4C,OAAO,QAAQ,IAAI,MAAM,GACrE,oBAAoB,OAAO,QAAQ,IAAI,MAAM;;CAEnD,MAAM,EAAE,gBAAgB,MAAM,iBAAiB;EAC7C,OAAO;EACP;EACA,MAAM,KAAK,QAAQ;EACnB,QAAQ,KAAK;EAGb,uBAAuB;EACxB,CAAC;CACF,MAAM,UAAU,0BAA0B,aAAa,OAAO;CAC9D,MAA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AAW;GACX,GAAG,qBAAqB,QAAQ;IAAE;IAAO;IAAK,EAAE,YAAY,OAAO;GACpE;EACF"}
|
|
@@ -28,7 +28,7 @@ var validateVariables = (value, schema) => {
|
|
|
28
28
|
} catch {
|
|
29
29
|
throw new SyntaxError(`[@pdfme/generator] invalid JSON string '${value}' for variables in field ${schema.name}`);
|
|
30
30
|
}
|
|
31
|
-
for (const variable of schema.variables) if (!values[variable]) {
|
|
31
|
+
for (const variable of schema.variables) if (!Object.prototype.hasOwnProperty.call(values, variable) || values[variable] === null || values[variable] === void 0) {
|
|
32
32
|
if (schema.required) throw new Error(`[@pdfme/generator] variable ${variable} is missing for field ${schema.name}`);
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
@@ -37,4 +37,4 @@ var validateVariables = (value, schema) => {
|
|
|
37
37
|
//#endregion
|
|
38
38
|
export { substituteVariablesAsInlineMarkdownLiterals as n, validateVariables as r, substituteVariables as t };
|
|
39
39
|
|
|
40
|
-
//# sourceMappingURL=helper-
|
|
40
|
+
//# sourceMappingURL=helper-Doen9Okh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper-
|
|
1
|
+
{"version":3,"file":"helper-Doen9Okh.js","names":[],"sources":["../src/multiVariableText/helper.ts"],"sourcesContent":["import { MultiVariableTextSchema } from './types.js';\nimport { escapeInlineMarkdown } from '../text/inlineMarkdown.js';\n\nexport const substituteVariables = (\n text: string,\n variablesIn: string | Record<string, string>,\n valueMapper: (value: string, variableName: string) => string = (value) => value,\n): string => {\n if (!text) {\n return '';\n }\n\n let substitutedText = text;\n\n if (variablesIn) {\n let variables: Record<string, string>;\n try {\n variables =\n typeof variablesIn === 'string'\n ? (JSON.parse(variablesIn || '{}') as Record<string, string>)\n : variablesIn;\n } catch {\n throw new SyntaxError(`[@pdfme/schemas] MVT: invalid JSON string '${variablesIn as string}'`);\n }\n\n Object.keys(variables).forEach((variableName) => {\n // handle special characters in variable name\n const variableForRegex = variableName.replace(/[/\\-\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n const regex = new RegExp('\\\\{' + variableForRegex + '\\\\}', 'g');\n substitutedText = substitutedText.replace(\n regex,\n valueMapper(variables[variableName], variableName),\n );\n });\n }\n\n // Remove any variables that were not substituted from inputs\n substitutedText = substitutedText.replace(/{[^{}]+}/g, '');\n\n return substitutedText;\n};\n\nexport const substituteVariablesAsInlineMarkdownLiterals = (\n text: string,\n variablesIn: string | Record<string, string>,\n): string => substituteVariables(text, variablesIn, escapeInlineMarkdown);\n\nexport const validateVariables = (value: string, schema: MultiVariableTextSchema): boolean => {\n if (schema.variables.length === 0) {\n return true;\n }\n\n let values;\n try {\n values = value ? (JSON.parse(value) as Record<string, string>) : {};\n } catch {\n throw new SyntaxError(\n `[@pdfme/generator] invalid JSON string '${value}' for variables in field ${schema.name}`,\n );\n }\n\n for (const variable of schema.variables) {\n if (\n !Object.prototype.hasOwnProperty.call(values, variable) ||\n values[variable] === null ||\n values[variable] === undefined\n ) {\n if (schema.required) {\n throw new Error(\n `[@pdfme/generator] variable ${variable} is missing for field ${schema.name}`,\n );\n }\n // If not required, then simply don't render this field if an input is missing\n return false;\n }\n }\n\n return true;\n};\n"],"mappings":";;AAGA,IAAa,uBACX,MACA,aACA,eAAgE,UAAU,UAC/D;AACX,KAAI,CAAC,KACH,QAAO;CAGT,IAAI,kBAAkB;AAEtB,KAAI,aAAa;EACf,IAAI;AACJ,MAAI;AACF,eACE,OAAO,gBAAgB,WAClB,KAAK,MAAM,eAAe,KAAK,GAChC;UACA;AACN,SAAM,IAAI,YAAY,8CAA8C,YAAsB,GAAG;;AAG/F,SAAO,KAAK,UAAU,CAAC,SAAS,iBAAiB;GAE/C,MAAM,mBAAmB,aAAa,QAAQ,0BAA0B,OAAO;GAC/E,MAAM,QAAQ,IAAI,OAAO,QAAQ,mBAAmB,OAAO,IAAI;AAC/D,qBAAkB,gBAAgB,QAChC,OACA,YAAY,UAAU,eAAe,aAAa,CACnD;IACD;;AAIJ,mBAAkB,gBAAgB,QAAQ,aAAa,GAAG;AAE1D,QAAO;;AAGT,IAAa,+CACX,MACA,gBACW,oBAAoB,MAAM,aAAa,qBAAqB;AAEzE,IAAa,qBAAqB,OAAe,WAA6C;AAC5F,KAAI,OAAO,UAAU,WAAW,EAC9B,QAAO;CAGT,IAAI;AACJ,KAAI;AACF,WAAS,QAAS,KAAK,MAAM,MAAM,GAA8B,EAAE;SAC7D;AACN,QAAM,IAAI,YACR,2CAA2C,MAAM,2BAA2B,OAAO,OACpF;;AAGH,MAAK,MAAM,YAAY,OAAO,UAC5B,KACE,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,SAAS,IACvD,OAAO,cAAc,QACrB,OAAO,cAAc,KAAA,GACrB;AACA,MAAI,OAAO,SACT,OAAM,IAAI,MACR,+BAA+B,SAAS,wBAAwB,OAAO,OACxE;AAGH,SAAO;;AAIX,QAAO"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { a as mapVerticalAlignToFlex, c as Formatter, i as makeElementPlainTextC
|
|
|
4
4
|
import { a as getCellPropPanelSchema, c as HEX_COLOR_PATTERN, i as getBodyWithSchemaRange, l as createSingleTable, n as getDynamicLayoutForTable, o as getColumnStylesPropPanelSchema, r as getBody, s as getDefaultCellStyles, t as getDynamicHeightsForTable } from "./dynamicTemplate-B4GCNLF9.js";
|
|
5
5
|
import { c as isEditable, d as countUniqueVariableNames, f as getVariableNames, i as createSvgStr, l as readFile, n as convertForPdfLayoutProps, o as hex2PrintingColor, p as visitVariables, r as createErrorElm, t as addAlphaToHex, u as rotatePoint } from "./utils-zDZkqBnX.js";
|
|
6
6
|
import { a as normalizeListItems, c as LIST_STYLE_BULLET, i as normalizeListItemEntries, l as LIST_STYLE_ORDERED, n as calculateListLayout, o as serializeListItems, s as DEFAULT_LIST_STYLE, t as getDynamicLayoutForList } from "./dynamicTemplate-BwzF9C1L.js";
|
|
7
|
-
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-
|
|
7
|
+
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-Doen9Okh.js";
|
|
8
8
|
import "./tables.js";
|
|
9
9
|
import "./lists.js";
|
|
10
10
|
import { DEFAULT_FONT_NAME, ZOOM, b64toUint8Array, getDefaultFont, getFallbackFontName, getInternalLinkTarget, mm2pt, normalizeLinkHref, px2mm } from "@pdfme/common";
|
package/dist/texts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { X as TEXT_OVERFLOW_EXPAND, Z as TEXT_OVERFLOW_VISIBLE, i as TEXT_LINE_SPLIT_UNIT, s as createTextLineSplitRange, u as getTextLineRange } from "./splitRange-DmVDtmzO.js";
|
|
2
2
|
import { o as mergeTextLineRangeValue } from "./measure-L5diay3k.js";
|
|
3
|
-
import { n as getDynamicLayoutForMultiVariableText, t as getDynamicLayoutForText } from "./dynamicTemplate-
|
|
3
|
+
import { n as getDynamicLayoutForMultiVariableText, t as getDynamicLayoutForText } from "./dynamicTemplate-CRjx4Mjc.js";
|
|
4
4
|
export { TEXT_LINE_SPLIT_UNIT, TEXT_OVERFLOW_EXPAND, TEXT_OVERFLOW_VISIBLE, createTextLineSplitRange, getDynamicLayoutForMultiVariableText, getDynamicLayoutForText, getTextLineRange, mergeTextLineRangeValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfme/schemas",
|
|
3
|
-
"version": "6.1.2-dev.
|
|
3
|
+
"version": "6.1.2-dev.21",
|
|
4
4
|
"description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pdf",
|