@ackplus/react-tanstack-data-table 1.0.19-beta-0.6 → 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 (258) hide show
  1. package/package.json +3 -11
  2. package/{index.js → src/index.d.ts} +3 -26
  3. package/src/index.js +31 -0
  4. package/src/lib/components/droupdown/menu-dropdown.d.ts +17 -0
  5. package/src/lib/components/droupdown/menu-dropdown.js +52 -0
  6. package/src/lib/components/filters/filter-value-input.d.ts +9 -0
  7. package/src/lib/components/filters/filter-value-input.js +58 -0
  8. package/src/lib/components/filters/index.d.ts +23 -0
  9. package/{lib → src/lib}/components/filters/index.js +6 -2
  10. package/src/lib/components/headers/draggable-header.d.ts +12 -0
  11. package/{lib → src/lib}/components/headers/draggable-header.js +35 -49
  12. package/{lib/components/headers/index.js → src/lib/components/headers/index.d.ts} +0 -3
  13. package/src/lib/components/headers/index.js +5 -0
  14. package/src/lib/components/headers/table-header.d.ts +10 -0
  15. package/src/lib/components/headers/table-header.js +48 -0
  16. package/src/lib/components/index.d.ts +7 -0
  17. package/src/lib/components/index.js +10 -0
  18. package/src/lib/components/pagination/data-table-pagination.d.ts +11 -0
  19. package/src/lib/components/pagination/data-table-pagination.js +25 -0
  20. package/src/lib/components/pagination/index.d.ts +1 -0
  21. package/src/lib/components/pagination/index.js +4 -0
  22. package/src/lib/components/rows/data-table-row.d.ts +13 -0
  23. package/src/lib/components/rows/data-table-row.js +31 -0
  24. package/src/lib/components/rows/empty-data-row.d.ts +6 -0
  25. package/src/lib/components/rows/empty-data-row.js +11 -0
  26. package/{lib/components/rows/index.js → src/lib/components/rows/index.d.ts} +0 -3
  27. package/src/lib/components/rows/index.js +6 -0
  28. package/src/lib/components/rows/loading-rows.d.ts +5 -0
  29. package/src/lib/components/rows/loading-rows.js +49 -0
  30. package/src/lib/components/table/data-table.d.ts +3 -0
  31. package/src/lib/components/table/data-table.js +492 -0
  32. package/src/lib/components/table/data-table.types.d.ts +114 -0
  33. package/src/lib/components/table/data-table.types.js +2 -0
  34. package/{lib/components/table/index.js → src/lib/components/table/index.d.ts} +0 -3
  35. package/src/lib/components/table/index.js +5 -0
  36. package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +9 -0
  37. package/src/lib/components/toolbar/bulk-actions-toolbar.js +25 -0
  38. package/src/lib/components/toolbar/column-custom-filter-control.d.ts +1 -0
  39. package/src/lib/components/toolbar/column-custom-filter-control.js +137 -0
  40. package/src/lib/components/toolbar/column-pinning-control.d.ts +1 -0
  41. package/src/lib/components/toolbar/column-pinning-control.js +105 -0
  42. package/src/lib/components/toolbar/column-reset-control.d.ts +1 -0
  43. package/src/lib/components/toolbar/column-reset-control.js +16 -0
  44. package/src/lib/components/toolbar/column-visibility-control.d.ts +1 -0
  45. package/src/lib/components/toolbar/column-visibility-control.js +31 -0
  46. package/src/lib/components/toolbar/data-table-toolbar.d.ts +14 -0
  47. package/src/lib/components/toolbar/data-table-toolbar.js +26 -0
  48. package/{lib/components/toolbar/index.js → src/lib/components/toolbar/index.d.ts} +1 -6
  49. package/src/lib/components/toolbar/index.js +17 -0
  50. package/src/lib/components/toolbar/table-export-control.d.ts +25 -0
  51. package/src/lib/components/toolbar/table-export-control.js +93 -0
  52. package/src/lib/components/toolbar/table-search-control.d.ts +1 -0
  53. package/src/lib/components/toolbar/table-search-control.js +61 -0
  54. package/src/lib/components/toolbar/table-size-control.d.ts +1 -0
  55. package/src/lib/components/toolbar/table-size-control.js +36 -0
  56. package/src/lib/contexts/data-table-context.d.ts +43 -0
  57. package/{lib → src/lib}/contexts/data-table-context.js +12 -8
  58. package/src/lib/examples/advanced-features-example.d.ts +1 -0
  59. package/src/lib/examples/advanced-features-example.js +264 -0
  60. package/src/lib/examples/bulk-actions-test.d.ts +1 -0
  61. package/src/lib/examples/bulk-actions-test.js +44 -0
  62. package/src/lib/examples/custom-column-filter-example.d.ts +1 -0
  63. package/{lib → src/lib}/examples/custom-column-filter-example.js +10 -10
  64. package/src/lib/examples/index.js +13 -0
  65. package/src/lib/examples/selection-test-example.d.ts +1 -0
  66. package/src/lib/examples/selection-test-example.js +101 -0
  67. package/src/lib/examples/simple-local-example.d.ts +1 -0
  68. package/{lib → src/lib}/examples/simple-local-example.js +14 -18
  69. package/src/lib/features/custom-column-filter.feature.d.ts +45 -0
  70. package/{lib → src/lib}/features/custom-column-filter.feature.js +40 -99
  71. package/src/lib/features/custom-selection.feature.d.ts +46 -0
  72. package/{lib → src/lib}/features/custom-selection.feature.js +18 -70
  73. package/src/lib/features/index.d.ts +2 -0
  74. package/src/lib/features/index.js +8 -0
  75. package/src/lib/hooks/index.d.ts +1 -0
  76. package/src/lib/hooks/index.js +4 -0
  77. package/src/lib/hooks/use-data-table-api.d.ts +56 -0
  78. package/{lib → src/lib}/hooks/use-data-table-api.js +79 -136
  79. package/src/lib/icons/add-icon.d.ts +2 -0
  80. package/src/lib/icons/add-icon.js +8 -0
  81. package/src/lib/icons/csv-icon.d.ts +2 -0
  82. package/src/lib/icons/csv-icon.js +8 -0
  83. package/src/lib/icons/delete-icon.d.ts +2 -0
  84. package/src/lib/icons/delete-icon.js +8 -0
  85. package/src/lib/icons/excel-icon.d.ts +2 -0
  86. package/src/lib/icons/excel-icon.js +8 -0
  87. package/src/lib/icons/index.js +17 -0
  88. package/src/lib/icons/unpin-icon.d.ts +2 -0
  89. package/src/lib/icons/unpin-icon.js +8 -0
  90. package/src/lib/icons/view-comfortable-icon.d.ts +2 -0
  91. package/src/lib/icons/view-comfortable-icon.js +8 -0
  92. package/src/lib/icons/view-compact-icon.d.ts +2 -0
  93. package/src/lib/icons/view-compact-icon.js +8 -0
  94. package/src/lib/types/column.types.d.ts +29 -0
  95. package/src/lib/types/column.types.js +5 -0
  96. package/src/lib/types/data-table-api.d.ts +134 -0
  97. package/src/lib/types/data-table-api.js +2 -0
  98. package/src/lib/types/export.types.d.ts +99 -0
  99. package/src/lib/types/export.types.js +2 -0
  100. package/src/lib/types/index.d.ts +6 -0
  101. package/src/lib/types/index.js +8 -0
  102. package/src/lib/types/slots.types.d.ts +272 -0
  103. package/src/lib/types/slots.types.js +2 -0
  104. package/src/lib/types/table.types.d.ts +63 -0
  105. package/src/lib/types/table.types.js +2 -0
  106. package/src/lib/utils/column-helpers.d.ts +7 -0
  107. package/src/lib/utils/column-helpers.js +43 -0
  108. package/src/lib/utils/debounced-fetch.utils.d.ts +11 -0
  109. package/{lib → src/lib}/utils/debounced-fetch.utils.js +15 -17
  110. package/src/lib/utils/export-utils.d.ts +30 -0
  111. package/src/lib/utils/export-utils.js +152 -0
  112. package/{lib/utils/index.js → src/lib/utils/index.d.ts} +0 -10
  113. package/src/lib/utils/index.js +10 -0
  114. package/src/lib/utils/slot-helpers.d.ts +9 -0
  115. package/src/lib/utils/slot-helpers.js +21 -0
  116. package/src/lib/utils/special-columns.utils.d.ts +6 -0
  117. package/src/lib/utils/special-columns.utils.js +52 -0
  118. package/src/lib/utils/styling-helpers.d.ts +36 -0
  119. package/src/lib/utils/styling-helpers.js +61 -0
  120. package/src/lib/utils/table-helpers.d.ts +9 -0
  121. package/{lib → src/lib}/utils/table-helpers.js +16 -31
  122. package/tsconfig.tsbuildinfo +1 -0
  123. package/LICENSE +0 -21
  124. package/index.d.ts.map +0 -1
  125. package/lib/components/droupdown/menu-dropdown.d.ts.map +0 -1
  126. package/lib/components/droupdown/menu-dropdown.js +0 -47
  127. package/lib/components/export-progress-dialog.d.ts.map +0 -1
  128. package/lib/components/export-progress-dialog.js +0 -30
  129. package/lib/components/filters/filter-value-input.d.ts.map +0 -1
  130. package/lib/components/filters/filter-value-input.js +0 -64
  131. package/lib/components/filters/index.d.ts.map +0 -1
  132. package/lib/components/headers/draggable-header.d.ts.map +0 -1
  133. package/lib/components/headers/index.d.ts.map +0 -1
  134. package/lib/components/headers/table-header.d.ts.map +0 -1
  135. package/lib/components/headers/table-header.js +0 -59
  136. package/lib/components/index.d.ts.map +0 -1
  137. package/lib/components/index.js +0 -18
  138. package/lib/components/pagination/data-table-pagination.d.ts.map +0 -1
  139. package/lib/components/pagination/data-table-pagination.js +0 -24
  140. package/lib/components/pagination/index.d.ts.map +0 -1
  141. package/lib/components/pagination/index.js +0 -4
  142. package/lib/components/rows/data-table-row.d.ts.map +0 -1
  143. package/lib/components/rows/data-table-row.js +0 -42
  144. package/lib/components/rows/empty-data-row.d.ts.map +0 -1
  145. package/lib/components/rows/empty-data-row.js +0 -8
  146. package/lib/components/rows/index.d.ts.map +0 -1
  147. package/lib/components/rows/loading-rows.d.ts.map +0 -1
  148. package/lib/components/rows/loading-rows.js +0 -46
  149. package/lib/components/table/data-table.d.ts.map +0 -1
  150. package/lib/components/table/data-table.js +0 -663
  151. package/lib/components/table/data-table.types.d.ts.map +0 -1
  152. package/lib/components/table/data-table.types.js +0 -6
  153. package/lib/components/table/index.d.ts.map +0 -1
  154. package/lib/components/toolbar/bulk-actions-toolbar.d.ts.map +0 -1
  155. package/lib/components/toolbar/bulk-actions-toolbar.js +0 -31
  156. package/lib/components/toolbar/column-custom-filter-control.d.ts.map +0 -1
  157. package/lib/components/toolbar/column-custom-filter-control.js +0 -149
  158. package/lib/components/toolbar/column-custum-filter-control.d.ts.map +0 -1
  159. package/lib/components/toolbar/column-custum-filter-control.js +0 -150
  160. package/lib/components/toolbar/column-pinning-control.d.ts.map +0 -1
  161. package/lib/components/toolbar/column-pinning-control.js +0 -103
  162. package/lib/components/toolbar/column-reset-control.d.ts.map +0 -1
  163. package/lib/components/toolbar/column-reset-control.js +0 -13
  164. package/lib/components/toolbar/column-visibility-control.d.ts.map +0 -1
  165. package/lib/components/toolbar/column-visibility-control.js +0 -27
  166. package/lib/components/toolbar/data-table-toolbar.d.ts.map +0 -1
  167. package/lib/components/toolbar/data-table-toolbar.js +0 -23
  168. package/lib/components/toolbar/index.d.ts.map +0 -1
  169. package/lib/components/toolbar/table-export-control.d.ts.map +0 -1
  170. package/lib/components/toolbar/table-export-control.js +0 -94
  171. package/lib/components/toolbar/table-search-control.d.ts.map +0 -1
  172. package/lib/components/toolbar/table-search-control.js +0 -61
  173. package/lib/components/toolbar/table-size-control.d.ts.map +0 -1
  174. package/lib/components/toolbar/table-size-control.js +0 -33
  175. package/lib/contexts/data-table-context.d.ts.map +0 -1
  176. package/lib/examples/advanced-features-example.d.ts.map +0 -1
  177. package/lib/examples/advanced-features-example.js +0 -282
  178. package/lib/examples/basic-example.d.ts.map +0 -1
  179. package/lib/examples/basic-example.js +0 -323
  180. package/lib/examples/bulk-actions-test.d.ts.map +0 -1
  181. package/lib/examples/bulk-actions-test.js +0 -47
  182. package/lib/examples/crud-api-example.d.ts.map +0 -1
  183. package/lib/examples/crud-api-example.js +0 -321
  184. package/lib/examples/custom-column-filter-example.d.ts.map +0 -1
  185. package/lib/examples/custom-selection-example.d.ts.map +0 -1
  186. package/lib/examples/custom-selection-example.js +0 -184
  187. package/lib/examples/export-callbacks-example.d.ts.map +0 -1
  188. package/lib/examples/export-callbacks-example.js +0 -155
  189. package/lib/examples/improved-export-example.d.ts.map +0 -1
  190. package/lib/examples/improved-export-example.js +0 -153
  191. package/lib/examples/improved-server-selection-example.d.ts.map +0 -1
  192. package/lib/examples/improved-server-selection-example.js +0 -118
  193. package/lib/examples/index.d.ts.map +0 -1
  194. package/lib/examples/selection-test-example.d.ts.map +0 -1
  195. package/lib/examples/selection-test-example.js +0 -111
  196. package/lib/examples/simple-local-example.d.ts.map +0 -1
  197. package/lib/examples/simple-server-selection-example.d.ts.map +0 -1
  198. package/lib/examples/simple-server-selection-example.js +0 -178
  199. package/lib/examples/virtualized-example.d.ts.map +0 -1
  200. package/lib/examples/virtualized-example.js +0 -119
  201. package/lib/features/custom-column-filter.feature.d.ts.map +0 -1
  202. package/lib/features/custom-selection.feature.d.ts.map +0 -1
  203. package/lib/features/index.d.ts.map +0 -1
  204. package/lib/features/index.js +0 -9
  205. package/lib/hooks/index.d.ts.map +0 -1
  206. package/lib/hooks/index.js +0 -6
  207. package/lib/hooks/use-data-table-api.d.ts.map +0 -1
  208. package/lib/hooks/use-table-state.d.ts.map +0 -1
  209. package/lib/hooks/use-table-state.js +0 -74
  210. package/lib/icons/add-icon.d.ts.map +0 -1
  211. package/lib/icons/add-icon.js +0 -5
  212. package/lib/icons/csv-icon.d.ts.map +0 -1
  213. package/lib/icons/csv-icon.js +0 -5
  214. package/lib/icons/delete-icon.d.ts.map +0 -1
  215. package/lib/icons/delete-icon.js +0 -5
  216. package/lib/icons/excel-icon.d.ts.map +0 -1
  217. package/lib/icons/excel-icon.js +0 -5
  218. package/lib/icons/index.d.ts.map +0 -1
  219. package/lib/icons/unpin-icon.d.ts.map +0 -1
  220. package/lib/icons/unpin-icon.js +0 -5
  221. package/lib/icons/view-comfortable-icon.d.ts.map +0 -1
  222. package/lib/icons/view-comfortable-icon.js +0 -5
  223. package/lib/icons/view-compact-icon.d.ts.map +0 -1
  224. package/lib/icons/view-compact-icon.js +0 -5
  225. package/lib/types/column.types.d.ts.map +0 -1
  226. package/lib/types/column.types.js +0 -2
  227. package/lib/types/data-table-api.d.ts.map +0 -1
  228. package/lib/types/data-table-api.js +0 -1
  229. package/lib/types/export.types.d.ts.map +0 -1
  230. package/lib/types/export.types.js +0 -5
  231. package/lib/types/hooks.types.d.ts.map +0 -1
  232. package/lib/types/hooks.types.js +0 -1
  233. package/lib/types/index.d.ts.map +0 -1
  234. package/lib/types/index.js +0 -14
  235. package/lib/types/slots.types.d.ts.map +0 -1
  236. package/lib/types/slots.types.js +0 -1
  237. package/lib/types/table.types.d.ts.map +0 -1
  238. package/lib/types/table.types.js +0 -1
  239. package/lib/utils/column-helpers.d.ts.map +0 -1
  240. package/lib/utils/column-helpers.js +0 -46
  241. package/lib/utils/debounced-fetch.utils.d.ts.map +0 -1
  242. package/lib/utils/export-utils.d.ts.map +0 -1
  243. package/lib/utils/export-utils.js +0 -181
  244. package/lib/utils/index.d.ts.map +0 -1
  245. package/lib/utils/selection-helpers.d.ts.map +0 -1
  246. package/lib/utils/selection-helpers.js +0 -162
  247. package/lib/utils/slot-helpers.d.ts.map +0 -1
  248. package/lib/utils/slot-helpers.js +0 -27
  249. package/lib/utils/special-columns.utils.d.ts.map +0 -1
  250. package/lib/utils/special-columns.utils.js +0 -77
  251. package/lib/utils/styling-helpers.d.ts.map +0 -1
  252. package/lib/utils/styling-helpers.js +0 -97
  253. package/lib/utils/table-helpers.d.ts.map +0 -1
  254. package/lib/utils/value-helpers.d.ts.map +0 -1
  255. package/lib/utils/value-helpers.js +0 -48
  256. package/tsconfig.lib.tsbuildinfo +0 -1
  257. /package/{lib/examples/index.js → src/lib/examples/index.d.ts} +0 -0
  258. /package/{lib/icons/index.js → src/lib/icons/index.d.ts} +0 -0
