@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
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Custom Column Filter Feature for TanStack Table
3
+ *
4
+ * This feature adds advanced column filtering capabilities to TanStack Table
5
+ * following the official custom features pattern introduced in v8.14.0
6
+ */
7
+ import { Table, TableFeature, RowData, Updater, RowModel } from '@tanstack/react-table';
8
+ import type { ColumnFilterState } from '../types/table.types';
9
+ export interface ColumnFilterRule {
10
+ id: string;
11
+ columnId: string;
12
+ operator: string;
13
+ value: any;
14
+ columnType?: string;
15
+ }
16
+ export interface ColumnFilterOptions {
17
+ enableAdvanceColumnFilter?: boolean;
18
+ onColumnFilterChange?: (updater: Updater<ColumnFilterState>) => void;
19
+ onColumnFilterApply?: (state: ColumnFilterState) => void;
20
+ }
21
+ declare module '@tanstack/react-table' {
22
+ interface TableState {
23
+ columnFilter: ColumnFilterState;
24
+ }
25
+ interface TableOptionsResolved<TData extends RowData> {
26
+ enableAdvanceColumnFilter?: boolean;
27
+ onColumnFilterChange?: (updater: Updater<ColumnFilterState>) => void;
28
+ onColumnFilterApply?: (state: ColumnFilterState) => void;
29
+ }
30
+ interface Table<TData extends RowData> {
31
+ setColumnFilterState: (updater: Updater<ColumnFilterState>) => void;
32
+ addPendingColumnFilter: (columnId: string, operator: string, value: any) => void;
33
+ updatePendingColumnFilter: (filterId: string, updates: Partial<ColumnFilterRule>) => void;
34
+ removePendingColumnFilter: (filterId: string) => void;
35
+ clearAllPendingColumnFilters: () => void;
36
+ setPendingFilterLogic: (logic: 'AND' | 'OR') => void;
37
+ applyPendingColumnFilters: () => void;
38
+ addColumnFilter: (columnId: string, operator: string, value: any) => void;
39
+ updateColumnFilter: (filterId: string, updates: Partial<ColumnFilterRule>) => void;
40
+ removeColumnFilter: (filterId: string) => void;
41
+ clearAllColumnFilters: () => void;
42
+ setFilterLogic: (logic: 'AND' | 'OR') => void;
43
+ getActiveColumnFilters: () => ColumnFilterRule[];
44
+ getPendingColumnFilters: () => ColumnFilterRule[];
45
+ getColumnFilterState: () => ColumnFilterState;
46
+ }
47
+ }
48
+ export declare const ColumnFilterFeature: TableFeature<any>;
49
+ /**
50
+ * Utility function to check if a row matches the custom column filters
51
+ * This can be used for client-side filtering
52
+ */
53
+ export declare function matchesCustomColumnFilters(row: any, filters: ColumnFilterRule[], logic?: 'AND' | 'OR'): boolean;
54
+ export declare const getCombinedFilteredRowModel: <TData>() => (table: Table<TData>) => () => RowModel<TData>;
55
+ //# sourceMappingURL=column-filter.feature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-filter.feature.d.ts","sourceRoot":"","sources":["../../../src/lib/features/column-filter.feature.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACH,KAAK,EACL,YAAY,EACZ,OAAO,EACP,OAAO,EAGP,QAAQ,EAGX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAChC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAErE,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC5D;AAGD,OAAO,QAAQ,uBAAuB,CAAC;IACnC,UAAU,UAAU;QAChB,YAAY,EAAE,iBAAiB,CAAC;KACnC;IAED,UAAU,oBAAoB,CAAC,KAAK,SAAS,OAAO;QAChD,yBAAyB,CAAC,EAAE,OAAO,CAAC;QACpC,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;QACrE,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;KAC5D;IAED,UAAU,KAAK,CAAC,KAAK,SAAS,OAAO;QACjC,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;QAGpE,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;QACjF,yBAAyB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;QAC1F,yBAAyB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;QACtD,4BAA4B,EAAE,MAAM,IAAI,CAAC;QACzC,qBAAqB,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;QAGrD,yBAAyB,EAAE,MAAM,IAAI,CAAC;QAGtC,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;QAC1E,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;QACnF,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;QAC/C,qBAAqB,EAAE,MAAM,IAAI,CAAC;QAClC,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;QAG9C,sBAAsB,EAAE,MAAM,gBAAgB,EAAE,CAAC;QACjD,uBAAuB,EAAE,MAAM,gBAAgB,EAAE,CAAC;QAClD,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;KACjD;CACJ;AA8BD,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,GAAG,CAqLjD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,0BAA0B,CACtC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,GAAE,KAAK,GAAG,IAAY,GAC5B,OAAO,CA2BT;AAED,eAAO,MAAM,2BAA2B,GAAI,KAAK,QACrC,OAAO,KAAK,CAAC,KAAK,CAAC,WAAS,QAAQ,CAAC,KAAK,CAsCrD,CAAC"}
@@ -1,27 +1,65 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getCombinedFilteredRowModel = exports.ColumnFilterFeature = void 0;
4
7
  exports.matchesCustomColumnFilters = matchesCustomColumnFilters;
