@easyvision/easyvision-ui 1.7.2 → 1.7.3

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 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,36 @@ 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
+
927
946
  Trade-offs:
928
947
 
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 |
948
+ | Mode | Network on select-all | Memory per selection | Reorder while selected | Untick individual rows | Best for |
949
+ |---|---|---|---|---|---|
950
+ | `'lazy'` (default) | none | O(page) | free | via `exceptIds` | export / submit flows; no list manipulation |
951
+ | `'eager'` | one paginated sweep | O(all ids + all rows) | locked | via header toggle (adds visible rows to `exceptIds`) | preview / reorder / transform before submit; one-line consumer code |
952
+ | `'eager-ids'` | one paginated sweep | 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
953
 
934
954
  Has no effect when `paginationMode === 'local'` (the table already knows the full set).
935
955
 
@@ -1070,7 +1090,7 @@ The toolbar row is hidden entirely when none of `toolbarLeft`, `toolbarRight`, o
1070
1090
  | `paginationDisplay` | `'always' \| 'fixedItemsPerPage' \| 'fixedTotalItems'` | `'always'` — footer rendering mode; see [Pagination footer modes](#pagination-footer-modes) |
1071
1091
  | `enableRowSelection` | `boolean` | `false` |
1072
1092
  | `selectAllScope` | `'page' \| 'all' \| 'toggleable'` | `'toggleable'` |
1073
- | `selectAllResolution` | `'lazy' \| 'eager'` | `'lazy'` — `'eager'` materializes the full id list on wildcard select-all and locks sort while active |
1093
+ | `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
1094
  | `onSelectionChange` | `(event) => void` | — |
1075
1095
  | `isLoading` | `boolean` | `false` |
1076
1096
  | `emptyMessage` | `string` | labels.noData |
package/dist/index.cjs CHANGED
@@ -2294,6 +2294,7 @@ function EasyVisionTable(props) {
2294
2294
  }, [isApi, page, itemsPerPage, sort, refetchSignal]);
2295
2295
  const resolveEagerAll = React8.useCallback(async () => {
2296
2296
  if (!fetchData) return;
2297
+ const collectRows = selectAllResolution === "eager";
2297
2298
  const seq = ++eagerSeqRef.current;
2298
2299
  setIsResolvingEager(true);
2299
2300
  try {
@@ -2322,18 +2323,18 @@ function EasyVisionTable(props) {
2322
2323
  const rid = getRowId(row);
2323
2324
  if (rid) {
2324
2325
  ids.push(rid);
2325
- rowsAcc.push(row);
2326
+ if (collectRows) rowsAcc.push(row);
2326
2327
  }
2327
2328
  }
2328
2329
  if (result.rows.length < PAGE_SIZE) break;
2329
2330
  }
2330
2331
  if (seq !== eagerSeqRef.current) return;
2331
2332
  setEagerAllIds(ids);
2332
- setEagerAllRows(rowsAcc);
2333
+ if (collectRows) setEagerAllRows(rowsAcc);
2333
2334
  } finally {
2334
2335
  if (seq === eagerSeqRef.current) setIsResolvingEager(false);
2335
2336
  }
2336
- }, [fetchData, externalFilter, sort, getRowId]);
2337
+ }, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
2337
2338
  const prevRefetchRef = React8.useRef(refetchSignal);
2338
2339
  React8.useEffect(() => {
2339
2340
  if (prevRefetchRef.current !== refetchSignal && page !== 1) {
@@ -2416,7 +2417,7 @@ function EasyVisionTable(props) {
2416
2417
  return r;
2417
2418
  }, [selection]);
2418
2419
  const sortingState = sort ? [{ id: sort.column, desc: sort.descending }] : [];
2419
- const isEagerWildcard = selectAllResolution === "eager" && isApi && selection.scope === "all";
2420
+ const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
2420
2421
  const tableInstance = reactTable.useReactTable({
2421
2422
  data: rows,
2422
2423
  columns: allColumns,
@@ -2491,6 +2492,19 @@ function EasyVisionTable(props) {
2491
2492
  outRows = eagerAllRows;
2492
2493
  }
2493
2494
  event = { scope: "all", mode: "in-memory", ids, rows: outRows };
2495
+ } else if (selectAllResolution === "eager-ids" && eagerAllIds) {
2496
+ const exceptSet = new Set(Object.keys(selection.exceptIds ?? {}));
2497
+ let ids;
2498
+ if (exceptSet.size) {
2499
+ ids = [];
2500
+ for (const rid of eagerAllIds) {
2501
+ if (exceptSet.has(rid)) continue;
2502
+ ids.push(rid);
2503
+ }
2504
+ } else {
2505
+ ids = eagerAllIds;
2506
+ }
2507
+ event = { scope: "all", mode: "in-memory-ids", ids };
2494
2508
  } else {
2495
2509
  const exceptIds = Object.keys(selection.exceptIds ?? {});
2496
2510
  const exceptSet = new Set(exceptIds);
@@ -2510,7 +2524,10 @@ function EasyVisionTable(props) {
2510
2524
  const selectedRows = rows.filter((r) => idSet.has(getRowId(r)));
2511
2525
  event = { scope: "page", ids, rows: selectedRows };
2512
2526
  }
2513
- const key = JSON.stringify({ ...event, rows: event.rows.length });
2527
+ const key = JSON.stringify({
2528
+ ...event,
2529
+ rows: "rows" in event ? event.rows.length : 0
2530
+ });
2514
2531
  if (key === lastSelectionEmittedRef.current) return;
2515
2532
  lastSelectionEmittedRef.current = key;
2516
2533
  onSelectionChange?.(event);
@@ -2579,7 +2596,7 @@ function EasyVisionTable(props) {
2579
2596
  (scope) => {
2580
2597
  if (scope === "all") {
2581
2598
  patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
2582
- if (selectAllResolution === "eager" && isApi) {
2599
+ if ((selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi) {
2583
2600
  setEagerAllIds(null);
2584
2601
  setEagerAllRows([]);
2585
2602
  void resolveEagerAll();