Skip to content

Commit

Permalink
trying out internal types
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Sep 29, 2024
1 parent c3de177 commit 199fffc
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface TableState_ColumnFiltering_Unavailable {
/**
* @deprecated Import the `ColumnFiltering` feature to use the column filtering APIs.
*/
columnFilters: ColumnFiltersState
columnFilters?: ColumnFiltersState
}

export type ColumnFiltersState = Array<ColumnFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface TableState_ColumnGrouping_Unavailable {
/**
* @deprecated Import the `ColumnGrouping` feature to use the column grouping APIs.
*/
grouping: GroupingState
grouping?: GroupingState
}

export interface AggregationFns {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface TableState_ColumnOrdering_Unavailable {
/**
* @deprecated Import the `ColumnOrdering` feature to use the column ordering APIs.
*/
columnOrder: ColumnOrderState
columnOrder?: ColumnOrderState
}

export interface TableOptions_ColumnOrdering {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface TableState_ColumnPinning_Unavailable {
/**
* @deprecated Import the `ColumnPinning` feature to use the column pinning APIs.
*/
columnPinning: ColumnPinningState
columnPinning?: ColumnPinningState
}

export interface TableOptions_ColumnPinning {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface TableState_ColumnResizing_Unavailable {
/**
* @deprecated Import the `ColumnResizing` feature to use the column resizing APIs.
*/
columnResizing: columnResizingState
columnResizing?: columnResizingState
}

export interface columnResizingState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface TableState_ColumnSizing_Unavailable {
/**
* @deprecated Import the `ColumnSizing` feature to use the column sizing APIs.
*/
columnSizing: ColumnSizingState
columnSizing?: ColumnSizingState
}

export type ColumnSizingState = Record<string, number>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface TableState_ColumnVisibility_Unavailable {
/**
* @deprecated Import the `ColumnVisibility` feature to use the column visibility APIs.
*/
columnVisibility: ColumnVisibilityState
columnVisibility?: ColumnVisibilityState
}

export interface TableOptions_ColumnVisibility {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface TableState_GlobalFiltering_Unavailable {
/**
* @deprecated Import the `GlobalFiltering` feature to use the global filtering APIs.
*/
globalFilter: any
globalFilter?: any
}

export interface ColumnDef_GlobalFiltering {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { filterFns } from '../../fns/filterFns'
import { isFunction } from '../../utils'
import { table_getInitialState } from '../../core/table/Tables.utils'
import type { ColumnDefBase_All } from '../../types/ColumnDef'
import type { TableOptions_GlobalFiltering } from './GlobalFiltering.types'
import type {
ColumnDef_GlobalFiltering,
TableOptions_GlobalFiltering,
} from './GlobalFiltering.types'
import type {
ColumnDef_ColumnFiltering,
FilterFn,
TableOptions_ColumnFiltering,
} from '../column-filtering/ColumnFiltering.types'
import type { CellData, RowData } from '../../types/type-utils'
import type { TableFeatures } from '../../types/TableFeatures'
import type { Table } from '../../types/Table'
import type { Table, Table_Internal } from '../../types/Table'
import type { Column } from '../../types/Column'
import type { BuiltInFilterFn } from '../../fns/filterFns'

Expand All @@ -28,16 +25,9 @@ export function column_getCanGlobalFilter<
TValue extends CellData = CellData,
>(
column: Column<TFeatures, TData, TValue> & {
columnDef: Partial<
ColumnDef_GlobalFiltering & ColumnDef_ColumnFiltering<TFeatures, TData>
>
},
table: Table<TFeatures, TData> & {
options: Partial<
TableOptions_GlobalFiltering<TFeatures, TData> &
TableOptions_ColumnFiltering<TFeatures, TData>
>
columnDef: ColumnDefBase_All<TFeatures, TData, TValue>
},
table: Table_Internal<TFeatures, TData>,
): boolean {
return (
(column.columnDef.enableGlobalFilter ?? true) &&
Expand All @@ -61,12 +51,7 @@ export function table_getGlobalFilterFn<
TFeatures extends TableFeatures,
TData extends RowData,
>(
table: Table<TFeatures, TData> & {
options: Partial<
TableOptions_GlobalFiltering<TFeatures, TData> &
TableOptions_ColumnFiltering<TFeatures, TData>
>
},
table: Table_Internal<TFeatures, TData>
): FilterFn<TFeatures, TData> | FilterFn<TFeatures, TData> | undefined {
const { globalFilterFn: globalFilterFn } = table.options

Expand All @@ -87,9 +72,7 @@ export function table_setGlobalFilter<
TFeatures extends TableFeatures,
TData extends RowData,
>(
table: Table<TFeatures, TData> & {
options: Partial<TableOptions_GlobalFiltering<TFeatures, TData>>
},
table: Table_Internal<TFeatures, TData>,
updater: any,
) {
table.options.onGlobalFilterChange?.(updater)
Expand All @@ -104,12 +87,7 @@ export function table_resetGlobalFilter<
TFeatures extends TableFeatures,
TData extends RowData,
>(
table: Table<TFeatures, TData> & {
options: Partial<
TableOptions_GlobalFiltering<TFeatures, TData> &
TableOptions_ColumnFiltering<TFeatures, TData>
>
},
table: Table_Internal<TFeatures, TData>,
defaultState?: boolean,
) {
table_setGlobalFilter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TableState_RowExpanding_Unavailable {
/**
* @deprecated Import the `RowExpanding` feature to use the row expansion APIs.
*/
expanded: ExpandedState
expanded?: ExpandedState
}

export interface Row_RowExpanding {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TableState_RowPagination_Unavailable {
/**
* @deprecated Import the `RowPagination` feature to use the row pagination APIs.
*/
pagination: PaginationState
pagination?: PaginationState
}

export interface TableOptions_RowPagination {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface TableState_RowPinning_Unavailable {
/**
* @deprecated Import the `RowPinning` feature to use the row pinning APIs.
*/
rowPinning: RowPinningState
rowPinning?: RowPinningState
}

export interface TableOptions_RowPinning<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface TableState_RowSelection_Unavailable {
/**
* @deprecated Import the `RowSelection` feature to use the row selection APIs.
*/
rowSelection: RowSelectionState
rowSelection?: RowSelectionState
}

export interface TableOptions_RowSelection<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface TableState_RowSorting_Unavailable {
/**
* @deprecated Import the `RowSorting` feature to use the row sorting APIs.
*/
sorting: SortingState
sorting?: SortingState
}

export interface SortingFns {}
Expand Down
63 changes: 56 additions & 7 deletions packages/table-core/src/types/ColumnDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,35 @@ import type { CellData, RowData, UnionToIntersection } from './type-utils'
import type { TableFeatures } from './TableFeatures'
import type { CellContext } from '../core/cells/Cells.types'
import type { HeaderContext } from '../core/headers/Headers.types'
import type { ColumnDef_ColumnFiltering } from '../features/column-filtering/ColumnFiltering.types'
import type { ColumnDef_ColumnGrouping } from '../features/column-grouping/ColumnGrouping.types'
import type { ColumnDef_ColumnPinning } from '../features/column-pinning/ColumnPinning.types'
import type { ColumnDef_ColumnResizing } from '../features/column-resizing/ColumnResizing.types'
import type {
ColumnDef_ColumnFiltering,
ColumnDef_ColumnFiltering_Unavailable,
} from '../features/column-filtering/ColumnFiltering.types'
import type {
ColumnDef_ColumnGrouping,
ColumnDef_ColumnGrouping_Unavailable,
} from '../features/column-grouping/ColumnGrouping.types'
import type {
ColumnDef_ColumnPinning,
ColumnDef_ColumnPinning_Unavailable,
} from '../features/column-pinning/ColumnPinning.types'
import type {
ColumnDef_ColumnResizing,
ColumnDef_ColumnResizing_Unavailable,
} from '../features/column-resizing/ColumnResizing.types'
import type { ColumnDef_ColumnSizing } from '../features/column-sizing/ColumnSizing.types'
import type { ColumnDef_ColumnVisibility } from '../features/column-visibility/ColumnVisibility.types'
import type { ColumnDef_GlobalFiltering } from '../features/global-filtering/GlobalFiltering.types'
import type { ColumnDef_RowSorting } from '../features/row-sorting/RowSorting.types'
import type {
ColumnDef_ColumnVisibility,
ColumnDef_ColumnVisibility_Unavailable,
} from '../features/column-visibility/ColumnVisibility.types'
import type {
ColumnDef_GlobalFiltering,
ColumnDef_GlobalFiltering_Unavailable,
} from '../features/global-filtering/GlobalFiltering.types'
import type {
ColumnDef_RowSorting,
ColumnDef_RowSorting_Unavailable,
} from '../features/row-sorting/RowSorting.types'

export interface ColumnMeta<
TFeatures extends TableFeatures,
Expand Down Expand Up @@ -92,6 +113,34 @@ export type ColumnDefBase<
: never)
>

// export type ColumnDefBase<
// TFeatures extends TableFeatures,
// TData extends RowData,
// TValue extends CellData = CellData,
// > = ColumnDefBase_Core<TFeatures, TData, TValue> &
// ('ColumnVisibility' extends keyof TFeatures
// ? ColumnDef_ColumnVisibility
// : ColumnDef_ColumnVisibility_Unavailable) &
// ('ColumnPinning' extends keyof TFeatures
// ? ColumnDef_ColumnPinning
// : ColumnDef_ColumnPinning_Unavailable) &
// ('ColumnFiltering' extends keyof TFeatures
// ? ColumnDef_ColumnFiltering<TFeatures, TData>
// : ColumnDef_ColumnFiltering_Unavailable<TFeatures, TData>) &
// ('GlobalFiltering' extends keyof TFeatures
// ? ColumnDef_GlobalFiltering
// : ColumnDef_GlobalFiltering_Unavailable) &
// ('RowSorting' extends keyof TFeatures
// ? ColumnDef_RowSorting<TFeatures, TData>
// : ColumnDef_RowSorting_Unavailable<TFeatures, TData>) &
// ('ColumnGrouping' extends keyof TFeatures
// ? ColumnDef_ColumnGrouping<TFeatures, TData, TValue>
// : ColumnDef_ColumnGrouping_Unavailable<TFeatures, TData, TValue>) &
// ('ColumnSizing' extends keyof TFeatures ? ColumnDef_ColumnSizing : {}) &
// ('ColumnResizing' extends keyof TFeatures
// ? ColumnDef_ColumnResizing
// : ColumnDef_ColumnResizing_Unavailable)

export type ColumnDefBase_All<
TFeatures extends TableFeatures,
TData extends RowData,
Expand Down
8 changes: 4 additions & 4 deletions packages/table-core/src/types/TableFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export interface TableFeature {
}

export interface CoreTableFeatures {
Tables?: TableFeature
Rows?: TableFeature
Headers?: TableFeature
Columns?: TableFeature
Cells?: TableFeature
Columns?: TableFeature
Headers?: TableFeature
Rows?: TableFeature
Tables?: TableFeature
}

export interface TableFeatures extends CoreTableFeatures {
Expand Down
Loading

0 comments on commit 199fffc

Please sign in to comment.