5
- const tslib_1 = require("tslib");
8
+ /**
9
+ * Custom Column Filter Feature for TanStack Table
10
+ *
11
+ * This feature adds advanced column filtering capabilities to TanStack Table
12
+ * following the official custom features pattern introduced in v8.14.0
13
+ */
6
14
  const react_table_1 = require("@tanstack/react-table");
7
- const moment_1 = tslib_1.__importDefault(require("moment"));
15
+ const moment_1 = __importDefault(require("moment"));
16
+ // Table instance methods for custom column filtering
17
+ // export interface ColumnFilterInstance<TData extends RowData> {
18
+ // setColumnFilterState: (updater: Updater<ColumnFilterState>) => void;
19
+ // // Pending filter methods (for draft state)
20
+ // addPendingColumnFilter: (columnId: string, operator: string, value: any) => void;
21
+ // updatePendingColumnFilter: (filterId: string, updates: Partial<ColumnFilterRule>) => void;
22
+ // removePendingColumnFilter: (filterId: string) => void;
23
+ // clearAllPendingColumnFilters: () => void;
24
+ // setPendingFilterLogic: (logic: 'AND' | 'OR') => void;
25
+ // // Apply pending filters to active filters
26
+ // applyPendingColumnFilters: () => void;
27
+ // // Legacy methods (for backward compatibility)
28
+ // addColumnFilter: (columnId: string, operator: string, value: any) => void;
29
+ // updateColumnFilter: (filterId: string, updates: Partial<ColumnFilterRule>) => void;
30
+ // removeColumnFilter: (filterId: string) => void;
31
+ // clearAllColumnFilters: () => void;
32
+ // setFilterLogic: (logic: 'AND' | 'OR') => void;
33
+ // // Getters
34
+ // getActiveColumnFilters: () => ColumnFilterRule[];
35
+ // getPendingColumnFilters: () => ColumnFilterRule[];
36
+ // getColumnFilterState: () => ColumnFilterState;
37
+ // }
38
+ // The custom feature implementation
8
39
  exports.ColumnFilterFeature = {
40
+ // Define the feature's initial state
9
41
  getInitialState: (state) => {
10
- return Object.assign({ columnFilter: {
42
+ return {
43
+ columnFilter: {
11
44
  filters: [],
12
45
  logic: 'AND',
13
46
  pendingFilters: [],
14
47
  pendingLogic: 'AND',
15
- } }, state);
48
+ },
49
+ ...state,
50
+ };
16
51
  },
52
+ // Define the feature's default options
17
53
  getDefaultOptions: (table) => {
18
54
  return {
19
55
  enableAdvanceColumnFilter: true,
20
56
  onColumnFilterChange: (0, react_table_1.makeStateUpdater)('columnFilter', table),
21
- onColumnFilterApply: (state) => {
57
+ onColumnFilterApply: () => {
58
+ // Implementation of onColumnFilterApply
22
59
  },
23
60
  };
24
61
  },
62
+ // Define the feature's table instance methods
25
63
  createTable: (table) => {
26
64
  table.setColumnFilterState = (updater) => {
27
65
  var _a, _b;
@@ -33,6 +71,7 @@ exports.ColumnFilterFeature = {
33
71
  };
34
72
  return (_b = (_a = table.options).onColumnFilterChange) === null || _b === void 0 ? void 0 : _b.call(_a, safeUpdater);
35
73
  };
74
+ // === PENDING FILTER METHODS (Draft state) ===
36
75
  table.addPendingColumnFilter = (columnId, operator, value) => {
37
76
  if (!table.options.enableAdvanceColumnFilter)
38
77
  return;
@@ -43,37 +82,58 @@ exports.ColumnFilterFeature = {
43
82
  operator,
44
83
  value,
45
84
  };
46
- return Object.assign(Object.assign({}, old), { pendingFilters: [...old.pendingFilters, newFilter] });
85
+ return {
86
+ ...old,
87
+ pendingFilters: [...old.pendingFilters, newFilter],
88
+ };
47
89
  });
48
90
  };
49
91
  table.updatePendingColumnFilter = (filterId, updates) => {
50
92
  if (!table.options.enableAdvanceColumnFilter)
51
93
  return;
52
94
  table.setColumnFilterState((old) => {
53
- const updatedFilters = old.pendingFilters.map((filter) => filter.id === filterId ? Object.assign(Object.assign({}, filter), updates) : filter);
54
- return Object.assign(Object.assign({}, old), { pendingFilters: updatedFilters });
95
+ const updatedFilters = old.pendingFilters.map((filter) => filter.id === filterId ? { ...filter, ...updates } : filter);
96
+ return {
97
+ ...old,
98
+ pendingFilters: updatedFilters,
99
+ };
55
100
  });
56
101
  };
57
102
  table.removePendingColumnFilter = (filterId) => {
58
103
  if (!table.options.enableAdvanceColumnFilter)
59
104
  return;
60
- table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { pendingFilters: old.pendingFilters.filter((filter) => filter.id !== filterId) })));
105
+ table.setColumnFilterState((old) => ({
106
+ ...old,
107
+ pendingFilters: old.pendingFilters.filter((filter) => filter.id !== filterId),
108
+ }));
61
109
  };
