@pdfme/schemas 6.1.12 → 6.1.13
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/barcodes/constants.d.ts +1 -1
- package/dist/barcodes/helper.d.ts +1 -1
- package/dist/barcodes/index.d.ts +1 -1
- package/dist/{builtins-D6FCodhC.js → builtins-8En4EIAG.js} +27 -21
- package/dist/{builtins-D6FCodhC.js.map → builtins-8En4EIAG.js.map} +1 -1
- package/dist/builtins.js +1 -1
- package/dist/date/helper.d.ts +1 -1
- package/dist/dynamicLayout.js +4 -4
- package/dist/{dynamicTemplate-Cco1tXiK.js → dynamicTemplate-CnK0nlnj.js} +45 -32
- package/dist/dynamicTemplate-CnK0nlnj.js.map +1 -0
- package/dist/{dynamicTemplate-BnIhGSVz.js → dynamicTemplate-DFk_de1Y.js} +5 -5
- package/dist/dynamicTemplate-DFk_de1Y.js.map +1 -0
- package/dist/{dynamicTemplate-C4UKzQbP.js → dynamicTemplate-DQF7c6NR.js} +2 -2
- package/dist/{dynamicTemplate-C4UKzQbP.js.map → dynamicTemplate-DQF7c6NR.js.map} +1 -1
- package/dist/{helper-BChY9FCm.js → helper-VroN19Ci.js} +2 -2
- package/dist/{helper-BChY9FCm.js.map → helper-VroN19Ci.js.map} +1 -1
- package/dist/index.js +55 -36
- package/dist/index.js.map +1 -1
- package/dist/lists.js +2 -2
- package/dist/{measure-B_6K--bf.js → measure-BC7tjAtT.js} +4 -3
- package/dist/{measure-B_6K--bf.js.map → measure-BC7tjAtT.js.map} +1 -1
- package/dist/{splitRange-BOUo4Tvl.js → splitRange-BHV0vb0Q.js} +48 -39
- package/dist/{splitRange-BOUo4Tvl.js.map → splitRange-BHV0vb0Q.js.map} +1 -1
- package/dist/splitRange.d.ts +3 -3
- package/dist/tables/helper.d.ts +34 -34
- package/dist/tables.js +2 -2
- package/dist/text/helper.d.ts +1 -1
- package/dist/text/measure.d.ts +1 -1
- package/dist/text/overflow.d.ts +2 -2
- package/dist/text/richTextPdfRender.d.ts +3 -3
- package/dist/texts.js +3 -3
- package/dist/{utils-Fs3Zwymf.js → utils-D_sFXK0U.js} +6 -3
- package/dist/{utils-Fs3Zwymf.js.map → utils-D_sFXK0U.js.map} +1 -1
- package/dist/utils.d.ts +2 -6
- package/dist/utils.js +2 -2
- package/package.json +5 -5
- package/dist/dynamicTemplate-BnIhGSVz.js.map +0 -1
- package/dist/dynamicTemplate-Cco1tXiK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-
|
|
2
|
-
import { a as measureTextLines, d as isInlineMarkdownTextSchema, g as parseInlineMarkdown, p as resolveFontVariant } from "./measure-
|
|
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 getBodyWithSchemaRange, l as createSingleTable, n as getDynamicLayoutForTable, o as getColumnStylesPropPanelSchema, r as getBody, s as getDefaultCellStyles, t as getDynamicHeightsForTable } from "./dynamicTemplate-
|
|
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-
|
|
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-BHV0vb0Q.js";
|
|
2
|
+
import { a as measureTextLines, d as isInlineMarkdownTextSchema, g as parseInlineMarkdown, p as resolveFontVariant } from "./measure-BC7tjAtT.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-8En4EIAG.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-CnK0nlnj.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-D_sFXK0U.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-DQF7c6NR.js";
|
|
7
|
+
import { n as substituteVariablesAsInlineMarkdownLiterals, r as validateVariables, t as substituteVariables } from "./helper-VroN19Ci.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";
|
|
@@ -34,7 +34,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
}
|
|
35
35
|
return to;
|
|
36
36
|
};
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
38
38
|
value: mod,
|
|
39
39
|
enumerable: true
|
|
40
40
|
}) : target, mod));
|
|
@@ -43,19 +43,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
43
43
|
var pdfRender$3 = async (arg) => {
|
|
44
44
|
const { value, schema, ...rest } = arg;
|
|
45
45
|
if (schema.readOnly) {
|
|
46
|
+
const readOnlyValue = schema.variables.length > 0 ? value : schema.text || "";
|
|
46
47
|
await pdfRender$4({
|
|
47
|
-
value,
|
|
48
|
+
value: readOnlyValue,
|
|
48
49
|
schema,
|
|
49
50
|
...rest
|
|
50
51
|
});
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
if (!validateVariables(value, schema)) return;
|
|
54
|
-
|
|
55
|
+
const renderArgs = {
|
|
55
56
|
value: isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(schema.text || "", value) : substituteVariables(schema.text || "", value),
|
|
56
57
|
schema,
|
|
57
58
|
...rest
|
|
58
|
-
}
|
|
59
|
+
};
|
|
60
|
+
await pdfRender$4(renderArgs);
|
|
59
61
|
};
|
|
60
62
|
//#endregion
|
|
61
63
|
//#region src/multiVariableText/propPanel.ts
|
|
@@ -209,7 +211,7 @@ var uiRender$3 = async (arg) => {
|
|
|
209
211
|
let text = schema.text;
|
|
210
212
|
let numVariables = schema.variables.length;
|
|
211
213
|
const renderResolvedValue = schema.readOnly === true && mode !== "designer";
|
|
212
|
-
const renderValue = renderResolvedValue ? value : isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(text, value) : substituteVariables(text, value);
|
|
214
|
+
const renderValue = renderResolvedValue ? numVariables > 0 ? value : text || "" : isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(text, value) : substituteVariables(text, value);
|
|
213
215
|
if (mode === "form" && numVariables > 0 && !renderResolvedValue) {
|
|
214
216
|
await formUiRender(arg);
|
|
215
217
|
return;
|
|
@@ -232,7 +234,7 @@ var uiRender$3 = async (arg) => {
|
|
|
232
234
|
const textBlock = rootElement.querySelector("#text-" + String(schema.id));
|
|
233
235
|
if (!textBlock) throw new Error("Text block not found. Ensure the text block has an id of \"text-\" + schema.id");
|
|
234
236
|
if (mode === "designer") textBlock.addEventListener("keyup", (event) => {
|
|
235
|
-
text = textBlock.
|
|
237
|
+
text = textBlock.innerText || "";
|
|
236
238
|
if (keyPressShouldBeChecked(event)) {
|
|
237
239
|
const newNumVariables = countUniqueVariableNames(text);
|
|
238
240
|
if (numVariables !== newNumVariables) {
|
|
@@ -257,7 +259,8 @@ var formUiRender = async (arg) => {
|
|
|
257
259
|
const substitutedText = substituteVariables(rawText, variables);
|
|
258
260
|
const inlineMarkdownRuns = isInlineMarkdownTextSchema(schema) ? parseInlineMarkdown(rawText) : void 0;
|
|
259
261
|
const font = options?.font || getDefaultFont();
|
|
260
|
-
const
|
|
262
|
+
const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
|
|
263
|
+
const textBlock = buildStyledTextContainer(arg, fontKitFont, inlineMarkdownRuns ? getInlineMarkdownFormDisplayText(inlineMarkdownRuns, variables) : substitutedText);
|
|
261
264
|
if (getTextLineRange(schema)) {
|
|
262
265
|
const { lines } = await measureTextLines({
|
|
263
266
|
value: inlineMarkdownRuns ? substituteVariablesAsInlineMarkdownLiterals(rawText, variables) : substitutedText,
|
|
@@ -1408,8 +1411,8 @@ var listSchema = {
|
|
|
1408
1411
|
var decoder = new TextDecoder();
|
|
1409
1412
|
var toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
|
|
1410
1413
|
var toHexString = (input, start = 0, end = input.length) => input.slice(start, end).reduce((memo, i) => memo + ("0" + i.toString(16)).slice(-2), "");
|
|
1411
|
-
var readUInt16BE = (input, offset = 0) => input[offset] *
|
|
1412
|
-
var readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] *
|
|
1414
|
+
var readUInt16BE = (input, offset = 0) => input[offset] * 256 + input[offset + 1];
|
|
1415
|
+
var readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 256 + input[offset + 3];
|
|
1413
1416
|
var extractSize = (input, index) => {
|
|
1414
1417
|
return {
|
|
1415
1418
|
height: readUInt16BE(input, index),
|
|
@@ -1547,9 +1550,10 @@ var imageSchema = {
|
|
|
1547
1550
|
_schema.height = boxHeight;
|
|
1548
1551
|
_schema.position.x += (boxWidth - _schema.width) / 2;
|
|
1549
1552
|
}
|
|
1553
|
+
const pageHeight = page.getHeight();
|
|
1550
1554
|
const { width, height, rotate, position, opacity } = convertForPdfLayoutProps({
|
|
1551
1555
|
schema: _schema,
|
|
1552
|
-
pageHeight
|
|
1556
|
+
pageHeight
|
|
1553
1557
|
});
|
|
1554
1558
|
const { x, y } = position;
|
|
1555
1559
|
const drawOptions = {
|
|
@@ -1647,7 +1651,8 @@ var imageSchema = {
|
|
|
1647
1651
|
input.accept = "image/jpeg, image/png";
|
|
1648
1652
|
input.addEventListener("change", (event) => {
|
|
1649
1653
|
const target = event.target;
|
|
1650
|
-
|
|
1654
|
+
const files = target instanceof HTMLInputElement ? target.files : null;
|
|
1655
|
+
readFile(files).then((result) => {
|
|
1651
1656
|
if (onChange) onChange({
|
|
1652
1657
|
key: "content",
|
|
1653
1658
|
value: result
|
|
@@ -1919,9 +1924,10 @@ var svgSchema = {
|
|
|
1919
1924
|
pdf: async (arg) => {
|
|
1920
1925
|
const { page, schema, value } = arg;
|
|
1921
1926
|
if (!value || !isValidSVG(value)) return;
|
|
1927
|
+
const pageHeight = page.getHeight();
|
|
1922
1928
|
const { width, height, position } = convertForPdfLayoutProps({
|
|
1923
1929
|
schema,
|
|
1924
|
-
pageHeight
|
|
1930
|
+
pageHeight
|
|
1925
1931
|
});
|
|
1926
1932
|
const { x, y } = position;
|
|
1927
1933
|
await page.drawSvg(value, {
|
|
@@ -2061,9 +2067,10 @@ var pdfRender$1 = async (arg) => {
|
|
|
2061
2067
|
image = await pdfDoc.embedPng(imageBuf);
|
|
2062
2068
|
_cache.set(inputBarcodeCacheKey, image);
|
|
2063
2069
|
}
|
|
2070
|
+
const pageHeight = page.getHeight();
|
|
2064
2071
|
const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
|
|
2065
2072
|
schema,
|
|
2066
|
-
pageHeight
|
|
2073
|
+
pageHeight
|
|
2067
2074
|
});
|
|
2068
2075
|
page.drawImage(image, {
|
|
2069
2076
|
x,
|
|
@@ -2382,9 +2389,10 @@ var lineSchema = {
|
|
|
2382
2389
|
const { page, schema, options } = arg;
|
|
2383
2390
|
if (schema.width === 0 || schema.height === 0 || !schema.color) return;
|
|
2384
2391
|
const { colorType } = options;
|
|
2392
|
+
const pageHeight = page.getHeight();
|
|
2385
2393
|
const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
|
|
2386
2394
|
schema,
|
|
2387
|
-
pageHeight
|
|
2395
|
+
pageHeight,
|
|
2388
2396
|
applyRotateTranslate: false
|
|
2389
2397
|
});
|
|
2390
2398
|
const pivot = {
|
|
@@ -2578,10 +2586,12 @@ var cellSchema = {
|
|
|
2578
2586
|
data: "",
|
|
2579
2587
|
fallback: true
|
|
2580
2588
|
} };
|
|
2589
|
+
const fontNames = Object.keys(font);
|
|
2590
|
+
const fallbackFontName = getFallbackFontName(font);
|
|
2581
2591
|
return getCellPropPanelSchema({
|
|
2582
2592
|
i18n,
|
|
2583
|
-
fontNames
|
|
2584
|
-
fallbackFontName
|
|
2593
|
+
fontNames,
|
|
2594
|
+
fallbackFontName
|
|
2585
2595
|
});
|
|
2586
2596
|
},
|
|
2587
2597
|
defaultSchema: {
|
|
@@ -2687,7 +2697,8 @@ var pdfRender = async (arg) => {
|
|
|
2687
2697
|
options,
|
|
2688
2698
|
_cache
|
|
2689
2699
|
};
|
|
2690
|
-
|
|
2700
|
+
const typedBody = Array.isArray(body) ? body.map((row) => Array.isArray(row) ? row.map((cell) => String(cell)) : []) : [];
|
|
2701
|
+
await drawTable(arg, await createSingleTable(typedBody, createTableArgs));
|
|
2691
2702
|
};
|
|
2692
2703
|
//#endregion
|
|
2693
2704
|
//#region src/tables/uiRender.ts
|
|
@@ -2938,8 +2949,7 @@ var uiRender = async (arg) => {
|
|
|
2938
2949
|
onClick: (e) => {
|
|
2939
2950
|
e.preventDefault();
|
|
2940
2951
|
const newColumnWidthPercentage = 25;
|
|
2941
|
-
const
|
|
2942
|
-
const scalingRatio = (100 - newColumnWidthPercentage) / totalCurrentWidth;
|
|
2952
|
+
const scalingRatio = 75 / schema.headWidthPercentages.reduce((acc, width) => acc + width, 0);
|
|
2943
2953
|
const scaledWidths = schema.headWidthPercentages.map((width) => width * scalingRatio);
|
|
2944
2954
|
onChange([
|
|
2945
2955
|
{
|
|
@@ -3023,7 +3033,8 @@ var uiRender = async (arg) => {
|
|
|
3023
3033
|
const startLeft = Number(handle.style.left.replace("mm", ""));
|
|
3024
3034
|
let move = 0;
|
|
3025
3035
|
const mouseMove = (e) => {
|
|
3026
|
-
|
|
3036
|
+
const moveX = (e.clientX - startClientX) / ZOOM / scale;
|
|
3037
|
+
let newLeft = startLeft + moveX;
|
|
3027
3038
|
if (newLeft < prevColumnLeft) newLeft = prevColumnLeft;
|
|
3028
3039
|
if (newLeft >= nextColumnRight) newLeft = nextColumnRight;
|
|
3029
3040
|
handle.style.left = `${newLeft}mm`;
|
|
@@ -3031,15 +3042,18 @@ var uiRender = async (arg) => {
|
|
|
3031
3042
|
};
|
|
3032
3043
|
rootElement.addEventListener("mousemove", mouseMove);
|
|
3033
3044
|
const commitResize = () => {
|
|
3034
|
-
if (move !== 0)
|
|
3035
|
-
|
|
3036
|
-
value: calcResizedHeadWidthPercentages({
|
|
3045
|
+
if (move !== 0) {
|
|
3046
|
+
const newHeadWidthPercentages = calcResizedHeadWidthPercentages({
|
|
3037
3047
|
currentHeadWidthPercentages: schema.headWidthPercentages,
|
|
3038
3048
|
currentHeadWidths: table.columns.map((column) => column.width),
|
|
3039
3049
|
changedHeadWidth: table.columns[i].width + move,
|
|
3040
3050
|
changedHeadIndex: i
|
|
3041
|
-
})
|
|
3042
|
-
|
|
3051
|
+
});
|
|
3052
|
+
onChange({
|
|
3053
|
+
key: "headWidthPercentages",
|
|
3054
|
+
value: newHeadWidthPercentages
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3043
3057
|
move = 0;
|
|
3044
3058
|
dragHandle.addEventListener("mouseover", setColor);
|
|
3045
3059
|
dragHandle.addEventListener("mouseout", resetColor);
|
|
@@ -5653,6 +5667,11 @@ var LOCALE_MAP = {
|
|
|
5653
5667
|
label: "Chinese",
|
|
5654
5668
|
adLocale: normalizeAdLocale(import_zh.default),
|
|
5655
5669
|
formatLocale: dateFns.zhCN
|
|
5670
|
+
},
|
|
5671
|
+
"zh-TW": {
|
|
5672
|
+
label: "Chinese (Traditional)",
|
|
5673
|
+
adLocale: normalizeAdLocale(import_zh.default),
|
|
5674
|
+
formatLocale: dateFns.zhTW
|
|
5656
5675
|
}
|
|
5657
5676
|
};
|
|
5658
5677
|
var getAirDatepickerLocale = (locale) => {
|
|
@@ -5713,14 +5732,13 @@ var getFmtValue = (value, type, schema, locale) => {
|
|
|
5713
5732
|
return value ? format(strDateToDate(value, type), formatString, { locale: locale.formatLocale }) : "";
|
|
5714
5733
|
};
|
|
5715
5734
|
var getFmtContent = (date, type) => {
|
|
5716
|
-
|
|
5735
|
+
return date ? format(date, (() => {
|
|
5717
5736
|
switch (type) {
|
|
5718
5737
|
case "date": return "yyyy/MM/dd";
|
|
5719
5738
|
case "time": return "HH:mm";
|
|
5720
5739
|
case "dateTime": return "yyyy/MM/dd HH:mm";
|
|
5721
5740
|
}
|
|
5722
|
-
})();
|
|
5723
|
-
return date ? format(date, fmt) : "";
|
|
5741
|
+
})()) : "";
|
|
5724
5742
|
};
|
|
5725
5743
|
var getPlugin = ({ type, icon }) => {
|
|
5726
5744
|
const defaultLocale = "en";
|
|
@@ -5779,7 +5797,8 @@ var getPlugin = ({ type, icon }) => {
|
|
|
5779
5797
|
content: i18n("set"),
|
|
5780
5798
|
onClick: (datepicker) => {
|
|
5781
5799
|
datepicker.hide();
|
|
5782
|
-
|
|
5800
|
+
const date = datepicker.selectedDates.length ? datepicker.selectedDates[0] : null;
|
|
5801
|
+
commitChange(date);
|
|
5783
5802
|
}
|
|
5784
5803
|
});
|
|
5785
5804
|
const airDatepicker = new AirDatepicker(input, {
|