@open-mercato/ui 0.6.8-develop.7029.1.a1bb3363af → 0.6.8-develop.7031.1.005201cd70
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/backend/DataTable.js +16 -3
- package/dist/backend/DataTable.js.map +2 -2
- package/dist/backend/utils/crud.js.map +2 -2
- package/dist/primitives/pagination.js +14 -9
- package/dist/primitives/pagination.js.map +2 -2
- package/package.json +3 -3
- package/src/backend/DataTable.tsx +36 -5
- package/src/backend/__tests__/DataTable.cappedPagination.test.tsx +122 -0
- package/src/backend/utils/crud.ts +2 -0
- package/src/primitives/__tests__/pagination.test.tsx +54 -0
- package/src/primitives/pagination.tsx +40 -9
|
@@ -1853,8 +1853,11 @@ function DataTable({
|
|
|
1853
1853
|
const paginationNode = React.useMemo(() => {
|
|
1854
1854
|
if (!pagination || pagination.total === 0) return null;
|
|
1855
1855
|
const { page, totalPages, onPageChange, durationMs, cacheStatus } = pagination;
|
|
1856
|
+
const totalIsCapped = pagination.totalIsCapped === true;
|
|
1857
|
+
const pageIsFull = data.length >= pagination.pageSize;
|
|
1856
1858
|
const startItem = (page - 1) * pagination.pageSize + 1;
|
|
1857
|
-
const endItem = Math.min(page * pagination.pageSize, pagination.total);
|
|
1859
|
+
const endItem = totalIsCapped ? Math.max(startItem, startItem + data.length - 1) : Math.min(page * pagination.pageSize, pagination.total);
|
|
1860
|
+
const pageIsEmpty = data.length === 0;
|
|
1858
1861
|
const effectiveDuration = typeof durationMs === "number" && Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : measuredDurationMs ?? void 0;
|
|
1859
1862
|
const durationLabel = showQueryTime ? formatDurationLabel(effectiveDuration) : "";
|
|
1860
1863
|
const normalizedCacheStatus = cacheStatus === "hit" || cacheStatus === "miss" ? cacheStatus : null;
|
|
@@ -1887,6 +1890,8 @@ function DataTable({
|
|
|
1887
1890
|
page,
|
|
1888
1891
|
pageSize: pagination.pageSize,
|
|
1889
1892
|
total: pagination.total,
|
|
1893
|
+
totalIsCapped,
|
|
1894
|
+
hasNextPage: totalIsCapped ? pageIsFull : void 0,
|
|
1890
1895
|
onPageChange: (next) => {
|
|
1891
1896
|
onPageChange(next);
|
|
1892
1897
|
scrollTableIntoView();
|
|
@@ -1896,14 +1901,22 @@ function DataTable({
|
|
|
1896
1901
|
scrollTableIntoView();
|
|
1897
1902
|
} : void 0,
|
|
1898
1903
|
pageSizeOptions,
|
|
1899
|
-
formatPageInfo: () =>
|
|
1904
|
+
formatPageInfo: () => {
|
|
1905
|
+
if (totalIsCapped) {
|
|
1906
|
+
if (pageIsEmpty) {
|
|
1907
|
+
return t("ui.dataTable.pagination.resultsCappedNoRows", "No further results past {total}", { total: pagination.total });
|
|
1908
|
+
}
|
|
1909
|
+
return durationLabel ? t("ui.dataTable.pagination.resultsCappedWithDuration", "Showing {start} to {end} of {total}+ results in {duration}", { start: startItem, end: endItem, total: pagination.total, duration: durationLabel }) : t("ui.dataTable.pagination.resultsCapped", "Showing {start} to {end} of {total}+ results", { start: startItem, end: endItem, total: pagination.total });
|
|
1910
|
+
}
|
|
1911
|
+
return durationLabel ? t("ui.dataTable.pagination.resultsWithDuration", "Showing {start} to {end} of {total} results in {duration}", { start: startItem, end: endItem, total: pagination.total, duration: durationLabel }) : t("ui.dataTable.pagination.results", "Showing {start} to {end} of {total} results", { start: startItem, end: endItem, total: pagination.total });
|
|
1912
|
+
},
|
|
1900
1913
|
formatPageSizeLabel: (size) => `${size} ${t("ui.dataTable.pagination.perPage", "per page")}`,
|
|
1901
1914
|
"aria-label": t("ui.dataTable.pagination.navAriaLabel", "Table pagination"),
|
|
1902
1915
|
className: "flex-1"
|
|
1903
1916
|
}
|
|
1904
1917
|
)
|
|
1905
1918
|
] });
|
|
1906
|
-
}, [pagination, showQueryTime, measuredDurationMs, scrollTableIntoView, t]);
|
|
1919
|
+
}, [pagination, data, showQueryTime, measuredDurationMs, scrollTableIntoView, t]);
|
|
1907
1920
|
const resolvedEntityIds = React.useMemo(() => {
|
|
1908
1921
|
if (Array.isArray(entityIds) && entityIds.length) {
|
|
1909
1922
|
const dedup = /* @__PURE__ */ new Set();
|