@pdfme/schemas 6.1.1-dev.8 → 6.1.2
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/box.d.ts +45 -0
- package/dist/{builtins-pN5NVCSV.js → builtins-BB2DHceW.js} +216 -102
- package/dist/builtins-BB2DHceW.js.map +1 -0
- package/dist/builtins.js +1 -1
- package/dist/dynamicLayout.d.ts +1 -0
- package/dist/dynamicLayout.js +5 -5
- package/dist/dynamicLayout.js.map +1 -1
- package/dist/{dynamicTemplate-CkrZKlg-.js → dynamicTemplate-B4GCNLF9.js} +19 -53
- package/dist/dynamicTemplate-B4GCNLF9.js.map +1 -0
- package/dist/{dynamicTemplate-Cy07Imb5.js → dynamicTemplate-BwzF9C1L.js} +3 -6
- package/dist/{dynamicTemplate-Cy07Imb5.js.map → dynamicTemplate-BwzF9C1L.js.map} +1 -1
- package/dist/{dynamicTemplate-ByBNu75x.js → dynamicTemplate-C7MdZxPm.js} +18 -14
- package/dist/dynamicTemplate-C7MdZxPm.js.map +1 -0
- package/dist/{helper-BaUAusvL.js → helper-CEme39Uo.js} +2 -2
- package/dist/{helper-BaUAusvL.js.map → helper-CEme39Uo.js.map} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +253 -75
- package/dist/index.js.map +1 -1
- package/dist/list/types.d.ts +0 -5
- package/dist/lists.d.ts +2 -1
- package/dist/lists.js +3 -2
- package/dist/{measure-h-7PUE2B.js → measure-L5diay3k.js} +37 -9
- package/dist/measure-L5diay3k.js.map +1 -0
- package/dist/{helper-CBd9plP_.js → splitRange-DmVDtmzO.js} +105 -4
- package/dist/splitRange-DmVDtmzO.js.map +1 -0
- package/dist/splitRange.d.ts +16 -0
- package/dist/tables/helper.d.ts +8 -100
- package/dist/tables/types.d.ts +2 -6
- package/dist/tables.d.ts +1 -0
- package/dist/tables.js +3 -2
- package/dist/text/measure.d.ts +9 -3
- package/dist/text/overflow.d.ts +6 -2
- package/dist/text/richTextPdfRender.d.ts +1 -1
- package/dist/text/types.d.ts +4 -5
- package/dist/texts.d.ts +2 -1
- package/dist/texts.js +4 -4
- package/dist/types.d.ts +3 -1
- package/dist/utils-zDZkqBnX.js +250 -0
- package/dist/utils-zDZkqBnX.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +3 -216
- package/package.json +1 -1
- package/dist/builtins-pN5NVCSV.js.map +0 -1
- package/dist/dynamicTemplate-ByBNu75x.js.map +0 -1
- package/dist/dynamicTemplate-CkrZKlg-.js.map +0 -1
- package/dist/helper-CBd9plP_.js.map +0 -1
- package/dist/measure-h-7PUE2B.js.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-
|
|
1
|
+
import { s as createTextLineSplitRange } from "./splitRange-DmVDtmzO.js";
|
|
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-CEme39Uo.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] };
|
|
@@ -18,20 +18,22 @@ var getDynamicLayoutForMultiVariableText = async (value, args) => {
|
|
|
18
18
|
_cache: args._cache,
|
|
19
19
|
ignoreDynamicFontSize: true
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const heights = getTextLineHeightsWithBox(lineHeights, schema);
|
|
22
|
+
const measuredHeight = sumLineHeights(heights);
|
|
22
23
|
if (measuredHeight <= schema.height || lineHeights.length === 0) return {
|
|
23
24
|
heights: [schema.height],
|
|
24
25
|
patchSplitSchema: () => ({ dynamicFontSize: void 0 })
|
|
25
26
|
};
|
|
26
27
|
return {
|
|
27
|
-
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] :
|
|
28
|
+
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,
|
|
28
29
|
patchSplitSchema: ({ start, end, isSplit }) => ({
|
|
29
30
|
dynamicFontSize: void 0,
|
|
30
|
-
|
|
31
|
+
__splitRange: lineHeights.length === 1 ? void 0 : createTextLineSplitRange(start, end),
|
|
32
|
+
__isSplit: isSplit,
|
|
33
|
+
...getTextSplitBoxStyle(schema, {
|
|
31
34
|
start,
|
|
32
35
|
end
|
|
33
|
-
},
|
|
34
|
-
__isSplit: isSplit
|
|
36
|
+
}, lineHeights.length)
|
|
35
37
|
})
|
|
36
38
|
};
|
|
37
39
|
};
|
|
@@ -48,24 +50,26 @@ var getDynamicLayoutForText = async (value, args) => {
|
|
|
48
50
|
_cache: args._cache,
|
|
49
51
|
ignoreDynamicFontSize: true
|
|
50
52
|
});
|
|
51
|
-
const
|
|
53
|
+
const heights = getTextLineHeightsWithBox(lineHeights, schema);
|
|
54
|
+
const measuredHeight = sumLineHeights(heights);
|
|
52
55
|
if (measuredHeight <= schema.height || lineHeights.length === 0) return {
|
|
53
56
|
heights: [schema.height],
|
|
54
57
|
patchSplitSchema: () => ({ dynamicFontSize: void 0 })
|
|
55
58
|
};
|
|
56
59
|
return {
|
|
57
|
-
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] :
|
|
60
|
+
heights: lineHeights.length === 1 ? [Math.max(schema.height, measuredHeight)] : heights,
|
|
58
61
|
patchSplitSchema: ({ start, end, isSplit }) => ({
|
|
59
62
|
dynamicFontSize: void 0,
|
|
60
|
-
|
|
63
|
+
__splitRange: lineHeights.length === 1 ? void 0 : createTextLineSplitRange(start, end),
|
|
64
|
+
__isSplit: isSplit,
|
|
65
|
+
...getTextSplitBoxStyle(schema, {
|
|
61
66
|
start,
|
|
62
67
|
end
|
|
63
|
-
},
|
|
64
|
-
__isSplit: isSplit
|
|
68
|
+
}, lineHeights.length)
|
|
65
69
|
})
|
|
66
70
|
};
|
|
67
71
|
};
|
|
68
72
|
//#endregion
|
|
69
73
|
export { getDynamicLayoutForMultiVariableText as n, getDynamicLayoutForText as t };
|
|
70
74
|
|
|
71
|
-
//# sourceMappingURL=dynamicTemplate-
|
|
75
|
+
//# sourceMappingURL=dynamicTemplate-C7MdZxPm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicTemplate-C7MdZxPm.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,MAAM,iBAAiB,eAAe,QAAQ;AAE9C,KAAI,kBAAkB,OAAO,UAAU,YAAY,WAAW,EAC5D,QAAO;EACL,SAAS,CAAC,OAAO,OAAO;EACxB,yBAAyB,EAAE,iBAAiB,KAAA,GAAW;EACxD;AAGH,QAAO;EACL,SAAS,YAAY,WAAW,IAAI,CAAC,KAAK,IAAI,OAAO,QAAQ,eAAe,CAAC,GAAG;EAChF,mBAAmB,EAAE,OAAO,KAAK,eAAe;GAC9C,iBAAiB,KAAA;GACjB,cAAc,YAAY,WAAW,IAAI,KAAA,IAAY,yBAAyB,OAAO,IAAI;GACzF,WAAW;GACX,GAAG,qBAAqB,QAAQ;IAAE;IAAO;IAAK,EAAE,YAAY,OAAO;GACpE;EACF;;;;ACtDH,IAAa,0BAA0B,OACrC,OACA,SACiC;AACjC,KAAI,KAAK,OAAO,SAAS,OAAQ,QAAO,EAAE,SAAS,CAAC,KAAK,OAAO,OAAO,EAAE;CAEzE,MAAM,SAAS,KAAK;AACpB,KAAI,OAAO,aAAA,SACT,QAAO,EAAE,SAAS,CAAC,OAAO,OAAO,EAAE;CAGrC,MAAM,EAAE,gBAAgB,MAAM,iBAAiB;EAC7C;EACA;EACA,MAAM,KAAK,QAAQ;EACnB,QAAQ,KAAK;EAGb,uBAAuB;EACxB,CAAC;CACF,MAAM,UAAU,0BAA0B,aAAa,OAAO;CAC9D,MAAM,iBAAiB,eAAe,QAAQ;AAE9C,KAAI,kBAAkB,OAAO,UAAU,YAAY,WAAW,EAC5D,QAAO;EACL,SAAS,CAAC,OAAO,OAAO;EACxB,yBAAyB,EAAE,iBAAiB,KAAA,GAAW;EACxD;AAGH,QAAO;EACL,SAAS,YAAY,WAAW,IAAI,CAAC,KAAK,IAAI,OAAO,QAAQ,eAAe,CAAC,GAAG;EAChF,mBAAmB,EAAE,OAAO,KAAK,eAAe;GAC9C,iBAAiB,KAAA;GACjB,cAAc,YAAY,WAAW,IAAI,KAAA,IAAY,yBAAyB,OAAO,IAAI;GACzF,WAAW;GACX,GAAG,qBAAqB,QAAQ;IAAE;IAAO;IAAK,EAAE,YAAY,OAAO;GACpE;EACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as escapeInlineMarkdown } from "./measure-L5diay3k.js";
|
|
2
2
|
//#region src/multiVariableText/helper.ts
|
|
3
3
|
var substituteVariables = (text, variablesIn, valueMapper = (value) => value) => {
|
|
4
4
|
if (!text) return "";
|
|
@@ -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-CEme39Uo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper-
|
|
1
|
+
{"version":3,"file":"helper-CEme39Uo.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 (!values[variable]) {\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,KAAI,CAAC,OAAO,WAAW;AACrB,MAAI,OAAO,SACT,OAAM,IAAI,MACR,+BAA+B,SAAS,wBAAwB,OAAO,OACxE;AAGH,SAAO;;AAIX,QAAO"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export { builtInPlugins } from './builtins.js';
|
|
|
18
18
|
export { text, multiVariableText, list, image, signature, svg, table, barcodes, line, rectangle, ellipse, dateTime, date, time, select, radioGroup, checkbox, };
|
|
19
19
|
export { getDynamicHeightsForTable, getDynamicLayoutForTable } from './tables.js';
|
|
20
20
|
export { getDynamicLayoutForList } from './lists.js';
|
|
21
|
+
export { BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS, LIST_ITEM_SPLIT_UNIT, TABLE_BODY_SPLIT_UNIT, TEXT_LINE_SPLIT_UNIT, createListItemSplitRange, createTableBodySplitRange, createTextLineSplitRange, getListItemRange, getTableBodyRange, getTextLineRange, type BuiltInDynamicLayoutSplitUnit, } from './splitRange.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as mapVerticalAlignToFlex, c as Formatter, i as makeElementPlainTextContentEditable, l as getExtraFormatterSchema, n as textSchema, o as uiRender$4, r as buildStyledTextContainer, s as propPanel$3, t as builtInPlugins, u as pdfRender$4 } from "./builtins-
|
|
4
|
-
import { a as getCellPropPanelSchema, c as HEX_COLOR_PATTERN, i as
|
|
5
|
-
import {
|
|
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-
|
|
7
|
-
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-
|
|
1
|
+
import { $ as VERTICAL_ALIGN_MIDDLE, F as DEFAULT_FONT_COLOR, G as PLACEHOLDER_FONT_COLOR, K as SYNTHETIC_BOLD_CSS_TEXT_SHADOW, N as DEFAULT_ALIGNMENT, a as createListItemSplitRange, b as createBoxDimension, c as getListItemRange, h as getFontKitFont, i as TEXT_LINE_SPLIT_UNIT, j as CODE_BACKGROUND_COLOR, 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, x as getBoxContentArea } from "./splitRange-DmVDtmzO.js";
|
|
2
|
+
import { a as measureTextLines, d as isInlineMarkdownTextSchema, g as parseInlineMarkdown, p as resolveFontVariant } from "./measure-L5diay3k.js";
|
|
3
|
+
import { a as mapVerticalAlignToFlex, c as Formatter, i as makeElementPlainTextContentEditable, l as getExtraFormatterSchema, n as textSchema, o as uiRender$4, r as buildStyledTextContainer, s as propPanel$3, t as builtInPlugins, u as pdfRender$4 } from "./builtins-BB2DHceW.js";
|
|
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
|
+
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
|
+
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-CEme39Uo.js";
|
|
8
8
|
import "./tables.js";
|
|
9
9
|
import "./lists.js";
|
|
10
|
-
import { DEFAULT_FONT_NAME, ZOOM, b64toUint8Array, getDefaultFont, getFallbackFontName, mm2pt, px2mm } from "@pdfme/common";
|
|
10
|
+
import { DEFAULT_FONT_NAME, ZOOM, b64toUint8Array, getDefaultFont, getFallbackFontName, getInternalLinkTarget, mm2pt, normalizeLinkHref, px2mm } from "@pdfme/common";
|
|
11
11
|
import { Buffer as Buffer$1 } from "buffer";
|
|
12
12
|
import { toRadians } from "@pdfme/pdf-lib";
|
|
13
13
|
import { Barcode, Calendar, CalendarClock, ChevronDown, Circle, CircleDot, Clock, Image, List, Minus, QrCode, Route, Square, SquareCheck, Table, Type } from "lucide";
|
|
@@ -58,41 +58,6 @@ var pdfRender$3 = async (arg) => {
|
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
60
|
//#endregion
|
|
61
|
-
//#region src/multiVariableText/variables.ts
|
|
62
|
-
var visitVariables = (content, visitor) => {
|
|
63
|
-
let startIndex = -1;
|
|
64
|
-
for (let i = 0; i < content.length; i++) {
|
|
65
|
-
const char = content[i];
|
|
66
|
-
if (char === "{") {
|
|
67
|
-
startIndex = i;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (char === "}" && startIndex !== -1) {
|
|
71
|
-
const name = content.slice(startIndex + 1, i);
|
|
72
|
-
if (name.length > 0) visitor({
|
|
73
|
-
name,
|
|
74
|
-
startIndex,
|
|
75
|
-
endIndex: i
|
|
76
|
-
});
|
|
77
|
-
startIndex = -1;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
var countUniqueVariableNames = (content) => {
|
|
82
|
-
const variableNames = /* @__PURE__ */ new Set();
|
|
83
|
-
visitVariables(content, ({ name }) => {
|
|
84
|
-
variableNames.add(name);
|
|
85
|
-
});
|
|
86
|
-
return variableNames.size;
|
|
87
|
-
};
|
|
88
|
-
var getVariableNames = (content) => {
|
|
89
|
-
const variableNames = [];
|
|
90
|
-
visitVariables(content, ({ name }) => {
|
|
91
|
-
variableNames.push(name);
|
|
92
|
-
});
|
|
93
|
-
return variableNames;
|
|
94
|
-
};
|
|
95
|
-
//#endregion
|
|
96
61
|
//#region src/multiVariableText/propPanel.ts
|
|
97
62
|
var mapDynamicVariables = (props) => {
|
|
98
63
|
const { rootElement, changeSchemas, activeSchema, i18n, options } = props;
|
|
@@ -246,16 +211,6 @@ var uiRender$3 = async (arg) => {
|
|
|
246
211
|
const renderResolvedValue = schema.readOnly === true && mode !== "designer";
|
|
247
212
|
const renderValue = renderResolvedValue ? value : isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(text, value) : substituteVariables(text, value);
|
|
248
213
|
if (mode === "form" && numVariables > 0 && !renderResolvedValue) {
|
|
249
|
-
if (schema.__textLineRange) {
|
|
250
|
-
await uiRender$4({
|
|
251
|
-
value: renderValue,
|
|
252
|
-
schema,
|
|
253
|
-
mode: "viewer",
|
|
254
|
-
rootElement,
|
|
255
|
-
...rest
|
|
256
|
-
});
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
214
|
await formUiRender(arg);
|
|
260
215
|
return;
|
|
261
216
|
}
|
|
@@ -303,6 +258,28 @@ var formUiRender = async (arg) => {
|
|
|
303
258
|
const inlineMarkdownRuns = isInlineMarkdownTextSchema(schema) ? parseInlineMarkdown(rawText) : void 0;
|
|
304
259
|
const font = options?.font || getDefaultFont();
|
|
305
260
|
const textBlock = buildStyledTextContainer(arg, await getFontKitFont(schema.fontName, font, _cache), inlineMarkdownRuns ? getInlineMarkdownFormDisplayText(inlineMarkdownRuns, variables) : substitutedText);
|
|
261
|
+
if (getTextLineRange(schema)) {
|
|
262
|
+
const { lines } = await measureTextLines({
|
|
263
|
+
value: inlineMarkdownRuns ? substituteVariablesAsInlineMarkdownLiterals(rawText, variables) : substitutedText,
|
|
264
|
+
schema,
|
|
265
|
+
font,
|
|
266
|
+
_cache,
|
|
267
|
+
ignoreDynamicFontSize: true
|
|
268
|
+
});
|
|
269
|
+
renderSplitVariableSpans({
|
|
270
|
+
textBlock,
|
|
271
|
+
lines,
|
|
272
|
+
runs: inlineMarkdownRuns,
|
|
273
|
+
rawText,
|
|
274
|
+
variables,
|
|
275
|
+
schema,
|
|
276
|
+
font,
|
|
277
|
+
theme,
|
|
278
|
+
onChange,
|
|
279
|
+
stopEditing
|
|
280
|
+
});
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
306
283
|
if (inlineMarkdownRuns) {
|
|
307
284
|
renderInlineMarkdownVariableSpans({
|
|
308
285
|
runs: inlineMarkdownRuns,
|
|
@@ -351,6 +328,190 @@ var formUiRender = async (arg) => {
|
|
|
351
328
|
}
|
|
352
329
|
}
|
|
353
330
|
};
|
|
331
|
+
var renderSplitVariableSpans = (arg) => {
|
|
332
|
+
const { textBlock, lines, runs, rawText, variables, schema, font, theme, onChange, stopEditing } = arg;
|
|
333
|
+
const lineRange = getTextLineRange(schema);
|
|
334
|
+
const lineSegments = getSplitLineSegments({
|
|
335
|
+
lines,
|
|
336
|
+
runs,
|
|
337
|
+
rawText,
|
|
338
|
+
variables,
|
|
339
|
+
start: lineRange?.start ?? 0,
|
|
340
|
+
end: lineRange?.end ?? lines.length
|
|
341
|
+
});
|
|
342
|
+
textBlock.innerHTML = "";
|
|
343
|
+
lineSegments.forEach((segments, lineIndex) => {
|
|
344
|
+
segments.forEach((segment) => {
|
|
345
|
+
if (segment.variableName) {
|
|
346
|
+
appendRangedVariableSpan({
|
|
347
|
+
textBlock,
|
|
348
|
+
segment,
|
|
349
|
+
variables,
|
|
350
|
+
schema,
|
|
351
|
+
font,
|
|
352
|
+
theme,
|
|
353
|
+
onChange,
|
|
354
|
+
stopEditing
|
|
355
|
+
});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const span = segment.run ? createStaticInlineMarkdownElement(segment.run) : document.createElement("span");
|
|
359
|
+
span.style.letterSpacing = lineIndex === lineSegments.length - 1 ? "0" : "inherit";
|
|
360
|
+
span.textContent = segment.text;
|
|
361
|
+
if (segment.run) applyInlineMarkdownStyle({
|
|
362
|
+
element: span,
|
|
363
|
+
run: segment.run,
|
|
364
|
+
schema,
|
|
365
|
+
font
|
|
366
|
+
});
|
|
367
|
+
textBlock.appendChild(span);
|
|
368
|
+
});
|
|
369
|
+
if (lineIndex < lineSegments.length - 1) textBlock.appendChild(document.createElement("br"));
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
var getSplitLineSegments = (arg) => {
|
|
373
|
+
const { lines, runs, rawText, variables, start, end } = arg;
|
|
374
|
+
return consumeMeasuredLineSegments(lines, runs ? buildResolvedInlineMarkdownChars(runs, variables) : buildResolvedPlainChars(rawText, variables), { dropUnmappedTargets: Boolean(runs) }).slice(start, end);
|
|
375
|
+
};
|
|
376
|
+
var buildResolvedPlainChars = (rawText, variables) => {
|
|
377
|
+
const chars = [];
|
|
378
|
+
let lastIndex = 0;
|
|
379
|
+
visitVariables(rawText, ({ name, startIndex, endIndex }) => {
|
|
380
|
+
appendTextChars(chars, rawText.slice(lastIndex, startIndex));
|
|
381
|
+
const value = variables[name] ?? "";
|
|
382
|
+
for (let i = 0; i < value.length; i += 1) chars.push({
|
|
383
|
+
char: value[i],
|
|
384
|
+
variableName: name,
|
|
385
|
+
variableOffset: i
|
|
386
|
+
});
|
|
387
|
+
lastIndex = endIndex + 1;
|
|
388
|
+
});
|
|
389
|
+
appendTextChars(chars, rawText.slice(lastIndex));
|
|
390
|
+
return chars;
|
|
391
|
+
};
|
|
392
|
+
var buildResolvedInlineMarkdownChars = (runs, variables) => {
|
|
393
|
+
const chars = [];
|
|
394
|
+
runs.forEach((run) => {
|
|
395
|
+
let lastIndex = 0;
|
|
396
|
+
visitVariables(run.text, ({ name, startIndex, endIndex }) => {
|
|
397
|
+
appendTextChars(chars, run.text.slice(lastIndex, startIndex), run);
|
|
398
|
+
const value = variables[name] ?? "";
|
|
399
|
+
for (let i = 0; i < value.length; i += 1) chars.push({
|
|
400
|
+
char: value[i],
|
|
401
|
+
variableName: name,
|
|
402
|
+
variableOffset: i,
|
|
403
|
+
run
|
|
404
|
+
});
|
|
405
|
+
lastIndex = endIndex + 1;
|
|
406
|
+
});
|
|
407
|
+
appendTextChars(chars, run.text.slice(lastIndex), run);
|
|
408
|
+
});
|
|
409
|
+
return chars;
|
|
410
|
+
};
|
|
411
|
+
var appendTextChars = (chars, text, run) => {
|
|
412
|
+
for (let i = 0; i < text.length; i += 1) chars.push({
|
|
413
|
+
char: text[i],
|
|
414
|
+
run
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
var consumeMeasuredLineSegments = (lines, resolvedChars, options = {}) => {
|
|
418
|
+
const lineSegments = [];
|
|
419
|
+
let cursor = 0;
|
|
420
|
+
lines.forEach((line) => {
|
|
421
|
+
const segments = [];
|
|
422
|
+
const lineText = stripTrailingLineBreaks(line);
|
|
423
|
+
for (let i = 0; i < lineText.length; i += 1) {
|
|
424
|
+
const target = lineText[i];
|
|
425
|
+
while (cursor < resolvedChars.length && resolvedChars[cursor].char !== target && isWhitespaceChar(resolvedChars[cursor].char) && !isWhitespaceChar(target)) cursor += 1;
|
|
426
|
+
if (cursor >= resolvedChars.length) {
|
|
427
|
+
if (options.dropUnmappedTargets) continue;
|
|
428
|
+
appendSegment(segments, { char: target });
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
const sourceChar = resolvedChars[cursor];
|
|
432
|
+
if (sourceChar.char === target) {
|
|
433
|
+
appendSegment(segments, sourceChar);
|
|
434
|
+
cursor += 1;
|
|
435
|
+
} else {
|
|
436
|
+
if (options.dropUnmappedTargets) continue;
|
|
437
|
+
appendSegment(segments, { char: target });
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
cursor = absorbHiddenTrailingWhitespace(segments, resolvedChars, cursor);
|
|
441
|
+
if (line.endsWith("\r\n") || line.endsWith("\n") || line.endsWith("\r")) {
|
|
442
|
+
if (resolvedChars[cursor]?.char === "\r" && resolvedChars[cursor + 1]?.char === "\n") cursor += 2;
|
|
443
|
+
else if (resolvedChars[cursor]?.char === "\n" || resolvedChars[cursor]?.char === "\r") cursor += 1;
|
|
444
|
+
}
|
|
445
|
+
lineSegments.push(segments);
|
|
446
|
+
});
|
|
447
|
+
return lineSegments;
|
|
448
|
+
};
|
|
449
|
+
var absorbHiddenTrailingWhitespace = (segments, resolvedChars, cursor) => {
|
|
450
|
+
let nextCursor = cursor;
|
|
451
|
+
while (nextCursor < resolvedChars.length && isHorizontalWhitespaceChar(resolvedChars[nextCursor].char)) {
|
|
452
|
+
const sourceChar = resolvedChars[nextCursor];
|
|
453
|
+
const lastSegment = segments.at(-1);
|
|
454
|
+
if (lastSegment && lastSegment.variableName === sourceChar.variableName && lastSegment.variableEnd === sourceChar.variableOffset && lastSegment.run === sourceChar.run && sourceChar.variableOffset !== void 0) lastSegment.variableEnd = sourceChar.variableOffset + 1;
|
|
455
|
+
nextCursor += 1;
|
|
456
|
+
}
|
|
457
|
+
return nextCursor;
|
|
458
|
+
};
|
|
459
|
+
var stripTrailingLineBreaks = (value) => {
|
|
460
|
+
let end = value.length;
|
|
461
|
+
while (end > 0) {
|
|
462
|
+
const char = value[end - 1];
|
|
463
|
+
if (char !== "\n" && char !== "\r") break;
|
|
464
|
+
end -= 1;
|
|
465
|
+
}
|
|
466
|
+
return value.slice(0, end);
|
|
467
|
+
};
|
|
468
|
+
var isWhitespaceChar = (value) => value === " " || value === " " || value === "\n" || value === "\r" || value === "\f" || value === "\v";
|
|
469
|
+
var isHorizontalWhitespaceChar = (value) => value === " " || value === " " || value === "\f" || value === "\v";
|
|
470
|
+
var appendSegment = (segments, sourceChar) => {
|
|
471
|
+
const lastSegment = segments.at(-1);
|
|
472
|
+
if (lastSegment && lastSegment.variableName === sourceChar.variableName && lastSegment.variableEnd === sourceChar.variableOffset && lastSegment.run === sourceChar.run) {
|
|
473
|
+
lastSegment.text += sourceChar.char;
|
|
474
|
+
if (sourceChar.variableOffset !== void 0) lastSegment.variableEnd = sourceChar.variableOffset + 1;
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
segments.push({
|
|
478
|
+
text: sourceChar.char,
|
|
479
|
+
variableName: sourceChar.variableName,
|
|
480
|
+
variableStart: sourceChar.variableOffset,
|
|
481
|
+
variableEnd: sourceChar.variableOffset === void 0 ? void 0 : sourceChar.variableOffset + 1,
|
|
482
|
+
run: sourceChar.run
|
|
483
|
+
});
|
|
484
|
+
};
|
|
485
|
+
var appendRangedVariableSpan = (arg) => {
|
|
486
|
+
const { textBlock, segment, variables, schema, font, theme, onChange, stopEditing } = arg;
|
|
487
|
+
if (!segment.variableName) return;
|
|
488
|
+
const span = document.createElement("span");
|
|
489
|
+
span.style.outline = `${theme.colorPrimary} dashed 1px`;
|
|
490
|
+
if (segment.run) applyInlineMarkdownStyle({
|
|
491
|
+
element: span,
|
|
492
|
+
run: segment.run,
|
|
493
|
+
schema,
|
|
494
|
+
font
|
|
495
|
+
});
|
|
496
|
+
makeElementPlainTextContentEditable(span);
|
|
497
|
+
span.textContent = segment.text;
|
|
498
|
+
span.addEventListener("blur", (e) => {
|
|
499
|
+
const variableName = segment.variableName;
|
|
500
|
+
if (!variableName) return;
|
|
501
|
+
const newValue = e.target.textContent || "";
|
|
502
|
+
if (newValue === segment.text) return;
|
|
503
|
+
const currentValue = variables[variableName] ?? "";
|
|
504
|
+
const start = Math.min(segment.variableStart ?? 0, currentValue.length);
|
|
505
|
+
const end = Math.min(segment.variableEnd ?? currentValue.length, currentValue.length);
|
|
506
|
+
variables[variableName] = currentValue.slice(0, start) + newValue + currentValue.slice(end);
|
|
507
|
+
if (onChange) onChange({
|
|
508
|
+
key: "content",
|
|
509
|
+
value: JSON.stringify(variables)
|
|
510
|
+
});
|
|
511
|
+
if (stopEditing) stopEditing();
|
|
512
|
+
});
|
|
513
|
+
textBlock.appendChild(span);
|
|
514
|
+
};
|
|
354
515
|
var getInlineMarkdownFormDisplayText = (runs, variables) => runs.map((run) => substituteVariables(run.text, variables)).join("");
|
|
355
516
|
var applyInlineMarkdownStyle = (arg) => {
|
|
356
517
|
const { element, run, schema, font } = arg;
|
|
@@ -362,6 +523,7 @@ var applyInlineMarkdownStyle = (arg) => {
|
|
|
362
523
|
}
|
|
363
524
|
if (resolvedFont.syntheticItalic) element.style.fontStyle = "italic";
|
|
364
525
|
const textDecorations = [];
|
|
526
|
+
if (run.href) textDecorations.push("underline");
|
|
365
527
|
if (run.strikethrough) textDecorations.push("line-through");
|
|
366
528
|
if (textDecorations.length > 0) element.style.textDecoration = textDecorations.join(" ");
|
|
367
529
|
if (run.code) {
|
|
@@ -371,10 +533,21 @@ var applyInlineMarkdownStyle = (arg) => {
|
|
|
371
533
|
if (!schema.fontVariants?.code || !font[schema.fontVariants.code]) element.style.fontFamily = resolvedFont.fontName ? `'${resolvedFont.fontName}', monospace` : "monospace";
|
|
372
534
|
}
|
|
373
535
|
};
|
|
536
|
+
var createStaticInlineMarkdownElement = (run) => {
|
|
537
|
+
const href = run.href ? normalizeLinkHref(run.href) : void 0;
|
|
538
|
+
if (!href) return document.createElement("span");
|
|
539
|
+
const anchor = document.createElement("a");
|
|
540
|
+
anchor.href = href;
|
|
541
|
+
if (!getInternalLinkTarget(href)) {
|
|
542
|
+
anchor.target = "_blank";
|
|
543
|
+
anchor.rel = "noopener noreferrer";
|
|
544
|
+
}
|
|
545
|
+
return anchor;
|
|
546
|
+
};
|
|
374
547
|
var appendTextSpan = (arg) => {
|
|
375
548
|
const { textBlock, text, run, schema, font } = arg;
|
|
376
549
|
if (!text) return;
|
|
377
|
-
const span =
|
|
550
|
+
const span = createStaticInlineMarkdownElement(run);
|
|
378
551
|
span.textContent = text;
|
|
379
552
|
applyInlineMarkdownStyle({
|
|
380
553
|
element: span,
|
|
@@ -610,7 +783,7 @@ var rectanglePdfRender$2 = rectangle.pdf;
|
|
|
610
783
|
var pdfRender$2 = async (arg) => {
|
|
611
784
|
const { schema, value } = arg;
|
|
612
785
|
const items = normalizeListItems(value);
|
|
613
|
-
const range = schema
|
|
786
|
+
const range = getListItemRange(schema) ?? {
|
|
614
787
|
start: 0,
|
|
615
788
|
end: items.length
|
|
616
789
|
};
|
|
@@ -875,7 +1048,7 @@ var uiRender$2 = async (arg) => {
|
|
|
875
1048
|
const usePlaceholder = editable && !value && Boolean(placeholder);
|
|
876
1049
|
const items = normalizeListItems(usePlaceholder ? placeholder || "" : value);
|
|
877
1050
|
const originalItems = normalizeListItemEntries(value);
|
|
878
|
-
const range = schema
|
|
1051
|
+
const range = getListItemRange(schema) ?? {
|
|
879
1052
|
start: 0,
|
|
880
1053
|
end: items.length
|
|
881
1054
|
};
|
|
@@ -2303,14 +2476,14 @@ var renderLine = async (arg, schema, position, width, height) => linePdfRender({
|
|
|
2303
2476
|
}
|
|
2304
2477
|
});
|
|
2305
2478
|
var createTextDiv = (schema) => {
|
|
2306
|
-
const
|
|
2479
|
+
const contentArea = getBoxContentArea(schema);
|
|
2307
2480
|
const textDiv = document.createElement("div");
|
|
2308
2481
|
textDiv.style.position = "absolute";
|
|
2309
2482
|
textDiv.style.zIndex = "1";
|
|
2310
|
-
textDiv.style.width = `${width
|
|
2311
|
-
textDiv.style.height = `${height
|
|
2312
|
-
textDiv.style.top = `${
|
|
2313
|
-
textDiv.style.left = `${
|
|
2483
|
+
textDiv.style.width = `${contentArea.width}mm`;
|
|
2484
|
+
textDiv.style.height = `${contentArea.height}mm`;
|
|
2485
|
+
textDiv.style.top = `${contentArea.topInset}mm`;
|
|
2486
|
+
textDiv.style.left = `${contentArea.leftInset}mm`;
|
|
2314
2487
|
return textDiv;
|
|
2315
2488
|
};
|
|
2316
2489
|
var createLineDiv = (width, height, top, right, bottom, left, borderColor) => {
|
|
@@ -2328,7 +2501,8 @@ var createLineDiv = (width, height, top, right, bottom, left, borderColor) => {
|
|
|
2328
2501
|
var cellSchema = {
|
|
2329
2502
|
pdf: async (arg) => {
|
|
2330
2503
|
const { schema } = arg;
|
|
2331
|
-
const { position, width, height, borderWidth
|
|
2504
|
+
const { position, width, height, borderWidth } = schema;
|
|
2505
|
+
const contentArea = getBoxContentArea(schema);
|
|
2332
2506
|
await Promise.all([
|
|
2333
2507
|
rectanglePdfRender$1({
|
|
2334
2508
|
...arg,
|
|
@@ -2365,12 +2539,12 @@ var cellSchema = {
|
|
|
2365
2539
|
...schema,
|
|
2366
2540
|
type: "text",
|
|
2367
2541
|
backgroundColor: "",
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
width: width
|
|
2373
|
-
height: height
|
|
2542
|
+
borderColor: "",
|
|
2543
|
+
borderWidth: createBoxDimension(0),
|
|
2544
|
+
padding: createBoxDimension(0),
|
|
2545
|
+
position: contentArea.position,
|
|
2546
|
+
width: contentArea.width,
|
|
2547
|
+
height: contentArea.height
|
|
2374
2548
|
}
|
|
2375
2549
|
});
|
|
2376
2550
|
},
|
|
@@ -2383,7 +2557,10 @@ var cellSchema = {
|
|
|
2383
2557
|
...arg,
|
|
2384
2558
|
schema: {
|
|
2385
2559
|
...schema,
|
|
2386
|
-
backgroundColor: ""
|
|
2560
|
+
backgroundColor: "",
|
|
2561
|
+
borderColor: "",
|
|
2562
|
+
borderWidth: createBoxDimension(0),
|
|
2563
|
+
padding: createBoxDimension(0)
|
|
2387
2564
|
},
|
|
2388
2565
|
rootElement: textDiv
|
|
2389
2566
|
});
|
|
@@ -2503,7 +2680,7 @@ async function drawTable(arg, table) {
|
|
|
2503
2680
|
}
|
|
2504
2681
|
var pdfRender = async (arg) => {
|
|
2505
2682
|
const { value, schema, basePdf, options, _cache } = arg;
|
|
2506
|
-
const body =
|
|
2683
|
+
const body = getBodyWithSchemaRange(typeof value !== "string" ? JSON.stringify(value || "[]") : value, schema);
|
|
2507
2684
|
const createTableArgs = {
|
|
2508
2685
|
schema,
|
|
2509
2686
|
basePdf,
|
|
@@ -2630,7 +2807,7 @@ var renderRowUi = (args) => {
|
|
|
2630
2807
|
if (!arg.onChange) return;
|
|
2631
2808
|
const newValue = Array.isArray(v) ? v[0].value : v.value;
|
|
2632
2809
|
if (section === "body") {
|
|
2633
|
-
const startRange = arg.schema
|
|
2810
|
+
const startRange = getTableBodyRange(arg.schema)?.start ?? 0;
|
|
2634
2811
|
value[rowIndex + startRange][colIndex] = newValue;
|
|
2635
2812
|
arg.onChange({
|
|
2636
2813
|
key: "content",
|
|
@@ -2683,7 +2860,8 @@ var resetEditingPosition = () => {
|
|
|
2683
2860
|
var uiRender = async (arg) => {
|
|
2684
2861
|
const { rootElement, onChange, schema, value, mode, scale } = arg;
|
|
2685
2862
|
const body = getBody(value);
|
|
2686
|
-
const
|
|
2863
|
+
const bodyRange = getTableBodyRange(schema);
|
|
2864
|
+
const bodyWidthRange = getBodyWithSchemaRange(value, schema, bodyRange);
|
|
2687
2865
|
const table = await createSingleTable(bodyWidthRange, arg);
|
|
2688
2866
|
const showHead = table.settings.showHead;
|
|
2689
2867
|
rootElement.innerHTML = "";
|
|
@@ -2736,7 +2914,7 @@ var uiRender = async (arg) => {
|
|
|
2736
2914
|
text: "-",
|
|
2737
2915
|
ariaLabel: "Remove row",
|
|
2738
2916
|
onClick: () => {
|
|
2739
|
-
const newTableBody = body.filter((_, j) => j !== i + (
|
|
2917
|
+
const newTableBody = body.filter((_, j) => j !== i + (bodyRange?.start ?? 0));
|
|
2740
2918
|
if (onChange) onChange({
|
|
2741
2919
|
key: "content",
|
|
2742
2920
|
value: JSON.stringify(newTableBody)
|
|
@@ -2746,7 +2924,7 @@ var uiRender = async (arg) => {
|
|
|
2746
2924
|
});
|
|
2747
2925
|
};
|
|
2748
2926
|
if (mode === "form" && onChange && !schema.readOnly) {
|
|
2749
|
-
if (
|
|
2927
|
+
if (bodyRange?.end === void 0 || bodyRange.end >= JSON.parse(value || "[]").length) rootElement.appendChild(createAddRowButton());
|
|
2750
2928
|
createRemoveRowButtons().forEach((button) => rootElement.appendChild(button));
|
|
2751
2929
|
}
|
|
2752
2930
|
if (mode === "designer" && onChange) {
|
|
@@ -6147,6 +6325,6 @@ var schema = {
|
|
|
6147
6325
|
icon: getCheckedIcon()
|
|
6148
6326
|
};
|
|
6149
6327
|
//#endregion
|
|
6150
|
-
export { barcodes, builtInPlugins, schema as checkbox, date_default as date, dateTime_default as dateTime, ellipse, getDynamicHeightsForTable, getDynamicLayoutForList, getDynamicLayoutForTable, imageSchema as image, lineSchema as line, listSchema as list, schema$1 as multiVariableText, schema$2 as radioGroup, rectangle, schema$3 as select, signature, svgSchema as svg, tableSchema as table, textSchema as text, time_default as time };
|
|
6328
|
+
export { BUILT_IN_DYNAMIC_LAYOUT_SPLIT_UNITS, LIST_ITEM_SPLIT_UNIT, TABLE_BODY_SPLIT_UNIT, TEXT_LINE_SPLIT_UNIT, barcodes, builtInPlugins, schema as checkbox, createListItemSplitRange, createTableBodySplitRange, createTextLineSplitRange, date_default as date, dateTime_default as dateTime, ellipse, getDynamicHeightsForTable, getDynamicLayoutForList, getDynamicLayoutForTable, getListItemRange, getTableBodyRange, getTextLineRange, imageSchema as image, lineSchema as line, listSchema as list, schema$1 as multiVariableText, schema$2 as radioGroup, rectangle, schema$3 as select, signature, svgSchema as svg, tableSchema as table, textSchema as text, time_default as time };
|
|
6151
6329
|
|
|
6152
6330
|
//# sourceMappingURL=index.js.map
|