bolesa-apitables 0.1.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/README.md +114 -0
- package/dist/index.cjs +2361 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +329 -0
- package/dist/index.d.ts +329 -0
- package/dist/index.js +2308 -0
- package/dist/index.js.map +1 -0
- package/package.json +87 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { AxiosInstance } from 'axios';
|
|
4
|
+
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
5
|
+
import { Store } from '@reduxjs/toolkit';
|
|
6
|
+
|
|
7
|
+
type ApiTablesLinkProps = {
|
|
8
|
+
href: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
target?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
type CustomControlProps = {
|
|
15
|
+
action: Record<string, unknown>;
|
|
16
|
+
closeModal: () => void;
|
|
17
|
+
rowRefetch?: (row: Record<string, unknown>) => void;
|
|
18
|
+
};
|
|
19
|
+
type BulkActionModalProps = {
|
|
20
|
+
closeModal: () => void;
|
|
21
|
+
action?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
type CustomControlMatcher = {
|
|
24
|
+
/** Match when `customControlAction.url.api` or `.web` includes this string */
|
|
25
|
+
match: string | RegExp;
|
|
26
|
+
component: ComponentType<CustomControlProps>;
|
|
27
|
+
};
|
|
28
|
+
type BulkActionModalMatcher = {
|
|
29
|
+
actionKey: string;
|
|
30
|
+
component: ComponentType<BulkActionModalProps>;
|
|
31
|
+
};
|
|
32
|
+
type RowActionModalMatcher = {
|
|
33
|
+
match: string | RegExp;
|
|
34
|
+
component: ComponentType<{
|
|
35
|
+
data: Record<string, unknown>;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Host-provided UI primitives. Map your design system (e.g. shadcn) into this bag.
|
|
40
|
+
* Only the components your tables use need to be supplied.
|
|
41
|
+
*/
|
|
42
|
+
type ApiTablesComponents = Record<string, ComponentType<Record<string, unknown>>>;
|
|
43
|
+
type ApiTablesConfig = {
|
|
44
|
+
/** Axios instance for table structure GET and query-table POST */
|
|
45
|
+
axiosTable: AxiosInstance;
|
|
46
|
+
/** Axios instance for auth/session endpoints (401 handling) */
|
|
47
|
+
axiosAuth?: AxiosInstance;
|
|
48
|
+
/** Optional private axios for custom controls that need it */
|
|
49
|
+
axiosPrivate?: AxiosInstance;
|
|
50
|
+
/** Host global Redux store — used by getExternalState and action side effects */
|
|
51
|
+
getExternalStore?: () => Store;
|
|
52
|
+
/**
|
|
53
|
+
* Value used to remount per-table Redux when global app state changes.
|
|
54
|
+
* In bolesa-app-ui this is `state.app.outScopeTableRefresher`.
|
|
55
|
+
*/
|
|
56
|
+
useOutScopeRefresher?: () => unknown;
|
|
57
|
+
/** Current locale sent as `ln` header on structure requests */
|
|
58
|
+
useLocale?: () => string | undefined;
|
|
59
|
+
/** Current pathname — used to re-fetch when route changes */
|
|
60
|
+
usePathname?: () => string;
|
|
61
|
+
/** i18n translate function, e.g. from next-intl */
|
|
62
|
+
useTranslations?: (namespace: string) => (key: string) => string;
|
|
63
|
+
/** Secure localStorage hook used for page size / column visibility */
|
|
64
|
+
useSecureLS?: () => {
|
|
65
|
+
get: (key: string) => unknown;
|
|
66
|
+
set: (key: string, value: unknown) => void;
|
|
67
|
+
};
|
|
68
|
+
/** Fallback when useSecureLS is not provided */
|
|
69
|
+
storage?: {
|
|
70
|
+
get: (key: string) => unknown;
|
|
71
|
+
set: (key: string, value: unknown) => void;
|
|
72
|
+
};
|
|
73
|
+
/** Design-system components (Button, Card, Select, Popup, …) */
|
|
74
|
+
components: ApiTablesComponents;
|
|
75
|
+
/** i18n-aware Link for redirect row actions */
|
|
76
|
+
Link?: ComponentType<ApiTablesLinkProps>;
|
|
77
|
+
/** Tailwind class merge helper */
|
|
78
|
+
cn?: (...classes: Array<string | false | null | undefined>) => string;
|
|
79
|
+
/** Custom control modals matched by URL substring */
|
|
80
|
+
customControls?: CustomControlMatcher[];
|
|
81
|
+
/** Bulk action modals matched by action_key */
|
|
82
|
+
bulkActionModals?: BulkActionModalMatcher[];
|
|
83
|
+
/** Extra row-action response modals (e.g. announcement preview) */
|
|
84
|
+
rowActionModals?: RowActionModalMatcher[];
|
|
85
|
+
/** String-keyed custom table elements, e.g. withdrawal_requests */
|
|
86
|
+
customElements?: Record<string, ComponentType<Record<string, unknown>>>;
|
|
87
|
+
/** Called on 401 — defaults to redirect /login */
|
|
88
|
+
onUnauthorized?: () => void | Promise<void>;
|
|
89
|
+
/** App-specific bulk action side effects (cart count, etc.) */
|
|
90
|
+
onBulkActionSuccess?: (action: Record<string, unknown>, response: Record<string, unknown> | undefined, payload: Record<string, unknown> | undefined) => void;
|
|
91
|
+
/** Toast implementation — defaults to sonner if installed */
|
|
92
|
+
toast?: {
|
|
93
|
+
success: (message: string) => void;
|
|
94
|
+
error: (message: string) => void;
|
|
95
|
+
};
|
|
96
|
+
downloadBlob?: (blob: Blob, filename?: string) => void;
|
|
97
|
+
downloadPDF?: (url: string, filename: string) => void | Promise<void>;
|
|
98
|
+
generatePDF?: (data: Record<string, unknown>, title?: string, filename?: string) => void | Promise<void>;
|
|
99
|
+
/** Optional global loader overlay (maps to bolesa _setMainLoader) */
|
|
100
|
+
setMainLoader?: (state: {
|
|
101
|
+
status: boolean;
|
|
102
|
+
msg?: string;
|
|
103
|
+
icon?: string | null;
|
|
104
|
+
}) => void;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type ApiTablesHostProviderProps = {
|
|
108
|
+
config: ApiTablesConfig;
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
};
|
|
111
|
+
declare function ApiTablesHostProvider({ config, children }: ApiTablesHostProviderProps): React.JSX.Element;
|
|
112
|
+
declare function useApiTablesConfig(): ApiTablesConfig;
|
|
113
|
+
declare function useApiTablesComponent<K extends keyof ApiTablesConfig['components']>(name: K): NonNullable<ApiTablesConfig['components'][K]>;
|
|
114
|
+
|
|
115
|
+
type ReactApiTableProps = {
|
|
116
|
+
table: unknown;
|
|
117
|
+
controller?: React__default.ReactNode;
|
|
118
|
+
children?: React__default.ReactNode;
|
|
119
|
+
params?: Record<string, unknown>;
|
|
120
|
+
tableStructureLoading?: boolean;
|
|
121
|
+
customElement?: React__default.ReactNode;
|
|
122
|
+
};
|
|
123
|
+
declare function ReactApiTable({ table, controller, children, params, tableStructureLoading, customElement, }: ReactApiTableProps): React__default.JSX.Element;
|
|
124
|
+
|
|
125
|
+
declare function ApiTablesProvider({ children }: {
|
|
126
|
+
children: React__default.ReactNode;
|
|
127
|
+
}): React__default.JSX.Element;
|
|
128
|
+
|
|
129
|
+
declare function ApiTablesController({ table, params, customElement, }: {
|
|
130
|
+
table: Record<string, unknown>;
|
|
131
|
+
params?: Record<string, unknown>;
|
|
132
|
+
customElement?: React__default.ReactNode;
|
|
133
|
+
}): React__default.JSX.Element;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* ApiTablesComponent is a comprehensive data table component that provides advanced functionality
|
|
137
|
+
* for displaying and managing tabular data.
|
|
138
|
+
*
|
|
139
|
+
* Features:
|
|
140
|
+
* - Filtering: Allows users to filter table data using customizable filter conditions
|
|
141
|
+
* - Sorting: Enables column-based sorting of table data
|
|
142
|
+
* - Bulk Actions: Supports performing actions on multiple selected rows
|
|
143
|
+
* - Column Visibility: Users can show/hide specific columns
|
|
144
|
+
* - Pagination: Breaks down large datasets into manageable pages
|
|
145
|
+
* - Page Size Control: Allows users to adjust number of rows per page
|
|
146
|
+
* - Custom Elements: Supports injection of custom UI elements
|
|
147
|
+
*
|
|
148
|
+
* @component
|
|
149
|
+
* @param {Object} props - Component props
|
|
150
|
+
* @param {React.ReactNode} props.customElement - Optional custom element to render above the table
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```jsx
|
|
154
|
+
* <ApiTablesComponent customElement={<CustomHeader />} />
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function ApiTablesComponent({ customElement }: any): React__default.JSX.Element;
|
|
158
|
+
|
|
159
|
+
interface TableStructureParams {
|
|
160
|
+
table: string;
|
|
161
|
+
params?: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
declare function useTableStructure(): {
|
|
164
|
+
getTableStructure: ({ table }: TableStructureParams) => Promise<void>;
|
|
165
|
+
tableStructure: unknown;
|
|
166
|
+
tableStructureLoading: boolean;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
interface TableFetcherParams {
|
|
170
|
+
tableName: string;
|
|
171
|
+
signal: AbortSignal;
|
|
172
|
+
pageSize: number;
|
|
173
|
+
currentPage: number;
|
|
174
|
+
appliedFilters: Record<string, unknown>;
|
|
175
|
+
tableSorting: Record<string, unknown>;
|
|
176
|
+
params?: Record<string, unknown>;
|
|
177
|
+
tbData: unknown[];
|
|
178
|
+
}
|
|
179
|
+
declare const useTableFetcher: () => {
|
|
180
|
+
tableFetchingHandler: ({ tableName, signal, pageSize, currentPage, appliedFilters, tableSorting, params, tbData, }: TableFetcherParams) => Promise<void>;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
interface Action {
|
|
184
|
+
onSuccess?: string;
|
|
185
|
+
onBulkSuccess?: string;
|
|
186
|
+
isBulk?: boolean;
|
|
187
|
+
action_key?: string;
|
|
188
|
+
}
|
|
189
|
+
interface LoaderInfo {
|
|
190
|
+
msg?: string;
|
|
191
|
+
icon?: string | null;
|
|
192
|
+
}
|
|
193
|
+
declare function useUtilsProvider(): {
|
|
194
|
+
triggerTableReload: () => void;
|
|
195
|
+
bulkActionsPostHandler: (method: string, url: string, payload: Record<string, unknown>, loaderInfo: LoaderInfo, action: Action) => Promise<void>;
|
|
196
|
+
rowActionsPostHandler: (method: string, url: string, payload: unknown, action: Action, customHeader?: Record<string, string>) => Promise<void>;
|
|
197
|
+
resetClickedRowAction: () => void;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
declare const createTableStore: () => _reduxjs_toolkit.EnhancedStore<{
|
|
201
|
+
tableCore: {
|
|
202
|
+
tableName: null;
|
|
203
|
+
structureColumns: null;
|
|
204
|
+
structureFilters: null;
|
|
205
|
+
customElement: string | null;
|
|
206
|
+
appliedFilters: never[];
|
|
207
|
+
renderedFilters: never[];
|
|
208
|
+
tableSorting: {};
|
|
209
|
+
tableData: never[];
|
|
210
|
+
tableBindings: null;
|
|
211
|
+
currentPage: number;
|
|
212
|
+
pageSize: number;
|
|
213
|
+
tablePagination: null;
|
|
214
|
+
tableFetchingLoading: boolean;
|
|
215
|
+
tableRefresher: number;
|
|
216
|
+
};
|
|
217
|
+
bulkActions: {
|
|
218
|
+
bulkActions: any[];
|
|
219
|
+
selectedBulkAction: null;
|
|
220
|
+
bulkActionPostLoading: boolean;
|
|
221
|
+
bulkActionPostResponse: null;
|
|
222
|
+
};
|
|
223
|
+
rowActions: {
|
|
224
|
+
structureRowActions: any[];
|
|
225
|
+
selectedRowActions: any[];
|
|
226
|
+
clickedRowAction: null;
|
|
227
|
+
rowActionPostLoading: boolean;
|
|
228
|
+
clickedRowActionResponse: null;
|
|
229
|
+
customControlAction: null;
|
|
230
|
+
actionsInRegularCells: boolean;
|
|
231
|
+
clickedRowActionId: null;
|
|
232
|
+
};
|
|
233
|
+
tableColumns: {
|
|
234
|
+
tableColumns: any[];
|
|
235
|
+
visibleColumns: any[];
|
|
236
|
+
selectedRows: any[];
|
|
237
|
+
selectedIds: any[];
|
|
238
|
+
toggledClearRows: boolean;
|
|
239
|
+
rowSelectedModal: null;
|
|
240
|
+
};
|
|
241
|
+
}, _reduxjs_toolkit.UnknownAction, _reduxjs_toolkit.Tuple<[_reduxjs_toolkit.StoreEnhancer<{
|
|
242
|
+
dispatch: _reduxjs_toolkit.ThunkDispatch<{
|
|
243
|
+
tableCore: {
|
|
244
|
+
tableName: null;
|
|
245
|
+
structureColumns: null;
|
|
246
|
+
structureFilters: null;
|
|
247
|
+
customElement: string | null;
|
|
248
|
+
appliedFilters: never[];
|
|
249
|
+
renderedFilters: never[];
|
|
250
|
+
tableSorting: {};
|
|
251
|
+
tableData: never[];
|
|
252
|
+
tableBindings: null;
|
|
253
|
+
currentPage: number;
|
|
254
|
+
pageSize: number;
|
|
255
|
+
tablePagination: null;
|
|
256
|
+
tableFetchingLoading: boolean;
|
|
257
|
+
tableRefresher: number;
|
|
258
|
+
};
|
|
259
|
+
bulkActions: {
|
|
260
|
+
bulkActions: any[];
|
|
261
|
+
selectedBulkAction: null;
|
|
262
|
+
bulkActionPostLoading: boolean;
|
|
263
|
+
bulkActionPostResponse: null;
|
|
264
|
+
};
|
|
265
|
+
rowActions: {
|
|
266
|
+
structureRowActions: any[];
|
|
267
|
+
selectedRowActions: any[];
|
|
268
|
+
clickedRowAction: null;
|
|
269
|
+
rowActionPostLoading: boolean;
|
|
270
|
+
clickedRowActionResponse: null;
|
|
271
|
+
customControlAction: null;
|
|
272
|
+
actionsInRegularCells: boolean;
|
|
273
|
+
clickedRowActionId: null;
|
|
274
|
+
};
|
|
275
|
+
tableColumns: {
|
|
276
|
+
tableColumns: any[];
|
|
277
|
+
visibleColumns: any[];
|
|
278
|
+
selectedRows: any[];
|
|
279
|
+
selectedIds: any[];
|
|
280
|
+
toggledClearRows: boolean;
|
|
281
|
+
rowSelectedModal: null;
|
|
282
|
+
};
|
|
283
|
+
}, undefined, _reduxjs_toolkit.UnknownAction>;
|
|
284
|
+
}>, _reduxjs_toolkit.StoreEnhancer]>>;
|
|
285
|
+
type TableStore = ReturnType<typeof createTableStore>;
|
|
286
|
+
type TableRootState = ReturnType<TableStore['getState']>;
|
|
287
|
+
/** Called once from host setup — replaces direct @/store/store import */
|
|
288
|
+
declare function setExternalStoreGetter(getter: () => {
|
|
289
|
+
getState: () => unknown;
|
|
290
|
+
}): void;
|
|
291
|
+
declare const getExternalState: () => unknown;
|
|
292
|
+
|
|
293
|
+
declare const _getTableComponents: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTableComponents">;
|
|
294
|
+
declare const _setAppliedFilters: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setAppliedFilters">;
|
|
295
|
+
declare const _setRenderedFilters: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setRenderedFilters">;
|
|
296
|
+
declare const _getTableData: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTableData">;
|
|
297
|
+
declare const _getTablePagination: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTablePagination">;
|
|
298
|
+
declare const _getTableBindings: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTableBindings">;
|
|
299
|
+
declare const _setTableLoading: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setTableLoading">;
|
|
300
|
+
declare const _setCurrentPage: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setCurrentPage">;
|
|
301
|
+
declare const _setTableSorting: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setTableSorting">;
|
|
302
|
+
declare const _changePageSize: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_changePageSize">;
|
|
303
|
+
declare const _triggerTableReload: _reduxjs_toolkit.ActionCreatorWithoutPayload<"tableCore/_triggerTableReload">;
|
|
304
|
+
declare const _resetTableCore: _reduxjs_toolkit.ActionCreatorWithoutPayload<"tableCore/_resetTableCore">;
|
|
305
|
+
|
|
306
|
+
declare const _setSelectedRows: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setSelectedRows">;
|
|
307
|
+
declare const _setToggledClearRow: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setToggledClearRow">;
|
|
308
|
+
declare const _setVisibleColumns: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setVisibleColumns">;
|
|
309
|
+
declare const _setRowSelectedModal: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setRowSelectedModal">;
|
|
310
|
+
declare const _setTableColumns: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setTableColumns">;
|
|
311
|
+
declare const _resetTableColumns: _reduxjs_toolkit.ActionCreatorWithoutPayload<"tableColumns/_resetTableColumns">;
|
|
312
|
+
|
|
313
|
+
declare const _getStructureBulkActions: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_getStructureBulkActions">;
|
|
314
|
+
declare const _getSelectedBulkAction: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_getSelectedBulkAction">;
|
|
315
|
+
declare const _bulkActionPostLoading: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_bulkActionPostLoading">;
|
|
316
|
+
declare const _bulkActionPostResponse: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_bulkActionPostResponse">;
|
|
317
|
+
declare const _resetTableBulkActions: _reduxjs_toolkit.ActionCreatorWithoutPayload<"bulkActions/_resetTableBulkActions">;
|
|
318
|
+
|
|
319
|
+
declare const _getStructureRowActions: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getStructureRowActions">;
|
|
320
|
+
declare const _checkActionsInRegularCells: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_checkActionsInRegularCells">;
|
|
321
|
+
declare const _getSelectedRowActions: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getSelectedRowActions">;
|
|
322
|
+
declare const _setRowActionPostLoading: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_setRowActionPostLoading">;
|
|
323
|
+
declare const _getClickedRowAction: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getClickedRowAction">;
|
|
324
|
+
declare const _getClickedRowActionId: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getClickedRowActionId">;
|
|
325
|
+
declare const _getClickedRowActionResponse: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getClickedRowActionResponse">;
|
|
326
|
+
declare const _getCustomControlRequest: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getCustomControlRequest">;
|
|
327
|
+
declare const _resetTableRowActions: _reduxjs_toolkit.ActionCreatorWithoutPayload<"rowActions/_resetTableRowActions">;
|
|
328
|
+
|
|
329
|
+
export { ApiTablesComponent, type ApiTablesComponents, type ApiTablesConfig, ApiTablesController, ApiTablesHostProvider, type ApiTablesLinkProps, ApiTablesProvider, type BulkActionModalMatcher, type CustomControlMatcher, type CustomControlProps, ReactApiTable, type RowActionModalMatcher, type TableRootState, type TableStore, _bulkActionPostLoading, _bulkActionPostResponse, _changePageSize, _checkActionsInRegularCells, _getClickedRowAction, _getClickedRowActionId, _getClickedRowActionResponse, _getCustomControlRequest, _getSelectedBulkAction, _getSelectedRowActions, _getStructureBulkActions, _getStructureRowActions, _getTableBindings, _getTableComponents, _getTableData, _getTablePagination, _resetTableBulkActions, _resetTableColumns, _resetTableCore, _resetTableRowActions, _setAppliedFilters, _setCurrentPage, _setRenderedFilters, _setRowActionPostLoading, _setRowSelectedModal, _setSelectedRows, _setTableColumns, _setTableLoading, _setTableSorting, _setToggledClearRow, _setVisibleColumns, _triggerTableReload, createTableStore, getExternalState, setExternalStoreGetter, useApiTablesComponent, useApiTablesConfig, useTableFetcher, useTableStructure, useUtilsProvider };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { AxiosInstance } from 'axios';
|
|
4
|
+
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
5
|
+
import { Store } from '@reduxjs/toolkit';
|
|
6
|
+
|
|
7
|
+
type ApiTablesLinkProps = {
|
|
8
|
+
href: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
target?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
type CustomControlProps = {
|
|
15
|
+
action: Record<string, unknown>;
|
|
16
|
+
closeModal: () => void;
|
|
17
|
+
rowRefetch?: (row: Record<string, unknown>) => void;
|
|
18
|
+
};
|
|
19
|
+
type BulkActionModalProps = {
|
|
20
|
+
closeModal: () => void;
|
|
21
|
+
action?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
type CustomControlMatcher = {
|
|
24
|
+
/** Match when `customControlAction.url.api` or `.web` includes this string */
|
|
25
|
+
match: string | RegExp;
|
|
26
|
+
component: ComponentType<CustomControlProps>;
|
|
27
|
+
};
|
|
28
|
+
type BulkActionModalMatcher = {
|
|
29
|
+
actionKey: string;
|
|
30
|
+
component: ComponentType<BulkActionModalProps>;
|
|
31
|
+
};
|
|
32
|
+
type RowActionModalMatcher = {
|
|
33
|
+
match: string | RegExp;
|
|
34
|
+
component: ComponentType<{
|
|
35
|
+
data: Record<string, unknown>;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Host-provided UI primitives. Map your design system (e.g. shadcn) into this bag.
|
|
40
|
+
* Only the components your tables use need to be supplied.
|
|
41
|
+
*/
|
|
42
|
+
type ApiTablesComponents = Record<string, ComponentType<Record<string, unknown>>>;
|
|
43
|
+
type ApiTablesConfig = {
|
|
44
|
+
/** Axios instance for table structure GET and query-table POST */
|
|
45
|
+
axiosTable: AxiosInstance;
|
|
46
|
+
/** Axios instance for auth/session endpoints (401 handling) */
|
|
47
|
+
axiosAuth?: AxiosInstance;
|
|
48
|
+
/** Optional private axios for custom controls that need it */
|
|
49
|
+
axiosPrivate?: AxiosInstance;
|
|
50
|
+
/** Host global Redux store — used by getExternalState and action side effects */
|
|
51
|
+
getExternalStore?: () => Store;
|
|
52
|
+
/**
|
|
53
|
+
* Value used to remount per-table Redux when global app state changes.
|
|
54
|
+
* In bolesa-app-ui this is `state.app.outScopeTableRefresher`.
|
|
55
|
+
*/
|
|
56
|
+
useOutScopeRefresher?: () => unknown;
|
|
57
|
+
/** Current locale sent as `ln` header on structure requests */
|
|
58
|
+
useLocale?: () => string | undefined;
|
|
59
|
+
/** Current pathname — used to re-fetch when route changes */
|
|
60
|
+
usePathname?: () => string;
|
|
61
|
+
/** i18n translate function, e.g. from next-intl */
|
|
62
|
+
useTranslations?: (namespace: string) => (key: string) => string;
|
|
63
|
+
/** Secure localStorage hook used for page size / column visibility */
|
|
64
|
+
useSecureLS?: () => {
|
|
65
|
+
get: (key: string) => unknown;
|
|
66
|
+
set: (key: string, value: unknown) => void;
|
|
67
|
+
};
|
|
68
|
+
/** Fallback when useSecureLS is not provided */
|
|
69
|
+
storage?: {
|
|
70
|
+
get: (key: string) => unknown;
|
|
71
|
+
set: (key: string, value: unknown) => void;
|
|
72
|
+
};
|
|
73
|
+
/** Design-system components (Button, Card, Select, Popup, …) */
|
|
74
|
+
components: ApiTablesComponents;
|
|
75
|
+
/** i18n-aware Link for redirect row actions */
|
|
76
|
+
Link?: ComponentType<ApiTablesLinkProps>;
|
|
77
|
+
/** Tailwind class merge helper */
|
|
78
|
+
cn?: (...classes: Array<string | false | null | undefined>) => string;
|
|
79
|
+
/** Custom control modals matched by URL substring */
|
|
80
|
+
customControls?: CustomControlMatcher[];
|
|
81
|
+
/** Bulk action modals matched by action_key */
|
|
82
|
+
bulkActionModals?: BulkActionModalMatcher[];
|
|
83
|
+
/** Extra row-action response modals (e.g. announcement preview) */
|
|
84
|
+
rowActionModals?: RowActionModalMatcher[];
|
|
85
|
+
/** String-keyed custom table elements, e.g. withdrawal_requests */
|
|
86
|
+
customElements?: Record<string, ComponentType<Record<string, unknown>>>;
|
|
87
|
+
/** Called on 401 — defaults to redirect /login */
|
|
88
|
+
onUnauthorized?: () => void | Promise<void>;
|
|
89
|
+
/** App-specific bulk action side effects (cart count, etc.) */
|
|
90
|
+
onBulkActionSuccess?: (action: Record<string, unknown>, response: Record<string, unknown> | undefined, payload: Record<string, unknown> | undefined) => void;
|
|
91
|
+
/** Toast implementation — defaults to sonner if installed */
|
|
92
|
+
toast?: {
|
|
93
|
+
success: (message: string) => void;
|
|
94
|
+
error: (message: string) => void;
|
|
95
|
+
};
|
|
96
|
+
downloadBlob?: (blob: Blob, filename?: string) => void;
|
|
97
|
+
downloadPDF?: (url: string, filename: string) => void | Promise<void>;
|
|
98
|
+
generatePDF?: (data: Record<string, unknown>, title?: string, filename?: string) => void | Promise<void>;
|
|
99
|
+
/** Optional global loader overlay (maps to bolesa _setMainLoader) */
|
|
100
|
+
setMainLoader?: (state: {
|
|
101
|
+
status: boolean;
|
|
102
|
+
msg?: string;
|
|
103
|
+
icon?: string | null;
|
|
104
|
+
}) => void;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type ApiTablesHostProviderProps = {
|
|
108
|
+
config: ApiTablesConfig;
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
};
|
|
111
|
+
declare function ApiTablesHostProvider({ config, children }: ApiTablesHostProviderProps): React.JSX.Element;
|
|
112
|
+
declare function useApiTablesConfig(): ApiTablesConfig;
|
|
113
|
+
declare function useApiTablesComponent<K extends keyof ApiTablesConfig['components']>(name: K): NonNullable<ApiTablesConfig['components'][K]>;
|
|
114
|
+
|
|
115
|
+
type ReactApiTableProps = {
|
|
116
|
+
table: unknown;
|
|
117
|
+
controller?: React__default.ReactNode;
|
|
118
|
+
children?: React__default.ReactNode;
|
|
119
|
+
params?: Record<string, unknown>;
|
|
120
|
+
tableStructureLoading?: boolean;
|
|
121
|
+
customElement?: React__default.ReactNode;
|
|
122
|
+
};
|
|
123
|
+
declare function ReactApiTable({ table, controller, children, params, tableStructureLoading, customElement, }: ReactApiTableProps): React__default.JSX.Element;
|
|
124
|
+
|
|
125
|
+
declare function ApiTablesProvider({ children }: {
|
|
126
|
+
children: React__default.ReactNode;
|
|
127
|
+
}): React__default.JSX.Element;
|
|
128
|
+
|
|
129
|
+
declare function ApiTablesController({ table, params, customElement, }: {
|
|
130
|
+
table: Record<string, unknown>;
|
|
131
|
+
params?: Record<string, unknown>;
|
|
132
|
+
customElement?: React__default.ReactNode;
|
|
133
|
+
}): React__default.JSX.Element;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* ApiTablesComponent is a comprehensive data table component that provides advanced functionality
|
|
137
|
+
* for displaying and managing tabular data.
|
|
138
|
+
*
|
|
139
|
+
* Features:
|
|
140
|
+
* - Filtering: Allows users to filter table data using customizable filter conditions
|
|
141
|
+
* - Sorting: Enables column-based sorting of table data
|
|
142
|
+
* - Bulk Actions: Supports performing actions on multiple selected rows
|
|
143
|
+
* - Column Visibility: Users can show/hide specific columns
|
|
144
|
+
* - Pagination: Breaks down large datasets into manageable pages
|
|
145
|
+
* - Page Size Control: Allows users to adjust number of rows per page
|
|
146
|
+
* - Custom Elements: Supports injection of custom UI elements
|
|
147
|
+
*
|
|
148
|
+
* @component
|
|
149
|
+
* @param {Object} props - Component props
|
|
150
|
+
* @param {React.ReactNode} props.customElement - Optional custom element to render above the table
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```jsx
|
|
154
|
+
* <ApiTablesComponent customElement={<CustomHeader />} />
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function ApiTablesComponent({ customElement }: any): React__default.JSX.Element;
|
|
158
|
+
|
|
159
|
+
interface TableStructureParams {
|
|
160
|
+
table: string;
|
|
161
|
+
params?: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
declare function useTableStructure(): {
|
|
164
|
+
getTableStructure: ({ table }: TableStructureParams) => Promise<void>;
|
|
165
|
+
tableStructure: unknown;
|
|
166
|
+
tableStructureLoading: boolean;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
interface TableFetcherParams {
|
|
170
|
+
tableName: string;
|
|
171
|
+
signal: AbortSignal;
|
|
172
|
+
pageSize: number;
|
|
173
|
+
currentPage: number;
|
|
174
|
+
appliedFilters: Record<string, unknown>;
|
|
175
|
+
tableSorting: Record<string, unknown>;
|
|
176
|
+
params?: Record<string, unknown>;
|
|
177
|
+
tbData: unknown[];
|
|
178
|
+
}
|
|
179
|
+
declare const useTableFetcher: () => {
|
|
180
|
+
tableFetchingHandler: ({ tableName, signal, pageSize, currentPage, appliedFilters, tableSorting, params, tbData, }: TableFetcherParams) => Promise<void>;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
interface Action {
|
|
184
|
+
onSuccess?: string;
|
|
185
|
+
onBulkSuccess?: string;
|
|
186
|
+
isBulk?: boolean;
|
|
187
|
+
action_key?: string;
|
|
188
|
+
}
|
|
189
|
+
interface LoaderInfo {
|
|
190
|
+
msg?: string;
|
|
191
|
+
icon?: string | null;
|
|
192
|
+
}
|
|
193
|
+
declare function useUtilsProvider(): {
|
|
194
|
+
triggerTableReload: () => void;
|
|
195
|
+
bulkActionsPostHandler: (method: string, url: string, payload: Record<string, unknown>, loaderInfo: LoaderInfo, action: Action) => Promise<void>;
|
|
196
|
+
rowActionsPostHandler: (method: string, url: string, payload: unknown, action: Action, customHeader?: Record<string, string>) => Promise<void>;
|
|
197
|
+
resetClickedRowAction: () => void;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
declare const createTableStore: () => _reduxjs_toolkit.EnhancedStore<{
|
|
201
|
+
tableCore: {
|
|
202
|
+
tableName: null;
|
|
203
|
+
structureColumns: null;
|
|
204
|
+
structureFilters: null;
|
|
205
|
+
customElement: string | null;
|
|
206
|
+
appliedFilters: never[];
|
|
207
|
+
renderedFilters: never[];
|
|
208
|
+
tableSorting: {};
|
|
209
|
+
tableData: never[];
|
|
210
|
+
tableBindings: null;
|
|
211
|
+
currentPage: number;
|
|
212
|
+
pageSize: number;
|
|
213
|
+
tablePagination: null;
|
|
214
|
+
tableFetchingLoading: boolean;
|
|
215
|
+
tableRefresher: number;
|
|
216
|
+
};
|
|
217
|
+
bulkActions: {
|
|
218
|
+
bulkActions: any[];
|
|
219
|
+
selectedBulkAction: null;
|
|
220
|
+
bulkActionPostLoading: boolean;
|
|
221
|
+
bulkActionPostResponse: null;
|
|
222
|
+
};
|
|
223
|
+
rowActions: {
|
|
224
|
+
structureRowActions: any[];
|
|
225
|
+
selectedRowActions: any[];
|
|
226
|
+
clickedRowAction: null;
|
|
227
|
+
rowActionPostLoading: boolean;
|
|
228
|
+
clickedRowActionResponse: null;
|
|
229
|
+
customControlAction: null;
|
|
230
|
+
actionsInRegularCells: boolean;
|
|
231
|
+
clickedRowActionId: null;
|
|
232
|
+
};
|
|
233
|
+
tableColumns: {
|
|
234
|
+
tableColumns: any[];
|
|
235
|
+
visibleColumns: any[];
|
|
236
|
+
selectedRows: any[];
|
|
237
|
+
selectedIds: any[];
|
|
238
|
+
toggledClearRows: boolean;
|
|
239
|
+
rowSelectedModal: null;
|
|
240
|
+
};
|
|
241
|
+
}, _reduxjs_toolkit.UnknownAction, _reduxjs_toolkit.Tuple<[_reduxjs_toolkit.StoreEnhancer<{
|
|
242
|
+
dispatch: _reduxjs_toolkit.ThunkDispatch<{
|
|
243
|
+
tableCore: {
|
|
244
|
+
tableName: null;
|
|
245
|
+
structureColumns: null;
|
|
246
|
+
structureFilters: null;
|
|
247
|
+
customElement: string | null;
|
|
248
|
+
appliedFilters: never[];
|
|
249
|
+
renderedFilters: never[];
|
|
250
|
+
tableSorting: {};
|
|
251
|
+
tableData: never[];
|
|
252
|
+
tableBindings: null;
|
|
253
|
+
currentPage: number;
|
|
254
|
+
pageSize: number;
|
|
255
|
+
tablePagination: null;
|
|
256
|
+
tableFetchingLoading: boolean;
|
|
257
|
+
tableRefresher: number;
|
|
258
|
+
};
|
|
259
|
+
bulkActions: {
|
|
260
|
+
bulkActions: any[];
|
|
261
|
+
selectedBulkAction: null;
|
|
262
|
+
bulkActionPostLoading: boolean;
|
|
263
|
+
bulkActionPostResponse: null;
|
|
264
|
+
};
|
|
265
|
+
rowActions: {
|
|
266
|
+
structureRowActions: any[];
|
|
267
|
+
selectedRowActions: any[];
|
|
268
|
+
clickedRowAction: null;
|
|
269
|
+
rowActionPostLoading: boolean;
|
|
270
|
+
clickedRowActionResponse: null;
|
|
271
|
+
customControlAction: null;
|
|
272
|
+
actionsInRegularCells: boolean;
|
|
273
|
+
clickedRowActionId: null;
|
|
274
|
+
};
|
|
275
|
+
tableColumns: {
|
|
276
|
+
tableColumns: any[];
|
|
277
|
+
visibleColumns: any[];
|
|
278
|
+
selectedRows: any[];
|
|
279
|
+
selectedIds: any[];
|
|
280
|
+
toggledClearRows: boolean;
|
|
281
|
+
rowSelectedModal: null;
|
|
282
|
+
};
|
|
283
|
+
}, undefined, _reduxjs_toolkit.UnknownAction>;
|
|
284
|
+
}>, _reduxjs_toolkit.StoreEnhancer]>>;
|
|
285
|
+
type TableStore = ReturnType<typeof createTableStore>;
|
|
286
|
+
type TableRootState = ReturnType<TableStore['getState']>;
|
|
287
|
+
/** Called once from host setup — replaces direct @/store/store import */
|
|
288
|
+
declare function setExternalStoreGetter(getter: () => {
|
|
289
|
+
getState: () => unknown;
|
|
290
|
+
}): void;
|
|
291
|
+
declare const getExternalState: () => unknown;
|
|
292
|
+
|
|
293
|
+
declare const _getTableComponents: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTableComponents">;
|
|
294
|
+
declare const _setAppliedFilters: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setAppliedFilters">;
|
|
295
|
+
declare const _setRenderedFilters: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setRenderedFilters">;
|
|
296
|
+
declare const _getTableData: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTableData">;
|
|
297
|
+
declare const _getTablePagination: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTablePagination">;
|
|
298
|
+
declare const _getTableBindings: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_getTableBindings">;
|
|
299
|
+
declare const _setTableLoading: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setTableLoading">;
|
|
300
|
+
declare const _setCurrentPage: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setCurrentPage">;
|
|
301
|
+
declare const _setTableSorting: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_setTableSorting">;
|
|
302
|
+
declare const _changePageSize: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableCore/_changePageSize">;
|
|
303
|
+
declare const _triggerTableReload: _reduxjs_toolkit.ActionCreatorWithoutPayload<"tableCore/_triggerTableReload">;
|
|
304
|
+
declare const _resetTableCore: _reduxjs_toolkit.ActionCreatorWithoutPayload<"tableCore/_resetTableCore">;
|
|
305
|
+
|
|
306
|
+
declare const _setSelectedRows: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setSelectedRows">;
|
|
307
|
+
declare const _setToggledClearRow: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setToggledClearRow">;
|
|
308
|
+
declare const _setVisibleColumns: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setVisibleColumns">;
|
|
309
|
+
declare const _setRowSelectedModal: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setRowSelectedModal">;
|
|
310
|
+
declare const _setTableColumns: _reduxjs_toolkit.ActionCreatorWithPayload<any, "tableColumns/_setTableColumns">;
|
|
311
|
+
declare const _resetTableColumns: _reduxjs_toolkit.ActionCreatorWithoutPayload<"tableColumns/_resetTableColumns">;
|
|
312
|
+
|
|
313
|
+
declare const _getStructureBulkActions: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_getStructureBulkActions">;
|
|
314
|
+
declare const _getSelectedBulkAction: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_getSelectedBulkAction">;
|
|
315
|
+
declare const _bulkActionPostLoading: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_bulkActionPostLoading">;
|
|
316
|
+
declare const _bulkActionPostResponse: _reduxjs_toolkit.ActionCreatorWithPayload<any, "bulkActions/_bulkActionPostResponse">;
|
|
317
|
+
declare const _resetTableBulkActions: _reduxjs_toolkit.ActionCreatorWithoutPayload<"bulkActions/_resetTableBulkActions">;
|
|
318
|
+
|
|
319
|
+
declare const _getStructureRowActions: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getStructureRowActions">;
|
|
320
|
+
declare const _checkActionsInRegularCells: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_checkActionsInRegularCells">;
|
|
321
|
+
declare const _getSelectedRowActions: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getSelectedRowActions">;
|
|
322
|
+
declare const _setRowActionPostLoading: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_setRowActionPostLoading">;
|
|
323
|
+
declare const _getClickedRowAction: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getClickedRowAction">;
|
|
324
|
+
declare const _getClickedRowActionId: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getClickedRowActionId">;
|
|
325
|
+
declare const _getClickedRowActionResponse: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getClickedRowActionResponse">;
|
|
326
|
+
declare const _getCustomControlRequest: _reduxjs_toolkit.ActionCreatorWithPayload<any, "rowActions/_getCustomControlRequest">;
|
|
327
|
+
declare const _resetTableRowActions: _reduxjs_toolkit.ActionCreatorWithoutPayload<"rowActions/_resetTableRowActions">;
|
|
328
|
+
|
|
329
|
+
export { ApiTablesComponent, type ApiTablesComponents, type ApiTablesConfig, ApiTablesController, ApiTablesHostProvider, type ApiTablesLinkProps, ApiTablesProvider, type BulkActionModalMatcher, type CustomControlMatcher, type CustomControlProps, ReactApiTable, type RowActionModalMatcher, type TableRootState, type TableStore, _bulkActionPostLoading, _bulkActionPostResponse, _changePageSize, _checkActionsInRegularCells, _getClickedRowAction, _getClickedRowActionId, _getClickedRowActionResponse, _getCustomControlRequest, _getSelectedBulkAction, _getSelectedRowActions, _getStructureBulkActions, _getStructureRowActions, _getTableBindings, _getTableComponents, _getTableData, _getTablePagination, _resetTableBulkActions, _resetTableColumns, _resetTableCore, _resetTableRowActions, _setAppliedFilters, _setCurrentPage, _setRenderedFilters, _setRowActionPostLoading, _setRowSelectedModal, _setSelectedRows, _setTableColumns, _setTableLoading, _setTableSorting, _setToggledClearRow, _setVisibleColumns, _triggerTableReload, createTableStore, getExternalState, setExternalStoreGetter, useApiTablesComponent, useApiTablesConfig, useTableFetcher, useTableStructure, useUtilsProvider };
|