@tanstack/table-core 8.0.0-alpha.53 → 8.0.0-alpha.57

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 (117) hide show
  1. package/build/cjs/core.js +9 -384
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/createTable.js.map +1 -1
  4. package/build/cjs/features/Cells.js +122 -0
  5. package/build/cjs/features/Cells.js.map +1 -0
  6. package/build/cjs/features/ColumnSizing.js +90 -37
  7. package/build/cjs/features/ColumnSizing.js.map +1 -1
  8. package/build/cjs/features/Columns.js +216 -0
  9. package/build/cjs/features/Columns.js.map +1 -0
  10. package/build/cjs/features/Expanding.js +1 -1
  11. package/build/cjs/features/Expanding.js.map +1 -1
  12. package/build/cjs/features/Filters.js +1 -1
  13. package/build/cjs/features/Filters.js.map +1 -1
  14. package/build/cjs/features/Grouping.js +1 -1
  15. package/build/cjs/features/Grouping.js.map +1 -1
  16. package/build/cjs/features/Headers.js +78 -153
  17. package/build/cjs/features/Headers.js.map +1 -1
  18. package/build/cjs/features/Ordering.js +2 -2
  19. package/build/cjs/features/Ordering.js.map +1 -1
  20. package/build/cjs/features/Pagination.js +1 -1
  21. package/build/cjs/features/Pagination.js.map +1 -1
  22. package/build/cjs/features/Pinning.js +172 -2
  23. package/build/cjs/features/Pinning.js.map +1 -1
  24. package/build/cjs/features/RowSelection.js +1 -1
  25. package/build/cjs/features/RowSelection.js.map +1 -1
  26. package/build/cjs/features/Rows.js +99 -0
  27. package/build/cjs/features/Rows.js.map +1 -0
  28. package/build/cjs/features/Sorting.js +1 -1
  29. package/build/cjs/features/Sorting.js.map +1 -1
  30. package/build/cjs/features/Visibility.js +51 -17
  31. package/build/cjs/features/Visibility.js.map +1 -1
  32. package/build/cjs/filterFns.js.map +1 -1
  33. package/build/cjs/sortingFns.js.map +1 -1
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getColumnFilteredRowModelSync.js.map +1 -1
  36. package/build/cjs/utils/getCoreRowModelAsync.js.map +1 -1
  37. package/build/cjs/utils/getCoreRowModelSync.js.map +1 -1
  38. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  39. package/build/cjs/utils/getGlobalFilteredRowModelSync.js.map +1 -1
  40. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  41. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  42. package/build/cjs/utils/getSortedRowModelSync.js.map +1 -1
  43. package/build/cjs/utils.js +2 -2
  44. package/build/cjs/utils.js.map +1 -1
  45. package/build/esm/index.js +879 -693
  46. package/build/esm/index.js.map +1 -1
  47. package/build/stats-html.html +1 -1
  48. package/build/stats-react.json +420 -318
  49. package/build/types/core.d.ts +5 -82
  50. package/build/types/createTable.d.ts +4 -4
  51. package/build/types/features/Cells.d.ts +14 -0
  52. package/build/types/features/ColumnSizing.d.ts +31 -23
  53. package/build/types/features/Columns.d.ts +54 -0
  54. package/build/types/features/Expanding.d.ts +6 -6
  55. package/build/types/features/Filters.d.ts +14 -14
  56. package/build/types/features/Grouping.d.ts +16 -16
  57. package/build/types/features/Headers.d.ts +5 -13
  58. package/build/types/features/Ordering.d.ts +5 -5
  59. package/build/types/features/Pagination.d.ts +5 -5
  60. package/build/types/features/Pinning.d.ts +21 -7
  61. package/build/types/features/RowSelection.d.ts +8 -8
  62. package/build/types/features/Rows.d.ts +29 -0
  63. package/build/types/features/Sorting.d.ts +12 -12
  64. package/build/types/features/Visibility.d.ts +11 -6
  65. package/build/types/filterFns.d.ts +10 -10
  66. package/build/types/sortingFns.d.ts +7 -7
  67. package/build/types/types.d.ts +37 -33
  68. package/build/types/utils/filterRowsUtils.d.ts +3 -3
  69. package/build/types/utils/getColumnFilteredRowModelAsync.d.ts +2 -2
  70. package/build/types/utils/getColumnFilteredRowModelSync.d.ts +2 -2
  71. package/build/types/utils/getCoreRowModelAsync.d.ts +2 -2
  72. package/build/types/utils/getCoreRowModelSync.d.ts +2 -2
  73. package/build/types/utils/getExpandedRowModel.d.ts +3 -3
  74. package/build/types/utils/getGlobalFilteredRowModelAsync.d.ts +2 -2
  75. package/build/types/utils/getGlobalFilteredRowModelSync.d.ts +2 -2
  76. package/build/types/utils/getGroupedRowModel.d.ts +2 -2
  77. package/build/types/utils/getPaginationRowModel.d.ts +2 -2
  78. package/build/types/utils/getSortedRowModelAsync.d.ts +4 -4
  79. package/build/types/utils/getSortedRowModelSync.d.ts +2 -2
  80. package/build/types/utils.d.ts +0 -1
  81. package/build/umd/index.development.js +857 -671
  82. package/build/umd/index.development.js.map +1 -1
  83. package/build/umd/index.production.js +1 -1
  84. package/build/umd/index.production.js.map +1 -1
  85. package/package.json +1 -1
  86. package/src/core.ts +32 -554
  87. package/src/createTable.ts +12 -5
  88. package/src/features/Cells.ts +156 -0
  89. package/src/features/ColumnSizing.ts +109 -58
  90. package/src/features/Columns.ts +290 -0
  91. package/src/features/Expanding.ts +6 -7
  92. package/src/features/Filters.ts +14 -15
  93. package/src/features/Grouping.ts +16 -17
  94. package/src/features/Headers.ts +51 -142
  95. package/src/features/Ordering.ts +8 -7
  96. package/src/features/Pagination.ts +5 -6
  97. package/src/features/Pinning.ts +198 -8
  98. package/src/features/RowSelection.ts +9 -10
  99. package/src/features/Rows.ts +151 -0
  100. package/src/features/Sorting.ts +12 -13
  101. package/src/features/Visibility.ts +73 -27
  102. package/src/filterFns.ts +10 -10
  103. package/src/sortingFns.ts +7 -7
  104. package/src/types.ts +47 -65
  105. package/src/utils/filterRowsUtils.ts +3 -3
  106. package/src/utils/getColumnFilteredRowModelAsync.ts +2 -2
  107. package/src/utils/getColumnFilteredRowModelSync.ts +2 -2
  108. package/src/utils/getCoreRowModelAsync.ts +2 -2
  109. package/src/utils/getCoreRowModelSync.ts +2 -2
  110. package/src/utils/getExpandedRowModel.ts +3 -3
  111. package/src/utils/getGlobalFilteredRowModelAsync.ts +2 -2
  112. package/src/utils/getGlobalFilteredRowModelSync.ts +2 -2
  113. package/src/utils/getGroupedRowModel.ts +3 -3
  114. package/src/utils/getPaginationRowModel.ts +2 -2
  115. package/src/utils/getSortedRowModelAsync.ts +4 -4
  116. package/src/utils/getSortedRowModelSync.ts +2 -2
  117. package/src/utils.ts +3 -5
