Skip to content

Commit

Permalink
fix: move async utils to experimental package
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed May 10, 2022
1 parent d29449a commit 0772943
Show file tree
Hide file tree
Showing 82 changed files with 3,153 additions and 1,063 deletions.
18 changes: 9 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
const { NODE_ENV, BABEL_ENV } = process.env;
const cjs = NODE_ENV === "test" || BABEL_ENV === "commonjs";
const loose = true;
const { NODE_ENV, BABEL_ENV } = process.env
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
const loose = true

module.exports = {
presets: [
[
"@babel/env",
'@babel/env',
{
loose,
modules: false,
// exclude: ['@babel/plugin-transform-regenerator'],
},
],
"@babel/react",
"@babel/preset-typescript",
'@babel/react',
'@babel/preset-typescript',
],
plugins: [
// 'babel-plugin-transform-async-to-promises',
cjs && ["@babel/transform-modules-commonjs", { loose }],
'babel-plugin-transform-async-to-promises',
cjs && ['@babel/transform-modules-commonjs', { loose }],
// [
// '@babel/transform-runtime',
// {
Expand All @@ -28,4 +28,4 @@ module.exports = {
// },
// ],
].filter(Boolean),
};
}
3 changes: 1 addition & 2 deletions docs/api/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ Filter state is stored on the table instance using the following shape:
export type FiltersTableState = {
columnFilters: ColumnFiltersState
globalFilter: any
columnFiltersProgress: number
globalFilterProgress: number
filtersProgress: number
}

export type ColumnFiltersState = ColumnFilter[]
Expand Down
8 changes: 4 additions & 4 deletions examples/basic/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './index.css'

import {
createTable,
getCoreRowModelSync,
getCoreRowModel,
useTableInstance,
} from '@tanstack/react-table'

