@dloizides/ui-tables 3.1.0 → 3.2.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  ### Added
6
6
 
7
+ - `fetchAllPages(fetchPage, { pageSize, maxPages, concurrency = 2 })`: reads every page from page 1 in batches of `concurrency`, stops at `maxPages`, returns `{ rows, truncated }`.
8
+ - `useReportFilterQuery({ params, setParams, keys })`: router-agnostic URL state for `ReportFilters`, plus `reportFiltersToParams` (every key, `undefined` clears).
9
+ - `ExportCsvAction` / `runCsvExport`: a row loader may return `{ rows, truncated }`; a truncated download reports `ExportOutcome.Truncated`.
7
10
  - `ReportFilters`: report filter preset over `Filters` (scope select, date range, multi status, currency) with typed values, URL query helpers (`reportFiltersFromQuery` / `reportFiltersToQuery` / `reportFiltersToSearch`), an inverted-range error that withholds `onChange`, and a compact mode below 768 px: one Filters button opening a `FilterSidePanel`.
8
11
  - `ExportCsvAction`: an Export CSV button over `toCsv` from `@dloizides/utils` with a Blob download, the shared `Button` loading state, and `csvFilename` / `runCsvExport` helpers.
9
12
  - `Filters`: a `multiSelect` field kind and an `error` on `dateRange` fields.
package/dist/index.d.mts CHANGED
@@ -1074,11 +1074,26 @@ interface ReportDraft {
1074
1074
  }
1075
1075
  declare function useReportDraft(value: ReportFilterValues, onChange: (next: ReportFilterValues) => void): ReportDraft;
1076
1076
 
1077
+ type ReportParamsSetter = (next: Record<string, string | undefined>) => void;
1078
+ interface UseReportFilterQueryOptions {
1079
+ params: ReportQuerySource;
1080
+ setParams: ReportParamsSetter;
1081
+ keys?: ReportQueryKeys;
1082
+ }
1083
+ interface ReportFilterQuery {
1084
+ values: ReportFilterValues;
1085
+ setValues: (next: ReportFilterValues) => void;
1086
+ }
1087
+ /** Report filters read from and written to any router's query params, so a refresh or link restores them. */
1088
+ declare function useReportFilterQuery({ params, setParams, keys, }: UseReportFilterQueryOptions): ReportFilterQuery;
1089
+
1077
1090
  declare function isIsoDate(value: string): boolean;
1078
1091
  declare function isRangeInverted(range: DateRangeValue): boolean;
1079
1092
  declare function countActiveReportFilters(values: ReportFilterValues): number;
1080
1093
  declare function reportFiltersFromQuery(source: ReportQuerySource, keys?: ReportQueryKeys): ReportFilterValues;
1081
1094
  declare function reportFiltersToQuery(values: ReportFilterValues, keys?: ReportQueryKeys): Record<string, string>;
1095
+ /** Route params that name every filter key, `undefined` for a key without a value so a router clears it. */
1096
+ declare function reportFiltersToParams(values: ReportFilterValues, keys?: ReportQueryKeys): Record<string, string | undefined>;
1082
1097
  declare function reportFiltersToSearch(values: ReportFilterValues, keys?: ReportQueryKeys): string;
1083
1098
 
1084
1099
  declare function buildReportFields(options: ReportFilterOptions, labels: ReportFilterLabels, values: ReportFilterValues): FilterField[];
@@ -1100,11 +1115,30 @@ declare const panelFiltersTestID: (testID: string) => string;
1100
1115
 
1101
1116
  declare const enum ExportOutcome {
1102
1117
  Downloaded = "downloaded",
1118
+ Truncated = "truncated",
1103
1119
  Unsupported = "unsupported",
1104
1120
  Failed = "failed"
1105
1121
  }
1106
1122
 
