@tanstack/table-core 8.10.1 → 8.10.2

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 (62) hide show
  1. package/build/lib/columnHelper.js.map +1 -1
  2. package/build/lib/core/cell.d.ts +36 -6
  3. package/build/lib/core/cell.js.map +1 -1
  4. package/build/lib/core/column.d.ts +46 -3
  5. package/build/lib/core/column.js.map +1 -1
  6. package/build/lib/core/headers.d.ts +160 -11
  7. package/build/lib/core/headers.js.map +1 -1
  8. package/build/lib/core/row.d.ts +81 -11
  9. package/build/lib/core/row.js.map +1 -1
  10. package/build/lib/core/table.d.ts +189 -28
  11. package/build/lib/core/table.js.map +1 -1
  12. package/build/lib/features/ColumnSizing.d.ts +140 -20
  13. package/build/lib/features/ColumnSizing.js.map +1 -1
  14. package/build/lib/features/Expanding.d.ts +126 -11
  15. package/build/lib/features/Expanding.js.map +1 -1
  16. package/build/lib/features/Filters.d.ts +225 -23
  17. package/build/lib/features/Filters.js.map +1 -1
  18. package/build/lib/features/Grouping.d.ts +151 -16
  19. package/build/lib/features/Grouping.js.map +1 -1
  20. package/build/lib/features/Ordering.d.ts +17 -2
  21. package/build/lib/features/Ordering.js.map +1 -1
  22. package/build/lib/features/Pagination.d.ts +118 -16
  23. package/build/lib/features/Pagination.js.map +1 -1
  24. package/build/lib/features/Pinning.d.ts +163 -13
  25. package/build/lib/features/Pinning.js.map +1 -1
  26. package/build/lib/features/RowSelection.d.ts +151 -16
  27. package/build/lib/features/RowSelection.js +5 -2
  28. package/build/lib/features/RowSelection.js.map +1 -1
  29. package/build/lib/features/Sorting.d.ts +187 -20
  30. package/build/lib/features/Sorting.js.map +1 -1
  31. package/build/lib/features/Visibility.d.ts +95 -12
  32. package/build/lib/features/Visibility.js.map +1 -1
  33. package/build/lib/filterFns.js.map +1 -1
  34. package/build/lib/index.esm.js +5 -2
  35. package/build/lib/index.esm.js.map +1 -1
  36. package/build/lib/index.mjs +5 -2
  37. package/build/lib/index.mjs.map +1 -1
  38. package/build/lib/utils.js.map +1 -1
  39. package/build/umd/index.development.js +5 -2
  40. package/build/umd/index.development.js.map +1 -1
  41. package/build/umd/index.production.js +1 -1
  42. package/build/umd/index.production.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/columnHelper.ts +2 -2
  45. package/src/core/cell.ts +36 -6
  46. package/src/core/column.ts +46 -3
  47. package/src/core/headers.ts +160 -11
  48. package/src/core/row.ts +88 -15
  49. package/src/core/table.ts +189 -28
  50. package/src/features/ColumnSizing.ts +143 -20
  51. package/src/features/Expanding.ts +126 -11
  52. package/src/features/Filters.ts +225 -24
  53. package/src/features/Grouping.ts +151 -17
  54. package/src/features/Ordering.ts +17 -2
  55. package/src/features/Pagination.ts +118 -16
  56. package/src/features/Pinning.ts +163 -13
  57. package/src/features/RowSelection.ts +154 -19
  58. package/src/features/Sorting.ts +187 -20
  59. package/src/features/Visibility.ts +98 -12
  60. package/src/filterFns.ts +2 -2
  61. package/src/types.ts +5 -5
  62. package/src/utils.ts +3 -3
@@ -16,11 +16,38 @@ export interface PaginationInitialTableState {
16
16
  }
17
17
 
