@jinaan/uikit 0.1.47 → 0.1.49

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.47",
3
+ "version": "0.1.49",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -416,6 +416,17 @@ export function DataTable<T>({
416
416
  // column steals its neighbor's width and every column shifts by one.
417
417
  const structureKey = `${selectable ? "s" : "-"}|${rowActions ? "a" : "-"}|${renderExpanded ? "e" : "-"}|${columnKey}`;
418
418
  const structureRef = useRef(structureKey);
419
+ // Column widths are measured from the rendered rows, so any data change
420
+ // (renamed key, new row with longer content) must invalidate the pinned
421
+ // widths — otherwise the stale widths truncate the new content.
422
+ const contentKey = useMemo(() => {
423
+ try {
424
+ return JSON.stringify(rows);
425
+ } catch {
426
+ return `rows:${rows.length}`;
427
+ }
428
+ }, [rows]);
429
+ const contentRef = useRef(contentKey);
419
430
  const pinned = columnWidths.length > 0;
420
431
 
421
432
  // Panel-scroll mode: the band stays fixed to the shell and cannot scroll
@@ -430,12 +441,13 @@ export function DataTable<T>({
430
441
  useLayoutEffect(() => {
431
442
  const table = bodyTableRef.current;
432
443
  if (!table) return;
433
- if (structureRef.current !== structureKey) {
434
- // Column set changed: drop the pinned widths so the body re-renders
435
- // content-sized (table-auto) and the next pass measures intrinsic
436
- // widths against the new structure. Without this, the effect would
437
- // measure the stale colgroup's shifted layout and pin the wrong widths.
444
+ if (structureRef.current !== structureKey || contentRef.current !== contentKey) {
445
+ // Column set or row content changed: drop the pinned widths so the body
446
+ // re-renders content-sized (table-auto) and the next pass measures
447
+ // intrinsic widths again. Without this, the effect would measure the
448
+ // stale colgroup's shifted layout and pin the wrong (truncating) widths.
438
449
  structureRef.current = structureKey;
450
+ contentRef.current = contentKey;
439
451
  setColumnWidths((prev) => (prev.length === 0 ? prev : []));
440
452
  return;
441
453
  }
@@ -479,7 +491,7 @@ export function DataTable<T>({
479
491
  // widths (false) and again after re-pinning (true). Safe to measure in
480
492
  // the pinned state because the floor reads sizer spans — intrinsic in
481
493
  // every state — never the pinned layout itself.
482
- }, [structureKey, pinned, loading, error, syncBandScroll]);
494
+ }, [structureKey, contentKey, pinned, loading, error, syncBandScroll]);
483
495
 
484
496
  const totalWidth = columnWidths.reduce((sum, width) => sum + width, 0);
485
497
 
@@ -788,7 +800,7 @@ export function DataTable<T>({
788
800
  />
789
801
  </th>
790
802
  )}
791
- {renderExpanded && <th className="h-(--table-header-h) w-11 px-(--table-pad-x)" />}
803
+ {renderExpanded && <th className="h-(--table-header-h) w-9 px-1.5" />}
792
804
  {visibleColumns.map((c) => (
793
805
  <th
794
806
  key={c.id}
@@ -939,7 +951,7 @@ export function DataTable<T>({
939
951
  </TableCell>
940
952
  )}
941
953
  {renderExpanded && (
942
- <TableCell className="w-11" onClick={(e) => e.stopPropagation()}>
954
+ <TableCell className="w-9 px-1.5" onClick={(e) => e.stopPropagation()}>
943
955
  <Button
944
956
  type="button"
945
957
  variant="ghost"