@asteby/metacore-runtime-react 23.11.0 → 23.11.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/CHANGELOG.md +6 -0
- package/dist/dynamic-table.d.ts.map +1 -1
- package/dist/dynamic-table.js +12 -3
- package/package.json +1 -1
- package/src/dynamic-table.tsx +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 23.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6e3cf4f: DynamicTable: el sentinel de infinite scroll se detiene cuando el backend devuelve una página corta/vacía, aunque meta.total reporte más filas de las que la lista entrega (drift count vs list). Elimina el skeleton accent parpadeando bajo las filas.
|
|
8
|
+
|
|
3
9
|
## 23.11.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-table.d.ts","sourceRoot":"","sources":["../src/dynamic-table.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAKH,KAAK,SAAS,EAajB,MAAM,uBAAuB,CAAA;AAgC9B,OAAO,KAAK,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAanF,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC7C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC/B,cAAc,CAAC,EAAE,GAAG,CAAA;IACpB,cAAc,CAAC,EAAE,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AAC,EAAE,CAAA;IAC/B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,wBAAgB,YAAY,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,aAAoB,EACpB,aAAkB,EAClB,QAAQ,EACR,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAiB,EACjB,iBAA4C,EAC5C,QAAQ,EACR,QAAQ,EACR,cAAsB,GACzB,EAAE,iBAAiB,+BAujCnB"}
|
package/dist/dynamic-table.js
CHANGED
|
@@ -50,6 +50,10 @@ export function DynamicTable({ model, endpoint, enableUrlSync = true, hiddenColu
|
|
|
50
50
|
// Infinite-scroll: a top-up page is in flight (distinct from the initial
|
|
51
51
|
// page load so only a small bottom spinner shows, not the whole-table one).
|
|
52
52
|
const [loadingMore, setLoadingMore] = useState(false);
|
|
53
|
+
// True once the backend returned a short/empty page: no more rows exist
|
|
54
|
+
// even if meta.total says otherwise (count/list drift would otherwise
|
|
55
|
+
// keep the sentinel re-firing forever). Reset by any page-1 fetch.
|
|
56
|
+
const [infExhausted, setInfExhausted] = useState(false);
|
|
53
57
|
const infPageRef = useRef(1);
|
|
54
58
|
const [optionsMap, setOptionsMap] = useState(new Map());
|
|
55
59
|
const [exportOpen, setExportOpen] = useState(false);
|
|
@@ -467,6 +471,11 @@ export function DynamicTable({ model, endpoint, enableUrlSync = true, hiddenColu
|
|
|
467
471
|
setData((prev) => (append ? dedupeById(prev, rows) : rows));
|
|
468
472
|
if (res.data.meta)
|
|
469
473
|
setRowCount(res.data.meta.total);
|
|
474
|
+
// A short page means the backend has no more rows, even if
|
|
475
|
+
// meta.total disagrees with the visible count (count query
|
|
476
|
+
// vs list query drift, dedupe). Without this the sentinel
|
|
477
|
+
// re-fires forever on empty pages.
|
|
478
|
+
setInfExhausted(rows.length < infPageSize);
|
|
470
479
|
}
|
|
471
480
|
}
|
|
472
481
|
catch (error) {
|
|
@@ -483,19 +492,19 @@ export function DynamicTable({ model, endpoint, enableUrlSync = true, hiddenColu
|
|
|
483
492
|
// the filters/search AND the sort (both live in buildFilterParams).
|
|
484
493
|
const filterSignature = useMemo(() => JSON.stringify(buildFilterParams()), [buildFilterParams]);
|
|
485
494
|
const loadNextPage = useCallback(() => {
|
|
486
|
-
if (loadingMore || loadingData)
|
|
495
|
+
if (loadingMore || loadingData || infExhausted)
|
|
487
496
|
return;
|
|
488
497
|
if (data.length >= rowCount)
|
|
489
498
|
return;
|
|
490
499
|
infPageRef.current += 1;
|
|
491
500
|
void fetchPage(infPageRef.current, true);
|
|
492
|
-
}, [loadingMore, loadingData, data.length, rowCount, fetchPage]);
|
|
501
|
+
}, [loadingMore, loadingData, infExhausted, data.length, rowCount, fetchPage]);
|
|
493
502
|
// Infinite-scroll sentinels. There are two scroll containers (desktop
|
|
494
503
|
// table + mobile card list) but only one is laid out at a time — the CSS
|
|
495
504
|
// `hidden`/`sm:hidden` container has no box, so its observer never fires.
|
|
496
505
|
// Each sentinel drives the SAME `loadNextPage`; its internal guards + the
|
|
497
506
|
// `disabled` flag keep concurrent/exhausted fetches from doubling up.
|
|
498
|
-
const infScrollDisabled = !infiniteScroll || loadingMore || loadingData || data.length >= rowCount;
|
|
507
|
+
const infScrollDisabled = !infiniteScroll || loadingMore || loadingData || infExhausted || data.length >= rowCount;
|
|
499
508
|
const { rootRef: infDesktopRoot, sentinelRef: infDesktopSentinel } = useInfiniteScrollSentinel({ onLoadMore: loadNextPage, disabled: infScrollDisabled });
|
|
500
509
|
const { rootRef: infMobileRoot, sentinelRef: infMobileSentinel } = useInfiniteScrollSentinel({ onLoadMore: loadNextPage, disabled: infScrollDisabled });
|
|
501
510
|
const initialFetchDone = useRef(false);
|
package/package.json
CHANGED
package/src/dynamic-table.tsx
CHANGED
|
@@ -157,6 +157,10 @@ export function DynamicTable({
|
|
|
157
157
|
// Infinite-scroll: a top-up page is in flight (distinct from the initial
|
|
158
158
|
// page load so only a small bottom spinner shows, not the whole-table one).
|
|
159
159
|
const [loadingMore, setLoadingMore] = useState(false)
|
|
160
|
+
// True once the backend returned a short/empty page: no more rows exist
|
|
161
|
+
// even if meta.total says otherwise (count/list drift would otherwise
|
|
162
|
+
// keep the sentinel re-firing forever). Reset by any page-1 fetch.
|
|
163
|
+
const [infExhausted, setInfExhausted] = useState(false)
|
|
160
164
|
const infPageRef = useRef(1)
|
|
161
165
|
const [optionsMap, setOptionsMap] = useState<Map<string, any[]>>(new Map())
|
|
162
166
|
|
|
@@ -546,6 +550,11 @@ export function DynamicTable({
|
|
|
546
550
|
const rows = res.data.data || []
|
|
547
551
|
setData((prev) => (append ? dedupeById(prev, rows) : rows))
|
|
548
552
|
if (res.data.meta) setRowCount(res.data.meta.total)
|
|
553
|
+
// A short page means the backend has no more rows, even if
|
|
554
|
+
// meta.total disagrees with the visible count (count query
|
|
555
|
+
// vs list query drift, dedupe). Without this the sentinel
|
|
556
|
+
// re-fires forever on empty pages.
|
|
557
|
+
setInfExhausted(rows.length < infPageSize)
|
|
549
558
|
}
|
|
550
559
|
} catch (error) {
|
|
551
560
|
console.error('Error al cargar los datos', error)
|
|
@@ -565,11 +574,11 @@ export function DynamicTable({
|
|
|
565
574
|
)
|
|
566
575
|
|
|
567
576
|
const loadNextPage = useCallback(() => {
|
|
568
|
-
if (loadingMore || loadingData) return
|
|
577
|
+
if (loadingMore || loadingData || infExhausted) return
|
|
569
578
|
if (data.length >= rowCount) return
|
|
570
579
|
infPageRef.current += 1
|
|
571
580
|
void fetchPage(infPageRef.current, true)
|
|
572
|
-
}, [loadingMore, loadingData, data.length, rowCount, fetchPage])
|
|
581
|
+
}, [loadingMore, loadingData, infExhausted, data.length, rowCount, fetchPage])
|
|
573
582
|
|
|
574
583
|
// Infinite-scroll sentinels. There are two scroll containers (desktop
|
|
575
584
|
// table + mobile card list) but only one is laid out at a time — the CSS
|
|
@@ -577,7 +586,7 @@ export function DynamicTable({
|
|
|
577
586
|
// Each sentinel drives the SAME `loadNextPage`; its internal guards + the
|
|
578
587
|
// `disabled` flag keep concurrent/exhausted fetches from doubling up.
|
|
579
588
|
const infScrollDisabled =
|
|
580
|
-
!infiniteScroll || loadingMore || loadingData || data.length >= rowCount
|
|
589
|
+
!infiniteScroll || loadingMore || loadingData || infExhausted || data.length >= rowCount
|
|
581
590
|
const { rootRef: infDesktopRoot, sentinelRef: infDesktopSentinel } =
|
|
582
591
|
useInfiniteScrollSentinel({ onLoadMore: loadNextPage, disabled: infScrollDisabled })
|
|
583
592
|
const { rootRef: infMobileRoot, sentinelRef: infMobileSentinel } =
|