@pagamio/frontend-commons-lib 0.8.340 → 0.8.341
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.
|
@@ -177,6 +177,15 @@ export interface UsePagamioTableConfig<T extends BaseEntity> {
|
|
|
177
177
|
enabled?: boolean;
|
|
178
178
|
staleTime?: number;
|
|
179
179
|
gcTime?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Auto-refetch interval (ms) for tables backed by long-running jobs
|
|
182
|
+
* (exports, imports, async report generation). Pass a fixed number to
|
|
183
|
+
* always poll, `false` to disable, or a predicate `(rows) => number | false`
|
|
184
|
+
* that returns the interval only while any row is still in flight — the
|
|
185
|
+
* predicate runs on every fetch settle so polling stops automatically
|
|
186
|
+
* once everything is terminal.
|
|
187
|
+
*/
|
|
188
|
+
refetchInterval?: number | false | ((rows: T[]) => number | false);
|
|
180
189
|
/**
|
|
181
190
|
* Keep the previous page's rows visible while the next page fetches
|
|
182
191
|
* (TanStack `placeholderData: keepPreviousData`). Defaults to true so
|
|
@@ -17,4 +17,4 @@ export declare const pagamioMapping: ResponseMapping;
|
|
|
17
17
|
* The hook tracks `page` zero-indexed internally; we bump on the way out.
|
|
18
18
|
*/
|
|
19
19
|
export declare const pagamioQueryConfig: QueryParamConfig;
|
|
20
|
-
export declare const usePagamioTable: <T extends BaseEntity>({ queryKey, queryFn, enabled: queryEnabled, staleTime, gcTime, keepPreviousData: keepPrev, data: clientData, columns, defaultFilters, responseMapping, queryParamConfig, pagination: paginationConfig, filtering: filteringConfig, sorting: sortingConfig, toolbar, searchPlaceholder, onRowClick, rowClassName, expandable, renderDetailPanel, }: UsePagamioTableConfig<T>) => UsePagamioTableReturn<T>;
|
|
20
|
+
export declare const usePagamioTable: <T extends BaseEntity>({ queryKey, queryFn, enabled: queryEnabled, staleTime, gcTime, refetchInterval, keepPreviousData: keepPrev, data: clientData, columns, defaultFilters, responseMapping, queryParamConfig, pagination: paginationConfig, filtering: filteringConfig, sorting: sortingConfig, toolbar, searchPlaceholder, onRowClick, rowClassName, expandable, renderDetailPanel, }: UsePagamioTableConfig<T>) => UsePagamioTableReturn<T>;
|
|
@@ -158,7 +158,7 @@ function clientSort(items, sortConfig) {
|
|
|
158
158
|
return sorted;
|
|
159
159
|
}
|
|
160
160
|
// ─── Hook ────────────────────────────────────────────────────────────
|
|
161
|
-
export const usePagamioTable = ({ queryKey, queryFn, enabled: queryEnabled = true, staleTime, gcTime, keepPreviousData: keepPrev = true, data: clientData, columns, defaultFilters = {}, responseMapping = springBootMapping, queryParamConfig = defaultQueryConfig, pagination: paginationConfig = { enabled: true, mode: 'client' }, filtering: filteringConfig = { enabled: true, mode: 'client', searchMode: 'server' }, sorting: sortingConfig = { enabled: true, mode: 'client' }, toolbar, searchPlaceholder, onRowClick, rowClassName, expandable, renderDetailPanel, }) => {
|
|
161
|
+
export const usePagamioTable = ({ queryKey, queryFn, enabled: queryEnabled = true, staleTime, gcTime, refetchInterval, keepPreviousData: keepPrev = true, data: clientData, columns, defaultFilters = {}, responseMapping = springBootMapping, queryParamConfig = defaultQueryConfig, pagination: paginationConfig = { enabled: true, mode: 'client' }, filtering: filteringConfig = { enabled: true, mode: 'client', searchMode: 'server' }, sorting: sortingConfig = { enabled: true, mode: 'client' }, toolbar, searchPlaceholder, onRowClick, rowClassName, expandable, renderDetailPanel, }) => {
|
|
162
162
|
// ── Local state ──────────────────────────────────────────────────
|
|
163
163
|
const [currentPage, setCurrentPage] = useState(paginationConfig.pageIndex ?? 0);
|
|
164
164
|
const [pageSize, setPageSize] = useState(paginationConfig.pageSize ?? 10);
|
|
@@ -190,6 +190,18 @@ export const usePagamioTable = ({ queryKey, queryFn, enabled: queryEnabled = tru
|
|
|
190
190
|
staleTime,
|
|
191
191
|
gcTime,
|
|
192
192
|
placeholderData: keepPrev ? keepPreviousData : undefined,
|
|
193
|
+
// Predicate form re-extracts rows from the raw response so callers can
|
|
194
|
+
// gate polling on row state (e.g. "any pending export") without needing
|
|
195
|
+
// to know the responseMapping shape.
|
|
196
|
+
refetchInterval: typeof refetchInterval === 'function'
|
|
197
|
+
? (query) => {
|
|
198
|
+
const raw = query.state.data;
|
|
199
|
+
if (!raw)
|
|
200
|
+
return false;
|
|
201
|
+
const { data: rows } = processResponse(raw, responseMapping);
|
|
202
|
+
return refetchInterval(rows);
|
|
203
|
+
}
|
|
204
|
+
: refetchInterval,
|
|
193
205
|
});
|
|
194
206
|
// ── Process server response ──────────────────────────────────────
|
|
195
207
|
const { serverData, serverTotal } = useMemo(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.341",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|