Skip to content

Commit

Permalink
back and forth progress on internal types
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Sep 29, 2024
1 parent ccb937d commit c3de177
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 214 deletions.
1 change: 0 additions & 1 deletion packages/table-core/src/core/headers/Headers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { Header } from '../../types/Header'
import type { RowData } from '../../types/type-utils'
import type { TableFeatures } from '../../types/TableFeatures'
import type { Table } from '../../types/Table'
import type { HeaderGroup } from '../../types/HeaderGroup'
import type { Header_Header } from './Headers.types'

export function header_getLeafHeaders<
Expand Down
2 changes: 1 addition & 1 deletion packages/table-core/src/core/rows/Rows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assignAPIs, getMemoOptions, memo } from '../../utils'
import { assignAPIs } from '../../utils'
import { table_getAllLeafColumns } from '../columns/Columns.utils'
import {
row_getAllCells,
Expand Down
115 changes: 56 additions & 59 deletions packages/table-core/src/types/ColumnDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,14 @@ 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,
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,
ColumnDef_ColumnSizing_Unavailable,
} from '../features/column-sizing/ColumnSizing.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'
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_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'

export interface ColumnMeta<
TFeatures extends TableFeatures,
Expand Down Expand Up @@ -75,42 +51,63 @@ type ColumnIdentifiers<
TValue extends CellData = CellData,
> = IdIdentifier<TFeatures, TData, TValue> | StringHeaderIdentifier

export type ColumnDefBase<
interface ColumnDefBase_Core<
TFeatures extends TableFeatures,
TData extends RowData,
TValue extends CellData = CellData,
> = UnionToIntersection<
| ('ColumnVisibility' extends keyof TFeatures
? ColumnDef_ColumnVisibility
: Partial<ColumnDef_ColumnVisibility_Unavailable>)
| ('ColumnPinning' extends keyof TFeatures
? ColumnDef_ColumnPinning
: Partial<ColumnDef_ColumnPinning_Unavailable>)
| ('ColumnFiltering' extends keyof TFeatures
? ColumnDef_ColumnFiltering<TFeatures, TData>
: Partial<ColumnDef_ColumnFiltering_Unavailable<TFeatures, TData>>)
| ('GlobalFiltering' extends keyof TFeatures
? ColumnDef_GlobalFiltering
: Partial<ColumnDef_GlobalFiltering_Unavailable>)
| ('RowSorting' extends keyof TFeatures
? ColumnDef_RowSorting<TFeatures, TData>
: Partial<ColumnDef_RowSorting_Unavailable<TFeatures, TData>>)
| ('ColumnGrouping' extends keyof TFeatures
? ColumnDef_ColumnGrouping<TFeatures, TData, TValue>
: Partial<ColumnDef_ColumnGrouping_Unavailable<TFeatures, TData, TValue>>)
| ('ColumnSizing' extends keyof TFeatures
? ColumnDef_ColumnSizing
: Partial<ColumnDef_ColumnSizing_Unavailable>)
| ('ColumnResizing' extends keyof TFeatures
? ColumnDef_ColumnResizing
: Partial<ColumnDef_ColumnResizing_Unavailable>)
> & {
> {
getUniqueValues?: AccessorFn<TData, Array<unknown>>
footer?: ColumnDefTemplate<HeaderContext<TFeatures, TData, TValue>>
cell?: ColumnDefTemplate<CellContext<TFeatures, TData, TValue>>
meta?: ColumnMeta<TFeatures, TData, TValue>
}

export type ColumnDefBase<
TFeatures extends TableFeatures,
TData extends RowData,
TValue extends CellData = CellData,
> = ColumnDefBase_Core<TFeatures, TData, TValue> &
UnionToIntersection<
| ('ColumnVisibility' extends keyof TFeatures
? ColumnDef_ColumnVisibility
: never)
| ('ColumnPinning' extends keyof TFeatures
? ColumnDef_ColumnPinning
: never)
| ('ColumnFiltering' extends keyof TFeatures
? ColumnDef_ColumnFiltering<TFeatures, TData>
: never)
| ('GlobalFiltering' extends keyof TFeatures
? ColumnDef_GlobalFiltering
: never)
| ('RowSorting' extends keyof TFeatures
? ColumnDef_RowSorting<TFeatures, TData>
: never)
| ('ColumnGrouping' extends keyof TFeatures
? ColumnDef_ColumnGrouping<TFeatures, TData, TValue>
: never)
| ('ColumnSizing' extends keyof TFeatures ? ColumnDef_ColumnSizing : never)
| ('ColumnResizing' extends keyof TFeatures
? ColumnDef_ColumnResizing
: never)
>

export type ColumnDefBase_All<
TFeatures extends TableFeatures,
TData extends RowData,
TValue extends CellData = CellData,
> = ColumnDefBase_Core<TFeatures, TData, TValue> &
Partial<
ColumnDef_ColumnVisibility &
ColumnDef_ColumnPinning &
ColumnDef_ColumnFiltering<TFeatures, TData> &
ColumnDef_GlobalFiltering &
ColumnDef_RowSorting<TFeatures, TData> &
ColumnDef_ColumnGrouping<TFeatures, TData, TValue> &
ColumnDef_ColumnSizing &
ColumnDef_ColumnResizing
>

export type IdentifiedColumnDef<
TFeatures extends TableFeatures,
TData extends RowData,
Expand Down
10 changes: 10 additions & 0 deletions packages/table-core/src/types/Table.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TableState_All } from './TableState'
import type { RowData, UnionToIntersection } from './type-utils'
import type { TableFeatures } from './TableFeatures'
import type { Table_Columns } from '../core/columns/Columns.types'
Expand All @@ -18,6 +19,7 @@ import type { Table_RowPagination } from '../features/row-pagination/RowPaginati
import type { Table_RowPinning } from '../features/row-pinning/RowPinning.types'
import type { Table_RowSelection } from '../features/row-selection/RowSelection.types'
import type { Table_RowSorting } from '../features/row-sorting/RowSorting.types'
import type { TableOptions_All } from './TableOptions'

