@chumsinc/sortable-tables 2.2.0 → 3.0.0

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 (66) hide show
  1. package/CHANGELOG.md +69 -52
  2. package/README.md +94 -4
  3. package/dist/DataTable.d.ts +6 -6
  4. package/dist/DataTableCell.d.ts +299 -295
  5. package/dist/DataTableCols.d.ts +5 -5
  6. package/dist/DataTableContext.d.ts +10 -0
  7. package/dist/DataTableProvider.d.ts +12 -0
  8. package/dist/DataTableTH.d.ts +6 -6
  9. package/dist/SortableTable.d.ts +6 -6
  10. package/dist/SortableTableHead.d.ts +6 -6
  11. package/dist/SortableTableHeadWrapper.d.ts +9 -0
  12. package/dist/SortableTableTH.d.ts +6 -6
  13. package/dist/StandaloneDataTable.d.ts +6 -0
  14. package/dist/StandaloneSortHelper.d.ts +5 -0
  15. package/dist/StandaloneSortableTable.d.ts +6 -0
  16. package/dist/Table.d.ts +6 -5
  17. package/dist/index.cjs.js +30 -34
  18. package/dist/index.cjs.js.map +1 -1
  19. package/dist/index.d.ts +20 -16
  20. package/dist/index.es.js +521 -471
  21. package/dist/index.es.js.map +1 -1
  22. package/dist/types.d.ts +104 -103
  23. package/dist/useField.d.ts +6 -0
  24. package/dist/useTableContext.d.ts +2 -0
  25. package/dist/useTableFields.d.ts +9 -0
  26. package/dist/useTableSort.d.ts +9 -0
  27. package/package.json +3 -3
  28. package/src/DataTable.tsx +34 -11
  29. package/src/DataTableCell.tsx +33 -28
  30. package/src/DataTableCols.tsx +11 -18
  31. package/src/DataTableContext.ts +13 -0
  32. package/src/DataTableHead.tsx +6 -7
  33. package/src/DataTableProvider.tsx +62 -0
  34. package/src/DataTableRow.tsx +8 -7
  35. package/src/DataTableTBody.tsx +1 -3
  36. package/src/DataTableTH.tsx +4 -3
  37. package/src/RowsPerPage.tsx +2 -4
  38. package/src/SortableTable.tsx +36 -12
  39. package/src/SortableTableHead.tsx +9 -9
  40. package/src/SortableTableHeadWrapper.tsx +20 -0
  41. package/src/SortableTableTH.tsx +4 -4
  42. package/src/StandaloneDataTable.tsx +16 -0
  43. package/src/StandaloneSortHelper.tsx +15 -0
  44. package/src/StandaloneSortableTable.tsx +21 -0
  45. package/src/Table.tsx +49 -44
  46. package/src/TablePagination.tsx +1 -3
  47. package/src/index.tsx +21 -15
  48. package/src/types.ts +127 -126
  49. package/src/useField.ts +19 -0
  50. package/src/useTableContext.ts +10 -0
  51. package/src/useTableFields.ts +20 -0
  52. package/src/useTableSort.ts +20 -0
  53. package/test/Main.tsx +37 -0
  54. package/test/TableColumnsHandler.tsx +9 -9
  55. package/test/TestTable.tsx +51 -46
  56. package/test/data.ts +232 -232
  57. package/test/index.tsx +11 -11
  58. package/test/tableFields.tsx +11 -3
  59. package/test/utils.ts +19 -0
  60. package/tsconfig.json +1 -0
  61. package/dist/DataTableWithContext.d.ts +0 -2
  62. package/dist/SortableTableWithContext.d.ts +0 -2
  63. package/dist/TableProvider.d.ts +0 -17
  64. package/src/DataTableWithContext.tsx +0 -41
  65. package/src/SortableTableWithContext.tsx +0 -44
  66. package/src/TableProvider.tsx +0 -77
