@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/dist/index.d.cts CHANGED
@@ -308,8 +308,14 @@ interface CreateLoopbackTableFetcherOptions<T> {
308
308
  fields?: string[];
309
309
  /** Order applied when the table has no active sort. */
310
310
  defaultOrder?: string[];
311
+ /**
312
+ * Field(s) requested when the table sets `idsOnly` (eager-ids select-all
313
+ * resolution). Defaults to `['id']`. Override if your model's primary key
314
+ * is named differently or if `getRowId` reads from another property.
315
+ */
316
+ idFields?: string[];
311
317
  }
312
- declare function createLoopbackTableFetcher<T = unknown>(opts: CreateLoopbackTableFetcherOptions<T>): ({ page, itemsPerPage, sort, filter, }: ApiFetchParams) => Promise<ApiFetchResult<T>>;
318
+ declare function createLoopbackTableFetcher<T = unknown>(opts: CreateLoopbackTableFetcherOptions<T>): ({ page, itemsPerPage, sort, filter, idsOnly, }: ApiFetchParams) => Promise<ApiFetchResult<T>>;
313
319
  /**
314
320
  * Evaluate a LoopBack `where` clause against a single row, returning `true`
315
321
  * iff the row satisfies the clause.
@@ -422,6 +428,13 @@ interface ApiFetchParams {
422
428
  } | null;
423
429
  /** Latest perform-confirmed multifilter query, when a multifilter is bound. */
424
430
  filter?: MultifilterQuery;
431
+ /**
432
+ * Hint that only the row id is needed. Set by the table during eager-ids
433
+ * select-all resolution so adapters can shrink the wire payload (e.g.
434
+ * Loopback's `fields: ['id']`, skipping `include`). Adapters that ignore
435
+ * this still work — they just send full rows that the table discards.
436
+ */
437
+ idsOnly?: boolean;
425
438
  }