/**
* The core table object that only includes the core table functionality such as column, header, row, and table APIS.
Expand Down Expand Up @@ -78,3 +80,11 @@ export type Table<
? Table_RowSorting<TFeatures, TData>
: never)
>

export type Table_Internal<
TFeatures extends TableFeatures,
TData extends RowData,
> = Omit<Table<TFeatures, TData>, 'getState' | 'options'> & {
getState: () => TableState_All
options: TableOptions_All<TFeatures, TData>
}
111 changes: 46 additions & 65 deletions packages/table-core/src/types/TableOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,19 @@ import type { TableOptions_Columns } from '../core/columns/Columns.types'
import type { TableOptions_Headers } from '../core/headers/Headers.types'
import type { TableOptions_Rows } from '../core/rows/Rows.types'
import type { TableOptions_Table } from '../core/table/Tables.types'
import type {
TableOptions_ColumnFiltering,
TableOptions_ColumnFiltering_Unavailable,
} from '../features/column-filtering/ColumnFiltering.types'
import type {
TableOptions_ColumnGrouping,
TableOptions_ColumnGrouping_Unavailable,
} from '../features/column-grouping/ColumnGrouping.types'
import type {
TableOptions_ColumnOrdering,
TableOptions_ColumnOrdering_Unavailable,
} from '../features/column-ordering/ColumnOrdering.types'
import type {
TableOptions_ColumnPinning,
TableOptions_ColumnPinning_Unavailable,
} from '../features/column-pinning/ColumnPinning.types'
import type {
TableOptions_ColumnResizing,
TableOptions_ColumnResizing_Unavailable,
} from '../features/column-resizing/ColumnResizing.types'
import type {
TableOptions_ColumnSizing,
TableOptions_ColumnSizing_Unavailable,
} from '../features/column-sizing/ColumnSizing.types'
import type {
TableOptions_ColumnVisibility,
TableOptions_ColumnVisibility_Unavailable,
} from '../features/column-visibility/ColumnVisibility.types'
import type {
TableOptions_GlobalFiltering,
TableOptions_GlobalFiltering_Unavailable,
} from '../features/global-filtering/GlobalFiltering.types'
import type {
TableOptions_RowExpanding,
TableOptions_RowExpanding_Unavailable,
} from '../features/row-expanding/RowExpanding.types'
import type {
TableOptions_RowPagination,
TableOptions_RowPagination_Unavailable,
} from '../features/row-pagination/RowPagination.types'
import type {
TableOptions_RowPinning,
TableOptions_RowPinning_Unavailable,
} from '../features/row-pinning/RowPinning.types'
import type {
TableOptions_RowSelection,
TableOptions_RowSelection_Unavailable,
} from '../features/row-selection/RowSelection.types'
import type {
TableOptions_RowSorting,
TableOptions_RowSorting_Unavailable,
} from '../features/row-sorting/RowSorting.types'
import type { TableOptions_ColumnFiltering } from '../features/column-filtering/ColumnFiltering.types'
import type { TableOptions_ColumnGrouping } from '../features/column-grouping/ColumnGrouping.types'
import type { TableOptions_ColumnOrdering } from '../features/column-ordering/ColumnOrdering.types'
import type { TableOptions_ColumnPinning } from '../features/column-pinning/ColumnPinning.types'
import type { TableOptions_ColumnResizing } from '../features/column-resizing/ColumnResizing.types'
import type { TableOptions_ColumnSizing } from '../features/column-sizing/ColumnSizing.types'
import type { TableOptions_ColumnVisibility } from '../features/column-visibility/ColumnVisibility.types'
import type { TableOptions_GlobalFiltering } from '../features/global-filtering/GlobalFiltering.types'
import type { TableOptions_RowExpanding } from '../features/row-expanding/RowExpanding.types'
import type { TableOptions_RowPagination } from '../features/row-pagination/RowPagination.types'
import type { TableOptions_RowPinning } from '../features/row-pinning/RowPinning.types'
import type { TableOptions_RowSelection } from '../features/row-selection/RowSelection.types'
import type { TableOptions_RowSorting } from '../features/row-sorting/RowSorting.types'
import type { RowData, UnionToIntersection } from './type-utils'
import type { TableFeatures } from './TableFeatures'

Expand All @@ -74,41 +35,61 @@ export type TableOptions<
UnionToIntersection<
| ('ColumnFiltering' extends keyof TFeatures
? TableOptions_ColumnFiltering<TFeatures, TData>
: Partial<TableOptions_ColumnFiltering_Unavailable<TFeatures, TData>>)
: never)
| ('ColumnGrouping' extends keyof TFeatures
? TableOptions_ColumnGrouping<TFeatures, TData>
: Partial<TableOptions_ColumnGrouping_Unavailable>)
: never)
| ('ColumnOrdering' extends keyof TFeatures
? TableOptions_ColumnOrdering
: Partial<TableOptions_ColumnOrdering_Unavailable>)
: never)
| ('ColumnPinning' extends keyof TFeatures
? TableOptions_ColumnPinning
: Partial<TableOptions_ColumnPinning_Unavailable>)
: never)
| ('ColumnResizing' extends keyof TFeatures
? TableOptions_ColumnResizing
: Partial<TableOptions_ColumnResizing_Unavailable>)
: never)
| ('ColumnSizing' extends keyof TFeatures
? TableOptions_ColumnSizing
: Partial<TableOptions_ColumnSizing_Unavailable>)
: never)
| ('ColumnVisibility' extends keyof TFeatures
? TableOptions_ColumnVisibility
: Partial<TableOptions_ColumnVisibility_Unavailable>)
: never)
| ('GlobalFiltering' extends keyof TFeatures
? TableOptions_GlobalFiltering<TFeatures, TData>
: Partial<TableOptions_GlobalFiltering_Unavailable<TFeatures, TData>>)
: never)
| ('RowExpanding' extends keyof TFeatures
? TableOptions_RowExpanding<TFeatures, TData>
: Partial<TableOptions_RowExpanding_Unavailable<TFeatures, TData>>)
: never)
| ('RowPagination' extends keyof TFeatures
? TableOptions_RowPagination
: Partial<TableOptions_RowPagination_Unavailable>)
: never)
| ('RowPinning' extends keyof TFeatures
? TableOptions_RowPinning<TFeatures, TData>
: Partial<TableOptions_RowPinning_Unavailable<TFeatures, TData>>)
: never)
| ('RowSelection' extends keyof TFeatures
? TableOptions_RowSelection<TFeatures, TData>
: Partial<TableOptions_RowSelection_Unavailable<TFeatures, TData>>)
: never)
| ('RowSorting' extends keyof TFeatures
? TableOptions_RowSorting<TFeatures, TData>
: Partial<TableOptions_RowSorting_Unavailable>)
: never)
>

export type TableOptions_All<
TFeatures extends TableFeatures,
TData extends RowData,
> = TableOptions_Core<TFeatures, TData> &
Partial<
TableOptions_ColumnFiltering<TFeatures, TData> &
TableOptions_ColumnGrouping<TFeatures, TData> &
TableOptions_ColumnOrdering &
TableOptions_ColumnPinning &
TableOptions_ColumnResizing &
TableOptions_ColumnSizing &
TableOptions_ColumnVisibility &
TableOptions_GlobalFiltering<TFeatures, TData> &
TableOptions_RowExpanding<TFeatures, TData> &
TableOptions_RowPagination &
TableOptions_RowPinning<TFeatures, TData> &
TableOptions_RowSelection<TFeatures, TData> &
TableOptions_RowSorting<TFeatures, TData>
>
Loading

0 comments on commit c3de177

Please sign in to comment.