@ackplus/react-tanstack-data-table 1.0.19-beta-0.7 → 1.0.19-beta-0.8

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.
Files changed (125) hide show
  1. package/README.md +599 -0
  2. package/package.json +1 -1
  3. package/src/index.d.ts +19 -0
  4. package/src/index.js +31 -0
  5. package/src/lib/components/droupdown/menu-dropdown.d.ts +17 -0
  6. package/src/lib/components/droupdown/menu-dropdown.js +52 -0
  7. package/src/lib/components/filters/filter-value-input.d.ts +9 -0
  8. package/src/lib/components/filters/filter-value-input.js +58 -0
  9. package/src/lib/components/filters/index.d.ts +23 -0
  10. package/src/lib/components/filters/index.js +129 -0
  11. package/src/lib/components/headers/draggable-header.d.ts +12 -0
  12. package/src/lib/components/headers/draggable-header.js +212 -0
  13. package/src/lib/components/headers/index.d.ts +2 -0
  14. package/src/lib/components/headers/index.js +5 -0
  15. package/src/lib/components/headers/table-header.d.ts +10 -0
  16. package/src/lib/components/headers/table-header.js +48 -0
  17. package/src/lib/components/index.d.ts +7 -0
  18. package/src/lib/components/index.js +10 -0
  19. package/src/lib/components/pagination/data-table-pagination.d.ts +11 -0
  20. package/src/lib/components/pagination/data-table-pagination.js +25 -0
  21. package/src/lib/components/pagination/index.d.ts +1 -0
  22. package/src/lib/components/pagination/index.js +4 -0
  23. package/src/lib/components/rows/data-table-row.d.ts +13 -0
  24. package/src/lib/components/rows/data-table-row.js +31 -0
  25. package/src/lib/components/rows/empty-data-row.d.ts +6 -0
  26. package/src/lib/components/rows/empty-data-row.js +11 -0
  27. package/src/lib/components/rows/index.d.ts +3 -0
  28. package/src/lib/components/rows/index.js +6 -0
  29. package/src/lib/components/rows/loading-rows.d.ts +5 -0
  30. package/src/lib/components/rows/loading-rows.js +49 -0
  31. package/src/lib/components/table/data-table.d.ts +3 -0
  32. package/src/lib/components/table/data-table.js +492 -0
  33. package/src/lib/components/table/data-table.types.d.ts +114 -0
  34. package/src/lib/components/table/data-table.types.js +2 -0
  35. package/src/lib/components/table/index.d.ts +2 -0
  36. package/src/lib/components/table/index.js +5 -0
  37. package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +9 -0
  38. package/src/lib/components/toolbar/bulk-actions-toolbar.js +25 -0
  39. package/src/lib/components/toolbar/column-custom-filter-control.d.ts +1 -0
  40. package/src/lib/components/toolbar/column-custom-filter-control.js +137 -0
  41. package/src/lib/components/toolbar/column-pinning-control.d.ts +1 -0
  42. package/src/lib/components/toolbar/column-pinning-control.js +105 -0
  43. package/src/lib/components/toolbar/column-reset-control.d.ts +1 -0
  44. package/src/lib/components/toolbar/column-reset-control.js +16 -0
  45. package/src/lib/components/toolbar/column-visibility-control.d.ts +1 -0
  46. package/src/lib/components/toolbar/column-visibility-control.js +31 -0
  47. package/src/lib/components/toolbar/data-table-toolbar.d.ts +14 -0
  48. package/src/lib/components/toolbar/data-table-toolbar.js +26 -0
  49. package/src/lib/components/toolbar/index.d.ts +8 -0
  50. package/src/lib/components/toolbar/index.js +17 -0
  51. package/src/lib/components/toolbar/table-export-control.d.ts +25 -0
  52. package/src/lib/components/toolbar/table-export-control.js +93 -0
  53. package/src/lib/components/toolbar/table-search-control.d.ts +1 -0
  54. package/src/lib/components/toolbar/table-search-control.js +61 -0
  55. package/src/lib/components/toolbar/table-size-control.d.ts +1 -0
  56. package/src/lib/components/toolbar/table-size-control.js +36 -0
  57. package/src/lib/contexts/data-table-context.d.ts +43 -0
  58. package/src/lib/contexts/data-table-context.js +54 -0
  59. package/src/lib/examples/advanced-features-example.d.ts +1 -0
  60. package/src/lib/examples/advanced-features-example.js +264 -0
  61. package/src/lib/examples/bulk-actions-test.d.ts +1 -0
  62. package/src/lib/examples/bulk-actions-test.js +44 -0
  63. package/src/lib/examples/custom-column-filter-example.d.ts +1 -0
  64. package/src/lib/examples/custom-column-filter-example.js +60 -0
  65. package/src/lib/examples/index.d.ts +5 -0
  66. package/src/lib/examples/index.js +13 -0
  67. package/src/lib/examples/selection-test-example.d.ts +1 -0
  68. package/src/lib/examples/selection-test-example.js +101 -0
  69. package/src/lib/examples/simple-local-example.d.ts +1 -0
  70. package/src/lib/examples/simple-local-example.js +97 -0
  71. package/src/lib/features/custom-column-filter.feature.d.ts +45 -0
  72. package/src/lib/features/custom-column-filter.feature.js +247 -0
  73. package/src/lib/features/custom-selection.feature.d.ts +46 -0
  74. package/src/lib/features/custom-selection.feature.js +172 -0
  75. package/src/lib/features/index.d.ts +2 -0
  76. package/src/lib/features/index.js +8 -0
  77. package/src/lib/hooks/index.d.ts +1 -0
  78. package/src/lib/hooks/index.js +4 -0
  79. package/src/lib/hooks/use-data-table-api.d.ts +56 -0
  80. package/src/lib/hooks/use-data-table-api.js +616 -0
  81. package/src/lib/icons/add-icon.d.ts +2 -0
  82. package/src/lib/icons/add-icon.js +8 -0
  83. package/src/lib/icons/csv-icon.d.ts +2 -0
  84. package/src/lib/icons/csv-icon.js +8 -0
  85. package/src/lib/icons/delete-icon.d.ts +2 -0
  86. package/src/lib/icons/delete-icon.js +8 -0
  87. package/src/lib/icons/excel-icon.d.ts +2 -0
  88. package/src/lib/icons/excel-icon.js +8 -0
  89. package/src/lib/icons/index.d.ts +7 -0
  90. package/src/lib/icons/index.js +17 -0
  91. package/src/lib/icons/unpin-icon.d.ts +2 -0
  92. package/src/lib/icons/unpin-icon.js +8 -0
  93. package/src/lib/icons/view-comfortable-icon.d.ts +2 -0
  94. package/src/lib/icons/view-comfortable-icon.js +8 -0
  95. package/src/lib/icons/view-compact-icon.d.ts +2 -0
  96. package/src/lib/icons/view-compact-icon.js +8 -0
  97. package/src/lib/types/column.types.d.ts +29 -0
  98. package/src/lib/types/column.types.js +5 -0
  99. package/src/lib/types/data-table-api.d.ts +134 -0
  100. package/src/lib/types/data-table-api.js +2 -0
  101. package/src/lib/types/export.types.d.ts +99 -0
  102. package/src/lib/types/export.types.js +2 -0
  103. package/src/lib/types/index.d.ts +6 -0
  104. package/src/lib/types/index.js +8 -0
  105. package/src/lib/types/slots.types.d.ts +272 -0
  106. package/src/lib/types/slots.types.js +2 -0
  107. package/src/lib/types/table.types.d.ts +63 -0
  108. package/src/lib/types/table.types.js +2 -0
  109. package/src/lib/utils/column-helpers.d.ts +7 -0
  110. package/src/lib/utils/column-helpers.js +43 -0
  111. package/src/lib/utils/debounced-fetch.utils.d.ts +11 -0
  112. package/src/lib/utils/debounced-fetch.utils.js +49 -0
  113. package/src/lib/utils/export-utils.d.ts +30 -0
  114. package/src/lib/utils/export-utils.js +152 -0
  115. package/src/lib/utils/index.d.ts +7 -0
  116. package/src/lib/utils/index.js +10 -0
  117. package/src/lib/utils/slot-helpers.d.ts +9 -0
  118. package/src/lib/utils/slot-helpers.js +21 -0
  119. package/src/lib/utils/special-columns.utils.d.ts +6 -0
  120. package/src/lib/utils/special-columns.utils.js +52 -0
  121. package/src/lib/utils/styling-helpers.d.ts +36 -0
  122. package/src/lib/utils/styling-helpers.js +61 -0
  123. package/src/lib/utils/table-helpers.d.ts +9 -0
  124. package/src/lib/utils/table-helpers.js +57 -0
  125. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,63 @@
