@jinaan/uikit 0.1.35 → 0.1.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinaan/uikit",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -353,6 +353,7 @@ export function DataTable<T>({
353
353
  // measuring the rendered body columns and pinning the band colgroup to the
354
354
  // same pixel widths; both tables share the surface's horizontal scroller.
355
355
  const bodyTableRef = useRef<HTMLTableElement | null>(null);
356
+ const bandTableRef = useRef<HTMLTableElement | null>(null);
356
357
  const [columnWidths, setColumnWidths] = useState<number[]>([]);
357
358
  // Deps must be primitives: visibleColumns is a fresh array every render and
358
359
  // would re-run this effect (and its setState) in a loop.
@@ -363,11 +364,20 @@ export function DataTable<T>({
363
364
  if (!table) return;
364
365
  const measure = () => {
365
366
  const cells = table.tBodies[0]?.rows.item(0)?.cells;
367
+ // The band may be squeezed narrower than its own sort-button content by
368
+ // the body-measured widths; scrollWidth reports the true minimum, so it
369
+ // floors each column and stops titles from overflowing their neighbors.
370
+ const bandCells = bandTableRef.current?.querySelectorAll("thead th");
366
371
  if (!cells || cells.length === 0) {
367
372
  setColumnWidths((prev) => (prev.length === 0 ? prev : []));
368
373
  return;
369
374
  }
370
- const widths = Array.from(cells, (cell) => Math.round(cell.getBoundingClientRect().width));
375
+ const widths = Array.from(cells, (cell, i) =>
376
+ Math.max(
377
+ Math.round(cell.getBoundingClientRect().width),
378
+ Math.round(bandCells?.item(i)?.scrollWidth ?? 0),
379
+ ),
380
+ );
371
381
  // Bail out when nothing changed: a new array would re-render, and the
372
382
  // re-render would re-run this effect, looping forever.
373
383
  setColumnWidths((prev) =>
@@ -653,6 +663,7 @@ export function DataTable<T>({
653
663
  // sr-only thead); widths are pinned to the measured body columns and
654
664
  // hidden until the first measurement lands so columns never flash.
655
665
  <table
666
+ ref={bandTableRef}
656
667
  role="presentation"
657
668
  className="w-full table-fixed border-collapse"
658
669
  style={{