package/test/data.ts CHANGED
@@ -1,232 +1,232 @@
1
- import {SortProps} from "../src";
2
-
3
- export interface ProductLine {
4
- ProductLine: string,
5
- ProductLineDesc: string,
6
- ProductType: string;
7
- Valuation: string;
8
- ExplodeKitItems: string;
9
- active: boolean;
10
- }
11
-
12
- export const productLines: ProductLine[] = [
13
- {
14
- "ProductLine": "A",
15
- "ProductLineDesc": "Watchbands",
16
- "ProductType": "F",
17
- "Valuation": "2",
18
- "ExplodeKitItems": "P",
19
- "active": true
20
- },
21
- {
22
- "ProductLine": "BC",
23
- "ProductLineDesc": "Beyond Coastal",
24
- "ProductType": "F",
25
- "Valuation": "5",
26
- "ExplodeKitItems": "P",
27
- "active": true
28
- },
29
- {
30
- "ProductLine": "CASE",
31
- "ProductLineDesc": "Accessory Cases & Bags",
32
- "ProductType": "F",
33
- "Valuation": "2",
34
- "ExplodeKitItems": "A",
35
- "active": true
36
- },
37
- {
38
- "ProductLine": "D",
39
- "ProductLineDesc": "Display Racks",
40
- "ProductType": "F",
41
- "Valuation": "2",
42
- "ExplodeKitItems": "P",
43
- "active": true
44
- },
45
- {
46
- "ProductLine": "E",
47
- "ProductLineDesc": "Retainers",
48
- "ProductType": "F",
49
- "Valuation": "2",
50
- "ExplodeKitItems": "P",
51
- "active": true
52
- },
53
- {
54
- "ProductLine": "E2",
55
- "ProductLineDesc": "Optical Accessories",
56
- "ProductType": "F",
57
- "Valuation": "2",
58
- "ExplodeKitItems": "P",
59
- "active": true
60
- },
61
- {
62
- "ProductLine": "F2",
63
- "ProductLineDesc": "Active Gear/Fitness",
64
- "ProductType": "F",
65
- "Valuation": "2",
66
- "ExplodeKitItems": "P",
67
- "active": true
68
- },
69
- {
70
- "ProductLine": "FGRM",
71
- "ProductLineDesc": "Finished Goods w/USA Step",
72
- "ProductType": "F",
73
- "Valuation": "2",
74
- "ExplodeKitItems": "P",
75
- "active": true
76
- },
77
- {
78
- "ProductLine": "FUSA",
79
- "ProductLineDesc": "#Freestyle USA Sales",
80
- "ProductType": "F",
81
- "Valuation": "2",
82
- "ExplodeKitItems": "A",
83
- "active": false
84
- },
85
- {
86
- "ProductLine": "G",
87
- "ProductLineDesc": "Chums Custom OEM",
88
- "ProductType": "F",
89
- "Valuation": "2",
90
- "ExplodeKitItems": "P",
91
- "active": true
92
- },
93
- {
94
- "ProductLine": "J",
95
- "ProductLineDesc": "Winter Products",
96
- "ProductType": "F",
97
- "Valuation": "2",
98
- "ExplodeKitItems": "P",
99
- "active": true
100
- },
101
- {
102
- "ProductLine": "JP",
103
- "ProductLineDesc": "Japan Products",
104
- "ProductType": "F",
105
- "Valuation": "2",
106
- "ExplodeKitItems": "A",
107
- "active": true
108
- },
109
- {
110
- "ProductLine": "K",
111
- "ProductLineDesc": "Keychains",
112
- "ProductType": "F",
113
- "Valuation": "2",
114
- "ExplodeKitItems": "P",
115
- "active": true
116
- },
117
- {
118
- "ProductLine": "L",
119
- "ProductLineDesc": "Wallets",
120
- "ProductType": "F",
121
- "Valuation": "2",
122
- "ExplodeKitItems": "P",
123
- "active": true
124
- },
125
- {
126
- "ProductLine": "M",
127
- "ProductLineDesc": "Misc Products",
128
- "ProductType": "F",
129
- "Valuation": "2",
130
- "ExplodeKitItems": "P",
131
- "active": true
132
- },
133
- {
134
- "ProductLine": "O",
135
- "ProductLineDesc": "Lip Balm/Lotion",
136
- "ProductType": "F",
137
- "Valuation": "2",
138
- "ExplodeKitItems": "P",
139
- "active": true
140
- },
141
- {
142
- "ProductLine": "P",
143
- "ProductLineDesc": "Paracord",
144
- "ProductType": "F",
145
- "Valuation": "2",
146
- "ExplodeKitItems": "A",
147
- "active": true
148
- },
149
- {
150
- "ProductLine": "POFG",
151
- "ProductLineDesc": "Purchased Items with WT",
152
- "ProductType": "F",
153
- "Valuation": "2",
154
- "ExplodeKitItems": "P",
155
- "active": true
156
- },
157
- {
158
- "ProductLine": "R",
159
- "ProductLineDesc": "Rep Sample Product",
160
- "ProductType": "F",
161
- "Valuation": "2",
162
- "ExplodeKitItems": "P",
163
- "active": true
164
- },
165
- {
166
- "ProductLine": "RBC",
167
- "ProductLineDesc": "#Rep Sample BeyondCoastal",
168
- "ProductType": "F",
169
- "Valuation": "2",
170
- "ExplodeKitItems": "A",
171
- "active": false
172
- },
173
- {
174
- "ProductLine": "RM",
175
- "ProductLineDesc": "Raw Materials",
176
- "ProductType": "R",
177
- "Valuation": "2",
178
- "ExplodeKitItems": "P",
179
- "active": true
180
- },
181
- {
182
- "ProductLine": "RMLY",
183
- "ProductLineDesc": "Lanyard RHOOKS Sold",
184
- "ProductType": "R",
185
- "Valuation": "2",
186
- "ExplodeKitItems": "P",
187
- "active": true
188
- },
189
- {
190
- "ProductLine": "S",
191
- "ProductLineDesc": "Promotional Products",
192
- "ProductType": "F",
193
- "Valuation": "2",
194
- "ExplodeKitItems": "P",
195
- "active": true
196
- },
197
- {
198
- "ProductLine": "T",
199
- "ProductLineDesc": "Kits",
200
- "ProductType": "F",
201
- "Valuation": "2",
202
- "ExplodeKitItems": "A",
203
- "active": true
204
- },
205
- {
206
- "ProductLine": "V",
207
- "ProductLineDesc": "Lanyards",
208
- "ProductType": "F",
209
- "Valuation": "2",
210
- "ExplodeKitItems": "P",
211
- "active": true
212
- }
213
- ];
214
-
215
- export const productLineSorter = (sort: SortProps<ProductLine>) => (a: ProductLine, b: ProductLine) => {
216
- const {field, ascending} = sort;
217
- const sortMod = ascending === false ? -1 : 1;
218
- switch (field) {
219
- case 'ProductLine':
220
- case 'ProductLineDesc':
221
- case 'ProductType':
222
- case 'Valuation':
223
- case 'ExplodeKitItems':
224
- return (
225
- a[field].localeCompare(b[field]) === 0
226
- ? a.ProductLine.localeCompare(b.ProductLine)
227
- : a[field].localeCompare(b[field])
228
- ) * sortMod;
229
- default:
230
- return a.ProductLine.localeCompare(b.ProductLine)
231
- }
232
- }
1
+ import type {SortProps} from "../src";
2
+
3
+ export interface ProductLine {
4
+ ProductLine: string,
5
+ ProductLineDesc: string,
6
+ ProductType: string;
7
+ Valuation: string;
8
+ ExplodeKitItems: string;
9
+ active: boolean;
10
+ }
11
+
12
+ export const productLines: ProductLine[] = [
13
+ {
14
+ "ProductLine": "A",
15
+ "ProductLineDesc": "Watchbands",
16
+ "ProductType": "F",
17
+ "Valuation": "2",
18
+ "ExplodeKitItems": "P",
19
+ "active": true
20
+ },
21
+ {
22
+ "ProductLine": "BC",
23
+ "ProductLineDesc": "Beyond Coastal",
24
+ "ProductType": "F",
25
+ "Valuation": "5",
26
+ "ExplodeKitItems": "P",
27
+ "active": true
28
+ },
29
+ {
30
+ "ProductLine": "CASE",
31
+ "ProductLineDesc": "Accessory Cases & Bags",
32
+ "ProductType": "F",
33
+ "Valuation": "2",
34
+ "ExplodeKitItems": "A",
35
+ "active": true
36
+ },
37
+ {
38
+ "ProductLine": "D",
39
+ "ProductLineDesc": "Display Racks",
40
+ "ProductType": "F",
41
+ "Valuation": "2",
42
+ "ExplodeKitItems": "P",
43
+ "active": true
44
+ },
45
+ {
46
+ "ProductLine": "E",
47
+ "ProductLineDesc": "Retainers",
48
+ "ProductType": "F",
49
+ "Valuation": "2",
50
+ "ExplodeKitItems": "P",
51
+ "active": true
52
+ },
53
+ {
54
+ "ProductLine": "E2",
55
+ "ProductLineDesc": "Optical Accessories",
56
+ "ProductType": "F",
57
+ "Valuation": "2",
58
+ "ExplodeKitItems": "P",
59
+ "active": true
60
+ },
61
+ {
62
+ "ProductLine": "F2",
63
+ "ProductLineDesc": "Active Gear/Fitness",
64
+ "ProductType": "F",
65
+ "Valuation": "2",
66
+ "ExplodeKitItems": "P",
67
+ "active": true
68
+ },
69
+ {
70
+ "ProductLine": "FGRM",
71
+ "ProductLineDesc": "Finished Goods w/USA Step",
72
+ "ProductType": "F",
73
+ "Valuation": "2",
74
+ "ExplodeKitItems": "P",
75
+ "active": true
76
+ },
77
+ {
78
+ "ProductLine": "FUSA",
79
+ "ProductLineDesc": "#Freestyle USA Sales",
80
+ "ProductType": "F",
81
+ "Valuation": "2",
82
+ "ExplodeKitItems": "A",
83
+ "active": false
84
+ },
85
+ {
86
+ "ProductLine": "G",
87
+ "ProductLineDesc": "Chums Custom OEM",
88
+ "ProductType": "F",
89
+ "Valuation": "2",
90
+ "ExplodeKitItems": "P",
91
+ "active": true
92
+ },
93
+ {
94
+ "ProductLine": "J",
95
+ "ProductLineDesc": "Winter Products",
96
+ "ProductType": "F",
97
+ "Valuation": "2",
98
+ "ExplodeKitItems": "P",
99
+ "active": true
100
+ },
101
+ {
102
+ "ProductLine": "JP",
103
+ "ProductLineDesc": "Japan Products",
104
+ "ProductType": "F",
105
+ "Valuation": "2",
106
+ "ExplodeKitItems": "A",
107
+ "active": true
108
+ },
109
+ {
110
+ "ProductLine": "K",
111
+ "ProductLineDesc": "Keychains",
112
+ "ProductType": "F",
113
+ "Valuation": "2",
114
+ "ExplodeKitItems": "P",
115
+ "active": true
116
+ },
117
+ {
118
+ "ProductLine": "L",
119
+ "ProductLineDesc": "Wallets",
120
+ "ProductType": "F",
121
+ "Valuation": "2",
122
+ "ExplodeKitItems": "P",
123
+ "active": true
124
+ },
125
+ {
126
+ "ProductLine": "M",
127
+ "ProductLineDesc": "Misc Products",
128
+ "ProductType": "F",
129
+ "Valuation": "2",
130
+ "ExplodeKitItems": "P",
131
+ "active": true
132
+ },
133
+ {
134
+ "ProductLine": "O",
135
+ "ProductLineDesc": "Lip Balm/Lotion",
136
+ "ProductType": "F",
137
+ "Valuation": "2",
138
+ "ExplodeKitItems": "P",
139
+ "active": true
140
+ },
141
+ {
142
+ "ProductLine": "P",
143
+ "ProductLineDesc": "Paracord",
144
+ "ProductType": "F",
145
+ "Valuation": "2",
146
+ "ExplodeKitItems": "A",
147
+ "active": true
148
+ },
149
+ {
150
+ "ProductLine": "POFG",
151
+ "ProductLineDesc": "Purchased Items with WT",
152
+ "ProductType": "F",
153
+ "Valuation": "2",
154
+ "ExplodeKitItems": "P",
155
+ "active": true
156
+ },
157
+ {
158
+ "ProductLine": "R",
159
+ "ProductLineDesc": "Rep Sample Product",
160
+ "ProductType": "F",
161
+ "Valuation": "2",
162
+ "ExplodeKitItems": "P",
163
+ "active": true
164
+ },
165
+ {
166
+ "ProductLine": "RBC",
167
+ "ProductLineDesc": "#Rep Sample BeyondCoastal",
168
+ "ProductType": "F",
169
+ "Valuation": "2",
170
+ "ExplodeKitItems": "A",
171
+ "active": false
172
+ },
173
+ {
174
+ "ProductLine": "RM",
175
+ "ProductLineDesc": "Raw Materials",
176
+ "ProductType": "R",
177
+ "Valuation": "2",
178
+ "ExplodeKitItems": "P",
179
+ "active": true
180
+ },
181
+ {
182
+ "ProductLine": "RMLY",
183
+ "ProductLineDesc": "Lanyard RHOOKS Sold",
184
+ "ProductType": "R",
185
+ "Valuation": "2",
186
+ "ExplodeKitItems": "P",
187
+ "active": true
188
+ },
189
+ {
190
+ "ProductLine": "S",
191
+ "ProductLineDesc": "Promotional Products",
192
+ "ProductType": "F",
193
+ "Valuation": "2",
194
+ "ExplodeKitItems": "P",
195
+ "active": true
196
+ },
197
+ {
198
+ "ProductLine": "T",
199
+ "ProductLineDesc": "Kits",
200
+ "ProductType": "F",
201
+ "Valuation": "2",
202
+ "ExplodeKitItems": "A",
203
+ "active": true
204
+ },
205
+ {
206
+ "ProductLine": "V",
207
+ "ProductLineDesc": "Lanyards",
208
+ "ProductType": "F",
209
+ "Valuation": "2",
210
+ "ExplodeKitItems": "P",
211
+ "active": true
212
+ }
213
+ ];
214
+
215
+ export const productLineSorter = (sort: SortProps<ProductLine>) => (a: ProductLine, b: ProductLine) => {
216
+ const {field, ascending} = sort;
217
+ const sortMod = ascending === false ? -1 : 1;
218
+ switch (field) {
219
+ case 'ProductLine':
220
+ case 'ProductLineDesc':
221
+ case 'ProductType':
222
+ case 'Valuation':
223
+ case 'ExplodeKitItems':
224
+ return (
225
+ a[field].localeCompare(b[field]) === 0
226
+ ? a.ProductLine.localeCompare(b.ProductLine)
227
+ : a[field].localeCompare(b[field])
228
+ ) * sortMod;
229
+ default:
230
+ return a.ProductLine.localeCompare(b.ProductLine)
231
+ }
232
+ }
package/test/index.tsx CHANGED
@@ -1,11 +1,11 @@
1
- import React from 'react';
2
- import {createRoot} from "react-dom/client";
3
- import TestTable from "./TestTable";
4
-
5
- const container = document.getElementById('app');
6
- const root = createRoot(container!);
7
- root.render(
8
- <React.StrictMode>
9
- <TestTable />
10
- </React.StrictMode>
11
- );
1
+ import React from 'react';
2
+ import {createRoot} from "react-dom/client";
3
+ import Main from "./Main";
4
+
5
+ const container = document.getElementById('app');
6
+ const root = createRoot(container!);
7
+ root.render(
8
+ <React.StrictMode>
9
+ <Main/>
10
+ </React.StrictMode>
11
+ );
@@ -1,5 +1,5 @@
1
- import {SortableTableField} from "../src";
2
- import {ProductLine} from "./data";
1
+ import type {SortableTableField} from "../src";
2
+ import type {ProductLine} from "./data";
3
3
  import React from "react";
