-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
34 lines (29 loc) · 899 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { DEFAULT_LOCKED_COLUMN_STYLES, TABLE_PARTIALS } from './constants'
export const getLockedColumnStyles = (currentColumn, allColumns, tablePart) => {
let left = 0
let width = DEFAULT_LOCKED_COLUMN_STYLES['max-width']
let finded = false
allColumns.forEach((col, idx) => {
if (col.dataIndex !== currentColumn.dataIndex && !finded) {
left += col?.customStyles?.data?.width || width
}
if (!finded) {
switch (tablePart) {
case TABLE_PARTIALS.HEADER:
width = currentColumn?.customStyles?.header?.width || width
break
case TABLE_PARTIALS.DATA:
width = currentColumn?.customStyles?.data?.width || width
break
}
}
if (col.dataIndex === currentColumn.dataIndex) {
finded = true
}
})
return {
left: `${left}px`,
'max-width': `${width}px`,
'min-width': `${width}px`
}
}