Commit Graph

100 Commits

Author SHA1 Message Date
Tanner Linsley
9fa1396f26 Mucho updates 2019-12-13 00:22:30 -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
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
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
Jakob Hjelmer Nielsen
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
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
Bart Nagel
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
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
gargroh
3d5249b716 [useSortBy] updating missed key rename (#1724) 2019-12-06 03:19:28 -05:00
Martin Brenner
7169b3100b Remove tooltip if columnDisableSortBy (#1685)
* Remove tooltip if columnDisableSortBy

* update sorting test snapshot
2019-12-05 15:48:57 -05:00
Tanner Linsley
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
Martin Brenner
487abd2119 pass the instance with updated rows (#1714) 2019-12-05 09:14:07 -05:00
Cody Schwebke
7014647b4a fix: fix crash in useSortBy resetSortBy action (#1695) 2019-12-03 12:52:08 -07: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
Roman Kovtun
d7da8b631d Fix issue with missing columnId in updater on column spread (#1682) 2019-12-02 20:49:04 -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
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
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 Llop
764a8ce281 Fix default resetSelectedRowsDeps (#1663)
* This one also is listening to rows, instead of data.
2019-11-29 21:14:25 -07:00
Jason Law
0a512adaf0 fix: memory leak fix (#1610)
* fix: memory leak

* Style change
2019-11-29 21:14:04 -07:00
Andros Rosa Llop
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
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
58028e45fc Rename disableGrouping, remove propTypes, update Readme 2019-11-20 10:23:52 -07:00
Tanner Linsley
ed3dd9e6b5 Add "default" sort/filter/groupBy options for non accessors, rename disableGrouping 2019-11-20 09:35:40 -07:00
Tanner Linsley
50b00b67c5 Added data-driven-classes-and-styles example
- Also updated snapshots
2019-11-20 08:43:57 -07:00
yvanzo
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
Hugo Bove
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
tannerlinsley
4842bc061d fix: fix includeAll filter type, add filteredRows 2019-10-07 10:27:18 -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
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
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
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 Bove
69e13b87c3 feat(useexpanded, usepagination): omit subRows from rows (#1562)
Added useExpanded 'expandSubRows' option
2019-10-02 06:51:14 -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
gargroh
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
f552c94972 fix(usepagination): fix unstable callbacks
Closes #1549
2019-09-26 13:21:34 -06:00
tannerlinsley
dfad9151c3 fix(expandedrows): fix in-page row expansion for paginateExpandedRows 2019-09-13 07:33:53 -06:00
Codar
aea76facf1 isAllRowsSelected can only be true if there are rows. (#1504) 2019-09-09 08:49:40 -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