@jinaan/uikit 0.1.56 → 0.1.58

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.56",
3
+ "version": "0.1.58",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -462,13 +462,25 @@ export function DataTable<T>({
462
462
  // shrink the stale minWidth would keep a scrollbar alive forever. The
463
463
  // sizer span is intrinsic in every state. Widths stay unrounded so the
464
464
  // sum is the exact content requirement.
465
+ //
466
+ // Content floor: fixed-layout cells don't grow with their content, so
467
+ // an interactive control (a role select that gains its label, a badge
468
+ // that renders late) would overflow into its neighbor. Read the cell's
469
+ // scrollWidth and its direct children's rects so overflowing content
470
+ // widens the column instead of spilling over it.
465
471
  const bandThs = bandTableRef.current?.querySelectorAll("thead th");
466
- const widths = Array.from(cells, (cell, i) =>
467
- Math.max(
472
+ const widths = Array.from(cells, (cell, i) => {
473
+ const childWidth = Math.max(
474
+ 0,
475
+ ...Array.from(cell.children, (child) => child.getBoundingClientRect().width),
476
+ );
477
+ return Math.max(
468
478
  cell.getBoundingClientRect().width,
479
+ cell.scrollWidth,
480
+ childWidth,
469
481
  bandThs?.item(i)?.querySelector("[data-col-sizer]")?.getBoundingClientRect().width ?? 0,
470
- ),
471
- );
482
+ );
483
+ });
472
484
  // Bail out when nothing changed: a new array would re-render, and the
473
485
  // re-render would re-run this effect, looping forever.
474
486
  setColumnWidths((prev) =>
@@ -497,7 +509,30 @@ export function DataTable<T>({
497
509
  if (typeof ResizeObserver === "undefined") return;
498
510
  const observer = new ResizeObserver(measure);
499
511
  observer.observe(table);
500
- return () => observer.disconnect();
512
+
513
+ // Cell content can change without the table resizing (an async label
514
+ // landing inside an already-pinned fixed column). Watch the tbody — not
515
+ // the whole table, so our own colgroup writes can't loop — and remeasure
516
+ // so overflowing content widens its column instead of overlapping the
517
+ // neighbor.
518
+ let frame: number | null = null;
519
+ const scheduleMeasure = () => {
520
+ if (frame !== null) return;
521
+ frame = requestAnimationFrame(() => {
522
+ frame = null;
523
+ measure();
524
+ });
525
+ };
526
+ const mutations = new MutationObserver(scheduleMeasure);
527
+ const firstBody = table.tBodies[0];
528
+ if (firstBody) {
529
+ mutations.observe(firstBody, { childList: true, characterData: true, subtree: true });
530
+ }
531
+ return () => {
532
+ observer.disconnect();
533
+ mutations.disconnect();
534
+ if (frame !== null) cancelAnimationFrame(frame);
535
+ };
501
536
  // `pinned` re-runs this effect after the structure reset clears the
502
537
  // widths (false) and again after re-pinning (true). Safe to measure in
503
538
  // the pinned state because the floor reads sizer spans — intrinsic in
@@ -79,7 +79,7 @@ export const DropdownMenuContent = forwardRef<
79
79
  ref={ref}
80
80
  sideOffset={sideOffset}
81
81
  className={cn(
82
- "menu-surface btn-inner-border z-50 min-w-48 overflow-hidden rounded-lg border border-line bg-(--button-secondary-bg) p-1",
82
+ "menu-surface btn-inner-border z-50 min-w-(--radix-popper-anchor-width) overflow-hidden rounded-lg border border-line bg-(--button-secondary-bg) p-1",
83
83
  "data-[state=open]:animate-in data-[state=closed]:animate-out",
84
84
  "data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0",
85
85
  "data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95",
package/src/select.tsx CHANGED
@@ -78,7 +78,7 @@ export const SelectContent = forwardRef<
78
78
  position={position}
79
79
  sideOffset={sideOffset}
80
80
  className={cn(
81
- "menu-surface btn-inner-border z-50 min-w-48 overflow-hidden rounded-lg border border-line bg-(--button-secondary-bg) p-1",
81
+ "menu-surface btn-inner-border z-50 min-w-(--radix-select-trigger-width) overflow-hidden rounded-lg border border-line bg-(--button-secondary-bg) p-1",
82
82
  "data-[state=open]:animate-in data-[state=closed]:animate-out",
83
83
  "data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0",
84
84
  "data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95",