dsh-commit-journal 0.3.0 → 0.6.0

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/client.js CHANGED
@@ -7,7 +7,7 @@ window.__ModuleLoader__.load({
7
7
  factory(require) {
8
8
  const React = require('react')
9
9
  const h = React.createElement
10
- const { useCallback, useEffect, useMemo, useRef, useState } = React
10
+ const { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } = React
11
11
  let ReactDOM = null
12
12
  try { ReactDOM = require('react-dom') } catch { ReactDOM = null }
13
13
 
@@ -126,11 +126,15 @@ window.__ModuleLoader__.load({
126
126
  defaultBranchPh: 'master / main / develop',
127
127
  watched: 'Watched',
128
128
  branch: 'Branch',
129
+ branchFilterPh: 'Filter branches',
130
+ branchLoading: 'Loading branches…',
131
+ branchNoMatch: 'No matching branches',
129
132
  time: 'Time',
130
133
  repo: 'Repo',
131
134
  title: 'Message',
132
135
  author: 'Author',
133
136
  sha: 'SHA',
137
+ diff: 'Diff',
134
138
  level: 'Level',
135
139
  levelInfo: 'Info',
136
140
  levelWarn: 'Warn',
@@ -145,6 +149,9 @@ window.__ModuleLoader__.load({
145
149
  activeDays: 'Active days',
146
150
  longestStreak: 'Longest streak',
147
151
  maxDay: 'Peak day',
152
+ diffTotal: 'Diff',
153
+ noteDiff: '{n} commits with line stats',
154
+ noteDiffEmpty: 'Sync again to fill line stats',
148
155
  noData: 'No data yet. Sync commits first.',
149
156
  confirmDelete: 'Delete this account?',
150
157
  confirmClearCommits: 'Clear local commits for this account?',
@@ -283,11 +290,15 @@ window.__ModuleLoader__.load({
283
290
  defaultBranchPh: 'master / main / develop',
284
291
  watched: '关注',
285
292
  branch: '分支',
293
+ branchFilterPh: '过滤分支',
294
+ branchLoading: '分支加载中…',
295
+ branchNoMatch: '没有匹配的分支',
286
296
  time: '时间',
287
297
  repo: '仓库',
288
298
  title: '说明',
289
299
  author: '作者',
290
300
  sha: 'SHA',
301
+ diff: '变更',
291
302
  level: '级别',
292
303
  levelInfo: '信息',
293
304
  levelWarn: '警告',
@@ -302,6 +313,9 @@ window.__ModuleLoader__.load({
302
313
  activeDays: '活跃天数',
303
314
  longestStreak: '最长连续',
304
315
  maxDay: '单日最高',
316
+ diffTotal: '变更',
317
+ noteDiff: '{n} 条提交含行数统计',
318
+ noteDiffEmpty: '重新同步后可填充行数',
305
319
  noData: '暂无数据,请先同步提交。',
306
320
  confirmDelete: '确定删除该账号?',
307
321
  confirmClearCommits: '清除该账号本地提交记录?',
@@ -375,6 +389,8 @@ window.__ModuleLoader__.load({
375
389
  --dsh-cj-heat-2: #40c463;
376
390
  --dsh-cj-heat-3: #30a14e;
377
391
  --dsh-cj-heat-4: #216e39;
392
+ --dsh-cj-add: var(--dsw-alias-state-success-primary, #16a34a);
393
+ --dsh-cj-del: var(--dsw-alias-state-error-primary, #dc2626);
378
394
  position: relative;
379
395
  box-sizing: border-box;
380
396
  height: 100%;
@@ -622,6 +638,52 @@ window.__ModuleLoader__.load({
622
638
  background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-bg-layer-1));
623
639
  box-shadow: var(--dsw-elevation-prominent, 0 8px 24px rgba(0,0,0,.18));
624
640
  }
641
+ /* 表体内的下拉挂在表体层,滚动时从下方穿过表头,不会盖住表头 */
642
+ .dsh-cj-select-menu.is-bound {
643
+ position: absolute;
644
+ z-index: 2;
645
+ }
646
+ .dsh-cj-select-menu.is-filterable {
647
+ display: flex;
648
+ flex-direction: column;
649
+ overflow: hidden;
650
+ padding: 0;
651
+ }
652
+ .dsh-cj-select-filter {
653
+ flex: none;
654
+ padding: 6px;
655
+ border-bottom: 1px solid var(--dsh-cj-border);
656
+ }
657
+ .dsh-cj-select-filter .dsh-cj-input {
658
+ display: block;
659
+ width: 100%;
660
+ height: 28px;
661
+ min-height: 28px;
662
+ }
663
+ .dsh-cj-select-list {
664
+ overflow: auto;
665
+ min-height: 0;
666
+ padding: 4px;
667
+ }
668
+ .dsh-cj-select-status {
669
+ display: flex;
670
+ align-items: center;
671
+ gap: 8px;
672
+ padding: 10px;
673
+ color: var(--dsw-alias-label-secondary);
674
+ font-size: 12px;
675
+ line-height: 18px;
676
+ }
677
+ .dsh-cj-select-spin {
678
+ width: 14px;
679
+ height: 14px;
680
+ flex: none;
681
+ border-radius: 50%;
682
+ border: 2px solid var(--dsh-cj-border);
683
+ border-top-color: var(--dsw-alias-brand-primary, #1677ff);
684
+ animation: dsh-cj-spin 0.7s linear infinite;
685
+ }
686
+ @keyframes dsh-cj-spin { to { transform: rotate(360deg); } }
625
687
  .dsh-cj-select-option {
626
688
  appearance: none;
627
689
  display: block;
@@ -738,34 +800,60 @@ window.__ModuleLoader__.load({
738
800
  line-height: 1.55;
739
801
  }
740
802
  .dsh-cj-error { color: var(--dsw-alias-state-error-primary); font-size: 12px; margin: 0 0 10px; }
803
+ /* 表头固定在滚动区外;滚动条只出现在表体 */
741
804
  .dsh-cj-table-wrap {
742
805
  flex: 1;
743
806
  min-height: 0;
744
807
  border: 1px solid var(--dsh-cj-border);
745
808
  border-radius: 12px;
746
- overflow: auto;
809
+ overflow: hidden;
747
810
  background: var(--dsw-alias-bg-layer-1);
811
+ display: flex;
812
+ flex-direction: column;
748
813
  }
749
814
  .dsh-cj-page-scroll > .dsh-cj-table-wrap {
750
815
  flex: initial;
751
816
  min-height: auto;
752
817
  max-height: none;
753
818
  }
819
+ .dsh-cj-table-head {
820
+ flex: none;
821
+ overflow: hidden;
822
+ position: relative;
823
+ z-index: 5;
824
+ background: var(--dsw-alias-bg-layer-2);
825
+ border-bottom: 1px solid var(--dsh-cj-border);
826
+ }
827
+ .dsh-cj-table-body {
828
+ flex: 1 1 auto;
829
+ min-height: 0;
830
+ overflow: auto;
831
+ position: relative;
832
+ z-index: 1;
833
+ }
834
+ /* 账号页整页滚动,表格随内容增高,不单独出滚动条 */
835
+ .dsh-cj-page-scroll .dsh-cj-table-body {
836
+ flex: none;
837
+ min-height: auto;
838
+ overflow: visible;
839
+ }
754
840
  .dsh-cj-table { width: 100%; border-collapse: collapse; }
755
841
  .dsh-cj-table th, .dsh-cj-table td {
756
842
  padding: 10px 12px;
757
843
  text-align: left;
758
844
  border-bottom: 1px solid var(--dsh-cj-border);
759
845
  vertical-align: top;
846
+ overflow-wrap: anywhere;
760
847
  }
761
848
  .dsh-cj-table th {
762
849
  font-weight: 600;
763
850
  color: var(--dsw-alias-label-secondary);
764
851
  background: var(--dsw-alias-bg-layer-2);
765
- position: sticky;
766
- top: 0;
852
+ border-bottom: 0;
767
853
  }
768
854
  .dsh-cj-table tr:last-child td { border-bottom: 0; }
855
+ .dsh-cj-table-wrap .dsh-cj-td-clip { max-width: none; }
856
+ .dsh-cj-table .dsh-cj-td-actions { overflow-wrap: normal; }
769
857
  /* Fallback Tag tones (match official Tag.module.css) */
770
858
  .dsh-cj-tag {
771
859
  display: inline-flex;
@@ -829,13 +917,32 @@ window.__ModuleLoader__.load({
829
917
  .dsh-cj-modal h3 { margin: 0 0 12px; font-size: 15px; }
830
918
  .dsh-cj-stats {
831
919
  display: grid;
832
- grid-template-columns: repeat(4, minmax(0, 1fr));
920
+ grid-template-columns: repeat(5, minmax(0, 1fr));
833
921
  gap: 10px;
834
922
  margin: 4px 0 16px;
835
923
  }
924
+ .dsh-cj-add {
925
+ color: var(--dsh-cj-add);
926
+ font-variant-numeric: tabular-nums;
927
+ }
928
+ .dsh-cj-del {
929
+ color: var(--dsh-cj-del);
930
+ font-variant-numeric: tabular-nums;
931
+ }
932
+ .dsh-cj-diff {
933
+ display: inline;
934
+ font-variant-numeric: tabular-nums;
935
+ white-space: nowrap;
936
+ }
937
+ .dsh-cj-diff .dsh-cj-diff-sep {
938
+ color: var(--dsw-alias-label-secondary);
939
+ }
836
940
  .dsh-cj-stat {
837
941
  position: relative;
838
942
  overflow: hidden;
943
+ display: flex;
944
+ flex-direction: column;
945
+ min-height: 92px;
839
946
  background: var(--dsw-alias-bg-layer-1);
840
947
  border: 1px solid var(--dsh-cj-border);
841
948
  border-radius: 12px;
@@ -854,10 +961,23 @@ window.__ModuleLoader__.load({
854
961
  margin-top: 4px;
855
962
  font-size: 26px;
856
963
  font-weight: 700;
857
- line-height: 1.2;
964
+ line-height: 32px;
965
+ min-height: 32px;
858
966
  color: var(--dsh-cj-heat-3);
859
967
  font-variant-numeric: tabular-nums;
860
968
  }
969
+ /* 须写在 .v 之后;与其它卡共用行高,底栏才能对齐 */
970
+ .dsh-cj-stat .v.v-diff {
971
+ font-size: 22px;
972
+ letter-spacing: -0.02em;
973
+ line-height: 32px;
974
+ min-height: 32px;
975
+ color: var(--dsw-alias-label-secondary);
976
+ min-width: 0;
977
+ white-space: nowrap;
978
+ overflow: hidden;
979
+ text-overflow: ellipsis;
980
+ }
861
981
  .dsh-cj-stat .v small {
862
982
  margin-left: 4px;
863
983
  font-size: 12px;
@@ -867,8 +987,10 @@ window.__ModuleLoader__.load({
867
987
  .dsh-cj-stat .n {
868
988
  position: relative;
869
989
  z-index: 1;
870
- margin-top: 3px;
990
+ margin-top: auto;
991
+ padding-top: 0;
871
992
  font-size: 12px;
993
+ line-height: 16px;
872
994
  color: var(--dsw-alias-label-secondary);
873
995
  min-height: 16px;
874
996
  }
@@ -1198,6 +1320,51 @@ window.__ModuleLoader__.load({
1198
1320
  return raw
1199
1321
  }
1200
1322
 
1323
+ // 大数压缩显示,避免窄卡溢出(活跃卡优先短格式,减少省略号)
1324
+ function formatCompactNum(n) {
1325
+ const num = Number(n) || 0
1326
+ const abs = Math.abs(num)
1327
+ if (abs >= 1e6) {
1328
+ const v = num / 1e6
1329
+ return (abs >= 1e7 ? v.toFixed(0) : v.toFixed(1).replace(/\.0$/, '')) + 'M'
1330
+ }
1331
+ if (abs >= 10000) return Math.round(num / 1000) + 'k'
1332
+ if (abs >= 1000) {
1333
+ return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'k'
1334
+ }
1335
+ return String(num)
1336
+ }
1337
+
1338
+ // 提交增删行汇总文案(tooltip 等);无数据返回空
1339
+ function formatDiffStats(c) {
1340
+ if (!c || (c.additions == null && c.deletions == null)) return ''
1341
+ const a = c.additions != null ? c.additions : 0
1342
+ const d = c.deletions != null ? c.deletions : 0
1343
+ let s = '+' + a + ' −' + d
1344
+ if (c.filesChanged != null) s += ' · ' + c.filesChanged + ' files'
1345
+ return s
1346
+ }
1347
+
1348
+ // 增删分色节点;无数据返回 null。opts: files / compact
1349
+ function renderDiffStats(c, opts) {
1350
+ if (!c || (c.additions == null && c.deletions == null)) return null
1351
+ const a = c.additions != null ? c.additions : 0
1352
+ const d = c.deletions != null ? c.deletions : 0
1353
+ const compact = Boolean(opts && opts.compact)
1354
+ const showFiles = opts && opts.files !== false && c.filesChanged != null
1355
+ const aText = '+' + (compact ? formatCompactNum(a) : a)
1356
+ const dText = '−' + (compact ? formatCompactNum(d) : d)
1357
+ const full = formatDiffStats(c)
1358
+ return h('span', { className: 'dsh-cj-diff', title: full },
1359
+ h('span', { className: 'dsh-cj-add' }, aText),
1360
+ h('span', { className: 'dsh-cj-diff-sep' }, ' '),
1361
+ h('span', { className: 'dsh-cj-del' }, dText),
1362
+ showFiles
1363
+ ? h('span', { className: 'dsh-cj-muted' }, ' · ' + c.filesChanged + ' files')
1364
+ : null
1365
+ )
1366
+ }
1367
+
1201
1368
  function fillMsg(tpl, vars) {
1202
1369
  return String(tpl || '').replace(/\{(\w+)\}/g, (_, k) => String(vars[k] ?? ''))
1203
1370
  }
@@ -1248,14 +1415,26 @@ window.__ModuleLoader__.load({
1248
1415
  className,
1249
1416
  placeholder,
1250
1417
  onOpen,
1418
+ boundScroll,
1419
+ filterable,
1420
+ filterPlaceholder,
1421
+ loading,
1422
+ loadingLabel,
1423
+ emptyLabel,
1251
1424
  'aria-label': ariaLabel,
1252
1425
  title
1253
1426
  }) {
1254
1427
  const [open, setOpen] = useState(false)
1428
+ const [query, setQuery] = useState('')
1255
1429
  const anchorRef = useRef(null)
1256
1430
  const menuRef = useRef(null)
1431
+ const filterRef = useRef(null)
1257
1432
  const [menuStyle, setMenuStyle] = useState(null)
1258
1433
  const list = options || []
1434
+ const q = filterable ? query.trim().toLowerCase() : ''
1435
+ const shown = q
1436
+ ? list.filter((o) => String(o.label || '').toLowerCase().includes(q) || String(o.value || '').toLowerCase().includes(q))
1437
+ : list
1259
1438
  const selected = list.find((o) => String(o.value) === String(value))
1260
1439
  const label = selected ? selected.label : (placeholder || '')
1261
1440
 
@@ -1273,12 +1452,62 @@ window.__ModuleLoader__.load({
1273
1452
  }, [onChange])
1274
1453
 
1275
1454
  useEffect(() => {
1276
- if (!open || UiMenu) return undefined
1455
+ if (!open) setQuery('')
1456
+ }, [open])
1457
+
1458
+ const filterFocused = useRef(false)
1459
+ useEffect(() => {
1460
+ if (!open) {
1461
+ filterFocused.current = false
1462
+ return undefined
1463
+ }
1464
+ if (!filterable || !menuStyle || filterFocused.current) return undefined
1465
+ const id = requestAnimationFrame(() => {
1466
+ const input = filterRef.current
1467
+ if (!input) return
1468
+ input.focus({ preventScroll: true })
1469
+ filterFocused.current = true
1470
+ })
1471
+ return () => cancelAnimationFrame(id)
1472
+ }, [open, filterable, menuStyle])
1473
+
1474
+ useEffect(() => {
1475
+ if (!open || (UiMenu && !boundScroll)) return undefined
1277
1476
  const place = () => {
1278
1477
  const el = anchorRef.current
1279
1478
  if (!el) return
1280
- const root = el.closest('.dsh-cj-root') || document.body
1479
+ const scrollBody = boundScroll ? el.closest('.dsh-cj-table-body') : null
1281
1480
  const a = el.getBoundingClientRect()
1481
+ if (scrollBody) {
1482
+ const b = scrollBody.getBoundingClientRect()
1483
+ if (a.bottom <= b.top || a.top >= b.bottom) {
1484
+ close()
1485
+ return
1486
+ }
1487
+ const width = Math.max(a.width, filterable ? 220 : 120)
1488
+ const rows = loading ? 1 : list.length
1489
+ const chrome = filterable ? 44 : 0
1490
+ const estimate = Math.min(280, Math.max(rows * 38 + 8 + chrome, 40 + chrome))
1491
+ const spaceBelow = Math.max(0, b.bottom - a.bottom - 8)
1492
+ const spaceAbove = Math.max(0, a.top - b.top - 8)
1493
+ let topVp = a.bottom + 4
1494
+ let height = Math.min(estimate, Math.max(spaceBelow, 40))
1495
+ if (spaceBelow < Math.min(estimate, 120) && spaceAbove > spaceBelow) {
1496
+ height = Math.min(estimate, Math.max(spaceAbove, 40))
1497
+ topVp = a.top - 4 - height
1498
+ }
1499
+ // 不把弹出层钉在可视区顶部:它跟行一起滚,越过表头时由表头盖住
1500
+ const leftVp = Math.min(Math.max(a.left, b.left), Math.max(b.left, b.right - width))
1501
+ setMenuStyle({
1502
+ position: 'absolute',
1503
+ left: Math.round(leftVp - b.left + scrollBody.scrollLeft) + 'px',
1504
+ top: Math.round(topVp - b.top + scrollBody.scrollTop) + 'px',
1505
+ width: Math.round(width) + 'px',
1506
+ maxHeight: Math.round(height) + 'px'
1507
+ })
1508
+ return
1509
+ }
1510
+ const root = el.closest('.dsh-cj-root') || document.body
1282
1511
  const bound = root.getBoundingClientRect()
1283
1512
  const width = Math.max(a.width, 120)
1284
1513
  const maxH = Math.min(280, Math.max(120, bound.height - 16))
@@ -1288,6 +1517,7 @@ window.__ModuleLoader__.load({
1288
1517
  top = Math.max(bound.top + 8, a.top - 4 - Math.min(maxH, list.length * 32 + 12))
1289
1518
  }
1290
1519
  setMenuStyle({
1520
+ position: 'fixed',
1291
1521
  left: Math.round(left) + 'px',
1292
1522
  top: Math.round(top) + 'px',
1293
1523
  width: Math.round(width) + 'px',
@@ -1312,7 +1542,7 @@ window.__ModuleLoader__.load({
1312
1542
  document.removeEventListener('mousedown', onDoc, true)
1313
1543
  document.removeEventListener('keydown', onKey, true)
1314
1544
  }
1315
- }, [close, list.length, open])
1545
+ }, [boundScroll, close, filterable, list.length, loading, open])
1316
1546
 
1317
1547
  const trigger = h('button', {
1318
1548
  ref: anchorRef,
@@ -1332,7 +1562,7 @@ window.__ModuleLoader__.load({
1332
1562
  )
1333
1563
  )
1334
1564
 
1335
- if (UiMenu) {
1565
+ if (UiMenu && !boundScroll) {
1336
1566
  const emptyId = '__dsh_cj_empty__'
1337
1567
  const toId = (v) => (v == null || v === '' ? emptyId : String(v))
1338
1568
  const fromId = (id) => {
@@ -1388,32 +1618,67 @@ window.__ModuleLoader__.load({
1388
1618
  })
1389
1619
  }
1390
1620
 
1621
+ const scrollBody = boundScroll && anchorRef.current
1622
+ ? anchorRef.current.closest('.dsh-cj-table-body')
1623
+ : null
1624
+ const optionNodes = shown.map((o) =>
1625
+ h('button', {
1626
+ key: String(o.value),
1627
+ type: 'button',
1628
+ role: 'option',
1629
+ className: 'dsh-cj-select-option',
1630
+ disabled: !!o.disabled,
1631
+ 'data-selected': String(o.value) === String(value) ? '1' : '0',
1632
+ 'aria-selected': String(o.value) === String(value),
1633
+ onClick: () => pick(o.value)
1634
+ }, o.label)
1635
+ )
1636
+ const menuBody = loading
1637
+ ? h('div', { className: 'dsh-cj-select-status', role: 'status' },
1638
+ h('span', { className: 'dsh-cj-select-spin', 'aria-hidden': true }),
1639
+ loadingLabel || '…'
1640
+ )
1641
+ : (optionNodes.length
1642
+ ? optionNodes
1643
+ : (filterable
1644
+ ? h('div', { className: 'dsh-cj-select-status' }, emptyLabel || '—')
1645
+ : null))
1391
1646
  const menu = open && menuStyle
1392
1647
  ? h('div', {
1393
1648
  ref: menuRef,
1394
- className: 'dsh-cj-select-menu',
1649
+ className: [
1650
+ 'dsh-cj-select-menu',
1651
+ scrollBody ? 'is-bound' : '',
1652
+ filterable ? 'is-filterable' : ''
1653
+ ].filter(Boolean).join(' '),
1395
1654
  role: 'listbox',
1396
- style: menuStyle
1655
+ style: menuStyle,
1656
+ onWheel: scrollBody ? (e) => e.stopPropagation() : undefined
1397
1657
  },
1398
- list.map((o) =>
1399
- h('button', {
1400
- key: String(o.value),
1401
- type: 'button',
1402
- role: 'option',
1403
- className: 'dsh-cj-select-option',
1404
- disabled: !!o.disabled,
1405
- 'data-selected': String(o.value) === String(value) ? '1' : '0',
1406
- 'aria-selected': String(o.value) === String(value),
1407
- onClick: () => pick(o.value)
1408
- }, o.label)
1409
- )
1658
+ filterable
1659
+ ? h('div', { className: 'dsh-cj-select-filter' },
1660
+ h('input', {
1661
+ ref: filterRef,
1662
+ className: 'dsh-cj-input',
1663
+ type: 'text',
1664
+ value: query,
1665
+ placeholder: filterPlaceholder || '',
1666
+ 'aria-label': filterPlaceholder || ariaLabel,
1667
+ onChange: (e) => setQuery(e.target.value)
1668
+ })
1669
+ )
1670
+ : null,
1671
+ filterable
1672
+ ? h('div', { className: 'dsh-cj-select-list' }, menuBody)
1673
+ : menuBody
1410
1674
  )
1411
1675
  : null
1412
1676
 
1677
+ const portalNode = scrollBody || document.body
1413
1678
  return h(React.Fragment, null,
1414
1679
  trigger,
1415
1680
  menu && ReactDOM && ReactDOM.createPortal
1416
- ? ReactDOM.createPortal(menu, document.body)
1681
+ ? ReactDOM.createPortal(menu, portalNode)
1417
1682
  : menu
1418
1683
  )
1419
1684
  }
@@ -1759,6 +2024,121 @@ window.__ModuleLoader__.load({
1759
2024
  }
1760
2025
  }
1761
2026
 
2027
+ /**
2028
+ * 表头固定、仅表体滚动的表格
2029
+ */
2030
+ function TableScroll({ head, children }) {
2031
+ const headRef = useRef(null)
2032
+ const bodyRef = useRef(null)
2033
+
2034
+ useLayoutEffect(() => {
2035
+ const headEl = headRef.current
2036
+ const bodyEl = bodyRef.current
2037
+ if (!headEl || !bodyEl) return undefined
2038
+
2039
+ const measureRow = (table) => {
2040
+ table.style.tableLayout = 'auto'
2041
+ table.style.width = 'max-content'
2042
+ table.querySelectorAll('th,td').forEach((cell) => { cell.style.width = '' })
2043
+ const row = (table.tHead && table.tHead.rows[0]) || table.rows[0]
2044
+ if (!row) return []
2045
+ return Array.from(row.cells).map((cell) => cell.getBoundingClientRect().width)
2046
+ }
2047
+
2048
+ const fitColumns = (cols, target) => {
2049
+ const n = cols.length
2050
+ if (!n || target <= 0) return cols
2051
+ const lock = cols.map((w, i) => i === n - 1 || w < 200)
2052
+ let locked = 0
2053
+ let flexSum = 0
2054
+ cols.forEach((w, i) => {
2055
+ if (lock[i]) locked += w
2056
+ else flexSum += w
2057
+ })
2058
+ if (locked >= target || flexSum <= 0) {
2059
+ const sum = cols.reduce((a, b) => a + b, 0) || 1
2060
+ const out = cols.map((w) => Math.floor((target * w) / sum))
2061
+ out[n - 1] = target - out.slice(0, -1).reduce((a, b) => a + b, 0)
2062
+ return out
2063
+ }
2064
+ const remain = target - locked
2065
+ const out = cols.slice()
2066
+ let used = 0
2067
+ const flexIdx = []
2068
+ cols.forEach((w, i) => { if (!lock[i]) flexIdx.push(i) })
2069
+ flexIdx.forEach((i, k) => {
2070
+ const next = k === flexIdx.length - 1
2071
+ ? remain - used
2072
+ : Math.floor((remain * cols[i]) / flexSum)
2073
+ out[i] = next
2074
+ used += next
2075
+ })
2076
+ return out
2077
+ }
2078
+
2079
+ const apply = (table, cols) => {
2080
+ table.style.tableLayout = 'fixed'
2081
+ table.style.width = '100%'
2082
+ const row = (table.tHead && table.tHead.rows[0]) || table.rows[0]
2083
+ if (!row) return
2084
+ Array.from(row.cells).forEach((cell, i) => {
2085
+ if (cols[i] > 0) cell.style.width = cols[i] + 'px'
2086
+ })
2087
+ }
2088
+
2089
+ let running = false
2090
+ const sync = () => {
2091
+ if (running) return
2092
+ running = true
2093
+ try {
2094
+ const headTable = headEl.querySelector('table')
2095
+ const bodyTable = bodyEl.querySelector('table')
2096
+ if (!headTable || !bodyTable) return
2097
+ for (let pass = 0; pass < 2; pass++) {
2098
+ const sb = bodyEl.offsetWidth - bodyEl.clientWidth
2099
+ headEl.style.paddingRight = sb > 0 ? sb + 'px' : ''
2100
+ const target = bodyEl.clientWidth
2101
+ if (!target) return
2102
+ const headW = measureRow(headTable)
2103
+ const bodyW = measureRow(bodyTable)
2104
+ const n = Math.max(headW.length, bodyW.length)
2105
+ if (!n) return
2106
+ const natural = []
2107
+ for (let i = 0; i < n; i++) natural.push(Math.ceil(Math.max(headW[i] || 0, bodyW[i] || 0)))
2108
+ const cols = fitColumns(natural, target)
2109
+ apply(headTable, cols)
2110
+ apply(bodyTable, cols)
2111
+ if (bodyEl.offsetWidth - bodyEl.clientWidth === sb) break
2112
+ }
2113
+ if (headEl.scrollLeft !== bodyEl.scrollLeft) headEl.scrollLeft = bodyEl.scrollLeft
2114
+ } finally {
2115
+ running = false
2116
+ }
2117
+ }
2118
+
2119
+ sync()
2120
+ const ro = new ResizeObserver(sync)
2121
+ ro.observe(bodyEl)
2122
+ const onScroll = () => {
2123
+ if (headEl.scrollLeft !== bodyEl.scrollLeft) headEl.scrollLeft = bodyEl.scrollLeft
2124
+ }
2125
+ bodyEl.addEventListener('scroll', onScroll, { passive: true })
2126
+ return () => {
2127
+ ro.disconnect()
2128
+ bodyEl.removeEventListener('scroll', onScroll)
2129
+ }
2130
+ }, [head, children])
2131
+
2132
+ return h('div', { className: 'dsh-cj-table-wrap' },
2133
+ h('div', { className: 'dsh-cj-table-head', ref: headRef },
2134
+ h('table', { className: 'dsh-cj-table' }, head)
2135
+ ),
2136
+ h('div', { className: 'dsh-cj-table-body', ref: bodyRef },
2137
+ h('table', { className: 'dsh-cj-table' }, children)
2138
+ )
2139
+ )
2140
+ }
2141
+
1762
2142
  function AccountsPage({ t, accounts, activeId, onChanged, busy, setBusy, notify }) {
1763
2143
  const [modal, setModal] = useState(null)
1764
2144
  const [form, setForm] = useState(emptyForm())
@@ -1852,17 +2232,16 @@ window.__ModuleLoader__.load({
1852
2232
  : h('div', { className: 'dsh-cj-muted' }, t('emptyAccount')),
1853
2233
  h(Btn, { primary: true, icon: IconPlus ? h(IconPlus) : null, onClick: openNew }, t('newAccount'))
1854
2234
  ),
1855
- h('div', { className: 'dsh-cj-table-wrap' },
1856
- h('table', { className: 'dsh-cj-table' },
1857
- h('thead', null, h('tr', null,
1858
- h('th', null, t('name')),
1859
- h('th', null, t('accountMode')),
1860
- h('th', null, t('provider')),
1861
- h('th', null, t('org')),
1862
- h('th', null, t('authors')),
1863
- h('th', null, '')
1864
- )),
1865
- h('tbody', null, accounts.map((a) =>
2235
+ h(TableScroll, {
2236
+ head: h('thead', null, h('tr', null,
2237
+ h('th', null, t('name')),
2238
+ h('th', null, t('accountMode')),
2239
+ h('th', null, t('provider')),
2240
+ h('th', null, t('org')),
2241
+ h('th', null, t('authors')),
2242
+ h('th', null, '')
2243
+ )),
2244
+ children: h('tbody', null, accounts.map((a) =>
1866
2245
  h('tr', { key: a.id },
1867
2246
  h('td', null,
1868
2247
  a.name, ' ',
@@ -1945,8 +2324,7 @@ window.__ModuleLoader__.load({
1945
2324
  )
1946
2325
  )
1947
2326
  ))
1948
- )
1949
- ),
2327
+ }),
1950
2328
  h(AccountModal, {
1951
2329
  open: !!modal,
1952
2330
  mode: modal,
@@ -1995,9 +2373,14 @@ window.__ModuleLoader__.load({
1995
2373
  return h(SelectField, {
1996
2374
  style: { width: 160 },
1997
2375
  value: current,
1998
- disabled: loading,
1999
- title: loading ? '…' : t('branch'),
2376
+ title: t('branch'),
2000
2377
  'aria-label': t('branch'),
2378
+ boundScroll: true,
2379
+ filterable: true,
2380
+ filterPlaceholder: t('branchFilterPh'),
2381
+ loading,
2382
+ loadingLabel: t('branchLoading'),
2383
+ emptyLabel: t('branchNoMatch'),
2001
2384
  onOpen: () => { ensureLoaded().catch(() => {}) },
2002
2385
  options: list.map((name) => ({
2003
2386
  value: name,
@@ -2136,15 +2519,14 @@ window.__ModuleLoader__.load({
2136
2519
  }, isLocal ? t('syncWatchedLocal') : t('syncWatched'))
2137
2520
  )
2138
2521
  ),
2139
- h('div', { className: 'dsh-cj-table-wrap' },
2140
- h('table', { className: 'dsh-cj-table' },
2141
- h('thead', null, h('tr', null,
2142
- h('th', null, t('watched')),
2143
- h('th', null, t('repo')),
2144
- h('th', null, t('branch')),
2145
- h('th', null, '')
2146
- )),
2147
- h('tbody', null, pageRepos.map((r) => {
2522
+ h(TableScroll, {
2523
+ head: h('thead', null, h('tr', null,
2524
+ h('th', null, t('watched')),
2525
+ h('th', null, t('repo')),
2526
+ h('th', null, t('branch')),
2527
+ h('th', null, '')
2528
+ )),
2529
+ children: h('tbody', null, pageRepos.map((r) => {
2148
2530
  const checked = isWatched(r.id)
2149
2531
  return h('tr', { key: r.id },
2150
2532
  h('td', null,
@@ -2204,8 +2586,7 @@ window.__ModuleLoader__.load({
2204
2586
  )
2205
2587
  )
2206
2588
  }))
2207
- )
2208
- ),
2589
+ }),
2209
2590
  h(TablePager, {
2210
2591
  t,
2211
2592
  total: filtered.length,
@@ -2329,27 +2710,26 @@ window.__ModuleLoader__.load({
2329
2710
  }
2330
2711
  }, t('clearCommits'))
2331
2712
  ),
2332
- h('div', { className: 'dsh-cj-table-wrap' },
2333
- h('table', { className: 'dsh-cj-table' },
2334
- h('thead', null, h('tr', null,
2335
- h('th', null, t('time')), h('th', null, t('repo')), h('th', null, t('title')),
2336
- h('th', null, t('author')), h('th', null, t('sha'))
2337
- )),
2338
- h('tbody', null, items.map((c) =>
2339
- h('tr', { key: c.id },
2340
- h('td', null, (c.committedAt || '').slice(0, 16).replace('T', ' ')),
2341
- h('td', null, shortRepoLabel(c.repoName)),
2342
- h('td', null, c.title),
2343
- h('td', null, c.authorName),
2344
- h('td', null,
2345
- c.webUrl
2346
- ? h('a', { className: 'dsh-cj-link', href: c.webUrl, target: '_blank', rel: 'noreferrer' }, c.shortId)
2347
- : c.shortId
2348
- )
2713
+ h(TableScroll, {
2714
+ head: h('thead', null, h('tr', null,
2715
+ h('th', null, t('time')), h('th', null, t('repo')), h('th', null, t('title')),
2716
+ h('th', null, t('diff')), h('th', null, t('author')), h('th', null, t('sha'))
2717
+ )),
2718
+ children: h('tbody', null, items.map((c) =>
2719
+ h('tr', { key: c.id },
2720
+ h('td', null, (c.committedAt || '').slice(0, 16).replace('T', ' ')),
2721
+ h('td', null, shortRepoLabel(c.repoName)),
2722
+ h('td', null, c.title),
2723
+ h('td', null, renderDiffStats(c, { compact: true }) || h('span', { className: 'dsh-cj-muted' }, '—')),
2724
+ h('td', null, c.authorName),
2725
+ h('td', null,
2726
+ c.webUrl
2727
+ ? h('a', { className: 'dsh-cj-link', href: c.webUrl, target: '_blank', rel: 'noreferrer' }, c.shortId)
2728
+ : c.shortId
2349
2729
  )
2350
- ))
2351
- )
2352
- ),
2730
+ )
2731
+ ))
2732
+ }),
2353
2733
  h(TablePager, {
2354
2734
  t,
2355
2735
  total,
@@ -2435,7 +2815,7 @@ window.__ModuleLoader__.load({
2435
2815
  const gridEnd = new Date(toDay); gridEnd.setDate(toDay.getDate() + endPad)
2436
2816
  const totalDays = Math.round((gridEnd - gridStart) / 86400000) + 1
2437
2817
  const weeks = Math.ceil(totalDays / 7)
2438
- const countByDay = new Map((data.days || []).map((d) => [d.date, d.count]))
2818
+ const dayByKey = new Map((data.days || []).map((d) => [d.date, d]))
2439
2819
  const step = Math.max(1, Math.ceil((data.stats.maxDayCount || 1) / 4))
2440
2820
  const now = new Date()
2441
2821
  const todayKey = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0')
@@ -2445,10 +2825,20 @@ window.__ModuleLoader__.load({
2445
2825
  const d = new Date(gridStart); d.setDate(gridStart.getDate() + i)
2446
2826
  const key = d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0')
2447
2827
  const inRange = d >= fromDay && d <= toDay
2448
- const count = inRange ? (countByDay.get(key) || 0) : 0
2828
+ const dayInfo = inRange ? dayByKey.get(key) : null
2829
+ const count = dayInfo ? (dayInfo.count || 0) : 0
2449
2830
  const level = count <= 0 ? 0 : Math.min(4, Math.ceil(count / step))
2450
2831
  if (inRange && count > 0) weekdayCounts[(d.getDay() + 6) % 7] += count
2451
- cells.push({ key, count, inRange, level, isToday: key === todayKey })
2832
+ cells.push({
2833
+ key,
2834
+ count,
2835
+ inRange,
2836
+ level,
2837
+ isToday: key === todayKey,
2838
+ additions: dayInfo && dayInfo.additions != null ? dayInfo.additions : null,
2839
+ deletions: dayInfo && dayInfo.deletions != null ? dayInfo.deletions : null,
2840
+ filesChanged: dayInfo && dayInfo.filesChanged != null ? dayInfo.filesChanged : null
2841
+ })
2452
2842
  }
2453
2843
  // Sparse month labels like the desktop reference (avoid crowding near the end)
2454
2844
  const monthLabels = []
@@ -2466,7 +2856,7 @@ window.__ModuleLoader__.load({
2466
2856
  let currentStreak = 0
2467
2857
  for (let cur = new Date(Math.min(toDay.getTime(), Date.now())); cur >= fromDay; cur.setDate(cur.getDate() - 1)) {
2468
2858
  const key = cur.getFullYear() + '-' + String(cur.getMonth() + 1).padStart(2, '0') + '-' + String(cur.getDate()).padStart(2, '0')
2469
- if ((countByDay.get(key) || 0) > 0) currentStreak++
2859
+ if ((dayByKey.get(key) || {}).count > 0) currentStreak++
2470
2860
  else break
2471
2861
  }
2472
2862
  const avg = data.stats.activeDays
@@ -2544,6 +2934,22 @@ window.__ModuleLoader__.load({
2544
2934
  h('div', { className: 'l' }, t('maxDay')),
2545
2935
  h('div', { className: 'v' }, stats.maxDayCount, h('small', null, t('unitCommit'))),
2546
2936
  h('div', { className: 'n' }, stats.maxDayDate || t('notePeak'))
2937
+ ),
2938
+ h('div', { className: 'dsh-cj-stat' },
2939
+ h('div', { className: 'l' }, t('diffTotal')),
2940
+ h('div', { className: 'v v-diff' },
2941
+ stats.commitsWithStats
2942
+ ? renderDiffStats({
2943
+ additions: stats.totalAdditions || 0,
2944
+ deletions: stats.totalDeletions || 0
2945
+ }, { files: false, compact: true })
2946
+ : h('span', { className: 'dsh-cj-muted' }, '—')
2947
+ ),
2948
+ h('div', { className: 'n' },
2949
+ stats.commitsWithStats
2950
+ ? fillMsg(t('noteDiff'), { n: stats.commitsWithStats })
2951
+ : t('noteDiffEmpty')
2952
+ )
2547
2953
  )
2548
2954
  ),
2549
2955
  heatmap && h('div', { className: 'dsh-cj-heat' },
@@ -2572,7 +2978,11 @@ window.__ModuleLoader__.load({
2572
2978
  },
2573
2979
  heatmap.cells.map((c) => {
2574
2980
  const clickable = c.inRange && c.count > 0
2575
- const tip = c.inRange ? (c.key + ' · ' + c.count + ' ' + t('unitCommit')) : c.key
2981
+ let tip = c.inRange ? (c.key + ' · ' + c.count + ' ' + t('unitCommit')) : c.key
2982
+ if (clickable && (c.additions != null || c.deletions != null)) {
2983
+ tip += ' · +' + (c.additions || 0) + ' −' + (c.deletions || 0)
2984
+ if (c.filesChanged != null) tip += ' · ' + c.filesChanged + ' files'
2985
+ }
2576
2986
  return h('button', {
2577
2987
  key: c.key,
2578
2988
  type: 'button',
@@ -2631,6 +3041,17 @@ window.__ModuleLoader__.load({
2631
3041
  h('div', null,
2632
3042
  h('span', null, t('maxDay')),
2633
3043
  h('strong', null, data.stats.maxDayCount)
3044
+ ),
3045
+ h('div', null,
3046
+ h('span', null, t('diffTotal')),
3047
+ h('strong', null,
3048
+ stats.commitsWithStats
3049
+ ? renderDiffStats({
3050
+ additions: stats.totalAdditions || 0,
3051
+ deletions: stats.totalDeletions || 0
3052
+ }, { files: false, compact: true })
3053
+ : '—'
3054
+ )
2634
3055
  )
2635
3056
  )
2636
3057
  )
@@ -2666,6 +3087,7 @@ window.__ModuleLoader__.load({
2666
3087
  h('div', { className: 'dsh-cj-commit-title' }, c.title),
2667
3088
  h('div', { className: 'dsh-cj-commit-meta' },
2668
3089
  h('span', { className: 'dsh-cj-commit-sha' }, c.sha),
3090
+ renderDiffStats(c, { compact: true }),
2669
3091
  h('span', null, c.authorName || ''),
2670
3092
  c.webUrl
2671
3093
  ? h(Btn, {
@@ -2747,20 +3169,18 @@ window.__ModuleLoader__.load({
2747
3169
  }
2748
3170
  }, t('clearLogs'))
2749
3171
  ),
2750
- h('div', { className: 'dsh-cj-table-wrap' },
2751
- h('table', { className: 'dsh-cj-table' },
2752
- h('thead', null, h('tr', null,
2753
- h('th', null, t('level')), h('th', null, t('time')), h('th', null, t('message'))
2754
- )),
2755
- h('tbody', null, items.map((l) =>
2756
- h('tr', { key: l.id },
2757
- h('td', null, logLevelTag(t, l.level)),
2758
- h('td', null, (l.at || '').replace('T', ' ').slice(0, 19)),
2759
- h('td', null, l.message)
2760
- )
2761
- ))
2762
- )
2763
- ),
3172
+ h(TableScroll, {
3173
+ head: h('thead', null, h('tr', null,
3174
+ h('th', null, t('level')), h('th', null, t('time')), h('th', null, t('message'))
3175
+ )),
3176
+ children: h('tbody', null, items.map((l) =>
3177
+ h('tr', { key: l.id },
3178
+ h('td', null, logLevelTag(t, l.level)),
3179
+ h('td', null, (l.at || '').replace('T', ' ').slice(0, 19)),
3180
+ h('td', null, l.message)
3181
+ )
3182
+ ))
3183
+ }),
2764
3184
  h(TablePager, {
2765
3185
  t,
2766
3186
  total,