{"id":13422016,"url":"https://github.com/makotot/paginated","last_synced_at":"2025-03-15T10:31:36.417Z","repository":{"id":47904893,"uuid":"329068558","full_name":"makotot/paginated","owner":"makotot","description":"⚛️ React render props component \u0026 custom hook for pagination.","archived":true,"fork":false,"pushed_at":"2021-08-14T16:26:36.000Z","size":959,"stargazers_count":22,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-27T22:30:10.956Z","etag":null,"topics":["component","headless-components","hooks","pagination","react","render-props"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@makotot/paginated","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/makotot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-12T17:56:33.000Z","updated_at":"2024-08-27T02:57:31.000Z","dependencies_parsed_at":"2022-09-13T03:01:58.374Z","dependency_job_id":null,"html_url":"https://github.com/makotot/paginated","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makotot%2Fpaginated","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makotot%2Fpaginated/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makotot%2Fpaginated/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makotot%2Fpaginated/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makotot","download_url":"https://codeload.github.com/makotot/paginated/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719097,"owners_count":20336591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","headless-components","hooks","pagination","react","render-props"],"created_at":"2024-07-30T23:00:35.596Z","updated_at":"2025-03-15T10:31:35.810Z","avatar_url":"https://github.com/makotot.png","language":"TypeScript","funding_links":[],"categories":["UI Components"],"sub_categories":["Paginator"],"readme":"# DEPRECATED - no longer actively maintained.\n\nPlease use [GhostUI](https://github.com/makotot/GhostUI) instead.\n\n# Paginated ![CI](https://github.com/makotot/paginated/workflows/CI/badge.svg?branch=master)\n\n![npm](https://img.shields.io/npm/v/@makotot/paginated?style=for-the-badge)\n![NPM](https://img.shields.io/npm/l/@makotot/paginated?style=for-the-badge)\n![npm bundle size](https://img.shields.io/bundlephobia/min/@makotot/paginated?style=for-the-badge)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/@makotot/paginated?style=for-the-badge)\n![GitHub contributors](https://img.shields.io/github/contributors/makotot/paginated?style=for-the-badge)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release)\n\n\u003e React render props \u0026 custom hook for pagination.\n\n## Features\n\n- **Headless component** -\n  There are no restrictions on the ui expression.\n- **Style free** - This lib only care about functionality of pagination.\n- **Tested with [RTL](https://github.com/testing-library/react-testing-library)**\n- **Small size** - https://bundlephobia.com/result?p=@makotot/paginated\n\n## Install\n\n```sh\nnpm i @makotot/paginated\n```\n\n## Example\n\n- [With Chakra UI](https://codesandbox.io/s/chakra-ui-gtwix)\n\n## Usage\n\n### Render Props\n\n```tsx\nimport { Paginated } from '@makotot/paginated'\n\n...\n\nreturn (\n  \u003cPaginated currentPage={1} totalPage={10} siblingsSize={2} boundarySize={2}\u003e\n    {({ pages, currentPage, hasPrev, hasNext, getFirstBoundary, getLastBoundary, isPrevTruncated, isNextTruncated }) =\u003e (\n      \u003cdiv\u003e\n        {hasPrev() \u0026\u0026 \u003ca href=\"#\"\u003eprev\u003c/a\u003e}\n        {getFirstBoundary().map(boundary =\u003e \u003ca href=\"#\" key={boundary}\u003e{boundary}\u003c/a\u003e)}\n        {isPrevTruncated \u0026\u0026 \u003cspan\u003e...\u003c/span\u003e}\n        {pages.map(page =\u003e {\n          return page === currentPage ? (\n            \u003cspan key={page}\u003e{page}\u003c/span\u003e\n          ) : (\n            \u003ca href=\"#\" key={page}\u003e{page}\u003c/a\u003e\n          );\n        })}\n        {isNextTruncated \u0026\u0026 \u003cspan\u003e...\u003c/span\u003e}\n        {getLastBoundary().map(boundary =\u003e \u003ca href=\"#\" key={boundary}\u003e{boundary}\u003c/a\u003e)}\n        {hasNext() \u0026\u0026 \u003ca href=\"#\"\u003enext\u003c/a\u003e}\n      \u003c/div\u003e\n    )}\n  \u003c/Paginated\u003e\n)\n```\n\n### Hooks\n\n```tsx\nimport { usePaginated } from '@makotot/paginated'\n\n...\n\nconst { pages, currentPage, hasPrev, hasNext, getFirstBoundary, getLastBoundary, isPrevTruncated, isNextTruncated } = usePaginated({ currentPage: 1, totalPage: 10, siblingsSize: 2, boundarySize: 2 });\n\nreturn (\n  \u003cdiv\u003e\n    {hasPrev() \u0026\u0026 \u003ca href=\"#\"\u003eprev\u003c/a\u003e}\n    {getFirstBoundary().map(boundary =\u003e \u003ca href=\"#\" key={boundary}\u003e{boundary}\u003c/a\u003e)}\n    {isPrevTruncated \u0026\u0026 \u003cspan\u003e...\u003c/span\u003e}\n    {pages.map(page =\u003e {\n      return page === currentPage ? (\n        \u003cspan key={page}\u003e{page}\u003c/span\u003e\n      ) : (\n        \u003ca href=\"#\" key={page}\u003e{page}\u003c/a\u003e\n      );\n    })}\n    {isNextTruncated \u0026\u0026 \u003cspan\u003e...\u003c/span\u003e}\n    {getLastBoundary().map(boundary =\u003e \u003ca href=\"#\" key={boundary}\u003e{boundary}\u003c/a\u003e)}\n    {hasNext() \u0026\u0026 \u003ca href=\"#\"\u003enext\u003c/a\u003e}\n  \u003c/div\u003e\n)\n```\n\n## Options\n\n### `currentPage`\n\nType: `number`\n\nThe value of current page. Required.\n\n### `totalPage`\n\nType: `number`\n\nThe value of total page. Required.\n\n### `siblingsSize`\n\nType: `number`\n\nThe items size of one side of the middle of pagination.\n\n### `boundarySize`\n\nType: `number`\n\nThe items size of one side of the edge of pagination.\n\n## Returns (Hooks) | Props (Render Props)\n\n### `pages`\n\nType: `number[]`\n\nThe page items of the middle of pagination.\n\n### `currentPage`\n\nType: `number`\n\nThe value of current page.\n\n### `hasPrev`\n\nType: `boolean`\n\nReturns `true` if previous page of the current page is exist.\n\n### `hasNext`\n\nType: `boolean`\n\nReturns `true` if next page of the current page is exist.\n\n### `getFirstBoundary`\n\nType: `() =\u003e number[]`\n\nReturns page items of first boundary.\n\n### `getLastBoundary`\n\nType: `() =\u003e number[]`\n\nReturns page items of last boundary.\n\n### `isPrevTruncated`\n\nType: `boolean`\n\nReturns `true` if pages before the current page is ellipsized.\n\n### `isNextTruncated`\n\nType: `boolean`\n\nReturns `true` if pages after the current page is ellipsized.\n\n## Authors\n\n- [makotot](https://github.com/makotot)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakotot%2Fpaginated","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakotot%2Fpaginated","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakotot%2Fpaginated/lists"}