Commit Graph

380 Commits

Author SHA1 Message Date
Roman Komarov
73ed7efbe6
useTable: Fixes memoizing of headerGroups (#1920)
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
2020-02-21 07:04:41 -07:00
Roman Komarov
7498059e98
useRowSelect: remove redundant checks (#1918)
* useRowSelect: remove redundant checks

* Update useRowSelect.js

Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
2020-02-21 07:03:27 -07:00
Tanner Linsley
917cfcc910 Better plugin order api 2020-02-15 20:00:42 -07:00
Tanner Linsley
083e81dc81 Normalize API method names and row modesl, add expandAll functionality including prop getter 2020-02-15 12:43:09 -07:00
gargroh
32ca5a240b
Add Column data in autoRemove of Filters (#1906)
* Update utils.js

* Update useFilters.js
2020-02-14 13:15:38 -07:00
Guy Gascoigne-Piggford
98b3161b2d
Add option to allow toggleRowSelect to not select subRows (#1879)
* Add option to allow toggleRowSelect to not select subRows

Iif you are using manualGrouping, it's convenient to be able
to select the group without selecting all of the children.

This adds an instance option `selectChildRows`, which defaults to true,
that can be set to false to allow selection of the group without it
selecting all of the children.

* fix lint error

Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
2020-02-14 13:14:10 -07:00
Guy Gascoigne-Piggford
1eb492694a
wrap instance dispatchers in useCallback (#1874)
addresses https://github.com/tannerlinsley/react-table/issues/1808

Several of the instance methods added by plugins wrap their state update
functions in useCallback, the ones that didn't do this can lead to problems
where when they are used in a component, for instance in a hook, their
required presence in the dependency array causes an infinite loop as
executing the function triggers an instance update and a new function
generation.  This PR addresses this.

Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
2020-02-14 13:07:56 -07:00
Tanner Linsley
14ff3ef6c5 Merge branch 'master' of https://github.com/react-tools/react-table 2020-02-14 13:03:25 -07:00
Tanner Linsley
fce2ebe763 Update useGlobalFilter.js 2020-02-14 13:03:11 -07:00
Zain Shaikh
812b416367
fix: fix spelling of manualGroupBy parameter (#1860)
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
2020-02-14 12:57:05 -07:00
Tanner Linsley
7dc9b85165 Polish merge conflicts and changelog updates 2020-02-14 12:12:24 -07:00
Tanner Linsley
21826a93e0 Merge branch 'master' of https://github.com/react-tools/react-table 2020-02-14 11:27:19 -07:00
Tanner Linsley
b989a8fa76 Changed: Tests, aggregation, hooks, columnVisibility, docs 2020-02-14 11:23:05 -07:00
ta-anders
8ea93b9fed fix(usefilters): fix userFilterTypes alias in setFilter action (#1842)
Fix to correctly alias filterTypes to userFilterTypes in set filter action, so that the filter
autoremove method is called correctly

fix #1831
2020-01-09 06:17:46 -07:00
gargroh
6ebf3183a0 [useSort] Add sort order custom sortMethod (#1615)
Added sort order as parameter for calling sortMethod(will be useful to provide more control in custom sortMethod)
2020-01-09 06:17:12 -07:00
Roman Ivaskevych
2a0dc6778d fix(usepagination resetpage on globalfilter change): pageIndex reset (#1813)
autoReset pageIndex on globalFilter change

"fix #1812"
2020-01-08 16:33:25 -07:00
ggascoigne
1d8ffb18f7 Add fixed width column support to useFlexLayout (#1810)
* Add fixed width column support to useFlexLayout

*  Allow useFlexLayout to honor canResize by calculating flex width separately from total width.
*  Update example to show the selection checkbox since that's a common fixed width use case.
*  Add example for right aligning columns.
*  Tweaked the styles for the table to better align the resize handles (since it made verifying the rest easier when they weren't misaligned by the scroll bar width)

Note that the resize behavior is still rather strange, but that's a separate problem that this change didn't really effect.

* swich to react-table@latest
2019-12-25 19:59:43 -07:00
Aaron Corley
45e5bed468 misc fixes for useGlobalFilter (#1795)
* docs(useglobalfilter.md): corrected documentation for setGlobalFilter

* fix(useglobalfilter.js): wrapped setGlobalFilter in useCallback

Wrapped setGlobalFilter in useCallback for identity stability.
2019-12-19 15:21:27 -07:00
Tanner Linsley
d18f1ba4d8 Add global filtering support via useGlobalFilter 2019-12-18 13:22:58 -07:00
Tanner Linsley
30a40aa0a2 Change meta signature for hooks 2019-12-18 11:54:43 -07:00
Tanner Linsley
cb59098685 Fix column hiding, add useControlledStat hook 2019-12-18 10:39:35 -07:00
hanvyj
4e013632dd Fix groupBy removed columns (#1776) (#1782) 2019-12-17 20:52:57 -07: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
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
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
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
15125f9326 Update useColumnVisibility.js 2019-12-10 12:42:19 -07:00
Tanner Linsley
e1fd921f07 Add useFinalInstance plugin hook 2019-12-10 11:56:41 -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
Tanner Linsley
492ba8a4f9 Update Changelog 2019-12-08 19:35:55 -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
Tanner Linsley
a152704fde v7.0.0-rc.1 2019-12-05 23:36:14 -05:00
Tanner Linsley
a33a008608 Add Footer Support 2019-12-05 23:11:50 -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
Tanner Linsley
b687cc01f0 7.0.0-beta.27 2019-12-04 22:46:53 -05:00