@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/dist/index.d.cts CHANGED
@@ -436,6 +436,10 @@ type SelectionChange<T = unknown> = {
436
436
  mode: 'in-memory';
437
437
  ids: string[];
438
438
  rows: T[];
439
+ } | {
440
+ scope: 'all';
441
+ mode: 'in-memory-ids';
442
+ ids: string[];
439
443
  } | {
440
444
  scope: 'all';
441
445
  mode: 'wildcard';
@@ -567,10 +571,17 @@ interface EasyVisionTableProps<T> extends BaseStatefulProps {
567
571
  * the rendered view). Best for flows that need the full id list up
568
572
  * front (preview, reorder, in-memory transforms before submit).
569
573
  *
574
+ * - `'eager-ids'`: like `'eager'` but only materializes ids — row objects
575
+ * are dropped as they are paginated. Emits
576
+ * `{ scope: 'all', mode: 'in-memory-ids', ids: [...full] }` (no `rows`).
577
+ * Same sort lock as `'eager'`. Use when the consumer only needs ids
578
+ * (bulk action by id, export by id) and carrying every row in memory
579
+ * is wasteful — e.g. selections of 50k+ rows.
580
+ *
570
581
  * Has no effect when `paginationMode === 'local'` (the table already
571
582
  * knows the full set in memory).
572
583
  */
573
- selectAllResolution?: 'lazy' | 'eager';
584
+ selectAllResolution?: 'lazy' | 'eager' | 'eager-ids';
574
585
  onSelectionChange?: (event: SelectionChange<T>) => void;
575
586
  isLoading?: boolean;
576
587
  emptyMessage?: string;
package/dist/index.d.ts CHANGED
@@ -436,6 +436,10 @@ type SelectionChange<T = unknown> = {
436
436
  mode: 'in-memory';
437
437
  ids: string[];
438
438
  rows: T[];
439
+ } | {
440
+ scope: 'all';
441
+ mode: 'in-memory-ids';
442
+ ids: string[];
439
443
  } | {
440
444
  scope: 'all';
441
445
  mode: 'wildcard';
@@ -567,10 +571,17 @@ interface EasyVisionTableProps<T> extends BaseStatefulProps {
567
571
  * the rendered view). Best for flows that need the full id list up
568
572
  * front (preview, reorder, in-memory transforms before submit).
569
573
  *
574
+ * - `'eager-ids'`: like `'eager'` but only materializes ids — row objects
575
+ * are dropped as they are paginated. Emits
576
+ * `{ scope: 'all', mode: 'in-memory-ids', ids: [...full] }` (no `rows`).
577
+ * Same sort lock as `'eager'`. Use when the consumer only needs ids
578
+ * (bulk action by id, export by id) and carrying every row in memory
579
+ * is wasteful — e.g. selections of 50k+ rows.
580
+ *
570
581
  * Has no effect when `paginationMode === 'local'` (the table already
571
582
  * knows the full set in memory).
572
583
  */
573
- selectAllResolution?: 'lazy' | 'eager';
584
+ selectAllResolution?: 'lazy' | 'eager' | 'eager-ids';
574
585
  onSelectionChange?: (event: SelectionChange<T>) => void;
575
586
  isLoading?: boolean;
576
587
  emptyMessage?: string;
package/dist/index.js CHANGED
@@ -2269,6 +2269,7 @@ function EasyVisionTable(props) {
2269
2269
  }, [isApi, page, itemsPerPage, sort, refetchSignal]);
2270
2270
  const resolveEagerAll = useCallback(async () => {
2271
2271
  if (!fetchData) return;
2272
+ const collectRows = selectAllResolution === "eager";
2272
2273
  const seq = ++eagerSeqRef.current;
2273
2274
  setIsResolvingEager(true);
2274
2275
  try {
@@ -2297,18 +2298,18 @@ function EasyVisionTable(props) {
2297
2298
  const rid = getRowId(row);
2298
2299
  if (rid) {
2299
2300
  ids.push(rid);
2300
- rowsAcc.push(row);
2301
+ if (collectRows) rowsAcc.push(row);
2301
2302
  }
2302
2303
  }
2303
2304
  if (result.rows.length < PAGE_SIZE) break;
2304
2305
  }
2305
2306
  if (seq !== eagerSeqRef.current) return;
2306
2307
  setEagerAllIds(ids);
2307
- setEagerAllRows(rowsAcc);
2308
+ if (collectRows) setEagerAllRows(rowsAcc);
2308
2309
  } finally {
2309
2310
  if (seq === eagerSeqRef.current) setIsResolvingEager(false);
2310
2311
  }
2311
- }, [fetchData, externalFilter, sort, getRowId]);
2312
+ }, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
2312
2313
  const prevRefetchRef = useRef(refetchSignal);
2313
2314
  useEffect(() => {
2314
2315
  if (prevRefetchRef.current !== refetchSignal && page !== 1) {
@@ -2391,7 +2392,7 @@ function EasyVisionTable(props) {
2391
2392
  return r;
2392
2393
  }, [selection]);
2393
2394
  const sortingState = sort ? [{ id: sort.column, desc: sort.descending }] : [];
2394
- const isEagerWildcard = selectAllResolution === "eager" && isApi && selection.scope === "all";
2395
+ const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
2395
2396
  const tableInstance = useReactTable({
2396
2397
  data: rows,
2397
2398
  columns: allColumns,
@@ -2466,6 +2467,19 @@ function EasyVisionTable(props) {
2466
2467
  outRows = eagerAllRows;
2467
2468
  }
2468
2469
  event = { scope: "all", mode: "in-memory", ids, rows: outRows };
2470
+ } else if (selectAllResolution === "eager-ids" && eagerAllIds) {
2471
+ const exceptSet = new Set(Object.keys(selection.exceptIds ?? {}));
2472
+ let ids;
2473
+ if (exceptSet.size) {
2474
+ ids = [];
2475
+ for (const rid of eagerAllIds) {
2476
+ if (exceptSet.has(rid)) continue;
2477
+ ids.push(rid);
2478
+ }
2479
+ } else {
2480
+ ids = eagerAllIds;
2481
+ }
2482
+ event = { scope: "all", mode: "in-memory-ids", ids };
2469
2483
  } else {
2470
2484
  const exceptIds = Object.keys(selection.exceptIds ?? {});
2471
2485
  const exceptSet = new Set(exceptIds);
@@ -2485,7 +2499,10 @@ function EasyVisionTable(props) {
2485
2499
  const selectedRows = rows.filter((r) => idSet.has(getRowId(r)));
2486
2500
  event = { scope: "page", ids, rows: selectedRows };
2487
2501
  }
2488
- const key = JSON.stringify({ ...event, rows: event.rows.length });
2502
+ const key = JSON.stringify({
2503
+ ...event,
2504
+ rows: "rows" in event ? event.rows.length : 0
2505
+ });
2489
2506
  if (key === lastSelectionEmittedRef.current) return;
2490
2507
  lastSelectionEmittedRef.current = key;
2491
2508
  onSelectionChange?.(event);
@@ -2554,7 +2571,7 @@ function EasyVisionTable(props) {
2554
2571
  (scope) => {
2555
2572
  if (scope === "all") {
2556
2573
  patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
2557
- if (selectAllResolution === "eager" && isApi) {
2574
+ if ((selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi) {
2558
2575
  setEagerAllIds(null);
2559
2576
  setEagerAllRows([]);
2560
2577
  void resolveEagerAll();