1107
- type CsvRowsSource<T> = readonly T[] | (() => Promise<readonly T[]>);
1123
+ declare const DEFAULT_FETCH_CONCURRENCY = 2;
1124
+ interface FetchedPage<T> {
1125
+ items: readonly T[];
1126
+ totalPages: number;
1127
+ }
1128
+ interface FetchedRows<T> {
1129
+ rows: T[];
1130
+ truncated: boolean;
1131
+ }
1132
+ type PageFetcher<T> = (page: number, pageSize: number) => Promise<FetchedPage<T>>;
1133
+ interface FetchAllPagesOptions {
1134
+ pageSize: number;
1135
+ maxPages: number;
1136
+ concurrency?: number;
1137
+ }
1138
+ /** Reads pages from 1 up to `maxPages`, `concurrency` at a time; `truncated` when the source has more. */
1139
+ declare function fetchAllPages<T>(fetchPage: PageFetcher<T>, { pageSize, maxPages, concurrency }: FetchAllPagesOptions): Promise<FetchedRows<T>>;
1140
+
1141
+ type CsvRowsSource<T> = readonly T[] | (() => Promise<readonly T[] | FetchedRows<T>>);
1108
1142
  type CsvDownloader = (csv: string, filename: string) => boolean;
1109
1143
  declare function csvFilename(base: string, range?: DateRangeValue): string;
1110
1144
  declare function downloadCsv(csv: string, filename: string): boolean;
@@ -1123,4 +1157,4 @@ interface ExportCsvActionProps<T> {
1123
1157
  }
1124
1158
  declare function ExportCsvAction<T>({ rows, columns, filename, label, hint, disabled, onDone, testID, }: ExportCsvActionProps<T>): React.ReactElement;
1125
1159
 
1126
- export { type BooleanFilterField, CARD_STACK_BREAKPOINT, type CsvDownloader, type CsvRowsSource, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_REPORT_QUERY_KEYS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, EMPTY_REPORT_FILTERS, EXPORT_CSV_TEST_ID, ExportCsvAction, type ExportCsvActionProps, ExportOutcome, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, FilterSidePanel, type FilterSidePanelProps, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type MultiSelectFilterField, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, REPORT_FIELD_KEYS, REPORT_FILTERS_TEST_ID, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, type ReportDraft, type ReportFilterLabels, type ReportFilterOptions, type ReportFilterValues, ReportFilters, type ReportFiltersProps, type ReportQueryKeys, type ReportQuerySource, type RowActionNone, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, buildReportFields, clearTestID, countActiveReportFilters, csvFilename, distinctValues, downloadCsv, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, fromFilterValues, isAttentionTone, isIsoDate, isRangeInverted, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, openPanelTestID, panelFiltersTestID, panelTestID, reportFiltersFromQuery, reportFiltersToQuery, reportFiltersToSearch, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, runCsvExport, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, toFilterValues, useFilterDraft, usePagedRows, useReportDraft };
1160
+ export { type BooleanFilterField, CARD_STACK_BREAKPOINT, type CsvDownloader, type CsvRowsSource, DEFAULT_FETCH_CONCURRENCY, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_REPORT_QUERY_KEYS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, EMPTY_REPORT_FILTERS, EXPORT_CSV_TEST_ID, ExportCsvAction, type ExportCsvActionProps, ExportOutcome, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FetchAllPagesOptions, type FetchedPage, type FetchedRows, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, FilterSidePanel, type FilterSidePanelProps, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type MultiSelectFilterField, type NumberFilterField, type PageFetcher, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, REPORT_FIELD_KEYS, REPORT_FILTERS_TEST_ID, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, type ReportDraft, type ReportFilterLabels, type ReportFilterOptions, type ReportFilterQuery, type ReportFilterValues, ReportFilters, type ReportFiltersProps, type ReportParamsSetter, type ReportQueryKeys, type ReportQuerySource, type RowActionNone, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, type UseReportFilterQueryOptions, applyTestID, buildReportFields, clearTestID, countActiveReportFilters, csvFilename, distinctValues, downloadCsv, fetchAllPages, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, fromFilterValues, isAttentionTone, isIsoDate, isRangeInverted, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, openPanelTestID, panelFiltersTestID, panelTestID, reportFiltersFromQuery, reportFiltersToParams, reportFiltersToQuery, reportFiltersToSearch, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, runCsvExport, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, toFilterValues, useFilterDraft, usePagedRows, useReportDraft, useReportFilterQuery };
package/dist/index.d.ts CHANGED
@@ -1074,11 +1074,26 @@ interface ReportDraft {
1074
1074
  }
