rez-table-listing-mui 0.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 (65) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/README.md +164 -0
  3. package/dist/index.d.ts +90 -0
  4. package/dist/index.js +1 -0
  5. package/dist/index.mjs +1 -0
  6. package/index.html +13 -0
  7. package/package.json +64 -0
  8. package/public/vite.svg +1 -0
  9. package/rollup.config.js +42 -0
  10. package/src/App.tsx +153 -0
  11. package/src/assets/svg.tsx +833 -0
  12. package/src/components/columm-visibility-modal/column-list-item.tsx +44 -0
  13. package/src/components/columm-visibility-modal/index.scss +72 -0
  14. package/src/components/columm-visibility-modal/index.tsx +175 -0
  15. package/src/components/common/index.scss +11 -0
  16. package/src/components/common/index.tsx +11 -0
  17. package/src/components/dropdown/index.scss +17 -0
  18. package/src/components/dropdown/index.tsx +27 -0
  19. package/src/components/index-table.tsx +266 -0
  20. package/src/components/index.scss +176 -0
  21. package/src/components/inputs/checkbox/index.tsx +58 -0
  22. package/src/components/inputs/index.scss +63 -0
  23. package/src/components/inputs/switch.tsx +14 -0
  24. package/src/components/nestedcomponent/index.scss +14 -0
  25. package/src/components/nestedcomponent/index.tsx +53 -0
  26. package/src/components/pagination/default/index.scss +76 -0
  27. package/src/components/pagination/default/index.tsx +168 -0
  28. package/src/components/sorting-modal.tsx/index.tsx +200 -0
  29. package/src/components/sorting-modal.tsx/sorting-item.tsx +35 -0
  30. package/src/components/table-body-dnd-cell.tsx +50 -0
  31. package/src/components/table-body.tsx +109 -0
  32. package/src/components/table-change-layout.tsx +106 -0
  33. package/src/components/table-dnd.tsx +62 -0
  34. package/src/components/table-head-dnd-cell.tsx +144 -0
  35. package/src/components/table-head-pin.tsx +16 -0
  36. package/src/components/table-head-popover.tsx +85 -0
  37. package/src/components/table-head.tsx +156 -0
  38. package/src/components/table.tsx +38 -0
  39. package/src/components/tabs/index.scss +41 -0
  40. package/src/components/tabs/index.tsx +132 -0
  41. package/src/components/topbar/index.scss +84 -0
  42. package/src/components/topbar/index.tsx +226 -0
  43. package/src/components/viewmore/index.scss +0 -0
  44. package/src/components/viewmore/index.tsx +171 -0
  45. package/src/index.ts +4 -0
  46. package/src/libs/hooks/useCraftTable.tsx +37 -0
  47. package/src/libs/hooks/useDefaultColumns.tsx +96 -0
  48. package/src/libs/hooks/useFullScreen.tsx +25 -0
  49. package/src/libs/hooks/useOutsideClick.tsx +24 -0
  50. package/src/libs/utils/Data-format.ts +18 -0
  51. package/src/libs/utils/amount-format.ts +70 -0
  52. package/src/libs/utils/common.ts +62 -0
  53. package/src/libs/utils/date-format.ts +6 -0
  54. package/src/libs/utils/make-data.ts +79 -0
  55. package/src/libs/utils/make-hierar-data.ts +51 -0
  56. package/src/libs/utils/make-nested-data.ts +86 -0
  57. package/src/libs/utils/rows-data.ts +251 -0
  58. package/src/main.tsx +9 -0
  59. package/src/types/common.ts +30 -0
  60. package/src/types/table-options.ts +38 -0
  61. package/src/types/table.ts +65 -0
  62. package/src/vite-env.d.ts +1 -0
  63. package/tsconfig.json +25 -0
  64. package/tsconfig.node.json +11 -0
  65. package/vite.config.ts +7 -0
