@sincpro/web-framework 3.14.0 → 3.15.0
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.
|
@@ -73,6 +73,11 @@ export type Listing<T, C extends CommandBodies = CommandBodies> = {
|
|
|
73
73
|
};
|
|
74
74
|
next: () => void;
|
|
75
75
|
prev: () => void;
|
|
76
|
+
/** Rows per page from now on — the page's range, touched and typed. Another size is another
|
|
77
|
+
* question: it starts on the first page, its search, filter and order kept. Between 1 and
|
|
78
|
+
* `maxRows`: a page is what the DOM holds, and a size past that is the frozen screen
|
|
79
|
+
* `pages` exists to avoid. */
|
|
80
|
+
resize: (size: number) => void;
|
|
76
81
|
/** `more` mode reached its ceiling: refine the search instead of loading on. */
|
|
77
82
|
capped: boolean;
|
|
78
83
|
};
|
package/dist/react/useListing.js
CHANGED
|
@@ -65,6 +65,8 @@ export function useListing(given, own = {}) {
|
|
|
65
65
|
criteria = merge(criteria, { selection: next.selection });
|
|
66
66
|
if (next.order.length > 0)
|
|
67
67
|
criteria = merge(criteria, { order: [...next.order] });
|
|
68
|
+
if (next.size !== undefined)
|
|
69
|
+
criteria = { ...criteria, pagination: { ...criteria.pagination, limit: next.size } };
|
|
68
70
|
return criteria;
|
|
69
71
|
};
|
|
70
72
|
const refine = useCallback((next) => {
|
|
@@ -92,6 +94,7 @@ export function useListing(given, own = {}) {
|
|
|
92
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
95
|
}, [meta]);
|
|
94
96
|
const index = cursors.length - 1;
|
|
97
|
+
const pageSize = narrowing.size ?? size;
|
|
95
98
|
const turn = (to) => {
|
|
96
99
|
setCursors(to);
|
|
97
100
|
void reading.refine(resumingFrom(narrowed(narrowing), to[to.length - 1] ?? null));
|
|
@@ -142,9 +145,9 @@ export function useListing(given, own = {}) {
|
|
|
142
145
|
paging,
|
|
143
146
|
page: {
|
|
144
147
|
index,
|
|
145
|
-
size,
|
|
146
|
-
from: reading.rows.length === 0 ? 0 : index *
|
|
147
|
-
to: index *
|
|
148
|
+
size: pageSize,
|
|
149
|
+
from: reading.rows.length === 0 ? 0 : index * pageSize + 1,
|
|
150
|
+
to: index * pageSize + reading.rows.length,
|
|
148
151
|
hasPrev: paging === "pages" && index > 0,
|
|
149
152
|
hasNext: paging === "pages" && reading.cursor !== null,
|
|
150
153
|
cursors,
|
|
@@ -158,6 +161,12 @@ export function useListing(given, own = {}) {
|
|
|
158
161
|
if (paging === "pages" && index > 0)
|
|
159
162
|
turn(cursors.slice(0, -1));
|
|
160
163
|
},
|
|
164
|
+
resize: (next) => {
|
|
165
|
+
const rows = Math.min(maxRows, Math.max(1, Math.floor(next)));
|
|
166
|
+
if (!Number.isFinite(rows) || rows === pageSize)
|
|
167
|
+
return;
|
|
168
|
+
narrow({ size: rows }, false);
|
|
169
|
+
},
|
|
161
170
|
capped,
|
|
162
171
|
};
|
|
163
172
|
}
|
|
@@ -458,7 +458,10 @@ export function EntityList({ listing, api, columns: askedColumns, cells, yesNo,
|
|
|
458
458
|
const fits = embedded && !partial;
|
|
459
459
|
const through = grouped ? (groups.status !== "ready" ? null : (_jsx("span", { className: "text-meta text-muted", children: groups.capped
|
|
460
460
|
? copy.groupsCapped(groups.buckets.length)
|
|
461
|
-
: copy.groups(groups.buckets.length, records) }))) : fits ? null : listing.paging === "pages" ? (page.from === 0 ? null : (_jsx(Pagination, { from: page.from, to: page.to, total: count?.value ?? page.to,
|
|
461
|
+
: copy.groups(groups.buckets.length, records) }))) : fits ? null : listing.paging === "pages" ? (page.from === 0 ? null : (_jsx(Pagination, { from: page.from, to: page.to, total: count?.value ?? page.to,
|
|
462
|
+
/* The range is touched to choose how many rows fit — in both styles. Without these two
|
|
463
|
+
the modern pill and the plain range drew a size nobody could change. */
|
|
464
|
+
pageSize: page.size, onPageSizeChange: listing.resize, ...(page.hasPrev ? { onPrev: listing.prev } : {}), ...(page.hasNext ? { onNext: listing.next } : {}) }))) : (_jsxs(_Fragment, { children: [count === null ? null : (_jsx("span", { className: "text-meta text-muted", children: copy.shown(listing.rows.length, count.value, count.exact) })), listing.capped ? (_jsx("span", { className: "text-meta text-muted", children: copy.capped(listing.rows.length) })) : listing.hasMore ? (_jsx(Button, { size: "sm", role: "secondary", disabled: listing.status === "loadingMore", onClick: listing.more, children: listing.status === "loadingMore" ? copy.loading : copy.loadMore })) : null] }));
|
|
462
465
|
const pageTotals = totalled && partial && present === "table";
|
|
463
466
|
// Written only when it says something: web-ui draws an embedded list's bar for any slot
|
|
464
467
|
// written, an empty one too. Its parts side by side and apart: the slot does not space them,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "The web client of sincpro_framework: entities, lists and records bound to the metadata the server publishes, drawn with @sincpro/web-ui and arranged with @sincpro/web-composer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|