@@ -33,6 +33,21 @@ export const cellStyle = (id: string, columns: Columns | undefined) => {
33
33
// Create and return styles separated by ';'
34
34
return styles . join ( ';' ) ;
35
35
} ;
36
+ // Styles for resizing the cells
37
+ export const getResizeStyles = (
38
+ rowHeights : { [ key : number ] : { max : number ; min : number } } ,
39
+ id : string | number ,
40
+ index : number
41
+ ) => {
42
+ return `
43
+ min-height: ${ rowHeights && rowHeights [ + id ] ? `${ rowHeights [ + id ] . min } px` : 'auto' } ;
44
+ max-height: ${ index !== 0 && rowHeights && rowHeights [ + id ]
45
+ ? `${ rowHeights [ + id ] . max } px`
46
+ : 'auto'
47
+ } ;
48
+ height: ${ rowHeights && rowHeights [ + id ] ? `${ rowHeights [ + id ] . min } px` : 'auto' } ;
49
+ ` ;
50
+ }
36
51
// Function to normalize the filters for back-end
37
52
export const normalizeFilters = ( filters : {
38
53
[ key : string ] : { [ key in FilterOptionsEnum ] ?: number | string | Date } ;
@@ -54,7 +69,7 @@ export const normalizeFilters = (filters: {
54
69
55
70
return filter ;
56
71
} ;
57
-
72
+ // Creates a CSV file and downloads it
58
73
export const exportAsCsv = ( tableId : string , exportedData : string ) => {
59
74
// Creating a hidden anchor element to download the CSV file
60
75
const anchor = document . createElement ( 'a' ) ;
@@ -65,7 +80,7 @@ export const exportAsCsv = (tableId: string, exportedData: string) => {
65
80
anchor . click ( ) ;
66
81
document . body . removeChild ( anchor ) ;
67
82
} ;
68
-
83
+ // Function to convert JSON data to CSV format
69
84
export const jsonToCsv = ( data : string ) : string => {
70
85
const json = JSON . parse ( data ) ;
71
86
@@ -96,7 +111,6 @@ export const jsonToCsv = (data: string): string => {
96
111
// Join rows with newlines
97
112
return rows . join ( '\n' ) ;
98
113
}
99
-
100
114
// Resetting the resized columns and/or rows
101
115
export const resetResize = (
102
116
headerRows : any ,
@@ -140,7 +154,7 @@ export const resetResize = (
140
154
} ) ;
141
155
}
142
156
} ;
143
-
157
+ // Finds the mapping for missing values
144
158
export const missingValuesFn = (
145
159
key : number | string ,
146
160
missingValues : { [ key : string | number ] : string }
@@ -160,7 +174,6 @@ export const missingValuesFn = (
160
174
161
175
return foundKey ? missingValues [ foundKey ] : key ;
162
176
} ;
163
-
164
177
// Function to update the server-side table data
165
178
export const updateTable = async (
166
179
pageSize : number ,
@@ -230,7 +243,7 @@ export const updateTable = async (
230
243
231
244
return response ;
232
245
} ;
233
-
246
+ // Function to convert server data to client data
234
247
export const convertServerColumns = (
235
248
serverColumns : ServerColumn [ ] ,
236
249
columns : Columns | undefined
@@ -288,7 +301,6 @@ export const convertServerColumns = (
288
301
289
302
return columnsConfig ;
290
303
} ;
291
-
292
304
// Calculates the maximum height of the cells in each row
293
305
export const getMaxCellHeightInRow = (
294
306
tableRef : HTMLTableElement ,
@@ -329,7 +341,6 @@ export const getMaxCellHeightInRow = (
329
341
} ) ;
330
342
} ) ;
331
343
} ;
332
-
333
344
// Calculates the minimum width of the cells in each column
334
345
export const getMinCellWidthInColumn = (
335
346
tableRef : HTMLTableElement ,
@@ -355,19 +366,4 @@ export const getMinCellWidthInColumn = (
355
366
} ) ;
356
367
return cw ;
357
368
} ) ;
358
- } ;
359
-
360
- export const getResizeStyles = (
361
- rowHeights : { [ key : number ] : { max : number ; min : number } } ,
362
- id : string | number ,
363
- index : number
364
- ) => {
365
- return `
366
- min-height: ${ rowHeights && rowHeights [ + id ] ? `${ rowHeights [ + id ] . min } px` : 'auto' } ;
367
- max-height: ${ index !== 0 && rowHeights && rowHeights [ + id ]
368
- ? `${ rowHeights [ + id ] . max } px`
369
- : 'auto'
370
- } ;
371
- height: ${ rowHeights && rowHeights [ + id ] ? `${ rowHeights [ + id ] . min } px` : 'auto' } ;
372
- ` ;
373
- }
369
+ } ;
0 commit comments