@jinaan/uikit 0.1.55 → 0.1.57
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/data-table.d.ts.map +1 -1
- package/dist/index.js +528 -516
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/combobox.tsx +3 -3
- package/src/data-table.tsx +40 -5
package/package.json
CHANGED
package/src/combobox.tsx
CHANGED
|
@@ -206,10 +206,10 @@ export function Combobox({
|
|
|
206
206
|
aria-selected={item.value === value}
|
|
207
207
|
onClick={() => pick(item)}
|
|
208
208
|
className={cn(
|
|
209
|
-
"flex w-full items-center gap-3 rounded-lg px-2 py-
|
|
209
|
+
"flex w-full items-center gap-3 rounded-lg px-2 py-1.5 text-left transition-colors",
|
|
210
210
|
item.value === value
|
|
211
|
-
? "bg-(--
|
|
212
|
-
: "hover:bg-(--
|
|
211
|
+
? "bg-(--combobox-search-bg)"
|
|
212
|
+
: "hover:bg-(--combobox-search-bg) focus:bg-(--combobox-search-bg) data-highlighted:bg-(--combobox-search-bg)",
|
|
213
213
|
)}
|
|
214
214
|
>
|
|
215
215
|
{renderItem ? (
|
package/src/data-table.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|