@ackplus/react-tanstack-data-table 1.0.35 → 1.1.1

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 (272) hide show
  1. package/LICENSE +21 -0
  2. package/{src → dist}/index.d.ts +21 -4
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +63 -0
  5. package/{src → dist}/lib/components/droupdown/menu-dropdown.d.ts +2 -1
  6. package/dist/lib/components/droupdown/menu-dropdown.d.ts.map +1 -0
  7. package/{src → dist}/lib/components/droupdown/menu-dropdown.js +38 -7
  8. package/{src → dist}/lib/components/filters/filter-value-input.d.ts +3 -1
  9. package/dist/lib/components/filters/filter-value-input.d.ts.map +1 -0
  10. package/dist/lib/components/filters/filter-value-input.js +83 -0
  11. package/{src → dist}/lib/components/filters/index.d.ts +1 -0
  12. package/dist/lib/components/filters/index.d.ts.map +1 -0
  13. package/dist/lib/components/filters/index.js +142 -0
  14. package/{src → dist}/lib/components/headers/draggable-header.d.ts +2 -2
  15. package/dist/lib/components/headers/draggable-header.d.ts.map +1 -0
  16. package/{src → dist}/lib/components/headers/draggable-header.js +81 -17
  17. package/dist/lib/components/headers/index.d.ts +6 -0
  18. package/dist/lib/components/headers/index.d.ts.map +1 -0
  19. package/dist/lib/components/headers/index.js +21 -0
  20. package/{src → dist}/lib/components/headers/table-header.d.ts +15 -1
  21. package/dist/lib/components/headers/table-header.d.ts.map +1 -0
  22. package/{src → dist}/lib/components/headers/table-header.js +50 -17
  23. package/{src → dist}/lib/components/index.d.ts +6 -1
  24. package/dist/lib/components/index.d.ts.map +1 -0
  25. package/dist/lib/components/index.js +32 -0
  26. package/{src → dist}/lib/components/pagination/data-table-pagination.d.ts +2 -1
  27. package/dist/lib/components/pagination/data-table-pagination.d.ts.map +1 -0
  28. package/{src → dist}/lib/components/pagination/data-table-pagination.js +20 -6
  29. package/dist/lib/components/pagination/index.d.ts +5 -0
  30. package/dist/lib/components/pagination/index.d.ts.map +1 -0
  31. package/dist/lib/components/pagination/index.js +20 -0
  32. package/{src → dist}/lib/components/rows/data-table-row.d.ts +15 -2
  33. package/dist/lib/components/rows/data-table-row.d.ts.map +1 -0
  34. package/{src → dist}/lib/components/rows/data-table-row.js +58 -25
  35. package/{src → dist}/lib/components/rows/empty-data-row.d.ts +3 -3
  36. package/dist/lib/components/rows/empty-data-row.d.ts.map +1 -0
  37. package/{src → dist}/lib/components/rows/empty-data-row.js +12 -4
  38. package/dist/lib/components/rows/index.d.ts +7 -0
  39. package/dist/lib/components/rows/index.d.ts.map +1 -0
  40. package/dist/lib/components/rows/index.js +22 -0
  41. package/{src → dist}/lib/components/rows/loading-rows.d.ts +3 -1
  42. package/dist/lib/components/rows/loading-rows.d.ts.map +1 -0
  43. package/{src → dist}/lib/components/rows/loading-rows.js +27 -19
  44. package/{src → dist}/lib/components/toolbar/bulk-actions-toolbar.d.ts +4 -3
  45. package/dist/lib/components/toolbar/bulk-actions-toolbar.d.ts.map +1 -0
  46. package/dist/lib/components/toolbar/bulk-actions-toolbar.js +49 -0
  47. package/{src → dist}/lib/components/toolbar/column-filter-control.d.ts +3 -1
  48. package/dist/lib/components/toolbar/column-filter-control.d.ts.map +1 -0
  49. package/{src → dist}/lib/components/toolbar/column-filter-control.js +73 -4
  50. package/{src → dist}/lib/components/toolbar/column-pinning-control.d.ts +2 -1
  51. package/dist/lib/components/toolbar/column-pinning-control.d.ts.map +1 -0
  52. package/{src → dist}/lib/components/toolbar/column-pinning-control.js +70 -6
  53. package/{src → dist}/lib/components/toolbar/column-reset-control.d.ts +3 -1
  54. package/dist/lib/components/toolbar/column-reset-control.d.ts.map +1 -0
  55. package/{src → dist}/lib/components/toolbar/column-reset-control.js +9 -2
  56. package/{src → dist}/lib/components/toolbar/column-visibility-control.d.ts +2 -1
  57. package/dist/lib/components/toolbar/column-visibility-control.d.ts.map +1 -0
  58. package/dist/lib/components/toolbar/column-visibility-control.js +77 -0
  59. package/{src → dist}/lib/components/toolbar/data-table-toolbar.d.ts +3 -2
  60. package/dist/lib/components/toolbar/data-table-toolbar.d.ts.map +1 -0
  61. package/{src → dist}/lib/components/toolbar/data-table-toolbar.js +17 -4
  62. package/{src → dist}/lib/components/toolbar/index.d.ts +4 -0
  63. package/dist/lib/components/toolbar/index.d.ts.map +1 -0
  64. package/{src → dist}/lib/components/toolbar/index.js +6 -0
  65. package/dist/lib/components/toolbar/table-export-control.d.ts +12 -0
  66. package/dist/lib/components/toolbar/table-export-control.d.ts.map +1 -0
  67. package/dist/lib/components/toolbar/table-export-control.js +67 -0
  68. package/{src → dist}/lib/components/toolbar/table-search-control.d.ts +3 -1
  69. package/dist/lib/components/toolbar/table-search-control.d.ts.map +1 -0
  70. package/{src → dist}/lib/components/toolbar/table-search-control.js +45 -2
  71. package/{src → dist}/lib/components/toolbar/table-size-control.d.ts +3 -1
  72. package/dist/lib/components/toolbar/table-size-control.d.ts.map +1 -0
  73. package/{src → dist}/lib/components/toolbar/table-size-control.js +20 -8
  74. package/{src → dist}/lib/contexts/data-table-context.d.ts +6 -2
  75. package/dist/lib/contexts/data-table-context.d.ts.map +1 -0
  76. package/{src → dist}/lib/contexts/data-table-context.js +34 -1
  77. package/dist/lib/data-table.d.ts +5 -0
  78. package/dist/lib/data-table.d.ts.map +1 -0
  79. package/{src/lib/components/table → dist/lib}/data-table.js +427 -143
  80. package/dist/lib/features/column-filter.feature.d.ts +55 -0
  81. package/dist/lib/features/column-filter.feature.d.ts.map +1 -0
  82. package/{src → dist}/lib/features/column-filter.feature.js +116 -18
  83. package/dist/lib/features/index.d.ts +9 -0
  84. package/dist/lib/features/index.d.ts.map +1 -0
  85. package/{src → dist}/lib/features/index.js +7 -0
  86. package/{src → dist}/lib/features/selection.feature.d.ts +8 -1
  87. package/dist/lib/features/selection.feature.d.ts.map +1 -0
  88. package/{src → dist}/lib/features/selection.feature.js +76 -15
  89. package/dist/lib/icons/add-icon.d.ts +4 -0
  90. package/dist/lib/icons/add-icon.d.ts.map +1 -0
  91. package/dist/lib/icons/add-icon.js +12 -0
  92. package/dist/lib/icons/csv-icon.d.ts +4 -0
  93. package/dist/lib/icons/csv-icon.d.ts.map +1 -0
  94. package/dist/lib/icons/csv-icon.js +12 -0
  95. package/dist/lib/icons/delete-icon.d.ts +4 -0
  96. package/dist/lib/icons/delete-icon.d.ts.map +1 -0
  97. package/dist/lib/icons/delete-icon.js +12 -0
  98. package/dist/lib/icons/excel-icon.d.ts +4 -0
  99. package/dist/lib/icons/excel-icon.d.ts.map +1 -0
  100. package/dist/lib/icons/excel-icon.js +12 -0
  101. package/dist/lib/icons/index.d.ts +8 -0
  102. package/dist/lib/icons/index.d.ts.map +1 -0
  103. package/dist/lib/icons/unpin-icon.d.ts +4 -0
  104. package/dist/lib/icons/unpin-icon.d.ts.map +1 -0
  105. package/dist/lib/icons/unpin-icon.js +12 -0
  106. package/{src → dist}/lib/icons/view-comfortable-icon.d.ts +3 -1
  107. package/dist/lib/icons/view-comfortable-icon.d.ts.map +1 -0
  108. package/dist/lib/icons/view-comfortable-icon.js +12 -0
  109. package/dist/lib/icons/view-compact-icon.d.ts +4 -0
  110. package/dist/lib/icons/view-compact-icon.d.ts.map +1 -0
  111. package/dist/lib/icons/view-compact-icon.js +12 -0
  112. package/{src → dist}/lib/types/column.types.d.ts +10 -1
  113. package/dist/lib/types/column.types.d.ts.map +1 -0
  114. package/{src → dist}/lib/types/data-table-api.d.ts +2 -1
  115. package/dist/lib/types/data-table-api.d.ts.map +1 -0
  116. package/{src/lib/components/table → dist/lib/types}/data-table.types.d.ts +10 -10
  117. package/dist/lib/types/data-table.types.d.ts.map +1 -0
  118. package/{src → dist}/lib/types/export.types.d.ts +38 -0
  119. package/dist/lib/types/export.types.d.ts.map +1 -0
  120. package/dist/lib/types/export.types.js +6 -0
  121. package/{src → dist}/lib/types/index.d.ts +5 -0
  122. package/dist/lib/types/index.d.ts.map +1 -0
  123. package/dist/lib/types/index.js +30 -0
  124. package/{src → dist}/lib/types/slots.types.d.ts +50 -3
  125. package/dist/lib/types/slots.types.d.ts.map +1 -0
  126. package/{src → dist}/lib/types/table.types.d.ts +14 -0
  127. package/dist/lib/types/table.types.d.ts.map +1 -0
  128. package/{src → dist}/lib/utils/column-helpers.d.ts +10 -0
  129. package/dist/lib/utils/column-helpers.d.ts.map +1 -0
  130. package/{src → dist}/lib/utils/column-helpers.js +20 -4
  131. package/{src → dist}/lib/utils/debounced-fetch.utils.d.ts +3 -5
  132. package/dist/lib/utils/debounced-fetch.utils.d.ts.map +1 -0
  133. package/{src → dist}/lib/utils/debounced-fetch.utils.js +12 -6
  134. package/{src → dist}/lib/utils/export-utils.d.ts +13 -0
  135. package/dist/lib/utils/export-utils.d.ts.map +1 -0
  136. package/dist/lib/utils/export-utils.js +252 -0
  137. package/{src → dist}/lib/utils/index.d.ts +4 -0
  138. package/dist/lib/utils/index.d.ts.map +1 -0
  139. package/dist/lib/utils/index.js +35 -0
  140. package/{src → dist}/lib/utils/logger.d.ts +43 -0
  141. package/dist/lib/utils/logger.d.ts.map +1 -0
  142. package/{src → dist}/lib/utils/logger.js +22 -2
  143. package/{src → dist}/lib/utils/slot-helpers.d.ts +39 -1
  144. package/dist/lib/utils/slot-helpers.d.ts.map +1 -0
  145. package/{src → dist}/lib/utils/slot-helpers.js +55 -6
  146. package/{src → dist}/lib/utils/special-columns.utils.d.ts +10 -0
  147. package/dist/lib/utils/special-columns.utils.d.ts.map +1 -0
  148. package/{src → dist}/lib/utils/special-columns.utils.js +41 -5
  149. package/{src → dist}/lib/utils/styling-helpers.d.ts +20 -0
  150. package/dist/lib/utils/styling-helpers.d.ts.map +1 -0
  151. package/dist/lib/utils/styling-helpers.js +108 -0
  152. package/{src → dist}/lib/utils/table-helpers.d.ts +25 -0
  153. package/dist/lib/utils/table-helpers.d.ts.map +1 -0
  154. package/{src → dist}/lib/utils/table-helpers.js +24 -0
  155. package/package.json +36 -11
  156. package/src/index.ts +71 -0
  157. package/src/lib/components/droupdown/menu-dropdown.tsx +97 -0
  158. package/src/lib/components/filters/filter-value-input.tsx +225 -0
  159. package/src/lib/components/filters/{index.js → index.ts} +3 -6
  160. package/src/lib/components/headers/draggable-header.tsx +326 -0
  161. package/src/lib/components/headers/{index.d.ts → index.ts} +4 -0
  162. package/src/lib/components/headers/table-header.tsx +173 -0
  163. package/src/lib/components/index.ts +21 -0
  164. package/src/lib/components/pagination/data-table-pagination.tsx +99 -0
  165. package/src/lib/components/pagination/index.ts +5 -0
  166. package/src/lib/components/rows/data-table-row.tsx +208 -0
  167. package/src/lib/components/rows/empty-data-row.tsx +69 -0
  168. package/src/lib/components/rows/{index.d.ts → index.ts} +4 -0
  169. package/src/lib/components/rows/loading-rows.tsx +160 -0
  170. package/src/lib/components/toolbar/bulk-actions-toolbar.tsx +125 -0
  171. package/src/lib/components/toolbar/column-filter-control.tsx +374 -0
  172. package/src/lib/components/toolbar/column-pinning-control.tsx +275 -0
  173. package/src/lib/components/toolbar/column-reset-control.tsx +74 -0
  174. package/src/lib/components/toolbar/column-visibility-control.tsx +105 -0
  175. package/src/lib/components/toolbar/data-table-toolbar.tsx +229 -0
  176. package/src/lib/components/toolbar/index.ts +17 -0
  177. package/src/lib/components/toolbar/table-export-control.tsx +179 -0
  178. package/src/lib/components/toolbar/table-search-control.tsx +155 -0
  179. package/src/lib/components/toolbar/table-size-control.tsx +102 -0
  180. package/src/lib/contexts/data-table-context.tsx +112 -0
  181. package/src/lib/data-table.tsx +1911 -0
  182. package/src/lib/features/README.md +161 -0
  183. package/src/lib/features/column-filter.feature.ts +456 -0
  184. package/src/lib/features/index.ts +23 -0
  185. package/src/lib/features/selection.feature.ts +318 -0
  186. package/src/lib/icons/add-icon.tsx +23 -0
  187. package/src/lib/icons/csv-icon.tsx +15 -0
  188. package/src/lib/icons/delete-icon.tsx +30 -0
  189. package/src/lib/icons/excel-icon.tsx +15 -0
  190. package/src/lib/icons/unpin-icon.tsx +18 -0
  191. package/src/lib/icons/view-comfortable-icon.tsx +45 -0
  192. package/src/lib/icons/view-compact-icon.tsx +55 -0
  193. package/src/lib/types/column.types.ts +44 -0
  194. package/src/lib/types/data-table-api.ts +169 -0
  195. package/src/lib/types/data-table.types.ts +139 -0
  196. package/src/lib/types/export.types.ts +154 -0
  197. package/src/lib/types/index.ts +22 -0
  198. package/src/lib/types/slots.types.ts +332 -0
  199. package/src/lib/types/table.types.ts +90 -0
  200. package/src/lib/utils/column-helpers.ts +72 -0
  201. package/src/lib/utils/debounced-fetch.utils.ts +54 -0
  202. package/src/lib/utils/export-utils.ts +285 -0
  203. package/src/lib/utils/index.ts +27 -0
  204. package/src/lib/utils/logger.ts +203 -0
  205. package/src/lib/utils/slot-helpers.tsx +194 -0
  206. package/src/lib/utils/special-columns.utils.ts +94 -0
  207. package/src/lib/utils/styling-helpers.ts +126 -0
  208. package/src/lib/utils/table-helpers.ts +106 -0
  209. package/src/index.js +0 -27
  210. package/src/lib/components/filters/filter-value-input.js +0 -41
  211. package/src/lib/components/headers/index.js +0 -5
  212. package/src/lib/components/index.js +0 -10
  213. package/src/lib/components/pagination/index.d.ts +0 -1
  214. package/src/lib/components/pagination/index.js +0 -4
  215. package/src/lib/components/rows/index.js +0 -6
  216. package/src/lib/components/table/data-table.d.ts +0 -4
  217. package/src/lib/components/table/index.d.ts +0 -2
  218. package/src/lib/components/table/index.js +0 -5
  219. package/src/lib/components/toolbar/bulk-actions-toolbar.js +0 -30
  220. package/src/lib/components/toolbar/column-visibility-control.js +0 -31
  221. package/src/lib/components/toolbar/table-export-control.d.ts +0 -31
  222. package/src/lib/components/toolbar/table-export-control.js +0 -56
  223. package/src/lib/examples/advanced-features-example.d.ts +0 -1
  224. package/src/lib/examples/advanced-features-example.js +0 -269
  225. package/src/lib/examples/bulk-actions-test.d.ts +0 -1
  226. package/src/lib/examples/bulk-actions-test.js +0 -44
  227. package/src/lib/examples/custom-column-filter-example.d.ts +0 -1
  228. package/src/lib/examples/custom-column-filter-example.js +0 -60
  229. package/src/lib/examples/index.d.ts +0 -8
  230. package/src/lib/examples/index.js +0 -19
  231. package/src/lib/examples/selection-test-example.d.ts +0 -1
  232. package/src/lib/examples/selection-test-example.js +0 -101
  233. package/src/lib/examples/server-side-fetching-example.d.ts +0 -1
  234. package/src/lib/examples/server-side-fetching-example.js +0 -245
  235. package/src/lib/examples/server-side-test.d.ts +0 -1
  236. package/src/lib/examples/server-side-test.js +0 -9
  237. package/src/lib/examples/simple-local-example.d.ts +0 -1
  238. package/src/lib/examples/simple-local-example.js +0 -95
  239. package/src/lib/examples/simple-slots-example.d.ts +0 -1
  240. package/src/lib/examples/simple-slots-example.js +0 -115
  241. package/src/lib/features/column-filter.feature.d.ts +0 -45
  242. package/src/lib/features/index.d.ts +0 -2
  243. package/src/lib/hooks/index.d.ts +0 -1
  244. package/src/lib/hooks/index.js +0 -4
  245. package/src/lib/hooks/use-data-table-api.d.ts +0 -46
  246. package/src/lib/hooks/use-data-table-api.js +0 -690
  247. package/src/lib/icons/add-icon.d.ts +0 -2
  248. package/src/lib/icons/add-icon.js +0 -8
  249. package/src/lib/icons/csv-icon.d.ts +0 -2
  250. package/src/lib/icons/csv-icon.js +0 -8
  251. package/src/lib/icons/delete-icon.d.ts +0 -2
  252. package/src/lib/icons/delete-icon.js +0 -8
  253. package/src/lib/icons/excel-icon.d.ts +0 -2
  254. package/src/lib/icons/excel-icon.js +0 -8
  255. package/src/lib/icons/unpin-icon.d.ts +0 -2
  256. package/src/lib/icons/unpin-icon.js +0 -8
  257. package/src/lib/icons/view-comfortable-icon.js +0 -8
  258. package/src/lib/icons/view-compact-icon.d.ts +0 -2
  259. package/src/lib/icons/view-compact-icon.js +0 -8
  260. package/src/lib/types/export.types.js +0 -2
  261. package/src/lib/types/index.js +0 -8
  262. package/src/lib/utils/export-utils.js +0 -175
  263. package/src/lib/utils/index.js +0 -11
  264. package/src/lib/utils/styling-helpers.js +0 -70
  265. package/tsconfig.tsbuildinfo +0 -1
  266. /package/{src → dist}/lib/icons/index.js +0 -0
  267. /package/{src → dist}/lib/types/column.types.js +0 -0
  268. /package/{src → dist}/lib/types/data-table-api.js +0 -0
  269. /package/{src/lib/components/table → dist/lib/types}/data-table.types.js +0 -0
  270. /package/{src → dist}/lib/types/slots.types.js +0 -0
  271. /package/{src → dist}/lib/types/table.types.js +0 -0
  272. /package/src/lib/icons/{index.d.ts → index.ts} +0 -0
