Compare commits

..
602 Commits
Author SHA1 Message Date
Tanner Linsley b3771502f8 v7.0.0-rc.11 2019-12-17 20:50:59 -07:00
Tanner Linsley 0df8cc5088 Update useFlexLayout.md 2019-12-17 20:46:03 -07:00
Tanner Linsley 7cebab7fb6 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-17 20:44:48 -07:00
Tanner Linsley 717ea7b211 Update Docs 2019-12-17 20:44:33 -07:00
size-plugin[bot]andGitHub 823d93946b 💁🏿‍♂️ 🚵‍♂️ update sizes-es.json 👍 2019-12-18 03:43:47 +00:00
size-plugin[bot]andGitHub b01749c5c7 🕴️ 🍀 update sizes-cjs.json 👍 2019-12-18 03:43:46 +00:00
Tanner Linsley b48cddb92b Add back useFlexLayout and full-width-resizable-table example 2019-12-17 20:41:28 -07:00
Tanner Linsley f48ef14975 Fix reset to use initial state, then fall back to default state 2019-12-17 20:40:34 -07:00
Tanner Linsley eeee14830d Update Changelog 2019-12-17 19:32:07 -07:00
Tanner Linsley f2776d0005 Fix getcolumnsHooks 2019-12-17 19:31:50 -07:00
Tanner Linsley ee18cf4b89 Add streaming rows snapshot 2019-12-17 19:31:09 -07:00
Chris NorwoodandTanner Linsley 632ea28c4b Update to use React.Fragment spread with row props (#1781) 2019-12-13 18:08:01 -07:00
Tanner LinsleyandGitHub 506a22062e Update README.md 2019-12-13 13:52:59 -07:00
size-plugin[bot]andGitHub 9e81e44da3 ☺️ 👨🏿‍🦳 update sizes-es.json 👍 2019-12-13 08:02:58 +00:00
size-plugin[bot]andGitHub acd6ac5d14 🤹🏽 🏋🏾 update sizes-es.json 👍 2019-12-13 08:00:27 +00:00
size-plugin[bot]andGitHub 78634585e7 🍒 👨🏼‍🍳 update sizes-es.json 👍 2019-12-13 07:55:23 +00:00
Tanner Linsley c8d2180e5b Create sandbox.config.json 2019-12-13 00:52:32 -07:00
Tanner Linsley 0575c1b36d Update examples.md 2019-12-13 00:50:11 -07:00
Tanner Linsley 96a185af59 v7.0.0-rc.10 2019-12-13 00:45:01 -07:00
Tanner Linsley 8c5f5084d2 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-13 00:44:18 -07:00
Tanner Linsley bca95b0928 Fix selection examples 2019-12-13 00:43:54 -07:00
Tanner Linsley 4143208334 Fix prefilteredRows 2019-12-13 00:41:10 -07:00
size-plugin[bot]andGitHub a3fb80fb81 🧝🏻 👷🏽‍♀️ update sizes-es.json 👍 2019-12-13 07:28:24 +00:00
size-plugin[bot]andGitHub 77f7eb689d 🇲🇩 🐏 update sizes-cjs.json 👍 2019-12-13 07:28:23 +00:00
Tanner Linsley d421cb52c5 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-13 00:26:06 -07:00
Tanner Linsley 81dcfd8dec Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-13 00:25:27 -07:00
Tanner Linsley 9fa1396f26 Mucho updates 2019-12-13 00:22:30 -07:00
Jason LawandTanner Linsley 0de4f69f14 Fix useRowSelect shouldExist (#1774) 2019-12-13 00:16:30 -07:00
size-plugin[bot]andGitHub dafd1a1972 😵 📆 update sizes-cjs.json 👍 2019-12-12 15:55:20 +00:00
size-plugin[bot]andGitHub cd5f7e6968 👩🏼‍🎓 👸🏼 update sizes-es.json 👍 2019-12-12 15:55:19 +00:00
Peng XiaoandTanner Linsley 32ae1a52e4 fix: render components should include memo/forwardRef (#1764) 2019-12-12 08:51:37 -07:00
Yarin BenadoandTanner Linsley 1509fc0438 Rename manualSorting to manualSortBy to reflect API changes (#1770) 2019-12-12 08:50:05 -07:00
Tanner LinsleyandGitHub 048f118279 Update README.md 2019-12-11 16:31:33 -07:00
Tanner LinsleyandGitHub e661d90d48 Update README.md 2019-12-11 15:43:57 -07:00
size-plugin[bot]andGitHub a9c04ca3dc 🩳 👨🏼 update sizes-es.json 👍 2019-12-11 06:08:38 +00:00
size-plugin[bot]andGitHub 1f18260a70 ✉️ 🇧🇫 update sizes-cjs.json 👍 2019-12-11 06:08:37 +00:00
Tanner Linsley 3109ca4d37 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-10 23:06:52 -07:00
Tanner Linsley b517ee13d5 v7.0.0-rc.9 2019-12-10 23:05:57 -07:00
Tanner Linsley ddfa0fa227 Death of the path, fix some hooks, fix selectedRows
- Fixed an issue where dependency hooks were not being reduced properly, thus the table would rerender unnecessarily
- Renamed `toggleRowSelectedAll` to `toggleAllRowsSelected`. Duh...
- Added an `indeterminate` boolean prop to the default props for row selection toggle prop getters
- Renamed `selectedRowPaths` to `selectedRowIds`, which also no longer contains paths, but row IDs
- Grouped or nested row selection actions and state are now derived, instead of tracked in state.
- Rows now have a new property called `id`, which existed before and was derived from the `getRowId` option
- Rows now also have an `isSomeSelected` prop when using the `useRowSelect` hook, which denotes that at least one subRow is selected (if applicable)
- Rows' `path` property has been deprecated in favor of `id`
- Expanded state is now tracked with row IDs instead of paths
- RowState is now tracked with row IDs instead of paths
- `toggleExpandedByPath` has been renamed to `toggleExpandedById`, and thus accepts a row ID now, instead of a row path
2019-12-10 23:04:34 -07:00
size-plugin[bot]andGitHub 63c6a56e38 🇪🇸 🏄🏾‍♀️ update sizes-es.json 👍 2019-12-10 23:36:27 +00:00
size-plugin[bot]andGitHub 213caf6544 👦 📎 update sizes-cjs.json 👍 2019-12-10 23:36:25 +00:00
Tanner Linsley 42b78d52ca v7.0.0-rc.8 2019-12-10 16:35:19 -07:00
Tanner Linsley 68fd89af3c Fix props clobbering
Fixes #1755
2019-12-10 16:34:23 -07:00
Tanner Linsley 0c43e19091 Fix useResizeColumns bug 2019-12-10 14:58:31 -07:00
size-plugin[bot]andGitHub 08bb50ae48 🧑🏻‍🤝‍🧑🏻 🔔 update sizes-es.json 👍 2019-12-10 19:44:09 +00:00
size-plugin[bot]andGitHub 0fcc9e608c 🇰🇪 🍐 update sizes-cjs.json 👍 2019-12-10 19:44:08 +00:00
Tanner Linsley 15125f9326 Update useColumnVisibility.js 2019-12-10 12:42:19 -07:00
Tanner Linsley b8701f260a Update CHANGELOG.md 2019-12-10 12:33:44 -07:00
Tanner Linsley 70bdd272e5 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-10 11:59:39 -07:00
size-plugin[bot]andGitHub 5ad648d9da 🇧🇸 👮🏽‍♂️ update sizes-es.json 👍 2019-12-10 18:58:59 +00:00
size-plugin[bot]andGitHub 117dc54439 💻 🙍🏾‍♀️ update sizes-cjs.json 👍 2019-12-10 18:58:58 +00:00
Tanner Linsley d8f0174d80 v7.0.0-rc.7 2019-12-10 11:57:54 -07:00
Tanner Linsley cf9517fe7a Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-10 11:57:21 -07:00
Tanner Linsley e1fd921f07 Add useFinalInstance plugin hook 2019-12-10 11:56:41 -07:00
dependabot[bot]andTanner Linsley 7222c1cb2b Bump eslint-utils from 1.4.0 to 1.4.3 in /examples/row-selection (#1754)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-10 11:51:39 -07:00
size-plugin[bot]andGitHub e984934e92 👩🏽‍⚖️ 🕵🏾‍♀️ update sizes-es.json 👍 2019-12-10 18:44:23 +00:00
size-plugin[bot]andGitHub 938bdd9885 🧏🏾 ✡️ update sizes-cjs.json 👍 2019-12-10 18:44:22 +00:00
Tanner Linsley 88a0d86d60 Update .size-snapshot.json 2019-12-10 11:42:31 -07:00
Tanner Linsley 690190081f Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-10 11:37:07 -07:00
Tanner Linsley 4a3311035d Added/updated hooks reorganization of hooks, new hook rules
- The exported (but undocumented) `applyHooks` function has been deprecated. Please use either `reduceHooks` or `loopHooks` utilities in your custom plugins now.
- The exported (but undocumented) `applyPropHooks` function has been deprecated. Please use the `makePropGetter` utility in your custom plugins now.
- Added the `reduceHooks` exported utility which is used to reduce a value through a collection of hooks. Each hook must return a value (mutation is discouraged)
- Added the `loopHooks` exported utility which is used to loop over a collection of hooks. Hooks are not allowed to return a value (mutation is encouraged)
- Prop-getter hook functions now support returning an array (in addition to the typical object of props). When an array is returned, each item in the array is smart-merged into a new props object (meaning it will intelligently compose and override styles and className)
- Added the `makePropGetter` exported utility which is used to create prop getters from a prop getter hook.
- Prop-getter function supplied to the table have 2 new overloaded options (in addition to the typical object of props):
  - `Function(props, instance, ...row/col/context) => Array<props> | props` - If a function is passed to a prop getter function, it will receive the previous props, the table instance, and potentially more context arguments. It is then be expected to return either an array of new props (to be smart-merged with styles and classes, the latest values taking priority over the previous values) or a props object (which will replace all previous props)
  - `Array<props>` - If an array is passed to a prop getter function, each prop object in the array will be smart-merged with styles and classes into the props from previous hooks (with the latest values taking priority over the previous values).
- Extracted default hooks into separate file.
- Added the `useOptions` plugin hook, which allows a plugin to reduce/modify the initial options being passed to the table
- Converted almost all usages of `instanceRef.current` to use `useGetLatest(instanceRef.current)` to help with avoiding memory leaks and to be more terse.
- Converted all previous prop-getter definitions to use the new `makePropGetter`
- Reorganized plugin hooks to declare as many hooks in the main plugin function as opposed to in the `useInstance` hook.
- Changed the `useInstanceBeforeDimensions` hook to be a `loopHooks` call instead of a reducer. An error will be thrown now if any of these hook functions returns a value (to discourage mutation of the instance)
- Changed the `useInstance` hook to be a `loopHooks` call instead of a reducer. An error will be thrown now if any of these hook functions returns a value (to discourage mutation of the instance)
- Change the `prepareRow` hook to be a `loopHooks` call instead of a reducer. An error will be thrown now if any of these hook functions returns a value (to discourage mutation of the row)
2019-12-10 11:35:05 -07:00
size-plugin[bot]andGitHub a73ee145b3 💍 ️ update sizes-cjs.json 👍 2019-12-10 13:42:08 +00:00
size-plugin[bot]andGitHub b0d2044e22 🤫 💪🏻 update sizes-es.json 👍 2019-12-10 13:42:07 +00:00
Jakob Hjelmer NielsenandTanner Linsley ccc89379da .add touch events to useResizeColumns (#1748)
.add onTouchStart to mergeProps
.add touch-action css to resizer
.mod increase resizer width or it is very hard to activate using touch devices
2019-12-10 06:39:02 -07:00
Tanner Linsley 9563dae006 Update README.md 2019-12-09 10:51:07 -07:00
Tanner Linsley d35d190708 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-09 10:51:05 -07:00
Tanner Linsley 614f40f47d Fix controlled pagination example 2019-12-09 10:12:36 -07:00
size-plugin[bot]andGitHub 5846c86605 👨‍💻 🛹 update sizes-es.json 👍 2019-12-09 17:02:19 +00:00
size-plugin[bot]andGitHub c5fb154d9b ⛹🏻‍♂️ 🏋🏼‍♀️ update sizes-cjs.json 👍 2019-12-09 17:02:18 +00:00
Tanner Linsley 5e6952db93 v7.0.0-rc.6 2019-12-09 09:53:29 -07:00
Tanner Linsley ac43ef2e38 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-09 09:52:50 -07:00
Tanner Linsley 9de699bfd3 Add/rename a few hooks, fix useColumnVisibility header deps
- The `columnsBeforeHeaderGroups` and `columnsBeforeHeaderGroupsDeps` hooks have been renamed to `flatColumns` and `flatColumnsDeps` respectively, which better reflects what they are used for, rather than their order, which can remain implicit.
- Added `headerGroups` and `headerGroupDeps` hooks, which, similar to `flatColumns`, allow you to decorate (and trigger) the memoized header group generation.
- Added `columns` and `columnsDeps` hooks, which, similar to `flatColumns` and `headerGroups`, allow you to decorate (and trigger) the memoized column generation/decoration.
- The new hook order is as follows: `columns/columnsDeps` => `flatColumns/flatColumnsDeps` => `headerGroups/headerGroupsDeps`
- `useColumnVisibility` now uses the new `headerGroupsDeps` hook to trigger header group regeneration when visibility changes
2019-12-09 09:52:27 -07:00
size-plugin[bot]andGitHub 38d82a0397 📘 🍫 update sizes-es.json 👍 2019-12-09 02:40:17 +00:00
size-plugin[bot]andGitHub 863bf50206 🍊 👨🏾‍🎨 update sizes-cjs.json 👍 2019-12-09 02:40:16 +00:00
Tanner Linsley 492ba8a4f9 Update Changelog 2019-12-08 19:35:55 -07:00
Tanner Linsley e0ad323bd8 v7.0.0-rc.5 2019-12-08 19:32:45 -07:00
Tanner Linsley c1e4fb8956 v7.0.0-rc.4 2019-12-08 19:26:49 -07:00
Bart NagelandTanner Linsley 1ac1d99f23 Fix link in documentation (#1733) 2019-12-06 21:51:34 -07:00
size-plugin[bot]andGitHub e5b991751a 🏊🏿‍♂️ 🧜🏻‍♂️ update sizes-cjs.json 👍 2019-12-07 03:49:50 +00:00
Bart NagelandTanner Linsley 8dc6559e64 Fix row.toggleExpanded(bool) (#1732)
The wrong variable was being checked against `undefined`, so the row was
always being toggled, rather than taking the parameter into account.
2019-12-06 20:39:45 -07:00
dependabot[bot]andTanner Linsley 2955335df1 Bump eslint-utils from 1.4.0 to 1.4.3 in /examples/grouping (#1730)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-06 16:42:41 -07:00
Tanner Linsley 8c090a734b Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-06 16:36:50 -07:00
Tanner Linsley 439ebad063 Update faq.md 2019-12-06 16:36:17 -07:00
size-plugin[bot]andGitHub 2ef6e13657 🧎🏼 🤳🏽 update sizes-es.json 👍 2019-12-06 23:35:30 +00:00
size-plugin[bot]andGitHub 6338b32bd8 🧝🏽‍♂️ 🇲🇦 update sizes-cjs.json 👍 2019-12-06 23:35:29 +00:00
Tanner Linsley 67544d33ff v7.0.0-rc.3 2019-12-06 16:33:41 -07:00
Tanner Linsley 3fa2cdf388 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-06 16:30:42 -07:00
Tanner Linsley 562a2feaef v7.0.0-rc.2 2019-12-06 16:30:08 -07:00
AlbericoandTanner Linsley 176986a07a docs(docs/api/readme.md): fix to useTable link that was giving 404 (#1726)
In the /docs/api/README.md the useTable link was linking to the file ./usetable.md that doesn't
exist, now it links to ./useTable
2019-12-06 10:25:15 -05:00
size-plugin[bot]andGitHub f824fea2ef 🙍🏿 ♟️ update sizes-es.json 👍 2019-12-06 08:21:02 +00:00
size-plugin[bot]andGitHub ace8f56371 🇦🇪 💨 update sizes-cjs.json 👍 2019-12-06 08:21:01 +00:00
gargrohandTanner Linsley 3d5249b716 [useSortBy] updating missed key rename (#1724) 2019-12-06 03:19:28 -05:00
ggascoigneandTanner Linsley 546cb4e076 put useFilters docs in correct file (#1723) 2019-12-06 01:18:48 -05:00
size-plugin[bot]andGitHub d1677dfebb 🇻🇨 🤰🏻 update sizes-es.json 👍 2019-12-06 04:37:44 +00:00
size-plugin[bot]andGitHub 4868d7835f 😖 💇🏾‍♀️ update sizes-cjs.json 👍 2019-12-06 04:37:43 +00:00
Tanner Linsley a152704fde v7.0.0-rc.1 2019-12-05 23:36:14 -05:00
Tanner Linsley 32033b7095 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-05 23:19:38 -05:00
Tanner Linsley f73d87ac5d v7.0.0-rc.0
Fixes #1573
Fixes #1719
Fixes #1718
2019-12-05 23:18:48 -05:00
dependabot[bot]andTanner Linsley b92e25c21a Bump eslint-utils from 1.4.0 to 1.4.3 in /examples/basic (#1720)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-05 23:17:00 -05:00
size-plugin[bot]andGitHub 536217e430 ⛹🏿‍♂️ 🦻🏻 update sizes-es.json 👍 2019-12-06 04:16:18 +00:00
size-plugin[bot]andGitHub d038c6e781 😒 🐜 update sizes-cjs.json 👍 2019-12-06 04:16:17 +00:00
Tanner Linsley 438ce81fc5 Update API doc links 2019-12-05 23:14:23 -05:00
Tanner Linsley 7a0688aa63 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-05 23:14:17 -05:00
Tanner Linsley a33a008608 Add Footer Support 2019-12-05 23:11:50 -05:00
size-plugin[bot]andGitHub 67dd1d23b1 🕓 😞 update sizes-cjs.json 👍 2019-12-05 20:56:38 +00:00
size-plugin[bot]andGitHub 4aad402644 📸 🤟🏼 update sizes-es.json 👍 2019-12-05 20:56:37 +00:00
Tanner Linsley 75acd4a35b Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-05 15:51:30 -05:00
Tanner Linsley a170d33956 7.0.0-beta.28 2019-12-05 15:51:09 -05:00
size-plugin[bot]andGitHub 4c9d868a12 🧜🏽‍♀️ 🧖‍♀️ update sizes-cjs.json 👍 2019-12-05 20:48:59 +00:00
size-plugin[bot]andGitHub 08d6e2da71 🦽 🟪 update sizes-es.json 👍 2019-12-05 20:48:58 +00:00
Martin BrennerandTanner Linsley 7169b3100b Remove tooltip if columnDisableSortBy (#1685)
* Remove tooltip if columnDisableSortBy

* update sorting test snapshot
2019-12-05 15:48:57 -05:00
dependabot[bot]andTanner Linsley e5d672b9ea Bump eslint-utils from 1.4.0 to 1.4.3 in /examples/column-hiding (#1717)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.3.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-05 15:48:41 -05:00
Tanner LinsleyandGitHub 8ba553871f Add useColumnVisibility as core hook (#1700)
* Update utils.js

* Update useTable.js

* Create useColumnVisibility.js

* Update useColumnVisibility.js

* Update useColumnVisibility.js

* Convert to core hook, use new reducerHanndler/actions

* Add useColumnVisibility internal hook
2019-12-05 15:45:25 -05:00
Tanner LinsleyandGitHub 3097997734 Merge 9727202b14 into master 2019-12-05 09:18:01 -05:00
Tanner Linsley 9727202b14 Update Example 2019-12-05 09:17:59 -05:00
size-plugin[bot]andGitHub 6cb52cc3a6 🤦🏽‍♀️ 🦑 update sizes-cjs.json 👍 2019-12-05 14:17:13 +00:00
size-plugin[bot]andGitHub ee4f3f1d75 🇳🇮 🈚️ update sizes-es.json 👍 2019-12-05 14:17:12 +00:00
Martin BrennerandTanner Linsley 487abd2119 pass the instance with updated rows (#1714) 2019-12-05 09:14:07 -05:00
Tanner Linsley 9829927fab Update installation.md 2019-12-04 22:54:31 -05:00
Tanner Linsley d838238e95 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-04 22:54:22 -05:00
Tanner Linsley 57cc5dc7d0 Update selectedRowPaths in examples 2019-12-04 22:52:14 -05:00
size-plugin[bot]andGitHub 2ddd7731fa 👠 🤏 update sizes-es.json 👍 2019-12-05 03:48:58 +00:00
size-plugin[bot]andGitHub b65c853d09 🤵🏿 🧎🏻 update sizes-cjs.json 👍 2019-12-05 03:48:57 +00:00
Tanner Linsley 974eab7f5f Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-04 22:47:06 -05:00
Tanner Linsley b687cc01f0 7.0.0-beta.27 2019-12-04 22:46:53 -05:00
Aaron AgarunovandTanner Linsley 5c2b8302c0 Remove getTableHeaderProps destructured from useTable (#1706) 2019-12-04 14:26:28 -05:00
Tanner LinsleyandGitHub 1bbc89cedb Update App.js 2019-12-03 13:28:16 -07:00
Tanner LinsleyandGitHub 184ec448af Update README.md 2019-12-03 13:25:51 -07:00
Tanner Linsley 0e243e28a8 v7.0.0-beta.26 2019-12-03 12:57:59 -07:00
Tanner Linsley 5d81f95d9b Upgrade examples to use "latest" 2019-12-03 12:55:01 -07:00
Tanner Linsley 403bb2848b Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-03 12:54:51 -07:00
Tanner Linsley 1b1fda6815 Remove typescript dep 2019-12-03 12:54:35 -07:00
Cody SchwebkeandTanner Linsley 7014647b4a fix: fix crash in useSortBy resetSortBy action (#1695) 2019-12-03 12:52:08 -07:00
onnadi-saandTanner Linsley 872cb49242 Change An -> A (#1693) 2019-12-03 12:31:03 -07:00
onnadi-saandTanner Linsley 945bf18ee0 Fix typo (#1692) 2019-12-03 12:04:18 -07:00
size-plugin[bot]andGitHub 1e321f22d3 🇱🇧 👩🏾‍🚒 update sizes-es.json 👍 2019-12-03 16:44:30 +00:00
size-plugin[bot]andGitHub 2740e55d76 🎴 🤗 update sizes-cjs.json 👍 2019-12-03 16:44:29 +00:00
Tanner Linsley 6b88340051 Merge branch 'master' of https://github.com/react-tools/react-table 2019-12-03 09:42:27 -07:00
Tanner Linsley 92603b6a70 v7.0.0-beta.24 2019-12-03 09:40:53 -07:00
size-plugin[bot]andGitHub 09c212ec6c 👭🏾 🚜 update sizes-es.json 👍 2019-12-03 03:50:37 +00:00
size-plugin[bot]andGitHub 482cef191f 👳🏼‍♀️ 😆 update sizes-cjs.json 👍 2019-12-03 03:50:37 +00:00
Roman KovtunandTanner Linsley d7da8b631d Fix issue with missing columnId in updater on column spread (#1682) 2019-12-02 20:49:04 -07:00
size-plugin[bot]andGitHub 85153d287f 🏃‍♂️ ⏺️ create sizes-es.json 👍 2019-12-03 00:08:05 +00:00
size-plugin[bot]andGitHub c7ac522da3 👩🏾🤝👨🏽 🌈 create sizes-cjs.json 👍 2019-12-03 00:08:04 +00:00
anotherjsguyandTanner Linsley 5393ebc7fa setup size-plugin-bot (#1677)
* setup size-plugin-bot

* Update package.json
2019-12-02 17:06:31 -07:00
Tanner Linsley f74e347a06 v7.0.0-beta.23 2019-12-02 16:53:57 -07:00
Tanner Linsley ef29b639bd Update CHANGELOG.md 2019-12-02 16:52:37 -07:00
Tanner Linsley 12b5d05ba2 Fix column resizing 2019-12-02 16:52:10 -07:00
Tanner Linsley f9a6273184 Rename useMain and useBeforeDimensions hooks 2019-12-02 16:12:23 -07:00
Tanner Linsley 83f889dad5 v7.0.0-beta.22 2019-12-02 12:29:46 -07:00
Tanner Linsley 49674a094a Update README.md 2019-12-02 11:18:06 -07:00
Tanner Linsley 6cb84037e1 v7.0.0-beta.21 2019-12-02 09:22:33 -07:00
Tanner Linsley 1682aef117 Removed deprecated defaultState export 2019-12-02 09:21:34 -07:00
Tanner Linsley b1cf2e91dd Update README.md 2019-12-02 01:30:52 -07:00
Tanner Linsley 127a7fca87 v7.0.0-beta.20 2019-12-02 01:28:28 -07:00
Tanner Linsley dac4744727 v7.0.0-beta.19 2019-12-01 00:23:42 -07:00
Tanner Linsley f27263ebbd v7.0.0-beta.17 2019-12-01 00:05:03 -07:00
Tanner Linsley 31450f1e73 v7.0.0-beta.16 2019-11-30 23:37:47 -07:00
Tanner Linsley 14a9248595 Fix row selection when used with grouping 2019-11-30 23:19:45 -07:00
Tanner Linsley 58ae9edafc Merge branch 'master' of https://github.com/react-tools/react-table 2019-11-30 22:28:53 -07:00
Tanner Linsley 50f2e84929 Fix memoization in depGetters 2019-11-30 22:28:30 -07:00
Andros Rosa LlopandTanner Linsley 764a8ce281 Fix default resetSelectedRowsDeps (#1663)
* This one also is listening to rows, instead of data.
2019-11-29 21:14:25 -07:00
Jason LawandTanner Linsley 0a512adaf0 fix: memory leak fix (#1610)
* fix: memory leak

* Style change
2019-11-29 21:14:04 -07:00
Tanner Linsley ee92b152ba Remove service workers 2019-11-28 12:25:36 -07:00
Tanner Linsley 301ab1b991 v7.0.0-beta.15 2019-11-25 12:48:07 -07:00
Andros Rosa LlopandTanner Linsley e924b80709 Fix types of getRowID & getSubRows (#1651)
Closes: https://github.com/tannerlinsley/react-table/issues/1628
2019-11-25 12:25:09 -07:00
Andros Rosa LlopandTanner Linsley 2ecdfbd24e [Fix] defaultGetResetPageDeps should listen to data, not rows (#1658)
Related to: https://github.com/tannerlinsley/react-table/issues/1657

Discussion: https://spectrum.chat/react-table/general/v7-maximum-update-depth-exceeded-usegroupby-useexpanded-with-usepagination~2c25e2b8-7a61-4c32-84b3-87db458701c2

Thanks to @iamjon for identifying usePagination was the culprit.
I then checked the last changes made to it, and noticed it was previously listening to data and now it listened to rows (which I believe is a new reference on each render), causing infinite loop on one of its effects.

I tested this change on my project and everything seems ok now.
2019-11-25 12:24:20 -07:00
Andros Rosa LlopandTanner Linsley 461aa0df96 Types: getGroupByToggleProps was lost (#1654)
* There it was, on an unused UseGroupByHeaderProps interface, while it should have been on UseGroupByColumnProps.
2019-11-22 19:31:14 -07:00
Tanner Linsley f7d0d5662e v7.0.0-beta.14 2019-11-20 12:20:14 -07:00
Tanner Linsley 3187061041 Use effect dependency user call 2019-11-20 12:09:24 -07:00
Tanner Linsley e2728d0fdb Add full-width-table example 2019-11-20 11:16:30 -07:00
Tanner Linsley c80dfabed4 Update README.md 2019-11-20 10:48:52 -07:00
Tanner Linsley aae70e1189 Update package.json 2019-11-20 10:46:47 -07:00
Tanner Linsley 354ee238e8 Add size-snapshot rollup plugin, upgrade node_modules, remove archives 2019-11-20 10:45:44 -07:00
Tanner Linsley cdcf11b4b0 v7.0.0-beta.13 2019-11-20 10:26:13 -07:00
Tanner Linsley b3a4a9db72 Update CHANGELOG.md 2019-11-20 10:25:40 -07:00
Tanner Linsley df30b97956 Update CHANGELOG.md 2019-11-20 10:24:41 -07:00
Tanner Linsley 58028e45fc Rename disableGrouping, remove propTypes, update Readme 2019-11-20 10:23:52 -07:00
Tanner Linsley 108ea1d358 Update README.md 2019-11-20 09:50:04 -07:00
Tanner Linsley aea60278b1 Disable workflows and use travis for now 2019-11-20 09:46:05 -07:00
Tanner Linsley 27cd93f4bf Merge branch 'master' of https://github.com/react-tools/react-table 2019-11-20 09:40:06 -07:00
Tanner Linsley ed3dd9e6b5 Add "default" sort/filter/groupBy options for non accessors, rename disableGrouping 2019-11-20 09:35:40 -07:00
BobandTanner Linsley 1b3730f5cb docs: drag and drop example using react dnd (#1627)
* docs: drag and drop example using react dnd

* docs: add row DnD example to examples list
2019-11-20 08:45:20 -07:00
Christian LehnerandTanner Linsley 81faac54ac fixed typo. the key is called data instead of rows (#1632) 2019-11-20 08:44:30 -07:00
Tanner Linsley 50b00b67c5 Added data-driven-classes-and-styles example
- Also updated snapshots
2019-11-20 08:43:57 -07:00
Nicolas BeauvaisandTanner Linsley 1be9f59180 Fix typo (#1645) 2019-11-20 08:00:07 -07:00
Igor KatsubaandTanner Linsley 6ccdce9908 Refactoring aggregations.js (#1646)
* Update aggregations.js

* Update aggregations.js
2019-11-18 14:18:48 -07:00
Tanner LinsleyandGitHub dd0d6d6640 Update README.md 2019-11-14 07:46:04 -07:00
Tanner LinsleyandGitHub ae37a77c9b Update README.md 2019-11-14 07:42:51 -07:00
Tanner Linsley a5e9653165 Merge branch 'master' of https://github.com/react-tools/react-table 2019-11-05 14:41:26 -07:00
ggascoigneandTanner Linsley 3b03ea32f5 remove Record from HeaderProps and CellProps (#1601)
These definitions mask errors in the other definitions and there are better
ways of extending these.

See https://github.com/tannerlinsley/react-table/pull/1597 for an
example of an existing prototype that was missing but harder to find
because of these definitions.
2019-11-05 14:37:06 -07:00
Josh HaleandTanner Linsley 61f0ded1d9 Fix simple typo in comments. (#1606) 2019-11-05 14:36:46 -07:00
yvanzoandTanner Linsley 4c013ba214 fix: empty class attribute (#1619)
The above `join` returns an empty `className` JSX attribute when
called on an empty array, setting an empty `class` HTML attribute.

fix #1618
2019-11-05 14:29:36 -07:00
Tanner Linsley 1d0c6f5b34 Update api.md 2019-11-05 14:10:55 -07:00
Tanner Linsley e00704fbce Test 2019-11-05 14:04:23 -07:00
Tanner LinsleyandGitHub 8ca57779a3 Update README.md 2019-11-05 13:45:30 -07:00
Tanner LinsleyandGitHub 1ba08abf74 Update README.md 2019-11-05 13:42:59 -07:00
Tanner LinsleyandGitHub c1b7abd886 Update README.md 2019-11-05 13:42:00 -07:00
Tanner Linsley c4d3ff79cb Merge branch 'master' of https://github.com/react-tools/react-table 2019-11-04 22:57:28 -07:00
Tanner LinsleyandGitHub 7b4a3cb3ec Update README.md 2019-11-04 22:54:11 -07:00
Tanner LinsleyandGitHub 43f116da76 Update README.md 2019-11-04 22:53:54 -07:00
Tanner Linsley 00f223d78d Merge branch 'master' of https://github.com/react-tools/react-table 2019-11-04 22:50:33 -07:00
Tanner LinsleyandGitHub 3747f26a3f Update README.md 2019-11-04 22:50:13 -07:00
Chuck DanielssonandTanner Linsley 9698677982 Update syntax in examples (#1631) 2019-11-04 22:29:31 -07:00
Tanner LinsleyandGitHub 0e92ec2415 Update README.md 2019-11-04 11:58:22 -07:00
Tanner LinsleyandGitHub bb505aad58 Update README.md 2019-11-04 11:57:52 -07:00
Tanner LinsleyandGitHub c4ac495d55 Update README.md 2019-10-30 18:01:55 -06:00
Tanner LinsleyandGitHub e0c85b8b02 Update README.md 2019-10-30 17:59:52 -06:00
Tanner LinsleyandGitHub 578af7964e Update README.md 2019-10-30 17:59:29 -06:00
Michael StramelandTanner Linsley 4b7c85624b Add selectedFlatRows (#1597) 2019-10-14 16:17:37 -06:00
Hugo BoveandTanner Linsley 1ea677331c fix(usegroupby): column.disableGrouping inverted logic (#1596)
unlike other hooks, the column.disableGrouping actually enabled grouping for a column
2019-10-14 09:25:22 -06:00
gargrohandTanner Linsley 83ee60d715 [useTable] Manage layout to honor column's show property (#1594) 2019-10-14 09:24:05 -06:00
Nattasit MoonchanabahtandTanner Linsley 9c7b1e3313 ♻️ Refactor code (#1588) 2019-10-12 16:25:33 -06:00
Christian MurphyandTanner Linsley 62924dea9b refactor: update complex types to use Array<> syntax (#1587)
re-enables dtslint array type rule
2019-10-10 15:39:32 -06:00
Michael LiandTanner Linsley 062a8c12b5 update selectedRows based on 7.0.beta.8 (#1586) 2019-10-10 15:37:26 -06:00
Roman KomarovandTanner Linsley 720fb21d60 docs(readme): adds a react-table-v6 package note (#1576) 2019-10-10 06:55:13 -06:00
Christian MurphyandTanner Linsley 777aa2b863 test: validate typings using dtslint (#1581)
* test: validate typings using dtslint

* build: switch typescript into strict mode
2019-10-09 17:48:11 -06:00
ggascoigneandTanner Linsley 51aa8e2eff fix react-table-config.d.ts (#1582)
It turns out that pulling the types directly from a package slightly
changes how visible they are to the consuming application.  This makes
sense, previously we explicitly adding the react-table module to the
global namespace an so didn't need explicit imports, but now that's not
the case.  So add explicit imports.
2019-10-09 17:47:34 -06:00
Christian MurphyandTanner Linsley 0d7a0d5aea ci: setup github actions continuous integration workflow (#1578)
* ci: setup github actions continuous integration workflow

* docs: add GitHub Action CI badge

* ci: remove travis ci in favor of github actions ci
2019-10-09 16:54:03 -06:00
Tanner Linsley fb94eaf103 v7.0.0-beta.12 2019-10-09 15:43:14 -06:00
Tanner Linsley 409c050cbf Merge branch 'master' of https://github.com/react-tools/react-table 2019-10-09 15:42:24 -06:00
ggascoigneandTanner Linsley cee24c74d8 Add typescript docs (#1564)
* Add typescript docs

* update for beta.10 and feedback
2019-10-09 15:42:09 -06:00
Michael StramelandTanner Linsley 499f21c349 Remove package-lock.json (#1579) 2019-10-09 15:19:04 -06:00
Tanner Linsley 2a39d5a21c v7.0.0-beta.11 2019-10-09 15:15:39 -06:00
36ba233e27 Updating types (#1535)
* Attempt to bring into alignment

fix plugin hook definitions

Remove old prop

Format

fix Header and Cell props

Rename prop

Abstract props to definitions

fix bad generic

fix typo

Revert "fix typo"

This reverts commit 1ca58c5d8fb017bb0af79dd4aa4f0cd296e7a7e8.

fix

* Remove documented prop

* Tweaks

* Re-add comment

* Some updates

* more changes

* Convert to interfaces

* more fixes

* rename sortByFn params

* Fixes

* Fix setFilter

* Hopefully the last changes

* Bump TypeScript Version for declaration file

Co-Authored-By: Christian Murphy <christian.murphy.42@gmail.com>

* format

* Linting

* fix typo

* expose defaultState

* swap aggregatedValue

* Allow cellvalue for accessor function return

* modifications

* manually added changes from ggascoigne

* remove changes from examples folder
2019-10-09 15:15:00 -06:00
Christian MurphyandTanner Linsley c7dfc45e2e ci: test cross platform (#1559)
* ci: test cross platform

Test on Node.js 10 and 12, long term release support versions.
Test on Linux, Mac, and Windows machines.

* fix: update ic-ci-cli to version 2

includes fixes to support windows

* ci: disable yarn gpg

* ci: double quote string for windows ci
2019-10-09 15:13:17 -06:00
Tanner LinsleyandGitHub 9dd36263fb Update README.md 2019-10-08 10:17:45 -06:00
Tanner Linsley 227f7905b0 Upgrade controlled pagination example for deduped fetching 2019-10-08 09:49:23 -06:00
Tanner Linsley f1ad032587 Update controlled pagination example 2019-10-08 09:46:06 -06:00
Tanner LinsleyandGitHub 93703d027c Update README.md 2019-10-08 09:38:30 -06:00
GeoffandTanner Linsley 75fb61a17f Update concepts.md (#1572)
Some grammatical errors are fixed.
2019-10-07 20:43:53 -06:00
Andrey IvlevandTanner Linsley 7c73a7a631 Fix isClassComponent function (#1571)
`Object.getPrototypeOf(component)` returns React `function Component()` function itself, not `Component.prototype`.
2019-10-07 12:17:22 -06:00
tannerlinsley cbb18368b2 v7.0.0-beta.10 2019-10-07 10:27:56 -06:00
tannerlinsley 4842bc061d fix: fix includeAll filter type, add filteredRows 2019-10-07 10:27:18 -06:00
tannerlinsley 0477ef26ca Merge branch 'master' of https://github.com/react-tools/react-table 2019-10-05 20:50:29 -06:00
tannerlinsley 82734fc898 v7.0.0-beta.9 2019-10-05 20:49:21 -06:00
tannerlinsley bbfc6428b7 refactor(usetable/usetablestate): integrate useTableState into useTable
useTableState was an early and hasty abstraction that hasn't proved useful in many ways. Anything
you could do with useTableState, you could easily do using the same options (assuming they exist) in
the useTable hook. For this reason, state is now a first class citizen of the useTable hook, along
with more sane properties and option locations for anything pertaining to state.
2019-10-05 20:48:28 -06:00
eclissi91andTanner Linsley 280ef16a75 Update api.md (#1567)
I have corrected typo of this issue #1565
2019-10-04 09:01:19 -06:00
tannerlinsley 7db7d59b3d v7.0.0-beta.8 2019-10-03 15:33:00 -06:00
tannerlinsley e43968c684 feat(userowselect): add selectedFlatRows, rename state.selectedRows
Added instance.selectedFlatRows to know which row objects are currently selecte
2019-10-03 14:08:34 -06:00
tannerlinsley e5c04614c1 v7.0.0-beta.7 2019-10-03 13:40:22 -06:00
tannerlinsley 0ef0bc4126 fix(userowselect): useRowSelect fixed to take into account filters
useRowSelect now takes into account filtered data when doing selectAll toggling and
isAllRowsSelected state.
2019-10-03 13:39:35 -06:00
tannerlinsley ef67b15c07 Merge branch 'master' of https://github.com/react-tools/react-table 2019-10-03 08:39:12 -06:00
Tanner Linsley d248be8877 Fix sandbox loop protection 2019-10-03 08:38:33 -06:00
tannerlinsley ea0799763d v7.0.0-beta.6 2019-10-03 08:26:45 -06:00
tannerlinsley 98fffc3819 Merge branch 'master' of https://github.com/react-tools/react-table 2019-10-03 08:26:13 -06:00
tannerlinsley de7f5c9385 feat(useresizecolumns): added useResizeColumns 2019-10-03 08:25:36 -06:00
Hugo BoveandTanner Linsley 69e13b87c3 feat(useexpanded, usepagination): omit subRows from rows (#1562)
Added useExpanded 'expandSubRows' option
2019-10-02 06:51:14 -06:00
tannerlinsley 727f4157c1 v7.0.0-beta.5 2019-10-01 20:49:07 -06:00
tannerlinsley 3f9ba8daba chore: user terser 2019-10-01 20:48:12 -06:00
tannerlinsley 3de1bbc3a7 v7.0.0-beta.4 2019-10-01 20:35:25 -06:00
tannerlinsley 7d84f86612 fix: cleanup 2019-10-01 20:34:37 -06:00
tannerlinsley 40477c1c83 fix: do not error on unkonwn user actions, side-effect-free 2019-10-01 20:33:55 -06:00
tannerlinsley 906988c35a Merge branch 'master' of https://github.com/react-tools/react-table 2019-10-01 14:26:11 -06:00
tannerlinsley 07d879f5bb docs(docs - example): updated example docs 2019-10-01 14:25:36 -06:00
Tanner LinsleyandGitHub e18f371623 Update README.md 2019-10-01 14:08:01 -06:00
tannerlinsley 76a55b5103 v7.0.0-beta.3 2019-10-01 14:04:05 -06:00
tannerlinsley 247687ee08 feat: ingested width logic, useAbsoluteLayout useBlockLayout
Width options (`width`, `minWidth`, `maxWidth`) options are now a part of the core column object.
useBlockLayout and useAbsoluteLayout hooks now use this new internalized information to implement
their layouts. Those examples have been updated. A virtualized-rows example has also been added to
show off how the useBlockLayout hook can be used to virtualize rows with react-window.
2019-10-01 14:03:11 -06:00
Julian BöhnkeandTanner Linsley f70d38e061 add material-ui table component example (#1557)
* add material-ui table component example

* remove unused styled-components package

* update to react-table@nex

* update sandbox link

* update docs

* Update examples.md
2019-09-30 12:48:10 -06:00
gargrohandTanner Linsley b6fdb99f06 useAbsoluteLayout: Enable react-table to build with divs (#1522)
* useAbsoluteLayout: To build tables with divs

* Adding `placeholderOf` attribute to column

* Adding `useAbsoluteLayout` in index.js

* Adding `useAbsoluteLayout` example

* Adding `useAbsoluteLayout` in api docs

* Adding test for `useAbsoluteLayout` hook
2019-09-30 07:40:35 -06:00
tannerlinsley 488da2ecc5 v7.0.0-beta.2 2019-09-30 07:32:56 -06:00
tannerlinsley 5f0e7cab8b fix: fix colspan prop to use column visibility
Fixes #1555
2019-09-30 07:31:43 -06:00
Nick OomsandTanner Linsley e2e67ed181 Added "in" to make the sentence more readable (#1554) 2019-09-28 06:44:01 -06:00
goldenLunchboxandTanner Linsley c8857a2871 Update api.md (#1551)
The state variable seemed to be missing in the useTable part (row 481) and I felt the need to comment on an additional import being needed.
2019-09-27 05:43:13 -06:00
Tanner LinsleyandGitHub 98583d35f3 Update README.md 2019-09-26 13:28:31 -06:00
tannerlinsley 0a1bf55a2c Merge branch 'master' of https://github.com/react-tools/react-table 2019-09-26 13:23:03 -06:00
tannerlinsley 54b4f8a5d1 v7.0.0-beta.1 2019-09-26 13:22:14 -06:00
tannerlinsley f552c94972 fix(usepagination): fix unstable callbacks
Closes #1549
2019-09-26 13:21:34 -06:00
ggascoigneandTanner Linsley 7ab6385839 TypeScript updates (#1521)
* TypeScript updates

I've found that trying to get solid TypeScript typings for this library
are a bit of a challenge.  The composable nature of the library means
that the types for the builtin functions are by their nature somewhat
minimal, and that the user needs to be able to extend those interfaces
to reflect the specific plugins that are in use.

With that in mind I propose something like this.

To get the best out of them, you then need to extend those interfaces
using declaration merging, see
https://www.typescriptlang.org/docs/handbook/declaration-merging.html

e.g.

```ts
declare module 'react-table-hooks' {
  export interface TableInstance<D = any>
    extends UseFiltersValues<D>,
      UsePaginationValues<D>,
      UseExpandedValues,
      UseGroupByValues {}

  export interface TableState<D = any>
    extends UsePaginationState,
      UseGroupByState,
      UseSortbyState<D>,
      UseFiltersState<D> {}
}
```

This also puts the ability to extend those types with any user defined
hooks completely in the users hands.

This gives the greatest flexibility, but I'll admit that it isn't
particularly obvious.  Perhaps a typescript readme and example is needed.

* fix useExpanded type

* fix module name

* fix typo

* address review feedback

* add IdType, update Filters definition
2019-09-20 09:37:45 -06:00
Tanner LinsleyandGitHub b8ed02cadc Update README.md 2019-09-17 15:44:02 -06:00
Tanner LinsleyandGitHub c3e917f13b Update README.md 2019-09-17 15:42:36 -06:00
tannerlinsley 7e6d719af4 docs(changelog): update changelog 2019-09-13 09:24:24 -06:00
tannerlinsley da678d0a61 Merge branch 'master' of https://github.com/react-tools/react-table 2019-09-13 09:22:09 -06:00
Tanner LinsleyandGitHub c3fe4c7fd8 Update README.md 2019-09-13 09:22:03 -06:00
tannerlinsley 45036054cb v7.0.0-beta.0 2019-09-13 09:09:44 -06:00
tannerlinsley 8d3a97c9a2 v7.0.0-alpha.36 2019-09-13 07:35:15 -06:00
tannerlinsley fb0eb3646a Merge branch 'master' of https://github.com/react-tools/react-table 2019-09-13 07:34:22 -06:00
tannerlinsley dfad9151c3 fix(expandedrows): fix in-page row expansion for paginateExpandedRows 2019-09-13 07:33:53 -06:00
Michael StramelandTanner Linsley c618542f6e Don't publish types (#1515) 2019-09-12 21:29:15 -06:00
Michael StramelandTanner Linsley 670a92734e Add typings (#1511) 2019-09-12 09:39:53 -06:00
Andrey NikonovandTanner Linsley c91130075b Fix typo (#1513) 2019-09-12 08:56:16 -06:00
Andrey NikonovandTanner Linsley c4a8eb147c Fix typo (#1512) 2019-09-12 08:56:04 -06:00
Tanner LinsleyandGitHub 388cb85f0a Update README.md 2019-09-10 13:17:12 -06:00
CodarandTanner Linsley aea76facf1 isAllRowsSelected can only be true if there are rows. (#1504) 2019-09-09 08:49:40 -06:00
tannerlinsley f829cd0222 v7.0.0-alpha.35 2019-09-09 08:25:09 -06:00
tannerlinsley 0a03ea3a75 fix: better flexRender utility (supports JSX elements now) 2019-09-09 08:24:08 -06:00
tannerlinsley 0aa55dac08 fix: fixed disablePageResetOnDataChangeRef dependencies
disablePageResetOnDataChangeRef will no longer trigger page resets when changed
2019-09-09 08:21:15 -06:00
Eddie HongandTanner Linsley 15778fe467 Fix typo in installation.md (#1498) 2019-09-06 10:59:47 -06:00
tannerlinsley ca23da0342 v7.0.0-alpha.34 2019-09-05 11:08:12 -06:00
tannerlinsley 072967b771 fix: fix defaultColumn.sortType, fix useGroupBy plugin order warning 2019-09-05 11:07:25 -06:00
tannerlinsley da9e94091f chore: removed unused example 2019-09-03 07:15:19 -06:00
Tanner LinsleyandGitHub a98ec48b20 Update README.md 2019-09-03 07:01:58 -06:00
Tanner LinsleyandGitHub 1e2ca74f96 Update README.md 2019-09-03 06:59:15 -06:00
Tanner LinsleyandGitHub aaa9459389 Update api.md 2019-09-03 06:33:07 -06:00
Tanner LinsleyandGitHub 7884f33486 Update README.md 2019-09-02 21:37:31 -06:00
Brian QianandTanner Linsley 6193a33c89 Changed docs to include sortType options for useSortBy (#1489)
* Update api.md

* Update README.md
2019-09-02 19:32:35 -06:00
tannerlinsley 0e54ef0005 v7.0.0-alpha.33 2019-08-29 09:27:31 -06:00
tannerlinsley b10446b8c4 fix: useExpanded uses flat array for state
useExpanded now uses a flat array of row path keys for tracking expanded state instead of nested
objects. This is both easier to use as a developer, but also enables expanding all rows or even
leaving nested rows in an expanded state, despite their parent rows' expanded state.

BREAKING CHANGE: See description
2019-08-29 09:14:11 -06:00
tannerlinsley 51165d92f6 v7.0.0-alpha.32 2019-08-28 10:51:51 -06:00
tannerlinsley bb8b10ca64 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-28 10:51:10 -06:00
gargrohandTanner Linsley 8742ce39c2 [useSort] Provide API to clear sorting at column level (#1476)
* [useSort] Provide API to clear sorting at column level

* updated docs
2019-08-28 10:51:04 -06:00
tannerlinsley 0486c5c787 fix: fix column-ordering example 2019-08-28 10:50:33 -06:00
dependabot[bot]andTanner Linsley f4b165d378 chore(deps): bump eslint-utils from 1.4.0 to 1.4.2 (#1477)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.2.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-08-28 08:51:10 -06:00
tannerlinsley e7722b1d95 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-27 10:08:53 -06:00
tannerlinsley 25cdefb2a1 fix: clean up examples 2019-08-27 10:08:13 -06:00
Tanner LinsleyandGitHub 4e3d1dd10a Update README.md 2019-08-27 10:04:37 -06:00
Tanner LinsleyandGitHub f6a1203403 Update README.md 2019-08-27 10:04:22 -06:00
Tanner LinsleyandGitHub a810556e57 Update README.md 2019-08-27 10:03:39 -06:00
tannerlinsley 8bb85b99c3 v7.0.0-alpha.31 2019-08-27 10:00:39 -06:00
tannerlinsley b0d6169848 feat: added useColumnOrder + examples 2019-08-27 09:59:52 -06:00
tannerlinsley 9b7264fad4 fix: update package.json 2019-08-27 07:13:11 -06:00
tannerlinsley abe723a87d fix: fix header group and header placeholder IDs 2019-08-27 07:11:01 -06:00
tannerlinsley 8776d78edb v7.0.0-alpha.29 2019-08-26 09:38:53 -06:00
tannerlinsley f0293f5511 fix: getRowID instead of getRowPathID 2019-08-26 09:38:14 -06:00
tannerlinsley 16c5512c4f v7.0.0-alpha.28 2019-08-26 09:27:52 -06:00
tannerlinsley 3b42c72e7c fix: better naming, fix header regen, getSubRows, getRowPathID 2019-08-26 09:27:07 -06:00
tannerlinsley f40b8f5ca2 v7.0.0-alpha.27 2019-08-23 09:25:33 -06:00
tannerlinsley b61a8ed040 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-23 09:25:00 -06:00
tannerlinsley 4665006109 fix(use-row-select): fix selection issue casued by wrong startsWith key 2019-08-23 09:24:36 -06:00
Ashwin BhatandTanner Linsley c0aa9533e9 fix field names in useSortBy docs (#1475) 2019-08-22 16:08:40 -06:00
tannerlinsley 944b75c709 v7.0.0-alpha.26 2019-08-22 14:52:37 -06:00
tannerlinsley 4537f28a8d fix: fix header regeneration and colspan, better sorting 2019-08-22 14:46:33 -06:00
tannerlinsley 7ae4c4f9c7 v7.0.0-alpha.25 2019-08-20 12:56:36 -06:00
tannerlinsley 785b524d3c fix: removed useFlexLayout, fixed dot notation for accessors 2019-08-20 12:55:50 -06:00
tannerlinsley 16aa1143e6 chore: update logo source 2019-08-20 10:56:20 -06:00
tannerlinsley 5100d76ec2 docs: update Logo & Readme 2019-08-20 10:31:15 -06:00
Tanner LinsleyandGitHub c8c99265af Update README.md 2019-08-20 09:36:24 -06:00
tannerlinsley 5293bb7d34 chore: update logo 2019-08-20 09:35:37 -06:00
tannerlinsley aab49949db fix: rename some booleans to use 'is' prefix, added new logo 2019-08-20 09:31:11 -06:00
Tanner LinsleyandGitHub 3eaf4eb605 Update installation.md 2019-08-20 07:51:35 -06:00
tannerlinsley 89dd6747be docs: update kitchen-sink readme 2019-08-19 16:49:22 -06:00
tannerlinsley 196fb3c198 docs: added kitchen sink to the examples list 2019-08-19 16:48:06 -06:00
tannerlinsley 516aae55eb fix: update package.json 2019-08-19 16:42:21 -06:00
tannerlinsley 4a45cd6574 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-19 16:41:49 -06:00
tannerlinsley f59efde6fe fix: fix path getters, better plugin hook integration, renaming things 2019-08-19 16:38:42 -06:00
tannerlinsley 93524d0701 docs: add kitch sink example 2019-08-19 15:33:07 -06:00
DomenuchandTanner Linsley 64e9d91e3c Allow row generator to listen for column changes (#1442)
* added column dependency to row generator memo listeners

* added assertion to stop an infinite loop inside usePagination
2019-08-19 15:00:33 -06:00
Tanner LinsleyandGitHub 16df48f950 Update README.md 2019-08-19 10:17:17 -06:00
Tanner LinsleyandGitHub 37e2e1363d Update README.md 2019-08-19 10:14:19 -06:00
CodarandTanner Linsley af37eead5b Sub rows are selected if the parent row is selected. (#1444)
* Sub rows are selected if the parent row is selected.

* Parent rows are updated accordingly if a subRow is selected.

* Updated useRowSelect snapshot tests to test subRow selection.
2019-08-18 17:40:02 -06:00
Paweł DąbrowskiandTanner Linsley 3f0bb0a0dd fix(use-sort-by): sorting now ignores column ids that no longer exist (#1454)
* fix(use-sort-by): sorting now ignores column ids that no longer exist

* fix(use-filters): filtering no longer fails when column doesn't exist

* fix(use-sortby): filtering out invalid sortBys before sorting
2019-08-16 09:14:30 -06:00
tannerlinsley afbdb3e572 chore: update package.json 2019-08-16 08:03:32 -06:00
tannerlinsley 40884e9a44 style: lock prettier version, fix sorting example 2019-08-16 07:20:52 -06:00
tannerlinsley 4712cf8af5 docs: docs 2019-08-15 15:44:47 -06:00
Tanner LinsleyandGitHub 44193e415d Create CODE_OF_CONDUCT.md (#1452) 2019-08-15 15:42:50 -06:00
tannerlinsley 317e6befe0 docs: docs 2019-08-15 15:38:51 -06:00
tannerlinsley 650ecbcf9e docs: docs 2019-08-15 15:37:16 -06:00
tannerlinsley 008ea6f930 docs: docs 2019-08-15 15:36:13 -06:00
tannerlinsley 8a8c18feca docs(docs): docs 2019-08-15 15:33:39 -06:00
tannerlinsley 98466e6414 docs(docs): improve docs 2019-08-15 15:32:03 -06:00
tannerlinsley 3aef7d3379 v7.0.0-alpha.22 2019-08-15 14:20:40 -06:00
tannerlinsley d9a4b6bd85 refactor: improve renderer function ergonomics
The renderer function for headers, columns, cells, aggregates, filters, etc used to mix properties
from all of those contexts, including rows. Now thow contexts are located on their own reserved
properties, eg. `Cell: ({ cell: { value}, row, column, ...instance }) => value`

BREAKING CHANGE: The renderer function for headers, columns, cells, aggregates, filters, etc used
2019-08-15 14:16:52 -06:00
tannerlinsley d50ec588bc fix(use-pagination): fixed use pagination pageIndex bug
Use pagination will no longer synchronously reset the pageIndex to 0 on mount
2019-08-15 09:55:22 -06:00
tannerlinsley f9242f604d fix(usesortby): fix usesortby merge regression 2019-08-15 09:04:07 -06:00
Eugene KrevenetsandTanner Linsley 59f6a768a7 improve(use-table): use single instance of defaultColumn property (#1451)
in case of using construction like:
```
{
  defaultColumn = {}
}
```
`defaultColumn` will get new instance each time, so as result it force to recalculation each of `React.useMemo`.
2019-08-15 08:58:42 -06:00
Maximilian BrandauandTanner Linsley bcd0da7379 fix: update colSpan (#1447)
Only count visible columns for determining the colSpan

fix #1446
2019-08-15 08:57:22 -06:00
tannerlinsley 14ea0abf27 docs(readme): fix Zappi link 2019-08-15 08:39:03 -06:00
tannerlinsley 696edacd48 fix(use-flex-layout): fix flex layout hook to use new internal hooks 2019-08-15 08:36:33 -06:00
tannerlinsley f665972584 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-15 08:31:57 -06:00
tannerlinsley deb15c3908 docs(readme): updated readme 2019-08-15 08:28:37 -06:00
Eugene KrevenetsandTanner Linsley c77ffacdc9 improve(sort): don't sort subrows less than 2 characters (#1449)
it improves performance because cuts a lot of sorting manipulations
2019-08-15 08:11:12 -06:00
gargrohandTanner Linsley d4303a2468 [v7] useSort - Multisort functionality: Limit max cols and optional shift key (#1433)
* [v7] useSort - Multisort functionality: Limit `multiSort` number and configurable shift key

1. Provide configuration for multisort that pressing shift key is not compulsory

2. Configurable limit on max number of columns for multisort, like configuration has been provided that `maxMultiSortColCount` is 3, suppose currenlty table is sorted by `[A, B, C]` and then clicking `D` for sorting should result in table sorted by `[B, C , D]`

* update readme for new multisort options

* Use `isMultiSortEvent` function 

so as to make `shift` key optional or take decision based on other parameters for multisorting

* `isMultiSortEvent` updated readme
2019-08-14 10:47:02 -06:00
Marian LumbaandTanner Linsley dc629aedfa updating code sandbox links (#1437) 2019-08-08 14:11:32 -06:00
tannerlinsley 134f3dc064 v7.0.0-alpha.21 2019-08-06 22:34:17 -06:00
tannerlinsley a667b7cb13 fix(use-pagination): better controlled/manual use-pagination 2019-08-06 22:32:17 -06:00
tannerlinsley 4f01c32216 v7.0.0-alpha.20 2019-08-06 20:01:52 -06:00
tannerlinsley 5145a632c9 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-06 20:01:11 -06:00
tannerlinsley 8508a6567d feat(multiple): useRowState, fix useRowSelect/useSortBy/usePagination 2019-08-06 19:57:48 -06:00
PierreandTanner Linsley 1e80dd85d6 fix: disableSorting in column config level (#1434) 2019-08-06 08:03:17 -06:00
Tanner LinsleyandGitHub 3cbb49fc37 Update README.md 2019-08-05 14:52:56 -06:00
tannerlinsley 110e04bf61 v7.0.0-alpha.19 2019-08-05 09:00:16 -06:00
tannerlinsley 2b30c84abc fix(utils/example): fixed ensurePluginOrder utility, perf/debug updates 2019-08-05 08:59:35 -06:00
tannerlinsley fd0fe43ad9 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-05 08:45:18 -06:00
gargrohandTanner Linsley 5975e0c4cd [Minor] use actual param in ensurePluginOrder (#1429) 2019-08-05 08:45:01 -06:00
gargrohandTanner Linsley e7bbddbb0f [Minor] typo correction (#1431) 2019-08-05 08:44:16 -06:00
Tanner LinsleyandGitHub 49a1023467 Update README.md 2019-08-05 08:43:39 -06:00
Tanner LinsleyandGitHub 7167350921 Update README.md 2019-08-05 08:39:54 -06:00
Tanner LinsleyandGitHub 77cb0d97a8 Update README.md 2019-08-05 07:39:55 -06:00
Tanner LinsleyandGitHub 0672de486a Update README.md 2019-08-05 07:38:07 -06:00
Tanner LinsleyandGitHub e0f83d32fe Update README.md 2019-08-05 06:53:29 -06:00
Tanner LinsleyandGitHub 3aaa5b9b1e Update README.md 2019-08-05 06:52:46 -06:00
Tanner LinsleyandGitHub 352de348fe Update README.md 2019-08-05 06:48:00 -06:00
tannerlinsley 21d3853dba v7.0.0-alpha.18 2019-08-03 14:37:38 -06:00
tannerlinsley 095979b9db docs(readme): updated readme 2019-08-03 14:36:52 -06:00
tannerlinsley f52d5af115 docs(examples): updated example directory names 2019-08-03 14:31:13 -06:00
tannerlinsley 037c32345f feat(use-row-select): added useRowSelect plugin hook + related 2019-08-03 14:20:08 -06:00
tannerlinsley 6ad0d4e0c0 Merge branch 'master' of https://github.com/react-tools/react-table 2019-08-02 07:43:30 -06:00
tannerlinsley 512790bc1c fix(multiple): sub-components example, minor refactors
Fixes #1423
2019-08-02 07:42:42 -06:00
gargrohandTanner Linsley 118b873531 fix(useFilters): Honor column level disableFilters by setting canFilters correct value (#1427)
* correcting typos

* [minor ] Readme update

* Honor `columnDisableFilters` in useFilters by setting `canFilters` correct value
2019-08-02 07:28:38 -06:00
tannerlinsley 39c2b152f6 docs(readme): better docs on nested columns 2019-07-31 16:21:03 -06:00
tannerlinsley adfc82b472 v7.0.0-alpha.17 2019-07-31 12:27:58 -06:00
tannerlinsley 6030282428 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-31 12:27:18 -06:00
tannerlinsley f6ee2a3d99 fix(npm/examples): added src back to npm package, fixed grouping example 2019-07-31 12:27:06 -06:00
AurimasandTanner Linsley 633cc27a99 fix(utils): default Cell renderer cleanup (#1421) 2019-07-31 08:47:21 -06:00
tannerlinsley 02b2671f5c v7.0.0-alpha.16 2019-07-30 17:01:59 -06:00
tannerlinsley 2c5610d885 test(usegroupby/useexpanded): improved tests for useGroupBy/useExpanded 2019-07-30 17:00:59 -06:00
tannerlinsley 12e7b3220d test: snapshots for useFilters, useGroupBy, useSortBy 2019-07-30 15:57:11 -06:00
tannerlinsley bcefe5d6e8 v7.0.0-alpha.15 2019-07-30 14:10:19 -06:00
tannerlinsley df827d76e2 test(usefilters): added useFilters test placeholder 2019-07-30 14:09:48 -06:00
tannerlinsley 0ae8693444 fix(global): fix npm dist, update docs 2019-07-30 14:07:31 -06:00
tannerlinsley 56f3dc9fe6 docs(example): removed page options from the pagination example state 2019-07-30 12:54:19 -06:00
tannerlinsley 5f58786e94 docs(examples): added pagination example 2019-07-30 12:51:14 -06:00
tannerlinsley 48f992fa0c v7.0.0-alpha.14 2019-07-30 11:44:21 -06:00
tannerlinsley 0b868fe8c4 chore(husky): added yarn test:ci 2019-07-30 11:43:22 -06:00
tannerlinsley a7a95b2ce6 fix(usepagination): pageOptions calculate correctly, added pagination ex 2019-07-30 11:41:11 -06:00
tannerlinsley 116f5cdeba docs(grouping example): better annotations and more data 2019-07-30 11:09:20 -06:00
tannerlinsley 0187fcfc2c fix(example): fixed css issues in codesandbox (no css prop) 2019-07-30 10:33:06 -06:00
tannerlinsley ab32339bfa v7.0.0-alpha.13 2019-07-30 10:23:42 -06:00
tannerlinsley 7fd8fa1dfc docs: adding grouping example 2019-07-30 10:21:05 -06:00
tannerlinsley bc89ae3027 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-30 09:57:04 -06:00
tannerlinsley af739d91d0 fix(usegroupby): fix useGroupBy, add grouping example and fix some tests 2019-07-30 09:56:44 -06:00
Cyril SimanandTanner Linsley 35f78132f6 Avoid react error if the data source doesn't have the property. (#1420)
* Fix : Avoid react error if the data source doesn't have the property.

* Update fix with tannerlinsley's better solution
2019-07-30 09:51:17 -06:00
Larry BothaandTanner Linsley d7a4db0979 chore(commitlint): add deps, config, and git hook (#1419) 2019-07-29 23:45:46 -06:00
tannerlinsley 11167e5635 Refactor useTable, sorting, and filtering to use new hook layer 2019-07-29 14:51:07 -06:00
Larry BothaandTanner Linsley 14a43b1a68 Update test configs (#1417)
* chore(package.json): use latest babel core, remove bridge

* test(.babelrc): add test environment so that Jest can use ES6 imports

* test(usetable): fix import
2019-07-29 14:34:33 -06:00
tannerlinsley 0375a7e7d5 Set up some failing tests 2019-07-29 12:05:19 -06:00
tannerlinsley 6b70309f42 Add prettier format 2019-07-29 11:33:47 -06:00
tannerlinsley 9b262676be Fix hook defaults 2019-07-29 11:14:41 -06:00
tannerlinsley 1caad4cd8c Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-29 11:00:11 -06:00
tannerlinsley dc73347003 Relocate columns and row logic, fix columns and useGroupBy to be more pure
Since useColumns was relying on groupBy logic, this was code smell. I wanted useGroupBy to be able to add that logic all by itself and not have to have dependencies in the core of the table.

To fix that, I've moved the core column and row logic to the useTable hook and added a new hook 'columnsBeforeHeaderGroups' to allow useGroupBy to do what i needs in a more pure way.
2019-07-29 11:00:07 -06:00
gargrohandTanner Linsley 66bfec34a8 [minor] Readme update (#1415)
* correcting typos

* [minor ] Readme update
2019-07-29 09:37:48 -06:00
gargrohandTanner Linsley 6347157f80 correcting typos (#1413) 2019-07-29 08:46:56 -06:00
jaapjanfransandTanner Linsley b6db8775ad Small readme example update (#1412)
in commit ea79cd8388 the`getRowProps` member of the headerGroup object changed into `getHeaderGroupProps`
2019-07-29 07:51:01 -06:00
tannerlinsley cadd8bf62a Rename examples and their directories 2019-07-26 16:03:54 -06:00
tannerlinsley 9f4746a7ac Add sorting guide 2019-07-26 15:54:50 -06:00
tannerlinsley a0ca841287 Update App.js 2019-07-26 11:27:10 -06:00
tannerlinsley 52ee923675 Update package.json 2019-07-26 11:22:58 -06:00
tannerlinsley 24f6a2750d fix(usefilters): fix filter type fallback and autoRemove functionality AGAIN 2019-07-26 11:22:23 -06:00
tannerlinsley 8988660618 fix(usefilters): fixed filtering fallback logic and autoRemove bug 2019-07-26 10:58:35 -06:00
tannerlinsley a3e5cac298 fix(usefilters): fixed the default filter to be 'text' 2019-07-26 10:52:27 -06:00
tannerlinsley 47d2651b8d docs: updated contribution documentation 2019-07-26 10:45:33 -06:00
tannerlinsley 412f64cece chore: released version 7.0.0-alpha.9 2019-07-26 10:39:19 -06:00
tannerlinsley 933cc27e33 Update README.md 2019-07-26 10:30:59 -06:00
tannerlinsley 54be978268 Update App.js 2019-07-26 10:30:20 -06:00
tannerlinsley 90922f8637 Upgrade filter types to support configurable autoRemoval 2019-07-26 10:19:38 -06:00
tannerlinsley fd8a686b30 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-26 07:14:06 -06:00
Larry BothaandTanner Linsley a361a372ee chore(packages): add husky and lint-staged (#1409) 2019-07-26 07:13:58 -06:00
Larry BothaandTanner Linsley 563e809d05 docs(package.json): add commitizen dep, config, and npm script (#1408)
use `npm run commit` to use commitizen for better commit messages

re #1383
2019-07-25 22:39:25 -06:00
tannerlinsley 7d267b3442 v7.0.0-alpha.8 2019-07-25 13:39:37 -06:00
tannerlinsley 388b3ec2b9 Update README.md 2019-07-25 13:39:13 -06:00
tannerlinsley b2abd82350 Use useEffect in dev, not layoutEffect 2019-07-25 13:39:10 -06:00
tannerlinsley 06a6d6fcc3 Rename getHeaderRowProps to getHeaderGroupProps 2019-07-25 13:38:52 -06:00
tannerlinsley d8599817ad Fix immutability issue with pagination and sortBy 2019-07-25 13:38:33 -06:00
tannerlinsley e1060db327 Satisfy exhuastive-deps in useTableState 2019-07-25 13:38:15 -06:00
tannerlinsley ea79cd8388 Fix renderer functions for blank headers 2019-07-25 13:37:58 -06:00
tannerlinsley b2ed18696f Add defaultColumn option 2019-07-25 13:37:31 -06:00
tannerlinsley 9f8eab5777 Update README.md 2019-07-25 10:27:49 -06:00
tannerlinsley 4f13f32023 Update rendering API and column/header model 2019-07-25 10:24:30 -06:00
tannerlinsley 5bb2e49764 Fix useTableState setState memoization 2019-07-25 07:04:52 -06:00
tannerlinsley d1f26fe7bc Fix action type detection 2019-07-24 07:21:26 -06:00
tannerlinsley c7d6562d04 Change actions and addActions to be simpler to use 2019-07-23 12:30:15 -06:00
tannerlinsley e82d2d4b36 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-23 12:22:01 -06:00
tannerlinsley 0716e234a1 Add sortBy example 2019-07-23 12:21:57 -06:00
tannerlinsley 824ee34ba9 Refactor sortBy logic 2019-07-23 12:20:32 -06:00
tannerlinsley 514fbabb88 Fix type action forcing 2019-07-23 12:12:46 -06:00
Maksim HorbachevskyandTanner Linsley 2ecf40518e Export utils to create custom hooks (#1403) 2019-07-23 12:03:17 -06:00
tannerlinsley fd64486286 Fix usePagination to work during SSR 2019-07-23 10:55:49 -06:00
tannerlinsley 34909305af Force action types in state reducer 2019-07-23 10:41:27 -06:00
tannerlinsley 5043af5071 Move useColumns and useRows into useTable (but allow overrides) 2019-07-23 10:22:46 -06:00
tannerlinsley 2ca7f78d72 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-21 15:41:28 -06:00
tannerlinsley 811cd015c2 Update README.md 2019-07-21 15:41:21 -06:00
AresMegaGlobalandTanner Linsley 9e37846a21 Update README.md (#1400) 2019-07-20 07:32:30 -06:00
tannerlinsley 723720c8b1 Update README.md 2019-07-18 15:07:41 -06:00
tannerlinsley 2a20ad3ba4 Update App.js 2019-07-18 15:06:10 -06:00
tannerlinsley c6d37e4834 Update basic example 2019-07-18 15:03:21 -06:00
tannerlinsley a1a192052d Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-18 14:56:06 -06:00
tannerlinsley 455e0730bf Bare bones basic example 2019-07-18 14:56:03 -06:00
Tanner LinsleyandGitHub 1d4867fa2f Update FUNDING.yml 2019-07-18 13:53:38 -06:00
Tanner LinsleyandGitHub c3da2a7c41 Update FUNDING.yml 2019-07-18 13:52:48 -06:00
Tanner LinsleyandGitHub c3a52c5845 Update FUNDING.yml 2019-07-18 13:51:26 -06:00
Tanner LinsleyandGitHub 6dea8103d3 Update FUNDING.yml 2019-07-18 13:51:09 -06:00
Tanner LinsleyandGitHub 3bab8372d1 Update FUNDING.yml 2019-07-18 13:50:29 -06:00
Tanner LinsleyandGitHub b85f457e62 Update FUNDING.yml 2019-07-18 13:41:35 -06:00
Tanner LinsleyandGitHub c6871084d6 Create FUNDING.yml 2019-07-18 13:40:43 -06:00
tannerlinsley 8946771563 Update README.md 2019-07-18 12:08:57 -06:00
tannerlinsley fbc8032d29 Fix disableMultiSort, change from sortByFn to sortTypes 2019-07-18 12:08:55 -06:00
tannerlinsley 6a3bc5559e Add pageCount to instance via usePagination hook 2019-07-18 12:08:04 -06:00
tannerlinsley 91e28b93bf Clean up useTokenPagination 2019-07-18 12:07:48 -06:00
tannerlinsley a6345dbe2b Add sortTypes 2019-07-18 12:07:39 -06:00
tannerlinsley 0b0de317ee Clean up useFlexLayout 2019-07-18 12:07:21 -06:00
tannerlinsley 0ed0c78286 Change expandedKey to manualExpandedKey, fix expanded index to use the original row index 2019-07-18 12:06:57 -06:00
tannerlinsley fad6ac4014 Update README.md 2019-07-17 12:40:54 -06:00
tannerlinsley 8f142b3788 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-17 12:39:40 -06:00
tannerlinsley daff1f9ca3 Documentation Checkpoint 2019-07-17 12:39:35 -06:00
DomenuchandTanner Linsley 96900f645a returned row inside row hook subscription (#1393) 2019-07-16 13:22:13 -06:00
tannerlinsley 272a99fcd8 Update README.md 2019-07-15 11:36:30 -06:00
tannerlinsley 07fb9529e4 v7.0.0-alpha.7 2019-07-15 11:29:50 -06:00
DomenuchandTanner Linsley b5d399efd6 Fixed grouped column Header that were not adjusting based on hidden child columns (#1381)
* added assertion to check for show property inside column

* reverted previous change

* added a filter to weed out non-visible columns when calculating the size for grouped Headers

* added another case to the previous filter to factor in blank grouped Headers
2019-07-15 11:28:22 -06:00
DomenuchandTanner Linsley 14e931548a added undefined to the unspecific getRowProps fn to retain the param order (#1392) 2019-07-15 11:27:13 -06:00
Larry BothaandTanner Linsley bc3ea07c3e Feature/add jest configs ref: #1383 (#1385)
* add deps for testing

* feat(tests): add jest configs

* uncomment module directories path
2019-07-15 11:25:32 -06:00
tannerlinsley 4a3929cd50 Merge branch 'master' of https://github.com/react-tools/react-table 2019-07-15 09:33:04 -06:00
Larry BothaandTanner Linsley e2bb09d8b2 Feature/add prettier config, ref #1383 (#1384)
* add prettier config

* write files with prettier

* install and configure lint-staged and husky - ref 1.2 in #1383

* feat(style): add prettier configs, ref 1.1 & 1.2 in #1383
2019-07-01 21:03:57 -06:00
ggascoigneandTanner Linsley 18f2dea247 Fix lint errors from react-hooks/exhaustive-deps (#1371)
They all seemed like reasonable warnings, this squashes them.
2019-07-01 09:43:46 -06:00
ggascoigneandTanner Linsley ead3599378 Fix pagination resetting to page zero with manualPagination (#1369)
* Fix pagination resetting to page zero with manualPagination

To be honest I'm not sure what this useLayoutEffect is there to do.
It has no visible effect if you don't use manualPagination, and if you
do it, simply jumps you back to the first page, defeating the point of
you having control of the pagination.

* Conditionally reset page on data change

Rather disable the whole page reset when filters, groupBy or sortBy
change, just because I wanted to disable the page reset on data change,
make that bit be conditional.

With that in mind, usePagination now accepts a
disablePageResetOnDataChange parameter.
2019-07-01 09:36:42 -06:00
Adrien DenatandTanner Linsley addf28a011 Fix useExpanded wrongly flattening subRows (#1372)
* Fix useExpanded wrongly flattening subRows

* Add new paginateSubRows option defaulting to true
2019-06-21 10:00:59 -06:00
Adrien DenatandTanner Linsley e4429b7143 Add support for es module build (#1374) 2019-06-21 09:43:05 -06:00
tannerlinsley 4b2d0eb187 v7.0.0-alpha.6 2019-06-20 15:24:02 -06:00
ggascoigneandTanner Linsley 5369051b05 Provide option to toggle sort like V6 (#1370)
V7 adds the option to remove a sort option, so it goes from asc -> desc
-> unset, then repeats.  V6 just went from asc -> desc then repeated.

Personally I much preferred this, I think that there's a case to be made
that this is the more expected behavior.

I'm not sure if this is really the best way to fix this since it adds
yet another api option and I completely understand that that is less
than desirable, but I also would rather add an option than have to
duplicate the whole useSortBy hook.
2019-06-20 12:50:36 -06:00
DomenuchandTanner Linsley 58d38b668b changed applyHook to applyPropHooks inside getRowProps mergeProps fn (#1367) 2019-06-20 12:49:04 -06:00
tannerlinsley 9de149cf3c v7.0.0-alpha.5 2019-06-11 11:41:38 -06:00
tannerlinsley 289dca1caf Merge branch 'master' of https://github.com/react-tools/react-table 2019-06-11 11:41:07 -06:00
tannerlinsley f257a3496f v7.0.0-alpha.4 2019-06-11 11:41:03 -06:00
tannerlinsley 312a137f02 Add colspan prop support out of the box, fix useTableState to be immutable, fix sorting and pagination performance, 2019-06-11 11:40:39 -06:00
HellycatandTanner Linsley c6167566da Fix misspelled in propTypes (#1353) 2019-05-31 07:18:26 -06:00
Dmitrii GaidarjiandTanner Linsley 5b0e68aead Fix defaultSortDesc blocking toggle action (#1341)
* Fix defaultSortDesc blocking toggle action

* Revert "Fix defaultSortDesc blocking toggle action"

This reverts commit 15e05cefd820e3f63e80a8e9d31b9431f295b55a.

* Fix defaultSortDesc blocking toggle action
2019-05-31 07:17:58 -06:00
tannerlinsley 2f5ebe460f Move initial column visibility to useTable.
This change allows you to technically use React Table without a layout hook. Under that assumption, you would need to come up with your own styling mechanisms for display.

The useSimpleLayout merely adds a single `width` style to the prop getters for column headers and cells.

The useFlexLayout is much more robust. Personally though, I have moved away from both, and am just using raw `display: table-row/table-cell` styles to let my tables display naturally.
2019-05-16 10:52:16 -06:00
tannerlinsley 2ab4a65dcc Merge 2019-04-29 12:41:02 -06:00
tannerlinsley 94a6ee53f7 Update .gitignore 2019-04-29 12:39:48 -06:00
tannerlinsley ab32721453 Fix: usePagination now supplies both pageIndex and pageSize 2019-04-29 12:39:29 -06:00
Gary MenzelandTanner Linsley 98bee0a4a7 Feature/useSimpleLayout (#1322)
* Install useSimpleLayout and adjust useTable and useRows as required.

* useSimpleLayout integration

* Minor final fix - replace .filter with .forEach

* Used a spread on the path.
2019-04-28 09:53:34 -06:00
George MauerandTanner Linsley 882e5f6fcf Fix sandbox config to proper extension for codesandbox (#1323) 2019-04-28 09:52:16 -06:00
tannerlinsley 8c81a31aa6 Update README.md 2019-04-26 22:28:25 -06:00
tannerlinsley 8e4601fa83 Move row and cell generation to useTable. Add warnings for unprepared rows 2019-04-25 16:33:00 -06:00
tannerlinsley 7c6076908d Merge branch 'master' of https://github.com/react-tools/react-table 2019-04-23 15:47:26 -06:00
tannerlinsley ab3252bc32 Remove unnecessary flex layout inline styles 2019-04-23 15:47:22 -06:00
Jose Manuel Vergara FlorezandTanner Linsley 085957f3c4 Fix Example link on ReadMe (#1308) 2019-04-23 15:26:43 -06:00
Bojan BedracandTanner Linsley fd5d9ddecd Broken 100k rows aggregation (#1283)
* Broken codesandbox example

* Delete file in wrong location
2019-04-23 15:22:36 -06:00
Paul VogelandTanner Linsley 4e3fa751dc TravisCI: Cache yarn files (#1289)
Like it is recommended by https://docs.travis-ci.com/user/caching/#yarn-cache
2019-03-12 11:08:24 -06:00
Paul VogelandTanner Linsley 3453ac5a76 TravisCI: Use node version 10 (#1288)
Since it's the active LTS according to https://nodejs.org/en/about/releases/
2019-03-12 09:00:46 -06:00
Gary MenzelandTanner Linsley a9971e66af Fixes for useExtended in useTable plus small bug (#1279)
* undefined error in GroupBy
row specific hooks and correct pathing for nested rows

* Ensuring correct git user
2019-02-27 08:06:47 -08:00
Tanner LinsleyandGitHub 33f30c7b7f Update README.md 2019-02-18 10:13:41 -07:00
Tanner LinsleyandGitHub 91d758711d Update README.md 2019-02-14 15:06:47 -07:00
Tanner LinsleyandGitHub b2498b0430 Update README.md 2019-02-14 14:51:07 -07:00
Tanner LinsleyandGitHub d599952e89 Update README.md 2019-02-14 14:48:57 -07:00
Tanner Linsley 3ee410bd05 Create _redirects 2019-02-11 13:19:27 -07:00
Tanner Linsley 8b07b2c84e Unzip old react-table examples in archives 2019-02-11 13:14:36 -07:00
Tanner Linsley a0495f6858 Rename hook files 2019-02-11 09:33:34 -07:00
Tanner Linsley 2d31d3bac9 v7.0.0-alpha.2 2019-02-06 16:23:02 -07:00
Tanner Linsley 8d269b95c7 v7.0.0-alpha.1 2019-02-06 16:20:07 -07:00
Tanner Linsley b6bd5b25f5 v7.0.0-alpha.0 2019-02-04 18:56:10 -07:00
Tanner Linsley 4d59f163c0 Merge branch 'master' of https://github.com/react-tools/react-table 2019-02-01 09:36:17 -07:00
Tanner Linsley 1f877a9c4d Update README.md 2019-02-01 09:36:13 -07:00
Tanner LinsleyandGitHub 6c46ea8a07 Update bug_report.md 2019-02-01 09:01:33 -07:00
Tanner LinsleyandGitHub 796a3cbc48 Update questions--support---help.md 2019-02-01 08:56:40 -07:00
Tanner LinsleyandGitHub c0c78d5de7 Update feature_request.md 2019-02-01 08:55:36 -07:00
Tanner Linsley 2a6dfb6ebd Init v7 src 2019-01-31 12:54:56 -07:00
Tanner Linsley a99ecbd567 Update README.md 2019-01-31 12:51:24 -07:00
Tanner Linsley 1ed45d2635 Update README.md 2019-01-31 12:49:14 -07:00
Tanner Linsley 96ab761367 Update README.md 2019-01-31 12:48:12 -07:00
Tanner Linsley d2f1563cd5 Update README.md 2019-01-31 12:46:22 -07:00
Tanner Linsley 73b4869329 Update README.md 2019-01-31 12:33:23 -07:00
Tanner Linsley 3190047284 Update README.md 2019-01-31 12:18:45 -07:00
Tanner Linsley 00efc98779 Fix linting, update Readme 2019-01-31 12:13:34 -07:00
Tanner Linsley 379d9e11d5 v6.9.0 2019-01-31 10:18:22 -07:00
John MaguireandTanner Linsley 3fff682578 apply @twheys PR #1077 as patch and update Array.concat to [].concat (#1241) 2019-01-31 10:15:09 -07:00
Josh McCulloughandTanner Linsley 168a8e3f93 update fireFetchData to use current state for select value (#1231) 2019-01-31 10:09:28 -07:00
Josh McCulloughandTanner Linsley 221164484f cleanup all but one linting issue (#1232) 2019-01-31 10:08:31 -07:00
Andrej GajdosandTanner Linsley c7d2c36454 adding position prop into pagination component (#1205)
- adding isTop prop into pagination component, which allows
differentiate if pagination is on top or bottom of the table
2019-01-31 10:08:06 -07:00
Laurent PandTanner Linsley 26961d0994 [fix] filter data on all available columns not just visible one (#1148) 2019-01-31 10:07:06 -07:00
Devin ClarkandTanner Linsley de6389cafc Adding IDs for select table, fixing backwards compatibility on floating left checkbox (#1208)
* Adding IDs for select all and individual row checkboxes

* Using keyfield const
2019-01-31 10:06:47 -07:00
Rahul VermaandTanner Linsley e0f9d98819 Adds aria-label prop to checkboxes (#1191) 2019-01-31 10:05:15 -07:00
Grzegorz RozdzialikandTanner Linsley 0365057446 Extract pagination elements renderers to pagination props (#1176)
Pagination elements are now customizable without having
to create a new Pagination component, that would
mostly mimic the existing one in terms of functionality.
2019-01-31 10:03:27 -07:00
StevenandTanner Linsley ec25bfbb5a fixed the sanbox code issue (#1174)
* fixed the sabox code issue

* add --copy-files flag to copy ti svg files to lib folder
2019-01-31 10:02:41 -07:00
Evan BrodieandTanner Linsley 0a1c12faca Adds import instructions to the HOC README (#1168)
* Adds import instructions to the HOC README

Also fixes up some language and remove other import instructions. It's better to just have the import instructions in just one place.

* Better visualizes a list of functions
2019-01-31 10:02:12 -07:00
AndyandTanner Linsley 1fddb1b97d Example code fixed with missing return statement (#1154) 2019-01-31 10:01:58 -07:00
Tanner Linsley 1e04377de7 Update README.md 2019-01-28 14:55:32 -07:00
Tanner Linsley 555c4fae9d Update README.md 2019-01-28 14:35:05 -07:00
Tanner Linsley 0d8ca53b76 Update README.md 2019-01-28 14:34:04 -07:00
Tanner Linsley 64db8e09d4 Update .gitignore 2019-01-28 13:47:31 -07:00
Tanner LinsleyandGitHub c5233c4404 Update README.md 2019-01-16 08:56:50 -07:00
Tanner LinsleyandGitHub d0d862f1e8 Add files via upload 2019-01-16 08:55:42 -07:00
Tanner LinsleyandGitHub dd3f30b099 Update bug_report.md 2018-10-04 14:55:20 -06:00
Tanner LinsleyandGitHub d5fc894dd7 Delete ISSUE_TEMPLATE.md 2018-10-04 14:54:16 -06:00
Tanner Linsley dc771ff25f Update issue templates 2018-10-04 14:53:51 -06:00
simjohandTanner Linsley d38021d4b0 Updated ReadMe with some more Props (#1142)
I found the added Props by looking into the defaultProps.js when I could not find a way change the styling of the filter row.
Custom Props
Built-in Components
Every single built-in component's props can be dynamically extended using any one of these prop-callbacks:

<ReactTable
  getProps={fn}
  getTableProps={fn}
  getTheadGroupProps={fn}
  getTheadGroupTrProps={fn}
  getTheadGroupThProps={fn}
  getTheadProps={fn}
  getTheadTrProps={fn}
  getTheadThProps={fn}
  +getTheadFilterProps={fn}
  +getTheadFilterTrProps={fn}
  +getTheadFilterThProps={fn}
2018-10-04 14:51:28 -06:00
Jannik KeyeandTanner Linsley 06648b2577 feature: allow minResizeWidth to be set (#1135)
* feature: allow minResizeWidth to be set

* fix: add minResizeWidth propType
2018-10-04 14:49:11 -06:00
Leonardo MerzaandTanner Linsley 836f256031 added closeExpanded function to subComponent callback (#1121) 2018-10-04 14:48:18 -06:00
Colton ColcleasureandTanner Linsley 188fc51336 Fixed defaultProps.selectType. (#1129)
Changed defaultProps.selectType from "check" to "checkbox".
2018-10-04 14:47:49 -06:00
tragessereandTanner Linsley 474244ce41 Pagination accessibility (#1127)
* Add aria-label attributes to pagination jump and row count selector with a new prop to specify different text.

* Add new text props for labels to README
2018-10-04 14:47:30 -06:00
Jakub ŻurawskiandTanner Linsley b6074a9ab1 Accesibility improvement - add role to tr in treeTable (#1114) 2018-10-04 14:45:40 -06:00
Mohamed NimirandTanner Linsley 3278e1b05e Update README.md (#1086)
Fixed server-side data bad example link to point to https://react-table.js.org/#/story/server-side-data instead of 404 link https://github.com/react-tools/react-table/blob/master/stories/ServerSide.js

Fixes #929
2018-10-04 14:44:15 -06:00
Alec ReserandTanner Linsley 2352cac4b8 Added placeholder to filter input. (#1087)
* Added placeholder to filter input.

* Changed package.json version.
2018-10-04 14:42:59 -06:00
Robin PhamandTanner Linsley d94f59a5fa only update state if page prop changes (#1082) 2018-10-04 14:42:37 -06:00
Jeremy LibermanandTanner Linsley 7876a3876c Resolve "cannot call class as a function" error (#1050)
When rendering a class component using the `class extends React.Component {}` syntax, you would get an error `TypeError: Cannot call a class as a function` because the check to determine whether a component was a class component was insufficient. It seems pointless to even have a check, however, because the JSX syntax can render both class and functional components.
2018-10-04 14:42:16 -06:00
maxime romaandTanner Linsley 02e65b4388 fix linter , update selectTable hoc (#1073)
* fix lint on foldable file add options to choose postion of checkbox
column

* (update hoc): selecttable options parameters position
2018-10-04 14:41:24 -06:00
Shubham KanodiaandTanner Linsley d9d49fa3de Adds "prop-types" as a peerDependency (#1069)
* Adds "prop-types" as a peerDependency

* Removed trailling comma
2018-10-04 14:40:13 -06:00
Kyle HallemanandTanner Linsley 41784cd52d allow rest props from getTfootProps for TfootComponent (#1035) 2018-10-04 14:39:48 -06:00
Mayank JethvaandTanner Linsley 9048835bcc ReactTable HOC: advancedExpandTable (#1000)
* initial commit

* update readme

* update examples and src

* edit readme

* use single instance of advancedExpandTable

* add in hoc codesandbox to docs, run eslint on new source file
2018-10-04 14:39:07 -06:00
Bret IkeharaandTanner Linsley b12fc8fc88 remove space in Logo name (#1033) 2018-10-04 14:38:33 -06:00
Krzysztof KaczmarczykandTanner Linsley 76fde77b0f Add additional column's renderers in TreeTable HOC (#1029)
Pass Expander, PivotValue and Pivot renderers to to column constructor in TreeTable HOC
2018-10-04 14:37:44 -06:00
smoleniuchandTanner Linsley f50b0a47cf SelectTable - Make input component type defaults to checkbox (#1021) 2018-10-04 14:37:19 -06:00
Don PflasterandTanner Linsley ac8b497671 Tree uses accessor or ID and always shows pivot cells (#1011)
* Also check ID field when finding pivot col in treeTableHOC

* Pass the ID if you've got one on treeTableHOC

* An expandable cell should never be hidden
2018-10-04 14:36:46 -06:00
Rebekah Heacock JonesandTanner Linsley c79806090a Fix propTypes validation for getFooterProps (#1007)
This should be a function (like the other getXProps), not an object
2018-10-04 14:36:20 -06:00
Tanner Linsley f55ce62041 Merge branch 'master' of https://github.com/react-tools/react-table 2018-05-29 10:56:34 -06:00
Mario ViensandTanner Linsley 4c9b44ab48 documentation formatting fix (#986) 2018-05-28 01:11:35 -06:00
Tanner Linsley 48869a65e7 Better issue template 2018-05-24 17:00:17 -06:00
emyarodandTanner Linsley 3246336120 Add cross-env package (#873)
* Fix typo

* Edit link to working codesandbox

Fix '100k Rows w/ Pivoting & Sub Components' example

Closes #870

* Add cross-env to remove environment variable errors on Windows
2018-05-24 16:36:37 -06:00
Efim PasianidiandTanner Linsley b12238d535 Add defaultPage prop (#941)
* add defaultPage prop

* fix defaultPage in manual mode
2018-05-24 16:36:19 -06:00
Mark McDonaldandTanner Linsley 1f92ed8d4f Add more documentation for overriding props (#975)
I think this is the most common way of setting columns or expanderDefaults.

I had to find issue #565 and then follow it to issue #394 to see explanations on how to do this.
2018-05-24 16:35:22 -06:00
TerryLeeandTanner Linsley cf59c644b4 Just correct names of parameters for onFilteredChanged (#967) 2018-05-24 16:33:09 -06:00
Steve SharpandTanner Linsley a7e8e26c00 Update README.md (#973)
Fixes typo
2018-05-24 16:32:50 -06:00
StevenandTanner Linsley dd4c1e2df6 add FoldableTable (#937)
I have used this library to develop a big application for my company and had been required to make the columns are foldable. I saw that feature is useful and would like to share with everybody. Especially to all developers who developed this great component.

Let me know if any issues with My component. I will fix it accordingly.
2018-05-24 16:32:34 -06:00
Anthon FredrikssonandTanner Linsley 621c3bf092 Fixed text mismatch when doing SSR (#957)
* fixed a mismatch issue when doing ssr. made some windows-specific changes to ease contributing

* remove accidentally committed file
2018-05-24 16:27:57 -06:00
Bill FienbergandTanner Linsley 72afabbd03 Fix README: defaultSortMethod doesn't match code (#910)
Updating the `defaultSortMethod` in the README to match the [code](https://github.com/react-tools/react-table/blob/3a8a037ee68b11e329c581a8d61a37db276a0dbf/src/defaultProps.js#L46)
2018-05-24 16:25:57 -06:00
Stuart CasarottoandTanner Linsley 4aa07c33da Typo (#899)
arra -> array
2018-05-24 16:25:41 -06:00
Frank NguyenandTanner Linsley d430d51888 Added react-dom as a peer dependency (#889) 2018-05-24 16:25:28 -06:00
AndrewandTanner Linsley 4824b4c8cc Remove header focus outline. Fixes react-tools/react-table#685 (#881) 2018-05-24 16:24:54 -06:00
Richard AandTanner Linsley 60766cf261 Add prefix to key of pad rows (#828)
Add prefix to key of pad rows so it doesn't conflict with keys of page rows.
Duplicate keys are causing rendering issues with preact.
2018-05-24 16:23:53 -06:00
Tanner Linsley fcdc3d88bc v6.8.6 2018-05-24 10:24:29 -06:00
Tanner Linsley 24a9efd670 v6.8.5 2018-05-19 00:47:17 -06:00
Tanner Linsley bdb7d44438 v6.8.4 2018-05-18 17:34:41 -06:00
Tanner Linsley 7a6ed50b81 Make data prop required, but allow it to be anything. 2018-05-18 17:34:03 -06:00
Tanner Linsley 8f062550aa v6.8.3 2018-05-18 17:32:04 -06:00
576 changed files with 307665 additions and 23911 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"loose": true
}
],
"@babel/react"
],
"env": {
"test": {
"presets": ["@babel/preset-env", "@babel/react"]
}
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": ["react-app", "prettier"]
}
-3
View File
@@ -1,3 +0,0 @@
module.exports = {
extends: 'react-tools',
}
+1
View File
@@ -0,0 +1 @@
* text=auto
+5
View File
@@ -0,0 +1,5 @@
# These are supported funding model platforms
github: tannerlinsley
patreon: tannerlinsley
custom: https://youtube.com/tannerlinsley
+48
View File
@@ -0,0 +1,48 @@
---
name: Bug report
about: Create a report to help us improve
---
# Using v6?
v6 is now considered feature complete to its current abilities and limitations. We are not actively working to fix any issues for v6 any more. We will, however, merge any non-breaking pull requests submitted to fix anything in v6.
# Using v7?
Thanks for using the beta version of React Table v7! We're very excited about it.
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Codesandbox!**
Use a new [react-table codesandbox](https://codesandbox.io/s/m5lxzzpz69) to reproduce the issue.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
@@ -0,0 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
---
# STOP
We do not track feature requests through Github. Please use the [Spectrum React Table Forum](https://spectrum.chat/react-table) to talk about new ideas and features.
@@ -0,0 +1,11 @@
---
name: Questions, Support & Help
about: Looking for help? Need a question answered?
---
# STOP
We do not use Github to track general support. Please use our public support forum at https://spectrum.chat/react-table.
NOTE: If a support/help/question issue is opened, it will be closed immediately and be redirected to the forum. Thanks for helping us keep our issues clean and productive!
+27
View File
@@ -0,0 +1,27 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build-and-test:
name: '${{ matrix.platform }}: node.js ${{ matrix.node-version }}'
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10, 12]
runs-on: ${{ matrix.platform }}
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Build and test
run: |
yarn install
yarn test
+3
View File
@@ -0,0 +1,3 @@
size-files:
- sizes-cjs.json
- sizes-es.json
+6 -3
View File
@@ -1,6 +1,7 @@
node_modules/
lib/
es/
node_modules
lib
dist
es
docs/build
react-table.js
react-table.min.js
@@ -8,3 +9,5 @@ react-table.css
*.log
.idea
.DS_Store
.history
package-lock.json
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
hooks: {
'pre-commit': 'lint-staged && yarn test:ci',
// 'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
},
}
+1
View File
@@ -0,0 +1 @@
package-lock=false
+40
View File
@@ -0,0 +1,40 @@
{
"dist/index.js": {
"bundled": 107213,
"minified": 49659,
"gzipped": 13264
},
"dist/index.es.js": {
"bundled": 106302,
"minified": 48847,
"gzipped": 13099,
"treeshaked": {
"rollup": {
"code": 80,
"import_statements": 21
},
"webpack": {
"code": 8249
}
}
},
"dist\\index.js": {
"bundled": 105386,
"minified": 49565,
"gzipped": 13008
},
"dist\\index.es.js": {
"bundled": 104543,
"minified": 48815,
"gzipped": 12856,
"treeshaked": {
"rollup": {
"code": 80,
"import_statements": 21
},
"webpack": {
"code": 8444
}
}
}
}
+16 -2
View File
@@ -1,4 +1,18 @@
language: node_js
node_js:
- "6"
script: npm test
- 10
- 12
os:
- linux
- osx
- windows
env:
global:
- YARN_GPG=no
cache: yarn
script: yarn test
+307 -70
View File
@@ -1,41 +1,278 @@
## 7.0.0-rc.11
- Fixed an issue where plugins using the `columns` hook were not getting decorated properly
- Added back a new rendition of the `useFlexLayout` plugin and accompanying example.
- Fixed all reset actions to use the initial state passed into the table, then fall back to the default initial state for the hook
## 7.0.0-rc.10
- Optimizations made to make accessors, prop getters and other internals much faster. 10x in some cases!
- Fixed docs for `usePagination` to have `pageIndex` and `pageSize` only available on the state object, not the instance
- Added a plugin order restriction to make sure `useResizeColumns` always comes before `useAbsoluteLayout`
- Fixed the `useFinalInstance` hook to not have an empty array as the first meta argument passed.
- Fixed an issue where memoized or ref-forwarded components could not be used as cell renderers
- The `toggleExpandedById` action has been renamed to `toggleExpanded`
- Added the `toggleAllExpanded` action
- Added the `setExpanded` action
- Changed `row.isAggregated` to `row.isGrouped`
- `state.expanded` and `state.selectedRowIds` are now objects (`{[rowId]: Bool}`), not arrays. This should help with mid-to-large size datasets while also being serializable (instead of a Set(), which is not as reliable)
- `state.filters` is now an array of objects (`{id, value}`). Since filters do have order and can be applied incrementally, it should be an array to ensure correct order.
- Moved the `flatColumns` and `flatColumnsDeps` hooks to be after row/data materialization. These hooks can then manipulate the `flatColumns` object after all data has been accessed without triggering row materialization again.
- Added the `row.allCells` property and the `cellColumns` reducer hook to determine which cells to create for each row. These cells are placed into `row.allCells`. The resulting cell array is not meant to be used for display in templating and is only made available for convenience and/or advanced templating.
- Added the `cells` reducer hook to determine which cells from the `row.allCells` array that should be placed into `row.cells`. The resulting cell array is the one that is intended for display in templating.
- Reducers are now passed the actual instance variable, not the instanceRef
- Added the `makeRenderer` utility (also exported)
- Removed `column.groupByBoundary` functionality. If needed, use the `flatColumns` hook to decorate, reorganize or re-order groupBy columns
- Fixed grouped row.id's to be truly unique
## 7.0.0-rc.9
- Fixed an issue where dependency hooks were not being reduced properly, thus the table would rerender unnecessarily
- Renamed `toggleRowSelectedAll` to `toggleAllRowsSelected`. Duh...
- Added an `indeterminate` boolean prop to the default props for row selection toggle prop getters
- Renamed `selectedRowPaths` to `selectedRowIds`, which also no longer contains paths, but row IDs
- Grouped or nested row selection actions and state are now derived, instead of tracked in state.
- Rows now have a new property called `id`, which existed before and was derived from the `getRowId` option
- Rows now also have an `isSomeSelected` prop when using the `useRowSelect` hook, which denotes that at least one subRow is selected (if applicable)
- Rows' `path` property has been deprecated in favor of `id`
- Expanded state is now tracked with row IDs instead of paths
- RowState is now tracked with row IDs instead of paths
- `toggleExpandedByPath` has been renamed to `toggleExpandedById`, and thus accepts a row ID now, instead of a row path
## 7.0.0-rc.8
- Fix an issue where `useResizeColumns` would crash when using the resizer prop getter
- Fix an issue where `useBlockLayout` was clobbering props sent to headers
## 7.0.0-rc.7
Removed:
- `applyHooks` (exported but undocumented) function has been deprecated. Please use either `reduceHooks` or `loopHooks` utilities in your custom plugins now.
- `applyPropHooks` (exported but undocumented) function has been deprecated. Please use the `makePropGetter` utility in your custom plugins now.
Added:
- `reduceHooks` exported utility which is used to reduce a value through a collection of hooks. Each hook must return a value (mutation is discouraged)
- `loopHooks` exported utility which is used to loop over a collection of hooks. Hooks are not allowed to return a value (mutation is encouraged)
- `makePropGetter` exported utility which is used to create prop getters from a prop getter hook.
- `useOptions` plugin hook, which allows a plugin to reduce/modify the initial options being passed to the table
- `useFinalInstance` plugin hook, which allows a plugin access to the final table instance before it is returned to the user.
Modified:
- Prop-getter hook functions now support returning an array (in addition to the typical object of props). When an array is returned, each item in the array is smart-merged into a new props object (meaning it will intelligently compose and override styles and className)
- Prop-getter function supplied to the table have 2 new overloaded options (in addition to the typical object of props):
- `Function(props, instance, ...row/col/context) => Array<props> | props` - If a function is passed to a prop getter function, it will receive the previous props, the table instance, and potentially more context arguments. It is then be expected to return either an array of new props (to be smart-merged with styles and classes, the latest values taking priority over the previous values) or a props object (which will replace all previous props)
- `Array<props>` - If an array is passed to a prop getter function, each prop object in the array will be smart-merged with styles and classes into the props from previous hooks (with the latest values taking priority over the previous values).
- Extracted default hooks into separate file.
- Converted almost all usages of `instanceRef.current` to use `useGetLatest(instanceRef.current)` to help with avoiding memory leaks and to be more terse.
- Converted all previous prop-getter definitions to use the new `makePropGetter`
- Reorganized plugin hooks to declare as many hooks in the main plugin function as opposed to in the `useInstance` hook.
- Changed the `useInstanceBeforeDimensions` hook to be a `loopHooks` call instead of a reducer. An error will be thrown now if any of these hook functions returns a value (to encourage mutation of the instance)
- Changed the `useInstance` hook to be a `loopHooks` call instead of a reducer. An error will be thrown now if any of these hook functions returns a value (to encourage mutation of the instance)
- Change the `prepareRow` hook to be a `loopHooks` call instead of a reducer. An error will be thrown now if any of these hook functions returns a value (to encourage mutation of the row)
## 7.0.0-rc.6
- The `columnsBeforeHeaderGroups` and `columnsBeforeHeaderGroupsDeps` hooks have been renamed to `flatColumns` and `flatColumnsDeps` respectively, which better reflects what they are used for, rather than their order, which can remain implicit.
- Added `headerGroups` and `headerGroupDeps` hooks, which, similar to `flatColumns`, allow you to decorate (and trigger) the memoized header group generation.
- Added `columns` and `columnsDeps` hooks, which, similar to `flatColumns` and `headerGroups`, allow you to decorate (and trigger) the memoized column generation/decoration.
- The new hook order is as follows: `columns/columnsDeps` => `flatColumns/flatColumnsDeps` => `headerGroups/headerGroupsDeps`
- `useColumnVisibility` now uses the new `headerGroupsDeps` hook to trigger header group regeneration when visibility changes
## 7.0.0-rc.5
- Fixed an issue where the exported `useAsyncDebounce` method would crash if its promise throw an error.
## 7.0.0-rc.4
- A maintenance release, purely intended to update the @latest tag (which was overwritten by a v6 publish)
## 7.0.0-rc.3
- Fixed an issue where `column.clearSortBy` would crash
## 7.0.0-rc.2
- `reducerHandlers` has been deprecated in favor of the new `stateReducers` hook.
- The `previousState` and `instanceRef` are now both generally available in state reducers for convenience.
- The global action property `action.instanceRef` has been deprecated.
- The `reducer` option has been renamed to `stateReducer` and in addition to passing a single reducer function now also supports passing an array of reducers
- Renamed `manualSorting` to be `manualSortBy` to be consistent with other naming conventions
- Removed the `getResetPageDeps` option in favor of the new `autoResetPage` option.
- Removed the `getResetFilterDeps` option in favor of the new `autoResetFilters` option.
- Removed the `getResetSortByDeps` option in favor of the new `autoResetSortBy` option.
- Removed the `getResetGroupByDeps` option in favor of the new `autoResetGroupBy` option.
- Removed the `getResetExpandedDeps` option in favor of the new `autoResetExpanded` option.
- Added a new exported utility called `useAsyncDebounce` to aid with external async side-effects.
- A new `useGetLatest` hook is used internally to track latest instances in a less ref-driven and verbose way.
- A new `useMountedLayoutEffect` hooks is now used internally to handle post-mount side-effects, mostly dealing with autoReset functionality
- Plugin hooks are now "consumed" using an internal `useConsumeHookGetter` hook. When they are consumed, they can no longer be manipulated past that point in the table lifecycle. This should help ensure people are using them in a relatively safe order with consistent expectations.
- Drastically "reduced" the reducer logic itself to be easier to understand and to be a stable reference for the life of the table. This change also means that the reducer must no longer be double-run/back-compared by React for changes in closure, thus actions and stateReducers (including user state reducers) will only fire once per action.
- Removed `debug` and related logging. It has been somewhat useful during development, but is now very noisy in the code. We can debug lifecycle and performance as needed from here on out.
- Removed unnecessary exports from `./utils.js` and moved all intentionally exported utilities to a new `./publicUtils.js` file.
## 7.0.0-rc.1
- Minor regex optimizations during row path creation
## 7.0.0-rc.0
- Added the support for the `Footer` renderer, `column.getFooterProps`, `footerGroups` and `footerGroup.getFooterProps`
## 7.0.0-beta.28
- Added the `useColumnVisibility` plugin as a core plugin along with several new instance and column-level methods to control column visibility
- Added the "column-hiding" example
## 7.0.0-beta.27
- Added the `useControlledState` option, which allows for hook-context control of the resolved internal table state
## 7.0.0-beta.26
- Fixed an issue where the table would crash if useSortBy was reset via the resetSortBy action
- Updated all of the examples to use the "react-table@latest" tag.
- `utils` is no longer an exported variable and instead, all of the individual util methods are exported at the root level of the library.
## 7.0.0-beta.25
- Fixed an issue where `useRowState` would crash due to invalid initial state of previous cell state on `columnId` lookup
## 7.0.0-beta.24
- Changed `selectedRowIds` to use a `Set()` instead of an array for performance.
- Removed types and related files from the repo. The community will now maintain types externally on Definitely Typed
## 7.0.0-beta.23
- The internal `useMain` hook has been renamed to `useInstance`
- The internal `useBeforeDimensions` hook has been renamed to `useInstanceBeforeDimensions`
- Fixed an issue where `useResizeColumns` wasn't working properly
## 7.0.0-beta.22
- Fixed an issue where `useRowState` would crash due to invalid initial state attempting to spread into the new state
## 7.0.0-beta.21
- Removed deprecated `defaultState` export
## 7.0.0-beta.20
- Internals have been reworked to use `useReducer` instead of `useState` for stability and architecture
- The `state` option has been removed in favor of using a custom reducer
- The `reducer` option has been changed to a new function signature: `function (newState, action, oldState) => newState`
- The `setState` table instance method is no longer supported
- The `dispatch` table instanced method was added
- The `ReactTable.actions` export is now a plain object of action types mapped to identically named action strings
- The `ReactTable.reducerHandlers` export was added, which is a plain object of plugin hook names mapped to their respective reducer functions
## 7.0.0-beta.19
- Added an `isAggregated` boolean parameter to the `aggregate` function signature
## 7.0.0-beta.16
- Removed service workers from examples
- Fixed a memory leak when `instance` was referenced in function closures
- Fixed an issue where the table would infinitely rerender due to incorrect effect dependencies
- Fixed an issue where row grouping and row selection would not work properly together.
## 7.0.0-beta.15
- Fixed an issue where `defaultGetResetPageDeps` was using `data` instead of `rows`
## 7.0.0-beta.14
- Removed
- `disablePageResetOnDataChange` option. use the `getResetPageDeps` option now.
- Added
- `getResetPageDeps` option
- `getResetFilterDeps` option
- `getResetSortByDeps` option
- `getResetGroupByDeps` option
- `getResetExpandedDeps` option
## 7.0.0-beta.13
- Added options
- `defaultCanSort`
- `defaultCanFilter`
- `defaultCanGroupBy`
- `column.defaultCanSort`
- `column.defaultCanFilter`
- `column.defaultCanGroupBy`
- Renamed
- `disableGrouping` to `disableGroupBy`
- `disableSorting` to `disableSortBy`
- `disableGroupBy` to `disableGroupBy`
- `column.disableGrouping` to `column.disableGroupBy`
- `column.disableSorting` to `column.disableSortBy`
- `column.disableGroupBy` to `column.disableGroupBy`
- Removed propType definitions. Since types are now being maintained, it makes little sense to also maintain these. Cooincidentally, this also saves some bundle size in some scenarios where they may not be removed properly by a developer's bundler.
## 7.0.0-beta.0
- Massive changes to the entire project and library. Please consult the README and documentation for more information regarding these changes.
## 6.8.6
#### Fixes & Optimizations
- Since `resolveData` is now capable of materializing data on it's own, the `data` prop is no longer required as a prop-type.
## 6.8.4
#### Fixes & Optimizations
- Only run `resolveData` prop when `data` prop has changed, not any others.
## 6.8.3
#### Fixes & Optimizations
- Allow the `resolveData` prop to alter or materialize new data when the `data` prop changes.
## 6.8.1
#### Fixes & Optimizations
* Updated eslint and code formatting
- Updated eslint and code formatting
## 6.7.5
#### Fixes & Optimizations
* Now passes `column` to `getResizerProps` (#667)
* NOTE: `getResizerProps` is now only called if the column is resizable
* Fixes the `className` ordering in defaultProps for ThComponent (#673)
* NOTE: user supplied classNames now come at the end so they can extend the defaults
- Now passes `column` to `getResizerProps` (#667)
- NOTE: `getResizerProps` is now only called if the column is resizable
- Fixes the `className` ordering in defaultProps for ThComponent (#673)
- NOTE: user supplied classNames now come at the end so they can extend the defaults
## 6.7.4
#### Fixes & Optimizations
* Fix Prop types for columns
- Fix Prop types for columns
## 6.7.3
#### Fixes & Optimizations
* Fix the rest of the proptypes
- Fix the rest of the proptypes
## 6.7.2
#### Fixes & Optimizations
* `getPropTypes` proptype check
- `getPropTypes` proptype check
## 6.7.1
#### Fixes & Optimizations
* `eslint-config` moved to dev deps
- `eslint-config` moved to dev deps
## 6.7.0
@@ -43,113 +280,113 @@
#### New Features
* Expose page/pageSize to rows/cells
* Supply sort direction to custom sort methods
- Expose page/pageSize to rows/cells
- Supply sort direction to custom sort methods
#### Fixes & Optimizations
* README updates
* Linter cleanup
* Added PropTypes node module
* Deps, linting and style upgrades
- README updates
- Linter cleanup
- Added PropTypes node module
- Deps, linting and style upgrades
## 6.6.0
#### Fixes & Optimizations
* moved repo to react-tools
* Doc examples moved to codesandbox.io
* README updates
* CSS refacting for rt-tfoot to match rt-thead
* CSS more specific for input and select
- moved repo to react-tools
- Doc examples moved to codesandbox.io
- README updates
- CSS refacting for rt-tfoot to match rt-thead
- CSS more specific for input and select
## 6.5.3
#### Fixes & Optimizations
* `onClick` proxying and eslint
- `onClick` proxying and eslint
## 6.5.2
#### New Features
* Provide onClick handleOriginal function - #406
- Provide onClick handleOriginal function - #406
#### Fixes & Optimizations
* README updates
* `makePathArray` in utils - #326
* Various fixes: #294, #376, #398, #415,
- README updates
- `makePathArray` in utils - #326
- Various fixes: #294, #376, #398, #415,
## 6.5.1
#### Fixes & Optimizations
* `defaultExpanded` now works correctly - #372
* `column.getProps().rest` props are now applied correctly
* `makeTemplateComponent` now supports `displayName` - #289
- `defaultExpanded` now works correctly - #372
- `column.getProps().rest` props are now applied correctly
- `makeTemplateComponent` now supports `displayName` - #289
## 6.5.0
##### New Features
* `column.filterAll` - defaults to `false`, but when set to `true` will provide the entire array of rows to `filterMethod` as opposed to one row at a time. This allows for more fine-grained filtering using any method you can dream up. See the [Custom Filtering example](https://react-table.js.org/#/story/custom-filtering) for more info.
- `column.filterAll` - defaults to `false`, but when set to `true` will provide the entire array of rows to `filterMethod` as opposed to one row at a time. This allows for more fine-grained filtering using any method you can dream up. See the [Custom Filtering example](https://react-table.js.org/#/story/custom-filtering) for more info.
## 6.4.0
##### New Features
* `PadRowComponent` - the content rendered inside of a padding row. Defaults to a react component that renders `&nbsp;`
- `PadRowComponent` - the content rendered inside of a padding row. Defaults to a react component that renders `&nbsp;`
## 6.3.0
##### New Features
* `defaultSortDesc` - allows you to set the default sorting direction for all columns to descending.
* `column.defaultSortDesc` - allows you to set the default sorting direction for a specific column. Falls back to the global `defaultSortDesc` when not set at all.
- `defaultSortDesc` - allows you to set the default sorting direction for all columns to descending.
- `column.defaultSortDesc` - allows you to set the default sorting direction for a specific column. Falls back to the global `defaultSortDesc` when not set at all.
## 6.0.0
##### New Features
* New Renderers:
* `Aggregated` - Custom renderer for aggregated cells
* `Pivot` - Custom renderer for Pivoted Cells (utilizes `Expander` and `PivotValue`)
* `PivotValue` - Custom renderer for Pivot cell values (deprecates the undocumented `pivotRender` option)
* `Expander` - Custom renderer for Pivot cell Expander
* Added custom sorting methods per table via `defaultSortMethod` and per column via `column.sortMethod`
* Pivot columns are now visibly separate and sorted/filtered independently.
* Added `column.resizable` to override global table `resizable` option for specific columns.
* Added `column.sortable` to override global table `sortable` option for specific columns.
* Added `column.filterable` to override global table `filterable` option for specific columns.
* Added `defaultExpanded` table option.
* All callbacks can now be utilized without needing to hoist and manage the piece of state they export. That is what their prop counterparts are for, so now the corresponding prop is used instead of the callback to detect a "fully controlled" state.
* Prevent transitions while column resizing for a smoother resize effect.
* Disable text selection while resizing columns.
- New Renderers:
- `Aggregated` - Custom renderer for aggregated cells
- `Pivot` - Custom renderer for Pivoted Cells (utilizes `Expander` and `PivotValue`)
- `PivotValue` - Custom renderer for Pivot cell values (deprecates the undocumented `pivotRender` option)
- `Expander` - Custom renderer for Pivot cell Expander
- Added custom sorting methods per table via `defaultSortMethod` and per column via `column.sortMethod`
- Pivot columns are now visibly separate and sorted/filtered independently.
- Added `column.resizable` to override global table `resizable` option for specific columns.
- Added `column.sortable` to override global table `sortable` option for specific columns.
- Added `column.filterable` to override global table `filterable` option for specific columns.
- Added `defaultExpanded` table option.
- All callbacks can now be utilized without needing to hoist and manage the piece of state they export. That is what their prop counterparts are for, so now the corresponding prop is used instead of the callback to detect a "fully controlled" state.
- Prevent transitions while column resizing for a smoother resize effect.
- Disable text selection while resizing columns.
##### Breaking API Changes
* New Renderers:
* `Cell` - deprecates and replaces `render`
* `Header` - deprecates and replaces `header`
* `Footer` - deprecates and replaces `footer`
* `Filter`- deprecates and replaces `filterRender`
* Callbacks now provide the destination state as the primary parameter(s). This makes hoisting and controlling the state in redux or component state much easier. eg.
* `onSorting` no longer requires you to build your own toggle logic
* `onResize` no longer requires you to build your own resize logic
* Renamed `onChange` callback -> `onFetchData` which will always fire when a new data model needs to be fetched (or if not using `manual`, when new data is materialized internally).
* Renamed `filtering` -> `filtered`
* Renamed `sorting` -> `sorted`
* Renamed `expandedRows` -> `expanded`
* Renamed `resizing` -> `resized`
* Renamed `defaultResizing` -> `defaultResized`
* Renamed `defaultFiltering` -> `defaultFiltered`
* Renamed `defaultSorting` -> `defaultSorted`
* Renamed `onSortingChange` -> `onSortedChange`
* Renamed `onFilteringChange` -> `onFilteredChange`
* Renamed `onResize` -> `onResizedChange`
* Renamed `onExpandRow` -> `onExpandedChange`
* Renamed `showFilters` -> `filterable`
* Renamed `hideFilter` -> `filterable` (Column option. Note the true/false value is now flipped.)
* `cellInfo.row` and `rowInfo.row` now reference the materialize data for the table. To reference the original row, use `cellInfo.original` and `rowInfo.original`
* Removed `pivotRender` column option. You can now control how the value is displayed by overriding the `PivotValueComponent` or the individual column's `PivotValue` renderer. See [Pivoting Options Story](https://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Pivoting%20Options&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel) for a reference on how to customize pivot column rendering.
- New Renderers:
- `Cell` - deprecates and replaces `render`
- `Header` - deprecates and replaces `header`
- `Footer` - deprecates and replaces `footer`
- `Filter`- deprecates and replaces `filterRender`
- Callbacks now provide the destination state as the primary parameter(s). This makes hoisting and controlling the state in redux or component state much easier. eg.
- `onSorting` no longer requires you to build your own toggle logic
- `onResize` no longer requires you to build your own resize logic
- Renamed `onChange` callback -> `onFetchData` which will always fire when a new data model needs to be fetched (or if not using `manual`, when new data is materialized internally).
- Renamed `filtering` -> `filtered`
- Renamed `sorting` -> `sorted`
- Renamed `expandedRows` -> `expanded`
- Renamed `resizing` -> `resized`
- Renamed `defaultResizing` -> `defaultResized`
- Renamed `defaultFiltering` -> `defaultFiltered`
- Renamed `defaultSorting` -> `defaultSorted`
- Renamed `onSortingChange` -> `onSortedChange`
- Renamed `onFilteringChange` -> `onFilteredChange`
- Renamed `onResize` -> `onResizedChange`
- Renamed `onExpandRow` -> `onExpandedChange`
- Renamed `showFilters` -> `filterable`
- Renamed `hideFilter` -> `filterable` (Column option. Note the true/false value is now flipped.)
- `cellInfo.row` and `rowInfo.row` now reference the materialize data for the table. To reference the original row, use `cellInfo.original` and `rowInfo.original`
- Removed `pivotRender` column option. You can now control how the value is displayed by overriding the `PivotValueComponent` or the individual column's `PivotValue` renderer. See [Pivoting Options Story](https://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Pivoting%20Options&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel) for a reference on how to customize pivot column rendering.
+76
View File
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at TANNERLINSLEY@GMAIL.COM. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
+28
View File
@@ -0,0 +1,28 @@
# Contributing
## Questions
If you have questions about implementation details, help or support, then please use our dedicated community forum at [Spectrum.chat/react-table](https://spectrum.chat/react-table) **PLEASE NOTE:** If you choose to instead open an issue for your question, your issue will be immediately closed and redirected to the forum.
## Reporting Issues
If you have found what you think is a bug, please [file an issue](https://github.com/tannerlinsley/react-table/issues/new). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [Spectrum.chat/react-table](https://spectrum.chat/react-table)
## Suggesting new features
If you are here to suggest a feature, first create an issue if it does not already exist. From there, we will discuss use-cases for the feature and then finally discuss how it could be implemented.
## Development
If you have been assigned to fix an issue or develop a new feature, please follow these steps to get started:
- Fork this repository
- Install dependencies by running `$ yarn`
- Link `react-table` locally by running `$ yarn link`
- Auto-build files as you edit by running `$ yarn start`
- Implement your changes and tests to files in the `src/` directory and corresponding test files
- To run examples, follow their individual directions. Usually this is just `$ yarn && yarn start`.
- To run examples using your local build, link to the local `react-table` by running `$ yarn link react-table` from the example's directory
- Document your changes in the root `README.md`
- To stage a commit, run `yarn commit`
- Submit PR for review
-18
View File
@@ -1,18 +0,0 @@
## What version of React-Table are you using?
Your bug may already be fixed in the latest release. Run `yarn upgrade react-table`!
Place your version here...
## What bug are you experiencing, or what feature are you proposing?
Please include a detailed explanation here...
## Use https://codesandbox.io/s/X6npLXPRW (by clicking the "Fork" button) to reproduce the issue.
Then paste a link to your newly forked codesandbox here...
## What are the steps to reproduce the issue?
1. list the steps
2. to reproduce
3. the issue
+207 -1013
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
# Using TypeScript with React-Table
Types for React Table are maintained externally by the Typescript community and are located at https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table.
Because React Table is not written in Typescript and the types are not maintained by the core team, there are no guarantees around the types always being up to date or working perfectly. If this is an issue for you, please contribute to the community types and discuss solutions there.
+1
View File
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] }
+17
View File
@@ -0,0 +1,17 @@
const path = require('path')
module.exports = {
moduleDirectories: [
'node_modules',
/*
* __dirname makes 'test/utils' available in tests, e.g.
*
* const {myModule} = require('utils/my-test-helper')
*/
__dirname,
],
rootDir: path.resolve(__dirname, '../../'),
roots: ['<rootDir>/src', __dirname],
transformIgnorePatterns: ['node_modules'],
snapshotSerializers: [require.resolve('snapshot-diff/serializer.js')],
}
+13
View File
@@ -0,0 +1,13 @@
const {rootDir} = require('./jest.common');
module.exports = {
rootDir,
displayName: 'lint',
runner: 'jest-runner-eslint',
testMatch: ['<rootDir>/src/**/*.js'],
testPathIgnorePatterns: ['node_modules', 'coverage', 'dist', '.test.js'],
};
+12
View File
@@ -0,0 +1,12 @@
const commonConfig = require('./jest.common')
module.exports = {
...commonConfig,
displayName: 'unit',
coverageDirectory: '../../coverage',
testMatch: ['<rootDir>/src/**/*.test.js'],
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
},
setupFilesAfterEnv: ['./configs/tests/setup.common.js'],
}
+2
View File
@@ -0,0 +1,2 @@
import '@testing-library/jest-dom/extend-expect'
import 'snapshot-diff/extend-expect'
-77
View File
@@ -1,77 +0,0 @@
module.exports = {
parserOptions: {
ecmaVersion: 8,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
node: false,
classes: true
},
sourceType: 'module'
},
parser: 'babel-eslint',
extends: ['standard'],
plugins: ['react'],
rules: {
// Nozzle
'jsx-quotes': [2, 'prefer-single'],
'comma-dangle': [2, 'always-multiline'],
// // React
'react/jsx-boolean-value': 2,
'react/jsx-curly-spacing': [2, 'never'],
'react/jsx-equals-spacing': [2, 'never'],
// 'react/jsx-indent': 2,
'react/jsx-indent-props': [2, 2],
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-undef': 2,
'react/jsx-tag-spacing': [
2,
{
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never'
}
],
'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
'react/self-closing-comp': 2,
'react/jsx-no-bind': [
2,
{
allowArrowFunctions: true,
allowBind: false,
ignoreRefs: true
}
],
'react/no-did-update-set-state': 2,
'react/no-unknown-property': 2,
'react/react-in-jsx-scope': 2,
'react/jsx-closing-bracket-location': [0, 'tag-aligned'],
'react/jsx-tag-spacing': [2, { beforeSelfClosing: 'always' }],
'react/jsx-wrap-multilines': 2,
'react/self-closing-comp': 2,
'react/jsx-key': 2,
'react/jsx-no-comment-textnodes': 2,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-target-blank': 2,
'react/jsx-no-undef': 2,
'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
'react/no-danger-with-children': 2,
'react/no-deprecated': 2,
'react/no-direct-mutation-state': 2,
'react/no-find-dom-node': 2,
'react/no-is-mounted': 2,
'react/no-render-return-value': 2,
'react/no-string-refs': 2,
'react/no-unknown-property': 2,
'react/react-in-jsx-scope': 2,
'react/require-render-return': 2
// 'react/jsx-max-props-per-line': [2, { maximum: 1 }]
}
}
-1
View File
@@ -1 +0,0 @@
react-table.js.org
+1 -1628
View File
File diff suppressed because it is too large Load Diff
+67
View File
@@ -0,0 +1,67 @@
# API
React Table uses React Hooks both internally and externally for almost all of its configuration and lifecycle management. Naturally, this is what allows React Table to be headless and lightweight while still having a concise and simple API.
React Table is essentially a compatible collection of **custom React hooks**:
- The primary React Table hook
- [`useTable`](./useTable.md)
- Plugin Hooks
- Core Plugin Hooks
- [`useGroupBy`](./useGroupBy.md)
- [`useFilters`](./useFilters.md)
- [`useSortBy`](./useSortBy.md)
- [`useExpanded`](./useExpanded.md)
- [`usePagination`](./usePagination.md)
- [`useTokenPagination` (Coming Soon)](./useTokenPagination.md)
- [`useRowSelect`](./useRowSelect.md)
- [`useRowState`](./useRowState.md)
- [`useColumnOrder`](./useColumnOrder.md)
- Layout Hooks
- [`useBlockLayout`](./useBlockLayout.md)
- [`useAbsoluteLayout`](./useAbsoluteLayout.md)
- [`useFlexLayout`](./useFlexLayout.md)
- [`useResizeColumns`](./useResizeColumns.md)
- 3rd Party Plugin Hooks
- Want your custom plugin hook listed here? [Submit a PR!](https://github.com/tannerlinsley/react-table/compare)
### Hook Usage
`useTable` is the **primary** hook used to build a React Table. It serves as the starting point for **every option and every plugin hook** that React Table supports. The options passed into `useTable` are supplied to every plugin hook after it in the order they are supplied, eventually resulting in a final `instance` object that you can use to build your table UI and interact with the table's state.
```js
const instance = useTable(
{
data: [...],
columns: [...],
},
useGroupBy,
useFilters,
useSortBy,
useExpanded,
usePagination
)
```
### The stages of React Table and plugins
1. `useTable` is called. A table instance is created.
1. The `instance.state` is resolved from either a custom user state or an automatically generated one.
1. A collection of plugin points is created at `instance.hooks`.
1. Each plugin is given the opportunity to add hooks to `instance.hook`.
1. As the `useTable` logic proceeds to run, each plugin hook type is used at a specific point in time with each individual hook function being executed the order it was registered.
1. The final instance object is returned from `useTable`, which the developer then uses to construct their table.
This multi-stage process is the secret sauce that allows React Table plugin hooks to work together and compose nicely, while not stepping on each others toes.
To dive deeper into plugins, see Plugins](TODO) and the [Plugin Guide
### Plugin Hook Order & Consistency
The order and usage of plugin hooks must follow The Laws of Hooks, just like any other custom hook. They must always be unconditionally called in the same order.
> **NOTE: In the event that you want to programmatically enable or disable plugin hooks, most of them provide options to disable their functionality, eg. `options.disableSortBy`**
### Option Memoization
React Table relies on memoization to determine when state and side effects should update or be calculated. This means that every option you pass to `useTable` should be memoized either via `React.useMemo` (for objects) or `React.useCallback` (for functions).
+43
View File
@@ -0,0 +1,43 @@
# `useAbsoluteLayout`
- Plugin Hook
- Optional
`useAbsoluteLayout` is a plugin hook that adds support for headers and cells to be rendered as absolutely positioned `div`s (or other non-table elements) with explicit `width`. Similar to the `useBlockLayout` hook, this becomes useful if and when you need to virtualize rows and cells for performance.
**NOTE:** Although no additional options are needed for this plugin to work, the core column options `width`, `minWidth` and `maxWidth` are used to calculate column and cell widths and must be set. [See Column Options](#column-options) for more information on these options.
### Instance Properties
- `getTableBodyProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for the table body
### Row Properties
- `getRowProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for rows
### Cell Properties
- `getCellProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for rows cells
### HeaderGroup Properties
- `getHeaderGroupProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
### Header Properties
- `getHeaderProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/absolute-layout)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/absolute-layout)
+37
View File
@@ -0,0 +1,37 @@
# `useBlocklayout`
- Plugin Hook
- Optional
`useBlocklayout` is a plugin hook that adds support for headers and cells to be rendered as `inline-block` `div`s (or other non-table elements) with explicit `width`. Similar to the `useAbsoluteLayout` hook, this becomes useful if and when you need to virtualize rows and cells for performance.
**NOTE:** Although no additional options are needed for this plugin to work, the core column options `width`, `minWidth` and `maxWidth` are used to calculate column and cell widths and must be set. [See Column Options](#column-options) for more information on these options.
### Row Properties
- `getRowProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for rows
### Cell Properties
- `getCellProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for rows cells
### HeaderGroup Properties
- `getHeaderGroupProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
### Header Properties
- `getHeaderProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/block-layout)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/block-layout)
+27
View File
@@ -0,0 +1,27 @@
# `useColumnOrder`
- Plugin Hook
- Optional
`useColumnOrder` is a plugin hook that implements **basic column reordering**. As columns are reordered, their header groups are reverse-engineered so as to never have orphaned header groups.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.columnOrder: Array<ColumnId>`
- Optional
- Defaults to `[]`
- Any column ID's not represented in this array will be naturally ordered based on their position in the original table's `column` structure
### Instance Properties
The following values are provided to the table `instance`:
- `setColumnOrder: Function(updater: Function | Array<ColumnId>) => void`
- Use this function to programmatically update the columnOrder.
- `updater` can be a function or value. If a `function` is passed, it will receive the current value and expect a new one to be returned.
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-ordering)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-ordering)
+58
View File
@@ -0,0 +1,58 @@
# `useExpanded`
- Plugin Hook
- Optional
`useExpanded` is the hook that implements **row expanding**. It is most often used with `useGroupBy` to expand grouped rows or on its own with nested `subRows` in tree-like `data` sets, but is not limited to these use-cases. It supports expanding rows both via internal table state and also via a hard-coded key on the raw row model.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.expanded: Object<rowId: String, expanded: Bool>`
- Optional
- Must be **memoized**
- An `object` of expanded row IDs with boolean property values.
- If a row's id is set to true in this object, that row will have an expanded state. For example, if `{ '3': true }` was passed as the `expanded` state, by default the **4th row in the original data array** would be expanded, since it would have that ID
- For nested expansion, you can **use nested IDs like `1.3`** to expand sub rows. For example, if `{ '3': true, '3.5': true }` was passed as the `expanded` state, then the **the 4th row would be expanded, along with the 6th subRow of the 4th row as well**.
- This information is stored in state since the table is allowed to manipulate the filter through user interaction.
- `getSubRows: Function(row, relativeIndex) => Rows[]`
- Optional
- See the [useTable hook](#table-options) for more details
- `manualExpandedKey: String`
- Optional
- Defaults to `expanded`
- This string is used as the key to detect manual expanded state on any given row. For example, if a raw data row like `{ name: 'Tanner Linsley', friends: [...], expanded: true}` was detected, it would always be expanded, regardless of state.
- `expandSubRows: Bool`
- Optional
- Defaults to `true`
- If set to `true`, expanded rows are rendered along with normal rows.
- If set to `false`, expanded rows will only be available through their parent row. This could be useful if you are implementing a custom expanded row view.
- `autoResetExpanded: Boolean`
- Defaults to `true`
- When `true`, the `expanded` state will automatically reset if any of the following conditions are met:
- `data` is changed
- To disable, set to `false`
- For more information see the FAQ ["How do I stop my table state from automatically resetting when my data changes?"](../faq.md#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes)
### Instance Properties
The following properties are available on the table instance returned from `useTable`
- `rows: Array<Row>`
- An array of **expanded** rows.
### Row Properties
The following additional properties are available on every `row` object returned by the table instance.
- `isExpanded: Bool`
- If `true`, this row is in an expanded state.
- `toggleExpanded: Function(?isExpanded: Bool) => void`
- This function will toggle the expanded state of a row between `true` and `false` or, if an `isExpanded` boolean is passed to the function, it will be set as the new `isExpanded` value.
- Rows with a hard-coded `manualExpandedKey` (defaults to `expanded`) set to `true` are not affected by this function or the internal expanded state.
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/expanding)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/expanding)
+94
View File
@@ -0,0 +1,94 @@
# `useFilters`
- Plugin Hook
- Optional
`useFilters` is the hook that implements **row filtering**.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.filters: Array<Object<id: String, value: any>>`
- Must be **memoized**
- An array of objects containing columnId's and their corresponding filter values. This information is stored in state since the table is allowed to manipulate the filter through user interaction.
- `manualFilters: Bool`
- Enables filter detection functionality, but does not automatically perform row filtering.
- Turn this on if you wish to implement your own row filter outside of the table (eg. server-side or manual row grouping/nesting)
- `disableFilters: Bool`
- Disables filtering for every column in the entire table.
- `defaultCanFilter: Bool`
- Optional
- Defaults to `false`
- If set to `true`, all columns will be filterable, regardless if they have a valid `accessor`
- `filterTypes: Object<filterKey: filterType>`
- Must be **memoized**
- Allows overriding or adding additional filter types for columns to use. If a column's filter type isn't found on this object, it will default to using the built-in filter types.
- For more information on filter types, see Filtering
- `autoResetFilters: Boolean`
- Defaults to `true`
- When `true`, the `filters` state will automatically reset if any of the following conditions are met:
- `data` is changed
- To disable, set to `false`
- For more information see the FAQ ["How do I stop my table state from automatically resetting when my data changes?"](./faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes)
### Column Options
The following options are supported on any `Column` object passed to the `columns` options in `useTable()`
- `Filter: Function | React.Component => JSX`
- **Required**
- Receives the table instance and column model as props
- Must return valid JSX
- This function (or component) is used to render this column's filter UI, eg.
- `disableFilters: Bool`
- Optional
- If set to `true`, will disable filtering for this column
- `defaultCanFilter: Bool`
- Optional
- Defaults to `false`
- If set to `true`, this column will be filterable, regardless if it has a valid `accessor`
- `filter: String | Function`
- Optional
- Defaults to `text`
- The resolved function from the this string/function will be used to filter the this column's data.
- If a `string` is passed, the function with that name located on either the custom `filterTypes` option or the built-in filtering types object will be used. If
- If a `function` is passed, it will be used directly.
- For more information on filter types, see Filtering
- If a **function** is passed, it must be **memoized**
### Instance Properties
The following values are provided to the table `instance`:
- `rows: Array<Row>`
- An array of **filtered** rows.
- `preFilteredRows: Array<Row>`
- The array of rows **used right before filtering**.
- Among many other use-cases, these rows are directly useful for building option lists in filters, since the resulting filtered `rows` do not contain every possible option.
- `setFilter: Function(columnId, filterValue) => void`
- An instance-level function used to update the filter value for a specific column.
- `setAllFilters: Function(filtersObject) => void`
- An instance-level function used to update the values for **all** filters on the table, all at once.
### Column Properties
The following properties are available on every `Column` object returned by the table instance.
- `canFilter: Bool`
- Denotes whether a column is filterable or not depending on if it has a valid accessor/data model or is manually disabled via an option.
- `setFilter: Function(filterValue) => void`
- A column-level function used to update the filter value for this column
- `filterValue: any`
- The current filter value for this column, resolved from the table state's `filters` object
- `preFilteredRows: Array<row>`
- The array of rows that were originally passed to this columns filter **before** they were filtered.
- This array of rows can be useful if building faceted filter options.
- `filteredRows: Array<row>`
- The resulting array of rows received from this columns filter **after** they were filtered.
- This array of rows can be useful if building faceted filter options.
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/filtering)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/filtering)
+43
View File
@@ -0,0 +1,43 @@
# `useFlexLayout`
- Plugin Hook
- Optional
`useFlexLayout` is a plugin hook that adds support for headers and cells to be rendered as `inline-block` `div`s (or other non-table elements) with `width` being used as the flex-basis and flex-grow. This hook becomes useful when implementing both virtualized and resizable tables that must also be able to stretch to fill all available space.
**NOTE:** Although no additional options are needed for this plugin to work, the core column options `width`, `minWidth` and `maxWidth` are used to calculate column and cell widths and must be set:
- `minWidth` is only used to limit column resizing. It does not define the minimum width for a column.
- `width` is used as both the `flex-basis` and `flex-grow`. This means that it essentially acts as both the minimum width and flex-ratio of the column.
- `maxWidth` is only used to limit column resizing. It does not define the maximum width for a column.
[See Column Options](#column-options) for more information on these options.
### Row Properties
- `getRowProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for rows
### Cell Properties
- `getCellProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for rows cells
### HeaderGroup Properties
- `getHeaderGroupProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
### Header Properties
- `getHeaderProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
### Example (Full Width Resizable Table)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/full-width-resizable-table)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/full-width-resizable-table)
+120
View File
@@ -0,0 +1,120 @@
# `useGroupBy`
- Plugin Hook
- Optional
`useGroupBy` is the hook that implements **row grouping and aggregation**.
- Each column's `getGroupByToggleProps()` function can be used to generate the props needed to make a clickable UI element that will toggle the grouping on or off for a specific column.
- Instance and column-level `toggleGroupBy` functions are also made available for programmatic grouping.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.groupBy: Array<String>`
- Must be **memoized**
- An array of groupBy ID strings, controlling which columns are used to calculate row grouping and aggregation. This information is stored in state since the table is allowed to manipulate the groupBy through user interaction.
- `manualGroupBy: Bool`
- Enables groupBy detection and functionality, but does not automatically perform row grouping.
- Turn this on if you wish to implement your own row grouping outside of the table (eg. server-side or manual row grouping/nesting)
- `disableGroupBy: Bool`
- Disables groupBy for the entire table.
- `aggregations: Object<aggregationKey: aggregationFn>`
- Must be **memoized**
- Allows overriding or adding additional aggregation functions for use when grouping/aggregating row values. If an aggregation key isn't found on this object, it will default to using the built-in aggregation functions
- `groupByFn: Function`
- Must be **memoized**
- Defaults to `defaultGroupByFn`
- This function is responsible for grouping rows based on the `state.groupBy` keys provided. It's very rare you would need to customize this function.
### Column Options
The following options are supported on any `Column` object passed to the `columns` options in `useTable()`
- `Aggregated: Function | React.Component => JSX`
- Optional
- Defaults to this column's `Cell` formatter
- Receives the table instance and cell model as props
- Must return valid JSX
- This function (or component) formats this column's value when it is being grouped and aggregated, eg. If this column was showing the number of visits for a user to a website and it was currently being grouped to show an **average** of the values, the `Aggregated` function for this column could format that value to `1,000 Avg. Visits`
- `aggregate: String | [String, String] | Function(values, rows, isAggregated: Bool) => any`
- If a single `String` is passed, it must be the key of either a user defined or predefined `aggregations` function.
- If a tuple array of `[String, String]` is passed, both must be a key of either a user defined or predefined `aggregations` function.
- The first is used to aggregate raw values, eg. `sum`-ing raw values together
- The second is used to aggregate values that have already been aggregated, eg. `average`-ing the sums produced by the raw aggregation level
- If a `Function` is passed, this function will receive the `values`, original `rows` of those values, and an `isAggregated` `Bool` of whether or not the values and rows have already been aggregated.
- `disableGroupBy: Boolean`
- Defaults to `false`
- If `true`, will disable grouping for this column.
### Instance Properties
The following values are provided to the table `instance`:
- `rows: Array<Row>`
- An array of **grouped and aggregated** rows.
- `preGroupedRows: Array<Row>`
- The array of rows originally used to create the grouped rows.
- `toggleGroupBy: Function(columnId: String, ?set: Bool) => void`
- This function can be used to programmatically set or toggle the groupBy state for a specific column.
### Column Properties
The following properties are available on every `Column` object returned by the table instance.
- `canGroupBy: Boolean`
- If `true`, this column is able to be grouped.
- This is resolved from the column having a valid accessor / data model, and not being manually disabled via other `useGroupBy` related options
- `isGrouped: Boolean`
- If `true`, this column is currently being grouped
- `groupedIndex: Int`
- If this column is currently being grouped, this integer is the index of this column's ID in the table state's `groupBy` array.
- `toggleGroupBy: Function(?set: Bool) => void`
- This function can be used to programmatically set or toggle the groupBy state fo this column.
- `getGroupByToggleProps: Function(props) => props`
- **Required**
- This function is used to resolve any props needed for this column's UI that is responsible for toggling grouping when the user clicks it.
- You can use the `getGroupByToggleProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props may override built-in sortBy props, so be careful!**
### Row Properties
The following properties are available on every `Row` object returned by the table instance.
- `groupById: String`
- The column ID for which this row is being grouped.
- Will be `undefined` if the row is an original row from `data` and not a materialized one from the grouping.
- `groupByVal: any`
- If the row is a materialized group row, this will be the grouping value that was used to create it.
- `values: Object`
- Similar to a regular row, a materialized grouping row also has a `values` object
- This object contains the **aggregated** values for this row's sub rows
- `subRows: Array<Row>`
- If the row is a materialized group row, this property is the array of materialized subRows that were grouped inside of this row.
- `depth: Int`
- If the row is a materialized group row, this is the grouping depth at which this row was created.
- `id: String`
- The unique ID for this row.
- This ID is unique across all rows, including sub rows
- Derived from the `getRowId` function, which defaults to chaining parent IDs and joining with a `.`
- If a row is a materialized grouping row, it will have an ID in the format of `columnId:groupByVal`.
- `isAggregated: Bool`
- Will be `true` if the row is an aggregated row
### Cell Properties
The following additional properties are available on every `Cell` object returned in an array of `cells` on every row object.
- `isGrouped: Bool`
- If `true`, this cell is a grouped cell, meaning it contains a grouping value and should usually display and expander.
- `isRepeatedValue: Bool`
- If `true`, this cell is a repeated value cell, meaning it contains a value that is already being displayed elsewhere (usually by a parent row's cell).
- Most of the time, this cell is not required to be displayed and can safely be hidden during rendering
- `isAggregated: Bool`
- If `true`, this cell's value has been aggregated and should probably be rendered with the `Aggregated` cell renderer.
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/grouping)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/grouping)
+84
View File
@@ -0,0 +1,84 @@
# `usePagination`
- Plugin Hook
- Optional
`usePagination` is the hook that implements **row pagination**. It can be used for both client-side pagination or server-side pagination. For more information on pagination, see Pagination
> **NOTE** Some server-side pagination implementations do not use page index and instead use **token based pagination**! If that's the case, please use the `useTokenPagination` plugin instead.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.pageSize: Int`
- **Required**
- Defaults to `10`
- Determines the amount of rows on any given page
- `initialState.pageIndex: Int`
- **Required**
- Defaults to `0`
- The index of the page that should be displayed via the `page` instance value
- `pageCount: Int`
- **Required if `manualPagination` is set to `true`**
- If `manualPagination` is `true`, then this value used to determine the amount of pages available. This amount is then used to materialize the `pageOptions` and also compute the `canNextPage` values on the table instance.
- `manualPagination: Bool`
- Enables pagination functionality, but does not automatically perform row pagination.
- Turn this on if you wish to implement your own pagination outside of the table (eg. server-side pagination or any other manual pagination technique)
- `autoResetPage: Boolean`
- Defaults to `true`
- When `true`, the `pageIndex` state will automatically reset if `manualPagination` is `false` and any of the following conditions are met:
- `data` is changed
- `manualSortBy` is `false` and `state.sortBy` is changed
- `manualFilters` is `false` and `state.filters` is changed
- `manualGroupBy` is `false` and `state.groupBy` is changed
- To disable, set to `false`
- For more information see the FAQ ["How do I stop my table state from automatically resetting when my data changes?"](./faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes)
- `paginateExpandedRows: Bool`
- Optional
- Only applies when using the `useExpanded` plugin hook simultaneously
- Defaults to `true`
- If set to `true`, expanded rows are paginated along with normal rows. This results in stable page sizes across every page.
- If set to `false`, expanded rows will be spliced in after pagination. This means that the total number of rows in a page can potentially be larger than the page size, depending on how many subrows are expanded.
### Instance Properties
The following values are provided to the table `instance`:
- `state.pageIndex: Int`
- This is the current `pageIndex` value, located on the state.
- `state.pageSize: Int`
- This is the current `pageSize` value, located on the state.
- `page: Array<row>`
- An array of rows for the **current** page, determined by the current `pageIndex` value.
- `pageCount: Int`
- If `manualPagination` is set to `false`, this is the total amount of pages available in the table based on the current `pageSize` value
- if `manualPagination` is set to `true`, this is merely the same `pageCount` option that was passed in the table options.
- `pageOptions: Array<Int>`
- An array of zero-based index integers corresponding to available pages in the table.
- This can be useful for generating things like select interfaces for the user to select a page from a list, instead of manually paginating to the desired page.
- `canPreviousPage: Bool`
- If there are pages and the current `pageIndex` is greater than `0`, this will be `true`
- `canNextPage:`
- If there are pages and the current `pageIndex` is less than `pageCount`, this will be `true`
- `gotoPage: Function(pageIndex)`
- This function, when called with a valid `pageIndex`, will set `pageIndex` to that value.
- If the aginateassed index is outside of the valid `pageIndex` range, then this function will do nothing.
- `previousPage: Function`
- This function decreases `state.pageIndex` by one.
- If there are no pages or `canPreviousPage` is false, this function will do nothing.
- `nextPage: Function`
- This function increases `state.pageIndex` by one.
- If there are no pages or `canNextPage` is false, this function will do nothing.
- `setPageSize: Function(pageSize)`
- This function sets `state.pageSize` to the new value.
- As a result of a pageSize change, a new `state.pageIndex` is also calculated. It is calculated via `Math.floor(currentTopRowIndex / newPageSize)`
### Example
- Basic Pagination
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination)
- Controlled Pagination
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination)
+35
View File
@@ -0,0 +1,35 @@
# `useResizeColumns`
- Plugin Hook
- Optional
`useResizeColumns` is a plugin hook that adds support for resizing headers and cells when using non-table elements for layout eg. the `useBlockLayout` and `useAbsoluteLayout` hooks. It even supports resizing column groups!
### Table Options
- `disableResizing: Bool`
- Defaults to `false`
- When set to `true`, resizing is disabled across the entire table
### Column Options
The core column options `width`, `minWidth` and `maxWidth` are used to calculate column and cell widths and must be set. [See Column Options](#column-options) for more information on these options.
- `disableResizing: Bool`
- Defaults to `false`
- When set to `true`, resizing is disabled for this column
### Header Properties
- `getResizerProps`
- **Usage Required**
- This core prop getter is required to to enable absolute layout for headers
- `canResize: Bool`
- Will be `true` if this column can be resized
- `isResizing: Bool`
- Will be `true` if this column is currently being resized
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-resizing)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-resizing)
+65
View File
@@ -0,0 +1,65 @@
# `useRowSelect`
- Plugin Hook
- Optional
`useRowSelect` is the hook that implements **basic row selection**. For more information on row selection, see Row Selection
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.selectedRowIds: Object<rowId: Boolean>`
- Optional
- Defaults to `{}`
- If a row's ID is set to `true` in this object, it will have a selected state.
- `manualRowSelectedKey: String`
- Optional
- Defaults to `isSelected`
- If this key is found on the **original** data row, and it is true, this row will be manually selected
- `autoResetSelectedRows: Boolean`
- Defaults to `true`
- When `true`, the `selectedRowIds` state will automatically reset if any of the following conditions are met:
- `data` is changed
- To disable, set to `false`
- For more information see the FAQ ["How do I stop my table state from automatically resetting when my data changes?"](./faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes)
### Instance Properties
The following values are provided to the table `instance`:
- `toggleRowSelected: Function(rowPath: String, ?set: Bool) => void`
- Use this function to toggle a row's selected state.
- Optionally pass `true` or `false` to set it to that state
- `toggleAllRowsSelected: Function(?set: Bool) => void`
- Use this function to toggle all rows as select or not
- Optionally pass `true` or `false` to set all rows to that state
- `getToggleAllRowsSelectedProps: Function(props) => props`
- Use this function to get the props needed for a **select all checkbox**.
- Props:
- `onChange: Function()`
- `style.cursor: 'pointer'`
- `checked: Bool`
- `title: 'Toggle All Rows Selected'`
- `isAllRowsSelected: Bool`
- Will be `true` if all rows are selected.
- If at least one row is not selected, will be `false`
- `selectedFlatRows: Array<Row>`
- The flat array of rows that are currently selected
### Row Properties
The following additional properties are available on every **prepared** `row` object returned by the table instance.
- `isSelected: Bool`
- Will be `true` if the row is currently selected
- `isSomeSelected: Bool`
- Will be `true` if the row has subRows and at least one of them is currently selected
- `toggleRowSelected: Function(?set)`
- Use this function to toggle this row's selected state.
- Optionally pass `true` or `false` to set it to that state
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/row-selection)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/row-selection)
+59
View File
@@ -0,0 +1,59 @@
# `useRowState`
- Plugin Hook
- Optional
`useRowState` is a plugin hook that implements **basic state management for _prepared_ rows and their cells**.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.rowState: Object<RowPathKey:Object<any, cellState: {columnId: Object}>>`
- Optional
- Defaults to `{}`
- If a row's ID is found in this array, it will have the state of the value corresponding to that key.
- Individual row states can contain anything, but they also contain a `cellState` key, which provides cell-level state based on column ID's to every
**prepared** cell in the table.
- `initialRowStateAccessor: Function`
- Optional
- This function may optionally return the initial state for a row.
- If this function is defined, it will be passed a `Row` object, from which you can return a value to use as the initial state, eg. `row => row.original.initialState`
- `autoResetRowState: Boolean`
- Defaults to `true`
- When `true`, the `rowState` state will automatically reset if any of the following conditions are met:
- `data` is changed
- To disable, set to `false`
- For more information see the FAQ ["How do I stop my table state from automatically resetting when my data changes?"](./faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes)
### Instance Properties
The following values are provided to the table `instance`:
- `setRowState: Function(rowPath: Array<string>, updater: Function | Any) => void`
- Use this function to programmatically update the state of a row.
- `updater` can be a function or value. If a `function` is passed, it will receive the current value and expect a new one to be returned.
- `setCellState: Function(rowPath: Array<string>, columnId: String, updater: Function | Any) => void`
- Use this function to programmatically update the cell of a row.
- `updater` can be a function or value. If a `function` is passed, it will receive the current value and expect a new one to be returned.
### Row Properties
The following additional properties are available on every **prepared** `row` object returned by the table instance.
- `state: Object`
- This is the state object for each row, pre-mapped to the row from the table state's `rowState` object via `rowState[row.id]`
- May also contain a `cellState` key/value pair, which is used to provide individual cell states to this row's cells
- `setState: Function(updater: Function | any)`
- Use this function to programmatically update the state of a row.
- `updater` can be a function or value. If a `function` is passed, it will receive the current value and expect a new one to be returned.
### Cell Properties
The following additional properties are available on every `Cell` object returned in an array of `cells` on every row object.
- `state: Object`
- This is the state object for each cell, pre-mapped to the cell from the table state's `rowState` object via `rowState[row.id].cellState[columnId]`
- `setState: Function(updater: Function | any)`
- Use this function to programmatically update the state of a cell.
- `updater` can be a function or value. If a `function` is passed, it will receive the current value and expect a new one to be returned.
+125
View File
@@ -0,0 +1,125 @@
# `useSortBy`
- Plugin Hook
- Optional
`useSortBy` is the hook that implements **row sorting**. It also support multi-sort (keyboard required).
- Multi-sort is enabled by default
- To sort the table via UI, attach the props generated from each column's `getSortByToggleProps()`, then click any of those elements.
- To multi-sort the table via UI, hold `shift` while clicking on any of those same elements that have the props from `getSortByToggleProps()` attached.
- To programmatically sort (or multi-sort) any column, use the `toggleSortBy` method located on the instance or each individual column.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `initialState.sortBy: Array<Object<id: columnId, desc: Bool>>`
- Must be **memoized**
- An array of sorting objects. If there is more than one object in the array, multi-sorting will be enabled. Each sorting object should contain an `id` key with the corresponding column ID to sort by. An optional `desc` key may be set to true or false to indicated ascending or descending sorting for that column. This information is stored in state since the table is allowed to manipulate the filter through user interaction.
- `manualSortBy: Bool`
- Enables sorting detection functionality, but does not automatically perform row sorting. Turn this on if you wish to implement your own sorting outside of the table (eg. server-side or manual row grouping/nesting)
- `disableSortBy: Bool`
- Disables sorting for every column in the entire table.
- `defaultCanSort: Bool`
- Optional
- Defaults to `false`
- If set to `true`, all columns will be sortable, regardless if they have a valid `accessor`
- `disableMultiSort: Bool`
- Disables multi-sorting for the entire table.
- `isMultiSortEvent: Function`
- Allows to override default multisort behaviour(i.e. multisort applies when shift key is pressed), if this function is provided then returned boolean value from this function will make decision whether newly applied sort action will be considered as multisort or not.
- Receives `event` as argument.
- `maxMultiSortColCount: Number`
- Limit on max number of columns for multisort, e.g. if set to 3, and suppose table is sorted by `[A, B, C]` and then clicking `D` for sorting should result in table sorted by `[B, C , D]`
- `disableSortRemove: Bool`
- If true, the un-sorted state will not be available to columns once they have been sorted.
- `disableMultiRemove: Bool`
- If true, the un-sorted state will not be available to multi-sorted columns.
- `orderByFn: Function`
- Must be **memoized**
- Defaults to the built-in default orderBy function
- This function is responsible for composing multiple sorting functions together for multi-sorting, and also handles both the directional sorting and stable-sorting tie breaking. Rarely would you want to override this function unless you have a very advanced use-case that requires it.
- `sortTypes: Object<sortKey: sortType>`
- Must be **memoized**
- Allows overriding or adding additional sort types for columns to use. If a column's sort type isn't found on this object, it will default to using the built-in sort types.
- For more information on sort types, see Sorting
- `autoResetSortBy: Boolean`
- Defaults to `true`
- When `true`, the `sortBy` state will automatically reset if any of the following conditions are met:
- `data` is changed
- To disable, set to `false`
- For more information see the FAQ ["How do I stop my table state from automatically resetting when my data changes?"](./faq#how-do-i-stop-my-table-state-from-automatically-resetting-when-my-data-changes)
### Column Options
The following options are supported on any `Column` object passed to the `columns` options in `useTable()`
- `defaultCanSort: Bool`
- Optional
- Defaults to `false`
- If set to `true`, this column will be sortable, regardless if it has a valid `accessor`
- `disableSortBy: Bool`
- Optional
- Defaults to `false`
- If set to `true`, the sorting for this column will be disabled
- `sortDescFirst: Bool`
- Optional
- Defaults to `false`
- If set to `true`, the first sort direction for this column will be descending instead of ascending
- `sortInverted: Bool`
- Optional
- Defaults to `false`
- If set to `true`, the underlying sorting direction will be inverted, but the UI will not.
- This may be useful in situations where positive and negative connotation is inverted, eg. a Golfing score where a lower score is considered more positive than a higher one.
- `sortType: String | Function`
- Used to compare 2 rows of data and order them correctly.
- If a **function** is passed, it must be **memoized**
- String options: `basic`, `datetime`, `alphanumeric`. Defaults to `alphanumeric`.
- The resolved function from the this string/function will be used to sort the this column's data.
- If a `string` is passed, the function with that name located on either the custom `sortTypes` option or the built-in sorting types object will be used.
- If a `function` is passed, it will be used.
- For more information on sort types, see Sorting
### Instance Properties
The following values are provided to the table `instance`:
- `rows: Array<Row>`
- An array of **sorted** rows.
- `preSortedRows: Array<Row>`
- The array of rows that were originally sorted.
- `toggleSortBy: Function(ColumnId: String, descending: Bool, isMulti: Bool) => void`
- This function can be used to programmatically toggle the sorting for any specific column
### Column Properties
The following properties are available on every `Column` object returned by the table instance.
- `canSort: Bool`
- Denotes whether a column is sortable or not depending on if it has a valid accessor/data model or is manually disabled via an option.
- `toggleSortBy: Function(descending, multi) => void`
- This function can be used to programmatically toggle the sorting for this column.
- This function is similar to the `instance`-level `toggleSortBy`, however, passing a columnId is not required since it is located on a `Column` object already.
- `getSortByToggleProps: Function(props) => props`
- **Required**
- This function is used to resolve any props needed for this column's UI that is responsible for toggling the sort direction when the user clicks it.
- You can use the `getSortByToggleProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props may override built-in sortBy props, so be careful!**
- `clearSorting: Function() => void`
- This function can be used to programmatically clear the sorting for this column.
- `isSorted: Boolean`
- Denotes whether this column is currently being sorted
- `sortedIndex: Int`
- If the column is currently sorted, this integer will be the index in the `sortBy` array from state that corresponds to this column.
- If this column is not sorted, the index will always be `-1`
- `isSortedDesc: Bool`
- If the column is currently sorted, this denotes whether the column's sort direction is descending or not.
- If `true`, the column is sorted `descending`
- If `false`, the column is sorted `ascending`
- If `undefined`, the column is not currently being sorted.
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/sorting)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sorting)
+299
View File
@@ -0,0 +1,299 @@
# `useTable`
- Required
`useTable` is the root hook for React Table. To use it, pass it with an options object with at least a `columns` and `data` value, followed by any React Table compatible hooks you want to use.
### Table Options
The following options are supported via the main options object passed to `useTable(options)`
- `columns: Array<Column>`
- Required
- Must be **memoized**
- The core columns configuration object for the entire table.
- Supports nested `columns` arrays via the column's `columns` key, eg. `[{ Header: 'My Group', columns: [...] }]`
- `data: Array<any>`
- Required
- Must be **memoized**
- The data array that you want to display on the table.
- `initialState: Object`
- Optional
- The initial state object for the table.
- Upon table initialization, this object is **merged over the table's `defaultState` object** (eg. `{...defaultState, ...initialState}`) that React Table and its hooks use to register default state to produce the final initial state object passed to the `React.useState` hook internally.
- `initialState.hiddenColumns: Array<ColumnId: String>`
- Optional
- The initial state object for hidden columns
- If a column's ID is contained in this array, it will be hidden
- `reducer: Function(newState, action, prevState) => newState`
- Optional
- With every action that is dispatched to the table's internal `React.useReducer` instance, this reducer is called and is allowed to modify the final state object for updating.
- It is passed the `newState`, `action`, and `prevState` and is expected to either return the `newState` or a modified version of the `newState`
- May also be used to "control" the state of the table, by overriding certain pieces of state regardless of the action.
- `useControlledState: HookFunction(state) => controlledState`
- Optional
- If you need to control part of the table state, this is the place to do it.
- This function is run on every single render, just like a hook and allows you to alter the final state of the table if necessary.
- You can use hooks inside of this function, but most of the time, we just suggest using `React.useMemo` to memoize your state overrides.
- See the FAQ ["How can I manually control the table state?"](./faq.md#how-can-i-manually-control-the-table-state) for a an example.
- `defaultColumn: Object`
- Optional
- Defaults to `{}`
- The default column object for every column passed to React Table.
- Column-specific properties will override the properties in this object, eg. `{ ...defaultColumn, ...userColumn }`
- This is particularly useful for adding global column properties. For instance, when using the `useFilters` plugin hook, add a default `Filter` renderer for every column, eg.`{ Filter: MyDefaultFilterComponent }`
- `initialRowStateKey: String`
- Optional
- Defaults to `initialState`
- This key is used to look for the initial state of a row when initializing the `rowState` for a`data` array.
- If the value located at `row[initialRowStateKey]` is falsey, `{}` will be used instead.
- `getSubRows: Function(row, relativeIndex) => Rows[]`
- Optional
- Must be **memoized**
- Defaults to `(row) => row.subRows || []`
- Use this function to change how React Table detects subrows. You could even use this function to generate sub rows if you want.
- By default, it will attempt to return the `subRows` property on the row, or an empty array if that is not found.
- `getRowId: Function(row, relativeIndex, ?parent) => string`
- Use this function to change how React Table detects unique rows and also how it constructs each row's underlying `id` property.
- Optional
- Must be **memoized**
- Defaults to `(row, relativeIndex, parent) => parent ? [parent.id, relativeIndex].join('.') : relativeIndex`
- `debug: Bool`
- Optional
- A flag to turn on debug mode.
- Defaults to `false`
### Column Options
The following options are supported on any column object you can pass to `columns`.
- `accessor: String | Function`
- **Required**
- This string/function is used to build the data model for your column.
- The data returned by an accessor should be **primitive** and sortable.
- If a string is passed, the column's value will be looked up on the original row via that key, eg. If your column's accessor is `firstName` then its value would be read from `row['firstName']`. You can also specify deeply nested values with accessors like `info.hobbies` or even `address[0].street`
- If a function is passed, the column's value will be looked up on the original row using this accessor function, eg. If your column's accessor is `row => row.firstName`, then its value would be determined by passing the row to this function and using the resulting value.
- `id: String`
- **Required if `accessor` is a function**
- This is the unique ID for the column. It is used by reference in things like sorting, grouping, filtering etc.
- If a **string** accessor is used, it defaults as the column ID, but can be overridden if necessary.
- `columns: Array<Column>`
- Optional
- A nested array of columns.
- If defined, the column will act as a header group. Columns can be recursively nested as much as needed.
- `Header: String | Function | React.Component => JSX`
- Optional
- Defaults to `() => null`
- Receives the table instance and column model as props
- Must either be a **string or return valid JSX**
- If a function/component is passed, it will be used for formatting the header value, eg. You can use a `Header` function to dynamically format the header using any table or column state.
- `Cell: Function | React.Component => JSX`
- Optional
- Defaults to `({ cell: { value } }) => String(value)`
- Receives the table instance and cell model as props
- Must return valid JSX
- This function (or component) is primarily used for formatting the column value, eg. If your column accessor returns a date object, you can use a `Cell` function to format that date to a readable format.
- `show: Bool`
- Optional
- Defaults to `undefined`
- If set to `true`, will take priority over any state in `hiddenColumns` and force this column to be visible at all times.
- If set to `false` will take priority over any state in `hiddenColumns` and force this column to be hidden at all times.
- `width: Int`
- Optional
- Defaults to `150`
- Specifies the width for the column (when using non-table-element layouts)
- `minWidth: Int`
- Optional
- Defaults to `0`
- Specifies the minimum width for the column (when using non-table-element layouts)
- Specifically useful when using plugin hooks that allow the user to resize column widths
- `maxWidth: Int`
- Optional
- Defaults to `0`
- Specifies the maximum width for the column (when using non-table-element layouts)
- Specifically useful when using plugin hooks that allow the user to resize column widths
### Instance Properties
The following properties are available on the table instance returned from `useTable`
- `state: Object`
- **Memoized** - This object reference will not change unless the internal table state is modified.
- This is the final state object of the table, which is the product of the `initialState`, internal table reducer and (optionally) a custom `reducer` supplied by the user.
- `dispatch: Function({ type: Actions[type], ...payload }) => void`
- This function is used both internally by React Table, and optionally by you (the developer) to update the table state programmatically.
- `type: Actions[type] | String`
- The action type corresponding to what action being taken against the state.
- `...payload`
- Any other action data that is associated with the action
- `columns: Array<Column>`
- A **nested** array of final column objects, **similar in structure to the original columns configuration option**.
- See [Column Properties](#column-properties) for more information
- `flatColumns: Array<Column>`
- A **flat** array of all final column objects.
- See [Column Properties](#column-properties) for more information
- `headerGroups: Array<HeaderGroup>`
- An array of normalized header groups, each containing a flattened array of final column objects for that row.
- **Some of these headers may be materialized as placeholders**
- See [HeaderGroup Properties](#headergroup-properties) for more information
- `footerGroups: Array<HeaderGroup>`
- An array of normalized header groups, but in reverse order, each containing a flattened array of final column objects for that row.
- **Some of these headers may be materialized as placeholders**
- See [HeaderGroup Properties](#headergroup-properties) for more information
- `headers: Array<Column>`
- A **nested** array of final header objects, **similar in structure to the original columns configuration option, but rebuilt for ordering**
- Each contains the headers that are displayed underneath it.
- **Some of these headers may be materialized as placeholders**
- See [Column Properties](#column-properties) for more information
- `flatHeaders[] Array<Column>`
- A **flat** array of final header objects found in each header group.
- **Some of these headers may be materialized as placeholders**
- See [Column Properties](#column-properties) for more information
- `rows: Array<Row>`
- An array of **materialized row objects** from the original `data` array and `columns` passed into the table options
- See [Row Properties](#row-properties) for more information
- `getTableProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for your table wrapper.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
- `getTableBodyProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for your table body wrapper.
- Custom props may be passed. **NOTE: Custom props will override built-in table body props, so be careful!**
- `prepareRow: Function(Row)`
- **Required**
- This function is responsible for lazily preparing a row for rendering. Any row that you intend to render in your table needs to be passed to this function **before every render**.
- **Why?** Since table data could potentially be very large, it can become very expensive to compute all of the necessary state for every row to be rendered regardless if it actually is rendered or not (for example if you are paginating or virtualizing the rows, you may only have a few rows visible at any given moment). This function allows only the rows you intend to display to be computed and prepped with the correct state.
- `flatRows: Array<Row>`
- An array of all rows, including subRows which have been flattened into the order in which they were detected (depth first)
- This can be helpful in calculating total row counts that must include subRows
- `totalColumnsWidth: Int`
- This is the total width of all visible columns (only available when using non-table-element layouts)
- `toggleHideColumn: Function(columnId: String, ?value: Boolean) => void`
- This function can be used to toggle or set a column's hidden state
- Passing a `value` is optional. If passed, the hidden state will be set to that Boolean value.
- If a `value` is not passed, the visibility for this column will be toggled.
- `setHiddenColumns: Function(Array<ColumnId: String> | Function(oldHiddenColumns) => Array<ColumnId: String>) => void`
- This function can be used to set the `hiddenColumns` state for the entire table.
- If a value is passed, `hiddenColumns` will be set to that value
- If a function is passed, it will received the previous `hiddenColumns` value and will be expected to return the new value.
- `toggleHideAllColumns: Function(?value: Boolean) => void`
- This function can be used to toggle or set the visibility for all columns to `true` or `false`
- If a value is not passed, the visibility for all columns will be toggled back and forth from `true` to `false`
- If `true` is passed, all columns will be hidden
- If a `false` is passed, all columns will be visible
- `getToggleHideAllColumnsProps: Function(userProps) => props`
- This function can be used to retrieve all necessary props to be placed on an `<input type='checkbox'>` component that will control the visibility of all columns
### HeaderGroup Properties
The following additional properties are available on every `headerGroup` object returned by the table instance.
- `headers: Array<Column>`
- **Required**
- The columns in this header group.
- `getHeaderGroupProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for this header group's row.
- You can use the `getHeaderGroupProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
- `getFooterGroupProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for this header group's footer row.
- You can use the `getFooterGroupProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
### Column Properties
The following properties are available on every `Column` object returned by the table instance.
- `id: String`
- The resolved column ID from either the column's `accessor` or the column's hard-coded `id` property
- `isVisible: Boolean`
- Whether the column should be currently visible or not.
- Columns that are not visible are still used for sorting, filtering, etc.
- `render: Function(type: String | Function | Component, ?props)`
- This function is used to render content with the added context of a column.
- The entire table `instance` will be passed to the renderer with the addition of a `column` property, containing a reference to the column
- If `type` is a string, will render using the `column[type]` renderer. React Table ships with default `Header` and `Footer` renderers. Other renderers like `Filter` and `Aggregated` are available via plugin hooks.
- If a function or component is passed instead of a string, it will be be passed the table instance and column model as props and is expected to return any valid JSX.
- `totalLeft: Int`
- This is the total width in pixels of all columns to the left of this column
- Specifically useful when using plugin hooks that allow the user to resize column widths
- `totalWidth: Int`
- This is the total width in pixels for this column (if it is a leaf-column) or or all of it's sub-columns (if it is a column group)
- Specifically useful when using plugin hooks that allow the user to resize column widths
- `getHeaderProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for this column's header cell.
- You can use the `getHeaderProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
- `getFooterProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for this column's footer cell.
- You can use the `getFooterProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
- `toggleHidden: Function(?hidden: Boolean) => void`
- This function can be used to hide or show this column.
- If no value is passed, the visibility of this column will be toggled.
- Optionally pass a value to set the visible.
- `getToggleHiddenProps: Function(userProps) => props`
- This function can be used to retrieve all necessary props to be placed on an `<input type='checkbox'>` component that will control the visibility of this column.
### Row Properties
The following additional properties are available on every `row` object returned by the table instance.
- `cells: Array<Cell>`
- An array of visible `Cell` objects containing properties and functions specific to the row and column it belongs to.
- These cells are normally intended for display
- See [Cell Properties](#cell-properties) for more information
- `allCells: Array<Cell>`
- An array of all `Cell` objects containing properties and functions specific to the row and column it belongs to.
- Not every cell contained here is guaranteed that it should be displayed and is made available here for convenience and advanced templating purposes.
- See [Cell Properties](#cell-properties) for more information
- `values: Object<columnId: any>`
- A map of this row's **resolved** values by columnId, eg. `{ firstName: 'Tanner', lastName: 'Linsley' }`
- `getRowProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for this row.
- You can use the `getRowProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
- `index: Int`
- The index of the original row in the `data` array that was passed to `useTable`. If this row is a subRow, it is the original index within the parent row's subRows array
- `original: Object`
- The original row object from the `data` array that was used to materialize this row.
- `subRows: Array<Row>`
- If subRows were detect on the original data object, this will be an array of those materialized row objects.
- `state: Object`
- The current state of the row. It's lifespan is attached to that of the original `data` array. When the raw `data` is changed, this state value is reset to the row's initial value (using the `initialRowStateKey` option).
- Can be updated via `instance.setRowState` or the row's `setState` function.
### Cell Properties
The following additional properties are available on every `Cell` object returned in an array of `cells` on every row object.
- `column: Column`
- The corresponding column object for this cell
- `row: Row`
- The corresponding row object for this cell
- `value: any`
- The **resolved** value for this cell.
- By default, this value is displayed on the table via the default `Cell` renderer. To override the way a cell displays
- `getCellProps: Function(?props)`
- **Required**
- This function is used to resolve any props needed for this cell.
- You can use the `getCellProps` hook to extend its functionality.
- Custom props may be passed. **NOTE: Custom props will override built-in table props, so be careful!**
- `render: Function(type: String | Function | Component, ?props)`
- **Required**
- This function is used to render content with the added context of a cell.
- The entire table `instance` will be passed to the renderer with the addition of `column`, `row` and `cell` properties, containing a reference to each respective item.
- If `type` is a string, will render using the `column[type]` renderer. React Table ships with a default `Cell` renderer. Other renderers like `Aggregated` are available via hooks like `useFilters`.
- If a function or component is passed instead of a string, it will be be passed the table instance and cell model as props and is expected to return any valid JSX.
### Example
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/basic)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/basic)
+8
View File
@@ -0,0 +1,8 @@
# `useTokenPagination (Coming Soon)`
- Plugin Hook
- Optional
`useTokenPagination` is the hook that **aids in implementing row pagination using tokens**. It is useful for server-side pagination implementations that use **tokens** instead of page index. For more information on pagination, see Pagination
> Documentation Coming Soon...
+33
View File
@@ -0,0 +1,33 @@
# Concepts
## React Table is a "headless" UI library
React Table is a headless utility, which means out of the box, it doesn't render or supply any actual UI elements. You are in charge of utilizing the state and callbacks of the hooks provided by this library to render your own table markup. [Read this article to understand why React Table is built this way](https://medium.com/merrickchristensen/headless-user-interface-components-565b0c0f2e18). If you don't want to, then here's a quick rundown anyway:
- Separation of Concerns - Not that superficial kind you read about all the time. The real kind. React Table as a library honestly has no business being in charge of your UI. The look, feel, and overall experience of your table is what makes your app or product great. The less React Table gets in the way of that, the better!
- Maintenance - By removing the massive (and seemingly endless) API surface area required to support every UI use-case, React Table can remain small, easy-to-use and simple to update/maintain.
- Extensibility - UI presents countless edge cases for a library simply because it's a creative medium, and one where every developer does things differently. By not dictating UI concerns, React Table empowers the developer to design and extend the UI based on their unique use-case.
## The React Table instance
At the heart of every React Table is the `useTable` hook and the table `instance` object that it returns. This `instance` object contains everything you'll ever need to build a table and interact with its state. This includes, but is not limited to:
- Columns
- Materialized Data
- Sorting
- Filtering
- Grouping
- Pagination
- Expanded State
- Any functionality provided by custom plugin hooks, too!
## Rendering your own UI
As of React Table v7, **you the developer** are responsible for rendering your own UI, but don't let that intimidate you! Table UIs are fun and React Table makes it so easy to wire up your own table UI. The easiest way to learn how to build your own table UI is to [see some existing React Table examples](./examples.md)!
---
After reading about React Table's concepts, you should:
- [Check Out Some Examples](./examples.md)
- [Study the API](./api/README.md)
+79
View File
@@ -0,0 +1,79 @@
# Examples
- **Simple** - All of these examples use automatic state management, meaning, they don't hoist any state out of the table or manually control anything. Start here for understanding the basics about how to build your table UI.
- Basic
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/basic)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/basic)
- Footers
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/footers)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/footers)
- Sorting
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/sorting)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sorting)
- Filtering
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/filtering)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/filtering)
- Grouping
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/grouping)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/grouping)
- Grouping (Single Column)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/grouping-column)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/grouping-column)
- Pagination
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination)
- Row Selection
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/row-selection)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/row-selection)
- Expanding
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/expanding)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/expanding)
- Sub Components
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/sub-components)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/sub-components)
- Editable Data
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/editable-data)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/editable-data)
- Column Ordering
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-ordering)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-ordering)
- Column Hiding
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-hiding)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-hiding)
- Column Resizing
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/column-resizing)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/column-resizing)
- Data-Driven Classes and Styles
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/data-driven-classes-and-styles)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/data-driven-classes-and-styles)
- Row DnD
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/row-dnd)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/row-dnd)
- Full Width Table (Table Elements with collapsible content)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/full-width-table)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/full-width-table)
- Full Width Resizable Table (via `useFlexLayout`)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/full-width-resizable-table)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/full-width-resizable-table)
- **Complex**
- The "Kitchen Sink"
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/kitchen-sink)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/kitchen-sink)
- **Controlled** - These examples are more advanced because they demonstrate how to manually control and respond to the state of the table.
- Pagination (Controlled)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
- [Open in CodeSandobx](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/pagination-controlled)
- **UI & Rendering** - These examples demonstrate how to use React Table with your favorite UI libraries or tools!
- Virtualized Rows (React-Window)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/virtualized-rows)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/virtualized-rows)
- Animated (Framer-Motion)
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/animated-framer-motion)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/animated-framer-motion)
- Material-UI
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/material-UI-components)
- [Open in CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/material-UI-components)
- [ ] Styled-Components
- [ ] CSS
- [ ] Bootstrap
- Want to write one of these examples or add another? [Submit a PR!](https://github.com/tannerlinsley/react-table/compare)
+121
View File
@@ -0,0 +1,121 @@
# FAQ
Below are some of the most frequently asked questions on how to use the React Table API to solve various table challenges you may encounter
<hr/>
## How can I manually control the table state?
Occasionally, you may need to override some of the table state from a parent component or from somewhere above the usage of `useTable`. In this case, you can turn to `useTable`'s `useControlledState` option. This hook function is run on every render and allows you an opportunity to override or change the final table state in a safe way.
For example, to control a table's `pageIndex` from a parent component:
```js
const [controlledPageIndex, setControlledPage] = React.useState(0)
useTable({
useControlledState: state => {
return React.useMemo(
() => ({
...state,
pageIndex: controlledPageIndex,
}),
[state, controlledPageIndex]
)
},
})
```
> **It's important that the state override is done within a `useMemo` call to prevent the state variable from changing on every render. It's also extremely important that you always use the `state` in any dependencies to ensure that you do not block normal state updates.**
## How can I use the table state to fetch new data?
When managing your data externally or asynchronously (eg. server-side pagination/sorting/grouping/etc), you will need to fetch new data as the internal table state changes. With React Hooks, this is fantastically easier than it was before now that we have the `React.useEffect` hook. We can use this hook to "watch" the table state for specific changes and use those effects to trigger fetches for new data (or synchronize any other state you may be managing externally from your table component):
```js
function Table({ data, onFetchData }) {
const {
state: { pageIndex, pageSize, sortBy, filters },
} = useTable({
data,
})
// When the these table states change, fetch new data!
React.useEffect(() => {
onFetchData({ pageIndex, pageSize, sortBy, filters })
}, [fetchData, pageIndex, pageSize, sortBy, filters])
return </>
}
```
Using this approach, you can respond and trigger any type of side-effect using the table instance!
## How can I debounce rapid table state changes?
React Table has a few built-in side-effects of it's own (most of which are meant for resetting parts of the state when `data` changes). By default, these state side-effects are on and when their conditions are met, they immediately fire off actions that will manipulate the table state. Sometimes, this may result in multiple rapid rerenders (usually just 2, or one more than normal), and could cause any side-effects you have watching the table state to also fire multiple times in-a-row. To alleviate this edge-case, React Table exports a `useAsyncDebounce` function that will allow you to debounce rapid side-effects and only use the latest one.
A good example of this when doing server-side pagination and sorting, a user changes the `sortBy` for a table and the `pageIndex` is automatically reset to `0` via an internal side effect. This would normally cause our effect below to fire 2 times, but with `useAsyncDebounce` we can make sure our data fetch function only gets called once:
```js
import { useTable, useAsyncDebounce } from 'react-table'
function Table({ data, onFetchData }) {
const {
state: { pageIndex, pageSize, sortBy, filters },
} = useTable({
data,
})
// Debounce our onFetchData call for 100ms
const onFetchDataDebounced = useAsyncDebounce(onFetchData, 100)
// When the these table states changes, fetch new data!
React.useEffect(() => {
// Every change will call our debounced function
onFetchDataDebounced({ pageIndex, pageSize, sortBy, filters })
// Only the last call after the 100ms debounce is over will be fired!
}, [onFetchDataDebounced, pageIndex, pageSize, sortBy, filters])
return </>
}
```
## How do I stop my table state from automatically resetting when my data changes?
Most plugins use state that _should_ normally reset when the data sources changes, but sometimes you need to suppress that from happening if you are filtering your data externally, or immutably editing your data while looking at it, or simply doing anything external with your data that you don't want to trigger a piece of table state to reset automatically.
For those situations, each plugin provides a way to disable the state from automatically resetting internally when data or other dependencies for a piece of state change. By setting any of them to `false`, you can stop the automatic resets from being triggered.
Here is an example of stopping basically every piece of state from changing as they normally do while we edit the `data` source for a table:
```js
const [data, setData] = React.useState([])
const skipPageResetRef = React.useRef()
const updateData = newData => {
// When data gets updated with this function, set a flag
// to disable all of the auto resetting
skipPageResetRef.current = true
setData(newData)
}
React.useEffect(() => {
// After the table has updated, always remove the flag
skipPageResetRef.current = false
})
useTable({
...
autoResetPage: !skipPageReset,
autoResetExpanded: !skipPageReset,
autoResetGroupBy: !skipPageReset,
autoResetSelectedRows: !skipPageReset,
autoResetSortBy: !skipPageReset,
autoResetFilters: !skipPageReset,
autoResetRowState: !skipPageReset,
})
```
Now, when we update our data, the above table states will not automatically reset!
+27
View File
@@ -0,0 +1,27 @@
# Installation
Install React Table as a dependency using `npm` or `yarn`
```bash
# NPM
$ npm install react-table
# Yarn
$ yarn add react-table
```
To import React Table:
```js
import {
useTable,
useGroupBy,
useFilters,
useSortBy,
useExpanded,
usePagination,
...
} from 'react-table'
```
Once you've installed React Table, continue to [Concepts](./concepts.md) to read more about how to utilize its API
-53
View File
@@ -1,53 +0,0 @@
{
"name": "new",
"version": "0.1.0",
"private": true,
"devDependencies": {
"autoprefixer": "^6.7.0",
"babel-cli": "6.14.0",
"babel-eslint": "6.1.2",
"babel-preset-es2015": "6.14.0",
"babel-preset-react": "6.11.1",
"babel-preset-stage-2": "6.13.0",
"eslint": "^4.1.1",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-class-property": "^1.0.6",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-standard": "^3.0.1",
"html-element-attributes": "^1.3.0",
"match-sorter": "^1.8.0",
"npm-run-all": "^3.1.1",
"onchange": "^3.0.2",
"postcss-cli": "^2.6.0",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-json-tree": "^0.10.9",
"rimraf": "^2.6.1",
"standard": "^10.0.2",
"stylus": "^0.54.5"
},
"dependencies": {
"eslint-config-react-tools": "^1.0.10",
"github-markdown-css": "^2.6.0",
"marked": "^0.3.6",
"namor": "^1.0.1",
"raw-loader": "^0.5.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-json-tree": "^0.10.9",
"react-script": "^2.0.5",
"react-scripts": "^0.9.5",
"react-story": "^0.0.10",
"shortid": "^2.2.8"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
File diff suppressed because it is too large Load Diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

-117
View File
@@ -1,117 +0,0 @@
/* eslint-disable */
import React from "react";
//
import ReactStory, { defaultProps } from "react-story";
import CodeSandbox from "./CodeSandbox.js";
import "./stories/utils/prism.css";
import "../../react-table.css";
import Readme from "./stories/Readme.js";
import HOCReadme from "./stories/HOCReadme.js";
// import Test from './stories/test.js'
// import Tester from './examples/expander';
const stories = [
{ name: "Readme", component: Readme },
{ name: "HOC Readme", component: HOCReadme },
// { name: 'Tester', component: Test },
{ name: "Simple Table", component: CodeSandbox("X6npLXPRW") },
{
name: "Cell Renderers & Custom Components",
component: CodeSandbox("OyRL04Z4Y")
},
{ name: "Default Sorting", component: CodeSandbox("gLwmmjzA3") },
{
name: "Custom Sorting",
component: CodeSandbox("VGx67J35")
},
{ name: "Custom Column Widths", component: CodeSandbox("o2OORXNXN") },
{ name: "Custom Component Props", component: CodeSandbox("nZW3L0wp4") },
{ name: "Server-side Data", component: CodeSandbox("wjrn8wy3R") },
{ name: "Sub Components", component: CodeSandbox("n2gqAxl7") },
{ name: "Pivoting & Aggregation", component: CodeSandbox("oNY9z8xN") },
{
name: "Pivoting & Aggregation w/ Sub Components",
component: CodeSandbox("p0kEVBgQ")
},
{
name: "100k Rows w/ Pivoting & Sub Components",
component: CodeSandbox("DRmKj0XyK")
},
{ name: "Pivoting Options", component: CodeSandbox("kZKmNBK6r") },
{ name: "Functional Rendering", component: CodeSandbox("VPZ0Bzv8X") },
{
name: "Custom Expander Position",
component: CodeSandbox("1jj2XrPEV")
},
{ name: 'Custom "No Data" Text', component: CodeSandbox("RgRpRDv80") },
{ name: "Footers", component: CodeSandbox("KOqQXn3p8") },
{ name: "Custom Filtering", component: CodeSandbox("5Eyxxxyx") },
{ name: "Controlled Component", component: CodeSandbox("r7XEZRK2") },
{ name: "Editable Table", component: CodeSandbox("n5r19gzQP") },
{
name: "Fixed Header w/ Vertical Scroll",
component: CodeSandbox("7LY0gjA8O")
},
{
name: "Multiple Pagers (Top and Bottom)",
component: CodeSandbox("VEZ8OgvX")
},
{ name: "Tree Table (HOC)", component: CodeSandbox("lxmr4wynzq") },
{ name: "Select Table (HOC)", component: CodeSandbox("7yq5ylw09j") },
{ name: "Select Tree Table (HOC)", component: CodeSandbox("2p7jp4klwp") }
];
export default class App extends React.Component {
render() {
return (
<ReactStory
style={{
display: "block",
width: "100%",
height: "100%"
}}
pathPrefix="story/"
StoryWrapper={props => (
<defaultProps.StoryWrapper
css={{
padding: 0,
display: "flex",
flexDirection: "column"
}}
>
<a
href="//github.com/react-tools/react-table"
style={{
display: "block",
textAlign: "center",
borderBottom: "solid 3px #cccccc"
}}
>
<img
src="https://github.com/react-tools/media/raw/master/logo-react-table.png"
alt="React Table Logo"
style={{
width: "150px",
padding: "10px"
}}
/>
</a>
<div
{...props}
style={{
flex: "1 0 auto",
position: "relative"
}}
/>
</defaultProps.StoryWrapper>
)}
stories={stories}
/>
);
}
}
-21
View File
@@ -1,21 +0,0 @@
import React from "react";
export default id => () => {
return (
<iframe
src={`https://codesandbox.io/embed/${id}?autoresize=1&hidenavigation=1&view=${
global.innerWidth < 1000 ? "preview" : "split"
}`}
style={{
position: "absolute",
top: 0,
left: 0,
width: `100%`,
height: `100%`,
border: 0,
overflow: `hidden`
}}
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
/>
);
};
-94
View File
@@ -1,94 +0,0 @@
import React from "react";
export default Component => {
const wrapper = class RTCheckboxTable extends React.Component {
// we only need a Component so we can get the 'ref' - pure components can't get a 'ref'
rowSelector = row => {
if (!row || !row.hasOwnProperty(this.props.keyField)) return null;
const checked = this.props.isSelected(row[this.props.keyField]);
return (
<input
type="checkbox"
checked={checked}
onClick={e => {
const { shiftKey } = e;
e.stopPropagation();
this.props.toggleSelection(row[this.props.keyField], shiftKey, row);
}}
onChange={() => {}}
value=""
/>
);
};
headSelector = row => {
const checked = this.props.selectAll;
return (
<input
type="checkbox"
checked={checked}
onClick={e => {
e.stopPropagation();
this.props.toggleAll();
}}
onChange={() => {}}
value=""
/>
);
};
// this is so we can expose the underlying ReactTable to get at the sortedData for selectAll
getWrappedInstance = () => this.wrappedInstance;
render() {
const {
columns: originalCols,
isSelected,
toggleSelection,
toggleAll,
keyField,
selectAll,
...rest
} = this.props;
const { rowSelector, headSelector } = this;
const select = {
id: "_selector",
accessor: () => "x", // this value is not important
Header: headSelector,
Cell: ci => {
return rowSelector(ci.original);
},
width: 30,
filterable: false,
sortable: false,
resizable: false,
style: { textAlign: "center" }
};
const columns = [select, ...originalCols];
const extra = {
columns
};
return (
<Component {...rest} {...extra} ref={r => (this.wrappedInstance = r)} />
);
}
};
wrapper.displayName = "RTCheckboxTable";
wrapper.defaultProps = {
keyField: "_id",
isSelected: key => {
console.log("No isSelected handler provided:", { key });
},
selectAll: false,
toggleSelection: (key, shift, row) => {
console.log("No toggleSelection handler provided:", { key, shift, row });
},
toggleAll: () => {
console.log("No toggleAll handler provided.");
}
};
return wrapper;
};
-148
View File
@@ -1,148 +0,0 @@
import React from "react";
import shortid from "shortid";
import ReactTable from "../../../../lib/index";
import "../../../../react-table.css";
import checkboxTableHOC from "./checkboxHOC";
const CheckboxTable = checkboxTableHOC(ReactTable);
async function getData() {
const result = await (await fetch("/au_500_tree.json")).json();
// we are adding a unique ID to the data for tracking the selected records
return result.map(item => {
const _id = shortid.generate();
return {
_id,
...item
};
});
}
function getColumns(data) {
const columns = [];
const sample = data[0];
for (let key in sample) {
if (key === "_id") continue;
columns.push({
accessor: key,
Header: key
});
}
return columns;
}
export class ComponentTest extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
columns: null,
selection: [],
selectAll: false
};
}
componentDidMount() {
getData().then(data => {
const columns = getColumns(data);
this.setState({ data, columns });
});
}
toggleSelection = (key, shift, row) => {
/*
Implementation of how to manage the selection state is up to the developer.
This implementation uses an array stored in the component state.
Other implementations could use object keys, a Javascript Set, or Redux... etc.
*/
// start off with the existing state
let selection = [...this.state.selection];
const keyIndex = selection.indexOf(key);
// check to see if the key exists
if (keyIndex >= 0) {
// it does exist so we will remove it using destructing
selection = [
...selection.slice(0, keyIndex),
...selection.slice(keyIndex + 1)
];
} else {
// it does not exist so add it
selection.push(key);
}
// update the state
this.setState({ selection });
};
toggleAll = () => {
/*
'toggleAll' is a tricky concept with any filterable table
do you just select ALL the records that are in your data?
OR
do you only select ALL the records that are in the current filtered data?
The latter makes more sense because 'selection' is a visual thing for the user.
This is especially true if you are going to implement a set of external functions
that act on the selected information (you would not want to DELETE the wrong thing!).
So, to that end, access to the internals of ReactTable are required to get what is
currently visible in the table (either on the current page or any other page).
The HOC provides a method call 'getWrappedInstance' to get a ref to the wrapped
ReactTable and then get the internal state and the 'sortedData'.
That can then be iterrated to get all the currently visible records and set
the selection state.
*/
const selectAll = this.state.selectAll ? false : true;
const selection = [];
if (selectAll) {
// we need to get at the internals of ReactTable
const wrappedInstance = this.checkboxTable.getWrappedInstance();
// the 'sortedData' property contains the currently accessible records based on the filter and sort
const currentRecords = wrappedInstance.getResolvedState().sortedData;
// we just push all the IDs onto the selection array
currentRecords.forEach(item => {
selection.push(item._original._id);
});
}
this.setState({ selectAll, selection });
};
isSelected = key => {
/*
Instead of passing our external selection state we provide an 'isSelected'
callback and detect the selection state ourselves. This allows any implementation
for selection (either an array, object keys, or even a Javascript Set object).
*/
return this.state.selection.includes(key);
};
logSelection = () => {
console.log("selection:", this.state.selection);
};
render() {
const { toggleSelection, toggleAll, isSelected, logSelection } = this;
const { data, columns, selectAll } = this.state;
const extraProps = {
selectAll,
isSelected,
toggleAll,
toggleSelection
};
return (
<div style={{ padding: "10px" }}>
<h1>react-table - Checkbox Table</h1>
<button onClick={logSelection}>Log Selection to Console</button>
{` (${this.state.selection.length}) selected`}
{data ? (
<CheckboxTable
data={data}
columns={columns}
ref={r => (this.checkboxTable = r)}
className="-striped -highlight"
{...extraProps}
/>
) : null}
</div>
);
}
}
// export default treeTableHOC(ComponentTest);
export default ComponentTest;
-60
View File
@@ -1,60 +0,0 @@
import React from "react";
export default class ComponentTest extends React.component {
render() {
return <div>Bozo</div>;
}
}
// import ReactTable from '../../../../lib/index'
// import '../../../../react-table.css'
//
// console.log('ReactTable:',ReactTable)
//
// const data = [
// {one:"1.1",two:"1.2"},
// {one:"2.1",two:"2.2"},
// {one:"3.1",two:"3.2"},
// {one:"4.1",two:"4.2"},
// ]
//
// const columns = [
// {accessor:'one', Header: 'One'},
// {accessor:'two', Header: 'Two'},
// ]
//
// class ExpanderComponent extends React.Component {
// render()
// {
// return (
// <div className={`rt-expander ${this.props.isExpanded ? '-open' : ''}`}>
// &bull;
// </div>
// )
// }
// }
//
// class SubComponent extends React.Component {
// render()
// {
// return <div>Nothing</div>
// }
// }
//
// export default class ComponentTest extends React.Component {
// render()
// {
// const rtProps = {
// data,
// columns,
// // ExpanderComponent: (props)=><ExpanderComponent {...props} />,
// // SubComponent: (props)=><SubComponent {...props} />,
// // multiSort: false,
// }
// return (
// <ReactTable
// {...rtProps}
// />
// )
// }
// }
-7
View File
@@ -1,7 +0,0 @@
/* eslint-disable */
import TreeTable from "./treetable";
import SelectTable from "./selecttable";
import SelectTreeTable from "./selecttreetable";
export { TreeTable, SelectTable, SelectTreeTable };
-173
View File
@@ -1,173 +0,0 @@
import React from "react";
import shortid from "shortid";
import ReactTable from "../../../../lib/index";
import "../../../../react-table.css";
import selectTableHOC from "../../../../lib/hoc/selectTable";
const SelectTable = selectTableHOC(ReactTable);
async function getData() {
const result = await (await fetch("/au_500_tree.json")).json();
// we are adding a unique ID to the data for tracking the selected records
return result.map(item => {
const _id = shortid.generate();
return {
_id,
...item
};
});
}
function getColumns(data) {
const columns = [];
const sample = data[0];
for (let key in sample) {
if (key === "_id") continue;
columns.push({
accessor: key,
Header: key
});
}
return columns;
}
export class ComponentTest extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
columns: null,
selection: [],
selectAll: false,
selectType: "checkbox"
};
}
componentDidMount() {
getData().then(data => {
const columns = getColumns(data);
this.setState({ data, columns });
});
}
toggleSelection = (key, shift, row) => {
/*
Implementation of how to manage the selection state is up to the developer.
This implementation uses an array stored in the component state.
Other implementations could use object keys, a Javascript Set, or Redux... etc.
*/
// start off with the existing state
if (this.state.selectType === "radio") {
let selection = [];
if (selection.indexOf(key) < 0) selection.push(key);
this.setState({ selection });
} else {
let selection = [...this.state.selection];
const keyIndex = selection.indexOf(key);
// check to see if the key exists
if (keyIndex >= 0) {
// it does exist so we will remove it using destructing
selection = [
...selection.slice(0, keyIndex),
...selection.slice(keyIndex + 1)
];
} else {
// it does not exist so add it
selection.push(key);
}
// update the state
this.setState({ selection });
}
};
toggleAll = () => {
/*
'toggleAll' is a tricky concept with any filterable table
do you just select ALL the records that are in your data?
OR
do you only select ALL the records that are in the current filtered data?
The latter makes more sense because 'selection' is a visual thing for the user.
This is especially true if you are going to implement a set of external functions
that act on the selected information (you would not want to DELETE the wrong thing!).
So, to that end, access to the internals of ReactTable are required to get what is
currently visible in the table (either on the current page or any other page).
The HOC provides a method call 'getWrappedInstance' to get a ref to the wrapped
ReactTable and then get the internal state and the 'sortedData'.
That can then be iterrated to get all the currently visible records and set
the selection state.
*/
const selectAll = this.state.selectAll ? false : true;
const selection = [];
if (selectAll) {
// we need to get at the internals of ReactTable
const wrappedInstance = this.selectTable.getWrappedInstance();
// the 'sortedData' property contains the currently accessible records based on the filter and sort
const currentRecords = wrappedInstance.getResolvedState().sortedData;
// we just push all the IDs onto the selection array
currentRecords.forEach(item => {
if (item._original) {
selection.push(item._original._id);
}
});
}
this.setState({ selectAll, selection });
};
isSelected = key => {
/*
Instead of passing our external selection state we provide an 'isSelected'
callback and detect the selection state ourselves. This allows any implementation
for selection (either an array, object keys, or even a Javascript Set object).
*/
return this.state.selection.includes(key);
};
logSelection = () => {
console.log("selection:", this.state.selection);
};
toggleType = () => {
this.setState({
selectType: this.state.selectType === "radio" ? "checkbox" : "radio",
selection: [],
selectAll: false
});
};
render() {
const {
toggleSelection,
toggleAll,
isSelected,
logSelection,
toggleType
} = this;
const { data, columns, selectAll, selectType } = this.state;
const extraProps = {
selectAll,
isSelected,
toggleAll,
toggleSelection,
selectType
};
return (
<div style={{ padding: "10px" }}>
<h1>react-table - Select Table</h1>
<button onClick={toggleType}>
Select Type: <strong>{selectType}</strong>
</button>
<button onClick={logSelection}>Log Selection to Console</button>
{` (${this.state.selection.length}) selected`}
{data ? (
<SelectTable
data={data}
columns={columns}
ref={r => (this.selectTable = r)}
className="-striped -highlight"
{...extraProps}
/>
) : null}
</div>
);
}
}
export default ComponentTest;
-238
View File
@@ -1,238 +0,0 @@
import React from "react";
import shortid from "shortid";
import ReactTable from "../../../../lib/index";
import "../../../../react-table.css";
import selectTableHOC from "../../../../lib/hoc/selectTable";
import treeTableHOC from "../../../../lib/hoc/treeTable";
const SelectTreeTable = selectTableHOC(treeTableHOC(ReactTable));
async function getData() {
const result = await (await fetch("/au_500_tree.json")).json();
// we are adding a unique ID to the data for tracking the selected records
return result.map(item => {
const _id = shortid.generate();
return {
_id,
...item
};
});
}
function getColumns(data) {
const columns = [];
const sample = data[0];
for (let key in sample) {
if (key === "_id") continue;
columns.push({
accessor: key,
Header: key
});
}
return columns;
}
function getNodes(data, node = []) {
data.forEach(item => {
if (item.hasOwnProperty("_subRows") && item._subRows) {
node = getNodes(item._subRows, node);
} else {
node.push(item._original);
}
});
return node;
}
export class ComponentTest extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
columns: null,
selection: [],
selectAll: false,
selectType: "checkbox"
};
}
componentDidMount() {
getData().then(data => {
const columns = getColumns(data);
const pivotBy = ["state", "post"];
this.setState({ data, columns, pivotBy });
});
}
toggleSelection = (key, shift, row) => {
/*
Implementation of how to manage the selection state is up to the developer.
This implementation uses an array stored in the component state.
Other implementations could use object keys, a Javascript Set, or Redux... etc.
*/
// start off with the existing state
if (this.state.selectType === "radio") {
let selection = [];
if (selection.indexOf(key) < 0) selection.push(key);
this.setState({ selection });
} else {
let selection = [...this.state.selection];
const keyIndex = selection.indexOf(key);
// check to see if the key exists
if (keyIndex >= 0) {
// it does exist so we will remove it using destructing
selection = [
...selection.slice(0, keyIndex),
...selection.slice(keyIndex + 1)
];
} else {
// it does not exist so add it
selection.push(key);
}
// update the state
this.setState({ selection });
}
};
toggleAll = () => {
/*
'toggleAll' is a tricky concept with any filterable table
do you just select ALL the records that are in your data?
OR
do you only select ALL the records that are in the current filtered data?
The latter makes more sense because 'selection' is a visual thing for the user.
This is especially true if you are going to implement a set of external functions
that act on the selected information (you would not want to DELETE the wrong thing!).
So, to that end, access to the internals of ReactTable are required to get what is
currently visible in the table (either on the current page or any other page).
The HOC provides a method call 'getWrappedInstance' to get a ref to the wrapped
ReactTable and then get the internal state and the 'sortedData'.
That can then be iterrated to get all the currently visible records and set
the selection state.
*/
const selectAll = this.state.selectAll ? false : true;
const selection = [];
if (selectAll) {
// we need to get at the internals of ReactTable
const wrappedInstance = this.selectTable.getWrappedInstance();
// the 'sortedData' property contains the currently accessible records based on the filter and sort
const currentRecords = wrappedInstance.getResolvedState().sortedData;
// we need to get all the 'real' (original) records out to get at their IDs
const nodes = getNodes(currentRecords);
// we just push all the IDs onto the selection array
nodes.forEach(item => {
selection.push(item._id);
});
}
this.setState({ selectAll, selection });
};
isSelected = key => {
/*
Instead of passing our external selection state we provide an 'isSelected'
callback and detect the selection state ourselves. This allows any implementation
for selection (either an array, object keys, or even a Javascript Set object).
*/
return this.state.selection.includes(key);
};
logSelection = () => {
console.log("selection:", this.state.selection);
};
toggleType = () => {
this.setState({
selectType: this.state.selectType === "radio" ? "checkbox" : "radio",
selection: [],
selectAll: false
});
};
toggleTree = () => {
if (this.state.pivotBy.length) {
this.setState({ pivotBy: [], expanded: {} });
} else {
this.setState({ pivotBy: ["state", "post"], expanded: {} });
}
};
onExpandedChange = expanded => {
this.setState({ expanded });
};
render() {
const {
toggleSelection,
toggleAll,
isSelected,
logSelection,
toggleType,
toggleTree,
onExpandedChange
} = this;
const {
data,
columns,
selectAll,
selectType,
pivotBy,
expanded
} = this.state;
const extraProps = {
selectAll,
isSelected,
toggleAll,
toggleSelection,
selectType,
pivotBy,
expanded,
onExpandedChange,
pageSize: 5
};
return (
<div style={{ padding: "10px" }}>
<h1>react-table - Select Tree Table</h1>
<p>
This example combines two HOCs (the TreeTable and the SelectTable) to
make a composite component.
</p>
<p>We'll call it SelectTreeTable!</p>
<p>Here is what the buttons do:</p>
<ul>
<li>
<strong>Toggle Tree:</strong> enables or disabled the pivotBy on the
table.
</li>
<li>
<strong>Select Type:</strong> changes from 'checkbox' to 'radio' and
back again.
</li>
<li>
<strong>Log Selection to Console:</strong> open your console to see
what has been selected.
</li>
</ul>
<p>
<strong>NOTE:</strong> the selection is maintained when toggling the
tree on and off but is cleared when switching between select types
(radio, checkbox).
</p>
<button onClick={toggleTree}>
Toggle Tree [{pivotBy && pivotBy.length ? pivotBy.join(", ") : ""}]
</button>
<button onClick={toggleType}>
Select Type: <strong>{selectType}</strong>
</button>
<button onClick={logSelection}>Log Selection to Console</button>
{` (${this.state.selection.length}) selected`}
{data ? (
<SelectTreeTable
data={data}
columns={columns}
ref={r => (this.selectTable = r)}
className="-striped -highlight"
freezeWhenExpanded={true}
{...extraProps}
/>
) : null}
</div>
);
}
}
export default ComponentTest;
-70
View File
@@ -1,70 +0,0 @@
import React from "react";
import ReactTable from "../../../../lib/index";
import "../../../../react-table.css";
import treeTableHOC from "../../../../lib/hoc/treeTable";
async function getData() {
const result = await (await fetch("/au_500_tree.json")).json();
return result;
}
function getColumns(data, pivotBy) {
const columns = [];
const sample = data[0];
for (let key in sample) {
columns.push({
accessor: key,
Header: key
});
}
return columns;
}
export class ComponentTest extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
columns: null,
pivotBy: null // ["firstName", "lastName"],
};
}
componentDidMount() {
getData().then(data => {
// console.log('cwm data:',data);
const pivotBy = ["state", "post", "city"];
const columns = getColumns(data, pivotBy);
// console.log('cwm cols:',columns);
this.setState({ data, columns, pivotBy });
});
}
showState = () => {
console.log("state:", this.reactTable.getResolvedState());
};
render() {
const { data, columns, pivotBy } = this.state;
const extraProps = {
data,
columns,
pivotBy
};
const TreeTable = treeTableHOC(ReactTable);
return (
<div style={{ padding: "10px" }}>
<h1>react-table - Tree Table</h1>
{data ? (
<TreeTable
ref={r => (this.reactTable = r)}
className="-striped -highlight"
defaultPageSize={5}
{...extraProps}
/>
) : null}
</div>
);
}
}
export default ComponentTest;
@@ -1,53 +0,0 @@
import React from "react";
export default Component => {
const wrapper = componentProps => {
const TrComponent = props => {
const { ri, ...rest } = props;
if (ri && ri.groupedByPivot) {
const cell = props.children[ri.level];
cell.props.style.flex = "unset";
cell.props.style.width = "100%";
cell.props.style.maxWidth = "unset";
cell.props.style.paddingLeft = `${componentProps.treeTableIndent *
ri.level}px`;
cell.props.style.backgroundColor = "#DDD";
cell.props.style.borderBottom = "1px solid rgba(128,128,128,0.2)";
return <div {...rest}>{cell}</div>;
}
return <Component.defaultProps.TrComponent {...rest} />;
};
const getTrProps = (state, ri, ci, instance) => {
return { ri };
};
const { columns, ...rest } = componentProps;
const extra = {
columns: columns.map(col => {
let column = col;
if (rest.pivotBy && rest.pivotBy.includes(col.accessor)) {
column = {
accessor: col.accessor,
width: `${componentProps.treeTableIndent}px`,
show: false,
Header: ""
};
}
return column;
}),
TrComponent,
getTrProps
};
return <Component {...rest} {...extra} />;
};
wrapper.displayName = "RTTreeTable";
wrapper.defaultProps = {
treeTableRowBackground: "#EEE",
treeTableIndent: 10
};
return wrapper;
};
-35
View File
@@ -1,35 +0,0 @@
import namor from "namor";
const range = len => {
const arr = [];
for (let i = 0; i < len; i++) {
arr.push(i);
}
return arr;
};
const newPerson = () => {
const statusChance = Math.random();
return {
firstName: namor.generate({ words: 1, numbers: 0 }),
lastName: namor.generate({ words: 1, numbers: 0 }),
age: Math.floor(Math.random() * 30),
visits: Math.floor(Math.random() * 100),
progress: Math.floor(Math.random() * 100),
status:
statusChance > 0.66
? "relationship"
: statusChance > 0.33
? "complicated"
: "single"
};
};
export function makeData(len = 5553) {
return range(len).map(d => {
return {
...newPerson(),
children: range(10).map(newPerson)
};
});
}
-10
View File
@@ -1,10 +0,0 @@
html,
body,
#root {
height: 100%;
}
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
-7
View File
@@ -1,7 +0,0 @@
import React from "react";
import ReactDOM from "react-dom";
//
import "./index.css";
import App from "./App.js";
ReactDOM.render(<App />, document.getElementById("root"));
-23
View File
@@ -1,23 +0,0 @@
/* eslint-disable */
import React from "react";
import marked from "marked";
//
import HOCReadme from "!raw!../../../src/hoc/README.md";
import "github-markdown-css/github-markdown.css";
import "./utils/prism.js";
export default class HOCStory extends React.Component {
render() {
return (
<div style={{ padding: "10px" }}>
<span
className="markdown-body"
dangerouslySetInnerHTML={{ __html: marked(HOCReadme) }}
/>
</div>
);
}
componentDidMount() {
global.Prism && global.Prism.highlightAll();
}
}
-23
View File
@@ -1,23 +0,0 @@
/* eslint-disable import/no-webpack-loader-syntax */
import React from "react";
import marked from "marked";
//
import Readme from "!raw!../../../README.md";
import "github-markdown-css/github-markdown.css";
import "./utils/prism.js";
export default class Story extends React.Component {
render() {
return (
<div style={{ padding: "10px" }}>
<span
className="markdown-body"
dangerouslySetInnerHTML={{ __html: marked(Readme) }}
/>
</div>
);
}
componentDidMount() {
global.Prism && global.Prism.highlightAll();
}
}
-27
View File
@@ -1,27 +0,0 @@
import React from "react";
import ReactTable from "../../../lib/index";
import "../../../react-table.css";
const data = [
{ one: "1.1", two: "1.2" },
{ one: "2.1", two: "2.2" },
{ one: "3.1", two: "3.2" },
{ one: "4.1", two: "4.2" }
];
const columns = [
{ accessor: "one", Header: "One" },
{ accessor: "two", Header: "Two" }
];
export default class Story extends React.Component {
render() {
return (
<div>
Test
<ReactTable data={data} columns={columns} />
</div>
);
}
}
-138
View File
@@ -1,138 +0,0 @@
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
File diff suppressed because one or more lines are too long
-7301
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
{
"presets": ["react-app"],
"plugins": ["styled-components"]
}
+1
View File
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
+7
View File
@@ -0,0 +1,7 @@
{
"extends": ["react-app", "prettier"],
"rules": {
// "eqeqeq": 0,
// "jsx-a11y/anchor-is-valid": 0
}
}
+23
View File
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+29
View File
@@ -0,0 +1,29 @@
const path = require('path')
const resolveFrom = require('resolve-from')
const fixLinkedDependencies = config => {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
react$: resolveFrom(path.resolve('node_modules'), 'react'),
'react-dom$': resolveFrom(path.resolve('node_modules'), 'react-dom'),
},
}
return config
}
const includeSrcDirectory = config => {
config.resolve = {
...config.resolve,
modules: [path.resolve('src'), ...config.resolve.modules],
}
return config
}
module.exports = [
['use-babel-config', '.babelrc'],
['use-eslint-config', '.eslintrc'],
fixLinkedDependencies,
// includeSrcDirectory,
]
+6
View File
@@ -0,0 +1,6 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and Rescripts.
You can:
- [Open this example in a new CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/absolute-layout)
- `yarn` and `yarn start` to run and edit the example
+35
View File
@@ -0,0 +1,35 @@
{
"private": true,
"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test",
"eject": "rescripts eject"
},
"dependencies": {
"namor": "^1.1.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"react-table": "latest",
"styled-components": "^4.3.2"
},
"devDependencies": {
"@rescripts/cli": "^0.0.11",
"@rescripts/rescript-use-babel-config": "^0.0.8",
"@rescripts/rescript-use-eslint-config": "^0.0.9",
"babel-eslint": "10.0.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

@@ -1,11 +1,17 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
Notice the use of %PUBLIC_URL% in the tag above.
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
@@ -13,9 +19,10 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React Table - A lightweight, fast and extendable datagrid built for React</title>
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
@@ -24,8 +31,8 @@
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
+164
View File
@@ -0,0 +1,164 @@
import React from 'react'
import styled from 'styled-components'
import { useTable, useAbsoluteLayout } from 'react-table'
import makeData from './makeData'
const Styles = styled.div`
padding: 1rem;
* {
box-sizing: border-box;
}
.table {
border: 1px solid #000;
max-width: 700px;
overflow-x: auto;
}
.header {
font-weight: bold;
}
.rows {
overflow-y: auto;
}
.row {
border-bottom: 1px solid #000;
height: 32px;
&.body {
:last-child {
border: 0;
}
}
}
.cell {
height: 100%;
line-height: 30px;
border-right: 1px solid #000;
padding-left: 5px;
:last-child {
border: 0;
}
}
`
function Table({ columns, data }) {
// Use the state and functions returned from useTable to build your UI
const defaultColumn = React.useMemo(
() => ({
width: 150,
}),
[]
)
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
} = useTable(
{
columns,
data,
defaultColumn,
},
useAbsoluteLayout
)
// Render the UI for your table
return (
<div {...getTableProps()} className="table">
<div>
{headerGroups.map(headerGroup => (
<div
{...headerGroup.getHeaderGroupProps()}
className="row header-group"
>
{headerGroup.headers.map(column => (
<div {...column.getHeaderProps()} className="cell header">
{column.render('Header')}
</div>
))}
</div>
))}
</div>
<div className="rows" {...getTableBodyProps()}>
{rows.map((row, i) => {
prepareRow(row)
return (
<div {...row.getRowProps()} className="row body">
{row.cells.map((cell, index) => (
<div {...cell.getCellProps()} key={index} className="cell">
{cell.render('Cell')}
</div>
))}
</div>
)
})}
</div>
</div>
)
}
function App() {
const columns = React.useMemo(
() => [
{
Header: 'Name',
columns: [
{
Header: 'First Name',
accessor: 'firstName',
},
{
Header: 'Last Name',
accessor: 'lastName',
},
],
},
{
Header: 'Info',
columns: [
{
Header: 'Age',
accessor: 'age',
width: 50,
},
{
Header: 'Visits',
accessor: 'visits',
width: 60,
},
{
Header: 'Status',
accessor: 'status',
},
{
Header: 'Profile Progress',
accessor: 'progress',
},
],
},
],
[]
)
const data = React.useMemo(() => makeData(20), [])
return (
<Styles>
<Table columns={columns} data={data} />
</Styles>
)
}
export default App
+9
View File
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
+13
View File
@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
+6
View File
@@ -0,0 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
ReactDOM.render(<App />, document.getElementById('root'))
+40
View File
@@ -0,0 +1,40 @@
import namor from 'namor'
const range = len => {
const arr = []
for (let i = 0; i < len; i++) {
arr.push(i)
}
return arr
}
const newPerson = () => {
const statusChance = Math.random()
return {
firstName: namor.generate({ words: 1, numbers: 0 }),
lastName: namor.generate({ words: 1, numbers: 0 }),
age: Math.floor(Math.random() * 30),
visits: Math.floor(Math.random() * 100),
progress: Math.floor(Math.random() * 100),
status:
statusChance > 0.66
? 'relationship'
: statusChance > 0.33
? 'complicated'
: 'single',
}
}
export default function makeData(...lens) {
const makeDataLevel = (depth = 0) => {
const len = lens[depth]
return range(len).map(d => {
return {
...newPerson(),
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
}
})
}
return makeDataLevel()
}
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
{
"presets": ["react-app"],
"plugins": ["styled-components"]
}
+1
View File
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
@@ -0,0 +1,7 @@
{
"extends": ["react-app", "prettier"],
"rules": {
// "eqeqeq": 0,
// "jsx-a11y/anchor-is-valid": 0
}
}
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
@@ -0,0 +1,29 @@
const path = require('path')
const resolveFrom = require('resolve-from')
const fixLinkedDependencies = config => {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
react$: resolveFrom(path.resolve('node_modules'), 'react'),
'react-dom$': resolveFrom(path.resolve('node_modules'), 'react-dom'),
},
}
return config
}
const includeSrcDirectory = config => {
config.resolve = {
...config.resolve,
modules: [path.resolve('src'), ...config.resolve.modules],
}
return config
}
module.exports = [
['use-babel-config', '.babelrc'],
['use-eslint-config', '.eslintrc'],
fixLinkedDependencies,
// includeSrcDirectory,
]
@@ -0,0 +1,6 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and Rescripts.
You can:
- [Open this example in a new CodeSandbox](https://codesandbox.io/s/github/tannerlinsley/react-table/tree/master/examples/animated-framer-motion)
- `yarn` and `yarn start` to run and edit the example
@@ -0,0 +1,37 @@
{
"private": true,
"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test",
"eject": "rescripts eject"
},
"dependencies": {
"framer-motion": "^1.6.3",
"match-sorter": "^4.0.1",
"namor": "^1.1.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"react-table": "latest",
"styled-components": "^4.3.2"
},
"devDependencies": {
"@rescripts/cli": "^0.0.11",
"@rescripts/rescript-use-babel-config": "^0.0.8",
"@rescripts/rescript-use-eslint-config": "^0.0.9",
"babel-eslint": "10.0.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
+384
View File
@@ -0,0 +1,384 @@
import React from 'react'
import styled from 'styled-components'
import { useTable, useSortBy, useFilters, useColumnOrder } from 'react-table'
import { motion, AnimatePresence } from 'framer-motion'
import matchSorter from 'match-sorter'
import makeData from './makeData'
const Styles = styled.div`
padding: 1rem;
table {
border-spacing: 0;
border: 1px solid black;
tr {
:last-child {
td {
border-bottom: 0;
}
}
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
background: white;
:last-child {
border-right: 0;
}
}
}
`
// Define a default UI for filtering
function DefaultColumnFilter({
column: { filterValue, preFilteredRows, setFilter },
}) {
const count = preFilteredRows.length
return (
<input
value={filterValue || ''}
onChange={e => {
setFilter(e.target.value || undefined) // Set undefined to remove the filter entirely
}}
placeholder={`Search ${count} records...`}
/>
)
}
// This is a custom filter UI for selecting
// a unique option from a list
function SelectColumnFilter({
column: { filterValue, setFilter, preFilteredRows, id },
}) {
// Calculate the options for filtering
// using the preFilteredRows
const options = React.useMemo(() => {
const options = new Set()
preFilteredRows.forEach(row => {
options.add(row.values[id])
})
return [...options.values()]
}, [id, preFilteredRows])
// Render a multi-select box
return (
<select
value={filterValue}
onChange={e => {
setFilter(e.target.value || undefined)
}}
>
<option value="">All</option>
{options.map((option, i) => (
<option key={i} value={option}>
{option}
</option>
))}
</select>
)
}
// This is a custom filter UI that uses a
// slider to set the filter value between a column's
// min and max values
function SliderColumnFilter({
column: { filterValue, setFilter, preFilteredRows, id },
}) {
// Calculate the min and max
// using the preFilteredRows
const [min, max] = React.useMemo(() => {
let min = preFilteredRows.length ? preFilteredRows[0].values[id] : 0
let max = preFilteredRows.length ? preFilteredRows[0].values[id] : 0
preFilteredRows.forEach(row => {
min = Math.min(row.values[id], min)
max = Math.max(row.values[id], max)
})
return [min, max]
}, [id, preFilteredRows])
return (
<>
<input
type="range"
min={min}
max={max}
value={filterValue || min}
onChange={e => {
setFilter(parseInt(e.target.value, 10))
}}
/>
<button onClick={() => setFilter(undefined)}>Off</button>
</>
)
}
// This is a custom UI for our 'between' or number range
// filter. It uses two number boxes and filters rows to
// ones that have values between the two
function NumberRangeColumnFilter({
column: { filterValue = [], preFilteredRows, setFilter, id },
}) {
const [min, max] = React.useMemo(() => {
let min = preFilteredRows.length ? preFilteredRows[0].values[id] : 0
let max = preFilteredRows.length ? preFilteredRows[0].values[id] : 0
preFilteredRows.forEach(row => {
min = Math.min(row.values[id], min)
max = Math.max(row.values[id], max)
})
return [min, max]
}, [id, preFilteredRows])
return (
<div
style={{
display: 'flex',
}}
>
<input
value={filterValue[0] || ''}
type="number"
onChange={e => {
const val = e.target.value
setFilter((old = []) => [val ? parseInt(val, 10) : undefined, old[1]])
}}
placeholder={`Min (${min})`}
style={{
width: '70px',
marginRight: '0.5rem',
}}
/>
to
<input
value={filterValue[1] || ''}
type="number"
onChange={e => {
const val = e.target.value
setFilter((old = []) => [old[0], val ? parseInt(val, 10) : undefined])
}}
placeholder={`Max (${max})`}
style={{
width: '70px',
marginLeft: '0.5rem',
}}
/>
</div>
)
}
function fuzzyTextFilterFn(rows, id, filterValue) {
return matchSorter(rows, filterValue, { keys: [row => row.values[id]] })
}
// Let the table remove the filter if the string is empty
fuzzyTextFilterFn.autoRemove = val => !val
function shuffle(arr) {
arr = [...arr]
const shuffled = []
while (arr.length) {
const rand = Math.floor(Math.random() * arr.length)
shuffled.push(arr.splice(rand, 1)[0])
}
return shuffled
}
function Table({ columns, data }) {
const defaultColumn = React.useMemo(
() => ({
// Let's set up our default Filter UI
Filter: DefaultColumnFilter,
}),
[]
)
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
flatColumns,
prepareRow,
setColumnOrder,
state,
} = useTable(
{
columns,
data,
defaultColumn,
},
useColumnOrder,
useFilters,
useSortBy
)
const spring = React.useMemo(
() => ({
type: 'spring',
damping: 50,
stiffness: 100,
}),
[]
)
const randomizeColumns = () => {
setColumnOrder(shuffle(flatColumns.map(d => d.id)))
}
return (
<>
<button onClick={() => randomizeColumns({})}>Randomize Columns</button>
<table {...getTableProps()}>
<thead>
{headerGroups.map((headerGroup, i) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<motion.th
{...column.getHeaderProps({
layoutTransition: spring,
style: {
minWidth: column.minWidth,
},
})}
>
<div {...column.getSortByToggleProps()}>
{column.render('Header')}
<span>
{column.isSorted
? column.isSortedDesc
? ' 🔽'
: ' 🔼'
: ''}
</span>
</div>
<div>{column.canFilter ? column.render('Filter') : null}</div>
</motion.th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
<AnimatePresence>
{rows.slice(0, 10).map(
(row, i) => {
prepareRow(row);
return (
<motion.tr
{...row.getRowProps({
layoutTransition: spring,
exit: { opacity: 0, maxHeight: 0 },
})}
>
{row.cells.map((cell, i) => {
return (
<motion.td
{...cell.getCellProps({
layoutTransition: spring,
})}
>
{cell.render('Cell')}
</motion.td>
)
})}
</motion.tr>
)}
)}
</AnimatePresence>
</tbody>
</table>
<pre>
<code>{JSON.stringify(state, null, 2)}</code>
</pre>
</>
)
}
// Define a custom filter filter function!
function filterGreaterThan(rows, id, filterValue) {
return rows.filter(row => {
const rowValue = row.values[id]
return rowValue >= filterValue
})
}
// This is an autoRemove method on the filter function that
// when given the new filter value and returns true, the filter
// will be automatically removed. Normally this is just an undefined
// check, but here, we want to remove the filter if it's not a number
filterGreaterThan.autoRemove = val => typeof val !== 'number'
function App() {
const columns = React.useMemo(
() => [
{
Header: 'Name',
columns: [
{
Header: 'First Name',
accessor: 'firstName',
minWidth: 150,
},
{
Header: 'Last Name',
accessor: 'lastName',
minWidth: 150,
// Use our custom `fuzzyText` filter on this column
filter: 'fuzzyText',
},
],
},
{
Header: 'Info',
columns: [
{
Header: 'Age',
accessor: 'age',
minWidth: 150,
Filter: SliderColumnFilter,
filter: 'equals',
},
{
Header: 'Visits',
accessor: 'visits',
minWidth: 150,
Filter: NumberRangeColumnFilter,
filter: 'between',
},
{
Header: 'Status',
accessor: 'status',
minWidth: 150,
Filter: SelectColumnFilter,
filter: 'includes',
},
{
Header: 'Profile Progress',
accessor: 'progress',
minWidth: 150,
Filter: SliderColumnFilter,
filter: filterGreaterThan,
},
],
},
],
[]
)
const data = React.useMemo(() => makeData(100), [])
return (
<Styles>
<Table columns={columns} data={data} />
</Styles>
)
}
export default App
@@ -0,0 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
ReactDOM.unmountComponentAtNode(div)
})
@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
@@ -0,0 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
ReactDOM.render(<App />, document.getElementById('root'))

Some files were not shown because too many files have changed in this diff Show More