1.14.2 • Published 4 months ago

bik-utils v1.14.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

7502NPM-Bikiran-Utils

Dependencies

1.clsx 2.tailwind-merge 3.Nextjs

IMPORTANT NOTE

This package was specifically developed and tailored for our organization’s projects. It may not be particularly helpful for your needs, but you’re welcome to try it out. Just keep in mind that it could potentially break your project—or it might work exactly as intended.

🎨 Available Components

<Pagination  />
<FilterBarWrapper />
<ServicesPopup />
<ButtonWrapper />
<CurrencySelector />
<CustomSidebar/>
<PageLoading />
<LoadingComp  />
<CookiesAcceptPopup />
<ProfileManage />
<TooltipUserInfo />
<UserInfoComp />

Pagination

You need to write this code where you will use your pagination .This will Check query Params and create a new url . which is important for this component

const pathname = usePathname();
const searchParams = useSearchParams();
const currentPage = Number(searchParams.get("CurrentPage"));
const queries = new URLSearchParams(searchParams.toString());

// Make URL with existing queries if any
const mkUrl = (number: number) => {
  queries.set("CurrentPage", number.toString());
  return `${pathname}?${queries.toString()}`;
};

Props and Usage

Props

proptypedescriptiondefault valuepriority
dataTPaginationthis is an object{} as TPagination✅Required
disabledbooleandetermine is that pagination is disabled or notfalse❌Optional
currentPagenumberWhich page it is now0✅Required
mkUrl(page: number) => stringadd query params(page:number) => string✅Required
linkFC<{ href: string; children: React.ReactNode }Pass the link tag herenull✅Required

Usage

import { usePathname, useSearchParams } from "next/navigation";
import Link from "next/link";
import Pagination from "your-pagination-package";

const MyPagination = ({ data }) => {
  const pathname = usePathname();
  const searchParams = useSearchParams();
  const currentPage = Number(searchParams.get("CurrentPage")) || 1;

  const makeUrl = (num: number) => {
    const queries = new URLSearchParams(searchParams.toString());
    queries.set("CurrentPage", num.toString());
    return `${pathname}?${queries.toString()}`;
  };

  return (
    <Pagination
      data={data}
      currentPage={currentPage}
      makeUrl={makeUrl}
      LinkComponent={Link}
    />
  );
};

🔗 More Details

For more details, visit the GitHub repository.


🔗 License

This project is licensed under the MIT License.


👨‍💻 Author

Created by bikiran.com. Feel free to contribute!

1.14.1

4 months ago

1.14.0

4 months ago

1.14.2

4 months ago

1.13.2

4 months ago

1.13.6

4 months ago

1.13.5

4 months ago

1.13.4

4 months ago

1.13.3

4 months ago

1.13.9

4 months ago

1.13.8

4 months ago

1.13.7

4 months ago

1.12.3

5 months ago

1.13.1

5 months ago

1.12.2

5 months ago

1.13.0

5 months ago

1.12.7

5 months ago

1.12.6

5 months ago

1.12.5

5 months ago

1.12.4

5 months ago

1.12.9

5 months ago

1.12.8

5 months ago

1.11.4

5 months ago

1.11.3

5 months ago

1.12.1

5 months ago

1.11.2

5 months ago

1.12.0

5 months ago

1.11.1

5 months ago

1.11.8

5 months ago

1.10.9

5 months ago

1.11.7

5 months ago

1.10.8

5 months ago

1.11.6

5 months ago

1.10.7

5 months ago

1.11.5

5 months ago

1.11.9

5 months ago

1.11.10

5 months ago

1.11.0

5 months ago

1.10.6

5 months ago

1.10.5

5 months ago

1.10.4

5 months ago

1.10.3

5 months ago

1.10.2

5 months ago

1.10.1

5 months ago

1.10.0

5 months ago

1.9.3

5 months ago

1.9.2

5 months ago

1.9.1

5 months ago

1.9.0

5 months ago

1.8.1

5 months ago

1.8.0

5 months ago

1.7.0

5 months ago

1.6.0

5 months ago

1.5.0

5 months ago

1.4.0

5 months ago

1.3.0

5 months ago

1.2.0

5 months ago

1.1.0

5 months ago