Skip to content

Commit 9db02e2

Browse files
committed
Rest of the examples
1 parent 085d887 commit 9db02e2

6 files changed

Lines changed: 102 additions & 212 deletions

File tree

apps/virtuoso.dev/docs/guides/third-party-integration/react-beautiful-dnd.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

apps/virtuoso.dev/docs/guides/third-party-integration/tanstack-table-integration.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The following takes the [virtualized rows example of @tanstack/table](https://ta
1111

1212
```tsx live
1313
import {TableVirtuoso} from 'react-virtuoso'
14+
import {useReducer, useState} from 'react'
15+
import { flexRender, useReactTable, getCoreRowModel, getSortedRowModel } from '@tanstack/react-table'
1416

1517
function makeData(count) {
1618
return Array.from({length: count}, (_, index) => {
@@ -71,15 +73,15 @@ export default function App() {
7173
const [data, setData] = React.useState(() => makeData(500));
7274
const refreshData = () => setData(() => makeData(500));
7375

74-
const table = Tanstack.useReactTable({
76+
const table = useReactTable({
7577
data,
7678
columns,
7779
state: {
7880
sorting
7981
},
8082
onSortingChange: setSorting,
81-
getCoreRowModel: Tanstack.getCoreRowModel(),
82-
getSortedRowModel: Tanstack.getSortedRowModel()
83+
getCoreRowModel: getCoreRowModel(),
84+
getSortedRowModel: getSortedRowModel()
8385
});
8486

8587
const { rows } = table.getRowModel();
@@ -114,7 +116,7 @@ export default function App() {
114116
<tr {...props}>
115117
{row.getVisibleCells().map((cell) => (
116118
<td key={cell.id} style={{ padding: "6px" }}>
117-
{Tanstack.flexRender(cell.column.columnDef.cell, cell.getContext())}
119+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
118120
</td>
119121
))}
120122
</tr>
@@ -149,7 +151,7 @@ export default function App() {
149151
onClick: header.column.getToggleSortingHandler()
150152
}}
151153
>
152-
{Tanstack.flexRender(
154+
{flexRender(
153155
header.column.columnDef.header,
154156
header.getContext()
155157
)}

apps/virtuoso.dev/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"@docusaurus/types": "^3.2.1",
2626
"@emotion/react": "^11.11.4",
2727
"@emotion/styled": "^11.11.0",
28-
"@hello-pangea/dnd": "^16.6.0",
2928
"@mdx-js/react": "^3.0.0",
3029
"@mui/material": "^5.15.14",
3130
"@ngneat/falso": "^7.2.0",

apps/virtuoso.dev/src/theme/CodeBlock/LiveCodeBlock/index.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as _V from 'react-virtuoso';
77
import * as _ML from '@virtuoso.dev/message-list'
88
import * as _Falso from '@ngneat/falso'
99
import * as MUIStyles from '@mui/material/styles'
10+
import * as TanstackReactTable from "@tanstack/react-table";
1011
import List from "@mui/material/List";
1112
import ListSubheader from "@mui/material/ListSubheader";
1213
import ListItem from "@mui/material/ListItem";
@@ -44,9 +45,11 @@ import falsoDtsCode from '!!raw-loader!../../../../../../node_modules/@ngneat/fa
4445
import { createSandbox } from './createCodesandbox';
4546

4647
import copy from 'copy-text-to-clipboard';
48+
4749
import ErrorBoundary from '@docusaurus/ErrorBoundary';
4850

4951
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
52+
5053
import { CacheProvider } from '@emotion/react';
5154

5255

@@ -69,9 +72,18 @@ const IMPORT_MAP = {
6972
'@mui/material/TableHead': TableHead,
7073
'@mui/material/TableRow': TableRow,
7174
'@mui/material/Paper': Paper,
72-
'@mui/material/styles': MUIStyles
75+
'@mui/material/styles': MUIStyles,
76+
'@tanstack/react-table': TanstackReactTable
7377
};
7478

79+
80+
const tanstackReactTableDtsCode = `
81+
export declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): any;
82+
export declare function useReactTable<TData extends RowData>(options: TableOptions<TData>): any;
83+
export declare function getCoreRowModel(): any;
84+
export declare function getSortedRowModel(): any;
85+
`
86+
7587
const genericDefaultIsAnyDtsCode = `declare const _default: any;
7688
export default _default;`
7789

@@ -126,6 +138,10 @@ monaco.languages.typescript.typescriptDefaults.setExtraLibs([
126138
content: (falsoDtsCode as any) as string,
127139
filePath: 'file:///node_modules/@types/ngneat__falso/index.d.ts',
128140
},
141+
{
142+
content: (tanstackReactTableDtsCode as any) as string,
143+
filePath: 'file:///node_modules/@types/tanstack__react-table/index.d.ts',
144+
},
129145
{
130146
content: (messageListDtsCode as any) as string,
131147
filePath: 'file:///node_modules/@types/virtuoso.dev__message-list/index.d.ts',

0 commit comments

Comments
 (0)