@pdfme/ui 6.1.13-dev.35 → 6.1.13-dev.37
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/index.js +61 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38372,25 +38372,51 @@ var splitFontFamilies = (fontFamily) => {
|
|
|
38372
38372
|
var normalizeFontFamily = (fontFamily) => {
|
|
38373
38373
|
return splitFontFamilies(fontFamily)[0] || fontFamily.trim();
|
|
38374
38374
|
};
|
|
38375
|
-
var parseColor$2 = (color, inherited) => {
|
|
38375
|
+
var parseColor$2 = (color, kind, options, inherited) => {
|
|
38376
38376
|
if (!color || color.length === 0) return void 0;
|
|
38377
38377
|
if (["none", "transparent"].includes(color)) return void 0;
|
|
38378
|
-
if (color === "currentColor")
|
|
38378
|
+
if (color === "currentColor") {
|
|
38379
|
+
if (inherited?.color) return {
|
|
38380
|
+
rgb: inherited.color,
|
|
38381
|
+
alpha: inherited.opacity?.toString()
|
|
38382
|
+
};
|
|
38383
|
+
return parseColor$2("#000000", kind, options);
|
|
38384
|
+
}
|
|
38379
38385
|
const parsedColor = colorString(color);
|
|
38386
|
+
const parsed = {
|
|
38387
|
+
rgb: parsedColor.rgb,
|
|
38388
|
+
alpha: parsedColor.alpha
|
|
38389
|
+
};
|
|
38390
|
+
const mappedColor = options.mapColor?.({
|
|
38391
|
+
color,
|
|
38392
|
+
parsed,
|
|
38393
|
+
kind,
|
|
38394
|
+
inherited
|
|
38395
|
+
});
|
|
38396
|
+
if (mappedColor) return {
|
|
38397
|
+
rgb: mappedColor.color,
|
|
38398
|
+
alpha: mappedColor.alpha !== void 0 ? mappedColor.alpha.toString() : parsedColor.alpha !== void 0 ? parsedColor.alpha.toString() : void 0
|
|
38399
|
+
};
|
|
38380
38400
|
return {
|
|
38381
38401
|
rgb: parsedColor.rgb,
|
|
38382
|
-
alpha: parsedColor.alpha ? parsedColor.alpha
|
|
38402
|
+
alpha: parsedColor.alpha !== void 0 ? parsedColor.alpha.toString() : void 0
|
|
38383
38403
|
};
|
|
38384
38404
|
};
|
|
38385
|
-
var parseAttributes = (element, inherited, matrix) => {
|
|
38405
|
+
var parseAttributes = (element, inherited, matrix, options) => {
|
|
38386
38406
|
const attributes = element.attributes;
|
|
38387
38407
|
const style = parseStyles$1(attributes.style);
|
|
38388
38408
|
const widthRaw = styleOrAttribute(attributes, style, "width", "");
|
|
38389
38409
|
const heightRaw = styleOrAttribute(attributes, style, "height", "");
|
|
38390
|
-
const fillRaw = parseColor$2(styleOrAttribute(attributes, style, "fill")
|
|
38410
|
+
const fillRaw = parseColor$2(styleOrAttribute(attributes, style, "fill"), "fill", options, {
|
|
38411
|
+
color: inherited.fill,
|
|
38412
|
+
opacity: inherited.fillOpacity
|
|
38413
|
+
});
|
|
38391
38414
|
const fillOpacityRaw = styleOrAttribute(attributes, style, "fill-opacity");
|
|
38392
38415
|
const opacityRaw = styleOrAttribute(attributes, style, "opacity");
|
|
38393
|
-
const strokeRaw = parseColor$2(styleOrAttribute(attributes, style, "stroke")
|
|
38416
|
+
const strokeRaw = parseColor$2(styleOrAttribute(attributes, style, "stroke"), "stroke", options, {
|
|
38417
|
+
color: inherited.stroke,
|
|
38418
|
+
opacity: inherited.strokeOpacity
|
|
38419
|
+
});
|
|
38394
38420
|
const strokeOpacityRaw = styleOrAttribute(attributes, style, "stroke-opacity");
|
|
38395
38421
|
const strokeLineCapRaw = styleOrAttribute(attributes, style, "stroke-linecap");
|
|
38396
38422
|
const strokeLineJoinRaw = styleOrAttribute(attributes, style, "stroke-linejoin");
|
|
@@ -38560,18 +38586,18 @@ var getAspectRatioTransformation = (matrix, originalWidth, originalHeight, targe
|
|
|
38560
38586
|
content: combineTransformation(combineTransformation(matrix, "translate", [x, y]), "scale", [scale])
|
|
38561
38587
|
};
|
|
38562
38588
|
};
|
|
38563
|
-
var parseHTMLNode = (node, inherited, matrix, clipSpaces) => {
|
|
38589
|
+
var parseHTMLNode = (node, inherited, matrix, clipSpaces, options) => {
|
|
38564
38590
|
if (node.nodeType === import_src.NodeType.COMMENT_NODE) return [];
|
|
38565
38591
|
else if (node.nodeType === import_src.NodeType.TEXT_NODE) return [];
|
|
38566
|
-
else if (node.tagName === "g") return parseGroupNode(node, inherited, matrix, clipSpaces);
|
|
38567
|
-
else if (node.tagName === "svg") return parseSvgNode(node, inherited, matrix, clipSpaces);
|
|
38592
|
+
else if (node.tagName === "g") return parseGroupNode(node, inherited, matrix, clipSpaces, options);
|
|
38593
|
+
else if (node.tagName === "svg") return parseSvgNode(node, inherited, matrix, clipSpaces, options);
|
|
38568
38594
|
else {
|
|
38569
38595
|
if (node.tagName === "polygon") {
|
|
38570
38596
|
node.tagName = "path";
|
|
38571
38597
|
node.attributes.d = `M${node.attributes.points}Z`;
|
|
38572
38598
|
delete node.attributes.points;
|
|
38573
38599
|
}
|
|
38574
|
-
const attributes = parseAttributes(node, inherited, matrix);
|
|
38600
|
+
const attributes = parseAttributes(node, inherited, matrix, options);
|
|
38575
38601
|
const svgAttributes = {
|
|
38576
38602
|
...attributes.inherited,
|
|
38577
38603
|
...attributes.svgAttributes,
|
|
@@ -38582,10 +38608,10 @@ var parseHTMLNode = (node, inherited, matrix, clipSpaces) => {
|
|
|
38582
38608
|
return [node];
|
|
38583
38609
|
}
|
|
38584
38610
|
};
|
|
38585
|
-
var parseSvgNode = (node, inherited, matrix, clipSpaces) => {
|
|
38611
|
+
var parseSvgNode = (node, inherited, matrix, clipSpaces, options) => {
|
|
38586
38612
|
if (!node.attributes.width) node.setAttribute("width", inherited.viewBox.width + "");
|
|
38587
38613
|
if (!node.attributes.height) node.setAttribute("height", inherited.viewBox.height + "");
|
|
38588
|
-
const attributes = parseAttributes(node, inherited, matrix);
|
|
38614
|
+
const attributes = parseAttributes(node, inherited, matrix, options);
|
|
38589
38615
|
const result = [];
|
|
38590
38616
|
const viewBox = node.attributes.viewBox ? parseViewBox(node.attributes.viewBox) : node.attributes.width && node.attributes.height ? parseViewBox(`0 0 ${node.attributes.width} ${node.attributes.height}`) : inherited.viewBox;
|
|
38591
38617
|
let newMatrix = combineTransformation(matrix, "translate", [parseFloat(node.attributes.x) || 0, parseFloat(node.attributes.y) || 0]);
|
|
@@ -38613,16 +38639,16 @@ var parseSvgNode = (node, inherited, matrix, clipSpaces) => {
|
|
|
38613
38639
|
const parsedNodes = parseHTMLNode(child, {
|
|
38614
38640
|
...attributes.inherited,
|
|
38615
38641
|
viewBox
|
|
38616
|
-
}, newMatrix, [...clipSpaces, baseClipSpace]);
|
|
38642
|
+
}, newMatrix, [...clipSpaces, baseClipSpace], options);
|
|
38617
38643
|
result.push(...parsedNodes);
|
|
38618
38644
|
});
|
|
38619
38645
|
return result;
|
|
38620
38646
|
};
|
|
38621
|
-
var parseGroupNode = (node, inherited, matrix, clipSpaces) => {
|
|
38622
|
-
const attributes = parseAttributes(node, inherited, matrix);
|
|
38647
|
+
var parseGroupNode = (node, inherited, matrix, clipSpaces, options) => {
|
|
38648
|
+
const attributes = parseAttributes(node, inherited, matrix, options);
|
|
38623
38649
|
const result = [];
|
|
38624
38650
|
node.childNodes.forEach((child) => {
|
|
38625
|
-
result.push(...parseHTMLNode(child, attributes.inherited, attributes.matrix, clipSpaces));
|
|
38651
|
+
result.push(...parseHTMLNode(child, attributes.inherited, attributes.matrix, clipSpaces, options));
|
|
38626
38652
|
});
|
|
38627
38653
|
return result;
|
|
38628
38654
|
};
|
|
@@ -38643,7 +38669,7 @@ var parseViewBox = (viewBox) => {
|
|
|
38643
38669
|
height: heightViewBox
|
|
38644
38670
|
};
|
|
38645
38671
|
};
|
|
38646
|
-
var parse$1$1 = (svg, { width, height, fontSize }, size, matrix) => {
|
|
38672
|
+
var parse$1$1 = (svg, { width, height, fontSize, mapColor }, size, matrix) => {
|
|
38647
38673
|
const htmlElement = (0, import_src.parse)(svg).firstChild;
|
|
38648
38674
|
if (width) htmlElement.setAttribute("width", width + "");
|
|
38649
38675
|
if (height) htmlElement.setAttribute("height", height + "");
|
|
@@ -38651,7 +38677,7 @@ var parse$1$1 = (svg, { width, height, fontSize }, size, matrix) => {
|
|
|
38651
38677
|
return parseHTMLNode(htmlElement, {
|
|
38652
38678
|
...size,
|
|
38653
38679
|
viewBox: parseViewBox(htmlElement.attributes.viewBox || "0 0 1 1")
|
|
38654
|
-
}, matrix, []);
|
|
38680
|
+
}, matrix, [], { mapColor });
|
|
38655
38681
|
};
|
|
38656
38682
|
var drawSvg = async (page, svg, options) => {
|
|
38657
38683
|
if (!svg) return;
|
|
@@ -40019,12 +40045,14 @@ var PDFPage = class {
|
|
|
40019
40045
|
assertOrUndefined(options.y, "options.y", ["number"]);
|
|
40020
40046
|
assertOrUndefined(options.width, "options.width", ["number"]);
|
|
40021
40047
|
assertOrUndefined(options.height, "options.height", ["number"]);
|
|
40048
|
+
assertOrUndefined(options.mapColor, "options.mapColor", [Function]);
|
|
40022
40049
|
await drawSvg(this, svg, {
|
|
40023
40050
|
x: options.x ?? this.x,
|
|
40024
40051
|
y: options.y ?? this.y,
|
|
40025
40052
|
fonts: options.fonts,
|
|
40026
40053
|
width: options.width,
|
|
40027
|
-
height: options.height
|
|
40054
|
+
height: options.height,
|
|
40055
|
+
mapColor: options.mapColor
|
|
40028
40056
|
});
|
|
40029
40057
|
}
|
|
40030
40058
|
getFont() {
|
|
@@ -85903,7 +85931,7 @@ var getDynamicLayoutForTable = async (value, args) => {
|
|
|
85903
85931
|
};
|
|
85904
85932
|
};
|
|
85905
85933
|
//#endregion
|
|
85906
|
-
//#region ../schemas/dist/utils-
|
|
85934
|
+
//#region ../schemas/dist/utils-CPYF2FY_.js
|
|
85907
85935
|
var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
|
|
85908
85936
|
const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
|
|
85909
85937
|
const { x: mmX, y: mmY } = position;
|
|
@@ -85952,6 +85980,15 @@ var hex2rgb = (hex) => {
|
|
|
85952
85980
|
hex.slice(4, 6)
|
|
85953
85981
|
].map((str) => parseInt(str, 16));
|
|
85954
85982
|
};
|
|
85983
|
+
var getHexOpacity = (hex) => {
|
|
85984
|
+
const normalized = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
85985
|
+
const opacityHex = normalized.length === 4 ? normalized.slice(3, 4).repeat(2) : normalized.length === 8 ? normalized.slice(6, 8) : "";
|
|
85986
|
+
return opacityHex ? parseInt(opacityHex, 16) / 255 : 1;
|
|
85987
|
+
};
|
|
85988
|
+
var rgbColorToCmykColor = ({ red, green, blue }) => {
|
|
85989
|
+
const key = 1 - Math.max(red, green, blue);
|
|
85990
|
+
return cmyk(key === 1 ? 0 : (1 - red - key) / (1 - key), key === 1 ? 0 : (1 - green - key) / (1 - key), key === 1 ? 0 : (1 - blue - key) / (1 - key), key);
|
|
85991
|
+
};
|
|
85955
85992
|
var hex2RgbColor = (hexString) => {
|
|
85956
85993
|
if (hexString) {
|
|
85957
85994
|
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
@@ -85962,18 +85999,12 @@ var hex2RgbColor = (hexString) => {
|
|
|
85962
85999
|
var hex2CmykColor = (hexString) => {
|
|
85963
86000
|
if (hexString) {
|
|
85964
86001
|
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
85965
|
-
|
|
85966
|
-
const
|
|
85967
|
-
const opacityColor = hexString.substring(6, 8);
|
|
85968
|
-
const opacity = opacityColor ? parseInt(opacityColor, 16) / 255 : 1;
|
|
85969
|
-
let r = parseInt(hexColor.substring(0, 2), 16) / 255;
|
|
85970
|
-
let g = parseInt(hexColor.substring(2, 4), 16) / 255;
|
|
85971
|
-
let b = parseInt(hexColor.substring(4, 6), 16) / 255;
|
|
86002
|
+
let [r, g, b] = hex2rgb(hexString).map((value) => value / 255);
|
|
86003
|
+
const opacity = getHexOpacity(hexString);
|
|
85972
86004
|
r = r * opacity + (1 - opacity);
|
|
85973
86005
|
g = g * opacity + (1 - opacity);
|
|
85974
86006
|
b = b * opacity + (1 - opacity);
|
|
85975
|
-
|
|
85976
|
-
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);
|
|
86007
|
+
return rgbColorToCmykColor(rgb(r, g, b));
|
|
85977
86008
|
}
|
|
85978
86009
|
};
|
|
85979
86010
|
var hex2PrintingColor = (color, colorType) => {
|
|
@@ -86193,7 +86224,7 @@ var Underline = [["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", {
|
|
|
86193
86224
|
y2: "20"
|
|
86194
86225
|
}]];
|
|
86195
86226
|
//#endregion
|
|
86196
|
-
//#region ../schemas/dist/builtins-
|
|
86227
|
+
//#region ../schemas/dist/builtins-C-2wyB_3.js
|
|
86197
86228
|
var addUriLinkAnnotation = (arg) => {
|
|
86198
86229
|
const { pdfDoc, page, uri, rect, borderWidth = 0 } = arg;
|
|
86199
86230
|
const safeUri = normalizeSafeLinkUri(uri);
|