@@ -1,17 +1,24 @@
1
1
  import { CustomFilterFns, FilterFn } from './features/Filters'
2
2
  import { AggregationFn, CustomAggregationFns } from './features/Grouping'
3
3
  import { CustomSortingFns, SortingFn } from './features/Sorting'
4
- import { ColumnDef, AccessorFn, AnyRender, AnyGenerics, Options } from './types'
4
+ import {
5
+ ColumnDef,
6
+ AccessorFn,
7
+ AnyRender,
8
+ TableGenerics,
9
+ Options,
10
+ } from './types'
5
11
  import { IfDefined, Overwrite, PartialKeys } from './utils'
6
12
 
7
- export type TableFactory<TGenerics extends AnyGenerics> = () => Table<TGenerics>
13
+ export type TableFactory<TGenerics extends TableGenerics> =
14
+ () => Table<TGenerics>
8
15
 
9
16
  export type CreateTableOptions<
10
17
  TRender extends AnyRender,
11
18
  TFilterFns extends CustomFilterFns<any>,
12
19
  TSortingFns extends CustomSortingFns<any>,
13
20
  TAggregationFns extends CustomAggregationFns<any>,
14
- TGenerics extends AnyGenerics
21
+ TGenerics extends TableGenerics
15
22
  > = Partial<
