@tanstack/table-core 8.0.0-alpha.83 → 8.0.0-alpha.84
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/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/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +1 -1
- package/build/cjs/features/Filters.js.map +1 -1
- 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 +3 -3
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +9 -5
- 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 +12 -11
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/esm/index.js +656 -761
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +391 -368
- 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/features/ColumnSizing.d.ts +2 -1
- package/build/types/features/Expanding.d.ts +2 -1
- package/build/types/features/Filters.d.ts +2 -1
- package/build/types/features/Grouping.d.ts +2 -1
- 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 +2 -1
- 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 +10 -53
- package/build/umd/index.development.js +660 -759
- 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/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/features/ColumnSizing.ts +1 -1
- package/src/features/Expanding.ts +1 -2
- package/src/features/Filters.ts +2 -2
- package/src/features/Grouping.ts +1 -1
- package/src/features/Ordering.ts +1 -1
- package/src/features/Pagination.ts +1 -1
- package/src/features/Pinning.ts +8 -4
- package/src/features/RowSelection.ts +1 -1
- package/src/features/Sorting.ts +1 -1
- package/src/features/Visibility.ts +1 -1
- package/src/index.ts +4 -8
- package/src/types.ts +9 -61
- package/src/utils/filterRowsUtils.ts +4 -2
- package/src/utils/getCoreRowModel.ts +4 -2
- package/src/utils/getGroupedRowModel.ts +6 -6
- 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 -191
- 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 -293
- package/src/features/Rows.ts +0 -142
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
|
-
}
|