@pdfme/schemas 6.1.11 → 6.1.12-dev.7
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/{builtins-Bs4Z7Q4K.js → builtins-BHOQnFbY.js} +27 -21
- package/dist/{builtins-Bs4Z7Q4K.js.map → builtins-BHOQnFbY.js.map} +1 -1
- package/dist/builtins.js +1 -1
- package/dist/dynamicLayout.js +4 -4
- package/dist/{dynamicTemplate-DILLiIp6.js → dynamicTemplate-BcCrm2SZ.js} +4 -4
- package/dist/{dynamicTemplate-DILLiIp6.js.map → dynamicTemplate-BcCrm2SZ.js.map} +1 -1
- package/dist/{dynamicTemplate-C9FSccAm.js → dynamicTemplate-BgH01dcs.js} +24 -23
- package/dist/{dynamicTemplate-C9FSccAm.js.map → dynamicTemplate-BgH01dcs.js.map} +1 -1
- 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-CbU88kUO.js → helper-VroN19Ci.js} +2 -2
- package/dist/{helper-CbU88kUO.js.map → helper-VroN19Ci.js.map} +1 -1
- package/dist/index.js +46 -33
- package/dist/index.js.map +1 -1
- package/dist/lists.js +2 -2
- package/dist/{measure-_MO-Voz3.js → measure-BC7tjAtT.js} +5 -4
- package/dist/{measure-_MO-Voz3.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/tables.js +2 -2
- package/dist/texts.js +3 -3
- package/dist/{utils-B8i6Nc_7.js → utils-nI6J7wZM.js} +8 -5
- package/dist/{utils-B8i6Nc_7.js.map → utils-nI6J7wZM.js.map} +1 -1
- package/dist/utils.js +2 -2
- package/package.json +5 -5
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-BHOQnFbY.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-BgH01dcs.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-nI6J7wZM.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));
|
|
@@ -51,11 +51,12 @@ var pdfRender$3 = async (arg) => {
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
if (!validateVariables(value, schema)) return;
|
|
54
|
-
|
|
54
|
+
const renderArgs = {
|
|
55
55
|
value: isInlineMarkdownTextSchema(schema) ? substituteVariablesAsInlineMarkdownLiterals(schema.text || "", value) : substituteVariables(schema.text || "", value),
|
|
56
56
|
schema,
|
|
57
57
|
...rest
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
|
+
await pdfRender$4(renderArgs);
|
|
59
60
|
};
|
|
60
61
|
//#endregion
|
|
61
62
|
//#region src/multiVariableText/propPanel.ts
|
|
@@ -257,7 +258,8 @@ var formUiRender = async (arg) => {
|
|
|
257
258
|
const substitutedText = substituteVariables(rawText, variables);
|
|
258
259
|
const inlineMarkdownRuns = isInlineMarkdownTextSchema(schema) ? parseInlineMarkdown(rawText) : void 0;
|
|
259
260
|
const font = options?.font || getDefaultFont();
|
|
260
|
-
const
|
|
261
|
+
const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
|
|
262
|
+
const textBlock = buildStyledTextContainer(arg, fontKitFont, inlineMarkdownRuns ? getInlineMarkdownFormDisplayText(inlineMarkdownRuns, variables) : substitutedText);
|
|
261
263
|
if (getTextLineRange(schema)) {
|
|
262
264
|
const { lines } = await measureTextLines({
|
|
263
265
|
value: inlineMarkdownRuns ? substituteVariablesAsInlineMarkdownLiterals(rawText, variables) : substitutedText,
|
|
@@ -1408,8 +1410,8 @@ var listSchema = {
|
|
|
1408
1410
|
var decoder = new TextDecoder();
|
|
1409
1411
|
var toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end));
|
|
1410
1412
|
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] *
|
|
1413
|
+
var readUInt16BE = (input, offset = 0) => input[offset] * 256 + input[offset + 1];
|
|
1414
|
+
var readUInt32BE = (input, offset = 0) => input[offset] * 2 ** 24 + input[offset + 1] * 2 ** 16 + input[offset + 2] * 256 + input[offset + 3];
|
|
1413
1415
|
var extractSize = (input, index) => {
|
|
1414
1416
|
return {
|
|
1415
1417
|
height: readUInt16BE(input, index),
|
|
@@ -1547,9 +1549,10 @@ var imageSchema = {
|
|
|
1547
1549
|
_schema.height = boxHeight;
|
|
1548
1550
|
_schema.position.x += (boxWidth - _schema.width) / 2;
|
|
1549
1551
|
}
|
|
1552
|
+
const pageHeight = page.getHeight();
|
|
1550
1553
|
const { width, height, rotate, position, opacity } = convertForPdfLayoutProps({
|
|
1551
1554
|
schema: _schema,
|
|
1552
|
-
pageHeight
|
|
1555
|
+
pageHeight
|
|
1553
1556
|
});
|
|
1554
1557
|
const { x, y } = position;
|
|
1555
1558
|
const drawOptions = {
|
|
@@ -1647,7 +1650,8 @@ var imageSchema = {
|
|
|
1647
1650
|
input.accept = "image/jpeg, image/png";
|
|
1648
1651
|
input.addEventListener("change", (event) => {
|
|
1649
1652
|
const target = event.target;
|
|
1650
|
-
|
|
1653
|
+
const files = target instanceof HTMLInputElement ? target.files : null;
|
|
1654
|
+
readFile(files).then((result) => {
|
|
1651
1655
|
if (onChange) onChange({
|
|
1652
1656
|
key: "content",
|
|
1653
1657
|
value: result
|
|
@@ -1919,9 +1923,10 @@ var svgSchema = {
|
|
|
1919
1923
|
pdf: async (arg) => {
|
|
1920
1924
|
const { page, schema, value } = arg;
|
|
1921
1925
|
if (!value || !isValidSVG(value)) return;
|
|
1926
|
+
const pageHeight = page.getHeight();
|
|
1922
1927
|
const { width, height, position } = convertForPdfLayoutProps({
|
|
1923
1928
|
schema,
|
|
1924
|
-
pageHeight
|
|
1929
|
+
pageHeight
|
|
1925
1930
|
});
|
|
1926
1931
|
const { x, y } = position;
|
|
1927
1932
|
await page.drawSvg(value, {
|
|
@@ -2061,9 +2066,10 @@ var pdfRender$1 = async (arg) => {
|
|
|
2061
2066
|
image = await pdfDoc.embedPng(imageBuf);
|
|
2062
2067
|
_cache.set(inputBarcodeCacheKey, image);
|
|
2063
2068
|
}
|
|
2069
|
+
const pageHeight = page.getHeight();
|
|
2064
2070
|
const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
|
|
2065
2071
|
schema,
|
|
2066
|
-
pageHeight
|
|
2072
|
+
pageHeight
|
|
2067
2073
|
});
|
|
2068
2074
|
page.drawImage(image, {
|
|
2069
2075
|
x,
|
|
@@ -2382,9 +2388,10 @@ var lineSchema = {
|
|
|
2382
2388
|
const { page, schema, options } = arg;
|
|
2383
2389
|
if (schema.width === 0 || schema.height === 0 || !schema.color) return;
|
|
2384
2390
|
const { colorType } = options;
|
|
2391
|
+
const pageHeight = page.getHeight();
|
|
2385
2392
|
const { width, height, rotate, position: { x, y }, opacity } = convertForPdfLayoutProps({
|
|
2386
2393
|
schema,
|
|
2387
|
-
pageHeight
|
|
2394
|
+
pageHeight,
|
|
2388
2395
|
applyRotateTranslate: false
|
|
2389
2396
|
});
|
|
2390
2397
|
const pivot = {
|
|
@@ -2578,10 +2585,12 @@ var cellSchema = {
|
|
|
2578
2585
|
data: "",
|
|
2579
2586
|
fallback: true
|
|
2580
2587
|
} };
|
|
2588
|
+
const fontNames = Object.keys(font);
|
|
2589
|
+
const fallbackFontName = getFallbackFontName(font);
|
|
2581
2590
|
return getCellPropPanelSchema({
|
|
2582
2591
|
i18n,
|
|
2583
|
-
fontNames
|
|
2584
|
-
fallbackFontName
|
|
2592
|
+
fontNames,
|
|
2593
|
+
fallbackFontName
|
|
2585
2594
|
});
|
|
2586
2595
|
},
|
|
2587
2596
|
defaultSchema: {
|
|
@@ -2687,7 +2696,8 @@ var pdfRender = async (arg) => {
|
|
|
2687
2696
|
options,
|
|
2688
2697
|
_cache
|
|
2689
2698
|
};
|
|
2690
|
-
|
|
2699
|
+
const typedBody = Array.isArray(body) ? body.map((row) => Array.isArray(row) ? row.map((cell) => String(cell)) : []) : [];
|
|
2700
|
+
await drawTable(arg, await createSingleTable(typedBody, createTableArgs));
|
|
2691
2701
|
};
|
|
2692
2702
|
//#endregion
|
|
2693
2703
|
//#region src/tables/uiRender.ts
|
|
@@ -2938,8 +2948,7 @@ var uiRender = async (arg) => {
|
|
|
2938
2948
|
onClick: (e) => {
|
|
2939
2949
|
e.preventDefault();
|
|
2940
2950
|
const newColumnWidthPercentage = 25;
|
|
2941
|
-
const
|
|
2942
|
-
const scalingRatio = (100 - newColumnWidthPercentage) / totalCurrentWidth;
|
|
2951
|
+
const scalingRatio = 75 / schema.headWidthPercentages.reduce((acc, width) => acc + width, 0);
|
|
2943
2952
|
const scaledWidths = schema.headWidthPercentages.map((width) => width * scalingRatio);
|
|
2944
2953
|
onChange([
|
|
2945
2954
|
{
|
|
@@ -3023,7 +3032,8 @@ var uiRender = async (arg) => {
|
|
|
3023
3032
|
const startLeft = Number(handle.style.left.replace("mm", ""));
|
|
3024
3033
|
let move = 0;
|
|
3025
3034
|
const mouseMove = (e) => {
|
|
3026
|
-
|
|
3035
|
+
const moveX = (e.clientX - startClientX) / ZOOM / scale;
|
|
3036
|
+
let newLeft = startLeft + moveX;
|
|
3027
3037
|
if (newLeft < prevColumnLeft) newLeft = prevColumnLeft;
|
|
3028
3038
|
if (newLeft >= nextColumnRight) newLeft = nextColumnRight;
|
|
3029
3039
|
handle.style.left = `${newLeft}mm`;
|
|
@@ -3031,15 +3041,18 @@ var uiRender = async (arg) => {
|
|
|
3031
3041
|
};
|
|
3032
3042
|
rootElement.addEventListener("mousemove", mouseMove);
|
|
3033
3043
|
const commitResize = () => {
|
|
3034
|
-
if (move !== 0)
|
|
3035
|
-
|
|
3036
|
-
value: calcResizedHeadWidthPercentages({
|
|
3044
|
+
if (move !== 0) {
|
|
3045
|
+
const newHeadWidthPercentages = calcResizedHeadWidthPercentages({
|
|
3037
3046
|
currentHeadWidthPercentages: schema.headWidthPercentages,
|
|
3038
3047
|
currentHeadWidths: table.columns.map((column) => column.width),
|
|
3039
3048
|
changedHeadWidth: table.columns[i].width + move,
|
|
3040
3049
|
changedHeadIndex: i
|
|
3041
|
-
})
|
|
3042
|
-
|
|
3050
|
+
});
|
|
3051
|
+
onChange({
|
|
3052
|
+
key: "headWidthPercentages",
|
|
3053
|
+
value: newHeadWidthPercentages
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3043
3056
|
move = 0;
|
|
3044
3057
|
dragHandle.addEventListener("mouseover", setColor);
|
|
3045
3058
|
dragHandle.addEventListener("mouseout", resetColor);
|
|
@@ -5713,14 +5726,13 @@ var getFmtValue = (value, type, schema, locale) => {
|
|
|
5713
5726
|
return value ? format(strDateToDate(value, type), formatString, { locale: locale.formatLocale }) : "";
|
|
5714
5727
|
};
|
|
5715
5728
|
var getFmtContent = (date, type) => {
|
|
5716
|
-
|
|
5729
|
+
return date ? format(date, (() => {
|
|
5717
5730
|
switch (type) {
|
|
5718
5731
|
case "date": return "yyyy/MM/dd";
|
|
5719
5732
|
case "time": return "HH:mm";
|
|
5720
5733
|
case "dateTime": return "yyyy/MM/dd HH:mm";
|
|
5721
5734
|
}
|
|
5722
|
-
})();
|
|
5723
|
-
return date ? format(date, fmt) : "";
|
|
5735
|
+
})()) : "";
|
|
5724
5736
|
};
|
|
5725
5737
|
var getPlugin = ({ type, icon }) => {
|
|
5726
5738
|
const defaultLocale = "en";
|
|
@@ -5779,7 +5791,8 @@ var getPlugin = ({ type, icon }) => {
|
|
|
5779
5791
|
content: i18n("set"),
|
|
5780
5792
|
onClick: (datepicker) => {
|
|
5781
5793
|
datepicker.hide();
|
|
5782
|
-
|
|
5794
|
+
const date = datepicker.selectedDates.length ? datepicker.selectedDates[0] : null;
|
|
5795
|
+
commitChange(date);
|
|
5783
5796
|
}
|
|
5784
5797
|
});
|
|
5785
5798
|
const airDatepicker = new AirDatepicker(input, {
|