-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
cellBorderUtils.ts
33 lines (30 loc) · 1.03 KB
/
cellBorderUtils.ts
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
import { GridPinnedColumnPosition } from '../hooks/features/columns/gridColumnsInterfaces';
export const shouldCellShowRightBorder = (
pinnedPosition: GridPinnedColumnPosition | undefined,
indexInSection: number,
sectionLength: number,
showCellVerticalBorderRootProp: boolean,
gridHasFiller: boolean,
) => {
const isSectionLastCell = indexInSection === sectionLength - 1;
if (pinnedPosition === GridPinnedColumnPosition.LEFT && isSectionLastCell) {
return true;
}
if (showCellVerticalBorderRootProp) {
if (pinnedPosition === GridPinnedColumnPosition.LEFT) {
return true;
}
if (pinnedPosition === GridPinnedColumnPosition.RIGHT) {
return !isSectionLastCell;
}
// pinnedPosition === undefined, middle section
return !isSectionLastCell || gridHasFiller;
}
return false;
};
export const shouldCellShowLeftBorder = (
pinnedPosition: GridPinnedColumnPosition | undefined,
indexInSection: number,
) => {
return pinnedPosition === GridPinnedColumnPosition.RIGHT && indexInSection === 0;
};