@tanstack/table-core 8.0.12 → 8.1.0

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 (127) hide show
  1. package/build/cjs/core/cell.js +13 -13
  2. package/build/cjs/core/cell.js.map +1 -1
  3. package/build/cjs/core/column.js +20 -21
  4. package/build/cjs/core/column.js.map +1 -1
  5. package/build/cjs/core/headers.js +63 -68
  6. package/build/cjs/core/headers.js.map +1 -1
  7. package/build/cjs/core/row.js +16 -11
  8. package/build/cjs/core/row.js.map +1 -1
  9. package/build/cjs/core/{instance.js → table.js} +46 -57
  10. package/build/cjs/core/table.js.map +1 -0
  11. package/build/cjs/features/ColumnSizing.js +36 -36
  12. package/build/cjs/features/ColumnSizing.js.map +1 -1
  13. package/build/cjs/features/Expanding.js +34 -34
  14. package/build/cjs/features/Expanding.js.map +1 -1
  15. package/build/cjs/features/Filters.js +46 -52
  16. package/build/cjs/features/Filters.js.map +1 -1
  17. package/build/cjs/features/Grouping.js +24 -49
  18. package/build/cjs/features/Grouping.js.map +1 -1
  19. package/build/cjs/features/Ordering.js +8 -8
  20. package/build/cjs/features/Ordering.js.map +1 -1
  21. package/build/cjs/features/Pagination.js +37 -37
  22. package/build/cjs/features/Pagination.js.map +1 -1
  23. package/build/cjs/features/Pinning.js +33 -33
  24. package/build/cjs/features/Pinning.js.map +1 -1
  25. package/build/cjs/features/RowSelection.js +86 -74
  26. package/build/cjs/features/RowSelection.js.map +1 -1
  27. package/build/cjs/features/Sorting.js +36 -40
  28. package/build/cjs/features/Sorting.js.map +1 -1
  29. package/build/cjs/features/Visibility.js +30 -30
  30. package/build/cjs/features/Visibility.js.map +1 -1
  31. package/build/cjs/index.js +3 -4
  32. package/build/cjs/index.js.map +1 -1
  33. package/build/cjs/utils/filterRowsUtils.js +8 -8
  34. package/build/cjs/utils/filterRowsUtils.js.map +1 -1
  35. package/build/cjs/utils/getCoreRowModel.js +8 -8
  36. package/build/cjs/utils/getCoreRowModel.js.map +1 -1
  37. package/build/cjs/utils/getExpandedRowModel.js +4 -4
  38. package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
  39. package/build/cjs/utils/getFacetedMinMaxValues.js +3 -3
  40. package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -1
  41. package/build/cjs/utils/getFacetedRowModel.js +4 -4
  42. package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
  43. package/build/cjs/utils/getFacetedUniqueValues.js +3 -3
  44. package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -1
  45. package/build/cjs/utils/getFilteredRowModel.js +8 -8
  46. package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
  47. package/build/cjs/utils/getGroupedRowModel.js +9 -9
  48. package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
  49. package/build/cjs/utils/getPaginationRowModel.js +4 -4
  50. package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
  51. package/build/cjs/utils/getSortedRowModel.js +7 -7
  52. package/build/cjs/utils/getSortedRowModel.js.map +1 -1
  53. package/build/cjs/utils.js +2 -2
  54. package/build/cjs/utils.js.map +1 -1
  55. package/build/esm/index.js +585 -677
  56. package/build/esm/index.js.map +1 -1
  57. package/build/stats-html.html +1 -1
  58. package/build/stats-react.json +352 -377
  59. package/build/types/index.d.ts +761 -29
  60. package/build/umd/index.development.js +586 -678
  61. package/build/umd/index.development.js.map +1 -1
  62. package/build/umd/index.production.js +1 -1
  63. package/build/umd/index.production.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/core/cell.ts +34 -28
  66. package/src/core/column.ts +83 -72
  67. package/src/core/headers.ts +118 -149
  68. package/src/core/row.ts +31 -25
  69. package/src/core/{instance.ts → table.ts} +85 -116
  70. package/src/features/ColumnSizing.ts +45 -47
  71. package/src/features/Expanding.ts +53 -59
  72. package/src/features/Filters.ts +112 -132
  73. package/src/features/Grouping.ts +63 -112
  74. package/src/features/Ordering.ts +19 -21
  75. package/src/features/Pagination.ts +54 -55
  76. package/src/features/Pinning.ts +49 -61
  77. package/src/features/RowSelection.ts +115 -114
  78. package/src/features/Sorting.ts +57 -72
  79. package/src/features/Visibility.ts +48 -48
  80. package/src/index.ts +1 -2
  81. package/src/types.ts +64 -69
  82. package/src/utils/filterRowsUtils.ts +33 -28
  83. package/src/utils/getCoreRowModel.ts +22 -22
  84. package/src/utils/getExpandedRowModel.ts +15 -15
  85. package/src/utils/getFacetedMinMaxValues.ts +6 -6
  86. package/src/utils/getFacetedRowModel.ts +12 -12
  87. package/src/utils/getFacetedUniqueValues.ts +6 -6
  88. package/src/utils/getFilteredRowModel.ts +17 -17
  89. package/src/utils/getGroupedRowModel.ts +18 -21
  90. package/src/utils/getPaginationRowModel.ts +10 -13
  91. package/src/utils/getSortedRowModel.ts +14 -14
  92. package/src/utils.ts +8 -2
  93. package/build/cjs/core/instance.js.map +0 -1
  94. package/build/cjs/createTable.js +0 -72
  95. package/build/cjs/createTable.js.map +0 -1
  96. package/build/types/aggregationFns.d.ts +0 -13
  97. package/build/types/core/cell.d.ts +0 -9
  98. package/build/types/core/column.d.ts +0 -40
  99. package/build/types/core/headers.d.ts +0 -46
  100. package/build/types/core/instance.d.ts +0 -58
  101. package/build/types/core/row.d.ts +0 -15
  102. package/build/types/createTable.d.ts +0 -63
  103. package/build/types/features/ColumnSizing.d.ts +0 -63
  104. package/build/types/features/Expanding.d.ts +0 -39
  105. package/build/types/features/Filters.d.ts +0 -90
  106. package/build/types/features/Grouping.d.ts +0 -68
  107. package/build/types/features/Ordering.d.ts +0 -18
  108. package/build/types/features/Pagination.d.ts +0 -42
  109. package/build/types/features/Pinning.d.ts +0 -40
  110. package/build/types/features/RowSelection.d.ts +0 -40
  111. package/build/types/features/Sorting.d.ts +0 -63
  112. package/build/types/features/Visibility.d.ts +0 -40
  113. package/build/types/filterFns.d.ts +0 -13
  114. package/build/types/sortingFns.d.ts +0 -11
  115. package/build/types/types.d.ts +0 -53
  116. package/build/types/utils/filterRowsUtils.d.ts +0 -4
  117. package/build/types/utils/getCoreRowModel.d.ts +0 -2
  118. package/build/types/utils/getExpandedRowModel.d.ts +0 -7
  119. package/build/types/utils/getFacetedMinMaxValues.d.ts +0 -2
  120. package/build/types/utils/getFacetedRowModel.d.ts +0 -2
  121. package/build/types/utils/getFacetedUniqueValues.d.ts +0 -2
  122. package/build/types/utils/getFilteredRowModel.d.ts +0 -2
  123. package/build/types/utils/getGroupedRowModel.d.ts +0 -2
  124. package/build/types/utils/getPaginationRowModel.d.ts +0 -4
  125. package/build/types/utils/getSortedRowModel.d.ts +0 -2
  126. package/build/types/utils.d.ts +0 -19
  127. package/src/createTable.ts +0 -188
