@ackplus/react-tanstack-data-table 1.0.19-beta-0.6

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 (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +599 -0
  3. package/index.d.ts.map +1 -0
  4. package/index.js +42 -0
  5. package/lib/components/droupdown/menu-dropdown.d.ts.map +1 -0
  6. package/lib/components/droupdown/menu-dropdown.js +47 -0
  7. package/lib/components/export-progress-dialog.d.ts.map +1 -0
  8. package/lib/components/export-progress-dialog.js +30 -0
  9. package/lib/components/filters/filter-value-input.d.ts.map +1 -0
  10. package/lib/components/filters/filter-value-input.js +64 -0
  11. package/lib/components/filters/index.d.ts.map +1 -0
  12. package/lib/components/filters/index.js +125 -0
  13. package/lib/components/headers/draggable-header.d.ts.map +1 -0
  14. package/lib/components/headers/draggable-header.js +226 -0
  15. package/lib/components/headers/index.d.ts.map +1 -0
  16. package/lib/components/headers/index.js +5 -0
  17. package/lib/components/headers/table-header.d.ts.map +1 -0
  18. package/lib/components/headers/table-header.js +59 -0
  19. package/lib/components/index.d.ts.map +1 -0
  20. package/lib/components/index.js +18 -0
  21. package/lib/components/pagination/data-table-pagination.d.ts.map +1 -0
  22. package/lib/components/pagination/data-table-pagination.js +24 -0
  23. package/lib/components/pagination/index.d.ts.map +1 -0
  24. package/lib/components/pagination/index.js +4 -0
  25. package/lib/components/rows/data-table-row.d.ts.map +1 -0
  26. package/lib/components/rows/data-table-row.js +42 -0
  27. package/lib/components/rows/empty-data-row.d.ts.map +1 -0
  28. package/lib/components/rows/empty-data-row.js +8 -0
  29. package/lib/components/rows/index.d.ts.map +1 -0
  30. package/lib/components/rows/index.js +6 -0
  31. package/lib/components/rows/loading-rows.d.ts.map +1 -0
  32. package/lib/components/rows/loading-rows.js +46 -0
  33. package/lib/components/table/data-table.d.ts.map +1 -0
  34. package/lib/components/table/data-table.js +663 -0
  35. package/lib/components/table/data-table.types.d.ts.map +1 -0
  36. package/lib/components/table/data-table.types.js +6 -0
  37. package/lib/components/table/index.d.ts.map +1 -0
  38. package/lib/components/table/index.js +5 -0
  39. package/lib/components/toolbar/bulk-actions-toolbar.d.ts.map +1 -0
  40. package/lib/components/toolbar/bulk-actions-toolbar.js +31 -0
  41. package/lib/components/toolbar/column-custom-filter-control.d.ts.map +1 -0
  42. package/lib/components/toolbar/column-custom-filter-control.js +149 -0
  43. package/lib/components/toolbar/column-custum-filter-control.d.ts.map +1 -0
  44. package/lib/components/toolbar/column-custum-filter-control.js +150 -0
  45. package/lib/components/toolbar/column-pinning-control.d.ts.map +1 -0
  46. package/lib/components/toolbar/column-pinning-control.js +103 -0
  47. package/lib/components/toolbar/column-reset-control.d.ts.map +1 -0
  48. package/lib/components/toolbar/column-reset-control.js +13 -0
  49. package/lib/components/toolbar/column-visibility-control.d.ts.map +1 -0
  50. package/lib/components/toolbar/column-visibility-control.js +27 -0
  51. package/lib/components/toolbar/data-table-toolbar.d.ts.map +1 -0
  52. package/lib/components/toolbar/data-table-toolbar.js +23 -0
  53. package/lib/components/toolbar/index.d.ts.map +1 -0
  54. package/lib/components/toolbar/index.js +13 -0
  55. package/lib/components/toolbar/table-export-control.d.ts.map +1 -0
  56. package/lib/components/toolbar/table-export-control.js +94 -0
  57. package/lib/components/toolbar/table-search-control.d.ts.map +1 -0
  58. package/lib/components/toolbar/table-search-control.js +61 -0
  59. package/lib/components/toolbar/table-size-control.d.ts.map +1 -0
  60. package/lib/components/toolbar/table-size-control.js +33 -0
  61. package/lib/contexts/data-table-context.d.ts.map +1 -0
  62. package/lib/contexts/data-table-context.js +50 -0
  63. package/lib/examples/advanced-features-example.d.ts.map +1 -0
  64. package/lib/examples/advanced-features-example.js +282 -0
  65. package/lib/examples/basic-example.d.ts.map +1 -0
  66. package/lib/examples/basic-example.js +323 -0
  67. package/lib/examples/bulk-actions-test.d.ts.map +1 -0
  68. package/lib/examples/bulk-actions-test.js +47 -0
  69. package/lib/examples/crud-api-example.d.ts.map +1 -0
  70. package/lib/examples/crud-api-example.js +321 -0
  71. package/lib/examples/custom-column-filter-example.d.ts.map +1 -0
  72. package/lib/examples/custom-column-filter-example.js +60 -0
  73. package/lib/examples/custom-selection-example.d.ts.map +1 -0
  74. package/lib/examples/custom-selection-example.js +184 -0
  75. package/lib/examples/export-callbacks-example.d.ts.map +1 -0
  76. package/lib/examples/export-callbacks-example.js +155 -0
  77. package/lib/examples/improved-export-example.d.ts.map +1 -0
  78. package/lib/examples/improved-export-example.js +153 -0
  79. package/lib/examples/improved-server-selection-example.d.ts.map +1 -0
  80. package/lib/examples/improved-server-selection-example.js +118 -0
  81. package/lib/examples/index.d.ts.map +1 -0
  82. package/lib/examples/index.js +5 -0
  83. package/lib/examples/selection-test-example.d.ts.map +1 -0
  84. package/lib/examples/selection-test-example.js +111 -0
  85. package/lib/examples/simple-local-example.d.ts.map +1 -0
  86. package/lib/examples/simple-local-example.js +101 -0
  87. package/lib/examples/simple-server-selection-example.d.ts.map +1 -0
  88. package/lib/examples/simple-server-selection-example.js +178 -0
  89. package/lib/examples/virtualized-example.d.ts.map +1 -0
  90. package/lib/examples/virtualized-example.js +119 -0
  91. package/lib/features/custom-column-filter.feature.d.ts.map +1 -0
  92. package/lib/features/custom-column-filter.feature.js +306 -0
  93. package/lib/features/custom-selection.feature.d.ts.map +1 -0
  94. package/lib/features/custom-selection.feature.js +224 -0
  95. package/lib/features/index.d.ts.map +1 -0
  96. package/lib/features/index.js +9 -0
  97. package/lib/hooks/index.d.ts.map +1 -0
  98. package/lib/hooks/index.js +6 -0
  99. package/lib/hooks/use-data-table-api.d.ts.map +1 -0
  100. package/lib/hooks/use-data-table-api.js +673 -0
  101. package/lib/hooks/use-table-state.d.ts.map +1 -0
  102. package/lib/hooks/use-table-state.js +74 -0
  103. package/lib/icons/add-icon.d.ts.map +1 -0
  104. package/lib/icons/add-icon.js +5 -0
  105. package/lib/icons/csv-icon.d.ts.map +1 -0
  106. package/lib/icons/csv-icon.js +5 -0
  107. package/lib/icons/delete-icon.d.ts.map +1 -0
  108. package/lib/icons/delete-icon.js +5 -0
  109. package/lib/icons/excel-icon.d.ts.map +1 -0
  110. package/lib/icons/excel-icon.js +5 -0
  111. package/lib/icons/index.d.ts.map +1 -0
  112. package/lib/icons/index.js +7 -0
  113. package/lib/icons/unpin-icon.d.ts.map +1 -0
  114. package/lib/icons/unpin-icon.js +5 -0
  115. package/lib/icons/view-comfortable-icon.d.ts.map +1 -0
  116. package/lib/icons/view-comfortable-icon.js +5 -0
  117. package/lib/icons/view-compact-icon.d.ts.map +1 -0
  118. package/lib/icons/view-compact-icon.js +5 -0
  119. package/lib/types/column.types.d.ts.map +1 -0
  120. package/lib/types/column.types.js +2 -0
  121. package/lib/types/data-table-api.d.ts.map +1 -0
  122. package/lib/types/data-table-api.js +1 -0
  123. package/lib/types/export.types.d.ts.map +1 -0
  124. package/lib/types/export.types.js +5 -0
  125. package/lib/types/hooks.types.d.ts.map +1 -0
  126. package/lib/types/hooks.types.js +1 -0
  127. package/lib/types/index.d.ts.map +1 -0
  128. package/lib/types/index.js +14 -0
  129. package/lib/types/slots.types.d.ts.map +1 -0
  130. package/lib/types/slots.types.js +1 -0
  131. package/lib/types/table.types.d.ts.map +1 -0
  132. package/lib/types/table.types.js +1 -0
  133. package/lib/utils/column-helpers.d.ts.map +1 -0
  134. package/lib/utils/column-helpers.js +46 -0
  135. package/lib/utils/debounced-fetch.utils.d.ts.map +1 -0
  136. package/lib/utils/debounced-fetch.utils.js +51 -0
  137. package/lib/utils/export-utils.d.ts.map +1 -0
  138. package/lib/utils/export-utils.js +181 -0
  139. package/lib/utils/index.d.ts.map +1 -0
  140. package/lib/utils/index.js +17 -0
  141. package/lib/utils/selection-helpers.d.ts.map +1 -0
  142. package/lib/utils/selection-helpers.js +162 -0
  143. package/lib/utils/slot-helpers.d.ts.map +1 -0
  144. package/lib/utils/slot-helpers.js +27 -0
  145. package/lib/utils/special-columns.utils.d.ts.map +1 -0
  146. package/lib/utils/special-columns.utils.js +77 -0
  147. package/lib/utils/styling-helpers.d.ts.map +1 -0
  148. package/lib/utils/styling-helpers.js +97 -0
  149. package/lib/utils/table-helpers.d.ts.map +1 -0
  150. package/lib/utils/table-helpers.js +72 -0
  151. package/lib/utils/value-helpers.d.ts.map +1 -0
  152. package/lib/utils/value-helpers.js +48 -0
  153. package/package.json +57 -0
  154. package/tsconfig.lib.tsbuildinfo +1 -0
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { CloudDownloadOutlined } from '@mui/icons-material';
3
+ import { IconButton, Tooltip, MenuItem, ListItemIcon, ListItemText, Typography, Box, } from '@mui/material';
4
+ import { MenuDropdown } from '../droupdown/menu-dropdown';
5
+ import { useDataTableContext } from '../../contexts/data-table-context';
6
+ import { ExcelIcon, CsvIcon } from '../../icons';
7
+ import { exportClientData, exportServerData } from '../../utils/export-utils';
8
+ import { getSlotComponent } from '../../utils/slot-helpers';
9
+ export function TableExportControl({ exportFilename: propsExportFilename, onServerExport: propsOnServerExport, onExportProgress: propsOnExportProgress, onExportComplete: propsOnExportComplete, onExportError: propsOnExportError, } = {}) {
10
+ const { table, apiRef, slots, slotProps, dataMode, isExporting, onCancelExport,
11
+ // Export callbacks from context (DataTable props)
12
+ exportFilename: contextExportFilename, onServerExport: contextOnServerExport, onExportProgress: contextOnExportProgress, onExportComplete: contextOnExportComplete, onExportError: contextOnExportError, } = useDataTableContext();
13
+ // Use props if provided, otherwise fall back to context values
14
+ const exportFilename = propsExportFilename || contextExportFilename || 'export';
15
+ const onServerExport = propsOnServerExport || contextOnServerExport;
16
+ const onExportProgress = propsOnExportProgress || contextOnExportProgress;
17
+ const onExportComplete = propsOnExportComplete || contextOnExportComplete;
18
+ const onExportError = propsOnExportError || contextOnExportError;
19
+ const ExportIconSlot = getSlotComponent(slots, 'exportIcon', CloudDownloadOutlined);
20
+ const CsvIconSlot = getSlotComponent(slots, 'csvIcon', CsvIcon);
21
+ const ExcelIconSlot = getSlotComponent(slots, 'excelIcon', ExcelIcon);
22
+ const handleExport = async (format) => {
23
+ try {
24
+ if (dataMode === 'server' && onServerExport) {
25
+ // Server mode export - fetch data with current filters and selection
26
+ const currentState = table.getState();
27
+ const currentFilters = {
28
+ globalFilter: currentState.globalFilter,
29
+ sorting: currentState.sorting,
30
+ columnFilters: currentState.columnFilters,
31
+ };
32
+ // Get selection data from apiRef if available
33
+ const selectionData = apiRef?.current?.selection?.getSelectionState();
34
+ await 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
+ // Client mode export - export selected rows if any, otherwise all filtered rows
47
+ await exportClientData(table, {
48
+ format,
49
+ filename: exportFilename,
50
+ onProgress: onExportProgress,
51
+ onComplete: onExportComplete,
52
+ onError: onExportError,
53
+ });
54
+ }
55
+ }
56
+ catch (error) {
57
+ console.error('Export failed:', error);
58
+ onExportError?.({
59
+ message: error instanceof Error ? error.message : 'Export failed',
60
+ code: 'PROCESSING_ERROR',
61
+ });
62
+ }
63
+ };
64
+ const selectedRowCount = Object.keys(table.getState().rowSelection).filter(key => table.getState().rowSelection[key]).length;
65
+ const summary = {
66
+ filteredRows: table.getFilteredRowModel().rows.length,
67
+ totalColumns: table.getVisibleLeafColumns().filter(col => col.getIsVisible()).length,
68
+ selectedRows: selectedRowCount,
69
+ hasSelection: selectedRowCount > 0,
70
+ };
71
+ return (_jsx(MenuDropdown, { anchor: (_jsx(Tooltip, { title: "Export data", children: _jsx(IconButton, { size: "small", disabled: isExporting, sx: {
72
+ flexShrink: 0,
73
+ color: isExporting ? 'warning.main' : 'text.secondary',
74
+ }, children: _jsx(ExportIconSlot, { ...slotProps?.exportIcon }) }) })), children: ({ handleClose }) => (_jsxs(Box, { sx: {
75
+ p: 1,
76
+ minWidth: 280,
77
+ }, children: [_jsxs(Box, { sx: {
78
+ mb: 2,
79
+ p: 1,
80
+ bgcolor: 'grey.50',
81
+ borderRadius: 1,
82
+ }, children: [_jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "Export Summary" }), _jsx(Typography, { variant: "body2", color: "text.secondary", children: summary.hasSelection
83
+ ? `${summary.selectedRows} selected • ${summary.totalColumns} visible columns`
84
+ : `${summary.filteredRows} filtered • ${summary.totalColumns} visible columns` }), summary.hasSelection ? (_jsx(Typography, { variant: "caption", color: "primary.main", sx: { fontWeight: 'medium' }, children: "Will export selected rows only" })) : null] }), isExporting ? (_jsxs(MenuItem, { onClick: () => {
85
+ onCancelExport?.();
86
+ handleClose();
87
+ }, children: [_jsx(ListItemIcon, { children: _jsx(ExportIconSlot, { fontSize: "small", color: "warning", ...slotProps?.exportIcon }) }), _jsx(ListItemText, { primary: "Cancel Export", secondary: "Stop current export" })] })) : (_jsxs(_Fragment, { children: [_jsxs(MenuItem, { onClick: async () => {
88
+ await handleExport('csv');
89
+ handleClose();
90
+ }, disabled: isExporting, children: [_jsx(ListItemIcon, { children: _jsx(CsvIconSlot, { fontSize: "small", ...slotProps?.csvIcon }) }), _jsx(ListItemText, { primary: "Export as CSV", secondary: ".csv format" })] }), _jsxs(MenuItem, { onClick: async () => {
91
+ await handleExport('excel');
92
+ handleClose();
93
+ }, disabled: isExporting, children: [_jsx(ListItemIcon, { children: _jsx(ExcelIconSlot, { fontSize: "small", ...slotProps?.excelIcon }) }), _jsx(ListItemText, { primary: "Export as Excel", secondary: ".xlsx format" })] })] }))] })) }));
94
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-search-control.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/toolbar/table-search-control.tsx"],"names":[],"mappings":"AAYA,wBAAgB,kBAAkB,4CAqHjC"}
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Clear, Search } from '@mui/icons-material';
3
+ import { Box, Tooltip } from '@mui/material';
4
+ import { IconButton } from '@mui/material';
5
+ import { Collapse } from '@mui/material';
6
+ import { OutlinedInput } from '@mui/material';
7
+ import { InputAdornment } from '@mui/material';
8
+ import { useCallback, useEffect, useRef, useState } from 'react';
9
+ import { useDataTableContext } from '../../contexts/data-table-context';
10
+ import { getSlotComponent } from '../../utils/slot-helpers';
11
+ export function TableSearchControl() {
12
+ const { table, slots, slotProps } = useDataTableContext();
13
+ const [searchVisible, setSearchVisible] = useState(false);
14
+ const searchInputRef = useRef(null);
15
+ const globalFilter = table.getState().globalFilter || '';
16
+ const hasSearch = globalFilter.length > 0;
17
+ const SearchIconSlot = getSlotComponent(slots, 'searchIcon', Search);
18
+ const ClearIconSlot = getSlotComponent(slots, 'clearIcon', Clear);
19
+ const handleChange = useCallback((e) => {
20
+ table.setGlobalFilter(e.target.value);
21
+ }, [table]);
22
+ const handleSearchToggle = () => {
23
+ if (searchVisible || hasSearch) {
24
+ // If search is visible or has text, hide it and clear
25
+ setSearchVisible(false);
26
+ table.setGlobalFilter('');
27
+ }
28
+ else {
29
+ // Show search input
30
+ setSearchVisible(true);
31
+ }
32
+ };
33
+ const handleSearchClear = () => {
34
+ table.setGlobalFilter('');
35
+ if (searchInputRef.current) {
36
+ searchInputRef.current.focus();
37
+ }
38
+ };
39
+ const handleSearchBlur = () => {
40
+ // Only auto-hide if search is empty
41
+ if (searchVisible && !hasSearch) {
42
+ setSearchVisible(false);
43
+ }
44
+ };
45
+ useEffect(() => {
46
+ if (searchVisible && searchInputRef.current) {
47
+ // Add a delay to ensure the Collapse animation completes
48
+ const timer = setTimeout(() => {
49
+ searchInputRef.current?.focus();
50
+ }, 200);
51
+ return () => clearTimeout(timer);
52
+ }
53
+ return undefined;
54
+ }, [searchVisible]);
55
+ return (_jsxs(Box, { sx: {
56
+ display: 'flex',
57
+ alignItems: 'center',
58
+ }, children: [!(searchVisible || hasSearch) && (_jsx(Tooltip, { title: "Search", children: _jsx(IconButton, { size: "small", onClick: handleSearchToggle, color: hasSearch ? 'primary' : 'default', sx: {
59
+ flexShrink: 0,
60
+ }, children: _jsx(SearchIconSlot, { ...slotProps?.searchIcon }) }) })), _jsx(Collapse, { in: searchVisible || hasSearch, orientation: "horizontal", children: _jsx(OutlinedInput, { inputRef: searchInputRef, placeholder: "Search...", value: globalFilter, onChange: handleChange, size: "small", onBlur: handleSearchBlur, sx: { minWidth: 200 }, endAdornment: hasSearch ? (_jsx(InputAdornment, { position: "end", children: _jsx(Tooltip, { title: "Clear search", children: _jsx(IconButton, { size: "small", onClick: handleSearchClear, edge: "end", children: _jsx(ClearIconSlot, { size: "small", ...slotProps?.clearIcon }) }) }) })) : null, startAdornment: searchVisible || hasSearch ? (_jsx(InputAdornment, { position: "start", children: _jsx(SearchIconSlot, { size: "small", ...slotProps?.searchIcon }) })) : null }) })] }));
61
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-size-control.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/toolbar/table-size-control.tsx"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,4CA4D/B"}
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { LineWeightOutlined } from '@mui/icons-material';
3
+ import { MenuItem, ListItemIcon, ListItemText, Tooltip, IconButton } from '@mui/material';
4
+ import { MenuDropdown } from '../droupdown/menu-dropdown';
5
+ import { useDataTableContext } from '../../contexts/data-table-context';
6
+ import { ViewComfortableIcon, ViewCompactIcon } from '../../icons';
7
+ import { getSlotComponent } from '../../utils/slot-helpers';
8
+ export function TableSizeControl() {
9
+ const { tableSize, onTableSizeChange, slotProps, slots } = useDataTableContext();
10
+ const TableSizeIconSlot = getSlotComponent(slots, 'tableSizeIcon', LineWeightOutlined);
11
+ const TableSizeSmallIconSlot = getSlotComponent(slots, 'tableSizeSmallIcon', ViewCompactIcon);
12
+ const TableSizeMediumIconSlot = getSlotComponent(slots, 'tableSizeMediumIcon', ViewComfortableIcon);
13
+ const SIZE_OPTIONS = [
14
+ {
15
+ value: 'small',
16
+ label: 'Compact',
17
+ description: 'Small padding, compact rows',
18
+ icon: _jsx(TableSizeSmallIconSlot, { ...slotProps?.tableSizeSmallIcon }),
19
+ },
20
+ {
21
+ value: 'medium',
22
+ label: 'Standard',
23
+ description: 'Default padding and spacing',
24
+ icon: _jsx(TableSizeMediumIconSlot, { ...slotProps?.tableSizeMediumIcon }),
25
+ },
26
+ ];
27
+ return (_jsx(MenuDropdown, { anchor: (_jsx(Tooltip, { title: "Table size", children: _jsx(IconButton, { size: "small", sx: {
28
+ flexShrink: 0,
29
+ }, children: _jsx(TableSizeIconSlot, { ...slotProps?.tableSizeIcon }) }) })), children: ({ handleClose }) => (_jsx(_Fragment, { children: SIZE_OPTIONS.map((option) => (_jsxs(MenuItem, { selected: tableSize === option.value, onClick: () => {
30
+ onTableSizeChange?.(option.value);
31
+ handleClose();
32
+ }, children: [_jsx(ListItemIcon, { children: option.icon }), _jsx(ListItemText, { primary: option.label, secondary: option.description })] }, option.value))) })) }));
33
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-table-context.d.ts","sourceRoot":"","sources":["../../../src/lib/contexts/data-table-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAA6B,SAAS,EAAW,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD;;GAEG;AACH,UAAU,qBAAqB,CAAC,CAAC,GAAG,GAAG;IACnC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC9C,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C,2BAA2B,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAGhC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC1C,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAG5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxG,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/F,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,cAAc,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxF;AAID,UAAU,sBAAsB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,qBAAqB,CAAC,CAAC,CAAC;IACtE,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,EACvC,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,KAAU,EACV,SAAc,EACd,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,GACjB,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CA4C3B;AAED,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,KAAK,qBAAqB,CAAC,CAAC,CAAC,CAMvE"}
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ const DataTableContext = createContext(null);
4
+ export function DataTableProvider({ children, table, apiRef, dataMode, tableSize, onTableSizeChange, customColumnsFilter, onChangeCustomColumnsFilter, slots = {}, slotProps = {}, isExporting, exportController, onCancelExport, exportFilename, onExportProgress, onExportComplete, onExportError, onServerExport, }) {
5
+ const value = useMemo(() => ({
6
+ table,
7
+ apiRef,
8
+ dataMode,
9
+ tableSize,
10
+ onTableSizeChange,
11
+ customColumnsFilter,
12
+ onChangeCustomColumnsFilter,
13
+ slots,
14
+ slotProps,
15
+ isExporting,
16
+ exportController,
17
+ onCancelExport,
18
+ exportFilename,
19
+ onExportProgress,
20
+ onExportComplete,
21
+ onExportError,
22
+ onServerExport,
23
+ }), [
24
+ table,
25
+ apiRef,
26
+ dataMode,
27
+ tableSize,
28
+ onTableSizeChange,
29
+ customColumnsFilter,
30
+ onChangeCustomColumnsFilter,
31
+ slots,
32
+ slotProps,
33
+ isExporting,
34
+ exportController,
35
+ onCancelExport,
36
+ exportFilename,
37
+ onExportProgress,
38
+ onExportComplete,
39
+ onExportError,
40
+ onServerExport,
41
+ ]);
42
+ return (_jsx(DataTableContext.Provider, { value: value, children: children }));
43
+ }
44
+ export function useDataTableContext() {
45
+ const context = useContext(DataTableContext);
46
+ if (!context) {
47
+ throw new Error('useDataTableContext must be used within a DataTableProvider');
48
+ }
49
+ return context;
50
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced-features-example.d.ts","sourceRoot":"","sources":["../../../src/lib/examples/advanced-features-example.tsx"],"names":[],"mappings":"AAmHA,wBAAgB,uBAAuB,4CAukBtC"}
@@ -0,0 +1,282 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useCallback, useMemo } from 'react';
3
+ import { Box, Typography, Button, Chip, TextField, Switch, FormControlLabel, Paper, Grid, Divider, IconButton, Tooltip, Badge, Avatar, LinearProgress, Rating, } from '@mui/material';
4
+ import { Edit as EditIcon, Save as SaveIcon, Cancel as CancelIcon, Add as AddIcon, Delete as DeleteIcon, Star as StarIcon, TrendingUp as TrendingUpIcon, TrendingDown as TrendingDownIcon, } from '@mui/icons-material';
5
+ import { DataTable } from '../components';
6
+ // Generate rich sample data
7
+ const generateEmployeeData = () => {
8
+ const departments = [
9
+ { id: 1, name: 'Engineering', color: '#2196F3' },
10
+ { id: 2, name: 'Design', color: '#9C27B0' },
11
+ { id: 3, name: 'Marketing', color: '#FF9800' },
12
+ { id: 4, name: 'Sales', color: '#4CAF50' },
13
+ { id: 5, name: 'HR', color: '#F44336' },
14
+ ];
15
+ const positions = ['Senior', 'Mid-level', 'Junior', 'Lead', 'Manager'];
16
+ const skills = ['React', 'TypeScript', 'Node.js', 'Python', 'Design', 'Analytics', 'Leadership'];
17
+ const names = ['Alice Johnson', 'Bob Smith', 'Charlie Brown', 'Diana Prince', 'Eva Garcia', 'Frank Miller', 'Grace Lee', 'Henry Davis'];
18
+ return Array.from({ length: 20 }, (_, index) => {
19
+ const dept = departments[index % departments.length];
20
+ const employeeSkills = skills.sort(() => 0.5 - Math.random()).slice(0, Math.floor(Math.random() * 4) + 2);
21
+ return {
22
+ id: index + 1,
23
+ name: names[index % names.length] || `Employee ${index + 1}`,
24
+ email: `employee${index + 1}@company.com`,
25
+ avatar: `https://i.pravatar.cc/40?img=${index + 1}`,
26
+ department: dept,
27
+ position: `${positions[index % positions.length]} ${dept.name.slice(0, -3)}er`,
28
+ salary: 60000 + (index * 5000) + Math.floor(Math.random() * 20000),
29
+ performance: {
30
+ rating: Math.floor(Math.random() * 5) + 1,
31
+ trend: ['up', 'down', 'stable'][Math.floor(Math.random() * 3)],
32
+ score: Math.floor(Math.random() * 40) + 60,
33
+ },
34
+ skills: employeeSkills,
35
+ startDate: new Date(2020 + Math.floor(Math.random() * 4), Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1).toISOString().split('T')[0],
36
+ isActive: Math.random() > 0.1,
37
+ projects: Array.from({ length: Math.floor(Math.random() * 3) + 1 }, (_, projIndex) => ({
38
+ id: projIndex + 1,
39
+ name: `Project ${String.fromCharCode(65 + projIndex)}`,
40
+ progress: Math.floor(Math.random() * 100),
41
+ priority: ['high', 'medium', 'low'][Math.floor(Math.random() * 3)],
42
+ })),
43
+ metadata: {
44
+ lastLogin: new Date(Date.now() - Math.floor(Math.random() * 30) * 24 * 60 * 60 * 1000).toISOString(),
45
+ vacationDays: Math.floor(Math.random() * 25),
46
+ certifications: Math.floor(Math.random() * 8),
47
+ },
48
+ };
49
+ });
50
+ };
51
+ export function AdvancedFeaturesExample() {
52
+ const [employees, setEmployees] = useState(generateEmployeeData());
53
+ const [editingRows, setEditingRows] = useState(new Set());
54
+ const [showAdvancedFeatures, setShowAdvancedFeatures] = useState(true);
55
+ const [showNestedData, setShowNestedData] = useState(false);
56
+ // Inline editing handlers
57
+ const handleStartEdit = useCallback((employeeId) => {
58
+ setEditingRows(prev => new Set([...prev, employeeId]));
59
+ }, []);
60
+ const handleSaveEdit = useCallback((employeeId) => {
61
+ setEditingRows(prev => {
62
+ const newSet = new Set(prev);
63
+ newSet.delete(employeeId);
64
+ return newSet;
65
+ });
66
+ // In a real app, you'd save to your data store here
67
+ }, []);
68
+ const handleCancelEdit = useCallback((employeeId) => {
69
+ setEditingRows(prev => {
70
+ const newSet = new Set(prev);
71
+ newSet.delete(employeeId);
72
+ return newSet;
73
+ });
74
+ // In a real app, you'd revert changes here
75
+ }, []);
76
+ const handleFieldChange = useCallback((employeeId, field, value) => {
77
+ setEmployees(prev => prev.map(emp => emp.id === employeeId
78
+ ? { ...emp, [field]: value }
79
+ : emp));
80
+ }, []);
81
+ // Custom cell renderers
82
+ const NameCell = ({ row }) => (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(Avatar, { src: row.avatar, sx: { width: 32, height: 32 } }), _jsxs(Box, { children: [_jsx(Typography, { variant: "body2", fontWeight: "medium", children: row.name }), _jsx(Typography, { variant: "caption", color: "text.secondary", children: row.email })] })] }));
83
+ const DepartmentCell = ({ row }) => (_jsx(Chip, { label: row.department.name, size: "small", sx: {
84
+ backgroundColor: row.department.color,
85
+ color: 'white',
86
+ fontWeight: 'medium',
87
+ } }));
88
+ const SalaryCell = ({ row }) => {
89
+ const isEditing = editingRows.has(row.id);
90
+ if (isEditing) {
91
+ return (_jsx(TextField, { size: "small", type: "number", value: row.salary, onChange: (e) => handleFieldChange(row.id, 'salary', parseInt(e.target.value)), sx: { width: 120 } }));
92
+ }
93
+ return (_jsxs(Typography, { variant: "body2", fontWeight: "medium", children: ["$", row.salary.toLocaleString()] }));
94
+ };
95
+ const PerformanceCell = ({ row }) => {
96
+ const trendIcon = {
97
+ up: _jsx(TrendingUpIcon, { sx: { color: 'success.main', fontSize: 16 } }),
98
+ down: _jsx(TrendingDownIcon, { sx: { color: 'error.main', fontSize: 16 } }),
99
+ stable: _jsx(StarIcon, { sx: { color: 'warning.main', fontSize: 16 } }),
100
+ };
101
+ return (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [_jsx(Rating, { value: row.performance.rating, size: "small", readOnly: true }), trendIcon[row.performance.trend], _jsxs(Typography, { variant: "caption", children: [row.performance.score, "%"] })] }));
102
+ };
103
+ const SkillsCell = ({ row }) => (_jsxs(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5, maxWidth: 200 }, children: [row.skills.slice(0, 3).map((skill, index) => (_jsx(Chip, { label: skill, size: "small", variant: "outlined", sx: { fontSize: '0.7rem', height: 20 } }, index))), row.skills.length > 3 && (_jsx(Chip, { label: `+${row.skills.length - 3}`, size: "small", variant: "filled", sx: { fontSize: '0.7rem', height: 20 } }))] }));
104
+ const ProjectsCell = ({ row }) => (_jsx(Box, { sx: { minWidth: 150 }, children: row.projects.map((project, index) => (_jsxs(Box, { sx: { mb: 0.5 }, children: [_jsxs(Box, { sx: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [_jsx(Typography, { variant: "caption", fontWeight: "medium", children: project.name }), _jsx(Chip, { label: project.priority, size: "small", color: project.priority === 'high' ? 'error' : project.priority === 'medium' ? 'warning' : 'default', sx: { fontSize: '0.6rem', height: 16 } })] }), _jsx(LinearProgress, { variant: "determinate", value: project.progress, sx: { height: 4, borderRadius: 2 }, color: project.priority === 'high' ? 'error' : project.priority === 'medium' ? 'warning' : 'primary' })] }, index))) }));
105
+ const ActionsCell = ({ row }) => {
106
+ const isEditing = editingRows.has(row.id);
107
+ if (isEditing) {
108
+ return (_jsxs(Box, { sx: { display: 'flex', gap: 0.5 }, children: [_jsx(Tooltip, { title: "Save changes", children: _jsx(IconButton, { size: "small", onClick: () => handleSaveEdit(row.id), color: "primary", children: _jsx(SaveIcon, { fontSize: "small" }) }) }), _jsx(Tooltip, { title: "Cancel editing", children: _jsx(IconButton, { size: "small", onClick: () => handleCancelEdit(row.id), color: "secondary", children: _jsx(CancelIcon, { fontSize: "small" }) }) })] }));
109
+ }
110
+ return (_jsxs(Box, { sx: { display: 'flex', gap: 0.5 }, children: [_jsx(Tooltip, { title: "Edit employee", children: _jsx(IconButton, { size: "small", onClick: () => handleStartEdit(row.id), color: "primary", children: _jsx(EditIcon, { fontSize: "small" }) }) }), _jsx(Tooltip, { title: "Delete employee", children: _jsx(IconButton, { size: "small", onClick: () => {
111
+ setEmployees(prev => prev.filter(emp => emp.id !== row.id));
112
+ }, color: "error", children: _jsx(DeleteIcon, { fontSize: "small" }) }) })] }));
113
+ };
114
+ // Row expansion content
115
+ const renderSubComponent = useCallback(({ row }) => (_jsx(Box, { sx: { p: 2, backgroundColor: 'grey.50', borderRadius: 1 }, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsxs(Grid, { size: { xs: 12, md: 6 }, children: [_jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "Contact Information" }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Email:" }), " ", row.email] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Position:" }), " ", row.position] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Start Date:" }), " ", new Date(row.startDate).toLocaleDateString()] })] }), _jsxs(Grid, { size: { xs: 12, md: 6 }, children: [_jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "Metadata" }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Last Login:" }), " ", new Date(row.metadata.lastLogin).toLocaleDateString()] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Vacation Days:" }), " ", row.metadata.vacationDays] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Certifications:" }), " ", row.metadata.certifications] })] }), _jsxs(Grid, { size: { xs: 12 }, children: [_jsx(Typography, { variant: "subtitle2", gutterBottom: true, children: "All Skills" }), _jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 }, children: row.skills.map((skill, index) => (_jsx(Chip, { label: skill, size: "small", color: "primary", variant: "outlined" }, index))) })] })] }) })), []);
116
+ // Dynamic column configuration
117
+ const columns = useMemo(() => {
118
+ const baseColumns = [
119
+ {
120
+ accessorKey: 'name',
121
+ header: 'Employee',
122
+ size: 200,
123
+ cell: ({ row }) => _jsx(NameCell, { row: row.original }),
124
+ enableSorting: true,
125
+ filterable: true,
126
+ type: 'text',
127
+ },
128
+ {
129
+ accessorKey: 'department.name',
130
+ header: 'Department',
131
+ size: 120,
132
+ cell: ({ row }) => _jsx(DepartmentCell, { row: row.original }),
133
+ enableSorting: true,
134
+ filterable: true,
135
+ type: 'select',
136
+ options: [
137
+ { value: 'Engineering', label: 'Engineering' },
138
+ { value: 'Design', label: 'Design' },
139
+ { value: 'Marketing', label: 'Marketing' },
140
+ { value: 'Sales', label: 'Sales' },
141
+ { value: 'HR', label: 'HR' },
142
+ ],
143
+ },
144
+ {
145
+ accessorKey: 'salary',
146
+ header: 'Salary',
147
+ size: 120,
148
+ cell: ({ row }) => _jsx(SalaryCell, { row: row.original }),
149
+ enableSorting: true,
150
+ filterable: true,
151
+ type: 'number',
152
+ },
153
+ {
154
+ accessorKey: 'startDate',
155
+ header: 'Start Date',
156
+ size: 140,
157
+ enableSorting: true,
158
+ filterable: true,
159
+ type: 'date',
160
+ cell: ({ row }) => (_jsx(Typography, { variant: "body2", children: new Date(row.original.startDate).toLocaleDateString() })),
161
+ },
162
+ {
163
+ accessorKey: 'performance.rating',
164
+ header: 'Performance',
165
+ size: 200,
166
+ cell: ({ row }) => _jsx(PerformanceCell, { row: row.original }),
167
+ enableSorting: true,
168
+ },
169
+ {
170
+ accessorKey: 'skills',
171
+ header: 'Skills',
172
+ size: 250,
173
+ cell: ({ row }) => _jsx(SkillsCell, { row: row.original }),
174
+ enableSorting: false,
175
+ },
176
+ ];
177
+ if (showNestedData) {
178
+ baseColumns.push({
179
+ accessorKey: 'projects',
180
+ header: 'Projects',
181
+ size: 200,
182
+ cell: ({ row }) => _jsx(ProjectsCell, { row: row.original }),
183
+ enableSorting: false,
184
+ });
185
+ }
186
+ if (showAdvancedFeatures) {
187
+ baseColumns.push({
188
+ id: 'actions',
189
+ header: 'Actions',
190
+ size: 100,
191
+ cell: ({ row }) => _jsx(ActionsCell, { row: row.original }),
192
+ enableSorting: false,
193
+ filterable: false,
194
+ });
195
+ }
196
+ return baseColumns;
197
+ }, [showAdvancedFeatures, showNestedData, editingRows]);
198
+ const addNewEmployee = useCallback(() => {
199
+ const newEmployee = {
200
+ id: Math.max(...employees.map(e => e.id)) + 1,
201
+ name: 'New Employee',
202
+ email: 'new@company.com',
203
+ avatar: 'https://i.pravatar.cc/40?img=1',
204
+ department: { id: 1, name: 'Engineering', color: '#2196F3' },
205
+ position: 'Junior Developer',
206
+ salary: 60000,
207
+ performance: { rating: 3, trend: 'stable', score: 75 },
208
+ skills: ['React'],
209
+ startDate: new Date().toISOString().split('T')[0],
210
+ isActive: true,
211
+ projects: [],
212
+ metadata: {
213
+ lastLogin: new Date().toISOString(),
214
+ vacationDays: 20,
215
+ certifications: 0,
216
+ },
217
+ };
218
+ setEmployees(prev => [...prev, newEmployee]);
219
+ handleStartEdit(newEmployee.id);
220
+ }, [employees, handleStartEdit]);
221
+ return (_jsxs(Box, { sx: { p: 3 }, children: [_jsx(Typography, { variant: "h4", gutterBottom: true, children: "Advanced Features Demo" }), _jsx(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." }), _jsxs(Paper, { sx: { p: 2, mb: 3 }, children: [_jsx(Typography, { variant: "h6", gutterBottom: true, children: "Feature Controls" }), _jsxs(Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap', alignItems: 'center' }, children: [_jsx(FormControlLabel, { control: _jsx(Switch, { checked: showAdvancedFeatures, onChange: (e) => setShowAdvancedFeatures(e.target.checked) }), label: "Inline Editing & Actions" }), _jsx(FormControlLabel, { control: _jsx(Switch, { checked: showNestedData, onChange: (e) => setShowNestedData(e.target.checked) }), label: "Show Project Data" }), _jsx(Button, { variant: "contained", startIcon: _jsx(AddIcon, {}), onClick: addNewEmployee, size: "small", children: "Add Employee" }), _jsx(Badge, { badgeContent: editingRows.size, color: "primary", children: _jsx(Typography, { variant: "body2", children: "Editing Rows" }) })] })] }), _jsxs(Paper, { sx: { p: 2, mb: 3 }, children: [_jsx(Typography, { variant: "h6", gutterBottom: true, children: "Statistics" }), _jsxs(Grid, { container: true, spacing: 2, children: [_jsxs(Grid, { size: { xs: 6, sm: 3 }, children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: "Total Employees" }), _jsx(Typography, { variant: "h6", children: employees.length })] }), _jsxs(Grid, { size: { xs: 6, sm: 3 }, children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: "Active Employees" }), _jsx(Typography, { variant: "h6", children: employees.filter(e => e.isActive).length })] }), _jsxs(Grid, { size: { xs: 6, sm: 3 }, children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: "Avg Salary" }), _jsxs(Typography, { variant: "h6", children: ["$", Math.round(employees.reduce((sum, e) => sum + e.salary, 0) / employees.length).toLocaleString()] })] }), _jsxs(Grid, { size: { xs: 6, sm: 3 }, children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: "Currently Editing" }), _jsx(Typography, { variant: "h6", children: editingRows.size })] })] })] }), _jsx(Divider, { sx: { my: 2 } }), _jsx(DataTable, { data: employees, totalRow: employees.length, columns: columns,
222
+ // Advanced features
223
+ enableRowSelection: true, enableMultiRowSelection: true, enableSorting: true, enableGlobalFilter: true, enableColumnFilter: true, enableColumnDragging: true, enableColumnPinning: true, enablePagination: true,
224
+ // Row expansion
225
+ getRowCanExpand: () => true, renderSubComponent: (row) => renderSubComponent({ row: row.original }),
226
+ // Initial state
227
+ initialState: {
228
+ pagination: {
229
+ pageIndex: 0,
230
+ pageSize: 10,
231
+ },
232
+ columnOrder: ['name', 'department.name', 'salary', 'performance.rating', 'skills'],
233
+ },
234
+ // Styling
235
+ tableContainerProps: {
236
+ sx: {
237
+ '& .MuiTableRow-root:hover': {
238
+ backgroundColor: 'action.hover',
239
+ },
240
+ '& .MuiTableCell-root': {
241
+ borderBottom: '1px solid',
242
+ borderColor: 'divider',
243
+ },
244
+ }
245
+ },
246
+ // Bulk actions
247
+ enableBulkActions: true, bulkActions: (selectionState) => (_jsxs(Box, { sx: { display: 'flex', gap: 1 }, children: [_jsx(Button, { variant: "outlined", size: "small", onClick: () => {
248
+ let selectedEmployees;
249
+ if (selectionState.type === 'include') {
250
+ selectedEmployees = employees.filter(emp => selectionState.ids.includes(emp.id.toString()));
251
+ }
252
+ else {
253
+ selectedEmployees = employees.filter(emp => !selectionState.ids.includes(emp.id.toString()));
254
+ }
255
+ const avgSalary = selectedEmployees.reduce((sum, emp) => sum + emp.salary, 0) / selectedEmployees.length;
256
+ alert(`Average salary of ${selectedEmployees.length} selected employees: $${Math.round(avgSalary).toLocaleString()}`);
257
+ }, children: "\uD83D\uDCCA Calculate Avg Salary" }), _jsx(Button, { variant: "outlined", size: "small", onClick: () => {
258
+ const updatedEmployees = employees.map(emp => {
259
+ const isSelected = selectionState.type === 'include'
260
+ ? selectionState.ids.includes(emp.id.toString())
261
+ : !selectionState.ids.includes(emp.id.toString());
262
+ return isSelected
263
+ ? { ...emp, performance: { ...emp.performance, rating: 5 } }
264
+ : emp;
265
+ });
266
+ setEmployees(updatedEmployees);
267
+ }, children: "\u2B50 Boost Performance" }), _jsx(Button, { variant: "outlined", size: "small", color: "error", onClick: () => {
268
+ let selectedEmployees;
269
+ if (selectionState.type === 'include') {
270
+ selectedEmployees = employees.filter(emp => selectionState.ids.includes(emp.id.toString()));
271
+ }
272
+ else {
273
+ selectedEmployees = employees.filter(emp => !selectionState.ids.includes(emp.id.toString()));
274
+ }
275
+ if (window.confirm(`Delete ${selectedEmployees.length} selected employees?`)) {
276
+ const selectedIds = selectedEmployees.map(emp => emp.id);
277
+ setEmployees(prev => prev.filter(emp => !selectedIds.includes(emp.id)));
278
+ }
279
+ }, children: "\uD83D\uDDD1\uFE0F Delete Selected" })] })),
280
+ // Fit to screen
281
+ fitToScreen: true }), _jsx(Box, { sx: { mt: 2 }, children: _jsxs(Typography, { variant: "body2", color: "text.secondary", children: ["\uD83D\uDCA1 ", _jsx("strong", { children: "Features demonstrated:" }), _jsx("br", {}), "\u2022 Inline editing with save/cancel actions", _jsx("br", {}), "\u2022 Custom cell renderers with rich content (avatars, ratings, progress bars)", _jsx("br", {}), "\u2022 Row expansion with detailed information", _jsx("br", {}), "\u2022 Dynamic column configuration", _jsx("br", {}), "\u2022 Complex nested data structures", _jsx("br", {}), "\u2022 Real-time statistics and bulk operations", _jsx("br", {}), "\u2022 Advanced styling and theming"] }) })] }));
282
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-example.d.ts","sourceRoot":"","sources":["../../../src/lib/examples/basic-example.tsx"],"names":[],"mappings":"AA6KA,wBAAgB,gBAAgB,4CAoR/B;AAGD,wBAAgB,0BAA0B,4CA2DzC"}