@tanstack/table-core 8.0.0-alpha.67 → 8.0.0-alpha.68
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.
- package/build/cjs/aggregationFns.js +25 -37
- package/build/cjs/aggregationFns.js.map +1 -1
- package/build/cjs/core.js +167 -46
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/createTable.js +24 -40
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/Cells.js +28 -34
- package/build/cjs/features/Cells.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +90 -107
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Columns.js +52 -79
- package/build/cjs/features/Columns.js.map +1 -1
- package/build/cjs/features/Expanding.js +48 -57
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +96 -191
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +52 -70
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +109 -165
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Ordering.js +30 -42
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js +63 -71
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +65 -121
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +92 -111
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Rows.js +32 -22
- package/build/cjs/features/Rows.js.map +1 -1
- package/build/cjs/features/Sorting.js +49 -68
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +43 -87
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/filterFns.js +48 -72
- package/build/cjs/filterFns.js.map +1 -1
- package/build/cjs/index.js +13 -13
- package/build/cjs/sortingFns.js +21 -21
- package/build/cjs/sortingFns.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +49 -55
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +98 -0
- package/build/cjs/utils/getCoreRowModel.js.map +1 -0
- package/build/cjs/utils/getExpandedRowModel.js +17 -21
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getFacetedMinMaxValues.js +48 -0
- package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -0
- package/build/cjs/utils/getFacetedRowModel.js +50 -0
- package/build/cjs/utils/getFacetedRowModel.js.map +1 -0
- package/build/cjs/utils/getFacetedUniqueValues.js +48 -0
- package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -0
- package/build/cjs/utils/getFilteredRowModel.js +130 -0
- package/build/cjs/utils/getFilteredRowModel.js.map +1 -0
- package/build/cjs/utils/getGroupedRowModel.js +126 -136
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +39 -39
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/cjs/utils/getSortedRowModel.js +112 -0
- package/build/cjs/utils/getSortedRowModel.js.map +1 -0
- package/build/cjs/utils.js +36 -207
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +1729 -2313
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +421 -481
- package/build/types/core.d.ts +3 -5
- package/build/types/features/Cells.d.ts +1 -1
- package/build/types/features/Columns.d.ts +1 -1
- package/build/types/features/Filters.d.ts +10 -5
- package/build/types/features/Grouping.d.ts +4 -3
- package/build/types/features/Rows.d.ts +4 -3
- package/build/types/index.d.ts +6 -4
- package/build/types/types.d.ts +3 -13
- package/build/types/utils/filterRowsUtils.d.ts +3 -3
- package/build/types/utils/getCoreRowModel.d.ts +2 -0
- package/build/types/utils/getFacetedMinMaxValues.d.ts +2 -0
- package/build/types/utils/getFacetedRowModel.d.ts +2 -0
- package/build/types/utils/getFacetedUniqueValues.d.ts +2 -0
- package/build/types/utils/{getCoreRowModelSync.d.ts → getFilteredRowModel.d.ts} +1 -1
- package/build/types/utils/getGroupedRowModel.d.ts +1 -1
- package/build/types/utils/getSortedRowModel.d.ts +2 -0
- package/build/types/utils.d.ts +1 -17
- package/build/umd/index.development.js +1730 -2316
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +197 -45
- package/src/features/Cells.ts +7 -11
- package/src/features/ColumnSizing.ts +6 -5
- package/src/features/Columns.ts +4 -8
- package/src/features/Filters.ts +95 -156
- package/src/features/Grouping.ts +16 -20
- package/src/features/Rows.ts +21 -6
- package/src/features/Sorting.ts +2 -2
- package/src/filterFns.ts +9 -9
- package/src/index.ts +12 -4
- package/src/sortingFns.ts +11 -11
- package/src/types.ts +3 -16
- package/src/utils/filterRowsUtils.ts +47 -68
- package/src/utils/{getCoreRowModelSync.ts → getCoreRowModel.ts} +2 -8
- package/src/utils/getFacetedMinMaxValues.ts +37 -0
- package/src/utils/getFacetedRowModel.ts +50 -0
- package/src/utils/getFacetedUniqueValues.ts +37 -0
- package/src/utils/{getFilteredRowModelSync.ts → getFilteredRowModel.ts} +29 -20
- package/src/utils/getGroupedRowModel.ts +52 -61
- package/src/utils/{getSortedRowModelSync.ts → getSortedRowModel.ts} +3 -3
- package/src/utils.ts +28 -236
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -112
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/utils/getCoreRowModelAsync.js +0 -125
- package/build/cjs/utils/getCoreRowModelAsync.js.map +0 -1
- package/build/cjs/utils/getCoreRowModelSync.js +0 -102
- package/build/cjs/utils/getCoreRowModelSync.js.map +0 -1
- package/build/cjs/utils/getFilteredRowModelSync.js +0 -125
- package/build/cjs/utils/getFilteredRowModelSync.js.map +0 -1
- package/build/cjs/utils/getSortedRowModelSync.js +0 -118
- package/build/cjs/utils/getSortedRowModelSync.js.map +0 -1
- package/build/types/utils/getCoreRowModelAsync.d.ts +0 -4
- package/build/types/utils/getFilteredRowModelAsync.d.ts +0 -4
- package/build/types/utils/getFilteredRowModelSync.d.ts +0 -2
- package/build/types/utils/getSortedRowModelAsync.d.ts +0 -13
- package/build/types/utils/getSortedRowModelSync.d.ts +0 -2
- package/src/utils/getCoreRowModelAsync.ts +0 -104
- package/src/utils/getFilteredRowModelAsync.ts +0 -157
- package/src/utils/getSortedRowModelAsync.ts +0 -200
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.68",
|
|
5
5
|
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/react-table#readme",
|
package/src/core.ts
CHANGED
|
@@ -26,10 +26,9 @@ import { Sorting } from './features/Sorting'
|
|
|
26
26
|
import { Visibility } from './features/Visibility'
|
|
27
27
|
import { Headers } from './features/Headers'
|
|
28
28
|
//
|
|
29
|
-
import { mean } from './aggregationFns'
|
|
30
29
|
|
|
31
30
|
export type CoreTableState = {
|
|
32
|
-
coreProgress: number
|
|
31
|
+
// coreProgress: number
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export type CoreOptions<TGenerics extends TableGenerics> = {
|
|
@@ -45,27 +44,52 @@ export type CoreOptions<TGenerics extends TableGenerics> = {
|
|
|
45
44
|
initialState?: InitialTableState
|
|
46
45
|
autoResetAll?: boolean
|
|
47
46
|
mergeOptions?: <T>(defaultOptions: T, options: Partial<T>) => T
|
|
47
|
+
keepPreviousData?: boolean
|
|
48
48
|
meta?: TGenerics['TableMeta']
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export type
|
|
51
|
+
export type CoreInstance<TGenerics extends TableGenerics> = {
|
|
52
52
|
// generics: TGenerics
|
|
53
53
|
initialState: TableState
|
|
54
54
|
reset: () => void
|
|
55
55
|
options: RequiredKeys<TableOptions<TGenerics>, 'state'>
|
|
56
56
|
setOptions: (newOptions: Updater<TableOptions<TGenerics>>) => void
|
|
57
57
|
queue: (cb: () => void) => void
|
|
58
|
-
// willUpdate: () => void
|
|
59
58
|
getState: () => TableState
|
|
60
59
|
setState: (updater: Updater<TableState>) => void
|
|
61
60
|
render: <TProps>(
|
|
62
61
|
template: Renderable<TGenerics, TProps>,
|
|
63
62
|
props: TProps
|
|
64
63
|
) => string | null | TGenerics['Rendered']
|
|
65
|
-
getOverallProgress: () => number
|
|
64
|
+
// getOverallProgress: () => number
|
|
65
|
+
// getProgressStage: () =>
|
|
66
|
+
// | undefined
|
|
67
|
+
// | 'coreRowModel'
|
|
68
|
+
// | 'filteredRowModel'
|
|
69
|
+
// | 'facetedRowModel'
|
|
66
70
|
_features: readonly TableFeature[]
|
|
71
|
+
// createBatch: (priority: keyof CoreBatches) => Batch
|
|
72
|
+
// init: () => void
|
|
73
|
+
// willUpdate: () => void
|
|
74
|
+
// destroy: () => void
|
|
75
|
+
// batches: CoreBatches
|
|
67
76
|
}
|
|
68
77
|
|
|
78
|
+
// export type Batch = {
|
|
79
|
+
// id: number
|
|
80
|
+
// priority: keyof CoreBatches
|
|
81
|
+
// tasks: (() => void)[]
|
|
82
|
+
// schedule: (cb: () => void) => void
|
|
83
|
+
// cancel: () => void
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
// type CoreBatches = {
|
|
87
|
+
// data: Batch[]
|
|
88
|
+
// facets: Batch[]
|
|
89
|
+
// }
|
|
90
|
+
|
|
91
|
+
// export type TaskPriority = keyof CoreBatches
|
|
92
|
+
|
|
69
93
|
export function createTableInstance<TGenerics extends TableGenerics>(
|
|
70
94
|
options: TableOptions<TGenerics>
|
|
71
95
|
): TableInstance<TGenerics> {
|
|
@@ -73,24 +97,24 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
73
97
|
console.info('Creating Table Instance...')
|
|
74
98
|
}
|
|
75
99
|
|
|
76
|
-
let instance = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
let instance = {
|
|
101
|
+
_features: [
|
|
102
|
+
Columns,
|
|
103
|
+
Rows,
|
|
104
|
+
Cells,
|
|
105
|
+
Headers,
|
|
106
|
+
Visibility,
|
|
107
|
+
Ordering,
|
|
108
|
+
Pinning,
|
|
109
|
+
Filters,
|
|
110
|
+
Sorting,
|
|
111
|
+
Grouping,
|
|
112
|
+
Expanding,
|
|
113
|
+
Pagination,
|
|
114
|
+
RowSelection,
|
|
115
|
+
ColumnSizing,
|
|
116
|
+
] as const,
|
|
117
|
+
} as unknown as CoreInstance<TGenerics>
|
|
94
118
|
|
|
95
119
|
const defaultOptions = instance._features.reduce((obj, feature) => {
|
|
96
120
|
return Object.assign(obj, feature.getDefaultOptions?.(instance))
|
|
@@ -107,13 +131,8 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
107
131
|
}
|
|
108
132
|
}
|
|
109
133
|
|
|
110
|
-
instance.options = {
|
|
111
|
-
...defaultOptions,
|
|
112
|
-
...options,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
134
|
const coreInitialState: CoreTableState = {
|
|
116
|
-
coreProgress: 1,
|
|
135
|
+
// coreProgress: 1,
|
|
117
136
|
}
|
|
118
137
|
|
|
119
138
|
let initialState = {
|
|
@@ -128,11 +147,90 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
128
147
|
const queued: (() => void)[] = []
|
|
129
148
|
let queuedTimeout = false
|
|
130
149
|
|
|
131
|
-
|
|
150
|
+
// let workScheduled = false
|
|
151
|
+
// let working = false
|
|
152
|
+
// let latestCallback: ReturnType<typeof requestIdleCallback>
|
|
153
|
+
// let batchUid = 0
|
|
154
|
+
// const onProgress = () => {}
|
|
155
|
+
// const getBatch = () => {
|
|
156
|
+
// instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
|
|
157
|
+
// instance.batches.facets = instance.batches.facets.filter(
|
|
158
|
+
// d => d.tasks.length
|
|
159
|
+
// )
|
|
160
|
+
|
|
161
|
+
// return (
|
|
162
|
+
// instance.batches.data.find(d => d.tasks.length) ??
|
|
163
|
+
// instance.batches.facets.find(d => d.tasks.length)
|
|
164
|
+
// )
|
|
165
|
+
// }
|
|
166
|
+
|
|
167
|
+
// const startWorkLoop = () => {
|
|
168
|
+
// working = true
|
|
169
|
+
|
|
170
|
+
// const workLoop = (deadline: IdleDeadline) => {
|
|
171
|
+
// const batch = getBatch()
|
|
172
|
+
|
|
173
|
+
// if (!batch) {
|
|
174
|
+
// working = false
|
|
175
|
+
// return
|
|
176
|
+
// }
|
|
177
|
+
// // Prioritize tasks
|
|
178
|
+
// while (deadline.timeRemaining() > 0 && batch.tasks.length) {
|
|
179
|
+
// batch.tasks.shift()!()
|
|
180
|
+
// }
|
|
181
|
+
|
|
182
|
+
// onProgress()
|
|
183
|
+
|
|
184
|
+
// if (working) {
|
|
185
|
+
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
186
|
+
// }
|
|
187
|
+
// }
|
|
188
|
+
|
|
189
|
+
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
190
|
+
// }
|
|
191
|
+
|
|
192
|
+
// const startWork = () => {
|
|
193
|
+
// if (getBatch() && !working) {
|
|
194
|
+
// if (
|
|
195
|
+
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
196
|
+
// instance.options.debugTable
|
|
197
|
+
// ) {
|
|
198
|
+
// console.info('Starting work...')
|
|
199
|
+
// }
|
|
200
|
+
// startWorkLoop()
|
|
201
|
+
// }
|
|
202
|
+
// }
|
|
203
|
+
|
|
204
|
+
// const stopWork = () => {
|
|
205
|
+
// if (working) {
|
|
206
|
+
// if (
|
|
207
|
+
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
208
|
+
// instance.options.debugTable
|
|
209
|
+
// ) {
|
|
210
|
+
// console.info('Stopping work...')
|
|
211
|
+
// }
|
|
212
|
+
|
|
213
|
+
// working = false
|
|
214
|
+
// cancelIdleCallback(latestCallback)
|
|
215
|
+
// }
|
|
216
|
+
// }
|
|
217
|
+
|
|
218
|
+
const midInstance: CoreInstance<TGenerics> = {
|
|
132
219
|
...instance,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
220
|
+
// init: () => {
|
|
221
|
+
// startWork()
|
|
222
|
+
// },
|
|
223
|
+
// willUpdate: () => {
|
|
224
|
+
// startWork()
|
|
225
|
+
// },
|
|
226
|
+
// destroy: () => {
|
|
227
|
+
// stopWork()
|
|
228
|
+
// },
|
|
229
|
+
options: {
|
|
230
|
+
...defaultOptions,
|
|
231
|
+
...options,
|
|
232
|
+
},
|
|
233
|
+
initialState,
|
|
136
234
|
queue: cb => {
|
|
137
235
|
queued.push(cb)
|
|
138
236
|
|
|
@@ -155,7 +253,43 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
155
253
|
)
|
|
156
254
|
}
|
|
157
255
|
},
|
|
158
|
-
|
|
256
|
+
// batches: {
|
|
257
|
+
// data: [],
|
|
258
|
+
// facets: [],
|
|
259
|
+
// },
|
|
260
|
+
// createBatch: priority => {
|
|
261
|
+
// const batchId = batchUid++
|
|
262
|
+
// let canceled: boolean
|
|
263
|
+
|
|
264
|
+
// const batch: Batch = {
|
|
265
|
+
// id: batchId,
|
|
266
|
+
// priority,
|
|
267
|
+
// tasks: [],
|
|
268
|
+
// schedule: cb => {
|
|
269
|
+
// if (canceled) return
|
|
270
|
+
// batch.tasks.push(cb)
|
|
271
|
+
|
|
272
|
+
// if (!working && !workScheduled) {
|
|
273
|
+
// workScheduled = true
|
|
274
|
+
// instance.queue(() => {
|
|
275
|
+
// workScheduled = false
|
|
276
|
+
// instance.setState(old => ({ ...old }))
|
|
277
|
+
// })
|
|
278
|
+
// }
|
|
279
|
+
// },
|
|
280
|
+
// cancel: () => {
|
|
281
|
+
// canceled = true
|
|
282
|
+
// batch.tasks = []
|
|
283
|
+
// instance.batches[priority] = instance.batches[priority].filter(
|
|
284
|
+
// b => b.id !== batchId
|
|
285
|
+
// )
|
|
286
|
+
// },
|
|
287
|
+
// }
|
|
288
|
+
|
|
289
|
+
// instance.batches[priority].push(batch)
|
|
290
|
+
|
|
291
|
+
// return batch
|
|
292
|
+
// },
|
|
159
293
|
reset: () => {
|
|
160
294
|
instance.setState(instance.initialState)
|
|
161
295
|
},
|
|
@@ -183,19 +317,37 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
183
317
|
instance.options.onStateChange?.(updater)
|
|
184
318
|
},
|
|
185
319
|
|
|
186
|
-
getOverallProgress: () => {
|
|
187
|
-
|
|
188
|
-
|
|
320
|
+
// getOverallProgress: () => {
|
|
321
|
+
// const { coreProgress, filtersProgress, facetProgress } =
|
|
322
|
+
// instance.getState()
|
|
189
323
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
324
|
+
// return mean(() =>
|
|
325
|
+
// [coreProgress, filtersProgress].filter(d => d < 1)
|
|
326
|
+
// ) as number
|
|
327
|
+
// },
|
|
328
|
+
// getProgressStage: () => {
|
|
329
|
+
// const { coreProgress, filtersProgress, facetProgress } =
|
|
330
|
+
// instance.getState()
|
|
331
|
+
|
|
332
|
+
// if (coreProgress < 1) {
|
|
333
|
+
// return 'coreRowModel'
|
|
334
|
+
// }
|
|
335
|
+
|
|
336
|
+
// if (filtersProgress < 1) {
|
|
337
|
+
// return 'filteredRowModel'
|
|
338
|
+
// }
|
|
339
|
+
|
|
340
|
+
// if (Object.values(facetProgress).some(d => d < 1)) {
|
|
341
|
+
// return 'facetedRowModel'
|
|
342
|
+
// }
|
|
343
|
+
// },
|
|
196
344
|
}
|
|
197
345
|
|
|
198
|
-
instance = Object.assign(instance,
|
|
346
|
+
instance = Object.assign(instance, midInstance)
|
|
347
|
+
|
|
348
|
+
instance._features.forEach(feature => {
|
|
349
|
+
return Object.assign(instance, feature.createInstance?.(instance))
|
|
350
|
+
})
|
|
199
351
|
|
|
200
|
-
return instance
|
|
352
|
+
return instance as TableInstance<TGenerics>
|
|
201
353
|
}
|
package/src/features/Cells.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type CellsInstance<TGenerics extends TableGenerics> = {
|
|
|
17
17
|
createCell: (
|
|
18
18
|
row: Row<TGenerics>,
|
|
19
19
|
column: Column<TGenerics>,
|
|
20
|
-
|
|
20
|
+
columnId: string
|
|
21
21
|
) => Cell<TGenerics>
|
|
22
22
|
getCell: (rowId: string, columnId: string) => Cell<TGenerics>
|
|
23
23
|
}
|
|
@@ -34,15 +34,11 @@ export const Cells = {
|
|
|
34
34
|
() => [instance.getAllLeafColumns()],
|
|
35
35
|
leafColumns => {
|
|
36
36
|
return leafColumns.map(column => {
|
|
37
|
-
return instance.createCell(
|
|
38
|
-
row as Row<TGenerics>,
|
|
39
|
-
column,
|
|
40
|
-
row.values[column.id]
|
|
41
|
-
)
|
|
37
|
+
return instance.createCell(row as Row<TGenerics>, column, column.id)
|
|
42
38
|
})
|
|
43
39
|
},
|
|
44
40
|
{
|
|
45
|
-
key: process.env.NODE_ENV === 'development'
|
|
41
|
+
key: process.env.NODE_ENV === 'development' && 'row.getAllCells',
|
|
46
42
|
debug: () => instance.options.debugAll ?? instance.options.debugRows,
|
|
47
43
|
}
|
|
48
44
|
),
|
|
@@ -69,14 +65,14 @@ export const Cells = {
|
|
|
69
65
|
instance: TableInstance<TGenerics>
|
|
70
66
|
): CellsInstance<TGenerics> => {
|
|
71
67
|
return {
|
|
72
|
-
createCell: (row, column,
|
|
68
|
+
createCell: (row, column, columnId) => {
|
|
73
69
|
const cell: CoreCell<TGenerics> = {
|
|
74
70
|
id: `${row.id}_${column.id}`,
|
|
75
71
|
rowId: row.id,
|
|
76
|
-
columnId
|
|
72
|
+
columnId,
|
|
77
73
|
row,
|
|
78
74
|
column,
|
|
79
|
-
|
|
75
|
+
getValue: () => row.getValue(columnId),
|
|
80
76
|
renderCell: () =>
|
|
81
77
|
column.cell
|
|
82
78
|
? instance.render(column.cell, {
|
|
@@ -84,7 +80,7 @@ export const Cells = {
|
|
|
84
80
|
column,
|
|
85
81
|
row,
|
|
86
82
|
cell: cell as Cell<TGenerics>,
|
|
87
|
-
|
|
83
|
+
getValue: cell.getValue,
|
|
88
84
|
})
|
|
89
85
|
: null,
|
|
90
86
|
}
|
|
@@ -138,7 +138,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
138
138
|
const index = columns.findIndex(d => d.id === column.id)
|
|
139
139
|
|
|
140
140
|
if (index > 0) {
|
|
141
|
-
const prevSiblingColumn = columns[index - 1]
|
|
141
|
+
const prevSiblingColumn = columns[index - 1]!
|
|
142
142
|
|
|
143
143
|
return (
|
|
144
144
|
prevSiblingColumn.getStart(position) + prevSiblingColumn.getSize()
|
|
@@ -188,7 +188,8 @@ export const ColumnSizing: TableFeature = {
|
|
|
188
188
|
},
|
|
189
189
|
getStart: () => {
|
|
190
190
|
if (header.index > 0) {
|
|
191
|
-
const prevSiblingHeader =
|
|
191
|
+
const prevSiblingHeader =
|
|
192
|
+
header.headerGroup.headers[header.index - 1]!
|
|
192
193
|
return prevSiblingHeader.getStart() + prevSiblingHeader.getSize()
|
|
193
194
|
}
|
|
194
195
|
|
|
@@ -221,7 +222,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
221
222
|
: [[column.id, column.getSize()]]
|
|
222
223
|
|
|
223
224
|
const clientX = isTouchStartEvent(e)
|
|
224
|
-
? Math.round(e.touches[0]
|
|
225
|
+
? Math.round(e.touches[0]!.clientX)
|
|
225
226
|
: (e as MouseEvent).clientX
|
|
226
227
|
|
|
227
228
|
const updateOffset = (
|
|
@@ -298,7 +299,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
298
299
|
e.preventDefault()
|
|
299
300
|
e.stopPropagation()
|
|
300
301
|
}
|
|
301
|
-
onMove(e.touches[0]
|
|
302
|
+
onMove(e.touches[0]!.clientX)
|
|
302
303
|
return false
|
|
303
304
|
},
|
|
304
305
|
upHandler: (e: TouchEvent) => {
|
|
@@ -308,7 +309,7 @@ export const ColumnSizing: TableFeature = {
|
|
|
308
309
|
e.preventDefault()
|
|
309
310
|
e.stopPropagation()
|
|
310
311
|
}
|
|
311
|
-
onEnd(e.touches[0]
|
|
312
|
+
onEnd(e.touches[0]!.clientX)
|
|
312
313
|
},
|
|
313
314
|
}
|
|
314
315
|
|
package/src/features/Columns.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
AccessorFn,
|
|
9
9
|
ColumnDef,
|
|
10
10
|
Renderable,
|
|
11
|
-
HeaderRenderProps,
|
|
12
11
|
} from '../types'
|
|
13
12
|
import { memo } from '../utils'
|
|
14
13
|
|
|
@@ -42,7 +41,7 @@ export type CoreColumnDef<TGenerics extends TableGenerics> = {
|
|
|
42
41
|
row: Row<TGenerics>
|
|
43
42
|
column: Column<TGenerics>
|
|
44
43
|
cell: Cell<TGenerics>
|
|
45
|
-
|
|
44
|
+
getValue: () => TGenerics['Value']
|
|
46
45
|
}
|
|
47
46
|
>
|
|
48
47
|
meta?: TGenerics['ColumnMeta']
|
|
@@ -93,12 +92,9 @@ export const Columns = {
|
|
|
93
92
|
defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>>
|
|
94
93
|
|
|
95
94
|
return {
|
|
96
|
-
header:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
props.header.column.id,
|
|
100
|
-
cell: ({ value = '' }: { value: any }): JSX.Element =>
|
|
101
|
-
typeof value === 'boolean' ? value.toString() : value,
|
|
95
|
+
header: props => props.header.column.id,
|
|
96
|
+
footer: props => props.header.column.id,
|
|
97
|
+
cell: props => props.getValue().toString?.() ?? null,
|
|
102
98
|
...instance._features.reduce((obj, feature) => {
|
|
103
99
|
return Object.assign(obj, feature.getDefaultColumn?.())
|
|
104
100
|
}, {}),
|