-
-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Switch to TanStack Table #1260
Conversation
|
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
…header to indeterminate, otherwise, checked or not)
Nice! I started working on this in parallel but you beat me to it. My solution is very close to what you have. Generics should technically be straightforward. Here's what works for me.
One could think about pulling the column definition out of the components. This is what I ended up doing. EDIT: I'm actually working on this using |
Hey, @kaechele It's my first time working with TanStack-anything, so glad I wasn't far off with how others are doing it. 😅
Yup. This is what I was doing, but when it came to passing props in the column defs, weird errors came up. Which leads me to:
Sure. I could look into this. Thanks.
Hmm... can I trouble you with a snippet of this? Can't get my head around what you mean, yet.
I'm actually wondering if I should just wait for Svelte 5 as well. I guess I'm doing it now in case it's easier when migrating to S5. 🤷 |
In the TanStack docs they recommend using column helpers for building column definitions which are quite similar to the API from svelte-headless-table. I believe the rationale is that they provide a higher type safety. |
Ah. Thanks a lot, @c-kirkeby Will change this in a few. |
Before I commit my interpretation of this:
Did you mean doing something like this: header.svelte type $$Props = HTMLAttributes<HTMLDivElement> & {
title: string;
canSort: boolean;
isSorted: boolean | 'asc' | 'desc' | boolean;
toggleSorting: (desc?: boolean, isMulti?: boolean) => void;
toggleVisibility: (v: boolean) => void;
}; and in columns.ts columnHelper.accessor('id', {
id: 'task',
header: ({ column }) => {
return renderComponent(ColumnHeader, {
title: 'Task',
canSort: column.getCanSort(),
isSorted: column.getIsSorted(),
toggleSorting: column.toggleSorting,
toggleVisibility: column.toggleVisibility
});
},
enableSorting: false,
enableHiding: false
}), |
Yes, this is partially what I had in mind. The other part, I just saw, you already had in your initial PR submission. Namely the creation of Not that it would be necessary for this example app, since it's pretty specific and self-contained. But that's how I would handle it in an application where I keep my data table more generic. I feel this may make the documentation a bit more useful. |
Closing as this has been shipped in the |
Closes: #1189
I wonder if we should wait for the Svelte 5 version, though? If that's the case, happy to close this and wait for it. 🙂
TODO:
Tasks
exampleonRowSelectionChange
,onSortingChange
,onColumnFiltersChange
,onColumnVisibilityChange
), preferably to separate function definitionschecked
isn't reacting to changes totable.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && 'indeterminate')
. Will keep investigating.Task
type instead./tasks-2
route to/tasks
cmd+p
is the way to go), but you know, 🤷 I can revert to the old way, though 🙂Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.pnpm format
andpnpm lint