@dloizides/ui-tables 3.1.0 → 3.3.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 +3 -0
- package/dist/index.d.mts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +54 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
@@ -2483,6 +2483,7 @@ function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, child
|
|
|
2483
2483
|
const { theme } = uiFeedback.useUi();
|
|
2484
2484
|
const { width } = reactNative.useWindowDimensions();
|
|
2485
2485
|
const panelWidth = Math.min(PANEL_MAX_WIDTH, Math.round(width * PANEL_SCREEN_SHARE));
|
|
2486
|
+
const focusTitleOnOpen = React2.useCallback((node) => node?.focus(), []);
|
|
2486
2487
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.root, children: [
|
|
2487
2488
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2488
2489
|
reactNative.Pressable,
|
|
@@ -2503,7 +2504,7 @@ function FilterSidePanel({ visible, onClose, title, closeLabel, closeHint, child
|
|
|
2503
2504
|
testID,
|
|
2504
2505
|
children: [
|
|
2505
2506
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.header, children: [
|
|
2506
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles6.title, { color: theme.colors.text }], children: title }),
|
|
2507
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { ref: focusTitleOnOpen, focusable: true, style: styles6.titleBox, testID: `${testID}-title`, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles6.title, { color: theme.colors.text }], children: title }) }),
|
|
2507
2508
|
/* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: closeLabel, hint: closeHint, tone: "primary", onPress: onClose, testID: `${testID}-close` })
|
|
2508
2509
|
] }),
|
|
2509
2510
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { children })
|
|
@@ -2516,6 +2517,7 @@ var styles6 = reactNative.StyleSheet.create({
|
|
|
2516
2517
|
root: { flex: 1, flexDirection: "row", justifyContent: "flex-end" },
|
|
2517
2518
|
panel: { height: "100%", padding: PANEL_PAD, borderLeftWidth: PANEL_BORDER },
|
|
2518
2519
|
header: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: HEADER_GAP, marginBottom: HEADER_BOTTOM },
|
|
2520
|
+
titleBox: { flexShrink: 1 },
|
|
2519
2521
|
title: { flexShrink: 1, fontSize: TITLE_FONT, fontWeight: "700" }
|
|
2520
2522
|
});
|
|
2521
2523
|
|
|
@@ -2570,6 +2572,11 @@ function reportFiltersToQuery(values, keys = DEFAULT_REPORT_QUERY_KEYS) {
|
|
|
2570
2572
|
];
|
|
2571
2573
|
return Object.fromEntries(entries.filter(([, value]) => value !== ""));
|
|
2572
2574
|
}
|
|
2575
|
+
function reportFiltersToParams(values, keys = DEFAULT_REPORT_QUERY_KEYS) {
|
|
2576
|
+
const query = reportFiltersToQuery(values, keys);
|
|
2577
|
+
const allKeys = [keys.scope, keys.from, keys.to, keys.statuses, keys.currency];
|
|
2578
|
+
return Object.fromEntries(allKeys.map((key) => [key, query[key]]));
|
|
2579
|
+
}
|
|
2573
2580
|
function reportFiltersToSearch(values, keys = DEFAULT_REPORT_QUERY_KEYS) {
|
|
2574
2581
|
return new URLSearchParams(reportFiltersToQuery(values, keys)).toString();
|
|
2575
2582
|
}
|
|
@@ -2685,10 +2692,23 @@ function ReportFilters({
|
|
|
2685
2692
|
var styles7 = reactNative.StyleSheet.create({
|
|
2686
2693
|
compactRow: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: COMPACT_GAP }
|
|
2687
2694
|
});
|
|
2695
|
+
function useReportFilterQuery({
|
|
2696
|
+
params,
|
|
2697
|
+
setParams,
|
|
2698
|
+
keys = DEFAULT_REPORT_QUERY_KEYS
|
|
2699
|
+
}) {
|
|
2700
|
+
const values = React2.useMemo(() => reportFiltersFromQuery(params, keys), [params, keys]);
|
|
2701
|
+
const setValues = React2.useCallback(
|
|
2702
|
+
(next) => setParams(reportFiltersToParams(next, keys)),
|
|
2703
|
+
[setParams, keys]
|
|
2704
|
+
);
|
|
2705
|
+
return { values, setValues };
|
|
2706
|
+
}
|
|
2688
2707
|
|
|
2689
2708
|
// src/ExportCsvAction/ExportOutcome.ts
|
|
2690
2709
|
var ExportOutcome = /* @__PURE__ */ ((ExportOutcome2) => {
|
|
2691
2710
|
ExportOutcome2["Downloaded"] = "downloaded";
|
|
2711
|
+
ExportOutcome2["Truncated"] = "truncated";
|
|
2692
2712
|
ExportOutcome2["Unsupported"] = "unsupported";
|
|
2693
2713
|
ExportOutcome2["Failed"] = "failed";
|
|
2694
2714
|
return ExportOutcome2;
|
|
@@ -2702,6 +2722,9 @@ var UNSAFE_FILENAME_CHARS = /[^A-Za-z0-9._-]+/g;
|
|
|
2702
2722
|
var SAFE_REPLACEMENT = "-";
|
|
2703
2723
|
var RANGE_JOINER = "--";
|
|
2704
2724
|
var PART_JOINER = "_";
|
|
2725
|
+
function isFetchedRows(data) {
|
|
2726
|
+
return !Array.isArray(data);
|
|
2727
|
+
}
|
|
2705
2728
|
function csvFilename(base, range) {
|
|
2706
2729
|
const safeBase = base.trim().replace(UNSAFE_FILENAME_CHARS, SAFE_REPLACEMENT);
|
|
2707
2730
|
if (range === void 0) return `${safeBase}${CSV_EXTENSION}`;
|
|
@@ -2725,8 +2748,11 @@ function downloadCsv(csv, filename) {
|
|
|
2725
2748
|
}
|
|
2726
2749
|
async function runCsvExport(rows, columns, filename, download = downloadCsv) {
|
|
2727
2750
|
try {
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2751
|
+
const loaded = typeof rows === "function" ? await rows() : rows;
|
|
2752
|
+
const data = isFetchedRows(loaded) ? loaded.rows : loaded;
|
|
2753
|
+
const truncated = isFetchedRows(loaded) && loaded.truncated;
|
|
2754
|
+
if (!download(utils.toCsv(data, columns), filename)) return "unsupported" /* Unsupported */;
|
|
2755
|
+
return truncated ? "truncated" /* Truncated */ : "downloaded" /* Downloaded */;
|
|
2730
2756
|
} catch {
|
|
2731
2757
|
return "failed" /* Failed */;
|
|
2732
2758
|
}
|
|
@@ -2765,6 +2791,27 @@ function ExportCsvAction({
|
|
|
2765
2791
|
);
|
|
2766
2792
|
}
|
|
2767
2793
|
|
|
2794
|
+
// src/ExportCsvAction/utils/fetchAllPages.ts
|
|
2795
|
+
var FIRST_PAGE3 = 1;
|
|
2796
|
+
var DEFAULT_FETCH_CONCURRENCY = 2;
|
|
2797
|
+
function pageNumbers(from, to) {
|
|
2798
|
+
return Array.from({ length: Math.max(to - from + 1, 0) }, (_unused, index) => from + index);
|
|
2799
|
+
}
|
|
2800
|
+
function chunk(pages, size) {
|
|
2801
|
+
const step = Math.max(Math.floor(size), 1);
|
|
2802
|
+
const count = Math.ceil(pages.length / step);
|
|
2803
|
+
return Array.from({ length: count }, (_unused, index) => pages.slice(index * step, index * step + step));
|
|
2804
|
+
}
|
|
2805
|
+
async function fetchAllPages(fetchPage, { pageSize, maxPages, concurrency = DEFAULT_FETCH_CONCURRENCY }) {
|
|
2806
|
+
const first = await fetchPage(FIRST_PAGE3, pageSize);
|
|
2807
|
+
const lastPage = Math.min(first.totalPages, maxPages);
|
|
2808
|
+
const pages = [first];
|
|
2809
|
+
for (const batch of chunk(pageNumbers(FIRST_PAGE3 + 1, lastPage), concurrency)) {
|
|
2810
|
+
pages.push(...await Promise.all(batch.map((page) => fetchPage(page, pageSize))));
|
|
2811
|
+
}
|
|
2812
|
+
return { rows: pages.flatMap((page) => [...page.items]), truncated: first.totalPages > maxPages };
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2768
2815
|
Object.defineProperty(exports, "DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS", {
|
|
2769
2816
|
enumerable: true,
|
|
2770
2817
|
get: function () { return uiForms.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS; }
|
|
@@ -2782,6 +2829,7 @@ Object.defineProperty(exports, "suggestOptions", {
|
|
|
2782
2829
|
get: function () { return uiForms.suggestOptions; }
|
|
2783
2830
|
});
|
|
2784
2831
|
exports.CARD_STACK_BREAKPOINT = CARD_STACK_BREAKPOINT;
|
|
2832
|
+
exports.DEFAULT_FETCH_CONCURRENCY = DEFAULT_FETCH_CONCURRENCY;
|
|
2785
2833
|
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
|
2786
2834
|
exports.DEFAULT_PAGE_SIZE_OPTIONS = DEFAULT_PAGE_SIZE_OPTIONS;
|
|
2787
2835
|
exports.DEFAULT_REPORT_QUERY_KEYS = DEFAULT_REPORT_QUERY_KEYS;
|
|
@@ -2823,6 +2871,7 @@ exports.countActiveReportFilters = countActiveReportFilters;
|
|
|
2823
2871
|
exports.csvFilename = csvFilename;
|
|
2824
2872
|
exports.distinctValues = distinctValues;
|
|
2825
2873
|
exports.downloadCsv = downloadCsv;
|
|
2874
|
+
exports.fetchAllPages = fetchAllPages;
|
|
2826
2875
|
exports.fieldTestID = fieldTestID;
|
|
2827
2876
|
exports.filterLedgerRows = filterLedgerRows;
|
|
2828
2877
|
exports.fitMonthGridColumns = fitMonthGridColumns;
|
|
@@ -2838,6 +2887,7 @@ exports.openPanelTestID = openPanelTestID;
|
|
|
2838
2887
|
exports.panelFiltersTestID = panelFiltersTestID;
|
|
2839
2888
|
exports.panelTestID = panelTestID;
|
|
2840
2889
|
exports.reportFiltersFromQuery = reportFiltersFromQuery;
|
|
2890
|
+
exports.reportFiltersToParams = reportFiltersToParams;
|
|
2841
2891
|
exports.reportFiltersToQuery = reportFiltersToQuery;
|
|
2842
2892
|
exports.reportFiltersToSearch = reportFiltersToSearch;
|
|
2843
2893
|
exports.resolveStatToneColor = resolveStatToneColor;
|
|
@@ -2854,5 +2904,6 @@ exports.toFilterValues = toFilterValues;
|
|
|
2854
2904
|
exports.useFilterDraft = useFilterDraft;
|
|
2855
2905
|
exports.usePagedRows = usePagedRows;
|
|
2856
2906
|
exports.useReportDraft = useReportDraft;
|
|
2907
|
+
exports.useReportFilterQuery = useReportFilterQuery;
|
|
2857
2908
|
//# sourceMappingURL=index.js.map
|
|
2858
2909
|
//# sourceMappingURL=index.js.map
|