Skip to content

Commit

Permalink
another row model refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Oct 22, 2024
1 parent 401d69b commit 889bfeb
Show file tree
Hide file tree
Showing 86 changed files with 799 additions and 995 deletions.
4 changes: 2 additions & 2 deletions docs/api/features/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ getPageCount: () => number
Returns the page count. If manually paginating or controlling the pagination state, this will come directly from the `options.pageCount` table option, otherwise it will be calculated from the table data using the total row count and current page size.
### `getPrePaginationRowModel`
### `getPrePaginatedRowModel`
```tsx
getPrePaginationRowModel: () => RowModel<TFeatures, TData>
getPrePaginatedRowModel: () => RowModel<TFeatures, TData>
```
Returns the row model for the table before any pagination has been applied.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const table = useTable({

If you decide that you need to use server-side pagination, here is how you can implement it.

No pagination row model is needed for server-side pagination, but if you have provided it for other tables that do need it in a shared component, you can still turn off the client-side pagination by setting the `manualPagination` option to `true`. Setting the `manualPagination` option to `true` will tell the table instance to use the `table.getPrePaginationRowModel` row model under the hood, and it will make the table instance assume that the `data` that you pass in is already paginated.
No pagination row model is needed for server-side pagination, but if you have provided it for other tables that do need it in a shared component, you can still turn off the client-side pagination by setting the `manualPagination` option to `true`. Setting the `manualPagination` option to `true` will tell the table instance to use the `table.getPrePaginatedRowModel` row model under the hood, and it will make the table instance assume that the `data` that you pass in is already paginated.

#### Page Count and Row Count

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/row-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ For normal rendering use cases, you will probably only need to use the `table.ge
- `getPreExpandedRowModel` - returns a row model that only includes root level rows with no expanded sub-rows included. Still includes sorting.
- `getPaginatedRowModel` - returns a row model that only includes the rows that should be displayed on the current page based on the pagination state.
- `getPrePaginationRowModel` - returns a row model without pagination applied (includes all rows).
- `getPrePaginatedRowModel` - returns a row model without pagination applied (includes all rows).
- `getSelectedRowModel` - returns a row model of all selected rows (but only based on the data that was passed to the table). Runs after getCoreRowModel.
- `getPreSelectedRowModel` - returns a row model before row selection is applied (Just returns getCoreRowModel).
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/filters/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}
</select>
</div>
<div>{{ table.getPrePaginationRowModel().rows.length }} Rows</div>
<div>{{ table.getPrePaginatedRowModel().rows.length }} Rows</div>
<div>
<button class="border rounded p-2 mb-2" (click)="refreshData()">
Refresh Data
Expand Down
2 changes: 1 addition & 1 deletion examples/qwik/filters/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const App = component$(() => {
})}
</tbody>
</table>
<div>{table.getPrePaginationRowModel().rows.length} Rows</div>
<div>{table.getPrePaginatedRowModel().rows.length} Rows</div>
<pre>{JSON.stringify(table.getState(), null, 2)}</pre>
</div>
)
Expand Down
6 changes: 3 additions & 3 deletions examples/react/custom-features/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ function App() {
const table = useTable({
_features: { DensityFeature }, // pass our custom feature to the table to be instantiated upon creation
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
Sorted: createSortedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
},
columns,
data,
Expand Down
4 changes: 2 additions & 2 deletions examples/react/editable-data/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const _features = tableFeatures({ RowPagination, ColumnFiltering })
const options = tableOptions<typeof _features, Person>({
_features,
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
})

Expand Down
6 changes: 3 additions & 3 deletions examples/react/expanding/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ function App() {
const table = useTable({
_features,
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
Sorted: createSortedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
},
columns,
data,
Expand Down
14 changes: 7 additions & 7 deletions examples/react/filters-faceted/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ function App() {
sortingFns,
},
_rowModels: {
Filtered: createFilteredRowModel(), // client-side filtering
Paginated: createPaginatedRowModel(),
Sorted: createSortedRowModel(),
Faceted: createFacetedRowModel(), // client-side faceting
FacetedMinMax: createFacetedMinMaxValues(), // generate min/max values for range filter
FacetedUnique: createFacetedUniqueValues(), // generate unique values for select filter/autocomplete
filteredRowModel: createFilteredRowModel(), // client-side filtering
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
facetedRowModel: createFacetedRowModel(), // client-side faceting
facetedMinMaxValues: createFacetedMinMaxValues(), // generate min/max values for range filter
facetedUniqueValues: createFacetedUniqueValues(), // generate unique values for select filter/autocomplete
},
columns,
data,
Expand Down Expand Up @@ -247,7 +247,7 @@ function App() {
))}
</select>
</div>
<div>{table.getPrePaginationRowModel().rows.length} Rows</div>
<div>{table.getPrePaginatedRowModel().rows.length} Rows</div>
<div>
<button onClick={rerender}>Force Rerender</button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions examples/react/filters-fuzzy/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ function App() {
filterFns,
},
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
Sorted: createSortedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
},
columns,
data,
Expand Down Expand Up @@ -294,7 +294,7 @@ function App() {
))}
</select>
</div>
<div>{table.getPrePaginationRowModel().rows.length} Rows</div>
<div>{table.getPrePaginatedRowModel().rows.length} Rows</div>
<div>
<button onClick={() => rerender()}>Force Rerender</button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions examples/react/filters/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ function App() {
sortingFns,
},
_rowModels: {
Filtered: createFilteredRowModel(), // client side filtering
Sorted: createSortedRowModel(),
Paginated: createPaginatedRowModel(),
filteredRowModel: createFilteredRowModel(), // client side filtering
sortedRowModel: createSortedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down Expand Up @@ -244,7 +244,7 @@ function App() {
))}
</select>
</div>
<div>{table.getPrePaginationRowModel().rows.length} Rows</div>
<div>{table.getPrePaginatedRowModel().rows.length} Rows</div>
<div>
<button onClick={() => rerender()}>Force Rerender</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/react/full-width-table/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function App() {

const table = useTable({
_rowModels: {
Paginated: createPaginatedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/fully-controlled/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function App() {
// Create the table and pass your options
const table = useTable({
_rowModels: {
Paginated: createPaginatedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down
14 changes: 7 additions & 7 deletions examples/react/grouping/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import type { Person } from './makeData'
const tableHelper = createTableHelper({
_features: {
ColumnFiltering,
RowPagination,
RowSorting,
ColumnGrouping,
RowExpanding,
RowPagination,
RowSorting,
},
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
Sorted: createSortedRowModel(),
Grouped: createGroupedRowModel(),
Expanded: createExpandedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
groupedRowModel: createGroupedRowModel(),
expandedRowModel: createExpandedRowModel(),
},
TData: {} as Person,
})
Expand Down
16 changes: 8 additions & 8 deletions examples/react/kitchen-sink/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export const App = () => {

const table = useTable({
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
Sorted: createSortedRowModel(),
Grouped: createGroupedRowModel(),
Faceted: createFacetedRowModel(),
FacetedMinMax: createFacetedMinMaxValues(),
FacetedUnique: createFacetedUniqueValues(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
groupedRowModel: createGroupedRowModel(),
facetedRowModel: createFacetedRowModel(),
facetedMinMaxValues: createFacetedMinMaxValues(),
facetedUniqueValues: createFacetedUniqueValues(),
},
columns,
data,
Expand Down Expand Up @@ -214,7 +214,7 @@ export const App = () => {
rowSelection={rowSelection}
setPageIndex={table.setPageIndex}
setPageSize={table.setPageSize}
totalRows={table.getPrePaginationRowModel().rows.length}
totalRows={table.getPrePaginatedRowModel().rows.length}
/>
<div className="p-2" />
<pre>{JSON.stringify(table.getState(), null, 2)}</pre>
Expand Down
4 changes: 2 additions & 2 deletions examples/react/material-ui-pagination/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function LocalTable({
}) {
const table = useTable({
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down
6 changes: 3 additions & 3 deletions examples/react/pagination/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ function MyTable({
_features,
_processingFns,
_rowModels: {
Sorted: createSortedRowModel(),
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down
6 changes: 3 additions & 3 deletions examples/react/row-pinning/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ function App() {
const table = useTable({
_features,
_rowModels: {
Filtered: createFilteredRowModel(),
Expanded: createExpandedRowModel(),
Paginated: createPaginatedRowModel(),
filteredRowModel: createFilteredRowModel(),
expandedRowModel: createExpandedRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down
4 changes: 2 additions & 2 deletions examples/react/row-selection/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function App() {
const table = useTable({
_features,
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
columns,
data,
Expand Down
6 changes: 3 additions & 3 deletions examples/react/sorting/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function App() {
sortingFns,
},
_rowModels: {
Sorted: createSortedRowModel(), // client-side sorting
sortedRowModel: createSortedRowModel(), // client-side sorting
},
columns,
data,
Expand Down Expand Up @@ -197,7 +197,7 @@ const rootElement = document.getElementById('root')
if (!rootElement) throw new Error('Failed to find the root element')

ReactDOM.createRoot(rootElement).render(
<React.StrictMode>
// <React.StrictMode>
<App />
</React.StrictMode>,
// </React.StrictMode>,
)
2 changes: 1 addition & 1 deletion examples/react/sub-components/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Table({
const table = useTable({
_features: { RowExpanding },
_rowModels: {
Expanded: createExpandedRowModel(),
expandedRowModel: createExpandedRowModel(),
},
columns,
data,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/virtualized-columns/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function App() {

const table = useTable({
_features: { ColumnSizing, RowSorting },
_rowModels: { Sorted: createSortedRowModel() },
_rowModels: { sortedRowModel: createSortedRowModel() },
columns,
data,
debugTable: true,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/virtualized-infinite-scrolling/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function App() {

const table = useTable({
_features: { ColumnSizing, RowSorting },
_rowModels: { Sorted: createSortedRowModel() },
_rowModels: { sortedRowModel: createSortedRowModel() },
data: flatData,
columns,
state: {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/virtualized-rows/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function App() {

const table = useTable({
_features: { ColumnSizing, RowSorting },
_rowModels: { Sorted: createSortedRowModel() },
_rowModels: { sortedRowModel: createSortedRowModel() },
columns,
data,
debugTable: true,
Expand Down
8 changes: 4 additions & 4 deletions examples/solid/filters/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ function App() {
const table = createTable({
_features,
_rowModels: {
Faceted: createFacetedRowModel(),
FacetedMinMax: createFacetedMinMaxValues(),
FacetedUnique: createFacetedUniqueValues(),
Filtered: createFilteredRowModel(),
facetedRowModel: createFacetedRowModel(),
facetedMinMaxValues: createFacetedMinMaxValues(),
facetedUniqueValues: createFacetedUniqueValues(),
filteredRowModel: createFilteredRowModel(),
},
get data() {
return data()
Expand Down
2 changes: 1 addition & 1 deletion examples/solid/sorting/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function App() {
const table = createTable({
_features,
_rowModels: {
Sorted: createSortedRowModel(),
sortedRowModel: createSortedRowModel(),
},
get data() {
return data()
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/column-pinning/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
const options: TableOptions<any, Person> = {
_features,
_rowModels: { Sorted: createSortedRowModel() },
_rowModels: { sortedRowModel: createSortedRowModel() },
get data() {
return data
},
Expand Down
4 changes: 2 additions & 2 deletions examples/svelte/filtering/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
const options: TableOptions<any, Person> = {
_features,
_rowModels: {
Filtered: createFilteredRowModel(),
Paginated: createPaginatedRowModel(),
filteredRowModel: createFilteredRowModel(),
paginatedRowModel: createPaginatedRowModel(),
},
data: makeData(25),
columns,
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/sorting/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
const options: TableOptions<typeof _features, Person> = {
_features,
_rowModels: {
Sorted: createSortedRowModel(),
sortedRowModel: createSortedRowModel(),
},
get data() {
return data
Expand Down
1 change: 0 additions & 1 deletion packages/react-table/src/tableHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { constructTableHelper } from '@tanstack/table-core'
import { useTable } from './useTable'
import type { ProcessingFns } from '../../table-core/dist/esm/types/ProcessingFns'
import type {
RowData,
Table,
Expand Down
Loading

0 comments on commit 889bfeb

Please sign in to comment.