@extend-ai/react-xlsx 0.12.0 → 0.12.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.cjs +17 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17179,6 +17179,15 @@ function resolveCanvasLineHeight(style, fallbackFontSize = 12) {
|
|
|
17179
17179
|
}
|
|
17180
17180
|
return fontSizePx * 1.2;
|
|
17181
17181
|
}
|
|
17182
|
+
function resolveCanvasTextMiddleY(verticalAlign, contentTop, contentHeight, lineHeight) {
|
|
17183
|
+
if (verticalAlign === "top") {
|
|
17184
|
+
return contentTop + lineHeight / 2;
|
|
17185
|
+
}
|
|
17186
|
+
if (verticalAlign === "middle") {
|
|
17187
|
+
return contentTop + contentHeight / 2;
|
|
17188
|
+
}
|
|
17189
|
+
return contentTop + contentHeight - lineHeight / 2;
|
|
17190
|
+
}
|
|
17182
17191
|
function resolveCanvasWrapIndex(context, text, maxWidth) {
|
|
17183
17192
|
if (text.length <= 1) {
|
|
17184
17193
|
return text.length;
|
|
@@ -26411,8 +26420,9 @@ function XlsxGrid({
|
|
|
26411
26420
|
const textColor = canvasCellStyle.textColor;
|
|
26412
26421
|
const shouldEllipsizeText = canvasCellStyle.textOverflowEllipsis;
|
|
26413
26422
|
const shouldWrapText = canvasCellStyle.usesWrappedText || rawText.includes("\n");
|
|
26423
|
+
const singleLineHeight = cellData.shrinkToFitFontSizePx ? resolveCanvasLineHeight(cellStyle, cellData.shrinkToFitFontSizePx) : resolveCanvasLineHeight(cellStyle, 12 * zoomFactor);
|
|
26414
26424
|
if (cellData.textRotationDeg && rawText.length > 0) {
|
|
26415
|
-
const textY = contentTop
|
|
26425
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26416
26426
|
const rotationOriginX = contentLeft + contentWidth / 2;
|
|
26417
26427
|
paneContext.save();
|
|
26418
26428
|
paneContext.translate(rotationOriginX, textY);
|
|
@@ -26452,7 +26462,7 @@ function XlsxGrid({
|
|
|
26452
26462
|
});
|
|
26453
26463
|
} else if (spillMaxWidth != null) {
|
|
26454
26464
|
const text = shouldEllipsizeText ? truncateCanvasText(paneContext, rawText, maxTextWidth) : rawText;
|
|
26455
|
-
const textY = contentTop
|
|
26465
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26456
26466
|
deferredSpillTextsByPane[pane].push({
|
|
26457
26467
|
align,
|
|
26458
26468
|
clipHeight: contentHeight + textClipOverscan * 2,
|
|
@@ -26472,7 +26482,7 @@ function XlsxGrid({
|
|
|
26472
26482
|
});
|
|
26473
26483
|
} else {
|
|
26474
26484
|
const text = cellData.shrinkToFit ? rawText : shouldEllipsizeText ? truncateCanvasText(paneContext, rawText, maxTextWidth) : rawText;
|
|
26475
|
-
const textY = contentTop
|
|
26485
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26476
26486
|
paneContext.fillText(text, textX, textY);
|
|
26477
26487
|
drawCanvasTextDecorations(paneContext, {
|
|
26478
26488
|
align,
|
|
@@ -29901,13 +29911,14 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
29901
29911
|
const align = canvasCellStyle.textAlign;
|
|
29902
29912
|
context.textAlign = align;
|
|
29903
29913
|
const textX = align === "right" ? contentLeft + contentWidth : align === "center" ? contentLeft + contentWidth / 2 : contentLeft;
|
|
29904
|
-
const textY = contentTop + contentHeight / 2;
|
|
29905
29914
|
const trailingInset = cellData.conditionalIcon ? 18 : 0;
|
|
29906
29915
|
const maxTextWidth = Math.max(0, contentWidth - trailingInset);
|
|
29916
|
+
const singleLineHeight = resolveCanvasLineHeight(cellData.style, 12);
|
|
29907
29917
|
if (cellData.textRotationDeg) {
|
|
29918
|
+
const alignedTextY = resolveCanvasTextMiddleY(cellData.style.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
29908
29919
|
const rotationOriginX = contentLeft + contentWidth / 2;
|
|
29909
29920
|
context.save();
|
|
29910
|
-
context.translate(rotationOriginX,
|
|
29921
|
+
context.translate(rotationOriginX, alignedTextY);
|
|
29911
29922
|
context.rotate(cellData.textRotationDeg * Math.PI / 180);
|
|
29912
29923
|
context.fillText(
|
|
29913
29924
|
rawText,
|
|
@@ -29930,7 +29941,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
29930
29941
|
});
|
|
29931
29942
|
} else {
|
|
29932
29943
|
const text = canvasCellStyle.textOverflowEllipsis ? truncateCanvasText(context, rawText, maxTextWidth) : rawText;
|
|
29933
|
-
context.fillText(text, textX,
|
|
29944
|
+
context.fillText(text, textX, resolveCanvasTextMiddleY(cellData.style.verticalAlign, contentTop, contentHeight, singleLineHeight));
|
|
29934
29945
|
}
|
|
29935
29946
|
}
|
|
29936
29947
|
if (cellData.conditionalIcon) {
|