@pdfme/schemas 6.1.1-dev.16 → 6.1.1-dev.17
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-IF8ozb_E.js → builtins-BNd4jd5D.js} +2 -2
- package/dist/{builtins-IF8ozb_E.js.map → builtins-BNd4jd5D.js.map} +1 -1
- package/dist/builtins.js +1 -1
- package/dist/dynamicLayout.js +2 -2
- package/dist/{dynamicTemplate-Fn7mpUsu.js → dynamicTemplate-BpD4RNw8.js} +1 -1
- package/dist/{dynamicTemplate-Fn7mpUsu.js.map → dynamicTemplate-BpD4RNw8.js.map} +1 -1
- package/dist/{dynamicTemplate-CB2Hj9cN.js → dynamicTemplate-CBvwRBx9.js} +2 -2
- package/dist/{dynamicTemplate-CB2Hj9cN.js.map → dynamicTemplate-CBvwRBx9.js.map} +1 -1
- package/dist/{helper-BJzBqIT4.js → helper-BFz9EwDz.js} +1 -1
- package/dist/{helper-BJzBqIT4.js.map → helper-BFz9EwDz.js.map} +1 -1
- package/dist/index.js +4 -39
- package/dist/index.js.map +1 -1
- package/dist/lists.js +1 -1
- package/dist/texts.js +1 -1
- package/dist/utils-Bd4CvhPZ.js +250 -0
- package/dist/utils-Bd4CvhPZ.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +3 -216
- package/package.json +1 -1
- package/dist/utils.js.map +0 -1
package/dist/lists.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as createListItemSplitRange, c as getListItemRange, n as LIST_ITEM_SPLIT_UNIT } from "./splitRange-CpXivbmJ.js";
|
|
2
|
-
import { a as normalizeListItems, i as normalizeListItemEntries, n as calculateListLayout, o as serializeListItems, r as getListMarkers, t as getDynamicLayoutForList } from "./dynamicTemplate-
|
|
2
|
+
import { a as normalizeListItems, i as normalizeListItemEntries, n as calculateListLayout, o as serializeListItems, r as getListMarkers, t as getDynamicLayoutForList } from "./dynamicTemplate-BpD4RNw8.js";
|
|
3
3
|
export { LIST_ITEM_SPLIT_UNIT, calculateListLayout, createListItemSplitRange, getDynamicLayoutForList, getListItemRange, getListMarkers, normalizeListItemEntries, normalizeListItems, serializeListItems };
|
package/dist/texts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { U as TEXT_OVERFLOW_EXPAND, W as TEXT_OVERFLOW_VISIBLE, i as TEXT_LINE_SPLIT_UNIT, s as createTextLineSplitRange, u as getTextLineRange } from "./splitRange-CpXivbmJ.js";
|
|
2
2
|
import { i as mergeTextLineRangeValue } from "./measure-Bjmh9Ro3.js";
|
|
3
|
-
import { n as getDynamicLayoutForMultiVariableText, t as getDynamicLayoutForText } from "./dynamicTemplate-
|
|
3
|
+
import { n as getDynamicLayoutForMultiVariableText, t as getDynamicLayoutForText } from "./dynamicTemplate-CBvwRBx9.js";
|
|
4
4
|
export { TEXT_LINE_SPLIT_UNIT, TEXT_OVERFLOW_EXPAND, TEXT_OVERFLOW_VISIBLE, createTextLineSplitRange, getDynamicLayoutForMultiVariableText, getDynamicLayoutForText, getTextLineRange, mergeTextLineRangeValue };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { t as getDynamicHeightsForTable$1 } from "./dynamicTemplate-CjbGepw4.js";
|
|
2
|
+
import { isHexValid, mm2pt } from "@pdfme/common";
|
|
3
|
+
import { cmyk, degrees, degreesToRadians, rgb } from "@pdfme/pdf-lib";
|
|
4
|
+
//#region src/multiVariableText/variables.ts
|
|
5
|
+
var visitVariables = (content, visitor) => {
|
|
6
|
+
let startIndex = -1;
|
|
7
|
+
for (let i = 0; i < content.length; i++) {
|
|
8
|
+
const char = content[i];
|
|
9
|
+
if (char === "{") {
|
|
10
|
+
startIndex = i;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (char === "}" && startIndex !== -1) {
|
|
14
|
+
const name = content.slice(startIndex + 1, i);
|
|
15
|
+
if (name.length > 0) visitor({
|
|
16
|
+
name,
|
|
17
|
+
startIndex,
|
|
18
|
+
endIndex: i
|
|
19
|
+
});
|
|
20
|
+
startIndex = -1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var countUniqueVariableNames = (content) => {
|
|
25
|
+
const variableNames = /* @__PURE__ */ new Set();
|
|
26
|
+
visitVariables(content, ({ name }) => {
|
|
27
|
+
variableNames.add(name);
|
|
28
|
+
});
|
|
29
|
+
return variableNames.size;
|
|
30
|
+
};
|
|
31
|
+
var getVariableNames = (content) => {
|
|
32
|
+
const variableNames = [];
|
|
33
|
+
visitVariables(content, ({ name }) => {
|
|
34
|
+
variableNames.push(name);
|
|
35
|
+
});
|
|
36
|
+
return variableNames;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/utils.ts
|
|
40
|
+
var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
|
|
41
|
+
const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
|
|
42
|
+
const { x: mmX, y: mmY } = position;
|
|
43
|
+
const rotateDegrees = rotate ? -rotate : 0;
|
|
44
|
+
const width = mm2pt(mmWidth);
|
|
45
|
+
const height = mm2pt(mmHeight);
|
|
46
|
+
let x = mm2pt(mmX);
|
|
47
|
+
let y = pageHeight - mm2pt(mmY) - height;
|
|
48
|
+
if (rotateDegrees && applyRotateTranslate) {
|
|
49
|
+
const pivotPoint = {
|
|
50
|
+
x: x + width / 2,
|
|
51
|
+
y: pageHeight - mm2pt(mmY) - height / 2
|
|
52
|
+
};
|
|
53
|
+
const rotatedPoint = rotatePoint({
|
|
54
|
+
x,
|
|
55
|
+
y
|
|
56
|
+
}, pivotPoint, rotateDegrees);
|
|
57
|
+
x = rotatedPoint.x;
|
|
58
|
+
y = rotatedPoint.y;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
position: {
|
|
62
|
+
x,
|
|
63
|
+
y
|
|
64
|
+
},
|
|
65
|
+
height,
|
|
66
|
+
width,
|
|
67
|
+
rotate: degrees(rotateDegrees),
|
|
68
|
+
opacity
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
var rotatePoint = (point, pivot, angleDegrees) => {
|
|
72
|
+
const angleRadians = degreesToRadians(angleDegrees);
|
|
73
|
+
return {
|
|
74
|
+
x: Math.cos(angleRadians) * (point.x - pivot.x) - Math.sin(angleRadians) * (point.y - pivot.y) + pivot.x,
|
|
75
|
+
y: Math.sin(angleRadians) * (point.x - pivot.x) + Math.cos(angleRadians) * (point.y - pivot.y) + pivot.y
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var getDynamicHeightsForTable = getDynamicHeightsForTable$1;
|
|
79
|
+
var addAlphaToHex = (hex, alphaPercentage) => {
|
|
80
|
+
if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(hex)) throw new Error("Invalid HEX color code");
|
|
81
|
+
let alphaHex = Math.round(alphaPercentage / 100 * 255).toString(16);
|
|
82
|
+
if (alphaHex.length === 1) alphaHex = "0" + alphaHex;
|
|
83
|
+
return hex + alphaHex;
|
|
84
|
+
};
|
|
85
|
+
var isEditable = (mode, schema) => mode === "designer" || mode === "form" && schema.readOnly !== true;
|
|
86
|
+
var hex2rgb = (hex) => {
|
|
87
|
+
if (hex.slice(0, 1) === "#") hex = hex.slice(1);
|
|
88
|
+
if (hex.length === 3) hex = hex.slice(0, 1) + hex.slice(0, 1) + hex.slice(1, 2) + hex.slice(1, 2) + hex.slice(2, 3) + hex.slice(2, 3);
|
|
89
|
+
return [
|
|
90
|
+
hex.slice(0, 2),
|
|
91
|
+
hex.slice(2, 4),
|
|
92
|
+
hex.slice(4, 6)
|
|
93
|
+
].map((str) => parseInt(str, 16));
|
|
94
|
+
};
|
|
95
|
+
var hex2RgbColor = (hexString) => {
|
|
96
|
+
if (hexString) {
|
|
97
|
+
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
98
|
+
const [r, g, b] = hex2rgb(hexString);
|
|
99
|
+
return rgb(r / 255, g / 255, b / 255);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var hex2CmykColor = (hexString) => {
|
|
103
|
+
if (hexString) {
|
|
104
|
+
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
105
|
+
hexString = hexString.replace("#", "");
|
|
106
|
+
const hexColor = hexString.substring(0, 6);
|
|
107
|
+
const opacityColor = hexString.substring(6, 8);
|
|
108
|
+
const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;
|
|
109
|
+
let r = parseInt(hexColor.substring(0, 2), 16) / 255;
|
|
110
|
+
let g = parseInt(hexColor.substring(2, 4), 16) / 255;
|
|
111
|
+
let b = parseInt(hexColor.substring(4, 6), 16) / 255;
|
|
112
|
+
r = r * opacity + (1 - opacity);
|
|
113
|
+
g = g * opacity + (1 - opacity);
|
|
114
|
+
b = b * opacity + (1 - opacity);
|
|
115
|
+
const k = 1 - Math.max(r, g, b);
|
|
116
|
+
return cmyk(k === 1 ? 0 : (1 - r - k) / (1 - k), k === 1 ? 0 : (1 - g - k) / (1 - k), k === 1 ? 0 : (1 - b - k) / (1 - k), k);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var hex2PrintingColor = (color, colorType) => {
|
|
120
|
+
if (typeof color === "object") return color;
|
|
121
|
+
return colorType?.toLowerCase() == "cmyk" ? hex2CmykColor(color) : hex2RgbColor(color);
|
|
122
|
+
};
|
|
123
|
+
var readFile = (input) => new Promise((resolve, reject) => {
|
|
124
|
+
const fileReader = new FileReader();
|
|
125
|
+
fileReader.onload = (e) => {
|
|
126
|
+
if (e.target?.result) resolve(e.target.result);
|
|
127
|
+
};
|
|
128
|
+
fileReader.onerror = () => {
|
|
129
|
+
reject(/* @__PURE__ */ new Error("[@pdfme/schemas] File reading failed"));
|
|
130
|
+
};
|
|
131
|
+
let file = null;
|
|
132
|
+
if (input instanceof FileList && input.length > 0) file = input[0];
|
|
133
|
+
else if (input instanceof File) file = input;
|
|
134
|
+
if (file) fileReader.readAsDataURL(file);
|
|
135
|
+
else reject(/* @__PURE__ */ new Error("[@pdfme/schemas] No files provided"));
|
|
136
|
+
});
|
|
137
|
+
var createErrorElm = () => {
|
|
138
|
+
const container = document.createElement("div");
|
|
139
|
+
Object.assign(container.style, {
|
|
140
|
+
display: "flex",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
justifyContent: "center",
|
|
143
|
+
width: "100%",
|
|
144
|
+
height: "100%"
|
|
145
|
+
});
|
|
146
|
+
const span = document.createElement("span");
|
|
147
|
+
Object.assign(span.style, {
|
|
148
|
+
color: "white",
|
|
149
|
+
background: "red",
|
|
150
|
+
padding: "0.25rem",
|
|
151
|
+
fontSize: "12pt",
|
|
152
|
+
fontWeight: "bold",
|
|
153
|
+
borderRadius: "2px",
|
|
154
|
+
fontFamily: "'Open Sans', sans-serif"
|
|
155
|
+
});
|
|
156
|
+
span.textContent = "ERROR";
|
|
157
|
+
container.appendChild(span);
|
|
158
|
+
return container;
|
|
159
|
+
};
|
|
160
|
+
var createSvgStr = (icon, attrs) => {
|
|
161
|
+
const safeTagNames = new Set([
|
|
162
|
+
"svg",
|
|
163
|
+
"circle",
|
|
164
|
+
"ellipse",
|
|
165
|
+
"g",
|
|
166
|
+
"line",
|
|
167
|
+
"path",
|
|
168
|
+
"polygon",
|
|
169
|
+
"polyline",
|
|
170
|
+
"rect"
|
|
171
|
+
]);
|
|
172
|
+
const safeAttributeNames = new Set([
|
|
173
|
+
"aria-hidden",
|
|
174
|
+
"aria-label",
|
|
175
|
+
"class",
|
|
176
|
+
"clip-rule",
|
|
177
|
+
"cx",
|
|
178
|
+
"cy",
|
|
179
|
+
"d",
|
|
180
|
+
"fill",
|
|
181
|
+
"fill-opacity",
|
|
182
|
+
"fill-rule",
|
|
183
|
+
"focusable",
|
|
184
|
+
"height",
|
|
185
|
+
"id",
|
|
186
|
+
"opacity",
|
|
187
|
+
"points",
|
|
188
|
+
"preserveAspectRatio",
|
|
189
|
+
"r",
|
|
190
|
+
"role",
|
|
191
|
+
"rx",
|
|
192
|
+
"ry",
|
|
193
|
+
"stroke",
|
|
194
|
+
"stroke-dasharray",
|
|
195
|
+
"stroke-dashoffset",
|
|
196
|
+
"stroke-linecap",
|
|
197
|
+
"stroke-linejoin",
|
|
198
|
+
"stroke-miterlimit",
|
|
199
|
+
"stroke-opacity",
|
|
200
|
+
"stroke-width",
|
|
201
|
+
"transform",
|
|
202
|
+
"vector-effect",
|
|
203
|
+
"viewBox",
|
|
204
|
+
"width",
|
|
205
|
+
"x",
|
|
206
|
+
"x1",
|
|
207
|
+
"x2",
|
|
208
|
+
"xmlns",
|
|
209
|
+
"xmlns:xlink",
|
|
210
|
+
"y",
|
|
211
|
+
"y1",
|
|
212
|
+
"y2"
|
|
213
|
+
]);
|
|
214
|
+
const escapeHtmlAttribute = (value) => value.replaceAll("&", "&").replaceAll("\"", """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">");
|
|
215
|
+
const escapeHtmlText = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
216
|
+
const toSafeAttributeString = (attributes) => Object.entries(attributes).filter(([key, value]) => safeAttributeNames.has(key) && value !== void 0 && value !== null && !key.toLowerCase().startsWith("on")).map(([key, value]) => `${key}="${escapeHtmlAttribute(String(value))}"`).join(" ");
|
|
217
|
+
const toSafeTagName = (tag) => {
|
|
218
|
+
const tagName = String(tag);
|
|
219
|
+
if (!safeTagNames.has(tagName)) throw new Error(`Invalid SVG tag name: ${tagName}`);
|
|
220
|
+
return tagName;
|
|
221
|
+
};
|
|
222
|
+
if (!Array.isArray(icon)) return escapeHtmlText(String(icon));
|
|
223
|
+
const svgAttrString = toSafeAttributeString({
|
|
224
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
225
|
+
width: "24",
|
|
226
|
+
height: "24",
|
|
227
|
+
viewBox: "0 0 24 24",
|
|
228
|
+
fill: "none",
|
|
229
|
+
stroke: "currentColor",
|
|
230
|
+
"stroke-width": "2",
|
|
231
|
+
"stroke-linecap": "round",
|
|
232
|
+
"stroke-linejoin": "round",
|
|
233
|
+
...attrs
|
|
234
|
+
});
|
|
235
|
+
const processElement = (element) => {
|
|
236
|
+
if (!Array.isArray(element)) return escapeHtmlText(String(element));
|
|
237
|
+
const [tag, attributes = {}, children = []] = element;
|
|
238
|
+
const tagName = toSafeTagName(tag);
|
|
239
|
+
const attrString = toSafeAttributeString(attributes);
|
|
240
|
+
let childrenString = "";
|
|
241
|
+
if (Array.isArray(children) && children.length > 0) childrenString = children.map((child) => processElement(child)).join("");
|
|
242
|
+
if (childrenString) return `<${String(tagName)}${attrString ? " " + String(attrString) : ""}>${childrenString}</${String(tagName)}>`;
|
|
243
|
+
else return `<${String(tagName)}${attrString ? " " + String(attrString) : ""}/>`;
|
|
244
|
+
};
|
|
245
|
+
return `<svg ${svgAttrString}>${Array.isArray(icon) ? icon.map((element) => processElement(element)).join("") : processElement(icon)}</svg>`;
|
|
246
|
+
};
|
|
247
|
+
//#endregion
|
|
248
|
+
export { getDynamicHeightsForTable as a, isEditable as c, countUniqueVariableNames as d, getVariableNames as f, createSvgStr as i, readFile as l, convertForPdfLayoutProps as n, hex2PrintingColor as o, visitVariables as p, createErrorElm as r, hex2RgbColor as s, addAlphaToHex as t, rotatePoint as u };
|
|
249
|
+
|
|
250
|
+
//# sourceMappingURL=utils-Bd4CvhPZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-Bd4CvhPZ.js","names":[],"sources":["../src/multiVariableText/variables.ts","../src/utils.ts"],"sourcesContent":["export type VariableMatch = {\n name: string;\n startIndex: number;\n endIndex: number;\n};\n\nexport type VariableIndices = Map<number, string>;\n\nexport const visitVariables = (content: string, visitor: (match: VariableMatch) => void): void => {\n let startIndex = -1;\n\n for (let i = 0; i < content.length; i++) {\n const char = content[i];\n\n if (char === '{') {\n // Restart from the latest opener so malformed input behaves like /{([^{}]+)}/g\n // without requiring backtracking.\n startIndex = i;\n continue;\n }\n\n if (char === '}' && startIndex !== -1) {\n const name = content.slice(startIndex + 1, i);\n if (name.length > 0) {\n visitor({ name, startIndex, endIndex: i });\n }\n startIndex = -1;\n }\n }\n};\n\nexport const getVariableIndices = (content: string): VariableIndices => {\n const indices: VariableIndices = new Map();\n\n visitVariables(content, ({ name, startIndex }) => {\n indices.set(startIndex, name);\n });\n\n return indices;\n};\n\nexport const countUniqueVariableNames = (content: string): number => {\n const variableNames = new Set<string>();\n\n visitVariables(content, ({ name }) => {\n variableNames.add(name);\n });\n\n return variableNames.size;\n};\n\nexport const getVariableNames = (content: string): string[] => {\n const variableNames: string[] = [];\n\n visitVariables(content, ({ name }) => {\n variableNames.push(name);\n });\n\n return variableNames;\n};\n","import type * as CSS from 'csstype';\nimport { cmyk, degrees, degreesToRadians, rgb, Color } from '@pdfme/pdf-lib';\nimport { Schema, mm2pt, Mode, isHexValid, ColorType } from '@pdfme/common';\nimport { IconNode } from 'lucide';\nimport { getDynamicHeightsForTable as _getDynamicHeightsForTable } from './tables/dynamicTemplate.js';\nexport { measureTextHeight } from './text/measure.js';\nexport { escapeInlineMarkdown } from './text/inlineMarkdown.js';\nexport { getVariableNames, visitVariables } from './multiVariableText/variables.js';\nexport const convertForPdfLayoutProps = ({\n schema,\n pageHeight,\n applyRotateTranslate = true,\n}: {\n schema: Schema;\n pageHeight: number;\n applyRotateTranslate?: boolean;\n}) => {\n const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;\n const { x: mmX, y: mmY } = position;\n\n const rotateDegrees = rotate ? -rotate : 0;\n const width = mm2pt(mmWidth);\n const height = mm2pt(mmHeight);\n let x = mm2pt(mmX);\n // PDF coordinate system is from bottom left, UI is top left, so we need to flip the y axis\n let y = pageHeight - mm2pt(mmY) - height;\n\n if (rotateDegrees && applyRotateTranslate) {\n // If rotating we must pivot around the same point as the UI performs its rotation.\n // The UI performs rotation around the objects center point (the pivot point below),\n // pdflib rotates around the bottom left corner of the object.\n // We must therefore adjust the X and Y by rotating the bottom left corner by this pivot point.\n const pivotPoint = { x: x + width / 2, y: pageHeight - mm2pt(mmY) - height / 2 };\n const rotatedPoint = rotatePoint({ x, y }, pivotPoint, rotateDegrees);\n x = rotatedPoint.x;\n y = rotatedPoint.y;\n }\n\n return {\n position: { x, y },\n height: height,\n width: width,\n rotate: degrees(rotateDegrees),\n opacity,\n };\n};\n\nexport const rotatePoint = (\n point: { x: number; y: number },\n pivot: { x: number; y: number },\n angleDegrees: number,\n): { x: number; y: number } => {\n const angleRadians = degreesToRadians(angleDegrees);\n\n const x =\n Math.cos(angleRadians) * (point.x - pivot.x) -\n Math.sin(angleRadians) * (point.y - pivot.y) +\n pivot.x;\n const y =\n Math.sin(angleRadians) * (point.x - pivot.x) +\n Math.cos(angleRadians) * (point.y - pivot.y) +\n pivot.y;\n\n return { x, y };\n};\n\nexport const getDynamicHeightsForTable = _getDynamicHeightsForTable;\n\n// ----------------------------------------\n\nexport const addAlphaToHex = (hex: string, alphaPercentage: number) => {\n if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(hex)) {\n throw new Error('Invalid HEX color code');\n }\n const alphaValue = Math.round((alphaPercentage / 100) * 255);\n let alphaHex = alphaValue.toString(16);\n if (alphaHex.length === 1) alphaHex = '0' + alphaHex;\n return hex + alphaHex;\n};\n\nexport const isEditable = (mode: Mode, schema: Schema) =>\n mode === 'designer' || (mode === 'form' && schema.readOnly !== true);\n\nconst hex2rgb = (hex: string) => {\n if (hex.slice(0, 1) === '#') hex = hex.slice(1);\n if (hex.length === 3)\n hex =\n hex.slice(0, 1) +\n hex.slice(0, 1) +\n hex.slice(1, 2) +\n hex.slice(1, 2) +\n hex.slice(2, 3) +\n hex.slice(2, 3);\n\n return [hex.slice(0, 2), hex.slice(2, 4), hex.slice(4, 6)].map((str) => parseInt(str, 16));\n};\n\nexport const hex2RgbColor = (hexString: string | undefined) => {\n if (hexString) {\n const isValid = isHexValid(hexString);\n\n if (!isValid) {\n throw new Error(`Invalid hex color value ${hexString}`);\n }\n\n const [r, g, b] = hex2rgb(hexString);\n\n return rgb(r / 255, g / 255, b / 255);\n }\n\n return undefined;\n};\n\nconst hex2CmykColor = (hexString: string | undefined) => {\n if (hexString) {\n const isValid = isHexValid(hexString);\n\n if (!isValid) {\n throw new Error(`Invalid hex color value ${hexString}`);\n }\n\n // Remove the # if it's present\n hexString = hexString.replace('#', '');\n\n // Extract the hexadecimal color code and the opacity\n const hexColor = hexString.substring(0, 6);\n const opacityColor = hexString.substring(6, 8);\n const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;\n\n // Convert the hex values to decimal\n let r = parseInt(hexColor.substring(0, 2), 16) / 255;\n let g = parseInt(hexColor.substring(2, 4), 16) / 255;\n let b = parseInt(hexColor.substring(4, 6), 16) / 255;\n\n // Apply the opacity\n r = r * opacity + (1 - opacity);\n g = g * opacity + (1 - opacity);\n b = b * opacity + (1 - opacity);\n\n // Calculate the CMYK values\n const k = 1 - Math.max(r, g, b);\n const c = k === 1 ? 0 : (1 - r - k) / (1 - k);\n const m = k === 1 ? 0 : (1 - g - k) / (1 - k);\n const y = k === 1 ? 0 : (1 - b - k) / (1 - k);\n\n return cmyk(c, m, y, k);\n }\n\n return undefined;\n};\n\nexport const hex2PrintingColor = (color?: string | Color, colorType?: ColorType) => {\n // if color is already CMYK, RGB or Grayscale, does not required to convert\n if (typeof color === 'object') return color;\n return colorType?.toLowerCase() == 'cmyk' ? hex2CmykColor(color) : hex2RgbColor(color);\n};\n\nexport const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n\n fileReader.onload = (e) => {\n if (e.target?.result) {\n resolve(e.target.result);\n }\n };\n\n fileReader.onerror = () => {\n reject(new Error('[@pdfme/schemas] File reading failed'));\n };\n\n let file: File | null = null;\n if (input instanceof FileList && input.length > 0) {\n file = input[0];\n } else if (input instanceof File) {\n file = input;\n }\n\n if (file) {\n fileReader.readAsDataURL(file);\n } else {\n reject(new Error('[@pdfme/schemas] No files provided'));\n }\n });\n\nexport const createErrorElm = () => {\n const container = document.createElement('div');\n const containerStyle: CSS.Properties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: '100%',\n };\n Object.assign(container.style, containerStyle);\n\n const span = document.createElement('span');\n const spanStyle: CSS.Properties = {\n color: 'white',\n background: 'red',\n padding: '0.25rem',\n fontSize: '12pt',\n fontWeight: 'bold',\n borderRadius: '2px',\n fontFamily: \"'Open Sans', sans-serif\",\n };\n Object.assign(span.style, spanStyle);\n\n span.textContent = 'ERROR';\n container.appendChild(span);\n\n return container;\n};\n\nexport const createSvgStr = (icon: IconNode, attrs?: Record<string, string>): string => {\n // In lucide 0.475.0, the icon is an array of elements, not a single SVG element\n // We need to create an SVG wrapper and add the elements as children\n\n const safeTagNames = new Set([\n 'svg',\n 'circle',\n 'ellipse',\n 'g',\n 'line',\n 'path',\n 'polygon',\n 'polyline',\n 'rect',\n ]);\n const safeAttributeNames = new Set([\n 'aria-hidden',\n 'aria-label',\n 'class',\n 'clip-rule',\n 'cx',\n 'cy',\n 'd',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'focusable',\n 'height',\n 'id',\n 'opacity',\n 'points',\n 'preserveAspectRatio',\n 'r',\n 'role',\n 'rx',\n 'ry',\n 'stroke',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'transform',\n 'vector-effect',\n 'viewBox',\n 'width',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'xmlns:xlink',\n 'y',\n 'y1',\n 'y2',\n ]);\n const escapeHtmlAttribute = (value: string): string =>\n value\n .replaceAll('&', '&')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''')\n .replaceAll('<', '<')\n .replaceAll('>', '>');\n const escapeHtmlText = (value: string): string =>\n value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');\n const toSafeAttributeString = (attributes: Record<string, string>): string =>\n Object.entries(attributes)\n .filter(\n ([key, value]) =>\n safeAttributeNames.has(key) &&\n value !== undefined &&\n value !== null &&\n !key.toLowerCase().startsWith('on'),\n )\n .map(([key, value]) => `${key}=\"${escapeHtmlAttribute(String(value))}\"`)\n .join(' ');\n const toSafeTagName = (tag: unknown): string => {\n const tagName = String(tag);\n if (!safeTagNames.has(tagName)) {\n throw new Error(`Invalid SVG tag name: ${tagName}`);\n }\n return tagName;\n };\n\n // Handle non-array input\n if (!Array.isArray(icon)) {\n return escapeHtmlText(String(icon));\n }\n\n // Create default SVG attributes\n const svgAttrs = {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '24',\n height: '24',\n viewBox: '0 0 24 24',\n fill: 'none',\n stroke: 'currentColor',\n 'stroke-width': '2',\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round',\n ...attrs,\n };\n const svgAttrString = toSafeAttributeString(svgAttrs);\n\n // Helper function to process a single element\n const processElement = (element: unknown): string => {\n if (!Array.isArray(element)) {\n return escapeHtmlText(String(element));\n }\n\n const [tag, attributes = {}, children = []] = element as [\n unknown,\n Record<string, string>,\n unknown[],\n ];\n const tagName = toSafeTagName(tag);\n const attrString = toSafeAttributeString(attributes);\n\n // Process children recursively\n let childrenString = '';\n\n if (Array.isArray(children) && children.length > 0) {\n childrenString = children.map((child) => processElement(child)).join('');\n }\n\n // Return properly formatted element string\n if (childrenString) {\n return `<${String(tagName)}${attrString ? ' ' + String(attrString) : ''}>${childrenString}</${String(tagName)}>`;\n } else {\n // Self-closing tag for empty children\n return `<${String(tagName)}${attrString ? ' ' + String(attrString) : ''}/>`;\n }\n };\n\n // Process all elements and join them\n const elementsString = Array.isArray(icon)\n ? icon.map((element) => processElement(element)).join('')\n : processElement(icon);\n\n // Return the complete SVG string\n return `<svg ${svgAttrString}>${elementsString}</svg>`;\n};\n"],"mappings":";;;;AAQA,IAAa,kBAAkB,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,OAAO,WAAW,GAAG,GAAG;;AAU5E,QAAO,QAAQ,cAAc,GALN,MAAM,QAAQ,KAAK,GACtC,KAAK,KAAK,YAAY,eAAe,QAAQ,CAAC,CAAC,KAAK,GAAG,GACvD,eAAe,KAAK,CAGuB"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Color } from '@pdfme/pdf-lib';
|
|
|
2
2
|
import { Schema, Mode, ColorType } from '@pdfme/common';
|
|
3
3
|
import { IconNode } from 'lucide';
|
|
4
4
|
export { measureTextHeight } from './text/measure.js';
|
|
5
|
+
export { escapeInlineMarkdown } from './text/inlineMarkdown.js';
|
|
6
|
+
export { getVariableNames, visitVariables } from './multiVariableText/variables.js';
|
|
5
7
|
export declare const convertForPdfLayoutProps: ({ schema, pageHeight, applyRotateTranslate, }: {
|
|
6
8
|
schema: Schema;
|
|
7
9
|
pageHeight: number;
|
package/dist/utils.js
CHANGED
|
@@ -1,216 +1,3 @@
|
|
|
1
|
-
import { n as measureTextHeight } from "./measure-Bjmh9Ro3.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { cmyk, degrees, degreesToRadians, rgb } from "@pdfme/pdf-lib";
|
|
5
|
-
//#region src/utils.ts
|
|
6
|
-
var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
|
|
7
|
-
const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
|
|
8
|
-
const { x: mmX, y: mmY } = position;
|
|
9
|
-
const rotateDegrees = rotate ? -rotate : 0;
|
|
10
|
-
const width = mm2pt(mmWidth);
|
|
11
|
-
const height = mm2pt(mmHeight);
|
|
12
|
-
let x = mm2pt(mmX);
|
|
13
|
-
let y = pageHeight - mm2pt(mmY) - height;
|
|
14
|
-
if (rotateDegrees && applyRotateTranslate) {
|
|
15
|
-
const pivotPoint = {
|
|
16
|
-
x: x + width / 2,
|
|
17
|
-
y: pageHeight - mm2pt(mmY) - height / 2
|
|
18
|
-
};
|
|
19
|
-
const rotatedPoint = rotatePoint({
|
|
20
|
-
x,
|
|
21
|
-
y
|
|
22
|
-
}, pivotPoint, rotateDegrees);
|
|
23
|
-
x = rotatedPoint.x;
|
|
24
|
-
y = rotatedPoint.y;
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
position: {
|
|
28
|
-
x,
|
|
29
|
-
y
|
|
30
|
-
},
|
|
31
|
-
height,
|
|
32
|
-
width,
|
|
33
|
-
rotate: degrees(rotateDegrees),
|
|
34
|
-
opacity
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
var rotatePoint = (point, pivot, angleDegrees) => {
|
|
38
|
-
const angleRadians = degreesToRadians(angleDegrees);
|
|
39
|
-
return {
|
|
40
|
-
x: Math.cos(angleRadians) * (point.x - pivot.x) - Math.sin(angleRadians) * (point.y - pivot.y) + pivot.x,
|
|
41
|
-
y: Math.sin(angleRadians) * (point.x - pivot.x) + Math.cos(angleRadians) * (point.y - pivot.y) + pivot.y
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var getDynamicHeightsForTable = getDynamicHeightsForTable$1;
|
|
45
|
-
var addAlphaToHex = (hex, alphaPercentage) => {
|
|
46
|
-
if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(hex)) throw new Error("Invalid HEX color code");
|
|
47
|
-
let alphaHex = Math.round(alphaPercentage / 100 * 255).toString(16);
|
|
48
|
-
if (alphaHex.length === 1) alphaHex = "0" + alphaHex;
|
|
49
|
-
return hex + alphaHex;
|
|
50
|
-
};
|
|
51
|
-
var isEditable = (mode, schema) => mode === "designer" || mode === "form" && schema.readOnly !== true;
|
|
52
|
-
var hex2rgb = (hex) => {
|
|
53
|
-
if (hex.slice(0, 1) === "#") hex = hex.slice(1);
|
|
54
|
-
if (hex.length === 3) hex = hex.slice(0, 1) + hex.slice(0, 1) + hex.slice(1, 2) + hex.slice(1, 2) + hex.slice(2, 3) + hex.slice(2, 3);
|
|
55
|
-
return [
|
|
56
|
-
hex.slice(0, 2),
|
|
57
|
-
hex.slice(2, 4),
|
|
58
|
-
hex.slice(4, 6)
|
|
59
|
-
].map((str) => parseInt(str, 16));
|
|
60
|
-
};
|
|
61
|
-
var hex2RgbColor = (hexString) => {
|
|
62
|
-
if (hexString) {
|
|
63
|
-
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
64
|
-
const [r, g, b] = hex2rgb(hexString);
|
|
65
|
-
return rgb(r / 255, g / 255, b / 255);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var hex2CmykColor = (hexString) => {
|
|
69
|
-
if (hexString) {
|
|
70
|
-
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
71
|
-
hexString = hexString.replace("#", "");
|
|
72
|
-
const hexColor = hexString.substring(0, 6);
|
|
73
|
-
const opacityColor = hexString.substring(6, 8);
|
|
74
|
-
const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;
|
|
75
|
-
let r = parseInt(hexColor.substring(0, 2), 16) / 255;
|
|
76
|
-
let g = parseInt(hexColor.substring(2, 4), 16) / 255;
|
|
77
|
-
let b = parseInt(hexColor.substring(4, 6), 16) / 255;
|
|
78
|
-
r = r * opacity + (1 - opacity);
|
|
79
|
-
g = g * opacity + (1 - opacity);
|
|
80
|
-
b = b * opacity + (1 - opacity);
|
|
81
|
-
const k = 1 - Math.max(r, g, b);
|
|
82
|
-
return cmyk(k === 1 ? 0 : (1 - r - k) / (1 - k), k === 1 ? 0 : (1 - g - k) / (1 - k), k === 1 ? 0 : (1 - b - k) / (1 - k), k);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var hex2PrintingColor = (color, colorType) => {
|
|
86
|
-
if (typeof color === "object") return color;
|
|
87
|
-
return colorType?.toLowerCase() == "cmyk" ? hex2CmykColor(color) : hex2RgbColor(color);
|
|
88
|
-
};
|
|
89
|
-
var readFile = (input) => new Promise((resolve, reject) => {
|
|
90
|
-
const fileReader = new FileReader();
|
|
91
|
-
fileReader.onload = (e) => {
|
|
92
|
-
if (e.target?.result) resolve(e.target.result);
|
|
93
|
-
};
|
|
94
|
-
fileReader.onerror = () => {
|
|
95
|
-
reject(/* @__PURE__ */ new Error("[@pdfme/schemas] File reading failed"));
|
|
96
|
-
};
|
|
97
|
-
let file = null;
|
|
98
|
-
if (input instanceof FileList && input.length > 0) file = input[0];
|
|
99
|
-
else if (input instanceof File) file = input;
|
|
100
|
-
if (file) fileReader.readAsDataURL(file);
|
|
101
|
-
else reject(/* @__PURE__ */ new Error("[@pdfme/schemas] No files provided"));
|
|
102
|
-
});
|
|
103
|
-
var createErrorElm = () => {
|
|
104
|
-
const container = document.createElement("div");
|
|
105
|
-
Object.assign(container.style, {
|
|
106
|
-
display: "flex",
|
|
107
|
-
alignItems: "center",
|
|
108
|
-
justifyContent: "center",
|
|
109
|
-
width: "100%",
|
|
110
|
-
height: "100%"
|
|
111
|
-
});
|
|
112
|
-
const span = document.createElement("span");
|
|
113
|
-
Object.assign(span.style, {
|
|
114
|
-
color: "white",
|
|
115
|
-
background: "red",
|
|
116
|
-
padding: "0.25rem",
|
|
117
|
-
fontSize: "12pt",
|
|
118
|
-
fontWeight: "bold",
|
|
119
|
-
borderRadius: "2px",
|
|
120
|
-
fontFamily: "'Open Sans', sans-serif"
|
|
121
|
-
});
|
|
122
|
-
span.textContent = "ERROR";
|
|
123
|
-
container.appendChild(span);
|
|
124
|
-
return container;
|
|
125
|
-
};
|
|
126
|
-
var createSvgStr = (icon, attrs) => {
|
|
127
|
-
const safeTagNames = new Set([
|
|
128
|
-
"svg",
|
|
129
|
-
"circle",
|
|
130
|
-
"ellipse",
|
|
131
|
-
"g",
|
|
132
|
-
"line",
|
|
133
|
-
"path",
|
|
134
|
-
"polygon",
|
|
135
|
-
"polyline",
|
|
136
|
-
"rect"
|
|
137
|
-
]);
|
|
138
|
-
const safeAttributeNames = new Set([
|
|
139
|
-
"aria-hidden",
|
|
140
|
-
"aria-label",
|
|
141
|
-
"class",
|
|
142
|
-
"clip-rule",
|
|
143
|
-
"cx",
|
|
144
|
-
"cy",
|
|
145
|
-
"d",
|
|
146
|
-
"fill",
|
|
147
|
-
"fill-opacity",
|
|
148
|
-
"fill-rule",
|
|
149
|
-
"focusable",
|
|
150
|
-
"height",
|
|
151
|
-
"id",
|
|
152
|
-
"opacity",
|
|
153
|
-
"points",
|
|
154
|
-
"preserveAspectRatio",
|
|
155
|
-
"r",
|
|
156
|
-
"role",
|
|
157
|
-
"rx",
|
|
158
|
-
"ry",
|
|
159
|
-
"stroke",
|
|
160
|
-
"stroke-dasharray",
|
|
161
|
-
"stroke-dashoffset",
|
|
162
|
-
"stroke-linecap",
|
|
163
|
-
"stroke-linejoin",
|
|
164
|
-
"stroke-miterlimit",
|
|
165
|
-
"stroke-opacity",
|
|
166
|
-
"stroke-width",
|
|
167
|
-
"transform",
|
|
168
|
-
"vector-effect",
|
|
169
|
-
"viewBox",
|
|
170
|
-
"width",
|
|
171
|
-
"x",
|
|
172
|
-
"x1",
|
|
173
|
-
"x2",
|
|
174
|
-
"xmlns",
|
|
175
|
-
"xmlns:xlink",
|
|
176
|
-
"y",
|
|
177
|
-
"y1",
|
|
178
|
-
"y2"
|
|
179
|
-
]);
|
|
180
|
-
const escapeHtmlAttribute = (value) => value.replaceAll("&", "&").replaceAll("\"", """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">");
|
|
181
|
-
const escapeHtmlText = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
182
|
-
const toSafeAttributeString = (attributes) => Object.entries(attributes).filter(([key, value]) => safeAttributeNames.has(key) && value !== void 0 && value !== null && !key.toLowerCase().startsWith("on")).map(([key, value]) => `${key}="${escapeHtmlAttribute(String(value))}"`).join(" ");
|
|
183
|
-
const toSafeTagName = (tag) => {
|
|
184
|
-
const tagName = String(tag);
|
|
185
|
-
if (!safeTagNames.has(tagName)) throw new Error(`Invalid SVG tag name: ${tagName}`);
|
|
186
|
-
return tagName;
|
|
187
|
-
};
|
|
188
|
-
if (!Array.isArray(icon)) return escapeHtmlText(String(icon));
|
|
189
|
-
const svgAttrString = toSafeAttributeString({
|
|
190
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
191
|
-
width: "24",
|
|
192
|
-
height: "24",
|
|
193
|
-
viewBox: "0 0 24 24",
|
|
194
|
-
fill: "none",
|
|
195
|
-
stroke: "currentColor",
|
|
196
|
-
"stroke-width": "2",
|
|
197
|
-
"stroke-linecap": "round",
|
|
198
|
-
"stroke-linejoin": "round",
|
|
199
|
-
...attrs
|
|
200
|
-
});
|
|
201
|
-
const processElement = (element) => {
|
|
202
|
-
if (!Array.isArray(element)) return escapeHtmlText(String(element));
|
|
203
|
-
const [tag, attributes = {}, children = []] = element;
|
|
204
|
-
const tagName = toSafeTagName(tag);
|
|
205
|
-
const attrString = toSafeAttributeString(attributes);
|
|
206
|
-
let childrenString = "";
|
|
207
|
-
if (Array.isArray(children) && children.length > 0) childrenString = children.map((child) => processElement(child)).join("");
|
|
208
|
-
if (childrenString) return `<${String(tagName)}${attrString ? " " + String(attrString) : ""}>${childrenString}</${String(tagName)}>`;
|
|
209
|
-
else return `<${String(tagName)}${attrString ? " " + String(attrString) : ""}/>`;
|
|
210
|
-
};
|
|
211
|
-
return `<svg ${svgAttrString}>${Array.isArray(icon) ? icon.map((element) => processElement(element)).join("") : processElement(icon)}</svg>`;
|
|
212
|
-
};
|
|
213
|
-
//#endregion
|
|
214
|
-
export { addAlphaToHex, convertForPdfLayoutProps, createErrorElm, createSvgStr, getDynamicHeightsForTable, hex2PrintingColor, hex2RgbColor, isEditable, measureTextHeight, readFile, rotatePoint };
|
|
215
|
-
|
|
216
|
-
//# sourceMappingURL=utils.js.map
|
|
1
|
+
import { n as measureTextHeight, p as escapeInlineMarkdown } from "./measure-Bjmh9Ro3.js";
|
|
2
|
+
import { a as getDynamicHeightsForTable, c as isEditable, f as getVariableNames, i as createSvgStr, l as readFile, n as convertForPdfLayoutProps, o as hex2PrintingColor, p as visitVariables, r as createErrorElm, s as hex2RgbColor, t as addAlphaToHex, u as rotatePoint } from "./utils-Bd4CvhPZ.js";
|
|
3
|
+
export { addAlphaToHex, convertForPdfLayoutProps, createErrorElm, createSvgStr, escapeInlineMarkdown, getDynamicHeightsForTable, getVariableNames, hex2PrintingColor, hex2RgbColor, isEditable, measureTextHeight, readFile, rotatePoint, visitVariables };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfme/schemas",
|
|
3
|
-
"version": "6.1.1-dev.
|
|
3
|
+
"version": "6.1.1-dev.17",
|
|
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",
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type * as CSS from 'csstype';\nimport { cmyk, degrees, degreesToRadians, rgb, Color } from '@pdfme/pdf-lib';\nimport { Schema, mm2pt, Mode, isHexValid, ColorType } from '@pdfme/common';\nimport { IconNode } from 'lucide';\nimport { getDynamicHeightsForTable as _getDynamicHeightsForTable } from './tables/dynamicTemplate.js';\nexport { measureTextHeight } from './text/measure.js';\nexport const convertForPdfLayoutProps = ({\n schema,\n pageHeight,\n applyRotateTranslate = true,\n}: {\n schema: Schema;\n pageHeight: number;\n applyRotateTranslate?: boolean;\n}) => {\n const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;\n const { x: mmX, y: mmY } = position;\n\n const rotateDegrees = rotate ? -rotate : 0;\n const width = mm2pt(mmWidth);\n const height = mm2pt(mmHeight);\n let x = mm2pt(mmX);\n // PDF coordinate system is from bottom left, UI is top left, so we need to flip the y axis\n let y = pageHeight - mm2pt(mmY) - height;\n\n if (rotateDegrees && applyRotateTranslate) {\n // If rotating we must pivot around the same point as the UI performs its rotation.\n // The UI performs rotation around the objects center point (the pivot point below),\n // pdflib rotates around the bottom left corner of the object.\n // We must therefore adjust the X and Y by rotating the bottom left corner by this pivot point.\n const pivotPoint = { x: x + width / 2, y: pageHeight - mm2pt(mmY) - height / 2 };\n const rotatedPoint = rotatePoint({ x, y }, pivotPoint, rotateDegrees);\n x = rotatedPoint.x;\n y = rotatedPoint.y;\n }\n\n return {\n position: { x, y },\n height: height,\n width: width,\n rotate: degrees(rotateDegrees),\n opacity,\n };\n};\n\nexport const rotatePoint = (\n point: { x: number; y: number },\n pivot: { x: number; y: number },\n angleDegrees: number,\n): { x: number; y: number } => {\n const angleRadians = degreesToRadians(angleDegrees);\n\n const x =\n Math.cos(angleRadians) * (point.x - pivot.x) -\n Math.sin(angleRadians) * (point.y - pivot.y) +\n pivot.x;\n const y =\n Math.sin(angleRadians) * (point.x - pivot.x) +\n Math.cos(angleRadians) * (point.y - pivot.y) +\n pivot.y;\n\n return { x, y };\n};\n\nexport const getDynamicHeightsForTable = _getDynamicHeightsForTable;\n\n// ----------------------------------------\n\nexport const addAlphaToHex = (hex: string, alphaPercentage: number) => {\n if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(hex)) {\n throw new Error('Invalid HEX color code');\n }\n const alphaValue = Math.round((alphaPercentage / 100) * 255);\n let alphaHex = alphaValue.toString(16);\n if (alphaHex.length === 1) alphaHex = '0' + alphaHex;\n return hex + alphaHex;\n};\n\nexport const isEditable = (mode: Mode, schema: Schema) =>\n mode === 'designer' || (mode === 'form' && schema.readOnly !== true);\n\nconst hex2rgb = (hex: string) => {\n if (hex.slice(0, 1) === '#') hex = hex.slice(1);\n if (hex.length === 3)\n hex =\n hex.slice(0, 1) +\n hex.slice(0, 1) +\n hex.slice(1, 2) +\n hex.slice(1, 2) +\n hex.slice(2, 3) +\n hex.slice(2, 3);\n\n return [hex.slice(0, 2), hex.slice(2, 4), hex.slice(4, 6)].map((str) => parseInt(str, 16));\n};\n\nexport const hex2RgbColor = (hexString: string | undefined) => {\n if (hexString) {\n const isValid = isHexValid(hexString);\n\n if (!isValid) {\n throw new Error(`Invalid hex color value ${hexString}`);\n }\n\n const [r, g, b] = hex2rgb(hexString);\n\n return rgb(r / 255, g / 255, b / 255);\n }\n\n return undefined;\n};\n\nconst hex2CmykColor = (hexString: string | undefined) => {\n if (hexString) {\n const isValid = isHexValid(hexString);\n\n if (!isValid) {\n throw new Error(`Invalid hex color value ${hexString}`);\n }\n\n // Remove the # if it's present\n hexString = hexString.replace('#', '');\n\n // Extract the hexadecimal color code and the opacity\n const hexColor = hexString.substring(0, 6);\n const opacityColor = hexString.substring(6, 8);\n const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;\n\n // Convert the hex values to decimal\n let r = parseInt(hexColor.substring(0, 2), 16) / 255;\n let g = parseInt(hexColor.substring(2, 4), 16) / 255;\n let b = parseInt(hexColor.substring(4, 6), 16) / 255;\n\n // Apply the opacity\n r = r * opacity + (1 - opacity);\n g = g * opacity + (1 - opacity);\n b = b * opacity + (1 - opacity);\n\n // Calculate the CMYK values\n const k = 1 - Math.max(r, g, b);\n const c = k === 1 ? 0 : (1 - r - k) / (1 - k);\n const m = k === 1 ? 0 : (1 - g - k) / (1 - k);\n const y = k === 1 ? 0 : (1 - b - k) / (1 - k);\n\n return cmyk(c, m, y, k);\n }\n\n return undefined;\n};\n\nexport const hex2PrintingColor = (color?: string | Color, colorType?: ColorType) => {\n // if color is already CMYK, RGB or Grayscale, does not required to convert\n if (typeof color === 'object') return color;\n return colorType?.toLowerCase() == 'cmyk' ? hex2CmykColor(color) : hex2RgbColor(color);\n};\n\nexport const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n\n fileReader.onload = (e) => {\n if (e.target?.result) {\n resolve(e.target.result);\n }\n };\n\n fileReader.onerror = () => {\n reject(new Error('[@pdfme/schemas] File reading failed'));\n };\n\n let file: File | null = null;\n if (input instanceof FileList && input.length > 0) {\n file = input[0];\n } else if (input instanceof File) {\n file = input;\n }\n\n if (file) {\n fileReader.readAsDataURL(file);\n } else {\n reject(new Error('[@pdfme/schemas] No files provided'));\n }\n });\n\nexport const createErrorElm = () => {\n const container = document.createElement('div');\n const containerStyle: CSS.Properties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '100%',\n height: '100%',\n };\n Object.assign(container.style, containerStyle);\n\n const span = document.createElement('span');\n const spanStyle: CSS.Properties = {\n color: 'white',\n background: 'red',\n padding: '0.25rem',\n fontSize: '12pt',\n fontWeight: 'bold',\n borderRadius: '2px',\n fontFamily: \"'Open Sans', sans-serif\",\n };\n Object.assign(span.style, spanStyle);\n\n span.textContent = 'ERROR';\n container.appendChild(span);\n\n return container;\n};\n\nexport const createSvgStr = (icon: IconNode, attrs?: Record<string, string>): string => {\n // In lucide 0.475.0, the icon is an array of elements, not a single SVG element\n // We need to create an SVG wrapper and add the elements as children\n\n const safeTagNames = new Set([\n 'svg',\n 'circle',\n 'ellipse',\n 'g',\n 'line',\n 'path',\n 'polygon',\n 'polyline',\n 'rect',\n ]);\n const safeAttributeNames = new Set([\n 'aria-hidden',\n 'aria-label',\n 'class',\n 'clip-rule',\n 'cx',\n 'cy',\n 'd',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'focusable',\n 'height',\n 'id',\n 'opacity',\n 'points',\n 'preserveAspectRatio',\n 'r',\n 'role',\n 'rx',\n 'ry',\n 'stroke',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'transform',\n 'vector-effect',\n 'viewBox',\n 'width',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'xmlns:xlink',\n 'y',\n 'y1',\n 'y2',\n ]);\n const escapeHtmlAttribute = (value: string): string =>\n value\n .replaceAll('&', '&')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''')\n .replaceAll('<', '<')\n .replaceAll('>', '>');\n const escapeHtmlText = (value: string): string =>\n value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');\n const toSafeAttributeString = (attributes: Record<string, string>): string =>\n Object.entries(attributes)\n .filter(\n ([key, value]) =>\n safeAttributeNames.has(key) &&\n value !== undefined &&\n value !== null &&\n !key.toLowerCase().startsWith('on'),\n )\n .map(([key, value]) => `${key}=\"${escapeHtmlAttribute(String(value))}\"`)\n .join(' ');\n const toSafeTagName = (tag: unknown): string => {\n const tagName = String(tag);\n if (!safeTagNames.has(tagName)) {\n throw new Error(`Invalid SVG tag name: ${tagName}`);\n }\n return tagName;\n };\n\n // Handle non-array input\n if (!Array.isArray(icon)) {\n return escapeHtmlText(String(icon));\n }\n\n // Create default SVG attributes\n const svgAttrs = {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '24',\n height: '24',\n viewBox: '0 0 24 24',\n fill: 'none',\n stroke: 'currentColor',\n 'stroke-width': '2',\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round',\n ...attrs,\n };\n const svgAttrString = toSafeAttributeString(svgAttrs);\n\n // Helper function to process a single element\n const processElement = (element: unknown): string => {\n if (!Array.isArray(element)) {\n return escapeHtmlText(String(element));\n }\n\n const [tag, attributes = {}, children = []] = element as [\n unknown,\n Record<string, string>,\n unknown[],\n ];\n const tagName = toSafeTagName(tag);\n const attrString = toSafeAttributeString(attributes);\n\n // Process children recursively\n let childrenString = '';\n\n if (Array.isArray(children) && children.length > 0) {\n childrenString = children.map((child) => processElement(child)).join('');\n }\n\n // Return properly formatted element string\n if (childrenString) {\n return `<${String(tagName)}${attrString ? ' ' + String(attrString) : ''}>${childrenString}</${String(tagName)}>`;\n } else {\n // Self-closing tag for empty children\n return `<${String(tagName)}${attrString ? ' ' + String(attrString) : ''}/>`;\n }\n };\n\n // Process all elements and join them\n const elementsString = Array.isArray(icon)\n ? icon.map((element) => processElement(element)).join('')\n : processElement(icon);\n\n // Return the complete SVG string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