62
110
  table.clearAllPendingColumnFilters = () => {
63
111
  if (!table.options.enableAdvanceColumnFilter)
64
112
  return;
65
- table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { pendingFilters: [] })));
113
+ table.setColumnFilterState((old) => ({
114
+ ...old,
115
+ pendingFilters: [],
116
+ }));
66
117
  };
67
118
  table.setPendingFilterLogic = (logic) => {
68
119
  if (!table.options.enableAdvanceColumnFilter)
69
120
  return;
70
- table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { pendingLogic: logic })));
121
+ table.setColumnFilterState((old) => ({
122
+ ...old,
123
+ pendingLogic: logic,
124
+ }));
71
125
  };
126
+ // === APPLY PENDING FILTERS ===
72
127
  table.applyPendingColumnFilters = () => {
73
128
  if (!table.options.enableAdvanceColumnFilter)
74
129
  return;
75
130
  table.setColumnFilterState((old) => {
76
- const newState = Object.assign(Object.assign({}, old), { filters: [...old.pendingFilters], logic: old.pendingLogic });
131
+ const newState = {
132
+ ...old,
133
+ filters: [...old.pendingFilters],
134
+ logic: old.pendingLogic,
135
+ };
136
+ // Call the apply callback after state update
77
137
  setTimeout(() => {
78
138
  var _a, _b;
79
139
  (_b = (_a = table.options).onColumnFilterApply) === null || _b === void 0 ? void 0 : _b.call(_a, newState);
@@ -81,9 +141,11 @@ exports.ColumnFilterFeature = {
81
141
  return newState;
82
142
  });
83
143
  };
144
+ // === LEGACY METHODS (for backward compatibility) ===
84
145
  table.addColumnFilter = (columnId, operator, value) => {
85
146
  if (!table.options.enableAdvanceColumnFilter)
86
147
  return;
148
+ // For backward compatibility, add directly to active filters
87
149
  table.setColumnFilterState((old) => {
88
150
  const newFilter = {
89
151
  id: `filter_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
@@ -91,32 +153,48 @@ exports.ColumnFilterFeature = {
91
153
  operator,
92
154
  value,
93
155
  };
94
- return Object.assign(Object.assign({}, old), { filters: [...old.filters, newFilter] });
156
+ return {
157
+ ...old,
158
+ filters: [...old.filters, newFilter],
159
+ };
95
160
  });
96
161
  };
97
162
  table.updateColumnFilter = (filterId, updates) => {
98
163
  if (!table.options.enableAdvanceColumnFilter)
99
164
  return;
100
165
  table.setColumnFilterState((old) => {
101
- const updatedFilters = old.filters.map((filter) => filter.id === filterId ? Object.assign(Object.assign({}, filter), updates) : filter);
102
- return Object.assign(Object.assign({}, old), { filters: updatedFilters });
166
+ const updatedFilters = old.filters.map((filter) => filter.id === filterId ? { ...filter, ...updates } : filter);
167
+ return {
168
+ ...old,
169
+ filters: updatedFilters,
170
+ };
103
171
  });
104
172
  };
105
173
  table.removeColumnFilter = (filterId) => {
106
174
  if (!table.options.enableAdvanceColumnFilter)
107
175
  return;
108
- table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { filters: old.filters.filter((filter) => filter.id !== filterId) })));
176
+ table.setColumnFilterState((old) => ({
177
+ ...old,
178
+ filters: old.filters.filter((filter) => filter.id !== filterId),
179
+ }));
109
180
  };
110
181
  table.clearAllColumnFilters = () => {
111
182
  if (!table.options.enableAdvanceColumnFilter)
112
183
  return;
113
- table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { filters: [] })));
184
+ table.setColumnFilterState((old) => ({
185
+ ...old,
186
+ filters: [],
187
+ }));
114
188
  };
115
189
  table.setFilterLogic = (logic) => {
116
190
  if (!table.options.enableAdvanceColumnFilter)
117
191
  return;
118
- table.setColumnFilterState((old) => (Object.assign(Object.assign({}, old), { logic })));
192
+ table.setColumnFilterState((old) => ({
193
+ ...old,
194
+ logic,
195
+ }));
119
196
  };
197
+ // === GETTERS ===
120
198
  table.getActiveColumnFilters = () => {
121
199
  const state = table.getState().columnFilter;
122
200
  return state.filters.filter((f) => f.columnId && f.operator);
@@ -130,6 +208,10 @@ exports.ColumnFilterFeature = {
130
208
  };
131
209
  },
132
210
  };
211
+ /**
212
+ * Utility function to check if a row matches the custom column filters
213
+ * This can be used for client-side filtering
214
+ */
133
215
  function matchesCustomColumnFilters(row, filters, logic = 'AND') {
134
216
  if (filters.length === 0)
135
217
  return true;
@@ -141,9 +223,11 @@ function matchesCustomColumnFilters(row, filters, logic = 'AND') {
141
223
  let columnValue;
142
224
  let columnType = filter.columnType || 'text';
143
225
  try {
226
+ // Try to get the value safely to avoid infinite loops
144
227
  const column = row.getAllCells().find((cell) => cell.column.id === filter.columnId);
145
228
  if (column) {
146
229
  columnValue = column.getValue();
230
+ // Try to get type from columnDef if not set
147
231
  if (!filter.columnType && column.column.columnDef && column.column.columnDef.type) {
148
232
  columnType = column.column.columnDef.type;
149
233
  }
@@ -160,6 +244,11 @@ function matchesCustomColumnFilters(row, filters, logic = 'AND') {
160
244
  const getCombinedFilteredRowModel = () => {
161
245
  return (table) => () => {
162
246
  var _a;
247
+ // Respect server/manual filtering: skip client filtering when manualFiltering is enabled
248
+ if (table.options.manualFiltering) {
249
+ return table.getCoreRowModel();
250
+ }
251
+ // Run the built-in global + column filters first:
163
252
  const baseFilteredModel = (0, react_table_1.getFilteredRowModel)()(table)();
164
253
  const { filters, logic } = (_a = table.getState().columnFilter) !== null && _a !== void 0 ? _a : {
165
254
  filters: [],
@@ -167,6 +256,7 @@ const getCombinedFilteredRowModel = () => {
167
256
  };
168
257
  if (!filters.length || !table.options.enableAdvanceColumnFilter)
169
258
  return baseFilteredModel;
259
+ // Apply custom column filters to pre-filtered rows
170
260
  const filteredRows = baseFilteredModel.rows.filter(row => matchesCustomColumnFilters(row, filters, logic));
171
261
  const flatRows = [];
172
262
  const rowsById = {};
@@ -185,13 +275,18 @@ const getCombinedFilteredRowModel = () => {
185
275
  };
186
276
  };
187
277
  exports.getCombinedFilteredRowModel = getCombinedFilteredRowModel;
278
+ /**
279
+ * Evaluate a single filter condition
280
+ */
188
281
  function evaluateFilterCondition(columnValue, operator, filterValue, type = 'text') {
282
+ // --- Date helpers using moment ---
189
283
  function toMoment(val) {
190
284
  if (!val)
191
285
  return null;
192
286
  const m = (0, moment_1.default)(val);
193
287
  return m.isValid() ? m : null;
194
288
  }
289
+ // --- Date type logic ---
195
290
  if (type === 'date') {
196
291
  const mCol = toMoment(columnValue);
197
292
  const mFilter = toMoment(filterValue);
@@ -214,6 +309,7 @@ function evaluateFilterCondition(columnValue, operator, filterValue, type = 'tex
214
309
  return true;
215
310
  }
216
311
  }
312
+ // --- Boolean type logic ---
217
313
  if (type === 'boolean') {
218
314
  switch (operator) {
219
315
  case 'is':
@@ -228,6 +324,7 @@ function evaluateFilterCondition(columnValue, operator, filterValue, type = 'tex
228
324
  return true;
229
325
  }
230
326
  }
327
+ // --- Select type logic (in, notIn, single select) ---
231
328
  if (type === 'select') {
232
329
  if (operator === 'in' || operator === 'notIn') {
233
330
  if (Array.isArray(filterValue)) {
@@ -244,6 +341,7 @@ function evaluateFilterCondition(columnValue, operator, filterValue, type = 'tex
244
341
  : columnValue !== filterValue;
245
342
  }
246
343
  }
344
+ // --- Text/Number type logic ---
247
345
  switch (operator) {
248
346
  case 'contains':
249
347
  return String(columnValue).toLowerCase().includes(String(filterValue).toLowerCase());
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Custom TanStack Table Features
3
+ *
4
+ * This module exports custom features that extend TanStack Table functionality
5
+ * following the official custom features pattern introduced in v8.14.0
6
+ */
7
+ export { ColumnFilterFeature, matchesCustomColumnFilters, type ColumnFilterRule, type ColumnFilterOptions, } from './column-filter.feature';
8
+ export { SelectionFeature, type SelectionState, type SelectMode, type SelectionOptions, type SelectionTableState, type SelectionInstance, } from './selection.feature';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/features/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GAC3B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACH,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACzB,MAAM,qBAAqB,CAAC"}
@@ -1,8 +1,15 @@
1
1
  "use strict";
2
+ /**
3
+ * Custom TanStack Table Features
4
+ *
5
+ * This module exports custom features that extend TanStack Table functionality
6
+ * following the official custom features pattern introduced in v8.14.0
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.SelectionFeature = exports.matchesCustomColumnFilters = exports.ColumnFilterFeature = void 0;
4
10
  var column_filter_feature_1 = require("./column-filter.feature");
5
11
  Object.defineProperty(exports, "ColumnFilterFeature", { enumerable: true, get: function () { return column_filter_feature_1.ColumnFilterFeature; } });
6
12
  Object.defineProperty(exports, "matchesCustomColumnFilters", { enumerable: true, get: function () { return column_filter_feature_1.matchesCustomColumnFilters; } });
13
+ // Export custom selection feature
7
14
  var selection_feature_1 = require("./selection.feature");
8
15
  Object.defineProperty(exports, "SelectionFeature", { enumerable: true, get: function () { return selection_feature_1.SelectionFeature; } });
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Custom Selection Feature for TanStack Table
3
+ *
4
+ * This feature adds custom selection capabilities to TanStack Table
5
+ * following the official custom features pattern (same as CustomColumnFilterFeature)
6
+ */
1
7
  import { TableFeature, RowData, Updater, Row } from '@tanstack/react-table';
2
8
  export interface SelectionState {
3
9
  ids: string[];
@@ -18,7 +24,7 @@ export interface SelectionOptions {
18
24
  export interface SelectionTableState {
19
25
  selectionState: SelectionState;
20
26
  }
21
- declare module '@tanstack/table-core' {
27
+ declare module '@tanstack/react-table' {
22
28
  interface TableState extends SelectionTableState {
23
29
  }
24
30
  interface TableOptionsResolved<TData extends RowData> extends SelectionOptions {
@@ -44,3 +50,4 @@ export interface SelectionInstance<TData extends RowData> {
44
50
  canSelectRow: (rowId: string) => boolean;
45
51
  }
46
52
  export declare const SelectionFeature: TableFeature<any>;
53
+ //# sourceMappingURL=selection.feature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.feature.d.ts","sourceRoot":"","sources":["../../../src/lib/features/selection.feature.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAEH,YAAY,EACZ,OAAO,EACP,OAAO,EAGP,GAAG,EACN,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,cAAc;IAC3B,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC/B;AAGD,MAAM,MAAM,uBAAuB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,CAAC,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC;AAG3F,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;AAGxC,MAAM,WAAW,gBAAgB;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;CACvE;AAGD,MAAM,WAAW,mBAAmB;IAChC,cAAc,EAAE,cAAc,CAAC;CAClC;AAGD,OAAO,QAAQ,uBAAuB,CAAC;IACnC,UAAU,UAAW,SAAQ,mBAAmB;KAAI;IACpD,UAAU,oBAAoB,CAAC,KAAK,SAAS,OAAO,CAChD,SAAQ,gBAAgB;KAAI;IAChC,UAAU,KAAK,CAAC,KAAK,SAAS,OAAO,CAAE,SAAQ,iBAAiB,CAAC,KAAK,CAAC;KAAI;CAC9E;AAGD,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,OAAO;IAEpD,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAC9D,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,IAAI,CAAC;IAGxB,oBAAoB,EAAE,MAAM,OAAO,CAAC;IACpC,qBAAqB,EAAE,MAAM,OAAO,CAAC;IACrC,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAG7C,iBAAiB,EAAE,MAAM,cAAc,CAAC;IACxC,gBAAgB,EAAE,MAAM,MAAM,CAAC;IAC/B,eAAe,EAAE,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;IACpC,iBAAiB,EAAE,MAAM,MAAM,EAAE,CAAC;IAGlC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C;AAGD,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,GAAG,CAgP9C,CAAC"}
@@ -1,15 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SelectionFeature = void 0;
4
+ /**
5
+ * Custom Selection Feature for TanStack Table
6
+ *
7
+ * This feature adds custom selection capabilities to TanStack Table
8
+ * following the official custom features pattern (same as CustomColumnFilterFeature)
9
+ */
4
10
  const react_table_1 = require("@tanstack/react-table");
11
+ // The custom selection feature implementation (same pattern as CustomColumnFilterFeature)
5
12
  exports.SelectionFeature = {
13
+ // Define the feature's initial state
6
14
  getInitialState: (state) => {
7
- return Object.assign({ selectionState: {
15
+ return {
16
+ selectionState: {
8
17
  ids: [],
9
18
  type: 'include',
10
19
  selectMode: 'page',
11
- } }, state);
20
+ },
21
+ ...state,
22
+ };
12
23
  },
24
+ // Define the feature's default options
13
25
  getDefaultOptions: (table) => {
14
26
  return {
15
27
  enableAdvanceSelection: true,
@@ -17,6 +29,7 @@ exports.SelectionFeature = {
17
29
  onSelectionStateChange: (0, react_table_1.makeStateUpdater)('selectionState', table),
18
30
  };
19
31
  },
32
+ // Define the feature's table instance methods
20
33
  createTable: (table) => {
21
34
  table.setSelectionState = (updater) => {
22
35
  var _a, _b;
@@ -28,6 +41,7 @@ exports.SelectionFeature = {
28
41
  };
29
42
  return (_b = (_a = table.options).onSelectionStateChange) === null || _b === void 0 ? void 0 : _b.call(_a, safeUpdater);
30
43
  };
44
+ // === BASIC SELECTION METHODS ===
31
45
  table.selectRow = (rowId) => {
32
46
  if (!table.options.enableAdvanceSelection)
33
47
  return;
@@ -35,11 +49,19 @@ exports.SelectionFeature = {
35
49
  return;
36
50
  table.setSelectionState((old) => {
37
51
  if (old.type === 'exclude') {
38
- return Object.assign(Object.assign({}, old), { ids: old.ids.filter(id => id !== rowId) });
52
+ // In exclude mode, selecting means removing from exclude list
53
+ return {
54
+ ...old,
55
+ ids: old.ids.filter(id => id !== rowId),
56
+ };
39
57
  }
40
58
  else {
59
+ // In include mode, selecting means adding to include list
41
60
  const newIds = old.ids.includes(rowId) ? old.ids : [...old.ids, rowId];
42
- return Object.assign(Object.assign({}, old), { ids: newIds });
61
+ return {
62
+ ...old,
63
+ ids: newIds,
64
+ };
43
65
  }
44
66
  });
45
67
  };
@@ -48,11 +70,19 @@ exports.SelectionFeature = {
48
70
  return;
49
71
  table.setSelectionState((old) => {
50
72
  if (old.type === 'exclude') {
73
+ // In exclude mode, deselecting means adding to exclude list
51
74
  const newIds = old.ids.includes(rowId) ? old.ids : [...old.ids, rowId];
52
- return Object.assign(Object.assign({}, old), { ids: newIds });
75
+ return {
76
+ ...old,
77
+ ids: newIds,
78
+ };
53
79
  }
54
80
  else {
55
- return Object.assign(Object.assign({}, old), { ids: old.ids.filter(id => id !== rowId) });
81
+ // In include mode, deselecting means removing from include list
82
+ return {
83
+ ...old,
84
+ ids: old.ids.filter(id => id !== rowId),
85
+ };
56
86
  }
57
87
  });
58
88
  };
@@ -67,24 +97,40 @@ exports.SelectionFeature = {
67
97
  }
68
98
  };
69
99
  table.selectAll = () => {
100
+ var _a, _b;
70
101
  if (!table.options.enableAdvanceSelection)
71
102
  return;
72
103
  const selectMode = table.options.selectMode || 'page';
104
+ const currentRows = ((_b = (_a = table.getPaginationRowModel) === null || _a === void 0 ? void 0 : _a.call(table)) === null || _b === void 0 ? void 0 : _b.rows) ||
105
+ table.getRowModel().rows;
73
106
  if (selectMode === 'all') {
74
- table.setSelectionState((old) => (Object.assign(Object.assign({}, old), { ids: [], type: 'exclude' })));
107
+ // In 'all' mode, use exclude type with empty list (select all)
108
+ table.setSelectionState((old) => ({
109
+ ...old,
110
+ ids: [],
111
+ type: 'exclude',
112
+ }));
75
113
  }
76
114
  else {
77
- const currentPageRows = table.getPaginationRowModel().rows;
78
- const selectableRowIds = currentPageRows
115
+ // In 'page' mode, select current page rows
116
+ const selectableRowIds = currentRows
79
117
  .filter(row => table.canSelectRow(row.id))
80
118
  .map(row => row.id);
81
- table.setSelectionState((old) => (Object.assign(Object.assign({}, old), { ids: selectableRowIds, type: 'include' })));
119
+ table.setSelectionState((old) => ({
120
+ ...old,
121
+ ids: selectableRowIds,
122
+ type: 'include',
123
+ }));
82
124
  }
83
125
  };
84
126
  table.deselectAll = () => {
85
127
  if (!table.options.enableAdvanceSelection)
86
128
  return;
87
- table.setSelectionState((old) => (Object.assign(Object.assign({}, old), { ids: [], type: 'include' })));
129
+ table.setSelectionState((old) => ({
130
+ ...old,
131
+ ids: [],
132
+ type: 'include',
133
+ }));
88
134
  };
89
135
  table.toggleAllRowsSelected = () => {
90
136
  if (!table.options.enableAdvanceSelection)
@@ -96,29 +142,36 @@ exports.SelectionFeature = {
96
142
  table.selectAll();
97
143
  }
98
144
  };
145
+ // === STATE CHECKERS ===
99
146
  table.getIsRowSelected = (rowId) => {
100
147
  const state = table.getSelectionState();
101
148
  if (state.type === 'exclude') {
149
+ // In exclude mode, selected if NOT in exclude list
102
150
  return !state.ids.includes(rowId);
103
151
  }
104
152
  else {
153
+ // In include mode, selected if in include list
105
154
  return state.ids.includes(rowId);
106
155
  }
107
156
  };
108
157
  table.getIsAllRowsSelected = () => {
158
+ var _a, _b;
109
159
  const state = table.getSelectionState();
110
160
  const selectMode = table.options.selectMode || 'page';
111
161
  if (selectMode === 'all') {
162
+ const totalCount = table.getRowCount();
163
+ if (totalCount === 0)
164
+ return false;
112
165
  if (state.type === 'exclude') {
113
166
  return state.ids.length === 0;
114
167
  }
115
168
  else {
116
- const totalCount = table.getRowCount();
117
169
  return state.ids.length === totalCount;
118
170
  }
119
171
  }
120
172
  else {
121
- const currentPageRows = table.getPaginationRowModel().rows;
173
+ // Page mode - check if all selectable rows on current page are selected
174
+ const currentPageRows = ((_b = (_a = table.getPaginationRowModel) === null || _a === void 0 ? void 0 : _a.call(table)) === null || _b === void 0 ? void 0 : _b.rows) || table.getRowModel().rows;
122
175
  const selectableRows = currentPageRows.filter(row => table.canSelectRow(row.id));
123
176
  if (selectableRows.length === 0)
124
177
  return false;
@@ -129,13 +182,16 @@ exports.SelectionFeature = {
129
182
  const state = table.getSelectionState();
130
183
  const selectMode = table.options.selectMode || 'page';
131
184
  if (selectMode === 'all' && state.type === 'exclude') {
185
+ // In exclude mode, we have some selected if not all are excluded
132
186
  const totalCount = table.getRowCount();
133
- return state.ids.length < totalCount && totalCount > 0;
187
+ return totalCount > 0 && state.ids.length < totalCount;
134
188
  }
135
189
  else {
190
+ // In include mode, we have some selected if list has items
136
191
  return state.ids.length > 0;
137
192
  }
138
193
  };
194
+ // === GETTERS ===
139
195
  table.getSelectionState = () => {
140
196
  return table.getState().selectionState || {
141
197
  ids: [],
@@ -147,6 +203,8 @@ exports.SelectionFeature = {
147
203
  const state = table.getSelectionState();
148
204
  const selectMode = table.options.selectMode || 'page';
149
205
  if (selectMode === 'all' && state.type === 'exclude') {
206
+ // For server-side data, use rowCount which includes total from server
207
+ // For client-side data, this will be the same as getRowModel().rows.length
150
208
  const totalCount = table.getRowCount();
151
209
  return Math.max(0, totalCount - state.ids.length);
152
210
  }
@@ -158,7 +216,7 @@ exports.SelectionFeature = {
158
216
  const state = table.getSelectionState();
159
217
  if (state.type === 'exclude') {
160
218
  console.warn('[SelectionFeature] getSelectedRowIds() is not accurate in exclude mode. Use getSelectionState() to interpret selection properly.');
161
- return [];
219
+ return []; // Return empty to avoid misleading API
162
220
  }
163
221
  return state.ids;
164
222
  };
@@ -166,12 +224,15 @@ exports.SelectionFeature = {
166
224
  const state = table.getSelectionState();
167
225
  const allRows = table.getRowModel().rows;
168
226
  if (state.type === 'exclude') {
227
+ // Return all rows except excluded ones
169
228
  return allRows.filter(row => !state.ids.includes(row.id));
170
229
  }
171
230
  else {
231
+ // Return only included rows
172
232
  return allRows.filter(row => state.ids.includes(row.id));
173
233
  }
174
234
  };
235
+ // === HELPER METHODS ===
175
236
  table.canSelectRow = (rowId) => {
176
237
  if (!table.options.isRowSelectable)
177
238
  return true;
@@ -0,0 +1,4 @@
1
+ import { ReactElement } from 'react';
2
+ import { SvgIconProps } from '@mui/material';
3
+ export declare function AddIcon(props: SvgIconProps): ReactElement;
4
+ //# sourceMappingURL=add-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-icon.d.ts","sourceRoot":"","sources":["../../../src/lib/icons/add-icon.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAW,YAAY,EAAE,MAAM,eAAe,CAAC;AAGtD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAkBzD"}