Skip to content

Commit

Permalink
fix: broken types on the PaginationLink + bump tanstack/router (#423)
Browse files Browse the repository at this point in the history
* tanstack router

* tanstack router plugin

* fix: types on the pagination `<Link>`
  • Loading branch information
SeanCassiere authored Sep 26, 2024
1 parent 85d8577 commit 367a3d6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 60 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"@tanstack/query-broadcast-client-experimental": "^5.56.2",
"@tanstack/react-query": "^5.56.2",
"@tanstack/react-query-devtools": "^5.56.2",
"@tanstack/react-router": "^1.58.3",
"@tanstack/react-router": "^1.58.9",
"@tanstack/react-table": "^8.20.5",
"@tanstack/react-virtual": "^3.10.7",
"@tanstack/router-devtools": "^1.58.3",
"@tanstack/router-devtools": "^1.58.9",
"@ts-rest/core": "^3.51.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down Expand Up @@ -86,7 +86,7 @@
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"@tanstack/eslint-plugin-router": "^1.58.6",
"@tanstack/router-plugin": "^1.58.4",
"@tanstack/router-plugin": "^1.58.10",
"@types/node": "^22.5.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
Expand Down
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 6 additions & 40 deletions src/components/ui/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,12 @@ const PaginationItem = React.forwardRef<
));
PaginationItem.displayName = "PaginationItem";

type PaginationLinkProps<
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
> = Pick<ButtonProps, "size"> & { isActive?: boolean } & LinkProps<
TRouter,
TFrom,
TTo,
TMaskFrom,
TMaskTo
> &
type PaginationLinkProps = Pick<ButtonProps, "size"> & {
isActive?: boolean;
} & LinkProps &
LinkComponentProps<"a">;

const PaginationLink = <
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(
props: PaginationLinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
) => {
const PaginationLink = (props: PaginationLinkProps) => {
const { size, className, isActive = false, ...rest } = props;

return (
Expand Down Expand Up @@ -117,15 +99,7 @@ const PaginationButton = ({
);
PaginationButton.displayName = "PaginationButton";

const PaginationLinkPrevious = <
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(
props: PaginationLinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
) => {
const PaginationLinkPrevious = (props: PaginationLinkProps) => {
const { className, ...rest } = props;
return (
<PaginationLink
Expand Down Expand Up @@ -157,15 +131,7 @@ const PaginationButtonPrevious = ({
);
PaginationButtonPrevious.displayName = "PaginationButtonPrevious";

const PaginationLinkNext = <
TRouter extends AnyRouter = RegisteredRouter,
TFrom extends RoutePaths<TRouter["routeTree"]> | string = string,
TTo extends string = "",
TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom,
TMaskTo extends string = "",
>(
props: PaginationLinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
) => {
const PaginationLinkNext = (props: PaginationLinkProps) => {
const { className, ...rest } = props;
return (
<PaginationLink
Expand Down

0 comments on commit 367a3d6

Please sign in to comment.