@tanstack/table-core 8.0.0-alpha.82 → 8.0.0-alpha.85
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 +50 -51
- package/build/cjs/aggregationFns.js.map +1 -1
- package/build/cjs/core/cell.js +38 -0
- package/build/cjs/core/cell.js.map +1 -0
- package/build/cjs/core/column.js +88 -0
- package/build/cjs/core/column.js.map +1 -0
- package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
- package/build/cjs/core/headers.js.map +1 -0
- package/build/cjs/core/instance.js +255 -0
- package/build/cjs/core/instance.js.map +1 -0
- package/build/cjs/core/row.js +77 -0
- package/build/cjs/core/row.js.map +1 -0
- package/build/cjs/createTable.js +3 -2
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +5 -5
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +11 -8
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +10 -10
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Ordering.js.map +1 -1
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/features/Pinning.js +17 -11
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js +8 -8
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +3 -3
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +9 -6
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +23 -21
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +9 -8
- package/build/cjs/utils/getCoreRowModel.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +13 -20
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getSortedRowModel.js +2 -2
- package/build/cjs/utils/getSortedRowModel.js.map +1 -1
- package/build/esm/index.js +764 -865
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +404 -381
- package/build/types/aggregationFns.d.ts +10 -19
- package/build/types/core/cell.d.ts +9 -0
- package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
- package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
- package/build/types/core/instance.d.ts +57 -0
- package/build/types/core/row.d.ts +15 -0
- package/build/types/createTable.d.ts +4 -4
- package/build/types/features/ColumnSizing.d.ts +2 -1
- package/build/types/features/Expanding.d.ts +2 -1
- package/build/types/features/Filters.d.ts +2 -3
- package/build/types/features/Grouping.d.ts +8 -9
- package/build/types/features/Ordering.d.ts +2 -1
- package/build/types/features/Pagination.d.ts +2 -1
- package/build/types/features/Pinning.d.ts +3 -2
- package/build/types/features/RowSelection.d.ts +2 -1
- package/build/types/features/Sorting.d.ts +2 -1
- package/build/types/features/Visibility.d.ts +2 -1
- package/build/types/index.d.ts +4 -2
- package/build/types/sortingFns.d.ts +4 -4
- package/build/types/types.d.ts +12 -53
- package/build/umd/index.development.js +767 -863
- 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/aggregationFns.ts +44 -40
- package/src/core/cell.ts +47 -0
- package/src/core/column.ts +148 -0
- package/src/{features/Headers.ts → core/headers.ts} +98 -99
- package/src/core/instance.ts +361 -0
- package/src/core/row.ts +85 -0
- package/src/createTable.ts +7 -4
- package/src/features/ColumnSizing.ts +6 -6
- package/src/features/Expanding.ts +1 -2
- package/src/features/Filters.ts +9 -10
- package/src/features/Grouping.ts +20 -22
- package/src/features/Ordering.ts +1 -1
- package/src/features/Pagination.ts +1 -1
- package/src/features/Pinning.ts +18 -9
- package/src/features/RowSelection.ts +1 -1
- package/src/features/Sorting.ts +10 -10
- package/src/features/Visibility.ts +3 -3
- package/src/index.ts +4 -8
- package/src/types.ts +16 -64
- package/src/utils/filterRowsUtils.ts +4 -2
- package/src/utils/getCoreRowModel.ts +4 -2
- package/src/utils/getGroupedRowModel.ts +14 -22
- package/src/utils/getSortedRowModel.ts +2 -2
- package/build/cjs/core.js +0 -168
- package/build/cjs/core.js.map +0 -1
- package/build/cjs/features/Cells.js +0 -101
- package/build/cjs/features/Cells.js.map +0 -1
- package/build/cjs/features/Columns.js +0 -189
- package/build/cjs/features/Columns.js.map +0 -1
- package/build/cjs/features/Headers.js.map +0 -1
- package/build/cjs/features/Rows.js +0 -94
- package/build/cjs/features/Rows.js.map +0 -1
- package/build/types/core.d.ts +0 -30
- package/build/types/features/Cells.d.ts +0 -13
- package/build/types/features/Rows.d.ts +0 -28
- package/src/core.ts +0 -246
- package/src/features/Cells.ts +0 -128
- package/src/features/Columns.ts +0 -289
- package/src/features/Rows.ts +0 -142
package/src/features/Columns.ts
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Cell,
|
|
3
|
-
Column,
|
|
4
|
-
Header,
|
|
5
|
-
TableGenerics,
|
|
6
|
-
TableInstance,
|
|
7
|
-
Row,
|
|
8
|
-
AccessorFn,
|
|
9
|
-
ColumnDef,
|
|
10
|
-
Renderable,
|
|
11
|
-
} from '../types'
|
|
12
|
-
import { memo } from '../utils'
|
|
13
|
-
|
|
14
|
-
export type CoreColumnDefType = 'data' | 'display' | 'group'
|
|
15
|
-
|
|
16
|
-
export type CoreColumnDef<TGenerics extends TableGenerics> = {
|
|
17
|
-
id: string
|
|
18
|
-
accessorKey?: string & keyof TGenerics['Row']
|
|
19
|
-
accessorFn?: AccessorFn<TGenerics['Row']>
|
|
20
|
-
columns?: ColumnDef<TGenerics>[]
|
|
21
|
-
header?: Renderable<
|
|
22
|
-
TGenerics,
|
|
23
|
-
{
|
|
24
|
-
instance: TableInstance<TGenerics>
|
|
25
|
-
header: Header<TGenerics>
|
|
26
|
-
column: Column<TGenerics>
|
|
27
|
-
}
|
|
28
|
-
>
|
|
29
|
-
footer?: Renderable<
|
|
30
|
-
TGenerics,
|
|
31
|
-
{
|
|
32
|
-
instance: TableInstance<TGenerics>
|
|
33
|
-
header: Header<TGenerics>
|
|
34
|
-
column: Column<TGenerics>
|
|
35
|
-
}
|
|
36
|
-
>
|
|
37
|
-
cell?: Renderable<
|
|
38
|
-
TGenerics,
|
|
39
|
-
{
|
|
40
|
-
instance: TableInstance<TGenerics>
|
|
41
|
-
row: Row<TGenerics>
|
|
42
|
-
column: Column<TGenerics>
|
|
43
|
-
cell: Cell<TGenerics>
|
|
44
|
-
getValue: () => TGenerics['Value']
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
meta?: TGenerics['ColumnMeta']
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type CoreColumn<TGenerics extends TableGenerics> = {
|
|
51
|
-
id: string
|
|
52
|
-
depth: number
|
|
53
|
-
accessorFn?: AccessorFn<TGenerics['Row']>
|
|
54
|
-
columnDef: ColumnDef<TGenerics>
|
|
55
|
-
columnDefType: CoreColumnDefType
|
|
56
|
-
columns: Column<TGenerics>[]
|
|
57
|
-
parent?: Column<TGenerics>
|
|
58
|
-
getFlatColumns: () => Column<TGenerics>[]
|
|
59
|
-
getLeafColumns: () => Column<TGenerics>[]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type ColumnsOptions<TGenerics extends TableGenerics> = {
|
|
63
|
-
columns: ColumnDef<TGenerics>[]
|
|
64
|
-
defaultColumn?: Partial<ColumnDef<TGenerics>>
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type ColumnsInstance<TGenerics extends TableGenerics> = {
|
|
68
|
-
getDefaultColumn: () => Partial<ColumnDef<TGenerics>>
|
|
69
|
-
getColumnDefs: () => ColumnDef<TGenerics>[]
|
|
70
|
-
createColumn: (
|
|
71
|
-
columnDef: ColumnDef<TGenerics>,
|
|
72
|
-
depth: number,
|
|
73
|
-
parent?: Column<TGenerics>
|
|
74
|
-
) => Column<TGenerics>
|
|
75
|
-
getAllColumns: () => Column<TGenerics>[]
|
|
76
|
-
getAllFlatColumns: () => Column<TGenerics>[]
|
|
77
|
-
getAllFlatColumnsById: () => Record<string, Column<TGenerics>>
|
|
78
|
-
getAllLeafColumns: () => Column<TGenerics>[]
|
|
79
|
-
getColumn: (columnId: string) => Column<TGenerics>
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
export const Columns = {
|
|
85
|
-
createInstance: <TGenerics extends TableGenerics>(
|
|
86
|
-
instance: TableInstance<TGenerics>
|
|
87
|
-
): ColumnsInstance<TGenerics> => {
|
|
88
|
-
return {
|
|
89
|
-
getDefaultColumn: memo(
|
|
90
|
-
() => [instance.options.defaultColumn],
|
|
91
|
-
defaultColumn => {
|
|
92
|
-
defaultColumn = (defaultColumn ?? {}) as Partial<ColumnDef<TGenerics>>
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
header: props => props.header.column.id,
|
|
96
|
-
footer: props => props.header.column.id,
|
|
97
|
-
cell: props => props.getValue().toString?.() ?? null,
|
|
98
|
-
...instance._features.reduce((obj, feature) => {
|
|
99
|
-
return Object.assign(obj, feature.getDefaultColumn?.())
|
|
100
|
-
}, {}),
|
|
101
|
-
...defaultColumn,
|
|
102
|
-
} as Partial<ColumnDef<TGenerics>>
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
debug: () =>
|
|
106
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
107
|
-
key: process.env.NODE_ENV === 'development' && 'getDefaultColumn',
|
|
108
|
-
}
|
|
109
|
-
),
|
|
110
|
-
|
|
111
|
-
getColumnDefs: () => instance.options.columns,
|
|
112
|
-
|
|
113
|
-
createColumn: (
|
|
114
|
-
columnDef: ColumnDef<TGenerics> & { columnDefType?: CoreColumnDefType },
|
|
115
|
-
depth: number,
|
|
116
|
-
parent
|
|
117
|
-
) => {
|
|
118
|
-
const defaultColumn = instance.getDefaultColumn()
|
|
119
|
-
|
|
120
|
-
let id =
|
|
121
|
-
columnDef.id ??
|
|
122
|
-
columnDef.accessorKey ??
|
|
123
|
-
(typeof columnDef.header === 'string' ? columnDef.header : undefined)
|
|
124
|
-
|
|
125
|
-
let accessorFn: AccessorFn<TGenerics['Row']> | undefined
|
|
126
|
-
|
|
127
|
-
if (columnDef.accessorFn) {
|
|
128
|
-
accessorFn = columnDef.accessorFn
|
|
129
|
-
} else if (columnDef.accessorKey) {
|
|
130
|
-
accessorFn = (originalRow?: TGenerics['Row']) =>
|
|
131
|
-
(originalRow as any)[columnDef.accessorKey]
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!id) {
|
|
135
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
136
|
-
throw new Error(
|
|
137
|
-
columnDef.accessorFn
|
|
138
|
-
? `Columns require an id when using an accessorFn`
|
|
139
|
-
: `Columns require an id when using a non-string header`
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
throw new Error()
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let column: CoreColumn<TGenerics> = {
|
|
146
|
-
...defaultColumn,
|
|
147
|
-
...columnDef,
|
|
148
|
-
id: `${id}`,
|
|
149
|
-
accessorFn,
|
|
150
|
-
parent: parent as any,
|
|
151
|
-
depth,
|
|
152
|
-
columnDef,
|
|
153
|
-
columnDefType: columnDef.columnDefType as CoreColumnDefType,
|
|
154
|
-
columns: [],
|
|
155
|
-
getFlatColumns: memo(
|
|
156
|
-
() => [true],
|
|
157
|
-
() => {
|
|
158
|
-
return [
|
|
159
|
-
column as Column<TGenerics>,
|
|
160
|
-
...column.columns?.flatMap(d => d.getFlatColumns()),
|
|
161
|
-
]
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
key:
|
|
165
|
-
process.env.NODE_ENV === 'production' &&
|
|
166
|
-
'column.getFlatColumns',
|
|
167
|
-
debug: () =>
|
|
168
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
169
|
-
}
|
|
170
|
-
),
|
|
171
|
-
getLeafColumns: memo(
|
|
172
|
-
() => [instance._getOrderColumnsFn()],
|
|
173
|
-
orderColumns => {
|
|
174
|
-
if (column.columns?.length) {
|
|
175
|
-
let leafColumns = column.columns.flatMap(column =>
|
|
176
|
-
column.getLeafColumns()
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
return orderColumns(leafColumns)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return [column as Column<TGenerics>]
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
key:
|
|
186
|
-
process.env.NODE_ENV === 'production' &&
|
|
187
|
-
'column.getLeafColumns',
|
|
188
|
-
debug: () =>
|
|
189
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
190
|
-
}
|
|
191
|
-
),
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
column = instance._features.reduce((obj, feature) => {
|
|
195
|
-
return Object.assign(obj, feature.createColumn?.(column, instance))
|
|
196
|
-
}, column)
|
|
197
|
-
|
|
198
|
-
// Yes, we have to convert instance to uknown, because we know more than the compiler here.
|
|
199
|
-
return column as Column<TGenerics>
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
getAllColumns: memo(
|
|
203
|
-
() => [instance.getColumnDefs()],
|
|
204
|
-
columnDefs => {
|
|
205
|
-
const recurseColumns = (
|
|
206
|
-
columnDefs: ColumnDef<TGenerics>[],
|
|
207
|
-
parent?: Column<TGenerics>,
|
|
208
|
-
depth = 0
|
|
209
|
-
): Column<TGenerics>[] => {
|
|
210
|
-
return columnDefs.map(columnDef => {
|
|
211
|
-
const column = instance.createColumn(columnDef, depth, parent)
|
|
212
|
-
|
|
213
|
-
column.columns = columnDef.columns
|
|
214
|
-
? recurseColumns(columnDef.columns, column, depth + 1)
|
|
215
|
-
: []
|
|
216
|
-
|
|
217
|
-
return column
|
|
218
|
-
})
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return recurseColumns(columnDefs)
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
key: process.env.NODE_ENV === 'development' && 'getAllColumns',
|
|
225
|
-
debug: () =>
|
|
226
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
227
|
-
}
|
|
228
|
-
),
|
|
229
|
-
|
|
230
|
-
getAllFlatColumns: memo(
|
|
231
|
-
() => [instance.getAllColumns()],
|
|
232
|
-
allColumns => {
|
|
233
|
-
return allColumns.flatMap(column => {
|
|
234
|
-
return column.getFlatColumns()
|
|
235
|
-
})
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
key: process.env.NODE_ENV === 'development' && 'getAllFlatColumns',
|
|
239
|
-
debug: () =>
|
|
240
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
241
|
-
}
|
|
242
|
-
),
|
|
243
|
-
|
|
244
|
-
getAllFlatColumnsById: memo(
|
|
245
|
-
() => [instance.getAllFlatColumns()],
|
|
246
|
-
flatColumns => {
|
|
247
|
-
return flatColumns.reduce((acc, column) => {
|
|
248
|
-
acc[column.id] = column
|
|
249
|
-
return acc
|
|
250
|
-
}, {} as Record<string, Column<TGenerics>>)
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
key:
|
|
254
|
-
process.env.NODE_ENV === 'development' && 'getAllFlatColumnsById',
|
|
255
|
-
debug: () =>
|
|
256
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
257
|
-
}
|
|
258
|
-
),
|
|
259
|
-
|
|
260
|
-
getAllLeafColumns: memo(
|
|
261
|
-
() => [instance.getAllColumns(), instance._getOrderColumnsFn()],
|
|
262
|
-
(allColumns, orderColumns) => {
|
|
263
|
-
let leafColumns = allColumns.flatMap(column =>
|
|
264
|
-
column.getLeafColumns()
|
|
265
|
-
)
|
|
266
|
-
return orderColumns(leafColumns)
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
key: process.env.NODE_ENV === 'development' && 'getAllLeafColumns',
|
|
270
|
-
debug: () =>
|
|
271
|
-
instance.options.debugAll ?? instance.options.debugColumns,
|
|
272
|
-
}
|
|
273
|
-
),
|
|
274
|
-
|
|
275
|
-
getColumn: columnId => {
|
|
276
|
-
const column = instance.getAllFlatColumnsById()[columnId]
|
|
277
|
-
|
|
278
|
-
if (!column) {
|
|
279
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
280
|
-
console.warn(`[Table] Column with id ${columnId} does not exist.`)
|
|
281
|
-
}
|
|
282
|
-
throw new Error()
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return column
|
|
286
|
-
},
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
}
|
package/src/features/Rows.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TableGenerics,
|
|
3
|
-
TableInstance,
|
|
4
|
-
Row,
|
|
5
|
-
RowModel,
|
|
6
|
-
RowValues,
|
|
7
|
-
} from '../types'
|
|
8
|
-
import { flattenBy } from '../utils'
|
|
9
|
-
|
|
10
|
-
export type CoreRow<TGenerics extends TableGenerics> = {
|
|
11
|
-
id: string
|
|
12
|
-
index: number
|
|
13
|
-
original?: TGenerics['Row']
|
|
14
|
-
depth: number
|
|
15
|
-
valuesCache: Record<string, any>
|
|
16
|
-
getValue: (columnId: string) => any
|
|
17
|
-
subRows: Row<TGenerics>[]
|
|
18
|
-
getLeafRows: () => Row<TGenerics>[]
|
|
19
|
-
originalSubRows?: TGenerics['Row'][]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type RowsOptions<TGenerics extends TableGenerics> = {
|
|
23
|
-
getCoreRowModel: (
|
|
24
|
-
instance: TableInstance<TGenerics>
|
|
25
|
-
) => () => RowModel<TGenerics>
|
|
26
|
-
getSubRows?: (
|
|
27
|
-
originalRow: TGenerics['Row'],
|
|
28
|
-
index: number
|
|
29
|
-
) => undefined | TGenerics['Row'][]
|
|
30
|
-
getRowId?: (
|
|
31
|
-
originalRow: TGenerics['Row'],
|
|
32
|
-
index: number,
|
|
33
|
-
parent?: Row<TGenerics>
|
|
34
|
-
) => string
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type RowsInstance<TGenerics extends TableGenerics> = {
|
|
38
|
-
getRowId: (
|
|
39
|
-
_: TGenerics['Row'],
|
|
40
|
-
index: number,
|
|
41
|
-
parent?: Row<TGenerics>
|
|
42
|
-
) => string
|
|
43
|
-
createRow: (
|
|
44
|
-
id: string,
|
|
45
|
-
original: TGenerics['Row'] | undefined,
|
|
46
|
-
rowIndex: number,
|
|
47
|
-
depth: number,
|
|
48
|
-
subRows?: Row<TGenerics>[]
|
|
49
|
-
) => Row<TGenerics>
|
|
50
|
-
getCoreRowModel: () => RowModel<TGenerics>
|
|
51
|
-
_getCoreRowModel?: () => RowModel<TGenerics>
|
|
52
|
-
getRowModel: () => RowModel<TGenerics>
|
|
53
|
-
getRow: (id: string) => Row<TGenerics>
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
export const Rows = {
|
|
59
|
-
// createRow: <TGenerics extends TableGenerics>(
|
|
60
|
-
// row: Row<TGenerics>,
|
|
61
|
-
// instance: TableInstance<TGenerics>
|
|
62
|
-
// ): CellsRow<TGenerics> => {
|
|
63
|
-
// return {}
|
|
64
|
-
// },
|
|
65
|
-
|
|
66
|
-
createInstance: <TGenerics extends TableGenerics>(
|
|
67
|
-
instance: TableInstance<TGenerics>
|
|
68
|
-
): RowsInstance<TGenerics> => {
|
|
69
|
-
return {
|
|
70
|
-
getRowId: (
|
|
71
|
-
row: TGenerics['Row'],
|
|
72
|
-
index: number,
|
|
73
|
-
parent?: Row<TGenerics>
|
|
74
|
-
) =>
|
|
75
|
-
instance.options.getRowId?.(row, index, parent) ??
|
|
76
|
-
`${parent ? [parent.id, index].join('.') : index}`,
|
|
77
|
-
createRow: (id, original, rowIndex, depth, subRows) => {
|
|
78
|
-
let row: CoreRow<TGenerics> = {
|
|
79
|
-
id,
|
|
80
|
-
index: rowIndex,
|
|
81
|
-
original,
|
|
82
|
-
depth,
|
|
83
|
-
valuesCache: {},
|
|
84
|
-
getValue: columnId => {
|
|
85
|
-
if (row.valuesCache.hasOwnProperty(columnId)) {
|
|
86
|
-
return row.valuesCache[columnId]
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const column = instance.getColumn(columnId)
|
|
90
|
-
|
|
91
|
-
if (!column.accessorFn) {
|
|
92
|
-
return undefined
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
row.valuesCache[columnId] = column.accessorFn(
|
|
96
|
-
row.original,
|
|
97
|
-
rowIndex
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
return row.valuesCache[columnId]
|
|
101
|
-
},
|
|
102
|
-
subRows: subRows ?? [],
|
|
103
|
-
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
for (let i = 0; i < instance._features.length; i++) {
|
|
107
|
-
const feature = instance._features[i]
|
|
108
|
-
Object.assign(row, feature?.createRow?.(row, instance))
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return row as Row<TGenerics>
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
getCoreRowModel: () => {
|
|
115
|
-
if (!instance._getCoreRowModel) {
|
|
116
|
-
instance._getCoreRowModel = instance.options.getCoreRowModel(instance)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return instance._getCoreRowModel()
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
// The final calls start at the bottom of the model,
|
|
123
|
-
// expanded rows, which then work their way up
|
|
124
|
-
|
|
125
|
-
getRowModel: () => {
|
|
126
|
-
return instance.getPaginationRowModel()
|
|
127
|
-
},
|
|
128
|
-
getRow: (id: string) => {
|
|
129
|
-
const row = instance.getRowModel().rowsById[id]
|
|
130
|
-
|
|
131
|
-
if (!row) {
|
|
132
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
133
|
-
throw new Error(`getRow expected an ID, but got ${id}`)
|
|
134
|
-
}
|
|
135
|
-
throw new Error()
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return row
|
|
139
|
-
},
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
}
|