Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/angular-table/src/injectTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ export function injectTable<

return ngZone.runOutsideAngular(() =>
lazyInit(() => {
const table = constructTable({
// Explicit type arguments skip generic inference from the spread object
// (a type-check hot spot); the spread only adds the angular reactivity
// binding to `features`.
const table = constructTable<TFeatures, TData>({
...options(),
features: {
coreReactivityFeature: angularReactivity(injector),
Expand Down
5 changes: 4 additions & 1 deletion packages/preact-table/src/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ export function useTable<
selector?: (state: TableState<TFeatures>) => TSelected,
): PreactTable<TFeatures, TData, TSelected> {
const [table] = useState(() => {
const tableInstance = constructTable({
// Explicit type arguments skip generic inference from the spread object (a
// type-check hot spot); the spread only adds the preact reactivity binding
// to `features`.
const tableInstance = constructTable<TFeatures, TData>({
...tableOptions,
features: {
coreReactivityFeature: preactReactivity(),
Expand Down
5 changes: 4 additions & 1 deletion packages/react-table/src/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ export function useTable<
selector?: (state: TableState<TFeatures>) => TSelected,
): ReactTable<TFeatures, TData, TSelected> {
const [table] = useState(() => {
const tableInstance = constructTable({
// Explicit type arguments skip generic inference from the spread object (a
// type-check hot spot); the spread only adds the react reactivity binding
// to `features`.
const tableInstance = constructTable<TFeatures, TData>({
...tableOptions,
features: {
coreReactivityFeature: reactReactivity(),
Expand Down
12 changes: 6 additions & 6 deletions packages/table-core/src/core/cells/coreCellsFeature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { Cell } from '../../types/Cell'
import type { Column } from '../../types/Column'

export interface CellContext<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
cell: Cell<TFeatures, TData, TValue>
Expand All @@ -19,8 +19,8 @@ export interface CellContext<
}

export interface Cell_CoreProperties<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
/**
Expand All @@ -42,8 +42,8 @@ export interface Cell_CoreProperties<
}

export interface Cell_Cell<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> extends Cell_CoreProperties<TFeatures, TData, TValue> {
/**
Expand Down
16 changes: 8 additions & 8 deletions packages/table-core/src/core/columns/coreColumnsFeature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { AccessorFn, ColumnDef } from '../../types/ColumnDef'
import type { Column } from '../../types/Column'

export interface Column_CoreProperties<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
/**
Expand Down Expand Up @@ -43,8 +43,8 @@ export interface Column_CoreProperties<
}

export interface Column_Column<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> extends Column_CoreProperties<TFeatures, TData, TValue> {
/**
Expand All @@ -59,8 +59,8 @@ export interface Column_Column<
}

export interface TableOptions_Columns<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
/**
Expand All @@ -74,8 +74,8 @@ export interface TableOptions_Columns<
}

export interface Table_Columns<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Returns a map of all flat columns by their ID.
Expand Down
20 changes: 10 additions & 10 deletions packages/table-core/src/core/headers/coreHeadersFeature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { HeaderGroup } from '../../types/HeaderGroup'
import type { Column } from '../../types/Column'

export interface Table_Headers<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Builds the visible header groups for the current column tree, visibility,
Expand All @@ -30,8 +30,8 @@ export interface Table_Headers<
}

export interface HeaderContext<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
/**
Expand All @@ -49,8 +49,8 @@ export interface HeaderContext<
}

export interface Header_CoreProperties<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
/**
Expand Down Expand Up @@ -100,8 +100,8 @@ export interface Header_CoreProperties<
}

export interface Header_Header<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> extends Header_CoreProperties<TFeatures, TData, TValue> {
/**
Expand All @@ -115,8 +115,8 @@ export interface Header_Header<
}

export interface HeaderGroup_Header<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
TValue extends CellData = CellData,
> {
depth: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ import type { TableFeatures } from '../../types/TableFeatures'
import type { RowData } from '../../types/type-utils'

export interface RowModel<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
rows: Array<Row<TFeatures, TData>>
flatRows: Array<Row<TFeatures, TData>>
rowsById: Record<string, Row<TFeatures, TData>>
}

export interface CachedRowModel_Core<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
coreRowModel: () => RowModel<TFeatures, TData>
}

export interface Table_RowModels_Core<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Returns the core row model before any processing has been applied.
Expand Down
9 changes: 5 additions & 4 deletions packages/table-core/src/core/row-models/createCoreRowModel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { constructRow } from '../rows/constructRow'
import { tableMemo } from '../../utils'
import { table_autoResetPageIndex } from '../../features/row-pagination/rowPaginationFeature.utils'
import type { Table, Table_Internal } from '../../types/Table'
import type { Table_Internal } from '../../types/Table'
import type { RowModel } from './coreRowModelsFeature.types'
import type { TableFeatures } from '../../types/TableFeatures'
import type { Row } from '../../types/Row'
Expand All @@ -15,9 +15,10 @@ import type { RowData } from '../../types/type-utils'
export function createCoreRowModel<
TFeatures extends TableFeatures,
TData extends RowData,
>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {
return (_table) => {
const table = _table as unknown as Table_Internal<TFeatures, TData>
>(): (
table: Table_Internal<TFeatures, TData>,
) => () => RowModel<TFeatures, TData> {
return (table) => {
return tableMemo({
feature: 'coreRowModelsFeature',
table,
Expand Down
16 changes: 8 additions & 8 deletions packages/table-core/src/core/rows/coreRowsFeature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { Row } from '../../types/Row'
import type { Cell } from '../../types/Cell'

export interface Row_CoreProperties<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
_uniqueValuesCache: Record<string, unknown>
_valuesCache: Record<string, unknown>
Expand Down Expand Up @@ -45,8 +45,8 @@ export interface Row_CoreProperties<
}

export interface Row_Row<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> extends Row_CoreProperties<TFeatures, TData> {
/**
* Builds a lookup of this row's cells keyed by leaf column id.
Expand Down Expand Up @@ -83,8 +83,8 @@ export interface Row_Row<
}

export interface TableOptions_Rows<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.
Expand All @@ -106,8 +106,8 @@ export interface TableOptions_Rows<
}

export interface Table_Rows<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
getRowId: (_: TData, index: number, parent?: Row<TFeatures, TData>) => string
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/table-core/src/core/table/constructTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ export function constructTable<
featuresList[i]!.constructTableAPIs?.(table)
}

return table
return table as unknown as Table<TFeatures, TData>
}
16 changes: 8 additions & 8 deletions packages/table-core/src/core/table/coreTablesFeature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type { TableOptions } from '../../types/TableOptions'
import type { TableState, TableState_All } from '../../types/TableState'

export interface TableMeta<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {}

/**
Expand Down Expand Up @@ -84,8 +84,8 @@ export type ExternalAtoms_All = Partial<{
}>

export interface TableOptions_Table<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* The feature modules registered on this table instance.
Expand Down Expand Up @@ -152,8 +152,8 @@ export interface TableOptions_Table<
}

export interface Table_CoreProperties<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Table reactivity bindings for interacting with TanStack Store.
Expand Down Expand Up @@ -220,8 +220,8 @@ export interface Table_CoreProperties<
}

export interface Table_Table<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> extends Table_CoreProperties<TFeatures, TData> {
/**
* Resets the table's internal base atoms to `table.initialState`.
Expand Down
10 changes: 8 additions & 2 deletions packages/table-core/src/core/table/coreTablesFeature.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export function table_mergeOptions<
newOptions: TableOptions<TFeatures, TData>,
) {
if (table.options.mergeOptions) {
return table.options.mergeOptions(table.options, newOptions)
return table.options.mergeOptions(
table.options as TableOptions<TFeatures, TData>,
newOptions,
)
}

return {
Expand All @@ -110,7 +113,10 @@ export function table_setOptions<
table: Table_Internal<TFeatures, TData>,
updater: Updater<TableOptions<TFeatures, TData>>,
): void {
const newOptions = functionalUpdate(updater, table.options)
const newOptions = functionalUpdate(
updater,
table.options as TableOptions<TFeatures, TData>,
)
// table static options that should never change after initialization
const { features, atoms, initialState } = table.options
const mergedOptions = Object.assign(table_mergeOptions(table, newOptions), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { TableFeatures } from '../../types/TableFeatures'
import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'

export interface Column_ColumnFaceting<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Computes min/max numeric facet values for this column.
Expand All @@ -25,8 +25,8 @@ export interface Column_ColumnFaceting<
}

export interface Table_RowModels_Faceted<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Computes min/max numeric facet values for the active faceting context.
Expand All @@ -49,17 +49,17 @@ export interface Table_RowModels_Faceted<
}

export interface CachedRowModel_Faceted<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
facetedRowModel?: (columnId: string) => () => RowModel<TFeatures, TData>
facetedMinMaxValues?: (columnId: string) => [number, number]
facetedUniqueValues?: (columnId: string) => Map<any, number>
}

export interface Table_ColumnFaceting<
TFeatures extends TableFeatures,
TData extends RowData,
in out TFeatures extends TableFeatures,
in out TData extends RowData,
> {
/**
* Returns the min and max values for the global filter.
Expand Down
Loading
Loading