18
18
  export interface PaginationOptions {
19
- pageCount?: number
20
- manualPagination?: boolean
21
- onPaginationChange?: OnChangeFn<PaginationState>
19
+ /**
20
+ * If set to `true`, pagination will be reset to the first page when page-altering state changes eg. `data` is updated, filters change, grouping changes, etc.
21
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#autoresetpageindex)
22
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
23
+ */
22
24
  autoResetPageIndex?: boolean
25
+ /**
26
+ * Returns the row model after pagination has taken place, but no further.
27
+ *
28
+ * Pagination columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here.
29
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpaginationrowmodel)
30
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
31
+ */
23
32
  getPaginationRowModel?: (table: Table<any>) => () => RowModel<any>
33
+ /**
34
+ * Enables manual pagination. If this option is set to `true`, the table will not automatically paginate rows using `getPaginationRowModel()` and instead will expect you to manually paginate the rows before passing them to the table. This is useful if you are doing server-side pagination and aggregation.
35
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#manualpagination)
36
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
37
+ */
38
+ manualPagination?: boolean
39
+ /**
40
+ * If this function is provided, it will be called when the pagination state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the `tableOptions.state.pagination` option.
41
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#onpaginationchange)
42
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
43
+ */
44
+ onPaginationChange?: OnChangeFn<PaginationState>
45
+ /**
46
+ * When manually controlling pagination, you should supply a total `pageCount` value to the table if you know it. If you do not know how many pages there are, you can set this to `-1`.
47
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#pagecount)
48
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
49
+ */
50
+ pageCount?: number
24
51
  }
25
52
 
