{"id":13751940,"url":"https://github.com/davidalekna/use-table-tools","last_synced_at":"2025-05-09T18:33:02.710Z","repository":{"id":38434229,"uuid":"145391518","full_name":"davidalekna/use-table-tools","owner":"davidalekna","description":"React Hooks for building kickass react table components","archived":false,"fork":false,"pushed_at":"2023-01-07T18:45:57.000Z","size":19179,"stargazers_count":18,"open_issues_count":37,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-01T02:01:58.032Z","etag":null,"topics":["checkboxes","grid","hooks","react","responsive","table","tools","utils-library"],"latest_commit_sha":null,"homepage":"","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/davidalekna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-20T08:51:08.000Z","updated_at":"2024-05-19T05:51:22.000Z","dependencies_parsed_at":"2023-02-07T21:16:55.348Z","dependency_job_id":null,"html_url":"https://github.com/davidalekna/use-table-tools","commit_stats":null,"previous_names":["davidalekna/react-data-browser"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidalekna%2Fuse-table-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidalekna%2Fuse-table-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidalekna%2Fuse-table-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidalekna%2Fuse-table-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidalekna","download_url":"https://codeload.github.com/davidalekna/use-table-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253303197,"owners_count":21886905,"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":["checkboxes","grid","hooks","react","responsive","table","tools","utils-library"],"created_at":"2024-08-03T09:00:57.351Z","updated_at":"2025-05-09T18:32:57.681Z","avatar_url":"https://github.com/davidalekna.png","language":"TypeScript","funding_links":[],"categories":["*.js"],"sub_categories":["React"],"readme":"\u003ch1 align=\"center\"\u003e\n  use-table-tools \n\u003c/h1\u003e\n\u003cp align=\"center\" style=\"font-size: 1.2rem;\"\u003eReact Hooks for building kickass react table components\u003c/p\u003e\n\n[![Build Status][build-badge]][build]\n[![MIT License][license-badge]][license]\n[![PRs Welcome][prs-badge]][prs]\n[![gzip size][gzip-badge]][unpkg-lib]\n\n\u003c!-- [![Code Coverage][coverage-badge]][coverage] --\u003e\n\n## Introduction\n\nuse-table-tools is a React Hooks library for building kickass react table components.\n\nIt features:\n\n- flexbox table with adjustable column configuration\n- checkboxes with multi select\n- client side sorting\n- shifting columns into or off view\n- number of visible columns per screen resolution\n\n![Example gif video](docs/video-example.gif)\n\n## Quick Start\n\n```jsx\nimport { useTableTools } from 'use-table-tools';\n\nfunction Table() {\n  const { ...utils } = useTableTools({\n    layout: [''],\n    columns: [],\n    totalItems: 0,\n  });\n\n  return \u003cdiv\u003ehello from table component\u003c/div\u003e;\n}\n```\n\n## Usage\n\n\u003c!-- \u003e [Try it out in the browser](https://codesandbox.io/s/github/davidalekna/data-browser-examples) --\u003e\n\nInside your React project directory, run the following:\n\n```\nyarn add use-table-tools\n```\n\nor with npm\n\n```\nnpm install use-table-tools\n```\n\n## API\n\n### Parameters\n\n- `layout?: { [key: number]: string[] } | string[]`: layout of the table. Can be a string of flex props per column `['0 0 25%', '1 1 35%', '0 0 20%', '0 0 20%']` or an object with flex props per breakpoint where the key is a breakpoint and the value is a flex props per column.\n\n```js\nconst layout = {\n  280: ['0 0 100%'],\n  348: ['0 0 50%', '0 0 50%'],\n  768: ['0 0 35%', '1 1 35%', '0 0 30%'],\n  1280: ['0 0 25%', '1 1 35%', '0 0 20%', '0 0 20%'],\n};\n```\n\n- `columns: ColumnProps[]`: define a shape of your data by providing what items should exist on the table component. It will accept and array of objects with the `label`, `fieldKey` and `locked` properties. Where `fieldKey` is the key name on you data object, rest is props for the table tools\n- `totalItems: number`: total items per page, required for the checkboxes to determin the state when all items selected\n- `clientSortBy?: SortProps`: initial client sort for the table\n- `checkedItems?: string[]`: initialize with already checked items\n\n### Return Values\n\n- `switchColumns: (from: string, to: string) =\u003e void`: provide colums keys from `sortKey` to `sortKey` and they will get replaced\n- `switchCurrentLayout: (currentLayout: string[]) =\u003e void`: will switch current layout to the given one and will update visible and offset columns. Also used to automatically adjust if layout has breakpoints defined.\n- `offsetColumns: (obj?: { includeVisible: boolean }) =\u003e ColumnProps[]`: shows offset columns with the ability to include visible ones as well\n- `onSelection: (items: string[]) =\u003e void`: should be applied to master checkbox input `onClick` action with visible item ids.\n- `deselectAll: () =\u003e void`: clears the state of selected item ids\n- `selectAll: (checkedItems: string[]) =\u003e void`: selects all items\n- `checkboxToggle: (evt: ChangeEvent\u003cHTMLInputElement\u003e) =\u003e void`: toggles checkbox by id\n- `checkboxShiftToggle: (evt: ChangeEvent\u003cHTMLInputElement\u003e) =\u003e void`: toggles checkbox by id and selects/deselects a range when shift key is on\n- `checkboxState: (id: string) =\u003e boolean`: returns a boolean state for the checkbox by id\n- `clientSortMethod: (a: object, b: object) =\u003e number`: method to be used in a sort function, like ramda sort\n- `changeSortDirection: (direction: SortProps['direction']) =\u003e void`: change current sort direction by specifying next direction\n- `toggleSortDirection: () =\u003e void`: toggle current sort field direction\n- `toggleSortByKey: (fieldKey: string) =\u003e void`: toggle sort direction on a field key\n- `sortData: (sortProps: SortProps) =\u003e void`: sorts data by provided sortField and direction props\n- `activeSort: (sortProps: SortProps) =\u003e boolean`: checks the state of the current active sort by key and direction\n- `activeSortKey: (key: string) =\u003e boolean`: checks the state of the current active sort by key\n- `getCheckboxProps: ({...}) =\u003e CheckboxProps`: spread checkbox props on the checkbox input\n\n### Options\n\n## Global Configuration\n\nReact Context API\n\n```jsx\n\u003cTableTools\u003e{(utils) =\u003e \u003cdiv /\u003e}\u003c/TableTools\u003e\n```\n\n```jsx\nconst utils = useTableToolsContext();\n```\n\n## Examples\n\nIn progress...\n\n## LICENSE\n\nMIT\n\n[build-badge]: https://circleci.com/gh/davidalekna/use-table-tools/tree/master.svg?style=svg\n[build]: https://travis-ci.org/davidalekna/use-table-tools\n[coverage-badge]: https://codecov.io/gh/davidalekna/use-table-tools/branch/master/graph/badge.svg?style=flat-square\n[coverage]: https://codecov.io/gh/davidalekna/use-table-tools\n[license-badge]: https://img.shields.io/npm/l/downshift.svg?style=flat-square\n[license]: https://github.com/davidalekna/use-table-tools/blob/master/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square\n[coc]: https://github.com/davidalekna/use-table-tools/blob/master/CODE_OF_CONDUCT.md\n[react-badge]: https://img.shields.io/badge/%E2%9A%9B%EF%B8%8F-(p)react-00d8ff.svg?style=flat-square\n[react]: https://facebook.github.io/react/\n[gzip-badge]: http://img.badgesize.io/https://unpkg.com/downshift/dist/downshift.umd.min.js?compression=gzip\u0026label=gzip%20size\u0026style=flat-square\n[size-badge]: http://img.badgesize.io/https://unpkg.com/downshift/dist/downshift.umd.min.js?label=size\u0026style=flat-square\n[unpkg-lib]: https://unpkg.com/use-table-tools/lib/\n[use-a-render-prop]: https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidalekna%2Fuse-table-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidalekna%2Fuse-table-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidalekna%2Fuse-table-tools/lists"}