@pdfme/ui 6.2.1-dev.13 → 6.2.1
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 +36 -60
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -86113,7 +86113,7 @@ var getDynamicLayoutForTable = async (value, args) => {
|
|
|
86113
86113
|
};
|
|
86114
86114
|
};
|
|
86115
86115
|
//#endregion
|
|
86116
|
-
//#region ../schemas/dist/utils-
|
|
86116
|
+
//#region ../schemas/dist/utils-CPYF2FY_.js
|
|
86117
86117
|
var convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true }) => {
|
|
86118
86118
|
const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
|
|
86119
86119
|
const { x: mmX, y: mmY } = position;
|
|
@@ -86153,26 +86153,7 @@ var rotatePoint = (point, pivot, angleDegrees) => {
|
|
|
86153
86153
|
};
|
|
86154
86154
|
};
|
|
86155
86155
|
var isEditable = (mode, schema) => mode === "designer" || mode === "form" && schema.readOnly !== true;
|
|
86156
|
-
var splitHexAlpha = (hexColor) => {
|
|
86157
|
-
if (!hexColor.startsWith("#")) return {
|
|
86158
|
-
color: hexColor,
|
|
86159
|
-
alpha: 1
|
|
86160
|
-
};
|
|
86161
|
-
const hex = hexColor.slice(1);
|
|
86162
|
-
if (!/^(?:[0-9a-f]{4}|[0-9a-f]{8})$/i.test(hex)) return {
|
|
86163
|
-
color: hexColor,
|
|
86164
|
-
alpha: 1
|
|
86165
|
-
};
|
|
86166
|
-
const rgbLength = hex.length === 4 ? 3 : 6;
|
|
86167
|
-
const alphaHex = hex.slice(rgbLength);
|
|
86168
|
-
return {
|
|
86169
|
-
color: `#${hex.slice(0, rgbLength)}`,
|
|
86170
|
-
alpha: parseInt(alphaHex.length === 1 ? alphaHex.repeat(2) : alphaHex, 16) / 255
|
|
86171
|
-
};
|
|
86172
|
-
};
|
|
86173
|
-
var applyAlphaToOpacity = (opacity, alpha) => alpha === 1 ? opacity : (opacity ?? 1) * alpha;
|
|
86174
86156
|
var hex2rgb = (hex) => {
|
|
86175
|
-
hex = splitHexAlpha(hex).color;
|
|
86176
86157
|
if (hex.slice(0, 1) === "#") hex = hex.slice(1);
|
|
86177
86158
|
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);
|
|
86178
86159
|
return [
|
|
@@ -86181,6 +86162,11 @@ var hex2rgb = (hex) => {
|
|
|
86181
86162
|
hex.slice(4, 6)
|
|
86182
86163
|
].map((str) => parseInt(str, 16));
|
|
86183
86164
|
};
|
|
86165
|
+
var getHexOpacity = (hex) => {
|
|
86166
|
+
const normalized = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
86167
|
+
const opacityHex = normalized.length === 4 ? normalized.slice(3, 4).repeat(2) : normalized.length === 8 ? normalized.slice(6, 8) : "";
|
|
86168
|
+
return opacityHex ? parseInt(opacityHex, 16) / 255 : 1;
|
|
86169
|
+
};
|
|
86184
86170
|
var rgbColorToCmykColor = ({ red, green, blue }) => {
|
|
86185
86171
|
const key = 1 - Math.max(red, green, blue);
|
|
86186
86172
|
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);
|
|
@@ -86195,7 +86181,11 @@ var hex2RgbColor = (hexString) => {
|
|
|
86195
86181
|
var hex2CmykColor = (hexString) => {
|
|
86196
86182
|
if (hexString) {
|
|
86197
86183
|
if (!isHexValid(hexString)) throw new Error(`Invalid hex color value ${hexString}`);
|
|
86198
|
-
|
|
86184
|
+
let [r, g, b] = hex2rgb(hexString).map((value) => value / 255);
|
|
86185
|
+
const opacity = getHexOpacity(hexString);
|
|
86186
|
+
r = r * opacity + (1 - opacity);
|
|
86187
|
+
g = g * opacity + (1 - opacity);
|
|
86188
|
+
b = b * opacity + (1 - opacity);
|
|
86199
86189
|
return rgbColorToCmykColor(rgb(r, g, b));
|
|
86200
86190
|
}
|
|
86201
86191
|
};
|
|
@@ -86416,7 +86406,7 @@ var Underline = [["path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", {
|
|
|
86416
86406
|
y2: "20"
|
|
86417
86407
|
}]];
|
|
86418
86408
|
//#endregion
|
|
86419
|
-
//#region ../schemas/dist/builtins-
|
|
86409
|
+
//#region ../schemas/dist/builtins-C-2wyB_3.js
|
|
86420
86410
|
var addUriLinkAnnotation = (arg) => {
|
|
86421
86411
|
const { pdfDoc, page, uri, rect, borderWidth = 0 } = arg;
|
|
86422
86412
|
const safeUri = normalizeSafeLinkUri(uri);
|
|
@@ -86524,7 +86514,7 @@ var getLinkAnnotationRect = (arg) => {
|
|
|
86524
86514
|
});
|
|
86525
86515
|
};
|
|
86526
86516
|
var drawRun = (arg) => {
|
|
86527
|
-
const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity,
|
|
86517
|
+
const { page, pdfLib, run, pdfFont, x, y, rotate, pivotPoint, fontSize, lineHeight, color, opacity, colorType, characterSpacing, strikethrough, underline } = arg;
|
|
86528
86518
|
const runWidth = getRunWidth(run, fontSize, characterSpacing);
|
|
86529
86519
|
const codePadding = run.code ? CODE_HORIZONTAL_PADDING : 0;
|
|
86530
86520
|
const textX = x + codePadding;
|
|
@@ -86559,7 +86549,7 @@ var drawRun = (arg) => {
|
|
|
86559
86549
|
pivotPoint,
|
|
86560
86550
|
fontSize,
|
|
86561
86551
|
color,
|
|
86562
|
-
opacity
|
|
86552
|
+
opacity
|
|
86563
86553
|
});
|
|
86564
86554
|
if (underline && runWidth > 0) drawDecorationLine({
|
|
86565
86555
|
page,
|
|
@@ -86570,7 +86560,7 @@ var drawRun = (arg) => {
|
|
|
86570
86560
|
pivotPoint,
|
|
86571
86561
|
fontSize,
|
|
86572
86562
|
color,
|
|
86573
|
-
opacity
|
|
86563
|
+
opacity
|
|
86574
86564
|
});
|
|
86575
86565
|
const drawAt = (drawX) => {
|
|
86576
86566
|
const point = rotate.angle === 0 ? {
|
|
@@ -86588,7 +86578,7 @@ var drawRun = (arg) => {
|
|
|
86588
86578
|
color,
|
|
86589
86579
|
lineHeight: lineHeight * fontSize,
|
|
86590
86580
|
font: pdfFont,
|
|
86591
|
-
opacity
|
|
86581
|
+
opacity,
|
|
86592
86582
|
...run.syntheticItalic ? { ySkew: pdfLib.degrees(12) } : {}
|
|
86593
86583
|
});
|
|
86594
86584
|
};
|
|
@@ -86599,8 +86589,7 @@ var drawRun = (arg) => {
|
|
|
86599
86589
|
}
|
|
86600
86590
|
};
|
|
86601
86591
|
var renderInlineMarkdownText = async (arg) => {
|
|
86602
|
-
const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, y, width, height, pivotPoint, rotate, opacity
|
|
86603
|
-
const textOpacity = applyAlphaToOpacity(opacity, colorAlpha);
|
|
86592
|
+
const { value, schema, font, embedPdfFont, fontKitFont, pdfDoc, page, pdfLib, _cache, colorType, fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing, x, y, width, height, pivotPoint, rotate, opacity } = arg;
|
|
86604
86593
|
const lines = applyTextLineRange(layoutRichTextLines({
|
|
86605
86594
|
runs: await resolveRichTextRuns({
|
|
86606
86595
|
runs: parseInlineMarkdown(value),
|
|
@@ -86646,7 +86635,7 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
86646
86635
|
pivotPoint,
|
|
86647
86636
|
fontSize,
|
|
86648
86637
|
color,
|
|
86649
|
-
opacity
|
|
86638
|
+
opacity
|
|
86650
86639
|
});
|
|
86651
86640
|
if (schema.underline) drawDecorationLine({
|
|
86652
86641
|
page,
|
|
@@ -86657,7 +86646,7 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
86657
86646
|
pivotPoint,
|
|
86658
86647
|
fontSize,
|
|
86659
86648
|
color,
|
|
86660
|
-
opacity
|
|
86649
|
+
opacity
|
|
86661
86650
|
});
|
|
86662
86651
|
}
|
|
86663
86652
|
line.runs.reduce((currentX, run, runIndex) => {
|
|
@@ -86676,7 +86665,6 @@ var renderInlineMarkdownText = async (arg) => {
|
|
|
86676
86665
|
lineHeight,
|
|
86677
86666
|
color,
|
|
86678
86667
|
opacity,
|
|
86679
|
-
textOpacity,
|
|
86680
86668
|
colorType,
|
|
86681
86669
|
characterSpacing: spacing,
|
|
86682
86670
|
strikethrough: Boolean(run.strikethrough),
|
|
@@ -86729,14 +86717,13 @@ var embedAndGetFont = (arg) => {
|
|
|
86729
86717
|
const pdfFontCache = getPdfFontCache(_cache);
|
|
86730
86718
|
const cachedFont = pdfFontCache[fontName];
|
|
86731
86719
|
if (cachedFont) return cachedFont;
|
|
86720
|
+
const fontValue = font[fontName];
|
|
86721
|
+
if (!fontValue) return Promise.reject(/* @__PURE__ */ new Error(`[@pdfme/schemas] Font "${fontName}" is not found.`));
|
|
86732
86722
|
const pdfFontPromise = (async () => {
|
|
86733
|
-
const fontValue = font[fontName];
|
|
86734
|
-
if (!fontValue) throw new Error(`[@pdfme/schemas] Font "${fontName}" is not found.`);
|
|
86735
86723
|
let fontData = fontValue.data;
|
|
86736
86724
|
if (typeof fontData === "string" && fontData.startsWith("http")) fontData = await fetchRemoteFontData(fontData);
|
|
86737
86725
|
return pdfDoc.embedFont(fontData, { subset: typeof fontValue.subset === "undefined" ? true : fontValue.subset });
|
|
86738
86726
|
})();
|
|
86739
|
-
pdfFontPromise.catch(() => {});
|
|
86740
86727
|
pdfFontCache[fontName] = pdfFontPromise;
|
|
86741
86728
|
return pdfFontPromise;
|
|
86742
86729
|
};
|
|
@@ -86746,16 +86733,14 @@ var getFontProp = ({ value, fontKitFont, schema, basePdf, colorType, fontSize: r
|
|
|
86746
86733
|
fontKitFont,
|
|
86747
86734
|
value
|
|
86748
86735
|
}) : schema.fontSize ?? 13);
|
|
86749
|
-
const
|
|
86750
|
-
const color = hex2PrintingColor(fontColorHex, colorType);
|
|
86736
|
+
const color = hex2PrintingColor(schema.fontColor || "#000000", colorType);
|
|
86751
86737
|
return {
|
|
86752
86738
|
alignment: schema.alignment ?? "left",
|
|
86753
86739
|
verticalAlignment: schema.verticalAlignment ?? "top",
|
|
86754
86740
|
lineHeight: schema.lineHeight ?? 1,
|
|
86755
86741
|
characterSpacing: schema.characterSpacing ?? 0,
|
|
86756
86742
|
fontSize,
|
|
86757
|
-
color
|
|
86758
|
-
colorAlpha
|
|
86743
|
+
color
|
|
86759
86744
|
};
|
|
86760
86745
|
};
|
|
86761
86746
|
var pdfRender = async (arg) => {
|
|
@@ -86797,7 +86782,7 @@ var pdfRender = async (arg) => {
|
|
|
86797
86782
|
_cache
|
|
86798
86783
|
});
|
|
86799
86784
|
const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
|
|
86800
|
-
const { fontSize, color,
|
|
86785
|
+
const { fontSize, color, alignment, verticalAlignment, lineHeight, characterSpacing } = getFontProp({
|
|
86801
86786
|
value: enableInlineMarkdown ? stripInlineMarkdown(value) : value,
|
|
86802
86787
|
fontKitFont,
|
|
86803
86788
|
schema,
|
|
@@ -86810,7 +86795,6 @@ var pdfRender = async (arg) => {
|
|
|
86810
86795
|
_cache
|
|
86811
86796
|
}) : void 0
|
|
86812
86797
|
});
|
|
86813
|
-
const textOpacity = applyAlphaToOpacity(opacity, colorAlpha);
|
|
86814
86798
|
if (enableInlineMarkdown) {
|
|
86815
86799
|
await renderInlineMarkdownText({
|
|
86816
86800
|
value,
|
|
@@ -86840,8 +86824,7 @@ var pdfRender = async (arg) => {
|
|
|
86840
86824
|
height: contentHeight,
|
|
86841
86825
|
pivotPoint,
|
|
86842
86826
|
rotate,
|
|
86843
|
-
opacity
|
|
86844
|
-
colorAlpha
|
|
86827
|
+
opacity
|
|
86845
86828
|
});
|
|
86846
86829
|
return;
|
|
86847
86830
|
}
|
|
@@ -86893,7 +86876,7 @@ var pdfRender = async (arg) => {
|
|
|
86893
86876
|
}, pivotPoint, rotate.angle),
|
|
86894
86877
|
thickness: 1 / 12 * fontSize,
|
|
86895
86878
|
color,
|
|
86896
|
-
opacity
|
|
86879
|
+
opacity
|
|
86897
86880
|
});
|
|
86898
86881
|
}
|
|
86899
86882
|
if (schema.underline && textWidth > 0) {
|
|
@@ -86910,7 +86893,7 @@ var pdfRender = async (arg) => {
|
|
|
86910
86893
|
}, pivotPoint, rotate.angle),
|
|
86911
86894
|
thickness: 1 / 12 * fontSize,
|
|
86912
86895
|
color,
|
|
86913
|
-
opacity
|
|
86896
|
+
opacity
|
|
86914
86897
|
});
|
|
86915
86898
|
}
|
|
86916
86899
|
if (rotate.angle !== 0) {
|
|
@@ -86930,7 +86913,7 @@ var pdfRender = async (arg) => {
|
|
|
86930
86913
|
color,
|
|
86931
86914
|
lineHeight: lineHeight * fontSize,
|
|
86932
86915
|
font: pdfFontValue,
|
|
86933
|
-
opacity
|
|
86916
|
+
opacity
|
|
86934
86917
|
});
|
|
86935
86918
|
});
|
|
86936
86919
|
};
|
|
@@ -86954,24 +86937,21 @@ var drawTextBoxDecoration = (arg) => {
|
|
|
86954
86937
|
height: rect.height,
|
|
86955
86938
|
rotate,
|
|
86956
86939
|
color: rect.color,
|
|
86957
|
-
opacity
|
|
86940
|
+
opacity
|
|
86958
86941
|
});
|
|
86959
86942
|
};
|
|
86960
86943
|
if (schema.backgroundColor) {
|
|
86961
|
-
const
|
|
86962
|
-
const color = hex2PrintingColor(bgHex, colorType);
|
|
86944
|
+
const color = hex2PrintingColor(schema.backgroundColor, colorType);
|
|
86963
86945
|
if (color) drawRectangle({
|
|
86964
86946
|
x,
|
|
86965
86947
|
y,
|
|
86966
86948
|
width,
|
|
86967
86949
|
height,
|
|
86968
|
-
color
|
|
86969
|
-
alpha
|
|
86950
|
+
color
|
|
86970
86951
|
});
|
|
86971
86952
|
}
|
|
86972
86953
|
if (!schema.borderColor || !hasBoxDimension(schema.borderWidth)) return;
|
|
86973
|
-
const
|
|
86974
|
-
const color = hex2PrintingColor(borderHex, colorType);
|
|
86954
|
+
const color = hex2PrintingColor(schema.borderColor, colorType);
|
|
86975
86955
|
if (!color) return;
|
|
86976
86956
|
const top = mm2pt(borderWidth.top);
|
|
86977
86957
|
const right = mm2pt(borderWidth.right);
|
|
@@ -86982,32 +86962,28 @@ var drawTextBoxDecoration = (arg) => {
|
|
|
86982
86962
|
y: y + height - top,
|
|
86983
86963
|
width,
|
|
86984
86964
|
height: top,
|
|
86985
|
-
color
|
|
86986
|
-
alpha
|
|
86965
|
+
color
|
|
86987
86966
|
});
|
|
86988
86967
|
drawRectangle({
|
|
86989
86968
|
x: x + width - right,
|
|
86990
86969
|
y,
|
|
86991
86970
|
width: right,
|
|
86992
86971
|
height,
|
|
86993
|
-
color
|
|
86994
|
-
alpha
|
|
86972
|
+
color
|
|
86995
86973
|
});
|
|
86996
86974
|
drawRectangle({
|
|
86997
86975
|
x,
|
|
86998
86976
|
y,
|
|
86999
86977
|
width,
|
|
87000
86978
|
height: bottom,
|
|
87001
|
-
color
|
|
87002
|
-
alpha
|
|
86979
|
+
color
|
|
87003
86980
|
});
|
|
87004
86981
|
drawRectangle({
|
|
87005
86982
|
x,
|
|
87006
86983
|
y,
|
|
87007
86984
|
width: left,
|
|
87008
86985
|
height,
|
|
87009
|
-
color
|
|
87010
|
-
alpha
|
|
86986
|
+
color
|
|
87011
86987
|
});
|
|
87012
86988
|
};
|
|
87013
86989
|
var TextStrikethroughIcon = createSvgStr(Strikethrough);
|