Skip to content

Commit 99df25a

Browse files
committed
fix some types for fns internally
1 parent a1219e2 commit 99df25a

File tree

32 files changed

+82
-65
lines changed

32 files changed

+82
-65
lines changed

examples/react/custom-features/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ function App() {
186186
const table = useTable({
187187
_features: { DensityFeature }, //pass our custom feature to the table to be instantiated upon creation
188188
_rowModels: {
189-
Core: createCoreRowModel(),
190189
Filtered: createFilteredRowModel(),
191190
Paginated: createPaginatedRowModel(),
192191
Sorted: createSortedRowModel(),

examples/react/expanding/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ function App() {
131131
const table = useTable({
132132
_features,
133133
_rowModels: {
134-
Core: createCoreRowModel(),
135134
Filtered: createFilteredRowModel(),
136135
Paginated: createPaginatedRowModel(),
137136
Sorted: createSortedRowModel(),

examples/react/filters-faceted/src/main.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ import {
1515
createFilteredRowModel,
1616
createPaginatedRowModel,
1717
createSortedRowModel,
18+
filterFns,
1819
flexRender,
20+
sortingFns,
1921
tableFeatures,
22+
tableFns,
2023
useTable,
2124
} from '@tanstack/react-table'
2225
import { makeData } from './makeData'
26+
import type { Fns } from '../../../../packages/table-core/dist/esm/types/Fns'
2327
import type {
2428
CellData,
2529
Column,
@@ -38,8 +42,13 @@ const _features = tableFeatures({
3842
RowSorting,
3943
})
4044

45+
const _fns = tableFns(_features, {
46+
filterFns,
47+
sortingFns,
48+
})
49+
4150
declare module '@tanstack/react-table' {
42-
//allows us to define custom properties for our columns
51+
// allows us to define custom properties for our columns
4352
interface ColumnMeta<
4453
TFeatures extends TableFeatures,
4554
TFns extends Fns<TFeatures, TFns, TData>,
@@ -55,7 +64,9 @@ function App() {
5564
[],
5665
)
5766

58-
const columns = React.useMemo<Array<ColumnDef<typeof _features, {}, Person>>>(
67+
const columns = React.useMemo<
68+
Array<ColumnDef<typeof _features, typeof _fns, Person>>
69+
>(
5970
() => [
6071
{
6172
accessorKey: 'firstName',
@@ -100,19 +111,19 @@ function App() {
100111
)
101112

102113
const [data, setData] = React.useState<Array<Person>>(() => makeData(5_000))
103-
const refreshData = () => setData((_old) => makeData(100_000)) //stress test
114+
const refreshData = () => setData((_old) => makeData(100_000)) // stress test
104115
const rerender = React.useReducer(() => ({}), {})[1]
105116

106117
const table = useTable({
107118
_features,
119+
_fns,
108120
_rowModels: {
109-
Core: createCoreRowModel(),
110-
Filtered: createFilteredRowModel(), //client-side filtering
121+
Filtered: createFilteredRowModel(), // client-side filtering
111122
Paginated: createPaginatedRowModel(),
112123
Sorted: createSortedRowModel(),
113-
Faceted: createFacetedRowModel(), //client-side faceting
114-
FacetedMinMax: createFacetedMinMaxValues(), //generate min/max values for range filter
115-
FacetedUnique: createFacetedUniqueValues(), //generate unique values for select filter/autocomplete
124+
Faceted: createFacetedRowModel(), // client-side faceting
125+
FacetedMinMax: createFacetedMinMaxValues(), // generate min/max values for range filter
126+
FacetedUnique: createFacetedUniqueValues(), // generate unique values for select filter/autocomplete
116127
},
117128
columns,
118129
data,
@@ -319,7 +330,7 @@ function Filter({ column }: { column: Column<any, Person, unknown> }) {
319330
>
320331
<option value="">All</option>
321332
{sortedUniqueValues.map((value) => (
322-
//dynamically generated select options from faceted values feature
333+
// dynamically generated select options from faceted values feature
323334
<option value={value} key={value}>
324335
{value}
325336
</option>

examples/react/filters-fuzzy/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ function App() {
127127
const table = useTable<typeof _features, Person>({
128128
_features,
129129
_rowModels: {
130-
Core: createCoreRowModel(),
131130
Filtered: createFilteredRowModel(),
132131
Paginated: createPaginatedRowModel(),
133132
Sorted: createSortedRowModel(),

examples/react/filters/src/main.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ function App() {
272272
)
273273
}
274274

275-
function Filter({ column }: { column: Column<any, any, Person, unknown> }) {
275+
function Filter({
276+
column,
277+
}: {
278+
column: Column<typeof _features, typeof _fns, Person, unknown>
279+
}) {
276280
const columnFilterValue = column.getFilterValue()
277281
const { filterVariant } = column.columnDef.meta ?? {}
278282

examples/react/full-width-resizable-table/src/main.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ function App() {
6363
const data = React.useMemo(() => makeData(20), [])
6464

6565
const table = useTable({
66-
_rowModels: {
67-
Core: createCoreRowModel(),
68-
},
66+
_rowModels: {},
6967
columns,
7068
data,
7169
enableColumnResizing: true,

examples/react/full-width-table/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function App() {
7575

7676
const table = useTable({
7777
_rowModels: {
78-
Core: createCoreRowModel(),
7978
Paginated: createPaginatedRowModel(),
8079
},
8180
columns,

examples/react/fully-controlled/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ function App() {
8484
// Create the table and pass your options
8585
const table = useTable({
8686
_rowModels: {
87-
Core: createCoreRowModel(),
8887
Paginated: createPaginatedRowModel(),
8988
},
9089
columns,

examples/react/grouping/src/main.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const tableHelper = createTableHelper({
3232
RowExpanding,
3333
},
3434
_rowModels: {
35-
Core: createCoreRowModel(),
3635
Filtered: createFilteredRowModel(),
3736
Paginated: createPaginatedRowModel(),
3837
Sorted: createSortedRowModel(),

examples/react/kitchen-sink/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export const App = () => {
8888

8989
const table = useTable({
9090
_rowModels: {
91-
Core: createCoreRowModel(),
9291
Filtered: createFilteredRowModel(),
9392
Paginated: createPaginatedRowModel(),
9493
Sorted: createSortedRowModel(),

0 commit comments

Comments
 (0)