1075
1075
  declare function useReportDraft(value: ReportFilterValues, onChange: (next: ReportFilterValues) => void): ReportDraft;
1076
1076
 
1077
+ type ReportParamsSetter = (next: Record<string, string | undefined>) => void;
1078
+ interface UseReportFilterQueryOptions {
1079
+ params: ReportQuerySource;
1080
+ setParams: ReportParamsSetter;
1081
+ keys?: ReportQueryKeys;
1082
+ }
1083
+ interface ReportFilterQuery {
1084
+ values: ReportFilterValues;
1085
+ setValues: (next: ReportFilterValues) => void;
1086
+ }
1087
+ /** Report filters read from and written to any router's query params, so a refresh or link restores them. */
1088
+ declare function useReportFilterQuery({ params, setParams, keys, }: UseReportFilterQueryOptions): ReportFilterQuery;
1089
+
1077
1090
  declare function isIsoDate(value: string): boolean;
1078
1091
  declare function isRangeInverted(range: DateRangeValue): boolean;
1079
1092
  declare function countActiveReportFilters(values: ReportFilterValues): number;
1080
1093
  declare function reportFiltersFromQuery(source: ReportQuerySource, keys?: ReportQueryKeys): ReportFilterValues;
1081
1094
  declare function reportFiltersToQuery(values: ReportFilterValues, keys?: ReportQueryKeys): Record<string, string>;
1095
+ /** Route params that name every filter key, `undefined` for a key without a value so a router clears it. */
1096
+ declare function reportFiltersToParams(values: ReportFilterValues, keys?: ReportQueryKeys): Record<string, string | undefined>;
1082
1097
  declare function reportFiltersToSearch(values: ReportFilterValues, keys?: ReportQueryKeys): string;
1083
1098
 
1084
1099
  declare function buildReportFields(options: ReportFilterOptions, labels: ReportFilterLabels, values: ReportFilterValues): FilterField[];
@@ -1100,11 +1115,30 @@ declare const panelFiltersTestID: (testID: string) => string;
1100
1115
 
1101
1116
  declare const enum ExportOutcome {
1102
1117
  Downloaded = "downloaded",
1118
+ Truncated = "truncated",
1103
1119
  Unsupported = "unsupported",
1104
1120
  Failed = "failed"
1105
1121
  }
1106
1122
 
1107
- type CsvRowsSource<T> = readonly T[] | (() => Promise<readonly T[]>);
1123
+ declare const DEFAULT_FETCH_CONCURRENCY = 2;
1124
+ interface FetchedPage<T> {
1125
+ items: readonly T[];
1126
+ totalPages: number;
1127
+ }
1128
+ interface FetchedRows<T> {
1129
+ rows: T[];
1130
+ truncated: boolean;
1131
+ }
1132
+ type PageFetcher<T> = (page: number, pageSize: number) => Promise<FetchedPage<T>>;
1133
+ interface FetchAllPagesOptions {
1134
+ pageSize: number;
1135
+ maxPages: number;
1136
+ concurrency?: number;
1137
+ }
1138
+ /** Reads pages from 1 up to `maxPages`, `concurrency` at a time; `truncated` when the source has more. */
1139
+ declare function fetchAllPages<T>(fetchPage: PageFetcher<T>, { pageSize, maxPages, concurrency }: FetchAllPagesOptions): Promise<FetchedRows<T>>;
1140
+
1141
+ type CsvRowsSource<T> = readonly T[] | (() => Promise<readonly T[] | FetchedRows<T>>);
1108
1142
  type CsvDownloader = (csv: string, filename: string) => boolean;
