From 914c05ae5c675f43582b614452652fb95ee3de6a Mon Sep 17 00:00:00 2001 From: Marco Schumacher Date: Wed, 27 Mar 2024 13:56:56 +0100 Subject: [PATCH] feat: allow exporting all items --- src/components/export.tsx | 4 ++-- src/misc/csvExport.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/export.tsx b/src/components/export.tsx index 003b35e..8b18123 100644 --- a/src/components/export.tsx +++ b/src/components/export.tsx @@ -21,11 +21,11 @@ export function Export(): JSX.Element { const [anchor, setAnchor] = useState(null); const generate = (options?: CsvExportOptions) => { - const { activeColumns, activeItems } = table.getState(); + const { activeColumns, activeItems, items } = table.getState(); const data = [ activeColumns.map((column) => String(column.id)), - ...activeItems.map((item) => + ...(options?.all ? items : activeItems).map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)), ), ]; diff --git a/src/misc/csvExport.ts b/src/misc/csvExport.ts index 1934893..d370c48 100644 --- a/src/misc/csvExport.ts +++ b/src/misc/csvExport.ts @@ -3,6 +3,7 @@ export type CsvExportOptions = { separator?: string; quote?: string; eol?: string; + all?: boolean; }; export function csvExport(