diff --git a/examples/vue/virtualized-rows/src/App.vue b/examples/vue/virtualized-rows/src/App.vue index 557dad3f6b..8333e3762c 100644 --- a/examples/vue/virtualized-rows/src/App.vue +++ b/examples/vue/virtualized-rows/src/App.vue @@ -2,11 +2,11 @@ import './index.css' import { computed, ref, h } from 'vue' import { - type ColumnDef, - FlexRender, - useVueTable, - getCoreRowModel, - getSortedRowModel, + type ColumnDef, + FlexRender, + useVueTable, + getCoreRowModel, + getSortedRowModel, } from '@tanstack/vue-table' import { useVirtualizer } from '@tanstack/vue-virtual' @@ -17,94 +17,93 @@ const search = ref('') const data = ref(makeData(50_000)) const filteredData = computed(() => { - const searchValue = search.value.toLowerCase(); - - // If no search value is present, return all data - if (!searchValue) return data.value; - - return data.value.filter(row => { - return Object.values(row).some(value => { - if (value instanceof Date) { - return value.toLocaleString().toLowerCase().includes(searchValue); - } - // Stringify the value and check if it contains the search term - return `${value}`.toLowerCase().includes(searchValue); - }); - }); -}); + const searchValue = search.value.toLowerCase() + + // If no search value is present, return all data + if (!searchValue) return data.value + + return data.value.filter(row => { + return Object.values(row).some(value => { + if (value instanceof Date) { + return value.toLocaleString().toLowerCase().includes(searchValue) + } + // Stringify the value and check if it contains the search term + return `${value}`.toLowerCase().includes(searchValue) + }) + }) +}) let searchTimeout: NodeJS.Timeout function handleDebounceSearch(ev: Event) { - if (searchTimeout) { clearTimeout(searchTimeout) } + if (searchTimeout) { + clearTimeout(searchTimeout) + } - searchTimeout = setTimeout(() => { - search.value = (ev?.target as HTMLInputElement)?.value ?? '' - }, 300) + searchTimeout = setTimeout(() => { + search.value = (ev?.target as HTMLInputElement)?.value ?? '' + }, 300) } const columns = computed[]>(() => [ - { - accessorKey: 'id', - header: 'ID', - }, - { - accessorKey: 'firstName', - cell: info => info.getValue(), - }, - { - accessorFn: row => row.lastName, - id: 'lastName', - cell: info => info.getValue(), - header: () => h('span', 'Last Name'), - }, - { - accessorKey: 'age', - header: () => 'Age', - }, - { - accessorKey: 'visits', - header: () => h('span', 'Visits'), - }, - { - accessorKey: 'status', - header: 'Status', - }, - { - accessorKey: 'progress', - header: 'Profile Progress', - }, - { - accessorKey: 'createdAt', - header: 'Created At', - cell: info => info.getValue().toLocaleString(), - }, + { + accessorKey: 'id', + header: 'ID', + }, + { + accessorKey: 'firstName', + cell: info => info.getValue(), + }, + { + accessorFn: row => row.lastName, + id: 'lastName', + cell: info => info.getValue(), + header: () => h('span', 'Last Name'), + }, + { + accessorKey: 'age', + header: () => 'Age', + }, + { + accessorKey: 'visits', + header: () => h('span', 'Visits'), + }, + { + accessorKey: 'status', + header: 'Status', + }, + { + accessorKey: 'progress', + header: 'Profile Progress', + }, + { + accessorKey: 'createdAt', + header: 'Created At', + cell: info => info.getValue().toLocaleString(), + }, ]) - const table = useVueTable({ - get data() { - return filteredData.value - }, - columns: columns.value, - getCoreRowModel: getCoreRowModel(), - getSortedRowModel: getSortedRowModel(), - debugTable: false, + get data() { + return filteredData.value + }, + columns: columns.value, + getCoreRowModel: getCoreRowModel(), + getSortedRowModel: getSortedRowModel(), + debugTable: false, }) - const rows = computed(() => table.getRowModel().rows) //The virtualizer needs to know the scrollable container element const tableContainerRef = ref(null) - const rowVirtualizerOptions = computed(() => { - return { - count: rows.value.length, - estimateSize: () => 33, //estimate row height for accurate scrollbar dragging - getScrollElement: () => tableContainerRef.value, - overscan: 5, - } + return { + count: rows.value.length, + estimateSize: () => 33, //estimate row height for accurate scrollbar dragging + getScrollElement: () => tableContainerRef.value, + overscan: 5, + } }) const rowVirtualizer = useVirtualizer(rowVirtualizerOptions) @@ -113,114 +112,119 @@ const virtualRows = computed(() => rowVirtualizer.value.getVirtualItems()) const totalSize = computed(() => rowVirtualizer.value.getTotalSize()) function measureElement(el?: Element) { - if (!el) { - return - } + if (!el) { + return + } - rowVirtualizer.value.measureElement(el) + rowVirtualizer.value.measureElement(el) - return undefined + return undefined } - diff --git a/examples/vue/virtualized-rows/src/index.css b/examples/vue/virtualized-rows/src/index.css index 810f0942b9..f243855583 100644 --- a/examples/vue/virtualized-rows/src/index.css +++ b/examples/vue/virtualized-rows/src/index.css @@ -40,9 +40,9 @@ td { .select-none { -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } .text-left {