From 9af64a2aa27a933a261af7e2b6eb1ad251bbe110 Mon Sep 17 00:00:00 2001 From: Kevin Van Cott Date: Mon, 6 Jan 2025 20:54:43 -0600 Subject: [PATCH] reintroduce old uniontointersection types --- examples/react/grouping/src/main.tsx | 6 +- .../angular-table/src/constructTableHelper.ts | 13 ++- .../angular-table/src/createTableHelper.ts | 6 +- .../preact-table/src/createTableHelper.ts | 8 +- packages/qwik-table/src/createTableHelper.ts | 8 +- packages/react-table/src/createTableHelper.ts | 8 +- .../src/core/table/coreTablesFeature.types.ts | 18 ++-- .../column-faceting/columnFacetingFeature.ts | 19 ++-- .../columnFilteringFeature.ts | 47 +++++----- .../column-grouping/columnGroupingFeature.ts | 47 +++++----- .../column-ordering/columnOrderingFeature.ts | 23 +++-- .../column-pinning/columnPinningFeature.ts | 31 ++++--- .../column-resizing/columnResizingFeature.ts | 24 ++--- .../column-sizing/columnSizingFeature.ts | 28 +++--- .../columnVisibilityFeature.ts | 31 ++++--- .../global-faceting/globalFacetingFeature.ts | 7 +- .../globalFilteringFeature.ts | 27 +++--- .../row-expanding/rowExpandingFeature.ts | 31 ++++--- .../row-pagination/rowPaginationFeature.ts | 27 +++--- .../features/row-pinning/rowPinningFeature.ts | 23 +++-- .../row-selection/rowSelectionFeature.ts | 23 +++-- .../features/row-sorting/rowSortingFeature.ts | 39 ++++---- .../table-core/src/features/stockFeatures.ts | 2 +- packages/table-core/src/types/Cell.ts | 20 ++++- packages/table-core/src/types/Column.ts | 58 +++++++++++- packages/table-core/src/types/ColumnDef.ts | 36 +++++++- packages/table-core/src/types/Header.ts | 22 ++++- packages/table-core/src/types/HeaderGroup.ts | 2 +- packages/table-core/src/types/Row.ts | 37 +++++++- packages/table-core/src/types/RowModel.ts | 62 ++++++++++++- packages/table-core/src/types/RowModelFns.ts | 27 +++++- packages/table-core/src/types/Table.ts | 89 ++++++++++++++++--- .../table-core/src/types/TableFeatures.ts | 4 +- packages/table-core/src/types/TableOptions.ts | 76 +++++++++++++--- packages/table-core/src/types/TableState.ts | 52 ++++++++++- packages/vue-table/src/createTableHelper.ts | 8 +- 36 files changed, 678 insertions(+), 311 deletions(-) diff --git a/examples/react/grouping/src/main.tsx b/examples/react/grouping/src/main.tsx index 9df1b06642..52cbacf5bf 100644 --- a/examples/react/grouping/src/main.tsx +++ b/examples/react/grouping/src/main.tsx @@ -31,13 +31,13 @@ const tableHelper = createTableHelper({ rowSortingFeature, }, _rowModels: { + expandedRowModel: createExpandedRowModel(), filteredRowModel: createFilteredRowModel(filterFns), + groupedRowModel: createGroupedRowModel(aggregationFns), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(sortFns), - groupedRowModel: createGroupedRowModel(aggregationFns), - expandedRowModel: createExpandedRowModel(), }, - TData: [] as Array, + TData: {} as Person, }) function App() { diff --git a/packages/angular-table/src/constructTableHelper.ts b/packages/angular-table/src/constructTableHelper.ts index 41bdecade4..c15853ebb1 100644 --- a/packages/angular-table/src/constructTableHelper.ts +++ b/packages/angular-table/src/constructTableHelper.ts @@ -17,15 +17,12 @@ import type { Signal } from '@angular/core' * Options for creating a table helper to share common options across multiple tables * coreColumnsFeature, data, and state are excluded from this type and reserved for only the `useTable`/`createTable` functions */ -type TableHelperOptions< +export type TableHelperOptions< TFeatures extends TableFeatures, - TDataList extends Array = Array, -> = Omit< - TableOptions>, - 'columns' | 'data' | 'state' -> & { + TData extends RowData, +> = Omit, 'columns' | 'data' | 'state'> & { _features: TFeatures - TData?: TDataList[number] // provide a cast for the TData type + TData?: TData // provide a cast for the TData type } /** @@ -57,7 +54,7 @@ export function constructTableHelper< tableCreator: ( tableOptions: () => TableOptions, ) => Table & Signal>, - tableHelperOptions: TableHelperOptions>, + tableHelperOptions: TableHelperOptions, ): TableHelper_Core { const { TData: _TData, ..._tableHelperOptions } = tableHelperOptions return { diff --git a/packages/angular-table/src/createTableHelper.ts b/packages/angular-table/src/createTableHelper.ts index b6325ef1f5..942685490e 100644 --- a/packages/angular-table/src/createTableHelper.ts +++ b/packages/angular-table/src/createTableHelper.ts @@ -1,11 +1,13 @@ -import { constructTableHelper } from './constructTableHelper' +import { + constructTableHelper, + TableHelperOptions, +} from './constructTableHelper' import { injectTable } from './injectTable' import type { Signal } from '@angular/core' import type { RowData, Table, TableFeatures, - TableHelperOptions, TableHelper_Core, TableOptions, } from '@tanstack/table-core' diff --git a/packages/preact-table/src/createTableHelper.ts b/packages/preact-table/src/createTableHelper.ts index b2b392cc98..cb82307e7f 100644 --- a/packages/preact-table/src/createTableHelper.ts +++ b/packages/preact-table/src/createTableHelper.ts @@ -23,15 +23,15 @@ export type TableHelper< export function createTableHelper< TFeatures extends TableFeatures, - TDataList extends Array = Array, + TData extends RowData, >( - tableHelperOptions: TableHelperOptions, -): TableHelper { + tableHelperOptions: TableHelperOptions, +): TableHelper { const tableHelper = constructTableHelper(useTable, tableHelperOptions) return { ...tableHelper, useTable: tableHelper.tableCreator, - } as unknown as TableHelper + } as unknown as TableHelper } // test diff --git a/packages/qwik-table/src/createTableHelper.ts b/packages/qwik-table/src/createTableHelper.ts index 9c3b865278..cd697f6da4 100644 --- a/packages/qwik-table/src/createTableHelper.ts +++ b/packages/qwik-table/src/createTableHelper.ts @@ -24,15 +24,15 @@ export type TableHelper< export function createTableHelper< TFeatures extends TableFeatures, - TDataList extends Array = Array, + TData extends RowData, >( - tableHelperOptions: TableHelperOptions, -): TableHelper { + tableHelperOptions: TableHelperOptions, +): TableHelper { const tableHelper = constructTableHelper(useTable as any, tableHelperOptions) return { ...tableHelper, useTable: tableHelper.tableCreator, - } as unknown as TableHelper + } as unknown as TableHelper } // test diff --git a/packages/react-table/src/createTableHelper.ts b/packages/react-table/src/createTableHelper.ts index b2b392cc98..cb82307e7f 100644 --- a/packages/react-table/src/createTableHelper.ts +++ b/packages/react-table/src/createTableHelper.ts @@ -23,15 +23,15 @@ export type TableHelper< export function createTableHelper< TFeatures extends TableFeatures, - TDataList extends Array = Array, + TData extends RowData, >( - tableHelperOptions: TableHelperOptions, -): TableHelper { + tableHelperOptions: TableHelperOptions, +): TableHelper { const tableHelper = constructTableHelper(useTable, tableHelperOptions) return { ...tableHelper, useTable: tableHelper.tableCreator, - } as unknown as TableHelper + } as unknown as TableHelper } // test diff --git a/packages/table-core/src/core/table/coreTablesFeature.types.ts b/packages/table-core/src/core/table/coreTablesFeature.types.ts index 92d0f8df6b..58cb41d17e 100644 --- a/packages/table-core/src/core/table/coreTablesFeature.types.ts +++ b/packages/table-core/src/core/table/coreTablesFeature.types.ts @@ -1,8 +1,8 @@ import type { CoreFeatures } from '../coreFeatures' import type { RowModelFns } from '../../types/RowModelFns' -import type { NoInfer, RowData, Updater } from '../../types/type-utils' +import type { RowData, Updater } from '../../types/type-utils' import type { TableFeatures } from '../../types/TableFeatures' -import type { CachedRowModels, CreateRowModels } from '../../types/RowModel' +import type { CachedRowModels, CreateRowModels_All } from '../../types/RowModel' import type { TableOptions } from '../../types/TableOptions' import type { TableState } from '../../types/TableState' @@ -13,7 +13,7 @@ export interface TableMeta< export interface TableOptions_Table< TFeatures extends TableFeatures, - TDataList extends Array, + TData extends RowData, > { /** * The features that you want to enable for the table. @@ -26,7 +26,7 @@ export interface TableOptions_Table< * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_rowmodels) * [Guide](https://tanstack.com/table/v8/docs/guide/tables) */ - _rowModels?: CreateRowModels | RowData> + _rowModels?: CreateRowModels_All /** * Set this option to override any of the `autoReset...` feature options. * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#autoresetall) @@ -38,7 +38,7 @@ export interface TableOptions_Table< * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#data) * [Guide](https://tanstack.com/table/v8/docs/guide/tables) */ - data: TDataList + data: Array /** * Set this option to `true` to output all debugging information to the console. * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugall) @@ -72,15 +72,15 @@ export interface TableOptions_Table< * [Guide](https://tanstack.com/table/v8/docs/guide/tables) */ mergeOptions?: ( - defaultOptions: TableOptions, - options: Partial>, - ) => TableOptions + defaultOptions: TableOptions, + options: Partial>, + ) => TableOptions /** * You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`. * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#meta) * [Guide](https://tanstack.com/table/v8/docs/guide/tables) */ - meta?: TableMeta + meta?: TableMeta /** * The `onStateChange` option can be used to optionally listen to state changes within the table. * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#onstatechange) diff --git a/packages/table-core/src/features/column-faceting/columnFacetingFeature.ts b/packages/table-core/src/features/column-faceting/columnFacetingFeature.ts index 675ab70e95..211c998734 100644 --- a/packages/table-core/src/features/column-faceting/columnFacetingFeature.ts +++ b/packages/table-core/src/features/column-faceting/columnFacetingFeature.ts @@ -4,18 +4,17 @@ import { column_getFacetedRowModel, column_getFacetedUniqueValues, } from './columnFacetingFeature.utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - CachedRowModel_Faceted, - Column_ColumnFaceting, - CreateRowModel_Faceted, -} from './columnFacetingFeature.types' -import type { RowData } from '../../types/type-utils' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// CachedRowModel_Faceted, +// Column_ColumnFaceting, +// CreateRowModel_Faceted, +// } from './columnFacetingFeature.types' interface ColumnFacetingFeatureConstructors { - Column: Column_ColumnFaceting - CreateRowModels: CreateRowModel_Faceted - CachedRowModel: CachedRowModel_Faceted + // Column: Column_ColumnFaceting + // CreateRowModels: CreateRowModel_Faceted + // CachedRowModel: CachedRowModel_Faceted } /** diff --git a/packages/table-core/src/features/column-filtering/columnFilteringFeature.ts b/packages/table-core/src/features/column-filtering/columnFilteringFeature.ts index 2229e8f369..a8df5d3876 100644 --- a/packages/table-core/src/features/column-filtering/columnFilteringFeature.ts +++ b/packages/table-core/src/features/column-filtering/columnFilteringFeature.ts @@ -11,30 +11,29 @@ import { table_resetColumnFilters, table_setColumnFilters, } from './columnFilteringFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - CachedRowModel_Filtered, - ColumnDef_ColumnFiltering, - Column_ColumnFiltering, - CreateRowModel_Filtered, - RowModelFns_ColumnFiltering, - Row_ColumnFiltering, - TableOptions_ColumnFiltering, - TableState_ColumnFiltering, - Table_ColumnFiltering, -} from './columnFilteringFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// CachedRowModel_Filtered, +// ColumnDef_ColumnFiltering, +// Column_ColumnFiltering, +// CreateRowModel_Filtered, +// RowModelFns_ColumnFiltering, +// Row_ColumnFiltering, +// TableOptions_ColumnFiltering, +// TableState_ColumnFiltering, +// Table_ColumnFiltering, +// } from './columnFilteringFeature.types' interface ColumnFilteringFeatureConstructors { - CachedRowModel: CachedRowModel_Filtered - Column: Column_ColumnFiltering - ColumnDef: ColumnDef_ColumnFiltering - CreateRowModels: CreateRowModel_Filtered - Row: Row_ColumnFiltering - RowModelFns: RowModelFns_ColumnFiltering - Table: Table_ColumnFiltering - TableOptions: TableOptions_ColumnFiltering - TableState: TableState_ColumnFiltering + // CachedRowModel: CachedRowModel_Filtered + // Column: Column_ColumnFiltering + // ColumnDef: ColumnDef_ColumnFiltering + // CreateRowModels: CreateRowModel_Filtered + // Row: Row_ColumnFiltering + // RowModelFns: RowModelFns_ColumnFiltering + // Table: Table_ColumnFiltering + // TableOptions: TableOptions_ColumnFiltering + // TableState: TableState_ColumnFiltering } /** @@ -101,8 +100,8 @@ export const columnFilteringFeature: TableFeature { - row.columnFilters = {} - row.columnFiltersMeta = {} + ;(row as any).columnFilters = {} + ;(row as any).columnFiltersMeta = {} }, constructTableAPIs: (table) => { diff --git a/packages/table-core/src/features/column-grouping/columnGroupingFeature.ts b/packages/table-core/src/features/column-grouping/columnGroupingFeature.ts index d5271eaa53..d5248b8f2d 100644 --- a/packages/table-core/src/features/column-grouping/columnGroupingFeature.ts +++ b/packages/table-core/src/features/column-grouping/columnGroupingFeature.ts @@ -16,32 +16,31 @@ import { table_resetGrouping, table_setGrouping, } from './columnGroupingFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - CachedRowModel_Grouped, - Cell_ColumnGrouping, - ColumnDef_ColumnGrouping, - Column_ColumnGrouping, - CreateRowModel_Grouped, - RowModelFns_ColumnGrouping, - Row_ColumnGrouping, - TableOptions_ColumnGrouping, - TableState_ColumnGrouping, - Table_ColumnGrouping, -} from './columnGroupingFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// CachedRowModel_Grouped, +// Cell_ColumnGrouping, +// ColumnDef_ColumnGrouping, +// Column_ColumnGrouping, +// CreateRowModel_Grouped, +// RowModelFns_ColumnGrouping, +// Row_ColumnGrouping, +// TableOptions_ColumnGrouping, +// TableState_ColumnGrouping, +// Table_ColumnGrouping, +// } from './columnGroupingFeature.types' interface ColumnGroupingFeatureConstructors { - CachedRowModel: CachedRowModel_Grouped - Cell: Cell_ColumnGrouping - Column: Column_ColumnGrouping - ColumnDef: ColumnDef_ColumnGrouping - CreateRowModels: CreateRowModel_Grouped - Row: Row_ColumnGrouping - RowModelFns: RowModelFns_ColumnGrouping - Table: Table_ColumnGrouping - TableOptions: TableOptions_ColumnGrouping - TableState: TableState_ColumnGrouping + // CachedRowModel: CachedRowModel_Grouped + // Cell: Cell_ColumnGrouping + // Column: Column_ColumnGrouping + // ColumnDef: ColumnDef_ColumnGrouping + // CreateRowModels: CreateRowModel_Grouped + // Row: Row_ColumnGrouping + // RowModelFns: RowModelFns_ColumnGrouping + // Table: Table_ColumnGrouping + // TableOptions: TableOptions_ColumnGrouping + // TableState: TableState_ColumnGrouping } /** diff --git a/packages/table-core/src/features/column-ordering/columnOrderingFeature.ts b/packages/table-core/src/features/column-ordering/columnOrderingFeature.ts index fdcfa48821..beed3ed55e 100644 --- a/packages/table-core/src/features/column-ordering/columnOrderingFeature.ts +++ b/packages/table-core/src/features/column-ordering/columnOrderingFeature.ts @@ -8,20 +8,19 @@ import { table_resetColumnOrder, table_setColumnOrder, } from './columnOrderingFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { - Column_ColumnOrdering, - TableOptions_ColumnOrdering, - TableState_ColumnOrdering, - Table_ColumnOrdering, -} from './columnOrderingFeature.types' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' +// import type { +// Column_ColumnOrdering, +// TableOptions_ColumnOrdering, +// TableState_ColumnOrdering, +// Table_ColumnOrdering, +// } from './columnOrderingFeature.types' +import type { TableFeature } from '../../types/TableFeatures' interface ColumnOrderingFeatureConstructors { - Column: Column_ColumnOrdering - Table: Table_ColumnOrdering - TableOptions: TableOptions_ColumnOrdering - TableState: TableState_ColumnOrdering + // Column: Column_ColumnOrdering + // Table: Table_ColumnOrdering + // TableOptions: TableOptions_ColumnOrdering + // TableState: TableState_ColumnOrdering } /** diff --git a/packages/table-core/src/features/column-pinning/columnPinningFeature.ts b/packages/table-core/src/features/column-pinning/columnPinningFeature.ts index 303a5937ca..74ea5c9899 100644 --- a/packages/table-core/src/features/column-pinning/columnPinningFeature.ts +++ b/packages/table-core/src/features/column-pinning/columnPinningFeature.ts @@ -31,24 +31,23 @@ import { table_resetColumnPinning, table_setColumnPinning, } from './columnPinningFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - ColumnDef_ColumnPinning, - Column_ColumnPinning, - Row_ColumnPinning, - TableOptions_ColumnPinning, - TableState_ColumnPinning, - Table_ColumnPinning, -} from './columnPinningFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// ColumnDef_ColumnPinning, +// Column_ColumnPinning, +// Row_ColumnPinning, +// TableOptions_ColumnPinning, +// TableState_ColumnPinning, +// Table_ColumnPinning, +// } from './columnPinningFeature.types' interface ColumnPinningFeatureConstructors { - Column: Column_ColumnPinning - ColumnDef: ColumnDef_ColumnPinning - Row: Row_ColumnPinning - Table: Table_ColumnPinning - TableOptions: TableOptions_ColumnPinning - TableState: TableState_ColumnPinning + // Column: Column_ColumnPinning + // ColumnDef: ColumnDef_ColumnPinning + // Row: Row_ColumnPinning + // Table: Table_ColumnPinning + // TableOptions: TableOptions_ColumnPinning + // TableState: TableState_ColumnPinning } /** diff --git a/packages/table-core/src/features/column-resizing/columnResizingFeature.ts b/packages/table-core/src/features/column-resizing/columnResizingFeature.ts index 726eece591..fb2eaa51dc 100644 --- a/packages/table-core/src/features/column-resizing/columnResizingFeature.ts +++ b/packages/table-core/src/features/column-resizing/columnResizingFeature.ts @@ -8,20 +8,20 @@ import { table_setColumnResizing, } from './columnResizingFeature.utils' import type { TableFeature } from '../../types/TableFeatures' -import type { - Column_ColumnResizing, - Header_ColumnResizing, - TableOptions_ColumnResizing, - TableState_ColumnResizing, - Table_ColumnResizing, -} from './columnResizingFeature.types' +// import type { +// Column_ColumnResizing, +// Header_ColumnResizing, +// TableOptions_ColumnResizing, +// TableState_ColumnResizing, +// Table_ColumnResizing, +// } from './columnResizingFeature.types' interface ColumnResizingFeatureConstructors { - Column: Column_ColumnResizing - Header: Header_ColumnResizing - Table: Table_ColumnResizing - TableOptions: TableOptions_ColumnResizing - TableState: TableState_ColumnResizing + // Column: Column_ColumnResizing + // Header: Header_ColumnResizing + // Table: Table_ColumnResizing + // TableOptions: TableOptions_ColumnResizing + // TableState: TableState_ColumnResizing } /** diff --git a/packages/table-core/src/features/column-sizing/columnSizingFeature.ts b/packages/table-core/src/features/column-sizing/columnSizingFeature.ts index 97eb641692..2f595607af 100644 --- a/packages/table-core/src/features/column-sizing/columnSizingFeature.ts +++ b/packages/table-core/src/features/column-sizing/columnSizingFeature.ts @@ -16,23 +16,23 @@ import { table_resetColumnSizing, table_setColumnSizing, } from './columnSizingFeature.utils' -import type { - ColumnDef_ColumnSizing, - Column_ColumnSizing, - Header_ColumnSizing, - TableOptions_ColumnSizing, - TableState_ColumnSizing, - Table_ColumnSizing, -} from './columnSizingFeature.types' +// import type { +// ColumnDef_ColumnSizing, +// Column_ColumnSizing, +// Header_ColumnSizing, +// TableOptions_ColumnSizing, +// TableState_ColumnSizing, +// Table_ColumnSizing, +// } from './columnSizingFeature.types' import type { TableFeature } from '../../types/TableFeatures' interface ColumnSizingFeatureConstructors { - ColumnDef: ColumnDef_ColumnSizing - Column: Column_ColumnSizing - Header: Header_ColumnSizing - Table: Table_ColumnSizing - TableOptions: TableOptions_ColumnSizing - TableState: TableState_ColumnSizing + // ColumnDef: ColumnDef_ColumnSizing + // Column: Column_ColumnSizing + // Header: Header_ColumnSizing + // Table: Table_ColumnSizing + // TableOptions: TableOptions_ColumnSizing + // TableState: TableState_ColumnSizing } /** diff --git a/packages/table-core/src/features/column-visibility/columnVisibilityFeature.ts b/packages/table-core/src/features/column-visibility/columnVisibilityFeature.ts index c4716f677a..f890a218e5 100644 --- a/packages/table-core/src/features/column-visibility/columnVisibilityFeature.ts +++ b/packages/table-core/src/features/column-visibility/columnVisibilityFeature.ts @@ -21,24 +21,23 @@ import { table_setColumnVisibility, table_toggleAllColumnsVisible, } from './columnVisibilityFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - ColumnDef_ColumnVisibility, - Column_ColumnVisibility, - Row_ColumnVisibility, - TableOptions_ColumnVisibility, - TableState_ColumnVisibility, - Table_ColumnVisibility, -} from './columnVisibilityFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// ColumnDef_ColumnVisibility, +// Column_ColumnVisibility, +// Row_ColumnVisibility, +// TableOptions_ColumnVisibility, +// TableState_ColumnVisibility, +// Table_ColumnVisibility, +// } from './columnVisibilityFeature.types' interface ColumnVisibilityFeatureConstructors { - ColumnDef: ColumnDef_ColumnVisibility - Column: Column_ColumnVisibility - Row: Row_ColumnVisibility - Table: Table_ColumnVisibility - TableOptions: TableOptions_ColumnVisibility - TableState: TableState_ColumnVisibility + // ColumnDef: ColumnDef_ColumnVisibility + // Column: Column_ColumnVisibility + // Row: Row_ColumnVisibility + // Table: Table_ColumnVisibility + // TableOptions: TableOptions_ColumnVisibility + // TableState: TableState_ColumnVisibility } /** diff --git a/packages/table-core/src/features/global-faceting/globalFacetingFeature.ts b/packages/table-core/src/features/global-faceting/globalFacetingFeature.ts index 2aa9f7bb99..645d9c3650 100644 --- a/packages/table-core/src/features/global-faceting/globalFacetingFeature.ts +++ b/packages/table-core/src/features/global-faceting/globalFacetingFeature.ts @@ -4,12 +4,11 @@ import { table_getGlobalFacetedRowModel, table_getGlobalFacetedUniqueValues, } from './globalFacetingFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { Table_GlobalFaceting } from './globalFacetingFeature.types' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' +import type { TableFeature } from '../../types/TableFeatures' +// import type { Table_GlobalFaceting } from './globalFacetingFeature.types' interface GlobalFacetingFeatureConstructors { - Table: Table_GlobalFaceting + // Table: Table_GlobalFaceting } /** diff --git a/packages/table-core/src/features/global-filtering/globalFilteringFeature.ts b/packages/table-core/src/features/global-filtering/globalFilteringFeature.ts index 3d39364ad4..47b61a45a9 100644 --- a/packages/table-core/src/features/global-filtering/globalFilteringFeature.ts +++ b/packages/table-core/src/features/global-filtering/globalFilteringFeature.ts @@ -6,22 +6,21 @@ import { table_resetGlobalFilter, table_setGlobalFilter, } from './globalFilteringFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - ColumnDef_GlobalFiltering, - Column_GlobalFiltering, - TableOptions_GlobalFiltering, - TableState_GlobalFiltering, - Table_GlobalFiltering, -} from './globalFilteringFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// ColumnDef_GlobalFiltering, +// Column_GlobalFiltering, +// TableOptions_GlobalFiltering, +// TableState_GlobalFiltering, +// Table_GlobalFiltering, +// } from './globalFilteringFeature.types' interface GlobalFilteringFeatureConstructors { - Column: Column_GlobalFiltering - ColumnDef: ColumnDef_GlobalFiltering - Table: Table_GlobalFiltering - TableOptions: TableOptions_GlobalFiltering - TableState: TableState_GlobalFiltering + // Column: Column_GlobalFiltering + // ColumnDef: ColumnDef_GlobalFiltering + // Table: Table_GlobalFiltering + // TableOptions: TableOptions_GlobalFiltering + // TableState: TableState_GlobalFiltering } /** diff --git a/packages/table-core/src/features/row-expanding/rowExpandingFeature.ts b/packages/table-core/src/features/row-expanding/rowExpandingFeature.ts index ed19d1e172..afbbcd8e7f 100644 --- a/packages/table-core/src/features/row-expanding/rowExpandingFeature.ts +++ b/packages/table-core/src/features/row-expanding/rowExpandingFeature.ts @@ -16,24 +16,23 @@ import { table_setExpanded, table_toggleAllRowsExpanded, } from './rowExpandingFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - CachedRowModel_Expanded, - CreateRowModel_Expanded, - Row_RowExpanding, - TableOptions_RowExpanding, - TableState_RowExpanding, - Table_RowExpanding, -} from './rowExpandingFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// CachedRowModel_Expanded, +// CreateRowModel_Expanded, +// Row_RowExpanding, +// TableOptions_RowExpanding, +// TableState_RowExpanding, +// Table_RowExpanding, +// } from './rowExpandingFeature.types' interface RowExpandingFeatureConstructors { - CachedRowModel: CachedRowModel_Expanded - CreateRowModels: CreateRowModel_Expanded - Row: Row_RowExpanding - Table: Table_RowExpanding - TableOptions: TableOptions_RowExpanding - TableState: TableState_RowExpanding + // CachedRowModel: CachedRowModel_Expanded + // CreateRowModels: CreateRowModel_Expanded + // Row: Row_RowExpanding + // Table: Table_RowExpanding + // TableOptions: TableOptions_RowExpanding + // TableState: TableState_RowExpanding } /** diff --git a/packages/table-core/src/features/row-pagination/rowPaginationFeature.ts b/packages/table-core/src/features/row-pagination/rowPaginationFeature.ts index c4d8f80648..5640617a5b 100644 --- a/packages/table-core/src/features/row-pagination/rowPaginationFeature.ts +++ b/packages/table-core/src/features/row-pagination/rowPaginationFeature.ts @@ -18,22 +18,21 @@ import { table_setPageSize, table_setPagination, } from './rowPaginationFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { - CachedRowModel_Paginated, - CreateRowModel_Paginated, - TableOptions_RowPagination, - TableState_RowPagination, - Table_RowPagination, -} from './rowPaginationFeature.types' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// CachedRowModel_Paginated, +// CreateRowModel_Paginated, +// TableOptions_RowPagination, +// TableState_RowPagination, +// Table_RowPagination, +// } from './rowPaginationFeature.types' interface RowPaginationFeatureConstructors { - CachedRowModel: CachedRowModel_Paginated - CreateRowModels: CreateRowModel_Paginated - Table: Table_RowPagination - TableOptions: TableOptions_RowPagination - TableState: TableState_RowPagination + // CachedRowModel: CachedRowModel_Paginated + // CreateRowModels: CreateRowModel_Paginated + // Table: Table_RowPagination + // TableOptions: TableOptions_RowPagination + // TableState: TableState_RowPagination } /** diff --git a/packages/table-core/src/features/row-pinning/rowPinningFeature.ts b/packages/table-core/src/features/row-pinning/rowPinningFeature.ts index 0ce73ddcfb..07f40136b8 100644 --- a/packages/table-core/src/features/row-pinning/rowPinningFeature.ts +++ b/packages/table-core/src/features/row-pinning/rowPinningFeature.ts @@ -12,20 +12,19 @@ import { table_resetRowPinning, table_setRowPinning, } from './rowPinningFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - Row_RowPinning, - TableOptions_RowPinning, - TableState_RowPinning, - Table_RowPinning, -} from './rowPinningFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// Row_RowPinning, +// TableOptions_RowPinning, +// TableState_RowPinning, +// Table_RowPinning, +// } from './rowPinningFeature.types' interface RowPinningFeatureConstructors { - Row: Row_RowPinning - Table: Table_RowPinning - TableOptions: TableOptions_RowPinning - TableState: TableState_RowPinning + // Row: Row_RowPinning + // Table: Table_RowPinning + // TableOptions: TableOptions_RowPinning + // TableState: TableState_RowPinning } /** diff --git a/packages/table-core/src/features/row-selection/rowSelectionFeature.ts b/packages/table-core/src/features/row-selection/rowSelectionFeature.ts index c9831c4d70..a06549fe85 100644 --- a/packages/table-core/src/features/row-selection/rowSelectionFeature.ts +++ b/packages/table-core/src/features/row-selection/rowSelectionFeature.ts @@ -24,20 +24,19 @@ import { table_toggleAllPageRowsSelected, table_toggleAllRowsSelected, } from './rowSelectionFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' -import type { - Row_RowSelection, - TableOptions_RowSelection, - TableState_RowSelection, - Table_RowSelection, -} from './rowSelectionFeature.types' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// Row_RowSelection, +// TableOptions_RowSelection, +// TableState_RowSelection, +// Table_RowSelection, +// } from './rowSelectionFeature.types' interface RowSelectionFeatureConstructors { - Row: Row_RowSelection - Table: Table_RowSelection - TableOptions: TableOptions_RowSelection - TableState: TableState_RowSelection + // Row: Row_RowSelection + // Table: Table_RowSelection + // TableOptions: TableOptions_RowSelection + // TableState: TableState_RowSelection } /** diff --git a/packages/table-core/src/features/row-sorting/rowSortingFeature.ts b/packages/table-core/src/features/row-sorting/rowSortingFeature.ts index adc0f8b596..0665cd36be 100644 --- a/packages/table-core/src/features/row-sorting/rowSortingFeature.ts +++ b/packages/table-core/src/features/row-sorting/rowSortingFeature.ts @@ -16,28 +16,27 @@ import { table_resetSorting, table_setSorting, } from './rowSortingFeature.utils' -import type { RowData } from '../../types/type-utils' -import type { - CachedRowModel_Sorted, - ColumnDef_RowSorting, - Column_RowSorting, - CreateRowModel_Sorted, - RowModelFns_RowSorting, - TableOptions_RowSorting, - TableState_RowSorting, - Table_RowSorting, -} from './rowSortingFeature.types' -import type { TableFeature, TableFeatures } from '../../types/TableFeatures' +import type { TableFeature } from '../../types/TableFeatures' +// import type { +// CachedRowModel_Sorted, +// ColumnDef_RowSorting, +// Column_RowSorting, +// CreateRowModel_Sorted, +// RowModelFns_RowSorting, +// TableOptions_RowSorting, +// TableState_RowSorting, +// Table_RowSorting, +// } from './rowSortingFeature.types' interface RowSortingFeatureConstructors { - CachedRowModel: CachedRowModel_Sorted - Column: Column_RowSorting - ColumnDef: ColumnDef_RowSorting - CreateRowModels: CreateRowModel_Sorted - RowModelFns: RowModelFns_RowSorting - Table: Table_RowSorting - TableOptions: TableOptions_RowSorting - TableState: TableState_RowSorting + // CachedRowModel: CachedRowModel_Sorted + // Column: Column_RowSorting + // ColumnDef: ColumnDef_RowSorting + // CreateRowModels: CreateRowModel_Sorted + // RowModelFns: RowModelFns_RowSorting + // Table: Table_RowSorting + // TableOptions: TableOptions_RowSorting + // TableState: TableState_RowSorting } /** diff --git a/packages/table-core/src/features/stockFeatures.ts b/packages/table-core/src/features/stockFeatures.ts index 7997b5cdad..1c5717969c 100644 --- a/packages/table-core/src/features/stockFeatures.ts +++ b/packages/table-core/src/features/stockFeatures.ts @@ -48,4 +48,4 @@ export const stockFeatures: StockFeatures = { rowPinningFeature, rowSelectionFeature, rowSortingFeature, -} +} as const diff --git a/packages/table-core/src/types/Cell.ts b/packages/table-core/src/types/Cell.ts index a4e54c2f15..0f9480f954 100644 --- a/packages/table-core/src/types/Cell.ts +++ b/packages/table-core/src/types/Cell.ts @@ -1,4 +1,5 @@ -import type { CellData, RowData } from './type-utils' +import type { Cell_ColumnGrouping } from '../features/column-grouping/columnGroupingFeature.types' +import type { CellData, RowData, UnionToIntersection } from './type-utils' import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' import type { Cell_Cell } from '../core/cells/coreCellsFeature.types' @@ -22,6 +23,19 @@ export type Cell< TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData, -> = Cell_Core & - ExtractFeatureTypes & +> = Cell_Cell & + UnionToIntersection< + 'columnGroupingFeature' extends keyof TFeatures + ? Cell_ColumnGrouping + : never + > & + ExtractFeatureTypes<'Cell', TFeatures> & Cell_Plugins + +// export type Cell< +// TFeatures extends TableFeatures, +// TData extends RowData, +// TValue extends CellData = CellData, +// > = Cell_Core & +// ExtractFeatureTypes & +// Cell_Plugins diff --git a/packages/table-core/src/types/Column.ts b/packages/table-core/src/types/Column.ts index 6187c0df6e..a9553e8231 100644 --- a/packages/table-core/src/types/Column.ts +++ b/packages/table-core/src/types/Column.ts @@ -1,7 +1,17 @@ -import type { Column_Column } from '../core/columns/coreColumnsFeature.types' -import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' -import type { RowData } from './type-utils' +import type { Column_RowSorting } from '../features/row-sorting/rowSortingFeature.types' +import type { Column_ColumnFaceting } from '../features/column-faceting/columnFacetingFeature.types' +import type { Column_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' +import type { Column_ColumnGrouping } from '../features/column-grouping/columnGroupingFeature.types' +import type { Column_ColumnOrdering } from '../features/column-ordering/columnOrderingFeature.types' +import type { Column_GlobalFiltering } from '../features/global-filtering/globalFilteringFeature.types' +import type { Column_ColumnPinning } from '../features/column-pinning/columnPinningFeature.types' +import type { Column_ColumnResizing } from '../features/column-resizing/columnResizingFeature.types' +import type { Column_ColumnSizing } from '../features/column-sizing/columnSizingFeature.types' +import type { Column_ColumnVisibility } from '../features/column-visibility/columnVisibilityFeature.types' import type { ColumnDefBase_All } from './ColumnDef' +import type { RowData, UnionToIntersection } from './type-utils' +import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' +import type { Column_Column } from '../core/columns/coreColumnsFeature.types' /** * Use this interface as a target for declaration merging to add your own plugin properties. @@ -24,9 +34,49 @@ export type Column< TData extends RowData, TValue = unknown, > = Column_Core & - ExtractFeatureTypes & + UnionToIntersection< + | ('columnFacetingFeature' extends keyof TFeatures + ? Column_ColumnFaceting + : never) + | ('columnFilteringFeature' extends keyof TFeatures + ? Column_ColumnFiltering + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? Column_ColumnGrouping + : never) + | ('columnOrderingFeature' extends keyof TFeatures + ? Column_ColumnOrdering + : never) + | ('columnPinningFeature' extends keyof TFeatures + ? Column_ColumnPinning + : never) + | ('columnResizingFeature' extends keyof TFeatures + ? Column_ColumnResizing + : never) + | ('columnSizingFeature' extends keyof TFeatures + ? Column_ColumnSizing + : never) + | ('columnVisibilityFeature' extends keyof TFeatures + ? Column_ColumnVisibility + : never) + | ('globalFilteringFeature' extends keyof TFeatures + ? Column_GlobalFiltering + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? Column_RowSorting + : never) + > & + ExtractFeatureTypes<'Column', TFeatures> & Column_Plugins +// export type Column< +// TFeatures extends TableFeatures, +// TData extends RowData, +// TValue = unknown, +// > = Column_Core & +// ExtractFeatureTypes<'Column', TFeatures> & +// Column_Plugins + export type Column_Internal< TFeatures extends TableFeatures, TData extends RowData, diff --git a/packages/table-core/src/types/ColumnDef.ts b/packages/table-core/src/types/ColumnDef.ts index d5fa78736f..0a2ba4b16e 100644 --- a/packages/table-core/src/types/ColumnDef.ts +++ b/packages/table-core/src/types/ColumnDef.ts @@ -77,9 +77,43 @@ export type ColumnDefBase< TData extends RowData, TValue extends CellData = CellData, > = ColumnDefBase_Core & - ExtractFeatureTypes & + UnionToIntersection< + | ('columnVisibilityFeature' extends keyof TFeatures + ? ColumnDef_ColumnVisibility + : never) + | ('columnPinningFeature' extends keyof TFeatures + ? ColumnDef_ColumnPinning + : never) + | ('columnFilteringFeature' extends keyof TFeatures + ? ColumnDef_ColumnFiltering + : never) + | ('globalFilteringFeature' extends keyof TFeatures + ? ColumnDef_GlobalFiltering + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? ColumnDef_RowSorting + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? ColumnDef_ColumnGrouping + : never) + | ('columnSizingFeature' extends keyof TFeatures + ? ColumnDef_ColumnSizing + : never) + | ('columnResizingFeature' extends keyof TFeatures + ? ColumnDef_ColumnResizing + : never) + > & + ExtractFeatureTypes<'ColumnDef', TFeatures> & ColumnDef_Plugins +// export type ColumnDefBase< +// TFeatures extends TableFeatures, +// TData extends RowData, +// TValue extends CellData = CellData, +// > = ColumnDefBase_Core & +// ExtractFeatureTypes<'ColumnDef', TFeatures> & +// ColumnDef_Plugins + export type ColumnDefBase_All< TFeatures extends TableFeatures, TData extends RowData, diff --git a/packages/table-core/src/types/Header.ts b/packages/table-core/src/types/Header.ts index a80d7f49f5..d11e7a8e7f 100644 --- a/packages/table-core/src/types/Header.ts +++ b/packages/table-core/src/types/Header.ts @@ -1,6 +1,8 @@ -import type { CellData, RowData } from './type-utils' +import type { Header_ColumnSizing } from '../features/column-sizing/columnSizingFeature.types' +import type { CellData, RowData, UnionToIntersection } from './type-utils' import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' import type { Header_Header } from '../core/headers/coreHeadersFeature.types' +import type { Header_ColumnResizing } from '../features/column-resizing/columnResizingFeature.types' /** * Use this interface as a target for declaration merging to add your own plugin properties. @@ -23,5 +25,21 @@ export type Header< TData extends RowData, TValue extends CellData = CellData, > = Header_Core & - ExtractFeatureTypes & + UnionToIntersection< + | ('columnSizingFeature' extends keyof TFeatures + ? Header_ColumnSizing + : never) + | ('columnResizingFeature' extends keyof TFeatures + ? Header_ColumnResizing + : never) + > & + ExtractFeatureTypes<'Header', TFeatures> & Header_Plugins + +// export type Header< +// TFeatures extends TableFeatures, +// TData extends RowData, +// TValue extends CellData = CellData, +// > = Header_Core & +// ExtractFeatureTypes<'Header', TFeatures> & +// Header_Plugins diff --git a/packages/table-core/src/types/HeaderGroup.ts b/packages/table-core/src/types/HeaderGroup.ts index 6281607939..4290be490e 100644 --- a/packages/table-core/src/types/HeaderGroup.ts +++ b/packages/table-core/src/types/HeaderGroup.ts @@ -20,5 +20,5 @@ export type HeaderGroup< TFeatures extends TableFeatures, TData extends RowData, > = HeaderGroup_Core & - ExtractFeatureTypes & + ExtractFeatureTypes<'HeaderGroup', TFeatures> & HeaderGroup_Plugins diff --git a/packages/table-core/src/types/Row.ts b/packages/table-core/src/types/Row.ts index 03a4ccacc6..7ce3e0c127 100644 --- a/packages/table-core/src/types/Row.ts +++ b/packages/table-core/src/types/Row.ts @@ -1,6 +1,13 @@ -import type { Row_Row } from '../core/rows/coreRowsFeature.types' +import type { Row_ColumnVisibility } from '../features/column-visibility/columnVisibilityFeature.types' +import type { Row_ColumnPinning } from '../features/column-pinning/columnPinningFeature.types' +import type { Row_ColumnGrouping } from '../features/column-grouping/columnGroupingFeature.types' +import type { Row_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' +import type { RowData, UnionToIntersection } from './type-utils' +import type { Row_RowExpanding } from '../features/row-expanding/rowExpandingFeature.types' +import type { Row_RowPinning } from '../features/row-pinning/rowPinningFeature.types' +import type { Row_RowSelection } from '../features/row-selection/rowSelectionFeature.types' import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' -import type { RowData } from './type-utils' +import type { Row_Row } from '../core/rows/coreRowsFeature.types' /** * Use this interface as a target for declaration merging to add your own plugin properties. @@ -20,5 +27,29 @@ export type Row< TFeatures extends TableFeatures, TData extends RowData, > = Row_Core & - ExtractFeatureTypes & + UnionToIntersection< + | ('columnFilteringFeature' extends keyof TFeatures + ? Row_ColumnFiltering + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? Row_ColumnGrouping + : never) + | ('columnPinningFeature' extends keyof TFeatures + ? Row_ColumnPinning + : never) + | ('columnVisibilityFeature' extends keyof TFeatures + ? Row_ColumnVisibility + : never) + | ('rowExpandingFeature' extends keyof TFeatures ? Row_RowExpanding : never) + | ('rowPinningFeature' extends keyof TFeatures ? Row_RowPinning : never) + | ('rowSelectionFeature' extends keyof TFeatures ? Row_RowSelection : never) + > & + ExtractFeatureTypes<'Row', TFeatures> & Row_Plugins + +// export type Row< +// TFeatures extends TableFeatures, +// TData extends RowData, +// > = Row_Core & +// ExtractFeatureTypes<'Row', TFeatures> & +// Row_Plugins diff --git a/packages/table-core/src/types/RowModel.ts b/packages/table-core/src/types/RowModel.ts index c7d5941678..bb5797be5c 100644 --- a/packages/table-core/src/types/RowModel.ts +++ b/packages/table-core/src/types/RowModel.ts @@ -13,6 +13,7 @@ import type { import type { CachedRowModel_Core, CreateRowModel_Core, + RowModel, } from '../core/row-models/coreRowModelsFeature.types' import type { CachedRowModel_Expanded, @@ -26,7 +27,7 @@ import type { CachedRowModel_Sorted, CreateRowModel_Sorted, } from '../features/row-sorting/rowSortingFeature.types' -import type { RowData } from './type-utils' +import type { RowData, UnionToIntersection } from './type-utils' import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' /** @@ -42,9 +43,36 @@ export type CreateRowModels< TFeatures extends TableFeatures, TData extends RowData, > = CreateRowModel_Core & - ExtractFeatureTypes & + UnionToIntersection< + | ('columnFacetingFeature' extends keyof TFeatures + ? CreateRowModel_Faceted + : never) + | ('columnFilteringFeature' extends keyof TFeatures + ? CreateRowModel_Filtered + : never) + | ('rowExpandingFeature' extends keyof TFeatures + ? CreateRowModel_Expanded + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? CreateRowModel_Grouped + : never) + | ('rowPaginationFeature' extends keyof TFeatures + ? CreateRowModel_Paginated + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? CreateRowModel_Sorted + : never) + > & + ExtractFeatureTypes<'CreateRowModels', TFeatures> & CreateRowModels_Plugins +// export type CreateRowModels< +// TFeatures extends TableFeatures, +// TData extends RowData, +// > = CreateRowModel_Core & +// ExtractFeatureTypes<'CreateRowModels', TFeatures> & +// CreateRowModels_Plugins + export type CreateRowModels_All< TFeatures extends TableFeatures, TData extends RowData, @@ -64,9 +92,37 @@ export interface CachedRowModels_Plugins< export type CachedRowModels< TFeatures extends TableFeatures, TData extends RowData, -> = ExtractFeatureTypes & +> = { + CachedRowModel_Core: () => RowModel +} & UnionToIntersection< + | ('columnFacetingFeature' extends keyof TFeatures + ? CachedRowModel_Faceted + : never) + | ('columnFilteringFeature' extends keyof TFeatures + ? CachedRowModel_Filtered + : never) + | ('rowExpandingFeature' extends keyof TFeatures + ? CachedRowModel_Expanded + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? CachedRowModel_Grouped + : never) + | ('rowPaginationFeature' extends keyof TFeatures + ? CachedRowModel_Paginated + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? CachedRowModel_Sorted + : never) +> & + ExtractFeatureTypes<'CachedRowModel', TFeatures> & CachedRowModels_Plugins +// export type CachedRowModels< +// TFeatures extends TableFeatures, +// TData extends RowData, +// > = ExtractFeatureTypes<'CachedRowModel', TFeatures> & +// CachedRowModels_Plugins + export type CachedRowModel_All< TFeatures extends TableFeatures, TData extends RowData = any, diff --git a/packages/table-core/src/types/RowModelFns.ts b/packages/table-core/src/types/RowModelFns.ts index 567237ddd8..aefcfd86df 100644 --- a/packages/table-core/src/types/RowModelFns.ts +++ b/packages/table-core/src/types/RowModelFns.ts @@ -1,6 +1,6 @@ import type { RowModelFns_RowSorting } from '../features/row-sorting/rowSortingFeature.types' import type { RowModelFns_ColumnGrouping } from '../features/column-grouping/columnGroupingFeature.types' -import type { RowData } from './type-utils' +import type { RowData, UnionToIntersection } from './type-utils' import type { RowModelFns_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' @@ -18,9 +18,28 @@ export interface RowModelFns_Core {} export type RowModelFns< TFeatures extends TableFeatures, TData extends RowData, -> = RowModelFns_Core & - ExtractFeatureTypes & - RowModelFns_Plugins +> = Partial< + UnionToIntersection< + | ('columnFilteringFeature' extends keyof TFeatures + ? RowModelFns_ColumnFiltering + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? RowModelFns_ColumnGrouping + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? RowModelFns_RowSorting + : never) + > & + ExtractFeatureTypes<'RowModelFns', TFeatures> & + RowModelFns_Plugins +> + +// export type RowModelFns< +// TFeatures extends TableFeatures, +// TData extends RowData, +// > = RowModelFns_Core & +// ExtractFeatureTypes<'RowModelFns', TFeatures> & +// RowModelFns_Plugins export type RowModelFns_All< TFeatures extends TableFeatures, diff --git a/packages/table-core/src/types/Table.ts b/packages/table-core/src/types/Table.ts index 8ea009675a..d4a2a0c781 100644 --- a/packages/table-core/src/types/Table.ts +++ b/packages/table-core/src/types/Table.ts @@ -1,14 +1,28 @@ -import type { TableOptions_All } from './TableOptions' -import type { Table_Table } from '../core/table/coreTablesFeature.types' -import type { Table_Rows } from '../core/rows/coreRowsFeature.types' -import type { Table_Headers } from '../core/headers/coreHeadersFeature.types' -import type { Table_Columns } from '../core/columns/coreColumnsFeature.types' -import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' -import type { RowData } from './type-utils' -import type { TableState_All } from './TableState' -import type { RowModelFns_All } from './RowModelFns' -import type { CachedRowModel_All, CreateRowModels_All } from './RowModel' +import type { Table_ColumnResizing } from '../features/column-resizing/columnResizingFeature.types' +import type { Table_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' +import type { Table_ColumnGrouping } from '../features/column-grouping/columnGroupingFeature.types' +import type { Table_ColumnPinning } from '../features/column-pinning/columnPinningFeature.types' +import type { Table_ColumnOrdering } from '../features/column-ordering/columnOrderingFeature.types' +import type { Table_ColumnVisibility } from '../features/column-visibility/columnVisibilityFeature.types' +import type { Table_ColumnSizing } from '../features/column-sizing/columnSizingFeature.types' +import type { Table_GlobalFaceting } from '../features/global-faceting/globalFacetingFeature.types' +import type { Table_RowPinning } from '../features/row-pinning/rowPinningFeature.types' +import type { Table_GlobalFiltering } from '../features/global-filtering/globalFilteringFeature.types' +import type { Table_RowExpanding } from '../features/row-expanding/rowExpandingFeature.types' +import type { Table_RowPagination } from '../features/row-pagination/rowPaginationFeature.types' +import type { Table_RowSelection } from '../features/row-selection/rowSelectionFeature.types' +import type { Table_RowSorting } from '../features/row-sorting/rowSortingFeature.types' import type { Table_RowModels } from '../core/row-models/coreRowModelsFeature.types' +import type { CachedRowModel_All, CreateRowModels_All } from './RowModel' +import type { RowModelFns_All } from './RowModelFns' +import type { TableState_All } from './TableState' +import type { RowData, UnionToIntersection } from './type-utils' +import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' +import type { Table_Columns } from '../core/columns/coreColumnsFeature.types' +import type { Table_Headers } from '../core/headers/coreHeadersFeature.types' +import type { Table_Rows } from '../core/rows/coreRowsFeature.types' +import type { Table_Table } from '../core/table/coreTablesFeature.types' +import type { TableOptions_All } from './TableOptions' /** * Use this interface as a target for declaration merging to add your own plugin properties. @@ -39,16 +53,67 @@ export type Table< TFeatures extends TableFeatures, TData extends RowData, > = Table_Core & - ExtractFeatureTypes & + UnionToIntersection< + | ('columnFilteringFeature' extends keyof TFeatures + ? Table_ColumnFiltering + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? Table_ColumnGrouping + : never) + | ('columnOrderingFeature' extends keyof TFeatures + ? Table_ColumnOrdering + : never) + | ('columnPinningFeature' extends keyof TFeatures + ? Table_ColumnPinning + : never) + | ('columnResizingFeature' extends keyof TFeatures + ? Table_ColumnResizing + : never) + | ('columnSizingFeature' extends keyof TFeatures + ? Table_ColumnSizing + : never) + | ('columnVisibilityFeature' extends keyof TFeatures + ? Table_ColumnVisibility + : never) + | ('globalFacetingFeature' extends keyof TFeatures + ? Table_GlobalFaceting + : never) + | ('globalFilteringFeature' extends keyof TFeatures + ? Table_GlobalFiltering + : never) + | ('rowExpandingFeature' extends keyof TFeatures + ? Table_RowExpanding + : never) + | ('rowPaginationFeature' extends keyof TFeatures + ? Table_RowPagination + : never) + | ('rowPinningFeature' extends keyof TFeatures + ? Table_RowPinning + : never) + | ('rowSelectionFeature' extends keyof TFeatures + ? Table_RowSelection + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? Table_RowSorting + : never) + > & + ExtractFeatureTypes<'Table', TFeatures> & Table_Plugins +// export type Table< +// TFeatures extends TableFeatures, +// TData extends RowData, +// > = Table_Core & +// ExtractFeatureTypes<'Table', TFeatures> & +// Table_Plugins + export type Table_Internal< TFeatures extends TableFeatures, TData extends RowData = any, > = Table & { _rowModels: CachedRowModel_All _rowModelFns: RowModelFns_All - options: TableOptions_All> & { + options: TableOptions_All & { _rowModels?: CreateRowModels_All state?: TableState_All initialState?: TableState_All diff --git a/packages/table-core/src/types/TableFeatures.ts b/packages/table-core/src/types/TableFeatures.ts index de044ac070..866a914d51 100644 --- a/packages/table-core/src/types/TableFeatures.ts +++ b/packages/table-core/src/types/TableFeatures.ts @@ -11,8 +11,8 @@ import type { TableState_All } from './TableState' import type { StockFeatures } from '../features/stockFeatures' export type ExtractFeatureTypes< - TFeatures extends TableFeatures, TKey extends keyof FeatureConstructors, + TFeatures extends TableFeatures, > = UnionToIntersection< { [K in keyof TFeatures]: TFeatures[K] extends TableFeature< @@ -117,7 +117,7 @@ export type GetDefaultColumnDef = < export type GetDefaultTableOptions = ( table: Table_Internal & Partial, - ) => Partial>> & + ) => Partial> & Partial export type GetInitialState = ( diff --git a/packages/table-core/src/types/TableOptions.ts b/packages/table-core/src/types/TableOptions.ts index 2caff65fb7..22a8cd4dd0 100644 --- a/packages/table-core/src/types/TableOptions.ts +++ b/packages/table-core/src/types/TableOptions.ts @@ -16,7 +16,7 @@ import type { TableOptions_RowPagination } from '../features/row-pagination/rowP import type { TableOptions_RowPinning } from '../features/row-pinning/rowPinningFeature.types' import type { TableOptions_RowSelection } from '../features/row-selection/rowSelectionFeature.types' import type { TableOptions_RowSorting } from '../features/row-sorting/rowSortingFeature.types' -import type { RowData } from './type-utils' +import type { RowData, UnionToIntersection } from './type-utils' import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' export interface TableOptions_Plugins< @@ -26,36 +26,84 @@ export interface TableOptions_Plugins< export interface TableOptions_Core< TFeatures extends TableFeatures, - TDataList extends Array, -> extends TableOptions_Table, + TData extends RowData, +> extends TableOptions_Table, TableOptions_Cell, - TableOptions_Columns, - TableOptions_Rows, + TableOptions_Columns, + TableOptions_Rows, TableOptions_Headers {} export type TableOptions< TFeatures extends TableFeatures, TData extends RowData, -> = TableOptions_Core> & - ExtractFeatureTypes & +> = TableOptions_Core & + UnionToIntersection< + | ('columnFilteringFeature' extends keyof TFeatures + ? TableOptions_ColumnFiltering + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? TableOptions_ColumnGrouping + : never) + | ('columnOrderingFeature' extends keyof TFeatures + ? TableOptions_ColumnOrdering + : never) + | ('columnPinningFeature' extends keyof TFeatures + ? TableOptions_ColumnPinning + : never) + | ('columnResizingFeature' extends keyof TFeatures + ? TableOptions_ColumnResizing + : never) + | ('columnSizingFeature' extends keyof TFeatures + ? TableOptions_ColumnSizing + : never) + | ('columnVisibilityFeature' extends keyof TFeatures + ? TableOptions_ColumnVisibility + : never) + | ('globalFilteringFeature' extends keyof TFeatures + ? TableOptions_GlobalFiltering + : never) + | ('rowExpandingFeature' extends keyof TFeatures + ? TableOptions_RowExpanding + : never) + | ('rowPaginationFeature' extends keyof TFeatures + ? TableOptions_RowPagination + : never) + | ('rowPinningFeature' extends keyof TFeatures + ? TableOptions_RowPinning + : never) + | ('rowSelectionFeature' extends keyof TFeatures + ? TableOptions_RowSelection + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? TableOptions_RowSorting + : never) + > & + ExtractFeatureTypes<'TableOptions', TFeatures> & TableOptions_Plugins +// export type TableOptions< +// TFeatures extends TableFeatures, +// TData extends RowData, +// > = TableOptions_Core & +// ExtractFeatureTypes<'TableOptions', TFeatures> & +// TableOptions_Plugins + export type TableOptions_All< TFeatures extends TableFeatures, - TDataList extends Array, -> = TableOptions_Core & + TData extends RowData, +> = TableOptions_Core & Partial< - TableOptions_ColumnFiltering & + TableOptions_ColumnFiltering & TableOptions_ColumnGrouping & TableOptions_ColumnOrdering & TableOptions_ColumnPinning & TableOptions_ColumnResizing & TableOptions_ColumnSizing & TableOptions_ColumnVisibility & - TableOptions_GlobalFiltering & - TableOptions_RowExpanding & + TableOptions_GlobalFiltering & + TableOptions_RowExpanding & TableOptions_RowPagination & - TableOptions_RowPinning & - TableOptions_RowSelection & + TableOptions_RowPinning & + TableOptions_RowSelection & TableOptions_RowSorting > diff --git a/packages/table-core/src/types/TableState.ts b/packages/table-core/src/types/TableState.ts index b57d398790..e90d550f62 100644 --- a/packages/table-core/src/types/TableState.ts +++ b/packages/table-core/src/types/TableState.ts @@ -1,3 +1,4 @@ +import type { UnionToIntersection } from './type-utils' import type { TableState_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' import type { TableState_ColumnGrouping } from '../features/column-grouping/columnGroupingFeature.types' import type { TableState_ColumnOrdering } from '../features/column-ordering/columnOrderingFeature.types' @@ -19,12 +20,57 @@ import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures' */ export interface TableState_Plugins {} -export type TableState = ExtractFeatureTypes< - TFeatures, - 'TableState' +export type TableState = UnionToIntersection< + | ('columnFilteringFeature' extends keyof TFeatures + ? TableState_ColumnFiltering + : never) + | ('columnGroupingFeature' extends keyof TFeatures + ? TableState_ColumnGrouping + : never) + | ('columnOrderingFeature' extends keyof TFeatures + ? TableState_ColumnOrdering + : never) + | ('columnPinningFeature' extends keyof TFeatures + ? TableState_ColumnPinning + : never) + | ('columnResizingFeature' extends keyof TFeatures + ? TableState_ColumnResizing + : never) + | ('columnSizingFeature' extends keyof TFeatures + ? TableState_ColumnSizing + : never) + | ('columnVisibilityFeature' extends keyof TFeatures + ? TableState_ColumnVisibility + : never) + | ('globalFilteringFeature' extends keyof TFeatures + ? TableState_GlobalFiltering + : never) + | ('rowExpandingFeature' extends keyof TFeatures + ? TableState_RowExpanding + : never) + | ('rowPaginationFeature' extends keyof TFeatures + ? TableState_RowPagination + : never) + | ('rowPinningFeature' extends keyof TFeatures + ? TableState_RowPinning + : never) + | ('rowSelectionFeature' extends keyof TFeatures + ? TableState_RowSelection + : never) + | ('rowSortingFeature' extends keyof TFeatures + ? TableState_RowSorting + : never) > & + ExtractFeatureTypes<'TableState', TFeatures> & TableState_Plugins +// export type TableState = ExtractFeatureTypes< +// export type TableState = ExtractFeatureTypes< +// 'TableState', +// TFeatures +// > & +// TableState_Plugins + export type TableState_All = Partial< TableState_ColumnFiltering & TableState_ColumnGrouping & diff --git a/packages/vue-table/src/createTableHelper.ts b/packages/vue-table/src/createTableHelper.ts index b2b392cc98..cb82307e7f 100644 --- a/packages/vue-table/src/createTableHelper.ts +++ b/packages/vue-table/src/createTableHelper.ts @@ -23,15 +23,15 @@ export type TableHelper< export function createTableHelper< TFeatures extends TableFeatures, - TDataList extends Array = Array, + TData extends RowData, >( - tableHelperOptions: TableHelperOptions, -): TableHelper { + tableHelperOptions: TableHelperOptions, +): TableHelper { const tableHelper = constructTableHelper(useTable, tableHelperOptions) return { ...tableHelper, useTable: tableHelper.tableCreator, - } as unknown as TableHelper + } as unknown as TableHelper } // test