@@ -1,101 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export declare function ServerSideFetchingExample(): import("react/jsx-runtime").JSX.Element;
@@ -1,245 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerSideFetchingExample = ServerSideFetchingExample;
4
- const tslib_1 = require("tslib");
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const material_1 = require("@mui/material");
8
- const data_table_1 = require("../components/table/data-table");
9
- const types_1 = require("../types");
10
- const MOCK_EMPLOYEES = Array.from({ length: 1000 }, (_, index) => {
11
- const departments = ['Engineering', 'Marketing', 'Sales', 'HR', 'Finance', 'Operations'];
12
- const roles = ['Manager', 'Senior', 'Junior', 'Lead', 'Director', 'Specialist'];
13
- const firstNames = ['John', 'Jane', 'Bob', 'Alice', 'Charlie', 'Diana', 'Eve', 'Frank', 'Grace', 'Henry'];
14
- const lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis', 'Rodriguez', 'Martinez'];
15
- const firstName = firstNames[Math.floor(Math.random() * firstNames.length)];
16
- const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
17
- return {
18
- id: index + 1,
19
- name: `${firstName} ${lastName}`,
20
- email: `${firstName.toLowerCase()}.${lastName.toLowerCase()}@company.com`,
21
- department: departments[Math.floor(Math.random() * departments.length)],
22
- role: roles[Math.floor(Math.random() * roles.length)],
23
- salary: Math.floor(Math.random() * 80000) + 40000,
24
- isActive: Math.random() > 0.15,
25
- joinDate: new Date(2020 + Math.floor(Math.random() * 4), Math.floor(Math.random() * 12), Math.floor(Math.random() * 28) + 1).toISOString().split('T')[0],
26
- };
27
- });
28
- function ServerSideFetchingExample() {
29
- const [loading, setLoading] = (0, react_1.useState)(false);
30
- const [error, setError] = (0, react_1.useState)(null);
31
- const [selectionInfo, setSelectionInfo] = (0, react_1.useState)(null);
32
- const [lastFetchParams, setLastFetchParams] = (0, react_1.useState)(null);
33
- const [fetchCount, setFetchCount] = (0, react_1.useState)(0);
34
- const [tab, setTab] = (0, react_1.useState)('all');
35
- const apiRef = (0, react_1.useRef)(null);
36
- const handleFetchData = (0, react_1.useCallback)((filters) => tslib_1.__awaiter(this, void 0, void 0, function* () {
37
- var _a, _b, _c;
38
- console.log('🔄 handleFetchData', { filters });
39
- setLoading(true);
40
- setError(null);
41
- setLastFetchParams(filters);
42
- setFetchCount(prev => prev + 1);
43
- try {
44
- yield new Promise(resolve => setTimeout(resolve, 300 + Math.random() * 500));
45
- let filteredData = [...MOCK_EMPLOYEES];
46
- if (filters.globalFilter) {
47
- const searchTerm = filters.globalFilter.toLowerCase();
48
- filteredData = filteredData.filter(employee => employee.name.toLowerCase().includes(searchTerm) ||
49
- employee.email.toLowerCase().includes(searchTerm) ||
50
- employee.department.toLowerCase().includes(searchTerm) ||
51
- employee.role.toLowerCase().includes(searchTerm));
52
- }
53
- if ((_b = (_a = filters.columnFilter) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.length) {
54
- filteredData = filteredData.filter(employee => {
55
- return filters.columnFilter.filters.every((filter) => {
56
- const value = employee[filter.columnId];
57
- const filterValue = filter.value;
58
- switch (filter.operator) {
59
- case 'equals':
60
- return value === filterValue;
61
- case 'contains':
62
- return String(value).toLowerCase().includes(String(filterValue).toLowerCase());
63
- case 'startsWith':
64
- return String(value).toLowerCase().startsWith(String(filterValue).toLowerCase());
65
- case 'endsWith':
66
- return String(value).toLowerCase().endsWith(String(filterValue).toLowerCase());
67
- case 'greaterThan':
68
- return Number(value) > Number(filterValue);
69
- case 'lessThan':
70
- return Number(value) < Number(filterValue);
71
- default:
72
- return true;
73
- }
74
- });
75
- });
76
- }
77
- if ((_c = filters.sorting) === null || _c === void 0 ? void 0 : _c.length) {
78
- filteredData.sort((a, b) => {
79
- for (const sort of filters.sorting) {
80
- const aValue = a[sort.id];
81
- const bValue = b[sort.id];
82
- let comparison = 0;
83
- if (aValue < bValue)
84
- comparison = -1;
85
- else if (aValue > bValue)
86
- comparison = 1;
87
- if (comparison !== 0) {
88
- return sort.desc ? -comparison : comparison;
89
- }
90
- }
91
- return 0;
92
- });
93
- }
94
- const total = filteredData.length;
95
- let pageData = filteredData;
96
- if (filters.pagination) {
97
- const { pageIndex = 0, pageSize = 10 } = filters.pagination;
98
- const start = pageIndex * pageSize;
99
- const end = start + pageSize;
100
- pageData = filteredData.slice(start, end);
101
- }
102
- return {
103
- data: pageData,
104
- total: total,
105
- };
106
- }
107
- catch (err) {
108
- console.error('❌ Error fetching data:', err);
109
- setError('Failed to fetch data. Please try again.');
110
- throw err;
111
- }
112
- finally {
113
- setLoading(false);
114
- }
115
- }), [tab]);
116
- const handleSelectionChange = (0, react_1.useCallback)((selection) => {
117
- setSelectionInfo(selection);
118
- }, []);
119
- (0, react_1.useEffect)(() => {
120
- var _a;
121
- if (tab) {
122
- console.log('🔄 Refreshing data');
123
- (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.data.refresh();
124
- }
125
- }, [tab]);
126
- const handleServerExport = (0, react_1.useCallback)((filters, selection) => tslib_1.__awaiter(this, void 0, void 0, function* () {
127
- console.log('📤 Exporting data with filters:', filters);
128
- console.log('📤 Export selection:', selection);
129
- yield new Promise(resolve => setTimeout(resolve, 1000));
130
- let exportData = [...MOCK_EMPLOYEES];
131
- if (filters === null || filters === void 0 ? void 0 : filters.globalFilter) {
132
- const searchTerm = filters.globalFilter.toLowerCase();
133
- exportData = exportData.filter(employee => employee.name.toLowerCase().includes(searchTerm) ||
134
- employee.email.toLowerCase().includes(searchTerm) ||
135
- employee.department.toLowerCase().includes(searchTerm) ||
136
- employee.role.toLowerCase().includes(searchTerm));
137
- }
138
- if (selection.type === 'include' && selection.ids.length > 0) {
139
- exportData = exportData.filter(employee => selection.ids.includes(employee.id.toString()));
140
- }
141
- else if (selection.type === 'exclude' && selection.ids.length > 0) {
142
- exportData = exportData.filter(employee => !selection.ids.includes(employee.id.toString()));
143
- }
144
- return {
145
- data: exportData,
146
- total: exportData.length,
147
- };
148
- }), []);
149
- const columns = [
150
- {
151
- id: 'name',
152
- accessorKey: 'name',
153
- header: 'Name',
154
- enableGlobalFilter: true,
155
- },
156
- {
157
- id: 'email',
158
- accessorKey: 'email',
159
- header: 'Email',
160
- enableGlobalFilter: true,
161
- },
162
- {
163
- id: 'department',
164
- accessorKey: 'department',
165
- header: 'Department',
166
- enableGlobalFilter: true,
167
- },
168
- {
169
- id: 'role',
170
- accessorKey: 'role',
171
- header: 'Role',
172
- enableGlobalFilter: true,
173
- },
174
- {
175
- id: 'salary',
176
- accessorKey: 'salary',
177
- header: 'Salary',
178
- accessorFn: (row) => `$${row.salary.toLocaleString()}`,
179
- hideInExport: true,
180
- },
181
- {
182
- id: 'isActive',
183
- accessorKey: 'isActive',
184
- header: 'Status',
185
- accessorFn: (row) => row.isActive ? 'Active' : 'Inactive',
186
- cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue() ? 'Active' : 'Inactive', color: getValue() ? 'success' : 'default', size: "small" })),
187
- },
188
- {
189
- id: 'joinDate',
190
- accessorKey: 'joinDate',
191
- header: 'Join Date',
192
- accessorFn: (row) => new Date(row.joinDate).toLocaleDateString(),
193
- },
194
- ];
195
- 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: "Server-Side Data Fetching Example" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", paragraph: true, children: "Demonstrates server-side data fetching with proper API ref state management and page-based selection. The Salary column has `hideInExport: true` so it will be excluded from exports." }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => setTab('all'), children: "All" }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => setTab('active'), children: "Active" }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => setTab('inactive'), children: "Inactive" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, sx: { mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: "primary", children: fetchCount }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "API Calls Made" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: "secondary", children: (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.ids.length) || 0 }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Selected Items" })] }) }), (0, jsx_runtime_1.jsx)(material_1.Card, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { sx: { pb: 2 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", color: loading ? 'warning.main' : 'success.main', children: loading ? 'Loading...' : 'Ready' }), loading && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 16 })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: "Server Status" })] }) })] }), error && ((0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { mb: 3 }, children: error })), (0, jsx_runtime_1.jsx)(material_1.Card, { sx: { mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "API Controls (via apiRef)" }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
196
- var _a;
197
- const state = (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.selection.getSelectionState();
198
- console.log('Current Selection State:', state);
199
- alert(`Selection: ${JSON.stringify(state, null, 2)}`);
200
- }, children: "Get Selection State" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
201
- var _a;
202
- const count = (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.selection.getSelectedCount();
203
- console.log('Selected Count:', count);
204
- alert(`Selected Count: ${count}`);
205
- }, children: "Get Selected Count" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
206
- var _a;
207
- (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.selection.selectAll();
208
- console.log('Selected all rows on current page');
209
- }, children: "Select All (Page)" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
210
- var _a;
211
- (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.selection.deselectAll();
212
- console.log('Deselected all rows');
213
- }, children: "Deselect All" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
214
- var _a;
215
- (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.data.refresh();
216
- console.log('Refreshed data');
217
- }, children: "Refresh Data" })] })] }) }), selectionInfo && ((0, jsx_runtime_1.jsx)(material_1.Card, { sx: { mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Current Selection Info" }), (0, jsx_runtime_1.jsx)(material_1.Paper, { sx: { p: 2, bgcolor: 'grey.50' }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 1, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Selection Type:" }), " ", selectionInfo.type] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Selected IDs:" }), " [", selectionInfo.ids.join(', '), "]"] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Count:" }), " ", selectionInfo.ids.length] })] }) })] }) })), (0, jsx_runtime_1.jsx)(material_1.Card, { sx: { mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Export & Column Configuration" }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "hideInExport Demo:" }), " The Salary column has `hideInExport: true` so it will be excluded from CSV/Excel exports. Try exporting to see the difference!"] }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 1, children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Exportable columns:" }), " Name, Email, Department, Role, Status, Join Date"] }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", color: "warning.main", children: [(0, jsx_runtime_1.jsx)("strong", { children: "Hidden from export:" }), " Salary (contains sensitive data)"] })] })] }) }), lastFetchParams && ((0, jsx_runtime_1.jsx)(material_1.Card, { sx: { mb: 3 }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Last Fetch Parameters" }), (0, jsx_runtime_1.jsx)(material_1.Paper, { sx: { p: 2, bgcolor: 'grey.50' }, children: (0, jsx_runtime_1.jsx)("pre", { style: { fontSize: '12px', margin: 0, overflow: 'auto' }, children: JSON.stringify(lastFetchParams, null, 2) }) })] }) })), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { mb: 3 } }), (0, jsx_runtime_1.jsx)(data_table_1.DataTable, { ref: apiRef, columns: columns, dataMode: "server", initialLoadData: true, onFetchData: handleFetchData, loading: loading, enableRowSelection: true, enableMultiRowSelection: true, selectMode: "page", onSelectionChange: handleSelectionChange, enableColumnPinning: true, enableColumnResizing: true, enableColumnDragging: true, enableBulkActions: true, bulkActions: (selectionState) => ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, children: [(0, jsx_runtime_1.jsxs)(material_1.Button, { variant: "contained", size: "small", color: "error", onClick: () => {
218
- console.log('Bulk delete action triggered');
219
- console.log('Selection state:', selectionState);
220
- alert(`Would delete ${selectionState.ids.length} items`);
221
- }, children: ["Delete Selected (", selectionState.ids.length, ")"] }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", onClick: () => {
222
- console.log('Bulk update action triggered');
223
- console.log('Selection state:', selectionState);
224
- alert(`Would update ${selectionState.ids.length} items`);
225
- }, children: "Update Selected" })] })), enableGlobalFilter: true, enableColumnFilter: true, enableSorting: true, enablePagination: true, initialState: {
226
- pagination: {
227
- pageIndex: 0,
228
- pageSize: 50,
229
- },
230
- columnPinning: {
231
- left: [types_1.DEFAULT_SELECTION_COLUMN_NAME],
232
- right: [],
233
- },
234
- }, enableExport: true, exportFilename: "employees", onServerExport: handleServerExport, onExportProgress: (progress) => {
235
- console.log('Export progress:', progress);
236
- }, onExportComplete: (result) => {
237
- console.log('Export completed:', result);
238
- }, onExportError: (error) => {
239
- console.error('Export error:', error);
240
- }, enableHover: true, enableStripes: true, tableSize: "medium", enableColumnVisibility: true, enableTableSizeControl: true, enableReset: true, emptyMessage: "No employees found matching your criteria", skeletonRows: 10, slotProps: {
241
- pagination: {
242
- rowsPerPageOptions: [5, 10, 20, 50, 100, 200],
243
- },
244
- } })] }));
245
- }
@@ -1 +0,0 @@
1
- export declare function ServerSideTest(): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerSideTest = ServerSideTest;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const material_1 = require("@mui/material");
6
- const server_side_fetching_example_1 = require("./server-side-fetching-example");
7
- function ServerSideTest() {
8
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { p: 2 }, children: (0, jsx_runtime_1.jsxs)(material_1.Paper, { sx: { p: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", gutterBottom: true, children: "Server-Side Data Fetching Test" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", paragraph: true, children: "This example demonstrates how to use the DataTable component with server-side data fetching. The onFetchData callback handles all server operations including filtering, sorting, and pagination." }), (0, jsx_runtime_1.jsx)(server_side_fetching_example_1.ServerSideFetchingExample, {})] }) }));
9
- }
@@ -1 +0,0 @@
1
- export declare function SimpleLocalExample(): import("react/jsx-runtime").JSX.Element;
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SimpleLocalExample = SimpleLocalExample;
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 products = [
9
- { id: 1, name: 'Laptop Pro', category: 'Electronics', price: 1299, inStock: true, rating: 4.5 },
10
- { id: 2, name: 'Wireless Mouse', category: 'Electronics', price: 29, inStock: true, rating: 4.2 },
11
- { id: 3, name: 'Coffee Mug', category: 'Kitchen', price: 12, inStock: false, rating: 4.8 },
12
- { id: 4, name: 'Desk Chair', category: 'Furniture', price: 189, inStock: true, rating: 4.0 },
13
- { id: 5, name: 'Notebook Set', category: 'Office', price: 15, inStock: true, rating: 4.3 },
14
- { id: 6, name: 'Water Bottle', category: 'Kitchen', price: 22, inStock: true, rating: 4.7 },
15
- { id: 7, name: 'Monitor Stand', category: 'Electronics', price: 45, inStock: false, rating: 4.1 },
16
- { id: 8, name: 'Pen Set', category: 'Office', price: 8, inStock: true, rating: 3.9 },
17
- { id: 9, name: 'Table Lamp', category: 'Furniture', price: 67, inStock: true, rating: 4.4 },
18
- { id: 10, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
19
- { id: 11, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
20
- { id: 12, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
21
- { id: 13, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
22
- { id: 14, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
23
- { id: 15, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
24
- { id: 16, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
25
- { id: 17, name: 'Phone Case', category: 'Electronics', price: 25, inStock: true, rating: 4.6 },
26
- ];
27
- const columns = [
28
- {
29
- accessorKey: 'name',
30
- header: 'Product Name',
31
- },
32
- {
33
- accessorKey: 'category',
34
- header: 'Category',
35
- cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue(), size: "small", variant: "outlined", color: "primary" })),
36
- },
37
- {
38
- accessorKey: 'price',
39
- header: 'Price',
40
- cell: ({ getValue }) => `$${getValue().toFixed(2)}`,
41
- },
42
- {
43
- accessorKey: 'inStock',
44
- header: 'In Stock',
45
- cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue() ? 'Yes' : 'No', color: getValue() ? 'success' : 'error', size: "small" })),
46
- },
47
- {
48
- accessorKey: 'rating',
49
- header: 'Rating',
50
- size: 100,
51
- minSize: 100,
52
- maxSize: 100,
53
- cell: ({ getValue }) => `⭐ ${getValue().toFixed(1)}`,
54
- },
55
- ];
56
- function SimpleLocalExample() {
57
- const bulkActions = (0, react_1.useCallback)((selectionState) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: 1 }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => {
58
- const count = selectionState.type === 'include'
59
- ? selectionState.ids.length
60
- : products.length - selectionState.ids.length;
61
- alert(`Selected ${count} products (${selectionState.type} mode)`);
62
- }, style: {
63
- padding: '8px 16px',
64
- borderRadius: '4px',
65
- border: '1px solid #ccc',
66
- background: '#f5f5f5',
67
- cursor: 'pointer'
68
- }, children: "\uD83D\uDCCA Show Count" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
69
- let selectedProducts;
70
- if (selectionState.type === 'include') {
71
- selectedProducts = products.filter(p => selectionState.ids.includes(p.id.toString()));
72
- }
73
- else {
74
- selectedProducts = products.filter(p => !selectionState.ids.includes(p.id.toString()));
75
- }
76
- const total = selectedProducts.reduce((sum, product) => sum + product.price, 0);
77
- alert(`Total value: $${total.toFixed(2)}`);
78
- }, style: {
79
- padding: '8px 16px',
80
- borderRadius: '4px',
81
- border: '1px solid #ccc',
82
- background: '#f5f5f5',
83
- cursor: 'pointer'
84
- }, children: "\uD83D\uDCB0 Calculate Total" })] })), []);
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: "Simple Local Data Example" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", color: "text.secondary", sx: { mb: 3 }, children: "A basic example using static local data with no API calls. Demonstrates essential DataTable features with minimal setup." }), (0, jsx_runtime_1.jsx)(components_1.DataTable, { data: products, totalRow: products.length, columns: columns, enableSorting: true, enableGlobalFilter: true, enableColumnFilter: true, enableColumnResizing: true, enableRowSelection: true, enableBulkActions: true, bulkActions: bulkActions, fitToScreen: true, initialState: {
86
- pagination: {
87
- pageIndex: 0,
88
- pageSize: 5,
89
- },
90
- }, slotProps: {
91
- pagination: {
92
- rowsPerPageOptions: [5, 10, 20, 30, 40, 50],
93
- },
94
- } }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { mt: 2, p: 2, backgroundColor: 'grey.50', borderRadius: 1 }, children: (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "body2", color: "text.secondary", children: ["\uD83D\uDCA1 ", (0, jsx_runtime_1.jsx)("strong", { children: "This example demonstrates:" }), (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Basic table with static local data", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Simple column definitions with custom cell renderers", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Sorting, filtering, and pagination", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Row selection with bulk actions", (0, jsx_runtime_1.jsx)("br", {}), "\u2022 Minimal setup - perfect for getting started"] }) })] }));
95
- }
@@ -1 +0,0 @@
1
- export declare function SimpleEnhancedSlotsExample(): import("react/jsx-runtime").JSX.Element;
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SimpleEnhancedSlotsExample = SimpleEnhancedSlotsExample;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const material_1 = require("@mui/material");
6
- const icons_material_1 = require("@mui/icons-material");
7
- const data_table_1 = require("../components/table/data-table");
8
- const sampleData = [
9
- { id: 1, name: 'John Doe', email: 'john@example.com', status: 'active' },
10
- { id: 2, name: 'Jane Smith', email: 'jane@example.com', status: 'active' },
11
- { id: 3, name: 'Bob Johnson', email: 'bob@example.com', status: 'inactive' },
12
- ];
13
- const columns = [
14
- { id: 'name', accessorKey: 'name', header: 'Name' },
15
- { id: 'email', accessorKey: 'email', header: 'Email' },
16
- {
17
- id: 'status',
18
- accessorKey: 'status',
19
- header: 'Status',
20
- cell: ({ getValue }) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { label: getValue(), color: getValue() === 'active' ? 'success' : 'default', size: "small" }))
21
- },
22
- ];
23
- const CustomSearchIcon = (props) => ((0, jsx_runtime_1.jsx)(icons_material_1.Star, Object.assign({}, props, { sx: Object.assign({ color: 'warning.main' }, props.sx) })));
24
- const CustomFilterIcon = (props) => ((0, jsx_runtime_1.jsx)(icons_material_1.Favorite, Object.assign({}, props, { sx: Object.assign({ color: 'error.main' }, props.sx) })));
25
- function SimpleEnhancedSlotsExample() {
26
- const theme = (0, material_1.useTheme)();
27
- 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: "Enhanced Slots System" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", paragraph: true, children: "This example demonstrates the key improvements in the enhanced slot system:" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mb: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Key Improvements:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Better Prop Merging:" }), " Special handling for sx, style, and className props"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Full Customization:" }), " Override any component without limitations"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Enhanced Type Safety:" }), " Better TypeScript support with proper typing"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Flexible Props:" }), " Pass any props to slot components"] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Priority System:" }), " User props override slot props override defaults"] })] })] }), (0, jsx_runtime_1.jsx)(data_table_1.DataTable, { data: sampleData, columns: columns, enableGlobalFilter: true, enableColumnVisibility: true, enableColumnFilter: true, slots: {
28
- searchIcon: CustomSearchIcon,
29
- filterIcon: CustomFilterIcon,
30
- }, slotProps: {
31
- searchIcon: {
32
- fontSize: 'large',
33
- sx: {
34
- animation: 'pulse 2s infinite',
35
- '@keyframes pulse': {
36
- '0%': { transform: 'scale(1)' },
37
- '50%': { transform: 'scale(1.1)' },
38
- '100%': { transform: 'scale(1)' },
39
- },
40
- },
41
- },
42
- filterIcon: {
43
- fontSize: 'medium',
44
- sx: {
45
- transform: 'rotate(0deg)',
46
- transition: 'transform 0.3s ease',
47
- '&:hover': {
48
- transform: 'rotate(180deg)',
49
- },
50
- },
51
- },
52
- tableContainer: {
53
- sx: {
54
- maxHeight: '400px',
55
- '&::-webkit-scrollbar': {
56
- width: '8px',
57
- },
58
- '&::-webkit-scrollbar-track': {
59
- backgroundColor: (0, material_1.alpha)(theme.palette.grey[300], 0.5),
60
- borderRadius: '4px',
61
- },
62
- '&::-webkit-scrollbar-thumb': {
63
- backgroundColor: theme.palette.primary.main,
64
- borderRadius: '4px',
65
- '&:hover': {
66
- backgroundColor: theme.palette.primary.dark,
67
- },
68
- },
69
- },
70
- },
71
- toolbar: {
72
- sx: {
73
- background: `linear-gradient(135deg, ${(0, material_1.alpha)(theme.palette.primary.main, 0.1)} 0%, ${(0, material_1.alpha)(theme.palette.secondary.main, 0.1)} 100%)`,
74
- border: `1px solid ${(0, material_1.alpha)(theme.palette.primary.main, 0.2)}`,
75
- borderRadius: 2,
76
- padding: 2,
77
- margin: '0 0 16px 0',
78
- },
79
- },
80
- } }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 4 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", gutterBottom: true, children: "Enhanced Slot Helper Functions:" }), (0, jsx_runtime_1.jsx)(material_1.Box, { component: "pre", sx: {
81
- backgroundColor: 'grey.100',
82
- p: 2,
83
- borderRadius: 1,
84
- fontSize: '0.875rem',
85
- overflow: 'auto',
86
- }, children: `// Enhanced prop merging with special handling
87
- export function mergeSlotProps(
88
- defaultProps = {},
89
- slotProps = {},
90
- userProps = {}
91
- ) {
92
- // Handles sx, style, and className merging
93
- // User props have highest priority
94
- }
95
-
96
- // Enhanced slot component retrieval
97
- export function getSlotComponentWithProps(
98
- slots,
99
- slotProps,
100
- slotName,
101
- fallback,
102
- defaultProps = {}
103
- ) {
104
- return {
105
- component: getSlotComponent(slots, slotName, fallback),
106
- props: mergeSlotProps(defaultProps, slotProps[slotName], {})
107
- };
108
- }
109
-
110
- // Usage in components:
111
- const { component: IconSlot, props: iconProps } =
112
- getSlotComponentWithProps(slots, slotProps, 'searchIcon', DefaultIcon);
113
-
114
- return <IconSlot {...iconProps} />;` })] })] }));
115
- }