1109
1143
  declare function csvFilename(base: string, range?: DateRangeValue): string;
1110
1144
  declare function downloadCsv(csv: string, filename: string): boolean;
@@ -1123,4 +1157,4 @@ interface ExportCsvActionProps<T> {
1123
1157
  }
1124
1158
  declare function ExportCsvAction<T>({ rows, columns, filename, label, hint, disabled, onDone, testID, }: ExportCsvActionProps<T>): React.ReactElement;
1125
1159
 
1126
- export { type BooleanFilterField, CARD_STACK_BREAKPOINT, type CsvDownloader, type CsvRowsSource, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_REPORT_QUERY_KEYS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, EMPTY_REPORT_FILTERS, EXPORT_CSV_TEST_ID, ExportCsvAction, type ExportCsvActionProps, ExportOutcome, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, FilterSidePanel, type FilterSidePanelProps, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type MultiSelectFilterField, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, REPORT_FIELD_KEYS, REPORT_FILTERS_TEST_ID, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, type ReportDraft, type ReportFilterLabels, type ReportFilterOptions, type ReportFilterValues, ReportFilters, type ReportFiltersProps, type ReportQueryKeys, type ReportQuerySource, type RowActionNone, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, buildReportFields, clearTestID, countActiveReportFilters, csvFilename, distinctValues, downloadCsv, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, fromFilterValues, isAttentionTone, isIsoDate, isRangeInverted, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, openPanelTestID, panelFiltersTestID, panelTestID, reportFiltersFromQuery, reportFiltersToQuery, reportFiltersToSearch, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, runCsvExport, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, toFilterValues, useFilterDraft, usePagedRows, useReportDraft };
1160
+ export { type BooleanFilterField, CARD_STACK_BREAKPOINT, type CsvDownloader, type CsvRowsSource, DEFAULT_FETCH_CONCURRENCY, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_REPORT_QUERY_KEYS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, EMPTY_REPORT_FILTERS, EXPORT_CSV_TEST_ID, ExportCsvAction, type ExportCsvActionProps, ExportOutcome, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FetchAllPagesOptions, type FetchedPage, type FetchedRows, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, FilterSidePanel, type FilterSidePanelProps, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type MultiSelectFilterField, type NumberFilterField, type PageFetcher, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, REPORT_FIELD_KEYS, REPORT_FILTERS_TEST_ID, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, type ReportDraft, type ReportFilterLabels, type ReportFilterOptions, type ReportFilterQuery, type ReportFilterValues, ReportFilters, type ReportFiltersProps, type ReportParamsSetter, type ReportQueryKeys, type ReportQuerySource, type RowActionNone, STATUS_LEDGER_TEST_ID, type SelectFilterField, SortDirection, type SortValue, StatCard, type StatCardProps, StatTone, StatusLedger, type StatusLedgerColumn, type StatusLedgerLabels, type StatusLedgerProps, StatusPill, type StatusPillProps, StatusTone, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TimeInput, type ToneColors, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, type UseReportFilterQueryOptions, applyTestID, buildReportFields, clearTestID, countActiveReportFilters, csvFilename, distinctValues, downloadCsv, fetchAllPages, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, fromFilterValues, isAttentionTone, isIsoDate, isRangeInverted, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, openPanelTestID, panelFiltersTestID, panelTestID, reportFiltersFromQuery, reportFiltersToParams, reportFiltersToQuery, reportFiltersToSearch, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, runCsvExport, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, toFilterValues, useFilterDraft, usePagedRows, useReportDraft, useReportFilterQuery };
package/dist/index.js CHANGED
@@ -2570,6 +2570,11 @@ function reportFiltersToQuery(values, keys = DEFAULT_REPORT_QUERY_KEYS) {
2570
2570
  ];
