Skip to content

Commit 5b2fad4

Browse files
committed
remove state unavailable types again
1 parent 4f502ca commit 5b2fad4

File tree

59 files changed

+260
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+260
-469
lines changed

packages/table-core/src/core/cells/constructCell.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CellData, RowData } from '../../types/type-utils'
2-
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
2+
import type { TableFeatures } from '../../types/TableFeatures'
33
import type { Table } from '../../types/Table'
44
import type { Row } from '../../types/Row'
55
import type { Cell } from '../../types/Cell'
@@ -22,7 +22,7 @@ export function constructCell<
2222
table,
2323
}
2424

25-
for (const feature of Object.values(table._features) as Array<TableFeature>) {
25+
for (const feature of Object.values(table._features)) {
2626
feature.constructCellAPIs?.(cell as Cell<TFeatures, TData, TValue>)
2727
}
2828

packages/table-core/src/core/columns/Columns.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export const Columns: TableFeature = {
3131
{
3232
fn: () => column_getLeafColumns(column),
3333
memoDeps: () => [
34-
table.getState().columnOrder,
35-
table.getState().grouping,
34+
table.options.state?.columnOrder,
35+
table.options.state?.grouping,
3636
table.options.columns,
3737
table.options.groupedColumnMode,
3838
],
@@ -63,8 +63,8 @@ export const Columns: TableFeature = {
6363
{
6464
fn: () => table_getAllLeafColumns(table),
6565
memoDeps: () => [
66-
table.getState().columnOrder,
67-
table.getState().grouping,
66+
table.options.state?.columnOrder,
67+
table.options.state?.grouping,
6868
table.options.columns,
6969
table.options.groupedColumnMode,
7070
],

packages/table-core/src/core/columns/Columns.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function table_getDefaultColumnDef<
6161
},
6262
cell: (props) => props.renderValue<any>()?.toString?.() ?? null,
6363
...Object.values(table._features).reduce((obj, feature) => {
64-
return Object.assign(obj ?? {}, feature?.getDefaultColumnDef?.())
64+
return Object.assign(obj, feature.getDefaultColumnDef?.())
6565
}, {}),
6666
...table.options.defaultColumn,
6767
} as Partial<ColumnDef<TFeatures, TData, unknown>>

packages/table-core/src/core/columns/constructColumn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CellData, RowData } from '../../types/type-utils'
2-
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
2+
import type { TableFeatures } from '../../types/TableFeatures'
33
import type { Table } from '../../types/Table'
44
import type {
55
AccessorFn,
@@ -83,7 +83,7 @@ export function constructColumn<
8383
table,
8484
}
8585

86-
for (const feature of Object.values(table._features) as Array<TableFeature>) {
86+
for (const feature of Object.values(table._features)) {
8787
feature.constructColumnAPIs?.(column as Column<TFeatures, TData, TValue>)
8888
}
8989

packages/table-core/src/core/headers/Headers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export const Headers: TableFeature = {
4545
fn: () => table_getHeaderGroups(table),
4646
memoDeps: () => [
4747
table.options.columns,
48-
table.getState().columnOrder,
49-
table.getState().grouping,
50-
table.getState().columnPinning,
48+
table.options.state?.columnOrder,
49+
table.options.state?.grouping,
50+
table.options.state?.columnPinning,
5151
table.options.groupedColumnMode,
5252
],
5353
},

packages/table-core/src/core/headers/Headers.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function table_getHeaderGroups<
4848
TData extends RowData,
4949
>(table: Table<TFeatures, TData>) {
5050
const { left, right } =
51-
table.getState().columnPinning ?? getDefaultColumnPinningState()
51+
table.options.state?.columnPinning ?? getDefaultColumnPinningState()
5252
const allColumns = table.getAllColumns()
5353
const leafColumns = table_getVisibleLeafColumns(table)
5454

packages/table-core/src/core/headers/constructHeader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CellData, RowData } from '../../types/type-utils'
2-
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
2+
import type { TableFeatures } from '../../types/TableFeatures'
33
import type { Table } from '../../types/Table'
44
import type { Header } from '../../types/Header'
55
import type { Column } from '../../types/Column'
@@ -34,7 +34,7 @@ export function constructHeader<
3434
table,
3535
}
3636

37-
for (const feature of Object.values(table._features) as Array<TableFeature>) {
37+
for (const feature of Object.values(table._features)) {
3838
feature.constructHeaderAPIs?.(header as Header<TFeatures, TData, TValue>)
3939
}
4040

packages/table-core/src/core/rows/constructRow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { RowData } from '../../types/type-utils'
2-
import type { TableFeature, TableFeatures } from '../../types/TableFeatures'
2+
import type { TableFeatures } from '../../types/TableFeatures'
33
import type { Table } from '../../types/Table'
44
import type { Row } from '../../types/Row'
55
import type { Row_CoreProperties } from './Rows.types'
@@ -28,7 +28,7 @@ export const constructRow = <
2828
table,
2929
}
3030

31-
for (const feature of Object.values(table._features) as Array<TableFeature>) {
31+
for (const feature of Object.values(table._features)) {
3232
feature.constructRowAPIs?.(row as Row<TFeatures, TData>)
3333
}
3434

packages/table-core/src/core/table/constructTable.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export function getInitialTableState<TFeatures extends TableFeatures>(
1212
initialState: Partial<TableState<TFeatures>> | undefined = {},
1313
): TableState<TFeatures> {
1414
Object.values(features).forEach((feature) => {
15-
initialState = feature.getInitialState?.(initialState) ?? initialState
15+
initialState =
16+
feature.getInitialState?.(initialState as TableState<TFeatures>) ??
17+
initialState
1618
})
1719
return structuredClone(initialState) as TableState<TFeatures>
1820
}

packages/table-core/src/features/column-faceting/createFacetedMinMaxValues.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ export function createFacetedMinMaxValues<
2020
column_getFacetedRowModel(table.getColumn(columnId), table)(),
2121
],
2222
fn: (facetedRowModel) =>
23-
_createFacetedMinMaxValues(table, columnId, facetedRowModel),
23+
_createFacetedMinMaxValues(columnId, facetedRowModel),
2424
})
2525
}
2626

2727
function _createFacetedMinMaxValues<
2828
TFeatures extends TableFeatures,
2929
TData extends RowData,
3030
>(
31-
table: Table<TFeatures, TData>,
3231
columnId: string,
3332
facetedRowModel?: RowModel<TFeatures, TData>,
3433
): undefined | [number, number] {

0 commit comments

Comments
 (0)