@@ -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 {};
@@ -1,8 +1,12 @@
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(() => ({
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)(() => ({
6
10
  table,
7
11
  apiRef,
8
12
  dataMode,
@@ -39,10 +43,10 @@ export function DataTableProvider({ children, table, apiRef, dataMode, tableSize
39
43
  onExportError,
40
44
  onServerExport,
41
45
  ]);
42
- return (_jsx(DataTableContext.Provider, { value: value, children: children }));
46
+ return ((0, jsx_runtime_1.jsx)(DataTableContext.Provider, { value: value, children: children }));
43
47
  }
44
- export function useDataTableContext() {
45
- const context = useContext(DataTableContext);
48
+ function useDataTableContext() {
49
+ const context = (0, react_1.useContext)(DataTableContext);
46
50
  if (!context) {
47
51
  throw new Error('useDataTableContext must be used within a DataTableProvider');
48
52
  }
@@ -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;
@@ -1,10 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Example: Custom Column Filter Feature Usage
4
- */
5
- import { useState } from 'react';
6
- import { Box, Typography } from '@mui/material';
7
- import { DataTable } from '../components/table/data-table';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomColumnFilterExample = CustomColumnFilterExample;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const material_1 = require("@mui/material");
7
+ const data_table_1 = require("../components/table/data-table");
8
8
  const sampleData = [
9
9
  { id: 1, name: 'John Doe', age: 30, department: 'Engineering', salary: 75000, isActive: true },
10
10
  { id: 2, name: 'Jane Smith', age: 25, department: 'Marketing', salary: 60000, isActive: true },
@@ -52,9 +52,9 @@ const columns = [
52
52
  type: 'boolean',
53
53
  },
54
54
  ];
55
- export function CustomColumnFilterExample() {
56
- const [data] = useState(sampleData);
57
- return (_jsxs(Box, { sx: { p: 3 }, children: [_jsx(Typography, { variant: "h4", gutterBottom: true, children: "Custom Column Filter Feature Example" }), _jsx(Typography, { variant: "body1", sx: { mb: 3 }, children: "Click the filter icon in the toolbar to test the custom column filter feature." }), _jsx(DataTable, { data: data, columns: columns, enableColumnFilter: true, enableGlobalFilter: true, enablePagination: true, enableSorting: true, onColumnFiltersChange: (filterState) => {
55
+ function CustomColumnFilterExample() {
56
+ const [data] = (0, react_1.useState)(sampleData);
57
+ 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: "Custom Column Filter Feature Example" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", sx: { mb: 3 }, children: "Click the filter icon in the toolbar to test the custom column filter feature." }), (0, jsx_runtime_1.jsx)(data_table_1.DataTable, { data: data, columns: columns, enableColumnFilter: true, enableGlobalFilter: true, enablePagination: true, enableSorting: true, onColumnFiltersChange: (filterState) => {
58
58
  console.log('Custom Column Filter State Changed:', filterState);
59
59
  } })] }));
60
60
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BulkActionsTest = exports.SimpleLocalExample = exports.AdvancedFeaturesExample = exports.SelectionTestExample = exports.CustomColumnFilterExample = void 0;
4
+ var custom_column_filter_example_1 = require("./custom-column-filter-example");
5
+ Object.defineProperty(exports, "CustomColumnFilterExample", { enumerable: true, get: function () { return custom_column_filter_example_1.CustomColumnFilterExample; } });
6
+ var selection_test_example_1 = require("./selection-test-example");
7
+ Object.defineProperty(exports, "SelectionTestExample", { enumerable: true, get: function () { return selection_test_example_1.SelectionTestExample; } });
8
+ var advanced_features_example_1 = require("./advanced-features-example");
9
+ Object.defineProperty(exports, "AdvancedFeaturesExample", { enumerable: true, get: function () { return advanced_features_example_1.AdvancedFeaturesExample; } });
10
+ var simple_local_example_1 = require("./simple-local-example");
11
+ Object.defineProperty(exports, "SimpleLocalExample", { enumerable: true, get: function () { return simple_local_example_1.SimpleLocalExample; } });
12
+ var bulk_actions_test_1 = require("./bulk-actions-test");
13
+ Object.defineProperty(exports, "BulkActionsTest", { enumerable: true, get: function () { return bulk_actions_test_1.BulkActionsTest; } });
@@ -0,0 +1 @@
1
+ export declare function SelectionTestExample(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectionTestExample = SelectionTestExample;
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 generateSampleData = () => {
9
+ const departments = ['Engineering', 'Marketing', 'Sales', 'HR', 'Finance'];
10
+ const firstNames = ['John', 'Jane', 'Bob', 'Alice', 'Charlie', 'Diana', 'Eva', 'Frank', 'Grace', 'Henry'];
11
+ const lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis', 'Rodriguez', 'Martinez'];
12
+ return Array.from({ length: 25 }, (_, index) => ({
13
+ id: index + 1,
14
+ name: `${firstNames[index % firstNames.length]} ${lastNames[index % lastNames.length]}`,
15
+ email: `user${index + 1}@example.com`,
16
+ department: departments[index % departments.length],
17
+ salary: 50000 + (index * 5000),
18
+ isActive: Math.random() > 0.3,
19
+ }));
20
+ };
21
+ const sampleData = generateSampleData();
22
+ const columns = [
23
+ {
24
+ accessorKey: 'name',
25
+ header: 'Name',
26
+ size: 150,
27
+ },
28
+ {
29
+ accessorKey: 'email',
30
+ header: 'Email',
31
+ size: 200,
32
+ },
33
+ {
34
+ accessorKey: 'department',
35
+ header: 'Department',
36
+ size: 120,
37
+ },
38
+ {
39
+ accessorKey: 'salary',
40
+ header: 'Salary',
41
+ size: 100,
42
+ cell: ({ getValue }) => `$${getValue().toLocaleString()}`,
43
+ },
44
+ {
45
+ accessorKey: 'isActive',
46
+ header: 'Status',
47
+ size: 100,
48
+ cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue() ? 'Active' : 'Inactive', color: getValue() ? 'success' : 'default', size: "small" })),
49
+ },
50
+ ];
51
+ function SelectionTestExample() {
52
+ const [selectMode, setSelectMode] = (0, react_1.useState)('page');
53
+ const [selectionState, setSelectionState] = (0, react_1.useState)({
54
+ ids: [],
55
+ type: 'include',
56
+ });
57
+ const tableRef = (0, react_1.useRef)(null);
58
+ const handleSelectionChange = (0, react_1.useCallback)((newSelectionState) => {
59
+ setSelectionState(newSelectionState);
60
+ }, []);
61
+ const handleSelectAll = (0, react_1.useCallback)(() => {
62
+ var _a;
63
+ (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.selection.selectAll();
64
+ }, []);
65
+ const handleDeselectAll = (0, react_1.useCallback)(() => {
66
+ var _a;
67
+ (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.selection.deselectAll();
68
+ }, []);
69
+ const handleSelectFirst5 = (0, react_1.useCallback)(() => {
70
+ const firstFiveIds = sampleData.slice(0, 5).map(user => user.id.toString());
71
+ firstFiveIds.forEach(id => {
72
+ var _a;
73
+ (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.selection.selectRow(id);
74
+ });
75
+ }, []);
76
+ const handleToggleRow = (0, react_1.useCallback)(() => {
77
+ var _a;
78
+ (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.selection.toggleRowSelection('3');
79
+ }, []);
80
+ const isRowSelectable = (0, react_1.useCallback)(({ row }) => {
81
+ return row.salary <= 100000;
82
+ }, []);
83
+ const selectedCount = selectionState.ids.length;
84
+ const selectedType = selectionState.type;
85
+ 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: "Selection Test Example" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", sx: { mb: 3 }, children: "Test the custom selection feature with different modes and operations. Users with salary > $100,000 are disabled for selection." }), (0, jsx_runtime_1.jsx)(material_1.Paper, { sx: { p: 2, mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsxs)(material_1.FormControl, { size: "small", sx: { minWidth: 120 }, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Selection Mode" }), (0, jsx_runtime_1.jsxs)(material_1.Select, { value: selectMode, label: "Selection Mode", onChange: (e) => setSelectMode(e.target.value), children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "page", children: "Page Mode" }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "all", children: "All Mode" })] })] }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: handleSelectAll, children: "Select All" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: handleDeselectAll, children: "Deselect All" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: handleSelectFirst5, children: "Select First 5" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: handleToggleRow, children: "Toggle User #3" })] }) }), (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: "Current Selection State" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: 2 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Mode:" }), " ", selectMode] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Type:" }), " ", selectedType] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Count:" }), " ", selectedCount] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", sx: { gridColumn: '1 / -1' }, children: [(0, jsx_runtime_1.jsx)("strong", { children: "IDs:" }), " ", selectionState.ids.join(', ') || 'None'] })] })] }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { my: 2 } }), (0, jsx_runtime_1.jsx)(components_1.DataTable, { ref: tableRef, data: sampleData, totalRow: sampleData.length, columns: columns, enableRowSelection: true, enableMultiRowSelection: true, selectMode: selectMode, isRowSelectable: isRowSelectable, onSelectionChange: handleSelectionChange, enablePagination: true, initialState: {
86
+ pagination: {
87
+ pageIndex: 0,
88
+ pageSize: 10,
89
+ },
90
+ }, 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: () => {
91
+ const count = selectionState.type === 'include'
92
+ ? selectionState.ids.length
93
+ : sampleData.length - selectionState.ids.length;
94
+ alert(`Exporting ${count} selected users (${selectionState.type} mode)`);
95
+ }, children: "\uD83D\uDCE4 Export Selected" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", color: "error", onClick: () => {
96
+ const count = selectionState.type === 'include'
97
+ ? selectionState.ids.length
98
+ : sampleData.length - selectionState.ids.length;
99
+ alert(`Would delete ${count} selected users (${selectionState.type} mode)`);
100
+ }, children: "\uD83D\uDDD1\uFE0F Delete Selected" })] })), enableSorting: true, enableGlobalFilter: true, 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: "Test Instructions:" }), (0, jsx_runtime_1.jsx)("br", {}), "1. Try selecting rows in \"Page\" mode, then switch pages - selections should be page-specific", (0, jsx_runtime_1.jsx)("br", {}), "2. Try \"All\" mode and select rows - this works across all pages", (0, jsx_runtime_1.jsx)("br", {}), "3. Note that users with salary > $100k are disabled (grayed out checkboxes)", (0, jsx_runtime_1.jsx)("br", {}), "4. Use the control buttons to test programmatic selection", (0, jsx_runtime_1.jsx)("br", {}), "5. Watch the \"Current Selection State\" panel to see how the selection data changes"] }) })] }));
101
+ }
@@ -0,0 +1 @@
1
+ export declare function SimpleLocalExample(): import("react/jsx-runtime").JSX.Element;