2571
2571
  return Object.fromEntries(entries.filter(([, value]) => value !== ""));
2572
2572
  }
2573
+ function reportFiltersToParams(values, keys = DEFAULT_REPORT_QUERY_KEYS) {
2574
+ const query = reportFiltersToQuery(values, keys);
2575
+ const allKeys = [keys.scope, keys.from, keys.to, keys.statuses, keys.currency];
2576
+ return Object.fromEntries(allKeys.map((key) => [key, query[key]]));
2577
+ }
2573
2578
  function reportFiltersToSearch(values, keys = DEFAULT_REPORT_QUERY_KEYS) {
2574
2579
  return new URLSearchParams(reportFiltersToQuery(values, keys)).toString();
2575
2580
  }
@@ -2685,10 +2690,23 @@ function ReportFilters({
2685
2690
  var styles7 = reactNative.StyleSheet.create({
2686
2691
  compactRow: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: COMPACT_GAP }
2687
2692
  });
2693
+ function useReportFilterQuery({
2694
+ params,
2695
+ setParams,
2696
+ keys = DEFAULT_REPORT_QUERY_KEYS
2697
+ }) {
2698
+ const values = React2.useMemo(() => reportFiltersFromQuery(params, keys), [params, keys]);
2699
+ const setValues = React2.useCallback(
2700
+ (next) => setParams(reportFiltersToParams(next, keys)),
2701
+ [setParams, keys]
2702
+ );
2703
+ return { values, setValues };
2704
+ }
2688
2705
 
2689
2706
  // src/ExportCsvAction/ExportOutcome.ts
2690
2707
  var ExportOutcome = /* @__PURE__ */ ((ExportOutcome2) => {
2691
2708
  ExportOutcome2["Downloaded"] = "downloaded";
2709
+ ExportOutcome2["Truncated"] = "truncated";
2692
2710
  ExportOutcome2["Unsupported"] = "unsupported";
2693
2711
  ExportOutcome2["Failed"] = "failed";
2694
2712
  return ExportOutcome2;
@@ -2702,6 +2720,9 @@ var UNSAFE_FILENAME_CHARS = /[^A-Za-z0-9._-]+/g;
2702
2720
  var SAFE_REPLACEMENT = "-";
2703
2721
  var RANGE_JOINER = "--";
2704
2722
  var PART_JOINER = "_";
2723
+ function isFetchedRows(data) {
2724
+ return !Array.isArray(data);
2725
+ }
2705
2726
  function csvFilename(base, range) {
2706
2727
  const safeBase = base.trim().replace(UNSAFE_FILENAME_CHARS, SAFE_REPLACEMENT);
2707
2728
  if (range === void 0) return `${safeBase}${CSV_EXTENSION}`;
@@ -2725,8 +2746,11 @@ function downloadCsv(csv, filename) {
2725
2746
  }
2726
2747
  async function runCsvExport(rows, columns, filename, download = downloadCsv) {
2727
2748
  try {
2728
- const data = typeof rows === "function" ? await rows() : rows;
2729
- return download(utils.toCsv(data, columns), filename) ? "downloaded" /* Downloaded */ : "unsupported" /* Unsupported */;
2749
+ const loaded = typeof rows === "function" ? await rows() : rows;
2750
+ const data = isFetchedRows(loaded) ? loaded.rows : loaded;
2751
+ const truncated = isFetchedRows(loaded) && loaded.truncated;
2752
+ if (!download(utils.toCsv(data, columns), filename)) return "unsupported" /* Unsupported */;
2753
+ return truncated ? "truncated" /* Truncated */ : "downloaded" /* Downloaded */;
2730
2754
  } catch {
2731
2755
  return "failed" /* Failed */;
2732
2756
  }
@@ -2765,6 +2789,27 @@ function ExportCsvAction({
2765
2789
  );
2766
2790
  }
2767
2791
 
2792
+ // src/ExportCsvAction/utils/fetchAllPages.ts
2793
+ var FIRST_PAGE3 = 1;
2794
+ var DEFAULT_FETCH_CONCURRENCY = 2;
2795
+ function pageNumbers(from, to) {
2796
+ return Array.from({ length: Math.max(to - from + 1, 0) }, (_unused, index) => from + index);
2797
+ }
2798
+ function chunk(pages, size) {
2799
+ const step = Math.max(Math.floor(size), 1);
2800
+ const count = Math.ceil(pages.length / step);
2801
+ return Array.from({ length: count }, (_unused, index) => pages.slice(index * step, index * step + step));
2802
+ }
2803
+ async function fetchAllPages(fetchPage, { pageSize, maxPages, concurrency = DEFAULT_FETCH_CONCURRENCY }) {
2804
+ const first = await fetchPage(FIRST_PAGE3, pageSize);
2805
+ const lastPage = Math.min(first.totalPages, maxPages);
2806
+ const pages = [first];
2807
+ for (const batch of chunk(pageNumbers(FIRST_PAGE3 + 1, lastPage), concurrency)) {
2808
+ pages.push(...await Promise.all(batch.map((page) => fetchPage(page, pageSize))));
2809
+ }
2810
+ return { rows: pages.flatMap((page) => [...page.items]), truncated: first.totalPages > maxPages };
2811
+ }
2812
+
2768
2813
  Object.defineProperty(exports, "DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS", {
2769
2814
  enumerable: true,
2770
2815
  get: function () { return uiForms.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS; }
@@ -2782,6 +2827,7 @@ Object.defineProperty(exports, "suggestOptions", {
2782
2827
  get: function () { return uiForms.suggestOptions; }
2783
2828
  });
2784
2829
  exports.CARD_STACK_BREAKPOINT = CARD_STACK_BREAKPOINT;
2830
+ exports.DEFAULT_FETCH_CONCURRENCY = DEFAULT_FETCH_CONCURRENCY;
2785
2831
  exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
2786
2832
  exports.DEFAULT_PAGE_SIZE_OPTIONS = DEFAULT_PAGE_SIZE_OPTIONS;
2787
2833
  exports.DEFAULT_REPORT_QUERY_KEYS = DEFAULT_REPORT_QUERY_KEYS;
@@ -2823,6 +2869,7 @@ exports.countActiveReportFilters = countActiveReportFilters;
2823
2869
  exports.csvFilename = csvFilename;
2824
2870
  exports.distinctValues = distinctValues;
2825
2871
  exports.downloadCsv = downloadCsv;
2872
+ exports.fetchAllPages = fetchAllPages;
2826
2873
  exports.fieldTestID = fieldTestID;
2827
2874
  exports.filterLedgerRows = filterLedgerRows;
2828
2875
  exports.fitMonthGridColumns = fitMonthGridColumns;
@@ -2838,6 +2885,7 @@ exports.openPanelTestID = openPanelTestID;
2838
2885
  exports.panelFiltersTestID = panelFiltersTestID;
2839
2886
  exports.panelTestID = panelTestID;
2840
2887
  exports.reportFiltersFromQuery = reportFiltersFromQuery;
2888
+ exports.reportFiltersToParams = reportFiltersToParams;
2841
2889
  exports.reportFiltersToQuery = reportFiltersToQuery;
2842
2890
  exports.reportFiltersToSearch = reportFiltersToSearch;
2843
2891
  exports.resolveStatToneColor = resolveStatToneColor;
@@ -2854,5 +2902,6 @@ exports.toFilterValues = toFilterValues;
2854
2902
  exports.useFilterDraft = useFilterDraft;
2855
2903
  exports.usePagedRows = usePagedRows;
2856
2904
  exports.useReportDraft = useReportDraft;
2905
+ exports.useReportFilterQuery = useReportFilterQuery;
2857
2906
  //# sourceMappingURL=index.js.map
2858
2907
  //# sourceMappingURL=index.js.map