@tanstack/table-core 8.0.0-alpha.10 → 8.0.0-alpha.13

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.10",
4
+ "version": "8.0.0-alpha.13",
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",
@@ -78,11 +78,17 @@ export type TableFactory<TGenerics extends Partial<DefaultGenerics>> = {
78
78
  column: Overwrite<
79
79
  TAccessor extends (...args: any[]) => any
80
80
  ? // Accessor Fn
81
- _NonGenerated<ColumnDef<TGenerics>>
81
+ _NonGenerated<
82
+ ColumnDef<Overwrite<TGenerics, { Value: ReturnType<TAccessor> }>>
83
+ >
82
84
  : TAccessor extends keyof TGenerics['Row']
83
85
  ? // Accessor Key
84
86
  Overwrite<
85
- _NonGenerated<ColumnDef<TGenerics>>,
87
+ _NonGenerated<
88
+ ColumnDef<
89
+ Overwrite<TGenerics, { Value: TGenerics['Row'][TAccessor] }>
90
+ >
91
+ >,
86
92
  {
87
93
  id?: string
88
94
  }
@@ -93,7 +99,18 @@ export type TableFactory<TGenerics extends Partial<DefaultGenerics>> = {
93
99
  accessorKey?: never
94
100
  }
95
101
  >
96
- ) => ColumnDef<TGenerics>
102
+ ) => ColumnDef<
103
+ Overwrite<
104
+ TGenerics,
105
+ {
106
+ Value: TAccessor extends (...args: any[]) => any
107
+ ? ReturnType<TAccessor>
108
+ : TAccessor extends keyof TGenerics['Row']
109
+ ? TGenerics['Row'][TAccessor]
110
+ : never
111
+ }
112
+ >
113
+ >
97
114
  }
98
115
 
99
116
  export function createTable<TRow>() {
@@ -67,6 +67,7 @@ export type SortingColumn<TGenerics extends PartialGenerics> = {
67
67
  getCanMultiSort: () => boolean
68
68
  getSortIndex: () => number
69
69
  getIsSorted: () => false | SortDirection
70
+ resetSorting: () => void
70
71
  toggleSorting: (desc?: boolean, isMulti?: boolean) => void
71
72
  getToggleSortingProps: <TGetter extends Getter<ToggleSortingProps>>(
72
73
  userProps?: TGetter
@@ -108,7 +109,7 @@ export type SortingInstance<TGenerics extends PartialGenerics> = {
108
109
  desc?: boolean,
109
110
  multi?: boolean
110
111
  ) => void
111
- resetSorting: () => void
112
+ resetSorting: (columnId?: string) => void
112
113
  getColumnCanSort: (columnId: string) => boolean
113
114
  getColumnCanMultiSort: (columnId: string) => boolean
114
115
  getColumnIsSorted: (columnId: string) => false | 'asc' | 'desc'
@@ -160,6 +161,7 @@ export const Sorting = {
160
161
  getCanMultiSort: () => instance.getColumnCanMultiSort(column.id),
161
162
  getSortIndex: () => instance.getColumnSortIndex(column.id),
162
163
  getIsSorted: () => instance.getColumnIsSorted(column.id),
164
+ resetSorting: () => instance.resetSorting(column.id),
163
165
  toggleSorting: (desc, isMulti) =>
164
166
  instance.toggleColumnSorting(column.id, desc, isMulti),
165
167
  getToggleSortingProps: userProps =>
@@ -402,8 +404,14 @@ export const Sorting = {
402
404
  getColumnSortIndex: columnId =>
403
405
  instance.getState().sorting?.findIndex(d => d.id === columnId) ?? -1,
404
406
 
405
- resetSorting: () => {
406
- instance.setSorting(instance.initialState?.sorting ?? [])
407
+ resetSorting: (columnId?: string) => {
408
+ if (columnId) {
409
+ instance.setSorting(old =>
410
+ old?.length ? old.filter(d => d.id !== columnId) : []
411
+ )
412
+ } else {
413
+ instance.setSorting(instance.initialState?.sorting ?? [])
414
+ }
407
415
  },
408
416
 
409
417
  getToggleSortingProps: (columnId, userProps) => {
package/src/.DS_Store DELETED
Binary file