Skip to content

Commit

Permalink
feat: add fns generic and refactor how fns get added
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Sep 30, 2024
1 parent b8f1cbf commit a1219e2
Show file tree
Hide file tree
Showing 170 changed files with 2,504 additions and 1,526 deletions.
12 changes: 6 additions & 6 deletions docs/api/core/cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ Renders the value for a cell the same as `getValue`, but will return the `render
### `row`

```tsx
row: Row<TFeatures, TData>
row: Row<TFeatures, TFns, TData>
```

The associated Row object for the cell.

### `column`

```tsx
column: Column<TFeatures, TData>
column: Column<TFeatures, TFns, TData>
```

The associated Column object for the cell.
Expand All @@ -52,10 +52,10 @@ The associated Column object for the cell.

```tsx
getContext: () => {
table: Table<TFeatures, TData>
column: Column<TFeatures, TData, TValue>
row: Row<TFeatures, TData>
cell: Cell<TFeatures, TData, TValue>
table: Table<TFeatures, TFns, TData>
column: Column<TFeatures, TFns, TData, TValue>
row: Row<TFeatures, TFns, TData>
cell: Cell<TFeatures, TFns, TData, TValue>
getValue: <TTValue = TValue extends CellData = CellData>() => TTValue
renderValue: <TTValue = TValue extends CellData = CellData>() => TTValue | null
}
Expand Down
24 changes: 12 additions & 12 deletions docs/api/core/column-def.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The accessor function to use when extracting the value for the column from each
### `columns`

```tsx
columns?: ColumnDef<TFeatures, TData>[]
columns?: ColumnDef<TFeatures, TFns, TData>[]
```

The child column defs to include in a group column.
Expand All @@ -49,9 +49,9 @@ The child column defs to include in a group column.
header?:
| string
| ((props: {
table: Table<TFeatures, TData>
header: Header<TFeatures, TData>
column: Column<TFeatures, TData>
table: Table<TFeatures, TFns, TData>
header: Header<TFeatures, TFns, TData>
column: Column<TFeatures, TFns, TData>
}) => unknown)
```

Expand All @@ -63,9 +63,9 @@ The header to display for the column. If a string is passed, it can be used as a
footer?:
| string
| ((props: {
table: Table<TFeatures, TData>
header: Header<TFeatures, TData>
column: Column<TFeatures, TData>
table: Table<TFeatures, TFns, TData>
header: Header<TFeatures, TFns, TData>
column: Column<TFeatures, TFns, TData>
}) => unknown)
```