16
23
  {
17
24
  render?: TRender
@@ -21,7 +28,7 @@ export type CreateTableOptions<
21
28
  } & Omit<Options<TGenerics>, 'filterFns' | 'sortingFns' | 'aggregationFns'>
22
29
  >
23
30
 
24
- export type Table<TGenerics extends AnyGenerics> = {
31
+ export type Table<TGenerics extends TableGenerics> = {
25
32
  generics: TGenerics
26
33
  options: Partial<Options<TGenerics>>
27
34
  setRowType: <TRow>() => Table<Overwrite<TGenerics, { Row: TRow }>>
@@ -125,7 +132,7 @@ export function createTableFactory<TRender extends AnyRender>(opts: {
125
132
 
126
133
  // A lot of returns in here are `as any` for a reason. Unless you
127
134
  // can find a better way to do this, then don't worry about them
128
- function createTable<TGenerics extends AnyGenerics>(
135
+ function createTable<TGenerics extends TableGenerics>(
129
136
  _?: undefined,
130
137
  __?: undefined,
131
138
  options?: CreateTableOptions<any, any, any, any, TGenerics>
@@ -0,0 +1,156 @@
1
+ import {
2
+ Cell,
3
+ TableGenerics,
4
+ TableInstance,
5
+ Row,
6
+ Column,
7
+ CoreCell,
8
+ Getter,
9
+ CellProps,
10
+ PropGetterValue,
11
+ } from '../types'
12
+ import { memo, propGetter } from '../utils'
13
+
14
+ export type CellsRow<TGenerics extends TableGenerics> = {
15
+ getAllCells: () => Cell<TGenerics>[]
16
+ getAllCellsByColumnId: () => Record<string, Cell<TGenerics>>
17
+ }
18
+
19
+ export type CellsInstance<TGenerics extends TableGenerics> = {
20
+ createCell: (
21
+ row: Row<TGenerics>,
22
+ column: Column<TGenerics>,
23
+ value: any
24
+ ) => Cell<TGenerics>
25
+ getCell: (rowId: string, columnId: string) => Cell<TGenerics>
26
+ getCellProps: <TGetter extends Getter<CellProps>>(
27
+ rowId: string,
28
+ columnId: string,
29
+ userProps?: TGetter
30
+ ) => undefined | PropGetterValue<CellProps, TGetter>
31
+ }
32
+
33
+ //
34
+
35
+ export const Cells = {
36
+ createRow: <TGenerics extends TableGenerics>(
37
+ row: Row<TGenerics>,
38
+ instance: TableInstance<TGenerics>
39
+ ): CellsRow<TGenerics> => {
40
+ return {
41
+ getAllCells: memo(
42
+ () => [instance.getAllLeafColumns()],
43
+ leafColumns => {
44
+ return leafColumns.map(column => {
45
+ return instance.createCell(
46
+ row as Row<TGenerics>,
47
+ column,
48
+ row.values[column.id]
49
+ )
50
+ })
51
+ },
52
+ {
53
+ key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
54
+ debug: () => instance.options.debugAll ?? instance.options.debugRows,
55
+ }
56
+ ),
57
+
58
+ getAllCellsByColumnId: memo(
59
+ () => [row.getAllCells()],
60
+ allCells => {
61
+ return allCells.reduce((acc, cell) => {
62
+ acc[cell.columnId] = cell
63
+ return acc
64
+ }, {} as Record<string, Cell<TGenerics>>)
65
+ },
66
+ {
67
+ key: 'row.getAllCellsByColumnId',
68
+ debug: () => instance.options.debugAll ?? instance.options.debugRows,
69
+ }
70
+ ),
71
+ }
72
+ },
73
+
74
+ createInstance: <TGenerics extends TableGenerics>(
75
+ instance: TableInstance<TGenerics>
76
+ ): CellsInstance<TGenerics> => {
77
+ return {
78
+ createCell: (row, column, value) => {
79
+ const cell: CoreCell<TGenerics> = {
80
+ id: `${row.id}_${column.id}`,
81
+ rowId: row.id,
82
+ columnId: column.id,
83
+ row,
84
+ column,
85
+ value,
86
+ getCellProps: userProps =>
87
+ instance.getCellProps(row.id, column.id, userProps)!,
88
+ renderCell: () =>
89
+ column.cell
90
+ ? instance.render(column.cell, {
91
+ instance,
92
+ column,
93
+ row,
94
+ cell: cell as Cell<TGenerics>,
95
+ value,
96
+ })
97
+ : null,
98
+ }
99
+
100
+ instance._features.forEach(feature => {
101
+ Object.assign(
102
+ cell,
103
+ feature.createCell?.(
104
+ cell as Cell<TGenerics>,
105
+ column,
106
+ row as Row<TGenerics>,
107
+ instance
108
+ )
109
+ )
110
+ }, {})
111
+
112
+ return cell as Cell<TGenerics>
113
+ },
114
+
115
+ getCell: (rowId: string, columnId: string) => {
116
+ const row = instance.getRow(rowId)
117
+
118
+ if (!row) {
119
+ if (process.env.NODE_ENV !== 'production') {
120
+ throw new Error(`[Table] could not find row with id ${rowId}`)
121
+ }
122
+ throw new Error()
123
+ }
124
+
125
+ const cell = row.getAllCellsByColumnId()[columnId]
126
+
127
+ if (!cell) {
128
+ if (process.env.NODE_ENV !== 'production') {
129
+ throw new Error(
130
+ `[Table] could not find cell ${columnId} in row ${rowId}`
131
+ )
132
+ }
133
+ throw new Error()
134
+ }
135
+
136
+ return cell
137
+ },
138
+
139
+ getCellProps: (rowId, columnId, userProps) => {
140
+ const cell = instance.getCell(rowId, columnId)
141
+
142
+ if (!cell) {
143
+ return
144
+ }
145
+
146
+ return propGetter(
147
+ {
148
+ key: cell.id,
149
+ role: 'gridcell',
150
+ },
151
+ userProps
152
+ )
153
+ },
154
+ }
155
+ },
156
+ }
@@ -3,17 +3,22 @@ import {
3
3
  Getter,
4
4
  Header,
5
5
  OnChangeFn,
6
- AnyGenerics,
7
- PartialGenerics,
6
+ TableGenerics,
8
7
  PropGetterValue,
9
8
  TableInstance,
10
9
  Updater,
11
10
  } from '../types'
12
- import { functionalUpdate, makeStateUpdater, memo, propGetter } from '../utils'
11
+ import { makeStateUpdater, propGetter } from '../utils'
12
+ import { ColumnPinningPosition } from './Pinning'
13
13
 
14
14
  //
15
15
 
16
- export type ColumnSizing = Record<string, number>
16
+ export type ColumnSizingTableState = {
17
+ columnSizing: ColumnSizingState
18
+ columnSizingInfo: ColumnSizingInfoState
19
+ }
20
+
21
+ export type ColumnSizingState = Record<string, number>
17
22
 
18
23
  export type ColumnSizingInfoState = {
19
24
  startOffset: null | number
@@ -24,23 +29,18 @@ export type ColumnSizingInfoState = {
24
29
  columnSizingStart: [string, number][]
25
30
  }
26
31
 
27
- export type ColumnSizingTableState = {
28
- columnSizing: ColumnSizing
29
- columnSizingInfo: ColumnSizingInfoState
30
- }
31
-
32
32
  export type ColumnResizeMode = 'onChange' | 'onEnd'
33
33
 
34
34
  export type ColumnSizingOptions = {
35
35
  enableColumnResizing?: boolean
36
36
  columnResizeMode?: ColumnResizeMode
37
- onColumnSizingChange?: OnChangeFn<ColumnSizing>
37
+ onColumnSizingChange?: OnChangeFn<ColumnSizingState>
38
38
  onColumnSizingInfoChange?: OnChangeFn<ColumnSizingInfoState>
39
39
  }
40
40
 
41
41
  export type ColumnSizingDefaultOptions = {
42
42
  columnResizeMode: ColumnResizeMode
43
- onColumnSizingChange: OnChangeFn<ColumnSizing>
43
+ onColumnSizingChange: OnChangeFn<ColumnSizingState>
44
44
  onColumnSizingInfoChange: OnChangeFn<ColumnSizingInfoState>
45
45
  }
46
46
 
@@ -52,9 +52,10 @@ export type ColumnResizerProps = {
52
52
  role?: string
53
53
  }
54
54
 
55
- export type ColumnSizingInstance<TGenerics extends AnyGenerics> = {
56
- getColumnWidth: (columnId: string) => number
57
- setColumnSizing: (updater: Updater<ColumnSizing>) => void
55
+ export type ColumnSizingInstance<TGenerics extends TableGenerics> = {
56
+ getColumnSize: (columnId: string) => number
57
+ getColumnStart: (columnId: string, position?: ColumnPinningPosition) => number
58
+ setColumnSizing: (updater: Updater<ColumnSizingState>) => void
58
59
  setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void
59
60
  resetColumnSizing: () => void
60
61
  resetColumnSize: (columnId: string) => void
@@ -68,23 +69,29 @@ export type ColumnSizingInstance<TGenerics extends AnyGenerics> = {
68
69
  ) => undefined | PropGetterValue<ColumnResizerProps, TGetter>
69
70
  getColumnIsResizing: (columnId: string) => boolean
70
71
  getHeaderIsResizing: (headerId: string) => boolean
72
+ getTotalSize: () => number
73
+ getLeftTotalSize: () => number
74
+ getCenterTotalSize: () => number
75
+ getRightTotalSize: () => number
71
76
  }
72
77
 
73
78
  export type ColumnSizingColumnDef = {
74
79
  enableResizing?: boolean
75
80
  defaultCanResize?: boolean
76
- width?: number
77
- minWidth?: number
78
- maxWidth?: number
81
+ size?: number
82
+ minSize?: number
83
+ maxSize?: number
79
84
  }
80
85
 
81
- export type ColumnSizingColumn<TGenerics extends AnyGenerics> = {
86
+ export type ColumnSizingColumn<TGenerics extends TableGenerics> = {
87
+ getSize: () => number
88
+ getStart: (position?: ColumnPinningPosition) => number
82
89
  getCanResize: () => boolean
83
90
  getIsResizing: () => boolean
84
91
  resetSize: () => void
85
92
  }
86
93
 
87
- export type ColumnSizingHeader<TGenerics extends AnyGenerics> = {
94
+ export type ColumnSizingHeader<TGenerics extends TableGenerics> = {
88
95
  getCanResize: () => boolean
89
96
  getIsResizing: () => boolean
90
97
  getResizerProps: <TGetter extends Getter<ColumnResizerProps>>(
@@ -96,9 +103,9 @@ export type ColumnSizingHeader<TGenerics extends AnyGenerics> = {
96
103
  //
97
104
 
98
105
  export const defaultColumnSizing = {
99
- width: 150,
100
- minWidth: 20,
101
- maxWidth: Number.MAX_SAFE_INTEGER,
106
+ size: 150,
107
+ minSize: 20,
108
+ maxSize: Number.MAX_SAFE_INTEGER,
102
109
  }
103
110
 
104
111
  export const ColumnSizing = {
@@ -119,7 +126,7 @@ export const ColumnSizing = {
119
126
  }
120
127
  },
121
128
 
122
- getDefaultOptions: <TGenerics extends AnyGenerics>(
129
+ getDefaultOptions: <TGenerics extends TableGenerics>(
123
130
  instance: TableInstance<TGenerics>
124
131
  ): ColumnSizingDefaultOptions => {
125
132
  return {
@@ -129,11 +136,37 @@ export const ColumnSizing = {
129
136
  }
130
137
  },
131
138
 
132
- getInstance: <TGenerics extends AnyGenerics>(
139
+ createColumn: <TGenerics extends TableGenerics>(
140
+ column: Column<TGenerics>,
141
+ instance: TableInstance<TGenerics>
142
+ ): ColumnSizingColumn<TGenerics> => {
143
+ return {
144
+ getSize: () => instance.getColumnSize(column.id),
145
+ getStart: position => instance.getColumnStart(column.id, position),
146
+ getIsResizing: () => instance.getColumnIsResizing(column.id),
147
+ getCanResize: () => instance.getColumnCanResize(column.id),
148
+ resetSize: () => instance.resetColumnSize(column.id),
149
+ }
150
+ },
151
+
152
+ createHeader: <TGenerics extends TableGenerics>(
153
+ header: Header<TGenerics>,
154
+ instance: TableInstance<TGenerics>
155
+ ): ColumnSizingHeader<TGenerics> => {
156
+ return {
157
+ getIsResizing: () => instance.getColumnIsResizing(header.column.id),
158
+ getCanResize: () => instance.getColumnCanResize(header.column.id),
159
+ resetSize: () => instance.resetColumnSize(header.column.id),
160
+ getResizerProps: userProps =>
161
+ instance.getHeaderResizerProps(header.id, userProps),
162
+ }
163
+ },
164
+
165
+ createInstance: <TGenerics extends TableGenerics>(
133
166
  instance: TableInstance<TGenerics>
134
167
  ): ColumnSizingInstance<TGenerics> => {
135
168
  return {
136
- getColumnWidth: (columnId: string) => {
169
+ getColumnSize: (columnId: string) => {
137
170
  const column = instance.getColumn(columnId)
138
171
 
139
172
  if (!column) {
@@ -144,12 +177,38 @@ export const ColumnSizing = {
144
177
 
145
178
  return Math.min(
146
179
  Math.max(
147
- column.minWidth ?? defaultColumnSizing.minWidth,
148
- columnSize ?? column.width ?? defaultColumnSizing.width
180
+ column.minSize ?? defaultColumnSizing.minSize,
181
+ columnSize ?? column.size ?? defaultColumnSizing.size
149
182
  ),
150
- column.maxWidth ?? defaultColumnSizing.maxWidth
183
+ column.maxSize ?? defaultColumnSizing.maxSize
151
184
  )
152
185
  },
186
+ getColumnStart: (columnId, position) => {
187
+ const column = instance.getColumn(columnId)
188
+
189
+ if (!column) {
190
+ throw new Error()
191
+ }
192
+
193
+ const columns = !position
194
+ ? instance.getVisibleLeafColumns()
195
+ : position === 'left'
196
+ ? instance.getLeftVisibleLeafColumns()
197
+ : instance.getRightVisibleLeafColumns()
198
+
199
+ const index = columns.findIndex(d => d.id === columnId)
200
+
201
+ if (index > 0) {
202
+ const prevSiblingColumn = columns[index - 1]
203
+
204
+ return (
205
+ instance.getColumnStart(prevSiblingColumn.id, position) +
206
+ prevSiblingColumn.getSize()
207
+ )
208
+ }
209
+
210
+ return 0
211
+ },
153
212
  setColumnSizing: updater =>
154
213
  instance.options.onColumnSizingChange?.(updater),
155
214
  setColumnSizingInfo: updater =>
@@ -232,11 +291,11 @@ export const ColumnSizing = {
232
291
 
233
292
  const header = headerId ? instance.getHeader(headerId) : undefined
234
293
 
235
- const startSize = header ? header.getWidth() : column.getWidth()
294
+ const startSize = header ? header.getSize() : column.getSize()
236
295
 
237
296
  const columnSizingStart: [string, number][] = header
238
- ? header.getLeafHeaders().map(d => [d.column.id, d.getWidth()])
239
- : [[column.id, column.getWidth()]]
297
+ ? header.getLeafHeaders().map(d => [d.column.id, d.getSize()])
298
+ : [[column.id, column.getSize()]]
240
299
 
241
300
  const clientX = isTouchStartEvent(e)
242
301
  ? Math.round(e.touches[0].clientX)
@@ -250,7 +309,7 @@ export const ColumnSizing = {
250
309
  return
251
310
  }
252
311
 
253
- let newColumnSizing: ColumnSizing = {}
312
+ let newColumnSizing: ColumnSizingState = {}
254
313
 
255
314
  instance.setColumnSizingInfo(old => {
256
315
  const deltaOffset = clientXPos - (old?.startOffset ?? 0)
@@ -259,11 +318,10 @@ export const ColumnSizing = {
259
318
  -0.999999
260
319
  )
261
320
 
262
- old.columnSizingStart.forEach(([columnId, headerWidth]) => {
321
+ old.columnSizingStart.forEach(([columnId, headerSize]) => {
263
322
  newColumnSizing[columnId] =
264
323
  Math.round(
265
- Math.max(headerWidth + headerWidth * deltaPercentage, 0) *
266
- 100
324
+ Math.max(headerSize + headerSize * deltaPercentage, 0) * 100
267
325
  ) / 100
268
326
  })
269
327
 
@@ -388,30 +446,23 @@ export const ColumnSizing = {
388
446
 
389
447
  return propGetter(initialProps, userProps)
390
448
  },
391
- }
392
- },
393
449
 
394
- createColumn: <TGenerics extends AnyGenerics>(
395
- column: Column<TGenerics>,
396
- instance: TableInstance<TGenerics>
397
- ): ColumnSizingColumn<TGenerics> => {
398
- return {
399
- getIsResizing: () => instance.getColumnIsResizing(column.id),
400
- getCanResize: () => instance.getColumnCanResize(column.id),
401
- resetSize: () => instance.resetColumnSize(column.id),
402
- }
403
- },
404
-
405
- createHeader: <TGenerics extends AnyGenerics>(
406
- header: Header<TGenerics>,
407
- instance: TableInstance<TGenerics>
408
- ): ColumnSizingHeader<TGenerics> => {
409
- return {
410
- getIsResizing: () => instance.getColumnIsResizing(header.column.id),
411
- getCanResize: () => instance.getColumnCanResize(header.column.id),
412
- resetSize: () => instance.resetColumnSize(header.column.id),
413
- getResizerProps: userProps =>
414
- instance.getHeaderResizerProps(header.id, userProps),
450
+ getTotalSize: () =>
451
+ instance.getHeaderGroups()[0]?.headers.reduce((sum, header) => {
452
+ return sum + header.getSize()
453
+ }, 0) ?? 0,
454
+ getLeftTotalSize: () =>
455
+ instance.getLeftHeaderGroups()[0]?.headers.reduce((sum, header) => {
456
+ return sum + header.getSize()
457
+ }, 0) ?? 0,
458
+ getCenterTotalSize: () =>
459
+ instance.getCenterHeaderGroups()[0]?.headers.reduce((sum, header) => {
460
+ return sum + header.getSize()
461
+ }, 0) ?? 0,
462
+ getRightTotalSize: () =>
463
+ instance.getRightHeaderGroups()[0]?.headers.reduce((sum, header) => {
464
+ return sum + header.getSize()
465
+ }, 0) ?? 0,
415
466
  }
416
467
  },
417
468
  }