diff --git a/examples/lit/virtualized-rows/package.json b/examples/lit/virtualized-rows/package.json index 59541ed453..2d2d7aca77 100644 --- a/examples/lit/virtualized-rows/package.json +++ b/examples/lit/virtualized-rows/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@faker-js/faker": "^8.4.1", - "@lit-labs/virtualizer": "^2.0.13", "@tanstack/lit-table": "^8.19.2", + "@tanstack/lit-virtual": "^3.8.3", "lit": "^3.1.4" }, "devDependencies": { diff --git a/examples/lit/virtualized-rows/src/main.ts b/examples/lit/virtualized-rows/src/main.ts index a33c18b877..d11e3fd0dd 100644 --- a/examples/lit/virtualized-rows/src/main.ts +++ b/examples/lit/virtualized-rows/src/main.ts @@ -6,12 +6,14 @@ import { flexRender, getCoreRowModel, getSortedRowModel, + Row, TableController, } from '@tanstack/lit-table' -import config from '../twind.config' import { styleMap } from 'lit/directives/style-map.js' -import { virtualize, virtualizerRef } from '@lit-labs/virtualizer/virtualize.js' + import { makeData, Person } from './makeData.ts' +import { VirtualizerController } from '@tanstack/lit-virtual' +import { createRef, ref, Ref } from 'lit/directives/ref.js' const columns: ColumnDef[] = [ { @@ -61,6 +63,20 @@ const data = makeData(50_000) class LitTableExample extends LitElement { private tableController = new TableController(this) + private tableContainerRef: Ref = createRef() + + private rowVirtualizerController: VirtualizerController + + connectedCallback() { + this.rowVirtualizerController = new VirtualizerController(this, { + count: data.length, + getScrollElement: () => this.tableContainerRef.value!, + estimateSize: () => 33, + overscan: 5, + }) + super.connectedCallback() + } + protected render(): unknown { const table = this.tableController.table({ columns, @@ -69,11 +85,14 @@ class LitTableExample extends LitElement { getCoreRowModel: getCoreRowModel(), }) const { rows } = table.getRowModel() + + const virtualizer = this.rowVirtualizerController.getVirtualizer() return html`
(${data.length} rows)
=12'} + '@tanstack/lit-virtual@3.8.3': + resolution: {integrity: sha512-SONYxXVjK8G0ZL3XF1Byc/U0c3ZNKyzYzSr2y4IW58X55K7OrQrLvAjJb/p1ZVLcX1T6GVMoFA3zeFss1fRwXg==} + peerDependencies: + lit: ^3.1.0 + '@tanstack/query-core@5.49.0': resolution: {integrity: sha512-xUTjCPHC8G+ZvIUzjoMOLnMpNXYPQI4HjhlizTVVBwtSp24iWo4/kaBzHAzsrCVyfbiaPIFFkUvicsY4r8kF8A==} @@ -5220,6 +5222,9 @@ packages: '@tanstack/virtual-core@3.8.1': resolution: {integrity: sha512-uNtAwenT276M9QYCjTBoHZ8X3MUeCRoGK59zPi92hMIxdfS9AyHjkDWJ94WroDxnv48UE+hIeo21BU84jKc8aQ==} + '@tanstack/virtual-core@3.8.3': + resolution: {integrity: sha512-vd2A2TnM5lbnWZnHi9B+L2gPtkSeOtJOAw358JqokIH1+v2J7vUAzFVPwB/wrye12RFOurffXu33plm4uQ+JBQ==} + '@testing-library/dom@10.2.0': resolution: {integrity: sha512-CytIvb6tVOADRngTHGWNxH8LPgO/3hi/BdCEHOf7Qd2GvZVClhVP0Wo/QHzWhpki49Bk0b4VT6xpt3fx8HTSIw==} engines: {node: '>=18'} @@ -12418,11 +12423,6 @@ snapshots: '@lit-labs/ssr-dom-shim@1.2.0': {} - '@lit-labs/virtualizer@2.0.13': - dependencies: - lit: 3.1.4 - tslib: 2.6.3 - '@lit/reactive-element@2.0.4': dependencies: '@lit-labs/ssr-dom-shim': 1.2.0 @@ -13008,6 +13008,11 @@ snapshots: '@tanstack/history@1.41.0': {} + '@tanstack/lit-virtual@3.8.3(lit@3.1.4)': + dependencies: + '@tanstack/virtual-core': 3.8.3 + lit: 3.1.4 + '@tanstack/query-core@5.49.0': {} '@tanstack/react-query@5.49.0(react@18.3.1)': @@ -13077,6 +13082,8 @@ snapshots: '@tanstack/virtual-core@3.8.1': {} + '@tanstack/virtual-core@3.8.3': {} + '@testing-library/dom@10.2.0': dependencies: '@babel/code-frame': 7.24.7