426
439
  interface ApiFetchResult<T> {
427
440
  rows: T[];
@@ -436,6 +449,10 @@ type SelectionChange<T = unknown> = {
436
449
  mode: 'in-memory';
437
450
  ids: string[];
438
451
  rows: T[];
452
+ } | {
453
+ scope: 'all';
454
+ mode: 'in-memory-ids';
455
+ ids: string[];
439
456
  } | {
440
457
  scope: 'all';
441
458
  mode: 'wildcard';
@@ -567,10 +584,17 @@ interface EasyVisionTableProps<T> extends BaseStatefulProps {
567
584
  * the rendered view). Best for flows that need the full id list up
568
585
  * front (preview, reorder, in-memory transforms before submit).
569
586
  *
587
+ * - `'eager-ids'`: like `'eager'` but only materializes ids — row objects
588
+ * are dropped as they are paginated. Emits
589
+ * `{ scope: 'all', mode: 'in-memory-ids', ids: [...full] }` (no `rows`).
590
+ * Same sort lock as `'eager'`. Use when the consumer only needs ids
591
+ * (bulk action by id, export by id) and carrying every row in memory
592
+ * is wasteful — e.g. selections of 50k+ rows.
593
+ *
570
594
  * Has no effect when `paginationMode === 'local'` (the table already
571
595
  * knows the full set in memory).
572
596
  */
573
- selectAllResolution?: 'lazy' | 'eager';
597
+ selectAllResolution?: 'lazy' | 'eager' | 'eager-ids';
574
598
  onSelectionChange?: (event: SelectionChange<T>) => void;
575
599
  isLoading?: boolean;
576
600
  emptyMessage?: string;
package/dist/index.d.ts CHANGED
@@ -308,8 +308,14 @@ interface CreateLoopbackTableFetcherOptions<T> {
308
308
  fields?: string[];
309
309
  /** Order applied when the table has no active sort. */
310
310
  defaultOrder?: string[];
311
+ /**
312
+ * Field(s) requested when the table sets `idsOnly` (eager-ids select-all
313
+ * resolution). Defaults to `['id']`. Override if your model's primary key
314
+ * is named differently or if `getRowId` reads from another property.
315
+ */
316
+ idFields?: string[];
311
317
  }
312
- declare function createLoopbackTableFetcher<T = unknown>(opts: CreateLoopbackTableFetcherOptions<T>): ({ page, itemsPerPage, sort, filter, }: ApiFetchParams) => Promise<ApiFetchResult<T>>;
318
+ declare function createLoopbackTableFetcher<T = unknown>(opts: CreateLoopbackTableFetcherOptions<T>): ({ page, itemsPerPage, sort, filter, idsOnly, }: ApiFetchParams) => Promise<ApiFetchResult<T>>;
313
319
  /**
314
320
  * Evaluate a LoopBack `where` clause against a single row, returning `true`
315
321
  * iff the row satisfies the clause.
@@ -422,6 +428,13 @@ interface ApiFetchParams {
422
428
  } | null;
423
429
  /** Latest perform-confirmed multifilter query, when a multifilter is bound. */
424
430
  filter?: MultifilterQuery;
431
+ /**
432
+ * Hint that only the row id is needed. Set by the table during eager-ids
433
+ * select-all resolution so adapters can shrink the wire payload (e.g.
434
+ * Loopback's `fields: ['id']`, skipping `include`). Adapters that ignore
435
+ * this still work — they just send full rows that the table discards.
436
+ */
437
+ idsOnly?: boolean;
425
438
  }
426
439
  interface ApiFetchResult<T> {
427
440
  rows: T[];
@@ -436,6 +449,10 @@ type SelectionChange<T = unknown> = {
436
449
  mode: 'in-memory';
437
450
  ids: string[];
438
451
  rows: T[];
452
+ } | {
453
+ scope: 'all';
454
+ mode: 'in-memory-ids';
455
+ ids: string[];
439
456
  } | {
440
457
  scope: 'all';
441
458
  mode: 'wildcard';
@@ -567,10 +584,17 @@ interface EasyVisionTableProps<T> extends BaseStatefulProps {
567
584
  * the rendered view). Best for flows that need the full id list up
568
585
  * front (preview, reorder, in-memory transforms before submit).
569
586
  *
587
+ * - `'eager-ids'`: like `'eager'` but only materializes ids — row objects
588
+ * are dropped as they are paginated. Emits
589
+ * `{ scope: 'all', mode: 'in-memory-ids', ids: [...full] }` (no `rows`).
590
+ * Same sort lock as `'eager'`. Use when the consumer only needs ids
591
+ * (bulk action by id, export by id) and carrying every row in memory
592
+ * is wasteful — e.g. selections of 50k+ rows.
593
+ *
570
594
  * Has no effect when `paginationMode === 'local'` (the table already
571
595
  * knows the full set in memory).
572
596
  */
573
- selectAllResolution?: 'lazy' | 'eager';
597
+ selectAllResolution?: 'lazy' | 'eager' | 'eager-ids';
574
598
  onSelectionChange?: (event: SelectionChange<T>) => void;
575
599
  isLoading?: boolean;
576
600
  emptyMessage?: string;
package/dist/index.js CHANGED
@@ -1986,23 +1986,26 @@ function ColumnVisibilityMenu({ table, label }) {
1986
1986
 
1987
1987
  // adapters/loopback.ts
1988
1988
  function createLoopbackTableFetcher(opts) {
1989
- const { fetchPage, fetchCount, include, fields, defaultOrder } = opts;
1989
+ const { fetchPage, fetchCount, include, fields, defaultOrder, idFields } = opts;
1990
1990
  return async ({
1991
1991
  page,
1992
1992
  itemsPerPage,
1993
1993
  sort,
1994
- filter
1994
+ filter,
1995
+ idsOnly
1995
1996
  }) => {
1996
1997
  const order = sort ? [`${sort.column} ${sort.descending ? "DESC" : "ASC"}`] : defaultOrder ?? [];
1997
1998
  const skip = (page - 1) * itemsPerPage;
1998
1999
  const where = filter?.where ?? {};
2000
+ const effectiveFields = idsOnly ? idFields ?? ["id"] : fields;
2001
+ const effectiveInclude = idsOnly ? void 0 : include;
1999
2002
  const pageFilter = {
2000
2003
  where,
2001
2004
  skip,
2002
2005
  limit: itemsPerPage,
2003
2006
  order,
2004
- ...include ? { include } : {},
2005
- ...fields ? { fields } : {}
2007
+ ...effectiveInclude ? { include: effectiveInclude } : {},
2008
+ ...effectiveFields ? { fields: effectiveFields } : {}
2006
2009
  };
2007
2010
  const [rows, count] = await Promise.all([
2008
2011
  fetchPage(pageFilter),
@@ -2269,6 +2272,7 @@ function EasyVisionTable(props) {
2269
2272
  }, [isApi, page, itemsPerPage, sort, refetchSignal]);
2270
2273
  const resolveEagerAll = useCallback(async () => {
2271
2274
  if (!fetchData) return;
2275
+ const collectRows = selectAllResolution === "eager";
2272
2276
  const seq = ++eagerSeqRef.current;
2273
2277
  setIsResolvingEager(true);
2274
2278
  try {
@@ -2289,7 +2293,8 @@ function EasyVisionTable(props) {
2289
2293
  page: p,
2290
2294
  itemsPerPage: PAGE_SIZE,
2291
2295
  sort,
2292
- filter: merged
2296
+ filter: merged,
2297
+ idsOnly: !collectRows
2293
2298
  });
2294
2299
  if (seq !== eagerSeqRef.current) return;
2295
2300
  knownTotal = result.totalCount;
@@ -2297,18 +2302,18 @@ function EasyVisionTable(props) {
2297
2302
  const rid = getRowId(row);
2298
2303
  if (rid) {
2299
2304
  ids.push(rid);
2300
- rowsAcc.push(row);
2305
+ if (collectRows) rowsAcc.push(row);
2301
2306
  }
2302
2307
  }
2303
2308
  if (result.rows.length < PAGE_SIZE) break;
2304
2309
  }
2305
2310
  if (seq !== eagerSeqRef.current) return;
2306
2311
  setEagerAllIds(ids);
2307
- setEagerAllRows(rowsAcc);
2312
+ if (collectRows) setEagerAllRows(rowsAcc);
2308
2313
  } finally {
2309
2314
  if (seq === eagerSeqRef.current) setIsResolvingEager(false);
2310
2315
  }
2311
- }, [fetchData, externalFilter, sort, getRowId]);
2316
+ }, [fetchData, externalFilter, sort, getRowId, selectAllResolution]);
2312
2317
  const prevRefetchRef = useRef(refetchSignal);
2313
2318
  useEffect(() => {
2314
2319
  if (prevRefetchRef.current !== refetchSignal && page !== 1) {
@@ -2391,7 +2396,7 @@ function EasyVisionTable(props) {
2391
2396
  return r;
2392
2397
  }, [selection]);
2393
2398
  const sortingState = sort ? [{ id: sort.column, desc: sort.descending }] : [];
2394
- const isEagerWildcard = selectAllResolution === "eager" && isApi && selection.scope === "all";
2399
+ const isEagerWildcard = (selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi && selection.scope === "all";
2395
2400
  const tableInstance = useReactTable({
2396
2401
  data: rows,
2397
2402
  columns: allColumns,
@@ -2466,6 +2471,19 @@ function EasyVisionTable(props) {
2466
2471
  outRows = eagerAllRows;
2467
2472
  }
2468
2473
  event = { scope: "all", mode: "in-memory", ids, rows: outRows };
2474
+ } else if (selectAllResolution === "eager-ids" && eagerAllIds) {
2475
+ const exceptSet = new Set(Object.keys(selection.exceptIds ?? {}));
2476
+ let ids;
2477
+ if (exceptSet.size) {
2478
+ ids = [];
2479
+ for (const rid of eagerAllIds) {
2480
+ if (exceptSet.has(rid)) continue;
2481
+ ids.push(rid);
2482
+ }
2483
+ } else {
2484
+ ids = eagerAllIds;
2485
+ }
2486
+ event = { scope: "all", mode: "in-memory-ids", ids };
2469
2487
  } else {
2470
2488
  const exceptIds = Object.keys(selection.exceptIds ?? {});
2471
2489
  const exceptSet = new Set(exceptIds);
@@ -2485,7 +2503,10 @@ function EasyVisionTable(props) {
2485
2503
  const selectedRows = rows.filter((r) => idSet.has(getRowId(r)));
2486
2504
  event = { scope: "page", ids, rows: selectedRows };
2487
2505
  }
2488
- const key = JSON.stringify({ ...event, rows: event.rows.length });
2506
+ const key = JSON.stringify({
2507
+ ...event,
2508
+ rows: "rows" in event ? event.rows.length : 0
2509
+ });
2489
2510
  if (key === lastSelectionEmittedRef.current) return;
2490
2511
  lastSelectionEmittedRef.current = key;
2491
2512
  onSelectionChange?.(event);
@@ -2554,7 +2575,7 @@ function EasyVisionTable(props) {
2554
2575
  (scope) => {
2555
2576
  if (scope === "all") {
2556
2577
  patch({ selection: { ids: {}, scope: "all", exceptIds: {} } });
2557
- if (selectAllResolution === "eager" && isApi) {
2578
+ if ((selectAllResolution === "eager" || selectAllResolution === "eager-ids") && isApi) {
2558
2579
  setEagerAllIds(null);
2559
2580
  setEagerAllRows([]);
2560
2581
  void resolveEagerAll();