@axzydev/axzy_ui_system 1.8.0 → 1.8.1
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/index.cjs +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/organisms/data-table/dataTable.tsx +29 -3
package/package.json
CHANGED
|
@@ -147,6 +147,29 @@ export default function ITDataTable<T extends Record<string, unknown>>({
|
|
|
147
147
|
const isTableVirtual = virtualized && effectiveView === "table";
|
|
148
148
|
const isStickyHeader = stickyHeader && isTableVirtual;
|
|
149
149
|
const resolvedRowHeight = rowHeight ?? getRowHeight(size, density);
|
|
150
|
+
|
|
151
|
+
// La virtualización espacios filas de `resolvedRowHeight`; si el contenedor
|
|
152
|
+
// corta a una altura arbitraria, la última fila sale partida. Medimos el
|
|
153
|
+
// encabezado y recortamos a un múltiplo exacto de fila.
|
|
154
|
+
const headRef = useRef<HTMLTableSectionElement | null>(null);
|
|
155
|
+
const [headHeight, setHeadHeight] = useState(0);
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (!isTableVirtual) return;
|
|
158
|
+
const el = headRef.current;
|
|
159
|
+
if (!el) return;
|
|
160
|
+
const measure = () => setHeadHeight(el.getBoundingClientRect().height);
|
|
161
|
+
measure();
|
|
162
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
163
|
+
const ro = new ResizeObserver(measure);
|
|
164
|
+
ro.observe(el);
|
|
165
|
+
return () => ro.disconnect();
|
|
166
|
+
}, [isTableVirtual, resolvedRowHeight]);
|
|
167
|
+
|
|
168
|
+
const snappedMaxHeight =
|
|
169
|
+
isTableVirtual && headHeight > 0
|
|
170
|
+
? headHeight +
|
|
171
|
+
Math.max(1, Math.floor((virtualizedMaxHeight - headHeight) / resolvedRowHeight)) * resolvedRowHeight
|
|
172
|
+
: virtualizedMaxHeight;
|
|
150
173
|
const columnCount = columns.length;
|
|
151
174
|
const pinnedMeta = React.useMemo(() => getPinnedColumnMeta(columns), [columns]);
|
|
152
175
|
const scrollOuterClass = isTableVirtual
|
|
@@ -507,7 +530,7 @@ export default function ITDataTable<T extends Record<string, unknown>>({
|
|
|
507
530
|
))}
|
|
508
531
|
</colgroup>
|
|
509
532
|
)}
|
|
510
|
-
<thead>
|
|
533
|
+
<thead ref={headRef}>
|
|
511
534
|
<tr
|
|
512
535
|
className={clsx(tableHeaderRow, "dark:text-slate-200", headerSlot.className)}
|
|
513
536
|
style={headerSlot.style}
|
|
@@ -590,7 +613,10 @@ export default function ITDataTable<T extends Record<string, unknown>>({
|
|
|
590
613
|
onRowClick && !isLoading && tableRowClickable,
|
|
591
614
|
rowSlot.className
|
|
592
615
|
)}
|
|
593
|
-
style={
|
|
616
|
+
style={{
|
|
617
|
+
...(isTableVirtual ? { height: resolvedRowHeight } : null),
|
|
618
|
+
...rowSlot.style,
|
|
619
|
+
}}
|
|
594
620
|
tabIndex={onRowClick && !isLoading ? 0 : undefined}
|
|
595
621
|
onClick={onRowClick && !isLoading ? handleRowClick(row) : undefined}
|
|
596
622
|
onKeyDown={onRowClick && !isLoading ? handleRowKeyDown(row) : undefined}
|
|
@@ -740,7 +766,7 @@ export default function ITDataTable<T extends Record<string, unknown>>({
|
|
|
740
766
|
<div
|
|
741
767
|
ref={scrollRef}
|
|
742
768
|
className="overflow-x-auto overflow-y-auto"
|
|
743
|
-
style={{ maxHeight:
|
|
769
|
+
style={{ maxHeight: snappedMaxHeight }}
|
|
744
770
|
>
|
|
745
771
|
{tableEl}
|
|
746
772
|
</div>
|