4
4
 
5
5
  export const tableFields: SortableTableField<ProductLine>[] = [
@@ -15,7 +15,7 @@ export const tableFields: SortableTableField<ProductLine>[] = [
15
15
  field: 'ProductLineDesc',
16
16
  title: 'Description',
17
17
  sortable: true,
18
- collapse: true,
18
+ visible: false,
19
19
  },
20
20
  {
21
21
  id: 'prodType',
@@ -41,4 +41,12 @@ export const tableFields: SortableTableField<ProductLine>[] = [
41
41
  render: (row) => <span className="badge bg-primary">{row.ExplodeKitItems}</span>,
42
42
  align: 'end'
43
43
  },
44
+ {
45
+ id: 'active',
46
+ field: 'active',
47
+ title: 'Active?',
48
+ sortable: true,
49
+ align: 'center',
50
+ render: (row) => <span className={`badge ${row.active ? 'bg-success' : 'bg-danger'}`}>{row.active ? 'Yes' : 'No'}</span>,
51
+ }
44
52
  ]
package/test/utils.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type {SortProps} from "../src";
2
+ import type {ProductLine} from "./data";
3
+
4
+ export const productLineSorter = (sort: SortProps<ProductLine>) => (a: ProductLine, b: ProductLine) => {
5
+ const {field, ascending} = sort;
6
+ const sortMod = ascending === false ? -1 : 1;
7
+ switch (field) {
8
+ case 'ProductLine':
9
+ case 'ProductLineDesc':
10
+ case 'ProductType':
11
+ case 'Valuation':
12
+ return (a[field].localeCompare(b[field]) === 0
13
+ ? a.ProductLine.localeCompare(b.ProductLine)
14
+ : a[field].localeCompare(b[field])
15
+ ) * sortMod;
16
+ default:
17
+ return a.ProductLine.localeCompare(b.ProductLine) * sortMod;
18
+ }
19
+ }
package/tsconfig.json CHANGED
@@ -25,6 +25,7 @@
25
25
  "strict": true,
26
26
  "target": "esNext",
27
27
  "useDefineForClassFields": true,
28
+ "verbatimModuleSyntax": true
28
29
  },