1
+ import { SortingState } from '@tanstack/react-table';
2
+ import { ColumnFilterRule, SelectionState } from '../features';
3
+ export type TableSize = 'small' | 'medium';
4
+ export interface TableState {
5
+ customColumnsFilter: CustomColumnFilterState;
6
+ selectionState?: SelectionState;
7
+ globalFilter?: string;
8
+ sorting?: SortingState;
9
+ pagination?: {
10
+ pageIndex: number;
11
+ pageSize: number;
12
+ };
13
+ columnOrder?: string[];
14
+ columnPinning?: {
15
+ left?: string[];
16
+ right?: string[];
17
+ };
18
+ columnVisibility?: Record<string, boolean>;
19
+ columnSizing?: Record<string, number>;
20
+ }
21
+ export interface TableFilters {
22
+ globalFilter: string;
23
+ customColumnsFilter: CustomColumnFilterState;
24
+ sorting: SortingState;
25
+ pagination: {
26
+ pageIndex: number;
27
+ pageSize: number;
28
+ };
29
+ columnOrder: string[];
30
+ columnPinning: {
31
+ left?: string[];
32
+ right?: string[];
33
+ };
34
+ }
35
+ export interface TableFiltersForFetch {
36
+ search?: string;
37
+ page?: number;
38
+ pageSize?: number;
39
+ sorting?: SortingState;
40
+ customColumnsFilter?: CustomColumnFilterState;
41
+ }
42
+ export interface CustomColumnFilterState {
43
+ filters: ColumnFilterRule[];
44
+ logic: 'AND' | 'OR';
45
+ pendingFilters: ColumnFilterRule[];
46
+ pendingLogic: 'AND' | 'OR';
47
+ }
48
+ export interface TablePerformanceMetrics {
49
+ renderTime: number;
50
+ dataProcessingTime: number;
51
+ totalRows: number;
52
+ visibleRows: number;
53
+ memoryUsage?: number;
54
+ }
55
+ export interface TableMetrics {
56
+ totalRows: number;
57
+ visibleRows: number;
58
+ totalColumns?: number;
59
+ visibleColumns?: number;
60
+ pinnedColumns?: number;
61
+ renderTime: number;
62
+ lastUpdated?: Date;
63
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { DataTableColumn } from '../types';
2
+ import { Column } from "@tanstack/react-table";
3
+ export type ColumnType = 'text' | 'number' | 'date' | 'boolean' | 'select' | 'actions';
4
+ export declare function getColumnType(column: Column<any, unknown>): ColumnType;
5
+ export declare function getCustomFilterComponent(column: Column<any, unknown>): any;
6
+ export declare function getColumnOptions(column: Column<any, unknown>): any[];
7
+ export declare function isColumnFilterable(column: DataTableColumn<any, unknown>): boolean;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getColumnType = getColumnType;
4
+ exports.getCustomFilterComponent = getCustomFilterComponent;
5
+ exports.getColumnOptions = getColumnOptions;
6
+ exports.isColumnFilterable = isColumnFilterable;
7
+ function getColumnType(column) {
8
+ var _a;
9
+ if ((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.type) {
10
+ return column.columnDef.type;
11
+ }
12
+ return 'text';
13
+ }
14
+ function getCustomFilterComponent(column) {
15
+ var _a, _b;
16
+ return ((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.filterComponent) || ((_b = column === null || column === void 0 ? void 0 : column.columnDef) === null || _b === void 0 ? void 0 : _b.editComponent);
17
+ }
18
+ function getColumnOptions(column) {
19
+ var _a;
20
+ if ((_a = column === null || column === void 0 ? void 0 : column.columnDef) === null || _a === void 0 ? void 0 : _a.options) {
21
+ return (column === null || column === void 0 ? void 0 : column.columnDef.options) || [];
22
+ }
23
+ const columnType = getColumnType(column);
24
+ if (columnType === 'boolean') {
25
+ return [
26
+ {
27
+ value: true,
28
+ label: 'Yes',
29
+ },
30
+ {
31
+ value: false,
32
+ label: 'No',
33
+ },
34
+ ];
35
+ }
36
+ return [];
37
+ }
38
+ function isColumnFilterable(column) {
39
+ if ((column === null || column === void 0 ? void 0 : column.filterable) !== undefined) {
40
+ return column === null || column === void 0 ? void 0 : column.filterable;
41
+ }
42
+ return true;
43
+ }
@@ -0,0 +1,11 @@
1
+ import { TableFiltersForFetch } from '../types';
2
+ export declare function useDebouncedFetch<T extends Record<string, any>>(onFetchData: ((filters: TableFiltersForFetch) => Promise<{
3
+ data: T[];
4
+ total: number;
5
+ }>) | undefined, delay?: number): {
6
+ debouncedFetch: (filters: TableFiltersForFetch) => Promise<{
7
+ data: T[];
8
+ total: number;
9
+ }>;
10
+ isLoading: boolean;
11
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDebouncedFetch = useDebouncedFetch;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = require("react");
6
+ function useDebouncedFetch(onFetchData, delay = 300) {
7
+ const [isLoading, setIsLoading] = (0, react_1.useState)(false);
8
+ const debounceTimer = (0, react_1.useRef)(null);
9
+ const lastFetchParams = (0, react_1.useRef)('');
10
+ const debouncedFetch = (0, react_1.useCallback)((filters) => tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ if (!onFetchData)
12
+ return null;
13
+ const currentParams = JSON.stringify(filters);
14
+ if (debounceTimer.current) {
15
+ clearTimeout(debounceTimer.current);
16
+ }
17
+ return new Promise((resolve) => {
18
+ debounceTimer.current = setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ if (lastFetchParams.current === currentParams) {
20
+ resolve(null);
21
+ return;
22
+ }
23
+ lastFetchParams.current = currentParams;
24
+ setIsLoading(true);
25
+ try {
26
+ const result = yield onFetchData(filters);
27
+ resolve(result);
28
+ }
29
+ catch (error) {
30
+ resolve(null);
31
+ }
32
+ finally {
33
+ setIsLoading(false);
34
+ }
35
+ }), delay);
36
+ });
37
+ }), [onFetchData, delay]);
38
+ (0, react_1.useEffect)(() => {
39
+ return () => {
40
+ if (debounceTimer.current) {
41
+ clearTimeout(debounceTimer.current);
42
+ }
43
+ };
44
+ }, []);
45
+ return {
46
+ debouncedFetch,
47
+ isLoading,
48
+ };
49
+ }
@@ -0,0 +1,30 @@
1
+ import { Table } from '@tanstack/react-table';
2
+ import { SelectionState } from '../features/custom-selection.feature';
3
+ export interface ExportOptions {
4
+ format: 'csv' | 'excel';
5
+ filename: string;
6
+ onProgress?: (progress: {
7
+ processedRows: number;
8
+ totalRows: number;
9
+ percentage: number;
10
+ }) => void;
11
+ onComplete?: (result: {
12
+ success: boolean;
13
+ filename: string;
14
+ totalRows: number;
15
+ }) => void;
16
+ onError?: (error: {
17
+ message: string;
18
+ code: string;
19
+ }) => void;
20
+ }
21
+ export interface ServerExportOptions extends ExportOptions {
22
+ fetchData: (filters?: any, selection?: SelectionState) => Promise<{
23
+ data: any[];
24
+ total: number;
25
+ }>;
26
+ currentFilters?: any;
27
+ selection?: SelectionState;
28
+ }
29
+ export declare function exportClientData<TData>(table: Table<TData>, options: ExportOptions): Promise<void>;
30
+ export declare function exportServerData<TData>(table: Table<TData>, options: ServerExportOptions): Promise<void>;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exportClientData = exportClientData;
4
+ exports.exportServerData = exportServerData;
5
+ const tslib_1 = require("tslib");
6
+ const XLSX = tslib_1.__importStar(require("xlsx"));
7
+ function exportClientData(table, options) {
8
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
+ const { format, filename, onProgress, onComplete, onError } = options;
10
+ try {
11
+ const selectedRows = table.getSelectedRows ? table.getSelectedRows() : [];
12
+ const hasSelectedRows = selectedRows.length > 0;
13
+ const rowsToExport = hasSelectedRows ? selectedRows : table.getFilteredRowModel().rows;
14
+ const exportData = rowsToExport.map((row, index) => {
15
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
16
+ processedRows: index + 1,
17
+ totalRows: rowsToExport.length,
18
+ percentage: Math.round(((index + 1) / rowsToExport.length) * 100),
19
+ });
20
+ const rowData = {};
21
+ row.getVisibleCells().forEach(cell => {
22
+ const header = typeof cell.column.columnDef.header === 'string'
23
+ ? cell.column.columnDef.header
24
+ : cell.column.id;
25
+ rowData[header] = cell.getValue() || '';
26
+ });
27
+ return rowData;
28
+ });
29
+ yield exportToFile(exportData, format, filename);
30
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete({
31
+ success: true,
32
+ filename: `${filename}.${format === 'excel' ? 'xlsx' : 'csv'}`,
33
+ totalRows: exportData.length,
34
+ });
35
+ }
36
+ catch (error) {
37
+ console.error('Client export failed:', error);
38
+ onError === null || onError === void 0 ? void 0 : onError({
39
+ message: error instanceof Error ? error.message : 'Export failed',
40
+ code: 'CLIENT_EXPORT_ERROR',
41
+ });
42
+ }
43
+ });
44
+ }
45
+ function exportServerData(table, options) {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ const { format, filename, fetchData, currentFilters, selection, onProgress, onComplete, onError } = options;
48
+ try {
49
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
50
+ processedRows: 0,
51
+ totalRows: 0,
52
+ percentage: 0,
53
+ });
54
+ const { data } = yield fetchData(currentFilters, selection);
55
+ if (!data || !Array.isArray(data)) {
56
+ throw new Error('Invalid data received from server');
57
+ }
58
+ const visibleColumns = table.getVisibleLeafColumns().filter(col => col.getIsVisible());
59
+ const exportData = data.map((rowData, index) => {
60
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
61
+ processedRows: index + 1,
62
+ totalRows: data.length,
63
+ percentage: Math.round(((index + 1) / data.length) * 100),
64
+ });
65
+ const exportRow = {};
66
+ visibleColumns.forEach(column => {
67
+ const columnId = column.id;
68
+ const header = typeof column.columnDef.header === 'string'
69
+ ? column.columnDef.header
70
+ : columnId;
71
+ let value = rowData[columnId];
72
+ const columnDef = column.columnDef;
73
+ if (columnDef.accessorFn && typeof columnDef.accessorFn === 'function') {
74
+ value = columnDef.accessorFn(rowData);
75
+ }
76
+ if (value === null || value === undefined) {
77
+ value = '';
78
+ }
79
+ else if (typeof value === 'object') {
80
+ value = JSON.stringify(value);
81
+ }
82
+ else {
83
+ value = String(value);
84
+ }
85
+ exportRow[header] = value;
86
+ });
87
+ return exportRow;
88
+ });
89
+ yield exportToFile(exportData, format, filename);
90
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete({
91
+ success: true,
92
+ filename: `${filename}.${format === 'excel' ? 'xlsx' : 'csv'}`,
93
+ totalRows: exportData.length,
94
+ });
95
+ }
96
+ catch (error) {
97
+ console.error('Server export failed:', error);
98
+ onError === null || onError === void 0 ? void 0 : onError({
99
+ message: error instanceof Error ? error.message : 'Export failed',
100
+ code: 'SERVER_EXPORT_ERROR',
101
+ });
102
+ }
103
+ });
104
+ }
105
+ function exportToFile(data, format, filename) {
106
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
107
+ if (data.length === 0) {
108
+ throw new Error('No data to export');
109
+ }
110
+ if (format === 'csv') {
111
+ const csv = convertToCSV(data);
112
+ downloadFile(csv, `${filename}.csv`, 'text/csv');
113
+ }
114
+ else {
115
+ const workbook = XLSX.utils.book_new();
116
+ const worksheet = XLSX.utils.json_to_sheet(data);
117
+ XLSX.utils.book_append_sheet(workbook, worksheet, 'Data');
118
+ const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
119
+ const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
120
+ downloadFile(blob, `${filename}.xlsx`, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
121
+ }
122
+ });
123
+ }
124
+ function convertToCSV(data) {
125
+ if (data.length === 0)
126
+ return '';
127
+ const headers = Object.keys(data[0]);
128
+ const csvRows = [headers.join(',')];
129
+ for (const row of data) {
130
+ const values = headers.map(header => {
131
+ const value = row[header] || '';
132
+ if (typeof value === 'string' && (value.includes(',') || value.includes('"') || value.includes('\n'))) {
133
+ return `"${value.replace(/"/g, '""')}"`;
134
+ }
135
+ return value;
136
+ });
137
+ csvRows.push(values.join(','));
138
+ }
139
+ return csvRows.join('\n');
140
+ }
141
+ function downloadFile(content, filename, mimeType) {
142
+ const blob = content instanceof Blob ? content : new Blob([content], { type: mimeType });
143
+ const url = URL.createObjectURL(blob);
144
+ const link = document.createElement('a');
145
+ link.href = url;
146
+ link.download = filename;
147
+ link.style.display = 'none';
148
+ document.body.appendChild(link);
149
+ link.click();
150
+ document.body.removeChild(link);
151
+ URL.revokeObjectURL(url);
152
+ }
@@ -0,0 +1,7 @@
1
+ export * from './styling-helpers';
2
+ export * from './table-helpers';
3
+ export * from './column-helpers';
4
+ export * from './export-utils';
5
+ export * from './special-columns.utils';
6
+ export * from './debounced-fetch.utils';
7
+ export * from './slot-helpers';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./styling-helpers"), exports);
5
+ tslib_1.__exportStar(require("./table-helpers"), exports);
6
+ tslib_1.__exportStar(require("./column-helpers"), exports);
7
+ tslib_1.__exportStar(require("./export-utils"), exports);
8
+ tslib_1.__exportStar(require("./special-columns.utils"), exports);
9
+ tslib_1.__exportStar(require("./debounced-fetch.utils"), exports);
10
+ tslib_1.__exportStar(require("./slot-helpers"), exports);
@@ -0,0 +1,9 @@
1
+ import { ComponentType } from 'react';
2
+ import { DataTableSlots } from '../types/slots.types';
3
+ export declare function getSlotComponent<T, K extends keyof DataTableSlots<T>>(slots: Partial<DataTableSlots<T>> | undefined, slotName: K, fallback: ComponentType<any>): ComponentType<any>;
4
+ export declare function renderSlot(slotComponent: ComponentType<any>, defaultProps: any, slotProps?: any): import("react/jsx-runtime").JSX.Element;
5
+ export declare function createSlottableComponent<T, K extends keyof DataTableSlots<T>>(slotName: K, defaultComponent: ComponentType<any>): (props: {
6
+ slots?: Partial<DataTableSlots<T>>;
7
+ slotProps?: any;
8
+ componentProps: any;
9
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSlotComponent = getSlotComponent;
4
+ exports.renderSlot = renderSlot;
5
+ exports.createSlottableComponent = createSlottableComponent;
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ function getSlotComponent(slots, slotName, fallback) {
8
+ return (slots === null || slots === void 0 ? void 0 : slots[slotName]) || fallback;
9
+ }
10
+ function renderSlot(slotComponent, defaultProps, slotProps) {
11
+ const mergedProps = Object.assign(Object.assign({}, defaultProps), slotProps);
12
+ const Component = slotComponent;
13
+ return (0, jsx_runtime_1.jsx)(Component, Object.assign({}, mergedProps));
14
+ }
15
+ function createSlottableComponent(slotName, defaultComponent) {
16
+ return function SlottableComponent(props) {
17
+ var _a;
18
+ const SlotComponent = getSlotComponent(props.slots, slotName, defaultComponent);
19
+ return renderSlot(SlotComponent, props.componentProps, (_a = props.slotProps) === null || _a === void 0 ? void 0 : _a[slotName]);
20
+ };
21
+ }
@@ -0,0 +1,6 @@
1
+ import { DataTableColumn } from '../types';
2
+ export interface SelectionColumnConfig<T> {
3
+ multiSelect?: boolean;
4
+ }
5
+ export declare const createSelectionColumn: <T>(config: Partial<DataTableColumn<T>> & SelectionColumnConfig<T>) => DataTableColumn<T>;
6
+ export declare const createExpandingColumn: <T>(config: Partial<DataTableColumn<T>>) => DataTableColumn<T>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExpandingColumn = exports.createSelectionColumn = void 0;
4
+ const icons_material_1 = require("@mui/icons-material");
5
+ const material_1 = require("@mui/material");
6
+ const react_1 = require("react");
7
+ const types_1 = require("../types");
8
+ const createSelectionColumn = (config) => (Object.assign({ id: types_1.DEFAULT_SELECTION_COLUMN_NAME, size: 60, align: 'center', filterable: false, enableResizing: false, enableSorting: false, enableHiding: false, enablePinning: false, hideInExport: true, header: ({ table }) => {
9
+ var _a, _b;
10
+ if (!config.multiSelect)
11
+ return null;
12
+ const allSelected = ((_a = table.getIsAllRowsSelected) === null || _a === void 0 ? void 0 : _a.call(table)) || false;
13
+ const someSelected = ((_b = table.getIsSomeRowsSelected) === null || _b === void 0 ? void 0 : _b.call(table)) || false;
14
+ return (0, react_1.createElement)(material_1.Checkbox, {
15
+ checked: allSelected,
16
+ indeterminate: someSelected && !allSelected,
17
+ disabled: false,
18
+ onChange: () => {
19
+ var _a;
20
+ (_a = table.toggleAllRowsSelected) === null || _a === void 0 ? void 0 : _a.call(table);
21
+ },
22
+ size: 'small',
23
+ sx: { p: 0 },
24
+ });
25
+ }, cell: ({ row, table }) => {
26
+ var _a, _b, _c;
27
+ const rowId = row.id;
28
+ const checked = ((_a = table.getIsRowSelected) === null || _a === void 0 ? void 0 : _a.call(table, rowId)) || false;
29
+ const canSelect = (_c = (_b = table.canSelectRow) === null || _b === void 0 ? void 0 : _b.call(table, rowId)) !== null && _c !== void 0 ? _c : true;
30
+ return (0, react_1.createElement)(material_1.Checkbox, {
31
+ checked,
32
+ disabled: !canSelect,
33
+ onChange: () => {
34
+ var _a;
35
+ if (canSelect) {
36
+ (_a = table.toggleRowSelected) === null || _a === void 0 ? void 0 : _a.call(table, rowId);
37
+ }
38
+ },
39
+ size: 'small',
40
+ sx: {
41
+ p: 0,
42
+ opacity: canSelect ? 1 : 0.5
43
+ },
44
+ });
45
+ } }, config));
46
+ exports.createSelectionColumn = createSelectionColumn;
47
+ const createExpandingColumn = (config) => (Object.assign({ id: types_1.DEFAULT_EXPANDING_COLUMN_NAME, size: 60, align: 'center', filterable: false, enableResizing: false, enableSorting: false, enableHiding: false, enablePinning: false, hideInExport: true, header: '', cell: ({ row }) => (0, react_1.createElement)(material_1.IconButton, {
48
+ onClick: row.getToggleExpandedHandler(),
49
+ size: 'small',
50
+ sx: { p: 0 },
51
+ }, row.getIsExpanded() ? (0, react_1.createElement)(icons_material_1.KeyboardArrowUpOutlined) : (0, react_1.createElement)(icons_material_1.KeyboardArrowDownOutlined)) }, config));
52
+ exports.createExpandingColumn = createExpandingColumn;
@@ -0,0 +1,36 @@
1
+ import type { DataTableColumn, PinnedColumnStyleOptions } from '../types';
2
+ export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions): {
3
+ boxShadow: string;
4
+ backgroundColor: string;
5
+ left?: number;
6
+ right?: number;
7
+ zIndex?: number;
8
+ width: string | number;
9
+ maxWidth: string | number;
10
+ overflow: string;
11
+ whiteSpace: string;
12
+ };
13
+ export declare const tableCellStyles: {
14
+ readonly sticky: {
15
+ readonly position: "sticky";
16
+ readonly zIndex: 10;
17
+ readonly backgroundColor: "background.paper";
18
+ };
19
+ readonly pinned: {
20
+ readonly borderRight: "1px solid";
21
+ readonly borderColor: "divider";
22
+ };
23
+ };
24
+ export declare const tableRowStyles: {
25
+ readonly hover: {
26
+ readonly '&:hover': {
27
+ readonly backgroundColor: "action.hover";
28
+ };
29
+ };
30
+ readonly striped: {
31
+ readonly '&:nth-of-type(odd)': {
32
+ readonly backgroundColor: "action.selected";
33
+ };
34
+ };
35
+ };
36
+ export declare function getColumnAlignment(column?: DataTableColumn<any>): 'left' | 'center' | 'right';
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tableRowStyles = exports.tableCellStyles = void 0;
4
+ exports.getPinnedColumnStyle = getPinnedColumnStyle;
5
+ exports.getColumnAlignment = getColumnAlignment;
6
+ const getBoxShadow = (isPinned, isLastLeftPinnedColumn, isFirstRightPinnedColumn) => {
7
+ if (isPinned === 'left' && isLastLeftPinnedColumn) {
8
+ return '1px 0 3px rgba(0, 0, 0, 0.12)';
9
+ }
10
+ if (isPinned === 'right' && isFirstRightPinnedColumn) {
11
+ return '-1px 0 3px rgba(0, 0, 0, 0.12)';
12
+ }
13
+ return 'none';
14
+ };
15
+ function getPinnedColumnStyle(options) {
16
+ const { width = 'auto', isPinned, pinnedPosition, pinnedRightPosition, isLastLeftPinnedColumn, isFirstRightPinnedColumn, zIndex = 1, disableStickyHeader = false, } = options;
17
+ const needsPinnedPositioning = isPinned;
18
+ const shouldBeSticky = isPinned;
19
+ let positionStyle = {};
20
+ if (shouldBeSticky) {
21
+ positionStyle = { position: 'sticky' };
22
+ }
23
+ else if (!disableStickyHeader) {
24
+ positionStyle = { position: 'relative' };
25
+ }
26
+ return Object.assign(Object.assign(Object.assign(Object.assign({ width, maxWidth: width, overflow: 'hidden', whiteSpace: 'nowrap' }, positionStyle), (needsPinnedPositioning ? {
27
+ left: isPinned === 'left' ? pinnedPosition : undefined,
28
+ right: isPinned === 'right' ? pinnedRightPosition : undefined,
29
+ zIndex,
30
+ } : {})), (isPinned && {
31
+ backgroundColor: 'background.paper',
32
+ })), { boxShadow: getBoxShadow(isPinned, !!isLastLeftPinnedColumn, !!isFirstRightPinnedColumn) });
33
+ }
34
+ exports.tableCellStyles = {
35
+ sticky: {
36
+ position: 'sticky',
37
+ zIndex: 10,
38
+ backgroundColor: 'background.paper',
39
+ },
40
+ pinned: {
41
+ borderRight: '1px solid',
42
+ borderColor: 'divider',
43
+ },
44
+ };
45
+ exports.tableRowStyles = {
46
+ hover: {
47
+ '&:hover': {
48
+ backgroundColor: 'action.hover',
49
+ },
50
+ },
51
+ striped: {
52
+ '&:nth-of-type(odd)': {
53
+ backgroundColor: 'action.selected',
54
+ },
55
+ },
56
+ };
57
+ function getColumnAlignment(column) {
58
+ if (!column)
59
+ return 'left';
60
+ return column.align || 'left';
61
+ }
@@ -0,0 +1,9 @@
1
+ import type { TableMetrics } from '../types';
2
+ export type DataTableSize = 'small' | 'medium';
3
+ export declare function calculateSkeletonRows(containerHeight: number, rowHeight: number, maxRows?: number): number;
4
+ export declare function generateRowId<T>(row: T, index: number, idKey?: keyof T): string;
5
+ export declare function calculatePinnedColumnsWidth(columns: any[], side: 'left' | 'right'): number;
6
+ export declare function shouldUseFixedLayout(fitToScreen: boolean, enableColumnResizing: boolean, totalColumns: number): boolean;
7
+ export declare function formatCellValue(value: any, type: string): string;
8
+ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
9
+ export declare function calculateTableMetrics(totalRows: number, visibleRows: number, columns: any[], renderStartTime: number): TableMetrics;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateSkeletonRows = calculateSkeletonRows;
4
+ exports.generateRowId = generateRowId;
5
+ exports.calculatePinnedColumnsWidth = calculatePinnedColumnsWidth;
6
+ exports.shouldUseFixedLayout = shouldUseFixedLayout;
7
+ exports.formatCellValue = formatCellValue;
8
+ exports.debounce = debounce;
9
+ exports.calculateTableMetrics = calculateTableMetrics;
10
+ function calculateSkeletonRows(containerHeight, rowHeight, maxRows = 10) {
11
+ const estimatedRows = Math.ceil(containerHeight / rowHeight);
12
+ return Math.min(estimatedRows, maxRows);
13
+ }
14
+ function generateRowId(row, index, idKey) {
15
+ if (idKey && row[idKey]) {
16
+ return String(row[idKey]);
17
+ }
18
+ return `row-${index}`;
19
+ }
20
+ function calculatePinnedColumnsWidth(columns, side) {
21
+ return columns
22
+ .filter(col => col.getIsPinned() === side)
23
+ .reduce((total, col) => total + (col.getSize() || 0), 0);
24
+ }
25
+ function shouldUseFixedLayout(fitToScreen, enableColumnResizing, totalColumns) {
26
+ return fitToScreen || (enableColumnResizing && totalColumns > 5);
27
+ }
28
+ function formatCellValue(value, type) {
29
+ if (value === null || value === undefined) {
30
+ return '-';
31
+ }
32
+ switch (type) {
33
+ case 'date':
34
+ return value instanceof Date ? value.toLocaleDateString() : String(value);
35
+ case 'number':
36
+ return typeof value === 'number' ? value.toLocaleString() : String(value);
37
+ case 'boolean':
38
+ return value ? 'Yes' : 'No';
39
+ default:
40
+ return String(value);
41
+ }
42
+ }
43
+ function debounce(func, wait) {
44
+ let timeout;
45
+ return (...args) => {
46
+ clearTimeout(timeout);
47
+ timeout = setTimeout(() => func(...args), wait);
48
+ };
49
+ }
50
+ function calculateTableMetrics(totalRows, visibleRows, columns, renderStartTime) {
51
+ return {
52
+ totalRows,
53
+ visibleRows,
54
+ pinnedColumns: columns.filter(col => col.getIsPinned()).length,
55
+ renderTime: performance.now() - renderStartTime,
56
+ };
57
+ }
@@ -0,0 +1 @@
1
+ {"version":"5.8.3"}