@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.js
CHANGED
|
@@ -17145,6 +17145,15 @@ function resolveCanvasLineHeight(style, fallbackFontSize = 12) {
|
|
|
17145
17145
|
}
|
|
17146
17146
|
return fontSizePx * 1.2;
|
|
17147
17147
|
}
|
|
17148
|
+
function resolveCanvasTextMiddleY(verticalAlign, contentTop, contentHeight, lineHeight) {
|
|
17149
|
+
if (verticalAlign === "top") {
|
|
17150
|
+
return contentTop + lineHeight / 2;
|
|
17151
|
+
}
|
|
17152
|
+
if (verticalAlign === "middle") {
|
|
17153
|
+
return contentTop + contentHeight / 2;
|
|
17154
|
+
}
|
|
17155
|
+
return contentTop + contentHeight - lineHeight / 2;
|
|
17156
|
+
}
|
|
17148
17157
|
function resolveCanvasWrapIndex(context, text, maxWidth) {
|
|
17149
17158
|
if (text.length <= 1) {
|
|
17150
17159
|
return text.length;
|
|
@@ -26377,8 +26386,9 @@ function XlsxGrid({
|
|
|
26377
26386
|
const textColor = canvasCellStyle.textColor;
|
|
26378
26387
|
const shouldEllipsizeText = canvasCellStyle.textOverflowEllipsis;
|
|
26379
26388
|
const shouldWrapText = canvasCellStyle.usesWrappedText || rawText.includes("\n");
|
|
26389
|
+
const singleLineHeight = cellData.shrinkToFitFontSizePx ? resolveCanvasLineHeight(cellStyle, cellData.shrinkToFitFontSizePx) : resolveCanvasLineHeight(cellStyle, 12 * zoomFactor);
|
|
26380
26390
|
if (cellData.textRotationDeg && rawText.length > 0) {
|
|
26381
|
-
const textY = contentTop
|
|
26391
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26382
26392
|
const rotationOriginX = contentLeft + contentWidth / 2;
|
|
26383
26393
|
paneContext.save();
|
|
26384
26394
|
paneContext.translate(rotationOriginX, textY);
|
|
@@ -26418,7 +26428,7 @@ function XlsxGrid({
|
|
|
26418
26428
|
});
|
|
26419
26429
|
} else if (spillMaxWidth != null) {
|
|
26420
26430
|
const text = shouldEllipsizeText ? truncateCanvasText(paneContext, rawText, maxTextWidth) : rawText;
|
|
26421
|
-
const textY = contentTop
|
|
26431
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26422
26432
|
deferredSpillTextsByPane[pane].push({
|
|
26423
26433
|
align,
|
|
26424
26434
|
clipHeight: contentHeight + textClipOverscan * 2,
|
|
@@ -26438,7 +26448,7 @@ function XlsxGrid({
|
|
|
26438
26448
|
});
|
|
26439
26449
|
} else {
|
|
26440
26450
|
const text = cellData.shrinkToFit ? rawText : shouldEllipsizeText ? truncateCanvasText(paneContext, rawText, maxTextWidth) : rawText;
|
|
26441
|
-
const textY = contentTop
|
|
26451
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26442
26452
|
paneContext.fillText(text, textX, textY);
|
|
26443
26453
|
drawCanvasTextDecorations(paneContext, {
|
|
26444
26454
|
align,
|
|
@@ -29867,13 +29877,14 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
29867
29877
|
const align = canvasCellStyle.textAlign;
|
|
29868
29878
|
context.textAlign = align;
|
|
29869
29879
|
const textX = align === "right" ? contentLeft + contentWidth : align === "center" ? contentLeft + contentWidth / 2 : contentLeft;
|
|
29870
|
-
const textY = contentTop + contentHeight / 2;
|
|
29871
29880
|
const trailingInset = cellData.conditionalIcon ? 18 : 0;
|
|
29872
29881
|
const maxTextWidth = Math.max(0, contentWidth - trailingInset);
|
|
29882
|
+
const singleLineHeight = resolveCanvasLineHeight(cellData.style, 12);
|
|
29873
29883
|
if (cellData.textRotationDeg) {
|
|
29884
|
+
const alignedTextY = resolveCanvasTextMiddleY(cellData.style.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
29874
29885
|
const rotationOriginX = contentLeft + contentWidth / 2;
|
|
29875
29886
|
context.save();
|
|
29876
|
-
context.translate(rotationOriginX,
|
|
29887
|
+
context.translate(rotationOriginX, alignedTextY);
|
|
29877
29888
|
context.rotate(cellData.textRotationDeg * Math.PI / 180);
|
|
29878
29889
|
context.fillText(
|
|
29879
29890
|
rawText,
|
|
@@ -29896,7 +29907,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
29896
29907
|
});
|
|
29897
29908
|
} else {
|
|
29898
29909
|
const text = canvasCellStyle.textOverflowEllipsis ? truncateCanvasText(context, rawText, maxTextWidth) : rawText;
|
|
29899
|
-
context.fillText(text, textX,
|
|
29910
|
+
context.fillText(text, textX, resolveCanvasTextMiddleY(cellData.style.verticalAlign, contentTop, contentHeight, singleLineHeight));
|
|
29900
29911
|
}
|
|
29901
29912
|
}
|
|
29902
29913
|
if (cellData.conditionalIcon) {
|