@dloizides/ui-tables 3.0.2 → 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
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Added
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`.
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`.
11
+ - `ExportCsvAction`: an Export CSV button over `toCsv` from `@dloizides/utils` with a Blob download, the shared `Button` loading state, and `csvFilename` / `runCsvExport` helpers.
12
+ - `Filters`: a `multiSelect` field kind and an `error` on `dateRange` fields.
13
+
5
14
  ### Fixed
6
15
 
7
16
  - `DataTable` / `StatusLedger`: a clickable row (`onRowPress`, no `keyboardNavigation`) renders as a focusable `div` with `role="group"` instead of a native `<button>`, so an Edit or Delete button in a cell is no longer a button inside a button. The row keeps its pointer cursor, hover and pressed tint, focus ring and Enter to open; Space no longer opens it (Space belongs to button roles). Pressing a button inside the row calls only that button. ROW-OPEN-1 "Every list row opens its record".
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@ import { UiTheme } from '@dloizides/ui-feedback';
3
3
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
4
4
  import { DateRangeValue, ControlOption } from '@dloizides/ui-forms';
5
5
  export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeValue, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
6
+ import { CsvColumn } from '@dloizides/utils';
6
7
 
7
8
  declare const enum StatTone {
8
9
  Neutral = "neutral",
@@ -568,7 +569,7 @@ declare const TABLE_I18N: {
568
569
  */
569
570
 
570
571
  /** The kinds of field the declarative bar can render. */
571
- type FilterFieldKind = 'select' | 'text' | 'number' | 'date' | 'dateRange' | 'typeahead' | 'boolean';
572
+ type FilterFieldKind = 'select' | 'multiSelect' | 'text' | 'number' | 'date' | 'dateRange' | 'typeahead' | 'boolean';
572
573
  /**
573
574
  * A single choice for a `select` / `typeahead` field. Label is pre-localized.
574
575
  *
@@ -580,7 +581,7 @@ type FilterFieldKind = 'select' | 'text' | 'number' | 'date' | 'dateRange' | 'ty
580
581
  type FilterOption = ControlOption;
581
582
 
582
583
  /** The runtime value a field holds, by kind. */
583
- type FilterValue = string | boolean | DateRangeValue;
584
+ type FilterValue = string | boolean | DateRangeValue | readonly string[];
584
585
  /** The applied/draft value map, keyed by each field's `key`. */
585
586
  type FilterValues = Record<string, FilterValue>;
586
587
  interface FilterFieldBase {
@@ -629,6 +630,11 @@ interface DateRangeFilterField extends FilterFieldBase {
629
630
  toLabel?: string;
630
631
  fromPlaceholder?: string;
631
632
  toPlaceholder?: string;
633
+ error?: string;
634
+ }
635
+ interface MultiSelectFilterField extends FilterFieldBase {
636
+ kind: 'multiSelect';
637
+ options: readonly FilterOption[];
632
638
  }
633
639
  /** A search-as-you-type combobox (the country-picker pattern). */
634
640
  interface TypeaheadFilterField extends FilterFieldBase {
@@ -647,7 +653,7 @@ interface BooleanFilterField extends FilterFieldBase {
647
653
  kind: 'boolean';
648
654
  }
649
655
  /** The discriminated union of every declarative filter field. */
650
- type FilterField = SelectFilterField | TextFilterField | NumberFilterField | DateFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
656
+ type FilterField = SelectFilterField | MultiSelectFilterField | TextFilterField | NumberFilterField | DateFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
651
657
 
652
658
  /**
653
659
  * FilterFieldView — dispatches one {@link FilterField} to its renderer, wired to the value map.
@@ -1005,4 +1011,150 @@ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessib
1005
1011
  /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
1006
1012
  declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
1007
1013
 
1008
- export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, 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, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
1014
+ interface ReportFilterValues {
1015
+ scope: string;
1016
+ range: DateRangeValue;
1017
+ statuses: readonly string[];
1018
+ currency: string;
1019
+ }
1020
+ interface ReportQueryKeys {
1021
+ scope: string;
1022
+ from: string;
1023
+ to: string;
1024
+ statuses: string;
1025
+ currency: string;
1026
+ }
1027
+ type ReportQuerySource = URLSearchParams | Readonly<Record<string, string | readonly string[] | null | undefined>>;
1028
+ interface ReportFilterOptions {
1029
+ scopes: readonly FilterOption[];
1030
+ statuses: readonly FilterOption[];
1031
+ currencies: readonly FilterOption[];
1032
+ }
1033
+ interface ReportFilterLabels {
1034
+ scope: string;
1035
+ range: string;
1036
+ from: string;
1037
+ to: string;
1038
+ statuses: string;
1039
+ currency: string;
1040
+ invalidRange: string;
1041
+ openPanel: string;
1042
+ openPanelHint: string;
1043
+ panelTitle: string;
1044
+ closePanel: string;
1045
+ closePanelHint: string;
1046
+ }
1047
+
1048
+ interface ReportFiltersProps {
1049
+ value: ReportFilterValues;
1050
+ onChange: (next: ReportFilterValues) => void;
1051
+ options: ReportFilterOptions;
1052
+ labels: ReportFilterLabels;
1053
+ actions?: React.ReactNode;
1054
+ compact?: boolean;
1055
+ renderSelect?: (args: RenderSelectArgs) => React.ReactNode;
1056
+ testID?: string;
1057
+ }
1058
+ declare function ReportFilters({ value, onChange, options, labels, actions, compact, renderSelect, testID, }: ReportFiltersProps): React.ReactElement;
1059
+
1060
+ interface FilterSidePanelProps {
1061
+ visible: boolean;
1062
+ onClose: () => void;
1063
+ title: string;
1064
+ closeLabel: string;
1065
+ closeHint: string;
1066
+ children: React.ReactNode;
1067
+ testID: string;
1068
+ }
1069
+ declare function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, children, testID }: FilterSidePanelProps): React.ReactElement;
1070
+
1071
+ interface ReportDraft {
1072
+ draft: ReportFilterValues;
1073
+ edit: (next: ReportFilterValues) => void;
1074
+ }
1075
+ declare function useReportDraft(value: ReportFilterValues, onChange: (next: ReportFilterValues) => void): ReportDraft;
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
+
1090
+ declare function isIsoDate(value: string): boolean;
1091
+ declare function isRangeInverted(range: DateRangeValue): boolean;
1092
+ declare function countActiveReportFilters(values: ReportFilterValues): number;
1093
+ declare function reportFiltersFromQuery(source: ReportQuerySource, keys?: ReportQueryKeys): ReportFilterValues;
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>;
1097
+ declare function reportFiltersToSearch(values: ReportFilterValues, keys?: ReportQueryKeys): string;
1098
+
1099
+ declare function buildReportFields(options: ReportFilterOptions, labels: ReportFilterLabels, values: ReportFilterValues): FilterField[];
1100
+ declare function toFilterValues(values: ReportFilterValues): FilterValues;
1101
+ declare function fromFilterValues(map: FilterValues): ReportFilterValues;
1102
+
1103
+ declare const REPORT_FILTERS_TEST_ID = "ui-report-filters";
1104
+ declare const REPORT_FIELD_KEYS: {
1105
+ readonly scope: "scope";
1106
+ readonly range: "range";
1107
+ readonly statuses: "statuses";
1108
+ readonly currency: "currency";
1109
+ };
1110
+ declare const DEFAULT_REPORT_QUERY_KEYS: ReportQueryKeys;
1111
+ declare const EMPTY_REPORT_FILTERS: ReportFilterValues;
1112
+ declare const openPanelTestID: (testID: string) => string;
1113
+ declare const panelTestID: (testID: string) => string;
1114
+ declare const panelFiltersTestID: (testID: string) => string;
1115
+
1116
+ declare const enum ExportOutcome {
1117
+ Downloaded = "downloaded",
1118
+ Truncated = "truncated",
1119
+ Unsupported = "unsupported",
1120
+ Failed = "failed"
1121
+ }
1122
+
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>>);
1142
+ type CsvDownloader = (csv: string, filename: string) => boolean;
1143
+ declare function csvFilename(base: string, range?: DateRangeValue): string;
1144
+ declare function downloadCsv(csv: string, filename: string): boolean;
1145
+ declare function runCsvExport<T>(rows: CsvRowsSource<T>, columns: ReadonlyArray<CsvColumn<T>>, filename: string, download?: CsvDownloader): Promise<ExportOutcome>;
1146
+
1147
+ declare const EXPORT_CSV_TEST_ID = "ui-export-csv";
1148
+ interface ExportCsvActionProps<T> {
1149
+ rows: CsvRowsSource<T>;
1150
+ columns: ReadonlyArray<CsvColumn<T>>;
1151
+ filename: string;
1152
+ label: string;
1153
+ hint: string;
1154
+ disabled?: boolean;
1155
+ onDone?: (outcome: ExportOutcome) => void;
1156
+ testID?: string;
1157
+ }
1158
+ declare function ExportCsvAction<T>({ rows, columns, filename, label, hint, disabled, onDone, testID, }: ExportCsvActionProps<T>): React.ReactElement;
1159
+
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
@@ -3,6 +3,7 @@ import { UiTheme } from '@dloizides/ui-feedback';
3
3
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
4
4
  import { DateRangeValue, ControlOption } from '@dloizides/ui-forms';
5
5
  export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeValue, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
6
+ import { CsvColumn } from '@dloizides/utils';
6
7
 
7
8
  declare const enum StatTone {
8
9
  Neutral = "neutral",
@@ -568,7 +569,7 @@ declare const TABLE_I18N: {
568
569
  */
569
570
 
570
571
  /** The kinds of field the declarative bar can render. */
571
- type FilterFieldKind = 'select' | 'text' | 'number' | 'date' | 'dateRange' | 'typeahead' | 'boolean';
572
+ type FilterFieldKind = 'select' | 'multiSelect' | 'text' | 'number' | 'date' | 'dateRange' | 'typeahead' | 'boolean';
572
573
  /**
573
574
  * A single choice for a `select` / `typeahead` field. Label is pre-localized.
574
575
  *
@@ -580,7 +581,7 @@ type FilterFieldKind = 'select' | 'text' | 'number' | 'date' | 'dateRange' | 'ty
580
581
  type FilterOption = ControlOption;
581
582
 
582
583
  /** The runtime value a field holds, by kind. */
583
- type FilterValue = string | boolean | DateRangeValue;
584
+ type FilterValue = string | boolean | DateRangeValue | readonly string[];
584
585
  /** The applied/draft value map, keyed by each field's `key`. */
585
586
  type FilterValues = Record<string, FilterValue>;
586
587
  interface FilterFieldBase {
@@ -629,6 +630,11 @@ interface DateRangeFilterField extends FilterFieldBase {
629
630
  toLabel?: string;
630
631
  fromPlaceholder?: string;
631
632
  toPlaceholder?: string;
633
+ error?: string;
634
+ }
635
+ interface MultiSelectFilterField extends FilterFieldBase {
636
+ kind: 'multiSelect';
637
+ options: readonly FilterOption[];
632
638
  }
633
639
  /** A search-as-you-type combobox (the country-picker pattern). */
634
640
  interface TypeaheadFilterField extends FilterFieldBase {
@@ -647,7 +653,7 @@ interface BooleanFilterField extends FilterFieldBase {
647
653
  kind: 'boolean';
648
654
  }
649
655
  /** The discriminated union of every declarative filter field. */
650
- type FilterField = SelectFilterField | TextFilterField | NumberFilterField | DateFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
656
+ type FilterField = SelectFilterField | MultiSelectFilterField | TextFilterField | NumberFilterField | DateFilterField | DateRangeFilterField | TypeaheadFilterField | BooleanFilterField;
651
657
 
652
658
  /**
653
659
  * FilterFieldView — dispatches one {@link FilterField} to its renderer, wired to the value map.
@@ -1005,4 +1011,150 @@ declare const MonthStatusGrid: ({ cells, onSelect, selectedId, columns, accessib
1005
1011
  /** The widest allowed column count, up to `requested`, whose cells stay at least 44 px wide. */
1006
1012
  declare function fitMonthGridColumns(requested: MonthGridColumns, width: number, gap: number): MonthGridColumns;
1007
1013
 
1008
- export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableBaseProps, type DataTableColumn, type DataTableProps, type DataTableRowAction, type DataTableStyleOverrides, type DateFilterField, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type LedgerFilter, LedgerLayout, MONTH_STATUS_GRID_TEST_ID, MonthGridColumns, type MonthStatusCell, MonthStatusGrid, type MonthStatusGridProps, type NumberFilterField, type PagedRows, PagedTableLayout, PagedTableLayoutKind, type PagedTableLayoutProps, Pager, type PagerProps, type PagerStyleOverrides, RelativeTime, type RelativeTimeProps, type RelativeTimeStrings, type RelativeUnitStrings, type RenderSelectArgs, 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, clearTestID, distinctValues, fieldTestID, filterLedgerRows, fitMonthGridColumns, formatRelativeTime, isAttentionTone, ledgerSectionTestID, ledgerSortDirectionTestID, monthCellTestID, resolveStatToneColor, rowDetailTestID, rowFadeTestID, rowSelectTestID, rowTestID, selectAllTestID, sortLedgerRows, splitNeedsLook, toEpochMs, useFilterDraft, usePagedRows };
1014
+ interface ReportFilterValues {
1015
+ scope: string;
1016
+ range: DateRangeValue;
1017
+ statuses: readonly string[];
1018
+ currency: string;
1019
+ }
1020
+ interface ReportQueryKeys {
1021
+ scope: string;
1022
+ from: string;
1023
+ to: string;
1024
+ statuses: string;
1025
+ currency: string;
1026
+ }
1027
+ type ReportQuerySource = URLSearchParams | Readonly<Record<string, string | readonly string[] | null | undefined>>;
1028
+ interface ReportFilterOptions {
1029
+ scopes: readonly FilterOption[];
1030
+ statuses: readonly FilterOption[];
1031
+ currencies: readonly FilterOption[];
1032
+ }
1033
+ interface ReportFilterLabels {
1034
+ scope: string;
1035
+ range: string;
1036
+ from: string;
1037
+ to: string;
1038
+ statuses: string;
1039
+ currency: string;
1040
+ invalidRange: string;
1041
+ openPanel: string;
1042
+ openPanelHint: string;
1043
+ panelTitle: string;
1044
+ closePanel: string;
1045
+ closePanelHint: string;
1046
+ }
1047
+
1048
+ interface ReportFiltersProps {
1049
+ value: ReportFilterValues;
1050
+ onChange: (next: ReportFilterValues) => void;
1051
+ options: ReportFilterOptions;
1052
+ labels: ReportFilterLabels;
1053
+ actions?: React.ReactNode;
1054
+ compact?: boolean;
1055
+ renderSelect?: (args: RenderSelectArgs) => React.ReactNode;
1056
+ testID?: string;
1057
+ }
1058
+ declare function ReportFilters({ value, onChange, options, labels, actions, compact, renderSelect, testID, }: ReportFiltersProps): React.ReactElement;
1059
+
1060
+ interface FilterSidePanelProps {
1061
+ visible: boolean;
1062
+ onClose: () => void;
1063
+ title: string;
1064
+ closeLabel: string;
1065
+ closeHint: string;
1066
+ children: React.ReactNode;
1067
+ testID: string;
1068
+ }
1069
+ declare function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, children, testID }: FilterSidePanelProps): React.ReactElement;
1070
+
1071
+ interface ReportDraft {
1072
+ draft: ReportFilterValues;
1073
+ edit: (next: ReportFilterValues) => void;
1074
+ }
1075
+ declare function useReportDraft(value: ReportFilterValues, onChange: (next: ReportFilterValues) => void): ReportDraft;
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
+
1090
+ declare function isIsoDate(value: string): boolean;
1091
+ declare function isRangeInverted(range: DateRangeValue): boolean;
1092
+ declare function countActiveReportFilters(values: ReportFilterValues): number;
1093
+ declare function reportFiltersFromQuery(source: ReportQuerySource, keys?: ReportQueryKeys): ReportFilterValues;
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>;
1097
+ declare function reportFiltersToSearch(values: ReportFilterValues, keys?: ReportQueryKeys): string;
1098
+
1099
+ declare function buildReportFields(options: ReportFilterOptions, labels: ReportFilterLabels, values: ReportFilterValues): FilterField[];
1100
+ declare function toFilterValues(values: ReportFilterValues): FilterValues;
1101
+ declare function fromFilterValues(map: FilterValues): ReportFilterValues;
1102
+
1103
+ declare const REPORT_FILTERS_TEST_ID = "ui-report-filters";
1104
+ declare const REPORT_FIELD_KEYS: {
1105
+ readonly scope: "scope";
1106
+ readonly range: "range";
1107
+ readonly statuses: "statuses";
1108
+ readonly currency: "currency";
1109
+ };
1110
+ declare const DEFAULT_REPORT_QUERY_KEYS: ReportQueryKeys;
1111
+ declare const EMPTY_REPORT_FILTERS: ReportFilterValues;
1112
+ declare const openPanelTestID: (testID: string) => string;
1113
+ declare const panelTestID: (testID: string) => string;
1114
+ declare const panelFiltersTestID: (testID: string) => string;
1115
+
1116
+ declare const enum ExportOutcome {
1117
+ Downloaded = "downloaded",
1118
+ Truncated = "truncated",
1119
+ Unsupported = "unsupported",
1120
+ Failed = "failed"
1121
+ }
1122
+
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>>);
1142
+ type CsvDownloader = (csv: string, filename: string) => boolean;
1143
+ declare function csvFilename(base: string, range?: DateRangeValue): string;
1144
+ declare function downloadCsv(csv: string, filename: string): boolean;
1145
+ declare function runCsvExport<T>(rows: CsvRowsSource<T>, columns: ReadonlyArray<CsvColumn<T>>, filename: string, download?: CsvDownloader): Promise<ExportOutcome>;
1146
+
1147
+ declare const EXPORT_CSV_TEST_ID = "ui-export-csv";
1148
+ interface ExportCsvActionProps<T> {
1149
+ rows: CsvRowsSource<T>;
1150
+ columns: ReadonlyArray<CsvColumn<T>>;
1151
+ filename: string;
1152
+ label: string;
1153
+ hint: string;
1154
+ disabled?: boolean;
1155
+ onDone?: (outcome: ExportOutcome) => void;
1156
+ testID?: string;
1157
+ }
1158
+ declare function ExportCsvAction<T>({ rows, columns, filename, label, hint, disabled, onDone, testID, }: ExportCsvActionProps<T>): React.ReactElement;
1159
+
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 };