@@ -0,0 +1,62 @@
1
+ import { Column } from "@tanstack/react-table";
2
+ import { alignProps } from "../../types/common";
3
+ import { CSSProperties } from "react";
4
+
5
+ export const formatClassName = (className: string): string => {
6
+ return className.replace(/\s+/g, " ").trim();
7
+ };
8
+
9
+ export const getColumnAlignment = (align: string) => {
10
+ const contentAlignment = {
11
+ left: "flex-start",
12
+ center: "center",
13
+ right: "flex-end",
14
+ };
15
+
16
+ const alignment = contentAlignment[(align as alignProps) || "left"];
17
+ return alignment;
18
+ };
19
+
20
+ export const getColumnPinningStyles = <T>(column: Column<T>): CSSProperties => {
21
+ const isPinned = column.getIsPinned();
22
+ const isLastLeftPinnedColumn =
23
+ isPinned === "left" && column.getIsLastColumn("left");
24
+ const isFirstRightPinnedColumn =
25
+ isPinned === "right" && column.getIsFirstColumn("right");
26
+
27
+ return {
28
+ boxShadow: isLastLeftPinnedColumn
29
+ ? "-4px 0 4px -4px gray inset"
30
+ : isFirstRightPinnedColumn
31
+ ? "4px 0 4px -4px gray inset"
32
+ : undefined,
33
+ background: "inherit",
34
+ left: isPinned === "left" ? `${column.getStart("left")}px` : undefined,
35
+ right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined,
36
+ position: isPinned ? "sticky" : "relative",
37
+ width: column.getSize(),
38
+ };
39
+ };
40
+
41
+ export const getColumnPinningStylesBody = <T>(
42
+ column: Column<T>
43
+ ): CSSProperties => {
44
+ const isPinned = column.getIsPinned();
45
+ const isLastLeftPinnedColumn =
46
+ isPinned === "left" && column.getIsLastColumn("left");
47
+ const isFirstRightPinnedColumn =
48
+ isPinned === "right" && column.getIsFirstColumn("right");
49
+
50
+ return {
51
+ boxShadow: isLastLeftPinnedColumn
52
+ ? "-4px 0 4px -4px gray inset"
53
+ : isFirstRightPinnedColumn
54
+ ? "4px 0 4px -4px gray inset"
55
+ : undefined,
56
+ background: "inherit",
57
+ left: isPinned === "left" ? `${column.getStart("left")}px` : undefined,
58
+ right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined,
59
+ position: isPinned ? "sticky" : "relative",
60
+ width: column.getSize(),
61
+ };
62
+ };
@@ -0,0 +1,6 @@
1
+ import moment from "moment";
2
+ import { formatDateProps } from "../../types/common";
3
+
4
+ export const formatDate = ({ date, style }: formatDateProps) => {
5
+ return moment(date).format(style);
6
+ };
@@ -0,0 +1,79 @@
1
+ export const generateTableData = () => {
2
+ const records = [];
3
+
4
+ // Adding a few specific records
5
+ records.push(
6
+ {
7
+ id: 1,
8
+ name: "Employee 1",
9
+ department: "Marketing",
10
+ position: "Senior Manager",
11
+ email: "employee1@example.com",
12
+ phone: "+1-202-555-0101",
13
+ dateOfJoining: "2018-05-21",
14
+ salary: 75000,
15
+ performanceRating: "A",
16
+ location: "New York",
17
+ status: "Active",
18
+ },
19
+ {
20
+ id: 2,
21
+ name: "Employee 2",
22
+ department: "Finance",
23
+ position: "Accountant",
24
+ email: "employee2@example.com",
25
+ phone: "+1-202-555-0112",
26
+ dateOfJoining: "2020-09-15",
27
+ salary: 60000,
28
+ performanceRating: "B",
29
+ location: "Chicago",
30
+ status: "Inactive",
31
+ },
32
+ {
33
+ id: 3,
34
+ name: "Employee 3",
35
+ department: "HR",
36
+ position: "HR Specialist",
37
+ email: "employee3@example.com",
38
+ phone: "+1-202-555-0133",
39
+ dateOfJoining: "2017-03-12",
40
+ salary: 58000,
41
+ performanceRating: "A",
42
+ location: "Boston",
43
+ status: "Pending",
44
+ }
45
+ );
46
+
47
+ // Adding dynamically generated records for variety
48
+ for (let i = 4; i <= 200; i++) {
49
+ records.push({
50
+ id: i,
51
+ name: `Employee ${i}`,
52
+ department: ["IT", "Marketing", "Finance", "HR", "Operations"][
53
+ Math.floor(Math.random() * 5)
54
+ ],
55
+ position: ["Specialist", "Manager", "Analyst", "Consultant", "Director"][
56
+ Math.floor(Math.random() * 5)
57
+ ],
58
+ email: `employee${i}@example.com`,
59
+ phone: `+1-202-555-${(i + 10).toString().padStart(4, "0")}`,
60
+ dateOfJoining: new Date(
61
+ 2015 + Math.floor(Math.random() * 8),
62
+ Math.floor(Math.random() * 12),
63
+ Math.floor(Math.random() * 28) + 1
64
+ )
65
+ .toISOString()
66
+ .split("T")[0],
67
+ salary: Math.floor(Math.random() * 40000) + 50000,
68
+ performanceRating: ["A", "B", "C"][Math.floor(Math.random() * 3)],
69
+ location: ["New York", "Chicago", "Boston", "Seattle", "Austin"][
70
+ Math.floor(Math.random() * 5)
71
+ ],
72
+ status: ["Active", "Inactive", "Pending", "Hold"][
73
+ Math.floor(Math.random() * 4)
74
+ ],
75
+ });
76
+ }
77
+
78
+ return records;
79
+ };
@@ -0,0 +1,51 @@
1
+ import { faker } from "@faker-js/faker";
2
+
3
+ export type Person = {
4
+ firstName: string;
5
+ lastName: string;
6
+ age: number;
7
+ visits: number;
8
+ progress: number;
9
+ status: "Active" | "Inactive";
10
+ department?: string;
11
+ subRows?: Person[];
12
+ };
13
+
14
+ const range = (len: number) => {
15
+ const arr: number[] = [];
16
+ for (let i = 0; i < len; i++) {
17
+ arr.push(i);
18
+ }
19
+ return arr;
20
+ };
21
+
22
+ const newPerson = (): Person => {
23
+ return {
24
+ firstName: faker.person.firstName(),
25
+ lastName: faker.person.lastName(),
26
+ age: faker.number.int(40),
27
+ visits: faker.number.int(1000),
28
+ progress: faker.number.int(100),
29
+ department: faker.helpers.shuffle<string>([
30
+ "HR",
31
+ "Engineering",
32
+ "Marketing",
33
+ "Sales",
34
+ ])[0]!,
35
+ status: faker.helpers.shuffle<Person["status"]>(["Active", "Inactive"])[0]!,
36
+ };
37
+ };
38
+
39
+ export function makeData(...lens: number[]) {
40
+ const makeDataLevel = (depth = 0): Person[] => {
41
+ const len = lens[depth]!;
42
+ return range(len).map((): Person => {
43
+ return {
44
+ ...newPerson(),
45
+ subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
46
+ };
47
+ });
48
+ };
49
+
50
+ return makeDataLevel();
51
+ }
@@ -0,0 +1,86 @@
1
+ export const generateRickAndMortyData = (count: number) => {
2
+ const names = [
3
+ "Rick Sanchez",
4
+ "Morty Smith",
5
+ "Summer Smith",
6
+ "Beth Smith",
7
+ "Jerry Smith",
8
+ "Birdperson",
9
+ "Squanchy",
10
+ "Tammy Guetermann",
11
+ "Evil Morty",
12
+ "Pickle Rick",
13
+ "Snowball",
14
+ "Abradolf Lincler",
15
+ ];
16
+
17
+ const statuses = ["Alive", "Dead", "Unknown"];
18
+ const speciesList = ["Human", "Alien", "Humanoid", "Robot", "Cronenberg"];
19
+ const genders = ["Male", "Female", "unknown"];
20
+ const locations = [
21
+ "Earth (C-137)",
22
+ "Citadel of Ricks",
23
+ "Anatomy Park",
24
+ "Interdimensional Cable",
25
+ "Planet Squanch",
26
+ "Venzenulon 7",
27
+ "Nuptia 4",
28
+ "Immortality Field Resort",
29
+ ];
30
+ const types = ["Genetic experiment", "Superhuman", "Parasite", "Ghost"];
31
+ const origins = [...locations, "unknown"];
32
+
33
+ const formatDate = (date: Date) => {
34
+ const day = String(date.getDate()).padStart(2, "0");
35
+ const month = String(date.getMonth() + 1).padStart(2);
36
+ const year = String(date.getFullYear());
37
+ return `${day}/${month}/${year}`;
38
+ };
39
+
40
+ const records = [];
41
+
42
+ for (let i = 1; i <= count; i++) {
43
+ const name = names[Math.floor(Math.random() * names.length)];
44
+ const status = statuses[Math.floor(Math.random() * statuses.length)];
45
+ const species = speciesList[Math.floor(Math.random() * speciesList.length)];
46
+ const gender = genders[Math.floor(Math.random() * genders.length)];
47
+ const originName = origins[Math.floor(Math.random() * origins.length)];
48
+ const locationName =
49
+ locations[Math.floor(Math.random() * locations.length)];
50
+ const type = types[Math.floor(Math.random() * types.length)];
51
+
52
+ const randomDate = new Date(
53
+ Date.now() - Math.random() * 365 * 24 * 60 * 60 * 1000
54
+ );
55
+ const joiningDate = formatDate(randomDate);
56
+ const salary = Math.floor(Math.random() * 1000000);
57
+
58
+ records.push({
59
+ id: i,
60
+ name,
61
+ status,
62
+ species,
63
+ type,
64
+ gender,
65
+ joiningDate,
66
+ salary,
67
+ origin: {
68
+ name: originName,
69
+ url: `https://rickandmortyapi.com/api/location/${
70
+ Math.floor(Math.random() * 30) + 1
71
+ }`,
72
+ },
73
+ location: {
74
+ name: locationName,
75
+ url: `https://rickandmortyapi.com/api/location/${
76
+ Math.floor(Math.random() * 30) + 1
77
+ }`,
78
+ },
79
+ image: `https://rickandmortyapi.com/api/character/avatar/${i}.jpeg`,
80
+ url: `https://rickandmortyapi.com/api/character/${i}`,
81
+ created: joiningDate,
82
+ });
83
+ }
84
+
85
+ return records;
86
+ };
@@ -0,0 +1,251 @@
1
+ export const getRowsData = [
2
+ {
3
+ id: 1,
4
+ name: "Employee 1",
5
+ department: "Marketing",
6
+ position: "Senior Manager",
7
+ email: "employee1@example.com",
8
+ phone: "+1-202-555-0101",
9
+ dateOfJoining: "2018-05-21",
10
+ salary: 75000,
11
+ performanceRating: "A",
12
+ location: "New York",
13
+ action: "Edit",
14
+ subRows: [
15
+ {
16
+ id: 1,
17
+ name: "Employee 1",
18
+ department: "Marketing",
19
+ position: "Senior Manager",
20
+ email: "employee1@example.com",
21
+ phone: "+1-202-555-0101",
22
+ dateOfJoining: "2018-05-21",
23
+ salary: 75000,
24
+ performanceRating: "A",
25
+ location: "New York",
26
+ },
27
+ {
28
+ id: 2,
29
+ name: "Employee 2",
30
+ department: "Finance",
31
+ position: "Accountant",
32
+ email: "employee2@example.com",
33
+ phone: "+1-202-555-0112",
34
+ dateOfJoining: "2020-09-15",
35
+ salary: 60000,
36
+ performanceRating: "B",
37
+ location: "Chicago",
38
+ },
39
+ {
40
+ id: 3,
41
+ name: "Employee 3",
42
+ department: "HR",
43
+ position: "HR Specialist",
44
+ email: "employee3@example.com",
45
+ phone: "+1-202-555-0133",
46
+ dateOfJoining: "2017-03-12",
47
+ salary: 58000,
48
+ performanceRating: "A",
49
+ location: "Boston",
50
+ },
51
+ {
52
+ id: 4,
53
+ name: "Employee 4",
54
+ department: "HR",
55
+ position: "Manager",
56
+ email: "employee4@example.com",
57
+ phone: "+1-202-555-0014",
58
+ dateOfJoining: "2022-02-18",
59
+ salary: 52740,
60
+ performanceRating: "C",
61
+ location: "Boston",
62
+ },
63
+ ],
64
+ },
65
+ {
66
+ id: 2,
67
+ name: "Employee 2",
68
+ department: "Finance",
69
+ position: "Accountant",
70
+ email: "employee2@example.com",
71
+ phone: "+1-202-555-0112",
72
+ dateOfJoining: "2020-09-15",
73
+ salary: 60000,
74
+ performanceRating: "B",
75
+ location: "Chicago",
76
+ subRows: [
77
+ {
78
+ id: 1,
79
+ name: "Employee 1",
80
+ department: "Marketing",
81
+ position: "Senior Manager",
82
+ email: "employee1@example.com",
83
+ phone: "+1-202-555-0101",
84
+ dateOfJoining: "2018-05-21",
85
+ salary: 75000,
86
+ performanceRating: "A",
87
+ location: "New York",
88
+ },
89
+ {
90
+ id: 2,
91
+ name: "Employee 2",
92
+ department: "Finance",
93
+ position: "Accountant",
94
+ email: "employee2@example.com",
95
+ phone: "+1-202-555-0112",
96
+ dateOfJoining: "2020-09-15",
97
+ salary: 60000,
98
+ performanceRating: "B",
99
+ location: "Chicago",
100
+ },
101
+ {
102
+ id: 3,
103
+ name: "Employee 3",
104
+ department: "HR",
105
+ position: "HR Specialist",
106
+ email: "employee3@example.com",
107
+ phone: "+1-202-555-0133",
108
+ dateOfJoining: "2017-03-12",
109
+ salary: 58000,
110
+ performanceRating: "A",
111
+ location: "Boston",
112
+ },
113
+ {
114
+ id: 4,
115
+ name: "Employee 4",
116
+ department: "HR",
117
+ position: "Manager",
118
+ email: "employee4@example.com",
119
+ phone: "+1-202-555-0014",
120
+ dateOfJoining: "2022-02-18",
121
+ salary: 52740,
122
+ performanceRating: "C",
123
+ location: "Boston",
124
+ },
125
+ ],
126
+ },
127
+ {
128
+ id: 3,
129
+ name: "Employee 3",
130
+ department: "HR",
131
+ position: "HR Specialist",
132
+ email: "employee3@example.com",
133
+ phone: "+1-202-555-0133",
134
+ dateOfJoining: "2017-03-12",
135
+ salary: 58000,
136
+ performanceRating: "A",
137
+ location: "Boston",
138
+ subRows: [
139
+ {
140
+ id: 1,
141
+ name: "Employee 1",
142
+ department: "Marketing",
143
+ position: "Senior Manager",
144
+ email: "employee1@example.com",
145
+ phone: "+1-202-555-0101",
146
+ dateOfJoining: "2018-05-21",
147
+ salary: 75000,
148
+ performanceRating: "A",
149
+ location: "New York",
150
+ },
151
+ {
152
+ id: 2,
153
+ name: "Employee 2",
154
+ department: "Finance",
155
+ position: "Accountant",
156
+ email: "employee2@example.com",
157
+ phone: "+1-202-555-0112",
158
+ dateOfJoining: "2020-09-15",
159
+ salary: 60000,
160
+ performanceRating: "B",
161
+ location: "Chicago",
162
+ },
163
+ {
164
+ id: 3,
165
+ name: "Employee 3",
166
+ department: "HR",
167
+ position: "HR Specialist",
168
+ email: "employee3@example.com",
169
+ phone: "+1-202-555-0133",
170
+ dateOfJoining: "2017-03-12",
171
+ salary: 58000,
172
+ performanceRating: "A",
173
+ location: "Boston",
174
+ },
175
+ {
176
+ id: 4,
177
+ name: "Employee 4",
178
+ department: "HR",
179
+ position: "Manager",
180
+ email: "employee4@example.com",
181
+ phone: "+1-202-555-0014",
182
+ dateOfJoining: "2022-02-18",
183
+ salary: 52740,
184
+ performanceRating: "C",
185
+ location: "Boston",
186
+ },
187
+ ],
188
+ },
189
+ {
190
+ id: 4,
191
+ name: "Employee 4",
192
+ department: "HR",
193
+ position: "Manager",
194
+ email: "employee4@example.com",
195
+ phone: "+1-202-555-0014",
196
+ dateOfJoining: "2022-02-18",
197
+ salary: 52740,
198
+ performanceRating: "C",
199
+ location: "Boston",
200
+ subRows: [
201
+ {
202
+ id: 1,
203
+ name: "Employee 1",
204
+ department: "Marketing",
205
+ position: "Senior Manager",
206
+ email: "employee1@example.com",
207
+ phone: "+1-202-555-0101",
208
+ dateOfJoining: "2018-05-21",
209
+ salary: 75000,
210
+ performanceRating: "A",
211
+ location: "New York",
212
+ },
213
+ {
214
+ id: 2,
215
+ name: "Employee 2",
216
+ department: "Finance",
217
+ position: "Accountant",
218
+ email: "employee2@example.com",
219
+ phone: "+1-202-555-0112",
220
+ dateOfJoining: "2020-09-15",
221
+ salary: 60000,
222
+ performanceRating: "B",
223
+ location: "Chicago",
224
+ },
225
+ {
226
+ id: 3,
227
+ name: "Employee 3",
228
+ department: "HR",
229
+ position: "HR Specialist",
230
+ email: "employee3@example.com",
231
+ phone: "+1-202-555-0133",
232
+ dateOfJoining: "2017-03-12",
233
+ salary: 58000,
234
+ performanceRating: "A",
235
+ location: "Boston",
236
+ },
237
+ {
238
+ id: 4,
239
+ name: "Employee 4",
240
+ department: "HR",
241
+ position: "Manager",
242
+ email: "employee4@example.com",
243
+ phone: "+1-202-555-0014",
244
+ dateOfJoining: "2022-02-18",
245
+ salary: 52740,
246
+ performanceRating: "C",
247
+ location: "Boston",
248
+ },
249
+ ],
250
+ },
251
+ ];
package/src/main.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import App from "./App.tsx";
4
+
5
+ ReactDOM.createRoot(document.getElementById("root")!).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>
9
+ );
@@ -0,0 +1,30 @@
1
+ export interface defaultColumnsProps {
2
+ id: number;
3
+ name: string;
4
+ department: string;
5
+ position: string;
6
+ email: string;
7
+ location: string;
8
+ phone: string;
9
+ dateOfJoining: string;
10
+ salary: number;
11
+ performanceRating: string;
12
+ subRows?: any;
13
+ }
14
+
15
+ export interface amountFormatProps {
16
+ amount: number;
17
+ decimal?: boolean;
18
+ removeFloat?: boolean;
19
+ compactFormat?: "crore" | "10lakh" | "lakh";
20
+ }
21
+
22
+ export interface formatDateProps {
23
+ date: string;
24
+ style: string;
25
+ }
26
+
27
+ export type alignProps = "left" | "center" | "right";
28
+ export interface align {
29
+ align: alignProps;
30
+ }
@@ -0,0 +1,38 @@
1
+ import {
2
+ PaginationState,
3
+ RowSelectionState,
4
+ SortingState,
5
+ ExpandedState,
6
+ } from "@tanstack/react-table";
7
+ import { Dispatch, SetStateAction } from "react";
8
+
9
+ export interface CraftTableOptionsProps {
10
+ sorting: SortingState;
11
+ setSorting: Dispatch<SetStateAction<SortingState>>;
12
+ pagination: PaginationState;
13
+ setPagination: Dispatch<SetStateAction<PaginationState>>;
14
+ rowSelection: RowSelectionState;
15
+ setRowSelection: Dispatch<SetStateAction<RowSelectionState>>;
16
+ isCompactTable?: boolean;
17
+ setIsCompactTable?: Dispatch<SetStateAction<boolean>>;
18
+ expanded: ExpandedState;
19
+ setExpanded: Dispatch<SetStateAction<ExpandedState>>;
20
+ }
21
+
22
+ export interface CraftTableFeatureProps {
23
+ enableSorting?: boolean;
24
+ enableServerSidePagination?: boolean;
25
+ enableServerSideSorting?: boolean;
26
+ enableRowSelection?: boolean;
27
+ enableColumnResizing?: boolean;
28
+ enableColumnReordering?: boolean;
29
+ enableColumnPinning?: boolean;
30
+ enableMultiColumnSorting?: boolean;
31
+
32
+ // custom features not provided by react table
33
+ enableTopbar?: boolean;
34
+ enableWordBreakAll?: boolean;
35
+ stickyHeader?: boolean;
36
+ compactTable?: boolean;
37
+ striped?: boolean;
38
+ }
@@ -0,0 +1,65 @@
1
+ import {
2
+ ColumnDef,
3
+ ColumnOrderState,
4
+ Header,
5
+ Row,
6
+ Table,
7
+ } from "@tanstack/react-table";
8
+ import {
9
+ CraftTableFeatureProps,
10
+ CraftTableOptionsProps,
11
+ } from "./table-options";
12
+ import React from "react";
13
+
14
+ export interface CraftTablePaginationProps {
15
+ totalRows?: number;
16
+ rowsPerPageArray?: number[];
17
+ showPagination?: boolean;
18
+ paginationPosition?: "top" | "bottom";
19
+ paginationView?: "full" | "compact";
20
+ }
21
+
22
+ interface LoadingOptionsProps {
23
+ isLoading: boolean;
24
+ loaderText?: string;
25
+ loadingComponent?: React.ReactNode;
26
+ }
27
+
28
+ export interface TopbarOptionsProps {
29
+ leftSideComponent?: React.ReactNode;
30
+ rightSideComponent?: React.ReactNode;
31
+ showFullscreenToggle?: boolean;
32
+ showColumnToggle?: boolean;
33
+ showCompactTableToggle?: boolean;
34
+ showChangeLayoutToggle?: boolean;
35
+ viewMoreToggle?: boolean;
36
+ showAddNewButton?: boolean;
37
+ showSearch?: boolean;
38
+ showFilter?: boolean;
39
+ showCustomizationToggle?: boolean;
40
+ }
41
+
42
+ export interface CraftTableProps<T> {
43
+ data: T[];
44
+ columns: ColumnDef<T>[];
45
+ tableStates: CraftTableOptionsProps;
46
+ paginationOptions?: CraftTablePaginationProps;
47
+ featureOptions?: CraftTableFeatureProps;
48
+ nestedComponent?: React.ComponentType<{ row: Row<T> }>;
49
+ loadingOptions?: LoadingOptionsProps;
50
+ topbarOptions?: TopbarOptionsProps;
51
+ }
52
+
53
+ export interface CraftTableComponentProps<T> {
54
+ table: Table<T>;
55
+ featureOptions: CraftTableFeatureProps;
56
+ NestedComponent?: React.ComponentType<{ row: Row<T> }>;
57
+ columnOrder: ColumnOrderState;
58
+ setColumnOrder: React.Dispatch<React.SetStateAction<ColumnOrderState>>;
59
+ isCompactTable: boolean;
60
+ }
61
+
62
+ export interface TableHeaderProps<T> {
63
+ header: Header<T, unknown>;
64
+ featureOptions: CraftTableFeatureProps;
65
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />