@extend-ai/react-xlsx 0.12.0 → 0.12.2
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 +50 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -11
- 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;
|
|
@@ -23678,9 +23687,6 @@ function XlsxGrid({
|
|
|
23678
23687
|
};
|
|
23679
23688
|
}, [activeSheet, asyncViewportRowBatch, getRowsBatchAsync, shouldVirtualizeRows, startBatchTransition, viewportRequest]);
|
|
23680
23689
|
const viewportRowBatch = getRowsBatchAsync ? asyncViewportRowBatch : syncViewportRowBatch;
|
|
23681
|
-
React4.useEffect(() => {
|
|
23682
|
-
cellRenderCacheRef.current.clear();
|
|
23683
|
-
}, [activeSheetIndex, displayColLimit, displayRowLimit, getCellStyle, palette, revision, viewportRowBatch, worksheet, zoomFactor]);
|
|
23684
23690
|
React4.useEffect(() => {
|
|
23685
23691
|
setAsyncViewportRowBatch(null);
|
|
23686
23692
|
}, [activeSheetIndex, revision]);
|
|
@@ -23699,9 +23705,39 @@ function XlsxGrid({
|
|
|
23699
23705
|
() => activeSheet ? chartRangeHighlights.filter((highlight) => highlight.workbookSheetIndex === activeSheet.workbookSheetIndex) : [],
|
|
23700
23706
|
[activeSheet, chartRangeHighlights]
|
|
23701
23707
|
);
|
|
23702
|
-
React4.
|
|
23708
|
+
const cellRenderCacheInvalidationKey = React4.useMemo(
|
|
23709
|
+
() => [
|
|
23710
|
+
activeSheetChartHighlights,
|
|
23711
|
+
activeSheetIndex,
|
|
23712
|
+
displayColLimit,
|
|
23713
|
+
displayRowLimit,
|
|
23714
|
+
getCellStyle,
|
|
23715
|
+
palette,
|
|
23716
|
+
revision,
|
|
23717
|
+
selectedChartId,
|
|
23718
|
+
viewportRowBatch,
|
|
23719
|
+
worksheet,
|
|
23720
|
+
zoomFactor
|
|
23721
|
+
],
|
|
23722
|
+
[
|
|
23723
|
+
activeSheetChartHighlights,
|
|
23724
|
+
activeSheetIndex,
|
|
23725
|
+
displayColLimit,
|
|
23726
|
+
displayRowLimit,
|
|
23727
|
+
getCellStyle,
|
|
23728
|
+
palette,
|
|
23729
|
+
revision,
|
|
23730
|
+
selectedChartId,
|
|
23731
|
+
viewportRowBatch,
|
|
23732
|
+
worksheet,
|
|
23733
|
+
zoomFactor
|
|
23734
|
+
]
|
|
23735
|
+
);
|
|
23736
|
+
const cellRenderCacheInvalidationRef = React4.useRef(null);
|
|
23737
|
+
if (cellRenderCacheInvalidationRef.current !== cellRenderCacheInvalidationKey) {
|
|
23703
23738
|
cellRenderCacheRef.current.clear();
|
|
23704
|
-
|
|
23739
|
+
cellRenderCacheInvalidationRef.current = cellRenderCacheInvalidationKey;
|
|
23740
|
+
}
|
|
23705
23741
|
const getCellData = React4.useCallback((row, col) => {
|
|
23706
23742
|
const cacheKey = `${row}:${col}`;
|
|
23707
23743
|
const cached = cellRenderCacheRef.current.get(cacheKey);
|
|
@@ -23908,6 +23944,7 @@ function XlsxGrid({
|
|
|
23908
23944
|
}, [
|
|
23909
23945
|
activeSheet,
|
|
23910
23946
|
activeSheetChartHighlights,
|
|
23947
|
+
cellRenderCacheInvalidationKey,
|
|
23911
23948
|
colIndexByActual,
|
|
23912
23949
|
colPrefixSums,
|
|
23913
23950
|
displayDefaultColWidth,
|
|
@@ -26411,8 +26448,9 @@ function XlsxGrid({
|
|
|
26411
26448
|
const textColor = canvasCellStyle.textColor;
|
|
26412
26449
|
const shouldEllipsizeText = canvasCellStyle.textOverflowEllipsis;
|
|
26413
26450
|
const shouldWrapText = canvasCellStyle.usesWrappedText || rawText.includes("\n");
|
|
26451
|
+
const singleLineHeight = cellData.shrinkToFitFontSizePx ? resolveCanvasLineHeight(cellStyle, cellData.shrinkToFitFontSizePx) : resolveCanvasLineHeight(cellStyle, 12 * zoomFactor);
|
|
26414
26452
|
if (cellData.textRotationDeg && rawText.length > 0) {
|
|
26415
|
-
const textY = contentTop
|
|
26453
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26416
26454
|
const rotationOriginX = contentLeft + contentWidth / 2;
|
|
26417
26455
|
paneContext.save();
|
|
26418
26456
|
paneContext.translate(rotationOriginX, textY);
|
|
@@ -26452,7 +26490,7 @@ function XlsxGrid({
|
|
|
26452
26490
|
});
|
|
26453
26491
|
} else if (spillMaxWidth != null) {
|
|
26454
26492
|
const text = shouldEllipsizeText ? truncateCanvasText(paneContext, rawText, maxTextWidth) : rawText;
|
|
26455
|
-
const textY = contentTop
|
|
26493
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26456
26494
|
deferredSpillTextsByPane[pane].push({
|
|
26457
26495
|
align,
|
|
26458
26496
|
clipHeight: contentHeight + textClipOverscan * 2,
|
|
@@ -26472,7 +26510,7 @@ function XlsxGrid({
|
|
|
26472
26510
|
});
|
|
26473
26511
|
} else {
|
|
26474
26512
|
const text = cellData.shrinkToFit ? rawText : shouldEllipsizeText ? truncateCanvasText(paneContext, rawText, maxTextWidth) : rawText;
|
|
26475
|
-
const textY = contentTop
|
|
26513
|
+
const textY = resolveCanvasTextMiddleY(cellStyle.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
26476
26514
|
paneContext.fillText(text, textX, textY);
|
|
26477
26515
|
drawCanvasTextDecorations(paneContext, {
|
|
26478
26516
|
align,
|
|
@@ -29901,13 +29939,14 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
29901
29939
|
const align = canvasCellStyle.textAlign;
|
|
29902
29940
|
context.textAlign = align;
|
|
29903
29941
|
const textX = align === "right" ? contentLeft + contentWidth : align === "center" ? contentLeft + contentWidth / 2 : contentLeft;
|
|
29904
|
-
const textY = contentTop + contentHeight / 2;
|
|
29905
29942
|
const trailingInset = cellData.conditionalIcon ? 18 : 0;
|
|
29906
29943
|
const maxTextWidth = Math.max(0, contentWidth - trailingInset);
|
|
29944
|
+
const singleLineHeight = resolveCanvasLineHeight(cellData.style, 12);
|
|
29907
29945
|
if (cellData.textRotationDeg) {
|
|
29946
|
+
const alignedTextY = resolveCanvasTextMiddleY(cellData.style.verticalAlign, contentTop, contentHeight, singleLineHeight);
|
|
29908
29947
|
const rotationOriginX = contentLeft + contentWidth / 2;
|
|
29909
29948
|
context.save();
|
|
29910
|
-
context.translate(rotationOriginX,
|
|
29949
|
+
context.translate(rotationOriginX, alignedTextY);
|
|
29911
29950
|
context.rotate(cellData.textRotationDeg * Math.PI / 180);
|
|
29912
29951
|
context.fillText(
|
|
29913
29952
|
rawText,
|
|
@@ -29930,7 +29969,7 @@ function useXlsxViewerThumbnails(options = {}) {
|
|
|
29930
29969
|
});
|
|
29931
29970
|
} else {
|
|
29932
29971
|
const text = canvasCellStyle.textOverflowEllipsis ? truncateCanvasText(context, rawText, maxTextWidth) : rawText;
|
|
29933
|
-
context.fillText(text, textX,
|
|
29972
|
+
context.fillText(text, textX, resolveCanvasTextMiddleY(cellData.style.verticalAlign, contentTop, contentHeight, singleLineHeight));
|
|
29934
29973
|
}
|
|
29935
29974
|
}
|
|
29936
29975
|
if (cellData.conditionalIcon) {
|