react-diff-viewer-continued 4.2.0 → 4.2.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/.claude/settings.local.json +2 -1
- package/.github/workflows/release.yml +2 -2
- package/CHANGELOG.md +17 -0
- package/lib/cjs/src/compute-lines.d.ts +4 -4
- package/lib/cjs/src/compute-lines.js +18 -23
- package/lib/cjs/src/index.d.ts +13 -4
- package/lib/cjs/src/index.js +112 -96
- package/lib/cjs/src/styles.d.ts +36 -32
- package/lib/cjs/src/styles.js +3 -7
- package/lib/cjs/src/workerBundle.d.ts +1 -1
- package/lib/cjs/src/workerBundle.js +1 -1
- package/lib/esm/src/compute-lines.js +18 -23
- package/lib/esm/src/index.js +99 -78
- package/lib/esm/src/styles.js +4 -8
- package/lib/esm/src/workerBundle.js +1 -1
- package/package.json +14 -14
- package/tsconfig.json +3 -4
package/lib/esm/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function applyDiffToHighlightedHtml(html, diffArray, styles) {
|
|
|
17
17
|
for (const diff of diffArray) {
|
|
18
18
|
const value = typeof diff.value === "string" ? diff.value : "";
|
|
19
19
|
if (value.length > 0) {
|
|
20
|
-
ranges.push({ start: pos, end: pos + value.length, type: diff.type });
|
|
20
|
+
ranges.push({ start: pos, end: pos + value.length, type: diff.type ?? DiffType.DEFAULT });
|
|
21
21
|
pos += value.length;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -51,6 +51,7 @@ function applyDiffToHighlightedHtml(html, diffArray, styles) {
|
|
|
51
51
|
.replace(/&/g, "&")
|
|
52
52
|
.replace(/"/g, '"')
|
|
53
53
|
.replace(/'/g, "'")
|
|
54
|
+
.replace(/'/g, "'")
|
|
54
55
|
.replace(/ /g, "\u00A0");
|
|
55
56
|
}
|
|
56
57
|
// Helper to get the wrapper tag for a diff type
|
|
@@ -156,6 +157,8 @@ class DiffViewer extends React.Component {
|
|
|
156
157
|
charMeasureRef = React.createRef();
|
|
157
158
|
stickyHeaderRef = React.createRef();
|
|
158
159
|
resizeObserver = null;
|
|
160
|
+
scrollDebounceTimer = null;
|
|
161
|
+
lastRenderedRange = { start: 0, end: Infinity };
|
|
159
162
|
static defaultProps = {
|
|
160
163
|
oldValue: "",
|
|
161
164
|
newValue: "",
|
|
@@ -183,6 +186,7 @@ class DiffViewer extends React.Component {
|
|
|
183
186
|
contentColumnWidth: null,
|
|
184
187
|
charWidth: null,
|
|
185
188
|
cumulativeOffsets: null,
|
|
189
|
+
isScrolling: false,
|
|
186
190
|
};
|
|
187
191
|
}
|
|
188
192
|
/**
|
|
@@ -190,27 +194,20 @@ class DiffViewer extends React.Component {
|
|
|
190
194
|
* This is used when word diff was deferred during initial computation.
|
|
191
195
|
*/
|
|
192
196
|
getWordDiffValues = (left, right, lineIndex) => {
|
|
193
|
-
// Handle empty left/right
|
|
194
197
|
if (!left || !right) {
|
|
195
198
|
return { leftValue: left?.value, rightValue: right?.value };
|
|
196
199
|
}
|
|
197
|
-
// If no raw values, word diff was already computed or disabled
|
|
198
|
-
// Use explicit undefined check since empty string is a valid raw value
|
|
199
200
|
if (left.rawValue === undefined || right.rawValue === undefined) {
|
|
200
201
|
return { leftValue: left.value, rightValue: right.value };
|
|
201
202
|
}
|
|
202
|
-
// Check cache
|
|
203
203
|
const cacheKey = `${lineIndex}-${left.rawValue}-${right.rawValue}`;
|
|
204
204
|
let cached = this.wordDiffCache.get(cacheKey);
|
|
205
205
|
if (!cached) {
|
|
206
|
-
// Compute word diff on-demand
|
|
207
|
-
// Use CHARS method for on-demand computation since rawValue is always a string
|
|
208
|
-
// (JSON/YAML methods only work with objects, not the string lines we have here)
|
|
209
206
|
const compareMethod = (this.props.compareMethod === DiffMethod.JSON || this.props.compareMethod === DiffMethod.YAML)
|
|
210
207
|
? DiffMethod.CHARS
|
|
211
208
|
: this.props.compareMethod;
|
|
212
209
|
const computed = computeDiff(left.rawValue, right.rawValue, compareMethod);
|
|
213
|
-
cached = { left: computed.left, right: computed.right };
|
|
210
|
+
cached = { left: computed.left ?? [], right: computed.right ?? [] };
|
|
214
211
|
this.wordDiffCache.set(cacheKey, cached);
|
|
215
212
|
}
|
|
216
213
|
return { leftValue: cached.left, rightValue: cached.right };
|
|
@@ -355,7 +352,7 @@ class DiffViewer extends React.Component {
|
|
|
355
352
|
const { lineInformation, lineBlocks, blocks } = this.state.computedDiffResult[cacheKey] ?? {};
|
|
356
353
|
if (!lineInformation)
|
|
357
354
|
return;
|
|
358
|
-
const offsets = this.buildCumulativeOffsets(lineInformation, lineBlocks, blocks, this.state.expandedBlocks, this.props.showDiffOnly, charWidth, columnWidth, this.props.splitView);
|
|
355
|
+
const offsets = this.buildCumulativeOffsets(lineInformation, lineBlocks, blocks, this.state.expandedBlocks, this.props.showDiffOnly ?? true, charWidth, columnWidth, this.props.splitView ?? true);
|
|
359
356
|
this.setState({ cumulativeOffsets: offsets, contentColumnWidth: columnWidth, charWidth }, () => {
|
|
360
357
|
// Force a scroll position update to recalculate visible rows with new offsets
|
|
361
358
|
this.onScroll();
|
|
@@ -442,7 +439,6 @@ class DiffViewer extends React.Component {
|
|
|
442
439
|
content = wordDiff.value;
|
|
443
440
|
}
|
|
444
441
|
else {
|
|
445
|
-
// If wordDiff.value is DiffInformation[], we don't handle it. See c0c99f5712.
|
|
446
442
|
content = undefined;
|
|
447
443
|
}
|
|
448
444
|
return wordDiff.type === DiffType.ADDED ? (_jsx("ins", { className: cn(this.styles.wordDiff, {
|
|
@@ -468,8 +464,9 @@ class DiffViewer extends React.Component {
|
|
|
468
464
|
renderLine = (lineNumber, type, prefix, value, additionalLineNumber, additionalPrefix) => {
|
|
469
465
|
const lineNumberTemplate = `${prefix}-${lineNumber}`;
|
|
470
466
|
const additionalLineNumberTemplate = `${additionalPrefix}-${additionalLineNumber}`;
|
|
471
|
-
const
|
|
472
|
-
|
|
467
|
+
const highlightLines = this.props.highlightLines ?? [];
|
|
468
|
+
const highlightLine = highlightLines.includes(lineNumberTemplate) ||
|
|
469
|
+
highlightLines.includes(additionalLineNumberTemplate);
|
|
473
470
|
const added = type === DiffType.ADDED;
|
|
474
471
|
const removed = type === DiffType.REMOVED;
|
|
475
472
|
const changed = type === DiffType.CHANGED;
|
|
@@ -478,7 +475,7 @@ class DiffViewer extends React.Component {
|
|
|
478
475
|
if (hasWordDiff) {
|
|
479
476
|
content = this.renderWordDiff(value, this.props.renderContent);
|
|
480
477
|
}
|
|
481
|
-
else if (this.props.renderContent) {
|
|
478
|
+
else if (this.props.renderContent && typeof value === "string") {
|
|
482
479
|
content = this.props.renderContent(value);
|
|
483
480
|
}
|
|
484
481
|
else {
|
|
@@ -506,11 +503,11 @@ class DiffViewer extends React.Component {
|
|
|
506
503
|
[this.styles.highlightedGutter]: highlightLine,
|
|
507
504
|
}), children: _jsx("pre", { className: this.styles.lineNumber, children: additionalLineNumber }) })), this.props.renderGutter
|
|
508
505
|
? this.props.renderGutter({
|
|
509
|
-
lineNumber,
|
|
510
|
-
type,
|
|
506
|
+
lineNumber: lineNumber ?? 0,
|
|
507
|
+
type: type ?? DiffType.DEFAULT,
|
|
511
508
|
prefix,
|
|
512
|
-
value,
|
|
513
|
-
additionalLineNumber,
|
|
509
|
+
value: value ?? "",
|
|
510
|
+
additionalLineNumber: additionalLineNumber ?? undefined,
|
|
514
511
|
additionalPrefix,
|
|
515
512
|
styles: this.styles,
|
|
516
513
|
})
|
|
@@ -529,10 +526,17 @@ class DiffViewer extends React.Component {
|
|
|
529
526
|
left: prefix === LineNumberPrefix.LEFT,
|
|
530
527
|
right: prefix === LineNumberPrefix.RIGHT,
|
|
531
528
|
}), onMouseDown: () => {
|
|
532
|
-
const
|
|
533
|
-
for (let i = 0; i <
|
|
534
|
-
|
|
535
|
-
|
|
529
|
+
const rightElements = document.getElementsByClassName("right");
|
|
530
|
+
for (let i = 0; i < rightElements.length; i++) {
|
|
531
|
+
rightElements[i]?.classList.remove(this.styles.noSelect);
|
|
532
|
+
}
|
|
533
|
+
const leftElements = document.getElementsByClassName("left");
|
|
534
|
+
for (let i = 0; i < leftElements.length; i++) {
|
|
535
|
+
leftElements[i]?.classList.remove(this.styles.noSelect);
|
|
536
|
+
}
|
|
537
|
+
const opposite = document.getElementsByClassName(prefix === LineNumberPrefix.LEFT ? "right" : "left");
|
|
538
|
+
for (let i = 0; i < opposite.length; i++) {
|
|
539
|
+
opposite[i]?.classList.add(this.styles.noSelect);
|
|
536
540
|
}
|
|
537
541
|
}, title: added && !hasWordDiff
|
|
538
542
|
? "Added line"
|
|
@@ -654,10 +658,9 @@ class DiffViewer extends React.Component {
|
|
|
654
658
|
!!this.props.infiniteLoading &&
|
|
655
659
|
containerHeightPx > 0 &&
|
|
656
660
|
containerHeightPx < 2000;
|
|
657
|
-
const { lineInformation, diffLines } = await computeLineInformationWorker(oldValue, newValue, disableWordDiff, compareMethod, linesOffset, this.props.alwaysShowLines, shouldDeferWordDiff);
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
: Math.round(this.props.extraLinesSurroundingDiff);
|
|
661
|
+
const { lineInformation, diffLines } = await computeLineInformationWorker(oldValue, newValue, disableWordDiff, compareMethod, linesOffset, this.props.alwaysShowLines, shouldDeferWordDiff, this.props.disableWorker);
|
|
662
|
+
const rawExtraLines = this.props.extraLinesSurroundingDiff ?? 3;
|
|
663
|
+
const extraLines = rawExtraLines < 0 ? 0 : Math.round(rawExtraLines);
|
|
661
664
|
const { lineBlocks, blocks } = computeHiddenBlocks(lineInformation, diffLines, extraLines);
|
|
662
665
|
this.state.computedDiffResult[cacheKey] = { lineInformation, lineBlocks, blocks };
|
|
663
666
|
this.setState((prev) => ({
|
|
@@ -690,9 +693,26 @@ class DiffViewer extends React.Component {
|
|
|
690
693
|
const newStartRow = cumulativeOffsets
|
|
691
694
|
? this.findLineAtOffset(contentScrollTop, cumulativeOffsets)
|
|
692
695
|
: Math.floor(contentScrollTop / DiffViewer.ESTIMATED_ROW_HEIGHT);
|
|
693
|
-
|
|
696
|
+
const viewportRows = Math.ceil(container.clientHeight / DiffViewer.ESTIMATED_ROW_HEIGHT);
|
|
697
|
+
const newEndRow = newStartRow + viewportRows;
|
|
698
|
+
const leavesRenderedRange = newStartRow < this.lastRenderedRange.start || newEndRow > this.lastRenderedRange.end;
|
|
699
|
+
if (this.scrollDebounceTimer) {
|
|
700
|
+
clearTimeout(this.scrollDebounceTimer);
|
|
701
|
+
}
|
|
702
|
+
const stateUpdate = {};
|
|
694
703
|
if (newStartRow !== this.state.visibleStartRow) {
|
|
695
|
-
|
|
704
|
+
stateUpdate.visibleStartRow = newStartRow;
|
|
705
|
+
}
|
|
706
|
+
if (leavesRenderedRange && !this.state.isScrolling) {
|
|
707
|
+
stateUpdate.isScrolling = true;
|
|
708
|
+
}
|
|
709
|
+
if (Object.keys(stateUpdate).length > 0) {
|
|
710
|
+
this.setState(stateUpdate);
|
|
711
|
+
}
|
|
712
|
+
if (this.state.isScrolling || leavesRenderedRange) {
|
|
713
|
+
this.scrollDebounceTimer = setTimeout(() => {
|
|
714
|
+
this.setState({ isScrolling: false });
|
|
715
|
+
}, 150);
|
|
696
716
|
}
|
|
697
717
|
};
|
|
698
718
|
/**
|
|
@@ -706,7 +726,7 @@ class DiffViewer extends React.Component {
|
|
|
706
726
|
// Calculate visible range for virtualization
|
|
707
727
|
let visibleRowStart = 0;
|
|
708
728
|
let visibleRowEnd = Infinity;
|
|
709
|
-
const buffer =
|
|
729
|
+
const buffer = infiniteLoading?.overscan ?? 20;
|
|
710
730
|
if (infiniteLoading && scrollableContainerRef.current) {
|
|
711
731
|
const container = scrollableContainerRef.current;
|
|
712
732
|
// Account for sticky header height in scroll calculations
|
|
@@ -804,7 +824,7 @@ class DiffViewer extends React.Component {
|
|
|
804
824
|
const lastLineOfBlock = blocks[blockIndex].endLine === lineIndex;
|
|
805
825
|
if (!expandedBlocks.includes(blockIndex) &&
|
|
806
826
|
lastLineOfBlock) {
|
|
807
|
-
diffNodes.push(_jsx(React.Fragment, { children: this.renderSkippedLineIndicator(blocks[blockIndex].lines, blockIndex, line.left.lineNumber, line.right.lineNumber) }, lineIndex));
|
|
827
|
+
diffNodes.push(_jsx(React.Fragment, { children: this.renderSkippedLineIndicator(blocks[blockIndex].lines, blockIndex, line.left.lineNumber ?? 0, line.right.lineNumber ?? 0) }, lineIndex));
|
|
808
828
|
continue;
|
|
809
829
|
}
|
|
810
830
|
if (!expandedBlocks.includes(blockIndex)) {
|
|
@@ -824,6 +844,7 @@ class DiffViewer extends React.Component {
|
|
|
824
844
|
const bottomPadding = cumulativeOffsets && lastRenderedRowIndex >= 0
|
|
825
845
|
? totalContentHeight - (cumulativeOffsets[lastRenderedRowIndex + 1] || totalContentHeight)
|
|
826
846
|
: 0;
|
|
847
|
+
this.lastRenderedRange = { start: visibleRowStart, end: visibleRowEnd };
|
|
827
848
|
return {
|
|
828
849
|
diffNodes,
|
|
829
850
|
blocks,
|
|
@@ -833,7 +854,6 @@ class DiffViewer extends React.Component {
|
|
|
833
854
|
bottomPadding,
|
|
834
855
|
totalContentHeight,
|
|
835
856
|
renderedCount: diffNodes.length,
|
|
836
|
-
// Debug info
|
|
837
857
|
debug: {
|
|
838
858
|
visibleRowStart,
|
|
839
859
|
visibleRowEnd,
|
|
@@ -890,6 +910,9 @@ class DiffViewer extends React.Component {
|
|
|
890
910
|
}
|
|
891
911
|
componentWillUnmount() {
|
|
892
912
|
this.resizeObserver?.disconnect();
|
|
913
|
+
if (this.scrollDebounceTimer) {
|
|
914
|
+
clearTimeout(this.scrollDebounceTimer);
|
|
915
|
+
}
|
|
893
916
|
}
|
|
894
917
|
render = () => {
|
|
895
918
|
const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, compareMethod, hideLineNumbers, nonce, } = this.props;
|
|
@@ -899,7 +922,7 @@ class DiffViewer extends React.Component {
|
|
|
899
922
|
throw Error('"oldValue" and "newValue" should be strings');
|
|
900
923
|
}
|
|
901
924
|
}
|
|
902
|
-
this.styles = this.computeStyles(this.props.styles, useDarkTheme, nonce);
|
|
925
|
+
this.styles = this.computeStyles(this.props.styles ?? {}, useDarkTheme ?? false, nonce ?? "");
|
|
903
926
|
const nodes = this.renderDiff();
|
|
904
927
|
let colSpanOnSplitView = 3;
|
|
905
928
|
let colSpanOnInlineView = 4;
|
|
@@ -951,54 +974,52 @@ class DiffViewer extends React.Component {
|
|
|
951
974
|
const tableElement = (_jsxs("table", { className: cn(this.styles.diffContainer, {
|
|
952
975
|
[this.styles.splitView]: splitView,
|
|
953
976
|
[this.styles.noWrap]: shouldNoWrap,
|
|
954
|
-
}), onMouseUp: () => {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
const element = elements.item(i);
|
|
958
|
-
element.classList.remove(this.styles.noSelect);
|
|
959
|
-
}
|
|
960
|
-
const elementsLeft = document.getElementsByClassName("left");
|
|
961
|
-
for (let i = 0; i < elementsLeft.length; i++) {
|
|
962
|
-
const element = elementsLeft.item(i);
|
|
963
|
-
element.classList.remove(this.styles.noSelect);
|
|
964
|
-
}
|
|
965
|
-
}, children: [_jsxs("colgroup", { children: [!this.props.hideLineNumbers && _jsx("col", { width: "50px" }), !splitView && !this.props.hideLineNumbers && _jsx("col", { width: "50px" }), this.props.renderGutter && _jsx("col", { width: "50px" }), _jsx("col", { width: "28px" }), _jsx("col", { width: "auto" }), splitView && (_jsxs(_Fragment, { children: [!this.props.hideLineNumbers && _jsx("col", { width: "50px" }), this.props.renderGutter && _jsx("col", { width: "50px" }), _jsx("col", { width: "28px" }), _jsx("col", { width: "auto" })] }))] }), _jsx("tbody", { children: nodes.diffNodes })] }));
|
|
966
|
-
return (_jsxs("div", { style: { ...scrollDivStyle, position: 'relative' }, onScroll: this.onScroll, ref: this.state.scrollableContainerRef, children: [(!this.props.hideSummary || leftTitle || rightTitle) && (_jsxs("div", { ref: this.stickyHeaderRef, className: this.styles.stickyHeader, children: [!this.props.hideSummary && (_jsxs("div", { className: this.styles.summary, role: "banner", children: [_jsx("button", { type: "button", className: this.styles.allExpandButton, onClick: () => {
|
|
967
|
-
this.setState({
|
|
968
|
-
expandedBlocks: allExpanded
|
|
969
|
-
? []
|
|
970
|
-
: nodes.blocks.map((b) => b.index),
|
|
971
|
-
}, () => this.recalculateOffsets());
|
|
972
|
-
}, children: allExpanded ? _jsx(Fold, {}) : _jsx(Expand, {}) }), " ", totalChanges, _jsx("div", { style: { display: "flex", gap: "1px" }, children: blocks }), this.props.summary ? _jsx("span", { children: this.props.summary }) : null] })), (leftTitle || rightTitle) && (_jsxs("div", { className: this.styles.columnHeaders, children: [_jsx("div", { className: this.styles.titleBlock, children: leftTitle ? (_jsx("pre", { className: this.styles.contentText, children: leftTitle })) : null }), splitView && (_jsx("div", { className: this.styles.titleBlock, children: rightTitle ? (_jsx("pre", { className: this.styles.contentText, children: rightTitle })) : null }))] }))] })), this.state.isLoading && LoadingElement && _jsx(LoadingElement, {}), this.props.infiniteLoading ? (_jsx("div", { style: {
|
|
973
|
-
height: nodes.totalContentHeight,
|
|
974
|
-
position: 'relative',
|
|
975
|
-
}, children: _jsx("div", { style: {
|
|
976
|
-
position: 'absolute',
|
|
977
|
-
top: nodes.topPadding,
|
|
978
|
-
left: 0,
|
|
979
|
-
right: 0,
|
|
980
|
-
}, children: tableElement }) })) : (tableElement), _jsx("span", { ref: this.charMeasureRef, style: {
|
|
977
|
+
}), onMouseUp: () => { }, children: [_jsxs("colgroup", { children: [!this.props.hideLineNumbers && _jsx("col", { width: "50px" }), !splitView && !this.props.hideLineNumbers && _jsx("col", { width: "50px" }), this.props.renderGutter && _jsx("col", { width: "50px" }), _jsx("col", { width: "28px" }), _jsx("col", { width: "auto" }), splitView && (_jsxs(_Fragment, { children: [!this.props.hideLineNumbers && _jsx("col", { width: "50px" }), this.props.renderGutter && _jsx("col", { width: "50px" }), _jsx("col", { width: "28px" }), _jsx("col", { width: "auto" })] }))] }), _jsx("tbody", { children: nodes.diffNodes })] }));
|
|
978
|
+
const showLoadingOverlay = (this.state.isLoading || this.state.isScrolling) && !!LoadingElement;
|
|
979
|
+
return (_jsxs("div", { style: { position: 'relative' }, children: [showLoadingOverlay && (_jsx("div", { style: {
|
|
981
980
|
position: 'absolute',
|
|
982
981
|
top: 0,
|
|
983
|
-
left:
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
982
|
+
left: 0,
|
|
983
|
+
right: 0,
|
|
984
|
+
bottom: 0,
|
|
985
|
+
zIndex: 3,
|
|
986
|
+
}, children: _jsx(LoadingElement, {}) })), _jsxs("div", { style: { ...scrollDivStyle, position: 'relative' }, onScroll: this.onScroll, ref: this.state.scrollableContainerRef, children: [(!this.props.hideSummary || leftTitle || rightTitle) && (_jsxs("div", { ref: this.stickyHeaderRef, className: this.styles.stickyHeader, children: [!this.props.hideSummary && (_jsxs("div", { className: this.styles.summary, role: "banner", children: [_jsx("button", { type: "button", className: this.styles.allExpandButton, onClick: () => {
|
|
987
|
+
this.setState({
|
|
988
|
+
expandedBlocks: allExpanded
|
|
989
|
+
? []
|
|
990
|
+
: nodes.blocks.map((b) => b.index),
|
|
991
|
+
}, () => this.recalculateOffsets());
|
|
992
|
+
}, children: allExpanded ? _jsx(Fold, {}) : _jsx(Expand, {}) }), " ", totalChanges, _jsx("div", { style: { display: "flex", gap: "1px" }, children: blocks }), this.props.summary ? _jsx("span", { children: this.props.summary }) : null] })), (leftTitle || rightTitle) && (_jsxs("div", { className: this.styles.columnHeaders, children: [_jsx("div", { className: this.styles.titleBlock, children: leftTitle ? (_jsx("pre", { className: this.styles.contentText, children: leftTitle })) : null }), splitView && (_jsx("div", { className: this.styles.titleBlock, children: rightTitle ? (_jsx("pre", { className: this.styles.contentText, children: rightTitle })) : null }))] }))] })), this.props.infiniteLoading ? (_jsx("div", { style: {
|
|
993
|
+
height: nodes.totalContentHeight,
|
|
994
|
+
position: 'relative',
|
|
995
|
+
}, children: _jsx("div", { style: {
|
|
996
|
+
position: 'absolute',
|
|
997
|
+
top: nodes.topPadding,
|
|
998
|
+
left: 0,
|
|
999
|
+
right: 0,
|
|
1000
|
+
visibility: this.state.isScrolling ? 'hidden' : 'visible',
|
|
1001
|
+
}, children: tableElement }) })) : (tableElement), _jsx("span", { ref: this.charMeasureRef, style: {
|
|
1002
|
+
position: 'absolute',
|
|
1003
|
+
top: 0,
|
|
1004
|
+
left: '-9999px',
|
|
1005
|
+
visibility: 'hidden',
|
|
1006
|
+
whiteSpace: 'pre',
|
|
1007
|
+
fontFamily: 'monospace',
|
|
1008
|
+
fontSize: 12,
|
|
1009
|
+
}, "aria-hidden": "true", children: "M" }), this.props.infiniteLoading && this.props.showDebugInfo && (_jsxs("div", { style: {
|
|
1010
|
+
position: 'fixed',
|
|
1011
|
+
top: 10,
|
|
1012
|
+
right: 10,
|
|
1013
|
+
background: 'rgba(0,0,0,0.85)',
|
|
1014
|
+
color: '#0f0',
|
|
1015
|
+
padding: '10px',
|
|
1016
|
+
fontFamily: 'monospace',
|
|
1017
|
+
fontSize: '11px',
|
|
1018
|
+
zIndex: 9999,
|
|
1019
|
+
borderRadius: '4px',
|
|
1020
|
+
maxWidth: '300px',
|
|
1021
|
+
lineHeight: 1.4,
|
|
1022
|
+
}, children: [_jsx("div", { style: { fontWeight: 'bold', marginBottom: '5px', color: '#fff' }, children: "Debug Info" }), _jsxs("div", { children: ["scrollTop: ", nodes.debug.scrollTop] }), _jsxs("div", { children: ["headerHeight: ", nodes.debug.headerHeight] }), _jsxs("div", { children: ["contentScrollTop: ", nodes.debug.contentScrollTop] }), _jsxs("div", { children: ["clientHeight: ", nodes.debug.clientHeight] }), _jsxs("div", { style: { marginTop: '5px', borderTop: '1px solid #444', paddingTop: '5px' }, children: [_jsxs("div", { children: ["visibleRowStart: ", nodes.debug.visibleRowStart] }), _jsxs("div", { children: ["visibleRowEnd: ", nodes.debug.visibleRowEnd] })] }), _jsxs("div", { style: { marginTop: '5px', borderTop: '1px solid #444', paddingTop: '5px' }, children: [_jsxs("div", { children: ["totalRows: ", nodes.debug.totalRows] }), _jsxs("div", { children: ["offsetsLength: ", nodes.debug.offsetsLength] }), _jsxs("div", { children: ["renderedCount: ", nodes.debug.renderedCount] })] }), _jsxs("div", { style: { marginTop: '5px', borderTop: '1px solid #444', paddingTop: '5px' }, children: [_jsxs("div", { children: ["topPadding: ", nodes.topPadding.toFixed(0)] }), _jsxs("div", { children: ["bottomPadding: ", nodes.bottomPadding.toFixed(0)] }), _jsxs("div", { children: ["totalContentHeight: ", nodes.totalContentHeight.toFixed(0)] })] }), _jsxs("div", { style: { marginTop: '5px', borderTop: '1px solid #444', paddingTop: '5px', color: '#ff0' }, children: [_jsxs("div", { children: ["cumulativeOffsets: ", this.state.cumulativeOffsets ? 'SET' : 'NULL'] }), _jsxs("div", { children: ["columnWidth: ", this.state.contentColumnWidth?.toFixed(0) ?? 'N/A', "px"] }), _jsxs("div", { children: ["charWidth: ", this.state.charWidth?.toFixed(2) ?? 'N/A', "px"] }), _jsxs("div", { children: ["charsPerRow: ", this.state.contentColumnWidth && this.state.charWidth ? Math.floor(this.state.contentColumnWidth / this.state.charWidth) : 'N/A'] })] }), this.state.cumulativeOffsets && (_jsxs("div", { style: { marginTop: '5px', borderTop: '1px solid #444', paddingTop: '5px', color: '#0ff', fontSize: '10px' }, children: [_jsxs("div", { children: ["offsets[", nodes.debug.visibleRowEnd, "]: ", this.state.cumulativeOffsets[nodes.debug.visibleRowEnd]?.toFixed(0) ?? 'N/A'] }), _jsxs("div", { children: ["offsets[", nodes.debug.totalRows - 1, "]: ", this.state.cumulativeOffsets[nodes.debug.totalRows - 1]?.toFixed(0) ?? 'N/A'] }), _jsxs("div", { children: ["offsets[", nodes.debug.totalRows, "]: ", this.state.cumulativeOffsets[nodes.debug.totalRows]?.toFixed(0) ?? 'N/A'] }), _jsxs("div", { style: { marginTop: '3px' }, children: ["viewportEnd: ", (nodes.debug.contentScrollTop + nodes.debug.clientHeight).toFixed(0)] }), _jsxs("div", { style: { marginTop: '3px', color: '#f0f' }, children: ["scrollHeight: ", this.state.scrollableContainerRef.current?.scrollHeight ?? 'N/A'] }), _jsxs("div", { children: ["maxScrollTop: ", (this.state.scrollableContainerRef.current?.scrollHeight ?? 0) - nodes.debug.clientHeight] })] }))] }))] })] }));
|
|
1002
1023
|
};
|
|
1003
1024
|
}
|
|
1004
1025
|
export default DiffViewer;
|
package/lib/esm/src/styles.js
CHANGED
|
@@ -404,16 +404,12 @@ export default (styleOverride, useDarkTheme = false, nonce = "") => {
|
|
|
404
404
|
};
|
|
405
405
|
const computerOverrideStyles = Object.keys(styles).reduce((acc, key) => ({
|
|
406
406
|
...acc,
|
|
407
|
-
|
|
408
|
-
[key]: css(styles[key]),
|
|
409
|
-
},
|
|
407
|
+
[key]: css(styles[key]),
|
|
410
408
|
}), {});
|
|
411
409
|
return Object.keys(defaultStyles).reduce((acc, key) => ({
|
|
412
410
|
...acc,
|
|
413
|
-
|
|
414
|
-
[key]
|
|
415
|
-
|
|
416
|
-
: defaultStyles[key],
|
|
417
|
-
},
|
|
411
|
+
[key]: computerOverrideStyles[key]
|
|
412
|
+
? cx(defaultStyles[key], computerOverrideStyles[key])
|
|
413
|
+
: defaultStyles[key],
|
|
418
414
|
}), {});
|
|
419
415
|
};
|