better-table 1.1.0 → 1.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/README.md +187 -18
- package/dist/better-table.cjs.js +1 -1
- package/dist/better-table.cjs.js.map +1 -1
- package/dist/better-table.css +1 -1
- package/dist/better-table.es.js +2225 -980
- package/dist/better-table.es.js.map +1 -1
- package/dist/components/BetterTable/__tests__/helpers/test-data.d.ts +125 -0
- package/dist/components/BetterTable/components/TableActionOverflow.d.ts +16 -0
- package/dist/components/BetterTable/components/TableColumnVisibility.d.ts +4 -0
- package/dist/components/BetterTable/components/TableExpandedRow.d.ts +8 -0
- package/dist/components/BetterTable/components/TableFilterPanel.d.ts +7 -0
- package/dist/components/BetterTable/components/TableFloatingFilter.d.ts +8 -0
- package/dist/components/BetterTable/components/TableRow.d.ts +2 -1
- package/dist/components/BetterTable/components/TableVirtualBody.d.ts +10 -0
- package/dist/components/BetterTable/components/index.d.ts +6 -0
- package/dist/components/BetterTable/constants.d.ts +20 -0
- package/dist/components/BetterTable/context/TableContext.d.ts +15 -65
- package/dist/components/BetterTable/context/TableDataContext.d.ts +18 -0
- package/dist/components/BetterTable/context/TableFilterContext.d.ts +17 -0
- package/dist/components/BetterTable/context/TablePaginationContext.d.ts +19 -0
- package/dist/components/BetterTable/context/TableSelectionContext.d.ts +15 -0
- package/dist/components/BetterTable/context/TableSortContext.d.ts +10 -0
- package/dist/components/BetterTable/context/TableUIContext.d.ts +33 -0
- package/dist/components/BetterTable/context/index.d.ts +14 -2
- package/dist/components/BetterTable/hooks/index.d.ts +6 -0
- package/dist/components/BetterTable/hooks/useColumnResize.d.ts +23 -0
- package/dist/components/BetterTable/hooks/useColumnVisibility.d.ts +24 -0
- package/dist/components/BetterTable/hooks/useExpandableRows.d.ts +19 -0
- package/dist/components/BetterTable/hooks/useFocusTrap.d.ts +6 -0
- package/dist/components/BetterTable/hooks/useMediaQuery.d.ts +8 -0
- package/dist/components/BetterTable/hooks/useTableFilter.d.ts +5 -3
- package/dist/components/BetterTable/hooks/useTablePagination.d.ts +3 -1
- package/dist/components/BetterTable/hooks/useTableSearch.d.ts +3 -1
- package/dist/components/BetterTable/hooks/useTableSort.d.ts +14 -2
- package/dist/components/BetterTable/hooks/useVirtualization.d.ts +25 -0
- package/dist/components/BetterTable/index.d.ts +5 -4
- package/dist/components/BetterTable/types.d.ts +178 -5
- package/dist/components/BetterTable/utils/sortData.d.ts +8 -1
- package/dist/index.d.ts +6 -5
- package/package.json +24 -15
|
@@ -3,6 +3,8 @@ interface UseTablePaginationOptions<T extends TableData> {
|
|
|
3
3
|
data: T[];
|
|
4
4
|
config?: PaginationConfig | false;
|
|
5
5
|
onPageChange?: (page: number, pageSize: number) => void;
|
|
6
|
+
/** When true, skip client-side pagination — data represents the current page from the server */
|
|
7
|
+
manual?: boolean;
|
|
6
8
|
}
|
|
7
9
|
interface UseTablePaginationReturn<T extends TableData> {
|
|
8
10
|
paginatedData: T[];
|
|
@@ -19,5 +21,5 @@ interface UseTablePaginationReturn<T extends TableData> {
|
|
|
19
21
|
startIndex: number;
|
|
20
22
|
endIndex: number;
|
|
21
23
|
}
|
|
22
|
-
export declare function useTablePagination<T extends TableData>({ data, config, onPageChange, }: UseTablePaginationOptions<T>): UseTablePaginationReturn<T>;
|
|
24
|
+
export declare function useTablePagination<T extends TableData>({ data, config, onPageChange, manual, }: UseTablePaginationOptions<T>): UseTablePaginationReturn<T>;
|
|
23
25
|
export {};
|
|
@@ -7,6 +7,8 @@ interface UseTableSearchOptions<T extends TableData> {
|
|
|
7
7
|
controlledValue?: string;
|
|
8
8
|
onSearchChange?: (value: string) => void;
|
|
9
9
|
debounceMs?: number;
|
|
10
|
+
/** When true, skip client-side search — data is returned as-is */
|
|
11
|
+
manual?: boolean;
|
|
10
12
|
}
|
|
11
13
|
interface UseTableSearchReturn<T extends TableData> {
|
|
12
14
|
searchedData: T[];
|
|
@@ -14,5 +16,5 @@ interface UseTableSearchReturn<T extends TableData> {
|
|
|
14
16
|
handleSearch: (value: string) => void;
|
|
15
17
|
clearSearch: () => void;
|
|
16
18
|
}
|
|
17
|
-
export declare function useTableSearch<T extends TableData>({ data, columns, searchColumns, initialValue, controlledValue, onSearchChange, }: UseTableSearchOptions<T>): UseTableSearchReturn<T>;
|
|
19
|
+
export declare function useTableSearch<T extends TableData>({ data, columns, searchColumns, initialValue, controlledValue, onSearchChange, debounceMs, manual, }: UseTableSearchOptions<T>): UseTableSearchReturn<T>;
|
|
18
20
|
export {};
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
import { SortState, TableData } from '../types';
|
|
1
|
+
import { SortState, MultiSortState, TableData } from '../types';
|
|
2
2
|
interface UseTableSortOptions<T extends TableData> {
|
|
3
3
|
data: T[];
|
|
4
4
|
initialSort?: SortState;
|
|
5
5
|
controlledSort?: SortState;
|
|
6
6
|
onSortChange?: (sort: SortState) => void;
|
|
7
|
+
/** Enable multi-sort (Shift+Click) */
|
|
8
|
+
multiSort?: boolean;
|
|
9
|
+
/** Controlled multi-sort state */
|
|
10
|
+
controlledMultiSort?: MultiSortState;
|
|
11
|
+
/** Callback when multi-sort changes */
|
|
12
|
+
onMultiSortChange?: (sorts: MultiSortState) => void;
|
|
13
|
+
/** When true, skip client-side sorting — data is returned as-is */
|
|
14
|
+
manual?: boolean;
|
|
7
15
|
}
|
|
8
16
|
interface UseTableSortReturn<T extends TableData> {
|
|
9
17
|
sortedData: T[];
|
|
10
18
|
sortState: SortState;
|
|
11
19
|
handleSort: (columnId: string) => void;
|
|
12
20
|
clearSort: () => void;
|
|
21
|
+
/** Multi-sort state (array of sort states in priority order) */
|
|
22
|
+
multiSortState: MultiSortState;
|
|
23
|
+
/** Whether multi-sort is enabled */
|
|
24
|
+
isMultiSort: boolean;
|
|
13
25
|
}
|
|
14
|
-
export declare function useTableSort<T extends TableData>({ data, initialSort, controlledSort, onSortChange, }: UseTableSortOptions<T>): UseTableSortReturn<T>;
|
|
26
|
+
export declare function useTableSort<T extends TableData>({ data, initialSort, controlledSort, onSortChange, multiSort, controlledMultiSort, onMultiSortChange, manual, }: UseTableSortOptions<T>): UseTableSortReturn<T>;
|
|
15
27
|
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
interface UseVirtualizationOptions {
|
|
3
|
+
/** Ref to the scrollable container */
|
|
4
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
5
|
+
/** Total number of items */
|
|
6
|
+
itemCount: number;
|
|
7
|
+
/** Fixed height per row in pixels */
|
|
8
|
+
rowHeight: number;
|
|
9
|
+
/** Extra rows to render above/below the viewport */
|
|
10
|
+
buffer: number;
|
|
11
|
+
/** Whether virtualization is active */
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface UseVirtualizationResult {
|
|
15
|
+
/** Total height of the virtualized content (px) */
|
|
16
|
+
totalHeight: number;
|
|
17
|
+
/** Index of the first row to render */
|
|
18
|
+
startIndex: number;
|
|
19
|
+
/** Index of the last row to render (exclusive) */
|
|
20
|
+
endIndex: number;
|
|
21
|
+
/** Top offset for the first rendered row (px) */
|
|
22
|
+
offsetTop: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function useVirtualization({ containerRef, itemCount, rowHeight, buffer, enabled, }: UseVirtualizationOptions): UseVirtualizationResult;
|
|
25
|
+
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { BetterTable, default } from './components';
|
|
2
|
-
export { defaultLocale } from './types';
|
|
3
|
-
export type { BetterTableProps, Column, RowAction, GlobalAction, PaginationConfig, SortState, FilterState, TableClassNames, TableLocale, TableData, } from './types';
|
|
2
|
+
export { defaultLocale, locales } from './types';
|
|
3
|
+
export type { BetterTableProps, Column, RowAction, GlobalAction, PaginationConfig, SortState, MultiSortState, FilterState, TableClassNames, TableLocale, TableData, LocaleKey, } from './types';
|
|
4
4
|
export { useTableSort } from './hooks/useTableSort';
|
|
5
5
|
export { useTableFilter } from './hooks/useTableFilter';
|
|
6
6
|
export { useTablePagination } from './hooks/useTablePagination';
|
|
7
7
|
export { useTableSelection } from './hooks/useTableSelection';
|
|
8
8
|
export { useTableSearch } from './hooks/useTableSearch';
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
9
|
+
export { useColumnVisibility } from './hooks/useColumnVisibility';
|
|
10
|
+
export { TableProvider, useTableData, useTableSortContext, useTableFilterContext, useTableSelectionContext, useTablePaginationContext, useTableUI, } from './context';
|
|
11
|
+
export type { TableProviderProps, TableDataContextValue, TableSortContextValue, TableFilterContextValue, TableSelectionContextValue, TablePaginationContextValue, TableUIContextValue, } from './context';
|
|
11
12
|
export { getValueFromPath } from './utils/getValueFromPath';
|
|
12
13
|
export { sortData } from './utils/sortData';
|
|
13
14
|
export { filterData, searchData } from './utils/filterData';
|
|
@@ -26,6 +26,12 @@ export interface Column<T extends TableData = TableData> {
|
|
|
26
26
|
filterable?: boolean;
|
|
27
27
|
/** Ancho de columna */
|
|
28
28
|
width?: string | number;
|
|
29
|
+
/** Ancho mínimo de columna en px (default: 50) */
|
|
30
|
+
minWidth?: number;
|
|
31
|
+
/** Ancho máximo de columna en px */
|
|
32
|
+
maxWidth?: number;
|
|
33
|
+
/** Whether this column can be resized (default: inherits from table-level resizable) */
|
|
34
|
+
resizable?: boolean;
|
|
29
35
|
/** Alineación del contenido */
|
|
30
36
|
align?: "left" | "center" | "right";
|
|
31
37
|
/** Columna oculta */
|
|
@@ -93,6 +99,15 @@ export interface PaginationConfig {
|
|
|
93
99
|
/** Mostrar salto a página */
|
|
94
100
|
showQuickJumper?: boolean;
|
|
95
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Configuration for expandable rows
|
|
104
|
+
*/
|
|
105
|
+
export interface ExpandableConfig<T extends TableData = TableData> {
|
|
106
|
+
/** Render function for the expanded row content */
|
|
107
|
+
render: (row: T, rowIndex: number) => ReactNode;
|
|
108
|
+
/** Whether only one row can be expanded at a time (default: false) */
|
|
109
|
+
accordion?: boolean;
|
|
110
|
+
}
|
|
96
111
|
/**
|
|
97
112
|
* Estado de ordenamiento
|
|
98
113
|
*/
|
|
@@ -100,11 +115,22 @@ export interface SortState {
|
|
|
100
115
|
columnId: string | null;
|
|
101
116
|
direction: "asc" | "desc";
|
|
102
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Estado de multi-sort (array de sort states en orden de prioridad)
|
|
120
|
+
*/
|
|
121
|
+
export type MultiSortState = SortState[];
|
|
122
|
+
/**
|
|
123
|
+
* Rango de fechas para filtros tipo date
|
|
124
|
+
*/
|
|
125
|
+
export interface DateFilterRange {
|
|
126
|
+
from?: string;
|
|
127
|
+
to?: string;
|
|
128
|
+
}
|
|
103
129
|
/**
|
|
104
130
|
* Estado de filtros
|
|
105
131
|
*/
|
|
106
132
|
export interface FilterState {
|
|
107
|
-
[columnId: string]: string | number | boolean | null;
|
|
133
|
+
[columnId: string]: string | number | boolean | DateFilterRange | null;
|
|
108
134
|
}
|
|
109
135
|
/**
|
|
110
136
|
* Personalización de estilos
|
|
@@ -145,13 +171,116 @@ export interface TableLocale {
|
|
|
145
171
|
sortDesc?: string;
|
|
146
172
|
filterBy?: string;
|
|
147
173
|
clearFilters?: string;
|
|
174
|
+
dateFrom?: string;
|
|
175
|
+
dateTo?: string;
|
|
148
176
|
selectAll?: string;
|
|
149
177
|
deselectAll?: string;
|
|
178
|
+
moreActions?: string;
|
|
179
|
+
clearSearch?: string;
|
|
180
|
+
closeModal?: string;
|
|
181
|
+
previousPage?: string;
|
|
182
|
+
nextPage?: string;
|
|
183
|
+
jumpToPage?: string;
|
|
184
|
+
details?: string;
|
|
185
|
+
columns?: string;
|
|
186
|
+
showAllColumns?: string;
|
|
187
|
+
hideColumn?: string;
|
|
188
|
+
sortPriority?: string;
|
|
189
|
+
clearSort?: string;
|
|
190
|
+
/** aria-live announcements */
|
|
191
|
+
resultsFound?: string;
|
|
192
|
+
noResultsFound?: string;
|
|
193
|
+
rowsSelected?: string;
|
|
194
|
+
/** Expandable rows */
|
|
195
|
+
expandRow?: string;
|
|
196
|
+
collapseRow?: string;
|
|
150
197
|
}
|
|
151
198
|
/**
|
|
152
|
-
* Locale por defecto
|
|
199
|
+
* Locale por defecto (Inglés)
|
|
200
|
+
*/
|
|
201
|
+
export declare const defaultLocale: Required<TableLocale>;
|
|
202
|
+
/**
|
|
203
|
+
* Locales predefinidos
|
|
153
204
|
*/
|
|
154
|
-
export declare const
|
|
205
|
+
export declare const locales: {
|
|
206
|
+
readonly en: Required<TableLocale>;
|
|
207
|
+
readonly es: {
|
|
208
|
+
search: string;
|
|
209
|
+
searchPlaceholder: string;
|
|
210
|
+
noData: string;
|
|
211
|
+
loading: string;
|
|
212
|
+
page: string;
|
|
213
|
+
of: string;
|
|
214
|
+
items: string;
|
|
215
|
+
selected: string;
|
|
216
|
+
rowsPerPage: string;
|
|
217
|
+
actions: string;
|
|
218
|
+
sortAsc: string;
|
|
219
|
+
sortDesc: string;
|
|
220
|
+
filterBy: string;
|
|
221
|
+
clearFilters: string;
|
|
222
|
+
dateFrom: string;
|
|
223
|
+
dateTo: string;
|
|
224
|
+
selectAll: string;
|
|
225
|
+
deselectAll: string;
|
|
226
|
+
moreActions: string;
|
|
227
|
+
clearSearch: string;
|
|
228
|
+
closeModal: string;
|
|
229
|
+
previousPage: string;
|
|
230
|
+
nextPage: string;
|
|
231
|
+
jumpToPage: string;
|
|
232
|
+
details: string;
|
|
233
|
+
columns: string;
|
|
234
|
+
showAllColumns: string;
|
|
235
|
+
hideColumn: string;
|
|
236
|
+
sortPriority: string;
|
|
237
|
+
clearSort: string;
|
|
238
|
+
resultsFound: string;
|
|
239
|
+
noResultsFound: string;
|
|
240
|
+
rowsSelected: string;
|
|
241
|
+
expandRow: string;
|
|
242
|
+
collapseRow: string;
|
|
243
|
+
};
|
|
244
|
+
readonly pt: {
|
|
245
|
+
search: string;
|
|
246
|
+
searchPlaceholder: string;
|
|
247
|
+
noData: string;
|
|
248
|
+
loading: string;
|
|
249
|
+
page: string;
|
|
250
|
+
of: string;
|
|
251
|
+
items: string;
|
|
252
|
+
selected: string;
|
|
253
|
+
rowsPerPage: string;
|
|
254
|
+
actions: string;
|
|
255
|
+
sortAsc: string;
|
|
256
|
+
sortDesc: string;
|
|
257
|
+
filterBy: string;
|
|
258
|
+
clearFilters: string;
|
|
259
|
+
dateFrom: string;
|
|
260
|
+
dateTo: string;
|
|
261
|
+
selectAll: string;
|
|
262
|
+
deselectAll: string;
|
|
263
|
+
moreActions: string;
|
|
264
|
+
clearSearch: string;
|
|
265
|
+
closeModal: string;
|
|
266
|
+
previousPage: string;
|
|
267
|
+
nextPage: string;
|
|
268
|
+
jumpToPage: string;
|
|
269
|
+
details: string;
|
|
270
|
+
columns: string;
|
|
271
|
+
showAllColumns: string;
|
|
272
|
+
hideColumn: string;
|
|
273
|
+
sortPriority: string;
|
|
274
|
+
clearSort: string;
|
|
275
|
+
resultsFound: string;
|
|
276
|
+
noResultsFound: string;
|
|
277
|
+
rowsSelected: string;
|
|
278
|
+
expandRow: string;
|
|
279
|
+
collapseRow: string;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/** Claves de locales predefinidos */
|
|
283
|
+
export type LocaleKey = keyof typeof locales;
|
|
155
284
|
/**
|
|
156
285
|
* Props principales del componente BetterTable
|
|
157
286
|
*/
|
|
@@ -166,6 +295,8 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
166
295
|
rowActions?: RowAction<T>[];
|
|
167
296
|
/** Acciones globales (toolbar) */
|
|
168
297
|
globalActions?: GlobalAction<T>[];
|
|
298
|
+
/** Máximo de acciones visibles inline antes de agrupar en menú overflow (default: 3) */
|
|
299
|
+
maxVisibleActions?: number;
|
|
169
300
|
/** Configuración de paginación (false para desactivar) */
|
|
170
301
|
pagination?: PaginationConfig | false;
|
|
171
302
|
/** Callback de cambio de página */
|
|
@@ -174,6 +305,14 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
174
305
|
sort?: SortState;
|
|
175
306
|
/** Callback de cambio de ordenamiento */
|
|
176
307
|
onSortChange?: (sort: SortState) => void;
|
|
308
|
+
/** Habilitar multi-sort (cada columna cicla: sin orden → asc → desc → sin orden, default: false) */
|
|
309
|
+
multiSort?: boolean;
|
|
310
|
+
/** Estado de multi-sort (controlado) */
|
|
311
|
+
multiSortState?: MultiSortState;
|
|
312
|
+
/** Callback de cambio de multi-sort */
|
|
313
|
+
onMultiSortChange?: (sorts: MultiSortState) => void;
|
|
314
|
+
/** Modo de visualización de filtros: 'floating' (en header), 'panel' (colapsable), o 'both' (default: 'floating') */
|
|
315
|
+
filterMode?: "floating" | "panel" | "both";
|
|
177
316
|
/** Estado de filtros (controlado) */
|
|
178
317
|
filters?: FilterState;
|
|
179
318
|
/** Callback de cambio de filtros */
|
|
@@ -186,6 +325,14 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
186
325
|
onSearchChange?: (value: string) => void;
|
|
187
326
|
/** Columnas en las que buscar (default: todas) */
|
|
188
327
|
searchColumns?: string[];
|
|
328
|
+
/** Milisegundos de debounce en la búsqueda (default: 300) */
|
|
329
|
+
searchDebounceMs?: number;
|
|
330
|
+
/** Skip client-side sorting — data is assumed pre-sorted by the server (default: false) */
|
|
331
|
+
manualSorting?: boolean;
|
|
332
|
+
/** Skip client-side filtering and search — data is assumed pre-filtered by the server (default: false) */
|
|
333
|
+
manualFiltering?: boolean;
|
|
334
|
+
/** Skip client-side pagination — data represents the current page from the server (default: false) */
|
|
335
|
+
manualPagination?: boolean;
|
|
189
336
|
/** Habilitar selección de filas */
|
|
190
337
|
selectable?: boolean;
|
|
191
338
|
/** Filas seleccionadas (controlado) */
|
|
@@ -194,6 +341,12 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
194
341
|
onSelectionChange?: (selectedRows: T[]) => void;
|
|
195
342
|
/** Modo de selección */
|
|
196
343
|
selectionMode?: "single" | "multiple";
|
|
344
|
+
/** Mostrar toggle de visibilidad de columnas en el toolbar */
|
|
345
|
+
columnVisibility?: boolean;
|
|
346
|
+
/** Estado controlado de columnas ocultas (array de column IDs) */
|
|
347
|
+
hiddenColumns?: string[];
|
|
348
|
+
/** Callback cuando cambia la visibilidad de columnas */
|
|
349
|
+
onColumnVisibilityChange?: (hiddenColumns: string[]) => void;
|
|
197
350
|
/** Estado de carga */
|
|
198
351
|
loading?: boolean;
|
|
199
352
|
/** Componente de loading personalizado */
|
|
@@ -211,8 +364,8 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
211
364
|
row?: CSSProperties;
|
|
212
365
|
cell?: CSSProperties;
|
|
213
366
|
};
|
|
214
|
-
/** Textos personalizados */
|
|
215
|
-
locale?: TableLocale;
|
|
367
|
+
/** Textos personalizados (preset: 'en' | 'es' | 'pt', o parcial para override) */
|
|
368
|
+
locale?: LocaleKey | TableLocale;
|
|
216
369
|
/** Header fijo al hacer scroll */
|
|
217
370
|
stickyHeader?: boolean;
|
|
218
371
|
/** Altura máxima (activa scroll interno) */
|
|
@@ -225,6 +378,14 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
225
378
|
hoverable?: boolean;
|
|
226
379
|
/** Tamaño de la tabla */
|
|
227
380
|
size?: "small" | "medium" | "large";
|
|
381
|
+
/** Enable column resizing via drag (default: false) */
|
|
382
|
+
resizable?: boolean;
|
|
383
|
+
/** Callback when a column is resized */
|
|
384
|
+
onColumnResize?: (columnId: string, width: number) => void;
|
|
385
|
+
/** Minimum column width in px when resizing (default: 50) */
|
|
386
|
+
minColumnWidth?: number;
|
|
387
|
+
/** Maximum column width in px when resizing */
|
|
388
|
+
maxColumnWidth?: number;
|
|
228
389
|
/** Callback al hacer click en una fila */
|
|
229
390
|
onRowClick?: (row: T, rowIndex: number) => void;
|
|
230
391
|
/** Callback al hacer doble click en una fila */
|
|
@@ -233,4 +394,16 @@ export interface BetterTableProps<T extends TableData = TableData> {
|
|
|
233
394
|
ariaLabel?: string;
|
|
234
395
|
/** ID del elemento que describe la tabla */
|
|
235
396
|
ariaDescribedBy?: string;
|
|
397
|
+
/** Configuration for expandable rows (render function for expanded content) */
|
|
398
|
+
expandable?: ExpandableConfig<T>;
|
|
399
|
+
/** Array of expanded row keys (controlled mode) */
|
|
400
|
+
expandedRows?: string[];
|
|
401
|
+
/** Callback when expanded rows change */
|
|
402
|
+
onExpandChange?: (expandedRows: string[]) => void;
|
|
403
|
+
/** Force-enable virtualization (auto-enabled when pagination is off and dataset > VIRTUALIZATION_THRESHOLD) */
|
|
404
|
+
virtualize?: boolean;
|
|
405
|
+
/** Fixed row height in px for virtualized rendering (default: 48) */
|
|
406
|
+
rowHeight?: number;
|
|
407
|
+
/** Extra rows rendered above/below the viewport as scroll buffer (default: 5) */
|
|
408
|
+
virtualBuffer?: number;
|
|
236
409
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TableData } from '../types';
|
|
1
|
+
import { TableData, MultiSortState } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Ordena un array de datos por una columna específica
|
|
4
4
|
* @param data - Array de datos a ordenar
|
|
@@ -7,3 +7,10 @@ import { TableData } from '../types';
|
|
|
7
7
|
* @returns Array ordenado (nueva referencia)
|
|
8
8
|
*/
|
|
9
9
|
export declare function sortData<T extends TableData>(data: T[], columnId: string, direction: "asc" | "desc"): T[];
|
|
10
|
+
/**
|
|
11
|
+
* Ordena un array de datos por múltiples columnas (multi-sort)
|
|
12
|
+
* @param data - Array de datos a ordenar
|
|
13
|
+
* @param sorts - Array de estados de sort en orden de prioridad
|
|
14
|
+
* @returns Array ordenado (nueva referencia)
|
|
15
|
+
*/
|
|
16
|
+
export declare function multiSortData<T extends TableData>(data: T[], sorts: MultiSortState): T[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* better-table
|
|
3
3
|
* A modern, flexible, and fully typed React data table component
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
export { BetterTable } from './components/BetterTable';
|
|
8
|
-
export { defaultLocale } from './components/BetterTable/types';
|
|
9
|
-
export type { BetterTableProps, Column, RowAction, GlobalAction, PaginationConfig, SortState, FilterState, TableClassNames, TableLocale, TableData, } from './components/BetterTable/types';
|
|
8
|
+
export { defaultLocale, locales } from './components/BetterTable/types';
|
|
9
|
+
export type { BetterTableProps, Column, RowAction, GlobalAction, ExpandableConfig, PaginationConfig, SortState, MultiSortState, FilterState, DateFilterRange, TableClassNames, TableLocale, TableData, LocaleKey, } from './components/BetterTable/types';
|
|
10
10
|
export { useTableSort } from './components/BetterTable/hooks/useTableSort';
|
|
11
11
|
export { useTableFilter } from './components/BetterTable/hooks/useTableFilter';
|
|
12
12
|
export { useTablePagination } from './components/BetterTable/hooks/useTablePagination';
|
|
13
13
|
export { useTableSelection } from './components/BetterTable/hooks/useTableSelection';
|
|
14
14
|
export { useTableSearch } from './components/BetterTable/hooks/useTableSearch';
|
|
15
|
-
export {
|
|
16
|
-
export
|
|
15
|
+
export { useColumnVisibility } from './components/BetterTable/hooks/useColumnVisibility';
|
|
16
|
+
export { TableProvider, useTableData, useTableSortContext, useTableFilterContext, useTableSelectionContext, useTablePaginationContext, useTableUI, } from './components/BetterTable/context';
|
|
17
|
+
export type { TableProviderProps, TableDataContextValue, TableSortContextValue, TableFilterContextValue, TableSelectionContextValue, TablePaginationContextValue, TableUIContextValue, } from './components/BetterTable/context';
|
|
17
18
|
export { getValueFromPath } from './components/BetterTable/utils/getValueFromPath';
|
|
18
19
|
export { sortData } from './components/BetterTable/utils/sortData';
|
|
19
20
|
export { filterData, searchData, } from './components/BetterTable/utils/filterData';
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-table",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A modern, flexible, and fully typed React data table component",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "jrodrigopuca",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/better-table.cjs.js",
|
|
@@ -36,9 +36,19 @@
|
|
|
36
36
|
"datagrid",
|
|
37
37
|
"typescript",
|
|
38
38
|
"sorting",
|
|
39
|
+
"multi-sort",
|
|
39
40
|
"filtering",
|
|
40
41
|
"pagination",
|
|
41
|
-
"selection"
|
|
42
|
+
"selection",
|
|
43
|
+
"column-visibility",
|
|
44
|
+
"column-resize",
|
|
45
|
+
"expandable-rows",
|
|
46
|
+
"virtualization",
|
|
47
|
+
"sticky-header",
|
|
48
|
+
"server-side",
|
|
49
|
+
"accessible",
|
|
50
|
+
"responsive",
|
|
51
|
+
"i18n"
|
|
42
52
|
],
|
|
43
53
|
"repository": {
|
|
44
54
|
"type": "git",
|
|
@@ -73,17 +83,6 @@
|
|
|
73
83
|
"vite-plugin-dts": "^4.5.0",
|
|
74
84
|
"vitest": "^4.0.18"
|
|
75
85
|
},
|
|
76
|
-
"scripts": {
|
|
77
|
-
"dev": "vite --config demo/vite.config.ts",
|
|
78
|
-
"build": "vite build",
|
|
79
|
-
"build:types": "tsc -p tsconfig.build.json",
|
|
80
|
-
"preview": "vite preview",
|
|
81
|
-
"test": "vitest --config vitest.config.ts",
|
|
82
|
-
"test:run": "vitest run --config vitest.config.ts",
|
|
83
|
-
"test:coverage": "vitest run --coverage --config vitest.config.ts",
|
|
84
|
-
"lint": "tsc --noEmit",
|
|
85
|
-
"prepublishOnly": "npm run build"
|
|
86
|
-
},
|
|
87
86
|
"browserslist": {
|
|
88
87
|
"production": [
|
|
89
88
|
">0.2%",
|
|
@@ -95,5 +94,15 @@
|
|
|
95
94
|
"last 1 firefox version",
|
|
96
95
|
"last 1 safari version"
|
|
97
96
|
]
|
|
97
|
+
},
|
|
98
|
+
"scripts": {
|
|
99
|
+
"dev": "vite --config demo/vite.config.ts",
|
|
100
|
+
"build": "vite build",
|
|
101
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
102
|
+
"preview": "vite preview",
|
|
103
|
+
"test": "vitest --config vitest.config.ts",
|
|
104
|
+
"test:run": "vitest run --config vitest.config.ts",
|
|
105
|
+
"test:coverage": "vitest run --coverage --config vitest.config.ts",
|
|
106
|
+
"lint": "tsc --noEmit"
|
|
98
107
|
}
|
|
99
|
-
}
|
|
108
|
+
}
|