Expand All @@ -77,10 +77,10 @@ The footer to display for the column. If a function is passed, it will be passed
cell?:
| string
| ((props: {
table: Table<TFeatures, TData>
row: Row<TFeatures, TData>
column: Column<TFeatures, TData>
cell: Cell<TFeatures, TData>
table: Table<TFeatures, TFns, TData>
row: Row<TFeatures, TFns, TData>
column: Column<TFeatures, TFns, TData>
cell: Cell<TFeatures, TFns, TData>
getValue: () => any
renderValue: () => any
}) => unknown)
Expand All @@ -100,7 +100,7 @@ The meta data to be associated with the column. We can access it anywhere when t
import '@tanstack/react-table' //or vue, svelte, solid, qwik, etc.
declare module '@tanstack/react-table' {
interface ColumnMeta<TFeatures extends TableFeatures, TData extends RowData, TValue> {
interface ColumnMeta<TFeatures extends TableFeatures, TFns extends Fns<TFeatures, TFns, TData>, TData extends RowData, TValue> {
foo: string
}
}
Expand Down
10 changes: 5 additions & 5 deletions docs/api/core/column.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,39 @@ The resolved accessor function to use when extracting the value for the column f
### `columnDef`

```tsx
columnDef: ColumnDef<TFeatures, TData>
columnDef: ColumnDef<TFeatures, TFns, TData>
```

The original column def used to create the column.

### `columns`

```tsx
type columns = ColumnDef<TFeatures, TData>[]
type columns = ColumnDef<TFeatures, TFns, TData>[]
```
The child column (if the column is a group column). Will be an empty array if the column is not a group column.
### `parent`
```tsx
parent?: Column<TFeatures, TData>
parent?: Column<TFeatures, TFns, TData>
```
The parent column for this column. Will be undefined if this is a root column.
### `getFlatColumns`
```tsx
type getFlatColumns = () => Column<TFeatures, TData>[]
type getFlatColumns = () => Column<TFeatures, TFns, TData>[]
```
Returns the flattened array of this column and all child/grand-child columns for this column.
### `getLeafColumns`
```tsx
type getLeafColumns = () => Column<TFeatures, TData>[]
type getLeafColumns = () => Column<TFeatures, TFns, TData>[]
```
Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.
2 changes: 1 addition & 1 deletion docs/api/core/header-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The depth of the header group, zero-indexed based.
### `headers`

```tsx
type headers = Header<TFeatures, TData>[]
type headers = Header<TFeatures, TFns, TData>[]
```
An array of [Header](../header) objects that belong to this header group
46 changes: 23 additions & 23 deletions docs/api/core/header.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ The depth of the header, zero-indexed based.
### `column`

```tsx
column: Column<TFeatures, TData>
column: Column<TFeatures, TFns, TData>
```

The header's associated [Column](../column) object

### `headerGroup`

```tsx
headerGroup: HeaderGroup<TFeatures, TData>
headerGroup: HeaderGroup<TFeatures, TFns, TData>
```

The header's associated [HeaderGroup](../header-group) object

### `subHeaders`

```tsx
type subHeaders = Header<TFeatures, TData>[]
type subHeaders = Header<TFeatures, TFns, TData>[]
```
The header's hierarchical sub/child headers. Will be empty if the header's associated column is a leaf-column.
Expand All @@ -75,7 +75,7 @@ The row-span for the header.
### `getLeafHeaders`
```tsx
type getLeafHeaders = () => Header<TFeatures, TData>[]
type getLeafHeaders = () => Header<TFeatures, TFns, TData>[]
```
Returns the leaf headers hierarchically nested under this header.
Expand All @@ -100,9 +100,9 @@ If the header is a placeholder header, this will be a unique header ID that does
```tsx
getContext: () => {
table: Table<TFeatures, TData>
header: Header<TFeatures, TData, TValue>
column: Column<TFeatures, TData, TValue>
table: Table<TFeatures, TFns, TData>
header: Header<TFeatures, TFns, TData, TValue>
column: Column<TFeatures, TFns, TData, TValue>
}
```
Expand All @@ -117,127 +117,127 @@ flexRender(header.column.columnDef.header, header.getContext())
### `getHeaderGroups`
```tsx
type getHeaderGroups = () => HeaderGroup<TFeatures, TData>[]
type getHeaderGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
Returns all header groups for the table.
### `getLeftHeaderGroups`
```tsx
type getLeftHeaderGroups = () => HeaderGroup<TFeatures, TData>[]
type getLeftHeaderGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
If pinning, returns the header groups for the left pinned columns.
### `getCenterHeaderGroups`
```tsx
type getCenterHeaderGroups = () => HeaderGroup<TFeatures, TData>[]
type getCenterHeaderGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
If pinning, returns the header groups for columns that are not pinned.
### `getRightHeaderGroups`
```tsx
type getRightHeaderGroups = () => HeaderGroup<TFeatures, TData>[]
type getRightHeaderGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
If pinning, returns the header groups for the right pinned columns.
### `getFooterGroups`
```tsx
type getFooterGroups = () => HeaderGroup<TFeatures, TData>[]
type getFooterGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
Returns all footer groups for the table.
### `getLeftFooterGroups`
```tsx
type getLeftFooterGroups = () => HeaderGroup<TFeatures, TData>[]
type getLeftFooterGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
If pinning, returns the footer groups for the left pinned columns.
### `getCenterFooterGroups`
```tsx
type getCenterFooterGroups = () => HeaderGroup<TFeatures, TData>[]
type getCenterFooterGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
If pinning, returns the footer groups for columns that are not pinned.
### `getRightFooterGroups`
```tsx
type getRightFooterGroups = () => HeaderGroup<TFeatures, TData>[]
type getRightFooterGroups = () => HeaderGroup<TFeatures, TFns, TData>[]
```
If pinning, returns the footer groups for the right pinned columns.
### `getFlatHeaders`
```tsx
type getFlatHeaders = () => Header<TFeatures, TData, unknown>[]
type getFlatHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
Returns headers for all columns in the table, including parent headers.
### `getLeftFlatHeaders`
```tsx
type getLeftFlatHeaders = () => Header<TFeatures, TData, unknown>[]
type getLeftFlatHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
If pinning, returns headers for all left pinned columns in the table, including parent headers.
### `getCenterFlatHeaders`
```tsx
type getCenterFlatHeaders = () => Header<TFeatures, TData, unknown>[]
type getCenterFlatHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
If pinning, returns headers for all columns that are not pinned, including parent headers.
### `getRightFlatHeaders`
```tsx
type getRightFlatHeaders = () => Header<TFeatures, TData, unknown>[]
type getRightFlatHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
If pinning, returns headers for all right pinned columns in the table, including parent headers.
### `getLeafHeaders`
```tsx
type getLeafHeaders = () => Header<TFeatures, TData, unknown>[]
type getLeafHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
Returns headers for all leaf columns in the table, (not including parent headers).
### `getLeftLeafHeaders`
```tsx
type getLeftLeafHeaders = () => Header<TFeatures, TData, unknown>[]
type getLeftLeafHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
If pinning, returns headers for all left pinned leaf columns in the table, (not including parent headers).
### `getCenterLeafHeaders`
```tsx
type getCenterLeafHeaders = () => Header<TFeatures, TData, unknown>[]
type getCenterLeafHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
If pinning, returns headers for all columns that are not pinned, (not including parent headers).
### `getRightLeafHeaders`
```tsx
type getRightLeafHeaders = () => Header<TFeatures, TData, unknown>[]
type getRightLeafHeaders = () => Header<TFeatures, TFns, TData, unknown>[]
```
If pinning, returns headers for all right pinned leaf columns in the table, (not including parent headers).
10 changes: 5 additions & 5 deletions docs/api/core/row.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,31 @@ Returns a unique array of values from the row for a given columnId.
### `subRows`

```tsx
type subRows = Row<TFeatures, TData>[]
type subRows = Row<TFeatures, TFns, TData>[]
```
An array of subRows for the row as returned and created by the `options.getSubRows` option.
### `getParentRow`
```tsx
type getParentRow = () => Row<TFeatures, TData> | undefined
type getParentRow = () => Row<TFeatures, TFns, TData> | undefined
```
Returns the parent row for the row, if it exists.
### `getParentRows`
```tsx
type getParentRows = () => Row<TFeatures, TData>[]
type getParentRows = () => Row<TFeatures, TFns, TData>[]
```
Returns the parent rows for the row, all the way up to a root row.
### `getLeafRows`
```tsx
type getLeafRows = () => Row<TFeatures, TData>[]
type getLeafRows = () => Row<TFeatures, TFns, TData>[]
```
Returns the leaf rows for the row, not including any parent rows.
Expand All @@ -117,7 +117,7 @@ An array of the original subRows as returned by the `options.getSubRows` option.
### `getAllCells`
```tsx
type getAllCells = () => Cell<TFeatures, TData>[]
type getAllCells = () => Cell<TFeatures, TFns, TData>[]
```
Returns all of the [Cells](../cell) for the row.
Loading

0 comments on commit a1219e2

Please sign in to comment.