@ackplus/react-tanstack-data-table 1.1.19 → 1.1.21
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/dist/lib/hooks/use-data-table-engine.d.ts.map +1 -1
- package/dist/lib/hooks/use-data-table-engine.js +54 -15
- package/dist/lib/types/data-table.types.d.ts +2 -1
- package/dist/lib/types/data-table.types.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/index.ts +0 -75
- package/src/lib/components/data-table-view.tsx +0 -386
- package/src/lib/components/droupdown/menu-dropdown.tsx +0 -103
- package/src/lib/components/filters/filter-value-input.tsx +0 -225
- package/src/lib/components/filters/index.ts +0 -126
- package/src/lib/components/headers/draggable-header.tsx +0 -326
- package/src/lib/components/headers/index.ts +0 -6
- package/src/lib/components/headers/table-header.tsx +0 -175
- package/src/lib/components/index.ts +0 -21
- package/src/lib/components/pagination/data-table-pagination.tsx +0 -111
- package/src/lib/components/pagination/index.ts +0 -5
- package/src/lib/components/rows/data-table-row.tsx +0 -218
- package/src/lib/components/rows/empty-data-row.tsx +0 -69
- package/src/lib/components/rows/index.ts +0 -7
- package/src/lib/components/rows/loading-rows.tsx +0 -164
- package/src/lib/components/toolbar/bulk-actions-toolbar.tsx +0 -125
- package/src/lib/components/toolbar/column-filter-control.tsx +0 -432
- package/src/lib/components/toolbar/column-pinning-control.tsx +0 -275
- package/src/lib/components/toolbar/column-reset-control.tsx +0 -74
- package/src/lib/components/toolbar/column-visibility-control.tsx +0 -105
- package/src/lib/components/toolbar/data-table-toolbar.tsx +0 -257
- package/src/lib/components/toolbar/index.ts +0 -17
- package/src/lib/components/toolbar/table-export-control.tsx +0 -233
- package/src/lib/components/toolbar/table-refresh-control.tsx +0 -62
- package/src/lib/components/toolbar/table-search-control.tsx +0 -155
- package/src/lib/components/toolbar/table-size-control.tsx +0 -102
- package/src/lib/contexts/data-table-context.tsx +0 -126
- package/src/lib/data-table.tsx +0 -29
- package/src/lib/features/README.md +0 -161
- package/src/lib/features/column-filter.feature.ts +0 -493
- package/src/lib/features/index.ts +0 -23
- package/src/lib/features/selection.feature.ts +0 -322
- package/src/lib/hooks/index.ts +0 -2
- package/src/lib/hooks/use-data-table-engine.ts +0 -1516
- package/src/lib/icons/add-icon.tsx +0 -23
- package/src/lib/icons/csv-icon.tsx +0 -15
- package/src/lib/icons/delete-icon.tsx +0 -30
- package/src/lib/icons/excel-icon.tsx +0 -15
- package/src/lib/icons/index.ts +0 -7
- package/src/lib/icons/unpin-icon.tsx +0 -18
- package/src/lib/icons/view-comfortable-icon.tsx +0 -45
- package/src/lib/icons/view-compact-icon.tsx +0 -55
- package/src/lib/types/column.types.ts +0 -63
- package/src/lib/types/data-table-api.ts +0 -191
- package/src/lib/types/data-table.types.ts +0 -192
- package/src/lib/types/export.types.ts +0 -223
- package/src/lib/types/index.ts +0 -24
- package/src/lib/types/slots.types.ts +0 -342
- package/src/lib/types/table.types.ts +0 -88
- package/src/lib/utils/column-helpers.ts +0 -72
- package/src/lib/utils/debounced-fetch.utils.ts +0 -131
- package/src/lib/utils/export-utils.ts +0 -712
- package/src/lib/utils/index.ts +0 -27
- package/src/lib/utils/logger.ts +0 -203
- package/src/lib/utils/slot-helpers.tsx +0 -194
- package/src/lib/utils/special-columns.utils.ts +0 -101
- package/src/lib/utils/styling-helpers.ts +0 -126
- package/src/lib/utils/table-helpers.ts +0 -106
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function AddIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
|
12
|
-
<circle
|
|
13
|
-
cx="12"
|
|
14
|
-
cy="12"
|
|
15
|
-
r="9"
|
|
16
|
-
fill="none"
|
|
17
|
-
stroke="currentColor"
|
|
18
|
-
strokeWidth="0.5"
|
|
19
|
-
opacity="0.3"
|
|
20
|
-
/>
|
|
21
|
-
</SvgIcon>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function CsvIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" />
|
|
12
|
-
<path d="M7,12.5A0.5,0.5 0 0,1 7.5,12H8.5A0.5,0.5 0 0,1 9,12.5V13.5A0.5,0.5 0 0,1 8.5,14H7.5A0.5,0.5 0 0,1 7,13.5M10.5,12.5A0.5,0.5 0 0,1 11,12H12A0.5,0.5 0 0,1 12.5,12.5V13.5A0.5,0.5 0 0,1 12,14H11A0.5,0.5 0 0,1 10.5,13.5M14,12.5A0.5,0.5 0 0,1 14.5,12H15.5A0.5,0.5 0 0,1 16,12.5V13.5A0.5,0.5 0 0,1 15.5,14H14.5A0.5,0.5 0 0,1 14,13.5" />
|
|
13
|
-
</SvgIcon>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function DeleteIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
|
|
12
|
-
<rect
|
|
13
|
-
x="9"
|
|
14
|
-
y="8"
|
|
15
|
-
width="2"
|
|
16
|
-
height="9"
|
|
17
|
-
fill="currentColor"
|
|
18
|
-
opacity="0.6"
|
|
19
|
-
/>
|
|
20
|
-
<rect
|
|
21
|
-
x="13"
|
|
22
|
-
y="8"
|
|
23
|
-
width="2"
|
|
24
|
-
height="9"
|
|
25
|
-
fill="currentColor"
|
|
26
|
-
opacity="0.6"
|
|
27
|
-
/>
|
|
28
|
-
</SvgIcon>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function ExcelIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" />
|
|
12
|
-
<path d="M11.5,15L9.75,12.5L11.5,10H10L8.75,11.5L7.5,10H6L7.75,12.5L6,15H7.5L8.75,13.5L10,15H11.5M15,10V12H17V10H15M15,14V16H17V14H15Z" />
|
|
13
|
-
</SvgIcon>
|
|
14
|
-
);
|
|
15
|
-
}
|
package/src/lib/icons/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { UnpinIcon } from './unpin-icon';
|
|
2
|
-
export { AddIcon } from './add-icon';
|
|
3
|
-
export { DeleteIcon } from './delete-icon';
|
|
4
|
-
export { ViewCompactIcon } from './view-compact-icon';
|
|
5
|
-
export { ViewComfortableIcon } from './view-comfortable-icon';
|
|
6
|
-
export { CsvIcon } from './csv-icon';
|
|
7
|
-
export { ExcelIcon } from './excel-icon';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function UnpinIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<path
|
|
12
|
-
d="M2 5.27L3.28 4 20 20.72 18.73 22l-3.41-3.41V22h-1.6v-6H8v-2l2-2V9.27L2 5.27zM16 12V4h1V2H7v2h1v3.73l8 8z"
|
|
13
|
-
opacity="0.7"
|
|
14
|
-
/>
|
|
15
|
-
<path d="M14.73 12L16 10.73V4h1V2H7v2h1v3.73l2.27 2.27z" />
|
|
16
|
-
</SvgIcon>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function ViewComfortableIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<rect
|
|
12
|
-
x="3"
|
|
13
|
-
y="3"
|
|
14
|
-
width="18"
|
|
15
|
-
height="3"
|
|
16
|
-
fill="currentColor"
|
|
17
|
-
rx="1"
|
|
18
|
-
/>
|
|
19
|
-
<rect
|
|
20
|
-
x="3"
|
|
21
|
-
y="8"
|
|
22
|
-
width="18"
|
|
23
|
-
height="3"
|
|
24
|
-
fill="currentColor"
|
|
25
|
-
rx="1"
|
|
26
|
-
/>
|
|
27
|
-
<rect
|
|
28
|
-
x="3"
|
|
29
|
-
y="13"
|
|
30
|
-
width="18"
|
|
31
|
-
height="3"
|
|
32
|
-
fill="currentColor"
|
|
33
|
-
rx="1"
|
|
34
|
-
/>
|
|
35
|
-
<rect
|
|
36
|
-
x="3"
|
|
37
|
-
y="18"
|
|
38
|
-
width="18"
|
|
39
|
-
height="3"
|
|
40
|
-
fill="currentColor"
|
|
41
|
-
rx="1"
|
|
42
|
-
/>
|
|
43
|
-
</SvgIcon>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function ViewCompactIcon(props: SvgIconProps): ReactElement {
|
|
6
|
-
return (
|
|
7
|
-
<SvgIcon
|
|
8
|
-
{...props}
|
|
9
|
-
viewBox="0 0 24 24"
|
|
10
|
-
>
|
|
11
|
-
<rect
|
|
12
|
-
x="3"
|
|
13
|
-
y="4"
|
|
14
|
-
width="18"
|
|
15
|
-
height="2"
|
|
16
|
-
fill="currentColor"
|
|
17
|
-
/>
|
|
18
|
-
<rect
|
|
19
|
-
x="3"
|
|
20
|
-
y="7"
|
|
21
|
-
width="18"
|
|
22
|
-
height="2"
|
|
23
|
-
fill="currentColor"
|
|
24
|
-
/>
|
|
25
|
-
<rect
|
|
26
|
-
x="3"
|
|
27
|
-
y="10"
|
|
28
|
-
width="18"
|
|
29
|
-
height="2"
|
|
30
|
-
fill="currentColor"
|
|
31
|
-
/>
|
|
32
|
-
<rect
|
|
33
|
-
x="3"
|
|
34
|
-
y="13"
|
|
35
|
-
width="18"
|
|
36
|
-
height="2"
|
|
37
|
-
fill="currentColor"
|
|
38
|
-
/>
|
|
39
|
-
<rect
|
|
40
|
-
x="3"
|
|
41
|
-
y="16"
|
|
42
|
-
width="18"
|
|
43
|
-
height="2"
|
|
44
|
-
fill="currentColor"
|
|
45
|
-
/>
|
|
46
|
-
<rect
|
|
47
|
-
x="3"
|
|
48
|
-
y="19"
|
|
49
|
-
width="18"
|
|
50
|
-
height="2"
|
|
51
|
-
fill="currentColor"
|
|
52
|
-
/>
|
|
53
|
-
</SvgIcon>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { ColumnDef, RowData, Column } from '@tanstack/react-table';
|
|
2
|
-
import { ColumnFilterRule } from '../features';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const DEFAULT_SELECTION_COLUMN_NAME = '_selection';
|
|
6
|
-
export const DEFAULT_EXPANDING_COLUMN_NAME = '_expanding';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Column Definition Types
|
|
10
|
-
* Consolidated column-related interfaces from various files
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Module augmentation to extend TanStack Table's ColumnMeta interface
|
|
15
|
-
* This automatically extends all ColumnDef types since they use ColumnMeta in their meta property
|
|
16
|
-
*/
|
|
17
|
-
declare module '@tanstack/react-table' {
|
|
18
|
-
interface ColumnDefBase<TData extends RowData, TValue> {
|
|
19
|
-
type?: 'boolean' | 'number' | 'date' | 'select' | 'text';
|
|
20
|
-
options?: {
|
|
21
|
-
label: string;
|
|
22
|
-
value: string;
|
|
23
|
-
}[];
|
|
24
|
-
align?: 'left' | 'center' | 'right';
|
|
25
|
-
filterable?: boolean;
|
|
26
|
-
hideInExport?: boolean;
|
|
27
|
-
exportHeader?: string | ((context: {
|
|
28
|
-
columnId: string;
|
|
29
|
-
defaultHeader: string;
|
|
30
|
-
columnDef: ColumnDefBase<TData, TValue>;
|
|
31
|
-
}) => string);
|
|
32
|
-
exportValue?: (context: {
|
|
33
|
-
value: any;
|
|
34
|
-
row: TData;
|
|
35
|
-
rowIndex: number;
|
|
36
|
-
columnId: string;
|
|
37
|
-
columnDef: ColumnDefBase<TData, TValue>;
|
|
38
|
-
}) => any;
|
|
39
|
-
exportFormat?: 'auto' | 'string' | 'number' | 'boolean' | 'json' | 'date' | ((context: {
|
|
40
|
-
value: any;
|
|
41
|
-
row: TData;
|
|
42
|
-
rowIndex: number;
|
|
43
|
-
columnId: string;
|
|
44
|
-
columnDef: ColumnDefBase<TData, TValue>;
|
|
45
|
-
}) => any);
|
|
46
|
-
wrapText?: boolean; // If true, text will wrap; if false, text will truncate with ellipsis (default: false)
|
|
47
|
-
editComponent?: React.ComponentType<{
|
|
48
|
-
value: any;
|
|
49
|
-
onChange: (value: any) => void;
|
|
50
|
-
filter: ColumnFilterRule;
|
|
51
|
-
column: Column<TData, TValue>;
|
|
52
|
-
}>;
|
|
53
|
-
filterComponent?: React.ComponentType<{
|
|
54
|
-
value: any;
|
|
55
|
-
onChange: (value: any) => void;
|
|
56
|
-
filter: ColumnFilterRule;
|
|
57
|
-
column: Column<TData, TValue>;
|
|
58
|
-
}>;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export type DataTableColumn<TData extends RowData, TValue = unknown> = ColumnDef<TData, TValue> & {
|
|
62
|
-
// All custom properties are now defined in the module augmentation above
|
|
63
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { ColumnPinningState, SortingState, ColumnOrderState, TableState, Row, Table } from '@tanstack/react-table';
|
|
2
|
-
|
|
3
|
-
import { ColumnFilterState } from './table.types';
|
|
4
|
-
import { SelectionState } from '../features';
|
|
5
|
-
import { ServerExportResult } from './export.types';
|
|
6
|
-
|
|
7
|
-
export interface DataRefreshApiOptions {
|
|
8
|
-
resetPagination?: boolean;
|
|
9
|
-
force?: boolean;
|
|
10
|
-
reason?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type DataRefreshApiInput = boolean | DataRefreshApiOptions;
|
|
14
|
-
|
|
15
|
-
export interface DataTableExportApiOptions {
|
|
16
|
-
filename?: string;
|
|
17
|
-
onlyVisibleColumns?: boolean;
|
|
18
|
-
onlySelectedRows?: boolean;
|
|
19
|
-
includeHeaders?: boolean;
|
|
20
|
-
chunkSize?: number;
|
|
21
|
-
strictTotalCheck?: boolean;
|
|
22
|
-
sanitizeCSV?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface DataTableApi<T = any> {
|
|
26
|
-
// Column Management
|
|
27
|
-
columnVisibility: {
|
|
28
|
-
showColumn: (columnId: string) => void;
|
|
29
|
-
hideColumn: (columnId: string) => void;
|
|
30
|
-
toggleColumn: (columnId: string) => void;
|
|
31
|
-
showAllColumns: () => void;
|
|
32
|
-
hideAllColumns: () => void;
|
|
33
|
-
resetColumnVisibility: () => void;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
table :{
|
|
37
|
-
getTable: () => Table<T>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Column Ordering
|
|
41
|
-
columnOrdering: {
|
|
42
|
-
setColumnOrder: (columnOrder: ColumnOrderState) => void;
|
|
43
|
-
moveColumn: (columnId: string, toIndex: number) => void;
|
|
44
|
-
resetColumnOrder: () => void;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Column Pinning
|
|
48
|
-
columnPinning: {
|
|
49
|
-
pinColumnLeft: (columnId: string) => void;
|
|
50
|
-
pinColumnRight: (columnId: string) => void;
|
|
51
|
-
unpinColumn: (columnId: string) => void;
|
|
52
|
-
setPinning: (pinning: ColumnPinningState) => void;
|
|
53
|
-
resetColumnPinning: () => void;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Column Resizing
|
|
57
|
-
columnResizing: {
|
|
58
|
-
resizeColumn: (columnId: string, width: number) => void;
|
|
59
|
-
autoSizeColumn: (columnId: string) => void;
|
|
60
|
-
autoSizeAllColumns: () => void;
|
|
61
|
-
resetColumnSizing: () => void;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// Filtering
|
|
65
|
-
filtering: {
|
|
66
|
-
setGlobalFilter: (filter: string) => void;
|
|
67
|
-
clearGlobalFilter: () => void;
|
|
68
|
-
setColumnFilters: (filters: ColumnFilterState, isApply?: boolean) => void;
|
|
69
|
-
addColumnFilter: (columnId: string, operator: string, value: any) => void;
|
|
70
|
-
removeColumnFilter: (filterId: string) => void;
|
|
71
|
-
clearAllFilters: () => void;
|
|
72
|
-
resetFilters: () => void;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Sorting
|
|
76
|
-
sorting: {
|
|
77
|
-
setSorting: (sorting: SortingState) => void;
|
|
78
|
-
sortColumn: (columnId: string, direction: 'asc' | 'desc' | false) => void;
|
|
79
|
-
clearSorting: () => void;
|
|
80
|
-
resetSorting: () => void;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// Pagination
|
|
84
|
-
pagination: {
|
|
85
|
-
goToPage: (pageIndex: number) => void;
|
|
86
|
-
nextPage: () => void;
|
|
87
|
-
previousPage: () => void;
|
|
88
|
-
setPageSize: (pageSize: number) => void;
|
|
89
|
-
goToFirstPage: () => void;
|
|
90
|
-
goToLastPage: () => void;
|
|
91
|
-
resetPagination?: () => void;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Enhanced Row Selection with automatic mode detection
|
|
95
|
-
selection: {
|
|
96
|
-
// Basic selection (works with current selectMode)
|
|
97
|
-
selectRow: (rowId: string) => void;
|
|
98
|
-
deselectRow: (rowId: string) => void;
|
|
99
|
-
toggleRowSelection: (rowId: string) => void;
|
|
100
|
-
|
|
101
|
-
// Smart selection methods (automatically handle page vs all modes)
|
|
102
|
-
selectAll: () => void; // Selects all based on current selectMode
|
|
103
|
-
deselectAll: () => void; // Deselects all
|
|
104
|
-
toggleSelectAll: () => void; // Toggles select all
|
|
105
|
-
|
|
106
|
-
// Selection state getters
|
|
107
|
-
getSelectionState: () => SelectionState; // Get selection state
|
|
108
|
-
getSelectedCount: () => number; // Get total selected count
|
|
109
|
-
// Returns selected rows that are currently loaded in the table instance.
|
|
110
|
-
// For server/manual pagination, use getSelectionState() for full selection intent.
|
|
111
|
-
getSelectedRows: () => Row<T>[]
|
|
112
|
-
// Selection state checks
|
|
113
|
-
isRowSelected: (rowId: string) => boolean;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// Data Management
|
|
117
|
-
data: {
|
|
118
|
-
// Refresh data with pagination reset
|
|
119
|
-
refresh: (options?: DataRefreshApiInput) => void;
|
|
120
|
-
// Reload data without all current states
|
|
121
|
-
reload: (options?: DataRefreshApiOptions) => void;
|
|
122
|
-
// Reset all data to initial state
|
|
123
|
-
resetAll: () => void;
|
|
124
|
-
|
|
125
|
-
// Data CRUD operations
|
|
126
|
-
getAllData: () => T[];
|
|
127
|
-
getRowData: (rowId: string) => T | undefined;
|
|
128
|
-
getRowByIndex: (index: number) => T | undefined;
|
|
129
|
-
updateRow: (rowId: string, updates: Partial<T>) => void;
|
|
130
|
-
updateRowByIndex: (index: number, updates: Partial<T>) => void;
|
|
131
|
-
insertRow: (newRow: T, index?: number) => void;
|
|
132
|
-
deleteRow: (rowId: string) => void;
|
|
133
|
-
deleteRowByIndex: (index: number) => void;
|
|
134
|
-
deleteSelectedRows: () => void;
|
|
135
|
-
replaceAllData: (newData: T[]) => void;
|
|
136
|
-
|
|
137
|
-
// Bulk operations
|
|
138
|
-
updateMultipleRows: (updates: Array<{ rowId: string; data: Partial<T> }>) => void;
|
|
139
|
-
insertMultipleRows: (newRows: T[], startIndex?: number) => void;
|
|
140
|
-
deleteMultipleRows: (rowIds: string[]) => void;
|
|
141
|
-
|
|
142
|
-
// Field-specific updates
|
|
143
|
-
updateField: (rowId: string, fieldName: keyof T, value: any) => void;
|
|
144
|
-
updateFieldByIndex: (index: number, fieldName: keyof T, value: any) => void;
|
|
145
|
-
|
|
146
|
-
// Data queries
|
|
147
|
-
findRows: (predicate: (row: T) => boolean) => T[];
|
|
148
|
-
findRowIndex: (predicate: (row: T) => boolean) => number;
|
|
149
|
-
getDataCount: () => number;
|
|
150
|
-
getFilteredDataCount: () => number;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
// Layout Management
|
|
154
|
-
layout: {
|
|
155
|
-
resetLayout: () => void;
|
|
156
|
-
resetAll: () => void;
|
|
157
|
-
saveLayout: () => any;
|
|
158
|
-
restoreLayout: (layout: any) => void;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// Table State
|
|
162
|
-
state: {
|
|
163
|
-
getTableState: () => any;
|
|
164
|
-
getCurrentFilters: () => ColumnFilterState;
|
|
165
|
-
getCurrentSorting: () => SortingState;
|
|
166
|
-
getCurrentPagination: () => { pageIndex: number; pageSize: number };
|
|
167
|
-
getCurrentSelection: () => SelectionState;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// Simplified Export
|
|
171
|
-
export: {
|
|
172
|
-
exportCSV: (options?: DataTableExportApiOptions) => Promise<void>;
|
|
173
|
-
exportExcel: (options?: DataTableExportApiOptions) => Promise<void>;
|
|
174
|
-
exportServerData: (options: {
|
|
175
|
-
format: 'csv' | 'excel';
|
|
176
|
-
filename?: string;
|
|
177
|
-
fetchData: (
|
|
178
|
-
filters?: Partial<TableState>,
|
|
179
|
-
selection?: SelectionState,
|
|
180
|
-
signal?: AbortSignal
|
|
181
|
-
) => Promise<ServerExportResult<T>>;
|
|
182
|
-
pageSize?: number;
|
|
183
|
-
includeHeaders?: boolean;
|
|
184
|
-
chunkSize?: number;
|
|
185
|
-
strictTotalCheck?: boolean;
|
|
186
|
-
sanitizeCSV?: boolean;
|
|
187
|
-
}) => Promise<void>;
|
|
188
|
-
isExporting: () => boolean;
|
|
189
|
-
cancelExport: () => void;
|
|
190
|
-
};
|
|
191
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for DataTable components
|
|
3
|
-
*/
|
|
4
|
-
import { Row, SortingState, ColumnResizeMode, ColumnPinningState, PaginationState, ColumnDef } from '@tanstack/react-table';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
6
|
-
|
|
7
|
-
import type { ColumnFilterState, TableFilters, TableState } from './index';
|
|
8
|
-
import { DataTableSlots, PartialSlotProps } from './slots.types';
|
|
9
|
-
import { DataTableSize } from '../utils/table-helpers';
|
|
10
|
-
import { SelectionState, SelectMode } from '../features';
|
|
11
|
-
import { DataTableLoggingOptions } from '../utils/logger';
|
|
12
|
-
import { ExportConcurrencyMode, ExportProgressPayload, ExportStateChange, ServerExportResult } from './export.types';
|
|
13
|
-
|
|
14
|
-
// Dynamic data management interfaces
|
|
15
|
-
// TableFilters now imported from types folder
|
|
16
|
-
|
|
17
|
-
export type DataRefreshReason = 'initial' | 'state-change' | 'refresh' | 'reload' | 'reset' | string;
|
|
18
|
-
|
|
19
|
-
export interface DataFetchMeta {
|
|
20
|
-
reason?: DataRefreshReason;
|
|
21
|
-
force?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface DataRefreshOptions extends DataFetchMeta {
|
|
25
|
-
resetPagination?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface DataRefreshContext {
|
|
29
|
-
filters: Partial<TableFilters>;
|
|
30
|
-
state: Partial<TableState>;
|
|
31
|
-
options: Required<Pick<DataRefreshOptions, 'resetPagination' | 'force'>> & {
|
|
32
|
-
reason: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type DataMutationAction =
|
|
37
|
-
| 'updateRow'
|
|
38
|
-
| 'updateRowByIndex'
|
|
39
|
-
| 'insertRow'
|
|
40
|
-
| 'deleteRow'
|
|
41
|
-
| 'deleteRowByIndex'
|
|
42
|
-
| 'deleteSelectedRows'
|
|
43
|
-
| 'replaceAllData'
|
|
44
|
-
| 'updateMultipleRows'
|
|
45
|
-
| 'insertMultipleRows'
|
|
46
|
-
| 'deleteMultipleRows'
|
|
47
|
-
| 'updateField'
|
|
48
|
-
| 'updateFieldByIndex';
|
|
49
|
-
|
|
50
|
-
export interface DataMutationContext<T> {
|
|
51
|
-
action: DataMutationAction;
|
|
52
|
-
previousData: T[];
|
|
53
|
-
nextData: T[];
|
|
54
|
-
rowId?: string;
|
|
55
|
-
index?: number;
|
|
56
|
-
rowIds?: string[];
|
|
57
|
-
totalRow?: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface DataTableProps<T> {
|
|
61
|
-
// Core data props
|
|
62
|
-
// columns: DataTableColumn<T>[] | AccessorKeyColumnDef <T, string>[];
|
|
63
|
-
columns: ColumnDef<T, any>[];
|
|
64
|
-
data?: T[];
|
|
65
|
-
totalRow?: number;
|
|
66
|
-
idKey?: keyof T;
|
|
67
|
-
extraFilter?: ReactNode | null;
|
|
68
|
-
footerFilter?: ReactNode | null;
|
|
69
|
-
|
|
70
|
-
// Data management modes (MUI DataGrid style)
|
|
71
|
-
dataMode?: 'client' | 'server'; // Data management mode (default: 'client')
|
|
72
|
-
initialState?: Partial<TableState>;
|
|
73
|
-
initialLoadData?: boolean; // Initial load data (default: true)
|
|
74
|
-
onDataStateChange?: (filters: Partial<TableState>) => void; // Callback when any filter/state changes
|
|
75
|
-
onFetchData?: (filters: Partial<TableFilters>, meta?: DataFetchMeta) => Promise<{ data: T[]; total: number }>;
|
|
76
|
-
onFetchStateChange?: (filters: Partial<TableState>, meta?: DataFetchMeta) => void;
|
|
77
|
-
onRefreshData?: (context: DataRefreshContext) => void | Promise<void>;
|
|
78
|
-
|
|
79
|
-
// Simplified Export props
|
|
80
|
-
exportFilename?: string;
|
|
81
|
-
exportConcurrency?: ExportConcurrencyMode;
|
|
82
|
-
exportChunkSize?: number;
|
|
83
|
-
exportStrictTotalCheck?: boolean;
|
|
84
|
-
exportSanitizeCSV?: boolean;
|
|
85
|
-
onExportProgress?: (progress: ExportProgressPayload) => void;
|
|
86
|
-
onExportComplete?: (result: { success: boolean; filename: string; totalRows: number }) => void;
|
|
87
|
-
onExportError?: (error: { message: string; code: string }) => void;
|
|
88
|
-
onExportStateChange?: (state: ExportStateChange) => void;
|
|
89
|
-
|
|
90
|
-
// Server export callback - receives current table state/filters and selection data
|
|
91
|
-
onServerExport?: (
|
|
92
|
-
filters?: Partial<TableState>,
|
|
93
|
-
selection?: SelectionState,
|
|
94
|
-
signal?: AbortSignal
|
|
95
|
-
) => Promise<ServerExportResult<any>>;
|
|
96
|
-
|
|
97
|
-
// Export cancellation callback - called when export is cancelled
|
|
98
|
-
onExportCancel?: () => void;
|
|
99
|
-
|
|
100
|
-
// Selection props
|
|
101
|
-
enableRowSelection?: boolean | ((row: Row<T>) => boolean);
|
|
102
|
-
enableMultiRowSelection?: boolean;
|
|
103
|
-
selectMode?: SelectMode; // 'page' | 'all' - defines selection scope
|
|
104
|
-
|
|
105
|
-
// Row selection control (like MUI DataGrid)
|
|
106
|
-
isRowSelectable?: (params: { row: T; id: string }) => boolean;
|
|
107
|
-
|
|
108
|
-
onSelectionChange?: (selection: SelectionState) => void;
|
|
109
|
-
|
|
110
|
-
// Row click props
|
|
111
|
-
onRowClick?: (event: React.MouseEvent<HTMLTableRowElement>, row: Row<T>) => void;
|
|
112
|
-
selectOnRowClick?: boolean; // If true, row click will toggle selection (default: false)
|
|
113
|
-
|
|
114
|
-
// Bulk action props
|
|
115
|
-
enableBulkActions?: boolean;
|
|
116
|
-
bulkActions?: (selectionState: SelectionState) => ReactNode;
|
|
117
|
-
|
|
118
|
-
// Column resizing props
|
|
119
|
-
enableColumnResizing?: boolean;
|
|
120
|
-
columnResizeMode?: ColumnResizeMode;
|
|
121
|
-
onColumnSizingChange?: (sizing: Record<string, number>) => void;
|
|
122
|
-
|
|
123
|
-
// Column ordering props
|
|
124
|
-
enableColumnDragging?: boolean;
|
|
125
|
-
onColumnDragEnd?: (columnOrder: string[]) => void;
|
|
126
|
-
|
|
127
|
-
// Column pinning props
|
|
128
|
-
enableColumnPinning?: boolean;
|
|
129
|
-
onColumnPinningChange?: (pinning: ColumnPinningState) => void;
|
|
130
|
-
|
|
131
|
-
// Column visibility props
|
|
132
|
-
enableColumnVisibility?: boolean;
|
|
133
|
-
onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;
|
|
134
|
-
|
|
135
|
-
// Expandable rows props
|
|
136
|
-
enableExpanding?: boolean;
|
|
137
|
-
getRowCanExpand?: (row: Row<T>) => boolean;
|
|
138
|
-
renderSubComponent?: (row: Row<T>) => ReactNode;
|
|
139
|
-
|
|
140
|
-
// Pagination props
|
|
141
|
-
enablePagination?: boolean;
|
|
142
|
-
paginationMode?: 'client' | 'server'; // Pagination mode (default: 'client')
|
|
143
|
-
|
|
144
|
-
// Filtering props
|
|
145
|
-
enableGlobalFilter?: boolean;
|
|
146
|
-
enableColumnFilter?: boolean;
|
|
147
|
-
filterMode?: 'client' | 'server'; // Filtering mode (default: 'client')
|
|
148
|
-
|
|
149
|
-
// Sorting props
|
|
150
|
-
enableSorting?: boolean;
|
|
151
|
-
sortingMode?: 'client' | 'server'; // Sorting mode (default: 'client')
|
|
152
|
-
onSortingChange?: (sorting: SortingState) => void;
|
|
153
|
-
|
|
154
|
-
// Styling props
|
|
155
|
-
enableHover?: boolean;
|
|
156
|
-
enableStripes?: boolean;
|
|
157
|
-
tableContainerProps?: any;
|
|
158
|
-
tableProps?: any;
|
|
159
|
-
fitToScreen?: boolean;
|
|
160
|
-
tableSize?: DataTableSize;
|
|
161
|
-
|
|
162
|
-
// Sticky header/footer props
|
|
163
|
-
enableStickyHeaderOrFooter?: boolean;
|
|
164
|
-
maxHeight?: string | number;
|
|
165
|
-
|
|
166
|
-
// Virtualization props
|
|
167
|
-
enableVirtualization?: boolean;
|
|
168
|
-
estimateRowHeight?: number;
|
|
169
|
-
|
|
170
|
-
// Toolbar props
|
|
171
|
-
enableTableSizeControl?: boolean;
|
|
172
|
-
enableExport?: boolean;
|
|
173
|
-
enableReset?: boolean;
|
|
174
|
-
enableRefresh?: boolean;
|
|
175
|
-
|
|
176
|
-
// Loading and empty states
|
|
177
|
-
loading?: boolean;
|
|
178
|
-
emptyMessage?: string | ReactNode;
|
|
179
|
-
skeletonRows?: number;
|
|
180
|
-
|
|
181
|
-
// Column filters props
|
|
182
|
-
onColumnFiltersChange?: (filterState: ColumnFilterState, isApplied?: boolean) => void;
|
|
183
|
-
onPaginationChange?: (pagination: PaginationState) => void;
|
|
184
|
-
onGlobalFilterChange?: (globalFilter: string) => void;
|
|
185
|
-
onColumnFilterChange?: (columnFilter: ColumnFilterState) => void;
|
|
186
|
-
// Slots for component customization (similar to MUI DataGrid)
|
|
187
|
-
slots?: Partial<DataTableSlots<T>>;
|
|
188
|
-
slotProps?: PartialSlotProps<T>;
|
|
189
|
-
|
|
190
|
-
// Logging configuration
|
|
191
|
-
logging?: boolean | DataTableLoggingOptions;
|
|
192
|
-
}
|