@git-diff-view/react 0.0.7 → 0.0.8
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/cjs/index.development.js +105 -46
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.production.js +105 -46
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/esm/index.mjs +105 -46
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/components/DiffSplitHunkLineNormal.d.ts.map +1 -1
- package/dist/types/components/DiffSplitLineNormal.d.ts.map +1 -1
- package/dist/types/components/DiffSplitViewNormal.d.ts.map +1 -1
- package/dist/types/components/DiffSplitViewWrap.d.ts.map +1 -1
- package/dist/types/components/DiffUnifiedHunkLine.d.ts.map +1 -1
- package/dist/types/components/DiffUnifiedLine.d.ts.map +1 -1
- package/dist/types/components/DiffUnifiedView.d.ts.map +1 -1
- package/dist/types/components/tools.d.ts +1 -0
- package/dist/types/components/tools.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -385,7 +385,7 @@ _File_instances = new WeakSet(), _File_doAST = function _File_doAST() {
|
|
|
385
385
|
}
|
|
386
386
|
};
|
|
387
387
|
const getFile = (raw, lang, fileName) => {
|
|
388
|
-
const key = raw + "--" + "0.0.
|
|
388
|
+
const key = raw + "--" + "0.0.8" + "--" + lang;
|
|
389
389
|
if (map.has(key))
|
|
390
390
|
return map.get(key);
|
|
391
391
|
const file = new File(raw, lang, fileName);
|
|
@@ -1054,7 +1054,7 @@ class DiffFile {
|
|
|
1054
1054
|
_DiffFile_hasBuildUnified.set(this, false);
|
|
1055
1055
|
_DiffFile_updateCount.set(this, 0);
|
|
1056
1056
|
_DiffFile_composeByDiff.set(this, false);
|
|
1057
|
-
this._version_ = "0.0.
|
|
1057
|
+
this._version_ = "0.0.8";
|
|
1058
1058
|
this._oldFileContent = "";
|
|
1059
1059
|
this._oldFileLang = "";
|
|
1060
1060
|
this._newFileContent = "";
|
|
@@ -1062,6 +1062,9 @@ class DiffFile {
|
|
|
1062
1062
|
this.diffLineLength = 0;
|
|
1063
1063
|
this.splitLineLength = 0;
|
|
1064
1064
|
this.unifiedLineLength = 0;
|
|
1065
|
+
this.expandSplitAll = false;
|
|
1066
|
+
this.expandUnifiedAll = false;
|
|
1067
|
+
this.hasCollapsed = false;
|
|
1065
1068
|
_DiffFile_id.set(this, "");
|
|
1066
1069
|
_DiffFile_clonedInstance.set(this, new Map());
|
|
1067
1070
|
this.getSplitLeftLine = (index) => {
|
|
@@ -1200,11 +1203,13 @@ class DiffFile {
|
|
|
1200
1203
|
Object.keys(__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f") || {}).forEach((key) => {
|
|
1201
1204
|
this.onSplitHunkExpand("all", +key, false);
|
|
1202
1205
|
});
|
|
1206
|
+
this.expandSplitAll = true;
|
|
1203
1207
|
}
|
|
1204
1208
|
else {
|
|
1205
1209
|
Object.keys(__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f") || {}).forEach((key) => {
|
|
1206
1210
|
this.onUnifiedHunkExpand("all", +key, false);
|
|
1207
1211
|
});
|
|
1212
|
+
this.expandUnifiedAll = true;
|
|
1208
1213
|
}
|
|
1209
1214
|
this.notifyAll();
|
|
1210
1215
|
};
|
|
@@ -1236,6 +1241,7 @@ class DiffFile {
|
|
|
1236
1241
|
__classPrivateFieldGet(this, _DiffFile_splitHunksLines, "f")[item.splitInfo.endHiddenIndex] = item;
|
|
1237
1242
|
}
|
|
1238
1243
|
});
|
|
1244
|
+
this.expandSplitAll = false;
|
|
1239
1245
|
}
|
|
1240
1246
|
else {
|
|
1241
1247
|
Object.values(__classPrivateFieldGet(this, _DiffFile_unifiedLines, "f") || {}).forEach((item) => {
|
|
@@ -1257,6 +1263,7 @@ class DiffFile {
|
|
|
1257
1263
|
__classPrivateFieldGet(this, _DiffFile_unifiedHunksLines, "f")[item.unifiedInfo.endHiddenIndex] = item;
|
|
1258
1264
|
}
|
|
1259
1265
|
});
|
|
1266
|
+
this.expandUnifiedAll = false;
|
|
1260
1267
|
}
|
|
1261
1268
|
this.notifyAll();
|
|
1262
1269
|
};
|
|
@@ -1283,6 +1290,10 @@ class DiffFile {
|
|
|
1283
1290
|
}
|
|
1284
1291
|
f();
|
|
1285
1292
|
});
|
|
1293
|
+
// support update from outside instance
|
|
1294
|
+
__classPrivateFieldGet(this, _DiffFile_clonedInstance, "f").forEach((_, instance) => {
|
|
1295
|
+
instance.notifyAll(true);
|
|
1296
|
+
});
|
|
1286
1297
|
};
|
|
1287
1298
|
this.getUpdateCount = () => __classPrivateFieldGet(this, _DiffFile_updateCount, "f");
|
|
1288
1299
|
this.getExpandEnabled = () => !__classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
@@ -1303,6 +1314,7 @@ class DiffFile {
|
|
|
1303
1314
|
const splitLineLength = this.splitLineLength;
|
|
1304
1315
|
const unifiedLineLength = this.unifiedLineLength;
|
|
1305
1316
|
const composeByDiff = __classPrivateFieldGet(this, _DiffFile_composeByDiff, "f");
|
|
1317
|
+
const hasCollapsed = this.hasCollapsed;
|
|
1306
1318
|
// split
|
|
1307
1319
|
const splitLeftLines = __classPrivateFieldGet(this, _DiffFile_splitLeftLines, "f");
|
|
1308
1320
|
const splitRightLines = __classPrivateFieldGet(this, _DiffFile_splitRightLines, "f");
|
|
@@ -1332,6 +1344,7 @@ class DiffFile {
|
|
|
1332
1344
|
unifiedLines,
|
|
1333
1345
|
unifiedHunkLines,
|
|
1334
1346
|
composeByDiff,
|
|
1347
|
+
hasCollapsed,
|
|
1335
1348
|
version,
|
|
1336
1349
|
};
|
|
1337
1350
|
};
|
|
@@ -1351,6 +1364,7 @@ class DiffFile {
|
|
|
1351
1364
|
__classPrivateFieldSet(this, _DiffFile_newFilePlaceholderLines, data.newFilePlaceholderLines, "f");
|
|
1352
1365
|
this.splitLineLength = data.splitLineLength;
|
|
1353
1366
|
this.unifiedLineLength = data.unifiedLineLength;
|
|
1367
|
+
this.hasCollapsed = data.hasCollapsed;
|
|
1354
1368
|
__classPrivateFieldSet(this, _DiffFile_splitLeftLines, data.splitLeftLines, "f");
|
|
1355
1369
|
__classPrivateFieldSet(this, _DiffFile_splitRightLines, data.splitRightLines, "f");
|
|
1356
1370
|
__classPrivateFieldSet(this, _DiffFile_splitHunksLines, data.splitHunkLines, "f");
|
|
@@ -1572,6 +1586,9 @@ class DiffFile {
|
|
|
1572
1586
|
if (!prevIsHidden && isHidden) {
|
|
1573
1587
|
hideStart = len;
|
|
1574
1588
|
}
|
|
1589
|
+
if (isHidden) {
|
|
1590
|
+
this.hasCollapsed = true;
|
|
1591
|
+
}
|
|
1575
1592
|
prevIsHidden = isHidden;
|
|
1576
1593
|
if (oldDiffLine && newDiffLine && !oldLineHasChange && !newLineHasChange) {
|
|
1577
1594
|
const current = newDiffLine;
|
|
@@ -1700,6 +1717,9 @@ class DiffFile {
|
|
|
1700
1717
|
if (!prevIsHidden && isHidden) {
|
|
1701
1718
|
hideStart = len;
|
|
1702
1719
|
}
|
|
1720
|
+
if (isHidden) {
|
|
1721
|
+
this.hasCollapsed = true;
|
|
1722
|
+
}
|
|
1703
1723
|
prevIsHidden = isHidden;
|
|
1704
1724
|
if (oldDiffLine && newDiffLine && !oldLineHasChange && !newLineHasChange) {
|
|
1705
1725
|
const current = newDiffLine;
|
|
@@ -2040,7 +2060,7 @@ const getUnifiedContentLine = (diffFile) => {
|
|
|
2040
2060
|
return lines.filter((line) => line.type === exports.DiffFileLineType.content);
|
|
2041
2061
|
};
|
|
2042
2062
|
|
|
2043
|
-
const versions = "0.0.
|
|
2063
|
+
const versions = "0.0.8";
|
|
2044
2064
|
|
|
2045
2065
|
const useUnmount = (cb, deps) => {
|
|
2046
2066
|
const ref = React.useRef(cb);
|
|
@@ -2281,6 +2301,38 @@ const ExpandAll = ({ className }) => {
|
|
|
2281
2301
|
React__namespace.createElement("path", { d: "m8.177.677 2.896 2.896a.25.25 0 0 1-.177.427H8.75v1.25a.75.75 0 0 1-1.5 0V4H5.104a.25.25 0 0 1-.177-.427L7.823.677a.25.25 0 0 1 .354 0ZM7.25 10.75a.75.75 0 0 1 1.5 0V12h2.146a.25.25 0 0 1 .177.427l-2.896 2.896a.25.25 0 0 1-.354 0l-2.896-2.896A.25.25 0 0 1 5.104 12H7.25v-1.25Zm-5-2a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM6 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 6 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5ZM12 8a.75.75 0 0 1-.75.75h-.5a.75.75 0 0 1 0-1.5h.5A.75.75 0 0 1 12 8Zm2.25.75a.75.75 0 0 0 0-1.5h-.5a.75.75 0 0 0 0 1.5h.5Z" })));
|
|
2282
2302
|
};
|
|
2283
2303
|
|
|
2304
|
+
const removeAllSelection = () => {
|
|
2305
|
+
const selection = window.getSelection();
|
|
2306
|
+
for (let i = 0; i < selection.rangeCount; i++) {
|
|
2307
|
+
selection.removeRange(selection.getRangeAt(i));
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
const syncScroll = (left, right) => {
|
|
2311
|
+
const onScroll = function (event) {
|
|
2312
|
+
if (event === null || event.target === null)
|
|
2313
|
+
return;
|
|
2314
|
+
if (event.target === left) {
|
|
2315
|
+
right.scrollTop = left.scrollTop;
|
|
2316
|
+
right.scrollLeft = left.scrollLeft;
|
|
2317
|
+
}
|
|
2318
|
+
else {
|
|
2319
|
+
left.scrollTop = right.scrollTop;
|
|
2320
|
+
left.scrollLeft = right.scrollLeft;
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2323
|
+
if (!left.onscroll) {
|
|
2324
|
+
left.onscroll = onScroll;
|
|
2325
|
+
}
|
|
2326
|
+
if (!right.onscroll) {
|
|
2327
|
+
right.onscroll = onScroll;
|
|
2328
|
+
}
|
|
2329
|
+
return () => {
|
|
2330
|
+
left.onscroll = null;
|
|
2331
|
+
right.onscroll = null;
|
|
2332
|
+
};
|
|
2333
|
+
};
|
|
2334
|
+
const asideWidth = "--diff-aside-width--";
|
|
2335
|
+
|
|
2284
2336
|
const _DiffSplitHunkLine = ({ index, diffFile, side, lineNumber, }) => {
|
|
2285
2337
|
var _a;
|
|
2286
2338
|
const currentHunk = diffFile.getSplitHunkLine(index);
|
|
@@ -2301,6 +2353,9 @@ const _DiffSplitHunkLine = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2301
2353
|
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 p-[1px] w-[1%] min-w-[40px] select-none", style: {
|
|
2302
2354
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2303
2355
|
color: `var(${plainLineNumberColorName})`,
|
|
2356
|
+
width: `var(${asideWidth})`,
|
|
2357
|
+
minWidth: `var(${asideWidth})`,
|
|
2358
|
+
maxWidth: `var(${asideWidth})`,
|
|
2304
2359
|
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onSplitHunkExpand("up", index) },
|
|
2305
2360
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px] relative", title: "Expand Down", "data-title": "Expand Down", onClick: () => {
|
|
2306
2361
|
diffFile.onSplitHunkExpand("down", index);
|
|
@@ -2475,6 +2530,9 @@ const _DiffSplitLine$1 = ({ index, diffFile, lineNumber, side, }) => {
|
|
|
2475
2530
|
React__namespace.createElement("td", { className: `diff-line-${exports.SplitSide[side]}-num sticky left-0 pl-[10px] pr-[10px] text-right align-top select-none w-[1%] min-w-[40px]`, style: {
|
|
2476
2531
|
backgroundColor: lineNumberBG,
|
|
2477
2532
|
color: `var(${plainLineNumberColorName})`,
|
|
2533
|
+
width: `var(${asideWidth})`,
|
|
2534
|
+
minWidth: `var(${asideWidth})`,
|
|
2535
|
+
maxWidth: `var(${asideWidth})`,
|
|
2478
2536
|
} },
|
|
2479
2537
|
hasDiff && enableAddWidget && (React__namespace.createElement(DiffSplitAddWidget, { index: index, lineNumber: currentLine.lineNumber, side: side, diffFile: diffFile, onWidgetClick: onAddWidgetClick, className: "absolute left-[100%] translate-x-[-50%] z-[1]", onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber: lineNumber, side: side }) })),
|
|
2480
2538
|
React__namespace.createElement("span", { "data-line-num": currentLine.lineNumber, style: { opacity: hasChange ? undefined : 0.5 } }, currentLine.lineNumber)),
|
|
@@ -2530,37 +2588,7 @@ const DiffSplitWidgetLine$1 = ({ index, diffFile, side, lineNumber, }) => {
|
|
|
2530
2588
|
return (React__namespace.createElement(_DiffSplitWidgetLine$1, { index: index, diffFile: diffFile, side: side, lineNumber: lineNumber, currentLine: currentLine, setWidget: setWidget, currentWidget: currentWidget }));
|
|
2531
2589
|
};
|
|
2532
2590
|
|
|
2533
|
-
|
|
2534
|
-
const selection = window.getSelection();
|
|
2535
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
2536
|
-
selection.removeRange(selection.getRangeAt(i));
|
|
2537
|
-
}
|
|
2538
|
-
};
|
|
2539
|
-
const syncScroll = (left, right) => {
|
|
2540
|
-
const onScroll = function (event) {
|
|
2541
|
-
if (event === null || event.target === null)
|
|
2542
|
-
return;
|
|
2543
|
-
if (event.target === left) {
|
|
2544
|
-
right.scrollTop = left.scrollTop;
|
|
2545
|
-
right.scrollLeft = left.scrollLeft;
|
|
2546
|
-
}
|
|
2547
|
-
else {
|
|
2548
|
-
left.scrollTop = right.scrollTop;
|
|
2549
|
-
left.scrollLeft = right.scrollLeft;
|
|
2550
|
-
}
|
|
2551
|
-
};
|
|
2552
|
-
if (!left.onscroll) {
|
|
2553
|
-
left.onscroll = onScroll;
|
|
2554
|
-
}
|
|
2555
|
-
if (!right.onscroll) {
|
|
2556
|
-
right.onscroll = onScroll;
|
|
2557
|
-
}
|
|
2558
|
-
return () => {
|
|
2559
|
-
left.onscroll = null;
|
|
2560
|
-
right.onscroll = null;
|
|
2561
|
-
};
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2591
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2564
2592
|
const onMouseDown$1 = (e) => {
|
|
2565
2593
|
const ele = e.target;
|
|
2566
2594
|
// need remove all the selection
|
|
@@ -2569,12 +2597,12 @@ const onMouseDown$1 = (e) => {
|
|
|
2569
2597
|
return;
|
|
2570
2598
|
}
|
|
2571
2599
|
};
|
|
2572
|
-
const DiffSplitViewTable = ({ side, diffFile
|
|
2600
|
+
const DiffSplitViewTable = ({ side, diffFile }) => {
|
|
2573
2601
|
const className = side === exports.SplitSide.new ? "new-diff-table" : "old-diff-table";
|
|
2574
2602
|
const lines = getSplitContentLines(diffFile);
|
|
2575
2603
|
return (React__namespace.createElement("table", { className: className + " border-collapse w-full", "data-mode": exports.SplitSide[side] },
|
|
2576
2604
|
React__namespace.createElement("colgroup", null,
|
|
2577
|
-
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col
|
|
2605
|
+
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-num-col` }),
|
|
2578
2606
|
React__namespace.createElement("col", { className: `diff-table-${exports.SplitSide[side]}-content-col` })),
|
|
2579
2607
|
React__namespace.createElement("thead", { className: "hidden" },
|
|
2580
2608
|
React__namespace.createElement("tr", null,
|
|
@@ -2606,24 +2634,29 @@ const DiffSplitViewNormal = React.memo(({ diffFile }) => {
|
|
|
2606
2634
|
return;
|
|
2607
2635
|
return syncScroll(left, right);
|
|
2608
2636
|
}, []);
|
|
2609
|
-
const
|
|
2637
|
+
const _width = useTextWidth({
|
|
2610
2638
|
text: splitLineLength.toString(),
|
|
2611
2639
|
font: { fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" },
|
|
2612
2640
|
});
|
|
2641
|
+
const width = Math.max(40, _width + 25);
|
|
2613
2642
|
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-wrap w-full flex basis-[50%]" },
|
|
2614
2643
|
React__namespace.createElement("div", { className: "old-diff-table-wrapper overflow-auto w-full scrollbar-hide scrollbar-disable", ref: ref1, style: {
|
|
2644
|
+
// @ts-ignore
|
|
2645
|
+
[asideWidth]: `${Math.round(width)}px`,
|
|
2615
2646
|
overscrollBehaviorX: "none",
|
|
2616
2647
|
fontFamily: "Menlo, Consolas, monospace",
|
|
2617
2648
|
fontSize: "var(--diff-font-size--)",
|
|
2618
2649
|
} },
|
|
2619
|
-
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile
|
|
2650
|
+
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.old, diffFile: diffFile })),
|
|
2620
2651
|
React__namespace.createElement("div", { className: "diff-split-line w-[1.5px] bg-[#ccc]" }),
|
|
2621
2652
|
React__namespace.createElement("div", { className: "new-diff-table-wrapper overflow-auto w-full scrollbar-hide scrollbar-disable", ref: ref2, style: {
|
|
2653
|
+
// @ts-ignore
|
|
2654
|
+
[asideWidth]: `${Math.round(width)}px`,
|
|
2622
2655
|
overscrollBehaviorX: "none",
|
|
2623
2656
|
fontFamily: "Menlo, Consolas, monospace",
|
|
2624
2657
|
fontSize: "var(--diff-font-size--)",
|
|
2625
2658
|
} },
|
|
2626
|
-
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.new, diffFile: diffFile
|
|
2659
|
+
React__namespace.createElement(DiffSplitViewTable, { side: exports.SplitSide.new, diffFile: diffFile }))));
|
|
2627
2660
|
});
|
|
2628
2661
|
DiffSplitViewNormal.displayName = "DiffSplitViewNormal";
|
|
2629
2662
|
|
|
@@ -2838,10 +2871,11 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
2838
2871
|
}
|
|
2839
2872
|
}
|
|
2840
2873
|
}, [setSelectSide]);
|
|
2841
|
-
const
|
|
2874
|
+
const _width = useTextWidth({
|
|
2842
2875
|
text: splitLineLength.toString(),
|
|
2843
2876
|
font: { fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" },
|
|
2844
2877
|
});
|
|
2878
|
+
const width = Math.max(40, _width + 25);
|
|
2845
2879
|
const lines = getSplitContentLines(diffFile);
|
|
2846
2880
|
return (React__namespace.createElement("div", { className: "split-diff-view split-diff-view-normal w-full" },
|
|
2847
2881
|
React__namespace.createElement("div", { className: "diff-table-wrapper w-full", style: {
|
|
@@ -2851,9 +2885,9 @@ const DiffSplitViewWrap = React.memo(({ diffFile }) => {
|
|
|
2851
2885
|
React__namespace.createElement(Style, { useSelector: splitSideInfo, id: `diff-root${diffFile.getId()}` }),
|
|
2852
2886
|
React__namespace.createElement("table", { className: "diff-table border-collapse table-fixed w-full" },
|
|
2853
2887
|
React__namespace.createElement("colgroup", null,
|
|
2854
|
-
React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width)
|
|
2888
|
+
React__namespace.createElement("col", { className: "diff-table-old-num-col", width: Math.round(width) }),
|
|
2855
2889
|
React__namespace.createElement("col", { className: "diff-table-old-content-col" }),
|
|
2856
|
-
React__namespace.createElement("col", { className: "diff-table-new-num-col", width: Math.round(width)
|
|
2890
|
+
React__namespace.createElement("col", { className: "diff-table-new-num-col", width: Math.round(width) }),
|
|
2857
2891
|
React__namespace.createElement("col", { className: "diff-table-new-content-col" })),
|
|
2858
2892
|
React__namespace.createElement("thead", { className: "hidden" },
|
|
2859
2893
|
React__namespace.createElement("tr", null,
|
|
@@ -2956,6 +2990,9 @@ const _DiffUnifiedHunkLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
2956
2990
|
React__namespace.createElement("td", { className: "diff-line-hunk-action sticky left-0 p-[1px] w-[1%] min-w-[100px] select-none", style: {
|
|
2957
2991
|
backgroundColor: `var(${hunkLineNumberBGName})`,
|
|
2958
2992
|
color: `var(${plainLineNumberColorName})`,
|
|
2993
|
+
width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
2994
|
+
maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
2995
|
+
minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
2959
2996
|
} }, couldExpand ? (isFirstLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Up", "data-title": "Expand Up", onClick: () => diffFile.onUnifiedHunkExpand("up", index) },
|
|
2960
2997
|
React__namespace.createElement(ExpandUp, { className: "fill-current" }))) : isLastLine ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand Down", "data-title": "Expand Down", onClick: () => diffFile.onUnifiedHunkExpand("down", index) },
|
|
2961
2998
|
React__namespace.createElement(ExpandDown, { className: "fill-current" }))) : isExpandAll ? (React__namespace.createElement("button", { className: "w-full diff-widget-tooltip hover:bg-blue-300 flex justify-center items-center py-[6px] cursor-pointer rounded-[2px]", title: "Expand All", "data-title": "Expand All", onClick: () => diffFile.onUnifiedHunkExpand("all", index) },
|
|
@@ -2987,6 +3024,9 @@ const DiffUnifiedOldLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber,
|
|
|
2987
3024
|
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 pl-[10px] pr-[10px] text-right select-none w-[1%] min-w-[100px] whitespace-nowrap align-top", style: {
|
|
2988
3025
|
color: `var(${plainLineNumberColorName})`,
|
|
2989
3026
|
backgroundColor: `var(${delLineNumberBGName})`,
|
|
3027
|
+
width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3028
|
+
maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3029
|
+
minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
2990
3030
|
} },
|
|
2991
3031
|
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.old, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
2992
3032
|
React__namespace.createElement("div", { className: "flex" },
|
|
@@ -3001,6 +3041,9 @@ const DiffUnifiedNewLine = ({ index, diffLine, rawLine, syntaxLine, lineNumber,
|
|
|
3001
3041
|
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 pl-[10px] pr-[10px] text-right select-none w-[1%] min-w-[100px] whitespace-nowrap align-top", style: {
|
|
3002
3042
|
color: `var(${plainLineNumberColorName})`,
|
|
3003
3043
|
backgroundColor: `var(${addLineNumberBGName})`,
|
|
3044
|
+
width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3045
|
+
maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3046
|
+
minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3004
3047
|
} },
|
|
3005
3048
|
enableAddWidget && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index - 1, lineNumber: lineNumber, diffFile: diffFile, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
3006
3049
|
React__namespace.createElement("div", { className: "flex" },
|
|
@@ -3044,6 +3087,9 @@ const _DiffUnifiedLine = React.memo(({ index, diffFile, lineNumber }) => {
|
|
|
3044
3087
|
return (React__namespace.createElement("tr", { "data-line": lineNumber, "data-state": unifiedLine.diff ? "diff" : "plain", className: "diff-line group" },
|
|
3045
3088
|
React__namespace.createElement("td", { className: "diff-line-num sticky left-0 pl-[10px] pr-[10px] text-right select-none w-[1%] min-w-[100px] whitespace-nowrap align-top", style: {
|
|
3046
3089
|
color: `var(${plainLineNumberColorName})`,
|
|
3090
|
+
width: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3091
|
+
maxWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3092
|
+
minWidth: `calc(calc(var(${asideWidth}) + 5px) * 2)`,
|
|
3047
3093
|
backgroundColor: hasDiff ? `var(${plainLineNumberBGName})` : `var(${expandContentBGName})`,
|
|
3048
3094
|
} },
|
|
3049
3095
|
enableAddWidget && hasDiff && (React__namespace.createElement(DiffUnifiedAddWidget, { index: index, diffFile: diffFile, lineNumber: unifiedLine.newLineNumber, side: exports.SplitSide.new, onWidgetClick: onAddWidgetClick, onOpenAddWidget: (lineNumber, side) => setWidget({ lineNumber, side }) })),
|
|
@@ -3099,6 +3145,7 @@ const DiffUnifiedWidgetLine = ({ index, diffFile, lineNumber, }) => {
|
|
|
3099
3145
|
return (React__namespace.createElement(_DiffUnifiedWidgetLine, { index: index, diffFile: diffFile, lineNumber: lineNumber, oldWidget: oldWidget, newWidget: newWidget, setWidget: setWidget }));
|
|
3100
3146
|
};
|
|
3101
3147
|
|
|
3148
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3102
3149
|
const onMouseDown = (e) => {
|
|
3103
3150
|
const ele = e.target;
|
|
3104
3151
|
// need remove all the selection
|
|
@@ -3123,15 +3170,27 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
3123
3170
|
return { widgetSide, widgetLineNumber, setWidget };
|
|
3124
3171
|
}), [useDiffContext]);
|
|
3125
3172
|
const contextValue = React.useMemo(() => ({ useWidget }), [useWidget]);
|
|
3173
|
+
const fontSize = useDiffContext(React.useCallback((s) => s.fontSize, []));
|
|
3126
3174
|
shim.useSyncExternalStore(diffFile.subscribe, diffFile.getUpdateCount);
|
|
3127
3175
|
React.useEffect(() => {
|
|
3128
3176
|
const { setWidget } = useWidget.getReadonlyState();
|
|
3129
3177
|
setWidget({});
|
|
3130
3178
|
}, [diffFile, useWidget]);
|
|
3179
|
+
const unifiedLineLength = diffFile.unifiedLineLength;
|
|
3180
|
+
const _width = useTextWidth({
|
|
3181
|
+
text: unifiedLineLength.toString(),
|
|
3182
|
+
font: { fontSize: fontSize + "px", fontFamily: "Menlo, Consolas, monospace" },
|
|
3183
|
+
});
|
|
3184
|
+
const width = Math.max(40, _width + 25);
|
|
3131
3185
|
const lines = getUnifiedContentLine(diffFile);
|
|
3132
3186
|
return (React__namespace.createElement(DiffWidgetContext.Provider, { value: contextValue },
|
|
3133
3187
|
React__namespace.createElement("div", { className: "unified-diff-view w-full" },
|
|
3134
|
-
React__namespace.createElement("div", { className: "unified-diff-table-wrapper overflow-auto w-full scrollbar-hide scrollbar-disable", style: {
|
|
3188
|
+
React__namespace.createElement("div", { className: "unified-diff-table-wrapper overflow-auto w-full scrollbar-hide scrollbar-disable", style: {
|
|
3189
|
+
// @ts-ignore
|
|
3190
|
+
[asideWidth]: `${Math.round(width)}px`,
|
|
3191
|
+
fontFamily: "Menlo, Consolas, monospace",
|
|
3192
|
+
fontSize: "var(--diff-font-size--)",
|
|
3193
|
+
} },
|
|
3135
3194
|
React__namespace.createElement("table", { className: "unified-diff-table border-collapse w-full" },
|
|
3136
3195
|
React__namespace.createElement("colgroup", null,
|
|
3137
3196
|
React__namespace.createElement("col", { className: "unified-diff-table-num-col" }),
|
|
@@ -3140,7 +3199,7 @@ const DiffUnifiedView = React.memo(({ diffFile }) => {
|
|
|
3140
3199
|
React__namespace.createElement("tr", null,
|
|
3141
3200
|
React__namespace.createElement("th", { scope: "col" }, "line number"),
|
|
3142
3201
|
React__namespace.createElement("th", { scope: "col" }, "line content"))),
|
|
3143
|
-
React__namespace.createElement("tbody", { className: "diff-table-body
|
|
3202
|
+
React__namespace.createElement("tbody", { className: "diff-table-body leading-[1.4]", onMouseDownCapture: onMouseDown },
|
|
3144
3203
|
lines.map((item) => (React__namespace.createElement(React.Fragment, { key: item.index },
|
|
3145
3204
|
React__namespace.createElement(DiffUnifiedHunkLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
3146
3205
|
React__namespace.createElement(DiffUnifiedLine, { index: item.index, lineNumber: item.lineNumber, diffFile: diffFile }),
|
|
@@ -3259,7 +3318,7 @@ const _InternalDiffView = (props) => {
|
|
|
3259
3318
|
]);
|
|
3260
3319
|
const value = React.useMemo(() => ({ useDiffContext }), [useDiffContext]);
|
|
3261
3320
|
return (React__namespace.createElement(DiffViewContext.Provider, { value: value },
|
|
3262
|
-
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.
|
|
3321
|
+
React__namespace.createElement("div", { className: "diff-tailwindcss-wrapper", "data-component": "git-diff-view", "data-version": `${"0.0.8"}` },
|
|
3263
3322
|
React__namespace.createElement("div", { className: "diff-style-root", style: {
|
|
3264
3323
|
// @ts-ignore
|
|
3265
3324
|
[diffFontSizeName]: diffViewFontSize + "px",
|
|
@@ -3312,7 +3371,7 @@ const DiffViewWithRef = (props, ref) => {
|
|
|
3312
3371
|
};
|
|
3313
3372
|
const DiffView = React.forwardRef(DiffViewWithRef);
|
|
3314
3373
|
DiffView.displayName = "DiffView";
|
|
3315
|
-
const version = "0.0.
|
|
3374
|
+
const version = "0.0.8";
|
|
3316
3375
|
|
|
3317
3376
|
exports.DefaultDiffExpansionStep = DefaultDiffExpansionStep;
|
|
3318
3377
|
exports.DiffFile = DiffFile;
|