@easyvision/easyvision-ui 1.7.2 → 1.7.4
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/README.md +30 -8
- package/dist/index.cjs +32 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +32 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -901,14 +901,14 @@ type SelectionChange<T> =
|
|
|
901
901
|
|
|
902
902
|
`'toggleable'` is the default UX: a chevron next to the header checkbox lets the user switch between "select page" and "select all". When the bound multifilter performs a new search, an `'all'` selection is cleared automatically (it would otherwise be stale).
|
|
903
903
|
|
|
904
|
-
#### `selectAllResolution`: lazy vs eager wildcard
|
|
904
|
+
#### `selectAllResolution`: lazy vs eager vs eager-ids wildcard
|
|
905
905
|
|
|
906
906
|
By default, "select all matching" in api mode emits a `wildcard` event (the host page is responsible for materializing the full id list when needed). Pages that need the full id list **up front** — e.g. to preview, reorder, or run in-memory transforms before submitting — can opt into eager resolution:
|
|
907
907
|
|
|
908
908
|
```tsx
|
|
909
909
|
<EasyVisionTable
|
|
910
910
|
enableRowSelection
|
|
911
|
-
selectAllResolution="eager" // 'lazy' (default) | 'eager'
|
|
911
|
+
selectAllResolution="eager" // 'lazy' (default) | 'eager' | 'eager-ids'
|
|
912
912
|
onSelectionChange={(event) => {
|
|
913
913
|
// In eager mode, wildcard becomes mode: 'in-memory' with the full id list.
|
|
914
914
|
setSelectedIds(event.ids); // ← always complete; no resolveSelection helper needed
|
|
@@ -920,16 +920,38 @@ By default, "select all matching" in api mode emits a `wildcard` event (the host
|
|
|
920
920
|
What changes in `'eager'` mode (api only):
|
|
921
921
|
- The moment the user enters `'all'` scope, the table paginates `fetchData` with the active filter and captures every matching id.
|
|
922
922
|
- The selection banner shows a spinner + "Cargando…" while resolving.
|
|
923
|
-
- Once resolved, `onSelectionChange` fires with `{ scope: 'all', mode: 'in-memory', ids: [...full] }` (no `exceptIds`, no `wildcard`).
|
|
923
|
+
- Once resolved, `onSelectionChange` fires with `{ scope: 'all', mode: 'in-memory', ids: [...full], rows: [...full] }` (no `exceptIds`, no `wildcard`).
|
|
924
924
|
- **Column sorting is locked while a wildcard selection is active** — otherwise the captured id order would silently desync from the rendered view. Clearing the selection unlocks sort.
|
|
925
925
|
- The cache is invalidated on multifilter perform, on `refetchSignal` change, and when leaving `'all'` scope; the next entry re-materializes.
|
|
926
926
|
|
|
927
|
+
`'eager-ids'` is the same flow as `'eager'` but drops row objects during pagination — only the id list is materialized:
|
|
928
|
+
|
|
929
|
+
```tsx
|
|
930
|
+
<EasyVisionTable
|
|
931
|
+
enableRowSelection
|
|
932
|
+
selectAllResolution="eager-ids"
|
|
933
|
+
onSelectionChange={(event) => {
|
|
934
|
+
if (event.scope === 'all' && event.mode === 'in-memory-ids') {
|
|
935
|
+
// event.ids is the full set. event.rows does not exist on this variant —
|
|
936
|
+
// TypeScript will error if you try to read it.
|
|
937
|
+
deleteByIds(event.ids);
|
|
938
|
+
}
|
|
939
|
+
}}
|
|
940
|
+
loopback={{ ... }}
|
|
941
|
+
/>
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
Use `'eager-ids'` when the consumer only needs ids (bulk action by id, export by id, submit-by-id) and selections can reach the tens of thousands — `'eager'` would carry every row object across all pages, which is wasteful at that scale.
|
|
945
|
+
|
|
946
|
+
**Wire-level payload reduction.** During eager-ids resolution the table sets `idsOnly: true` on each `fetchData` call. The built-in loopback adapter honors this by requesting `fields: ['id']` and dropping `include` for those calls — so the server returns only id objects, not full rows, dramatically shrinking the network payload for large selections. Custom `fetchData` implementations can read `params.idsOnly` and apply the same optimization (or ignore it — they'll still work, just sending more bytes than needed). The loopback adapter accepts an `idFields?: string[]` option (defaults to `['id']`) if your model's primary key is named differently.
|
|
947
|
+
|
|
927
948
|
Trade-offs:
|
|
928
949
|
|
|
929
|
-
| Mode | Network on select-all | Reorder while selected | Untick individual rows | Best for |
|
|
930
|
-
|
|
931
|
-
| `'lazy'` (default) | none | free | via `exceptIds` | export / submit flows; no list manipulation |
|
|
932
|
-
| `'eager'` | one paginated sweep | locked | via header toggle (adds visible rows to `exceptIds`) | preview / reorder / transform before submit; one-line consumer code |
|
|
950
|
+
| Mode | Network on select-all | Memory per selection | Reorder while selected | Untick individual rows | Best for |
|
|
951
|
+
|---|---|---|---|---|---|
|
|
952
|
+
| `'lazy'` (default) | none | O(page) | free | via `exceptIds` | export / submit flows; no list manipulation |
|
|
953
|
+
| `'eager'` | one paginated sweep, full rows | O(all ids + all rows) | locked | via header toggle (adds visible rows to `exceptIds`) | preview / reorder / transform before submit; one-line consumer code |
|
|
954
|
+
| `'eager-ids'` | one paginated sweep, **ids only** (loopback adapter) | O(all ids only) | locked | via header toggle (adds visible rows to `exceptIds`) | bulk action by id at scale (50k+); consumer only needs ids |
|
|
933
955
|
|
|
934
956
|
Has no effect when `paginationMode === 'local'` (the table already knows the full set).
|
|
935
957
|
|
|
@@ -1070,7 +1092,7 @@ The toolbar row is hidden entirely when none of `toolbarLeft`, `toolbarRight`, o
|
|
|
1070
1092
|
| `paginationDisplay` | `'always' \| 'fixedItemsPerPage' \| 'fixedTotalItems'` | `'always'` — footer rendering mode; see [Pagination footer modes](#pagination-footer-modes) |
|
|
1071
1093
|
| `enableRowSelection` | `boolean` | `false` |
|
|
1072
1094
|
| `selectAllScope` | `'page' \| 'all' \| 'toggleable'` | `'toggleable'` |
|
|
1073
|
-
| `selectAllResolution` | `'lazy' \| 'eager'` | `'lazy'` — `'eager'` materializes the full id list on wildcard select-all
|
|
1095
|
+
| `selectAllResolution` | `'lazy' \| 'eager' \| 'eager-ids'` | `'lazy'` — `'eager'` materializes the full id list + rows on wildcard select-all (locks sort); `'eager-ids'` is the same but skips row materialization, for bulk-by-id flows at scale |
|
|
1074
1096
|
| `onSelectionChange` | `(event) => void` | — |
|
|
1075
1097
|
| `isLoading` | `boolean` | `false` |
|
|
1076
1098
|
| `emptyMessage` | `string` | labels.noData |
|
package/dist/index.cjs
CHANGED
|
@@ -2011,23 +2011,26 @@ function ColumnVisibilityMenu({ table, label }) {
|
|
|
2011
2011
|
|
|
2012
2012
|
// adapters/loopback.ts
|
|
2013
2013
|
function createLoopbackTableFetcher(opts) {
|
|
2014
|
-
const { fetchPage, fetchCount, include, fields, defaultOrder } = opts;
|
|
2014
|
+
const { fetchPage, fetchCount, include, fields, defaultOrder, idFields } = opts;
|
|
2015
2015
|
return async ({
|
|
2016
2016
|
page,
|
|
2017
2017
|
itemsPerPage,
|
|
2018
2018
|
sort,
|
|
2019
|
-
filter
|
|
2019
|
+
filter,
|
|
2020
|
+
idsOnly
|
|
2020
2021
|
}) => {
|
|
2021
2022
|
const order = sort ? [`${sort.column} ${sort.descending ? "DESC" : "ASC"}`] : defaultOrder ?? [];
|
|
2022
2023
|
const skip = (page - 1) * itemsPerPage;
|
|
2023
2024
|
const where = filter?.where ?? {};
|
|
2025
|
+
const effectiveFields = idsOnly ? idFields ?? ["id"] : fields;
|
|
2026
|
+
const effectiveInclude = idsOnly ? void 0 : include;
|
|
2024
2027
|
const pageFilter = {
|
|
2025
2028
|
where,
|
|
2026
2029
|
skip,
|
|
2027
2030
|
limit: itemsPerPage,
|
|
2028
2031
|
order,
|
|
2029
|
-
...
|
|
2030
|
-
...
|
|
2032
|
+
...effectiveInclude ? { include: effectiveInclude } : {},
|
|
2033
|
+
...effectiveFields ? { fields: effectiveFields } : {}
|
|
2031
2034
|
};
|
|
2032
2035
|
const [rows, count] = await Promise.all([
|
|
2033
2036
|
fetchPage(pageFilter),
|
|
@@ -2294,6 +2297,7 @@ function EasyVisionTable(props) {
|
|
|
2294
2297
|
}, [isApi, page, itemsPerPage, sort, refetchSignal]);
|
|
2295
2298
|
const resolveEagerAll = React8.useCallback(async () => {
|
|
2296
2299
|
if (!fetchData) return;
|
|
2300
|
+
const collectRows = selectAllResolution === "eager";
|
|
2297
2301
|
const seq = ++eagerSeqRef.current;
|
|
2298
2302
|
setIsResolvingEager(true);
|
|
2299
2303
|
try {
|
|
@@ -2314,7 +2318,8 @@ function EasyVisionTable(props) {
|
|
|
2314
2318
|
page: p,
|
|
2315
2319
|
itemsPerPage: PAGE_SIZE,
|
|
2316
2320
|
sort,
|
|
2317
|
-
filter: merged
|
|
2321
|
+
filter: merged,
|
|
2322
|
+
idsOnly: !collectRows
|
|
2318
2323
|
});
|
|
2319
2324
|
if (seq !== eagerSeqRef.current) return;
|
|
2320
2325
|
knownTotal = result.totalCount;
|
|
@@ -2322,18 +2327,18 @@ function EasyVisionTable(props) {
|
|
|
2322
2327
|
const rid = getRowId(row);
|
|
2323
2328
|
if (rid) {
|
|
2324
2329
|
ids.push(rid);
|
|
2325
|
-
rowsAcc.push(row);
|
|
2330
|
+
if (collectRows) rowsAcc.push(row);
|
|
2326
2331
|
}
|
|
2327
2332
|
}
|
|
2328
2333
|
if (result.rows.length < PAGE_SIZE) break;
|
|
2329
2334
|
}
|
|
2330
2335
|
if (seq !== eagerSeqRef.current) return;
|
|
2331
2336
|
setEagerAllIds(ids);
|
|
2332
|
-
setEagerAllRows(rowsAcc);
|
|
2337
|
+
if (collectRows) setEagerAllRows(rowsAcc);
|
|
2333
2338
|
} finally {
|
|
2334
2339
|
if (seq === eagerSeqRef.current) setIsResolvingEager(false);
|
|
2335
2340
|
}
|
|
2336
|
-
}, [fetchData, externalFilter, sort, getRowId]);
|
|
2341
|
+
}, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
|
|
2337
2342
|
const prevRefetchRef = React8.useRef(refetchSignal);
|
|
2338
2343
|
React8.useEffect(() => {
|
|
2339
2344
|
if (prevRefetchRef.current !== refetchSignal && page !== 1) {
|
|
@@ -2416,7 +2421,7 @@ function EasyVisionTable(props) {
|
|
|
2416
2421
|
return r;
|
|
2417
2422
|
}, [selection]);
|
|
2418
2423
|
const sortingState = sort ? [{ id: sort.column, desc: sort.descending }] : [];
|
|
2419
|
-
const isEagerWildcard = selectAllResolution === "eager" && isApi && selection.scope === "all";
|
|
2424
|
+
const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
|
|
2420
2425
|
const tableInstance = reactTable.useReactTable({
|
|
2421
2426
|
data: rows,
|
|
2422
2427
|
columns: allColumns,
|
|
@@ -2491,6 +2496,19 @@ function EasyVisionTable(props) {
|
|
|
2491
2496
|
outRows = eagerAllRows;
|
|
2492
2497
|
}
|
|
2493
2498
|
event = { scope: "all", mode: "in-memory", ids, rows: outRows };
|
|
2499
|
+
} else if (selectAllResolution === "eager-ids" && eagerAllIds) {
|
|
2500
|
+
const exceptSet = new Set(Object.keys(selection.exceptIds ?? {}));
|
|
2501
|
+
let ids;
|
|
2502
|
+
if (exceptSet.size) {
|
|
2503
|
+
ids = [];
|
|
2504
|
+
for (const rid of eagerAllIds) {
|
|
2505
|
+
if (exceptSet.has(rid)) continue;
|
|
2506
|
+
ids.push(rid);
|
|
2507
|
+
}
|
|
2508
|
+
} else {
|
|
2509
|
+
ids = eagerAllIds;
|
|
2510
|
+
}
|
|
2511
|
+
event = { scope: "all", mode: "in-memory-ids", ids };
|
|
2494
2512
|
} else {
|
|
2495
2513
|
const exceptIds = Object.keys(selection.exceptIds ?? {});
|
|
2496
2514
|
const exceptSet = new Set(exceptIds);
|
|
@@ -2510,7 +2528,10 @@ function EasyVisionTable(props) {
|
|
|
2510
2528
|
const selectedRows = rows.filter((r) => idSet.has(getRowId(r)));
|
|
2511
2529
|
event = { scope: "page", ids, rows: selectedRows };
|
|
2512
2530
|
}
|
|
2513
|
-
const key = JSON.stringify({
|
|
2531
|
+
const key = JSON.stringify({
|
|
2532
|
+
...event,
|
|
2533
|
+
rows: "rows" in event ? event.rows.length : 0
|
|
2534
|
+
});
|
|
2514
2535
|
if (key === lastSelectionEmittedRef.current) return;
|
|
2515
2536
|
lastSelectionEmittedRef.current = key;
|
|
2516
2537
|
onSelectionChange?.(event);
|
|
@@ -2579,7 +2600,7 @@ function EasyVisionTable(props) {
|
|
|
2579
2600
|
(scope) => {
|
|
2580
2601
|
if (scope === "all") {
|
|
2581
2602
|
patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
|
|
2582
|
-
if (selectAllResolution === "eager" && isApi) {
|
|
2603
|
+
if ((selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi) {
|
|
2583
2604
|
setEagerAllIds(null);
|
|
2584
2605
|
setEagerAllRows([]);
|
|
2585
2606
|
void resolveEagerAll();
|