29
30
  "include": ["src/**/*"],
30
31
  "exclude": ["node_modules","dist"]
@@ -1,2 +0,0 @@
1
- import { DataTableProps } from './types';
2
- export default function DataTableWithContext<T = unknown>({ className, size, responsive, sticky, data, keyField, rowClassName, renderRow, onSelectRow, selected, tableHeadProps, children, tfoot, ...rest }: Omit<DataTableProps<T>, 'fields'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- import { SortableTableProps } from './types';
2
- export default function SortableTableWithContext<T = unknown>({ className, size, responsive, sticky, data, keyField, rowClassName, renderRow, onSelectRow, selected, tableHeadProps, children, tfoot, currentSort, onChangeSort, ...rest }: Omit<SortableTableProps<T>, 'fields'>): import("react/jsx-runtime").JSX.Element;
@@ -1,17 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { DataTableField } from './types';
3
- export interface TableContextData<T = unknown> {
4
- fields: DataTableField<T>[];
5
- setFields: (next: DataTableField<T>[] | ((prev: DataTableField<T>[]) => DataTableField<T>[])) => void;
6
- updateField: (key: string | number, arg: Partial<DataTableField<T>>) => void;
7
- getField: (key: string | number) => DataTableField<T> | undefined;
8
- }
9
- export interface TableProviderProps<T = unknown> {
10
- initialFields: DataTableField<T>[];
11
- children: ReactNode;
12
- }
13
- export default function TableProvider<T = unknown>({ children, initialFields }: TableProviderProps<T>): import("react/jsx-runtime").JSX.Element;
14
- export declare function useTableContext<T = unknown>(): TableContextData<T>;
15
- export declare function useTableFields<T = unknown>(): DataTableField<T>[];
16
- export declare function useField<T = unknown>(key: string | number): DataTableField<T> | null;
17
- export declare function useHasTableFieldsContext(): boolean;
@@ -1,41 +0,0 @@
1
- import type {DataTableProps} from "./types";
2
- import clsx from "clsx";
3
- import Table from "./Table";
4
- import {DataTableCols, DataTableTBody} from "./index";
5
- import DataTableHead from "./DataTableHead";
6
-
7
-
8
- export default function DataTableWithContext<T = unknown>({
9
- className,
10
- size,
11
- responsive,
12
- sticky,
13
- data,
14
- keyField,
15
- rowClassName,
16
- renderRow,
17
- onSelectRow,
18
- selected,
19
- tableHeadProps,
20
- children,
21
- tfoot,
22
- ...rest
23
- }: Omit<DataTableProps<T>, 'fields'>) {
24
- const tableClassName = clsx('table', className, {
25
- [`table-${size}`]: !!size,
26
- })
27
-
28
- return (
29
- <Table sticky={sticky} responsive={responsive} className={tableClassName} {...rest}>
30
- <DataTableCols/>
31
- <DataTableHead {...tableHeadProps}/>
32
- {!!data.length && (
33
- <DataTableTBody data={data} keyField={keyField} rowClassName={rowClassName}
34
- renderRow={renderRow}
35
- onSelectRow={onSelectRow} selected={selected}/>
36
- )}
37
- {children}
38
- {tfoot}
39
- </Table>
40
- )
41
- }
@@ -1,44 +0,0 @@
1
- import type {SortableTableProps} from "./types";
2
- import clsx from "clsx";
3
- import Table from "./Table";
4
- import {DataTableCols, DataTableTBody} from "./index";
5
- import SortableTableHead from "./SortableTableHead";
6
- import React from "react";
7
-
8
-
9
- export default function SortableTableWithContext<T = unknown>({
10
- className,
11
- size,
12
- responsive,
13
- sticky,
14
- data,
15
- keyField,
16
- rowClassName,
17
- renderRow,
18
- onSelectRow,
19
- selected,
20
- tableHeadProps,
21
- children,
22
- tfoot,
23
- currentSort,
24
- onChangeSort,
25
- ...rest
26
- }: Omit<SortableTableProps<T>, 'fields'>) {
27
- const tableClassName = clsx('table', className, {
28
- [`table-${size}`]: !!size,
29
- })
30
-
31
- return (
32
- <Table className={tableClassName} responsive={responsive} sticky={sticky} {...rest}>
33
- <DataTableCols/>
34
- <SortableTableHead currentSort={currentSort} onChangeSort={onChangeSort} {...tableHeadProps}/>
35
- {!!data.length && (
36
- <DataTableTBody data={data} keyField={keyField} rowClassName={rowClassName}
37
- renderRow={renderRow}
38
- onSelectRow={onSelectRow} selected={selected}/>
39
- )}
40
- {children}
41
- {tfoot}
42
- </Table>
43
- )
44
- }