@tanstack/table-core 8.0.0-alpha.83 → 8.0.0-alpha.86

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 (105) hide show
  1. package/build/cjs/aggregationFns.js +50 -51
  2. package/build/cjs/aggregationFns.js.map +1 -1
  3. package/build/cjs/core/cell.js +38 -0
  4. package/build/cjs/core/cell.js.map +1 -0
  5. package/build/cjs/core/column.js +88 -0
  6. package/build/cjs/core/column.js.map +1 -0
  7. package/build/cjs/{features/Headers.js → core/headers.js} +54 -66
  8. package/build/cjs/core/headers.js.map +1 -0
  9. package/build/cjs/core/instance.js +255 -0
  10. package/build/cjs/core/instance.js.map +1 -0
  11. package/build/cjs/core/row.js +77 -0
  12. package/build/cjs/core/row.js.map +1 -0
  13. package/build/cjs/features/ColumnSizing.js.map +1 -1
  14. package/build/cjs/features/Expanding.js +0 -1
  15. package/build/cjs/features/Expanding.js.map +1 -1
  16. package/build/cjs/features/Filters.js +2 -3
  17. package/build/cjs/features/Filters.js.map +1 -1
  18. package/build/cjs/features/Grouping.js +5 -5
  19. package/build/cjs/features/Grouping.js.map +1 -1
  20. package/build/cjs/features/Ordering.js.map +1 -1
  21. package/build/cjs/features/Pagination.js.map +1 -1
  22. package/build/cjs/features/Pinning.js +3 -3
  23. package/build/cjs/features/Pinning.js.map +1 -1
  24. package/build/cjs/features/RowSelection.js.map +1 -1
  25. package/build/cjs/features/Sorting.js.map +1 -1
  26. package/build/cjs/features/Visibility.js +0 -5
  27. package/build/cjs/features/Visibility.js.map +1 -1
  28. package/build/cjs/index.js +9 -6
  29. package/build/cjs/index.js.map +1 -1
  30. package/build/cjs/utils/filterRowsUtils.js +23 -21
  31. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  32. package/build/cjs/utils/getCoreRowModel.js +9 -8
  33. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  34. package/build/cjs/utils/getExpandedRowModel.js +2 -2
  35. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  36. package/build/cjs/utils/getGroupedRowModel.js +13 -20
  37. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  38. package/build/cjs/utils/getPaginationRowModel.js +1 -1
  39. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  40. package/build/esm/index.js +718 -838
  41. package/build/esm/index.js.map +1 -1
  42. package/build/stats-html.html +1 -1
  43. package/build/stats-react.json +403 -380
  44. package/build/types/aggregationFns.d.ts +10 -19
  45. package/build/types/core/cell.d.ts +9 -0
  46. package/build/types/{features/Columns.d.ts → core/column.d.ts} +3 -17
  47. package/build/types/{features/Headers.d.ts → core/headers.d.ts} +26 -11
  48. package/build/types/core/instance.d.ts +57 -0
  49. package/build/types/core/row.d.ts +15 -0
  50. package/build/types/features/ColumnSizing.d.ts +2 -1
  51. package/build/types/features/Expanding.d.ts +2 -2
  52. package/build/types/features/Filters.d.ts +2 -3
  53. package/build/types/features/Grouping.d.ts +8 -9
  54. package/build/types/features/Ordering.d.ts +2 -1
  55. package/build/types/features/Pagination.d.ts +2 -1
  56. package/build/types/features/Pinning.d.ts +2 -1
  57. package/build/types/features/RowSelection.d.ts +2 -1
  58. package/build/types/features/Sorting.d.ts +2 -1
  59. package/build/types/features/Visibility.d.ts +7 -7
  60. package/build/types/index.d.ts +4 -2
  61. package/build/types/sortingFns.d.ts +4 -4
  62. package/build/types/types.d.ts +10 -53
  63. package/build/umd/index.development.js +721 -836
  64. package/build/umd/index.development.js.map +1 -1
  65. package/build/umd/index.production.js +1 -1
  66. package/build/umd/index.production.js.map +1 -1
  67. package/package.json +1 -1
  68. package/src/aggregationFns.ts +44 -40
  69. package/src/core/cell.ts +47 -0
  70. package/src/core/column.ts +148 -0
  71. package/src/{features/Headers.ts → core/headers.ts} +98 -99
  72. package/src/core/instance.ts +361 -0
  73. package/src/core/row.ts +85 -0
  74. package/src/features/ColumnSizing.ts +1 -1
  75. package/src/features/Expanding.ts +1 -4
  76. package/src/features/Filters.ts +2 -7
  77. package/src/features/Grouping.ts +16 -19
  78. package/src/features/Ordering.ts +1 -1
  79. package/src/features/Pagination.ts +1 -1
  80. package/src/features/Pinning.ts +8 -4
  81. package/src/features/RowSelection.ts +1 -1
  82. package/src/features/Sorting.ts +1 -1
  83. package/src/features/Visibility.ts +8 -17
  84. package/src/index.ts +4 -8
  85. package/src/types.ts +9 -61
  86. package/src/utils/filterRowsUtils.ts +4 -2
  87. package/src/utils/getCoreRowModel.ts +4 -2
  88. package/src/utils/getExpandedRowModel.ts +1 -5
  89. package/src/utils/getGroupedRowModel.ts +14 -23
  90. package/build/cjs/core.js +0 -168
  91. package/build/cjs/core.js.map +0 -1
  92. package/build/cjs/features/Cells.js +0 -101
  93. package/build/cjs/features/Cells.js.map +0 -1
  94. package/build/cjs/features/Columns.js +0 -191
  95. package/build/cjs/features/Columns.js.map +0 -1
  96. package/build/cjs/features/Headers.js.map +0 -1
  97. package/build/cjs/features/Rows.js +0 -94
  98. package/build/cjs/features/Rows.js.map +0 -1
  99. package/build/types/core.d.ts +0 -30
  100. package/build/types/features/Cells.d.ts +0 -13
  101. package/build/types/features/Rows.d.ts +0 -28
  102. package/src/core.ts +0 -246
  103. package/src/features/Cells.ts +0 -128
  104. package/src/features/Columns.ts +0 -293
  105. package/src/features/Rows.ts +0 -142
@@ -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
- }