forked from pavlitoPogosov/React-Table-Component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
32 lines (29 loc) · 775 Bytes
/
Copy pathutils.ts
File metadata and controls
32 lines (29 loc) · 775 Bytes
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
import type {Table} from '@tanstack/react-table';
import type {CSSProperties} from 'styled-components';
export const getTableCellStyle = ({
size,
minSize,
maxSize,
flexGrow = 1,
}: {
size?: number | string;
minSize?: number | string;
maxSize?: number | string;
flexGrow?: number;
}): CSSProperties => ({
width: size,
maxWidth: maxSize,
minWidth: minSize,
flexGrow,
});
export const getTableCbxCellStyle = (): CSSProperties => ({
flex: '40px 0 auto',
minWidth: 0,
width: 40,
});
export const getTableExtraDataModel = <D extends Record<string, any>>(table: Table<D>, name: string) => ({
value: table.options.meta?.getExtraData()[name],
onChange: <V extends any>(value: V) => {
table.options.meta?.updateExtraData(name, value);
},
});