26
53
  export interface PaginationDefaultOptions {
@@ -29,22 +56,97 @@ export interface PaginationDefaultOptions {
29
56
 
30
57
  export interface PaginationInstance<TData extends RowData> {
31
58
  _autoResetPageIndex: () => void
32
- setPagination: (updater: Updater<PaginationState>) => void
33
- resetPagination: (defaultState?: boolean) => void
34
- setPageIndex: (updater: Updater<number>) => void
59
+ _getPaginationRowModel?: () => RowModel<TData>
60
+ /**
61
+ * Returns whether the table can go to the next page.
62
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getcannextpage)
63
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
64
+ */
65
+ getCanNextPage: () => boolean
66
+ /**
67
+ * Returns whether the table can go to the previous page.
68
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getcanpreviouspage)
69
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
70
+ */
71
+ getCanPreviousPage: () => boolean
72
+ /**
73
+ * Returns the page count. If manually paginating or controlling the pagination state, this will come directly from the `options.pageCount` table option, otherwise it will be calculated from the table data using the total row count and current page size.
74
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpagecount)
75
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
76
+ */
77
+ getPageCount: () => number
78
+ /**
79
+ * Returns an array of page options (zero-index-based) for the current page size.
80
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpageoptions)
81
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
82
+ */
83
+ getPageOptions: () => number[]
84
+ /**
85
+ * Returns the row model for the table after pagination has been applied.
86
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpaginationrowmodel)
87
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
88
+ */
89
+ getPaginationRowModel: () => RowModel<TData>
90
+ /**
91
+ * Returns the row model for the table before any pagination has been applied.
92
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getprepaginationrowmodel)
93
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
94
+ */
95
+ getPrePaginationRowModel: () => RowModel<TData>
96
+ /**
97
+ * Increments the page index by one, if possible.
98
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#nextpage)
99
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
100
+ */
101
+ nextPage: () => void
102
+ /**
103
+ * Decrements the page index by one, if possible.
104
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#previouspage)
105
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
106
+ */
107
+ previousPage: () => void
108
+ /**
109
+ * Resets the page index to its initial state. If `defaultState` is `true`, the page index will be reset to `0` regardless of initial state.
110
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpageindex)
111
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
112
+ */
35
113
  resetPageIndex: (defaultState?: boolean) => void
36
- setPageSize: (updater: Updater<number>) => void
114
+ /**
115
+ * Resets the page size to its initial state. If `defaultState` is `true`, the page size will be reset to `10` regardless of initial state.
116
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpagesize)
117
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
118
+ */
37
119
  resetPageSize: (defaultState?: boolean) => void
120
+ /**
121
+ * Resets the **pagination** state to `initialState.pagination`, or `true` can be passed to force a default blank state reset to `[]`.
122
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpagination)
123
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
124
+ */
125
+ resetPagination: (defaultState?: boolean) => void
126
+ /**
127
+ * Updates the page count using the provided function or value.
128
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagecount)
129
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
130
+ */
38
131
  setPageCount: (updater: Updater<number>) => void
39
- getPageOptions: () => number[]
40
- getCanPreviousPage: () => boolean
41
- getCanNextPage: () => boolean
42
- previousPage: () => void
43
- nextPage: () => void
44
- getPrePaginationRowModel: () => RowModel<TData>
45
- getPaginationRowModel: () => RowModel<TData>
46
- _getPaginationRowModel?: () => RowModel<TData>
47
- getPageCount: () => number
132
+ /**
133
+ * Updates the page index using the provided function or value in the `state.pagination.pageIndex` state.
134
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpageindex)
135
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
136
+ */
137
+ setPageIndex: (updater: Updater<number>) => void
138
+ /**
139
+ * Updates the page size using the provided function or value in the `state.pagination.pageSize` state.
140
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagesize)
141
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
142
+ */
143
+ setPageSize: (updater: Updater<number>) => void
144
+ /**
145
+ * Sets or updates the `state.pagination` state.
146
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagination)
147
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
148
+ */
149
+ setPagination: (updater: Updater<PaginationState>) => void
48
150
  }
49
151
 
50
152
  //
@@ -19,8 +19,8 @@ export interface ColumnPinningState {
19
19
  }
20
20
 
21
21
  export interface RowPinningState {
22
- top?: string[]
23
22
  bottom?: string[]
23
+ top?: string[]
24
24
  }
25
25
 
26
26
  export interface ColumnPinningTableState {
@@ -32,15 +32,45 @@ export interface RowPinningTableState {
32
32
  }
33
33
 
34
34
  export interface ColumnPinningOptions {
35
- onColumnPinningChange?: OnChangeFn<ColumnPinningState>
36
- enablePinning?: boolean
35
+ /**
36
+ * Enables/disables column pinning for the table. Defaults to `true`.
37
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#enablecolumnpinning)
38
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
39
+ */
37
40
  enableColumnPinning?: boolean
41
+ /**
42
+ * Enables/disables all pinning for the table. Defaults to `true`.
43
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#enablepinning)
44
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
45
+ */
46
+ enablePinning?: boolean
47
+ /**
48
+ * If provided, this function will be called with an `updaterFn` when `state.columnPinning` changes. This overrides the default internal state management, so you will also need to supply `state.columnPinning` from your own managed state.
49
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#oncolumnpinningchange)
50
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/oncolumnpinningchange)
51
+ */
52
+ onColumnPinningChange?: OnChangeFn<ColumnPinningState>
38
53
  }
39
54
 
40
55
  export interface RowPinningOptions<TData extends RowData> {
41
- onRowPinningChange?: OnChangeFn<RowPinningState>
56
+ /**
57
+ * Enables/disables row pinning for the table. Defaults to `true`.
58
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#enablerowpinning)
59
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
60
+ */
42
61
  enableRowPinning?: boolean | ((row: Row<TData>) => boolean)
62
+ /**
63
+ * When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.
64
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#keeppinnedrows)
65
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
66
+ */
43
67
  keepPinnedRows?: boolean
68
+ /**
69
+ * If provided, this function will be called with an `updaterFn` when `state.rowPinning` changes. This overrides the default internal state management, so you will also need to supply `state.rowPinning` from your own managed state.
70
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#onrowpinningchange)
71
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/onrowpinningchange)
72
+ */
73
+ onRowPinningChange?: OnChangeFn<RowPinningState>
44
74
  }
45
75
 
46
76
  export interface ColumnPinningDefaultOptions {
@@ -52,26 +82,86 @@ export interface RowPinningDefaultOptions {
52
82
  }
53
83
 
54
84
  export interface ColumnPinningColumnDef {
85
+ /**
86
+ * Enables/disables column pinning for this column. Defaults to `true`.
87
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#enablepinning-1)
88
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
89
+ */
55
90
  enablePinning?: boolean
56
91
  }
57
92
 
58
93
  export interface ColumnPinningColumn {
94
+ /**
95
+ * Returns whether or not the column can be pinned.
96
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getcanpin)
97
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
98
+ */
59
99
  getCanPin: () => boolean
60
- getPinnedIndex: () => number
100
+ /**
101
+ * Returns the pinned position of the column. (`'left'`, `'right'` or `false`)
102
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getispinned)
103
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
104
+ */
61
105
  getIsPinned: () => ColumnPinningPosition
106
+ /**
107
+ * Returns the numeric pinned index of the column within a pinned column group.
108
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getpinnedindex)
109
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
110
+ */
111
+ getPinnedIndex: () => number
112
+ /**
113
+ * Pins a column to the `'left'` or `'right'`, or unpins the column to the center if `false` is passed.
114
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#pin)
115
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
116
+ */
62
117
  pin: (position: ColumnPinningPosition) => void
63
118
  }
64
119
 
65
120
  export interface ColumnPinningRow<TData extends RowData> {
66
- getLeftVisibleCells: () => Cell<TData, unknown>[]
121
+ /**
122
+ * Returns all center pinned (unpinned) leaf cells in the row.
123
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getcentervisiblecells)
124
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
125
+ */
67
126
  getCenterVisibleCells: () => Cell<TData, unknown>[]
127
+ /**
128
+ * Returns all left pinned leaf cells in the row.
129
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getleftvisiblecells)
130
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
131
+ */
132
+ getLeftVisibleCells: () => Cell<TData, unknown>[]
133
+ /**
134
+ * Returns all right pinned leaf cells in the row.
135
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getrightvisiblecells)
136
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
137
+ */
68
138
  getRightVisibleCells: () => Cell<TData, unknown>[]
69
139
  }
70
140
 
71
141
  export interface RowPinningRow {
142
+ /**
143
+ * Returns whether or not the row can be pinned.
144
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getcanpin-1)
145
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
146
+ */
72
147
  getCanPin: () => boolean
148
+ /**
149
+ * Returns the pinned position of the row. (`'top'`, `'bottom'` or `false`)
150
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getispinned-1)
151
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
152
+ */
73
153
  getIsPinned: () => RowPinningPosition
154
+ /**
155
+ * Returns the numeric pinned index of the row within a pinned row group.
156
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getpinnedindex-1)
157
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
158
+ */
74
159
  getPinnedIndex: () => number
160
+ /**
161
+ * Pins a row to the `'top'` or `'bottom'`, or unpins the row to the center if `false` is passed.
162
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#pin-1)
163
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
164
+ */
75
165
  pin: (
76
166
  position: RowPinningPosition,
77
167
  includeLeafRows?: boolean,
@@ -80,22 +170,82 @@ export interface RowPinningRow {
80
170
  }
81
171
 
82
172
  export interface ColumnPinningInstance<TData extends RowData> {
83
- setColumnPinning: (updater: Updater<ColumnPinningState>) => void
84
- resetColumnPinning: (defaultState?: boolean) => void
173
+ /**
174
+ * Returns all center pinned (unpinned) leaf columns.
175
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getcenterleafcolumns)
176
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
177
+ */
178
+ getCenterLeafColumns: () => Column<TData, unknown>[]
179
+ /**
180
+ * Returns whether or not any columns are pinned. Optionally specify to only check for pinned columns in either the `left` or `right` position.
181
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getissomecolumnspinned)
182
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
183
+ */
85
184
  getIsSomeColumnsPinned: (position?: ColumnPinningPosition) => boolean
185
+ /**
186
+ * Returns all left pinned leaf columns.
187
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getleftleafcolumns)
188
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
189
+ */
86
190
  getLeftLeafColumns: () => Column<TData, unknown>[]
191
+ /**
192
+ * Returns all right pinned leaf columns.
193
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getrightleafcolumns)
194
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
195
+ */
87
196
  getRightLeafColumns: () => Column<TData, unknown>[]
88
- getCenterLeafColumns: () => Column<TData, unknown>[]
197
+ /**
198
+ * Resets the **columnPinning** state to `initialState.columnPinning`, or `true` can be passed to force a default blank state reset to `{ left: [], right: [], }`.
199
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#resetcolumnpinning)
200
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
201
+ */
202
+ resetColumnPinning: (defaultState?: boolean) => void
203
+ /**
204
+ * Sets or updates the `state.columnPinning` state.
205
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#setcolumnpinning)
206
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
207
+ */
208
+ setColumnPinning: (updater: Updater<ColumnPinningState>) => void
89
209
  }
90
210
 
91
211
  export interface RowPinningInstance<TData extends RowData> {
92
- setRowPinning: (updater: Updater<RowPinningState>) => void
93
- resetRowPinning: (defaultState?: boolean) => void
94
- getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean
95
212
  _getPinnedRows: (position: 'top' | 'bottom') => Row<TData>[]
96
- getTopRows: () => Row<TData>[]
213
+ /**
214
+ * Returns all bottom pinned rows.
215
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getbottomrows)
216
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
217
+ */
97
218
  getBottomRows: () => Row<TData>[]
219
+ /**
220
+ * Returns all rows that are not pinned to the top or bottom.
221
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getcenterrows)
222
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
223
+ */
98
224
  getCenterRows: () => Row<TData>[]
225
+ /**
226
+ * Returns whether or not any rows are pinned. Optionally specify to only check for pinned rows in either the `top` or `bottom` position.
227
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#getissomerowspinned)
228
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
229
+ */
230
+ getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean
231
+ /**
232
+ * Returns all top pinned rows.
233
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#gettoprows)
234
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
235
+ */
236
+ getTopRows: () => Row<TData>[]
237
+ /**
238
+ * Resets the **rowPinning** state to `initialState.rowPinning`, or `true` can be passed to force a default blank state reset to `{ top: [], bottom: [], }`.
239
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#resetrowpinning)
240
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
241
+ */
242
+ resetRowPinning: (defaultState?: boolean) => void
243
+ /**
244
+ * Sets or updates the `state.rowPinning` state.
245
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pinning#setrowpinning)
246
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pinning)
247
+ */
248
+ setRowPinning: (updater: Updater<RowPinningState>) => void
99
249
  }
100
250
 
101
251
  //
@@ -9,9 +9,32 @@ export interface RowSelectionTableState {
9
9
  }
10
10
 
11
11
  export interface RowSelectionOptions<TData extends RowData> {
12
- enableRowSelection?: boolean | ((row: Row<TData>) => boolean)
12
+ /**
13
+ * - Enables/disables multiple row selection for all rows in the table OR
14
+ * - A function that given a row, returns whether to enable/disable multiple row selection for that row's children/grandchildren
15
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablemultirowselection)
16
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
17
+ */
13
18
  enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)
19
+ /**
20
+ * - Enables/disables row selection for all rows in the table OR
21
+ * - A function that given a row, returns whether to enable/disable row selection for that row
22
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablerowselection)
23
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
24
+ */
25
+ enableRowSelection?: boolean | ((row: Row<TData>) => boolean)
26
+ /**
27
+ * Enables/disables automatic sub-row selection when a parent row is selected, or a function that enables/disables automatic sub-row selection for each row.
28
+ * (Use in combination with expanding or grouping features)
29
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablesubrowselection)
30
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
31
+ */
14
32
  enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)
33
+ /**
34
+ * If provided, this function will be called with an `updaterFn` when `state.rowSelection` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
35
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#onrowselectionchange)
36
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
37
+ */
15
38
  onRowSelectionChange?: OnChangeFn<RowSelectionState>
16
39
  // enableGroupingRowSelection?:
17
40
  // | boolean
@@ -27,31 +50,141 @@ export interface RowSelectionOptions<TData extends RowData> {
27
50
  }
28
51
 
29
52
  export interface RowSelectionRow {
30
- getIsSelected: () => boolean
31
- getIsSomeSelected: () => boolean
32
- getIsAllSubRowsSelected: () => boolean
33
- getCanSelect: () => boolean
53
+ /**
54
+ * Returns whether or not the row can multi-select.
55
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanmultiselect)
56
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
57
+ */
34
58
  getCanMultiSelect: () => boolean
59
+ /**
60
+ * Returns whether or not the row can be selected.
61
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselect)
62
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
63
+ */
64
+ getCanSelect: () => boolean
65
+ /**
66
+ * Returns whether or not the row can select sub rows automatically when the parent row is selected.
67
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselectsubrows)
68
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
69
+ */
35
70
  getCanSelectSubRows: () => boolean
36
- toggleSelected: (value?: boolean) => void
71
+ /**
72
+ * Returns whether or not all of the row's sub rows are selected.
73
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallsubrowsselected)
74
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
75
+ */
76
+ getIsAllSubRowsSelected: () => boolean
77
+ /**
78
+ * Returns whether or not the row is selected.
79
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisselected)
80
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
81
+ */
82
+ getIsSelected: () => boolean
83
+ /**
84
+ * Returns whether or not some of the row's sub rows are selected.
85
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomeselected)
86
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
87
+ */
88
+ getIsSomeSelected: () => boolean
89
+ /**
90
+ * Returns a handler that can be used to toggle the row.
91
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleselectedhandler)
92
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
93
+ */
37
94
  getToggleSelectedHandler: () => (event: unknown) => void
95
+ /**
96
+ * Selects/deselects the row.
97
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleselected)
98
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
99
+ */
100
+ toggleSelected: (value?: boolean, opts?: { selectChildren?: boolean }) => void
38
101
  }
39
102
 
40
103
  export interface RowSelectionInstance<TData extends RowData> {
41
- getToggleAllRowsSelectedHandler: () => (event: unknown) => void
42
- getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void
43
- setRowSelection: (updater: Updater<RowSelectionState>) => void
44
- resetRowSelection: (defaultState?: boolean) => void
45
- getIsAllRowsSelected: () => boolean
104
+ /**
105
+ * Returns the row model of all rows that are selected after filtering has been applied.
106
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getfilteredselectedrowmodel)
107
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
108
+ */
109
+ getFilteredSelectedRowModel: () => RowModel<TData>
110
+ /**
111
+ * Returns the row model of all rows that are selected after grouping has been applied.
112
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getgroupedselectedrowmodel)
113
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
114
+ */
115
+ getGroupedSelectedRowModel: () => RowModel<TData>
116
+ /**
117
+ * Returns whether or not all rows on the current page are selected.
118
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallpagerowsselected)
119
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
120
+ */
46
121
  getIsAllPageRowsSelected: () => boolean
47
- getIsSomeRowsSelected: () => boolean
122
+ /**
123
+ * Returns whether or not all rows in the table are selected.
124
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallrowsselected)
125
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
126
+ */
127
+ getIsAllRowsSelected: () => boolean
128
+ /**
129
+ * Returns whether or not all rows on the current page are selected.
130
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomepagerowsselected)
131
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
132
+ */
48
133
  getIsSomePageRowsSelected: () => boolean
49
- toggleAllRowsSelected: (value?: boolean) => void
50
- toggleAllPageRowsSelected: (value?: boolean) => void
134
+ /**
135
+ * Returns whether or not all rows in the table are selected.
136
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomerowsselected)
137
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
138
+ */
139
+ getIsSomeRowsSelected: () => boolean
140
+ /**
141
+ * Returns the core row model of all rows before row selection has been applied.
142
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getpreselectedrowmodel)
143
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
144
+ */
51
145
  getPreSelectedRowModel: () => RowModel<TData>
146
+ /**
147
+ * Returns the row model of all rows that are selected.
148
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getselectedrowmodel)
149
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
150
+ */
52
151
  getSelectedRowModel: () => RowModel<TData>
53
- getFilteredSelectedRowModel: () => RowModel<TData>
54
- getGroupedSelectedRowModel: () => RowModel<TData>
152
+ /**
153
+ * Returns a handler that can be used to toggle all rows on the current page.
154
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallpagerowsselectedhandler)
155
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
156
+ */
157
+ getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void
158
+ /**
159
+ * Returns a handler that can be used to toggle all rows in the table.
160
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallrowsselectedhandler)
161
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
162
+ */
163
+ getToggleAllRowsSelectedHandler: () => (event: unknown) => void
164
+ /**
165
+ * Resets the **rowSelection** state to the `initialState.rowSelection`, or `true` can be passed to force a default blank state reset to `{}`.
166
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#resetrowselection)
167
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
168
+ */
169
+ resetRowSelection: (defaultState?: boolean) => void
170
+ /**
171
+ * Sets or updates the `state.rowSelection` state.
172
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#setrowselection)
173
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
174
+ */
175
+ setRowSelection: (updater: Updater<RowSelectionState>) => void
176
+ /**
177
+ * Selects/deselects all rows on the current page.
178
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallpagerowsselected)
179
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
180
+ */
181
+ toggleAllPageRowsSelected: (value?: boolean) => void
182
+ /**
183
+ * Selects/deselects all rows in the table.
184
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallrowsselected)
185
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
186
+ */
187
+ toggleAllRowsSelected: (value?: boolean) => void
55
188
  }
56
189
 
57
190
  //
@@ -342,7 +475,7 @@ export const RowSelection: TableFeature = {
342
475
  row: Row<TData>,
343
476
  table: Table<TData>
344
477
  ): void => {
345
- row.toggleSelected = value => {
478
+ row.toggleSelected = (value, opts) => {
346
479
  const isSelected = row.getIsSelected()
347
480
 
348
481
  table.setRowSelection(old => {
@@ -354,7 +487,9 @@ export const RowSelection: TableFeature = {
354
487
 
355
488
  const selectedRowIds = { ...old }
356
489
 
357
- mutateRowIsSelected(selectedRowIds, row.id, value, table)
490
+ if (opts?.selectChildren ?? true) {
491
+ mutateRowIsSelected(selectedRowIds, row.id, value, table)
492
+ }
358
493
 
359
494
  return selectedRowIds
360
495
  })
@@ -497,7 +632,7 @@ export function isSubRowSelected<TData extends RowData>(
497
632
  table: Table<TData>
498
633
  ): boolean | 'some' | 'all' {
499
634
  if (!row.subRows?.length) return false
500
-
635
+
501
636
  let allChildrenSelected = true
502
637
  let someSelected = false
503
638