@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,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableExportControl = TableExportControl;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const icons_material_1 = require("@mui/icons-material");
7
+ const material_1 = require("@mui/material");
8
+ const menu_dropdown_1 = require("../droupdown/menu-dropdown");
9
+ const data_table_context_1 = require("../../contexts/data-table-context");
10
+ const icons_1 = require("../../icons");
11
+ const export_utils_1 = require("../../utils/export-utils");
12
+ const slot_helpers_1 = require("../../utils/slot-helpers");
13
+ function TableExportControl({ exportFilename: propsExportFilename, onServerExport: propsOnServerExport, onExportProgress: propsOnExportProgress, onExportComplete: propsOnExportComplete, onExportError: propsOnExportError, } = {}) {
14
+ const { table, apiRef, slots, slotProps, dataMode, isExporting, onCancelExport, exportFilename: contextExportFilename, onServerExport: contextOnServerExport, onExportProgress: contextOnExportProgress, onExportComplete: contextOnExportComplete, onExportError: contextOnExportError, } = (0, data_table_context_1.useDataTableContext)();
15
+ const exportFilename = propsExportFilename || contextExportFilename || 'export';
16
+ const onServerExport = propsOnServerExport || contextOnServerExport;
17
+ const onExportProgress = propsOnExportProgress || contextOnExportProgress;
18
+ const onExportComplete = propsOnExportComplete || contextOnExportComplete;
19
+ const onExportError = propsOnExportError || contextOnExportError;
20
+ const ExportIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'exportIcon', icons_material_1.CloudDownloadOutlined);
21
+ const CsvIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'csvIcon', icons_1.CsvIcon);
22
+ const ExcelIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'excelIcon', icons_1.ExcelIcon);
23
+ const handleExport = (format) => tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ var _a, _b;
25
+ try {
26
+ if (dataMode === 'server' && onServerExport) {
27
+ const currentState = table.getState();
28
+ const currentFilters = {
29
+ globalFilter: currentState.globalFilter,
30
+ sorting: currentState.sorting,
31
+ columnFilters: currentState.columnFilters,
32
+ };
33
+ const selectionData = (_b = (_a = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _a === void 0 ? void 0 : _a.selection) === null || _b === void 0 ? void 0 : _b.getSelectionState();
34
+ yield (0, export_utils_1.exportServerData)(table, {
35
+ format,
36
+ filename: exportFilename,
37
+ fetchData: (filters, selection) => onServerExport(filters || currentFilters, selection),
38
+ currentFilters,
39
+ selection: selectionData,
40
+ onProgress: onExportProgress,
41
+ onComplete: onExportComplete,
42
+ onError: onExportError,
43
+ });
44
+ }
45
+ else {
46
+ yield (0, export_utils_1.exportClientData)(table, {
47
+ format,
48
+ filename: exportFilename,
49
+ onProgress: onExportProgress,
50
+ onComplete: onExportComplete,
51
+ onError: onExportError,
52
+ });
53
+ }
54
+ }
55
+ catch (error) {
56
+ console.error('Export failed:', error);
57
+ onExportError === null || onExportError === void 0 ? void 0 : onExportError({
58
+ message: error instanceof Error ? error.message : 'Export failed',
59
+ code: 'PROCESSING_ERROR',
60
+ });
61
+ }
62
+ });
63
+ const selectedRowCount = Object.keys(table.getState().rowSelection).filter(key => table.getState().rowSelection[key]).length;
64
+ const summary = {
65
+ filteredRows: table.getFilteredRowModel().rows.length,
66
+ totalColumns: table.getVisibleLeafColumns().filter(col => col.getIsVisible()).length,
67
+ selectedRows: selectedRowCount,
68
+ hasSelection: selectedRowCount > 0,
69
+ };
70
+ return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Export data", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", disabled: isExporting, sx: {
71
+ flexShrink: 0,
72
+ color: isExporting ? 'warning.main' : 'text.secondary',
73
+ }, children: (0, jsx_runtime_1.jsx)(ExportIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.exportIcon)) }) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
74
+ p: 1,
75
+ minWidth: 280,
76
+ }, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
77
+ mb: 2,
78
+ p: 1,
79
+ bgcolor: 'grey.50',
80
+ borderRadius: 1,
81
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: "Export Summary" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: summary.hasSelection
82
+ ? `${summary.selectedRows} selected • ${summary.totalColumns} visible columns`
83
+ : `${summary.filteredRows} filtered • ${summary.totalColumns} visible columns` }), summary.hasSelection ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "primary.main", sx: { fontWeight: 'medium' }, children: "Will export selected rows only" })) : null] }), isExporting ? ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => {
84
+ onCancelExport === null || onCancelExport === void 0 ? void 0 : onCancelExport();
85
+ handleClose();
86
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(ExportIconSlot, Object.assign({ fontSize: "small", color: "warning" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.exportIcon)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "Cancel Export", secondary: "Stop current export" })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
87
+ yield handleExport('csv');
88
+ handleClose();
89
+ }), disabled: isExporting, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(CsvIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.csvIcon)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "Export as CSV", secondary: ".csv format" })] }), (0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
90
+ yield handleExport('excel');
91
+ handleClose();
92
+ }), disabled: isExporting, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(ExcelIconSlot, Object.assign({ fontSize: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.excelIcon)) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "Export as Excel", secondary: ".xlsx format" })] })] }))] })) }));
93
+ }
@@ -0,0 +1 @@
1
+ export declare function TableSearchControl(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableSearchControl = TableSearchControl;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_material_1 = require("@mui/icons-material");
6
+ const material_1 = require("@mui/material");
7
+ const material_2 = require("@mui/material");
8
+ const material_3 = require("@mui/material");
9
+ const material_4 = require("@mui/material");
10
+ const material_5 = require("@mui/material");
11
+ const react_1 = require("react");
12
+ const data_table_context_1 = require("../../contexts/data-table-context");
13
+ const slot_helpers_1 = require("../../utils/slot-helpers");
14
+ function TableSearchControl() {
15
+ const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
16
+ const [searchVisible, setSearchVisible] = (0, react_1.useState)(false);
17
+ const searchInputRef = (0, react_1.useRef)(null);
18
+ const globalFilter = table.getState().globalFilter || '';
19
+ const hasSearch = globalFilter.length > 0;
20
+ const SearchIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'searchIcon', icons_material_1.Search);
21
+ const ClearIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'clearIcon', icons_material_1.Clear);
22
+ const handleChange = (0, react_1.useCallback)((e) => {
23
+ table.setGlobalFilter(e.target.value);
24
+ }, [table]);
25
+ const handleSearchToggle = () => {
26
+ if (searchVisible || hasSearch) {
27
+ setSearchVisible(false);
28
+ table.setGlobalFilter('');
29
+ }
30
+ else {
31
+ setSearchVisible(true);
32
+ }
33
+ };
34
+ const handleSearchClear = () => {
35
+ table.setGlobalFilter('');
36
+ if (searchInputRef.current) {
37
+ searchInputRef.current.focus();
38
+ }
39
+ };
40
+ const handleSearchBlur = () => {
41
+ if (searchVisible && !hasSearch) {
42
+ setSearchVisible(false);
43
+ }
44
+ };
45
+ (0, react_1.useEffect)(() => {
46
+ if (searchVisible && searchInputRef.current) {
47
+ const timer = setTimeout(() => {
48
+ var _a;
49
+ (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
50
+ }, 200);
51
+ return () => clearTimeout(timer);
52
+ }
53
+ return undefined;
54
+ }, [searchVisible]);
55
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
56
+ display: 'flex',
57
+ alignItems: 'center',
58
+ }, children: [!(searchVisible || hasSearch) && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Search", children: (0, jsx_runtime_1.jsx)(material_2.IconButton, { size: "small", onClick: handleSearchToggle, color: hasSearch ? 'primary' : 'default', sx: {
59
+ flexShrink: 0,
60
+ }, children: (0, jsx_runtime_1.jsx)(SearchIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.searchIcon)) }) })), (0, jsx_runtime_1.jsx)(material_3.Collapse, { in: searchVisible || hasSearch, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_4.OutlinedInput, { inputRef: searchInputRef, placeholder: "Search...", value: globalFilter, onChange: handleChange, size: "small", onBlur: handleSearchBlur, sx: { minWidth: 200 }, endAdornment: hasSearch ? ((0, jsx_runtime_1.jsx)(material_5.InputAdornment, { position: "end", children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Clear search", children: (0, jsx_runtime_1.jsx)(material_2.IconButton, { size: "small", onClick: handleSearchClear, edge: "end", children: (0, jsx_runtime_1.jsx)(ClearIconSlot, Object.assign({ size: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.clearIcon)) }) }) })) : null, startAdornment: searchVisible || hasSearch ? ((0, jsx_runtime_1.jsx)(material_5.InputAdornment, { position: "start", children: (0, jsx_runtime_1.jsx)(SearchIconSlot, Object.assign({ size: "small" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.searchIcon)) })) : null }) })] }));
61
+ }
@@ -0,0 +1 @@
1
+ export declare function TableSizeControl(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TableSizeControl = TableSizeControl;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_material_1 = require("@mui/icons-material");
6
+ const material_1 = require("@mui/material");
7
+ const menu_dropdown_1 = require("../droupdown/menu-dropdown");
8
+ const data_table_context_1 = require("../../contexts/data-table-context");
9
+ const icons_1 = require("../../icons");
10
+ const slot_helpers_1 = require("../../utils/slot-helpers");
11
+ function TableSizeControl() {
12
+ const { tableSize, onTableSizeChange, slotProps, slots } = (0, data_table_context_1.useDataTableContext)();
13
+ const TableSizeIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeIcon', icons_material_1.LineWeightOutlined);
14
+ const TableSizeSmallIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeSmallIcon', icons_1.ViewCompactIcon);
15
+ const TableSizeMediumIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeMediumIcon', icons_1.ViewComfortableIcon);
16
+ const SIZE_OPTIONS = [
17
+ {
18
+ value: 'small',
19
+ label: 'Compact',
20
+ description: 'Small padding, compact rows',
21
+ icon: (0, jsx_runtime_1.jsx)(TableSizeSmallIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.tableSizeSmallIcon)),
22
+ },
23
+ {
24
+ value: 'medium',
25
+ label: 'Standard',
26
+ description: 'Default padding and spacing',
27
+ icon: (0, jsx_runtime_1.jsx)(TableSizeMediumIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.tableSizeMediumIcon)),
28
+ },
29
+ ];
30
+ return ((0, jsx_runtime_1.jsx)(menu_dropdown_1.MenuDropdown, { anchor: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Table size", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", sx: {
31
+ flexShrink: 0,
32
+ }, children: (0, jsx_runtime_1.jsx)(TableSizeIconSlot, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.tableSizeIcon)) }) })), children: ({ handleClose }) => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: SIZE_OPTIONS.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { selected: tableSize === option.value, onClick: () => {
33
+ onTableSizeChange === null || onTableSizeChange === void 0 ? void 0 : onTableSizeChange(option.value);
34
+ handleClose();
35
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: option.icon }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: option.label, secondary: option.description })] }, option.value))) })) }));
36
+ }
@@ -0,0 +1,43 @@
1
+ import { Table } from '@tanstack/react-table';
2
+ import { ReactNode, RefObject } from 'react';
3
+ import { CustomColumnFilterState, TableSize } from '../types';
4
+ import { DataTableApi } from '../types/data-table-api';
5
+ interface DataTableContextValue<T = any> {
6
+ table?: Table<T>;
7
+ apiRef?: RefObject<DataTableApi<T>>;
8
+ dataMode?: 'client' | 'server';
9
+ tableSize?: TableSize;
10
+ onTableSizeChange?: (size: TableSize) => void;
11
+ customColumnsFilter?: CustomColumnFilterState;
12
+ onChangeCustomColumnsFilter?: (filter: CustomColumnFilterState) => void;
13
+ slots?: Record<string, any>;
14
+ slotProps?: Record<string, any>;
15
+ isExporting?: boolean;
16
+ exportController?: AbortController | null;
17
+ onCancelExport?: () => void;
18
+ exportFilename?: string;
19
+ onExportProgress?: (progress: {
20
+ processedRows: number;
21
+ totalRows: number;
22
+ percentage: number;
23
+ }) => void;
24
+ onExportComplete?: (result: {
25
+ success: boolean;
26
+ filename: string;
27
+ totalRows: number;
28
+ }) => void;
29
+ onExportError?: (error: {
30
+ message: string;
31
+ code: string;
32
+ }) => void;
33
+ onServerExport?: (filters?: Partial<any>) => Promise<{
34
+ data: any[];
35
+ total: number;
36
+ }>;
37
+ }
38
+ interface DataTableProviderProps<T = any> extends DataTableContextValue<T> {
39
+ children: ReactNode;
40
+ }
41
+ export declare function DataTableProvider<T = any>({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, customColumnsFilter, onChangeCustomColumnsFilter, slots, slotProps, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }: DataTableProviderProps<T>): import("react/jsx-runtime").JSX.Element;
42
+ export declare function useDataTableContext<T = any>(): DataTableContextValue<T>;
43
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataTableProvider = DataTableProvider;
4
+ exports.useDataTableContext = useDataTableContext;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const DataTableContext = (0, react_1.createContext)(null);
8
+ function DataTableProvider({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, customColumnsFilter, onChangeCustomColumnsFilter, slots = {}, slotProps = {}, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }) {
9
+ const value = (0, react_1.useMemo)(() => ({
10
+ table,
11
+ apiRef,
12
+ dataMode,
13
+ tableSize,
14
+ onTableSizeChange,
15
+ customColumnsFilter,
16
+ onChangeCustomColumnsFilter,
17
+ slots,
18
+ slotProps,
19
+ isExporting,
20
+ exportController,
21
+ onCancelExport,
22
+ exportFilename,
23
+ onExportProgress,
24
+ onExportComplete,
25
+ onExportError,
26
+ onServerExport,
27
+ }), [
28
+ table,
29
+ apiRef,
30
+ dataMode,
31
+ tableSize,
32
+ onTableSizeChange,
33
+ customColumnsFilter,
34
+ onChangeCustomColumnsFilter,
35
+ slots,
36
+ slotProps,
37
+ isExporting,
38
+ exportController,
39
+ onCancelExport,
40
+ exportFilename,
41
+ onExportProgress,
42
+ onExportComplete,
43
+ onExportError,
44
+ onServerExport,
45
+ ]);
46
+ return ((0, jsx_runtime_1.jsx)(DataTableContext.Provider, { value: value, children: children }));
47
+ }
48
+ function useDataTableContext() {
49
+ const context = (0, react_1.useContext)(DataTableContext);
50
+ if (!context) {
51
+ throw new Error('useDataTableContext must be used within a DataTableProvider');
52
+ }
53
+ return context;
54
+ }
@@ -0,0 +1 @@
1
+ export declare function AdvancedFeaturesExample(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdvancedFeaturesExample = AdvancedFeaturesExample;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const material_1 = require("@mui/material");
7
+ const icons_material_1 = require("@mui/icons-material");
8
+ const components_1 = require("../components");
9
+ const generateEmployeeData = () => {
10
+ const departments = [
11
+ { id: 1, name: 'Engineering', color: '#2196F3' },
12
+ { id: 2, name: 'Design', color: '#9C27B0' },
13
+ { id: 3, name: 'Marketing', color: '#FF9800' },
14
+ { id: 4, name: 'Sales', color: '#4CAF50' },
15
+ { id: 5, name: 'HR', color: '#F44336' },
16
+ ];
17
+ const positions = ['Senior', 'Mid-level', 'Junior', 'Lead', 'Manager'];
18
+ const skills = ['React', 'TypeScript', 'Node.js', 'Python', 'Design', 'Analytics', 'Leadership'];
19
+ const names = ['Alice Johnson', 'Bob Smith', 'Charlie Brown', 'Diana Prince', 'Eva Garcia', 'Frank Miller', 'Grace Lee', 'Henry Davis'];
20
+ return Array.from({ length: 20 }, (_, index) => {
21
+ const dept = departments[index % departments.length];
22
+ const employeeSkills = skills.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * 4) + 2);
23
+ return {
24
+ id: index + 1,
25
+ name: names[index % names.length] || `Employee ${index + 1}`,
26
+ email: `employee${index + 1}@company.com`,
27
+ avatar: `https://i.pravatar.cc/40?img=${index + 1}`,
28
+ department: dept,
29
+ position: `${positions[index % positions.length]} ${dept.name.slice(0, -3)}er`,
30
+ salary: 60000 + (index * 5000) + Math.floor(Math.random() * 20000),
31
+ performance: {
32
+ rating: Math.floor(Math.random() * 5) + 1,
33
+ trend: ['up', 'down', 'stable'][Math.floor(Math.random() * 3)],
34
+ score: Math.floor(Math.random() * 40) + 60,
35
+ },
36
+ skills: employeeSkills,
37
+ startDate: new Date(2020 + Math.floor(Math.random() * 4), Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1).toISOString().split('T')[0],
38
+ isActive: Math.random() > 0.1,
39
+ projects: Array.from({ length: Math.floor(Math.random() * 3) + 1 }, (_, projIndex) => ({
40
+ id: projIndex + 1,
41
+ name: `Project ${String.fromCharCode(65 + projIndex)}`,
42
+ progress: Math.floor(Math.random() * 100),
43
+ priority: ['high', 'medium', 'low'][Math.floor(Math.random() * 3)],
44
+ })),
45
+ metadata: {
46
+ lastLogin: new Date(Date.now() - Math.floor(Math.random() * 30) * 24 * 60 * 60 * 1000).toISOString(),
47
+ vacationDays: Math.floor(Math.random() * 25),
48
+ certifications: Math.floor(Math.random() * 8),
49
+ },
50
+ };
51
+ });
52
+ };
53
+ function AdvancedFeaturesExample() {
54
+ const [employees, setEmployees] = (0, react_1.useState)(generateEmployeeData());
55
+ const [editingRows, setEditingRows] = (0, react_1.useState)(new Set());
56
+ const [showAdvancedFeatures, setShowAdvancedFeatures] = (0, react_1.useState)(true);
57
+ const [showNestedData, setShowNestedData] = (0, react_1.useState)(false);
58
+ const handleStartEdit = (0, react_1.useCallback)((employeeId) => {
59
+ setEditingRows(prev => new Set([...prev, employeeId]));
60
+ }, []);
61
+ const handleSaveEdit = (0, react_1.useCallback)((employeeId) => {
62
+ setEditingRows(prev => {
63
+ const newSet = new Set(prev);
64
+ newSet.delete(employeeId);
65
+ return newSet;
66
+ });
67
+ }, []);
68
+ const handleCancelEdit = (0, react_1.useCallback)((employeeId) => {
69
+ setEditingRows(prev => {
70
+ const newSet = new Set(prev);
71
+ newSet.delete(employeeId);
72
+ return newSet;
73
+ });
74
+ }, []);
75
+ const handleFieldChange = (0, react_1.useCallback)((employeeId, field, value) => {
76
+ setEmployees(prev => prev.map(emp => emp.id === employeeId
77
+ ? Object.assign(Object.assign({}, emp), { [field]: value }) : emp));
78
+ }, []);
79
+ const NameCell = ({ row }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { src: row.avatar, sx: { width: 32, height: 32 } }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: "medium", children: row.name }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: "text.secondary", children: row.email })] })] }));
80
+ const DepartmentCell = ({ row }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: row.department.name, size: "small", sx: {
81
+ backgroundColor: row.department.color,
82
+ color: 'white',
83
+ fontWeight: 'medium',
84
+ } }));
85
+ const SalaryCell = ({ row }) => {
86
+ const isEditing = editingRows.has(row.id);
87
+ if (isEditing) {
88
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small", type: "number", value: row.salary, onChange: (e) => handleFieldChange(row.id, 'salary', parseInt(e.target.value)), sx: { width: 120 } }));
89
+ }
90
+ return ((0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", fontWeight: "medium", children: ["$", row.salary.toLocaleString()] }));
91
+ };
92
+ const PerformanceCell = ({ row }) => {
93
+ const trendIcon = {
94
+ up: (0, jsx_runtime_1.jsx)(icons_material_1.TrendingUp, { sx: { color: 'success.main', fontSize: 16 } }),
95
+ down: (0, jsx_runtime_1.jsx)(icons_material_1.TrendingDown, { sx: { color: 'error.main', fontSize: 16 } }),
96
+ stable: (0, jsx_runtime_1.jsx)(icons_material_1.Star, { sx: { color: 'warning.main', fontSize: 16 } }),
97
+ };
98
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Rating, { value: row.performance.rating, size: "small", readOnly: true }), trendIcon[row.performance.trend], (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", children: [row.performance.score, "%"] })] }));
99
+ };
100
+ const SkillsCell = ({ row }) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5, maxWidth: 200 }, children: [row.skills.slice(0, 3).map((skill, index) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: skill, size: "small", variant: "outlined", sx: { fontSize: '0.7rem', height: 20 } }, index))), row.skills.length > 3 && ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: `+${row.skills.length - 3}`, size: "small", variant: "filled", sx: { fontSize: '0.7rem', height: 20 } }))] }));
101
+ const ProjectsCell = ({ row }) => ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { minWidth: 150 }, children: row.projects.map((project, index) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mb: 0.5 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", fontWeight: "medium", children: project.name }), (0, jsx_runtime_1.jsx)(material_1.Chip, { label: project.priority, size: "small", color: project.priority === 'high' ? 'error' : project.priority === 'medium' ? 'warning' : 'default', sx: { fontSize: '0.6rem', height: 16 } })] }), (0, jsx_runtime_1.jsx)(material_1.LinearProgress, { variant: "determinate", value: project.progress, sx: { height: 4, borderRadius: 2 }, color: project.priority === 'high' ? 'error' : project.priority === 'medium' ? 'warning' : 'primary' })] }, index))) }));
102
+ const ActionsCell = ({ row }) => {
103
+ const isEditing = editingRows.has(row.id);
104
+ if (isEditing) {
105
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 0.5 }, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Save changes", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handleSaveEdit(row.id), color: "primary", children: (0, jsx_runtime_1.jsx)(icons_material_1.Save, { fontSize: "small" }) }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Cancel editing", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handleCancelEdit(row.id), color: "secondary", children: (0, jsx_runtime_1.jsx)(icons_material_1.Cancel, { fontSize: "small" }) }) })] }));
106
+ }
107
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 0.5 }, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Edit employee", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => handleStartEdit(row.id), color: "primary", children: (0, jsx_runtime_1.jsx)(icons_material_1.Edit, { fontSize: "small" }) }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Delete employee", children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: () => {
108
+ setEmployees(prev => prev.filter(emp => emp.id !== row.id));
109
+ }, color: "error", children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, { fontSize: "small" }) }) })] }));
110
+ };
111
+ const renderSubComponent = (0, react_1.useCallback)(({ row }) => ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { p: 2, backgroundColor: 'grey.50', borderRadius: 1 }, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 12, md: 6 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: "Contact Information" }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Email:" }), " ", row.email] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Position:" }), " ", row.position] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Start Date:" }), " ", new Date(row.startDate).toLocaleDateString()] })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 12, md: 6 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: "Metadata" }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Last Login:" }), " ", new Date(row.metadata.lastLogin).toLocaleDateString()] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Vacation Days:" }), " ", row.metadata.vacationDays] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Certifications:" }), " ", row.metadata.certifications] })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 12 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", gutterBottom: true, children: "All Skills" }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 }, children: row.skills.map((skill, index) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: skill, size: "small", color: "primary", variant: "outlined" }, index))) })] })] }) })), []);
112
+ const columns = (0, react_1.useMemo)(() => {
113
+ const baseColumns = [
114
+ {
115
+ accessorKey: 'name',
116
+ header: 'Employee',
117
+ size: 200,
118
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(NameCell, { row: row.original }),
119
+ enableSorting: true,
120
+ filterable: true,
121
+ type: 'text',
122
+ },
123
+ {
124
+ accessorKey: 'department.name',
125
+ header: 'Department',
126
+ size: 120,
127
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(DepartmentCell, { row: row.original }),
128
+ enableSorting: true,
129
+ filterable: true,
130
+ type: 'select',
131
+ options: [
132
+ { value: 'Engineering', label: 'Engineering' },
133
+ { value: 'Design', label: 'Design' },
134
+ { value: 'Marketing', label: 'Marketing' },
135
+ { value: 'Sales', label: 'Sales' },
136
+ { value: 'HR', label: 'HR' },
137
+ ],
138
+ },
139
+ {
140
+ accessorKey: 'salary',
141
+ header: 'Salary',
142
+ size: 120,
143
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(SalaryCell, { row: row.original }),
144
+ enableSorting: true,
145
+ filterable: true,
146
+ type: 'number',
147
+ },
148
+ {
149
+ accessorKey: 'startDate',
150
+ header: 'Start Date',
151
+ size: 140,
152
+ enableSorting: true,
153
+ filterable: true,
154
+ type: 'date',
155
+ cell: ({ row }) => ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: new Date(row.original.startDate).toLocaleDateString() })),
156
+ },
157
+ {
158
+ accessorKey: 'performance.rating',
159
+ header: 'Performance',
160
+ size: 200,
161
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(PerformanceCell, { row: row.original }),
162
+ enableSorting: true,
163
+ },
164
+ {
165
+ accessorKey: 'skills',
166
+ header: 'Skills',
167
+ size: 250,
168
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(SkillsCell, { row: row.original }),
169
+ enableSorting: false,
170
+ },
171
+ ];
172
+ if (showNestedData) {
173
+ baseColumns.push({
174
+ accessorKey: 'projects',
175
+ header: 'Projects',
176
+ size: 200,
177
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(ProjectsCell, { row: row.original }),
178
+ enableSorting: false,
179
+ });
180
+ }
181
+ if (showAdvancedFeatures) {
182
+ baseColumns.push({
183
+ id: 'actions',
184
+ header: 'Actions',
185
+ size: 100,
186
+ cell: ({ row }) => (0, jsx_runtime_1.jsx)(ActionsCell, { row: row.original }),
187
+ enableSorting: false,
188
+ filterable: false,
189
+ });
190
+ }
191
+ return baseColumns;
192
+ }, [showAdvancedFeatures, showNestedData, editingRows]);
193
+ const addNewEmployee = (0, react_1.useCallback)(() => {
194
+ const newEmployee = {
195
+ id: Math.max(...employees.map(e => e.id)) + 1,
196
+ name: 'New Employee',
197
+ email: 'new@company.com',
198
+ avatar: 'https://i.pravatar.cc/40?img=1',
199
+ department: { id: 1, name: 'Engineering', color: '#2196F3' },
200
+ position: 'Junior Developer',
201
+ salary: 60000,
202
+ performance: { rating: 3, trend: 'stable', score: 75 },
203
+ skills: ['React'],
204
+ startDate: new Date().toISOString().split('T')[0],
205
+ isActive: true,
206
+ projects: [],
207
+ metadata: {
208
+ lastLogin: new Date().toISOString(),
209
+ vacationDays: 20,
210
+ certifications: 0,
211
+ },
212
+ };
213
+ setEmployees(prev => [...prev, newEmployee]);
214
+ handleStartEdit(newEmployee.id);
215
+ }, [employees, handleStartEdit]);
216
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { p: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", gutterBottom: true, children: "Advanced Features Demo" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", sx: { mb: 3 }, children: "A comprehensive example showcasing inline editing, custom cell renderers, row expansion, dynamic columns, and complex local data operations." }), (0, jsx_runtime_1.jsxs)(material_1.Paper, { sx: { p: 2, mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Feature Controls" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { checked: showAdvancedFeatures, onChange: (e) => setShowAdvancedFeatures(e.target.checked) }), label: "Inline Editing & Actions" }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { checked: showNestedData, onChange: (e) => setShowNestedData(e.target.checked) }), label: "Show Project Data" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", startIcon: (0, jsx_runtime_1.jsx)(icons_material_1.Add, {}), onClick: addNewEmployee, size: "small", children: "Add Employee" }), (0, jsx_runtime_1.jsx)(material_1.Badge, { badgeContent: editingRows.size, color: "primary", children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: "Editing Rows" }) })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Paper, { sx: { p: 2, mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Statistics" }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 6, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Total Employees" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", children: employees.length })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 6, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Active Employees" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", children: employees.filter(e => e.isActive).length })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 6, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Avg Salary" }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "h6", children: ["$", Math.round(employees.reduce((sum, e) => sum + e.salary, 0) / employees.length).toLocaleString()] })] }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { size: { xs: 6, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Currently Editing" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", children: editingRows.size })] })] })] }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { my: 2 } }), (0, jsx_runtime_1.jsx)(components_1.DataTable, { data: employees, totalRow: employees.length, columns: columns, enableRowSelection: true, enableMultiRowSelection: true, enableSorting: true, enableGlobalFilter: true, enableColumnFilter: true, enableColumnDragging: true, enableColumnPinning: true, enablePagination: true, getRowCanExpand: () => true, renderSubComponent: (row) => renderSubComponent({ row: row.original }), initialState: {
217
+ pagination: {
218
+ pageIndex: 0,
219
+ pageSize: 10,
220
+ },
221
+ columnOrder: ['name', 'department.name', 'salary', 'performance.rating', 'skills'],
222
+ }, tableContainerProps: {
223
+ sx: {
224
+ '& .MuiTableRow-root:hover': {
225
+ backgroundColor: 'action.hover',
226
+ },
227
+ '& .MuiTableCell-root': {
228
+ borderBottom: '1px solid',
229
+ borderColor: 'divider',
230
+ },
231
+ }
232
+ }, enableBulkActions: true, bulkActions: (selectionState) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
233
+ let selectedEmployees;
234
+ if (selectionState.type === 'include') {
235
+ selectedEmployees = employees.filter(emp => selectionState.ids.includes(emp.id.toString()));
236
+ }
237
+ else {
238
+ selectedEmployees = employees.filter(emp => !selectionState.ids.includes(emp.id.toString()));
239
+ }
240
+ const avgSalary = selectedEmployees.reduce((sum, emp) => sum + emp.salary, 0) / selectedEmployees.length;
241
+ alert(`Average salary of ${selectedEmployees.length} selected employees: $${Math.round(avgSalary).toLocaleString()}`);
242
+ }, children: "\uD83D\uDCCA Calculate Avg Salary" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
243
+ const updatedEmployees = employees.map(emp => {
244
+ const isSelected = selectionState.type === 'include'
245
+ ? selectionState.ids.includes(emp.id.toString())
246
+ : !selectionState.ids.includes(emp.id.toString());
247
+ return isSelected
248
+ ? Object.assign(Object.assign({}, emp), { performance: Object.assign(Object.assign({}, emp.performance), { rating: 5 }) }) : emp;
249
+ });
250
+ setEmployees(updatedEmployees);
251
+ }, children: "\u2B50 Boost Performance" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", color: "error", onClick: () => {
252
+ let selectedEmployees;
253
+ if (selectionState.type === 'include') {
254
+ selectedEmployees = employees.filter(emp => selectionState.ids.includes(emp.id.toString()));
255
+ }
256
+ else {
257
+ selectedEmployees = employees.filter(emp => !selectionState.ids.includes(emp.id.toString()));
258
+ }
259
+ if (window.confirm(`Delete ${selectedEmployees.length} selected employees?`)) {
260
+ const selectedIds = selectedEmployees.map(emp => emp.id);
261
+ setEmployees(prev => prev.filter(emp => !selectedIds.includes(emp.id)));
262
+ }
263
+ }, children: "\uD83D\uDDD1\uFE0F Delete Selected" })] })), fitToScreen: true }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2 }, children: (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", color: "text.secondary", children: ["\uD83D\uDCA1 ", (0, jsx_runtime_1.jsx)("strong", { children: "Features demonstrated:" }), (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Inline editing with save/cancel actions", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Custom cell renderers with rich content (avatars, ratings, progress bars)", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Row expansion with detailed information", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Dynamic column configuration", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Complex nested data structures", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Real-time statistics and bulk operations", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Advanced styling and theming"] }) })] }));
264
+ }
@@ -0,0 +1 @@
1
+ export declare function BulkActionsTest(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BulkActionsTest = BulkActionsTest;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const material_1 = require("@mui/material");
7
+ const components_1 = require("../components");
8
+ const testData = [
9
+ { id: 1, name: 'Item 1', value: 100 },
10
+ { id: 2, name: 'Item 2', value: 200 },
11
+ { id: 3, name: 'Item 3', value: 300 },
12
+ { id: 4, name: 'Item 4', value: 400 },
13
+ { id: 5, name: 'Item 5', value: 500 },
14
+ ];
15
+ const columns = [
16
+ {
17
+ accessorKey: 'name',
18
+ header: 'Name',
19
+ size: 150,
20
+ },
21
+ {
22
+ accessorKey: 'value',
23
+ header: 'Value',
24
+ size: 100,
25
+ },
26
+ ];
27
+ function BulkActionsTest() {
28
+ const [selectionInfo, setSelectionInfo] = (0, react_1.useState)('No selection');
29
+ const handleSelectionChange = (selection) => {
30
+ const count = selection.type === 'include'
31
+ ? selection.ids.length
32
+ : testData.length - selection.ids.length;
33
+ setSelectionInfo(`Selected: ${count} items (${selection.type} mode) - IDs: [${selection.ids.join(', ')}]`);
34
+ };
35
+ const bulkActions = (0, react_1.useCallback)((selectionState) => {
36
+ const selectedCount = selectionState.type === 'include'
37
+ ? selectionState.ids.length
38
+ : testData.length - selectionState.ids.length;
39
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', gap: 1 }, children: (0, jsx_runtime_1.jsxs)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
40
+ alert(`Action on ${selectedCount} items. Selection state: ${JSON.stringify(selectionState, null, 2)}`);
41
+ }, children: ["Test Action (", selectedCount, ")"] }) }));
42
+ }, []);
43
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { p: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h4", gutterBottom: true, children: "Bulk Actions Test" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", sx: { mb: 2 }, children: "This example tests that bulk actions work without infinite loops." }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", sx: { mb: 3, p: 2, backgroundColor: 'grey.100', borderRadius: 1 }, children: [(0, jsx_runtime_1.jsx)("strong", { children: "Current Selection:" }), " ", selectionInfo] }), (0, jsx_runtime_1.jsx)(components_1.DataTable, { data: testData, totalRow: testData.length, columns: columns, enableRowSelection: true, enableMultiRowSelection: true, enableBulkActions: true, bulkActions: bulkActions, onSelectionChange: handleSelectionChange, enablePagination: false, enableSorting: true, enableGlobalFilter: false, fitToScreen: true }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2, p: 2, backgroundColor: 'success.light', borderRadius: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "success.dark", children: "\u2705 If you can see this and select rows without the page freezing, the infinite loop issue is fixed!" }) })] }));
44
+ }
@@ -0,0 +1 @@
1
+ export declare function CustomColumnFilterExample(): import("react/jsx-runtime").JSX.Element;