Skip to content

Commit

Permalink
Fix Svelte Adapter (#5762)
Browse files Browse the repository at this point in the history
* fix svelte adapter and update examples

* fix svelte adapter and update examples

* remove console logs

---------

Co-authored-by: Kevin Van Cott <[email protected]>
  • Loading branch information
walker-tx and KevinVandy authored Sep 27, 2024
1 parent f1ba2f4 commit ccb937d
Show file tree
Hide file tree
Showing 18 changed files with 5,666 additions and 2,344 deletions.
2 changes: 1 addition & 1 deletion examples/svelte/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0-next",
"@tanstack/svelte-table": "^9.0.0-alpha.10",
"@tsconfig/svelte": "^5.0.4",
"svelte": "^5.0.0-next",
"svelte": "^5.0.0-next.260",
"svelte-check": "^3.8.4",
"typescript": "5.4.5",
"vite": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/column-groups/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0-next",
"@tanstack/svelte-table": "^9.0.0-alpha.10",
"@tsconfig/svelte": "^5.0.4",
"svelte": "^5.0.0-next",
"svelte": "5.0.0-next.260",
"svelte-check": "^3.8.4",
"typescript": "5.4.5",
"vite": "^5.3.2"
Expand Down
10 changes: 7 additions & 3 deletions examples/svelte/column-groups/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
FlexRender,
createCoreRowModel,
createTable,
tableFeatures,
tableOptions,
} from '@tanstack/svelte-table'
import './index.css'
Expand Down Expand Up @@ -44,7 +45,9 @@
},
]
const defaultColumns: ColumnDef<any, Person>[] = [
const _features = tableFeatures({})
const defaultColumns: ColumnDef<typeof _features, Person>[] = [
{
header: 'Name',
footer: (props) => props.column.id,
Expand Down Expand Up @@ -97,9 +100,10 @@
]
const options = tableOptions({
_features,
_rowModels: {},
data: defaultData,
columns: defaultColumns,
getCoreRowModel: createCoreRowModel(),
})
const table = createTable(options)
Expand All @@ -126,7 +130,7 @@
<tbody>
{#each table.getRowModel().rows as row}
<tr>
{#each row.getVisibleCells() as cell}
{#each row.getAllCells() as cell}
<td>
<FlexRender
content={cell.column.columnDef.cell}
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/column-ordering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0-next",
"@tanstack/svelte-table": "^9.0.0-alpha.10",
"@tsconfig/svelte": "^5.0.4",
"svelte": "^5.0.0-next",
"svelte": "5.0.0-next.260",
"svelte-check": "^3.8.4",
"typescript": "5.4.5",
"vite": "^5.3.2"
Expand Down
19 changes: 12 additions & 7 deletions examples/svelte/column-ordering/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
import type {
ColumnDef,
ColumnOrderState,
OnChangeFn,
TableOptions,
ColumnVisibilityState,
TableOptions,
} from '@tanstack/svelte-table'
import {
ColumnOrdering,
ColumnVisibility,
FlexRender,
createCoreRowModel,
createSortedRowModel,
createTable,
tableFeatures,
} from '@tanstack/svelte-table'
import './index.css'
import { makeData, type Person } from './makeData'
import { createTableState } from './state.svelte'
const _features = tableFeatures({
ColumnOrdering,
ColumnVisibility,
})
const columns: ColumnDef<any, Person>[] = [
{
header: 'Name',
Expand Down Expand Up @@ -75,7 +80,9 @@
const [columnVisibility, setColumnVisibility] =
createTableState<ColumnVisibilityState>({})
const options: TableOptions<any, Person> = {
const options: TableOptions<typeof _features, Person> = {
_features,
_rowModels: {},
get data() {
return data
},
Expand All @@ -90,8 +97,6 @@
},
onColumnOrderChange: setColumnOrder,
onColumnVisibilityChange: setColumnVisibility,
getCoreRowModel: createCoreRowModel(),
getSortedRowModel: createSortedRowModel(),
debugTable: true,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte/column-pinning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0-next",
"@tanstack/svelte-table": "^9.0.0-alpha.10",
"@tsconfig/svelte": "^5.0.4",
"svelte": "^5.0.0-next",
"svelte": "5.0.0-next.260",
"svelte-check": "^3.8.4",
"typescript": "5.4.5",
"vite": "^5.3.2"
Expand Down
Loading

0 comments on commit ccb937d

Please sign in to comment.