@columenlabs/lumen-ui 0.1.184 → 0.1.185

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.
@@ -65,6 +65,9 @@ export interface ServerPaging {
65
65
  /** The server groups the rows: the Group button offers the domain's groupable fields, and a
66
66
  * group's rows load when it opens. Without it a server's page groups nothing. */
67
67
  groups?: ServerGroups;
68
+ /** Every row for the filter, in the server's order (the server may cap it): Export saves and
69
+ * copies these instead of the one page shown. Left out: Export takes the page. */
70
+ all?: () => Promise<readonly unknown[]>;
68
71
  }
69
72
  /** One group a server counted: its key (the group field's value as the view shows it), its row
70
73
  * count (null: not counted), and, once open, the rows loaded so far. */
@@ -174,7 +177,7 @@ export interface LumenViewProps<T> {
174
177
  * table (the domain's id and `cardId`); left out: `configureLumen({ resizableColumns })`. */
175
178
  resizable?: boolean;
176
179
  /** Every row before the page's filter: Export then offers Filtered or All while a filter hides
177
- * some. Left out (or a server's page): Export takes the rows shown. */
180
+ * some. Left out: Export takes the rows shown, or a server's `paging.all`. */
178
181
  allRows?: T[];
179
182
  }
180
183
  /** What the header's + offers. */
@@ -263,20 +263,33 @@ function useExportScope(key) {
263
263
  * row on every page. On desktop it is an icon button with its menu; on a phone (`items`) its
264
264
  * entries join the card's ⋯ menu.
265
265
  */
266
- function useExport({ name, columns, rows, all, groupBy, sort, hidden, scopeKey, }) {
266
+ function useExport({ name, columns, rows, all, groupBy, sort, hidden, scopeKey, fetchAll, }) {
267
267
  const [picked, setScope] = useExportScope(scopeKey);
268
268
  const split = !!all && all.length !== rows.length;
269
269
  const scope = split ? picked : 'filtered';
270
270
  const chosen = scope === 'all' && all ? all : rows;
271
- const text = () => csvOf({ columns, rows: chosen, groupBy, sort, hidden });
272
- const download = () => text().then((csv) => saveCsv(name, csv));
273
- const n = chosen.length;
274
- const counted = `${n.toLocaleString()} ${n === 1 ? 'row' : 'rows'}`;
271
+ const text = async () => csvOf({
272
+ columns,
273
+ rows: fetchAll ? (await fetchAll()) : chosen,
274
+ groupBy,
275
+ sort,
276
+ hidden,
277
+ });
278
+ const download = () => text().then((csv) => saveCsv(name, csv), () => void toast.error('Could not load every row to export'));
279
+ const n = fetchAll ? null : chosen.length;
280
+ const counted = n == null ? 'Every matching row' : `${n.toLocaleString()} ${n === 1 ? 'row' : 'rows'}`;
275
281
  const copy = async () => {
282
+ let csv;
283
+ try {
284
+ csv = await text();
285
+ }
286
+ catch {
287
+ toast.error('Could not load every row to export');
288
+ return;
289
+ }
276
290
  try {
277
- const csv = await text();
278
291
  await navigator.clipboard.writeText(csv);
279
- toast.success(`Copied ${counted} to the clipboard`);
292
+ toast.success(n == null ? 'Copied every matching row' : `Copied ${counted} to the clipboard`);
280
293
  }
281
294
  catch {
282
295
  toast.error('The browser blocked the copy', {
@@ -337,6 +350,7 @@ export function LumenView({ domain, config, rows, total = rows.length, paging: s
337
350
  sort: config.sort,
338
351
  hidden: amountsHidden,
339
352
  scopeKey: `${domain.id}:${cardId}`,
353
+ fetchAll: server?.all,
340
354
  });
341
355
  const exporter = !pivot && on('download') ? exports : null;
342
356
  const pagination = config.pagination ?? viewPaginationSchema.parse({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.184",
3
+ "version": "0.1.185",
4
4
  "description": "Lumen: shared React components (frame, views, widgets, charts, drawers).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "@codemirror/lang-javascript": "6.2.5",
50
50
  "@codemirror/lang-json": "6.0.2",
51
51
  "@codemirror/lang-sql": "6.10.0",
52
- "@columenlabs/lumen-ui-types": "0.1.184",
52
+ "@columenlabs/lumen-ui-types": "0.1.185",
53
53
  "@dnd-kit/core": "6.3.1",
54
54
  "@dnd-kit/sortable": "10.0.0",
55
55
  "@dnd-kit/utilities": "3.2.2",