Expand Down Expand Up @@ -53,12 +53,12 @@ const defaultColumns = [
footer: props => props.column.id,
columns: [
table.createDataColumn('firstName', {
cell: info => info.value,
cell: info => info.getValue(),
footer: props => props.column.id,
}),
table.createDataColumn(row => row.lastName, {
id: 'lastName',
cell: info => info.value,
cell: info => info.getValue(),
header: () => <span>Last Name</span>,
footer: props => props.column.id,
}),
Expand Down Expand Up @@ -104,7 +104,7 @@ function App() {
const instance = useTableInstance(table, {
data,
columns,
getCoreRowModel: getCoreRowModelSync(),
getCoreRowModel: getCoreRowModel(),
})

return (
Expand Down
8 changes: 4 additions & 4 deletions examples/column-ordering/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './index.css'
import {
ColumnOrderState,
createTable,
getCoreRowModelSync,
getCoreRowModel,
useTableInstance,
} from '@tanstack/react-table'
import { makeData, Person } from './makeData'
Expand All @@ -20,12 +20,12 @@ const defaultColumns = [
footer: props => props.column.id,
columns: [
table.createDataColumn('firstName', {
cell: info => info.value,
cell: info => info.getValue(),
footer: props => props.column.id,
}),
table.createDataColumn(row => row.lastName, {
id: 'lastName',
cell: info => info.value,
cell: info => info.getValue(),
header: () => <span>Last Name</span>,
footer: props => props.column.id,
}),
Expand Down Expand Up @@ -78,7 +78,7 @@ function App() {
},
onColumnVisibilityChange: setColumnVisibility,
onColumnOrderChange: setColumnOrder,
getCoreRowModel: getCoreRowModelSync(),
getCoreRowModel: getCoreRowModel(),
debugTable: true,
debugHeaders: true,
debugColumns: true,
Expand Down
6 changes: 3 additions & 3 deletions examples/column-ordering/src/makeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const newPerson = (): Person => {
'relationship',
'complicated',
'single',
])[0],
])[0]!,
}
}

export function makeData(...lens: number[]) {
const makeDataLevel = (depth = 0) => {
const len = lens[depth]
const makeDataLevel = (depth = 0): Person[] => {
const len = lens[depth]!
return range(len).map((d): Person => {
return {
...newPerson(),
Expand Down
9 changes: 4 additions & 5 deletions examples/column-pinning/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import './index.css'
import {
ColumnOrderState,
createTable,
getCoreRowModelAsync,
getCoreRowModelSync,
getCoreRowModel,
useTableInstance,
VisibilityState,
} from '@tanstack/react-table'
Expand All @@ -22,12 +21,12 @@ const defaultColumns = [
footer: props => props.column.id,
columns: [
table.createDataColumn('firstName', {
cell: info => info.value,
cell: info => info.getValue(),
footer: props => props.column.id,
}),
table.createDataColumn(row => row.lastName, {
id: 'lastName',
cell: info => info.value,
cell: info => info.getValue(),
header: () => <span>Last Name</span>,
footer: props => props.column.id,
}),
Expand Down Expand Up @@ -85,7 +84,7 @@ function App() {
onColumnVisibilityChange: setColumnVisibility,
onColumnOrderChange: setColumnOrder,
onColumnPinningChange: setColumnPinning,
getCoreRowModel: getCoreRowModelSync(),
getCoreRowModel: getCoreRowModel(),
debugTable: true,
debugHeaders: true,
debugColumns: true,
Expand Down
6 changes: 3 additions & 3 deletions examples/column-pinning/src/makeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const newPerson = (): Person => {
'relationship',
'complicated',
'single',
])[0],
])[0]!,
}
}

export function makeData(...lens: number[]) {
const makeDataLevel = (depth = 0) => {
const len = lens[depth]
const makeDataLevel = (depth = 0): Person[] => {
const len = lens[depth]!
return range(len).map((d): Person => {
return {
...newPerson(),
Expand Down
8 changes: 4 additions & 4 deletions examples/column-sizing/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
createTable,
useTableInstance,
ColumnResizeMode,
getCoreRowModelSync,
getCoreRowModel,
} from '@tanstack/react-table'

type Person = {
Expand Down Expand Up @@ -54,12 +54,12 @@ const defaultColumns = [
footer: props => props.column.id,
columns: [
table.createDataColumn('firstName', {
cell: info => info.value,
cell: info => info.getValue(),
footer: props => props.column.id,
}),
table.createDataColumn(row => row.lastName, {
id: 'lastName',
cell: info => info.value,
cell: info => info.getValue(),
header: () => <span>Last Name</span>,
footer: props => props.column.id,
}),
Expand Down Expand Up @@ -109,7 +109,7 @@ function App() {
data,
columns,
columnResizeMode,
getCoreRowModel: getCoreRowModelSync(),
getCoreRowModel: getCoreRowModel(),
debugTable: true,
debugHeaders: true,
debugColumns: true,
Expand Down
8 changes: 4 additions & 4 deletions examples/column-visibility/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import './index.css'

import {
createTable,
getCoreRowModelSync,
getCoreRowModel,
useTableInstance,
} from '@tanstack/react-table'

Expand Down Expand Up @@ -53,12 +53,12 @@ const defaultColumns = [
footer: props => props.column.id,
columns: [
table.createDataColumn('firstName', {
cell: info => info.value,
cell: info => info.getValue(),
footer: props => props.column.id,
}),
table.createDataColumn(row => row.lastName, {
id: 'lastName',
cell: info => info.value,
cell: info => info.getValue(),
header: () => <span>Last Name</span>,
footer: props => props.column.id,
}),
Expand Down Expand Up @@ -109,7 +109,7 @@ function App() {
columnVisibility,
},
onColumnVisibilityChange: setColumnVisibility,
getCoreRowModel: getCoreRowModelSync(),
getCoreRowModel: getCoreRowModel(),
debugTable: true,
debugHeaders: true,
debugColumns: true,
Expand Down
18 changes: 10 additions & 8 deletions examples/editable-data/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
TableInstance,
ColumnDef,
useTableInstance,
getCoreRowModelSync,
getFilteredRowModelSync,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
} from '@tanstack/react-table'
import { makeData, Person } from './makeData'
Expand All @@ -29,7 +29,8 @@ type MyTableGenerics = typeof table.generics

// Give our default column cell renderer editing superpowers!
const defaultColumn: Partial<ColumnDef<MyTableGenerics>> = {
cell: ({ value: initialValue, row: { index }, column: { id }, instance }) => {
cell: ({ getValue, row: { index }, column: { id }, instance }) => {
const initialValue = getValue()
// We need to keep and update the state of the cell normally
const [value, setValue] = React.useState(initialValue)

Expand Down Expand Up @@ -128,8 +129,8 @@ function App() {
data,
columns,
defaultColumn,
getCoreRowModel: getCoreRowModelSync(),
getFilteredRowModel: getFilteredRowModelSync(),
getCoreRowModel: getCoreRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getPaginationRowModel: getPaginationRowModel(),
autoResetPageIndex,
// Provide our updateData function to our table meta
Expand All @@ -141,7 +142,7 @@ function App() {
old.map((row, index) => {
if (index === rowIndex) {
return {
...old[rowIndex],
...old[rowIndex]!,
[columnId]: value,
}
}
Expand Down Expand Up @@ -273,8 +274,9 @@ function Filter({
column: Column<any>
instance: TableInstance<any>
}) {
const firstValue =
instance.getPreFilteredRowModel().flatRows[0].values[column.id]
const firstValue = instance
.getPreFilteredRowModel()
.flatRows[0]?.getValue(column.id)

const columnFilterValue = column.getFilterValue()

Expand Down
6 changes: 3 additions & 3 deletions examples/editable-data/src/makeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const newPerson = (): Person => {
'relationship',
'complicated',
'single',
])[0],
])[0]!,
}
}

export function makeData(...lens: number[]) {
const makeDataLevel = (depth = 0) => {
const len = lens[depth]
const makeDataLevel = (depth = 0): Person[] => {
const len = lens[depth]!
return range(len).map((d): Person => {
return {
...newPerson(),
Expand Down
19 changes: 10 additions & 9 deletions examples/expanding/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
TableInstance,
ExpandedState,
useTableInstance,
getCoreRowModelSync,
getCoreRowModel,
getPaginationRowModel,
getFilteredRowModelSync,
getFilteredRowModel,
getExpandedRowModel,
} from '@tanstack/react-table'
import { makeData, Person } from './makeData'
Expand Down Expand Up @@ -47,7 +47,7 @@ function App() {
First Name
</>
),
cell: ({ row, value }) => (
cell: ({ row, getValue }) => (
<div
style={{
// Since rows are flattened by default,
Expand Down Expand Up @@ -76,14 +76,14 @@ function App() {
) : (
'🔵'
)}{' '}
{value}
{getValue()}
</div>
),
footer: props => props.column.id,
}),
table.createDataColumn(row => row.lastName, {
id: 'lastName',
cell: info => info.value,
cell: info => info.getValue(),
header: () => <span>Last Name</span>,
footer: props => props.column.id,
}),
Expand Down Expand Up @@ -133,9 +133,9 @@ function App() {
},
onExpandedChange: setExpanded,
getSubRows: row => row.subRows,
getCoreRowModel: getCoreRowModelSync(),
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getFilteredRowModel: getFilteredRowModelSync(),
getFilteredRowModel: getFilteredRowModel(),
getExpandedRowModel: getExpandedRowModel(),
debugTable: true,
})
Expand Down Expand Up @@ -262,8 +262,9 @@ function Filter({
column: Column<any>
instance: TableInstance<any>
}) {
const firstValue =
instance.getPreFilteredRowModel().flatRows[0].values[column.id]
const firstValue = instance
.getPreFilteredRowModel()
.flatRows[0]?.getValue(column.id)

const columnFilterValue = column.getFilterValue()

Expand Down
6 changes: 3 additions & 3 deletions examples/expanding/src/makeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const newPerson = (): Person => {
'relationship',
'complicated',
'single',
])[0],
])[0]!,
}
}

export function makeData(...lens: number[]) {
const makeDataLevel = (depth = 0) => {
const len = lens[depth]
const makeDataLevel = (depth = 0): Person[] => {
const len = lens[depth]!
return range(len).map((d): Person => {
return {
...newPerson(),
Expand Down
Loading

0 comments on commit 0772943

Please sign in to comment.