@tanstack/table-core 8.0.0-alpha.72 → 8.0.0-alpha.73

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/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.72",
4
+ "version": "8.0.0-alpha.73",
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
@@ -44,8 +44,8 @@ export type CoreOptions<TGenerics extends TableGenerics> = {
44
44
  initialState?: InitialTableState
45
45
  autoResetAll?: boolean
46
46
  mergeOptions?: <T>(defaultOptions: T, options: Partial<T>) => T
47
- keepPreviousData?: boolean
48
47
  meta?: TGenerics['TableMeta']
48
+ // keepPreviousData?: boolean
49
49
  }
50
50
 
51
51
  export type CoreInstance<TGenerics extends TableGenerics> = {
@@ -54,20 +54,20 @@ export type CoreInstance<TGenerics extends TableGenerics> = {
54
54
  reset: () => void
55
55
  options: RequiredKeys<TableOptions<TGenerics>, 'state'>
56
56
  setOptions: (newOptions: Updater<TableOptions<TGenerics>>) => void
57
- queue: (cb: () => void) => void
58
57
  getState: () => TableState
59
58
  setState: (updater: Updater<TableState>) => void
60
- render: <TProps>(
59
+ _queue: (cb: () => void) => void
60
+ _render: <TProps>(
61
61
  template: Renderable<TGenerics, TProps>,
62
62
  props: TProps
63
63
  ) => string | null | TGenerics['Rendered']
64
+ _features: readonly TableFeature[]
64
65
  // getOverallProgress: () => number
65
66
  // getProgressStage: () =>
66
67
  // | undefined
67
68
  // | 'coreRowModel'
68
69
  // | 'filteredRowModel'
69
70
  // | 'facetedRowModel'
70
- _features: readonly TableFeature[]
71
71
  // createBatch: (priority: keyof CoreBatches) => Batch
72
72
  // init: () => void
73
73
  // willUpdate: () => void
@@ -231,7 +231,7 @@ export function createTableInstance<TGenerics extends TableGenerics>(
231
231
  ...options,
232
232
  },
233
233
  initialState,
234
- queue: cb => {
234
+ _queue: cb => {
235
235
  queued.push(cb)
236
236
 
237
237
  if (!queuedTimeout) {
@@ -297,7 +297,7 @@ export function createTableInstance<TGenerics extends TableGenerics>(
297
297
  const newOptions = functionalUpdate(updater, instance.options)
298
298
  instance.options = mergeOptions(newOptions)
299
299
  },
300
- render: (template, props) => {
300
+ _render: (template, props) => {
301
301
  if (typeof instance.options.render === 'function') {
302
302
  return instance.options.render(template, props)
303
303
  }
@@ -75,7 +75,7 @@ export const Cells = {
75
75
  getValue: () => row.getValue(columnId),
76
76
  renderCell: () =>
77
77
  column.cell
78
- ? instance.render(column.cell, {
78
+ ? instance._render(column.cell, {
79
79
  instance,
80
80
  column,
81
81
  row,
@@ -82,7 +82,7 @@ export const Expanding: TableFeature = {
82
82
  return {
83
83
  _autoResetExpanded: () => {
84
84
  if (!registered) {
85
- instance.queue(() => {
85
+ instance._queue(() => {
86
86
  registered = true
87
87
  })
88
88
  return
@@ -98,7 +98,7 @@ export const Expanding: TableFeature = {
98
98
  ) {
99
99
  if (queued) return
100
100
  queued = true
101
- instance.queue(() => {
101
+ instance._queue(() => {
102
102
  instance.resetExpanded()
103
103
  queued = false
104
104
  })
@@ -267,7 +267,7 @@ export const Grouping: TableFeature = {
267
267
  const template = column.aggregatedCell ?? column.cell
268
268
 
269
269
  return template
270
- ? instance.render(template, {
270
+ ? instance._render(template, {
271
271
  instance,
272
272
  column,
273
273
  row,
@@ -88,7 +88,7 @@ export const Headers = {
88
88
  },
89
89
  renderHeader: () =>
90
90
  column.header
91
- ? instance.render(column.header, {
91
+ ? instance._render(column.header, {
92
92
  instance,
93
93
  header: header as Header<TGenerics>,
94
94
  column,
@@ -96,7 +96,7 @@ export const Headers = {
96
96
  : null,
97
97
  renderFooter: () =>
98
98
  column.footer
99
- ? instance.render(column.footer, {
99
+ ? instance._render(column.footer, {
100
100
  instance,
101
101
  header: header as Header<TGenerics>,
102
102
  column,
@@ -33,7 +33,6 @@ export type PaginationOptions<TGenerics extends TableGenerics> = {
33
33
 
34
34
  export type PaginationDefaultOptions = {
35
35
  onPaginationChange: OnChangeFn<PaginationState>
36
- autoResetPageIndex: boolean
37
36
  }
38
37
 
39
38
  export type PaginationInstance<TGenerics extends TableGenerics> = {
@@ -82,7 +81,6 @@ export const Pagination: TableFeature = {
82
81
  ): PaginationDefaultOptions => {
83
82
  return {
84
83
  onPaginationChange: makeStateUpdater('pagination', instance),
85
- autoResetPageIndex: true,
86
84
  }
87
85
  },
88
86
 
@@ -95,23 +93,20 @@ export const Pagination: TableFeature = {
95
93
  return {
96
94
  _autoResetPageIndex: () => {
97
95
  if (!registered) {
98
- instance.queue(() => {
96
+ instance._queue(() => {
99
97
  registered = true
100
98
  })
101
99
  return
102
100
  }
103
101
 
104
- if (instance.options.autoResetAll === false) {
105
- return
106
- }
107
-
108
102
  if (
109
- instance.options.autoResetAll === true ||
110
- instance.options.autoResetPageIndex
103
+ instance.options.autoResetAll ??
104
+ instance.options.autoResetPageIndex ??
105
+ !instance.options.manualPagination
111
106
  ) {
112
107
  if (queued) return
113
108
  queued = true
114
- instance.queue(() => {
109
+ instance._queue(() => {
115
110
  instance.resetPageIndex()
116
111
  queued = false
117
112
  })
@@ -138,7 +133,7 @@ export const Pagination: TableFeature = {
138
133
  let pageIndex = functionalUpdate(updater, old.pageIndex)
139
134
 
140
135
  const maxPageIndex =
141
- old.pageCount && old.pageCount > 0
136
+ typeof old.pageCount !== 'undefined'
142
137
  ? old.pageCount - 1
143
138
  : Number.MAX_SAFE_INTEGER
144
139
 
@@ -155,7 +155,7 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
155
155
  key: process.env.NODE_ENV === 'development' && 'getGroupedRowModel',
156
156
  debug: () => instance.options.debugAll ?? instance.options.debugTable,
157
157
  onChange: () => {
158
- instance.queue(() => {
158
+ instance._queue(() => {
159
159
  instance._autoResetExpanded()
160
160
  instance._autoResetPageIndex()
161
161
  })