@@ -1,19 +0,0 @@
1
- import { NoInfer, TableState, Updater } from './types';
2
- export declare type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
- export declare type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
4
- export declare type Overwrite<T, U extends {
5
- [TKey in keyof T]?: any;
6
- }> = Omit<T, keyof U> & U;
7
- export declare type IfDefined<T, N> = 0 extends 1 & T ? N : T extends {} ? T : N;
8
- export declare function functionalUpdate<T>(updater: Updater<T>, input: T): T;
9
- export declare function noop(): void;
10
- export declare function makeStateUpdater(key: keyof TableState, instance: unknown): (updater: Updater<any>) => void;
11
- declare type AnyFunction = (...args: any) => any;
12
- export declare function isFunction<T extends AnyFunction>(d: any): d is T;
13
- export declare function flattenBy<TNode>(arr: TNode[], getChildren: (item: TNode) => TNode[]): TNode[];
14
- export declare function memo<TDeps extends readonly any[], TResult>(getDeps: () => [...TDeps], fn: (...args: NoInfer<[...TDeps]>) => TResult, opts: {
15
- key: any;
16
- debug?: () => any;
17
- onChange?: (result: TResult) => void;
18
- }): () => TResult;
19
- export {};
@@ -1,188 +0,0 @@
1
- import { CustomFilterFns, FilterFn } from './features/Filters'
2
- import { AggregationFn, CustomAggregationFns } from './features/Grouping'
3
- import { CustomSortingFns, SortingFn } from './features/Sorting'
4
- import {
5
- ColumnDef,
6
- AccessorFn,
7
- AnyRender,
8
- TableGenerics,
9
- TableOptionsResolved,
10
- TableOptions,
11
- } from './types'
12
- import { IfDefined, Overwrite } from './utils'
13
-
14
- export type TableFactory<TGenerics extends TableGenerics> =
15
- () => Table<TGenerics>
16
-
17
- export type CreateTableOptions<
18
- TRender extends AnyRender,
19
- TFilterFns extends CustomFilterFns<any>,
20
- TSortingFns extends CustomSortingFns<any>,
21
- TAggregationFns extends CustomAggregationFns<any>,
22
- TGenerics extends TableGenerics
23
- > = Partial<
24
- {
25
- render?: TRender
26
- filterFns?: TFilterFns
27
- sortingFns?: TSortingFns
28
- aggregationFns?: TAggregationFns
29
- } & Omit<
30
- TableOptionsResolved<TGenerics>,
31
- 'filterFns' | 'sortingFns' | 'aggregationFns'
32
- >
33
- >
34
-
35
- export type Table<TGenerics extends TableGenerics> = {
36
- generics: TGenerics
37
- options: Partial<TableOptionsResolved<TGenerics>>
38
- // setGenerics: <T extends TableGenerics>() => Table<T>
39
- setRowType: <TRow>() => Table<Overwrite<TGenerics, { Row: TRow }>>
40
- setTableMetaType: <TTableMeta>() => Table<
41
- Overwrite<TGenerics, { TableMeta: TTableMeta }>
42
- >
43
- setColumnMetaType: <TColumnMeta>() => Table<
44
- Overwrite<TGenerics, { ColumnMeta: TColumnMeta }>
45
- >
46
- setFilterMetaType: <TFilterMeta>() => Table<
47
- Overwrite<TGenerics, { FilterMeta: TFilterMeta }>
48
- >
49
- setOptions: <
50
- TFilterFns extends Record<string, FilterFn<any>>,
51
- TSortingFns extends Record<string, SortingFn<any>>,
52
- TAggregationFns extends Record<string, AggregationFn<any>>
53
- >(
54
- options: CreateTableOptions<
55
- any,
56
- TFilterFns,
57
- TSortingFns,
58
- TAggregationFns,
59
- TGenerics
60
- >
61
- ) => Table<
62
- Overwrite<
63
- TGenerics,
64
- {
65
- FilterFns: IfDefined<TFilterFns, TGenerics['FilterFns']>
66
- SortingFns: IfDefined<TSortingFns, TGenerics['SortingFns']>
67
- AggregationFns: IfDefined<TAggregationFns, TGenerics['AggregationFns']>
68
- }
69
- >
70
- >
71
- createGroup: (
72
- column: Overwrite<
73
- | Overwrite<
74
- ColumnDef<any>,
75
- {
76
- header: string
77
- id?: string
78
- }
79
- >
80
- | Overwrite<
81
- ColumnDef<any>,
82
- {
83
- id: string
84
- header?: string | ((...any: any) => any)
85
- }
86
- >,
87
- {
88
- accessorFn?: never
89
- accessorKey?: never
90
- columns?: ColumnDef<any>[]
91
- }
92
- >
93
- ) => ColumnDef<TGenerics>
94
- createDisplayColumn: (
95
- column: Omit<ColumnDef<TGenerics>, 'columns'>
96
- ) => ColumnDef<TGenerics>
97
- createDataColumn: <
98
- TAccessor extends AccessorFn<TGenerics['Row']> | keyof TGenerics['Row']
99
- >(
100
- accessor: TAccessor,
101
- column: Overwrite<
102
- TAccessor extends (...args: any[]) => any
103
- ? // Accessor Fn
104
- ColumnDef<Overwrite<TGenerics, { Value: ReturnType<TAccessor> }>>
105
- : TAccessor extends keyof TGenerics['Row']
106
- ? // Accessor Key
107
- Overwrite<
108
- ColumnDef<
109
- Overwrite<TGenerics, { Value: TGenerics['Row'][TAccessor] }>
110
- >,
111
- {
112
- id?: string
113
- }
114
- >
115
- : never,
116
- {
117
- accessorFn?: never
118
- accessorKey?: never
119
- columns?: ColumnDef<any>[]
120
- }
121
- >
122
- ) => ColumnDef<TGenerics>
123
- createOptions: (options: TableOptions<TGenerics>) => TableOptions<TGenerics>
124
- }
125
-
126
- //
127
-
128
- export function createTableFactory<TRenderer extends AnyRender>(opts: {
129
- render: TRenderer
130
- }): () => Table<{ Renderer: TRenderer; Rendered: ReturnType<TRenderer> }> {
131
- return () => createTable(undefined, undefined, opts)
132
- }
133
-
134
- // A lot of returns in here are `as any` for a reason. Unless you
135
- // can find a better way to do this, then don't worry about them
136
- function createTable<TGenerics extends TableGenerics>(
137
- _?: undefined,
138
- __?: undefined,
139
- options?: CreateTableOptions<any, any, any, any, TGenerics>
140
- ): Table<TGenerics> {
141
- const table: Table<TGenerics> = {
142
- generics: undefined!,
143
- options: options ?? {
144
- render: (() => {
145
- throw new Error('')
146
- })(),
147
- },
148
- // setGenerics: () => table as any,
149
- setRowType: () => table as any,
150
- setTableMetaType: () => table as any,
151
- setColumnMetaType: () => table as any,
152
- setFilterMetaType: () => table as any,
153
- setOptions: newOptions =>
154
- createTable(_, __, {
155
- ...options,
156
- ...newOptions,
157
- } as any),
158
- createDisplayColumn: column => ({ ...column, columnDefType: 'display' }),
159
- createGroup: column => ({ ...column, columnDefType: 'group' } as any),
160
- createDataColumn: (accessor, column): any => {
161
- column = {
162
- ...column,
163
- columnDefType: 'data',
164
- id: column.id,
165
- }
166
-
167
- if (typeof accessor === 'string') {
168
- return {
169
- ...column,
170
- id: column.id ?? accessor,
171
- accessorKey: accessor,
172
- }
173
- }
174
-
175
- if (typeof accessor === 'function') {
176
- return {
177
- ...column,
178
- accessorFn: accessor,
179
- }
180
- }
181
-
182
- throw new Error('Invalid accessor')
183
- },
184
- createOptions: options => options,
185
- }
186
-
187
- return table
188
- }