Compare commits

...
Author SHA1 Message Date
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
94 changed files with 24414 additions and 14205 deletions
+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
+1
View File
@@ -10,3 +10,4 @@ react-table.css
.idea
.DS_Store
.history
package-lock.json
+1 -1
View File
@@ -1,6 +1,6 @@
module.exports = {
hooks: {
'pre-commit': 'lint-staged && yarn test:ci',
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
// 'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
},
}
+1
View File
@@ -0,0 +1 @@
package-lock=false
+13 -2
View File
@@ -1,7 +1,18 @@
language: node_js
node_js:
- "10"
- 10
- 12
os:
- linux
- osx
- windows
env:
global:
- YARN_GPG=no
cache: yarn
script: npm test
script: yarn test
+20
View File
@@ -1,3 +1,23 @@
## 7.0.0-beta.14
## 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.
+101 -71
View File
@@ -4,32 +4,20 @@
Hooks for building **lightweight, fast and extendable datagrids** for React
<a href="https://travis-ci.org/tannerlinsley/react-table" target="\_parent">
<img alt="" src="https://travis-ci.org/tannerlinsley/react-table.svg?branch=master" />
</a>
<a href="https://bundlephobia.com/result?p=react-table@next" target="\_parent">
<img alt="" src="https://badgen.net/bundlephobia/minzip/react-table@next" />
</a>
<a href="https://npmjs.com/package/react-table" target="\_parent">
<img alt="" src="https://img.shields.io/npm/dm/react-table.svg" />
</a>
<a href="https://spectrum.chat/react-table">
<img alt="Join the community on Spectrum" src="https://withspectrum.github.io/badge/badge.svg" />
</a>
<a href="https://github.com/tannerlinsley/react-table" target="\_parent">
<img alt="" src="https://img.shields.io/github/stars/tannerlinsley/react-table.svg?style=social&label=Star" />
</a>
<a href="https://twitter.com/tannerlinsley" target="\_parent">
<img alt="" src="https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow" />
</a>
<br />
<br />
<a href="https://patreon.com/tannerlinsley">
<img width="180" alt="" src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/become-a-patron.png" />
</a>
[![#TanStack](https://img.shields.io/twitter/url?color=%2308a0e9&label=%23TanStack&style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Fbutton_hashtag%3DTanStack)](https://twitter.com/intent/tweet?button_hashtag=TanStack)
<br />
<br />
<!-- [![GitHub Actions CI](https://github.com/tannerlinsley/react-table/workflows/CI/badge.svg)](https://github.com/tannerlinsley/react-table/actions) -->
[![Travis CI](https://travis-ci.org/tannerlinsley/react-table.svg?branch=master)](https://travis-ci.org/tannerlinsley/react-table)
[![Bundlephobia](https://badgen.net/bundlephobia/minzip/react-table@next)](https://bundlephobia.com/result?p=react-table@next)
[![NPM Package](https://img.shields.io/npm/dm/react-table.svg)](https://npmjs.com/package/react-table)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/react-table)
[![GitHub Stars](https://img.shields.io/github/stars/tannerlinsley/react-table.svg?style=social&label=Star)](https://github.com/tannerlinsley/react-table)
[![Twitter Followers](https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow)](https://twitter.com/tannerlinsley)
Enjoy this library? Try them all! [React Query](https://github.com/tannerlinsley/react-query), [React Form](https://github.com/tannerlinsley/react-form), [React Charts](https://github.com/tannerlinsley/react-charts)
### [Become a Sponsor](https://github.com/sponsors/tannerlinsley/)
## Features
@@ -71,6 +59,8 @@ Please [visit the v6 branch](https://github.com/tannerlinsley/react-table/tree/v
The differences between the 2 versions are incredibly massive. Unfortunately, I cannot write a one-to-one upgrade guide for any of v6's API, simply because much of it is irrelevant with v7's headless approach. The best approach for migrating to v7 is to learn its API by reading the documentation and then following some of the examples to begin building your own table component.
In case you would need to have both v6 and v7 in one app during the migration process (large codebase, complex use cases), you can install an official [`react-table-6` package](https://www.npmjs.com/package/react-table-6) alongside the `react-table`.
## Documentation
- [Installation](./docs/installation.md) - Walk through how to install React Table
@@ -82,24 +72,46 @@ The differences between the 2 versions are incredibly massive. Unfortunately, I
## Sponsors
**React Table v7** is being built and maintained by me, @tannerlinsley and I am always in need of more Patreon support to keep this project afloat. If you would like to contribute to my Patreon goal for v7 and beyond, [visit my Patreon and help me out!](https://patreon.com/tannerlinsley)
This library is being built and maintained by me, @tannerlinsley and I am always in need of more support to keep this project afloat. If you would like to get additional support, add your logo or name on this README, or simply just contribute to my open source Sponsorship goal, [visit my Github Sponsors page!](https://github.com/sponsors/tannerlinsley/)
<table>
<tbody {...getTableBodyProps()}>
<tbody>
<tr>
<td align="center" valign="middle">
<a href="https://patreon.com/tannerlinsley" target="_blank">
<img width='200' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/platinum.png">
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
<img width='150' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/diamond.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
Become a Sponsor!
</a>
</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td align="center" valign="middle">
<a href="https://github.com/sponsors/tannerlinsley/" target="_blank">
<img width='150' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/platinum.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://tryretool.com/?utm_source=sponsor&utm_campaign=react_table" target="_blank">
<img width='350' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-retool.png">
<img width='225' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-retool.png">
</a>
</td>
<td align="center" valign="middle">
<a href="http://bjntech.com/index.html?utm_campaign=react_table" target="_blank">
<img width='250' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-bjn.png">
<img width='225' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-bjn.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
Become a Sponsor!
</a>
</td>
</tr>
@@ -107,38 +119,26 @@ The differences between the 2 versions are incredibly massive. Unfortunately, I
</table>
<table>
<tbody {...getTableBodyProps()}>
<tbody>
<tr>
<td align="center" valign="middle">
<a href="https://patreon.com/tannerlinsley" target="_blank">
<img width='200' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/gold.png">
<a href="https://github.com/sponsors/tannerlinsley/" target="_blank">
<img width='150' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/gold.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://nozzle.io" target="_blank">
<img width='230' src="https://nozzle.io/img/logo-blue.png">
<img width='225' src="https://nozzle.io/img/logo-blue.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://zappi.io/web/" target="_blank">
<img width='230' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-zappi.png">
</a>
</td>
</tr>
</tbody>
</table>
<table>
<tbody {...getTableBodyProps()}>
<tr>
<td align="center" valign="middle">
<a href="https://patreon.com/tannerlinsley" target="_blank">
<img width='200' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver.png">
<img width='225' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-zappi.png">
</a>
</td>
<td align="center" valign="middle">
<a href="https://patreon.com/tannerlinsley" target="_blank">
<img src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver-placeholder.png">
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
Become a Sponsor!
</a>
</td>
</tr>
@@ -146,43 +146,73 @@ The differences between the 2 versions are incredibly massive. Unfortunately, I
</table>
<table>
<tbody {...getTableBodyProps()}>
<tbody>
<tr>
<td valign="top">
<a href="https://patreon.com/tannerlinsley">
<img width='200' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/supporters.png" />
<td align="center" valign="middle">
<a href="https://github.com/sponsors/tannerlinsley/" target="_blank">
<img width='150' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver.png">
</a>
</td>
<td>
<div><a href="https://www.metso.com/">Pekka</a></div>
<div>Jon Eickmeier</div>
<td align="center" valign="middle">
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
Become a Sponsor!
</a>
</td>
</tr>
</tbody>
</table>
<table>
<tbody {...getTableBodyProps()}>
<tbody>
<tr>
<td valign="top">
<a href="https://patreon.com/tannerlinsley">
<img width='200' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/fans.png" />
<a href="https://github.com/sponsors/tannerlinsley/">
<img width='150' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/supporters.png" />
</a>
</td>
<td>
<div>Sortmy.games</div>
<div>Hugo Meissner</div>
<div>Benoit Leger-Derville</div>
<div>Thomas Funk</div>
<div>Dan Houle</div>
<div>David Pickut</div>
<div>Jordan Soltman</div>
<div>Robert Tajnšek</div>
<ul>
<li>Jon Eickmeier</li>
<li><a href="https://github.com/Shah-Sahab">Syed Hussain<a></li>
</ul>
</td>
<td>
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
Become a Supporter!
</a>
</td>
</tr>
</tbody>
</table>
<a href="https://patreon.com/tannerlinsley">
<img width="150" alt="" src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/become-a-patron.png" />
</a>
<table>
<tbody>
<tr>
<td valign="top">
<a href="https://github.com/sponsors/tannerlinsley/">
<img width='150' src="https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/fans.png" />
</a>
</td>
<td>
<ul>
<li>Sortmy.games</li>
<li>Hugo Meissner</li>
<li>Benoit Leger-Derville</li>
<li>Thomas Funk</li>
<li>Dan Houle</li>
<li>David Pickut</li>
<li>Jordan Soltman</li>
<li>Robert Tajnšek</li>
<li>Pekka Tapani</li>
</ul>
</td>
<td>
<a href="https://github.com/sponsors/tannerlinsley" target="_blank">
Become a Fan!
</a>
</td>
</tr>
</tbody>
</table>
### [Become a Sponsor](https://github.com/sponsors/tannerlinsley/)
+39
View File
@@ -0,0 +1,39 @@
# Using TypeScript with React-Table
React-table is a very flexible library, because of this, the shape of data at almost every contact point is defined by the specific set of plugins that you choose to pass to `useTable`.
To get started, copy the file `react-table-config.d.ts` into your source tree (e.g. into a types folder). This expands the default types with all of the plugin extensions currently in the type definitions.
You can stop here if you like, but while this is simple, it's a bit misleading. Out of the box, these types will suggest that you have access to values that come from plugins that you aren't using, i.e. the error checking is weakened.
To bring the resulting types into better alignment with your plugins, you should edit your local copy of `react-table-config.d.ts` and comment out all of the interfaces that don't apply to your chosen set of plugins.
e.g.
if you are only using `useSortBy` and `usePagination` then you would take this:
```tsx
extends UseExpandedOptions<D>,
UseFiltersOptions<D>,
UseGroupByOptions<D>,
UsePaginationOptions<D>,
UseRowSelectOptions<D>,
UseSortByOptions<D>,
UseFiltersOptions<D>,
UseResizeColumnsOptions<D>,
Record<string, any> {}
```
and convert it to this:
```tsx
export interface TableOptions<D extends object>
extends UsePaginationOptions<D>,
UseSortByOptions<D> {}
```
Then follow the same pattern for all of the other interfaces in the file. You'll notice that many plugins don't extend all of the top-level interfaces.
## Caveat
The interfaces are all global. If you have several different configurations for the table, you should create interfaces using the union of all of the plugins that you are using.
+25 -15
View File
@@ -58,7 +58,7 @@ To dive deeper into plugins, see Plugins](TODO) and the [Plugin Guide
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.disableSorting`**
> **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
@@ -68,7 +68,7 @@ React Table relies on memoization to determine when state and side effects shoul
- Required
`useTable` is the root hook for React Table. To use it, pass it with an options object with at least a `columns` and `rows` value, followed by any React Table compatible hooks you want to use.
`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
@@ -93,6 +93,7 @@ The following options are supported via the main options object passed to `useTa
- When either the internal `state` or this `state` object change, this object is **always merged over the internal table state** (eg. `{...state, ...overrides}`) to produce the final state object that is then passed to the `useTable` options.
- `reducer: Function(oldState, newState) => finalState`
- Optional
- Must be **memoized**
- Inspired by Kent C. Dodd's [State Reducer Pattern](https://kentcdodds.com/blog/the-state-reducer-pattern-with-react-hooks)
- With every `setState` call to the table's internal `React.useState` instance, this reducer is called and is allowed to modify the final state object for updating.
- It is passed the `oldState`, the `newState`, and when provided, an optional action `type`.
@@ -358,8 +359,12 @@ The following options are supported via the main options object passed to `useTa
- Identical to the `state.sortBy` option above
- `manualSorting: 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)
- `disableSorting: Bool`
- `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`
@@ -384,7 +389,11 @@ The following options are supported via the main options object passed to `useTa
The following options are supported on any `Column` object passed to the `columns` options in `useTable()`
- `disableSorting: Bool`
- `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
@@ -465,18 +474,15 @@ The following options are supported via the main options object passed to `useTa
- An object of 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.
- `initialState.filters`
- Identical to the `state.filters` option above
- `defaultFilter: String | Function`
- If a **function** is passed, it must be **memoized**
- Defaults to `text`
- The function (or resolved function from the string) will be used as the default/fallback filter method for every column that has filtering enabled.
- If a `string` is passed, the function with that name located on the `filterTypes` option object will be used.
- If a `function` is passed, it will be used.
- For more information on filter types, see Filtering
- `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.
@@ -494,6 +500,10 @@ The following options are supported on any `Column` object passed to the `column
- `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`
@@ -561,7 +571,7 @@ The following options are supported via the main options object passed to `useTa
- `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)
- `disableGrouping: Bool`
- `disableGroupBy: Bool`
- Disables groupBy for the entire table.
- `aggregations: Object<aggregationKey: aggregationFn>`
- Must be **memoized**
@@ -581,9 +591,9 @@ The following options are supported on any `Column` object passed to the `column
- 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`
- `disableGrouping: Boolean`
- Defaults to `true`
- If `true`, this column is able to be grouped.
- `disableGroupBy: Boolean`
- Defaults to `false`
- If `true`, will disable grouping for this column.
### Instance Properties
+3 -3
View File
@@ -2,7 +2,7 @@
## 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:
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.
@@ -10,7 +10,7 @@ React Table is a headless utility, which means out of the box, it doesn't render
## 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 it's state. This includes, but is not limited to:
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
@@ -23,7 +23,7 @@ At the heart of every React Table is the `useTable` hook and the table `instance
## 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 UI's 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)!
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)!
---
+6
View File
@@ -34,6 +34,12 @@
- 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)
- **Complex**
- The "Kitchen Sink"
- [Source](https://github.com/tannerlinsley/react-table/tree/master/examples/kitchen-sink)
+9 -10
View File
@@ -93,18 +93,17 @@ function Table({ columns, data }) {
<div className="rows" {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<div {...row.getRowProps()} className="row body">
{row.cells.map(cell => {
return (
<div {...cell.getCellProps()} className="cell">
{cell.render('Cell')}
</div>
)
})}
{row.cells.map((cell,index) => (
<div {...cell.getCellProps()} key={index} className="cell">
{cell.render('Cell')}
</div>
))}
</div>
)
)}
)}
</div>
</div>
+4 -3
View File
@@ -268,8 +268,9 @@ function Table({ columns, data }) {
<tbody {...getTableBodyProps()}>
<AnimatePresence>
{rows.slice(0, 10).map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<motion.tr
{...row.getRowProps({
layoutTransition: spring,
@@ -288,7 +289,7 @@ function Table({ columns, data }) {
)
})}
</motion.tr>
)
)}
)}
</AnimatePresence>
</tbody>
+4 -3
View File
@@ -60,14 +60,15 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -76,8 +76,9 @@ function Table({ columns, data }) {
<div {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<div {...row.getRowProps()} className="tr">
{row.cells.map(cell => {
return (
@@ -87,7 +88,7 @@ function Table({ columns, data }) {
)
})}
</div>
)
)}
)}
</div>
</div>
+4 -3
View File
@@ -81,8 +81,9 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{rows.slice(0, 10).map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map((cell, i) => {
return (
@@ -90,7 +91,7 @@ function Table({ columns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -103,8 +103,9 @@ function Table({ columns, data }) {
<div {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<div {...row.getRowProps()} className="tr">
{row.cells.map(cell => {
return (
@@ -114,7 +115,7 @@ function Table({ columns, data }) {
)
})}
</div>
)
)}
)}
</div>
</div>
@@ -0,0 +1,4 @@
{
"presets": ["react-app"],
"plugins": ["styled-components"]
}
@@ -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/data-driven-classes-and-styles)
- `yarn` and `yarn start` to run and edit the example
@@ -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": "next",
"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"
}
@@ -0,0 +1,202 @@
import React from 'react'
import styled from 'styled-components'
import { useTable, utils } from 'react-table'
import makeData from './makeData'
const Styles = styled.div`
padding: 1rem;
.user {
background-color: blue;
color: white;
}
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;
:last-child {
border-right: 0;
}
}
}
`
// Create a default prop getter
const defaultPropGetter = () => ({})
// Expose some prop getters for headers, rows and cells, or more if you want!
function Table({
columns,
data,
getHeaderProps = defaultPropGetter,
getColumnProps = defaultPropGetter,
getRowProps = defaultPropGetter,
getCellProps = defaultPropGetter,
}) {
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
} = useTable({
columns,
data,
})
return (
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th
// Merge all of the header Props
{...utils.mergeProps(
column.getHeaderProps(),
{
className: column.className,
style: column.style,
},
getColumnProps(column),
getHeaderProps(column)
)}
>
{column.render('Header')}
</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map((row, i) => {
prepareRow(row)
return (
// Merge row props
<tr {...utils.mergeProps(row.getRowProps(), getRowProps(row))}>
{row.cells.map(cell => {
return (
<td
// Merge cell props
{...utils.mergeProps(
cell.getCellProps(),
{
className: cell.column.className,
style: cell.column.style,
},
getColumnProps(cell.column),
getCellProps(cell)
)}
>
{cell.render('Cell')}
</td>
)
})}
</tr>
)
})}
</tbody>
</table>
)
}
function App() {
const columns = React.useMemo(
() => [
{
Header: 'Name',
columns: [
{
Header: 'First Name',
accessor: 'firstName',
className: 'user',
style: {
fontWeight: 'bolder',
},
},
],
},
{
Header: 'Scores',
columns: [
{
Header: 'Day 1',
accessor: 'score0',
},
{
Header: 'Day 2',
accessor: 'score1',
},
{
Header: 'Day 3',
accessor: 'score2',
},
{
Header: 'Day 4',
accessor: 'score3',
},
{
Header: 'Day 5',
accessor: 'score4',
},
{
Header: 'Day 6',
accessor: 'score5',
},
{
Header: 'Day 7',
accessor: 'score6',
},
],
},
],
[]
)
const data = React.useMemo(() => makeData(20), [])
return (
<Styles>
<Table
columns={columns}
data={data}
getHeaderProps={column => ({
onClick: () => alert('Header!'),
})}
getColumnProps={column => ({
onClick: () => alert('Column!'),
})}
getRowProps={row => ({
style: {
background: row.index % 2 === 0 ? 'rgba(0,0,0,.1)' : 'white',
},
})}
getCellProps={cellInfo => ({
style: {
backgroundColor: `hsl(${120 * ((120 - cellInfo.value) / 120) * -1 +
120}, 100%, 67%)`,
},
})}
/>
</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,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'
ReactDOM.render(<App />, document.getElementById('root'))
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister()
@@ -0,0 +1,36 @@
import namor from 'namor'
const range = len => {
const arr = []
for (let i = 0; i < len; i++) {
arr.push(i)
}
return arr
}
const newPerson = () => {
return {
firstName: namor.generate({ words: 1, numbers: 0 }),
score0: Math.floor(Math.random() * 100),
score1: Math.floor(Math.random() * 100),
score2: Math.floor(Math.random() * 100),
score3: Math.floor(Math.random() * 100),
score4: Math.floor(Math.random() * 100),
score5: Math.floor(Math.random() * 100),
score6: Math.floor(Math.random() * 100),
}
}
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()
}
@@ -0,0 +1,135 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
)
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config)
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
)
})
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config)
}
})
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing
if (installingWorker == null) {
return
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
)
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration)
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.')
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration)
}
}
}
}
}
})
.catch(error => {
console.error('Error during service worker registration:', error)
})
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type')
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload()
})
})
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config)
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
)
})
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister()
})
}
}
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -127,8 +127,9 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
</thead>
<tbody {...getTableBodyProps()}>
{page.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -136,7 +137,7 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -63,8 +63,9 @@ function Table({ columns: userColumns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -72,7 +73,7 @@ function Table({ columns: userColumns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -254,8 +254,9 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{firstPageRows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -263,7 +264,7 @@ function Table({ columns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -80,8 +80,9 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{firstPageRows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -120,7 +121,7 @@ function Table({ columns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -351,8 +351,9 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
</thead>
<tbody {...getTableBodyProps()}>
{page.map(
row =>
prepareRow(row) || (
row => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -378,7 +379,7 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -351,8 +351,9 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
</thead>
<tbody {...getTableBodyProps()}>
{page.map(
row =>
prepareRow(row) || (
row => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -378,7 +379,7 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -40,8 +40,9 @@ function Table({ columns, data }) {
</TableHead>
<TableBody>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<TableRow {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -51,7 +52,7 @@ function Table({ columns, data }) {
)
})}
</TableRow>
)
)}
)}
</TableBody>
</MaUTable>
+92 -77
View File
@@ -1,8 +1,8 @@
import React from 'react'
import styled from 'styled-components'
import { useTable, usePagination } from 'react-table'
import React from "react";
import styled from "styled-components";
import { useTable, usePagination } from "react-table";
import makeData from './makeData'
import makeData from "./makeData";
const Styles = styled.div`
padding: 1rem;
@@ -35,7 +35,7 @@ const Styles = styled.div`
.pagination {
padding: 0.5rem;
}
`
`;
// Let's add a fetchData method to our Table component that will be used to fetch
// new data when pagination state changes
@@ -45,7 +45,7 @@ function Table({
data,
fetchData,
loading,
pageCount: controlledPageCount,
pageCount: controlledPageCount
}) {
const {
getTableProps,
@@ -61,28 +61,30 @@ function Table({
nextPage,
previousPage,
setPageSize,
rows,
// Get the state from the instance
state: { pageIndex, pageSize },
state: { pageIndex, pageSize }
} = useTable(
{
columns,
data,
state: { pageIndex: 0 }, // Pass our hoisted table state
initialState: { pageIndex: 0 }, // Pass our hoisted table state
manualPagination: true, // Tell the usePagination
// hook that we'll handle our own data fetching
// This means we'll also have to provide our own
// pageCount.
pageCount: controlledPageCount,
pageCount: controlledPageCount
},
usePagination
)
);
// Now we can get our table state from the hoisted table state tuple
// Listen for changes in pagination and use the state to fetch our new data
React.useEffect(() => {
fetchData({ pageIndex, pageSize })
}, [fetchData, pageIndex, pageSize])
console.log(pageIndex);
fetchData({ pageIndex, pageSize });
}, [fetchData, pageIndex, pageSize]);
// Render the UI for your table
return (
@@ -95,7 +97,7 @@ function Table({
pageSize,
pageCount,
canNextPage,
canPreviousPage,
canPreviousPage
},
null,
2
@@ -107,30 +109,36 @@ function Table({
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>{column.render('Header')}</th>
<th {...column.getHeaderProps()}>{column.render("Header")}</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
)
<td {...cell.getCellProps()}>{cell.render("Cell")}</td>
);
})}
</tr>
)
)}
)}
{loading ? (
// Use our custom loading state to show a loading indicator
<tr>
<tr>
{loading ? (
// Use our custom loading state to show a loading indicator
<td>Loading...</td>
</tr>
) : null}
) : (
<td>
Showing {page.length} of ~{controlledPageCount * pageSize}{" "}
results
</td>
)}
</tr>
</tbody>
</table>
{/*
@@ -139,39 +147,39 @@ function Table({
*/}
<div className="pagination">
<button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{'<<'}
</button>{' '}
{"<<"}
</button>{" "}
<button onClick={() => previousPage()} disabled={!canPreviousPage}>
{'<'}
</button>{' '}
{"<"}
</button>{" "}
<button onClick={() => nextPage()} disabled={!canNextPage}>
{'>'}
</button>{' '}
{">"}
</button>{" "}
<button onClick={() => gotoPage(pageCount - 1)} disabled={!canNextPage}>
{'>>'}
</button>{' '}
{">>"}
</button>{" "}
<span>
Page{' '}
Page{" "}
<strong>
{pageIndex + 1} of {pageOptions.length}
</strong>{' '}
</strong>{" "}
</span>
<span>
| Go to page:{' '}
| Go to page:{" "}
<input
type="number"
defaultValue={pageIndex + 1}
onChange={e => {
const page = e.target.value ? Number(e.target.value) - 1 : 0
gotoPage(page)
const page = e.target.value ? Number(e.target.value) - 1 : 0;
gotoPage(page);
}}
style={{ width: '100px' }}
style={{ width: "100px" }}
/>
</span>{' '}
</span>{" "}
<select
value={pageSize}
onChange={e => {
setPageSize(Number(e.target.value))
setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map(pageSize => (
@@ -182,79 +190,86 @@ function Table({
</select>
</div>
</>
)
);
}
// Let's simulate a large dataset on the server (outside of our component)
const serverData = makeData(10000)
const serverData = makeData(10000);
function App() {
const columns = React.useMemo(
() => [
{
Header: 'Name',
Header: "Name",
columns: [
{
Header: 'First Name',
accessor: 'firstName',
Header: "First Name",
accessor: "firstName"
},
{
Header: 'Last Name',
accessor: 'lastName',
},
],
Header: "Last Name",
accessor: "lastName"
}
]
},
{
Header: 'Info',
Header: "Info",
columns: [
{
Header: 'Age',
accessor: 'age',
Header: "Age",
accessor: "age"
},
{
Header: 'Visits',
accessor: 'visits',
Header: "Visits",
accessor: "visits"
},
{
Header: 'Status',
accessor: 'status',
Header: "Status",
accessor: "status"
},
{
Header: 'Profile Progress',
accessor: 'progress',
},
],
},
Header: "Profile Progress",
accessor: "progress"
}
]
}
],
[]
)
);
// We'll start our table without any data
const [data, setData] = React.useState([])
const [loading, setLoading] = React.useState(false)
const [pageCount, setPageCount] = React.useState(0)
const [data, setData] = React.useState([]);
const [loading, setLoading] = React.useState(false);
const [pageCount, setPageCount] = React.useState(0);
const fetchIdRef = React.useRef(0);
const fetchData = React.useCallback(({ pageSize, pageIndex }) => {
// This will get called when the table needs new data
// You could fetch your data from literally anywhere,
// even a server. But for this example, we'll just fake it.
// Give this fetch an ID
const fetchID = ++fetchIdRef.current;
// Set the loading state
setLoading(true)
setLoading(true);
// We'll even set a delay to simulate a server here
setTimeout(() => {
const startRow = pageSize * pageIndex
const endRow = startRow + pageSize
setData(serverData.slice(startRow, endRow))
// Only update the data if this is the latest fetch
if (fetchID === fetchIdRef.current) {
const startRow = pageSize * pageIndex;
const endRow = startRow + pageSize;
setData(serverData.slice(startRow, endRow));
// Your server could send back total page count.
// For now we'll just fake it, too
setPageCount(Math.ceil(serverData.length / pageSize))
// Your server could send back total page count.
// For now we'll just fake it, too
setPageCount(Math.ceil(serverData.length / pageSize));
setLoading(false)
}, 1000)
}, [])
setLoading(false);
}
}, 1000);
}, []);
return (
<Styles>
@@ -266,7 +281,7 @@ function App() {
pageCount={pageCount}
/>
</Styles>
)
);
}
export default App
export default App;
+4 -3
View File
@@ -96,8 +96,9 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{page.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -105,7 +106,7 @@ function Table({ columns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+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/row-dhd)
- `yarn` and `yarn start` to run and edit the example
+38
View File
@@ -0,0 +1,38 @@
{
"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": "next",
"styled-components": "^4.3.2",
"react-dnd": "^9.4.0",
"react-dnd-html5-backend": "^9.4.0",
"immutability-helper": "^3.0.1"
},
"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

+38
View File
@@ -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>
+15
View File
@@ -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"
}
+222
View File
@@ -0,0 +1,222 @@
import React, { useState, useMemo, useRef, useCallback } from 'react'
import styled from 'styled-components'
import { useTable } from 'react-table'
import { DndProvider, useDrag, useDrop } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import update from 'immutability-helper'
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;
:last-child {
border-right: 0;
}
}
}
`
const Table = ({ columns, data }) => {
const [records, setRecords] = useState(data)
const getRowID = useCallback(row => {
return row.id
}, [])
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
} = useTable({
data: records,
columns,
getRowID,
})
const moveRow = (dragIndex, hoverIndex) => {
const dragRecord = records[dragIndex]
setRecords(
update(records, {
$splice: [[dragIndex, 1], [hoverIndex, 0, dragRecord]],
})
)
}
return (
<DndProvider backend={HTML5Backend}>
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
<th></th>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>{column.render('Header')}</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, index) =>
prepareRow(row) || (
<Row
index={index}
row={row}
moveRow={moveRow}
{...row.getRowProps()}
/>
)
)}
</tbody>
</table>
</DndProvider>
)
}
const DND_ITEM_TYPE = 'row'
const Row = ({ row, index, moveRow }) => {
const dropRef = useRef(null)
const dragRef = useRef(null)
const [, drop] = useDrop({
accept: DND_ITEM_TYPE,
hover(item, monitor) {
if (!dropRef.current) {
return
}
const dragIndex = item.index
const hoverIndex = index
// Don't replace items with themselves
if (dragIndex === hoverIndex) {
return
}
// Determine rectangle on screen
const hoverBoundingRect = dropRef.current.getBoundingClientRect()
// Get vertical middle
const hoverMiddleY =
(hoverBoundingRect.bottom - hoverBoundingRect.top) / 2
// Determine mouse position
const clientOffset = monitor.getClientOffset()
// Get pixels to the top
const hoverClientY = clientOffset.y - hoverBoundingRect.top
// Only perform the move when the mouse has crossed half of the items height
// When dragging downwards, only move when the cursor is below 50%
// When dragging upwards, only move when the cursor is above 50%
// Dragging downwards
if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
return
}
// Dragging upwards
if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
return
}
// Time to actually perform the action
moveRow(dragIndex, hoverIndex)
// Note: we're mutating the monitor item here!
// Generally it's better to avoid mutations,
// but it's good here for the sake of performance
// to avoid expensive index searches.
item.index = hoverIndex
},
})
const [{ isDragging }, drag, preview] = useDrag({
item: { type: DND_ITEM_TYPE, index },
collect: monitor => ({
isDragging: monitor.isDragging(),
}),
})
const opacity = isDragging ? 0 : 1
preview(drop(dropRef))
drag(dragRef)
return (
<tr ref={dropRef} style={{ opacity }}>
<td ref={dragRef}>move</td>
{row.cells.map(cell => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
})}
</tr>
)
}
const App = () => {
const columns = useMemo(
() => [
{
Header: 'ID',
accessor: 'id',
},
{
Header: 'Name',
columns: [
{
Header: 'First Name',
accessor: 'firstName',
},
{
Header: 'Last Name',
accessor: 'lastName',
},
],
},
{
Header: 'Info',
columns: [
{
Header: 'Age',
accessor: 'age',
},
{
Header: 'Visits',
accessor: 'visits',
},
{
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;
}
+12
View File
@@ -0,0 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'
ReactDOM.render(<App />, document.getElementById('root'))
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister()
+41
View File
@@ -0,0 +1,41 @@
import namor from 'namor'
const range = len => {
const arr = []
for (let i = 0; i < len; i++) {
arr.push(i)
}
return arr
}
const newPerson = id => {
const statusChance = Math.random()
return {
id,
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(i => {
return {
...newPerson(i),
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
}
})
}
return makeDataLevel()
}
+135
View File
@@ -0,0 +1,135 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
)
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config)
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
)
})
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config)
}
})
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing
if (installingWorker == null) {
return
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
)
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration)
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.')
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration)
}
}
}
}
}
})
.catch(error => {
console.error('Error during service worker registration:', error)
})
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type')
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload()
})
})
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config)
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
)
})
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister()
})
}
}
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -66,8 +66,9 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -75,7 +76,7 @@ function Table({ columns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -45,14 +45,15 @@ function MyTable() {
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
})}
</tr>
)
)}
)}
</tbody>
</table>
+4 -3
View File
@@ -78,8 +78,9 @@ function Table({ columns, data }) {
</thead>
<tbody {...getTableBodyProps()}>
{firstPageRows.map(
(row, i) =>
prepareRow(row) || (
(row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
@@ -87,7 +88,7 @@ function Table({ columns, data }) {
)
})}
</tr>
)
)}
)}
</tbody>
</table>
+26 -26
View File
@@ -70,39 +70,39 @@ function Table({ columns: userColumns, data, renderRowSubComponent }) {
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
// Use a React.Fragment here so the table markup is still valid
<>
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
)
})}
</tr>
{/*
{rows.map((row, i) => {
prepareRow(row)
return (
// Use a React.Fragment here so the table markup is still valid
<>
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
)
})}
</tr>
{/*
If the row is in an expanded state, render a row with a
column that spands the entire length of the table.
column that fills the entire length of the table.
*/}
{row.isExpanded ? (
<tr>
<td colSpan={flatColumns.length}>
{/*
{row.isExpanded ? (
<tr>
<td colSpan={flatColumns.length}>
{/*
Inside it, call our renderRowSubComponent function. In reality,
you coul pass whatever you want as props to
you could pass whatever you want as props to
a component like this, including the entire
table instance. But for this example, we'll just
pass the row
*/}
{renderRowSubComponent({ row })}
</td>
</tr>
) : null}
</>
)
)}
{renderRowSubComponent({ row })}
</td>
</tr>
) : null}
</>
)
})}
</tbody>
</table>
<br />
Vendored
+622 -266
View File
@@ -1,281 +1,637 @@
declare module 'react-table' {
import { ReactNode, useState } from 'react'
// TypeScript Version: 3.5
type StringKey<D> = Extract<keyof D, string>
type IdType<D> = StringKey<D> | string
import { ReactNode, ComponentType, MouseEvent } from 'react'
type SortingRule<D> = {
id: IdType<D>
desc: boolean
}
/**
* The empty definitions of below provides a base definition for the parts used by useTable, that can then be extended in the users code.
*
* @example
* export interface TableOptions<D extends object = {}}>
* extends
* UseExpandedOptions<D>,
* UseFiltersOptions<D> {}
*/
export interface TableOptions<D extends object> extends UseTableOptions<D> {}
export type SortingRules<D> = SortingRule<D>[]
export interface TableInstance<D extends object = {}>
extends Omit<TableOptions<D>, 'columns' | 'state'>,
UseTableInstanceProps<D> {}
export type SortByFn = (a: any, b: any, desc: boolean) => 0 | 1 | -1
export interface TableState<
D extends object = {}
> {} /* tslint:disable-line no-empty-interface */ // eslint-disable-line @typescript-eslint/no-empty-interface
export type Filters<D> = Record<IdType<D>, string>
export interface Hooks<D extends object = {}> extends UseTableHooks<D> {}
export interface Cell<D = {}> extends TableInstance<D> {
cell: { value: any }
column: Column<D>
row: Row<D>
render: (type: 'Cell' | 'Aggregated', userProps?: any) => any
isGrouped?: boolean
isAggregated?: boolean
isRepeatedValue?: boolean
getCellProps: () => any
}
export interface Cell<D extends object = {}> extends UseTableCellProps<D> {}
export interface Row<D = {}> {
index: number
cells: Cell<D>[]
getRowProps: (userProps?: any) => any
original: D
path: any[]
values: any[]
depth: number
}
export interface Column<D extends object = {}>
extends UseTableColumnOptions<D> {}
export interface UseExpandedRow<D = {}> {
subRows?: D[]
groupByID?: string | number
toggleExpanded?: () => any
isExpanded?: boolean
isAggregated?: boolean
}
export interface ColumnInstance<D extends object = {}>
extends Omit<Column<D>, 'id'>,
UseTableColumnProps<D> {}
export type AccessorFn<D> = (
originalRow: D,
index: number,
sub: {
subRows: [D]
depth: number
data: [D]
}
) => unknown
export interface HeaderGroup<D extends object = {}>
extends ColumnInstance<D>,
UseTableHeaderGroupProps<D> {}
export interface HeaderColumn<D> {
/**
* This string/function is used to build the data model for your column.
*/
accessor: IdType<D> | AccessorFn<D>
Header?: ReactNode | ((props: TableInstance<D>) => ReactNode)
Filter?: ReactNode | ((props: TableInstance<D>) => ReactNode)
Cell?: ReactNode | ((cell: Cell<D>) => ReactNode)
/**
* This is the unique ID for the column. It is used by reference in things like sorting, grouping, filtering etc.
*/
id?: IdType<D>
minWidth?: string | number
maxWidth?: string | number
width?: string | number
disableSorting?: boolean
canSortBy?: boolean
sortByFn?: SortByFn
defaultSortDesc?: boolean
isAggregated?: any
}
export interface Row<D extends object = {}> extends UseTableRowProps<D> {}
export interface Column<D> extends HeaderColumn<D> {
show?: boolean | ((instance: TableInstance<D>) => boolean)
columns?: Column<D>[]
}
/* #region useTable */
export function useTable<D extends object = {}>(
options: TableOptions<D>,
...plugins: Array<PluginHook<D>>
): TableInstance<D>
export type Page<D = {}> = Row<D>[]
/**
* NOTE: To use custom options, use "Interface Merging" to add the custom options
*/
export type UseTableOptions<D extends object> = {
columns: Array<Column<D>>
data: D[]
} & Partial<{
initialState: Partial<TableState<D>>
state: Partial<TableState<D>>
reducer: (
oldState: TableState<D>,
newState: TableState<D>,
type: string
) => TableState<D>
defaultColumn: Partial<Column<D>>
initialRowStateKey: IdType<D>
getSubRows: (row: Row<D>, relativeIndex: number) => Array<Row<D>>
getRowID: (row: Row<D>, relativeIndex: number) => string
debug: boolean
}>
export interface EnhancedColumn<D>
extends Omit<Column<D>, 'columns'>,
TableInstance<D> {
id: IdType<D>
column: Column<D>
render: (type: 'Header' | 'Filter', userProps?: any) => any
getHeaderProps: (userProps?: any) => any
getSortByToggleProps: (userProps?: any) => any
isSorted: boolean
isSortedDesc: boolean
sortedIndex: number
isVisible: boolean
canSort?: boolean
}
export interface UseTableHooks<D extends object> {
columnsBeforeHeaderGroups: Array<
(
flatColumns: Array<Column<D>>,
instance: TableInstance<D>
) => Array<Column<D>>
>
columnsBeforeHeaderGroupsDeps: Array<
(deps: any[], instance: TableInstance<D>) => any[]
>
useMain: Array<(instance: TableInstance<D>) => TableInstance<D>>
useRows: Array<
(rows: Array<Row<D>>, instance: TableInstance<D>) => Array<Row<D>>
>
prepareRow: Array<(row: Row<D>, instance: TableInstance<D>) => Row<D>>
export interface HeaderGroup<D = {}> {
headers: EnhancedColumn<D>[]
getHeaderGroupProps: (userProps?: any) => any
}
export interface Hooks {
columnsBeforeHeaderGroups: any[]
columnsBeforeHeaderGroupsDeps: any[]
useMain: any[]
useColumns: any[]
useHeaders: any[]
useHeaderGroups: any[]
useRows: any[]
prepareRow: any[]
getTableProps: any[]
getRowProps: any[]
getHeaderGroupProps: any[]
getHeaderProps: any[]
getCellProps: any[]
}
export interface RowsProps {
subRowsKey: string
}
export interface FiltersProps {
filterFn: () => void
manualFilters: boolean
disableFilters: boolean
setFilter: () => any
setAllFilters: () => any
}
export interface UsePaginationState {
pageIndex: number
pageSize: number
pageCount: number
rowCount: number
}
export interface UsePaginationValues<D = {}> {
page: Page<D>
pageIndex: number // yes, this is on instance and state
pageSize: number // yes, this is on instance and state
canPreviousPage: boolean
canNextPage: boolean
nextPage: () => any
previousPage: () => any
setPageSize: (size: number) => any
pageOptions: any[]
manualPagination: boolean
paginateExpandedRows: boolean
disablePageResetOnDataChange: boolean
pageCount: number
gotoPage: (page: number) => any
}
export interface UseFiltersState<D> {
filters?: Filters<D>
}
export interface UseFiltersValues<D> {
setFilter: (columnID: keyof D, value: string) => void
setAllFilters: (values: Filters<D>) => void
disableFilters: boolean
}
export interface UseGroupByValues {
groupByFn: any
manualGroupBy: boolean
disableGrouping: boolean
aggregations: any
}
export interface UseGroupByState {
groupBy: string[]
isAggregated?: boolean
}
export interface UseExpandedValues {
toggleExpanded?: () => any
}
export interface UseSortbyOptions {
sortByFn?: SortByFn
manualSorting?: boolean
disableSorting?: boolean
defaultSortDesc?: boolean
disableMultiSort?: boolean
}
export interface UseSortbyState<D> {
sortBy?: SortingRules<D>
}
export interface TableInstance<D = {}> extends TableOptions<D> {
hooks: Hooks
rows: Row<D>[]
columns: EnhancedColumn<D>[]
headerGroups: HeaderGroup<D>[]
headers: HeaderGroup<D>[]
getTableProps: (userProps?: any) => any
getRowProps: (userProps?: any) => any
prepareRow: (row: Row<D>) => any
state: TableState<D>
setState: SetState<D>
}
export interface TableOptions<D = {}> {
data: D[]
columns: HeaderColumn<D>[]
debug?: boolean
loading: boolean
defaultColumn?: Partial<Column<D>>
initialState?: Partial<TableState<D>>
state?: Partial<TableState<D>>
reducer?: (
oldState: TableState<D>,
newState: TableState<D>,
type: string
) => any
}
// The empty definition of TableState is not an error. It provides a definition
// for the state, that can then be extended in the users code.
//
// e.g.
//
// export interface TableState<D = {}}>
// extends UsePaginationState,
// UseGroupByState,
// UseSortbyState<D>,
// UseFiltersState<D> {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface TableState<D = {}> {}
export type SetState<D> = (
updater: (old: TableState<D>) => TableState<D>,
actions: any
) => void
export function useTable<D = {}>(
props: TableOptions<D>,
...plugins: any[]
): TableInstance<D>
export function useFilters<D = {}>(
props: TableOptions<D>
): TableOptions<D> & {
rows: Row<D>[]
}
export function useSortBy<D = {}>(
props: TableOptions<D>
): TableOptions<D> & {
rows: Row<D>[]
}
export function useGroupBy<D = {}>(
props: TableOptions<D>
): TableOptions<D> & { rows: Row<D>[] }
export function usePagination<D = {}>(
props: TableOptions<D>
): UsePaginationValues<D>
export function useExpanded<D = {}>(
props: TableOptions<D>
): TableOptions<D> & {
toggleExpandedByPath: () => any
expandedDepth: []
rows: Row<D>[]
}
export const actions: Record<string, string>
export function addActions(...actions: string[]): void
export const defaultState: Record<string, any>
// Prop Hooks
getTableProps: Array<(instance: TableInstance<D>) => object>
getTableBodyProps: Array<(instance: TableInstance<D>) => object>
getRowProps: Array<(row: Row<D>, instance: TableInstance<D>) => object>
getHeaderGroupProps: Array<
(headerGroup: HeaderGroup<D>, instance: TableInstance<D>) => object
>
getHeaderProps: Array<
(column: Column<D>, instance: TableInstance<D>) => object
>
getCellProps: Array<(cell: Cell<D>, instance: TableInstance<D>) => object>
}
export interface UseTableColumnOptions<D extends object>
extends Accessor<D>,
Partial<{
columns: Array<Column<D>>
show: boolean | ((instance: TableInstance<D>) => boolean)
Header: Renderer<HeaderProps<D>>
Cell: Renderer<CellProps<D>>
width?: number
minWidth?: number
maxWidth?: number
}> {}
export interface UseTableInstanceProps<D extends object> {
columns: Array<ColumnInstance<D>>
flatColumns: Array<ColumnInstance<D>>
headerGroups: Array<HeaderGroup<D>>
headers: Array<ColumnInstance<D>>
flatHeaders: Array<ColumnInstance<D>>
rows: Array<Row<D>>
getTableProps: (props?: object) => object
getTableBodyProps: (props?: object) => object
prepareRow: (row: Row<D>) => void
rowPaths: string[]
flatRows: Array<Row<D>>
state: TableState<D>
setState: SetState<D>
totalColumnsWidth: number
}
export interface UseTableHeaderGroupProps<D extends object> {
headers: Array<ColumnInstance<D>>
getHeaderGroupProps: (props?: object) => object
totalHeaderCount: number
}
export interface UseTableColumnProps<D extends object> {
id: IdType<D>
isVisible: boolean
render: (type: 'Header' | string, props?: object) => ReactNode
getHeaderProps: (props?: object) => object
parent: ColumnInstance<D>
depth: number
index: number
}
export interface UseTableRowProps<D extends object> {
cells: Array<Cell<D>>
values: Record<IdType<D>, CellValue>
getRowProps: (props?: object) => object
index: number
original: D
path: Array<IdType<D>>
subRows: Array<Row<D>>
}
export interface UseTableCellProps<D extends object> {
column: ColumnInstance<D>
row: Row<D>
value: CellValue
getCellProps: (props?: object) => object
render: (type: 'Cell' | string, userProps?: object) => ReactNode
}
export type HeaderProps<D extends object> = TableInstance<D> & {
column: ColumnInstance<D>
}
export type CellProps<D extends object> = TableInstance<D> & {
column: ColumnInstance<D>
row: Row<D>
cell: Cell<D>
}
// NOTE: At least one of (id | accessor | Header as string) required
export interface Accessor<D extends object> {
accessor?:
| IdType<D>
| ((
originalRow: D,
index: number,
sub: {
subRows: D[]
depth: number
data: D[]
}
) => CellValue)
id?: IdType<D>
}
/* #endregion */
// Plugins
/* #region useColumnOrder */
export function useColumnOrder<D extends object = {}>(hooks: Hooks<D>): void
export namespace useColumnOrder {
const pluginName = 'useColumnOrder'
}
export interface UseColumnOrderState<D extends object> {
columnOrder: Array<IdType<D>>
}
export interface UseColumnOrderInstanceProps<D extends object> {
setColumnOrder: (
updater: (columnOrder: Array<IdType<D>>) => Array<IdType<D>>
) => void
}
/* #endregion */
/* #region useExpanded */
export function useExpanded<D extends object = {}>(hooks: Hooks<D>): void
export namespace useExpanded {
const pluginName = 'useExpanded'
}
export type UseExpandedOptions<D extends object> = Partial<{
getSubRows: (row: Row<D>, relativeIndex: number) => Array<Row<D>>
manualExpandedKey: IdType<D>
paginateExpandedRows: boolean
}>
export interface UseExpandedHooks<D extends object> {
getExpandedToggleProps: Array<
(row: Row<D>, instance: TableInstance<D>) => object
>
}
export interface UseExpandedState<D extends object> {
expanded: Array<IdType<D>>
}
export interface UseExpandedInstanceProps<D extends object> {
rows: Array<Row<D>>
toggleExpandedByPath: (path: Array<IdType<D>>, isExpanded: boolean) => void
expandedDepth: number
}
export interface UseExpandedRowProps<D extends object> {
isExpanded: boolean
canExpand: boolean
subRows: Array<Row<D>>
toggleExpanded: (isExpanded?: boolean) => void
getExpandedToggleProps: (props?: object) => object
}
/* #endregion */
/* #region useFilters */
export function useFilters<D extends object = {}>(hooks: Hooks<D>): void
export namespace useFilters {
const pluginName = 'useFilters'
}
export type UseFiltersOptions<D extends object> = Partial<{
manualFilters: boolean
disableFilters: boolean
filterTypes: Filters<D>
}>
export interface UseFiltersState<D extends object> {
filters: Filters<D>
}
export type UseFiltersColumnOptions<D extends object> = Partial<{
disableFilters: boolean
Filter: Renderer<FilterProps<D>>
filter: FilterType<D> | DefaultFilterTypes | keyof Filters<D>
}>
export interface UseFiltersInstanceProps<D extends object> {
rows: Array<Row<D>>
preFilteredRows: Array<Row<D>>
setFilter: (
columnId: IdType<D>,
updater: ((filterValue: FilterValue) => FilterValue) | FilterValue
) => void
setAllFilters: (
updater: Filters<D> | ((filters: Filters<D>) => Filters<D>)
) => void
}
export interface UseFiltersColumnProps<D extends object> {
canFilter: boolean
setFilter: (
updater: ((filterValue: FilterValue) => FilterValue) | FilterValue
) => void
filterValue: FilterValue
preFilteredRows: Array<Row<D>>
filteredRows: Array<Row<D>>
}
export type FilterProps<D extends object> = HeaderProps<D>
export type FilterValue = any
export type Filters<D extends object> = Record<IdType<D>, FilterValue>
export type DefaultFilterTypes =
| 'text'
| 'exactText'
| 'exactTextCase'
| 'includes'
| 'includesAll'
| 'exact'
| 'equals'
| 'between'
export interface FilterType<D extends object> {
(
rows: Array<Row<D>>,
columnId: IdType<D>,
filterValue: FilterValue,
column: ColumnInstance<D>
): Array<Row<D>>
autoRemove?: (filterValue: FilterValue) => boolean
}
/* #endregion */
/* #region useGroupBy */
export function useGroupBy<D extends object = {}>(hooks: Hooks<D>): void
export namespace useGroupBy {
const pluginName = 'useGroupBy'
}
export type UseGroupByOptions<D extends object> = Partial<{
manualGroupBy: boolean
disableGroupBy: boolean
aggregations: Record<string, AggregatorFn<D>>
groupByFn: (
rows: Array<Row<D>>,
columnId: IdType<D>
) => Record<string, Row<D>>
}>
export interface UseGroupByHooks<D extends object> {
getGroupByToggleProps: Array<
(header: HeaderGroup<D>, instance: TableInstance<D>) => object
>
}
export interface UseGroupByState<D extends object> {
groupBy: Array<IdType<D>>
}
export type UseGroupByColumnOptions<D extends object> = Partial<{
aggregate: Aggregator<D> | Array<Aggregator<D>>
Aggregated: Renderer<CellProps<D>>
disableGroupBy: boolean
groupByBoundary: boolean
}>
export interface UseGroupByInstanceProps<D extends object> {
rows: Array<Row<D>>
preGroupedRows: Array<Row<D>>
toggleGroupBy: (columnId: IdType<D>, toggle: boolean) => void
}
export interface UseGroupByColumnProps<D extends object> {
canGroupBy: boolean
isGrouped: boolean
groupedIndex: number
toggleGroupBy: () => void
}
export interface UseGroupByHeaderProps<D extends object> {
getGroupByToggleProps: (props?: object) => object
}
export interface UseGroupByRowProps<D extends object> {
isAggregated: boolean
groupByID: IdType<D>
groupByVal: string
values: Record<IdType<D>, AggregatedValue>
subRows: Array<Row<D>>
depth: number
path: Array<IdType<D>>
index: number
}
export interface UseGroupByCellProps<D extends object> {
isGrouped: boolean
isRepeatedValue: boolean
isAggregated: boolean
}
export type DefaultAggregators =
| 'sum'
| 'average'
| 'median'
| 'uniqueCount'
| 'count'
export type AggregatorFn<D extends object> = (
columnValues: CellValue[],
rows: Array<Row<D>>
) => AggregatedValue
export type Aggregator<D extends object> =
| AggregatorFn<D>
| DefaultAggregators
| string
export type AggregatedValue = any
/* #endregion */
/* #region usePagination */
export function usePagination<D extends object = {}>(hooks: Hooks<D>): void
export namespace usePagination {
const pluginName = 'usePagination'
}
export type UsePaginationOptions<D extends object> = Partial<{
pageCount: number
manualPagination: boolean
disablePageResetOnDataChange: boolean
paginateExpandedRows: boolean
}>
export interface UsePaginationState<D extends object> {
pageSize: number
pageIndex: number
}
export interface UsePaginationInstanceProps<D extends object> {
page: Array<Row<D>>
pageCount: number
pageOptions: number[]
canPreviousPage: boolean
canNextPage: boolean
gotoPage: (updater: ((pageIndex: number) => number) | number) => void
previousPage: () => void
nextPage: () => void
setPageSize: (pageSize: number) => void
pageIndex: number
pageSize: number
}
/* #endregion */
/* #region useRowSelect */
export function useRowSelect<D extends object = {}>(hooks: Hooks<D>): void
export namespace useRowSelect {
const pluginName = 'useRowSelect'
}
export type UseRowSelectOptions<D extends object> = Partial<{
manualRowSelectedKey: IdType<D>
}>
export interface UseRowSelectHooks<D extends object> {
getToggleRowSelectedProps: Array<
(row: Row<D>, instance: TableInstance<D>) => object
>
getToggleAllRowsSelectedProps: Array<(instance: TableInstance<D>) => object>
}
export interface UseRowSelectState<D extends object> {
selectedRowPaths: Array<IdType<D>>
}
export interface UseRowSelectInstanceProps<D extends object> {
toggleRowSelected: (rowPath: IdType<D>, set?: boolean) => void
toggleRowSelectedAll: (set?: boolean) => void
getToggleAllRowsSelectedProps: (props?: object) => object
isAllRowsSelected: boolean
selectedFlatRows: Array<Row<D>>
}
export interface UseRowSelectRowProps<D extends object> {
isSelected: boolean
toggleRowSelected: (set?: boolean) => void
getToggleRowSelectedProps: (props?: object) => object
}
/* #endregion */
/* #region useRowState */
export function useRowState<D extends object = {}>(hooks: Hooks<D>): void
export namespace useRowState {
const pluginName = 'useRowState'
}
export type UseRowStateOptions<D extends object> = Partial<{
initialRowStateAccessor: (row: Row<D>) => UseRowStateLocalState<D>
}>
export interface UseRowStateState<D extends object> {
rowState: Partial<{
cellState: UseRowStateLocalState<D>
rowState: UseRowStateLocalState<D>
}>
}
export interface UseRowStateInstanceProps<D extends object> {
setRowState: (rowPath: string[], updater: UseRowUpdater) => void // Purposely not exposing action
setCellState: (
rowPath: string[],
columnID: IdType<D>,
updater: UseRowUpdater
) => void
}
export interface UseRowStateRowProps<D extends object> {
state: UseRowStateLocalState<D>
setState: (updater: UseRowUpdater) => void
}
export interface UseRowStateCellProps<D extends object> {
state: UseRowStateLocalState<D>
setState: (updater: UseRowUpdater) => void
}
export type UseRowUpdater<T = unknown> = T | ((prev: T) => T)
export type UseRowStateLocalState<D extends object, T = unknown> = Record<
IdType<D>,
T
>
/* #endregion */
/* #region useSortBy */
export function useSortBy<D extends object = {}>(hooks: Hooks<D>): void
export namespace useSortBy {
const pluginName = 'useSortBy'
}
export type UseSortByOptions<D extends object> = Partial<{
manualSorting: boolean
disableSortBy: boolean
disableMultiSort: boolean
isMultiSortEvent: (e: MouseEvent) => boolean
maxMultiSortColCount: number
disableSortRemove: boolean
disabledMultiRemove: boolean
orderByFn: (
rows: Array<Row<D>>,
sortFns: Array<SortByFn<D>>,
directions: boolean[]
) => Array<Row<D>>
sortTypes: Record<string, SortByFn<D>>
}>
export interface UseSortByHooks<D extends object> {
getSortByToggleProps: Array<
(column: Column<D>, instance: TableInstance<D>) => object
>
}
export interface UseSortByState<D extends object> {
sortBy: Array<SortingRule<D>>
}
export type UseSortByColumnOptions<D extends object> = Partial<{
disableSortBy: boolean
sortDescFirst: boolean
sortInverted: boolean
sortType: SortByFn<D> | DefaultSortTypes | string
}>
export interface UseSortByInstanceProps<D extends object> {
rows: Array<Row<D>>
preSortedRows: Array<Row<D>>
toggleSortBy: (
columnId: IdType<D>,
descending: boolean,
isMulti: boolean
) => void
}
export interface UseSortByColumnProps<D extends object> {
canSort: boolean
toggleSortBy: (descending: boolean, multi: boolean) => void
getSortByToggleProps: (props?: object) => object
clearSorting: () => void
isSorted: boolean
sortedIndex: number
isSortedDesc: boolean | undefined
}
export type SortByFn<D extends object> = (
rowA: Row<D>,
rowB: Row<D>,
columnId: IdType<D>
) => 0 | 1 | -1
export type DefaultSortTypes = 'alphanumeric' | 'datetime' | 'basic'
export interface SortingRule<D> {
id: IdType<D>
desc?: boolean
}
/* #endregion */
/* #region useAbsoluteLayout */
export function useAbsoluteLayout<D extends object = {}>(hooks: Hooks<D>): void
export namespace useAbsoluteLayout {
const pluginName = 'useAbsoluteLayout'
}
/* #endregion */
/* #region useBlockLayout */
export function useBlockLayout<D extends object = {}>(hooks: Hooks<D>): void
export namespace useBlockLayout {
const pluginName = 'useBlockLayout'
}
/* #endregion */
/* #region useResizeColumns */
export function useResizeColumns<D extends object = {}>(hooks: Hooks<D>): void
export namespace useResizeColumns {
const pluginName = 'useResizeColumns'
}
export interface UseResizeColumnsOptions<D extends object> {
disableResizing?: boolean
}
export interface UseResizeColumnsColumnOptions<D extends object> {
disableResizing?: boolean
}
export interface UseResizeColumnsHeaderProps<D extends object> {
getResizerProps: (props?: object) => object
canResize: boolean
isResizing: boolean
}
/* #endregion */
// Additional API
export const actions: Record<string, string>
export function addActions(...actions: string[]): void
export const defaultState: Record<string, any>
// Helpers
export type StringKey<D> = Extract<keyof D, string>
export type IdType<D> = StringKey<D> | string
export type CellValue = any
export type Renderer<Props> = ComponentType<Props> | ReactNode
export interface PluginHook<D extends object> {
(hooks: Hooks<D>): void
pluginName: string
}
export type SetState<D extends object> = (
updater: (old: TableState<D>) => TableState<D>,
type: keyof typeof actions
) => void
-11527
View File
File diff suppressed because it is too large Load Diff
+7 -4
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "7.0.0-beta.10",
"version": "7.0.0-beta.13",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
@@ -20,9 +20,11 @@
"sideEffects": false,
"scripts": {
"commit": "git add . && git-cz",
"test": "is-ci 'test:ci' 'test:dev'",
"test": "is-ci \"test:ci\" \"test:dev\"",
"test:dev": "jest --watch",
"test:ci": "jest",
"test:ci": "yarn test:jest && yarn test:types",
"test:jest": "jest",
"test:types": "dtslint",
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "yarn build",
@@ -60,6 +62,7 @@
"commitizen": "^4.0.3",
"core-js": "3.2.1",
"cross-env": "^5.2.0",
"dtslint": "^0.9.8",
"eslint": "5.x",
"eslint-config-prettier": "^4.3.0",
"eslint-config-react-app": "^4.0.1",
@@ -75,7 +78,7 @@
"eslint-plugin-react-hooks": "1.7.0",
"eslint-plugin-standard": "^4.0.0",
"husky": "^3.0.3",
"is-ci-cli": "^1.1.1",
"is-ci-cli": "^2.0.0",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"jest-runner-eslint": "^0.7.4",
+99
View File
@@ -0,0 +1,99 @@
import {
UseColumnOrderInstanceProps,
UseColumnOrderState,
UseExpandedInstanceProps,
UseExpandedOptions,
UseExpandedRowProps,
UseExpandedState,
UseFiltersColumnOptions,
UseFiltersColumnProps,
UseFiltersInstanceProps,
UseFiltersOptions,
UseFiltersState,
UseGroupByCellProps,
UseGroupByColumnOptions,
UseGroupByColumnProps,
UseGroupByInstanceProps,
UseGroupByOptions,
UseGroupByRowProps,
UseGroupByState,
UsePaginationInstanceProps,
UsePaginationOptions,
UsePaginationState,
UseResizeColumnsColumnOptions,
UseResizeColumnsHeaderProps,
UseResizeColumnsOptions,
UseRowSelectInstanceProps,
UseRowSelectOptions,
UseRowSelectRowProps,
UseRowSelectState,
UseRowStateCellProps,
UseRowStateInstanceProps,
UseRowStateRowProps,
UseSortByColumnOptions,
UseSortByColumnProps,
UseSortByInstanceProps,
UseSortByOptions,
UseSortByState,
UseTableCellProps,
} from 'react-table'
declare module 'react-table' {
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
export interface TableOptions<D extends object>
extends UseExpandedOptions<D>,
UseFiltersOptions<D>,
UseGroupByOptions<D>,
UsePaginationOptions<D>,
UseRowSelectOptions<D>,
UseSortByOptions<D>,
UseFiltersOptions<D>,
UseResizeColumnsOptions<D>,
// note that having Record here allows you to add anything to the options, this matches the spirit of the
// underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
// feature set, this is a safe default.
Record<string, any> {}
export interface TableInstance<D extends object = {}>
extends UseColumnOrderInstanceProps<D>,
UseExpandedInstanceProps<D>,
UseFiltersInstanceProps<D>,
UseGroupByInstanceProps<D>,
UsePaginationInstanceProps<D>,
UseRowSelectInstanceProps<D>,
UseRowStateInstanceProps<D>,
UseSortByInstanceProps<D> {}
export interface TableState<D extends object = {}>
extends UseColumnOrderState<D>,
UseExpandedState<D>,
UseFiltersState<D>,
UseGroupByState<D>,
UsePaginationState<D>,
UseRowSelectState<D>,
UseSortByState<D> {}
export interface Column<D extends object = {}>
extends UseFiltersColumnOptions<D>,
UseGroupByColumnOptions<D>,
UseSortByColumnOptions<D>,
UseResizeColumnsColumnOptions<D> {}
export interface ColumnInstance<D extends object = {}>
extends UseFiltersColumnProps<D>,
UseGroupByColumnProps<D>,
UseSortByColumnProps<D>,
UseResizeColumnsHeaderProps<D> {}
export interface Cell<D extends object = {}>
extends UseTableCellProps<D>,
UseGroupByCellProps<D>,
UseRowStateCellProps<D> {}
export interface Row<D extends object = {}>
extends UseExpandedRowProps<D>,
UseGroupByRowProps<D>,
UseRowSelectRowProps<D>,
UseRowStateRowProps<D> {}
}
+3 -7
View File
@@ -7,13 +7,9 @@ export function average(values, rows) {
}
export function median(values) {
let min = values[0] || ''
let max = values[0] || ''
values.forEach(value => {
min = Math.min(min, value)
max = Math.max(max, value)
})
values = values.length ? values : [0]
let min = Math.min(...values)
let max = Math.max(...values)
return (min + max) / 2
}
@@ -2,169 +2,111 @@
exports[`renders a basic table 1`] = `
<DocumentFragment>
<table
class=""
>
<table>
<thead>
<tr
class=""
>
<tr>
<th
class=""
colspan="2"
>
Name
</th>
<th
class=""
colspan="4"
>
Info
</th>
</tr>
<tr
class=""
>
<tr>
<th
class=""
colspan="1"
>
First Name
</th>
<th
class=""
colspan="1"
>
Last Name
</th>
<th
class=""
colspan="1"
>
Age
</th>
<th
class=""
colspan="1"
>
Visits
</th>
<th
class=""
colspan="1"
>
Status
</th>
<th
class=""
colspan="1"
>
Profile Progress
</th>
</tr>
</thead>
<tbody
class=""
>
<tr
class=""
>
<td
class=""
>
<tbody>
<tr>
<td>
tanner
</td>
<td
class=""
>
<td>
linsley
</td>
<td
class=""
>
<td>
29
</td>
<td
class=""
>
<td>
100
</td>
<td
class=""
>
<td>
In Relationship
</td>
<td
class=""
>
<td>
50
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
derek
</td>
<td
class=""
>
<td>
perkins
</td>
<td
class=""
>
<td>
40
</td>
<td
class=""
>
<td>
40
</td>
<td
class=""
>
<td>
Single
</td>
<td
class=""
>
<td>
80
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
joe
</td>
<td
class=""
>
<td>
bergevin
</td>
<td
class=""
>
<td>
45
</td>
<td
class=""
>
<td>
20
</td>
<td
class=""
>
<td>
Complicated
</td>
<td
class=""
>
<td>
10
</td>
</tr>
+6 -18
View File
@@ -1,5 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
//
import {
applyHooks,
@@ -12,16 +12,6 @@ import {
determineHeaderVisibility,
} from '../utils'
const propTypes = {
// General
data: PropTypes.array.isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
defaultColumn: PropTypes.object,
getSubRows: PropTypes.func,
getRowID: PropTypes.func,
debug: PropTypes.bool,
}
const renderErr =
'You must specify a valid render component. This could be "column.Cell", "column.Header", "column.Filter", "column.Aggregated" or any other custom renderer component.'
@@ -34,9 +24,6 @@ const defaultGetSubRows = (row, index) => row.subRows || []
const defaultGetRowID = (row, index) => index
export const useTable = (props, ...plugins) => {
// Validate props
PropTypes.checkPropTypes(propTypes, props, 'property', 'useTable')
// Destructure props
let {
data,
@@ -122,7 +109,7 @@ export const useTable = (props, ...plugins) => {
[defaultColumn, userColumns]
)
// Get the flat list of all columns andllow hooks to decorate
// Get the flat list of all columns and allow hooks to decorate
// those columns (and trigger this memoization via deps)
let flatColumns = React.useMemo(() => {
if (process.env.NODE_ENV === 'development' && debug)
@@ -447,9 +434,10 @@ function calculateHeaderWidths(headers, left = 0) {
header.maxWidth
)
}
left += header.totalWidth
sumTotalWidth += header.totalWidth
if (header.isVisible) {
left += header.totalWidth
sumTotalWidth += header.totalWidth
}
})
return sumTotalWidth
@@ -74,7 +74,6 @@ exports[`renders a table 1`] = `
</div>
</div>
<div
class=""
style="position: relative; width: 1400px;"
>
<div
@@ -73,9 +73,7 @@ exports[`renders a table 1`] = `
</div>
</div>
</div>
<div
class=""
>
<div>
<div
class="row"
style="display: flex; width: 1400px;"
File diff suppressed because it is too large Load Diff
@@ -5,7 +5,7 @@ Snapshot Diff:
- First value
+ Second value
@@ -37,11 +37,11 @@
@@ -27,11 +27,11 @@
colspan="1"
>
Last Name
@@ -16,87 +16,59 @@ Snapshot Diff:
/>
</th>
<th
class=""
colspan="1"
@@ -117,78 +117,10 @@
</td>
<td
class=""
>
@@ -87,50 +87,10 @@
<td>
status: In Relationship
</td>
<td>
progress: 50
- </td>
- </tr>
- <tr
- class=""
- >
- <td
- class=""
- >
- <tr>
- <td>
- firstName: derek
- </td>
- <td
- class=""
- >
- <td>
- lastName: perkins
- </td>
- <td
- class=""
- >
- <td>
- age: 40
- </td>
- <td
- class=""
- >
- <td>
- visits: 40
- </td>
- <td
- class=""
- >
- <td>
- status: Single
- </td>
- <td
- class=""
- >
- <td>
- progress: 80
- </td>
- </tr>
- <tr
- class=""
- >
- <td
- class=""
- >
- <tr>
- <td>
- firstName: joe
- </td>
- <td
- class=""
- >
- <td>
- lastName: bergevin
- </td>
- <td
- class=""
- >
- <td>
- age: 45
- </td>
- <td
- class=""
- >
- <td>
- visits: 20
- </td>
- <td
- class=""
- >
- <td>
- status: Complicated
- </td>
- <td
- class=""
- >
- <td>
- progress: 10
</td>
</tr>
<tr
class=""
>
<tr>
<td>
firstName: jaylen
`;
exports[`renders a filterable table 2`] = `
@@ -104,7 +76,7 @@ Snapshot Diff:
- First value
+ Second value
@@ -37,11 +37,11 @@
@@ -27,11 +27,11 @@
colspan="1"
>
Last Name
@@ -115,84 +87,60 @@ Snapshot Diff:
/>
</th>
<th
class=""
colspan="1"
@@ -91,70 +91,70 @@
class=""
>
<td
class=""
>
@@ -71,46 +71,46 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- firstName: tanner
+ firstName: derek
</td>
<td
class=""
>
<td>
- lastName: linsley
+ lastName: perkins
</td>
<td
class=""
>
<td>
- age: 29
+ age: 40
</td>
<td
class=""
>
<td>
- visits: 100
+ visits: 40
</td>
<td
class=""
>
<td>
- status: In Relationship
+ status: Single
</td>
<td
class=""
>
<td>
- progress: 50
+ progress: 80
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
- firstName: jaylen
+ firstName: joe
</td>
<td
class=""
>
<td>
- lastName: linsley
+ lastName: bergevin
</td>
<td
class=""
>
<td>
- age: 26
+ age: 45
</td>
<td
class=""
>
<td>
- visits: 99
+ visits: 20
</td>
<td
class=""
>
<td>
- status: In Relationship
+ status: Complicated
</td>
<td
class=""
>
<td>
- progress: 70
+ progress: 10
</td>
@@ -5,9 +5,9 @@ Snapshot Diff:
- First value
+ Second value
@@ -29,13 +29,13 @@
@@ -19,24 +19,24 @@
>
<span
class=""
style="cursor: pointer;"
title="Toggle GroupBy"
>
@@ -18,10 +18,9 @@ Snapshot Diff:
+ Last Name
</th>
<th
class=""
colspan="1"
>
@@ -44,11 +44,11 @@
<span
style="cursor: pointer;"
title="Toggle GroupBy"
>
@@ -31,93 +30,66 @@ Snapshot Diff:
+ First Name
</th>
<th
class=""
colspan="1"
>
@@ -109,138 +109,119 @@
class=""
>
<td
class=""
>
<span
@@ -83,86 +83,81 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- firstName: tanner
- </td>
- <td
- class=""
+ <span
+ style="cursor: pointer;"
>
- lastName: linsley
- </td>
- <td
- class=""
- >
- age: 29
- </td>
- <td
- class=""
- >
- visits: 100
- </td>
- <td
- class=""
- >
- status: In Relationship
+ >
+ 👉
+ </span>
+ lastName: linsley (2)
</td>
<td
class=""
>
<td>
- lastName: linsley
+ 2 Names
</td>
<td>
- age: 29
+ 27.5 (avg)
</td>
<td>
- visits: 100
- </td>
- <td>
- status: In Relationship
- </td>
- <td>
- progress: 50
- </td>
- </tr>
- <tr
- class=""
- >
- <td
- class=""
- >
- <tr>
- <td>
- firstName: derek
- </td>
- <td
- class=""
- >
- lastName: perkins
+ 2 Names
</td>
<td
class=""
>
- age: 40
+ 27.5 (avg)
</td>
<td
class=""
>
- visits: 40
+ 199 (total)
</td>
<td
class=""
>
<td>
- lastName: perkins
- </td>
- <td>
- age: 40
- </td>
- <td>
- visits: 40
- </td>
- <td>
- status: Single
+ status: null
</td>
<td
class=""
>
<td>
- progress: 80
+ 60 (med)
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
- firstName: joe
+ <span
+ style="cursor: pointer;"
@@ -126,43 +98,29 @@ Snapshot Diff:
+ </span>
+ lastName: perkins (1)
</td>
<td
class=""
>
<td>
- lastName: bergevin
+ 1 Names
</td>
<td
class=""
>
<td>
- age: 45
+ 40 (avg)
</td>
<td
class=""
>
<td>
- visits: 20
+ 40 (total)
</td>
<td
class=""
>
<td>
- status: Complicated
+ status: null
</td>
<td
class=""
>
<td>
- progress: 10
+ 80 (med)
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
- firstName: jaylen
+ <span
+ style="cursor: pointer;"
@@ -171,33 +129,23 @@ Snapshot Diff:
+ </span>
+ lastName: bergevin (1)
</td>
<td
class=""
>
<td>
- lastName: linsley
+ 1 Names
</td>
<td
class=""
>
<td>
- age: 26
+ 45 (avg)
</td>
<td
class=""
>
<td>
- visits: 99
+ 20 (total)
</td>
<td
class=""
>
<td>
- status: In Relationship
+ status: null
</td>
<td
class=""
>
<td>
- progress: 70
+ 10 (med)
</td>
@@ -212,41 +160,38 @@ Snapshot Diff:
- First value
+ Second value
@@ -6,17 +6,29 @@
<tr
class=""
>
@@ -1,16 +1,26 @@
<DocumentFragment>
<table>
<thead>
<tr>
<th
class=""
- colspan="2"
+ colspan="1"
>
Name
</th>
<th
class=""
- colspan="4"
+ colspan="1"
+ >
+ Info
+ </th>
+ <th
+ class=""
+ colspan="1"
+ >
+ Name
+ </th>
+ <th
+ class=""
+ colspan="1"
+ >
+ Info
+ </th>
+ <th
+ colspan="1"
>
Name
</th>
<th
- colspan="4"
+ colspan="3"
>
Info
</th>
</tr>
<tr
@@ -42,13 +54,13 @@
<tr>
@@ -30,35 +40,35 @@
>
<span
class=""
style="cursor: pointer;"
title="Toggle GroupBy"
>
@@ -257,10 +202,9 @@ Snapshot Diff:
+ Visits
</th>
<th
class=""
colspan="1"
>
@@ -57,11 +69,11 @@
<span
style="cursor: pointer;"
title="Toggle GroupBy"
>
@@ -270,10 +214,9 @@ Snapshot Diff:
+ First Name
</th>
<th
class=""
colspan="1"
>
@@ -70,11 +82,11 @@
<span
style="cursor: pointer;"
title="Toggle GroupBy"
>
@@ -283,89 +226,69 @@ Snapshot Diff:
+ Age
</th>
<th
class=""
colspan="1"
>
@@ -116,10 +128,13 @@
<span
@@ -90,18 +100,16 @@
>
👉
</span>
lastName: linsley (2)
</td>
+ <td
+ class=""
+ />
<td
class=""
>
+ <td />
<td>
2 Names
</td>
@@ -129,15 +144,10 @@
<td>
27.5 (avg)
</td>
<td
class=""
>
- 199 (total)
- </td>
- <td
- class=""
- >
- <td>
- 199 (total)
</td>
<td>
status: null
</td>
<td
class=""
>
@@ -157,22 +167,20 @@
<td>
@@ -115,20 +123,18 @@
>
👉
</span>
lastName: perkins (1)
</td>
<td
class=""
- >
- 1 Names
- </td>
+ />
<td
class=""
>
- 40 (avg)
+ 1 Names
+ <td />
<td>
1 Names
</td>
<td
class=""
>
<td>
40 (avg)
</td>
<td>
- 40 (total)
+ 40 (avg)
</td>
<td
class=""
>
- </td>
- <td>
status: null
@@ -196,22 +204,20 @@
</td>
<td>
80 (med)
</td>
@@ -140,18 +146,16 @@
>
👉
</span>
lastName: bergevin (1)
</td>
<td
class=""
- >
- 1 Names
+ <td />
<td>
1 Names
</td>
<td>
45 (avg)
- </td>
+ />
<td
class=""
>
- 45 (avg)
+ 1 Names
</td>
<td
class=""
>
- <td>
- 20 (total)
+ 45 (avg)
</td>
<td
class=""
>
<td>
status: null
</td>
<td>
`;
@@ -5,137 +5,137 @@ Snapshot Diff:
- First value
+ Second value
@@ -67,11 +67,11 @@
class=""
>
<td
class=""
>
@@ -47,11 +47,11 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- tanner 21
+ tanner 31
</td>
<td
class=""
>
<td>
linsley
@@ -101,11 +101,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -67,11 +67,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 22
+ tanner 32
</td>
<td
class=""
>
<td>
linsley
@@ -135,11 +135,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -87,11 +87,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 23
+ tanner 33
</td>
<td
class=""
>
<td>
linsley
@@ -169,11 +169,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -107,11 +107,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 24
+ tanner 34
</td>
<td
class=""
>
<td>
linsley
@@ -203,11 +203,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -127,11 +127,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 25
+ tanner 35
</td>
<td
class=""
>
<td>
linsley
@@ -237,11 +237,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -147,11 +147,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 26
+ tanner 36
</td>
<td
class=""
>
<td>
linsley
@@ -271,11 +271,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -167,11 +167,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 27
+ tanner 37
</td>
<td
class=""
>
<td>
linsley
@@ -305,11 +305,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -187,11 +187,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 28
+ tanner 38
</td>
<td
class=""
>
<td>
linsley
@@ -339,11 +339,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -207,11 +207,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 29
+ tanner 39
</td>
<td
class=""
>
<td>
linsley
@@ -373,11 +373,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -227,11 +227,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 30
+ tanner 40
</td>
<td
class=""
>
<td>
linsley
@@ -425,20 +425,20 @@
</td>
<td>
@@ -269,20 +269,20 @@
</button>
<span>
@@ -165,137 +165,137 @@ Snapshot Diff:
- First value
+ Second value
@@ -67,11 +67,11 @@
class=""
>
<td
class=""
>
@@ -47,11 +47,11 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- tanner 31
+ tanner 41
</td>
<td
class=""
>
<td>
linsley
@@ -101,11 +101,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -67,11 +67,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 32
+ tanner 42
</td>
<td
class=""
>
<td>
linsley
@@ -135,11 +135,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -87,11 +87,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 33
+ tanner 43
</td>
<td
class=""
>
<td>
linsley
@@ -169,11 +169,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -107,11 +107,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 34
+ tanner 44
</td>
<td
class=""
>
<td>
linsley
@@ -203,11 +203,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -127,11 +127,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 35
+ tanner 45
</td>
<td
class=""
>
<td>
linsley
@@ -237,11 +237,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -147,11 +147,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 36
+ tanner 46
</td>
<td
class=""
>
<td>
linsley
@@ -271,11 +271,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -167,11 +167,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 37
+ tanner 47
</td>
<td
class=""
>
<td>
linsley
@@ -305,11 +305,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -187,11 +187,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 38
+ tanner 48
</td>
<td
class=""
>
<td>
linsley
@@ -339,11 +339,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -207,11 +207,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 39
+ tanner 49
</td>
<td
class=""
>
<td>
linsley
@@ -373,11 +373,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -227,11 +227,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 40
+ tanner 50
</td>
<td
class=""
>
<td>
linsley
@@ -425,20 +425,20 @@
</td>
<td>
@@ -269,20 +269,20 @@
</button>
<span>
@@ -325,137 +325,137 @@ Snapshot Diff:
- First value
+ Second value
@@ -67,11 +67,11 @@
class=""
>
<td
class=""
>
@@ -47,11 +47,11 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- tanner 41
+ tanner 91
</td>
<td
class=""
>
<td>
linsley
@@ -101,11 +101,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -67,11 +67,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 42
+ tanner 92
</td>
<td
class=""
>
<td>
linsley
@@ -135,11 +135,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -87,11 +87,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 43
+ tanner 93
</td>
<td
class=""
>
<td>
linsley
@@ -169,11 +169,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -107,11 +107,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 44
+ tanner 94
</td>
<td
class=""
>
<td>
linsley
@@ -203,11 +203,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -127,11 +127,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 45
+ tanner 95
</td>
<td
class=""
>
<td>
linsley
@@ -237,11 +237,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -147,11 +147,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 46
+ tanner 96
</td>
<td
class=""
>
<td>
linsley
@@ -271,11 +271,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -167,11 +167,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 47
+ tanner 97
</td>
<td
class=""
>
<td>
linsley
@@ -305,11 +305,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -187,11 +187,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 48
+ tanner 98
</td>
<td
class=""
>
<td>
linsley
@@ -339,11 +339,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -207,11 +207,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 49
+ tanner 99
</td>
<td
class=""
>
<td>
linsley
@@ -373,11 +373,11 @@
class=""
>
<td
class=""
>
</td>
<td>
@@ -227,11 +227,11 @@
50
</td>
</tr>
<tr>
<td>
- tanner 50
+ tanner 100
</td>
<td
class=""
>
<td>
linsley
@@ -414,31 +414,35 @@
</td>
<td>
@@ -258,31 +258,35 @@
<button>
&lt;
File diff suppressed because it is too large Load Diff
@@ -5,7 +5,7 @@ Snapshot Diff:
- First value
+ Second value
@@ -31,11 +31,13 @@
@@ -22,11 +22,13 @@
colspan="1"
style="cursor: pointer;"
title="Toggle SortBy"
@@ -17,125 +17,87 @@ Snapshot Diff:
+ </span>
</th>
<th
class=""
colspan="1"
style="cursor: pointer;"
@@ -89,104 +91,104 @@
class=""
>
<td
class=""
>
title="Toggle SortBy"
@@ -69,66 +71,66 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- firstName: tanner
+ firstName: derek
</td>
<td
class=""
>
<td>
- lastName: linsley
+ lastName: perkins
</td>
<td
class=""
>
<td>
- age: 29
+ age: 40
</td>
<td
class=""
>
<td>
- visits: 100
+ visits: 40
</td>
<td
class=""
>
<td>
- status: In Relationship
+ status: Single
</td>
<td
class=""
>
<td>
- progress: 50
+ progress: 80
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
- firstName: derek
+ firstName: joe
</td>
<td
class=""
>
<td>
- lastName: perkins
+ lastName: bergevin
</td>
<td
class=""
>
<td>
- age: 40
+ age: 45
</td>
<td
class=""
>
<td>
- visits: 40
+ visits: 20
</td>
<td
class=""
>
<td>
- status: Single
+ status: Complicated
</td>
<td
class=""
>
<td>
- progress: 80
+ progress: 10
</td>
</tr>
<tr
class=""
>
<td
class=""
>
<tr>
<td>
- firstName: joe
+ firstName: tanner
</td>
<td
class=""
>
<td>
- lastName: bergevin
+ lastName: linsley
</td>
<td
class=""
>
<td>
- age: 45
+ age: 29
</td>
<td
class=""
>
<td>
- visits: 20
+ visits: 100
</td>
<td
class=""
>
<td>
- status: Complicated
+ status: In Relationship
</td>
<td
class=""
>
<td>
- progress: 10
+ progress: 50
</td>
@@ -150,7 +112,7 @@ Snapshot Diff:
- First value
+ Second value
@@ -32,11 +32,11 @@
@@ -23,11 +23,11 @@
style="cursor: pointer;"
title="Toggle SortBy"
>
@@ -161,87 +123,67 @@ Snapshot Diff:
</span>
</th>
<th
class=""
colspan="1"
@@ -91,36 +91,36 @@
class=""
>
<td
class=""
>
style="cursor: pointer;"
@@ -71,26 +71,26 @@
</tr>
</thead>
<tbody>
<tr>
<td>
- firstName: derek
+ firstName: tanner
</td>
<td
class=""
>
<td>
- lastName: perkins
+ lastName: linsley
</td>
<td
class=""
>
<td>
- age: 40
+ age: 29
</td>
<td
class=""
>
<td>
- visits: 40
+ visits: 100
</td>
<td
class=""
>
<td>
- status: Single
+ status: In Relationship
</td>
<td
class=""
>
<td>
- progress: 80
+ progress: 50
</td>
</tr>
<tr
class=""
>
@@ -159,36 +159,36 @@
class=""
>
<td
class=""
>
<tr>
<td>
firstName: joe
@@ -111,26 +111,26 @@
progress: 10
</td>
</tr>
<tr>
<td>
- firstName: tanner
+ firstName: derek
</td>
<td
class=""
>
<td>
- lastName: linsley
+ lastName: perkins
</td>
<td
class=""
>
<td>
- age: 29
+ age: 40
</td>
<td
class=""
>
<td>
- visits: 100
+ visits: 40
</td>
<td
class=""
>
<td>
- status: In Relationship
+ status: Single
</td>
<td
class=""
>
<td>
- progress: 50
+ progress: 80
</td>
-6
View File
@@ -1,7 +1,3 @@
import PropTypes from 'prop-types'
const propTypes = {}
export const useAbsoluteLayout = hooks => {
hooks.useMain.push(useMain)
}
@@ -9,8 +5,6 @@ export const useAbsoluteLayout = hooks => {
useAbsoluteLayout.pluginName = 'useAbsoluteLayout'
const useMain = instance => {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useAbsoluteLayout')
const {
totalColumnsWidth,
hooks: {
-6
View File
@@ -1,7 +1,3 @@
import PropTypes from 'prop-types'
const propTypes = {}
export const useBlockLayout = hooks => {
hooks.useMain.push(useMain)
}
@@ -9,8 +5,6 @@ export const useBlockLayout = hooks => {
useBlockLayout.pluginName = 'useBlockLayout'
const useMain = instance => {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useBlockLayout')
const {
totalColumnsWidth,
hooks: { getRowProps, getHeaderGroupProps, getHeaderProps, getCellProps },
-7
View File
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { addActions, actions } from '../actions'
import { defaultState } from '../hooks/useTable'
@@ -8,10 +7,6 @@ defaultState.columnOrder = []
addActions('setColumnOrder')
const propTypes = {
initialRowStateAccessor: PropTypes.func,
}
export const useColumnOrder = hooks => {
hooks.columnsBeforeHeaderGroupsDeps.push((deps, instance) => {
return [...deps, instance.state.columnOrder]
@@ -54,8 +49,6 @@ function columnsBeforeHeaderGroups(columns, instance) {
}
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useColumnOrder')
const { setState } = instance
const setColumnOrder = React.useCallback(
-8
View File
@@ -1,5 +1,4 @@
import { useMemo } from 'react'
import PropTypes from 'prop-types'
import { mergeProps, applyPropHooks, expandRows } from '../utils'
import { addActions, actions } from '../actions'
@@ -9,11 +8,6 @@ defaultState.expanded = []
addActions('toggleExpanded', 'useExpanded')
const propTypes = {
manualExpandedKey: PropTypes.string,
paginateExpandedRows: PropTypes.bool,
}
export const useExpanded = hooks => {
hooks.getExpandedToggleProps = []
hooks.useMain.push(useMain)
@@ -22,8 +16,6 @@ export const useExpanded = hooks => {
useExpanded.pluginName = 'useExpanded'
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useExpanded')
const {
debug,
rows,
+8 -16
View File
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { getFirstDefined, isFunction } from '../utils'
import * as filterTypes from '../filterTypes'
@@ -10,17 +9,6 @@ defaultState.filters = {}
addActions('setFilter', 'setAllFilters')
const propTypes = {
columns: PropTypes.arrayOf(
PropTypes.shape({
disableFilters: PropTypes.bool,
Filter: PropTypes.any,
})
),
manualFilters: PropTypes.bool,
}
export const useFilters = hooks => {
hooks.useMain.push(useMain)
}
@@ -28,8 +16,6 @@ export const useFilters = hooks => {
useFilters.pluginName = 'useFilters'
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useFilters')
const {
debug,
rows,
@@ -37,6 +23,7 @@ function useMain(instance) {
flatColumns,
filterTypes: userFilterTypes,
manualFilters,
defaultCanFilter = false,
disableFilters,
state: { filters },
setState,
@@ -108,7 +95,12 @@ function useMain(instance) {
}
flatColumns.forEach(column => {
const { id, accessor, disableFilters: columnDisableFilters } = column
const {
id,
accessor,
defaultCanFilter: columnDefaultCanFilter,
disableFilters: columnDisableFilters,
} = column
// Determine if a column is filterable
column.canFilter = accessor
@@ -117,7 +109,7 @@ function useMain(instance) {
disableFilters === true ? false : undefined,
true
)
: false
: getFirstDefined(columnDefaultCanFilter, defaultCanFilter, false)
// Provide the column a way of updating the filter value
column.setFilter = val => setFilter(column.id, val)
+11 -29
View File
@@ -1,5 +1,4 @@
import { useMemo } from 'react'
import PropTypes from 'prop-types'
import * as aggregations from '../aggregations'
import { addActions, actions } from '../actions'
@@ -16,27 +15,6 @@ defaultState.groupBy = []
addActions('toggleGroupBy')
const propTypes = {
// General
columns: PropTypes.arrayOf(
PropTypes.shape({
aggregate: PropTypes.oneOfType([
PropTypes.func,
PropTypes.string,
PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.func, PropTypes.string])
),
]),
disableGrouping: PropTypes.bool,
Aggregated: PropTypes.any,
})
),
groupByFn: PropTypes.func,
manualGrouping: PropTypes.bool,
disableGrouping: PropTypes.bool,
aggregations: PropTypes.object,
}
export const useGroupBy = hooks => {
hooks.columnsBeforeHeaderGroups.push(columnsBeforeHeaderGroups)
hooks.columnsBeforeHeaderGroupsDeps.push((deps, instance) => {
@@ -67,8 +45,6 @@ function columnsBeforeHeaderGroups(flatColumns, { state: { groupBy } }) {
}
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useGroupBy')
const {
debug,
rows,
@@ -76,7 +52,8 @@ function useMain(instance) {
flatHeaders,
groupByFn = defaultGroupByFn,
manualGroupBy,
disableGrouping,
defaultCanGroupBy,
disableGroupBy,
aggregations: userAggregations = {},
hooks,
plugins,
@@ -87,17 +64,22 @@ function useMain(instance) {
ensurePluginOrder(plugins, [], 'useGroupBy', ['useSortBy', 'useExpanded'])
flatColumns.forEach(column => {
const { id, accessor, disableGrouping: columnDisableGrouping } = column
const {
id,
accessor,
defaultGroupBy: defaultColumnGroupBy,
disableGroupBy: columnDisableGroupBy,
} = column
column.isGrouped = groupBy.includes(id)
column.groupedIndex = groupBy.indexOf(id)
column.canGroupBy = accessor
? getFirstDefined(
columnDisableGrouping,
disableGrouping === true ? false : undefined,
columnDisableGroupBy === true ? false : undefined,
disableGroupBy === true ? false : undefined,
true
)
: false
: getFirstDefined(defaultColumnGroupBy, defaultCanGroupBy, false)
if (column.canGroupBy) {
column.toggleGroupBy = () => toggleGroupBy(column.id)
-9
View File
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
//
import { addActions, actions } from '../actions'
@@ -11,12 +10,6 @@ defaultState.pageIndex = 0
addActions('pageChange', 'pageSizeChange')
const propTypes = {
// General
manualPagination: PropTypes.bool,
paginateExpandedRows: PropTypes.bool,
}
export const usePagination = hooks => {
hooks.useMain.push(useMain)
}
@@ -24,8 +17,6 @@ export const usePagination = hooks => {
usePagination.pluginName = 'usePagination'
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'usePagination')
const {
data,
rows,
-6
View File
@@ -1,5 +1,3 @@
import PropTypes from 'prop-types'
//
import { defaultState } from '../hooks/useTable'
@@ -12,8 +10,6 @@ defaultState.columnResizing = {
defaultColumn.canResize = true
const propTypes = {}
export const useResizeColumns = hooks => {
hooks.useBeforeDimensions.push(useBeforeDimensions)
}
@@ -21,8 +17,6 @@ export const useResizeColumns = hooks => {
useResizeColumns.pluginName = 'useResizeColumns'
const useBeforeDimensions = instance => {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useResizeColumns')
instance.hooks.getResizerProps = []
const {
-9
View File
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import {
mergeProps,
@@ -14,10 +13,6 @@ defaultState.selectedRowPaths = []
addActions('toggleRowSelected', 'toggleRowSelectedAll')
const propTypes = {
manualRowSelectedKey: PropTypes.string,
}
export const useRowSelect = hooks => {
hooks.getToggleRowSelectedProps = []
hooks.getToggleAllRowsSelectedProps = []
@@ -28,8 +23,6 @@ export const useRowSelect = hooks => {
useRowSelect.pluginName = 'useRowSelect'
function useRows(rows, instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useRowSelect')
const {
state: { selectedRowPaths },
} = instance
@@ -57,8 +50,6 @@ function useRows(rows, instance) {
}
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useRowSelect')
const {
hooks,
manualRowSelectedKey = 'isSelected',
-7
View File
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { addActions, actions } from '../actions'
import { defaultState } from '../hooks/useTable'
@@ -8,10 +7,6 @@ defaultState.rowState = {}
addActions('setRowState', 'setCellState')
const propTypes = {
initialRowStateAccessor: PropTypes.func,
}
export const useRowState = hooks => {
hooks.useMain.push(useMain)
}
@@ -19,8 +14,6 @@ export const useRowState = hooks => {
useRowState.pluginName = 'useRowState'
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useRowState')
const {
hooks,
rows,
+11 -28
View File
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { ensurePluginOrder, defaultColumn } from '../utils'
import { addActions, actions } from '../actions'
@@ -19,26 +18,6 @@ defaultColumn.sortDescFirst = false
addActions('sortByChange')
const propTypes = {
// General
columns: PropTypes.arrayOf(
PropTypes.shape({
sortType: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
sortDescFirst: PropTypes.bool,
disableSorting: PropTypes.bool,
})
),
orderByFn: PropTypes.func,
sortTypes: PropTypes.object,
manualSorting: PropTypes.bool,
disableSorting: PropTypes.bool,
disableMultiSort: PropTypes.bool,
isMultiSortEvent: PropTypes.func,
maxMultiSortColCount: PropTypes.number,
disableSortRemove: PropTypes.bool,
disableMultiRemove: PropTypes.bool,
}
export const useSortBy = hooks => {
hooks.useMain.push(useMain)
}
@@ -46,8 +25,6 @@ export const useSortBy = hooks => {
useSortBy.pluginName = 'useSortBy'
function useMain(instance) {
PropTypes.checkPropTypes(propTypes, instance, 'property', 'useSortBy')
const {
debug,
rows,
@@ -55,7 +32,8 @@ function useMain(instance) {
orderByFn = defaultOrderByFn,
sortTypes: userSortTypes,
manualSorting,
disableSorting,
defaultCanSort,
disableSortBy,
disableSortRemove,
disableMultiRemove,
disableMultiSort,
@@ -162,15 +140,20 @@ function useMain(instance) {
// Add the getSortByToggleProps method to columns and headers
flatHeaders.forEach(column => {
const { accessor, disableSorting: columnDisableSorting, id } = column
const {
accessor,
canSort: defaultColumnCanSort,
disableSortBy: columnDisableSortBy,
id,
} = column
const canSort = accessor
? getFirstDefined(
columnDisableSorting === true ? false : undefined,
disableSorting === true ? false : undefined,
columnDisableSortBy === true ? false : undefined,
disableSortBy === true ? false : undefined,
true
)
: false
: getFirstDefined(defaultCanSort, defaultColumnCanSort, false)
column.canSort = canSort
+10 -1
View File
@@ -288,7 +288,10 @@ export function flexRender(Comp, props) {
function isClassComponent(component) {
return (
typeof component === 'function' &&
!!Object.getPrototypeOf(component).isReactComponent
!!(() => {
let proto = Object.getPrototypeOf(component)
return proto.prototype && proto.prototype.isReactComponent
})()
)
}
@@ -302,6 +305,7 @@ function isReactComponent(component) {
export const mergeProps = (...groups) => {
let props = {}
groups.forEach(({ style = {}, className, ...rest } = {}) => {
props = {
...props,
@@ -313,6 +317,11 @@ export const mergeProps = (...groups) => {
className: [props.className, className].filter(Boolean).join(' '),
}
})
if (props.className === '') {
delete props.className
}
return props
}
+10
View File
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"strict": true,
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts"]
}
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"no-empty-interface": false,
"no-unnecessary-generics": false,
"semicolon": false,
"whitespace": false
}
}
+151 -12
View File
@@ -1282,6 +1282,11 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==
"@types/parsimmon@^1.3.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@types/parsimmon/-/parsimmon-1.10.0.tgz#ffb81cb023ff435a41d4710a29ab23c561dc9fdf"
integrity sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==
"@types/prop-types@*":
version "15.7.1"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6"
@@ -1939,6 +1944,11 @@ buffer-from@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=
builtin-modules@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484"
@@ -2045,7 +2055,7 @@ chalk@2.3.1:
escape-string-regexp "^1.0.5"
supports-color "^5.2.0"
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2:
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
@@ -2191,11 +2201,21 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"
command-exists@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.8.tgz#715acefdd1223b9c9b37110a149c6392c2852291"
integrity sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw==
commander@^2.11.0, commander@^2.20.0, commander@~2.20.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
commander@^2.12.1:
version "2.20.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.1.tgz#3863ce3ca92d0831dcf2a102f5fb4b5926afd0f9"
integrity sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==
commitizen@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/commitizen/-/commitizen-4.0.3.tgz#c19a4213257d0525b85139e2f36db7cc3b4f6dae"
@@ -2374,6 +2394,15 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"
cross-spawn@^7.0.0:
version "7.0.1"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.1.tgz#0ab56286e0f7c24e153d04cc2aa027e43a9a5d14"
integrity sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
which "^2.0.1"
css-select-base-adapter@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz#3b2ff4972cc362ab88561507a95408a1432135d7"
@@ -2586,6 +2615,22 @@ define-property@^2.0.2:
is-descriptor "^1.0.2"
isobject "^3.0.1"
definitelytyped-header-parser@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz#f21374b8a18fabcd3ba4b008a0bcbc9db2b7b4c4"
integrity sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog==
dependencies:
"@types/parsimmon" "^1.3.0"
parsimmon "^1.2.0"
definitelytyped-header-parser@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/definitelytyped-header-parser/-/definitelytyped-header-parser-3.7.2.tgz#a5b2ec9521762910e870477b01ce9feca06d9fb7"
integrity sha512-nlkiv+QLlRSc3C3qAbusWPaBiyPLldwRFnrxvoxjdZHvHbIh2+U09qdmzzWV35Rs/I3MMhcoWRcVUi3M1G935Q==
dependencies:
"@types/parsimmon" "^1.3.0"
parsimmon "^1.2.0"
del@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/del/-/del-5.0.0.tgz#4fa698b7a1ffb4e2ab3e8929ed699799654d6720"
@@ -2708,6 +2753,35 @@ dot-prop@^3.0.0:
dependencies:
is-obj "^1.0.0"
download-file-sync@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/download-file-sync/-/download-file-sync-1.0.4.tgz#d3e3c543f836f41039455b9034c72e355b036019"
integrity sha1-0+PFQ/g29BA5RVuQNMcuNVsDYBk=
dts-critic@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/dts-critic/-/dts-critic-2.1.0.tgz#d7a6fcdcec301f639b7700fd9a2c9db4ab7071f4"
integrity sha512-vXfmzBfaC4sBML2Er1YfFbcknyxp9t16x1NF0nTYj20gDR1dCF8aOpu/c+CgySxFyqEyLq6t0FkmWwpZEX6VLQ==
dependencies:
command-exists "^1.2.8"
definitelytyped-header-parser "^1.2.0"
download-file-sync "^1.0.4"
semver "^6.2.0"
yargs "^12.0.5"
dtslint@^0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/dtslint/-/dtslint-0.9.8.tgz#c1fdc12c73f57f10528f0b4dda04be5c82919129"
integrity sha512-cxxGo0mQO9mFQcUShtPbmmoZ+PrUczEV6R/PaN06dnv2IbgtIgLyrO8NBeU7VeHMxpe6exESy48oom97LWUIkA==
dependencies:
definitelytyped-header-parser "^3.7.2"
dts-critic "^2.1.0"
fs-extra "^6.0.1"
request "^2.88.0"
strip-json-comments "^2.0.1"
tslint "5.14.0"
typescript next
ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"
@@ -3512,6 +3586,15 @@ fs-extra@8.1.0:
jsonfile "^4.0.0"
universalify "^0.1.0"
fs-extra@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b"
integrity sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"
fs-minipass@^1.2.5:
version "1.2.6"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.6.tgz#2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07"
@@ -4016,12 +4099,13 @@ is-callable@^1.1.4:
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"
integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==
is-ci-cli@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/is-ci-cli/-/is-ci-cli-1.1.1.tgz#2dc924d192fe8d76074dcb96a2122a7d00d0ee83"
integrity sha512-c8xV1IkPvcdB9fAKo3QZ4SmdzsgPHOZ8Xz88T9CCSMrksKMn41R4jUxUP1UbFNPYiYoz8XvHt3RZ3ODKIPyLYQ==
is-ci-cli@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-ci-cli/-/is-ci-cli-2.0.0.tgz#606dd5051c636ac80e1deb4c1c30aa5294220159"
integrity sha512-pgdXwbBaRfyG3XJ/+AYbgCb5WE10TZwj4pvoSYI1YrmGDslcS0lhvqvAKmZrSq2248/jGoZ2g9yC63APlBy1uQ==
dependencies:
is-ci "^1.0.10"
cross-spawn "^7.0.0"
is-ci "^2.0.0"
is-ci@^1.0.10:
version "1.2.1"
@@ -4951,7 +5035,7 @@ js-tokens@^3.0.2:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=
js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.9.1:
js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.7.0, js-yaml@^3.9.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
@@ -6134,6 +6218,11 @@ parse5@4.0.0:
resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608"
integrity sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==
parsimmon@^1.2.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/parsimmon/-/parsimmon-1.13.0.tgz#6e4ef3dbd45ed6ea6808be600ac4b9c8a44228cf"
integrity sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A==
pascalcase@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
@@ -6171,7 +6260,7 @@ path-key@^2.0.0, path-key@^2.0.1:
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
path-key@^3.0.0:
path-key@^3.0.0, path-key@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.0.tgz#99a10d870a803bdd5ee6f0470e58dfcd2f9a54d3"
integrity sha512-8cChqz0RP6SHJkMt48FW0A7+qUOn+OsnOsVtzI59tZ8m+5bCSk7hzwET0pulwOM2YMn9J1efb07KB9l9f30SGg==
@@ -6707,7 +6796,7 @@ request-promise-native@^1.0.5:
stealthy-require "^1.1.1"
tough-cookie "^2.3.3"
request@^2.87.0:
request@^2.87.0, request@^2.88.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==
@@ -7010,7 +7099,7 @@ semver@6.1.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b"
integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==
semver@^6.0.0, semver@^6.1.1:
semver@^6.0.0, semver@^6.1.1, semver@^6.2.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
@@ -7052,11 +7141,23 @@ shebang-command@^1.2.0:
dependencies:
shebang-regex "^1.0.0"
shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
dependencies:
shebang-regex "^3.0.0"
shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
shebang-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
shelljs@0.7.6:
version "0.7.6"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.6.tgz#379cccfb56b91c8601e4793356eb5382924de9ad"
@@ -7662,11 +7763,37 @@ trim-right@^1.0.1:
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=
tslib@^1.9.0:
tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
tslint@5.14.0:
version "5.14.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.14.0.tgz#be62637135ac244fc9b37ed6ea5252c9eba1616e"
integrity sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ==
dependencies:
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
chalk "^2.3.0"
commander "^2.12.1"
diff "^3.2.0"
glob "^7.1.1"
js-yaml "^3.7.0"
minimatch "^3.0.4"
mkdirp "^0.5.1"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.8.0"
tsutils "^2.29.0"
tsutils@^2.29.0:
version "2.29.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==
dependencies:
tslib "^1.8.1"
tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
@@ -7696,6 +7823,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typescript@next:
version "3.7.0-dev.20191009"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.0-dev.20191009.tgz#852e49dca797bb35acf930583ef65e7b3b23fc01"
integrity sha512-Vk/wZedTpVd3QAhr3mG1+sbUHcpJ1wfw49Wo1NCQvzMa0vHCJeocEwWzaV2yWprsuuFv4+e8tjCj1Vnme2CMHg==
uglify-js@^3.1.4:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
@@ -7873,6 +8005,13 @@ which@^1.2.14, which@^1.2.9, which@^1.3.0:
dependencies:
isexe "^2.0.0"
which@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.1.tgz#f1cf94d07a8e571b6ff006aeb91d0300c47ef0a4"
integrity sha512-N7GBZOTswtB9lkQBZA4+zAXrjEIWAUOB93AvzUiudRzRxhUdLURQ7D/gAIMY1gatT/LTbmbcv8SiYazy3eYB7w==
dependencies:
isexe "^2.0.0"
wide-align@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457"
@@ -7986,7 +8125,7 @@ yargs-parser@^11.1.1:
camelcase "^5.0.0"
decamelize "^1.2.0"
yargs@^12.0.2:
yargs@^12.0.2, yargs@^12.0.5:
version "12.0.5"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==